提交修改
This commit is contained in:
parent
b502fb522a
commit
1cc0d06eb8
@ -0,0 +1,46 @@
|
||||
package com.heyu.api.tencent.handle;
|
||||
|
||||
|
||||
import com.heyu.api.data.utils.MobileUtils;
|
||||
import com.heyu.api.data.utils.StringUtils;
|
||||
import com.heyu.api.tencent.TencentBaseHandle;
|
||||
import com.heyu.api.tencent.request.TCheckPhoneAndNameRequest;
|
||||
import com.tencentcloudapi.faceid.v20180301.FaceidClient;
|
||||
import com.tencentcloudapi.faceid.v20180301.models.CheckPhoneAndNameRequest;
|
||||
import com.tencentcloudapi.faceid.v20180301.models.CheckPhoneAndNameResponse;
|
||||
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=CheckPhoneAndName
|
||||
*
|
||||
* 手机号二要素核验
|
||||
*/
|
||||
@Component
|
||||
public class TCheckPhoneAndNameHandle extends TencentBaseHandle<TCheckPhoneAndNameRequest, CheckPhoneAndNameResponse> {
|
||||
|
||||
@Autowired
|
||||
private FaceidClient client;
|
||||
|
||||
|
||||
@Override
|
||||
public String check(TCheckPhoneAndNameRequest tCheckPhoneAndNameRequest) {
|
||||
if (StringUtils.isBlank(tCheckPhoneAndNameRequest.getName())
|
||||
&& StringUtils.isBlank(tCheckPhoneAndNameRequest.getMobile())) {
|
||||
return "姓名+手机号不能为空";
|
||||
}
|
||||
if (!MobileUtils.validateMobile(tCheckPhoneAndNameRequest.getMobile())) {
|
||||
return "手机号格式不正确";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckPhoneAndNameResponse run(TCheckPhoneAndNameRequest ap) throws Exception {
|
||||
CheckPhoneAndNameRequest checkPhoneAndNameRequest = new CheckPhoneAndNameRequest();
|
||||
checkPhoneAndNameRequest.setName(ap.getName());
|
||||
checkPhoneAndNameRequest.setMobile(ap.getMobile());
|
||||
checkPhoneAndNameRequest.setEncryption(ap.getEncryption());
|
||||
return client.CheckPhoneAndName(checkPhoneAndNameRequest);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package com.heyu.api.tencent.request;
|
||||
|
||||
|
||||
import com.tencentcloudapi.faceid.v20180301.models.Encryption;
|
||||
import lombok.Data;
|
||||
|
||||
/***
|
||||
* https://console.cloud.tencent.com/api/explorer?Product=faceid&Version=2018-03-01&Action=CheckPhoneAndName
|
||||
*
|
||||
* 手机号二要素核验
|
||||
*/
|
||||
@Data
|
||||
public class TCheckPhoneAndNameRequest {
|
||||
|
||||
/***
|
||||
* ⼿机号。
|
||||
* 示例值:16137688175
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/***
|
||||
* 姓名。
|
||||
* 示例值:韦小宝
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/***
|
||||
* 否 Encryption 敏感数据加密信息。
|
||||
* - 对传入信息(姓名、手机号)有加密需求的用户可使用此参数,详情请点击左侧链接。
|
||||
*/
|
||||
private Encryption encryption;
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package com.heyu.api.controller.certificate.mobile;
|
||||
|
||||
import com.heyu.api.controller.request.mobile.Mobile2MetaVerificationRequest;
|
||||
import com.heyu.api.controller.resp.mobile.Mobile3MetaVerificationResp;
|
||||
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.TCheckPhoneAndNameHandle;
|
||||
import com.heyu.api.tencent.request.TCheckPhoneAndNameRequest;
|
||||
import com.tencentcloudapi.faceid.v20180301.models.CheckPhoneAndNameResponse;
|
||||
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/2/meta")
|
||||
|
||||
@NotIntercept
|
||||
public class Mobile2MetaVerificationController {
|
||||
|
||||
|
||||
public final static Map<String, String> checkResult = new HashMap<>();
|
||||
|
||||
|
||||
@Autowired
|
||||
private TCheckPhoneAndNameHandle tCheckPhoneAndNameHandle;
|
||||
|
||||
|
||||
@RequestMapping("/verification")
|
||||
public R verification(Mobile2MetaVerificationRequest request) {
|
||||
Mobile3MetaVerificationResp resp = new Mobile3MetaVerificationResp("1");
|
||||
TCheckPhoneAndNameRequest tPhone3MetaVerificationRequest = new TCheckPhoneAndNameRequest();
|
||||
tPhone3MetaVerificationRequest.setMobile(request.getMobile());
|
||||
|
||||
tPhone3MetaVerificationRequest.setName(request.getRealName());
|
||||
|
||||
ApiR<CheckPhoneAndNameResponse> tR = tCheckPhoneAndNameHandle.handle(tPhone3MetaVerificationRequest);
|
||||
if (tR.isSuccess()) {
|
||||
CheckPhoneAndNameResponse response = tR.getData();
|
||||
resp.setCheckResult(response.getResult());
|
||||
resp.setDesc(checkResult.get(response.getResult()));
|
||||
resp.setDescription(response.getDescription());
|
||||
return R.ok().setData(resp);
|
||||
|
||||
}
|
||||
return R.error(tR.getErrorMsg());
|
||||
}
|
||||
|
||||
|
||||
static {
|
||||
checkResult.put("0", "验证结果一致");
|
||||
checkResult.put("1", "验证结果不一致");
|
||||
checkResult.put("-1", "查无记录");
|
||||
checkResult.put("-2", "引擎未知错误");
|
||||
checkResult.put("-3", "引擎服务异常");
|
||||
checkResult.put("-4", "姓名校验不通过");
|
||||
checkResult.put("-5", "手机号码不合法");
|
||||
checkResult.put("-6", " 认证次数超过当日限制,请次日重试");
|
||||
}
|
||||
|
||||
}
|
||||
@ -17,7 +17,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/***
|
||||
*
|
||||
*手机号三要素核验
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
package com.heyu.api.controller.request.mobile;
|
||||
|
||||
|
||||
import com.heyu.api.data.dto.BaseRequest;
|
||||
import lombok.Data;
|
||||
|
||||
/***
|
||||
* https://console.cloud.tencent.com/api/explorer?Product=faceid&Version=2018-03-01&Action=PhoneVerification
|
||||
*
|
||||
* 手机号二要素核验
|
||||
*/
|
||||
@Data
|
||||
public class Mobile2MetaVerificationRequest extends BaseRequest {
|
||||
|
||||
|
||||
/***
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
|
||||
/**
|
||||
* 真实姓名。
|
||||
*/
|
||||
private String realName;
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user