提交 3eac68cb 编写于 作者: minghao.wu's avatar minghao.wu

feature: 增加后端静默注册v3接口

上级 8dd03379
......@@ -233,6 +233,44 @@ public class AccountController extends AccountBaseController {
return PicaResponse.toResponse(result);
}
public PicaResponse<LoginResult> registerV3(@RequestBody AccountReq req) {
this.checkMobilePhone(req.getMobilePhone());
//接入新旭事务一致性
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));
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));
switch (deviceType) { //注册来源
case "1":
account.setRegisterSource(CommonConstants.SYSTEM_TYPE_P024_NO_3); //pc
break;
case "2":
account.setRegisterSource(CommonConstants.SYSTEM_TYPE_P024_NO_1); //android
break;
case "3":
account.setRegisterSource(CommonConstants.SYSTEM_TYPE_P024_NO_2); //ios
break;
default:
account.setRegisterSource(AccountTypeEnum.DEVICE_TYPE_H5.getCode()); //H5注册
}
//创建账号
accountService.createAccount(account,null);
//生成token并返回
String newToken = "";
if(deviceType.equals("1")){
newToken = this.generateToken(account, "4"); //pc端注册,目前无法生成新token
}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));
return PicaResponse.toResponse(result);
}
@ApiOperation("H5端验证码登录,无需完善信息")
@PostMapping("/login-register/v1")
// @RepeatForbidden(uniqueKey = "content")
......@@ -422,6 +460,59 @@ public class AccountController extends AccountBaseController {
}
}
@ApiOperation("后端注册,不验证验证码,无需完善信息")
@PostMapping("/login-register/v3")
public PicaResponse<LoginResult> loginRegisterV3(@RequestBody EncryptEntity entity) throws Exception {
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
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));
AccountReq req = new AccountReq();
req.setMobilePhone(request.getMobile());
// 登录或注册,只能使用验证码
req.setPassword(null);
req.setAuthCode(request.getAuthCode());
req.setFlag("0");
req.setUnionid(request.getUnionId());
// 判断账号是否已经存在
Account account = accountService.getByMobilePhone(req.getMobilePhone());
if (account != null) {
// 登录
PicaResponse response = null;
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));
}
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()));
return PicaResponse.toResponse(result);
}
return response;
} else {
// 注册
PicaResponse<LoginResult> result = null;
try {
result = this.registerV3(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));
}
throw e;
}
intactUtil.sendIntact(batchNo,"h5-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(){
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册