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

saas平台修改

上级 17a1b41d
流水线 #42851 已失败 于阶段
...@@ -42,8 +42,8 @@ public class HospitalSaasRoleController extends AccountBaseController { ...@@ -42,8 +42,8 @@ public class HospitalSaasRoleController extends AccountBaseController {
@ApiOperation("机构saas平台角色列表") @ApiOperation("机构saas平台角色列表")
@PostMapping(value = "/hospital/role/listByPage") @PostMapping(value = "/hospital/role/listByPage")
@EnabledLoginValidate @EnabledLoginValidate
public PicaResponse<HospitalRoleResp> ListByPage(@RequestBody HospitalRoleListReq req) { public PicaResponse<HospitalRoleResp> listByPage(@RequestBody HospitalRoleListReq req) {
HospitalRoleResp hospitalRoleResp = hospitalSaasRoleService.ListByPage(req); HospitalRoleResp hospitalRoleResp = hospitalSaasRoleService.listByPage(req);
return PicaResponse.toResponse(hospitalRoleResp); return PicaResponse.toResponse(hospitalRoleResp);
} }
......
...@@ -32,28 +32,28 @@ public class HospitalSaasUserController extends AccountBaseController { ...@@ -32,28 +32,28 @@ public class HospitalSaasUserController extends AccountBaseController {
@ApiOperation("机构saas平台人员注册 0失败 1成功") @ApiOperation("机构saas平台人员注册 0失败 1成功")
@PostMapping(value = "/hospital/register") @PostMapping(value = "/hospital/register")
@EnabledLoginValidate @EnabledLoginValidate
public PicaResponse<Integer> Register(@Validated @RequestBody HospitalSaasUserReq req) { public PicaResponse<Integer> register(@RequestBody HospitalSaasUserReq req) {
return PicaResponse.toResponse(hospitalSaasUserService.register(req, super.getProductType(), super.getSourceType(), getPicaUser())); return PicaResponse.toResponse(hospitalSaasUserService.register(req, super.getProductType(), super.getSourceType(), getPicaUser()));
} }
@ApiOperation("机构saas平台人员更新 0失败 1成功") @ApiOperation("机构saas平台人员更新 0失败 1成功")
@PostMapping(value = "/hospital/upsert") @PostMapping(value = "/hospital/upsert")
@EnabledLoginValidate @EnabledLoginValidate
public PicaResponse<Integer> Upsert(@RequestBody HospitalSaasUserReq req) { public PicaResponse<Integer> upsert(@RequestBody HospitalSaasUserReq req) {
return PicaResponse.toResponse(hospitalSaasUserService.upsert(req, getPicaUser())); return PicaResponse.toResponse(hospitalSaasUserService.upsert(req, getPicaUser()));
} }
@ApiOperation("机构saas平台人员列表查询") @ApiOperation("机构saas平台人员列表查询")
@GetMapping(value = "/hospital/list") @GetMapping(value = "/hospital/list")
@EnabledLoginValidate @EnabledLoginValidate
public PicaResponse<HospitalSaasUserResp> List(@RequestBody HospitalSaasUserListReq req) { public PicaResponse<HospitalSaasUserResp> list(@RequestBody HospitalSaasUserListReq req) {
return PicaResponse.toResponse(hospitalSaasUserService.listByPage(req)); return PicaResponse.toResponse(hospitalSaasUserService.listByPage(req));
} }
@ApiOperation("机构saas平台人员删除 0失败 1成功") @ApiOperation("机构saas平台人员删除 0失败 1成功")
@DeleteMapping(value = "/hospital/delete") @DeleteMapping(value = "/hospital/delete")
@EnabledLoginValidate @EnabledLoginValidate
public PicaResponse<Integer> Delete(@RequestParam("id") Long id) { public PicaResponse<Integer> delete(@RequestParam("id") Long id) {
return PicaResponse.toResponse(hospitalSaasUserService.delete(id)); return PicaResponse.toResponse(hospitalSaasUserService.delete(id));
} }
...@@ -67,7 +67,7 @@ public class HospitalSaasUserController extends AccountBaseController { ...@@ -67,7 +67,7 @@ public class HospitalSaasUserController extends AccountBaseController {
@ApiOperation("机构saas平台人员-角色列表") @ApiOperation("机构saas平台人员-角色列表")
@GetMapping(value = "/hospital/role/listByPage") @GetMapping(value = "/hospital/role/listByPage")
@EnabledLoginValidate @EnabledLoginValidate
public PicaResponse<HospitalRoleResp> ListByPage() { public PicaResponse<HospitalRoleResp> listByPage() {
return PicaResponse.toResponse(hospitalSaasRoleService.querySaasRoles()); return PicaResponse.toResponse(hospitalSaasRoleService.querySaasRoles());
} }
......
...@@ -22,9 +22,9 @@ public interface PermissionRoleMapper { ...@@ -22,9 +22,9 @@ public interface PermissionRoleMapper {
int updateByPrimaryKey(PermissionRole record); int updateByPrimaryKey(PermissionRole record);
List<HospitalRoleDto> ListByPage(Map<String, Object> map); List<HospitalRoleDto> listByPage(Map<String, Object> map);
int ListCountByPage(Map<String, Object> map); int listCountByPage(Map<String, Object> map);
int deleteById(Long id); int deleteById(Long id);
......
// Copyright 2016-2101 Pica. // Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.req; package com.pica.cloud.account.account.server.req;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.foundation.entity.PicaWarnException;
import com.pica.cloud.foundation.utils.utils.ValidateUtils;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.NonNull; import lombok.NonNull;
import org.apache.commons.lang.StringUtils;
import org.hibernate.validator.constraints.NotBlank; import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.Max; import javax.validation.constraints.Max;
...@@ -23,26 +27,43 @@ public class HospitalSaasUserReq { ...@@ -23,26 +27,43 @@ public class HospitalSaasUserReq {
private Long id; private Long id;
@ApiModelProperty("姓名") @ApiModelProperty("姓名")
@NotBlank(message = "姓名不能为空!")
@Max(value = 16, message = "长度≤16字符!")
private String name; private String name;
@ApiModelProperty("机构id") @ApiModelProperty("机构id")
private Integer hospitalId; private Integer hospitalId;
@ApiModelProperty("手机号") @ApiModelProperty("手机号")
@NotBlank(message = "手机号不能为空!")
private String mobile; private String mobile;
@ApiModelProperty("密码") @ApiModelProperty("密码")
@NotBlank(message = "密码不能为空!")
private String password; private String password;
@ApiModelProperty("备注") @ApiModelProperty("备注")
private String comment; private String comment;
@ApiModelProperty("角色id") @ApiModelProperty("角色id")
@NotBlank(message = "角色id不能为空!")
private Long roleId; private Long roleId;
private void checkInsertParams() {
if (StringUtils.isBlank(this.mobile)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "手机号不能为空");
}
if (StringUtils.isBlank(this.name)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "姓名不能为空");
}
if (StringUtils.isBlank(this.password)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "密码不能为空");
}
if (null == this.roleId) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "角色id不能为空");
}
if (this.name.length() > 16) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "姓名长度≤16字符!");
}
if (!ValidateUtils.isMobile(this.mobile)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "姓名长度≤16字符!");
}
}
} }
...@@ -15,8 +15,9 @@ import java.util.List; ...@@ -15,8 +15,9 @@ import java.util.List;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
public class HospitalRoleResp { public class HospitalRoleResp {
@ApiModelProperty("查询列表")
private List<HospitalRoleDto> list = new ArrayList(); private List<HospitalRoleDto> list = new ArrayList();
@ApiModelProperty("总条数") @ApiModelProperty("总条数")
private Integer totalCount = 0; private Integer totalCount = 0;
......
...@@ -18,7 +18,7 @@ public interface HospitalSaasRoleService { ...@@ -18,7 +18,7 @@ public interface HospitalSaasRoleService {
int insertAndModify(HospitalRoleDetailReq req, PicaUser user); int insertAndModify(HospitalRoleDetailReq req, PicaUser user);
HospitalRoleResp ListByPage(HospitalRoleListReq req); HospitalRoleResp listByPage(HospitalRoleListReq req);
int delete(Long id); int delete(Long id);
......
...@@ -53,7 +53,7 @@ public class HospitalSaasRoleServiceImpl implements HospitalSaasRoleService { ...@@ -53,7 +53,7 @@ public class HospitalSaasRoleServiceImpl implements HospitalSaasRoleService {
if (null != byNameCode) { if (null != byNameCode) {
throw new PicaWarnException(AccountExceptionEnum.PAT_ACCT_HAS_EXIST.getCode(), AccountExceptionEnum.PAT_ACCT_HAS_EXIST.getMessage()); throw new PicaWarnException(AccountExceptionEnum.PAT_ACCT_HAS_EXIST.getCode(), AccountExceptionEnum.PAT_ACCT_HAS_EXIST.getMessage());
} }
role.setRoleCode("saas_admin"+ CommonUtil.getRandom(10)); role.setRoleCode("saas_admin" + CommonUtil.getRandom(10));
role.setRemark(req.getDescribe()); role.setRemark(req.getDescribe());
role.setCreatedId(Long.valueOf(user.getId())); role.setCreatedId(Long.valueOf(user.getId()));
role.setCreatedTime(new Date()); role.setCreatedTime(new Date());
...@@ -80,22 +80,22 @@ public class HospitalSaasRoleServiceImpl implements HospitalSaasRoleService { ...@@ -80,22 +80,22 @@ public class HospitalSaasRoleServiceImpl implements HospitalSaasRoleService {
} }
@Override @Override
public HospitalRoleResp ListByPage(HospitalRoleListReq req) { public HospitalRoleResp listByPage(HospitalRoleListReq req) {
ArrayList<Object> list = new ArrayList<>(3); ArrayList<Object> list = new ArrayList<>(3);
list.add(1); list.add(1);
list.add(2); list.add(2);
//todo 过滤当前人员的角色信息 //todo 过滤当前人员的角色信息
//list.add(); //list.add();
Map<String, Object> map = new HashMap(2); Map<String, Object> map = new HashMap(4);
map.put("list", list); map.put("list", list);
map.put("name", req.getName()); map.put("name", req.getName());
int count = permissionRoleMapper.ListCountByPage(map); int count = permissionRoleMapper.listCountByPage(map);
if (count < 1) { if (count < 1) {
return new HospitalRoleResp(Collections.emptyList(), 0); return new HospitalRoleResp(Collections.emptyList(), 0);
} }
map.put("pageNo", (req.getPageNo() - 1) * req.getPageSize()); map.put("pageNo", (req.getPageNo() - 1) * req.getPageSize());
map.put("pageSize", req.getPageSize()); map.put("pageSize", req.getPageSize());
List<HospitalRoleDto> roleDtos = permissionRoleMapper.ListByPage(map); List<HospitalRoleDto> roleDtos = permissionRoleMapper.listByPage(map);
return new HospitalRoleResp(roleDtos, count); return new HospitalRoleResp(roleDtos, count);
} }
...@@ -103,7 +103,7 @@ public class HospitalSaasRoleServiceImpl implements HospitalSaasRoleService { ...@@ -103,7 +103,7 @@ public class HospitalSaasRoleServiceImpl implements HospitalSaasRoleService {
@Transactional @Transactional
public int delete(Long id) { public int delete(Long id) {
permissionRoleMapper.deleteById(id); permissionRoleMapper.deleteById(id);
//把这个角色下的人员信息 调整为默认角色 //把这个角色下的人员信息 调整为默认角色 todo 需写死一个默认角色的id
permissionDoctorRoleMapper.upsertDefaultRole(id); permissionDoctorRoleMapper.upsertDefaultRole(id);
return 1; return 1;
} }
...@@ -118,7 +118,7 @@ public class HospitalSaasRoleServiceImpl implements HospitalSaasRoleService { ...@@ -118,7 +118,7 @@ public class HospitalSaasRoleServiceImpl implements HospitalSaasRoleService {
public HospitalRoleDto getRoleDetail(Long id) { public HospitalRoleDto getRoleDetail(Long id) {
HospitalRoleDto roleDto = new HospitalRoleDto(); HospitalRoleDto roleDto = new HospitalRoleDto();
PermissionRole permissionRole = permissionRoleMapper.selectByPrimaryKey(id); PermissionRole permissionRole = permissionRoleMapper.selectByPrimaryKey(id);
BeanUtils.copyProperties(permissionRole,roleDto); BeanUtils.copyProperties(permissionRole, roleDto);
roleDto.setRoleId(permissionRole.getId()); roleDto.setRoleId(permissionRole.getId());
return roleDto; return roleDto;
} }
......
...@@ -57,7 +57,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService { ...@@ -57,7 +57,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
} }
//得到手机号 //得到手机号
String mobile = req.getMobile(); String mobile = req.getMobile();
//注册接口幂等性处理:注册成功,删除缓存. //幂等校验
String nxKey = Constants.REPEAT_REGISTER_PREFIX + mobile; String nxKey = Constants.REPEAT_REGISTER_PREFIX + mobile;
Long resultNx = redisClient.setnx(nxKey, mobile); Long resultNx = redisClient.setnx(nxKey, mobile);
redisClient.expire(nxKey, 2); redisClient.expire(nxKey, 2);
...@@ -66,7 +66,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService { ...@@ -66,7 +66,7 @@ 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); Account byMobilePhone = accountMapper.getByMobilePhone(mobileEncrypt);
//说明是新用户注册,走注册逻辑,如果已经存在按产品要求走更新逻辑 //新用户 走注册逻辑
if (accountInfoEntity == null) { if (accountInfoEntity == null) {
redisClient.expire(nxKey, 30); redisClient.expire(nxKey, 30);
Date currentTime = Calendar.getInstance().getTime(); Date currentTime = Calendar.getInstance().getTime();
...@@ -88,7 +88,6 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService { ...@@ -88,7 +88,6 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
} else { } else {
//走更新的逻辑,只可以更新角色和备注, 如果需要更新密码 就覆盖老的密码 //走更新的逻辑,只可以更新角色和备注, 如果需要更新密码 就覆盖老的密码
byMobilePhone.setComment(req.getComment()); byMobilePhone.setComment(req.getComment());
//TODO 密码需接入加密的逻辑
byMobilePhone.setPassword(req.getPassword()); byMobilePhone.setPassword(req.getPassword());
accountMapper.updateByIdSelective(byMobilePhone); accountMapper.updateByIdSelective(byMobilePhone);
//更新角色信息 逻辑删除 //更新角色信息 逻辑删除
...@@ -141,7 +140,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService { ...@@ -141,7 +140,7 @@ public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
map.put("name", req.getName()); map.put("name", req.getName());
map.put("mobile", req.getMobile()); map.put("mobile", req.getMobile());
Integer count = accountMapper.listCountByPage(map); Integer count = accountMapper.listCountByPage(map);
if (count <= 1) { if (count < 1) {
return new HospitalSaasUserResp(Collections.emptyList(), 0); return new HospitalSaasUserResp(Collections.emptyList(), 0);
} }
map.put("pageNo", (req.getPageNo() - 1) * req.getPageSize()); map.put("pageNo", (req.getPageNo() - 1) * req.getPageSize());
......
...@@ -150,18 +150,18 @@ ...@@ -150,18 +150,18 @@
) )
</if> </if>
<if test="name != null and name != ''"> <if test="name != null and name != ''">
and pr.role_name like concat('%',trim(#{name,jdbcType=VARCHAR}),'%') and pr.role_name like concat(trim(#{name,jdbcType=VARCHAR}),'%')
</if> </if>
</sql> </sql>
<select id="ListCountByPage" resultType="java.lang.Integer"> <select id="listCountByPage" resultType="java.lang.Integer">
select count(*) select count(*)
from permission_role as pr from permission_role as pr
where pr.delete_flag = 1 where pr.delete_flag = 1
<include refid="list_by_page"></include> <include refid="list_by_page"></include>
</select> </select>
<select id="ListByPage" resultType="com.pica.cloud.account.account.server.resp.HospitalRoleDto"> <select id="listByPage" resultType="com.pica.cloud.account.account.server.resp.HospitalRoleDto">
select select
pr.created_time as createTime, pr.created_time as createTime,
pr.role_name as roleName, pr.role_name as roleName,
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册