提交 788524eb 编写于 作者: tao.jin's avatar tao.jin

Merge branch 'dev-2022218' into 'release'

Dev 2022218

See merge request !90
流水线 #43152 已失败 于阶段
......@@ -11,7 +11,7 @@
<groupId>com.pica.cloud.account</groupId>
<artifactId>pica-cloud-account-client</artifactId>
<version>1.0.7</version>
<version>1.0.8</version>
<name>pica-cloud-account-client</name>
<packaging>jar</packaging>
......@@ -28,7 +28,7 @@
<dependency>
<groupId>com.pica.cloud.account</groupId>
<artifactId>pica-cloud-account-common</artifactId>
<version>1.0.7</version>
<version>1.0.8</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
......
......@@ -14,11 +14,16 @@ public interface CaptchaClient {
@GetMapping("/account/account/acknowledge")
PicaResponse<Boolean> acknowledge(@RequestParam("captchaToken") String captchaToken,
@RequestParam("captchaAnswer") String captchaAnswer);
@RequestParam("captchaAnswer") String captchaAnswer);
@GetMapping("/account/account/check/authCode")
PicaResponse checkAuthCode(@RequestParam("mobilePhone") String mobilePhone,
@RequestParam("flag") String flag,
@RequestParam("authCode") String authCode);
@GetMapping("/account/account/checkMobile/authCode")
PicaResponse checkDetectionCode(@RequestParam("mobilePhone") String mobilePhone,
@RequestParam("flag") String flag,
@RequestParam("authCode") String authCode);
}
......@@ -11,7 +11,7 @@
<groupId>com.pica.cloud.account</groupId>
<artifactId>pica-cloud-account-common</artifactId>
<version>1.0.7</version>
<version>1.0.8</version>
<name>pica-cloud-account-common</name>
<packaging>jar</packaging>
......
......@@ -161,7 +161,7 @@
<dependency>
<groupId>com.pica.cloud.account</groupId>
<artifactId>pica-cloud-account-common</artifactId>
<version>1.0.7</version>
<version>1.0.8</version>
</dependency>
<dependency>
......
......@@ -103,8 +103,8 @@ public class AccountController extends AccountBaseController {
@ApiOperation("教培项目校验短信验证码")
@GetMapping("/check/authCode")
public PicaResponse checkAuthCode(@ApiParam(value = "手机号", required = true) @RequestParam("mobilePhone") String mobilePhone,
@ApiParam(value = "验证码类型 0默认 1注册 2修改密码 4微信登录绑定手机 5修改手机 6重置密码 7患者招募提交问卷(效验") @RequestParam(value = "flag", defaultValue = "0") String flag,
@ApiParam(value = "短信验证码", required = true) @RequestParam("authCode") String authCode) {
@ApiParam(value = "验证码类型 0默认 1注册 2修改密码 4微信登录绑定手机 5修改手机 6重置密码 7患者招募提交问卷(效验") @RequestParam(value = "flag", defaultValue = "0") String flag,
@ApiParam(value = "短信验证码", required = true) @RequestParam("authCode") String authCode) {
this.checkMobilePhone(mobilePhone);
AccountReq accountReq = new AccountReq();
accountReq.setMobilePhone(mobilePhone);
......@@ -114,11 +114,26 @@ public class AccountController extends AccountBaseController {
return PicaResponse.toResponse();
}
@ApiOperation("校验短信验证码(不清缓存)")
@GetMapping("/checkMobile/authCode")
public PicaResponse checkDetectionCode(@ApiParam(value = "手机号", required = true) @RequestParam("mobilePhone") String mobilePhone,
@ApiParam(value = "验证码类型 0默认 1注册 2修改密码 4微信登录绑定手机 5修改手机 6重置密码 7患者招募提交问卷(效验 9患者报告") @RequestParam(value = "flag", defaultValue = "0") String flag,
@ApiParam(value = "短信验证码", required = true) @RequestParam("authCode") String authCode) {
this.checkMobilePhone(mobilePhone);
AccountReq accountReq = new AccountReq();
accountReq.setMobilePhone(mobilePhone);
accountReq.setFlag(flag);
accountReq.setAuthCode(authCode);
this.checkAuthCodeV2(accountReq);
return PicaResponse.toResponse();
}
@EnabledLoginValidate
@ApiOperation("校验登录用户的短信验证码")
@GetMapping("/check/H5/authCode/login")
public PicaResponse checkLoginAuthCode(@ApiParam(value = "验证码类型 0默认 1注册 2修改密码 4微信登录绑定手机 5修改手机 6重置密码 7患者招募提交问卷(效验") @RequestParam(value = "flag", defaultValue = "0") String flag,
@ApiParam(value = "短信验证码", required = true) @RequestParam("authCode") String authCode) {
@ApiParam(value = "短信验证码", required = true) @RequestParam("authCode") String authCode) {
if ("000000".equals(authCode)) {
return PicaResponse.toResponse();
}
......@@ -136,25 +151,25 @@ public class AccountController extends AccountBaseController {
@ApiOperation("微信登录")
@PostMapping("/login/wechat")
public PicaResponse<String> wechatLogin(@RequestBody AccountReq req) {
logger.info("wechatLogin:{}",JSONObject.toJSONString(req));
logger.info("wechatLogin:{}", JSONObject.toJSONString(req));
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"wechatLogin",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"req:"+ JSON.toJSONString(req));
intactUtil.sendIntact(batchNo, "wechatLogin", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "req:" + JSON.toJSONString(req));
if (StringUtils.isBlank(req.getUnionid())) {
intactUtil.sendIntact(batchNo,"wechatLogin",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"确认unionId");
intactUtil.sendIntact(batchNo, "wechatLogin", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "确认unionId");
return PicaResponse.toResponse(null, PicaResultCode.PARAM_IS_INVALID.code(), "缺少unionid");
}
Account account = accountService.getByUnionid(req.getUnionid()); //获取账号信息
if (account == null) {
intactUtil.sendIntact(batchNo,"wechatLogin",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"该unionid未绑定云鹊医账号");
intactUtil.sendIntact(batchNo, "wechatLogin", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该unionid未绑定云鹊医账号");
return PicaResponse.toResponse(null, PicaResultCode.RESULE_DATA_NONE.code(), "该unionid未绑定云鹊医账号");
}
//已经绑定过云鹊医账号,登录成功,返回token
String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios
String newToken = this.generateToken(account, deviceType);
intactUtil.sendIntact(batchNo,"wechatLogin",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"req:"+ JSON.toJSONString(req));
intactUtil.sendIntact(batchNo, "wechatLogin", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "req:" + JSON.toJSONString(req));
return PicaResponse.toResponse(newToken);
}
......@@ -166,22 +181,22 @@ public class AccountController extends AccountBaseController {
logger.info("login:{}", JSONObject.toJSONString(req));
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"req:"+ JSON.toJSONString(req));
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "req:" + JSON.toJSONString(req));
Account account = accountService.getByMobilePhone(req.getMobilePhone()); //获取账号信息
if (account == null) {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"未注册,请验证码登录");
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "未注册,请验证码登录");
return PicaResponse.toResponse(null, PicaResultCode.RESULE_DATA_NONE.code(), "未注册,请验证码登录");
}
if (StringUtils.isBlank(req.getPassword())) {
//验证码登录
req.setFlag("0");
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"校验验证码前的返回,因为验证码可能校验不通过,就直接返回了");
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "校验验证码前的返回,因为验证码可能校验不通过,就直接返回了");
//校验验证码
this.checkAuthCode(req);
} else { //密码登录
if (!StringUtils.equals(req.getPassword(), account.getPassword())) {
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"请输入正确的密码");
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "请输入正确的密码");
return PicaResponse.toResponse(null, PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的密码");
}
}
......@@ -201,13 +216,13 @@ public class AccountController extends AccountBaseController {
String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios
// String newToken = this.generateToken(account, deviceType);
String newToken = "";
if(deviceType.equals("1")){
if (deviceType.equals("1")) {
newToken = this.generateToken(account, "4"); //pc端注册,目前无法生成新token
}else {
} else {
newToken = this.generateToken(account, deviceType);
}
intactUtil.sendIntact(batchNo,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"req:"+ JSON.toJSONString(req));
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "req:" + JSON.toJSONString(req));
return PicaResponse.toResponse(newToken);
}
......@@ -215,10 +230,10 @@ public class AccountController extends AccountBaseController {
// @PostMapping("/register")
public PicaResponse<LoginResult> register(@RequestBody AccountReq req) {
this.checkMobilePhone(req.getMobilePhone());
accountUtils.checkRegisterMobilePhoneAndAuthCode(req.getMobilePhone(),req.getFlag(),req.getAuthCode());
accountUtils.checkRegisterMobilePhoneAndAuthCode(req.getMobilePhone(), req.getFlag(), req.getAuthCode());
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"register",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"req:"+ JSON.toJSONString(req));
intactUtil.sendIntact(batchNo, "register", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "req:" + JSON.toJSONString(req));
String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios
Account account = new Account();
account.setMobilePhone(EncryptUtils.encryptContent(req.getMobilePhone(), EncryptConstants.ENCRYPT_TYPE_MOBILE));
......@@ -236,19 +251,19 @@ public class AccountController extends AccountBaseController {
account.setRegisterSource(AccountTypeEnum.DEVICE_TYPE_H5.getCode()); //H5注册
}
//创建账号
accountService.createAccount(account,null);
accountService.createAccount(account, null);
//生成token并返回
String newToken = "";
if(deviceType.equals("1")){
if (deviceType.equals("1")) {
newToken = this.generateToken(account, "4"); //pc端注册,目前无法生成新token
}else {
} else {
newToken = this.generateToken(account, deviceType);
}
LoginResult result = new LoginResult();
result.setToken(newToken);
intactUtil.sendIntact(batchNo,"register",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"req:"+ JSON.toJSONString(req));
intactUtil.sendIntact(batchNo, "register", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "req:" + JSON.toJSONString(req));
return PicaResponse.toResponse(result);
}
......@@ -261,7 +276,7 @@ public class AccountController extends AccountBaseController {
this.checkMobilePhone(request.getMobile());
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"h5-loginRegister",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"entity:"+ JSON.toJSONString(entity));
intactUtil.sendIntact(batchNo, "h5-loginRegister", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "entity:" + JSON.toJSONString(entity));
AccountReq req = new AccountReq();
req.setMobilePhone(request.getMobile());
// 登录或注册,只能使用验证码
......@@ -278,15 +293,15 @@ public class AccountController extends AccountBaseController {
try {
response = this.login(req);
} catch (PicaException e) {
if(e.getCode().equals(PicaResultCode.PARAM_IS_INVALID.code()) || e.getCode().equals(PicaResultCode.RESULE_DATA_NONE.code())){
intactUtil.sendIntact(batchNo,"h5-loginRegister",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"验证码错误或过期-不加入提醒,返回值:"+ JSON.toJSONString(response));
if (e.getCode().equals(PicaResultCode.PARAM_IS_INVALID.code()) || e.getCode().equals(PicaResultCode.RESULE_DATA_NONE.code())) {
intactUtil.sendIntact(batchNo, "h5-loginRegister", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "验证码错误或过期-不加入提醒,返回值:" + JSON.toJSONString(response));
}
throw e;
}
if (response.getData() != null) {
LoginResult result = new LoginResult();
result.setToken(response.getData().toString());
intactUtil.sendIntact(batchNo,"h5-loginRegister",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"登录成功,返回值:"+ JSON.toJSONString(response.getData()));
intactUtil.sendIntact(batchNo, "h5-loginRegister", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "登录成功,返回值:" + JSON.toJSONString(response.getData()));
return PicaResponse.toResponse(result);
}
......@@ -297,12 +312,12 @@ public class AccountController extends AccountBaseController {
try {
result = this.register(req);
} catch (PicaException e) {
if(e.getCode().equals(PicaResultCode.PARAM_IS_INVALID.code()) || e.getCode().equals(PicaResultCode.RESULE_DATA_NONE.code())){
intactUtil.sendIntact(batchNo,"h5-loginRegister",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"验证码错误或过期-不加入提醒,返回值:"+ JSON.toJSONString(result));
if (e.getCode().equals(PicaResultCode.PARAM_IS_INVALID.code()) || e.getCode().equals(PicaResultCode.RESULE_DATA_NONE.code())) {
intactUtil.sendIntact(batchNo, "h5-loginRegister", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "验证码错误或过期-不加入提醒,返回值:" + JSON.toJSONString(result));
}
throw e;
}
intactUtil.sendIntact(batchNo,"h5-loginRegister",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"注册成功,返回值:"+ JSON.toJSONString(result));
intactUtil.sendIntact(batchNo, "h5-loginRegister", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "注册成功,返回值:" + JSON.toJSONString(result));
return result;
}
}
......@@ -316,7 +331,7 @@ public class AccountController extends AccountBaseController {
this.checkMobilePhone(request.getMobile());
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"webLive-loginRegister",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"entity:"+ JSON.toJSONString(entity));
intactUtil.sendIntact(batchNo, "webLive-loginRegister", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "entity:" + JSON.toJSONString(entity));
AccountReq req = new AccountReq();
req.setMobilePhone(request.getMobile());
// 登录或注册,只能使用验证码
......@@ -337,22 +352,22 @@ public class AccountController extends AccountBaseController {
logger.info("login:{}", JSONObject.toJSONString(req));
//接入新旭事务一致性
String batchNo1 = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo1,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"req:"+ JSON.toJSONString(req));
intactUtil.sendIntact(batchNo1, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "req:" + JSON.toJSONString(req));
Account account1 = accountService.getByMobilePhone(req.getMobilePhone()); //获取账号信息
if (account1 == null) {
intactUtil.sendIntact(batchNo1,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"未注册,请验证码登录");
intactUtil.sendIntact(batchNo1, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "未注册,请验证码登录");
return PicaResponse.toResponse(null, PicaResultCode.RESULE_DATA_NONE.code(), "未注册,请验证码登录");
}
if (StringUtils.isBlank(req.getPassword())) {
//验证码登录
req.setFlag("0");
intactUtil.sendIntact(batchNo1,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"校验验证码前的返回,因为验证码可能校验不通过,就直接返回了");
intactUtil.sendIntact(batchNo1, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "校验验证码前的返回,因为验证码可能校验不通过,就直接返回了");
//校验验证码
this.checkAuthCode(req);
} else { //密码登录
if (!StringUtils.equals(req.getPassword(), account1.getPassword())) {
intactUtil.sendIntact(batchNo1,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"请输入正确的密码");
intactUtil.sendIntact(batchNo1, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "请输入正确的密码");
return PicaResponse.toResponse(null, PicaResultCode.PARAM_IS_INVALID.code(), "请输入正确的密码");
}
}
......@@ -371,20 +386,20 @@ public class AccountController extends AccountBaseController {
//登录成功,清除旧token,生成新token
String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios
String newToken = this.generateTokenWebLive(account1, deviceType);
intactUtil.sendIntact(batchNo1,"login",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"req:"+ JSON.toJSONString(req));
intactUtil.sendIntact(batchNo1, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "req:" + JSON.toJSONString(req));
response = PicaResponse.toResponse(newToken);
} catch (PicaException e) {
if(e.getCode().equals(PicaResultCode.PARAM_IS_INVALID.code()) || e.getCode().equals(PicaResultCode.RESULE_DATA_NONE.code())){
intactUtil.sendIntact(batchNo,"webLive-loginRegister",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"验证码错误或过期-不加入提醒,返回值:"+ JSON.toJSONString(response));
if (e.getCode().equals(PicaResultCode.PARAM_IS_INVALID.code()) || e.getCode().equals(PicaResultCode.RESULE_DATA_NONE.code())) {
intactUtil.sendIntact(batchNo, "webLive-loginRegister", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "验证码错误或过期-不加入提醒,返回值:" + JSON.toJSONString(response));
}
throw e;
}
if (response.getData() != null) {
LoginResult result = new LoginResult();
result.setToken(response.getData().toString());
intactUtil.sendIntact(batchNo,"webLive-loginRegister",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"登录成功,返回值:"+ JSON.toJSONString(response.getData()));
intactUtil.sendIntact(batchNo, "webLive-loginRegister", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "登录成功,返回值:" + JSON.toJSONString(response.getData()));
return PicaResponse.toResponse(result);
}
......@@ -396,10 +411,10 @@ public class AccountController extends AccountBaseController {
// result = this.register(req);
this.checkMobilePhone(req.getMobilePhone());
accountUtils.checkRegisterMobilePhoneAndAuthCode(req.getMobilePhone(),req.getFlag(),req.getAuthCode());
accountUtils.checkRegisterMobilePhoneAndAuthCode(req.getMobilePhone(), req.getFlag(), req.getAuthCode());
//接入新旭事务一致性
String batchNo2 = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo2,"register",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"req:"+ JSON.toJSONString(req));
intactUtil.sendIntact(batchNo2, "register", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "req:" + JSON.toJSONString(req));
String deviceType = super.getDeviceInfo("device_type"); //1:pc 2:android 3:ios
Account account2 = new Account();
account2.setMobilePhone(EncryptUtils.encryptContent(req.getMobilePhone(), EncryptConstants.ENCRYPT_TYPE_MOBILE));
......@@ -418,32 +433,32 @@ public class AccountController extends AccountBaseController {
}
//创建web live账号
accountService.createAccount(account2,AccountTypeEnum.PRODUCT_TYPE_ECO_LIVE.getCode());
accountService.createAccount(account2, AccountTypeEnum.PRODUCT_TYPE_ECO_LIVE.getCode());
//生成token并返回
String newToken = this.generateTokenWebLive(account2, deviceType);
LoginResult result1 = new LoginResult();
result1.setToken(newToken);
intactUtil.sendIntact(batchNo2,"register",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"req:"+ JSON.toJSONString(req));
intactUtil.sendIntact(batchNo2, "register", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "req:" + JSON.toJSONString(req));
// return PicaResponse.toResponse(result);
result = PicaResponse.toResponse(result1);
} catch (PicaException e) {
if(e.getCode().equals(PicaResultCode.PARAM_IS_INVALID.code()) || e.getCode().equals(PicaResultCode.RESULE_DATA_NONE.code())){
intactUtil.sendIntact(batchNo,"webLive--loginRegister",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"验证码错误或过期-不加入提醒,返回值:"+ JSON.toJSONString(result));
if (e.getCode().equals(PicaResultCode.PARAM_IS_INVALID.code()) || e.getCode().equals(PicaResultCode.RESULE_DATA_NONE.code())) {
intactUtil.sendIntact(batchNo, "webLive--loginRegister", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "验证码错误或过期-不加入提醒,返回值:" + JSON.toJSONString(result));
}
throw e;
}
intactUtil.sendIntact(batchNo,"webLive--loginRegister",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"注册成功,返回值:"+ JSON.toJSONString(result));
intactUtil.sendIntact(batchNo, "webLive--loginRegister", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "注册成功,返回值:" + JSON.toJSONString(result));
return result;
}
}
@ApiOperation("获取内部机构医生ids")
@GetMapping("/innerDoctors")
public PicaResponse<List<Integer>> getDoctorsByInnerOrg(){
public PicaResponse<List<Integer>> getDoctorsByInnerOrg() {
return PicaResponse.toResponse(doctorService.getDoctorsByInnerOrg());
}
......@@ -481,6 +496,27 @@ public class AccountController extends AccountBaseController {
redisClient.del(authCodeKey); //清除验证码
}
//校验验证码(注释删除逻辑)
private void checkAuthCodeV2(AccountReq req) {
String flag = StringUtils.isBlank(req.getFlag()) ? "0" : req.getFlag();
if (StringUtils.isBlank(req.getAuthCode())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误");
}
String authCodeKey = this.getAuthCodeKey(req.getMobilePhone(), flag);
logger.info(authCodeKey);
String cacheCode = redisClient.get(authCodeKey); //从redis获取验证码
if (StringUtils.isBlank(cacheCode)) {
throw new PicaException(PicaResultCode.RESULE_DATA_NONE.code(), "短信验证码已过期,请重新获取");
}
if (!StringUtils.equals(req.getAuthCode(), cacheCode)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "短信验证码错误");
}
// redisClient.del(authCodeKey); //清除验证码
}
//生成H5 token
private String generateH5Token(Account account) {
String newToken = StringUtils.EMPTY;
......@@ -554,7 +590,7 @@ public class AccountController extends AccountBaseController {
private String generateToken(Account account, String deviceType) {
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"generateToken",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"account:"+ JSON.toJSONString(account)+",deviceType:"+deviceType);
intactUtil.sendIntact(batchNo, "generateToken", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "account:" + JSON.toJSONString(account) + ",deviceType:" + deviceType);
String newToken;
switch (deviceType) { //设备信息
case "1": //pc
......@@ -569,14 +605,14 @@ public class AccountController extends AccountBaseController {
default: //H5
newToken = this.generateH5Token(account);
}
intactUtil.sendIntact(batchNo,"generateToken",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"newToken:"+newToken);
intactUtil.sendIntact(batchNo, "generateToken", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "newToken:" + newToken);
return newToken;
}
private String generateTokenWebLive(Account account, String deviceType) {
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"generateToken",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"account:"+ JSON.toJSONString(account)+",deviceType:"+deviceType);
intactUtil.sendIntact(batchNo, "generateToken", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "account:" + JSON.toJSONString(account) + ",deviceType:" + deviceType);
String newToken;
switch (deviceType) { //设备信息
case "1": //pc
......@@ -591,7 +627,7 @@ public class AccountController extends AccountBaseController {
default: //H5
newToken = this.generateH5TokenWebLive(account);
}
intactUtil.sendIntact(batchNo,"generateToken",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"newToken:"+newToken);
intactUtil.sendIntact(batchNo, "generateToken", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "newToken:" + newToken);
return newToken;
}
......
......@@ -32,6 +32,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Objects;
@Api(description = "短信验证码资源")
@RestController
public class AutoCodeController extends AccountBaseController {
......@@ -107,10 +109,10 @@ public class AutoCodeController extends AccountBaseController {
@PostMapping(value = "/authCode")
public PicaResponse getAuthCode(@RequestBody AesAuthCodeReq authCodeReq, HttpServletRequest req) throws Exception {
// 验证码类型 0默认 1注册 2微信登录绑定手机 3修改手机
// 4重置密码 5忘记密码 7患者招募提交问卷(效验) 8Appe登录绑定手机
// 4重置密码 5忘记密码 7患者招募提交问卷(效验) 8Appe登录绑定手机 9患者查询检测报告列表
EncryptEntity entity = new EncryptEntity();
if(StringUtils.isEmpty(authCodeReq.getKey()) && StringUtils.isEmpty(authCodeReq.getContent())){
if (StringUtils.isEmpty(authCodeReq.getKey()) && StringUtils.isEmpty(authCodeReq.getContent())) {
//明文时处理
entity = RSAUtil.getAuthCodeEncrypt(authCodeReq);
logger.info("AesAuthCodeReq getAuthCode:" + JSONObject.toJSONString(authCodeReq));
......@@ -123,7 +125,7 @@ public class AutoCodeController extends AccountBaseController {
loginAes.setMobile(authCodeReq.getMobile());
loginAes.setDeviceInfo(super.getDeviceInfoLow("deviceinfo"));
loginService.insertLoginAesLog(loginAes);
}else {
} else {
//执行原逻辑
entity.setKey(authCodeReq.getKey());
entity.setContent(authCodeReq.getContent());
......@@ -131,12 +133,15 @@ public class AutoCodeController extends AccountBaseController {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setSourceType(super.getSourceType());
logger.info("authCode/getAuthCode:{}",JSONObject.toJSONString(request));
logger.info("authCode/getAuthCode:{}", JSONObject.toJSONString(request));
AccountUtils.checkMobilePhone(request.getMobile());
if (request.getBizType() != null && request.getBizType().equals(1)) {
logger.info("app-rcValidate-start");
if (Objects.equals(9, request.getFlag())) {
logger.info("input select patient record ");
}
// 调用风控接口
authCodeService.rcValidate(req, request, super.getDeviceInfo(), super.getSourceType());
// 发送短信验证码
......@@ -209,7 +214,7 @@ public class AutoCodeController extends AccountBaseController {
//验证码保存到redis,失效时间10分钟
cacheClient.set(this.getAuthCodeKey(mobilePhone, flag), authCode, 600);
//处理验证码原子性的问题
cacheClient.set(RegisterCodeKeyUtils.getRegisterKey(mobilePhone,authCode), 100, 600);
cacheClient.set(RegisterCodeKeyUtils.getRegisterKey(mobilePhone, authCode), 100, 600);
logger.info(this.getAuthCodeKey(mobilePhone, flag));
//发送短信
super.sendMobileMessage(mobilePhone, message, senderId);
......@@ -285,7 +290,7 @@ public class AutoCodeController extends AccountBaseController {
private void processSendAuthCode(String mobilePhone, Integer flag, String authCodeKeySecure) {
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"processSendAuthCode",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"mobilePhone:"+mobilePhone+",flag:"+flag+",authCodeKeySecure:"+authCodeKeySecure);
intactUtil.sendIntact(batchNo, "processSendAuthCode", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "mobilePhone:" + mobilePhone + ",flag:" + flag + ",authCodeKeySecure:" + authCodeKeySecure);
long start = System.currentTimeMillis();
String authCode = CommonUtil.createValidateCode();
String message = "您的验证码是" + authCode + ",在10分钟内有效。如非本人操作,请忽略本短信!";
......@@ -294,17 +299,17 @@ public class AutoCodeController extends AccountBaseController {
String authCodeKey = getAuthCodeKey(mobilePhone, flag.toString());
boolean set = cacheClient.set(authCodeKey, authCode, 600);
logger.info(cacheClient.get(authCodeKey));
logger.info("验证码缓存是否成功----->:"+set);
logger.info("验证码缓存信息----->:"+authCodeKey);
logger.info("验证码缓存是否成功----->:" + set);
logger.info("验证码缓存信息----->:" + authCodeKey);
cacheClient.set(authCodeKeySecure, System.currentTimeMillis(), 60);
//处理验证码原子性的问题
cacheClient.set(RegisterCodeKeyUtils.getRegisterKey(mobilePhone,authCode), 100, 600);
cacheClient.set(RegisterCodeKeyUtils.getRegisterKey(mobilePhone, authCode), 100, 600);
long end1 = System.currentTimeMillis();
logger.info("processSendAuthCode-1 used {} million seconds", end1-start);
logger.info("processSendAuthCode-1 used {} million seconds", end1 - start);
super.sendMobileMessage(mobilePhone, message, senderId);
long end2 = System.currentTimeMillis();
logger.info("processSendAuthCode-2 used {} million seconds", end2-start);
intactUtil.sendIntact(batchNo,"processSendAuthCode",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"mobilePhone:"+mobilePhone+",flag:"+flag+",authCodeKeySecure:"+authCodeKeySecure);
logger.info("processSendAuthCode-2 used {} million seconds", end2 - start);
intactUtil.sendIntact(batchNo, "processSendAuthCode", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "mobilePhone:" + mobilePhone + ",flag:" + flag + ",authCodeKeySecure:" + authCodeKeySecure);
}
......@@ -322,11 +327,10 @@ public class AutoCodeController extends AccountBaseController {
@ApiOperation("微信获取验证码")
@PostMapping(value = "/authCode/get")
public PicaResponse getAuthCode(){
public PicaResponse getAuthCode() {
String cacheCode = cacheClient.get("authCode-j1VrU5MSc1uuZaEa82ZKfQ==");
return PicaResponse.toResponse(cacheCode);
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册