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

Merge branch 'dev_SaaS20220301' into 'release'

Dev saa s20220301

See merge request !92
流水线 #43217 已失败 于阶段
......@@ -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>
......@@ -99,14 +105,14 @@
<version>1.3.6</version>
</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>
......@@ -195,6 +201,11 @@
<artifactId>xxl-job-core</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.pica.cloud.trade</groupId>
<artifactId>pica-cloud-store-client</artifactId>
<version>1.4.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
......@@ -256,17 +267,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>
......@@ -294,14 +305,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>
......@@ -317,7 +327,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>
......
......@@ -38,9 +38,6 @@ import java.util.*;
public abstract class AccountBaseController extends BaseController {
private static final String KEY_PREFIX = "token-doctor-";
private Logger logger = LoggerFactory.getLogger(AccountBaseController.class);
@Autowired
......@@ -118,7 +115,7 @@ public abstract class AccountBaseController extends BaseController {
public void sendMobileMessage(String mobile, String content, long senderId) {
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo,"sendMobileMessage",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1,"mobile:"+mobile+",content:"+content+",senderId:"+senderId);
intactUtil.sendIntact(batchNo, "sendMobileMessage", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "mobile:" + mobile + ",content:" + content + ",senderId:" + senderId);
String sysCodeStr = super.getSysCode();
int sysCode = 10; //默认移动端
if (StringUtils.isNotBlank(sysCodeStr)) {
......@@ -151,13 +148,13 @@ public abstract class AccountBaseController extends BaseController {
picapSendMsgModel.setSysName(SysCode.APP.sysName());
String postData = JSON.toJSONString(picapSendMsgModel);
logger.info("sendMobileTo-mobile:{}, senderId-{}",mobile, senderId);
logger.info("sendMobileTo-mobile:{}, senderId-{}", mobile, senderId);
long start = System.currentTimeMillis();
String jsonObj = HttpClientUtil.httpExecute(messageUrl, postData);
intactUtil.sendIntact(batchNo,"sendMobileMessage",com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3,"jsonObj:"+jsonObj);
intactUtil.sendIntact(batchNo, "sendMobileMessage", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "jsonObj:" + jsonObj);
long end1 = System.currentTimeMillis();
logger.info("sendMobileMessage-send message used {} million seconds", end1-start);
logger.info("sendMobileMessage-send message used {} million seconds", end1 - start);
logger.info("sendMobileTo-{}", jsonObj);
if (StringUtils.isEmpty(jsonObj)) {
......@@ -167,7 +164,7 @@ public abstract class AccountBaseController extends BaseController {
}
try {
PicaResponse resp = JSON.parseObject(jsonObj, PicaResponse.class);
if(Objects.nonNull(resp) && PicaResultCode.SUCCESS.code().equals(resp.getCode())){
if (Objects.nonNull(resp) && PicaResultCode.SUCCESS.code().equals(resp.getCode())) {
logger.info("send message success, the result is: {}", jsonObj);
} else {
logger.error("send message fail, response code not equals success code");
......@@ -214,7 +211,7 @@ public abstract class AccountBaseController extends BaseController {
}
/**
* 产品线类型:productType: 1.云鹊医(默认值) 2云鹊健康
* 产品线类型:productType: 1.云鹊医(默认值) 2云鹊健康 3 saas
*
* @return
*/
......@@ -229,7 +226,7 @@ public abstract class AccountBaseController extends BaseController {
/**
* 终端来源 sourceType:1.android 2.ios 3.web
* 4.wechat(例如微信小程序)、H5 5.admin
* 4.wechat(例如微信小程序)、H5 5.admin 6. saas
*
* @return
*/
......
......@@ -3,10 +3,7 @@ package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.constants.Constants;
import com.pica.cloud.account.account.server.entity.Account;
import com.pica.cloud.account.account.server.entity.Doctor;
import com.pica.cloud.account.account.server.entity.EncryptEntity;
import com.pica.cloud.account.account.server.entity.LoginResult;
import com.pica.cloud.account.account.server.entity.*;
import com.pica.cloud.account.account.server.enums.AccountTypeEnum;
import com.pica.cloud.account.account.server.req.AccountReq;
import com.pica.cloud.account.account.server.req.BaseRequest;
......
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSON;
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.HospitalRoleDetailDto;
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 com.pica.cloud.foundation.utils.entity.PicaUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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
@RequestMapping("/hospital")
public class HospitalSaasRoleController extends AccountBaseController {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
HospitalSaasRoleService hospitalSaasRoleService;
@ApiOperation("机构saas角色-新增或更新")
@PostMapping(value = "/role/insertAndModify")
@EnabledLoginValidate
public PicaResponse<Integer> insertAndModify(@RequestBody HospitalRoleDetailReq req) {
logger.info("insertAndModify:url:/hospital/role/insertAndModify.start:{}",JSON.toJSONString(req));
PicaUser user = fetchPicaUser();
return PicaResponse.toResponse(hospitalSaasRoleService.insertAndModify(req, user));
}
@ApiOperation("机构saas角色-删除")
@DeleteMapping(value = "/role/delete/{id}")
@EnabledLoginValidate
public PicaResponse<Integer> delete(@PathVariable("id") Long id) {
logger.info("delete: url:/hospital//role/delete/id.start:id={}",id);
PicaUser user = fetchPicaUser();
return PicaResponse.toResponse(hospitalSaasRoleService.delete(id, user));
}
@ApiOperation("机构saas平台角色列表")
@PostMapping(value = "/role/listByPage")
@EnabledLoginValidate
public PicaResponse<HospitalRoleResp> listByPage(@RequestBody HospitalRoleListReq req) {
logger.info("listByPage: url:/hospital/role/listByPage.start:{}",JSON.toJSONString(req));
HospitalRoleResp hospitalRoleResp = hospitalSaasRoleService.listByPage(req);
return PicaResponse.toResponse(hospitalRoleResp);
}
@ApiOperation("机构saas角色-角色详情")
@GetMapping(value = "/role/getRoleDetail/{id}")
@EnabledLoginValidate
public PicaResponse<HospitalRoleDetailDto> getRoleDetail(@PathVariable("id") Long id) {
logger.info("getRoleDetail: url:/hospital/role/getRoleDetail/id.start:id={}",id);
return PicaResponse.toResponse(hospitalSaasRoleService.getRoleDetail(id));
}
}
\ No newline at end of file
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.controller;
import com.alibaba.fastjson.JSON;
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.HospitalSaasUserEditResp;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
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 {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private HospitalSaasUserService hospitalSaasUserService;
@Autowired
private HospitalSaasRoleService hospitalSaasRoleService;
@ApiOperation("机构saas平台人员注册 0失败 1成功")
@PostMapping(value = "/hospital/register")
@EnabledLoginValidate
public PicaResponse<Integer> register(@RequestBody HospitalSaasUserReq req, @RequestHeader("token") String token) {
logger.info("register: url:/saas/hospital/register. start: {}", JSON.toJSONString(req));
Long doctorId = super.getDoctorIdByToken();
return PicaResponse.toResponse(hospitalSaasUserService.register(req, doctorId));
}
@ApiOperation("机构saas平台人员更新 0失败 1成功")
@PostMapping(value = "/hospital/upsert")
@EnabledLoginValidate
public PicaResponse<Integer> upsert(@RequestBody HospitalSaasUserReq req) {
logger.info("upsert: url:/saas/hospital/upsert. start: {}", JSON.toJSONString(req));
Long doctorId = super.getDoctorIdByToken();
return PicaResponse.toResponse(hospitalSaasUserService.upsert(req,doctorId));
}
@ApiOperation("机构saas平台人员列表查询")
@PostMapping(value = "/hospital/list")
@EnabledLoginValidate
public PicaResponse<HospitalSaasUserResp> list(@RequestBody HospitalSaasUserListReq req) {
logger.info("list: url:/saas/hospital/list. start: {}", JSON.toJSONString(req));
return PicaResponse.toResponse(hospitalSaasUserService.listByPage(req));
}
@ApiOperation("机构saas平台人员详情更改查询")
@GetMapping(value = "/hospital/edit/{id}")
@EnabledLoginValidate
public PicaResponse<HospitalSaasUserEditResp> edit(@PathVariable("id") Long id) {
logger.info("edit: url:/saas/hospital/edit/id. start: id={}", id);
return PicaResponse.toResponse(hospitalSaasUserService.edit(id));
}
@ApiOperation("机构saas平台人员删除 0失败 1成功")
@GetMapping(value = "/hospital/delete")
@EnabledLoginValidate
public PicaResponse<Integer> delete(@RequestParam("id") Long id) {
logger.info("delete: url:/saas/hospital/delete. start: id={}", 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(hospitalSaasUserService.userDetail(fetchPicaUser()));
}
@ApiOperation("机构saas人员-角色列表")
@GetMapping(value = "/hospital/listByPage")
@EnabledLoginValidate
public PicaResponse<HospitalRoleResp> roleList() {
return PicaResponse.toResponse(hospitalSaasRoleService.querySaasRoles());
}
}
......@@ -448,4 +448,30 @@ public class LoginController extends AccountBaseController {
return PicaResponse.toResponse();
}
/**
* saas机构管理平台密码登录接口
*
* @author wenlei.liao
* @date 2022/3/1 18:45
* @param
* @return
*/
@ApiOperation("saas机构管理平台密码登录接口")
@PostMapping("/saasLogin")
public PicaResponse<SaasLoginResult> saasLogin(@RequestBody SaasLoginReq authCodeReq) throws Exception {
EncryptEntity entity = new EncryptEntity();
entity.setKey(authCodeReq.getKey());
entity.setContent(authCodeReq.getContent());
BaseRequest request = CryptoUtil.decrypt(entity, BaseRequest.class);
request.setProductType(super.getProductType());
Integer sourceType = super.getSourceType();
request.setSourceType(sourceType == null ? 0 : sourceType);
request.setLoginIp(super.getIpAddr());
request.setUserTokenTourist(super.getUserTokenTourist());
AccountUtils.checkMobilePhone(request.getMobile());
AccountUtils.checkPassword(request.getPassword());
SaasLoginResult login = loginService.saasLogin(request);
return PicaResponse.toResponse(login);
}
}
......@@ -61,7 +61,7 @@ public class PasswordController extends AccountBaseController {
String password = request.getPassword();
if (!StringUtils.isEmpty(password) && !StringUtils.isEmpty(oldPwd)) {
if (!password.equals(oldPwd)) {
passwordService.modifyPassword(mobile, oldPwd, password);
passwordService.modifyPassword(mobile, oldPwd, password, false);
return PicaResponse.toResponse();
} else {
throw new AccountException(AccountExceptionEnum.PICA_PASSWORD_EQUAL);
......
......@@ -6,6 +6,7 @@ import java.util.Date;
/**
* 账号
*
* @author andong
* @create 2019/5/20
*/
......@@ -75,6 +76,18 @@ public class Account {
private Date birthday;
private Integer hospitalId;
private String hospital;
public Integer getHospitalId() {
return hospitalId;
}
public void setHospitalId(Integer hospitalId) {
this.hospitalId = hospitalId;
}
public String getNativePlace() {
return nativePlace;
}
......@@ -322,4 +335,12 @@ public class Account {
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getHospital() {
return hospital;
}
public void setHospital(String hospital) {
this.hospital = hospital;
}
}
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 String remark;
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;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.entity;
import java.util.Date;
public class SaaSMenu {
private Integer id;
private Long hospitalId;
private String permissionRoleId;
private String name;
private String url;
private Integer parentId;
private Integer systemType;
private Integer seq;
private Integer deleteFlag;
private Integer creatId;
private Date creatTime;
private Integer modifyId;
private Date modifyTime;
private String icon;
private Integer menuType;
private Integer secondMenuId;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Long getHospitalId() {
return hospitalId;
}
public void setHospitalId(Long hospitalId) {
this.hospitalId = hospitalId;
}
public String getPermissionRoleId() {
return permissionRoleId;
}
public void setPermissionRoleId(String permissionRoleId) {
this.permissionRoleId = permissionRoleId == null ? null : permissionRoleId.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url == null ? null : url.trim();
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public Integer getSystemType() {
return systemType;
}
public void setSystemType(Integer systemType) {
this.systemType = systemType;
}
public Integer getSeq() {
return seq;
}
public void setSeq(Integer seq) {
this.seq = seq;
}
public Integer getDeleteFlag() {
return deleteFlag;
}
public void setDeleteFlag(Integer deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Integer getCreatId() {
return creatId;
}
public void setCreatId(Integer creatId) {
this.creatId = creatId;
}
public Date getCreatTime() {
return creatTime;
}
public void setCreatTime(Date creatTime) {
this.creatTime = creatTime;
}
public Integer getModifyId() {
return modifyId;
}
public void setModifyId(Integer modifyId) {
this.modifyId = modifyId;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon == null ? null : icon.trim();
}
public Integer getMenuType() {
return menuType;
}
public void setMenuType(Integer menuType) {
this.menuType = menuType;
}
public Integer getSecondMenuId() {
return secondMenuId;
}
public void setSecondMenuId(Integer secondMenuId) {
this.secondMenuId = secondMenuId;
}
}
\ No newline at end of file
package com.pica.cloud.account.account.server.entity;
public class SaasLoginReq {
/**
* 加密后的密文
*/
private String key;
/**
* 加密后的数据
*/
private String content;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
package com.pica.cloud.account.account.server.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @ClassName SaasLoginResult
* @Description
* @Author wenlei.liao
* @Date 2022/3/1 15:50
*/
@ApiModel
public class SaasLoginResult {
@ApiModelProperty("token")
private String token;
@ApiModelProperty("机构id")
private Integer hospitalId;
@ApiModelProperty("机构名称")
private String hospitalName;
@ApiModelProperty("用户id 未加密")
private Long userId;
@ApiModelProperty("未加密手机号")
private String mobile;
@ApiModelProperty("用户id,已经加密处理")
private String doctorId;
@ApiModelProperty("医生名称")
private String name;
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public Integer getHospitalId() {
return hospitalId;
}
public void setHospitalId(Integer hospitalId) {
this.hospitalId = hospitalId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getDoctorId() {
return doctorId;
}
public void setDoctorId(String doctorId) {
this.doctorId = doctorId;
}
public String getHospitalName() {
return hospitalName;
}
public void setHospitalName(String hospitalName) {
this.hospitalName = hospitalName;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.enums;
import lombok.Getter;
/**
* @Author Pica
* @Date 2022/3/4 18:39
*/
@Getter
public enum SaasRoleEnum {
NULL_ROLE(0L,"无角色信息"),
MAIN_ADMIN_ROLE(1L, "主管理员"),
ADMIN_ROLE(2L, "系统管理员"),
SAAS_MAIN_ADMIN(3L, "saas系统管理员"),
SAAS_DOCTOR(4L,"开单医生");
private Long code;
private String msg;
SaasRoleEnum(Long code, String msg) {
this.code = code;
this.msg = msg;
}
}
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 com.pica.cloud.account.account.server.resp.HospitalSaasUserEditResp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -9,6 +11,7 @@ import java.util.Map;
/**
* 账号Mapper
*
* @author andong
* @create 2019/5/20
*/
......@@ -21,8 +24,9 @@ public interface AccountMapper {
//新增账号
void insertSelective(Account account);
//更新账号
int updateByIdSelective(Account account);
Integer updateByIdSelective(Account account);
//根据手机号获取账号
Account getByMobilePhone(@Param("mobilePhone") String mobilePhone);
......@@ -33,4 +37,13 @@ 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);
HospitalSaasUserEditResp selectUserRoleById(Long id);
int adminRoleCountByhospitalId(Long hospitalId);
}
......@@ -2,6 +2,12 @@ package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.PermissionDoctorRole;
import com.pica.cloud.account.account.server.resp.RoleDto;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface PermissionDoctorRoleMapper {
int deleteByPrimaryKey(Long id);
......@@ -22,4 +28,19 @@ public interface PermissionDoctorRoleMapper {
* @return
*/
Integer updatePermissionModifyRecord();
int deleteByDoctorId(Map map);
List<PermissionDoctorRole> selectByRoleId(Long id);
List<RoleDto> selectRoleByUserId(Long id);
int deleteByRoleId(Map<String, Object> map);
List<PermissionDoctorRole> queryDoctorMenu(Integer doctorId);
PermissionDoctorRole selectByHospitalIdRoleId(@Param("hospitalId") Integer hospitalId, @Param("roleId") Integer roleId);
int batchInsert(List<PermissionDoctorRole> list);
}
\ 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(Map<String, Object> map);
List<RoleDto> querySaasRoles();
PermissionRole selectByNameCode(PermissionRole record);
List<PermissionRole> selectByDoctorId(Map<String, Long> map);
}
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.entity.SaaSMenu;
import java.util.List;
import java.util.Map;
public interface SaaSMenuMapper {
int deleteByPrimaryKey(Integer id);
int insert(SaaSMenu record);
int insertSelective(SaaSMenu record);
SaaSMenu selectByPrimaryKey(Integer id);
int batchInsert(List<SaaSMenu> list);
List<SaaSMenu> selectByRoleId(String id);
int updateByPrimaryKeySelective(SaaSMenu record);
int updateByPrimaryKey(SaaSMenu record);
int deleteByRoleId(Map<String, Object> map);
}
\ No newline at end of file
......@@ -5,7 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
@ApiModel
public class DoctorReq {
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("姓名")
......
// 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 org.hibernate.validator.constraints.NotBlank;
import javax.validation.constraints.Max;
/**
* @Author qinwh
* @Date 2022/3/1 20:27
*/
@Data
@ApiModel
public class HospitalRoleDetailReq {
@ApiModelProperty("角色id")
private Long id;
@ApiModelProperty("角色名称")
private String name;
@ApiModelProperty("角色描述")
private String remark;
}
// 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 = 10;
@ApiModelProperty("页码")
private Integer pageNo = 1;
@ApiModelProperty("登录来源 0:运营平台 1:saas")
private Integer loginFlag = 0;
}
// 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 = 10;
@ApiModelProperty("页码")
private Integer pageNo = 1;
@ApiModelProperty("登录来源 0:运营平台 1:saas")
private Integer loginFlag = 0;
}
// Copyright 2016-2101 Pica.
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.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang.StringUtils;
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
/**
* @Author qinwh
* @Date 2022/3/1 10:45
*/
@ApiModel
@Data
public class HospitalSaasUserReq {
@ApiModelProperty("人员id")
private Long id;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("机构id")
private Integer hospitalId;
@ApiModelProperty("机构id")
private String hospitalName;
@ApiModelProperty("手机号")
private String mobile;
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("备注")
private String comment;
@ApiModelProperty("角色id 0 无角色 1 主管理员 2 管理员 3 saas系统管理员 4 saas用户")
private List<Long> roleId;
@ApiModelProperty("产品类型 1.云鹊医 2.云鹊健康 3.SAAS")
private Integer productType;
@ApiModelProperty("资源类型 1表示安卓,2表示ios,3表示web,4表示H5登录,5表示admin后台 6.SAAS")
private Integer sourceType;
@ApiModelProperty("登录来源 0:运营平台 1:saas")
private Integer loginFlag = 0;
public void checkInsertParams() {
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(), "姓名不能为空");
}
if (StringUtils.isBlank(this.password)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "密码不能为空");
}
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(), "手机号格式不正确!");
}
if (null == this.productType) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "产品类型不能为空!");
}
if (null == this.sourceType) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "资源类型不能为空!");
}
if (!Pattern.matches("^[A-Za-z0-9]{5,10}$", this.password)) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "密码需由6-10位字母或数字组成!");
}
if (Objects.nonNull(this.comment) && this.comment.length() > 100) {
throw new PicaWarnException(AccountExceptionEnum.PICA_NOT_EMPTY.getCode(), "备注长度须≤100字符");
}
}
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.resp;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @Author Pica
* @Date 2022/3/3 14:36
*/
@Data
public class HospitalRoleDetailDto {
@ApiModelProperty("角色名称")
private String roleName;
@ApiModelProperty("角色id")
private Long roleId;
@ApiModelProperty("备注")
private String remark;
}
// 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 19:54
*/
@Data
public class HospitalRoleDto {
@ApiModelProperty("角色名称")
private String roleName;
@ApiModelProperty("角色id")
private Long roleId;
@ApiModelProperty("备注")
private String remark;
@ApiModelProperty("创建人名称")
private String createName;
@ApiModelProperty("创建人id")
private String createId;
@ApiModelProperty("创建时间")
private Long createTime;
@ApiModelProperty("saas系统管理员标识 0 不是 1是")
private Integer adminSaasFlag = 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 19:54
*/
@Data
@AllArgsConstructor
public class HospitalRoleResp {
@ApiModelProperty("查询列表")
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 String hospitalName;
@ApiModelProperty("机构地址")
private String hospitalAddress;
@ApiModelProperty("手机号")
private String mobile;
@ApiModelProperty("角色id")
private Integer roleId;
@ApiModelProperty("角色名称")
private String roleName;
@ApiModelProperty("资质认证status")
private Integer status;
@ApiModelProperty("资质认证statusStr")
private String statusStr;
}
// 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;
import java.util.List;
/**
* @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("角色")
private List<RoleDto> roles;
@ApiModelProperty("角色id")
private Long roleId;
@ApiModelProperty("角色名称")
private String roleName;
@ApiModelProperty("saas系统管理员标识 0 不是 1是")
private Integer adminSaasFlag = 0;
}
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.resp;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @Author Pica
* @Date 2022/3/3 17:58
*/
@Data
public class HospitalSaasUserEditResp {
@ApiModelProperty("id")
private Long id;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("手机号")
private String mobile;
@ApiModelProperty("备注")
private String comment;
@ApiModelProperty("角色")
private List<RoleDto> roles;
@ApiModelProperty("密码")
private String password;
@ApiModelProperty("密码是否可修改 1 不可修改 2 可修改")
private Integer pwdFlag = 1;
@ApiModelProperty("角色ids")
private List<Long> roleIds;
}
// 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;
}
......@@ -63,4 +63,5 @@ public interface DoctorService {
List<Integer> getDoctorsByInnerOrg();
void cancelAccountByDoctorId(CancelAccountDto cancelAccountDto, PicaUser fetchPicaUser);
}
// 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.HospitalRoleDetailDto;
import com.pica.cloud.account.account.server.resp.HospitalRoleDto;
import com.pica.cloud.account.account.server.resp.HospitalRoleResp;
import com.pica.cloud.account.account.server.resp.HospitalSaasRoleResp;
import com.pica.cloud.foundation.utils.entity.PicaUser;
/**
* @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, PicaUser user);
HospitalSaasRoleResp querySaasRoles();
HospitalRoleDetailDto getRoleDetail(Long id);
}
// 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.HospitalSaasUserDetailResp;
import com.pica.cloud.account.account.server.resp.HospitalSaasUserEditResp;
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, Long doctorId);
HospitalSaasUserResp listByPage(HospitalSaasUserListReq req);
int upsert(HospitalSaasUserReq req, Long doctorId);
int delete(Long id);
HospitalSaasUserDetailResp userDetail(PicaUser user);
HospitalSaasUserEditResp edit(Long id);
}
package com.pica.cloud.account.account.server.service;
import com.pica.cloud.account.account.server.entity.AccountUser;
import com.pica.cloud.account.account.server.entity.LogLoginAes;
import com.pica.cloud.account.account.server.entity.LoginResult;
import com.pica.cloud.account.account.server.entity.PICAPDoctor;
import com.pica.cloud.account.account.server.entity.*;
import com.pica.cloud.account.account.server.req.BaseRequest;
import com.pica.cloud.account.account.server.resp.UnifiedVerificationResp;
import com.pica.cloud.foundation.entity.PicaResponse;
......@@ -105,4 +102,14 @@ public interface LoginService {
void loginSwitch(AccountUser oldUser, AccountUser loginUser);
/**
* saas 密码登录
*
* @author wenlei.liao
* @date 2022/3/1 18:51
* @param
* @return
*/
SaasLoginResult saasLogin(BaseRequest request);
}
......@@ -13,7 +13,7 @@ public interface PasswordService {
* @param oldPwd 旧密码
* @param pwd 新密码
*/
void modifyPassword(String mobile, String oldPwd, String pwd);
void modifyPassword(String mobile, String oldPwd, String pwd, Boolean isForced);
/**
* 忘记密码
......
......@@ -363,7 +363,6 @@ public class DoctorServiceImpl implements DoctorService {
simpleProducer.send(kafkaSendTopic, kafkaModel);
}
private void checkResponse(String checkExecute) {
PicaResponse checkResponse = JSON.parseObject(checkExecute, PicaResponse.class);
if (!checkResponse.getCode().equals(PicaResultCode.SUCCESS.code())) {
......
// Copyright 2016-2101 Pica.
package com.pica.cloud.account.account.server.service.impl;
import com.pica.cloud.account.account.server.entity.PermissionRole;
import com.pica.cloud.account.account.server.entity.SaaSMenu;
import com.pica.cloud.account.account.server.enums.AccountExceptionEnum;
import com.pica.cloud.account.account.server.enums.SaasRoleEnum;
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.mapper.SaaSMenuMapper;
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.*;
import com.pica.cloud.account.account.server.service.HospitalSaasRoleService;
import com.pica.cloud.foundation.entity.PicaResultCode;
import com.pica.cloud.foundation.entity.PicaWarnException;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import com.pica.cloud.foundation.utils.utils.CommonUtil;
import org.apache.commons.lang.StringUtils;
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;
@Autowired
SaaSMenuMapper saaSMenuMapper;
@Override
@Transactional
public int insertAndModify(HospitalRoleDetailReq req, PicaUser user) {
if (StringUtils.isEmpty(req.getName()) || req.getName().trim().length() > 16) {
throw new PicaWarnException(PicaResultCode.DATA_EXCEPTION.code(), "姓名长度≤16字符");
}
if (StringUtils.isNotEmpty(req.getRemark()) && req.getName().trim().length() > 100) {
throw new PicaWarnException(PicaResultCode.DATA_EXCEPTION.code(), "备注长度≤100字符");
}
if (Objects.nonNull(req.getId()) && (req.getId() <= SaasRoleEnum.SAAS_DOCTOR.getCode())) {
throw new PicaWarnException(AccountExceptionEnum.PAT_ACCT_HAS_EXIST.getCode(), "该角色无法编辑或删除");
}
int num;
PermissionRole role = new PermissionRole();
role.setRoleName(req.getName());
PermissionRole byNameCode = permissionRoleMapper.selectByNameCode(role);
if (null != byNameCode) {
throw new PicaWarnException(AccountExceptionEnum.PAT_ACCT_HAS_EXIST.getCode(), "该角色名称重复");
}
if (null != req.getId()) {
role.setId(req.getId());
role.setRoleName(req.getName());
role.setRemark(req.getRemark());
role.setModifiedId(Long.valueOf(user.getId()));
role.setModifiedTime(new Date());
num = permissionRoleMapper.updateByPrimaryKeySelective(role);
} else {
role.setRoleCode("saas_admin" + CommonUtil.getRandom(10));
role.setRemark(req.getRemark());
role.setCreatedId(Long.valueOf(user.getId()));
role.setCreatedTime(new Date());
role.setModifiedId(Long.valueOf(user.getId()));
role.setModifiedTime(new Date());
num = permissionRoleMapper.insertSelective(role);
List<SaaSMenu> saaSMenus = saaSMenuMapper.selectByRoleId(String.valueOf(4));
saaSMenus.forEach(t -> {
t.setPermissionRoleId(String.valueOf(role.getId()));
t.setModifyId(user.getId());
t.setModifyTime(new Date());
t.setCreatTime(new Date());
t.setCreatId(user.getId());
});
saaSMenuMapper.batchInsert(saaSMenus);
}
return num;
}
@Override
public HospitalRoleResp listByPage(HospitalRoleListReq req) {
Map<String, Object> map = new HashMap(4);
if (req.getLoginFlag() == 1) {
List<Long> list = Arrays.asList(SaasRoleEnum.MAIN_ADMIN_ROLE.getCode(), SaasRoleEnum.ADMIN_ROLE.getCode(), SaasRoleEnum.SAAS_MAIN_ADMIN.getCode());
map.put("list", list);
} else {
List<Long> list = Arrays.asList(SaasRoleEnum.MAIN_ADMIN_ROLE.getCode(), SaasRoleEnum.ADMIN_ROLE.getCode());
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());
List<HospitalRoleDto> roleDtos = permissionRoleMapper.listByPage(map);
for (HospitalRoleDto roleDto : roleDtos) {
if (Objects.equals(roleDto.getRoleId(), SaasRoleEnum.SAAS_MAIN_ADMIN.getCode()) ||
Objects.equals(roleDto.getRoleId(), SaasRoleEnum.SAAS_DOCTOR.getCode())) {
roleDto.setAdminSaasFlag(1);
}
}
return new HospitalRoleResp(roleDtos, count);
}
@Override
@Transactional
public int delete(Long id, PicaUser user) {
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());
map.put("modifiedTime", new Date());
permissionRoleMapper.deleteById(map);
permissionDoctorRoleMapper.deleteByRoleId(map);
saaSMenuMapper.deleteByRoleId(map);
return 1;
}
@Override
public HospitalSaasRoleResp querySaasRoles() {
List<RoleDto> roleDtos = permissionRoleMapper.querySaasRoles();
return new HospitalSaasRoleResp(roleDtos);
}
@Override
public HospitalRoleDetailDto getRoleDetail(Long id) {
PermissionRole permissionRole = permissionRoleMapper.selectByPrimaryKey(id);
HospitalRoleDetailDto dto = new HospitalRoleDetailDto();
BeanUtils.copyProperties(permissionRole, dto);
return dto;
}
}
// 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.SaasRoleEnum;
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.*;
import com.pica.cloud.account.account.server.service.AccountService;
import com.pica.cloud.account.account.server.service.HospitalSaasUserService;
import com.pica.cloud.account.account.server.service.PasswordService;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.ExecutorServiceUtils;
import com.pica.cloud.foundation.encryption.common.constants.EncryptConstants;
import com.pica.cloud.foundation.encryption.util.EncryptUtils;
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.MD5Util;
import com.pica.cloud.trade.store.client.StoreCertifyServiceClient;
import com.pica.cloud.trade.store.resp.certify.StoreCertifyStatus;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Author Pica
* @Date 2022/3/1 15:52
*/
@Service
public class HospitalSaasUserServiceImpl implements HospitalSaasUserService {
private Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private ICacheClient redisClient;
@Autowired
private AccountInfoDetailMapper accountInfoDetailMapper;
@Autowired
private AccountMapper accountMapper;
@Autowired
private PUserRoleMapper pUserRoleMapper;
@Autowired
private PermissionDoctorRoleMapper doctorRoleMapper;
@Autowired
private HospitalMapper hospitalMapper;
@Autowired
private PermissionRoleMapper permissionRoleMapper;
@Autowired
private StoreCertifyServiceClient storeCertifyServiceClient;
@Autowired
private AccountService accountService;
@Autowired
private PasswordService passwordService;
@Override
@Transactional
public int register(HospitalSaasUserReq req, Long doctorId) {
req.checkInsertParams();
if (req.getRoleId().contains(SaasRoleEnum.SAAS_MAIN_ADMIN.getCode())) {
PermissionDoctorRole existRole = doctorRoleMapper.selectByHospitalIdRoleId(req.getHospitalId(), SaasRoleEnum.SAAS_MAIN_ADMIN.getCode().intValue());
if (existRole != null) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "saas系统管理员已存在");
}
}
if (CollectionUtils.isNotEmpty(req.getRoleId()) &&
((req.getRoleId().contains(SaasRoleEnum.MAIN_ADMIN_ROLE.getCode())) || req.getRoleId().contains(SaasRoleEnum.ADMIN_ROLE.getCode()))) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "主管理员或系统管理员不可被操作");
}
if (req.getLoginFlag() == 1 && CollectionUtils.isNotEmpty(req.getRoleId()) &&
((req.getRoleId().contains(SaasRoleEnum.MAIN_ADMIN_ROLE.getCode())) || req.getRoleId().contains(SaasRoleEnum.ADMIN_ROLE.getCode()) || req.getRoleId().contains(SaasRoleEnum.SAAS_MAIN_ADMIN.getCode()))) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "saas系统管理员不可被操作");
}
if (CollectionUtils.isNotEmpty(req.getRoleId()) &&
(req.getRoleId().contains(SaasRoleEnum.NULL_ROLE.getCode())) && req.getRoleId().size() > 1) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "角色选择非法");
}
//得到手机号
String mobile = req.getMobile();
//幂等校验
String nxKey = Constants.REPEAT_REGISTER_PREFIX + mobile;
Long resultNx = redisClient.setnx(nxKey, mobile);
if (resultNx == 0) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "重复提交");
}
redisClient.expire(nxKey, 2);
if (resultNx == 1) {
//手机号加密
String mobileEncrypt = AESUtil.encryptV0(mobile);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(mobileEncrypt);
//密码已经存在的处理逻辑
if (Objects.nonNull(accountInfoEntity) && StringUtils.isNotBlank(accountInfoEntity.getPassword())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "用户已存在,且密码已设置,不可进行编辑");
}
//用户不存在的处理逻辑
if (accountInfoEntity == null) {
Date currentTime = Calendar.getInstance().getTime();
String md5Pwd = StringUtils.upperCase(MD5Util.MD5(req.getPassword()));
// account_info
AccountInfoEntity accountInfo = buildAccountInfo(mobileEncrypt, currentTime, req.getProductType(), req.getSourceType(), md5Pwd);
accountInfoDetailMapper.insertSelective(accountInfo);
Integer acctId = accountInfo.getId();
accountInfoDetailMapper.updateCreateInfo(acctId);
// doctor
Account account = buildDoctorMsg(req, mobileEncrypt, currentTime, req.getSourceType(), md5Pwd, acctId);
accountMapper.insertSelective(account);
insertAppRole(account.getId());
insertSaasRole(req.getRoleId(), req.getHospitalId().longValue(), account.getId(), account.getId());
redisClient.del(nxKey);
return 1;
}
Account byMobilePhone = accountMapper.getByMobilePhone(mobileEncrypt);
if (!req.getHospitalId().equals(byMobilePhone.getHospitalId())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "正在添加的用户非本机构下用户");
}
Account account = new Account();
account.setId(byMobilePhone.getId());
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 (StringUtils.isNotEmpty(req.getPassword()) && StringUtils.isEmpty(byMobilePhone.getPassword())) {
passwordService.modifyPassword(mobileEncrypt, byMobilePhone.getPassword(), StringUtils.upperCase(MD5Util.MD5(req.getPassword())), true);
}
}
return 1;
}
private void insertSaasRole(List<Long> roleIdList, Long hospitalId, Long doctorId, Long userId) {
if (CollectionUtils.isEmpty(roleIdList)) {
return;
}
List<PermissionDoctorRole> list = new ArrayList<>();
roleIdList.forEach(t -> {
PermissionDoctorRole doctorRole = new PermissionDoctorRole();
doctorRole.setDoctorId(doctorId);
doctorRole.setHospitalId(hospitalId);
doctorRole.setRoleId(t);
doctorRole.setDeleteFlag(1);
doctorRole.setCreatedId(userId);
doctorRole.setCreatedTime(new Date());
doctorRole.setModifiedId(userId);
doctorRole.setModifiedTime(new Date());
list.add(doctorRole);
});
doctorRoleMapper.batchInsert(list);
}
@Override
public HospitalSaasUserResp listByPage(HospitalSaasUserListReq req) {
Map<String, Object> map = new HashMap<>(5);
map.put("hospitalId", req.getHospitalId());
map.put("name", req.getName());
if (StringUtils.isBlank(req.getMobile()) && Objects.nonNull(req.getMobile()) && req.getMobile().length() >= 1) {
map.put("mobile", req.getMobile());
} else {
map.put("mobile", AESUtil.encryptV0(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());
List<HospitalSaasUserDto> lists = accountMapper.listByPage(map);
//手机号 解密脱敏
lists.stream().forEach(t -> {
List<RoleDto> roleDtos = doctorRoleMapper.selectRoleByUserId(t.getId());
List<Long> roleIds = roleDtos.stream().map(RoleDto::getId).collect(Collectors.toList());
t.setRoles(roleDtos);
String phone = EncryptUtils.decryptContent(t.getMobile(), EncryptConstants.ENCRYPT_TYPE_MOBILE, EncryptConstants.ENCRYPT_DECRYPT_KEY);
String mixMobile = mixMobile(phone);
t.setMobile(mixMobile);
});
return new HospitalSaasUserResp(lists, count);
}
@Override
public int upsert(HospitalSaasUserReq req, Long doctorId) {
if (Objects.isNull(req) || Objects.isNull(req.getHospitalId()) || CollectionUtils.isEmpty(req.getRoleId())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "参数错误");
}
List<Long> inputRoleIdList = new ArrayList<>();
inputRoleIdList.addAll(req.getRoleId());
List<Long> delRoleIdList = new ArrayList<>();
/** 判定saas系统管理员重复 */
if (inputRoleIdList.contains(SaasRoleEnum.SAAS_MAIN_ADMIN.getCode())) {
PermissionDoctorRole existRole = doctorRoleMapper.selectByHospitalIdRoleId(req.getHospitalId(), SaasRoleEnum.SAAS_MAIN_ADMIN.getCode().intValue());
if (existRole != null && !existRole.getDoctorId().equals(req.getId())) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "saas系统管理员已存在");
}
}
/** 移除不可编辑的角色 */
if (req.getLoginFlag() == 0) {
inputRoleIdList.removeIf(ele -> ele.equals(SaasRoleEnum.MAIN_ADMIN_ROLE.getCode()));
inputRoleIdList.removeIf(ele -> ele.equals(SaasRoleEnum.ADMIN_ROLE.getCode()));
delRoleIdList.addAll(Arrays.asList(SaasRoleEnum.MAIN_ADMIN_ROLE.getCode(), SaasRoleEnum.ADMIN_ROLE.getCode()));
} else if (req.getLoginFlag() == 1) {
inputRoleIdList.removeIf(ele -> ele.equals(SaasRoleEnum.MAIN_ADMIN_ROLE.getCode()));
inputRoleIdList.removeIf(ele -> ele.equals(SaasRoleEnum.ADMIN_ROLE.getCode()));
inputRoleIdList.removeIf(ele -> ele.equals(SaasRoleEnum.SAAS_MAIN_ADMIN.getCode()));
delRoleIdList.addAll(Arrays.asList(SaasRoleEnum.MAIN_ADMIN_ROLE.getCode(), SaasRoleEnum.ADMIN_ROLE.getCode(), SaasRoleEnum.SAAS_MAIN_ADMIN.getCode()));
}
if (CollectionUtils.isNotEmpty(inputRoleIdList)) {
Map<String, Object> map = new HashMap(3);
map.put("id", req.getId());
map.put("delRoleIdList", delRoleIdList);
map.put("modifiedId", doctorId);
map.put("modifiedTime", new Date());
doctorRoleMapper.deleteByDoctorId(map);
if (!inputRoleIdList.contains(SaasRoleEnum.NULL_ROLE.getCode())) {
insertSaasRole(inputRoleIdList, req.getHospitalId().longValue(), req.getId(), doctorId);
} else if (inputRoleIdList.size() > 1) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "角色清除与其他角色添加不可以并存");
}
}
/** 修改备注 */
Account account = new Account();
account.setId(req.getId());
account.setModifyId(doctorId);
account.setModifyTime(Calendar.getInstance().getTime());
if (StringUtils.isNotEmpty(req.getComment())) {
account.setComment(req.getComment());
}
accountService.updateAccountById(account);
/** 修改密码 */
if (StringUtils.isNotEmpty(req.getPassword())) {
String mobileEncrypt = AESUtil.encryptV0(req.getMobile());
Account accountExist = accountMapper.getByMobilePhone(mobileEncrypt);
if (accountExist == null) {
throw new PicaException(PicaResultCode.PARAM_IS_INVALID.code(), "当前用户不存在");
}
if (StringUtils.isEmpty(accountExist.getPassword())) {
passwordService.modifyPassword(mobileEncrypt, accountExist.getPassword(), StringUtils.upperCase(MD5Util.MD5(req.getPassword())), true);
}
}
return 1;
}
@Override
@Deprecated
public int delete(Long id) {
//删除本身信息,删除人员的权限关联信息,删除人员的协议信息
// todo
return 0;
}
/**
* 获取机构用户账户信息
*
* @param user
* @return
*/
@Override
public HospitalSaasUserDetailResp userDetail(PicaUser user) {
HospitalSaasUserDetailResp resp = new HospitalSaasUserDetailResp();
Account pDoctor = accountMapper.selectById(user.getId());
if (null == pDoctor) {
return resp;
}
if (null != pDoctor.getHospitalId() && 0L != pDoctor.getHospitalId()) {
Hospital hospital = hospitalMapper.selectByPrimaryKey(pDoctor.getHospitalId());
if (null != hospital) {
resp.setHospitalId(hospital.getId().longValue());
resp.setHospitalName(hospital.getName());
resp.setHospitalAddress(hospital.getHospitalAddress());
}
} else {
return resp;
}
resp.setName(pDoctor.getName());
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 roleName = roles.stream().map(t -> t.getRoleName()).distinct().collect(Collectors.joining(","));
resp.setRoleName(roleName);
// 获取批发资质
StoreCertifyStatus storeCertifyStatus = null;
try {
storeCertifyStatus = storeCertifyServiceClient.statusByDoctorId(user.getToken(), pDoctor.getId().intValue()).getData();
resp.setStatusStr(storeCertifyStatus.getCertifyStatusStr());
resp.setStatus(storeCertifyStatus.getCertifyStatus());
} catch (Exception e) {
logger.error("userDetail storeCertifyServiceClient.statusByDoctorId error: {}==doctorId: {}", e, pDoctor.getId());
}
return resp;
}
@Override
public HospitalSaasUserEditResp edit(Long id) {
HospitalSaasUserEditResp resp = accountMapper.selectUserRoleById(id);
List<RoleDto> roleDtos = doctorRoleMapper.selectRoleByUserId(resp.getId());
resp.setRoles(roleDtos);
resp.setRoleIds(roleDtos.stream().map(RoleDto::getId).collect(Collectors.toList()));
if (null == resp) {
return new HospitalSaasUserEditResp();
}
resp.setPwdFlag(2);
//手机号不为空 解密脱敏
if (StringUtils.isNotBlank(resp.getMobile())) {
String phone = EncryptUtils.decryptContent(resp.getMobile(), EncryptConstants.ENCRYPT_TYPE_MOBILE, EncryptConstants.ENCRYPT_DECRYPT_KEY);
resp.setMobile(phone);
return resp;
}
if (StringUtils.isNotBlank(resp.getPassword())) {
resp.setPwdFlag(1);
}
return resp;
}
//处理app端 用户-角色关系
private void insertAppRole(Long userId) {
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);
accountInfo.setRegTime(currentTime);
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.setHospital(hospitalSaasUserReq.getHospitalName());
account.setCreatId(0L);
account.setModifyId(0L);
account.setCreatTime(currentTime);
account.setRegTime(currentTime);
account.setModifyTime(currentTime);
account.setFirstLoginTime(currentTime);
account.setLastLoginTime(currentTime);
account.setRegisterSource(sourceType);
return account;
}
private static String mixMobile(String mobile) {
if (org.apache.commons.lang3.StringUtils.isBlank(mobile)) {
return mobile;
}
if (mobile.length() == 11) {
return (new StringBuilder()).append(mobile.substring(0, 3)).append("****").append(mobile.substring(7)).toString();
}
return (new StringBuilder()).append(mobile.substring(0, 1)).append("***").append(mobile.substring(mobile.length())).toString();
}
}
......@@ -36,6 +36,7 @@ import com.pica.cloud.foundation.utils.utils.ValidateUtils;
import com.pica.cloud.patient.smartcontract.common.utils.HttpClientCloudUtils;
import io.jsonwebtoken.*;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......@@ -46,10 +47,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.security.PublicKey;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.*;
@Service
public class LoginServiceImpl implements LoginService {
......@@ -101,6 +99,9 @@ public class LoginServiceImpl implements LoginService {
@Autowired
private IntactUtil intactUtil;
@Autowired
private PermissionDoctorRoleMapper permissionDoctorRoleMapper;
@Value("${doubleWritingMode}")
private boolean doubleWritingMode;
......@@ -1105,4 +1106,182 @@ public class LoginServiceImpl implements LoginService {
AccountTypeEnum.LOG_TYPE_LOGIN.getCode(), loginUser.getToken(), 1, oldUser.getUserTokenTourist());
picaLogUtils.info(entity);
}
@Override
public SaasLoginResult saasLogin(BaseRequest request) {
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "request:" + JSON.toJSONString(request));
String mobile = request.getMobile();
Integer sourceType = request.getSourceType();
String encrypt = AESUtil.encryptV0(mobile);
AccountInfoEntity accountInfoEntity = accountInfoDetailMapper.selectByMobile(encrypt);
logger.info("bizType:{}, account not null:{}", request.getBizType(), accountInfoEntity != null);
if (accountInfoEntity != null) {
String oldPwd = accountInfoEntity.getPassword();
String password = request.getPassword();
if (null != request.getBizType() &&
request.getBizType().equals(1)) {
// 新版-未设置密码
if (StringUtils.isEmpty(oldPwd)) {
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该手机号尚未设置密码,设置密码请前往云鹊医APP,或使用其他方式登录。");
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_SETED_PASSWORD_H5.getMessage());
} else {
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该手机号{mobile}尚未设置密码,请先设置密码。");
throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getCode(),
AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getMessage()
.replace("{mobile}", mobile));
}
} else {
// 判断账号是否已锁
logger.info("new login failure:" + mobile);
String lockKey = Constants.ACCOUNT_LOCK_KEY.replace("{mobile}", mobile);
if (redisClient.exists(lockKey)) {
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该账号密码错误次数已达上限请24小时后再试,或请使用其他登录方式");
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getMessage());
} else {
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该账号{mobile}的密码错误次数已达上限请24小时后再试,或请使用其他登录方式或找回密码");
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_5.getMessage().replace("{mobile}", mobile));
}
}
if (password.equals(oldPwd)) {
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "接下来调用pwdLoginCorrect");
return pwdSaaSLoginCorrect(request, mobile, encrypt, accountInfoEntity);
} else {
String errorKey = Constants.PWD_ERROR_NUM_KEY.replace("{mobile}", mobile);
if (redisClient.exists(errorKey)) {
int errorCount = Integer.parseInt(redisClient.get(errorKey));
errorCount = errorCount + 1;
redisClient.set(errorKey, errorCount, Constants.PWD_ERROR_NUM_SECONDS);
if (errorCount <= 4) {
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "密码错误,请重试");
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_4.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_4.getMessage());
} else {
// 设置账号锁定24h
redisClient.set(lockKey, mobile, Constants.PWD_ERROR_NUM_SECONDS);
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该账号密码错误次数已达上限请24小时后再试,或请使用其他登录方式");
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_5_H5.getMessage());
} else {
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该账号{mobile}的密码错误次数已达上限请24小时后再试,或请使用其他登录方式或找回密码");
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_5.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_5.getMessage().replace("{mobile}", mobile));
}
}
} else {
redisClient.set(errorKey, 1, Constants.PWD_ERROR_NUM_SECONDS);
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "密码错误,请重试");
throw new PicaException(AccountExceptionEnum.PICA_PWD_MISMATCH_4.getCode(),
AccountExceptionEnum.PICA_PWD_MISMATCH_4.getMessage());
}
}
}
} else {
// 旧版本
if (password.equals(oldPwd)) {
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "接下来调用pwdLoginCorrect");
return pwdSaaSLoginCorrect(request, mobile, encrypt, accountInfoEntity);
} else {
logger.info("login failure:" + mobile);
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "请输入正确的密码");
throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_ERROR.getCode(), AccountExceptionEnum.PICA_PASSWORD_ERROR.getMessage());
}
}
} else {
if (null != request.getBizType() &&
request.getBizType().equals(1)) {
if (sourceType != null && SourceTypeEnum.H5.getCode().equals(sourceType)) {
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该手机号尚未设置密码,设置密码请前往云鹊医APP,或使用其他方式登录。");
throw new PicaWarnException(AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getCode(),
AccountExceptionEnum.PICA_MOBILE_NOT_REGIST_H5.getMessage());
} else {
// 新版-未注册
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "该手机号{mobile}尚未设置密码,请先设置密码。");
throw new PicaException(AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getCode(),
AccountExceptionEnum.PICA_PASSWORD_RULE_ERROR.getMessage()
.replace("{mobile}", mobile));
}
} else {
intactUtil.sendIntact(batchNo, "login", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "未注册,请先注册");
throw new PicaException(AccountExceptionEnum.PICA_NOT_REGISTER.getCode(), AccountExceptionEnum.PICA_NOT_REGISTER.getMessage());
}
}
}
private SaasLoginResult pwdSaaSLoginCorrect(BaseRequest request, String mobile, String encrypt, AccountInfoEntity accountInfoEntity) {
//接入新旭事务一致性
String batchNo = IntactUtils.getUUID();
intactUtil.sendIntact(batchNo, "pwdLoginCorrect", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_1, "request:" + JSON.toJSONString(request) + ",+mobile:" + mobile + ",encrypt:" + encrypt + ",accountInfoEntity:" + JSON.toJSONString(accountInfoEntity));
Date currentTime = new Date();
Integer acctId = accountInfoEntity.getId();
int productType = request.getProductType();
int sourceType = request.getSourceType();
Doctor doctorInfo = null;
doctorInfo = doctorInfoMapper.getDoctorInfoByMobile(encrypt);
if (null == doctorInfo) {
logger.error("此手机号无用户:{}", mobile);
intactUtil.sendIntact(batchNo, "pwdLoginCorrect", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "request:" + JSON.toJSONString(request) + ",+mobile 此手机号无用户:" + mobile + ",encrypt:" + ",accountInfoEntity:" + JSON.toJSONString(accountInfoEntity));
}
if(null == doctorInfo.getHospitalId() || 0 == doctorInfo.getHospitalId()){
throw new PicaException(AccountExceptionEnum.PICA_PARAMS_ERROR.getCode(), "请先加入机构");
}
//查询登录用户角色权限信息
List<PermissionDoctorRole> doctorRoles = permissionDoctorRoleMapper.queryDoctorMenu(doctorInfo.getId());
if(CollectionUtils.isEmpty(doctorRoles)){
PermissionDoctorRole role = permissionDoctorRoleMapper.selectByHospitalIdRoleId(doctorInfo.getHospitalId(), 3);
String name = "";
if(null != role){
Doctor doctor = doctorInfoMapper.selectByPrimaryKey(Math.toIntExact(role.getDoctorId()));
if(null != doctor){
name = doctor.getName();
}
}
throw new PicaException(AccountExceptionEnum.PICA_PARAMS_ERROR.getCode(), "请先联系系统管理员"+ name +"开通账号");
}
Integer userId = 0;
if (productType != AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) {
userId = doctorInfo.getId();
} else if (productType == AccountTypeEnum.PRODUCT_TYPE_HEALTH.getCode()) {
AccountPatientInfoEntity accountPatientInfoEntity = accountPatientInfoMapper.selectByAcctId(acctId);
userId = accountPatientInfoEntity.getId();
}
Account account = new Account();
account.setId(userId.longValue());
account.setAcctId(acctId);
account.setCreatTime(currentTime);
account.setMobilePhone(mobile);
account.setRegisterSource(sourceType);
String newToken = tokenUtils.generateToken(account);
SaasLoginResult result = new SaasLoginResult();
result.setToken(newToken);
result.setHospitalId(doctorInfo.getHospitalId());
result.setHospitalName(doctorInfo.getHospital());
result.setUserId(userId.longValue());
result.setMobile(mobile);
result.setName(doctorInfo.getName());
result.setDoctorId(EncryptUtils.encryptContent(userId + "", EncryptConstants.ENCRYPT_TYPE_ID));
intactUtil.sendIntact(batchNo, "pwdLoginCorrect", com.pica.cloud.foundation.completeness.contract.constants.CommonConstants.INTACT_CONTENT_LOG_STATUS_3, "request:" + JSON.toJSONString(request) + ",+mobile:" + mobile + ",encrypt:" + ",accountInfoEntity:" + JSON.toJSONString(accountInfoEntity));
return result;
}
}
......@@ -59,11 +59,11 @@ public class PasswordServiceImpl implements PasswordService {
@Override
@Transactional
public void modifyPassword(String mobile, String oldPwd, String pwd) {
public void modifyPassword(String mobile, String oldPwd, String pwd, Boolean isForced) {
AccountInfoEntity entity = accountInfoDetailMapper.selectByMobile(mobile);
if (entity != null) {
//added by joy begin 晓庆说 这批空密码用户不应该在设置密码处 修改密码,提示:引导客户去密码登录;
if(StringUtil.isEmpty(entity.getPassword())){
if(!isForced && StringUtil.isEmpty(entity.getPassword())){
throw new AccountException(AccountExceptionEnum.PICA_PASSWORD_RESET);
}
//added by joy end
......
// 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();
}
}
}
}
}
}
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>
......
......@@ -2,344 +2,411 @@
<!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"/>
<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"/>
<result column="hospital_id" jdbcType="INTEGER" property="hospitalId"/>
<result column="hospital" jdbcType="VARCHAR" property="hospital"/>
</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, hospital
</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>
<if test="hospitalId != null">
hospital_id,
</if>
<if test="hospital != null">
hospital,
</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>
<if test="hospitalId != null">
#{hospitalId,jdbcType=INTEGER},
</if>
<if test="hospital != null">
#{hospital,jdbcType=VARCHAR},
</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="hospitalId != null">
hospital_id = #{hospitalId,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 mobile != '' ">
and p.mobile_phone = #{mobile}
</if>
<if test="name != null and name != ''">
and p.name = #{name}
</if>
<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>
<select id="listCountByPage" resultType="java.lang.Integer">
select count(*)
from p_doctor as p
where
<include refid="select_list_page"></include>
</select>
<select id="listByPage" resultType="com.pica.cloud.account.account.server.resp.HospitalSaasUserDto">
select
p.id as id,
p.name as name,
p.hospital_id as hospitalId,
p.mobile_phone as mobile,
p.comment as comment
from p_doctor as p
where
<include refid="select_list_page"></include>
ORDER BY p.reg_time DESC
limit #{pageNo},#{pageSize}
</select>
</mapper>
\ No newline at end of file
<select id="selectUserRoleById" resultType="com.pica.cloud.account.account.server.resp.HospitalSaasUserEditResp">
select p.id as id,
p.name as name,
p.hospital_id as hospitalId,
p.mobile_phone as mobile,
p.comment as comment,
p.password as password
from p_doctor as p
where p.id = #{id, jdbcType=INTEGER}
and p.delete_flag = 1
limit 1
</select>
<select id="adminRoleCountByhospitalId" resultType="java.lang.Integer">
select count(*)
from p_doctor as pd
join permission_doctor_role as pdr on pd.id = pdr.doctor_id and pdr.role_id = 3 and pdr.delete_flag = 1
where pd.hospital_id = #{hospitalId}
AND pd.delete_flag = 1
limit 1
</select>
</mapper>
......@@ -13,38 +13,50 @@
<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 id="insert" parameterType="com.pica.cloud.account.account.server.entity.PermissionDoctorRole"
useGeneratedKeys="true" keyProperty="id">
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=",">
......@@ -106,6 +118,17 @@
</if>
</trim>
</insert>
<insert id="batchInsert" keyProperty="id" useGeneratedKeys="true" >
insert into permission_doctor_role (doctor_id, hospital_id,
role_id, delete_flag, created_id,
created_time, modified_id, modified_time)
values
<foreach collection="list" item="item" separator=",">
( #{item.doctorId,jdbcType=BIGINT}, #{item.hospitalId,jdbcType=BIGINT},
#{item.roleId,jdbcType=BIGINT}, #{item.deleteFlag,jdbcType=INTEGER}, #{item.createdId,jdbcType=BIGINT},
#{item.createdTime,jdbcType=TIMESTAMP}, #{item.modifiedId,jdbcType=BIGINT}, #{item.modifiedTime,jdbcType=TIMESTAMP})
</foreach>
</insert>
<update id="updateByPrimaryKeySelective"
parameterType="com.pica.cloud.account.account.server.entity.PermissionDoctorRole">
update permission_doctor_role
......@@ -138,15 +161,69 @@
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.util.Map">
update permission_doctor_role
set delete_flag = 2,
modified_id = #{modifiedId,jdbcType=BIGINT},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP}
where doctor_id = #{id,jdbcType=BIGINT}
<if test="delRoleIdList != null and delRoleIdList.size() > 0">
and role_id not in
<foreach collection="delRoleIdList" open="(" close=")" separator="," item="item">
#{item}
</foreach>
</if>
</update>
<update id="deleteByRoleId" parameterType="java.util.Map">
update permission_doctor_role
set delete_flag = 2,
modified_id = #{modifiedId,jdbcType=BIGINT},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP}
where role_id = #{id,jdbcType=BIGINT}
and delete_flag = 1
</update>
<select id="queryDoctorMenu" parameterType="java.lang.Integer" resultMap="BaseResultMap">
SELECT pr.*
FROM permission_doctor_role pr,
p_saas_menu pm
WHERE pr.doctor_id = #{doctorId}
AND pr.role_id = pm.permission_role_id
AND pr.delete_flag = 1
AND pm.delete_flag = 1
AND pm.system_type = 42
GROUP BY pm.NAME
</select>
<select id="selectByHospitalIdRoleId" parameterType="java.lang.Integer" resultMap="BaseResultMap">
SELECT pr.*
FROM permission_doctor_role pr
WHERE pr.hospital_id = #{hospitalId}
and pr.role_id = #{roleId}
AND pr.delete_flag = 1
order by pr.modified_time desc
limit 1
</select>
<select id="selectRoleByUserId" resultType="com.pica.cloud.account.account.server.resp.RoleDto">
select pr.id as id,
pr.role_name as name
from permission_doctor_role as pdr
left join permission_role as pr ON pdr.role_id = pr.id and pr.delete_flag = 1
where pdr.doctor_id = #{id,jdbcType=BIGINT}
and pdr.delete_flag = 1
</select>
</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"/>
<result column="remark" property="remark" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id, role_code, role_name, delete_flag, created_id, created_time, modified_id, modified_time,remark
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">
select
<include refid="Base_Column_List"/>
from permission_role
where id = #{id,jdbcType=BIGINT} and delete_flag = 1
</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, remark,
delete_flag, created_id, created_time,
modified_id, modified_time)
values (#{id,jdbcType=BIGINT}, #{roleCode,jdbcType=VARCHAR}, #{roleName,jdbcType=VARCHAR},
#{remark,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"
useGeneratedKeys="true" keyProperty="id">
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="remark != null">
remark,
</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="remark != null">
#{remark,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="remark != null">
remark = #{remark,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=",">
#{item}
</foreach>
)
</if>
<if test="name != null and name != ''">
and pr.role_name like concat(#{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
UNIX_TIMESTAMP(pr.created_time) * 1000 as createTime,
pr.role_name as roleName,
pr.id as roleId,
pr.remark as remark,
pr.created_id as createId,
ifnull(pd.user_name, '系统定义') as createName
from permission_role as pr
left join p_admin pd on pd.id = pr.created_id
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
where p.id not in (1, 2)
and p.delete_flag = 1
</select>
<update id="deleteById">
update permission_role
set delete_flag = 2,
modified_id = #{modifiedId,jdbcType=BIGINT},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=BIGINT}
</update>
<select id="selectByNameCode" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from permission_role
where delete_flag = 1
<if test="roleCode != null and roleCode != '' ">
and role_code = #{roleCode}
</if>
<if test="roleName != null and roleName != '' ">
and role_name = #{roleName}
</if>
</select>
<select id="selectByDoctorId" resultType="com.pica.cloud.account.account.server.entity.PermissionRole"
parameterType="java.util.Map">
select r.role_code as roleCode,
r.role_name as roleName
from permission_doctor_role dr
JOIN permission_role r on dr.role_id = r.id and r.delete_flag = 1
WHERE dr.delete_flag = 1
and dr.doctor_id = #{doctorId ,jdbcType=BIGINT}
AND dr.hospital_id = #{hospitalId ,jdbcType=BIGINT}
</select>
</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.SaaSMenuMapper">
<resultMap id="BaseResultMap" type="com.pica.cloud.account.account.server.entity.SaaSMenu">
<id column="id" property="id" jdbcType="INTEGER"/>
<result column="hospital_id" property="hospitalId" jdbcType="BIGINT"/>
<result column="permission_role_id" property="permissionRoleId" jdbcType="VARCHAR"/>
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="url" property="url" jdbcType="VARCHAR"/>
<result column="parent_id" property="parentId" jdbcType="INTEGER"/>
<result column="system_type" property="systemType" jdbcType="INTEGER"/>
<result column="seq" property="seq" jdbcType="INTEGER"/>
<result column="delete_flag" property="deleteFlag" jdbcType="INTEGER"/>
<result column="created_id" property="creatId" jdbcType="INTEGER" />
<result column="created_time" property="creatTime" jdbcType="TIMESTAMP" />
<result column="modified_id" property="modifyId" jdbcType="INTEGER" />
<result column="modified_time" property="modifyTime" jdbcType="TIMESTAMP" />
<result column="icon" property="icon" jdbcType="VARCHAR"/>
<result column="menu_type" property="menuType" jdbcType="INTEGER"/>
<result column="second_menu_id" property="secondMenuId" jdbcType="INTEGER"/>
</resultMap>
<sql id="Base_Column_List">
id, hospital_id, permission_role_id, name, url, parent_id, system_type, seq, delete_flag,
created_id, created_time, modified_id, modified_time, icon, menu_type, second_menu_id
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer">
select
<include refid="Base_Column_List"/>
from p_saas_menu
where id = #{id,jdbcType=INTEGER}
</select>
<select id="selectByRoleId" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from p_saas_menu
where permission_role_id = #{id,jdbcType=VARCHAR} and delete_flag = 1
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete
from p_saas_menu
where id = #{id,jdbcType=INTEGER}
</delete>
<update id="deleteByRoleId" parameterType="java.util.Map">
update p_saas_menu
set delete_flag = 2,
modified_id = #{modifiedId,jdbcType=BIGINT},
modified_time = #{modifiedTime,jdbcType=TIMESTAMP}
where permission_role_id = #{id,jdbcType=VARCHAR}
and delete_flag = 1
</update>
<insert id="insert" parameterType="com.pica.cloud.account.account.server.entity.SaaSMenu">
insert into p_saas_menu (id, hospital_id, permission_role_id,
name, url, parent_id,
system_type, seq, delete_flag,
created_id, created_time, modified_id,
modified_time, icon, menu_type,
second_menu_id)
values (#{id,jdbcType=INTEGER}, #{hospitalId,jdbcType=BIGINT}, #{permissionRoleId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{url,jdbcType=VARCHAR}, #{parentId,jdbcType=INTEGER},
#{systemType,jdbcType=INTEGER}, #{seq,jdbcType=INTEGER}, #{deleteFlag,jdbcType=INTEGER},
#{creatId,jdbcType=INTEGER}, #{creatTime,jdbcType=TIMESTAMP}, #{modifyId,jdbcType=INTEGER},
#{modifyTime,jdbcType=TIMESTAMP}, #{icon,jdbcType=VARCHAR}, #{menuType,jdbcType=INTEGER},
#{secondMenuId,jdbcType=INTEGER})
</insert>
<insert id="batchInsert" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
insert into p_saas_menu (hospital_id, permission_role_id,
name, url, parent_id,
system_type, seq, delete_flag,
created_id, created_time, modified_id,
modified_time, icon, menu_type,
second_menu_id)
values
<foreach collection="list" item="item" separator=",">
( #{item.hospitalId,jdbcType=BIGINT}, #{item.permissionRoleId,jdbcType=VARCHAR},
#{item.name,jdbcType=VARCHAR}, #{item.url,jdbcType=VARCHAR}, #{item.parentId,jdbcType=INTEGER},
#{item.systemType,jdbcType=INTEGER}, #{item.seq,jdbcType=INTEGER}, #{item.deleteFlag,jdbcType=INTEGER},
#{item.creatId,jdbcType=INTEGER}, #{item.creatTime,jdbcType=TIMESTAMP}, #{item.modifyId,jdbcType=INTEGER},
#{item.modifyTime,jdbcType=TIMESTAMP}, #{item.icon,jdbcType=VARCHAR}, #{item.menuType,jdbcType=INTEGER},
#{item.secondMenuId,jdbcType=INTEGER} )
</foreach>
</insert>
<insert id="insertSelective" parameterType="com.pica.cloud.account.account.server.entity.SaaSMenu">
insert into p_saas_menu
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="hospitalId != null">
hospital_id,
</if>
<if test="permissionRoleId != null">
permission_role_id,
</if>
<if test="name != null">
name,
</if>
<if test="url != null">
url,
</if>
<if test="parentId != null">
parent_id,
</if>
<if test="systemType != null">
system_type,
</if>
<if test="seq != null">
seq,
</if>
<if test="deleteFlag != null">
delete_flag,
</if>
<if test="creatId != null">
created_id,
</if>
<if test="creatTime != null">
created_time,
</if>
<if test="modifyId != null">
modified_id,
</if>
<if test="modifyTime != null">
modified_time,
</if>
<if test="icon != null">
icon,
</if>
<if test="menuType != null">
menu_type,
</if>
<if test="secondMenuId != null">
second_menu_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="hospitalId != null">
#{hospitalId,jdbcType=BIGINT},
</if>
<if test="permissionRoleId != null">
#{permissionRoleId,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="url != null">
#{url,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
#{parentId,jdbcType=INTEGER},
</if>
<if test="systemType != null">
#{systemType,jdbcType=INTEGER},
</if>
<if test="seq != null">
#{seq,jdbcType=INTEGER},
</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="icon != null">
#{icon,jdbcType=VARCHAR},
</if>
<if test="menuType != null">
#{menuType,jdbcType=INTEGER},
</if>
<if test="secondMenuId != null">
#{secondMenuId,jdbcType=INTEGER},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.pica.cloud.account.account.server.entity.SaaSMenu">
update p_saas_menu
<set>
<if test="hospitalId != null">
hospital_id = #{hospitalId,jdbcType=BIGINT},
</if>
<if test="permissionRoleId != null">
permission_role_id = #{permissionRoleId,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="url != null">
url = #{url,jdbcType=VARCHAR},
</if>
<if test="parentId != null">
parent_id = #{parentId,jdbcType=INTEGER},
</if>
<if test="systemType != null">
system_type = #{systemType,jdbcType=INTEGER},
</if>
<if test="seq != null">
seq = #{seq,jdbcType=INTEGER},
</if>
<if test="deleteFlag != null">
delete_flag = #{deleteFlag,jdbcType=INTEGER},
</if>
<if test="creatId != null">
created_id = #{creatId,jdbcType=INTEGER},
</if>
<if test="creatTime != null">
created_time = #{creatTime,jdbcType=TIMESTAMP},
</if>
<if test="modifyId != null">
modified_id = #{modifyId,jdbcType=INTEGER},
</if>
<if test="modifyTime != null">
modified_time = #{modifyTime,jdbcType=TIMESTAMP},
</if>
<if test="icon != null">
icon = #{icon,jdbcType=VARCHAR},
</if>
<if test="menuType != null">
menu_type = #{menuType,jdbcType=INTEGER},
</if>
<if test="secondMenuId != null">
second_menu_id = #{secondMenuId,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.pica.cloud.account.account.server.entity.SaaSMenu">
update p_saas_menu
set hospital_id = #{hospitalId,jdbcType=BIGINT},
permission_role_id = #{permissionRoleId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR},
parent_id = #{parentId,jdbcType=INTEGER},
system_type = #{systemType,jdbcType=INTEGER},
seq = #{seq,jdbcType=INTEGER},
delete_flag = #{deleteFlag,jdbcType=INTEGER},
created_id = #{creatId,jdbcType=INTEGER},
created_time = #{creatTime,jdbcType=TIMESTAMP},
modified_id = #{modifyId,jdbcType=INTEGER},
modified_time = #{modifyTime,jdbcType=TIMESTAMP},
icon = #{icon,jdbcType=VARCHAR},
menu_type = #{menuType,jdbcType=INTEGER},
second_menu_id = #{secondMenuId,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
package com.pica.cloud.account.account.server.mapper;
import com.pica.cloud.account.account.server.service.impl.HospitalSaasUserServiceImpl;
import com.pica.cloud.foundation.utils.entity.PicaUser;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* User: Joy
* Description:
* Date: 2022-03-03 18:08
*/
@RunWith(SpringRunner.class)
@SpringBootTest
public class HospitalSaasUserServiceTest {
@Autowired
private HospitalSaasUserServiceImpl hospitalSaasUserService;
@Test
public void test1(){
PicaUser user = new PicaUser();
user.setId(1000005487);
user.setToken("1234");
hospitalSaasUserService.userDetail(user);
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册