From 56aea7aa05995ac0cca7c28e1324c4360afd4df5 Mon Sep 17 00:00:00 2001 From: mitao <2763622819@qq.com> Date: 星期五, 06 十二月 2024 18:02:16 +0800 Subject: [PATCH] 系统管理:用户管理接口 --- medicalWaste-admin/src/main/resources/application.yml | 215 ---------- medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysDepartmentServiceImpl.java | 3 medicalWaste-system/src/main/resources/mapper/system/SysDepartmentMapper.xml | 2 medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/system/SysIndexController.java | 27 + medicalWaste-common/src/main/java/com/sinata/common/core/domain/BaseEntity.java | 9 medicalWaste-system/src/main/java/com/sinata/system/mapper/SysUserMapper.java | 21 medicalWaste-system/src/main/java/com/sinata/system/service/ISysUserService.java | 50 ++ medicalWaste-system/src/main/java/com/sinata/system/domain/SysDepartmentInfo.java | 4 medicalWaste-system/src/main/java/com/sinata/system/domain/query/SysUserQuery.java | 27 + medicalWaste-system/src/main/resources/mapper/system/SysUserMapper.xml | 30 + medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysUserServiceImpl.java | 164 +++++++ medicalWaste-common/src/main/java/com/sinata/common/core/domain/entity/SysUser.java | 66 ++ /dev/null | 0 medicalWaste-framework/src/main/java/com/sinata/framework/config/SecurityConfig.java | 2 medicalWaste-admin/src/main/resources/application-prod.yml | 214 ++++++++++ medicalWaste-system/src/main/java/com/sinata/system/domain/vo/SysUserVO.java | 37 + medicalWaste-system/src/main/java/com/sinata/system/service/SysDepartmentService.java | 12 medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/system/SysUserController.java | 86 ++++ medicalWaste-system/src/main/java/com/sinata/system/domain/dto/SysUserStatusDTO.java | 26 + medicalWaste-admin/src/main/resources/application-dev.yml | 214 ++++++++++ medicalWaste-system/src/main/java/com/sinata/system/mapper/SysUserRoleMapper.java | 8 medicalWaste-system/src/main/java/com/sinata/system/domain/dto/SysUserDTO.java | 39 + 22 files changed, 1,001 insertions(+), 255 deletions(-) diff --git a/medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/system/SysIndexController.java b/medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/system/SysIndexController.java index 23a84e0..d9665f5 100644 --- a/medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/system/SysIndexController.java +++ b/medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/system/SysIndexController.java @@ -1,28 +1,43 @@ package com.sinata.web.controller.backend.system; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import com.sinata.common.config.RuoYiConfig; import com.sinata.common.utils.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; /** * 首页 * * @author ruoyi */ -@RestController +@Controller public class SysIndexController { /** 系统基础配置 */ @Autowired private RuoYiConfig ruoyiConfig; + @Value("${spring.profiles.active}") + private String env; + + @RequestMapping("/") + public String index() { + if (!env.equals("dev")) { + return "redirect:/msg"; + } else { + return "redirect:/doc.html"; + } + } + /** * 访问首页,提示语 */ - @RequestMapping("/") - public String index() + @RequestMapping("/msg") + @ResponseBody + public String msg() { return StringUtils.format("欢迎使用{}后台管理框架,当前版本:v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion()); } diff --git a/medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/system/SysUserController.java b/medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/system/SysUserController.java index 0696fdb..f6798de 100644 --- a/medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/system/SysUserController.java +++ b/medicalWaste-admin/src/main/java/com/sinata/web/controller/backend/system/SysUserController.java @@ -3,20 +3,27 @@ import com.sinata.common.annotation.Log; import com.sinata.common.core.controller.BaseController; import com.sinata.common.core.domain.AjaxResult; +import com.sinata.common.core.domain.R; import com.sinata.common.core.domain.entity.SysDept; import com.sinata.common.core.domain.entity.SysRole; import com.sinata.common.core.domain.entity.SysUser; import com.sinata.common.core.page.TableDataInfo; +import com.sinata.common.entity.PageDTO; import com.sinata.common.enums.BusinessType; import com.sinata.common.utils.SecurityUtils; import com.sinata.common.utils.StringUtils; import com.sinata.common.utils.poi.ExcelUtil; +import com.sinata.system.domain.dto.SysUserDTO; +import com.sinata.system.domain.dto.SysUserStatusDTO; +import com.sinata.system.domain.query.SysUserQuery; +import com.sinata.system.domain.vo.SysUserVO; import com.sinata.system.service.ISysDeptService; import com.sinata.system.service.ISysPostService; import com.sinata.system.service.ISysRoleService; import com.sinata.system.service.ISysUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import org.apache.commons.lang3.ArrayUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; @@ -31,6 +38,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; import java.util.List; import java.util.stream.Collectors; @@ -40,6 +48,7 @@ * @author ruoyi */ @Api(tags = {"管理后台-用户管理"}) +@Validated @RestController @RequestMapping("/backend/system/user") public class SysUserController extends BaseController @@ -56,6 +65,82 @@ @Autowired private ISysPostService postService; + /** + * 用户分页列表 + * + * @param query + * @return + */ + @ApiOperation("用户分页列表") + @PostMapping("/page") + public R<PageDTO<SysUserVO>> pageList(@RequestBody SysUserQuery query) { + return R.ok(userService.pageList(query)); + } + + /** + * 新增用户 + * + * @param dto + * @return + */ + @ApiOperation("新增用户") + @PostMapping("/add") + public R<?> add(@Valid @RequestBody SysUserDTO dto) { + userService.add(dto); + return R.ok(); + } + + /** + * 编辑用户 + * + * @param dto + * @return + */ + @ApiOperation("编辑用户") + @PostMapping("/edit") + public R<?> edit(@Valid @RequestBody SysUserDTO dto) { + userService.edit(dto); + return R.ok(); + } + + /** + * 查询用户详情 + * + * @param userId + * @return + */ + @ApiOperation("用户详情") + @GetMapping("/detail/{userId}") + public R<SysUserVO> getDetailInfo(@ApiParam(name = "userId", value = "用户id", required = true) @PathVariable("userId") Long userId) { + return R.ok(userService.getDetailInfo(userId)); + } + + /** + * 批量修改账号状态 + * + * @param userIds + * @param status + * @return + */ + @ApiOperation("批量修改账号状态") + @PostMapping("/updStatusBatch") + public R<?> updStatusBatch(@Valid @RequestBody SysUserStatusDTO dto) { + userService.updStatusBatch(dto); + return R.ok(); + } + + /** + * 批量删除 + * + * @param userIds + * @return + */ + @ApiOperation("批量删除") + @PostMapping("/delBatch") + public R<?> delBatch(@RequestBody List<Long> userIds) { + userService.delBatch(userIds); + return R.ok(); + } /** * 获取用户列表 */ @@ -124,7 +209,6 @@ */ //@PreAuthorize("@ss.hasPermi('system:user:add')") @Log(title = "用户管理", businessType = BusinessType.INSERT) - @ApiOperation(value = "新增用户") @PostMapping public AjaxResult add(@Validated @RequestBody SysUser user) { diff --git a/medicalWaste-admin/src/main/resources/application-dev.yml b/medicalWaste-admin/src/main/resources/application-dev.yml new file mode 100644 index 0000000..70d3e5b --- /dev/null +++ b/medicalWaste-admin/src/main/resources/application-dev.yml @@ -0,0 +1,214 @@ +# 项目相关配置 +ruoyi: + # 名称 + name: RuoYi + # 版本 + version: 3.8.8 + # 版权年份 + copyrightYear: 2024 + # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) + profile: D:/ruoyi/uploadPath + # 获取ip地址开关 + addressEnabled: false + # 验证码类型 math 数字计算 char 字符验证 + captchaType: math + +# 开发环境配置 +server: + # 服务器的HTTP端口,默认为8080 + port: 8080 + servlet: + # 应用的访问路径 + context-path: / + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # 连接数满后的排队数,默认为100 + accept-count: 1000 + threads: + # tomcat最大线程数,默认为200 + max: 800 + # Tomcat启动初始化的线程数,默认值10 + min-spare: 100 + +# 日志配置 +logging: + level: + com.sinata: debug + org.springframework: warn + +# 用户配置 +user: + password: + # 密码最大错误次数 + maxRetryCount: 5 + # 密码锁定时间(默认10分钟) + lockTime: 10 +# Spring配置 +spring: + # 资源信息 + messages: + # 国际化资源文件路径 + basename: i18n/messages + # 文件上传 + servlet: + multipart: + # 单个文件大小 + max-file-size: 10MB + # 设置总上传的文件大小 + max-request-size: 20MB + # 服务模块 + devtools: + restart: + # 热部署开关 + enabled: true + # redis 配置 + redis: + # 地址 + host: localhost + # 端口,默认为6379 + port: 6379 + # 数据库索引 + database: 0 + # 密码 + password: 123456 + # 连接超时时间 + timeout: 10s + lettuce: + pool: + # 连接池中的最小空闲连接 + min-idle: 0 + # 连接池中的最大空闲连接 + max-idle: 8 + # 连接池的最大数据库连接数 + max-active: 8 + # #连接池最大阻塞等待时间(使用负值表示没有限制) + max-wait: -1ms +# 数据源配置 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: dm.jdbc.driver.DmDriver +# driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: +# url: jdbc:mysql://localhost:3306/medical_waste?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:dm://127.0.0.1:5236/MEDICAL_WASTE?schema=MEDICAL_WASTE + username: SYSDBA + password: SYSDBA + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: + username: + password: + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置连接超时时间 + connectTimeout: 30000 + # 配置网络超时时间 + socketTimeout: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: ruoyi + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + jackson: + # 全局设置@JsonFormat的格式pattern + date-format: yyyy-MM-dd HH:mm:ss + # 设置全局时区 + time-zone: GMT+8 + # 当地时区 + locale: zh_CN + + +# token配置 +token: + # 令牌自定义标识 + header: Authorization + # 令牌密钥 + secret: abcdefghijklmnopqrstuvwxyz + # 令牌有效期(默认30分钟) + expireTime: 720 + +# MyBatis配置 +mybatis-plus: + # 搜索指定包别名 + typeAliasesPackage: com.sinata.**.domain + # 配置mapper的扫描,找到所有的mapper.xml映射文件 + mapperLocations: classpath*:mapper/**/*Mapper.xml + # 加载全局的配置文件 +# configLocation: classpath:mybatis/mybatis-config.xml + configuration: + # 自动驼峰命名规则(camel case)映射 + mapUnderscoreToCamelCase: true + # MyBatis 自动映射策略 + # NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射 + autoMappingBehavior: PARTIAL + # MyBatis 自动映射时未知列或未知属性处理策 + # NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息 + autoMappingUnknownColumnBehavior: NONE + # 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl + # 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl + # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl + logImpl: org.apache.ibatis.logging.slf4j.Slf4jImpl + global-config: + db-config: + logic-delete-field: del_flag + logic-delete-value: 1 + logic-not-delete-value: 0 + banner: true +# PageHelper分页插件 +pagehelper: + helperDialect: oracle + supportMethodsArguments: true + params: count=countSql + +# Swagger配置 +swagger: + # 是否开启swagger + enabled: true + # 请求前缀 + pathMapping: / + +# 防止XSS攻击 +xss: + # 过滤开关 + enabled: true + # 排除链接(多个用逗号分隔) + excludes: /system/notice + # 匹配链接 + urlPatterns: /system/*,/monitor/*,/tool/* diff --git a/medicalWaste-admin/src/main/resources/application-druid.yml b/medicalWaste-admin/src/main/resources/application-druid.yml deleted file mode 100644 index e69de29..0000000 --- a/medicalWaste-admin/src/main/resources/application-druid.yml +++ /dev/null diff --git a/medicalWaste-admin/src/main/resources/application-prod.yml b/medicalWaste-admin/src/main/resources/application-prod.yml new file mode 100644 index 0000000..70d3e5b --- /dev/null +++ b/medicalWaste-admin/src/main/resources/application-prod.yml @@ -0,0 +1,214 @@ +# 项目相关配置 +ruoyi: + # 名称 + name: RuoYi + # 版本 + version: 3.8.8 + # 版权年份 + copyrightYear: 2024 + # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) + profile: D:/ruoyi/uploadPath + # 获取ip地址开关 + addressEnabled: false + # 验证码类型 math 数字计算 char 字符验证 + captchaType: math + +# 开发环境配置 +server: + # 服务器的HTTP端口,默认为8080 + port: 8080 + servlet: + # 应用的访问路径 + context-path: / + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # 连接数满后的排队数,默认为100 + accept-count: 1000 + threads: + # tomcat最大线程数,默认为200 + max: 800 + # Tomcat启动初始化的线程数,默认值10 + min-spare: 100 + +# 日志配置 +logging: + level: + com.sinata: debug + org.springframework: warn + +# 用户配置 +user: + password: + # 密码最大错误次数 + maxRetryCount: 5 + # 密码锁定时间(默认10分钟) + lockTime: 10 +# Spring配置 +spring: + # 资源信息 + messages: + # 国际化资源文件路径 + basename: i18n/messages + # 文件上传 + servlet: + multipart: + # 单个文件大小 + max-file-size: 10MB + # 设置总上传的文件大小 + max-request-size: 20MB + # 服务模块 + devtools: + restart: + # 热部署开关 + enabled: true + # redis 配置 + redis: + # 地址 + host: localhost + # 端口,默认为6379 + port: 6379 + # 数据库索引 + database: 0 + # 密码 + password: 123456 + # 连接超时时间 + timeout: 10s + lettuce: + pool: + # 连接池中的最小空闲连接 + min-idle: 0 + # 连接池中的最大空闲连接 + max-idle: 8 + # 连接池的最大数据库连接数 + max-active: 8 + # #连接池最大阻塞等待时间(使用负值表示没有限制) + max-wait: -1ms +# 数据源配置 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + driver-class-name: dm.jdbc.driver.DmDriver +# driverClassName: com.mysql.cj.jdbc.Driver + druid: + # 主库数据源 + master: +# url: jdbc:mysql://localhost:3306/medical_waste?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:dm://127.0.0.1:5236/MEDICAL_WASTE?schema=MEDICAL_WASTE + username: SYSDBA + password: SYSDBA + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + enabled: false + url: + username: + password: + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置连接超时时间 + connectTimeout: 30000 + # 配置网络超时时间 + socketTimeout: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: ruoyi + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true + jackson: + # 全局设置@JsonFormat的格式pattern + date-format: yyyy-MM-dd HH:mm:ss + # 设置全局时区 + time-zone: GMT+8 + # 当地时区 + locale: zh_CN + + +# token配置 +token: + # 令牌自定义标识 + header: Authorization + # 令牌密钥 + secret: abcdefghijklmnopqrstuvwxyz + # 令牌有效期(默认30分钟) + expireTime: 720 + +# MyBatis配置 +mybatis-plus: + # 搜索指定包别名 + typeAliasesPackage: com.sinata.**.domain + # 配置mapper的扫描,找到所有的mapper.xml映射文件 + mapperLocations: classpath*:mapper/**/*Mapper.xml + # 加载全局的配置文件 +# configLocation: classpath:mybatis/mybatis-config.xml + configuration: + # 自动驼峰命名规则(camel case)映射 + mapUnderscoreToCamelCase: true + # MyBatis 自动映射策略 + # NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射 + autoMappingBehavior: PARTIAL + # MyBatis 自动映射时未知列或未知属性处理策 + # NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息 + autoMappingUnknownColumnBehavior: NONE + # 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl + # 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl + # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl + logImpl: org.apache.ibatis.logging.slf4j.Slf4jImpl + global-config: + db-config: + logic-delete-field: del_flag + logic-delete-value: 1 + logic-not-delete-value: 0 + banner: true +# PageHelper分页插件 +pagehelper: + helperDialect: oracle + supportMethodsArguments: true + params: count=countSql + +# Swagger配置 +swagger: + # 是否开启swagger + enabled: true + # 请求前缀 + pathMapping: / + +# 防止XSS攻击 +xss: + # 过滤开关 + enabled: true + # 排除链接(多个用逗号分隔) + excludes: /system/notice + # 匹配链接 + urlPatterns: /system/*,/monitor/*,/tool/* diff --git a/medicalWaste-admin/src/main/resources/application.yml b/medicalWaste-admin/src/main/resources/application.yml index 70d3e5b..90385b2 100644 --- a/medicalWaste-admin/src/main/resources/application.yml +++ b/medicalWaste-admin/src/main/resources/application.yml @@ -1,214 +1,3 @@ -# 项目相关配置 -ruoyi: - # 名称 - name: RuoYi - # 版本 - version: 3.8.8 - # 版权年份 - copyrightYear: 2024 - # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath) - profile: D:/ruoyi/uploadPath - # 获取ip地址开关 - addressEnabled: false - # 验证码类型 math 数字计算 char 字符验证 - captchaType: math - -# 开发环境配置 -server: - # 服务器的HTTP端口,默认为8080 - port: 8080 - servlet: - # 应用的访问路径 - context-path: / - tomcat: - # tomcat的URI编码 - uri-encoding: UTF-8 - # 连接数满后的排队数,默认为100 - accept-count: 1000 - threads: - # tomcat最大线程数,默认为200 - max: 800 - # Tomcat启动初始化的线程数,默认值10 - min-spare: 100 - -# 日志配置 -logging: - level: - com.sinata: debug - org.springframework: warn - -# 用户配置 -user: - password: - # 密码最大错误次数 - maxRetryCount: 5 - # 密码锁定时间(默认10分钟) - lockTime: 10 -# Spring配置 spring: - # 资源信息 - messages: - # 国际化资源文件路径 - basename: i18n/messages - # 文件上传 - servlet: - multipart: - # 单个文件大小 - max-file-size: 10MB - # 设置总上传的文件大小 - max-request-size: 20MB - # 服务模块 - devtools: - restart: - # 热部署开关 - enabled: true - # redis 配置 - redis: - # 地址 - host: localhost - # 端口,默认为6379 - port: 6379 - # 数据库索引 - database: 0 - # 密码 - password: 123456 - # 连接超时时间 - timeout: 10s - lettuce: - pool: - # 连接池中的最小空闲连接 - min-idle: 0 - # 连接池中的最大空闲连接 - max-idle: 8 - # 连接池的最大数据库连接数 - max-active: 8 - # #连接池最大阻塞等待时间(使用负值表示没有限制) - max-wait: -1ms -# 数据源配置 - datasource: - type: com.alibaba.druid.pool.DruidDataSource - driver-class-name: dm.jdbc.driver.DmDriver -# driverClassName: com.mysql.cj.jdbc.Driver - druid: - # 主库数据源 - master: -# url: jdbc:mysql://localhost:3306/medical_waste?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - url: jdbc:dm://127.0.0.1:5236/MEDICAL_WASTE?schema=MEDICAL_WASTE - username: SYSDBA - password: SYSDBA - # 从库数据源 - slave: - # 从数据源开关/默认关闭 - enabled: false - url: - username: - password: - # 初始连接数 - initialSize: 5 - # 最小连接池数量 - minIdle: 10 - # 最大连接池数量 - maxActive: 20 - # 配置获取连接等待超时的时间 - maxWait: 60000 - # 配置连接超时时间 - connectTimeout: 30000 - # 配置网络超时时间 - socketTimeout: 60000 - # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 - timeBetweenEvictionRunsMillis: 60000 - # 配置一个连接在池中最小生存的时间,单位是毫秒 - minEvictableIdleTimeMillis: 300000 - # 配置一个连接在池中最大生存的时间,单位是毫秒 - maxEvictableIdleTimeMillis: 900000 - # 配置检测连接是否有效 - validationQuery: SELECT 1 FROM DUAL - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - webStatFilter: - enabled: true - statViewServlet: - enabled: true - # 设置白名单,不填则允许所有访问 - allow: - url-pattern: /druid/* - # 控制台管理用户名和密码 - login-username: ruoyi - login-password: 123456 - filter: - stat: - enabled: true - # 慢SQL记录 - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: true - wall: - config: - multi-statement-allow: true - jackson: - # 全局设置@JsonFormat的格式pattern - date-format: yyyy-MM-dd HH:mm:ss - # 设置全局时区 - time-zone: GMT+8 - # 当地时区 - locale: zh_CN - - -# token配置 -token: - # 令牌自定义标识 - header: Authorization - # 令牌密钥 - secret: abcdefghijklmnopqrstuvwxyz - # 令牌有效期(默认30分钟) - expireTime: 720 - -# MyBatis配置 -mybatis-plus: - # 搜索指定包别名 - typeAliasesPackage: com.sinata.**.domain - # 配置mapper的扫描,找到所有的mapper.xml映射文件 - mapperLocations: classpath*:mapper/**/*Mapper.xml - # 加载全局的配置文件 -# configLocation: classpath:mybatis/mybatis-config.xml - configuration: - # 自动驼峰命名规则(camel case)映射 - mapUnderscoreToCamelCase: true - # MyBatis 自动映射策略 - # NONE:不启用 PARTIAL:只对非嵌套 resultMap 自动映射 FULL:对所有 resultMap 自动映射 - autoMappingBehavior: PARTIAL - # MyBatis 自动映射时未知列或未知属性处理策 - # NONE:不做处理 WARNING:打印相关警告 FAILING:抛出异常和详细信息 - autoMappingUnknownColumnBehavior: NONE - # 更详细的日志输出 会有性能损耗 org.apache.ibatis.logging.stdout.StdOutImpl - # 关闭日志记录 (可单纯使用 p6spy 分析) org.apache.ibatis.logging.nologging.NoLoggingImpl - # 默认日志输出 org.apache.ibatis.logging.slf4j.Slf4jImpl - logImpl: org.apache.ibatis.logging.slf4j.Slf4jImpl - global-config: - db-config: - logic-delete-field: del_flag - logic-delete-value: 1 - logic-not-delete-value: 0 - banner: true -# PageHelper分页插件 -pagehelper: - helperDialect: oracle - supportMethodsArguments: true - params: count=countSql - -# Swagger配置 -swagger: - # 是否开启swagger - enabled: true - # 请求前缀 - pathMapping: / - -# 防止XSS攻击 -xss: - # 过滤开关 - enabled: true - # 排除链接(多个用逗号分隔) - excludes: /system/notice - # 匹配链接 - urlPatterns: /system/*,/monitor/*,/tool/* + profiles: + active: prod \ No newline at end of file diff --git a/medicalWaste-common/src/main/java/com/sinata/common/core/domain/BaseEntity.java b/medicalWaste-common/src/main/java/com/sinata/common/core/domain/BaseEntity.java index 1b59520..0b7a9c4 100644 --- a/medicalWaste-common/src/main/java/com/sinata/common/core/domain/BaseEntity.java +++ b/medicalWaste-common/src/main/java/com/sinata/common/core/domain/BaseEntity.java @@ -1,6 +1,5 @@ package com.sinata.common.core.domain; -import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -26,21 +25,21 @@ private String searchValue; /** 创建者 */ - @TableField(value = "create_by", fill = FieldFill.INSERT) + @TableField(value = "create_by") private String createBy; /** 创建时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @TableField(value = "create_time", fill = FieldFill.INSERT) + @TableField(value = "create_time") private Date createTime; /** 更新者 */ - @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) + @TableField(value = "update_by") private String updateBy; /** 更新时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) + @TableField(value = "update_time") private Date updateTime; /** 备注 */ diff --git a/medicalWaste-common/src/main/java/com/sinata/common/core/domain/entity/SysUser.java b/medicalWaste-common/src/main/java/com/sinata/common/core/domain/entity/SysUser.java index bd7aba6..da45f88 100644 --- a/medicalWaste-common/src/main/java/com/sinata/common/core/domain/entity/SysUser.java +++ b/medicalWaste-common/src/main/java/com/sinata/common/core/domain/entity/SysUser.java @@ -1,16 +1,23 @@ package com.sinata.common.core.domain.entity; -import java.util.Date; -import java.util.List; -import javax.validation.constraints.*; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableLogic; import com.sinata.common.annotation.Excel; import com.sinata.common.annotation.Excel.ColumnType; import com.sinata.common.annotation.Excel.Type; import com.sinata.common.annotation.Excels; import com.sinata.common.core.domain.BaseEntity; import com.sinata.common.xss.Xss; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.util.Date; +import java.util.List; /** * 用户对象 sys_user @@ -23,6 +30,7 @@ /** 用户ID */ @Excel(name = "用户序号", type = Type.EXPORT, cellType = ColumnType.NUMERIC, prompt = "用户编号") + @TableId(type = IdType.AUTO) private Long userId; /** 部门ID */ @@ -60,6 +68,7 @@ private String status; /** 删除标志(0代表存在 2代表删除) */ + @TableLogic private String delFlag; /** 最后登录IP */ @@ -75,25 +84,72 @@ @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT), @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT) }) + @TableField(exist = false) private SysDept dept; /** 角色对象 */ + @TableField(exist = false) private List<SysRole> roles; /** 角色组 */ + @TableField(exist = false) private Long[] roleIds; /** 岗位组 */ + @TableField(exist = false) private Long[] postIds; /** 角色ID */ + @TableField(exist = false) private Long roleId; + + /** + * 微信openId + */ + @TableField("OPEN_ID") + private String openId; + + /** + * 绑定车辆id + */ + @TableField("CAR_ID") + private Long carId; + /** + * 区域id/机构id/单位id + */ + @TableField("DEPARTMENT_ID") + private Long departmentId; + public SysUser() { } + public String getOpenId() { + return openId; + } + + public void setOpenId(String openId) { + this.openId = openId; + } + + public Long getCarId() { + return carId; + } + + public void setCarId(Long carId) { + this.carId = carId; + } + + public Long getDepartmentId() { + return departmentId; + } + + public void setDepartmentId(Long departmentId) { + this.departmentId = departmentId; + } + public SysUser(Long userId) { this.userId = userId; diff --git a/medicalWaste-framework/src/main/java/com/sinata/framework/config/SecurityConfig.java b/medicalWaste-framework/src/main/java/com/sinata/framework/config/SecurityConfig.java index 0ff6ad5..459dad9 100644 --- a/medicalWaste-framework/src/main/java/com/sinata/framework/config/SecurityConfig.java +++ b/medicalWaste-framework/src/main/java/com/sinata/framework/config/SecurityConfig.java @@ -113,7 +113,7 @@ // 对于登录login 注册register 验证码captchaImage 允许匿名访问 requests.antMatchers("/backend/login", "/register", "/captchaImage").permitAll() // 静态资源,可匿名访问 - .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() + .antMatchers(HttpMethod.GET, "/", "/msg", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() // 除上面外的所有请求全部需要鉴权认证 .anyRequest().authenticated(); diff --git a/medicalWaste-system/src/main/java/com/sinata/system/domain/SysDepartmentInfo.java b/medicalWaste-system/src/main/java/com/sinata/system/domain/SysDepartmentInfo.java index 417f33f..4f2fdd3 100644 --- a/medicalWaste-system/src/main/java/com/sinata/system/domain/SysDepartmentInfo.java +++ b/medicalWaste-system/src/main/java/com/sinata/system/domain/SysDepartmentInfo.java @@ -38,11 +38,11 @@ @ApiModelProperty("机构级别(数据字典id)") @TableField("INSTITUTION_LEVEL") - private Integer institutionLevel; + private Long institutionLevel; @ApiModelProperty("机构性质(数据字典id)") @TableField("INSTITUTION_TYPE") - private Integer institutionType; + private Long institutionType; @ApiModelProperty("每日产废范围起") @TableField("DAILY_MIN_WASTE_QUANTITY") diff --git a/medicalWaste-system/src/main/java/com/sinata/system/domain/dto/SysUserDTO.java b/medicalWaste-system/src/main/java/com/sinata/system/domain/dto/SysUserDTO.java new file mode 100644 index 0000000..3e0f105 --- /dev/null +++ b/medicalWaste-system/src/main/java/com/sinata/system/domain/dto/SysUserDTO.java @@ -0,0 +1,39 @@ +package com.sinata.system.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; + +/** + * @author mitao + * @date 2024/12/6 + */ +@Data +@ApiModel("用户数据传输对象") +public class SysUserDTO { + + @ApiModelProperty(value = "用户id", notes = "新增不传,编辑必传") + private Long userId; + + @ApiModelProperty(value = "机构id") + @NotNull(message = "机构id不能为空") + private Long departmentId; + + @ApiModelProperty(value = "姓名") + @NotBlank(message = "姓名不能为空") + private String nickName; + + @ApiModelProperty(value = "用户名(手机号)") + @NotBlank(message = "用户名不能为空") + private String userName; + + @ApiModelProperty(value = "登录密码") + private String password; + + @ApiModelProperty("角色id") + @NotNull(message = "角色id不能为空") + private Long roleId; +} diff --git a/medicalWaste-system/src/main/java/com/sinata/system/domain/dto/SysUserStatusDTO.java b/medicalWaste-system/src/main/java/com/sinata/system/domain/dto/SysUserStatusDTO.java new file mode 100644 index 0000000..440d7b2 --- /dev/null +++ b/medicalWaste-system/src/main/java/com/sinata/system/domain/dto/SysUserStatusDTO.java @@ -0,0 +1,26 @@ +package com.sinata.system.domain.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; +import java.util.List; + +/** + * @author mitao + * @date 2024/12/6 + */ +@Data +@ApiModel("用户状态数据传输对象") +public class SysUserStatusDTO { + + @ApiModelProperty("用户id列表") + @NotEmpty(message = "用户id列表不能为空") + private List<Long> userIds; + + @ApiModelProperty("账号状态 0:启用 1:禁用") + @NotBlank(message = "账号状态不能为空") + private String status; +} diff --git a/medicalWaste-system/src/main/java/com/sinata/system/domain/query/SysUserQuery.java b/medicalWaste-system/src/main/java/com/sinata/system/domain/query/SysUserQuery.java new file mode 100644 index 0000000..5d90a06 --- /dev/null +++ b/medicalWaste-system/src/main/java/com/sinata/system/domain/query/SysUserQuery.java @@ -0,0 +1,27 @@ +package com.sinata.system.domain.query; + +import com.sinata.common.entity.BasePage; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * @author mitao + * @date 2024/12/5 + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel("用户查询对象") +public class SysUserQuery extends BasePage { + + private static final long serialVersionUID = 685950217989591434L; + @ApiModelProperty("机构id") + private Long departmentId; + + @ApiModelProperty("姓名") + private String nickName; + + @ApiModelProperty("角色id") + private Long roleId; +} diff --git a/medicalWaste-system/src/main/java/com/sinata/system/domain/vo/SysUserVO.java b/medicalWaste-system/src/main/java/com/sinata/system/domain/vo/SysUserVO.java new file mode 100644 index 0000000..f86dbb7 --- /dev/null +++ b/medicalWaste-system/src/main/java/com/sinata/system/domain/vo/SysUserVO.java @@ -0,0 +1,37 @@ +package com.sinata.system.domain.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @author mitao + * @date 2024/12/5 + */ +@Data +@ApiModel("用户视图对象") +public class SysUserVO { + @ApiModelProperty("用户id") + private Long userId; + + @ApiModelProperty("用户名") + private String nickName; + + @ApiModelProperty("用户名") + private String userName; + + @ApiModelProperty("角色") + private String roleName; + + @ApiModelProperty("账号状态 0:正常 1:停用") + private String status; + + @ApiModelProperty(value = "机构id") + private Long departmentId; + + @ApiModelProperty(value = "登录密码") + private String password; + + @ApiModelProperty("角色id") + private Long roleId; +} diff --git a/medicalWaste-system/src/main/java/com/sinata/system/mapper/SysUserMapper.java b/medicalWaste-system/src/main/java/com/sinata/system/mapper/SysUserMapper.java index 8300a78..f801cfb 100644 --- a/medicalWaste-system/src/main/java/com/sinata/system/mapper/SysUserMapper.java +++ b/medicalWaste-system/src/main/java/com/sinata/system/mapper/SysUserMapper.java @@ -1,15 +1,19 @@ package com.sinata.system.mapper; -import java.util.List; -import org.apache.ibatis.annotations.Param; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.sinata.common.core.domain.entity.SysUser; +import com.sinata.system.domain.vo.SysUserVO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 用户表 数据层 * * @author ruoyi */ -public interface SysUserMapper +public interface SysUserMapper extends BaseMapper<SysUser> { /** * 根据条件分页查询用户列表 @@ -124,4 +128,15 @@ * @return 结果 */ public SysUser checkEmailUnique(String email); + + /** + * 分页查询用户 + * + * @param sysUserVOPage + * @param departmentId + * @param nickName + * @param roleId + * @return + */ + Page<SysUserVO> pageList(Page<SysUserVO> sysUserVOPage, @Param("departmentId") Long departmentId, @Param("nickName") String nickName, @Param("roleId") Long roleId, @Param("treeCode") String treeCode); } diff --git a/medicalWaste-system/src/main/java/com/sinata/system/mapper/SysUserRoleMapper.java b/medicalWaste-system/src/main/java/com/sinata/system/mapper/SysUserRoleMapper.java index ca9a089..0833eb1 100644 --- a/medicalWaste-system/src/main/java/com/sinata/system/mapper/SysUserRoleMapper.java +++ b/medicalWaste-system/src/main/java/com/sinata/system/mapper/SysUserRoleMapper.java @@ -1,15 +1,17 @@ package com.sinata.system.mapper; -import java.util.List; -import org.apache.ibatis.annotations.Param; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.sinata.system.domain.SysUserRole; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 用户与角色关联表 数据层 * * @author ruoyi */ -public interface SysUserRoleMapper +public interface SysUserRoleMapper extends BaseMapper<SysUserRole> { /** * 通过用户ID删除用户和角色关联 diff --git a/medicalWaste-system/src/main/java/com/sinata/system/service/ISysUserService.java b/medicalWaste-system/src/main/java/com/sinata/system/service/ISysUserService.java index 13aee2e..a966a76 100644 --- a/medicalWaste-system/src/main/java/com/sinata/system/service/ISysUserService.java +++ b/medicalWaste-system/src/main/java/com/sinata/system/service/ISysUserService.java @@ -1,14 +1,21 @@ package com.sinata.system.service; -import java.util.List; +import com.baomidou.mybatisplus.extension.service.IService; import com.sinata.common.core.domain.entity.SysUser; +import com.sinata.common.entity.PageDTO; +import com.sinata.system.domain.dto.SysUserDTO; +import com.sinata.system.domain.dto.SysUserStatusDTO; +import com.sinata.system.domain.query.SysUserQuery; +import com.sinata.system.domain.vo.SysUserVO; + +import java.util.List; /** * 用户 业务层 * * @author ruoyi */ -public interface ISysUserService +public interface ISysUserService extends IService<SysUser> { /** * 根据条件分页查询用户列表 @@ -203,4 +210,43 @@ * @return 结果 */ public String importUser(List<SysUser> userList, Boolean isUpdateSupport, String operName); + + PageDTO<SysUserVO> pageList(SysUserQuery query); + + /** + * 新增用户 + * + * @param dto + */ + void add(SysUserDTO dto); + + /** + * 编辑用户 + * + * @param dto + */ + void edit(SysUserDTO dto); + + /** + * 查询用户详情 + * + * @param userId + * @return + */ + SysUserVO getDetailInfo(Long userId); + + /** + * 批量修改账号状态 + * + * @param dto@return + */ + void updStatusBatch(SysUserStatusDTO dto); + + /** + * 批量删除 + * + * @param userIds + * @return + */ + void delBatch(List<Long> userIds); } diff --git a/medicalWaste-system/src/main/java/com/sinata/system/service/SysDepartmentService.java b/medicalWaste-system/src/main/java/com/sinata/system/service/SysDepartmentService.java index 474bc2a..5e9e5fe 100644 --- a/medicalWaste-system/src/main/java/com/sinata/system/service/SysDepartmentService.java +++ b/medicalWaste-system/src/main/java/com/sinata/system/service/SysDepartmentService.java @@ -39,6 +39,13 @@ List<SysDepartmentVO> getRegionTree(String keyword); /** + * 当前登录用户所在区域 + * + * @return + */ + SysDepartment getMyDepartment(); + + /** * 新增区域 * * @param dto @@ -72,5 +79,10 @@ */ String getOrgCode(Long parentId, Integer orgType); + /** + * 删除区域 + * + * @param id + */ void deleteRegion(Long id); } diff --git a/medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysDepartmentServiceImpl.java b/medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysDepartmentServiceImpl.java index e4cf610..9ad50a5 100644 --- a/medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysDepartmentServiceImpl.java +++ b/medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysDepartmentServiceImpl.java @@ -130,7 +130,8 @@ * * @return */ - private SysDepartment getMyDepartment() { + @Override + public SysDepartment getMyDepartment() { Long userId = SecurityUtils.getUserId(); return baseMapper.getDepartmentByUserId(userId); } diff --git a/medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysUserServiceImpl.java b/medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysUserServiceImpl.java index 15d6c27..439e870 100644 --- a/medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysUserServiceImpl.java +++ b/medicalWaste-system/src/main/java/com/sinata/system/service/impl/SysUserServiceImpl.java @@ -1,27 +1,28 @@ package com.sinata.system.service.impl; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; -import javax.validation.Validator; -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 org.springframework.util.CollectionUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.sinata.common.annotation.DataScope; import com.sinata.common.constant.UserConstants; import com.sinata.common.core.domain.entity.SysRole; import com.sinata.common.core.domain.entity.SysUser; +import com.sinata.common.entity.PageDTO; import com.sinata.common.exception.ServiceException; +import com.sinata.common.utils.BeanUtils; +import com.sinata.common.utils.DateUtils; import com.sinata.common.utils.SecurityUtils; import com.sinata.common.utils.StringUtils; import com.sinata.common.utils.bean.BeanValidators; import com.sinata.common.utils.spring.SpringUtils; +import com.sinata.system.domain.SysDepartment; import com.sinata.system.domain.SysPost; import com.sinata.system.domain.SysUserPost; import com.sinata.system.domain.SysUserRole; +import com.sinata.system.domain.dto.SysUserDTO; +import com.sinata.system.domain.dto.SysUserStatusDTO; +import com.sinata.system.domain.query.SysUserQuery; +import com.sinata.system.domain.vo.SysUserVO; import com.sinata.system.mapper.SysPostMapper; import com.sinata.system.mapper.SysRoleMapper; import com.sinata.system.mapper.SysUserMapper; @@ -30,6 +31,20 @@ import com.sinata.system.service.ISysConfigService; import com.sinata.system.service.ISysDeptService; import com.sinata.system.service.ISysUserService; +import com.sinata.system.service.SysDepartmentService; +import org.apache.commons.lang3.ArrayUtils; +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 org.springframework.util.CollectionUtils; + +import javax.validation.Validator; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; /** * 用户 业务层处理 @@ -37,7 +52,7 @@ * @author ruoyi */ @Service -public class SysUserServiceImpl implements ISysUserService +public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService { private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class); @@ -64,6 +79,8 @@ @Autowired protected Validator validator; + @Autowired + private SysDepartmentService sysDepartmentService; /** * 根据条件分页查询用户列表 @@ -547,4 +564,129 @@ } return successMsg.toString(); } + + /** + * 分页查询 + * + * @param query + * @return + */ + @Override + public PageDTO<SysUserVO> pageList(SysUserQuery query) { + String treeCode = ""; + if (Objects.isNull(query.getDepartmentId())) { + SysDepartment myDepartment = sysDepartmentService.getMyDepartment(); + if (Objects.nonNull(myDepartment)) { + treeCode = myDepartment.getTreeCode(); + } + } + Page<SysUserVO> page = baseMapper.pageList(new Page<>(query.getPageCurr(), query.getPageSize()), query.getDepartmentId(), query.getNickName(), query.getRoleId(), treeCode); + return PageDTO.of(page); + } + + /** + * 新增用户 + * + * @param dto + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void add(SysUserDTO dto) { + SysUser sysUser = BeanUtils.copyBean(dto, SysUser.class); + if (StringUtils.isBlank(dto.getPassword())) { + throw new ServiceException("登录密码不能为空"); + } + if (!checkUserNameUnique(sysUser)) { + throw new ServiceException("新增用户" + dto.getUserName() + "失败,登录账号已存在"); + } + sysUser.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); + sysUser.setCreateBy(SecurityUtils.getUserId().toString()); + sysUser.setCreateTime(DateUtils.getNowDate()); + save(sysUser); + //添加用户角色关系 + SysUserRole sysUserRole = new SysUserRole(); + sysUserRole.setUserId(sysUser.getUserId()); + sysUserRole.setRoleId(dto.getRoleId()); + userRoleMapper.insert(sysUserRole); + } + + /** + * 编辑用户 + * + * @param dto + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void edit(SysUserDTO dto) { + SysUser sysUser = BeanUtils.copyBean(dto, SysUser.class); + if (!checkUserNameUnique(sysUser)) { + throw new ServiceException("编辑用户" + dto.getUserName() + "失败,登录账号已存在"); + } + if (StringUtils.isNotBlank(dto.getPassword())) { + sysUser.setPassword(SecurityUtils.encryptPassword(dto.getPassword())); + } + sysUser.setUpdateBy(SecurityUtils.getUserId().toString()); + sysUser.setUpdateTime(DateUtils.getNowDate()); + updateById(sysUser); + // 删除用户与角色关联 + userRoleMapper.deleteUserRoleByUserId(sysUser.getUserId()); + // 新增用户与角色管理 + SysUserRole sysUserRole = new SysUserRole(); + sysUserRole.setUserId(sysUser.getUserId()); + sysUserRole.setRoleId(dto.getRoleId()); + userRoleMapper.insert(sysUserRole); + } + + /** + * 查询用户详情 + * + * @param userId + * @return + */ + @Override + public SysUserVO getDetailInfo(Long userId) { + SysUser sysUser = this.getById(userId); + SysUserVO sysUserVO = null; + if (Objects.nonNull(sysUser)) { + sysUserVO = BeanUtils.copyBean(sysUser, SysUserVO.class); + sysUserVO.setPassword(""); + //查询用户角色 + SysUserRole sysUserRole = userRoleMapper.selectOne(Wrappers.lambdaQuery(SysUserRole.class).eq(SysUserRole::getUserId, sysUserVO.getUserId())); + if (Objects.nonNull(sysUserRole)) { + sysUserVO.setRoleId(sysUserRole.getRoleId()); + } + } + return sysUserVO; + } + + /** + * 批量修改账号状态 + * + * @param dto@return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void updStatusBatch(SysUserStatusDTO dto) { + List<SysUser> sysUsers = this.listByIds(dto.getUserIds()); + sysUsers.forEach(user -> user.setStatus(dto.getStatus())); + updateBatchById(sysUsers); + } + + /** + * 批量删除 + * + * @param userIds + * @return + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void delBatch(List<Long> userIds) { + Long[] userIdList = userIds.toArray(new Long[0]); + if (ArrayUtils.contains(userIdList, SecurityUtils.getUserId())) { + throw new ServiceException("当前账号不能删除"); + } + // 删除用户与角色关联 + userRoleMapper.deleteUserRole(userIdList); + this.removeBatchByIds(userIds); + } } diff --git a/medicalWaste-system/src/main/resources/mapper/system/SysDepartmentMapper.xml b/medicalWaste-system/src/main/resources/mapper/system/SysDepartmentMapper.xml index b02d405..2b87d90 100644 --- a/medicalWaste-system/src/main/resources/mapper/system/SysDepartmentMapper.xml +++ b/medicalWaste-system/src/main/resources/mapper/system/SysDepartmentMapper.xml @@ -35,7 +35,7 @@ ID, DEPARTMENT_NAME, PARENT_ID, TREE_CODE, ORG_TYPE, ORG_CODE, ADDRESS, LONGITUDE, LATITUDE, CONTACT_PERSON, CONTACT_PHONE, REMARK, LEGAL_PERSON, UNIFIED_SOCIAL_CREDIT_CODE </sql> <select id="getDepartmentByUserId" resultType="com.sinata.system.domain.SysDepartment"> - SELECT t2.* FROM SYS_USER_DEPARTMENT t1 LEFT JOIN SYS_DEPARTMENT t2 ON t1.DEPARTMENT_ID = t2.ID + SELECT t2.* FROM SYS_USER t1 LEFT JOIN SYS_DEPARTMENT t2 ON t1.DEPARTMENT_ID = t2.ID <where> t1.USER_ID = #{userId} </where> diff --git a/medicalWaste-system/src/main/resources/mapper/system/SysUserMapper.xml b/medicalWaste-system/src/main/resources/mapper/system/SysUserMapper.xml index 3a52d0e..66853c6 100644 --- a/medicalWaste-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/medicalWaste-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -141,7 +141,35 @@ <select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult"> select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1 </select> - + <select id="pageList" resultType="com.sinata.system.domain.vo.SysUserVO"> + SELECT su.USER_ID,su.NICK_NAME, + su.USER_NAME, + su.STATUS, + sd.DEPARTMENT_NAME, + sr.ROLE_NAME + FROM SYS_USER su + LEFT JOIN SYS_DEPARTMENT sd + ON su.DEPARTMENT_ID = sd.ID + LEFT JOIN SYS_USER_ROLE sur + ON sur.USER_ID = su.USER_ID + LEFT JOIN SYS_ROLE sr + ON sr.ROLE_ID = sur.ROLE_ID + <where> + <if test="departmentId != null and departmentId != ''">] + sud.DEPARTMENT_ID = #{departmentId} + </if> + <if test="nickName != null and nickName != ''">] + su.NICK_NAME LIKE CONCAT('%',#{nickName},'%') + </if> + <if test="roleId != null and roleId != ''">] + sur.ROLE_ID = #{roleId} + </if> + <if test="treeCode != null and treeCode != ''"> + sd.TREE_CODE LIKE CONCAT(#{treeCode},'%') + </if> + </where> + </select> + <insert id="insertUser" parameterType="SysUser" useGeneratedKeys="true" keyProperty="userId"> insert into sys_user( <if test="userId != null and userId != 0">user_id,</if> -- Gitblit v1.7.1