Browse Source

数据源切换问题解决

newMaster
zzc 5 months ago
parent
commit
e9631dd2d4
  1. 6
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/DmsLoginController.java
  2. 3
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/FmsFollowupQueueController.java
  3. 66
      acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsPatientController.java
  4. 4
      acupuncture-admin/src/main/resources/application-stage.yml
  5. 4
      acupuncture-admin/src/main/resources/application.yml
  6. 2
      acupuncture-common/src/main/java/com/acupuncture/common/constant/UserConstants.java
  7. 14
      acupuncture-common/src/main/java/com/acupuncture/common/utils/SecurityUtils.java
  8. 100
      acupuncture-framework/src/main/java/com/acupuncture/framework/aspectj/AdminGlobalDataSourceAspect.java
  9. 47
      acupuncture-framework/src/main/java/com/acupuncture/framework/config/LoadingDataSource.java
  10. 50
      acupuncture-framework/src/main/java/com/acupuncture/framework/datasource/DataSourceManager.java
  11. 36
      acupuncture-framework/src/main/java/com/acupuncture/framework/datasource/DynamicDataSource.java
  12. 2
      acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/UserDetailsServiceImpl.java
  13. 2
      acupuncture-generator/src/main/resources/mbg.xml
  14. 2
      acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/FmsFollowupDto.java
  15. 90
      acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsPatientDto.java
  16. 238
      acupuncture-system/src/main/java/com/acupuncture/system/domain/po/PmsPatient.java
  17. 1528
      acupuncture-system/src/main/java/com/acupuncture/system/domain/po/PmsPatientExample.java
  18. 54
      acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/PmsPatientVo.java
  19. 7
      acupuncture-system/src/main/java/com/acupuncture/system/mapper/SysUserMapper.java
  20. 2
      acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/DmsUserDao.java
  21. 18
      acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/PmsPatientDao.java
  22. 28
      acupuncture-system/src/main/java/com/acupuncture/system/persist/mapper/PmsPatientMapper.java
  23. 8
      acupuncture-system/src/main/java/com/acupuncture/system/service/DmsLoginService.java
  24. 8
      acupuncture-system/src/main/java/com/acupuncture/system/service/ISysUserService.java
  25. 47
      acupuncture-system/src/main/java/com/acupuncture/system/service/PmsPatientService.java
  26. 26
      acupuncture-system/src/main/java/com/acupuncture/system/service/impl/DmsLoginServiceImpl.java
  27. 68
      acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsPatientServiceImpl.java
  28. 5
      acupuncture-system/src/main/java/com/acupuncture/system/service/impl/SysUserServiceImpl.java
  29. 55
      acupuncture-system/src/main/resources/mapper/dao/PmsPatientDao.xml
  30. 5
      acupuncture-system/src/main/resources/mapper/dao/SysPowerDao.xml
  31. 442
      acupuncture-system/src/main/resources/mapper/system/PmsPatientMapper.xml
  32. 10
      acupuncture-system/src/main/resources/mapper/system/SysUserMapper.xml

6
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/DmsLoginController.java

@ -14,6 +14,7 @@ import com.acupuncture.framework.web.service.TokenService;
import com.acupuncture.framework.web.service.WebDmsLoginService;
import com.acupuncture.system.domain.vo.DmsLoginUserVo;
import com.acupuncture.system.service.DmsLoginService;
import com.acupuncture.system.service.ISysUserService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -41,6 +42,8 @@ public class DmsLoginController {
private TokenService tokenService;
@Resource
private DmsLoginService dmsLoginService;
@Resource
private ISysUserService sysUserService;
/**
* 登录方法
@ -66,7 +69,8 @@ public class DmsLoginController {
@GetMapping("getInfo")
public AjaxResult getInfo() {
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser user = loginUser.getUser();
//获取用户从库信息
SysUser user = sysUserService.selectUserByTenantId(loginUser.getTenantId(), loginUser.getUsername());
//刷新token
tokenService.refreshToken(loginUser);
AjaxResult ajax = AjaxResult.success();

3
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/FmsFollowupQueueController.java

@ -1,9 +1,8 @@
package com.acupuncture.web.controller.web;
import com.acupuncture.common.annotation.Anonymous;
import com.acupuncture.common.core.domain.BaseDto;
import com.acupuncture.common.core.domain.JsonResponse;
import com.acupuncture.system.domain.vo.FmsFollowupDto;
import com.acupuncture.system.domain.dto.FmsFollowupDto;
import com.acupuncture.system.domain.vo.FmsFollowupVo;
import com.acupuncture.system.service.FmsFollowupQueueService;
import com.github.pagehelper.PageHelper;

66
acupuncture-admin/src/main/java/com/acupuncture/web/controller/web/PmsPatientController.java

@ -0,0 +1,66 @@
package com.acupuncture.web.controller.web;
import com.acupuncture.common.core.domain.BaseDto;
import com.acupuncture.common.core.domain.JsonResponse;
import com.acupuncture.system.domain.dto.PmsPatientDto;
import com.acupuncture.system.domain.vo.PmsPatientVo;
import com.acupuncture.system.service.PmsPatientService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author zzc
* @Package com.acupuncture.web.controller.web
* @Date 2025/2/11 9:13
* @description:
*/
@Slf4j
@Api(tags = "随访相关")
@RestController
@RequestMapping("/patient")
public class PmsPatientController {
@Resource
private PmsPatientService pmsPatientService;
@ApiOperation("添加患者信息")
@PostMapping("/add")
public JsonResponse<Integer> add(@RequestBody @Validated PmsPatientDto.PatientAdd dto){
pmsPatientService.add(dto);
return JsonResponse.ok();
}
@ApiOperation("修改患者信息")
@PostMapping("/upd")
public JsonResponse<Integer> upd(@RequestBody @Validated PmsPatientDto.PatientUpd dto){
pmsPatientService.upd(dto);
return JsonResponse.ok();
}
@ApiOperation("删除患者信息")
@PostMapping("/del")
public JsonResponse<Integer> del(@RequestBody @Validated PmsPatientDto.Delete dto){
pmsPatientService.del(dto.getIdList());
return JsonResponse.ok();
}
@ApiOperation("查询患者信息")
@PostMapping("/query")
public JsonResponse<PageInfo<PmsPatientVo.PatientResult>> query(@RequestBody @Validated BaseDto<PmsPatientDto.PatientQuery> dto){
if (dto.getPageNum() > 0) {
PageHelper.startPage(dto.getPageNum(), dto.getPageSize());
}
return JsonResponse.ok(new PageInfo<>(pmsPatientService.query(dto.getParam())));
}
}

4
acupuncture-admin/src/main/resources/application-stage.yml

@ -6,9 +6,9 @@ spring:
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/acupuncture?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://sd.tall.wiki:3306/acupuncture?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: q7510327
password: po3OynBO[M3579p6L7)o
# 从库数据源
slave:
# 从数据源开关/默认关闭

4
acupuncture-admin/src/main/resources/application.yml

@ -7,7 +7,7 @@ acupuncture:
# 版权年份
copyrightYear: 2025
# 文件路径 示例( Windows配置D:/acupuncture/uploadPath,Linux配置 /home/acupuncture/uploadPath)
profile: D:/acupuncture/uploadPath
profile: /home/acupuncture/uploadPath
# 获取ip地址开关
addressEnabled: false
# 验证码类型 math 数字计算 char 字符验证
@ -52,7 +52,7 @@ spring:
# 国际化资源文件路径
basename: i18n/messages
profiles:
active: dev
active: stage
# 文件上传
servlet:
multipart:

2
acupuncture-common/src/main/java/com/acupuncture/common/constant/UserConstants.java

@ -78,4 +78,6 @@ public class UserConstants
*/
public static final int PASSWORD_MIN_LENGTH = 5;
public static final int PASSWORD_MAX_LENGTH = 20;
public static final String HEADER_KEY_TOKEN = "Authorization";
}

14
acupuncture-common/src/main/java/com/acupuncture/common/utils/SecurityUtils.java

@ -175,4 +175,18 @@ public class SecurityUtils
.anyMatch(x -> Constants.SUPER_ADMIN.equals(x) || PatternMatchUtils.simpleMatch(x, role));
}
/**
* 租户ID
**/
public static Long getTenantId()
{
try
{
return getLoginUser().getTenantId();
}
catch (Exception e)
{
throw new ServiceException("获取租户ID异常", HttpStatus.UNAUTHORIZED);
}
}
}

100
acupuncture-framework/src/main/java/com/acupuncture/framework/aspectj/AdminGlobalDataSourceAspect.java

@ -0,0 +1,100 @@
package com.acupuncture.framework.aspectj;
import cn.hutool.core.util.StrUtil;
import com.acupuncture.common.constant.UserConstants;
import com.acupuncture.common.exception.base.BaseException;
import com.acupuncture.common.utils.SecurityUtils;
import com.acupuncture.common.utils.StringUtils;
import com.acupuncture.framework.datasource.DataSourceManager;
import com.acupuncture.framework.datasource.DynamicDataSourceContextHolder;
import com.acupuncture.system.domain.po.UmsDataSource;
import com.acupuncture.system.mapper.SysUserMapper;
import com.acupuncture.system.service.DmsLoginService;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
* 多数据源处理
*
* @author cc
*/
@Aspect
@Order(1)
@Component
public class AdminGlobalDataSourceAspect {
protected Logger logger = LoggerFactory.getLogger(getClass());
// @Autowired
// private UmsDataSourceMapper umsDataSourceMapper;
@Resource
private DmsLoginService dmsLoginService;
private static final String DATASOURCE_NOT_FOUND = "未找到数据源";
@Pointcut("(execution(* com.acupuncture.web.controller..*.*(..))) && !@annotation(com.acupuncture.common.annotation.DataSource)")
public void dsPointCut() {
}
@Around("dsPointCut()")
public Object around(ProceedingJoinPoint point) throws Throwable {
String dataSourceKey = getDataSource(point);
if (StringUtils.isNotNull(dataSourceKey)) {
DataSourceManager.setDataSourceKey(dataSourceKey);
}
try {
return point.proceed();
} finally {
// 销毁数据源 在执行方法之后
DynamicDataSourceContextHolder.clearDataSourceType();
}
}
/**
* 获取需要切换的数据源
*/
public String getDataSource(ProceedingJoinPoint point) {
// 获取请求携带的令牌
HttpServletRequest request = ((ServletRequestAttributes)
RequestContextHolder.getRequestAttributes()).getRequest();
String authHeader = request.getHeader(UserConstants.HEADER_KEY_TOKEN);
//token为空
if(StrUtil.isEmpty(authHeader)){
return null;
}
// String deptId = request.getHeader(WebConstant.HEADER_KEY_DEPT_ID);
Long tenantId = SecurityUtils.getTenantId();
if (tenantId == null) {
return null;
}
//设置所属医院和数据源
// SecurityUtils.setCurrentHospitalId(Long.parseLong(deptId));
// // 获取当前的用户
// LoginUser loginUser = SecurityUtils.getLoginUser();
// if(ObjectUtil.isNull(loginUser) || loginUser.getUser().isAdmin()){
// return null;
// }
//根据部门ID查询数据源
UmsDataSource dataSource = dmsLoginService.getDataSourceByTenantId(tenantId);
if (dataSource == null) {
throw new BaseException(DATASOURCE_NOT_FOUND);
}
return dataSource.getDataSourceKey();
}
}

47
acupuncture-framework/src/main/java/com/acupuncture/framework/config/LoadingDataSource.java

@ -0,0 +1,47 @@
package com.acupuncture.framework.config;
import com.acupuncture.common.utils.ExceptionUtil;
import com.acupuncture.framework.datasource.DataSourceManager;
import com.acupuncture.system.domain.po.UmsDataSource;
import com.acupuncture.system.domain.po.UmsDataSourceExample;
import com.acupuncture.system.persist.mapper.UmsDataSourceMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* 启动初始化数据
*
* @author zy
* @date 2024/4/27 15:07
*/
@Component
@Slf4j
public class LoadingDataSource implements InitializingBean {
@Resource
private UmsDataSourceMapper umsDataSourceMapper;
@Resource
private DataSourceManager dataSourceManager;
@Override
public void afterPropertiesSet() {
// 加载数据源
UmsDataSourceExample example = new UmsDataSourceExample();
example.createCriteria().andDelFlagEqualTo((byte) 0);
List<UmsDataSource> baseDataSources = umsDataSourceMapper.selectByExample(example);
log.info("初次启动加载数据源...{}", baseDataSources);
for (UmsDataSource dataSource : baseDataSources) {
try {
dataSourceManager.createDataSource(dataSource);
} catch (Exception e) {
e.printStackTrace();
log.error("加载数据源失败:", ExceptionUtil.getExceptionMessage(e));
}
}
}
}

50
acupuncture-framework/src/main/java/com/acupuncture/framework/datasource/DataSourceManager.java

@ -0,0 +1,50 @@
package com.acupuncture.framework.datasource;
import com.acupuncture.system.domain.po.UmsDataSource;
import com.zaxxer.hikari.HikariDataSource;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author zy
* @date 2024/4/27 15:11
*/
@Component
public class DataSourceManager {
/**
* JDBC数据源连接池
*/
public static final Map<String, DataSource> DATA_SOURCE_POOL_JDBC = new ConcurrentHashMap<>();
public void createDataSource(UmsDataSource ds) {
String datasourceId = ds.getDataSourceKey();
String username = ds.getUsername();
String password = ds.getPassword();
String jdbcUrl = ds.getUrl();
HikariDataSource dataSource = new HikariDataSource();
dataSource.setUsername(username);
dataSource.setPassword(password);
dataSource.setJdbcUrl(jdbcUrl);
dataSource.setMinimumIdle(2);
dataSource.setMaxLifetime(1800000);
dataSource.setIdleTimeout(600000);
dataSource.setConnectionTimeout(10000);
DataSourceManager.DATA_SOURCE_POOL_JDBC.put(datasourceId, dataSource);
}
/**
* 设置数据源key
*
* @param key
*/
public static void setDataSourceKey(String key) {
DynamicDataSourceContextHolder.setDataSourceType(key);
}
}

36
acupuncture-framework/src/main/java/com/acupuncture/framework/datasource/DynamicDataSource.java

@ -1,5 +1,7 @@
package com.acupuncture.framework.datasource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;
import javax.sql.DataSource;
import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
@ -23,4 +25,38 @@ public class DynamicDataSource extends AbstractRoutingDataSource
{
return DynamicDataSourceContextHolder.getDataSourceType();
}
/**
* 切换数据源
*
* @return
*/
@Override
protected DataSource determineTargetDataSource() {
Object dataSourceKey = this.determineCurrentLookupKey();
// 默认系统数据源
if (dataSourceKey == null) {
return super.getResolvedDefaultDataSource();
}
DataSource dataSource = DataSourceManager.DATA_SOURCE_POOL_JDBC.get(dataSourceKey);
if (dataSource == null) {
throw new RuntimeException("数据源不存在!");
}
return dataSource;
}
/**
* 获取连接
*
* @return
* @throws SQLException
*/
@Override
public Connection getConnection() throws SQLException {
Connection connection = this.determineTargetDataSource().getConnection();
return connection;
}
}

2
acupuncture-framework/src/main/java/com/acupuncture/framework/web/service/UserDetailsServiceImpl.java

@ -99,7 +99,7 @@ public class UserDetailsServiceImpl implements UserDetailsService
public UserDetails createLoginUser(DmsLoginUserVo.DataScoreVo user)
{
SysUser sysUser = new SysUser();
sysUser.setUserName(user.getDmsUsername());
sysUser.setUserName(user.getUsername());
sysUser.setUserId(user.getDmsUserId());
return new LoginUser(user.getDmsUserId(), user.getHospitalId(), sysUser, CollUtil.newHashSet(), user.getTenantId() ,user.getScoreId());
}

2
acupuncture-generator/src/main/resources/mbg.xml

@ -62,7 +62,7 @@
<table tableName="fms_followup_queue" domainObjectName="FmsFollowupQueue" enableDeleteByExample="false"/>
<table tableName="fms_followup_task" domainObjectName="FmsFollowupTask" enableDeleteByExample="false"/>
<table tableName="fms_patient_queue_relation" domainObjectName="FmsPatientQueueRelation" enableDeleteByExample="false"/>
<table tableName="pms_patient" domainObjectName="Pms_patient" enableDeleteByExample="false"/>
<table tableName="pms_patient" domainObjectName="PmsPatient" enableDeleteByExample="false"/>
<table tableName="pms_treatment" domainObjectName="PmsTreatment" enableDeleteByExample="false"/>
<table tableName="pms_treatment_record" domainObjectName="PmsTreatmentRecord" enableDeleteByExample="false"/>
<table tableName="rms_report_type" domainObjectName="RmsReportType" enableDeleteByExample="false"/>

2
acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/FmsFollowupDto.java → acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/FmsFollowupDto.java

@ -1,4 +1,4 @@
package com.acupuncture.system.domain.vo;
package com.acupuncture.system.domain.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

90
acupuncture-system/src/main/java/com/acupuncture/system/domain/dto/PmsPatientDto.java

@ -0,0 +1,90 @@
package com.acupuncture.system.domain.dto;
import com.acupuncture.system.domain.po.PmsPatient;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @Author zzc
* @Package com.acupuncture.system.domain.dto
* @Date 2025/2/10 17:26
* @description:
*/
public class PmsPatientDto {
@Data
public static class PatientQuery {
@ApiModelProperty("关键字 支持模糊名字,拼音首拼,拼音全拼")
private String keywords;
@ApiModelProperty("开始年龄")
private Integer startAge;
@ApiModelProperty("结束年龄")
private Integer endAge;
@ApiModelProperty("性别")
private Integer gender;
@ApiModelProperty("建档组织")
private Long tenantId;
@ApiModelProperty("身份证")
private String idCard;
@ApiModelProperty("来源")
private Integer sourceId;
@ApiModelProperty("建档人")
private String createBy;
}
@Data
public static class PatientAdd {
private String name;
private Byte gender;
private Date birthDate;
private String ethnicity;
private Integer educationYears;
private String phone;
private Byte idCardType;
private String idCard;
private Byte source;
private String currentIllnessHistory;
}
@Data
public static class PatientUpd {
private Long id;
private String name;
private Byte gender;
private Date birthDate;
private String ethnicity;
private Integer educationYears;
private String phone;
private Byte idCardType;
private String idCard;
private Byte source;
private String currentIllnessHistory;
}
@Data
public static class Delete {
private List<Long> idList;
}
}

238
acupuncture-system/src/main/java/com/acupuncture/system/domain/po/PmsPatient.java

@ -0,0 +1,238 @@
package com.acupuncture.system.domain.po;
import java.io.Serializable;
import java.util.Date;
public class PmsPatient implements Serializable {
private Long id;
private String name;
private String pinyinFull;
private String pinyinSimple;
private Byte gender;
private Date birthDate;
private String ethnicity;
private Integer educationYears;
private String phone;
private Byte idCardType;
private String idCard;
private Byte source;
private String currentIllnessHistory;
private Byte delFlag;
private Long tenantId;
private String createBy;
private Date createTime;
private String updateBy;
private Date updateTime;
private String remark;
private static final long serialVersionUID = 1L;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getPinyinFull() {
return pinyinFull;
}
public void setPinyinFull(String pinyinFull) {
this.pinyinFull = pinyinFull == null ? null : pinyinFull.trim();
}
public String getPinyinSimple() {
return pinyinSimple;
}
public void setPinyinSimple(String pinyinSimple) {
this.pinyinSimple = pinyinSimple == null ? null : pinyinSimple.trim();
}
public Byte getGender() {
return gender;
}
public void setGender(Byte gender) {
this.gender = gender;
}
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
public String getEthnicity() {
return ethnicity;
}
public void setEthnicity(String ethnicity) {
this.ethnicity = ethnicity == null ? null : ethnicity.trim();
}
public Integer getEducationYears() {
return educationYears;
}
public void setEducationYears(Integer educationYears) {
this.educationYears = educationYears;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone == null ? null : phone.trim();
}
public Byte getIdCardType() {
return idCardType;
}
public void setIdCardType(Byte idCardType) {
this.idCardType = idCardType;
}
public String getIdCard() {
return idCard;
}
public void setIdCard(String idCard) {
this.idCard = idCard == null ? null : idCard.trim();
}
public Byte getSource() {
return source;
}
public void setSource(Byte source) {
this.source = source;
}
public String getCurrentIllnessHistory() {
return currentIllnessHistory;
}
public void setCurrentIllnessHistory(String currentIllnessHistory) {
this.currentIllnessHistory = currentIllnessHistory == null ? null : currentIllnessHistory.trim();
}
public Byte getDelFlag() {
return delFlag;
}
public void setDelFlag(Byte delFlag) {
this.delFlag = delFlag;
}
public Long getTenantId() {
return tenantId;
}
public void setTenantId(Long tenantId) {
this.tenantId = tenantId;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy == null ? null : createBy.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy == null ? null : updateBy.trim();
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark == null ? null : remark.trim();
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", name=").append(name);
sb.append(", pinyinFull=").append(pinyinFull);
sb.append(", pinyinSimple=").append(pinyinSimple);
sb.append(", gender=").append(gender);
sb.append(", birthDate=").append(birthDate);
sb.append(", ethnicity=").append(ethnicity);
sb.append(", educationYears=").append(educationYears);
sb.append(", phone=").append(phone);
sb.append(", idCardType=").append(idCardType);
sb.append(", idCard=").append(idCard);
sb.append(", source=").append(source);
sb.append(", currentIllnessHistory=").append(currentIllnessHistory);
sb.append(", delFlag=").append(delFlag);
sb.append(", tenantId=").append(tenantId);
sb.append(", createBy=").append(createBy);
sb.append(", createTime=").append(createTime);
sb.append(", updateBy=").append(updateBy);
sb.append(", updateTime=").append(updateTime);
sb.append(", remark=").append(remark);
sb.append("]");
return sb.toString();
}
}

1528
acupuncture-system/src/main/java/com/acupuncture/system/domain/po/PmsPatientExample.java

File diff suppressed because it is too large

54
acupuncture-system/src/main/java/com/acupuncture/system/domain/vo/PmsPatientVo.java

@ -0,0 +1,54 @@
package com.acupuncture.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @Author zzc
* @Package com.acupuncture.system.domain.vo
* @Date 2025/2/10 17:22
* @description:
*/
public class PmsPatientVo {
@Data
public static class PatientResult {
@ApiModelProperty("")
private Long id;
@ApiModelProperty("患者姓名")
private String name;
@ApiModelProperty("性别(0男, 1女)")
private Integer gender;
@ApiModelProperty("出生日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date birthDate;
@ApiModelProperty("民族")
private String ethnicity;
@ApiModelProperty("受教育年限")
private Integer educationYears;
@ApiModelProperty("手机号码")
private String phone;
@ApiModelProperty("证件类型(0身份证;1护照或外国人永居证; 2港澳居民来往内地通行; 3台湾居民来往大陆通行证; 4其他;)")
private Integer idCardType;
@ApiModelProperty("证件号码")
private String idCard;
@ApiModelProperty("数据来源(0筛查, 1录入, 2HIS)")
private Integer source;
@ApiModelProperty("现病史,存储格式:[\"高血压\",\"脑血管病\"]")
private String currentIllnessHistory;
@ApiModelProperty("建档组织(当前登录账号医院ID)")
private Long organizationId;
@ApiModelProperty("创建者")
private String createBy;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("备注")
private String remark;
}
}

7
acupuncture-system/src/main/java/com/acupuncture/system/mapper/SysUserMapper.java

@ -51,6 +51,13 @@ public interface SysUserMapper
*/
public SysUser selectUserById(Long userId);
/**
* 通过租户ID和用户名查询用户
*
* @param userId 用户ID
* @return 用户对象信息
*/
SysUser selectUserByTenantId(@Param("tenantId") Long tenantId, @Param("userName") String userName);
/**
* 新增用户信息
*

2
acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/DmsUserDao.java

@ -20,7 +20,6 @@ public interface DmsUserDao {
* @param userName 用户名
* @return 用户对象信息
*/
@DataSource(DataSourceType.MASTER)
DmsLoginUserVo.DmsUserVo selectUserByUserName(@Param("userName") String userName);
/**
@ -28,7 +27,6 @@ public interface DmsUserDao {
* @param userName
* @return
*/
@DataSource(DataSourceType.MASTER)
DmsLoginUserVo.DataScoreVo queryLoginUserDataScore(@Param("userName") String userName);
/**

18
acupuncture-system/src/main/java/com/acupuncture/system/persist/dao/PmsPatientDao.java

@ -0,0 +1,18 @@
package com.acupuncture.system.persist.dao;
import com.acupuncture.system.domain.dto.PmsPatientDto;
import com.acupuncture.system.domain.vo.PmsPatientVo;
import java.util.List;
/**
* @Author zzc
* @Package com.acupuncture.system.persist.dao
* @Date 2025/2/10 17:55
* @description:
*/
public interface PmsPatientDao {
List<PmsPatientVo.PatientResult> query(PmsPatientDto.PatientQuery dto);
}

28
acupuncture-system/src/main/java/com/acupuncture/system/persist/mapper/PmsPatientMapper.java

@ -0,0 +1,28 @@
package com.acupuncture.system.persist.mapper;
import com.acupuncture.system.domain.po.PmsPatient;
import com.acupuncture.system.domain.po.PmsPatientExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface PmsPatientMapper {
long countByExample(PmsPatientExample example);
int deleteByPrimaryKey(Long id);
int insert(PmsPatient record);
int insertSelective(PmsPatient record);
List<PmsPatient> selectByExample(PmsPatientExample example);
PmsPatient selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") PmsPatient record, @Param("example") PmsPatientExample example);
int updateByExample(@Param("record") PmsPatient record, @Param("example") PmsPatientExample example);
int updateByPrimaryKeySelective(PmsPatient record);
int updateByPrimaryKey(PmsPatient record);
}

8
acupuncture-system/src/main/java/com/acupuncture/system/service/DmsLoginService.java

@ -2,6 +2,7 @@ package com.acupuncture.system.service;
import com.acupuncture.common.core.domain.entity.SysUser;
import com.acupuncture.system.domain.po.DmsUser;
import com.acupuncture.system.domain.po.UmsDataSource;
import com.acupuncture.system.domain.vo.DmsLoginUserVo;
/**
@ -27,4 +28,11 @@ public interface DmsLoginService {
* @return 结果
*/
public int resetPwd(DmsLoginUserVo.DmsUserVo user);
/**
* 根据租户ID获取数据源
* @param tenantId
* @return
*/
UmsDataSource getDataSourceByTenantId(Long tenantId);
}

8
acupuncture-system/src/main/java/com/acupuncture/system/service/ISysUserService.java

@ -50,6 +50,14 @@ public interface ISysUserService
*/
public SysUser selectUserById(Long userId);
/**
* 通过用户ID查询用户
*
* @param userId 用户ID
* @return 用户对象信息
*/
public SysUser selectUserByTenantId(Long tenantId, String username);
/**
* 根据用户ID查询用户所属角色组
*

47
acupuncture-system/src/main/java/com/acupuncture/system/service/PmsPatientService.java

@ -0,0 +1,47 @@
package com.acupuncture.system.service;
import com.acupuncture.common.annotation.DataSource;
import com.acupuncture.common.enums.DataSourceType;
import com.acupuncture.system.domain.dto.PmsPatientDto;
import com.acupuncture.system.domain.vo.PmsPatientVo;
import java.util.List;
/**
* @Author zzc
* @Package com.acupuncture.system.service
* @Date 2025/2/10 17:29
* @description:
*/
public interface PmsPatientService {
/**
* 添加患者信息
* @param dto
* @return
*/
int add(PmsPatientDto.PatientAdd dto);
/**
* 修改患者信息
* @param dto
* @return
*/
int upd(PmsPatientDto.PatientUpd dto);
/**
* 删除患者信息
* @param idList
* @return
*/
int del(List<Long> idList);
/**
* 查询患者信息
* @param dto
* @return
*/
List<PmsPatientVo.PatientResult> query(PmsPatientDto.PatientQuery dto);
}

26
acupuncture-system/src/main/java/com/acupuncture/system/service/impl/DmsLoginServiceImpl.java

@ -1,8 +1,12 @@
package com.acupuncture.system.service.impl;
import com.acupuncture.system.domain.po.DmsTenant;
import com.acupuncture.system.domain.po.DmsUser;
import com.acupuncture.system.domain.po.UmsDataSource;
import com.acupuncture.system.domain.vo.DmsLoginUserVo;
import com.acupuncture.system.persist.dao.DmsUserDao;
import com.acupuncture.system.persist.mapper.DmsTenantMapper;
import com.acupuncture.system.persist.mapper.UmsDataSourceMapper;
import com.acupuncture.system.service.DmsLoginService;
import org.springframework.stereotype.Service;
@ -20,6 +24,12 @@ public class DmsLoginServiceImpl implements DmsLoginService {
@Resource
private DmsUserDao dmsUserDao;
@Resource
private DmsTenantMapper dmsTenantMapper;
@Resource
private UmsDataSourceMapper umsDataSourceMapper;
@Override
public DmsLoginUserVo.DataScoreVo selectUserByUserName(String userName) {
return dmsUserDao.queryLoginUserDataScore(userName);
@ -29,4 +39,20 @@ public class DmsLoginServiceImpl implements DmsLoginService {
public int resetPwd(DmsLoginUserVo.DmsUserVo user) {
return dmsUserDao.updateUser(user);
}
@Override
public UmsDataSource getDataSourceByTenantId(Long tenantId) {
DmsTenant dmsTenant = dmsTenantMapper.selectByPrimaryKey(tenantId);
if (dmsTenant == null || dmsTenant.getDelFlag() == 1) {
return null;
}
if (dmsTenant.getDataSourceId() != null) {
UmsDataSource umsDataSource = umsDataSourceMapper.selectByPrimaryKey(dmsTenant.getDataSourceId());
if (umsDataSource == null || umsDataSource.getDelFlag() == 1) {
return null;
}
return umsDataSource;
}
return null;
}
}

68
acupuncture-system/src/main/java/com/acupuncture/system/service/impl/PmsPatientServiceImpl.java

@ -0,0 +1,68 @@
package com.acupuncture.system.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import com.acupuncture.common.utils.SecurityUtils;
import com.acupuncture.system.domain.dto.PmsPatientDto;
import com.acupuncture.system.domain.po.PmsPatient;
import com.acupuncture.system.domain.po.PmsPatientExample;
import com.acupuncture.system.domain.vo.PmsPatientVo;
import com.acupuncture.system.persist.dao.PmsPatientDao;
import com.acupuncture.system.persist.mapper.PmsPatientMapper;
import com.acupuncture.system.service.PmsPatientService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* @Author zzc
* @Package com.acupuncture.system.service
* @Date 2025/2/10 17:29
* @description:
*/
@Service
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class PmsPatientServiceImpl implements PmsPatientService {
@Resource
private PmsPatientMapper pmsPatientMapper;
@Resource
private PmsPatientDao pmsPatientDao;
@Override
public int add(PmsPatientDto.PatientAdd dto) {
PmsPatient pmsPatient = BeanUtil.copyProperties(dto, PmsPatient.class);
pmsPatient.setId(IdUtil.getSnowflakeNextId());
pmsPatient.setCreateBy(SecurityUtils.getUsername());
pmsPatient.setDelFlag((byte) 0);
pmsPatient.setCreateTime(new Date());
pmsPatient.setTenantId(SecurityUtils.getTenantId());
return pmsPatientMapper.insertSelective(pmsPatient);
}
@Override
public int upd(PmsPatientDto.PatientUpd dto) {
PmsPatient pmsPatient = BeanUtil.copyProperties(dto, PmsPatient.class);
pmsPatient.setUpdateBy(SecurityUtils.getUsername());
pmsPatient.setUpdateTime(new Date());
return pmsPatientMapper.updateByPrimaryKeySelective(pmsPatient);
}
@Override
public int del(List<Long> idList) {
PmsPatientExample pmsPatientExample = new PmsPatientExample();
pmsPatientExample.createCriteria().andIdIn(idList).andDelFlagEqualTo((byte) 0);
PmsPatient pmsPatient = new PmsPatient();
pmsPatient.setDelFlag((byte) 1);
return pmsPatientMapper.updateByExampleSelective(pmsPatient, pmsPatientExample);
}
@Override
public List<PmsPatientVo.PatientResult> query(PmsPatientDto.PatientQuery dto) {
return pmsPatientDao.query(dto);
}
}

5
acupuncture-system/src/main/java/com/acupuncture/system/service/impl/SysUserServiceImpl.java

@ -128,6 +128,11 @@ public class SysUserServiceImpl implements ISysUserService
return userMapper.selectUserById(userId);
}
@Override
public SysUser selectUserByTenantId(Long tenantId, String username) {
return userMapper.selectUserByTenantId(tenantId, username);
}
/**
* 查询用户所属角色组
*

55
acupuncture-system/src/main/resources/mapper/dao/PmsPatientDao.xml

@ -0,0 +1,55 @@
<?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.acupuncture.system.persist.dao.PmsPatientDao">
<select id="query" resultType="com.acupuncture.system.domain.vo.PmsPatientVo$PatientResult"
parameterType="com.acupuncture.system.domain.dto.PmsPatientDto$PatientQuery">
SELECT
id,
name,
gender,
birth_date as birthDate,
ethnicity,
education_years as educationYears,
phone,
id_card_type as idCardType,
id_card as idCard,
source,
current_illness_history as currentIllnessHistory,
create_by as createBy,
create_time as createTime
FROM
pms_patient
<where>
del_flag = 0
<if test="query.tenantId != null">
AND tenant_id = #{query.tenantId}
</if>
<if test="query.gender != null">
AND gender = #{query.gender}
</if>
<if test="query.phone != null and query.phone != ''">
AND phone = #{query.phone}
</if>
<if test="query.idCard != null and query.idCard != ''">
AND id_card = #{query.idCard}
</if>
<if test="query.source != null">
AND source = #{query.source}
</if>
<if test="query.startAge != null">
AND DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), birth_date)), '%Y') + 0 &gt;= #{query.startAge}
</if>
<if test="query.endAge != null">
AND DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), birth_date)), '%Y') + 0 &lt;= #{query.endAge}
</if>
<if test="query.keywords != null and query.keywords != ''">
AND (
name LIKE CONCAT('%', #{query.keywords}, '%')
OR pinyin_full LIKE CONCAT('%', #{query.keywords}, '%')
OR pinyin_simple LIKE CONCAT('%', #{query.keywords}, '%')
)
</if>
</where>
</select>
</mapper>

5
acupuncture-system/src/main/resources/mapper/dao/SysPowerDao.xml

@ -23,7 +23,7 @@
select
d.id as dmsUserId,
d.nick_name as dmsUserNickName,
d.user_name,
d.user_name as username,
d.password,
s.id as scoreId,
s.data_source_key as dataSourceKey,
@ -42,7 +42,7 @@
left join
ums_data_source s
on
d.tenant_id = t.id
t.data_source_id = s.id
<where>
<if test="userName != null and userName != ''">
and d.user_name = #{userName}
@ -50,6 +50,7 @@
and s.del_flag = 0
and t.del_flag = 0
</where>
group by d.id
</select>
<update id="updateUser" parameterType="com.acupuncture.system.domain.vo.DmsLoginUserVo$DmsUserVo">

442
acupuncture-system/src/main/resources/mapper/system/PmsPatientMapper.xml

@ -0,0 +1,442 @@
<?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.acupuncture.system.persist.mapper.PmsPatientMapper">
<resultMap id="BaseResultMap" type="com.acupuncture.system.domain.po.PmsPatient">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="pinyin_full" jdbcType="VARCHAR" property="pinyinFull" />
<result column="pinyin_simple" jdbcType="VARCHAR" property="pinyinSimple" />
<result column="gender" jdbcType="TINYINT" property="gender" />
<result column="birth_date" jdbcType="DATE" property="birthDate" />
<result column="ethnicity" jdbcType="VARCHAR" property="ethnicity" />
<result column="education_years" jdbcType="INTEGER" property="educationYears" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="id_card_type" jdbcType="TINYINT" property="idCardType" />
<result column="id_card" jdbcType="VARCHAR" property="idCard" />
<result column="source" jdbcType="TINYINT" property="source" />
<result column="current_illness_history" jdbcType="VARCHAR" property="currentIllnessHistory" />
<result column="del_flag" jdbcType="TINYINT" property="delFlag" />
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, name, pinyin_full, pinyin_simple, gender, birth_date, ethnicity, education_years,
phone, id_card_type, id_card, source, current_illness_history, del_flag, tenant_id,
create_by, create_time, update_by, update_time, remark
</sql>
<select id="selectByExample" parameterType="com.acupuncture.system.domain.po.PmsPatientExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from pms_patient
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from pms_patient
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from pms_patient
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.acupuncture.system.domain.po.PmsPatient">
insert into pms_patient (id, name, pinyin_full,
pinyin_simple, gender, birth_date,
ethnicity, education_years, phone,
id_card_type, id_card, source,
current_illness_history, del_flag, tenant_id,
create_by, create_time, update_by,
update_time, remark)
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{pinyinFull,jdbcType=VARCHAR},
#{pinyinSimple,jdbcType=VARCHAR}, #{gender,jdbcType=TINYINT}, #{birthDate,jdbcType=DATE},
#{ethnicity,jdbcType=VARCHAR}, #{educationYears,jdbcType=INTEGER}, #{phone,jdbcType=VARCHAR},
#{idCardType,jdbcType=TINYINT}, #{idCard,jdbcType=VARCHAR}, #{source,jdbcType=TINYINT},
#{currentIllnessHistory,jdbcType=VARCHAR}, #{delFlag,jdbcType=TINYINT}, #{tenantId,jdbcType=BIGINT},
#{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
#{updateTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.acupuncture.system.domain.po.PmsPatient">
insert into pms_patient
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
name,
</if>
<if test="pinyinFull != null">
pinyin_full,
</if>
<if test="pinyinSimple != null">
pinyin_simple,
</if>
<if test="gender != null">
gender,
</if>
<if test="birthDate != null">
birth_date,
</if>
<if test="ethnicity != null">
ethnicity,
</if>
<if test="educationYears != null">
education_years,
</if>
<if test="phone != null">
phone,
</if>
<if test="idCardType != null">
id_card_type,
</if>
<if test="idCard != null">
id_card,
</if>
<if test="source != null">
source,
</if>
<if test="currentIllnessHistory != null">
current_illness_history,
</if>
<if test="delFlag != null">
del_flag,
</if>
<if test="tenantId != null">
tenant_id,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="remark != null">
remark,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=BIGINT},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="pinyinFull != null">
#{pinyinFull,jdbcType=VARCHAR},
</if>
<if test="pinyinSimple != null">
#{pinyinSimple,jdbcType=VARCHAR},
</if>
<if test="gender != null">
#{gender,jdbcType=TINYINT},
</if>
<if test="birthDate != null">
#{birthDate,jdbcType=DATE},
</if>
<if test="ethnicity != null">
#{ethnicity,jdbcType=VARCHAR},
</if>
<if test="educationYears != null">
#{educationYears,jdbcType=INTEGER},
</if>
<if test="phone != null">
#{phone,jdbcType=VARCHAR},
</if>
<if test="idCardType != null">
#{idCardType,jdbcType=TINYINT},
</if>
<if test="idCard != null">
#{idCard,jdbcType=VARCHAR},
</if>
<if test="source != null">
#{source,jdbcType=TINYINT},
</if>
<if test="currentIllnessHistory != null">
#{currentIllnessHistory,jdbcType=VARCHAR},
</if>
<if test="delFlag != null">
#{delFlag,jdbcType=TINYINT},
</if>
<if test="tenantId != null">
#{tenantId,jdbcType=BIGINT},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="remark != null">
#{remark,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.acupuncture.system.domain.po.PmsPatientExample" resultType="java.lang.Long">
select count(*) from pms_patient
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update pms_patient
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.pinyinFull != null">
pinyin_full = #{record.pinyinFull,jdbcType=VARCHAR},
</if>
<if test="record.pinyinSimple != null">
pinyin_simple = #{record.pinyinSimple,jdbcType=VARCHAR},
</if>
<if test="record.gender != null">
gender = #{record.gender,jdbcType=TINYINT},
</if>
<if test="record.birthDate != null">
birth_date = #{record.birthDate,jdbcType=DATE},
</if>
<if test="record.ethnicity != null">
ethnicity = #{record.ethnicity,jdbcType=VARCHAR},
</if>
<if test="record.educationYears != null">
education_years = #{record.educationYears,jdbcType=INTEGER},
</if>
<if test="record.phone != null">
phone = #{record.phone,jdbcType=VARCHAR},
</if>
<if test="record.idCardType != null">
id_card_type = #{record.idCardType,jdbcType=TINYINT},
</if>
<if test="record.idCard != null">
id_card = #{record.idCard,jdbcType=VARCHAR},
</if>
<if test="record.source != null">
source = #{record.source,jdbcType=TINYINT},
</if>
<if test="record.currentIllnessHistory != null">
current_illness_history = #{record.currentIllnessHistory,jdbcType=VARCHAR},
</if>
<if test="record.delFlag != null">
del_flag = #{record.delFlag,jdbcType=TINYINT},
</if>
<if test="record.tenantId != null">
tenant_id = #{record.tenantId,jdbcType=BIGINT},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.updateBy != null">
update_by = #{record.updateBy,jdbcType=VARCHAR},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
<if test="record.remark != null">
remark = #{record.remark,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update pms_patient
set id = #{record.id,jdbcType=BIGINT},
name = #{record.name,jdbcType=VARCHAR},
pinyin_full = #{record.pinyinFull,jdbcType=VARCHAR},
pinyin_simple = #{record.pinyinSimple,jdbcType=VARCHAR},
gender = #{record.gender,jdbcType=TINYINT},
birth_date = #{record.birthDate,jdbcType=DATE},
ethnicity = #{record.ethnicity,jdbcType=VARCHAR},
education_years = #{record.educationYears,jdbcType=INTEGER},
phone = #{record.phone,jdbcType=VARCHAR},
id_card_type = #{record.idCardType,jdbcType=TINYINT},
id_card = #{record.idCard,jdbcType=VARCHAR},
source = #{record.source,jdbcType=TINYINT},
current_illness_history = #{record.currentIllnessHistory,jdbcType=VARCHAR},
del_flag = #{record.delFlag,jdbcType=TINYINT},
tenant_id = #{record.tenantId,jdbcType=BIGINT},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_by = #{record.updateBy,jdbcType=VARCHAR},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
remark = #{record.remark,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.acupuncture.system.domain.po.PmsPatient">
update pms_patient
<set>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="pinyinFull != null">
pinyin_full = #{pinyinFull,jdbcType=VARCHAR},
</if>
<if test="pinyinSimple != null">
pinyin_simple = #{pinyinSimple,jdbcType=VARCHAR},
</if>
<if test="gender != null">
gender = #{gender,jdbcType=TINYINT},
</if>
<if test="birthDate != null">
birth_date = #{birthDate,jdbcType=DATE},
</if>
<if test="ethnicity != null">
ethnicity = #{ethnicity,jdbcType=VARCHAR},
</if>
<if test="educationYears != null">
education_years = #{educationYears,jdbcType=INTEGER},
</if>
<if test="phone != null">
phone = #{phone,jdbcType=VARCHAR},
</if>
<if test="idCardType != null">
id_card_type = #{idCardType,jdbcType=TINYINT},
</if>
<if test="idCard != null">
id_card = #{idCard,jdbcType=VARCHAR},
</if>
<if test="source != null">
source = #{source,jdbcType=TINYINT},
</if>
<if test="currentIllnessHistory != null">
current_illness_history = #{currentIllnessHistory,jdbcType=VARCHAR},
</if>
<if test="delFlag != null">
del_flag = #{delFlag,jdbcType=TINYINT},
</if>
<if test="tenantId != null">
tenant_id = #{tenantId,jdbcType=BIGINT},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.acupuncture.system.domain.po.PmsPatient">
update pms_patient
set name = #{name,jdbcType=VARCHAR},
pinyin_full = #{pinyinFull,jdbcType=VARCHAR},
pinyin_simple = #{pinyinSimple,jdbcType=VARCHAR},
gender = #{gender,jdbcType=TINYINT},
birth_date = #{birthDate,jdbcType=DATE},
ethnicity = #{ethnicity,jdbcType=VARCHAR},
education_years = #{educationYears,jdbcType=INTEGER},
phone = #{phone,jdbcType=VARCHAR},
id_card_type = #{idCardType,jdbcType=TINYINT},
id_card = #{idCard,jdbcType=VARCHAR},
source = #{source,jdbcType=TINYINT},
current_illness_history = #{currentIllnessHistory,jdbcType=VARCHAR},
del_flag = #{delFlag,jdbcType=TINYINT},
tenant_id = #{tenantId,jdbcType=BIGINT},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR},
update_time = #{updateTime,jdbcType=TIMESTAMP},
remark = #{remark,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>

10
acupuncture-system/src/main/resources/mapper/system/SysUserMapper.xml

@ -6,6 +6,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="SysUser" id="SysUserResult">
<id property="userId" column="user_id" />
<result property="tenantId" column="tenant_id" />
<result property="deptId" column="dept_id" />
<result property="userName" column="user_name" />
<result property="nickName" column="nick_name" />
@ -47,7 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectUserVo">
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
select u.user_id, u.tenant_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
from sys_user u
@ -129,7 +130,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectUserVo"/>
where u.user_id = #{userId}
</select>
<select id="selectUserByTenantId" resultMap="SysUserResult">
<include refid="selectUserVo"/>
where u.tenant_id = #{tenantId} and u.user_name = #{userName}
</select>
<select id="checkUserNameUnique" parameterType="String" resultMap="SysUserResult">
select user_id, user_name from sys_user where user_name = #{userName} and del_flag = '0' limit 1
</select>

Loading…
Cancel
Save