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

fix --系统管理员唯一性校验

上级 87bd665f
流水线 #42982 已取消 于阶段
......@@ -42,6 +42,8 @@ public interface AccountMapper {
List<HospitalSaasUserDto> listByPage(Map<String, Object> map);
HospitalSaasUserEditResp selectUserRoleById (Long id);
HospitalSaasUserEditResp selectUserRoleById(Long id);
int adminRoleCountByhospitalId(Long hospitalId);
}
......@@ -60,8 +60,6 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
@Autowired
private PUserRoleMapper pUserRoleMapper;
@Autowired
private AgreementLogEntityMapper agreementLogEntityMapper;
@Autowired
private PermissionDoctorRoleMapper doctorRoleMapper;
@Autowired
private HospitalMapper hospitalMapper;
......@@ -82,6 +80,10 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
@Transactional
public int register(HospitalSaasUserReq req, Long doctorId) {
req.checkInsertParams();
int count = accountMapper.adminRoleCountByhospitalId(req.getHospitalId().longValue());
if (count >= 1 && null != req.getRoleId() && 3 == req.getRoleId()) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "当前已存在系统管理员,请勿重复设置");
}
//得到手机号
String mobile = req.getMobile();
//幂等校验
......@@ -187,7 +189,13 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
String mobileEncrypt = AESUtil.encryptV0(req.getMobile());
Account accountExist = accountMapper.getByMobilePhone(mobileEncrypt);
if (Objects.isNull(req) || null == req.getHospitalId()) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "参数错误");
}
int count = accountMapper.adminRoleCountByhospitalId(req.getHospitalId().longValue());
if (count >= 1 && null != req.getRoleId() && 3 == req.getRoleId()) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "当前已存在系统管理员,请勿重复设置");
}
if (accountExist == null) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "当前用户不存在");
}
......@@ -205,7 +213,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
passwordService.modifyPassword(mobileEncrypt, accountExist.getPassword(), StringUtils.upperCase(MD5Util.MD5(req.getPassword())), true);
}
Map map =new HashMap(3);
Map map = new HashMap(3);
map.put("id", req.getId());
map.put("modifiedId", doctorId);
map.put("modifiedTime", new Date());
......
server.port=13201
server.context-path=/account
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
spring.application.name=${server.port}-pica-cloud-account
#config server settings
spring.cloud.config.name=com.pica.cloud.account
......
......@@ -9,7 +9,7 @@
<!-- <classPathEntry location="/Users/wangyongbo/Downloads/software/mysql-connector-java-5.1.39.jar"/>-->
<!-- <classPathEntry location="D:\programer\reponsitory\maven\mysql\mysql-connector-java\5.1.39\mysql-connector-java-5.1.39.jar"/>-->
<!--<classPathEntry location="E:\mysql_jar/mysql-connector-java-5.1.39.jar"/>-->
<classPathEntry location="C:\\soft\\apache-maven-3.6.1\\resp\\mysql\\mysql-connector-java\\5.1.47\\mysql-connector-java-5.1.47.jar"/>
<classPathEntry location="/Users/zhoupengcheng/mysql_jar/mysql-connector-java-5.1.49.jar"/>
<context id="tableEntity" targetRuntime="MyBatis3">
<commentGenerator>
......@@ -44,7 +44,7 @@
<!-- <table tableName="account_apple_info" domainObjectName="AccountAppleInfo" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
<!-- <table tableName="account_pat_family_record" domainObjectName="AccountPatFamilyRecord" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>-->
<table tableName="cancel_account_log" domainObjectName="CancelAccountLog" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="log_one_chlick_check" domainObjectName="LogOneChlickCheck" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
</generatorConfiguration>
......
......@@ -50,7 +50,8 @@
where id = #{id,jdbcType=INTEGER}
</select>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.Account" useGeneratedKeys="true" keyProperty="id">
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.Account"
useGeneratedKeys="true" keyProperty="id">
insert into p_doctor
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sex != null">
......@@ -404,4 +405,10 @@
where p.id = #{id, jdbcType=INTEGER}
limit 1
</select>
<select id="adminRoleCountByhospitalId" resultType="java.lang.Integer">
select count(*)
from p_doctor as pd join p_user_role_mapping as purm on pd.id = purm.user_id and purm.user_role_id = 3
where pd.hospital_id = #{hospitalId}
</select>
</mapper>
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册