优化上上签个人用户注册
新增查询用户注册状态功能
This commit is contained in:
@@ -11,4 +11,8 @@ public interface SignRegisterService {
|
||||
* @return
|
||||
*/
|
||||
AjaxResult registerPerson(PersonRegisterVO personRegisterVO);
|
||||
/**
|
||||
* 查询用户认证状态/user/async/applyCert/status/
|
||||
*/
|
||||
AjaxResult queryRegisterStatus(PersonRegisterVO personRegisterVO);
|
||||
}
|
||||
|
||||
+27
-3
@@ -1,6 +1,7 @@
|
||||
package com.ruoyi.bestsign.service.impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ruoyi.bestsign.domain.PersonRegisterVO;
|
||||
import com.ruoyi.bestsign.service.SignRegisterService;
|
||||
import com.ruoyi.bestsign.utils.BestsignOpenApiClient;
|
||||
@@ -22,14 +23,37 @@ public class RegisterServiceImpl implements SignRegisterService {
|
||||
@Override
|
||||
public AjaxResult registerPerson(PersonRegisterVO personRegisterVO) {
|
||||
try {
|
||||
String s = bestsignOpenApiClient.userPersonalReg(personRegisterVO.getAccount(),
|
||||
JSONObject jsonObject = bestsignOpenApiClient.userPersonalReg(personRegisterVO.getAccount(),
|
||||
personRegisterVO.getName(),
|
||||
personRegisterVO.getMail(),
|
||||
personRegisterVO.getMobile(),
|
||||
personRegisterVO.getCredential().getIdentity(),
|
||||
personRegisterVO.getCredential().getIdentityType(),
|
||||
null, null, null, null, null);
|
||||
AjaxResult.success(s);
|
||||
null, null, null, null, null, "/user/reg/");
|
||||
AjaxResult.success(jsonObject);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error(e.getMessage());
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户认证状态/user/async/applyCert/status/
|
||||
*
|
||||
* @param personRegisterVO
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult queryRegisterStatus(PersonRegisterVO personRegisterVO) {
|
||||
try {
|
||||
JSONObject jsonObject = bestsignOpenApiClient.userPersonalReg(personRegisterVO.getAccount(),
|
||||
personRegisterVO.getName(),
|
||||
personRegisterVO.getMail(),
|
||||
personRegisterVO.getMobile(),
|
||||
personRegisterVO.getCredential().getIdentity(),
|
||||
personRegisterVO.getCredential().getIdentityType(),
|
||||
null, null, null, null, null, "/user/async/applyCert/status/");
|
||||
AjaxResult.success(jsonObject);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error(e.getMessage());
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
@@ -24,13 +25,16 @@ public class BestsignOpenApiClient {
|
||||
/**
|
||||
* 开发者私钥
|
||||
*/
|
||||
@Value("${ssq.privateKey}")
|
||||
private String privateKey;
|
||||
// @Value("${ssq.privateKey}")
|
||||
private String privateKey="MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCiDRuz+dxqkWqHdov0hK+KEWLw/e8MQSqkZZ4c01Yr6cSmQiWyV8Xin0u5S/EA02FWxpjLi1nLriVtOBhZGsoryFmcJrwzSnQ5PORP/HhfcAWFE/Y+3qSQS1OiU7e5wbReCgEUvx4GHZuhdu8cOvq5DG9l33YFZrIEMBTmnf8eKT54STx0tjcKl7U6B6nsiThy3zVtpWXVv6H1HGmxC0KT4EQ388s/PFjrwmk+GFb3EpKCns/GQHf7QrtNz1ZOgCXfgQiQ+91/tcngzUH+zMCIxn5lS+ENAxVI6Ev3W9Y0QHtKwmO4ORVuAskJYzBB2xKI/gw8+PUXNziMAKXuoUAjAgMBAAECggEAd7yHw6vTGUrpE76cGsgPjEzcdoSqpLth7qbG9TWSblAEZXRqtiP0q0ZYhUl/gcSuH5gOPhdw+fZq4RCZrP0GdONMkvxsAtn4lnJPoGpD5wC2k2X0hO+tWJDP8xk4n6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ON3XKJl23ip";
|
||||
/**
|
||||
* Host地址
|
||||
*/
|
||||
@Value("${ssq.serverHost}")
|
||||
private String serverHost;
|
||||
/**
|
||||
* 签名参数
|
||||
*/
|
||||
private static String urlSignParams = "?developerId=%s&rtick=%s&signType=rsa&sign=%s";
|
||||
|
||||
// public BestsignOpenApiClient(String developerId, String privateKey,
|
||||
@@ -55,35 +59,37 @@ public class BestsignOpenApiClient {
|
||||
* @param province 省份
|
||||
* @param city 城市
|
||||
* @param address 地址
|
||||
* @param method 地址
|
||||
* @return 异步申请任务单号
|
||||
* @throws IOException
|
||||
*/
|
||||
public String userPersonalReg(String account, String name, String mail,
|
||||
public JSONObject userPersonalReg(String account, String name, String mail,
|
||||
String mobile, String identity, String identityType,
|
||||
String contactMail, String contactMobile, String province,
|
||||
String city, String address) throws Exception {
|
||||
String host = this.serverHost;
|
||||
String method = "/user/reg/";
|
||||
|
||||
// 组装请求参数,作为requestbody
|
||||
String city, String address,@NotNull String method) throws Exception {
|
||||
//body参数
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("account", account);
|
||||
requestBody.put("name", name);
|
||||
requestBody.put("userType", "1");
|
||||
requestBody.put("mail", mail);
|
||||
requestBody.put("mobile", mobile);
|
||||
|
||||
//用户帐号
|
||||
requestBody.put("account", account);
|
||||
//用户名称
|
||||
requestBody.put("name", name);
|
||||
//用户类型
|
||||
requestBody.put("userType", "1");
|
||||
//用户邮箱
|
||||
requestBody.put("mail",mail);
|
||||
//用户手机号
|
||||
requestBody.put("mobile", mobile);
|
||||
//用户证件信息对象
|
||||
JSONObject credential = new JSONObject();
|
||||
//用户证件号
|
||||
credential.put("identity", identity);
|
||||
//用户证件类型
|
||||
credential.put("identityType", identityType);
|
||||
credential.put("contactMail", contactMail);
|
||||
credential.put("contactMobile", contactMobile);
|
||||
credential.put("province", province);
|
||||
credential.put("city", city);
|
||||
credential.put("address", address);
|
||||
requestBody.put("credential", credential);
|
||||
|
||||
//是否申请证书
|
||||
requestBody.put("applyCert", "2");
|
||||
requestBody.put("applyCert", "1");
|
||||
// 生成一个时间戳参数
|
||||
String rtick = RSAUtils.getRtick();
|
||||
// 计算参数签名
|
||||
@@ -100,20 +106,24 @@ public class BestsignOpenApiClient {
|
||||
System.out.println(responseBody);
|
||||
// 返回结果解析
|
||||
JSONObject userObj = JSON.parseObject(responseBody);
|
||||
System.out.println(JSON.toJSONString(userObj));
|
||||
return userObj;
|
||||
// 返回errno为0,表示成功,其他表示失败
|
||||
if (userObj.getIntValue("errno") == 0) {
|
||||
JSONObject data = userObj.getJSONObject("data");
|
||||
if (data != null) {
|
||||
//对返回data进行处理
|
||||
String taskId = data.getString("taskId");
|
||||
return taskId;
|
||||
}
|
||||
} else {
|
||||
//接口返回异常
|
||||
System.out.println(userObj.getIntValue("errno"));
|
||||
System.out.println(userObj.getString("errmsg"));
|
||||
}
|
||||
return userObj.toJSONString();
|
||||
// if (userObj.getIntValue("errno") == 0) {
|
||||
// JSONObject data = userObj.getJSONObject("data");
|
||||
// if (data != null) {
|
||||
// //对返回data进行处理
|
||||
// String taskId = data.getString("taskId");
|
||||
// return taskId;
|
||||
// }
|
||||
// return null;
|
||||
// } else {
|
||||
// //接口返回异常
|
||||
// System.out.println(userObj.getIntValue("errno"));
|
||||
// System.out.println(userObj.getString("errmsg"));
|
||||
// throw new Exception(userObj.getIntValue("errno") + ":"
|
||||
// + userObj.getString("errmsg"));
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user