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

Merge branch 'dev-20220318' into 'release'

Dev 20220318

See merge request !97
流水线 #43788 已取消 于阶段
// 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,16 +105,17 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
//手机号加密
String mobileEncrypt = AESUtil.encryptV0(mobile);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt);
//密码已经存在的处理逻辑
if (Objects.nonNull(accountInfoEntity) && StringUtils.isNotBlank(accountInfoEntity.getPassword())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "用户已存在,且密码已设置,不可进行编辑");
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 (accountInfoEntity == null) {
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 +127,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());
}
accountService.updateAccountById(account);
/** 修改密码 */
Integer acctId = byMobilePhone.getAcctId();
if (null == acctId){
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "数据有误");
if (hospitalId.equals(req.getHospitalId())){
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;
......@@ -331,38 +321,40 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
}
@Override
@Transactional
public HospitalSaasUserEditResp edit(Long id) {
HospitalSaasUserEditResp resp = accountMapper.selectUserRoleById(id);
if (null == resp) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "数据有误");
}
List<RoleDto> roleDtos = doctorRoleMapper.selectRoleByUserId(resp.getId());
resp.setRoles(roleDtos);
resp.setRoleIds(roleDtos.stream().map(RoleDto::getId).collect(Collectors.toList()));
if (null == resp) {
return new HospitalSaasUserEditResp();
}
resp.setPwdFlag(2);
if (resp.getAcctId() != null){
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByPrimaryKey(resp.getAcctId());
AccountInfoEntity accountInfo;
if (null == resp.getAcctId() || null == (accountInfo=accountInfoDetailMapper.selectByPrimaryKey(resp.getAcctId()))){
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "数据有误");
}
if (StringUtils.isNotBlank(accountInfo.getPassword())) {
resp.setPwdFlag(1);
resp.setPassword(accountInfo.getPassword());
}
}
//手机号不为空 解密脱敏
if (StringUtils.isNotBlank(resp.getMobile())) {
String phone = EncryptUtils.decryptContent(resp.getMobile(), EncryptConstants.ENCRYPT_TYPE_MOBILE, EncryptConstants.ENCRYPT_DECRYPT_KEY);
resp.setMobile(phone);
return resp;
}
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);
......
......@@ -319,6 +319,9 @@
<if test="birthday != null">
birthday = #{birthday,jdbcType=DATE},
</if>
<if test="acctId != null">
acct_id = #{acctId,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
......@@ -394,6 +397,7 @@
p.hospital_id as hospitalId,
p.mobile_phone as mobile,
p.comment as comment,
p.password as password,
p.acct_id as acctId
from p_doctor as p
where p.id = #{id, jdbcType=INTEGER}
......
......@@ -46,7 +46,7 @@
select
<include refid="Base_Column_List" />
from p_hospital
where id = #{id,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER} and delete_flag = 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from p_hospital
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册