提交 c651cf11 编写于 作者: wenhao.qin's avatar wenhao.qin

代码pull修改

上级 343ec708
流水线 #43754 已取消 于阶段
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.service.impl;
import com.alibaba.fastjson.JSON;
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.*;
import com.pica.cloud.account.account.server.enums.SaasRoleEnum;
......@@ -104,6 +105,11 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
//手机号加密
String mobileEncrypt = AESUtil.encryptV0(mobile);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt);
Account byMobilePhone = accountMapper.getByMobilePhone(mobileEncrypt);
if ((null == accountInfoEntity && byMobilePhone != null) || (null != accountInfoEntity && byMobilePhone == null)){
logger.error("saas注册,account和doctor存在数据不一致情况, req={}", JSON.toJSONString(req));
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "数据有误,本次提交失败");
}
//密码已经存在的处理逻辑
if (Objects.nonNull(accountInfoEntity) && StringUtils.isNotBlank(accountInfoEntity.getPassword())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "用户已存在,且密码已设置,不可进行编辑");
......@@ -113,7 +119,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
Date currentTime = Calendar.getInstance().getTime();
String md5Pwd = StringUtils.upperCase(MD5Util.MD5(req.getPassword()));
// account_info
AccountInfoEntity accountInfo = buildAccountInfo(mobileEncrypt, currentTime, req.getProductType(), req.getSourceType(), md5Pwd);
AccountInfoEntity accountInfo = buildAccountInfo(mobileEncrypt, currentTime, req.getProductType(), req.getName(),req.getSourceType(), md5Pwd);
accountInfoDetailMapper.insertSelective(accountInfo);
Integer acctId = accountInfo.getId();
accountInfoDetailMapper.updateCreateInfo(acctId);
......@@ -125,31 +131,19 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
redisClient.del(nxKey);
return 1;
}
Account byMobilePhone = accountMapper.getByMobilePhone(mobileEncrypt);
if (!req.getHospitalId().equals(byMobilePhone.getHospitalId())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "正在添加的用户非本机构下用户");
//用户存在的处理逻辑 给出提示信息
Integer hospitalId = byMobilePhone.getHospitalId();
Hospital hospital;
if (null == hospitalId || null == (hospital = hospitalMapper.selectByPrimaryKey(hospitalId))){
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "该手机号已存在,但未加入机构,请至云鹊医App中加入机构");
}
Account account = new Account();
account.setId(byMobilePhone.getId());
account.setModifyId(doctorId);
account.setHospitalId(req.getHospitalId());
account.setHospital(req.getHospitalName());
account.setModifyTime(Calendar.getInstance().getTime());
if (StringUtils.isNotEmpty(req.getComment())) {
account.setComment(req.getComment());
if (hospitalId.equals(req.getHospitalId())){
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "该手机号已存在本机构中");
}
accountService.updateAccountById(account);
/** 修改密码 */
Integer acctId = byMobilePhone.getAcctId();
if (null == acctId){
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "数据有误");
}
if (StringUtils.isNotEmpty(req.getPassword()) && StringUtils.isEmpty(byMobilePhone.getPassword())) {
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByPrimaryKey(acctId);
if (accountInfo == null){
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "当前用户不存在");
}
passwordService.modifyPassword(mobileEncrypt, accountInfo.getPassword(), StringUtils.upperCase(MD5Util.MD5(req.getPassword())), true);
if (!req.getHospitalId().equals(byMobilePhone.getHospitalId())) {
throw new PicaException(
PicaResultCode.PARAM_IS_INVALID.code(),
String.format("该手机号已存在于\"%s\"中,如需修改请至云鹊医App中修改所属机构",hospital.getName()));
}
}
return 1;
......@@ -356,13 +350,14 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
return resp;
}
private AccountInfoEntity buildAccountInfo(String mobileEncrypt, Date currentTime, int productType, int sourceType, String password) {
private AccountInfoEntity buildAccountInfo(String mobileEncrypt, Date currentTime, int productType,String name, int sourceType, String password) {
AccountInfoEntity accountInfo = new AccountInfoEntity();
accountInfo.setMobilePhone(mobileEncrypt);
accountInfo.setPassword(password);
accountInfo.setCreatedTime(currentTime);
accountInfo.setCreatedId(0);
accountInfo.setModifiedId(0);
accountInfo.setName(name);
accountInfo.setModifiedTime(currentTime);
accountInfo.setRegTime(currentTime);
accountInfo.setDeleteFlag(1);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册