提交 2c3c33be 编写于 作者: wenhao.qin's avatar wenhao.qin

saas系统人员+角色后台信息维护(初次提交,不完善)

上级 5f975051
流水线 #42784 已取消 于阶段
......@@ -58,6 +58,12 @@
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
<version>1.18.4</version>
</dependency>
<!--pica dependencies begin-->
<dependency>
......@@ -89,14 +95,14 @@
</exclusions>
</dependency>
<!--<dependency>-->
<!--<groupId>io.springfox</groupId>-->
<!--<artifactId>springfox-swagger2</artifactId>-->
<!--<version>2.8.0</version>-->
<!--<groupId>io.springfox</groupId>-->
<!--<artifactId>springfox-swagger2</artifactId>-->
<!--<version>2.8.0</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>io.springfox</groupId>-->
<!--<artifactId>springfox-swagger-ui</artifactId>-->
<!--<version>2.8.0</version>-->
<!--<groupId>io.springfox</groupId>-->
<!--<artifactId>springfox-swagger-ui</artifactId>-->
<!--<version>2.8.0</version>-->
<!--</dependency>-->
<!--<dependency>
......@@ -241,17 +247,17 @@
<version>1.2.73</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.pica.cloud.foundation</groupId>-->
<!-- <artifactId>pica-cloud-redis</artifactId>-->
<!-- <version>1.4.0</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <artifactId>jedis</artifactId>-->
<!-- <groupId>redis.clients</groupId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>com.pica.cloud.foundation</groupId>-->
<!-- <artifactId>pica-cloud-redis</artifactId>-->
<!-- <version>1.4.0</version>-->
<!-- <exclusions>-->
<!-- <exclusion>-->
<!-- <artifactId>jedis</artifactId>-->
<!-- <groupId>redis.clients</groupId>-->
<!-- </exclusion>-->
<!-- </exclusions>-->
<!-- </dependency>-->
<dependency>
<groupId>com.pica.cloud.foundation</groupId>
......@@ -279,14 +285,13 @@
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>nexus</id>
<!-- <url>http://192.168.141.133:8082/repository/maven-public/</url>-->
<!-- <url>http://192.168.141.133:8082/repository/maven-public/</url>-->
<url>http://nexus.picahealth.com:8082/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
......@@ -302,7 +307,7 @@
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<!-- <url>http://192.168.141.133:8082/repository/maven-public/</url>-->
<!-- <url>http://192.168.141.133:8082/repository/maven-public/</url>-->
<url>http://nexus.picahealth.com:8082/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
......
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.req.HospitalRoleDetailReq;
import com.pica.cloud.account.account.server.req.HospitalRoleListReq;
import com.pica.cloud.account.account.server.resp.HospitalRoleResp;
import com.pica.cloud.account.account.server.service.HospitalSaasRoleService;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.service.starter.interceptor.EnabledLoginValidate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @Author qinwh
* @Date 2022/3/1 15:54
*/
@Api(description = "机构saas角色资源")
@RestController("/saas")
public class HospitalSaasRoleController extends AccountBaseController {
@Autowired
HospitalSaasRoleService hospitalSaasRoleService;
@ApiOperation("机构saas角色-新增或更新")
@PostMapping(value = "/hospital/role/insertAndModify")
@EnabledLoginValidate
public PicaResponse<Integer> insertAndModify(HospitalRoleDetailReq req) {
return PicaResponse.toResponse(hospitalSaasRoleService.insertAndModify(req, getPicaUser()));
}
@ApiOperation("机构saas角色-删除")
@DeleteMapping(value = "/hospital/role/delete")
@EnabledLoginValidate
public PicaResponse<Integer> delete(@RequestParam("id") Long id) {
return PicaResponse.toResponse(hospitalSaasRoleService.delete(id));
}
@ApiOperation("机构saas平台角色列表")
@GetMapping(value = "/hospital/role/listByPage")
@EnabledLoginValidate
public PicaResponse<HospitalRoleResp> ListByPage(@RequestBody HospitalRoleListReq req) {
HospitalRoleResp hospitalRoleResp = hospitalSaasRoleService.ListByPage(req);
return PicaResponse.toResponse(hospitalRoleResp);
}
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.controller;
import com.pica.cloud.account.account.server.req.HospitalSaasUserListReq;
import com.pica.cloud.account.account.server.req.HospitalSaasUserReq;
import com.pica.cloud.account.account.server.resp.HospitalRoleResp;
import com.pica.cloud.account.account.server.resp.HospitalSaasUserDetailResp;
import com.pica.cloud.account.account.server.resp.HospitalSaasUserResp;
import com.pica.cloud.account.account.server.service.HospitalSaasRoleService;
import com.pica.cloud.account.account.server.service.HospitalSaasUserService;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.service.starter.interceptor.EnabledLoginValidate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @Author qinwh
* @Date 2022/3/1 14:45
*/
@Api(description = "机构saas人员资源")
@RestController
@RequestMapping("/saas")
public class HospitalSaasUserController extends AccountBaseController {
@Autowired
private HospitalSaasUserService hospitalSaasUserService;
@Autowired
private HospitalSaasRoleService hospitalSaasRoleService;
@ApiOperation("机构saas平台人员注册 0失败 1成功")
@PostMapping(value = "/hospital/register")
@EnabledLoginValidate
public PicaResponse<Integer> Register(@Validated @RequestBody HospitalSaasUserReq req) {
return PicaResponse.toResponse(hospitalSaasUserService.register(req, super.getProductType(), super.getSourceType(), getPicaUser()));
}
@ApiOperation("机构saas平台人员更新 0失败 1成功")
@PostMapping(value = "/hospital/upsert")
@EnabledLoginValidate
public PicaResponse<Integer> Upsert(@RequestBody HospitalSaasUserReq req) {
return PicaResponse.toResponse(hospitalSaasUserService.upsert(req, getPicaUser()));
}
@ApiOperation("机构saas平台人员列表查询")
@GetMapping(value = "/hospital/list")
@EnabledLoginValidate
public PicaResponse<HospitalSaasUserResp> List(@RequestBody HospitalSaasUserListReq req) {
return PicaResponse.toResponse(hospitalSaasUserService.listByPage(req));
}
@ApiOperation("机构saas平台人员删除 0失败 1成功")
@DeleteMapping(value = "/hospital/delete")
@EnabledLoginValidate
public PicaResponse<Integer> Delete(@RequestParam("id") Long id) {
return PicaResponse.toResponse(hospitalSaasUserService.delete(id));
}
@ApiOperation("机构saas平台人员账户")
@GetMapping(value = "/hospital/userDetail")
@EnabledLoginValidate
public PicaResponse<HospitalSaasUserDetailResp> userDetail(@RequestHeader("token") String token) {
return PicaResponse.toResponse(new HospitalSaasUserDetailResp());
}
@ApiOperation("机构saas平台人员-角色列表")
@GetMapping(value = "/hospital/role/listByPage")
@EnabledLoginValidate
public PicaResponse<HospitalRoleResp> ListByPage() {
return PicaResponse.toResponse(hospitalSaasRoleService.querySaasRoles());
}
}
......@@ -6,6 +6,7 @@ import java.util.Date;
/**
* 账号
*
* @author andong
* @create 2019/5/20
*/
......@@ -77,6 +78,16 @@ public class Account {
private Long hospitalId;
private Integer hospitalId;
public Integer getHospitalId() {
return hospitalId;
}
public void setHospitalId(Integer hospitalId) {
this.hospitalId = hospitalId;
}
public String getNativePlace() {
return nativePlace;
}
......
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
import lombok.Builder;
import java.util.Date;
public class PUserRole {
private Integer id;
......
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class PermissionRole {
private Long id;
private String roleCode;
private String roleName;
private Integer deleteFlag;
private Long createdId;
private Date createdTime;
private Long modifiedId;
private Date modifiedTime;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getRoleCode() {
return roleCode;
}
public void setRoleCode(String roleCode) {
this.roleCode = roleCode == null ? null : roleCode.trim();
}
public String getRoleName() {
return roleName;
}
public void setRoleName(String roleName) {
this.roleName = roleName == null ? null : roleName.trim();
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Long getCreatedId() {
return createdId;
}
public void setCreatedId(Long createdId) {
this.createdId = createdId;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public Long getModifiedId() {
return modifiedId;
}
public void setModifiedId(Long modifiedId) {
this.modifiedId = modifiedId;
}
public Date getModifiedTime() {
return modifiedTime;
}
public void setModifiedTime(Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.resp.HospitalSaasUserDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -9,6 +10,7 @@ import java.util.Map;
/**
* 账号Mapper
*
* @author andong
* @create 2019/5/20
*/
......@@ -33,4 +35,8 @@ public interface AccountMapper {
Account getByUnionid(@Param("unionid") String unionid);
List<Map<String, Object>> getHospitalInfoByPage(@Param("id") Long id, @Param("offset") int offset, @Param("size") int size);
Integer listCountByPage( Map<String, Object> map);
List<HospitalSaasUserDto> listByPage(Map<String, Object> map);
}
......@@ -3,6 +3,9 @@ package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.PermissionDoctorRole;
import java.util.List;
public interface PermissionDoctorRoleMapper {
int deleteByPrimaryKey(Long id);
......@@ -22,4 +25,11 @@ public interface PermissionDoctorRoleMapper {
* @return
*/
Integer updatePermissionModifyRecord();
int deleteByDoctorId(Long id);
List<PermissionDoctorRole> selectByRoleId(Long id);
int upsertDefaultRole( Long id);
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.PermissionRole;
import com.pica.cloud.account.account.server.req.HospitalRoleListReq;
import com.pica.cloud.account.account.server.resp.HospitalRoleDto;
import com.pica.cloud.account.account.server.resp.HospitalSaasRoleResp;
import com.pica.cloud.account.account.server.resp.RoleDto;
import java.util.List;
import java.util.Map;
public interface PermissionRoleMapper {
int deleteByPrimaryKey(Long id);
int insert(PermissionRole record);
int insertSelective(PermissionRole record);
PermissionRole selectByPrimaryKey(Long id);
int updateByPrimaryKeySelective(PermissionRole record);
int updateByPrimaryKey(PermissionRole record);
List<HospitalRoleDto> ListByPage(Map<String, Object> map);
int ListCountByPage(Map<String, Object> map);
int deleteById(Long id);
List<RoleDto> querySaasRoles();
}
\ No newline at end of file
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author qinwh
* @Date 2022/3/1 20:27
*/
@Data
@ApiModel
public class HospitalRoleDetailReq {
@ApiModelProperty("角色id")
private Long id;
@ApiModelProperty("角色name")
private String name;
@ApiModelProperty("角色描述")
private String describe;
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author qinwh
* @Date 2022/3/1 19:52
*/
@Data
@ApiModel
public class HospitalRoleListReq {
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("每页显示记录数")
private Integer pageSize;
@ApiModelProperty("页码")
private Integer pageNo;
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author qinwh
* @Date 2022/3/1 16:22
*/
@ApiModel
@Data
public class HospitalSaasUserListReq {
@ApiModelProperty("机构id")
private Integer hospitalId;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("手机号")
private String mobile;
@ApiModelProperty("角色id")
private Integer roleId;
@ApiModelProperty("每页显示记录数")
private Integer pageSize;
@ApiModelProperty("页码")
private Integer pageNo;
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.req;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NonNull;
import org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.Max;
import javax.validation.constraints.Pattern;
/**
* @Author qinwh
* @Date 2022/3/1 10:45
*/
@ApiModel
@Data
public class HospitalSaasUserReq {
@ApiModelProperty("人员id")
private Long id;
@ApiModelProperty("姓名")
@NotBlank(message = "姓名不能为空!")
@Max(value = 16, message = "长度≤16字符!")
private String name;
@ApiModelProperty("机构id")
private Integer hospitalId;
@ApiModelProperty("手机号")
@NotBlank(message = "手机号不能为空!")
private String mobile;
@ApiModelProperty("密码")
@NotBlank(message = "密码不能为空!")
private String password;
@ApiModelProperty("备注")
private String comment;
@ApiModelProperty("角色id")
@NotBlank(message = "角色id不能为空!")
private Long roleId;
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.resp;
import lombok.Data;
/**
* @Author qinwh
* @Date 2022/3/1 19:54
*/
@Data
public class HospitalRoleDto {
private String roleName;
private Long roleId;
private String describe;
private String createId;
private Long createTime;
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.resp;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* @Author qinwh
* @Date 2022/3/1 19:54
*/
@Data
@AllArgsConstructor
public class HospitalRoleResp {
private List<HospitalRoleDto> list = new ArrayList();
@ApiModelProperty("总条数")
private Integer totalCount = 0;
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.resp;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* @Author qinwh
* @Date 2022/3/1 15:26
*/
@Data
@AllArgsConstructor
public class HospitalSaasRoleResp {
@ApiModelProperty("列表数据")
private List<RoleDto> list = new ArrayList<>();
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.resp;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author qinwh
* @Date 2022/3/1 17:43
*/
@Data
public class HospitalSaasUserDetailResp {
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("机构id")
private Long hospitalId;
@ApiModelProperty("机构名称")
private Long hospitalName;
@ApiModelProperty("机构地址")
private Long hospitalAddress;
@ApiModelProperty("手机号")
private String mobile;
@ApiModelProperty("角色id")
private Integer roleId;
@ApiModelProperty("角色名称")
private String roleName;
@ApiModelProperty("验证是否通过(1未认证,2认证中,3认证通过,4认证不通过,5验证码认证,6 重新认证中,7 重新认证失败)")
private Integer status;
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.resp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author qinwh
* @Date 2022/3/1 15:13
*/
@ApiModel
@Data
public class HospitalSaasUserDto {
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("机构id")
private Long hospitalId;
@ApiModelProperty("手机号")
private String mobile;
@ApiModelProperty("备注")
private String comment;
@ApiModelProperty("角色id")
private Integer roleId;
@ApiModelProperty("角色名称")
private String roleName;
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.resp;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* @Author qinwh
* @Date 2022/3/1 15:10
*/
@ApiModel
@Data
@AllArgsConstructor
public class HospitalSaasUserResp {
@ApiModelProperty("列表数据")
private List<HospitalSaasUserDto> list = new ArrayList<>();
@ApiModelProperty("总条数")
private Integer totalCount = 0;
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.resp;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author qinwh
* @Date 2022/3/1 15:30
*/
@Data
public class RoleDto {
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("姓名")
private String name;
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.req.HospitalRoleDetailReq;
import com.pica.cloud.account.account.server.req.HospitalRoleListReq;
import com.pica.cloud.account.account.server.resp.HospitalRoleResp;
import com.pica.cloud.account.account.server.resp.HospitalSaasRoleResp;
import com.pica.cloud.account.account.server.resp.RoleDto;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author qinwh
* @Date 2022/3/1 19:32
*/
public interface HospitalSaasRoleService {
int insertAndModify(HospitalRoleDetailReq req, PicaUser user);
HospitalRoleResp ListByPage(HospitalRoleListReq req);
int delete(Long id);
HospitalSaasRoleResp querySaasRoles();
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.entity.LoginResult;
import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.req.HospitalSaasUserListReq;
import com.pica.cloud.account.account.server.req.HospitalSaasUserReq;
import com.pica.cloud.account.account.server.resp.HospitalSaasUserResp;
import com.pica.cloud.foundation.entity.PicaResponse;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import java.util.List;
/**
* @Author Pica
* @Date 2022/3/1 15:50
*/
public interface HospitalSaasUserService {
int register(HospitalSaasUserReq baseRequest, Integer productType, Integer sourceType, PicaUser user);
HospitalSaasUserResp listByPage(HospitalSaasUserListReq req);
int upsert(HospitalSaasUserReq req, PicaUser user);
int delete(Long id);
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.PermissionDoctorRole;
import com.pica.cloud.account.account.server.entity.PermissionRole;
import com.pica.cloud.account.account.server.mapper.PermissionDoctorRoleMapper;
import com.pica.cloud.account.account.server.mapper.PermissionRoleMapper;
import com.pica.cloud.account.account.server.req.HospitalRoleDetailReq;
import com.pica.cloud.account.account.server.req.HospitalRoleListReq;
import com.pica.cloud.account.account.server.resp.HospitalRoleResp;
import com.pica.cloud.account.account.server.resp.HospitalSaasRoleResp;
import com.pica.cloud.account.account.server.resp.RoleDto;
import com.pica.cloud.account.account.server.service.HospitalSaasRoleService;
import com.pica.cloud.account.account.server.util.captcha.CommonUtils;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
* @Author qinwh
* @Date 2022/3/1 19:33
*/
@Service
public class HospitalSaasRoleServiceImpl implements HospitalSaasRoleService {
@Autowired
PermissionRoleMapper permissionRoleMapper;
@Autowired
PermissionDoctorRoleMapper permissionDoctorRoleMapper;
@Override
public int insertAndModify(HospitalRoleDetailReq req, PicaUser user) {
PermissionRole role = permissionRoleMapper.selectByPrimaryKey(req.getId());
//新增
if (Objects.isNull(role)) {
//新增
role = new PermissionRole();
BeanUtils.copyProperties(req, role);
CommonUtils.setCommonParam(role, user.getId(), Calendar.getInstance().getTime());
permissionRoleMapper.insert(role);
} else {
//更新
// todo roleCode 字段格式定义
role.setRoleName(req.getName());
// todo 描述信息 需新增字段
permissionRoleMapper.updateByPrimaryKeySelective(role);
}
return 1;
}
@Override
public HospitalRoleResp ListByPage(HospitalRoleListReq req) {
ArrayList<Object> list = new ArrayList<>(3);
list.add(1);
list.add(2);
//todo 过滤当前人员的角色信息
//list.add();
Map<String, Object> map = new HashMap(2);
map.put("list", list);
map.put("name", req.getName());
int count = permissionRoleMapper.ListCountByPage(map);
if (count < 1) {
return new HospitalRoleResp(Collections.emptyList(), 0);
}
map.put("pageNo", (req.getPageNo() - 1) * req.getPageSize());
map.put("pageSize", req.getPageSize());
return new HospitalRoleResp(permissionRoleMapper.ListByPage(map), count);
}
@Override
@Transactional
public int delete(Long id) {
permissionRoleMapper.deleteById(id);
//把这个角色下的人员信息 调整为默认角色
permissionDoctorRoleMapper.upsertDefaultRole(id);
return 1;
}
@Override
public HospitalSaasRoleResp querySaasRoles() {
List<RoleDto> roleDtos = permissionRoleMapper.querySaasRoles();
return new HospitalSaasRoleResp(roleDtos);
}
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.service.impl;
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.AccountTypeEnum;
import com.pica.cloud.account.account.server.log.AccountLogEntityUtils;
import com.pica.cloud.account.account.server.log.AccountLogUtils;
import com.pica.cloud.account.account.server.mapper.*;
import com.pica.cloud.account.account.server.req.HospitalSaasUserListReq;
import com.pica.cloud.account.account.server.req.HospitalSaasUserReq;
import com.pica.cloud.account.account.server.resp.HospitalSaasUserResp;
import com.pica.cloud.account.account.server.service.HospitalSaasUserService;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.ExecutorServiceUtils;
import com.pica.cloud.account.account.server.util.captcha.CommonUtils;
import com.pica.cloud.foundation.entity.PicaException;
import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.redis.ICacheClient;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import com.pica.cloud.foundation.utils.utils.ValidateUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.ExecutorService;
/**
* @Author Pica
* @Date 2022/3/1 15:52
*/
@Service
public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
@Autowired
private ICacheClient redisClient;
@Autowired
private AccountInfoDetailMapper accountInfoDetailMapper;
@Autowired
private AccountMapper accountMapper;
@Autowired
private AccountLogUtils picaLogUtils;
@Autowired
private PUserRoleMapper pUserRoleMapper;
@Autowired
private AgreementLogEntityMapper agreementLogEntityMapper;
@Autowired
private PermissionDoctorRoleMapper doctorRoleMapper;
@Override
@Transactional
public int register(HospitalSaasUserReq req, Integer productType, Integer sourceType, PicaUser user) {
if (!ValidateUtils.isMobile(req.getMobile()) || Objects.isNull(productType) || Objects.isNull(sourceType)) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), PicaResultCode.PARAM_IS_INVALID.message());
}
//得到手机号
String mobile = req.getMobile();
//注册接口幂等性处理:注册成功,删除缓存.
String nxKey = Constants.REPEAT_REGISTER_PREFIX + mobile;
Long resultNx = redisClient.setnx(nxKey, mobile);
redisClient.expire(nxKey, 2);
if (resultNx == 1) {
//手机号加密
String mobileEncrypt = AESUtil.encryptV0(mobile);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt);
Account byMobilePhone = accountMapper.getByMobilePhone(mobileEncrypt);
//说明是新用户注册,走注册逻辑,如果已经存在按产品要求走更新逻辑
if (accountInfoEntity == null) {
redisClient.expire(nxKey, 30);
Date currentTime = Calendar.getInstance().getTime();
String password = req.getPassword();
AccountInfoEntity accountInfo = buildAccountInfo(mobileEncrypt, currentTime, productType, sourceType, password);
accountInfoDetailMapper.insertSelective(accountInfo);
Integer acctId = accountInfo.getId();
accountInfoDetailMapper.updateCreateInfo(acctId);
Account account = buildDoctorMsg(req, mobileEncrypt, currentTime, sourceType, password, acctId);
accountMapper.insertSelective(account);
Long userId = account.getId();
LogLoginEntity entity = AccountLogEntityUtils.getLogLoginEntity(acctId, productType, productType, AccountTypeEnum.LOGIN_REGISTER.getCode(), null, AccountTypeEnum.LOGIN_STATUS_SUCCESS.getCode(), AccountTypeEnum.LOG_TYPE_LOGIN.getCode(), null, 1, null);
picaLogUtils.info(entity);
processAgreement(userId);
insertAppRole(userId, req, user);
insertSaasRole(req, user);
redisClient.del(nxKey);
return 1;
} else {
//走更新的逻辑,只可以更新角色和备注, 如果需要更新密码 就覆盖老的密码
byMobilePhone.setComment(req.getComment());
//TODO 密码需接入加密的逻辑
byMobilePhone.setPassword(req.getPassword());
accountMapper.updateByIdSelective(byMobilePhone);
//更新角色信息 逻辑删除
doctorRoleMapper.deleteByDoctorId(req.getId());
//插入新的角色关系
insertSaasRole(req, user);
}
}
return 1;
}
private void insertSaasRole(HospitalSaasUserReq req, PicaUser user) {
PermissionDoctorRole doctorRole = new PermissionDoctorRole();
doctorRole.setDoctorId(req.getId());
doctorRole.setHospitalId(req.getHospitalId().longValue());
doctorRole.setRoleId(req.getRoleId());
doctorRole.setDeleteFlag(1);
doctorRole.setRoleId(req.getRoleId());
CommonUtils.setCommonParam(doctorRole, user.getId(), Calendar.getInstance().getTime());
doctorRoleMapper.insert(doctorRole);
}
private void processAgreement(Long userId) {
ExecutorService executor = ExecutorServiceUtils.getExecutor();
executor.submit(() -> {
Integer protocolId = agreementLogEntityMapper.getLatestProtocolId(2); //获取最新用户协议ID
PProtocolLog log = new PProtocolLog();
log.setUserId(userId.toString());
log.setProtocolId(protocolId);
log.setUserType(2);
log.setType(2);
log.setStatus((short) 1);
log.setCreatedId(userId.intValue());
log.setModifiedId(userId.intValue());
agreementLogEntityMapper.insertProtocolLog(log);
agreementLogEntityMapper.updateSignNum(protocolId); //更新用户协议签署数量
protocolId = agreementLogEntityMapper.getLatestProtocolId(3); //获取最新隐私协议ID
log.setProtocolId(protocolId);
log.setType(3);
agreementLogEntityMapper.insertProtocolLog(log);
agreementLogEntityMapper.updateSignNum(protocolId); //更新隐私协议签署数量
});
}
@Override
public HospitalSaasUserResp listByPage(HospitalSaasUserListReq req) {
Map<String, Object> map = new HashMap<>(5);
map.put("hospitalId", req.getHospitalId());
map.put("name", req.getName());
map.put("mobile", req.getMobile());
Integer count = accountMapper.listCountByPage(map);
if (count <= 1) {
return new HospitalSaasUserResp(Collections.emptyList(), 0);
}
map.put("pageNo", (req.getPageNo() - 1) * req.getPageSize());
map.put("pageSize", req.getPageSize());
return new HospitalSaasUserResp(accountMapper.listByPage(map), count);
}
@Override
public int upsert(HospitalSaasUserReq req, PicaUser user) {
//走更新的逻辑,只可以更新角色和备注
String mobileEncrypt = AESUtil.encryptV0(req.getMobile());
Account account = accountMapper.getByMobilePhone(mobileEncrypt);
String comment = account.getComment();
if (!Objects.equals(comment, req.getComment())) {
account.setComment(req.getComment());
accountMapper.updateByIdSelective(account);
}
//更新角色信息 逻辑删除
doctorRoleMapper.deleteByDoctorId(req.getId());
insertSaasRole(req, user);
return 1;
}
@Override
public int delete(Long id) {
//删除本身信息,删除人员的权限关联信息,删除人员的协议信息
// todo
return 0;
}
//处理app端 用户-角色关系
private void insertAppRole(Long userId, HospitalSaasUserReq req, PicaUser user) {
ExecutorServiceUtils.getExecutor().submit(new Runnable() {
@Override
public void run() {
Date date = new Date();
PUserRole pUserRole = new PUserRole();
pUserRole.setSystemId(5);
pUserRole.setUserRoleId(2);
pUserRole.setUserId(userId.intValue());
pUserRole.setUserType(1);
pUserRole.setStatus(2);
pUserRole.setDeleteFlag(1);
pUserRole.setCreatId(userId.intValue());
pUserRole.setCreatTime(date);
pUserRole.setModifyId(userId.intValue());
pUserRole.setModifyTime(date);
pUserRoleMapper.insertSelective(pUserRole);
pUserRole.setSystemId(1);
pUserRoleMapper.insertSelective(pUserRole);
pUserRole.setSystemId(3);
pUserRoleMapper.insertSelective(pUserRole);
}
});
}
private AccountInfoEntity buildAccountInfo(String mobileEncrypt, Date currentTime, int productType, int sourceType, String password) {
AccountInfoEntity accountInfo = new AccountInfoEntity();
accountInfo.setMobilePhone(mobileEncrypt);
accountInfo.setPassword(password);
accountInfo.setCreatedTime(currentTime);
accountInfo.setCreatedId(0);
accountInfo.setModifiedId(0);
accountInfo.setModifiedTime(currentTime);
accountInfo.setRegTime(currentTime);
accountInfo.setDeleteFlag(1);
accountInfo.setSex(0);
accountInfo.setRegisterProduct(productType);
accountInfo.setRegisterSource(sourceType);
return accountInfo;
}
private Account buildDoctorMsg(HospitalSaasUserReq hospitalSaasUserReq, String mobileEncrypt, Date currentTime, int sourceType, String password, Integer acctId) {
Account account = new Account();
account.setAcctId(acctId);
account.setMobilePhone(mobileEncrypt);
account.setPassword(password);
if (!StringUtils.isBlank(password)) {
account.setEntireFlag(3);
}
account.setName(hospitalSaasUserReq.getName());
account.setComment(hospitalSaasUserReq.getComment());
account.setDeleteFlag(1);
account.setHospitalId(hospitalSaasUserReq.getHospitalId());
account.setCreatId(0L);
account.setModifyId(0L);
account.setCreatTime(currentTime);
account.setModifyTime(currentTime);
account.setFirstLoginTime(currentTime);
account.setLastLoginTime(currentTime);
account.setRegisterSource(sourceType);
// logger.info("register-add-doctor-start");
return account;
}
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.util.captcha;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Date;
/**
* @Author Pica
* @Date 2022/3/1 18:41
*/
public class CommonUtils {
public static <T> void setCommonParam(T o, int doctorId, Date date) {
Class classes = o.getClass();
Method[] methods = classes.getMethods();
if (methods != null) {
for (Method method : methods) {
if (method.getParameterCount() == 1) {
try {
switch (method.getName()) {
case "setDeleteFlag":
if (method.getParameterTypes()[0].getName().contains("Byte")) {
method.invoke(o, new Byte("1"));
} else if (method.getParameterTypes()[0].getName().contains("Integer")) {
method.invoke(o, 1);
}
break;
case "setCreatedId":
method.invoke(o, doctorId);
break;
case "setCreatedTime":
method.invoke(o, date);
break;
case "setModifiedId":
method.invoke(o, doctorId);
break;
case "setModifiedTime":
method.invoke(o, date);
break;
default:
break;
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
}
}
......@@ -2,6 +2,38 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.pica.cloud.account.account.server.mapper.AccountMapper">
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.Account">
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="sex" jdbcType="INTEGER" property="sex"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="mobile_phone" jdbcType="VARCHAR" property="mobilePhone"/>
<result column="acct_id" jdbcType="INTEGER" property="acctId"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="certify_status" jdbcType="INTEGER" property="certifyStatus"/>
<result column="nation" jdbcType="VARCHAR" property="nation"/>
<result column="avatar_image_url" jdbcType="VARCHAR" property="avatarImageUrl"/>
<result column="email" jdbcType="VARCHAR" property="email"/>
<result column="qrcode" jdbcType="VARCHAR" property="qrcode"/>
<result column="nickname" jdbcType="VARCHAR" property="nickname"/>
<result column="personal_sign" jdbcType="VARCHAR" property="personalSign"/>
<result column="delete_flag" jdbcType="INTEGER" property="deleteFlag"/>
<result column="creat_id" jdbcType="INTEGER" property="creatId"/>
<result column="creat_time" jdbcType="TIMESTAMP" property="creatTime"/>
<result column="modify_id" jdbcType="INTEGER" property="modifyId"/>
<result column="modify_time" jdbcType="TIMESTAMP" property="modifyTime"/>
<result column="password" jdbcType="VARCHAR" property="password"/>
<result column="info" jdbcType="VARCHAR" property="info"/>
<result column="entire_flag" jdbcType="INTEGER" property="entireFlag"/>
<result column="reg_time" jdbcType="DATE" property="regTime"/>
<result column="last_login_time" jdbcType="TIMESTAMP" property="lastLoginTime"/>
<result column="unionid" jdbcType="VARCHAR" property="unionid"/>
<result column="register_source" jdbcType="INTEGER" property="registerSource"/>
<result column="comment" jdbcType="VARCHAR" property="comment"/>
<result column="register_type" jdbcType="INTEGER" property="registerType"/>
<result column="first_login_time" jdbcType="TIMESTAMP" property="firstLoginTime"/>
<result column="card" jdbcType="VARCHAR" property="card"/>
<result column="birthday" jdbcType="DATE" property="birthday"/>
</resultMap>
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.Account">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="sex" jdbcType="INTEGER" property="sex" />
......@@ -36,311 +68,351 @@
<result column="hospital_id" jdbcType="INTEGER" property="hospitalId" />
</resultMap>
<sql id="Base_Column_List">
id, sex, name, mobile_phone, status, certify_status, nation, avatar_image_url, email, qrcode, nickname, personal_sign, delete_flag,
<sql id="Base_Column_List">
id, sex, name, mobile_phone, status, certify_status, nation, avatar_image_url, email, qrcode, nickname, personal_sign, delete_flag,
creat_id, creat_time, modify_id, modify_time, password, info, entire_flag, reg_time, last_login_time,
unionid, register_source, comment, register_type, first_login_time, card, birthday
</sql>
unionid, register_source, comment, register_type, first_login_time, card, birthday, hospital_id
</sql>
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from p_doctor
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectById" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from p_doctor
where id = #{id,jdbcType=INTEGER}
</select>
<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">
sex,
</if>
<if test="name != null">
name,
</if>
<if test="mobilePhone != null">
mobile_phone,
</if>
<if test="avatarImageUrl != null">
avatar_image_url,
</if>
<if test="acctId != null">
acct_id,
</if>
<if test="email != null">
email,
</if>
<if test="qrcode != null">
qrcode,
</if>
<if test="nickname != null">
nickname,
</if>
<if test="personalSign != null">
personal_sign,
</if>
<if test="deleteFlag != null">
delete_flag,
</if>
<if test="creatId != null">
creat_id,
</if>
<if test="creatTime != null">
creat_time,
</if>
<if test="modifyId != null">
modify_id,
</if>
<if test="modifyTime != null">
modify_time,
</if>
<if test="password != null">
password,
</if>
<if test="info != null">
info,
</if>
<if test="entireFlag != null">
entire_flag,
</if>
<if test="regTime != null">
reg_time,
</if>
<if test="lastLoginTime != null">
last_login_time,
</if>
<if test="unionid != null">
unionid,
</if>
<if test="registerSource != null">
register_source,
</if>
<if test="comment != null">
comment,
</if>
<if test="registerType != null">
register_type,
</if>
<if test="firstLoginTime != null">
first_login_time,
</if>
<if test="card != null">
card,
</if>
<if test="birthday != null">
birthday,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sex != null">
#{sex,jdbcType=INTEGER},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="mobilePhone != null">
#{mobilePhone,jdbcType=VARCHAR},
</if>
<if test="avatarImageUrl != null">
#{avatarImageUrl,jdbcType=VARCHAR},
</if>
<if test="acctId != null">
#{acctId,jdbcType=INTEGER},
</if>
<if test="email != null">
#{email,jdbcType=VARCHAR},
</if>
<if test="qrcode != null">
#{qrcode,jdbcType=VARCHAR},
</if>
<if test="nickname != null">
#{nickname,jdbcType=VARCHAR},
</if>
<if test="personalSign != null">
#{personalSign,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null">
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="creatId != null">
#{creatId,jdbcType=INTEGER},
</if>
<if test="creatTime != null">
#{creatTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null">
#{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null">
#{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="password != null">
#{password,jdbcType=VARCHAR},
</if>
<if test="info != null">
#{info,jdbcType=VARCHAR},
</if>
<if test="entireFlag != null">
#{entireFlag,jdbcType=INTEGER},
</if>
<if test="regTime != null">
#{regTime,jdbcType=DATE},
</if>
<if test="lastLoginTime != null">
#{lastLoginTime,jdbcType=TIMESTAMP},
</if>
<if test="unionid != null">
#{unionid,jdbcType=VARCHAR},
</if>
<if test="registerSource != null">
#{registerSource,jdbcType=INTEGER},
</if>
<if test="comment != null">
#{comment,jdbcType=VARCHAR},
</if>
<if test="registerType != null">
#{registerType,jdbcType=INTEGER},
</if>
<if test="firstLoginTime != null">
#{firstLoginTime,jdbcType=TIMESTAMP},
</if>
<if test="card != null">
#{card,jdbcType=VARCHAR},
</if>
<if test="birthday != null">
#{birthday,jdbcType=DATE},
</if>
</trim>
</insert>
<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">
sex,
</if>
<if test="name != null">
name,
</if>
<if test="mobilePhone != null">
mobile_phone,
</if>
<if test="avatarImageUrl != null">
avatar_image_url,
</if>
<if test="acctId != null">
acct_id,
</if>
<if test="email != null">
email,
</if>
<if test="qrcode != null">
qrcode,
</if>
<if test="nickname != null">
nickname,
</if>
<if test="personalSign != null">
personal_sign,
</if>
<if test="deleteFlag != null">
delete_flag,
</if>
<if test="creatId != null">
creat_id,
</if>
<if test="creatTime != null">
creat_time,
</if>
<if test="modifyId != null">
modify_id,
</if>
<if test="modifyTime != null">
modify_time,
</if>
<if test="password != null">
password,
</if>
<if test="info != null">
info,
</if>
<if test="entireFlag != null">
entire_flag,
</if>
<if test="regTime != null">
reg_time,
</if>
<if test="lastLoginTime != null">
last_login_time,
</if>
<if test="unionid != null">
unionid,
</if>
<if test="registerSource != null">
register_source,
</if>
<if test="comment != null">
comment,
</if>
<if test="registerType != null">
register_type,
</if>
<if test="firstLoginTime != null">
first_login_time,
</if>
<if test="card != null">
card,
</if>
<if test="birthday != null">
birthday,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sex != null">
#{sex,jdbcType=INTEGER},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="mobilePhone != null">
#{mobilePhone,jdbcType=VARCHAR},
</if>
<if test="avatarImageUrl != null">
#{avatarImageUrl,jdbcType=VARCHAR},
</if>
<if test="acctId != null">
#{acctId,jdbcType=INTEGER},
</if>
<if test="email != null">
#{email,jdbcType=VARCHAR},
</if>
<if test="qrcode != null">
#{qrcode,jdbcType=VARCHAR},
</if>
<if test="nickname != null">
#{nickname,jdbcType=VARCHAR},
</if>
<if test="personalSign != null">
#{personalSign,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null">
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="creatId != null">
#{creatId,jdbcType=INTEGER},
</if>
<if test="creatTime != null">
#{creatTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null">
#{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null">
#{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="password != null">
#{password,jdbcType=VARCHAR},
</if>
<if test="info != null">
#{info,jdbcType=VARCHAR},
</if>
<if test="entireFlag != null">
#{entireFlag,jdbcType=INTEGER},
</if>
<if test="regTime != null">
#{regTime,jdbcType=DATE},
</if>
<if test="lastLoginTime != null">
#{lastLoginTime,jdbcType=TIMESTAMP},
</if>
<if test="unionid != null">
#{unionid,jdbcType=VARCHAR},
</if>
<if test="registerSource != null">
#{registerSource,jdbcType=INTEGER},
</if>
<if test="comment != null">
#{comment,jdbcType=VARCHAR},
</if>
<if test="registerType != null">
#{registerType,jdbcType=INTEGER},
</if>
<if test="firstLoginTime != null">
#{firstLoginTime,jdbcType=TIMESTAMP},
</if>
<if test="card != null">
#{card,jdbcType=VARCHAR},
</if>
<if test="birthday != null">
#{birthday,jdbcType=DATE},
</if>
</trim>
</insert>
<update id="updateByIdSelective" parameterType="com.pica.cloud.account.account.server.entity.Account">
update p_doctor
<set>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="certifyStatus != null">
certify_status = #{certifyStatus,jdbcType=INTEGER},
</if>
<if test="nation != null">
nation = #{nation,jdbcType=VARCHAR},
</if>
<if test="nativePlace != null">
native_place = #{nativePlace,jdbcType=VARCHAR},
</if>
<if test="sex != null">
sex = #{sex,jdbcType=INTEGER},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="mobilePhone != null">
mobile_phone = #{mobilePhone,jdbcType=VARCHAR},
</if>
<if test="avatarImageUrl != null">
avatar_image_url = #{avatarImageUrl,jdbcType=VARCHAR},
</if>
<if test="email != null">
email = #{email,jdbcType=VARCHAR},
</if>
<if test="qrcode != null">
qrcode = #{qrcode,jdbcType=VARCHAR},
</if>
<if test="nickname != null">
nickname = #{nickname,jdbcType=VARCHAR},
</if>
<if test="personalSign != null">
personal_sign = #{personalSign,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null">
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="creatId != null">
creat_id = #{creatId,jdbcType=INTEGER},
</if>
<if test="creatTime != null">
creat_time = #{creatTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null">
modify_id = #{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null">
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="password != null">
password = #{password,jdbcType=VARCHAR},
</if>
<if test="info != null">
info = #{info,jdbcType=VARCHAR},
</if>
<if test="entireFlag != null">
entire_flag = #{entireFlag,jdbcType=INTEGER},
</if>
<if test="regTime != null">
reg_time = #{regTime,jdbcType=DATE},
</if>
<if test="lastLoginTime != null">
last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
</if>
<if test="unionid != null">
unionid = #{unionid,jdbcType=VARCHAR},
</if>
<if test="registerSource != null">
register_source = #{registerSource,jdbcType=INTEGER},
</if>
<if test="comment != null">
comment = #{comment,jdbcType=VARCHAR},
</if>
<if test="registerType != null">
register_type = #{registerType,jdbcType=INTEGER},
</if>
<if test="firstLoginTime != null">
first_login_time = #{firstLoginTime,jdbcType=TIMESTAMP},
</if>
<if test="card != null">
card = #{card,jdbcType=VARCHAR},
</if>
<if test="birthday != null">
birthday = #{birthday,jdbcType=DATE},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByIdSelective" parameterType="com.pica.cloud.account.account.server.entity.Account">
update p_doctor
<set>
<if test="status != null">
status = #{status,jdbcType=INTEGER},
</if>
<if test="certifyStatus != null">
certify_status = #{certifyStatus,jdbcType=INTEGER},
</if>
<if test="nation != null">
nation = #{nation,jdbcType=VARCHAR},
</if>
<if test="nativePlace != null">
native_place = #{nativePlace,jdbcType=VARCHAR},
</if>
<if test="sex != null">
sex = #{sex,jdbcType=INTEGER},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="mobilePhone != null">
mobile_phone = #{mobilePhone,jdbcType=VARCHAR},
</if>
<if test="avatarImageUrl != null">
avatar_image_url = #{avatarImageUrl,jdbcType=VARCHAR},
</if>
<if test="email != null">
email = #{email,jdbcType=VARCHAR},
</if>
<if test="qrcode != null">
qrcode = #{qrcode,jdbcType=VARCHAR},
</if>
<if test="nickname != null">
nickname = #{nickname,jdbcType=VARCHAR},
</if>
<if test="personalSign != null">
personal_sign = #{personalSign,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null">
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="creatId != null">
creat_id = #{creatId,jdbcType=INTEGER},
</if>
<if test="creatTime != null">
creat_time = #{creatTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null">
modify_id = #{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null">
modify_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="password != null">
password = #{password,jdbcType=VARCHAR},
</if>
<if test="info != null">
info = #{info,jdbcType=VARCHAR},
</if>
<if test="entireFlag != null">
entire_flag = #{entireFlag,jdbcType=INTEGER},
</if>
<if test="regTime != null">
reg_time = #{regTime,jdbcType=DATE},
</if>
<if test="lastLoginTime != null">
last_login_time = #{lastLoginTime,jdbcType=TIMESTAMP},
</if>
<if test="unionid != null">
unionid = #{unionid,jdbcType=VARCHAR},
</if>
<if test="registerSource != null">
register_source = #{registerSource,jdbcType=INTEGER},
</if>
<if test="comment != null">
comment = #{comment,jdbcType=VARCHAR},
</if>
<if test="registerType != null">
register_type = #{registerType,jdbcType=INTEGER},
</if>
<if test="firstLoginTime != null">
first_login_time = #{firstLoginTime,jdbcType=TIMESTAMP},
</if>
<if test="card != null">
card = #{card,jdbcType=VARCHAR},
</if>
<if test="birthday != null">
birthday = #{birthday,jdbcType=DATE},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<select id="getByMobilePhone" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from p_doctor
where mobile_phone = #{mobilePhone} and delete_flag = 1 limit 1
</select>
<select id="getByMobilePhone" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from p_doctor
where mobile_phone = #{mobilePhone} and delete_flag = 1 limit 1
</select>
<select id="getByUnionid" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from p_doctor
where unionid = #{unionid} and delete_flag = 1
limit 1
</select>
<select id="getByUnionid" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from p_doctor
where unionid = #{unionid} and delete_flag = 1
limit 1
</select>
<select id="getByCard" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from p_doctor
where card = #{card} and delete_flag = 1
limit 1
</select>
<select id="getByCard" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from p_doctor
where card = #{card} and delete_flag = 1
limit 1
</select>
<select id="getHospitalInfoByPage" resultType="map">
select id, hospital_id, hospital,mobile_phone,name,
status, avatar_image_url, email,
province, province_name,city, city_name, county, county_name,town, town_name,
title,title_id
from p_doctor
where delete_flag = 1
<if test="id != null">
and id = #{id}
</if>
limit #{offset}, #{size}
</select>
<sql id="select_list_page">
p.delete_flag=1 AND p.hospital_id=#{hospitalId}
<if test="mobile != null">
and p.mobile_phone = #{mobile}
</if>
<if test="name != null">
and p.name = #{name}
</if>
</sql>
<select id="listCountByPage" resultType="java.lang.Integer">
select count(*)
from p_doctor as p left join permission_doctor_role as pdr
ON p.id=pdr.doctor_id and p.hospital_id=pdr.hospital_id and pdr.delete_flag=1
left join permission_role as pr ON pdr.role_id = pr.id and pr.delete_flag=1
where
<include refid="select_list_page"></include>
</select>
<select id="listByPage" resultType="com.pica.cloud.account.account.server.resp.HospitalSaasUserDto">
select
p.name as name,
p.hospital_id as hospitalId,
p.mobile_phone as mobile,
p.comment as comment,
pr.id as roleId,
pr.role_name as roleName
from p_doctor as p
left join permission_doctor_role as pdr ON p.id=pdr.doctor_id and p.hospital_id=pdr.hospital_id and
pdr.delete_flag=1
left join permission_role as pr ON pdr.role_id = pr.id and pr.delete_flag=1
where
<include refid="select_list_page"></include>
ORDER BY p.reg_time DESC
limit #{pageNo},#{pageSize}
</select>
<select id="getHospitalInfoByPage" resultType="map">
select id, hospital_id, hospital,mobile_phone,name,
status, avatar_image_url, email,
province, province_name,city, city_name, county, county_name,town, town_name,
title,title_id
from p_doctor
where delete_flag = 1
<if test="id != null">
and id = #{id}
</if>
limit #{offset}, #{size}
</select>
</mapper>
\ No newline at end of file
......@@ -13,38 +13,49 @@
<result column="modified_time" property="modifiedTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, doctor_id, hospital_id, role_id, delete_flag, created_id, created_time, modified_id,
id, doctor_id, hospital_id, role_id, delete_flag, created_id, created_time, modified_id,
modified_time
</sql>
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from permission_doctor_role
where id = #{id,jdbcType=BIGINT}
</select>
<select id="selectByRoleId" resultType="com.pica.cloud.account.account.server.entity.PermissionDoctorRole">
select
<include refid="Base_Column_List"/>
from permission_doctor_role
where role_id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from permission_doctor_role
where id = #{id,jdbcType=BIGINT}
</delete>
delete
from permission_doctor_role
where id = #{id,jdbcType=BIGINT}
</delete>
<!--用户权限记录表的变更-->
<insert id="updatePermissionModifyRecord">
insert into log_permission_doctor_role(`id`, `doctor_id`, `hospital_id`, `role_id`, `delete_flag`, `created_id`,
`created_time`, `modified_id`, `modified_time`)
SELECT * FROM permission_doctor_role where modified_time &gt; DATE_SUB(DATE_FORMAT(NOW(),'%Y-%m-%d
%H:00:00'),INTERVAL 1 hour) and modified_time &lt; DATE_FORMAT(NOW(), '%Y-%m-%d %H:00:00')
`created_time`, `modified_id`, `modified_time`)
SELECT *
FROM permission_doctor_role
where modified_time &gt; DATE_SUB(DATE_FORMAT(NOW(), '%Y-%m-%d
%H:00:00'), INTERVAL 1 hour)
and modified_time &lt; DATE_FORMAT(NOW(), '%Y-%m-%d %H:00:00')
</insert>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.PermissionDoctorRole">
insert into permission_doctor_role (id, doctor_id, hospital_id,
role_id, delete_flag, created_id,
created_time, modified_id, modified_time
)
values (#{id,jdbcType=BIGINT}, #{doctorId,jdbcType=BIGINT}, #{hospitalId,jdbcType=BIGINT},
#{roleId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=INTEGER}, #{createdId,jdbcType=BIGINT},
#{createdTime,jdbcType=TIMESTAMP}, #{modifiedId,jdbcType=BIGINT}, #{modifiedTime,jdbcType=TIMESTAMP}
)
</insert>
insert into permission_doctor_role (id, doctor_id, hospital_id,
role_id, delete_flag, created_id,
created_time, modified_id, modified_time)
values (#{id,jdbcType=BIGINT}, #{doctorId,jdbcType=BIGINT}, #{hospitalId,jdbcType=BIGINT},
#{roleId,jdbcType=BIGINT}, #{deleteFlag,jdbcType=INTEGER}, #{createdId,jdbcType=BIGINT},
#{createdTime,jdbcType=TIMESTAMP}, #{modifiedId,jdbcType=BIGINT}, #{modifiedTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.PermissionDoctorRole">
insert into permission_doctor_role
<trim prefix="(" suffix=")" suffixOverrides=",">
......@@ -138,15 +149,30 @@
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.PermissionDoctorRole">
update permission_doctor_role
set doctor_id = #{doctorId,jdbcType=BIGINT},
hospital_id = #{hospitalId,jdbcType=BIGINT},
role_id = #{roleId,jdbcType=BIGINT},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
created_id = #{createdId,jdbcType=BIGINT},
created_time = #{createdTime,jdbcType=TIMESTAMP},
modified_id = #{modifiedId,jdbcType=BIGINT},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
update permission_doctor_role
set doctor_id = #{doctorId,jdbcType=BIGINT},
hospital_id = #{hospitalId,jdbcType=BIGINT},
role_id = #{roleId,jdbcType=BIGINT},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
created_id = #{createdId,jdbcType=BIGINT},
created_time = #{createdTime,jdbcType=TIMESTAMP},
modified_id = #{modifiedId,jdbcType=BIGINT},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<update id="deleteByDoctorId" parameterType="java.lang.Integer">
update permission_doctor_role
set delete_flag = 2
where doctor_id = #{id,jdbcType=BIGINT}
</update>
<update id="upsertDefaultRole" parameterType="java.lang.Integer">
update permission_doctor_role
set role_id = 2
where role_id = #{id,jdbcType=BIGINT}
and delete_flag = 1
</update>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.pica.cloud.account.account.server.mapper.PermissionRoleMapper">
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.PermissionRole">
<id column="id" property="id" jdbcType="BIGINT"/>
<result column="role_code" property="roleCode" jdbcType="VARCHAR"/>
<result column="role_name" property="roleName" jdbcType="VARCHAR"/>
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER"/>
<result column="created_id" property="createdId" jdbcType="BIGINT"/>
<result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
<result column="modified_id" property="modifiedId" jdbcType="BIGINT"/>
<result column="modified_time" property="modifiedTime" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id, role_code, role_name, delete_flag, created_id, created_time, modified_id, modified_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from permission_role
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete
from permission_role
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.PermissionRole">
insert into permission_role (id, role_code, role_name,
delete_flag, created_id, created_time,
modified_id, modified_time)
values (#{id,jdbcType=BIGINT}, #{roleCode,jdbcType=VARCHAR}, #{roleName,jdbcType=VARCHAR},
#{deleteFlag,jdbcType=INTEGER}, #{createdId,jdbcType=BIGINT}, #{createdTime,jdbcType=TIMESTAMP},
#{modifiedId,jdbcType=BIGINT}, #{modifiedTime,jdbcType=TIMESTAMP})
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.PermissionRole">
insert into permission_role
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="roleCode != null">
role_code,
</if>
<if test="roleName != null">
role_name,
</if>
<if test="deleteFlag != null">
delete_flag,
</if>
<if test="createdId != null">
created_id,
</if>
<if test="createdTime != null">
created_time,
</if>
<if test="modifiedId != null">
modified_id,
</if>
<if test="modifiedTime != null">
modified_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="roleCode != null">
#{roleCode,jdbcType=VARCHAR},
</if>
<if test="roleName != null">
#{roleName,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null">
#{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null">
#{createdId,jdbcType=BIGINT},
</if>
<if test="createdTime != null">
#{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null">
#{modifiedId,jdbcType=BIGINT},
</if>
<if test="modifiedTime != null">
#{modifiedTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective"
parameterType="com.pica.cloud.account.account.server.entity.PermissionRole">
update permission_role
<set>
<if test="roleCode != null">
role_code = #{roleCode,jdbcType=VARCHAR},
</if>
<if test="roleName != null">
role_name = #{roleName,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null">
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="createdId != null">
created_id = #{createdId,jdbcType=BIGINT},
</if>
<if test="createdTime != null">
created_time = #{createdTime,jdbcType=TIMESTAMP},
</if>
<if test="modifiedId != null">
modified_id = #{modifiedId,jdbcType=BIGINT},
</if>
<if test="modifiedTime != null">
modified_time = #{modifiedTime,jdbcType=TIMESTAMP},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.PermissionRole">
update permission_role
set role_code = #{roleCode,jdbcType=VARCHAR},
role_name = #{roleName,jdbcType=VARCHAR},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
created_id = #{createdId,jdbcType=BIGINT},
created_time = #{createdTime,jdbcType=TIMESTAMP},
modified_id = #{modifiedId,jdbcType=BIGINT},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<sql id="list_by_page">
<if test="list!=null and list.size>0">
and pr.id not in (
<foreach collection="list" item="item" separator=","></foreach>
)
</if>
<if test="name != null and name != ''">
and pr.role_name like concat('%',trim(#{name,jdbcType=VARCHAR}),'%')
</if>
</sql>
<select id="ListCountByPage" resultType="java.lang.Integer">
select count(*)
from permission_role as pr
where pr.delete_flag = 1
<include refid="list_by_page"></include>
</select>
<select id="ListByPage" resultType="com.pica.cloud.account.account.server.resp.HospitalRoleDto">
select pr.created_time c
from permission_role as pr
where pr.delete_flag = 1
<include refid="list_by_page"></include>
ORDER BY pr.created_time ASC
Limit #{pageNo},#{pageSize}
</select>
<select id="querySaasRoles" resultType="com.pica.cloud.account.account.server.resp.RoleDto">
select p.id as id, p.role_name as name
from permission_role as p
# todo id暂不确定
where p.id not in (1, 2, 3)
</select>
<update id="deleteById">
update permission_role
set delete_flag = 2
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册