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

fix: 添加用户

上级 7436af87
流水线 #42957 已取消 于阶段
...@@ -88,7 +88,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService { ...@@ -88,7 +88,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
String nxKey = Constants.REPEAT_REGISTER_PREFIX + mobile; String nxKey = Constants.REPEAT_REGISTER_PREFIX + mobile;
Long resultNx = redisClient.setnx(nxKey, mobile); Long resultNx = redisClient.setnx(nxKey, mobile);
if (resultNx == 0) { if (resultNx == 0) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "该角色名称重复"); throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "重复提交");
} }
redisClient.expire(nxKey, 2); redisClient.expire(nxKey, 2);
if (resultNx == 1) { if (resultNx == 1) {
...@@ -97,46 +97,46 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService { ...@@ -97,46 +97,46 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt);
//密码已经存在的处理逻辑 //密码已经存在的处理逻辑
if (Objects.nonNull(accountInfoEntity) && StringUtils.isNotBlank(accountInfoEntity.getPassword())) { if (Objects.nonNull(accountInfoEntity) && StringUtils.isNotBlank(accountInfoEntity.getPassword())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "密码已经存在,不可进行编辑"); throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "用户已存在,且密码已设置,不可进行编辑");
} }
Account byMobilePhone = accountMapper.getByMobilePhone(mobileEncrypt);
//用户不存在的处理逻辑 //用户不存在的处理逻辑
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
redisClient.expire(nxKey, 30);
Date currentTime = Calendar.getInstance().getTime(); Date currentTime = Calendar.getInstance().getTime();
String password = req.getPassword(); String md5Pwd = StringUtils.upperCase(MD5Util.MD5(req.getPassword()));
String md5Pwd = MD5Util.MD5(password);
// account_info
AccountInfoEntity accountInfo = buildAccountInfo(mobileEncrypt, currentTime, req.getProductType(), req.getSourceType(), md5Pwd); AccountInfoEntity accountInfo = buildAccountInfo(mobileEncrypt, currentTime, req.getProductType(), req.getSourceType(), md5Pwd);
accountInfoDetailMapper.insertSelective(accountInfo); accountInfoDetailMapper.insertSelective(accountInfo);
Integer acctId = accountInfo.getId(); Integer acctId = accountInfo.getId();
accountInfoDetailMapper.updateCreateInfo(acctId); accountInfoDetailMapper.updateCreateInfo(acctId);
Account account = buildDoctorMsg(req, mobileEncrypt, currentTime, req.getSourceType(), password, acctId);
// doctor
Account account = buildDoctorMsg(req, mobileEncrypt, currentTime, req.getSourceType(), md5Pwd, acctId);
accountMapper.insertSelective(account); accountMapper.insertSelective(account);
Long userId = account.getId();
processAgreement(userId); insertAppRole(account.getId());
insertAppRole(userId); insertSaasRole(req, account.getId(), account.getId());
insertSaasRole(req, account.getId(), userId);
redisClient.del(nxKey); redisClient.del(nxKey);
return 1; return 1;
} }
//用户存在,但密码不存在的处理逻辑
if (Objects.nonNull(accountInfoEntity) && StringUtils.isBlank(accountInfoEntity.getPassword())) { Account byMobilePhone = accountMapper.getByMobilePhone(mobileEncrypt);
byMobilePhone.setPassword(req.getPassword()); if (!req.getHospitalId().equals(byMobilePhone.getHospitalId())) {
byMobilePhone.setComment(req.getComment()); throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "正在添加的用户非本机构下用户");
accountMapper.updateByIdSelective(byMobilePhone);
if (!Objects.equals(req.getRoleId(), -1)) {
insertSaasRole(req, byMobilePhone.getId(), doctorId);
}
} }
//用户存在,但密码不存在的处理逻辑 Account account = new Account();
if (Objects.nonNull(accountInfoEntity) && StringUtils.isBlank(accountInfoEntity.getPassword())) { account.setId(byMobilePhone.getId());
byMobilePhone.setPassword(req.getPassword()); account.setModifyId(doctorId);
byMobilePhone.setComment(req.getComment()); account.setHospitalId(req.getHospitalId());
byMobilePhone.setHospitalId(req.getHospitalId()); account.setModifyTime(Calendar.getInstance().getTime());
accountMapper.updateByIdSelective(byMobilePhone); if (StringUtils.isNotEmpty(req.getComment())) {
if (!Objects.equals(req.getRoleId(), -1)) { account.setComment(req.getComment());
insertSaasRole(req, byMobilePhone.getId(), doctorId);
} }
accountService.updateAccountById(account);
/** 修改密码 */
if (StringUtils.isNotEmpty(req.getPassword()) && StringUtils.isEmpty(byMobilePhone.getPassword())) {
passwordService.modifyPassword(mobileEncrypt, byMobilePhone.getPassword(), StringUtils.upperCase(MD5Util.MD5(req.getPassword())), true);
} }
} }
return 1; return 1;
...@@ -155,29 +155,6 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService { ...@@ -155,29 +155,6 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
doctorRoleMapper.insert(doctorRole); doctorRoleMapper.insert(doctorRole);
} }
private void processAgreement(Long userId) {
ExecutorService executor = ExecutorServiceUtils.getExecutor();
executor.submit(() -> {
Integer protocolId = agreementLogEntityMapper.getLatestProtocolId(2); //获取最新用户协议ID
PProtocolLog log = new PProtocolLog();
log.setUserId(userId.toString());
log.setProtocolId(protocolId);
log.setUserType(2);
log.setType(2);
log.setStatus((short) 1);
log.setCreatedId(userId.intValue());
log.setModifiedId(userId.intValue());
agreementLogEntityMapper.insertProtocolLog(log);
agreementLogEntityMapper.updateSignNum(protocolId); //更新用户协议签署数量
protocolId = agreementLogEntityMapper.getLatestProtocolId(3); //获取最新隐私协议ID
log.setProtocolId(protocolId);
log.setType(3);
agreementLogEntityMapper.insertProtocolLog(log);
agreementLogEntityMapper.updateSignNum(protocolId); //更新隐私协议签署数量
});
}
@Override @Override
public HospitalSaasUserResp listByPage(HospitalSaasUserListReq req) { public HospitalSaasUserResp listByPage(HospitalSaasUserListReq req) {
String mobileEncrypt = AESUtil.encryptV0(req.getMobile()); String mobileEncrypt = AESUtil.encryptV0(req.getMobile());
...@@ -306,11 +283,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService { ...@@ -306,11 +283,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
String phone = EncryptUtils.decryptContent(resp.getMobile(), EncryptConstants.ENCRYPT_TYPE_MOBILE, EncryptConstants.ENCRYPT_DECRYPT_KEY); String phone = EncryptUtils.decryptContent(resp.getMobile(), EncryptConstants.ENCRYPT_TYPE_MOBILE, EncryptConstants.ENCRYPT_DECRYPT_KEY);
resp.setMobile(phone); resp.setMobile(phone);
} }
if (StringUtils.isNotBlank(resp.getPassword())) {
resp.setPwdFlag(1);
} else {
resp.setPwdFlag(2); resp.setPwdFlag(2);
}
return resp; return resp;
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册