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

fix: 添加用户

上级 7436af87
流水线 #42957 已取消 于阶段
......@@ -88,7 +88,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
String nxKey = Constants.REPEAT_REGISTER_PREFIX + mobile;
Long resultNx = redisClient.setnx(nxKey, mobile);
if (resultNx == 0) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "该角色名称重复");
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "重复提交");
}
redisClient.expire(nxKey, 2);
if (resultNx == 1) {
......@@ -97,46 +97,46 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt);
//密码已经存在的处理逻辑
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) {
redisClient.expire(nxKey, 30);
Date currentTime = Calendar.getInstance().getTime();
String password = req.getPassword();
String md5Pwd = MD5Util.MD5(password);
String md5Pwd = StringUtils.upperCase(MD5Util.MD5(req.getPassword()));
// account_info
AccountInfoEntity accountInfo = buildAccountInfo(mobileEncrypt, currentTime, req.getProductType(), req.getSourceType(), md5Pwd);
accountInfoDetailMapper.insertSelective(accountInfo);
Integer acctId = accountInfo.getId();
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);
Long userId = account.getId();
processAgreement(userId);
insertAppRole(userId);
insertSaasRole(req, account.getId(), userId);
insertAppRole(account.getId());
insertSaasRole(req, account.getId(), account.getId());
redisClient.del(nxKey);
return 1;
}
//用户存在,但密码不存在的处理逻辑
if (Objects.nonNull(accountInfoEntity) && StringUtils.isBlank(accountInfoEntity.getPassword())) {
byMobilePhone.setPassword(req.getPassword());
byMobilePhone.setComment(req.getComment());
accountMapper.updateByIdSelective(byMobilePhone);
if (!Objects.equals(req.getRoleId(), -1)) {
insertSaasRole(req, byMobilePhone.getId(), doctorId);
}
Account byMobilePhone = accountMapper.getByMobilePhone(mobileEncrypt);
if (!req.getHospitalId().equals(byMobilePhone.getHospitalId())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "正在添加的用户非本机构下用户");
}
Account account = new Account();
account.setId(byMobilePhone.getId());
account.setModifyId(doctorId);
account.setHospitalId(req.getHospitalId());
account.setModifyTime(Calendar.getInstance().getTime());
if (StringUtils.isNotEmpty(req.getComment())) {
account.setComment(req.getComment());
}
//用户存在,但密码不存在的处理逻辑
if (Objects.nonNull(accountInfoEntity) && StringUtils.isBlank(accountInfoEntity.getPassword())) {
byMobilePhone.setPassword(req.getPassword());
byMobilePhone.setComment(req.getComment());
byMobilePhone.setHospitalId(req.getHospitalId());
accountMapper.updateByIdSelective(byMobilePhone);
if (!Objects.equals(req.getRoleId(), -1)) {
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;
......@@ -155,29 +155,6 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
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
public HospitalSaasUserResp listByPage(HospitalSaasUserListReq req) {
String mobileEncrypt = AESUtil.encryptV0(req.getMobile());
......@@ -306,11 +283,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
String phone = EncryptUtils.decryptContent(resp.getMobile(), EncryptConstants.ENCRYPT_TYPE_MOBILE, EncryptConstants.ENCRYPT_DECRYPT_KEY);
resp.setMobile(phone);
}
if (StringUtils.isNotBlank(resp.getPassword())) {
resp.setPwdFlag(1);
} else {
resp.setPwdFlag(2);
}
resp.setPwdFlag(2);
return resp;
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册