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

fix --all(自测优化)

上级 149e149b
流水线 #43017 已取消 于阶段
......@@ -52,7 +52,7 @@ public class HospitalSaasUserController extends AccountBaseController {
return PicaResponse.toResponse(hospitalSaasUserService.listByPage(req));
}
@ApiOperation("机构saas平台人员详情查询")
@ApiOperation("机构saas平台人员详情更改查询")
@GetMapping(value = "/hospital/edit/{id}")
@EnabledLoginValidate
public PicaResponse<HospitalSaasUserEditResp> edit(@PathVariable("id") Long id) {
......@@ -66,17 +66,17 @@ public class HospitalSaasUserController extends AccountBaseController {
return PicaResponse.toResponse(hospitalSaasUserService.delete(id));
}
@ApiOperation("机构saas平台人员详情")
@ApiOperation("机构saas人员详情")
@GetMapping(value = "/hospital/userDetail")
@EnabledLoginValidate
public PicaResponse<HospitalSaasUserDetailResp> userDetail(@RequestHeader("token") String token) {
return PicaResponse.toResponse(hospitalSaasUserService.userDetail(fetchPicaUser()));
}
@ApiOperation("机构saas平台人员-角色列表")
@ApiOperation("机构saas人员-角色列表")
@GetMapping(value = "/hospital/listByPage")
@EnabledLoginValidate
public PicaResponse<HospitalRoleResp> listByPage() {
public PicaResponse<HospitalRoleResp> roleList() {
return PicaResponse.toResponse(hospitalSaasRoleService.querySaasRoles());
}
......
......@@ -17,9 +17,9 @@ public class HospitalRoleListReq {
private String name;
@ApiModelProperty("每页显示记录数")
private Integer pageSize;
private Integer pageSize = 10;
@ApiModelProperty("页码")
private Integer pageNo;
private Integer pageNo = 1;
}
......@@ -52,6 +52,9 @@ public class HospitalSaasUserReq {
if (StringUtils.isBlank(this.mobile)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "手机号不能为空");
}
if (Objects.isNull(this.hospitalId)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "机构id不能为空");
}
if (StringUtils.isBlank(this.name)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "姓名不能为空");
}
......
......@@ -86,27 +86,20 @@ public class HospitalSaasRoleServiceImpl implements HospitalSaasRoleService {
map.put("pageNo", (req.getPageNo() - 1) * req.getPageSize());
map.put("pageSize", req.getPageSize());
List<HospitalRoleDto> roleDtos = permissionRoleMapper.listByPage(map);
for (HospitalRoleDto roleDto : roleDtos) {
if (Objects.equals(roleDto.getRoleId(), SaasRoleEnum.SAAS_MAIN_ADMIN.getCode())) {
roleDto.setAdminSaasFlag(1);
}
}
return new HospitalRoleResp(roleDtos, count);
}
@Override
@Transactional
public int delete(Long id, PicaUser user) {
if (id == null || id == 0L) {
throw new PicaWarnException(AccountExceptionEnum.PAT_ACCT_HAS_EXIST.getCode(), "请输入角色id");
}
if (id <= SaasRoleEnum.SAAS_DOCTOR.getCode()) {
throw new PicaWarnException(AccountExceptionEnum.PAT_ACCT_HAS_EXIST.getCode(), "该角色无法删除");
}
Map<String, Object> map = new HashMap<>(3);
map.put("id", id);
map.put("modifiedId", user.getId());
......
......@@ -72,10 +72,7 @@ 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(), "当前已存在系统管理员,请勿重复设置");
}
validatorAdminRole(req.getRoleId(), req.getHospitalId().longValue());
//得到手机号
String mobile = req.getMobile();
//幂等校验
......@@ -156,7 +153,6 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
@Override
public HospitalSaasUserResp listByPage(HospitalSaasUserListReq req) {
String mobileEncrypt = AESUtil.encryptV0(req.getMobile());
Map<String, Object> map = new HashMap<>(5);
map.put("hospitalId", req.getHospitalId());
map.put("name", req.getName());
......@@ -165,9 +161,9 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
if (count < 1) {
return new HospitalSaasUserResp(Collections.emptyList(), 0);
}
map.put("pageNo", (req.getPageNo() - 1) * req.getPageSize());
map.put("pageSize", req.getPageSize());
List<HospitalSaasUserDto> lists = accountMapper.listByPage(map);
//手机号 解密脱敏
lists.stream().forEach(t -> {
......@@ -179,22 +175,24 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
}
});
return new HospitalSaasUserResp(lists, count);
}
private void validatorAdminRole(Long roleId, Long hospitalId) {
int count = accountMapper.adminRoleCountByhospitalId(hospitalId);
if (count >= 1 && null != roleId && Objects.equals(roleId, SaasRoleEnum.SAAS_MAIN_ADMIN.getCode())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "当前已存在系统管理员,请勿重复设置");
}
}
@Override
public int upsert(HospitalSaasUserReq req, Long doctorId) {
//走更新的逻辑,只可以更新角色和备注
String mobileEncrypt = AESUtil.encryptV0(req.getMobile());
Account accountExist = accountMapper.getByMobilePhone(mobileEncrypt);
if (Objects.isNull(req) || null == req.getHospitalId()) {
if (Objects.isNull(req) || Objects.isNull(req.getHospitalId())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "参数错误");
}
int count = accountMapper.adminRoleCountByhospitalId(req.getHospitalId().longValue());
if (count >= 1 && null != req.getRoleId() && Objects.equals(req.getRoleId(),SaasRoleEnum.SAAS_MAIN_ADMIN.getCode())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "当前已存在系统管理员,请勿重复设置");
}
validatorAdminRole(req.getRoleId(), req.getHospitalId().longValue());
String mobileEncrypt = AESUtil.encryptV0(req.getMobile());
Account accountExist = accountMapper.getByMobilePhone(mobileEncrypt);
if (accountExist == null) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "当前用户不存在");
}
......@@ -212,7 +210,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
passwordService.modifyPassword(mobileEncrypt, accountExist.getPassword(), StringUtils.upperCase(MD5Util.MD5(req.getPassword())), true);
}
Map map = new HashMap(3);
Map<String, Object> map = new HashMap(3);
map.put("id", req.getId());
map.put("modifiedId", doctorId);
map.put("modifiedTime", new Date());
......@@ -222,6 +220,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
}
@Override
@Deprecated
public int delete(Long id) {
//删除本身信息,删除人员的权限关联信息,删除人员的协议信息
// todo
......@@ -254,16 +253,14 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
return resp;
}
resp.setName(pDoctor.getName());
resp.setMobile(EncryptUtils.decryptContent(pDoctor.getMobilePhone()
, EncryptConstants.ENCRYPT_TYPE_MOBILE, EncryptConstants.ENCRYPT_DECRYPT_KEY));
resp.setMobile(EncryptUtils.decryptContent(pDoctor.getMobilePhone(), EncryptConstants.ENCRYPT_TYPE_MOBILE, EncryptConstants.ENCRYPT_DECRYPT_KEY));
// saas角色获取
Map<String, Long> map = new HashMap<>();
map.put("doctorId", pDoctor.getId());
map.put("hospitalId", pDoctor.getHospitalId().longValue());
List<PermissionRole> roles = permissionRoleMapper.selectByDoctorId(map);
String join = roles.stream().map(t -> t.getRoleName()).collect(Collectors.joining());
resp.setRoleName(join);
String roleName = roles.stream().map(t -> t.getRoleName()).distinct().collect(Collectors.joining());
resp.setRoleName(roleName);
// 获取批发资质
StoreCertifyStatus storeCertifyStatus = null;
try {
......@@ -271,9 +268,8 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
resp.setStatusStr(storeCertifyStatus.getCertifyStatusStr());
resp.setStatus(storeCertifyStatus.getCertifyStatus());
} catch (Exception e) {
logger.error("userDetail storeCertifyServiceClient.statusByDoctorId error {}", e);
logger.error("userDetail storeCertifyServiceClient.statusByDoctorId error: {}==doctorId: {}", e, pDoctor.getId());
}
return resp;
}
......@@ -283,7 +279,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
if (null == resp) {
return new HospitalSaasUserEditResp();
}
//手机号 解密脱敏
//手机号 不为空 解密脱敏
if (StringUtils.isNotBlank(resp.getMobile())) {
String phone = EncryptUtils.decryptContent(resp.getMobile(), EncryptConstants.ENCRYPT_TYPE_MOBILE, EncryptConstants.ENCRYPT_DECRYPT_KEY);
resp.setMobile(phone);
......
......@@ -407,8 +407,10 @@
</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
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}
limit 1
</select>
</mapper>
......@@ -19,7 +19,7 @@
select
<include refid="Base_Column_List"/>
from permission_role
where id = #{id,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT} and delete_flag = 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册