提交修改
This commit is contained in:
parent
1cc0d06eb8
commit
dce1433fdd
@ -0,0 +1,35 @@
|
||||
package com.heyu.api.tencent.handle;
|
||||
|
||||
|
||||
import com.heyu.api.data.utils.StringUtils;
|
||||
import com.heyu.api.tencent.TencentBaseHandle;
|
||||
import com.tencentcloudapi.faceid.v20180301.FaceidClient;
|
||||
import com.tencentcloudapi.faceid.v20180301.models.MinorsVerificationRequest;
|
||||
import com.tencentcloudapi.faceid.v20180301.models.MinorsVerificationResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/***
|
||||
* https://console.cloud.tencent.com/api/explorer?Product=faceid&Version=2018-03-01&Action=MinorsVerification
|
||||
*
|
||||
* 手机号实名查询
|
||||
*/
|
||||
@Component
|
||||
public class TMinorsVerificationHandle extends TencentBaseHandle<MinorsVerificationRequest, MinorsVerificationResponse> {
|
||||
@Autowired
|
||||
private FaceidClient client;
|
||||
|
||||
@Override
|
||||
public String check(MinorsVerificationRequest tMinorsVerificationRequest) {
|
||||
if (StringUtils.isBlank(tMinorsVerificationRequest.getMobile())) {
|
||||
return "手机号不能为空";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MinorsVerificationResponse run(MinorsVerificationRequest ap) throws Exception {
|
||||
|
||||
return client.MinorsVerification(ap);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
package com.heyu.api.tencent.request;
|
||||
|
||||
|
||||
import com.heyu.api.tencent.TencentBaseRequest;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* https://console.cloud.tencent.com/api/explorer?Product=faceid&Version=2018-03-01&Action=MinorsVerification
|
||||
* <p>
|
||||
* 手机号实名查询
|
||||
*/
|
||||
@Data
|
||||
public class TMinorsVerificationRequest extends TencentBaseRequest {
|
||||
|
||||
/***
|
||||
* 是 String 参与校验的参数类型。
|
||||
* 0:使用手机号进行校验;
|
||||
* 1:使用姓名与身份证号进行校验。
|
||||
*/
|
||||
private String type = "0";
|
||||
|
||||
|
||||
/***
|
||||
* 否 String 手机号,11位数字,
|
||||
* 特别提示:
|
||||
* 手机号验证只限制在腾讯健康守护可信模型覆盖的数据范围内,与手机号本身在运营商是否实名无关联,不在范围会提示“手机号未实名”,建议客户与传入姓名和身份证号信息组合使用。
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
|
||||
/***
|
||||
* 否 String 身份证号码。
|
||||
*/
|
||||
private String idCard;
|
||||
|
||||
/***
|
||||
* 否 String 姓名。
|
||||
*/
|
||||
private String name;
|
||||
|
||||
|
||||
/***
|
||||
* 否 Encryption 敏感数据加密信息。对传入信息(姓名、身份证号、手机号)有加密需求的用户可使用此参数,详情请点击左侧链接。
|
||||
*/
|
||||
private String Encryption;
|
||||
|
||||
}
|
||||
@ -0,0 +1,79 @@
|
||||
package com.heyu.api.controller.certificate.mobile;
|
||||
|
||||
import com.heyu.api.controller.request.mobile.Mobile2MetaVerificationRequest;
|
||||
import com.heyu.api.controller.resp.mobile.MobileInfoVerificationResp;
|
||||
import com.heyu.api.data.annotation.NotIntercept;
|
||||
import com.heyu.api.data.utils.ApiR;
|
||||
import com.heyu.api.data.utils.R;
|
||||
import com.heyu.api.tencent.handle.TMinorsVerificationHandle;
|
||||
import com.tencentcloudapi.faceid.v20180301.models.MinorsVerificationRequest;
|
||||
import com.tencentcloudapi.faceid.v20180301.models.MinorsVerificationResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
* 手机号实名查询
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/mobile/info")
|
||||
|
||||
@NotIntercept
|
||||
public class MinorsVerificationController {
|
||||
|
||||
|
||||
public final static Map<String, String> checkResult = new HashMap<>();
|
||||
public final static Map<String, String> ageRangeMap = new HashMap<>();
|
||||
|
||||
|
||||
@Autowired
|
||||
private TMinorsVerificationHandle tMinorsVerificationHandle;
|
||||
|
||||
@RequestMapping("/verification")
|
||||
public R verification(Mobile2MetaVerificationRequest request) {
|
||||
MobileInfoVerificationResp resp = new MobileInfoVerificationResp();
|
||||
MinorsVerificationRequest tPhone3MetaVerificationRequest = new MinorsVerificationRequest();
|
||||
tPhone3MetaVerificationRequest.setMobile(request.getMobile());
|
||||
// 0:使用手机号进行校验;
|
||||
tPhone3MetaVerificationRequest.setType("0");
|
||||
|
||||
ApiR<MinorsVerificationResponse> tR = tMinorsVerificationHandle.handle(tPhone3MetaVerificationRequest);
|
||||
|
||||
|
||||
if (tR.isSuccess()) {
|
||||
MinorsVerificationResponse response = tR.getData();
|
||||
resp.setCheckResult(response.getResult());
|
||||
resp.setDesc(checkResult.get(response.getResult()));
|
||||
resp.setAgeRange(response.getAgeRange());
|
||||
resp.setAgeRangeDesc(ageRangeMap.get(response.getAgeRange()));
|
||||
return R.ok().setData(resp);
|
||||
|
||||
}
|
||||
return R.error(tR.getErrorMsg());
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
checkResult.put("0:", "成年");
|
||||
checkResult.put("-1", "未成年");
|
||||
checkResult.put("-3", "姓名和身份证号不一致");
|
||||
checkResult.put("-2", "未查询到手机号信息");
|
||||
checkResult.put("-4", "非法身份证号(长度、校验位等不正确)");
|
||||
checkResult.put("-5", "非法姓名(长度、格式等不正确)");
|
||||
checkResult.put("-6", "权威数据源服务异常");
|
||||
checkResult.put("-7", "未查询到身份信息");
|
||||
|
||||
ageRangeMap.put("[0,8)", "表示年龄小于8周岁区间,不包括8岁");
|
||||
ageRangeMap.put("[8,16)", "表示年龄8-16周岁区间,不包括16岁");
|
||||
ageRangeMap.put("[16,18)", "表示年龄16-18周岁区间,不包括18岁");
|
||||
ageRangeMap.put("[18,+)", "表示年龄大于18周岁");
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package com.heyu.api.controller.resp.mobile;
|
||||
|
||||
|
||||
import com.heyu.api.controller.resp.certificate.BaseCheckResultResp;
|
||||
import lombok.Data;
|
||||
|
||||
/***
|
||||
* https://console.cloud.tencent.com/api/explorer?Product=faceid&Version=2018-03-01&Action=PhoneVerification
|
||||
*
|
||||
* 手机号三要素核验
|
||||
*/
|
||||
@Data
|
||||
public class MobileInfoVerificationResp extends BaseCheckResultResp {
|
||||
|
||||
|
||||
/***
|
||||
* Description String 业务结果描述。
|
||||
*/
|
||||
private String description;
|
||||
|
||||
|
||||
/***
|
||||
* AgeRange String 该字段的值为年龄区间。格式为[a,b),
|
||||
* [0,8)表示年龄小于8周岁区间,不包括8岁;
|
||||
* [8,16)表示年龄8-16周岁区间,不包括16岁;
|
||||
* [16,18)表示年龄16-18周岁区间,不包括18岁;
|
||||
* [18,+)表示年龄大于18周岁。
|
||||
*/
|
||||
private String ageRange;
|
||||
|
||||
private String ageRangeDesc;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user