4 changed files with 105 additions and 1 deletions
@ -0,0 +1,19 @@
|
||||
package com.biutag.outer.config; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
import org.springframework.context.annotation.Configuration; |
||||
|
||||
@Setter |
||||
@Getter |
||||
@Configuration |
||||
@ConfigurationProperties( |
||||
prefix = "xyb" |
||||
) |
||||
public class XybProperties { |
||||
|
||||
private String clinetId; |
||||
|
||||
private String publicKey; |
||||
} |
||||
@ -0,0 +1,38 @@
|
||||
package com.biutag.outer.domain.vo; |
||||
|
||||
import lombok.Getter; |
||||
import lombok.Setter; |
||||
|
||||
@Setter |
||||
@Getter |
||||
public class XybUserInfo { |
||||
|
||||
private String id; |
||||
|
||||
// 身份证
|
||||
private String certificateNum; |
||||
|
||||
// 身份证开始时间
|
||||
private String certEffDate; |
||||
|
||||
// 身份证结束时间
|
||||
private String certExpDate; |
||||
|
||||
// 身份证类型
|
||||
private String certificateType; |
||||
|
||||
// 姓名
|
||||
private String name; |
||||
|
||||
// 电话
|
||||
private String phone; |
||||
|
||||
// 实名认证等级
|
||||
private String realLvl; |
||||
|
||||
// 性别
|
||||
private String sex; |
||||
|
||||
// 用户类型
|
||||
private String userType; |
||||
} |
||||
@ -0,0 +1,43 @@
|
||||
package com.biutag.outer.util; |
||||
|
||||
import cn.hutool.crypto.asymmetric.KeyType; |
||||
import cn.hutool.crypto.asymmetric.RSA; |
||||
import cn.hutool.http.HttpResponse; |
||||
import cn.hutool.http.HttpUtil; |
||||
import com.alibaba.fastjson2.JSON; |
||||
import com.alibaba.fastjson2.JSONObject; |
||||
import com.biutag.outer.config.XybProperties; |
||||
import com.biutag.outer.domain.vo.XybUserInfo; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
@Slf4j |
||||
@Component |
||||
public class XybApi { |
||||
|
||||
private static XybProperties xybProperties; |
||||
|
||||
public XybApi(XybProperties properties) { |
||||
XybApi.xybProperties = properties; |
||||
} |
||||
|
||||
public static XybUserInfo getXybUserInfo(String accessLink) { |
||||
// https://mycs.csbtv.com
|
||||
String url = String.format("https://mycs.csbtv.com/my-exclusive-api/xyb/getXybUserInfo?accessLink=%s&clientId=%s", accessLink, |
||||
xybProperties.getClinetId()); |
||||
log.info(url); |
||||
HttpResponse httpResponse = HttpUtil.createGet(url) |
||||
.execute(); |
||||
log.info(httpResponse.body()); |
||||
if (!httpResponse.isOk()) { |
||||
log.error("湘易办服务异常: {}", httpResponse.body()); |
||||
throw new RuntimeException("湘易办服务异常"); |
||||
} |
||||
JSONObject response = JSON.parseObject(httpResponse.body()); |
||||
RSA rsaPri = new RSA(null, xybProperties.getPublicKey()); |
||||
String jsonStr = rsaPri.decryptStr(response.getString("data"), KeyType.PublicKey); |
||||
// String jsonStr = rsaPri.decryptStr("HdLGrWa3fg1hBdYpQHhpG9L1QMi2FnhN6ZsXzEXumXnPnwDauG7t2efZ2eFIM7kifFurXU6DftULecezi2ouUVzWyqMffBfZDzlPrapQgQcAVpV8N8VMEH8FwgiAg0yjP9AwdKpsfOGhiEGkascaj2U99gpqNL4P02Vdz67sbnVmkjD3VWOZkh6P5h1i12ldEZTdoLmYT24V5n4QnK7O63oSIDMzaOH1A8ZhBKpYuG0XqzvklpHpllthqajMsAtXN3RFcXmvzQX8aIm9QHDECHl4syl1SJgegdJuyngbFzOkmUrBLVSRrBBRsHXMTg/Iydb9cC3CkyNlLEHqCgJwGg==", KeyType.PublicKey);
|
||||
return JSON.parseObject(jsonStr, XybUserInfo.class); |
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue