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

Merge branch 'dev-20220318' into 'release'

Dev 20220318

See merge request !97
流水线 #43788 已取消 于阶段
// Copyright 2016-2101 Pica. // Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.service.impl; 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.constants.Constants;
import com.pica.cloud.account.account.server.entity.*; import com.pica.cloud.account.account.server.entity.*;
import com.pica.cloud.account.account.server.enums.SaasRoleEnum; import com.pica.cloud.account.account.server.enums.SaasRoleEnum;
...@@ -104,16 +105,17 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService { ...@@ -104,16 +105,17 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
//手机号加密 //手机号加密
String mobileEncrypt = AESUtil.encryptV0(mobile); String mobileEncrypt = AESUtil.encryptV0(mobile);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt); AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt);
//密码已经存在的处理逻辑 Account byMobilePhone = accountMapper.getByMobilePhone(mobileEncrypt);
if (Objects.nonNull(accountInfoEntity) && StringUtils.isNotBlank(accountInfoEntity.getPassword())) { if ((null == accountInfoEntity && byMobilePhone != null) || (null != accountInfoEntity && byMobilePhone == null)){
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "用户已存在,且密码已设置,不可进行编辑"); logger.error("saas注册,account和doctor存在数据不一致情况, req={}", JSON.toJSONString(req));
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "数据有误,本次提交失败");
} }
//用户不存在的处理逻辑 //用户不存在的处理逻辑
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
Date currentTime = Calendar.getInstance().getTime(); Date currentTime = Calendar.getInstance().getTime();
String md5Pwd = StringUtils.upperCase(MD5Util.MD5(req.getPassword())); String md5Pwd = StringUtils.upperCase(MD5Util.MD5(req.getPassword()));
// account_info // 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); accountInfoDetailMapper.insertSelective(accountInfo);
Integer acctId = accountInfo.getId(); Integer acctId = accountInfo.getId();
accountInfoDetailMapper.updateCreateInfo(acctId); accountInfoDetailMapper.updateCreateInfo(acctId);
...@@ -125,31 +127,19 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService { ...@@ -125,31 +127,19 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
redisClient.del(nxKey); redisClient.del(nxKey);
return 1; return 1;
} }
Account byMobilePhone = accountMapper.getByMobilePhone(mobileEncrypt); //用户存在的处理逻辑 给出提示信息
if (!req.getHospitalId().equals(byMobilePhone.getHospitalId())) { Integer hospitalId = byMobilePhone.getHospitalId();
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "正在添加的用户非本机构下用户"); Hospital hospital;
if (null == hospitalId || null == (hospital = hospitalMapper.selectByPrimaryKey(hospitalId))){
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "该手机号已存在,但未加入机构,请至云鹊医App中加入机构");
} }
Account account = new Account(); if (hospitalId.equals(req.getHospitalId())){
account.setId(byMobilePhone.getId()); throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "该手机号已存在本机构中");
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); if (!req.getHospitalId().equals(byMobilePhone.getHospitalId())) {
/** 修改密码 */ throw new PicaException(
Integer acctId = byMobilePhone.getAcctId(); PicaResultCode.PARAM_IS_INVALID.code(),
if (null == acctId){ String.format("该手机号已存在于\"%s\"中,如需修改请至云鹊医App中修改所属机构",hospital.getName()));
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);
} }
} }
return 1; return 1;
...@@ -331,38 +321,40 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService { ...@@ -331,38 +321,40 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
} }
@Override @Override
@Transactional
public HospitalSaasUserEditResp edit(Long id) { public HospitalSaasUserEditResp edit(Long id) {
HospitalSaasUserEditResp resp = accountMapper.selectUserRoleById(id); HospitalSaasUserEditResp resp = accountMapper.selectUserRoleById(id);
if (null == resp) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "数据有误");
}
List<RoleDto> roleDtos = doctorRoleMapper.selectRoleByUserId(resp.getId()); List<RoleDto> roleDtos = doctorRoleMapper.selectRoleByUserId(resp.getId());
resp.setRoles(roleDtos); resp.setRoles(roleDtos);
resp.setRoleIds(roleDtos.stream().map(RoleDto::getId).collect(Collectors.toList())); resp.setRoleIds(roleDtos.stream().map(RoleDto::getId).collect(Collectors.toList()));
if (null == resp) {
return new HospitalSaasUserEditResp();
}
resp.setPwdFlag(2); resp.setPwdFlag(2);
if (resp.getAcctId() != null){ AccountInfoEntity accountInfo;
AccountInfoEntity accountInfo = accountInfoDetailMapper.selectByPrimaryKey(resp.getAcctId()); if (null == resp.getAcctId() || null == (accountInfo=accountInfoDetailMapper.selectByPrimaryKey(resp.getAcctId()))){
if (StringUtils.isNotBlank(accountInfo.getPassword())) { throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "数据有误");
resp.setPwdFlag(1); }
resp.setPassword(accountInfo.getPassword()); if (StringUtils.isNotBlank(accountInfo.getPassword())) {
} resp.setPwdFlag(1);
resp.setPassword(accountInfo.getPassword());
} }
//手机号不为空 解密脱敏 //手机号不为空 解密脱敏
if (StringUtils.isNotBlank(resp.getMobile())) { if (StringUtils.isNotBlank(resp.getMobile())) {
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);
return resp;
} }
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(); AccountInfoEntity accountInfo = new AccountInfoEntity();
accountInfo.setMobilePhone(mobileEncrypt); accountInfo.setMobilePhone(mobileEncrypt);
accountInfo.setPassword(password); accountInfo.setPassword(password);
accountInfo.setCreatedTime(currentTime); accountInfo.setCreatedTime(currentTime);
accountInfo.setCreatedId(0); accountInfo.setCreatedId(0);
accountInfo.setModifiedId(0); accountInfo.setModifiedId(0);
accountInfo.setName(name);
accountInfo.setModifiedTime(currentTime); accountInfo.setModifiedTime(currentTime);
accountInfo.setRegTime(currentTime); accountInfo.setRegTime(currentTime);
accountInfo.setDeleteFlag(1); accountInfo.setDeleteFlag(1);
......
...@@ -319,6 +319,9 @@ ...@@ -319,6 +319,9 @@
<if test="birthday != null"> <if test="birthday != null">
birthday = #{birthday,jdbcType=DATE}, birthday = #{birthday,jdbcType=DATE},
</if> </if>
<if test="acctId != null">
acct_id = #{acctId,jdbcType=INTEGER},
</if>
</set> </set>
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
...@@ -394,6 +397,7 @@ ...@@ -394,6 +397,7 @@
p.hospital_id as hospitalId, p.hospital_id as hospitalId,
p.mobile_phone as mobile, p.mobile_phone as mobile,
p.comment as comment, p.comment as comment,
p.password as password,
p.acct_id as acctId p.acct_id as acctId
from p_doctor as p from p_doctor as p
where p.id = #{id, jdbcType=INTEGER} where p.id = #{id, jdbcType=INTEGER}
......
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
select select
<include refid="Base_Column_List" /> <include refid="Base_Column_List" />
from p_hospital from p_hospital
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER} and delete_flag = 1
</select> </select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from p_hospital delete from p_hospital
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册