fix:类型转换
parent
faec7b3922
commit
1212ffad82
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,49 @@
|
||||||
|
package com.muyu.data.mart.controller;
|
||||||
|
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.data.mart.common.BasicApi;
|
||||||
|
import com.muyu.data.mart.domain.realname.RealNameReq;
|
||||||
|
import com.muyu.data.mart.domain.realname.RealNameResp;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:chaiyapeng
|
||||||
|
* @Package:com.muyu.data.mart.controller
|
||||||
|
* @Project:cloud-port
|
||||||
|
* @name:ApiUserController
|
||||||
|
* @Date:2024/9/9 17:14
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api")
|
||||||
|
@Log4j2
|
||||||
|
@Tag(name = "接口调用",description = "进行不同接口调用")
|
||||||
|
public class ApiUserController {
|
||||||
|
|
||||||
|
@Resource(name = "api-real-name")
|
||||||
|
private BasicApi<RealNameReq, RealNameResp> realNameService;
|
||||||
|
|
||||||
|
|
||||||
|
public ApiUserController(BasicApi<RealNameReq, RealNameResp> realNameService){
|
||||||
|
this.realNameService = realNameService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/realname")
|
||||||
|
@Operation(summary = "实名认证",description = "实名认证")
|
||||||
|
public Result RealName(@RequestBody RealNameReq realNameReq) {
|
||||||
|
RealNameResp realNameResp = null;
|
||||||
|
try {
|
||||||
|
realNameResp = realNameService.send(realNameReq);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return Result.success(realNameResp);
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,4 +17,18 @@
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.sf.json-lib</groupId>
|
||||||
|
<artifactId>json-lib</artifactId>
|
||||||
|
<version>2.2.3</version>
|
||||||
|
<classifier>jdk15</classifier>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.15</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.muyu.data.mart.service.controller;
|
||||||
|
|
||||||
|
import com.muyu.data.mart.common.BasicApi;
|
||||||
|
import com.muyu.data.mart.domain.realname.RealNameReq;
|
||||||
|
import com.muyu.data.mart.domain.realname.RealNameResp;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:chaiyapeng
|
||||||
|
* @Package:com.muyu.data.mart.service.controller
|
||||||
|
* @Project:cloud-port
|
||||||
|
* @name:RealNameController
|
||||||
|
* @Date:2024/9/9 16:29
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/juhe")
|
||||||
|
public class RealNameController {
|
||||||
|
@Resource(name = "juhe-real-name")
|
||||||
|
private BasicApi<RealNameReq, RealNameResp> respBasicApi;
|
||||||
|
|
||||||
|
@PostMapping("/real/name")
|
||||||
|
public RealNameResp realName(@RequestBody RealNameReq realNameReq) {
|
||||||
|
RealNameResp realNameResp = null;
|
||||||
|
try {
|
||||||
|
realNameResp = respBasicApi.send(realNameReq);
|
||||||
|
return realNameResp;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,6 +8,17 @@ import com.muyu.data.mart.domain.realname.juhe.JuHeRealNameReq;
|
||||||
import com.muyu.data.mart.domain.realname.juhe.JuHeRealNameResp;
|
import com.muyu.data.mart.domain.realname.juhe.JuHeRealNameResp;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:chaiyapeng
|
* @Author:chaiyapeng
|
||||||
|
@ -28,26 +39,94 @@ public class RealNameServiceImpl implements BasicApi<RealNameReq, RealNameResp>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public RealNameResp send(RealNameReq realNameReq) {
|
public RealNameResp send(RealNameReq realNameReq) {
|
||||||
|
|
||||||
JuHeRealNameReq juHeRealNameReq = JuHeRealNameReq.realNameReqBuilder(realNameReq);
|
JuHeRealNameReq juHeRealNameReq = JuHeRealNameReq.realNameReqBuilder(realNameReq);
|
||||||
JuHeResult<JuHeRealNameResp> juHeRealNameRespJuHeResult = sendApi(juHeRealNameReq);
|
JuHeResult<JuHeRealNameResp> juHeRealNameRespJuHeResult = null;
|
||||||
|
|
||||||
|
try {
|
||||||
return RealNameResp.builder().build();
|
juHeRealNameRespJuHeResult = sendApi(juHeRealNameReq);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return RealNameResp.builder()
|
||||||
|
.code(String.valueOf(juHeRealNameRespJuHeResult.getErrorCode()))
|
||||||
|
.mag(juHeRealNameRespJuHeResult.getReason())
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String API_URL = "http://op.juhe.cn/idcard/query";
|
||||||
|
// 接口请求Key
|
||||||
|
public static String API_KEY = "3a2afc3ff97304c4f6b16325a99c34b0";
|
||||||
public JuHeResult<JuHeRealNameResp> sendApi(JuHeRealNameReq juHeRealNameReq){
|
public JuHeResult<JuHeRealNameResp> sendApi(JuHeRealNameReq juHeRealNameReq){
|
||||||
|
HashMap<String, String> map = new HashMap<>();
|
||||||
|
map.put("key", API_KEY);
|
||||||
|
map.put("idcard", juHeRealNameReq.getIdCard());
|
||||||
|
map.put("realname", juHeRealNameReq.getRealName());
|
||||||
|
map.put("orderid", "");
|
||||||
|
|
||||||
|
String queryString = params(map);
|
||||||
|
URL url = null;
|
||||||
|
try {
|
||||||
|
url = new URL(API_URL + "?" + queryString);
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
connection.setRequestMethod("GET");
|
||||||
|
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
|
String inputLine;
|
||||||
|
StringBuffer response = new StringBuffer();
|
||||||
|
while ((inputLine = in.readLine()) != null) {
|
||||||
|
response.append(inputLine);
|
||||||
|
}
|
||||||
|
in.close();
|
||||||
|
System.out.println(response);
|
||||||
|
StringBuffer stringBuffer = new StringBuffer(response);
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(stringBuffer.toString());
|
||||||
|
String reason = jsonObject.getString("reason");
|
||||||
|
JSONObject resultObj = jsonObject.getJSONObject("result");
|
||||||
|
String realname = resultObj.getString("realname");
|
||||||
|
String idcard = resultObj.getString("idcard");
|
||||||
|
int res = resultObj.getIntValue("res");
|
||||||
|
int errorCode = jsonObject.getIntValue("error_code");
|
||||||
return new JuHeResult<JuHeRealNameResp>(){{
|
return new JuHeResult<JuHeRealNameResp>(){{
|
||||||
setErrorCode(0);
|
setErrorCode(errorCode);
|
||||||
setReason("成功");
|
setReason(reason);
|
||||||
setResult(
|
setResult(
|
||||||
JuHeRealNameResp.builder()
|
JuHeRealNameResp.builder()
|
||||||
.realName(juHeRealNameReq.getRealName())
|
.realName(realname)
|
||||||
.idCard(juHeRealNameReq.getIdCard())
|
.idCard(idcard)
|
||||||
.res(0)
|
.res(res)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
}};
|
}};
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// return new JuHeResult<JuHeRealNameResp>(){{
|
||||||
|
// setErrorCode(0);
|
||||||
|
// setReason("成功");
|
||||||
|
// setResult(
|
||||||
|
// JuHeRealNameResp.builder()
|
||||||
|
// .realName(juHeRealNameReq.getRealName())
|
||||||
|
// .idCard(juHeRealNameReq.getIdCard())
|
||||||
|
// .res(0)
|
||||||
|
// .build()
|
||||||
|
// );
|
||||||
|
// }};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static String params(Map<String, String> map) {
|
||||||
|
return map.entrySet().stream()
|
||||||
|
.map(entry -> {
|
||||||
|
try {
|
||||||
|
return entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.toString());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return entry.getKey() + "=" + entry.getValue();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.collect(Collectors.joining("&"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,73 @@
|
||||||
|
# Tomcat
|
||||||
server:
|
server:
|
||||||
port: 98
|
port: 9777
|
||||||
|
|
||||||
|
# nacos线上地址
|
||||||
|
nacos:
|
||||||
|
addr: 47.116.184.54:8848
|
||||||
|
user-name: nacos
|
||||||
|
password: nacos
|
||||||
|
namespace: cloud-2112
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: cloud-port
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: ${nacos.addr}
|
||||||
|
# nacos用户名
|
||||||
|
username: ${nacos.user-name}
|
||||||
|
# nacos密码
|
||||||
|
password: ${nacos.password}
|
||||||
|
# 命名空间
|
||||||
|
namespace: ${nacos.namespace}
|
||||||
|
config:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: ${nacos.addr}
|
||||||
|
# nacos用户名
|
||||||
|
username: ${nacos.user-name}
|
||||||
|
# nacos密码
|
||||||
|
password: ${nacos.password}
|
||||||
|
# 命名空间
|
||||||
|
namespace: ${nacos.namespace}
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
# 系统共享配置
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# 系统环境Config共享配置
|
||||||
|
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
|
||||||
|
- application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# rabbit 配置文件
|
||||||
|
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
mybatis-plus:
|
||||||
|
configuration:
|
||||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 配置 MyBatis 的日志输出实现类,这里是输出到控制台
|
||||||
|
mapper-locations: classpath:/mapper/*.xml # MyBatis Mapper 文件的位置,这里假设是 XML 形式的 Mapper
|
||||||
|
global-config:
|
||||||
|
db-config:
|
||||||
|
id-type: auto # 主键生成策略,这里设置为自动增长
|
||||||
|
logic-delete-value: 1 # 逻辑删除标记值,例如设置为 1 表示已删除
|
||||||
|
logic-not-delete-value: 0 # 逻辑未删除标记值,例如设置为 0 表示未删除
|
||||||
|
banner: false # 关闭控制台打印的 MyBatis-Plus Banne
|
||||||
|
#fdfs:
|
||||||
|
# so-timeout: 1500 # socket 连接时长
|
||||||
|
# connect-timeout: 600 # 连接 tracker 服务器超时时长
|
||||||
|
# # 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流
|
||||||
|
# tracker-list: 49.235.108.160:22122
|
||||||
|
# web-server-url: 49.235.108.160:8888
|
||||||
|
# pool:
|
||||||
|
# jmx-enabled: false
|
||||||
|
# # 生成缩略图
|
||||||
|
# thumb-image:
|
||||||
|
# height: 500
|
||||||
|
# width: 500
|
||||||
|
|
144499
logs/cloud-etl/error.log
144499
logs/cloud-etl/error.log
File diff suppressed because it is too large
Load Diff
11333
logs/cloud-etl/info.log
11333
logs/cloud-etl/info.log
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue