From 4684b8ea5eaf41d68dba12fef7e15586e0377004 Mon Sep 17 00:00:00 2001 From: Odboy Date: Wed, 14 Jan 2026 22:17:21 +0800 Subject: [PATCH 01/14] =?UTF-8?q?refactor(framework):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=20MyBatis=20Plus=20=E6=9F=A5=E8=AF=A2=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E7=B1=BB=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatisplus/core/KitMpQUtil.java | 19 ++++++++++--------- .../mybatisplus/core/KitMpQUtil.java | 7 ++++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpQUtil.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpQUtil.java index c97387b4..3103ff22 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpQUtil.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpQUtil.java @@ -15,7 +15,7 @@ */ package cn.odboy.framework.mybatisplus.core; -import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.odboy.base.KitBaseUserTimeTb; @@ -26,6 +26,8 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Arrays; @@ -33,8 +35,7 @@ import java.util.Collection; import java.util.List; import java.util.Optional; import java.util.stream.Collectors; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; +import lombok.Data; import lombok.extern.slf4j.Slf4j; /** @@ -131,7 +132,7 @@ public class KitMpQUtil { private static void handleInOrNotQuery(boolean b, QueryWrapper queryWrapper, String attributeName, Object fieldVal) { Collection wrapNotInVal = (Collection) fieldVal; - if (CollectionUtil.isNotEmpty(wrapNotInVal)) { + if (CollUtil.isNotEmpty(wrapNotInVal)) { Optional anyValOptional = wrapNotInVal.stream().findAny(); if (anyValOptional.isPresent()) { Object o = anyValOptional.get(); @@ -159,7 +160,7 @@ public class KitMpQUtil { if (fieldVal instanceof List) { List between = new ArrayList<>((List) fieldVal); int minLength = 2; - if (CollectionUtil.isNotEmpty(between) && between.size() >= minLength) { + if (CollUtil.isNotEmpty(between) && between.size() >= minLength) { queryWrapper.between(finalAttributeName, between.get(0), between.get(1)); } else { throw new BadRequestException("BETWEEN类型的对象列表长度必须 >= 2"); @@ -179,7 +180,7 @@ public class KitMpQUtil { */ private static void handleBlurryQuery(QueryWrapper queryWrapper, String blurry, Object fieldVal) { List blurryList = - Arrays.stream(blurry.split(",")).filter(StrUtil::isNotBlank).distinct().toList(); + Arrays.stream(blurry.split(",")).filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList()); queryWrapper.and(wrapper -> { for (String blurryItem : blurryList) { String column = StrUtil.toUnderlineCase(blurryItem); @@ -198,7 +199,7 @@ public class KitMpQUtil { } public static void main(String[] args) { - QueryWrapper query = new QueryWrapper(); + QueryWrapper query = new QueryWrapper<>(); query.or(wrapper -> wrapper.eq("username", 1).or().eq("nickname", 2)); query.eq("id", 1); query.orderByDesc("id"); @@ -214,13 +215,13 @@ public class KitMpQUtil { System.err.println(query.getTargetSql()); } + @Data @TableName("test_domain") private static class TestDomain { @NotNull(groups = KitBaseUserTimeTb.Update.class) @TableId(value = "user_id", type = IdType.AUTO) - private Long - id; + private Long id; @TableField(value = "dept_id") private Long deptId; @NotBlank diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpQUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpQUtil.java index a4bf25e0..f9bc8001 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpQUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpQUtil.java @@ -35,6 +35,7 @@ import java.util.Optional; import java.util.stream.Collectors; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import lombok.Data; import lombok.extern.slf4j.Slf4j; /** @@ -198,7 +199,7 @@ public class KitMpQUtil { } public static void main(String[] args) { - QueryWrapper query = new QueryWrapper(); + QueryWrapper query = new QueryWrapper<>(); query.or(wrapper -> wrapper.eq("username", 1).or().eq("nickname", 2)); query.eq("id", 1); query.orderByDesc("id"); @@ -214,13 +215,13 @@ public class KitMpQUtil { System.err.println(query.getTargetSql()); } + @Data @TableName("test_domain") private static class TestDomain { @NotNull(groups = KitBaseUserTimeTb.Update.class) @TableId(value = "user_id", type = IdType.AUTO) - private Long - id; + private Long id; @TableField(value = "dept_id") private Long deptId; @NotBlank From 4d773797cd7dedf7a1c36910c6b47b05dae2bbe7 Mon Sep 17 00:00:00 2001 From: Odboy Date: Wed, 14 Jan 2026 22:17:47 +0800 Subject: [PATCH 02/14] =?UTF-8?q?style(java):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=92=8C=E6=B8=85=E7=90=86?= =?UTF-8?q?=E6=9C=AA=E4=BD=BF=E7=94=A8=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SystemDeptController.java | 2 +- .../controller/SystemDictController.java | 2 +- .../controller/SystemJobController.java | 2 +- .../controller/SystemMenuController.java | 2 +- .../controller/SystemOnlineController.java | 2 +- .../controller/SystemQuartzJobController.java | 2 +- .../controller/SystemRoleController.java | 2 +- .../controller/SystemUserController.java | 2 +- .../system/dal/dataobject/SystemDeptTb.java | 4 +- .../dal/dataobject/SystemDictDetailTb.java | 4 +- .../system/dal/dataobject/SystemDictTb.java | 6 +- .../dal/dataobject/SystemEmailConfigTb.java | 2 +- .../system/dal/dataobject/SystemJobTb.java | 6 +- .../system/dal/dataobject/SystemMenuTb.java | 4 +- .../dal/dataobject/SystemOperationLogTb.java | 2 +- .../dal/dataobject/SystemQuartzJobTb.java | 6 +- .../dal/dataobject/SystemQuartzLogTb.java | 2 +- .../system/dal/dataobject/SystemRoleTb.java | 4 +- .../system/dal/dataobject/SystemUserTb.java | 6 +- .../model/export/SystemDeptExportRowVo.java | 2 +- .../model/export/SystemDictExportRowVo.java | 2 +- .../model/export/SystemJobExportRowVo.java | 2 +- .../export/SystemLocalStorageExportRowVo.java | 2 +- .../model/export/SystemMenuExportRowVo.java | 2 +- .../export/SystemOssStorageExportRowVo.java | 2 +- .../export/SystemQuartzJobExportRowVo.java | 2 +- .../export/SystemQuartzLogExportRowVo.java | 2 +- .../model/export/SystemRoleExportRowVo.java | 2 +- .../model/export/SystemUserExportRowVo.java | 2 +- .../request/SystemCheckEmailCaptchaArgs.java | 2 +- .../model/request/SystemCreateDeptArgs.java | 4 +- .../model/request/SystemCreateDictArgs.java | 2 +- .../request/SystemCreateDictDetailArgs.java | 4 +- .../model/request/SystemCreateJobArgs.java | 4 +- .../model/request/SystemCreateRoleArgs.java | 4 +- .../model/request/SystemQueryDeptArgs.java | 2 +- .../dal/model/request/SystemQueryJobArgs.java | 4 +- .../model/request/SystemQueryMenuArgs.java | 2 +- .../request/SystemQueryQuartzJobArgs.java | 2 +- .../model/request/SystemQueryRoleArgs.java | 2 +- .../model/request/SystemQueryStorageArgs.java | 2 +- .../model/request/SystemQueryUserArgs.java | 4 +- .../model/request/SystemSendEmailArgs.java | 6 +- .../request/SystemUpdateQuartzJobArgs.java | 4 +- .../model/request/SystemUserLoginArgs.java | 2 +- .../dal/model/response/SystemDeptVo.java | 4 +- .../model/response/SystemMenuRouterVo.java | 2 +- .../dal/model/response/SystemMenuVo.java | 4 +- .../response/SystemProductLineTreeVo.java | 2 +- .../dal/model/response/SystemQuartzJobVo.java | 1 + .../dal/model/response/SystemRoleVo.java | 4 +- .../model/response/SystemSimpleUserVo.java | 4 +- .../dal/model/response/SystemUserInfoVo.java | 4 +- .../dal/model/response/SystemUserJwtVo.java | 6 +- .../model/response/SystemUserOnlineVo.java | 2 +- .../dal/model/response/SystemUserVo.java | 4 +- .../dal/mysql/SystemDictDetailMapper.java | 6 +- .../dal/mysql/SystemRoleDeptMapper.java | 2 +- .../system/dal/mysql/SystemUserJobMapper.java | 2 +- .../system/dal/mysql/SystemUserMapper.java | 2 +- .../dal/mysql/SystemUserRoleMapper.java | 2 +- .../dal/redis/SystemUserOnlineInfoDAO.java | 6 +- .../operalog/OperationLogAspect.java | 5 +- .../system/framework/quartz/QuartzManage.java | 2 +- .../storage/minio/MinioRepository.java | 4 +- .../system/service/SystemAuthService.java | 132 +-- .../system/service/SystemCaptchaService.java | 86 +- .../system/service/SystemDataService.java | 110 +-- .../system/service/SystemDeptService.java | 828 ++++++++--------- .../service/SystemDictDetailService.java | 196 ++-- .../system/service/SystemDictService.java | 180 ++-- .../system/service/SystemEmailService.java | 220 ++--- .../system/service/SystemJobService.java | 204 ++--- .../service/SystemLocalStorageService.java | 236 ++--- .../system/service/SystemMenuService.java | 786 ++++++++-------- .../system/service/SystemMonitorService.java | 330 +++---- .../service/SystemOperationLogService.java | 22 +- .../service/SystemOssStorageService.java | 12 +- .../service/SystemQuartzJobService.java | 486 +++++----- .../system/service/SystemRoleDeptService.java | 104 +-- .../system/service/SystemRoleMenuService.java | 120 +-- .../system/service/SystemRoleService.java | 440 ++++----- .../system/service/SystemUserDeptService.java | 16 +- .../system/service/SystemUserJobService.java | 80 +- .../system/service/SystemUserRoleService.java | 214 ++--- .../system/service/SystemUserService.java | 860 ++++++++--------- .../impl/SystemMinioStorageServiceImpl.java | 196 ++-- .../dal/model/response/SystemQuartzJobVo.java | 1 + .../dal/mysql/SystemDictDetailMapper.java | 6 +- .../dal/mysql/SystemRoleDeptMapper.java | 1 - .../system/dal/mysql/SystemUserJobMapper.java | 1 - .../operalog/OperationLogAspect.java | 3 +- .../storage/local/MultipartConfig.java | 4 +- .../system/service/SystemAuthService.java | 134 +-- .../system/service/SystemCaptchaService.java | 85 +- .../system/service/SystemDataService.java | 109 ++- .../system/service/SystemDeptService.java | 830 ++++++++--------- .../service/SystemDictDetailService.java | 196 ++-- .../system/service/SystemDictService.java | 182 ++-- .../system/service/SystemEmailService.java | 220 ++--- .../system/service/SystemJobService.java | 206 ++--- .../service/SystemLocalStorageService.java | 236 ++--- .../system/service/SystemMenuService.java | 788 ++++++++-------- .../system/service/SystemMonitorService.java | 330 +++---- .../service/SystemOperationLogService.java | 22 +- .../service/SystemOssStorageService.java | 14 +- .../service/SystemQuartzJobService.java | 488 +++++----- .../system/service/SystemRoleDeptService.java | 100 +- .../system/service/SystemRoleMenuService.java | 120 +-- .../system/service/SystemRoleService.java | 436 ++++----- .../system/service/SystemUserDeptService.java | 16 +- .../system/service/SystemUserJobService.java | 80 +- .../system/service/SystemUserRoleService.java | 214 ++--- .../system/service/SystemUserService.java | 862 +++++++++--------- .../impl/SystemMinioStorageServiceImpl.java | 196 ++-- 115 files changed, 5969 insertions(+), 5969 deletions(-) diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDeptController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDeptController.java index b6b009a0..266ca03a 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDeptController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDeptController.java @@ -26,9 +26,9 @@ import cn.odboy.system.service.SystemDeptService; import cn.odboy.util.KitPageUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import jakarta.servlet.http.HttpServletResponse; import java.util.List; import java.util.Set; -import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictController.java index e3d3e9ae..1bd4485e 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictController.java @@ -25,9 +25,9 @@ import cn.odboy.system.service.SystemDictService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import jakarta.servlet.http.HttpServletResponse; import java.util.List; import java.util.Set; -import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemJobController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemJobController.java index 0ab929cf..2147717f 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemJobController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemJobController.java @@ -25,8 +25,8 @@ import cn.odboy.system.service.SystemJobService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import java.util.Set; import jakarta.servlet.http.HttpServletResponse; +import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMenuController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMenuController.java index 992eebd3..dcbcae27 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMenuController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMenuController.java @@ -27,9 +27,9 @@ import cn.odboy.system.service.SystemMenuService; import cn.odboy.util.KitPageUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import jakarta.servlet.http.HttpServletResponse; import java.util.List; import java.util.Set; -import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOnlineController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOnlineController.java index 2ccc1927..5a0f5d91 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOnlineController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOnlineController.java @@ -24,8 +24,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import java.util.Set; import jakarta.servlet.http.HttpServletResponse; +import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemQuartzJobController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemQuartzJobController.java index 43d90df4..d366d25b 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemQuartzJobController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemQuartzJobController.java @@ -27,8 +27,8 @@ import cn.odboy.system.service.SystemQuartzJobService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import java.util.Set; import jakarta.servlet.http.HttpServletResponse; +import java.util.Set; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemRoleController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemRoleController.java index d90d44e5..9fa710f3 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemRoleController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemRoleController.java @@ -27,9 +27,9 @@ import cn.odboy.system.service.SystemRoleService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import jakarta.servlet.http.HttpServletResponse; import java.util.List; import java.util.Set; -import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemUserController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemUserController.java index aa1358c9..2a7274f1 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemUserController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemUserController.java @@ -30,9 +30,9 @@ import cn.odboy.system.service.SystemUserService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import jakarta.servlet.http.HttpServletResponse; import java.util.List; import java.util.Set; -import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDeptTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDeptTb.java index b7daf633..4c454a28 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDeptTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDeptTb.java @@ -22,9 +22,9 @@ import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; +import java.util.Objects; import lombok.Getter; import lombok.Setter; -import java.util.Objects; @Getter @Setter @@ -79,4 +79,4 @@ public class SystemDeptTb extends KitBaseUserTimeTb { public String getLabel() { return name; } -} \ No newline at end of file +} diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictDetailTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictDetailTb.java index caab4087..0a525186 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictDetailTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictDetailTb.java @@ -21,9 +21,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.NotNull; import lombok.Getter; import lombok.Setter; -import jakarta.validation.constraints.NotNull; @Getter @Setter @@ -43,4 +43,4 @@ public class SystemDictDetailTb extends KitBaseUserTimeTb { private String value; @ApiModelProperty(value = "排序") private Integer dictSort = 999; -} \ No newline at end of file +} diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictTb.java index d80bffd0..d5e06719 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictTb.java @@ -22,10 +22,10 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.Setter; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; @Getter @Setter @@ -42,4 +42,4 @@ public class SystemDictTb extends KitBaseUserTimeTb { @ApiModelProperty(value = "描述") @TableField(updateStrategy = FieldStrategy.ALWAYS) private String description; -} \ No newline at end of file +} diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemEmailConfigTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemEmailConfigTb.java index 13fa3848..a687fd4f 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemEmailConfigTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemEmailConfigTb.java @@ -19,9 +19,9 @@ import cn.odboy.base.KitObject; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.NotBlank; import lombok.Data; import lombok.EqualsAndHashCode; -import jakarta.validation.constraints.NotBlank; /** * 邮件配置类,数据存覆盖式存入数据存 diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemJobTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemJobTb.java index 39574cb0..0e9a12fb 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemJobTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemJobTb.java @@ -20,11 +20,11 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.Setter; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import java.util.Objects; +import lombok.Getter; +import lombok.Setter; @Getter @Setter @@ -61,4 +61,4 @@ public class SystemJobTb extends KitBaseUserTimeTb { public int hashCode() { return Objects.hash(id); } -} \ No newline at end of file +} diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemMenuTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemMenuTb.java index 3f7d1cd7..a1b38205 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemMenuTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemMenuTb.java @@ -21,10 +21,10 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.Setter; import jakarta.validation.constraints.NotNull; import java.util.Objects; +import lombok.Getter; +import lombok.Setter; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemOperationLogTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemOperationLogTb.java index 345c7887..e32d899d 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemOperationLogTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemOperationLogTb.java @@ -23,10 +23,10 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.util.Date; import lombok.Getter; import lombok.Setter; import lombok.ToString; -import java.util.Date; /** *

diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzJobTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzJobTb.java index fe865114..d8e9af14 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzJobTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzJobTb.java @@ -22,10 +22,10 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.Setter; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; @Getter @Setter @@ -63,4 +63,4 @@ public class SystemQuartzJobTb extends KitBaseUserTimeTb { @ApiModelProperty(value = "备注") @TableField(updateStrategy = FieldStrategy.ALWAYS) private String description; -} \ No newline at end of file +} diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzLogTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzLogTb.java index 3a82a0a6..514c28e4 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzLogTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzLogTb.java @@ -22,9 +22,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; +import java.util.Date; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Date; @Data @TableName("system_quartz_log") diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleTb.java index 342e3371..54fc4884 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleTb.java @@ -23,11 +23,11 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.Setter; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import java.util.Objects; +import lombok.Getter; +import lombok.Setter; /** * 角色 diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserTb.java index b89748d3..01085ac8 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserTb.java @@ -21,13 +21,13 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.Setter; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import java.util.Date; import java.util.Objects; +import lombok.Getter; +import lombok.Setter; @Getter @Setter @@ -86,4 +86,4 @@ public class SystemUserTb extends KitBaseUserTimeTb { public int hashCode() { return Objects.hash(id, username); } -} \ No newline at end of file +} diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemDeptExportRowVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemDeptExportRowVo.java index 8173a6d6..02a9da71 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemDeptExportRowVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemDeptExportRowVo.java @@ -2,9 +2,9 @@ package cn.odboy.system.dal.model.export; import cn.idev.excel.annotation.ExcelProperty; import cn.odboy.base.KitObject; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemDictExportRowVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemDictExportRowVo.java index a9ecf480..0cd7ff7d 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemDictExportRowVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemDictExportRowVo.java @@ -2,9 +2,9 @@ package cn.odboy.system.dal.model.export; import cn.idev.excel.annotation.ExcelProperty; import cn.odboy.base.KitObject; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemJobExportRowVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemJobExportRowVo.java index bfba86f8..d4e6f2cd 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemJobExportRowVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemJobExportRowVo.java @@ -2,9 +2,9 @@ package cn.odboy.system.dal.model.export; import cn.idev.excel.annotation.ExcelProperty; import cn.odboy.base.KitObject; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemLocalStorageExportRowVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemLocalStorageExportRowVo.java index 232e082b..5148a50e 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemLocalStorageExportRowVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemLocalStorageExportRowVo.java @@ -2,9 +2,9 @@ package cn.odboy.system.dal.model.export; import cn.idev.excel.annotation.ExcelProperty; import cn.odboy.base.KitObject; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemMenuExportRowVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemMenuExportRowVo.java index 8e5c4c71..21c2f4e2 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemMenuExportRowVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemMenuExportRowVo.java @@ -2,9 +2,9 @@ package cn.odboy.system.dal.model.export; import cn.idev.excel.annotation.ExcelProperty; import cn.odboy.base.KitObject; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemOssStorageExportRowVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemOssStorageExportRowVo.java index 552737ed..da9d765d 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemOssStorageExportRowVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemOssStorageExportRowVo.java @@ -2,9 +2,9 @@ package cn.odboy.system.dal.model.export; import cn.idev.excel.annotation.ExcelProperty; import cn.odboy.base.KitObject; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemQuartzJobExportRowVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemQuartzJobExportRowVo.java index 1e773828..1f35df7e 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemQuartzJobExportRowVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemQuartzJobExportRowVo.java @@ -2,9 +2,9 @@ package cn.odboy.system.dal.model.export; import cn.idev.excel.annotation.ExcelProperty; import cn.odboy.base.KitObject; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemQuartzLogExportRowVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemQuartzLogExportRowVo.java index 5f536e7a..de272d53 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemQuartzLogExportRowVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemQuartzLogExportRowVo.java @@ -2,9 +2,9 @@ package cn.odboy.system.dal.model.export; import cn.idev.excel.annotation.ExcelProperty; import cn.odboy.base.KitObject; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemRoleExportRowVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemRoleExportRowVo.java index 155b57e8..549ff2e8 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemRoleExportRowVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemRoleExportRowVo.java @@ -2,9 +2,9 @@ package cn.odboy.system.dal.model.export; import cn.idev.excel.annotation.ExcelProperty; import cn.odboy.base.KitObject; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemUserExportRowVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemUserExportRowVo.java index 2ffcecae..cb91d952 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemUserExportRowVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/export/SystemUserExportRowVo.java @@ -2,9 +2,9 @@ package cn.odboy.system.dal.model.export; import cn.idev.excel.annotation.ExcelProperty; import cn.odboy.base.KitObject; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCheckEmailCaptchaArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCheckEmailCaptchaArgs.java index 97a0e8b3..b5d776b1 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCheckEmailCaptchaArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCheckEmailCaptchaArgs.java @@ -16,9 +16,9 @@ package cn.odboy.system.dal.model.request; import cn.odboy.base.KitObject; +import jakarta.validation.constraints.NotBlank; import lombok.Getter; import lombok.Setter; -import jakarta.validation.constraints.NotBlank; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateDeptArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateDeptArgs.java index 6a4db862..48f2b339 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateDeptArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateDeptArgs.java @@ -16,10 +16,10 @@ package cn.odboy.system.dal.model.request; import cn.odboy.base.KitObject; -import lombok.Data; -import lombok.EqualsAndHashCode; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateDictArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateDictArgs.java index a18a0341..545425df 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateDictArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateDictArgs.java @@ -16,9 +16,9 @@ package cn.odboy.system.dal.model.request; import cn.odboy.base.KitObject; +import jakarta.validation.constraints.NotBlank; import lombok.Data; import lombok.EqualsAndHashCode; -import jakarta.validation.constraints.NotBlank; @Data @EqualsAndHashCode(callSuper = false) diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateDictDetailArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateDictDetailArgs.java index 20b2d686..99eeb7c7 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateDictDetailArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateDictDetailArgs.java @@ -17,10 +17,10 @@ package cn.odboy.system.dal.model.request; import cn.odboy.base.KitObject; import cn.odboy.system.dal.dataobject.SystemDictTb; -import lombok.Data; -import lombok.EqualsAndHashCode; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateJobArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateJobArgs.java index 3cf210f1..3a162e65 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateJobArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateJobArgs.java @@ -16,10 +16,10 @@ package cn.odboy.system.dal.model.request; import cn.odboy.base.KitObject; -import lombok.Data; -import lombok.EqualsAndHashCode; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateRoleArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateRoleArgs.java index f9526661..c195955a 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateRoleArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateRoleArgs.java @@ -17,11 +17,11 @@ package cn.odboy.system.dal.model.request; import cn.odboy.base.KitObject; import cn.odboy.system.dal.dataobject.SystemDeptTb; -import lombok.Data; -import lombok.EqualsAndHashCode; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import java.util.Set; +import lombok.Data; +import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryDeptArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryDeptArgs.java index 73b2b8c5..008cc29a 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryDeptArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryDeptArgs.java @@ -16,9 +16,9 @@ package cn.odboy.system.dal.model.request; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; import java.util.Date; import java.util.List; +import lombok.Data; @Data public class SystemQueryDeptArgs { diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryJobArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryJobArgs.java index 84dd329f..299d1543 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryJobArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryJobArgs.java @@ -16,10 +16,10 @@ package cn.odboy.system.dal.model.request; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.NoArgsConstructor; import java.util.Date; import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; @Data @NoArgsConstructor diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryMenuArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryMenuArgs.java index 8c2b881e..f7a45ff9 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryMenuArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryMenuArgs.java @@ -16,9 +16,9 @@ package cn.odboy.system.dal.model.request; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; import java.util.Date; import java.util.List; +import lombok.Data; @Data public class SystemQueryMenuArgs { diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryQuartzJobArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryQuartzJobArgs.java index 421a34fa..6aebbb30 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryQuartzJobArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryQuartzJobArgs.java @@ -16,9 +16,9 @@ package cn.odboy.system.dal.model.request; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; import java.util.Date; import java.util.List; +import lombok.Data; @Data public class SystemQueryQuartzJobArgs { diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryRoleArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryRoleArgs.java index 38e0aff3..b3771982 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryRoleArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryRoleArgs.java @@ -16,9 +16,9 @@ package cn.odboy.system.dal.model.request; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; import java.util.Date; import java.util.List; +import lombok.Data; @Data public class SystemQueryRoleArgs { diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryStorageArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryStorageArgs.java index befe3996..4e524e5d 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryStorageArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryStorageArgs.java @@ -16,9 +16,9 @@ package cn.odboy.system.dal.model.request; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; import java.util.Date; import java.util.List; +import lombok.Data; @Data public class SystemQueryStorageArgs { diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryUserArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryUserArgs.java index 134c29de..42ad7160 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryUserArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemQueryUserArgs.java @@ -17,12 +17,12 @@ package cn.odboy.system.dal.model.request; import cn.odboy.base.KitObject; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.EqualsAndHashCode; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; +import lombok.Data; +import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemSendEmailArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemSendEmailArgs.java index e289dd29..ef1d03e2 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemSendEmailArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemSendEmailArgs.java @@ -16,12 +16,12 @@ package cn.odboy.system.dal.model.request; import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotEmpty; import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; /** * 发送邮件时,接收参数的类 diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemUpdateQuartzJobArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemUpdateQuartzJobArgs.java index dbe967f3..c568980c 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemUpdateQuartzJobArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemUpdateQuartzJobArgs.java @@ -16,10 +16,10 @@ package cn.odboy.system.dal.model.request; import cn.odboy.base.KitObject; -import lombok.Data; -import lombok.EqualsAndHashCode; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemUserLoginArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemUserLoginArgs.java index 7ffa5127..1b629817 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemUserLoginArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemUserLoginArgs.java @@ -16,9 +16,9 @@ package cn.odboy.system.dal.model.request; import io.swagger.annotations.ApiModelProperty; +import jakarta.validation.constraints.NotBlank; import lombok.Getter; import lombok.Setter; -import jakarta.validation.constraints.NotBlank; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemDeptVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemDeptVo.java index e88f92b9..ae6dba88 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemDeptVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemDeptVo.java @@ -3,11 +3,11 @@ package cn.odboy.system.dal.model.response; import cn.odboy.base.KitBaseUserTimeTb; import cn.odboy.system.dal.dataobject.SystemRoleTb; import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.Setter; import java.util.List; import java.util.Objects; import java.util.Set; +import lombok.Getter; +import lombok.Setter; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemMenuRouterVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemMenuRouterVo.java index e2303138..d98c65ff 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemMenuRouterVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemMenuRouterVo.java @@ -17,9 +17,9 @@ package cn.odboy.system.dal.model.response; import cn.odboy.base.KitObject; import io.swagger.annotations.ApiModelProperty; +import java.util.List; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.List; /** * 构建前端路由时用到 diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemMenuVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemMenuVo.java index fbb7e339..597a02af 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemMenuVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemMenuVo.java @@ -3,11 +3,11 @@ package cn.odboy.system.dal.model.response; import cn.odboy.base.KitBaseUserTimeTb; import cn.odboy.system.dal.dataobject.SystemRoleTb; import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.Setter; import java.util.List; import java.util.Objects; import java.util.Set; +import lombok.Getter; +import lombok.Setter; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemProductLineTreeVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemProductLineTreeVo.java index 417025d5..91527bee 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemProductLineTreeVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemProductLineTreeVo.java @@ -16,9 +16,9 @@ package cn.odboy.system.dal.model.response; import cn.odboy.base.KitObject; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemQuartzJobVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemQuartzJobVo.java index caf2e513..3dcf0f8c 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemQuartzJobVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemQuartzJobVo.java @@ -8,6 +8,7 @@ import lombok.Setter; @Getter @Setter public class SystemQuartzJobVo extends KitBaseUserTimeTb { + private Long id; @ApiModelProperty(value = "定时器名称") private String jobName; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemRoleVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemRoleVo.java index 92eba2c6..88a34ce2 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemRoleVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemRoleVo.java @@ -5,10 +5,10 @@ import cn.odboy.system.constant.SystemDataScopeEnum; import cn.odboy.system.dal.dataobject.SystemDeptTb; import cn.odboy.system.dal.dataobject.SystemUserTb; import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.Setter; import java.util.Objects; import java.util.Set; +import lombok.Getter; +import lombok.Setter; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemSimpleUserVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemSimpleUserVo.java index 4b2aef64..7585556c 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemSimpleUserVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemSimpleUserVo.java @@ -20,9 +20,9 @@ import cn.odboy.system.dal.dataobject.SystemDeptTb; import cn.odboy.system.dal.dataobject.SystemJobTb; import cn.odboy.system.dal.dataobject.SystemRoleTb; import io.swagger.annotations.ApiModelProperty; +import java.util.Set; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Set; @Data @EqualsAndHashCode(callSuper = false) @@ -52,4 +52,4 @@ public class SystemSimpleUserVo extends KitObject { private Boolean enabled; @ApiModelProperty(value = "是否为admin账号", hidden = true) private Boolean isAdmin = false; -} \ No newline at end of file +} diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserInfoVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserInfoVo.java index 4d4a6bff..1d435bc4 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserInfoVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserInfoVo.java @@ -16,11 +16,11 @@ package cn.odboy.system.dal.model.response; import cn.odboy.base.KitObject; -import lombok.Data; -import lombok.EqualsAndHashCode; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import lombok.Data; +import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserJwtVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserJwtVo.java index 5f9c064c..9d47f2ef 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserJwtVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserJwtVo.java @@ -17,12 +17,12 @@ package cn.odboy.system.dal.model.response; import com.alibaba.fastjson2.annotation.JSONField; import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Getter; -import org.springframework.security.core.userdetails.UserDetails; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.springframework.security.core.userdetails.UserDetails; @Getter @AllArgsConstructor diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserOnlineVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserOnlineVo.java index 1d66b684..90d0ad67 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserOnlineVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserOnlineVo.java @@ -16,8 +16,8 @@ package cn.odboy.system.dal.model.response; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; import java.util.Date; +import lombok.Data; /** * 在线用户 diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserVo.java index 3aa00bfb..0495fc8f 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemUserVo.java @@ -4,11 +4,11 @@ import cn.odboy.base.KitBaseUserTimeTb; import cn.odboy.system.dal.dataobject.SystemJobTb; import cn.odboy.system.dal.dataobject.SystemRoleTb; import io.swagger.annotations.ApiModelProperty; -import lombok.Getter; -import lombok.Setter; import java.util.Date; import java.util.Objects; import java.util.Set; +import lombok.Getter; +import lombok.Setter; @Getter @Setter diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDictDetailMapper.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDictDetailMapper.java index 7771e651..ae579144 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDictDetailMapper.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDictDetailMapper.java @@ -21,9 +21,9 @@ import cn.odboy.system.dal.model.response.SystemDictDetailVo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.util.List; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import java.util.List; /** * 字典明细 Mapper @@ -33,7 +33,7 @@ import java.util.List; @Mapper public interface SystemDictDetailMapper extends BaseMapper { - IPage selectPageByArgs(Page page, @Param("args") SystemQueryDictDetailArgs args); + IPage selectPageByArgs(Page page, @Param("args") SystemQueryDictDetailArgs args); - List listDictDetailByName(@Param("name") String name); + List listDictDetailByName(@Param("name") String name); } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleDeptMapper.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleDeptMapper.java index 0d5740b4..e94bdbda 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleDeptMapper.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleDeptMapper.java @@ -18,9 +18,9 @@ package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemDeptTb; import cn.odboy.system.dal.dataobject.SystemRoleDeptTb; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import java.util.Set; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import java.util.Set; /** * 角色部门关联 Mapper diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserJobMapper.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserJobMapper.java index cb38efbc..60655242 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserJobMapper.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserJobMapper.java @@ -18,9 +18,9 @@ package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemJobTb; import cn.odboy.system.dal.dataobject.SystemUserJobTb; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import java.util.Set; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import java.util.Set; /** * 用户职位关联 Mapper diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserMapper.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserMapper.java index 1676257e..4bfdd651 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserMapper.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserMapper.java @@ -18,8 +18,8 @@ package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemUserTb; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; import java.util.Set; +import org.apache.ibatis.annotations.Mapper; /** * 用户 Mapper diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserRoleMapper.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserRoleMapper.java index d3937f9c..cc6cf958 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserRoleMapper.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserRoleMapper.java @@ -18,9 +18,9 @@ package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemRoleTb; import cn.odboy.system.dal.dataobject.SystemUserRoleTb; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import java.util.Set; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import java.util.Set; @Mapper public interface SystemUserRoleMapper extends BaseMapper { diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java index 88a7990e..17f6d339 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java @@ -15,9 +15,6 @@ import cn.odboy.util.KitIPUtil; import cn.odboy.util.KitPageUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.metadata.IPage; -import lombok.AllArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Component; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import java.util.ArrayList; @@ -26,6 +23,9 @@ import java.util.Date; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; @Slf4j @Component diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/OperationLogAspect.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/OperationLogAspect.java index 87652ac1..f882e811 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/OperationLogAspect.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/OperationLogAspect.java @@ -28,6 +28,7 @@ import cn.odboy.util.KitIPUtil; import com.alibaba.fastjson2.JSON; import io.swagger.annotations.ApiOperation; import jakarta.servlet.http.HttpServletRequest; +import java.lang.reflect.Method; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -35,7 +36,6 @@ import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.lang.reflect.Method; /** * 捕捉操作日志 @@ -48,7 +48,8 @@ import java.lang.reflect.Method; @Component public class OperationLogAspect { - @Autowired private SystemOperationLogMapper systemOperationLogMapper; + @Autowired + private SystemOperationLogMapper systemOperationLogMapper; @Around("@annotation(operationLog)") public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog) diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/QuartzManage.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/QuartzManage.java index 6b80b97d..3057ba88 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/QuartzManage.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/QuartzManage.java @@ -18,8 +18,8 @@ package cn.odboy.system.framework.quartz; import cn.odboy.framework.exception.BadRequestException; import cn.odboy.system.dal.dataobject.SystemQuartzJobTb; import cn.odboy.system.dal.model.response.SystemQuartzJobVo; -import java.util.Date; import jakarta.annotation.Resource; +import java.util.Date; import lombok.extern.slf4j.Slf4j; import org.quartz.CronScheduleBuilder; import org.quartz.CronTrigger; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/minio/MinioRepository.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/minio/MinioRepository.java index 8980a0d4..6332d57f 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/minio/MinioRepository.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/minio/MinioRepository.java @@ -43,13 +43,13 @@ import io.minio.Result; import io.minio.http.Method; import io.minio.messages.Bucket; import io.minio.messages.Item; +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.http.HttpServletResponse; import java.io.File; import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import jakarta.servlet.ServletOutputStream; -import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java index feb4c08b..ce820994 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java @@ -28,76 +28,76 @@ import org.springframework.stereotype.Service; @Service public class SystemAuthService { - @Autowired - private AppProperties properties; - @Autowired - private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; - @Autowired - private TokenProvider tokenProvider; - @Autowired - private PasswordEncoder passwordEncoder; - @Autowired - private UserDetailsHandler userDetailsService; - @Autowired - private SystemCaptchaService systemCaptchaService; + @Autowired + private AppProperties properties; + @Autowired + private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; + @Autowired + private TokenProvider tokenProvider; + @Autowired + private PasswordEncoder passwordEncoder; + @Autowired + private UserDetailsHandler userDetailsService; + @Autowired + private SystemCaptchaService systemCaptchaService; - /** - * 登录 -> TestPassed - */ - public SystemAuthVo doLogin(SystemUserLoginArgs loginArgs, HttpServletRequest request) throws Exception { - KitValidUtil.notNull(loginArgs); + /** + * 登录 -> TestPassed + */ + public SystemAuthVo doLogin(SystemUserLoginArgs loginArgs, HttpServletRequest request) throws Exception { + KitValidUtil.notNull(loginArgs); - // 密码解密 - String password = - KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginArgs.getPassword()); - // 校验验证码 - systemCaptchaService.validate(loginArgs.getUuid(), loginArgs.getCode()); - // 获取用户信息 - SystemUserJwtVo jwtUser = userDetailsService.loadUserByUsername(loginArgs.getUsername()); - // 验证用户密码 - if (!passwordEncoder.matches(password, jwtUser.getPassword())) { - throw new BadRequestException("登录密码错误"); - } - - // 登录验证 - Authentication authentication = - new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities()); - SecurityContextHolder.getContext().setAuthentication(authentication); - - // 生成令牌 - String token = tokenProvider.createToken(jwtUser); - // 返回 token 与 用户信息 - SystemAuthVo authInfo = new SystemAuthVo(); - authInfo.setToken(String.format("%s %s", SystemConst.TOKEN_PREFIX, token)); - /// 这里是为了清空密码 - authInfo.setUser(KitBeanUtil.copyToClass(jwtUser, SystemUserInfoVo.class)); - - if (properties.getLogin().isSingle()) { - // 踢掉之前已经登录的token - systemUserOnlineInfoDAO.kickOutByUsername(loginArgs.getUsername()); - } - // 保存在线信息 - systemUserOnlineInfoDAO.saveUserJwtModelByToken(jwtUser, token, request); - // 返回登录信息 - return authInfo; + // 密码解密 + String password = + KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginArgs.getPassword()); + // 校验验证码 + systemCaptchaService.validate(loginArgs.getUuid(), loginArgs.getCode()); + // 获取用户信息 + SystemUserJwtVo jwtUser = userDetailsService.loadUserByUsername(loginArgs.getUsername()); + // 验证用户密码 + if (!passwordEncoder.matches(password, jwtUser.getPassword())) { + throw new BadRequestException("登录密码错误"); } - /** - * 获取当前登录人信息 -> TestPassed - */ - public SystemUserJwtVo getCurrentUserInfo() { - SystemUserJwtVo jwtUser = (SystemUserJwtVo)KitSecurityHelper.getCurrentUser(); - if (jwtUser.getUser() != null) { - jwtUser.getUser().setPassword(null); - } - return jwtUser; - } + // 登录验证 + Authentication authentication = + new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities()); + SecurityContextHolder.getContext().setAuthentication(authentication); - /** - * 退出登录 -> TestPassed - */ - public void doLogout(HttpServletRequest request) { - String token = tokenProvider.getToken(request); - systemUserOnlineInfoDAO.logoutByToken(token); + // 生成令牌 + String token = tokenProvider.createToken(jwtUser); + // 返回 token 与 用户信息 + SystemAuthVo authInfo = new SystemAuthVo(); + authInfo.setToken(String.format("%s %s", SystemConst.TOKEN_PREFIX, token)); + /// 这里是为了清空密码 + authInfo.setUser(KitBeanUtil.copyToClass(jwtUser, SystemUserInfoVo.class)); + + if (properties.getLogin().isSingle()) { + // 踢掉之前已经登录的token + systemUserOnlineInfoDAO.kickOutByUsername(loginArgs.getUsername()); } + // 保存在线信息 + systemUserOnlineInfoDAO.saveUserJwtModelByToken(jwtUser, token, request); + // 返回登录信息 + return authInfo; + } + + /** + * 获取当前登录人信息 -> TestPassed + */ + public SystemUserJwtVo getCurrentUserInfo() { + SystemUserJwtVo jwtUser = (SystemUserJwtVo) KitSecurityHelper.getCurrentUser(); + if (jwtUser.getUser() != null) { + jwtUser.getUser().setPassword(null); + } + return jwtUser; + } + + /** + * 退出登录 -> TestPassed + */ + public void doLogout(HttpServletRequest request) { + String token = tokenProvider.getToken(request); + systemUserOnlineInfoDAO.logoutByToken(token); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java index 2a6776e3..308d5129 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java @@ -10,9 +10,9 @@ import cn.odboy.framework.redis.KitRedisHelper; import cn.odboy.system.dal.model.response.SystemCaptchaVo; import cn.odboy.system.dal.redis.SystemCacheKey; import com.wf.captcha.base.Captcha; +import java.util.concurrent.TimeUnit; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.concurrent.TimeUnit; /** * 验证码 @@ -20,50 +20,50 @@ import java.util.concurrent.TimeUnit; @Service public class SystemCaptchaService { - @Autowired - private KitRedisHelper redisHelper; - @Autowired - private AppProperties properties; + @Autowired + private KitRedisHelper redisHelper; + @Autowired + private AppProperties properties; - /** - * 获取登录验证码 -> TestPassed - */ - public SystemCaptchaVo getLoginCaptcha() { - // 获取运算的结果 - Captcha captcha = properties.getLogin().getCaptchaSetting().getCaptcha(); - String uuid = SystemCacheKey.CAPTCHA_LOGIN + IdUtil.simpleUUID(); - //当验证码类型为 arithmetic时且长度 >= 2 时, captcha.text()的结果有几率为浮点型 - String captchaValue = captcha.text(); - if (captcha.getCharType() - 1 == CaptchaCodeEnum.ARITHMETIC.ordinal() && captchaValue.contains( - SystemConst.SYMBOL_DOT)) { - captchaValue = captchaValue.split("\\.")[0]; - } - // 保存 - redisHelper.set(uuid, captchaValue, properties.getLogin().getCaptchaSetting().getExpiration(), - TimeUnit.MINUTES); - // 验证码信息 - SystemCaptchaVo captchaVo = new SystemCaptchaVo(); - captchaVo.setUuid(uuid); - captchaVo.setImg(captcha.toBase64()); - return captchaVo; + /** + * 获取登录验证码 -> TestPassed + */ + public SystemCaptchaVo getLoginCaptcha() { + // 获取运算的结果 + Captcha captcha = properties.getLogin().getCaptchaSetting().getCaptcha(); + String uuid = SystemCacheKey.CAPTCHA_LOGIN + IdUtil.simpleUUID(); + //当验证码类型为 arithmetic时且长度 >= 2 时, captcha.text()的结果有几率为浮点型 + String captchaValue = captcha.text(); + if (captcha.getCharType() - 1 == CaptchaCodeEnum.ARITHMETIC.ordinal() && captchaValue.contains( + SystemConst.SYMBOL_DOT)) { + captchaValue = captchaValue.split("\\.")[0]; } + // 保存 + redisHelper.set(uuid, captchaValue, properties.getLogin().getCaptchaSetting().getExpiration(), + TimeUnit.MINUTES); + // 验证码信息 + SystemCaptchaVo captchaVo = new SystemCaptchaVo(); + captchaVo.setUuid(uuid); + captchaVo.setImg(captcha.toBase64()); + return captchaVo; + } - /** - * 验证验证码 -> TestPassed - * - * @param uuid 验证码uuid - * @param inputCode 用户输入的验证码 - */ - public void validate(String uuid, String inputCode) { - // 查询验证码 - String code = redisHelper.get(uuid, String.class); - if (StrUtil.isBlank(code)) { - throw new BadRequestException("验证码不存在或已过期"); - } - // 清除验证码 - redisHelper.del(uuid); - if (StrUtil.isBlank(inputCode) || !code.equalsIgnoreCase(inputCode)) { - throw new BadRequestException("验证码错误"); - } + /** + * 验证验证码 -> TestPassed + * + * @param uuid 验证码uuid + * @param inputCode 用户输入的验证码 + */ + public void validate(String uuid, String inputCode) { + // 查询验证码 + String code = redisHelper.get(uuid, String.class); + if (StrUtil.isBlank(code)) { + throw new BadRequestException("验证码不存在或已过期"); } + // 清除验证码 + redisHelper.del(uuid); + if (StrUtil.isBlank(inputCode) || !code.equalsIgnoreCase(inputCode)) { + throw new BadRequestException("验证码错误"); + } + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java index fa552094..17fd9f30 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java @@ -20,14 +20,14 @@ import cn.odboy.system.constant.SystemDataScopeEnum; import cn.odboy.system.dal.dataobject.SystemDeptTb; import cn.odboy.system.dal.dataobject.SystemRoleTb; import cn.odboy.system.dal.model.response.SystemUserVo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** * 数据权限 @@ -37,61 +37,61 @@ import java.util.stream.Collectors; @Service public class SystemDataService { - @Autowired - private SystemUserRoleService systemUserRoleService; - @Autowired - private SystemDeptService systemDeptService; - @Autowired - private SystemRoleDeptService systemRoleDeptService; + @Autowired + private SystemUserRoleService systemUserRoleService; + @Autowired + private SystemDeptService systemDeptService; + @Autowired + private SystemRoleDeptService systemRoleDeptService; - /** - * 获取数据权限 -> TestPassed - * - * @param user / - * @return / - */ - public List queryDeptIdByArgs(SystemUserVo user) { - List deptIds = new ArrayList<>(); - // 查询用户角色 - Set roleList = systemUserRoleService.listUserRoleByUserId(user.getId()); - // 获取对应的部门ID - for (SystemRoleTb role : roleList) { - SystemDataScopeEnum dataScopeEnum = SystemDataScopeEnum.find(role.getDataScope()); - switch (Objects.requireNonNull(dataScopeEnum)) { - case THIS_LEVEL: - Long currentDeptId = user.getDept().getId(); - deptIds.add(currentDeptId); - break; - case CUSTOMIZE: - // 优化 283ms -> 51 ms - List customDeptIds = this.queryCustomDataPermissionByArgs(deptIds, role.getId()); - deptIds.addAll(customDeptIds); - break; - default: - return new ArrayList<>(); - } - } - return deptIds.stream().distinct().collect(Collectors.toList()); + /** + * 获取数据权限 -> TestPassed + * + * @param user / + * @return / + */ + public List queryDeptIdByArgs(SystemUserVo user) { + List deptIds = new ArrayList<>(); + // 查询用户角色 + Set roleList = systemUserRoleService.listUserRoleByUserId(user.getId()); + // 获取对应的部门ID + for (SystemRoleTb role : roleList) { + SystemDataScopeEnum dataScopeEnum = SystemDataScopeEnum.find(role.getDataScope()); + switch (Objects.requireNonNull(dataScopeEnum)) { + case THIS_LEVEL: + Long currentDeptId = user.getDept().getId(); + deptIds.add(currentDeptId); + break; + case CUSTOMIZE: + // 优化 283ms -> 51 ms + List customDeptIds = this.queryCustomDataPermissionByArgs(deptIds, role.getId()); + deptIds.addAll(customDeptIds); + break; + default: + return new ArrayList<>(); + } } + return deptIds.stream().distinct().collect(Collectors.toList()); + } - /** - * 获取自定义的数据权限 -> TestPassed - * - * @param deptIds 部门ID(外部数据) - * @param roleId 角色ID - * @return 数据权限ID(所有部门ID数据) - */ - private List queryCustomDataPermissionByArgs(List deptIds, Long roleId) { - Set deptList = systemRoleDeptService.listUserDeptByRoleId(roleId); - Map> deptPidMap = - systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); - for (SystemDeptTb dept : deptList) { - deptIds.add(dept.getId()); - List deptChildren = deptPidMap.getOrDefault(dept.getId(), null); - if (CollUtil.isNotEmpty(deptChildren)) { - deptIds.addAll(systemDeptService.queryChildDeptIdByDeptIds(deptChildren, deptPidMap)); - } - } - return deptIds; + /** + * 获取自定义的数据权限 -> TestPassed + * + * @param deptIds 部门ID(外部数据) + * @param roleId 角色ID + * @return 数据权限ID(所有部门ID数据) + */ + private List queryCustomDataPermissionByArgs(List deptIds, Long roleId) { + Set deptList = systemRoleDeptService.listUserDeptByRoleId(roleId); + Map> deptPidMap = + systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); + for (SystemDeptTb dept : deptList) { + deptIds.add(dept.getId()); + List deptChildren = deptPidMap.getOrDefault(dept.getId(), null); + if (CollUtil.isNotEmpty(deptChildren)) { + deptIds.addAll(systemDeptService.queryChildDeptIdByDeptIds(deptChildren, deptPidMap)); + } } + return deptIds; + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java index f784329f..f92bb582 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java @@ -36,9 +36,6 @@ import cn.odboy.util.KitClassUtil; import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import jakarta.servlet.http.HttpServletResponse; import java.lang.reflect.Field; import java.util.ArrayList; @@ -51,458 +48,461 @@ import java.util.Map; import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemDeptService { - @Autowired - private SystemDeptMapper systemDeptMapper; - @Autowired - private SystemUserDeptService systemUserDeptService; - @Autowired - private SystemRoleDeptService systemRoleDeptService; + @Autowired + private SystemDeptMapper systemDeptMapper; + @Autowired + private SystemUserDeptService systemUserDeptService; + @Autowired + private SystemRoleDeptService systemRoleDeptService; - /** - * 创建 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveDept(SystemCreateDeptArgs args) { - KitValidUtil.notNull(args); + /** + * 创建 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveDept(SystemCreateDeptArgs args) { + KitValidUtil.notNull(args); - SystemDeptTb record = KitBeanUtil.copyToClass(args, SystemDeptTb.class); - systemDeptMapper.insert(record); + SystemDeptTb record = KitBeanUtil.copyToClass(args, SystemDeptTb.class); + systemDeptMapper.insert(record); - this.updateDeptSubCnt(args.getPid()); + this.updateDeptSubCnt(args.getPid()); + } + + /** + * 编辑 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateDeptById(SystemDeptTb args) { + KitValidUtil.notNull(args); + // 旧的父部门 + Long oldPid = this.getDeptById(args.getId()).getPid(); + // 新的父部门 + Long newPid = args.getPid(); + if (args.getPid() != null && args.getId().equals(args.getPid())) { + throw new BadRequestException("上级不能为自己"); } + SystemDeptTb dept = systemDeptMapper.selectById(args.getId()); + args.setId(dept.getId()); + systemDeptMapper.updateById(args); + this.updateDeptSubCnt(oldPid); + this.updateDeptSubCnt(newPid); + } - /** - * 编辑 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateDeptById(SystemDeptTb args) { - KitValidUtil.notNull(args); - // 旧的父部门 - Long oldPid = this.getDeptById(args.getId()).getPid(); - // 新的父部门 - Long newPid = args.getPid(); - if (args.getPid() != null && args.getId().equals(args.getPid())) { - throw new BadRequestException("上级不能为自己"); + /** + * 根据部门id获取部门信息 -> TestPassed + * + * @param id 部门id + * @return / + */ + private SystemDeptTb getDeptById(Long id) { + return systemDeptMapper.selectById(id); + } + + /** + * 删除 + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteDeptByIds(Set ids) { + // 获取部门, 和其所有子部门 + Set depts = this.traverseDeptByIdWithPids(ids); + // 验证是否被角色或用户关联 + this.verifyBindRelationByIds(depts); + for (SystemDeptVo dept : depts) { + systemDeptMapper.deleteById(dept.getId()); + this.updateDeptSubCnt(dept.getPid()); + } + } + + /** + * 更新父节点中子节点数目 -> TestPassed + * + * @param deptId / + */ + @Transactional(rollbackFor = Exception.class) + public void updateDeptSubCnt(Long deptId) { + if (deptId != null) { + long count = this.countDeptByPid(deptId); + systemDeptMapper.updateDeptSubCountById(count, deptId); + } + } + + private long countDeptByPid(Long pid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemDeptTb::getPid, pid); + return systemDeptMapper.selectCount(wrapper); + } + + /** + * 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表 + */ + private List deduplication(List list) { + List deptList = new ArrayList<>(); + // 使用 Set 存储所有部门的 id + Set idSet = list.stream().map(SystemDeptTb::getId).collect(Collectors.toSet()); + // 遍历部门列表, 筛选出没有父部门的部门 + for (SystemDeptTb dept : list) { + if (!idSet.contains(dept.getPid())) { + deptList.add(dept); + } + } + return deptList; + } + + private List queryDeptByArgs(SystemQueryDeptArgs args) { + KitValidUtil.notNull(args); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(CollUtil.isNotEmpty(args.getIds()), SystemDeptTb::getId, args.getIds()); + wrapper.like(StrUtil.isNotBlank(args.getName()), SystemDeptTb::getName, args.getName()); + wrapper.eq(args.getEnabled() != null, SystemDeptTb::getEnabled, args.getEnabled()); + wrapper.eq(args.getPid() != null, SystemDeptTb::getPid, args.getPid()); + wrapper.isNull(args.getPidIsNull() != null, SystemDeptTb::getPid); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemDeptTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + } + wrapper.orderByAsc(SystemDeptTb::getDeptSort); + return systemDeptMapper.selectList(wrapper); + } + + /** + * 查询所有数据 + * + * @param args 条件 + * @param isQuery / + * @return / + * @throws Exception / + */ + public List queryAllDeptByArgs(SystemQueryDeptArgs args, Boolean isQuery) throws Exception { + String dataScopeType = KitSecurityHelper.getDataScopeType(); + if (isQuery) { + if (dataScopeType.equals(SystemDataScopeEnum.ALL.getValue())) { + args.setPidIsNull(true); + } + List fields = KitClassUtil.getAllFields(args.getClass(), new ArrayList<>()); + List fieldNames = new ArrayList<>() {{ + add("pidIsNull"); + add("enabled"); + }}; + for (Field field : fields) { + // 设置对象的访问权限, 保证对private的属性的访问 + field.setAccessible(true); + Object val = field.get(args); + if (fieldNames.contains(field.getName())) { + continue; } - SystemDeptTb dept = systemDeptMapper.selectById(args.getId()); - args.setId(dept.getId()); - systemDeptMapper.updateById(args); - this.updateDeptSubCnt(oldPid); - this.updateDeptSubCnt(newPid); - } - - /** - * 根据部门id获取部门信息 -> TestPassed - * - * @param id 部门id - * @return / - */ - private SystemDeptTb getDeptById(Long id) { - return systemDeptMapper.selectById(id); - } - - /** - * 删除 - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteDeptByIds(Set ids) { - // 获取部门, 和其所有子部门 - Set depts = this.traverseDeptByIdWithPids(ids); - // 验证是否被角色或用户关联 - this.verifyBindRelationByIds(depts); - for (SystemDeptVo dept : depts) { - systemDeptMapper.deleteById(dept.getId()); - this.updateDeptSubCnt(dept.getPid()); + if (ObjectUtil.isNotNull(val)) { + args.setPidIsNull(null); + break; } + } } + // 数据权限 + args.setIds(KitSecurityHelper.getCurrentUserDataScope()); + List list = this.queryDeptByArgs(args); + // 如果为空, 就代表为自定义权限或者本级权限, 就需要去重, 不理解可以注释掉,看查询结果 + if (StrUtil.isBlank(dataScopeType)) { + return this.deduplication(list); + } + return list; + } - /** - * 更新父节点中子节点数目 -> TestPassed - * - * @param deptId / - */ - @Transactional(rollbackFor = Exception.class) - public void updateDeptSubCnt(Long deptId) { - if (deptId != null) { - long count = this.countDeptByPid(deptId); - systemDeptMapper.updateDeptSubCountById(count, deptId); + /** + * 根据ID查询 + * + * @param id / + * @return / + */ + public SystemDeptVo getDeptVoById(Long id) { + return KitBeanUtil.copyToClass(systemDeptMapper.selectById(id), SystemDeptVo.class); + } + + /** + * 获取部门下所有关联的部门 + * + * @param deptTbList / + * @param depts / + */ + private void queryRelationDeptByArgs(List deptTbList, Set depts) { + for (SystemDeptVo dept : deptTbList) { + depts.add(dept); + List deptList = this.listDeptVoByPid(dept.getId()); + if (CollUtil.isNotEmpty(deptList)) { + queryRelationDeptByArgs(deptList, depts); + } + } + } + + private List listDeptVoByPid(Long pid) { + return KitBeanUtil.copyToList(this.listDeptByPid(pid), SystemDeptVo.class); + } + + public List queryChildDeptIdByDeptIds(List deptList, Map> deptPidMap) { + List list = new ArrayList<>(); + for (SystemDeptTb systemDeptTb : deptList) { + if (systemDeptTb != null && systemDeptTb.getEnabled()) { + List deptList1 = deptPidMap.getOrDefault(systemDeptTb.getId(), null); + if (CollUtil.isNotEmpty(deptList1)) { + list.addAll(this.queryChildDeptIdByDeptIds(deptList1, deptPidMap)); } + list.add(systemDeptTb.getId()); + } } + return list; + } - private long countDeptByPid(Long pid) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemDeptTb::getPid, pid); - return systemDeptMapper.selectCount(wrapper); + /** + * 根据ID获取同级与上级数据 + * + * @param dept / + * @param deptList / + * @return / + */ + private List querySuperiorDeptByPid(SystemDeptVo dept, List deptList) { + if (dept.getPid() == null) { + deptList.addAll(this.listRootDept()); + return deptList; } + deptList.addAll(this.listDeptVoByPid(dept.getPid())); + return querySuperiorDeptByPid(this.getDeptVoById(dept.getPid()), deptList); + } - /** - * 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表 - */ - private List deduplication(List list) { - List deptList = new ArrayList<>(); - // 使用 Set 存储所有部门的 id - Set idSet = list.stream().map(SystemDeptTb::getId).collect(Collectors.toSet()); - // 遍历部门列表, 筛选出没有父部门的部门 - for (SystemDeptTb dept : list) { - if (!idSet.contains(dept.getPid())) { - deptList.add(dept); - } + private List listRootDept() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.isNull(SystemDeptTb::getPid); + return KitBeanUtil.copyToList(systemDeptMapper.selectList(wrapper), SystemDeptVo.class); + } + + /** + * 构建树形数据 + * + * @return / + */ + public KitPageResult searchDeptTree(List ids, Boolean exclude) { + Set deptSet1 = new LinkedHashSet<>(); + for (Long id : ids) { + // 同级数据 + SystemDeptVo dept = this.getDeptVoById(id); + // 上级数据 + List depts = this.querySuperiorDeptByPid(dept, new ArrayList<>()); + if (exclude) { + for (SystemDeptVo data : depts) { + if (data.getId().equals(dept.getPid())) { + data.setSubCount(data.getSubCount() - 1); + } } - return deptList; + // 编辑部门时不显示自己以及自己下级的数据, 避免出现PID数据环形问题 + depts = depts.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toList()); + } + deptSet1.addAll(depts); } - - private List queryDeptByArgs(SystemQueryDeptArgs args) { - KitValidUtil.notNull(args); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(CollUtil.isNotEmpty(args.getIds()), SystemDeptTb::getId, args.getIds()); - wrapper.like(StrUtil.isNotBlank(args.getName()), SystemDeptTb::getName, args.getName()); - wrapper.eq(args.getEnabled() != null, SystemDeptTb::getEnabled, args.getEnabled()); - wrapper.eq(args.getPid() != null, SystemDeptTb::getPid, args.getPid()); - wrapper.isNull(args.getPidIsNull() != null, SystemDeptTb::getPid); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemDeptTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + List deptList = new ArrayList<>(deptSet1); + // 构建部门树 + Set trees = new LinkedHashSet<>(); + Set deptSet = new LinkedHashSet<>(); + List deptNames = deptList.stream().map(SystemDeptVo::getName).collect(Collectors.toList()); + boolean isChild; + for (SystemDeptVo dept : deptList) { + isChild = false; + if (dept.getPid() == null) { + trees.add(dept); + } + for (SystemDeptVo it : deptList) { + if (it.getPid() != null && dept.getId().equals(it.getPid())) { + isChild = true; + if (dept.getChildren() == null) { + dept.setChildren(new ArrayList<>()); + } + dept.getChildren().add(it); } - wrapper.orderByAsc(SystemDeptTb::getDeptSort); - return systemDeptMapper.selectList(wrapper); + } + if (isChild) { + deptSet.add(dept); + } else if (dept.getPid() != null && !deptNames.contains(this.getDeptVoById(dept.getPid()).getName())) { + deptSet.add(dept); + } } + if (CollUtil.isEmpty(trees)) { + trees = deptSet; + } + KitPageResult baseResult = new KitPageResult<>(); + baseResult.setContent(CollUtil.isEmpty(trees) ? new ArrayList<>(deptSet) : new ArrayList<>(trees)); + baseResult.setTotalElements(deptSet.size()); + return baseResult; + } - /** - * 查询所有数据 - * - * @param args 条件 - * @param isQuery / - * @return / - * @throws Exception / - */ - public List queryAllDeptByArgs(SystemQueryDeptArgs args, Boolean isQuery) throws Exception { - String dataScopeType = KitSecurityHelper.getDataScopeType(); - if (isQuery) { - if (dataScopeType.equals(SystemDataScopeEnum.ALL.getValue())) { - args.setPidIsNull(true); - } - List fields = KitClassUtil.getAllFields(args.getClass(), new ArrayList<>()); - List fieldNames = new ArrayList<>() {{ - add("pidIsNull"); - add("enabled"); - }}; - for (Field field : fields) { - // 设置对象的访问权限, 保证对private的属性的访问 - field.setAccessible(true); - Object val = field.get(args); - if (fieldNames.contains(field.getName())) { - continue; - } - if (ObjectUtil.isNotNull(val)) { - args.setPidIsNull(null); - break; - } - } - } - // 数据权限 - args.setIds(KitSecurityHelper.getCurrentUserDataScope()); - List list = this.queryDeptByArgs(args); - // 如果为空, 就代表为自定义权限或者本级权限, 就需要去重, 不理解可以注释掉,看查询结果 - if (StrUtil.isBlank(dataScopeType)) { - return this.deduplication(list); - } - return list; + /** + * 验证是否被角色或用户关联 + * + * @param deptSet / + */ + public void verifyBindRelationByIds(Set deptSet) { + Set deptIds = deptSet.stream().map(SystemDeptVo::getId).collect(Collectors.toSet()); + if (systemUserDeptService.countUserByDeptIds(deptIds) > 0) { + throw new BadRequestException("所选部门存在用户关联,请解除后再试!"); } + if (systemRoleDeptService.countRoleByDeptIds(deptIds) > 0) { + throw new BadRequestException("所选部门存在角色关联,请解除后再试!"); + } + } - /** - * 根据ID查询 - * - * @param id / - * @return / - */ - public SystemDeptVo getDeptVoById(Long id) { - return KitBeanUtil.copyToClass(systemDeptMapper.selectById(id), SystemDeptVo.class); - } + private List listEnabledDepts() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemDeptTb::getEnabled, 1); + return systemDeptMapper.selectList(wrapper); + } - /** - * 获取部门下所有关联的部门 - * - * @param deptTbList / - * @param depts / - */ - private void queryRelationDeptByArgs(List deptTbList, Set depts) { - for (SystemDeptVo dept : deptTbList) { - depts.add(dept); - List deptList = this.listDeptVoByPid(dept.getId()); - if (CollUtil.isNotEmpty(deptList)) { - queryRelationDeptByArgs(deptList, depts); - } - } + /** + * 遍历所有部门和子部门 + * + * @param ids / + */ + public Set traverseDeptByIdWithPids(Set ids) { + Set depts = new HashSet<>(); + for (Long id : ids) { + // 根部门 + depts.add(this.getDeptVoById(id)); + // 子部门 + List deptList = this.listDeptVoByPid(id); + if (CollUtil.isNotEmpty(deptList)) { + queryRelationDeptByArgs(deptList, depts); + } } + return depts; + } - private List listDeptVoByPid(Long pid) { - return KitBeanUtil.copyToList(this.listDeptByPid(pid), SystemDeptVo.class); - } + public List listDeptSelectDataSource() { + List depts = this.listEnabledDepts(); + return buildDeptSelectOptions(depts); + } - public List queryChildDeptIdByDeptIds(List deptList, Map> deptPidMap) { - List list = new ArrayList<>(); - for (SystemDeptTb systemDeptTb : deptList) { - if (systemDeptTb != null && systemDeptTb.getEnabled()) { - List deptList1 = deptPidMap.getOrDefault(systemDeptTb.getId(), null); - if (CollUtil.isNotEmpty(deptList1)) { - list.addAll(this.queryChildDeptIdByDeptIds(deptList1, deptPidMap)); - } - list.add(systemDeptTb.getId()); - } - } - return list; + private List buildDeptSelectOptions(List depts) { + // 获取所有部门并按父子关系组织 + Map deptMap = + depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); + List options = new ArrayList<>(); + for (SystemDeptTb dept : depts) { + // 构建部门ID路径 + List pathIds = new ArrayList<>(); + buildDeptIdPath(dept, deptMap, pathIds); + // 反转路径,从顶级部门到当前部门 + Collections.reverse(pathIds); + SystemProductLineVo dto = new SystemProductLineVo(); + dto.setValue(dept.getId()); + dto.setIdPath(pathIds.stream().map(String::valueOf).collect(Collectors.joining("-"))); + // 保留名称路径用于显示 + dto.setLabel(buildNamePath(dept, deptMap)); + options.add(dto); } + // 按部门名称路径排序 + options.sort(Comparator.comparing(SystemProductLineVo::getLabel)); + return options; + } - /** - * 根据ID获取同级与上级数据 - * - * @param dept / - * @param deptList / - * @return / - */ - private List querySuperiorDeptByPid(SystemDeptVo dept, List deptList) { - if (dept.getPid() == null) { - deptList.addAll(this.listRootDept()); - return deptList; - } - deptList.addAll(this.listDeptVoByPid(dept.getPid())); - return querySuperiorDeptByPid(this.getDeptVoById(dept.getPid()), deptList); + private void buildDeptIdPath(SystemDeptTb dept, Map deptMap, List pathIds) { + pathIds.add(dept.getId()); + if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) { + buildDeptIdPath(deptMap.get(dept.getPid()), deptMap, pathIds); } + } - private List listRootDept() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.isNull(SystemDeptTb::getPid); - return KitBeanUtil.copyToList(systemDeptMapper.selectList(wrapper), SystemDeptVo.class); - } + private String buildNamePath(SystemDeptTb dept, Map deptMap) { + List pathNames = new ArrayList<>(); + buildDeptNamePath(dept, deptMap, pathNames); + Collections.reverse(pathNames); + return String.join(" / ", pathNames); + } - /** - * 构建树形数据 - * - * @return / - */ - public KitPageResult searchDeptTree(List ids, Boolean exclude) { - Set deptSet1 = new LinkedHashSet<>(); - for (Long id : ids) { - // 同级数据 - SystemDeptVo dept = this.getDeptVoById(id); - // 上级数据 - List depts = this.querySuperiorDeptByPid(dept, new ArrayList<>()); - if (exclude) { - for (SystemDeptVo data : depts) { - if (data.getId().equals(dept.getPid())) { - data.setSubCount(data.getSubCount() - 1); - } - } - // 编辑部门时不显示自己以及自己下级的数据, 避免出现PID数据环形问题 - depts = depts.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toList()); - } - deptSet1.addAll(depts); - } - List deptList = new ArrayList<>(deptSet1); - // 构建部门树 - Set trees = new LinkedHashSet<>(); - Set deptSet = new LinkedHashSet<>(); - List deptNames = deptList.stream().map(SystemDeptVo::getName).collect(Collectors.toList()); - boolean isChild; - for (SystemDeptVo dept : deptList) { - isChild = false; - if (dept.getPid() == null) { - trees.add(dept); - } - for (SystemDeptVo it : deptList) { - if (it.getPid() != null && dept.getId().equals(it.getPid())) { - isChild = true; - if (dept.getChildren() == null) { - dept.setChildren(new ArrayList<>()); - } - dept.getChildren().add(it); - } - } - if (isChild) { - deptSet.add(dept); - } else if (dept.getPid() != null && !deptNames.contains(this.getDeptVoById(dept.getPid()).getName())) { - deptSet.add(dept); - } - } - if (CollUtil.isEmpty(trees)) { - trees = deptSet; - } - KitPageResult baseResult = new KitPageResult<>(); - baseResult.setContent(CollUtil.isEmpty(trees) ? new ArrayList<>(deptSet) : new ArrayList<>(trees)); - baseResult.setTotalElements(deptSet.size()); - return baseResult; + private void buildDeptNamePath(SystemDeptTb dept, Map deptMap, List pathNames) { + pathNames.add(dept.getName()); + if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) { + buildDeptNamePath(deptMap.get(dept.getPid()), deptMap, pathNames); } + } - /** - * 验证是否被角色或用户关联 - * - * @param deptSet / - */ - public void verifyBindRelationByIds(Set deptSet) { - Set deptIds = deptSet.stream().map(SystemDeptVo::getId).collect(Collectors.toSet()); - if (systemUserDeptService.countUserByDeptIds(deptIds) > 0) { - throw new BadRequestException("所选部门存在用户关联,请解除后再试!"); - } - if (systemRoleDeptService.countRoleByDeptIds(deptIds) > 0) { - throw new BadRequestException("所选部门存在角色关联,请解除后再试!"); - } + public List listDeptSelectProDataSource() { + List depts = this.listEnabledDepts(); + // 获取所有部门并按父子关系组织 + Map deptMap = + depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); + List options = new ArrayList<>(); + // 构建树形结构 + for (SystemDeptTb dept : depts) { + // 只处理顶级部门(pid为null或0的部门) + if (dept.getPid() == null || dept.getPid() == 0) { + SystemProductLineTreeVo vo = buildDeptTreePro(dept, deptMap); + options.add(vo); + } } + // 按排序字段排序 + options.sort(Comparator.comparingInt(o -> { + Long id = Long.valueOf(o.getValue()); + return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0; + })); + return options; + } - private List listEnabledDepts() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemDeptTb::getEnabled, 1); - return systemDeptMapper.selectList(wrapper); + /** + * 递归构建部门树 + * + * @param dept 当前部门 + * @param deptMap 部门映射 + * @return SystemProductLineTreeVo 树节点 + */ + private SystemProductLineTreeVo buildDeptTreePro(SystemDeptTb dept, Map deptMap) { + SystemProductLineTreeVo vo = new SystemProductLineTreeVo(); + vo.setValue(String.valueOf(dept.getId())); + vo.setLabel(dept.getName()); + // 查找子部门 + List children = new ArrayList<>(); + for (SystemDeptTb childDept : deptMap.values()) { + if (dept.getId().equals(childDept.getPid())) { + children.add(buildDeptTreePro(childDept, deptMap)); + } } + // 子部门按排序字段排序 + children.sort(Comparator.comparingInt(o -> { + Long id = Long.valueOf(o.getValue()); + return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0; + })); + vo.setChildren(children); + return vo; + } - /** - * 遍历所有部门和子部门 - * - * @param ids / - */ - public Set traverseDeptByIdWithPids(Set ids) { - Set depts = new HashSet<>(); - for (Long id : ids) { - // 根部门 - depts.add(this.getDeptVoById(id)); - // 子部门 - List deptList = this.listDeptVoByPid(id); - if (CollUtil.isNotEmpty(deptList)) { - queryRelationDeptByArgs(deptList, depts); - } - } - return depts; - } + public List listDeptByPid(long pid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemDeptTb::getPid, pid); + return systemDeptMapper.selectList(wrapper); + } - public List listDeptSelectDataSource() { - List depts = this.listEnabledDepts(); - return buildDeptSelectOptions(depts); + public void exportDeptXlsx(HttpServletResponse response, SystemQueryDeptArgs args) throws Exception { + List systemDeptTbs = this.queryAllDeptByArgs(args, false); + List rowVos = new ArrayList<>(); + for (SystemDeptTb dataObject : systemDeptTbs) { + SystemDeptExportRowVo rowVo = new SystemDeptExportRowVo(); + rowVo.setName(dataObject.getName()); + rowVo.setEnabled(dataObject.getEnabled() ? SystemZhConst.ENABLE_STR : SystemZhConst.DISABLE_STR); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); } + KitExcelExporter.exportSimple(response, "部门数据", SystemDeptExportRowVo.class, rowVos); + } - private List buildDeptSelectOptions(List depts) { - // 获取所有部门并按父子关系组织 - Map deptMap = - depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); - List options = new ArrayList<>(); - for (SystemDeptTb dept : depts) { - // 构建部门ID路径 - List pathIds = new ArrayList<>(); - buildDeptIdPath(dept, deptMap, pathIds); - // 反转路径,从顶级部门到当前部门 - Collections.reverse(pathIds); - SystemProductLineVo dto = new SystemProductLineVo(); - dto.setValue(dept.getId()); - dto.setIdPath(pathIds.stream().map(String::valueOf).collect(Collectors.joining("-"))); - // 保留名称路径用于显示 - dto.setLabel(buildNamePath(dept, deptMap)); - options.add(dto); - } - // 按部门名称路径排序 - options.sort(Comparator.comparing(SystemProductLineVo::getLabel)); - return options; - } - - private void buildDeptIdPath(SystemDeptTb dept, Map deptMap, List pathIds) { - pathIds.add(dept.getId()); - if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) { - buildDeptIdPath(deptMap.get(dept.getPid()), deptMap, pathIds); - } - } - - private String buildNamePath(SystemDeptTb dept, Map deptMap) { - List pathNames = new ArrayList<>(); - buildDeptNamePath(dept, deptMap, pathNames); - Collections.reverse(pathNames); - return String.join(" / ", pathNames); - } - - private void buildDeptNamePath(SystemDeptTb dept, Map deptMap, List pathNames) { - pathNames.add(dept.getName()); - if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) { - buildDeptNamePath(deptMap.get(dept.getPid()), deptMap, pathNames); - } - } - - public List listDeptSelectProDataSource() { - List depts = this.listEnabledDepts(); - // 获取所有部门并按父子关系组织 - Map deptMap = - depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); - List options = new ArrayList<>(); - // 构建树形结构 - for (SystemDeptTb dept : depts) { - // 只处理顶级部门(pid为null或0的部门) - if (dept.getPid() == null || dept.getPid() == 0) { - SystemProductLineTreeVo vo = buildDeptTreePro(dept, deptMap); - options.add(vo); - } - } - // 按排序字段排序 - options.sort(Comparator.comparingInt(o -> { - Long id = Long.valueOf(o.getValue()); - return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0; - })); - return options; - } - - /** - * 递归构建部门树 - * - * @param dept 当前部门 - * @param deptMap 部门映射 - * @return SystemProductLineTreeVo 树节点 - */ - private SystemProductLineTreeVo buildDeptTreePro(SystemDeptTb dept, Map deptMap) { - SystemProductLineTreeVo vo = new SystemProductLineTreeVo(); - vo.setValue(String.valueOf(dept.getId())); - vo.setLabel(dept.getName()); - // 查找子部门 - List children = new ArrayList<>(); - for (SystemDeptTb childDept : deptMap.values()) { - if (dept.getId().equals(childDept.getPid())) { - children.add(buildDeptTreePro(childDept, deptMap)); - } - } - // 子部门按排序字段排序 - children.sort(Comparator.comparingInt(o -> { - Long id = Long.valueOf(o.getValue()); - return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0; - })); - vo.setChildren(children); - return vo; - } - - public List listDeptByPid(long pid) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemDeptTb::getPid, pid); - return systemDeptMapper.selectList(wrapper); - } - - public void exportDeptXlsx(HttpServletResponse response, SystemQueryDeptArgs args) throws Exception { - List systemDeptTbs = this.queryAllDeptByArgs(args, false); - List rowVos = new ArrayList<>(); - for (SystemDeptTb dataObject : systemDeptTbs) { - SystemDeptExportRowVo rowVo = new SystemDeptExportRowVo(); - rowVo.setName(dataObject.getName()); - rowVo.setEnabled(dataObject.getEnabled() ? SystemZhConst.ENABLE_STR : SystemZhConst.DISABLE_STR); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - KitExcelExporter.exportSimple(response, "部门数据", SystemDeptExportRowVo.class, rowVos); - } - - public List listPidNonNull() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemDeptTb::getEnabled, 1); - wrapper.isNotNull(SystemDeptTb::getPid); - return systemDeptMapper.selectList(wrapper); - } + public List listPidNonNull() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemDeptTb::getEnabled, 1); + wrapper.isNotNull(SystemDeptTb::getPid); + return systemDeptMapper.selectList(wrapper); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java index eb12357e..863e9f45 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java @@ -31,122 +31,122 @@ import cn.odboy.util.KitValidUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemDictDetailService { - @Autowired - private SystemDictDetailMapper systemDictDetailMapper; - @Autowired - private SystemDictMapper systemDictMapper; + @Autowired + private SystemDictDetailMapper systemDictDetailMapper; + @Autowired + private SystemDictMapper systemDictMapper; - /** - * 创建 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveDictDetail(SystemCreateDictDetailArgs args) { - KitValidUtil.notNull(args); - KitValidUtil.notNull(args.getDict()); - SystemDictDetailTb dictDetail = KitBeanUtil.copyToClass(args, SystemDictDetailTb.class); - dictDetail.setDictId(args.getDict().getId()); - systemDictDetailMapper.insert(dictDetail); + /** + * 创建 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveDictDetail(SystemCreateDictDetailArgs args) { + KitValidUtil.notNull(args); + KitValidUtil.notNull(args.getDict()); + SystemDictDetailTb dictDetail = KitBeanUtil.copyToClass(args, SystemDictDetailTb.class); + dictDetail.setDictId(args.getDict().getId()); + systemDictDetailMapper.insert(dictDetail); + } + + /** + * 编辑 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateDictDetailById(SystemDictDetailTb args) { + SystemDictDetailTb dictDetail = systemDictDetailMapper.selectById(args.getId()); + args.setId(dictDetail.getId()); + systemDictDetailMapper.insertOrUpdate(args); + } + + /** + * 删除 -> TestPassed + * + * @param id / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteDictDetailById(Long id) { + systemDictDetailMapper.deleteById(id); + } + + @Transactional(rollbackFor = Exception.class) + public void deleteDictDetailByDictIds(Set ids) { + if (CollUtil.isNotEmpty(ids)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemDictDetailTb::getDictId, ids); + systemDictDetailMapper.delete(wrapper); } + } - /** - * 编辑 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateDictDetailById(SystemDictDetailTb args) { - SystemDictDetailTb dictDetail = systemDictDetailMapper.selectById(args.getId()); - args.setId(dictDetail.getId()); - systemDictDetailMapper.insertOrUpdate(args); + /** + * 分页查询 -> TestPassed + * + * @param args 条件 + * @param page 分页参数 + * @return / + */ + public KitPageResult searchDictDetail(SystemQueryDictDetailArgs args, + Page page) { + IPage iPage = systemDictDetailMapper.selectPageByArgs(page, args); + List dictIds = + iPage.getRecords().stream().map(SystemDictDetailVo::getDictId).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(dictIds)) { + Map id2ItemMap = + systemDictMapper.selectByIds(dictIds).stream().collect(Collectors.toMap(SystemDictTb::getId, i -> i)); + for (SystemDictDetailVo record : iPage.getRecords()) { + record.setDict(id2ItemMap.get(record.getDictId())); + } } + return KitPageUtil.toPage(iPage); + } - /** - * 删除 -> TestPassed - * - * @param id / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteDictDetailById(Long id) { - systemDictDetailMapper.deleteById(id); + /** + * 根据字典名称获取字典详情 -> TestPassed + * + * @param name 字典名称 + * @return / + */ + public List listDictDetailByName(String name) { + if (StrUtil.isBlank(name)) { + return new ArrayList<>(); } - - @Transactional(rollbackFor = Exception.class) - public void deleteDictDetailByDictIds(Set ids) { - if (CollUtil.isNotEmpty(ids)) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemDictDetailTb::getDictId, ids); - systemDictDetailMapper.delete(wrapper); + List detailVos = systemDictDetailMapper.listDictDetailByName(name); + if (CollUtil.isNotEmpty(detailVos)) { + SystemDictDetailVo systemDictDetailVo = detailVos.stream().findFirst().orElse(null); + if (systemDictDetailVo != null) { + SystemDictTb systemDictTb = systemDictMapper.selectById(systemDictDetailVo.getDictId()); + if (systemDictTb != null) { + for (SystemDictDetailVo detailVo : detailVos) { + detailVo.setDict(systemDictTb); + } } + } } + return detailVos; + } - /** - * 分页查询 -> TestPassed - * - * @param args 条件 - * @param page 分页参数 - * @return / - */ - public KitPageResult searchDictDetail(SystemQueryDictDetailArgs args, - Page page) { - IPage iPage = systemDictDetailMapper.selectPageByArgs(page, args); - List dictIds = - iPage.getRecords().stream().map(SystemDictDetailVo::getDictId).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(dictIds)) { - Map id2ItemMap = - systemDictMapper.selectByIds(dictIds).stream().collect(Collectors.toMap(SystemDictTb::getId, i -> i)); - for (SystemDictDetailVo record : iPage.getRecords()) { - record.setDict(id2ItemMap.get(record.getDictId())); - } - } - return KitPageUtil.toPage(iPage); - } - - /** - * 根据字典名称获取字典详情 -> TestPassed - * - * @param name 字典名称 - * @return / - */ - public List listDictDetailByName(String name) { - if (StrUtil.isBlank(name)) { - return new ArrayList<>(); - } - List detailVos = systemDictDetailMapper.listDictDetailByName(name); - if (CollUtil.isNotEmpty(detailVos)) { - SystemDictDetailVo systemDictDetailVo = detailVos.stream().findFirst().orElse(null); - if (systemDictDetailVo != null) { - SystemDictTb systemDictTb = systemDictMapper.selectById(systemDictDetailVo.getDictId()); - if (systemDictTb != null) { - for (SystemDictDetailVo detailVo : detailVos) { - detailVo.setDict(systemDictTb); - } - } - } - } - return detailVos; - } - - public Map> getDictDetailMap(String dictName) { - String[] names = dictName.split("[,, ]"); - Map> dictMap = new HashMap<>(16); - for (String name : names) { - dictMap.put(name, this.listDictDetailByName(name)); - } - return dictMap; + public Map> getDictDetailMap(String dictName) { + String[] names = dictName.split("[,, ]"); + Map> dictMap = new HashMap<>(16); + for (String name : names) { + dictMap.put(name, this.listDictDetailByName(name)); } + return dictMap; + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictService.java index 698c24a1..a6b81a75 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictService.java @@ -29,111 +29,111 @@ import cn.odboy.util.KitPageUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import jakarta.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.List; import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemDictService { - @Autowired - private SystemDictMapper systemDictMapper; - @Autowired - private SystemDictDetailService systemDictDetailService; + @Autowired + private SystemDictMapper systemDictMapper; + @Autowired + private SystemDictDetailService systemDictDetailService; - /** - * 创建 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveDict(SystemCreateDictArgs args) { - SystemDictTb dictTb = KitBeanUtil.copyToClass(args, SystemDictTb.class); - systemDictMapper.insert(dictTb); - } + /** + * 创建 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveDict(SystemCreateDictArgs args) { + SystemDictTb dictTb = KitBeanUtil.copyToClass(args, SystemDictTb.class); + systemDictMapper.insert(dictTb); + } - /** - * 编辑 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateDictById(SystemDictTb args) { - SystemDictTb dict = systemDictMapper.selectById(args.getId()); - dict.setName(args.getName()); - dict.setDescription(args.getDescription()); - systemDictMapper.insertOrUpdate(dict); - } + /** + * 编辑 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateDictById(SystemDictTb args) { + SystemDictTb dict = systemDictMapper.selectById(args.getId()); + dict.setName(args.getName()); + dict.setDescription(args.getDescription()); + systemDictMapper.insertOrUpdate(dict); + } - /** - * 删除 -> TestPassed - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteDictByIds(Set ids) { - // 删除字典 - systemDictMapper.deleteByIds(ids); - // 删除字典详情 - systemDictDetailService.deleteDictDetailByDictIds(ids); - } + /** + * 删除 -> TestPassed + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteDictByIds(Set ids) { + // 删除字典 + systemDictMapper.deleteByIds(ids); + // 删除字典详情 + systemDictDetailService.deleteDictDetailByDictIds(ids); + } - /** - * 分页查询 -> TestPassed - * - * @param args 条件 - * @param page 分页参数 - * @return / - */ - public KitPageResult searchDict(SystemQueryDictArgs args, Page page) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQueryParams(args, wrapper); - Page selectPage = systemDictMapper.selectPage(page, wrapper); - return KitPageUtil.toPage(selectPage); - } + /** + * 分页查询 -> TestPassed + * + * @param args 条件 + * @param page 分页参数 + * @return / + */ + public KitPageResult searchDict(SystemQueryDictArgs args, Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(args, wrapper); + Page selectPage = systemDictMapper.selectPage(page, wrapper); + return KitPageUtil.toPage(selectPage); + } - private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper wrapper) { - if (args != null) { - wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or() - .like(SystemDictTb::getDescription, args.getBlurry())); - } + private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper wrapper) { + if (args != null) { + wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or() + .like(SystemDictTb::getDescription, args.getBlurry())); } + } - public List queryDictByArgs(SystemQueryDictArgs args) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQueryParams(args, wrapper); - return systemDictMapper.selectList(wrapper); - } + public List queryDictByArgs(SystemQueryDictArgs args) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(args, wrapper); + return systemDictMapper.selectList(wrapper); + } - public void exportDictXlsx(HttpServletResponse response, SystemQueryDictArgs args) { - List systemDictTbs = this.queryDictByArgs(args); - List rowVos = new ArrayList<>(); - for (SystemDictTb dataObject : systemDictTbs) { - List dictDetails = systemDictDetailService.listDictDetailByName(dataObject.getName()); - if (CollUtil.isEmpty(dictDetails)) { - SystemDictExportRowVo rowVo = new SystemDictExportRowVo(); - rowVo.setName(dataObject.getName()); - rowVo.setDescription(dataObject.getDescription()); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVo.setLabel(""); - rowVo.setValue(""); - rowVos.add(rowVo); - continue; - } - for (SystemDictDetailVo dictDetail : dictDetails) { - SystemDictExportRowVo rowVo = new SystemDictExportRowVo(); - rowVo.setName(dataObject.getName()); - rowVo.setDescription(dataObject.getDescription()); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVo.setLabel(dictDetail.getLabel()); - rowVo.setValue(dictDetail.getValue()); - rowVos.add(rowVo); - } - } - KitExcelExporter.exportSimple(response, "字典数据", SystemDictExportRowVo.class, rowVos); + public void exportDictXlsx(HttpServletResponse response, SystemQueryDictArgs args) { + List systemDictTbs = this.queryDictByArgs(args); + List rowVos = new ArrayList<>(); + for (SystemDictTb dataObject : systemDictTbs) { + List dictDetails = systemDictDetailService.listDictDetailByName(dataObject.getName()); + if (CollUtil.isEmpty(dictDetails)) { + SystemDictExportRowVo rowVo = new SystemDictExportRowVo(); + rowVo.setName(dataObject.getName()); + rowVo.setDescription(dataObject.getDescription()); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVo.setLabel(""); + rowVo.setValue(""); + rowVos.add(rowVo); + continue; + } + for (SystemDictDetailVo dictDetail : dictDetails) { + SystemDictExportRowVo rowVo = new SystemDictExportRowVo(); + rowVo.setName(dataObject.getName()); + rowVo.setDescription(dataObject.getDescription()); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVo.setLabel(dictDetail.getLabel()); + rowVo.setValue(dictDetail.getValue()); + rowVos.add(rowVo); + } } + KitExcelExporter.exportSimple(response, "字典数据", SystemDictExportRowVo.class, rowVos); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemEmailService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemEmailService.java index 8fb0cca6..fb8036d7 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemEmailService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemEmailService.java @@ -30,134 +30,134 @@ import cn.odboy.system.dal.model.request.SystemSendEmailArgs; import cn.odboy.system.dal.mysql.SystemEmailConfigMapper; import cn.odboy.util.KitDesEncryptUtil; import cn.odboy.util.KitResourceTemplateUtil; +import java.util.Collections; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Collections; @Slf4j @Service public class SystemEmailService { - @Autowired - private SystemEmailConfigMapper systemEmailConfigMapper; - @Autowired - private KitRedisHelper redisHelper; - @Autowired - private AppProperties properties; + @Autowired + private SystemEmailConfigMapper systemEmailConfigMapper; + @Autowired + private KitRedisHelper redisHelper; + @Autowired + private AppProperties properties; - /** - * 更新邮件配置 -> TestPassed - * - * @param emailConfig 邮箱配置 - */ - @Transactional(rollbackFor = Exception.class) - public void updateEmailConfigById(SystemEmailConfigTb emailConfig) throws Exception { - SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig(); - if (!emailConfig.getPassword().equals(systemEmailConfigTb.getPassword())) { - // 对称加密 - systemEmailConfigTb.setPassword(KitDesEncryptUtil.desEncrypt(emailConfig.getPassword())); - } - systemEmailConfigTb.setId(1L); - systemEmailConfigMapper.insertOrUpdate(systemEmailConfigTb); + /** + * 更新邮件配置 -> TestPassed + * + * @param emailConfig 邮箱配置 + */ + @Transactional(rollbackFor = Exception.class) + public void updateEmailConfigById(SystemEmailConfigTb emailConfig) throws Exception { + SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig(); + if (!emailConfig.getPassword().equals(systemEmailConfigTb.getPassword())) { + // 对称加密 + systemEmailConfigTb.setPassword(KitDesEncryptUtil.desEncrypt(emailConfig.getPassword())); } + systemEmailConfigTb.setId(1L); + systemEmailConfigMapper.insertOrUpdate(systemEmailConfigTb); + } - /** - * 发送邮件 -> TestPassed - * - * @param sendEmailRequest 邮件发送的内容 - */ - public void sendEmail(SystemSendEmailArgs sendEmailRequest) { - SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig(); - if (systemEmailConfigTb.getId() == null) { - throw new BadRequestException("请先配置, 再操作"); - } - // 封装 - MailAccount account = new MailAccount(); - // 设置用户 - String user = systemEmailConfigTb.getFromUser().split("@")[0]; - account.setUser(user); - account.setHost(systemEmailConfigTb.getHost()); - account.setPort(Integer.parseInt(systemEmailConfigTb.getPort())); - account.setAuth(true); - try { - // 对称解密 - account.setPass(KitDesEncryptUtil.desDecrypt(systemEmailConfigTb.getPassword())); - } catch (Exception e) { - throw new BadRequestException(e.getMessage()); - } - account.setFrom(systemEmailConfigTb.getUser() + "<" + systemEmailConfigTb.getFromUser() + ">"); - // ssl方式发送 - account.setSslEnable(true); - // 使用STARTTLS安全连接 - account.setStarttlsEnable(true); - // 解决jdk8之后默认禁用部分tls协议, 导致邮件发送失败的问题 - account.setSslProtocols("TLSv1 TLSv1.1 TLSv1.2"); - String content = sendEmailRequest.getContent(); - // 发送 - try { - int size = sendEmailRequest.getTos().size(); - Mail.create(account).setTos(sendEmailRequest.getTos().toArray(new String[size])) - .setTitle(sendEmailRequest.getSubject()).setContent(content).setHtml(true) - // 关闭session - .setUseGlobalSession(false).send(); - } catch (Exception e) { - log.error("邮件发送失败", e); - throw new BadRequestException("邮件发送失败"); - } + /** + * 发送邮件 -> TestPassed + * + * @param sendEmailRequest 邮件发送的内容 + */ + public void sendEmail(SystemSendEmailArgs sendEmailRequest) { + SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig(); + if (systemEmailConfigTb.getId() == null) { + throw new BadRequestException("请先配置, 再操作"); } + // 封装 + MailAccount account = new MailAccount(); + // 设置用户 + String user = systemEmailConfigTb.getFromUser().split("@")[0]; + account.setUser(user); + account.setHost(systemEmailConfigTb.getHost()); + account.setPort(Integer.parseInt(systemEmailConfigTb.getPort())); + account.setAuth(true); + try { + // 对称解密 + account.setPass(KitDesEncryptUtil.desDecrypt(systemEmailConfigTb.getPassword())); + } catch (Exception e) { + throw new BadRequestException(e.getMessage()); + } + account.setFrom(systemEmailConfigTb.getUser() + "<" + systemEmailConfigTb.getFromUser() + ">"); + // ssl方式发送 + account.setSslEnable(true); + // 使用STARTTLS安全连接 + account.setStarttlsEnable(true); + // 解决jdk8之后默认禁用部分tls协议, 导致邮件发送失败的问题 + account.setSslProtocols("TLSv1 TLSv1.1 TLSv1.2"); + String content = sendEmailRequest.getContent(); + // 发送 + try { + int size = sendEmailRequest.getTos().size(); + Mail.create(account).setTos(sendEmailRequest.getTos().toArray(new String[size])) + .setTitle(sendEmailRequest.getSubject()).setContent(content).setHtml(true) + // 关闭session + .setUseGlobalSession(false).send(); + } catch (Exception e) { + log.error("邮件发送失败", e); + throw new BadRequestException("邮件发送失败"); + } + } - /** - * 校验邮箱验证码 -> TestPassed - */ - public void checkEmailCaptchaV1(SystemCaptchaBizEnum biEnum, String email, String code) { - String redisKey = biEnum.getRedisKey() + email; - String value = redisHelper.get(redisKey, String.class); - if (value == null || !value.equals(code)) { - throw new BadRequestException("无效验证码"); - } else { - redisHelper.del(redisKey); - } + /** + * 校验邮箱验证码 -> TestPassed + */ + public void checkEmailCaptchaV1(SystemCaptchaBizEnum biEnum, String email, String code) { + String redisKey = biEnum.getRedisKey() + email; + String value = redisHelper.get(redisKey, String.class); + if (value == null || !value.equals(code)) { + throw new BadRequestException("无效验证码"); + } else { + redisHelper.del(redisKey); } + } - /** - * 发送给邮箱验证码 - */ - public void sendCaptcha(SystemCaptchaBizEnum biEnum, String email) { - if (biEnum == null) { - throw new BadRequestException("biEnum必填"); - } - String content; - String redisKey = biEnum.getRedisKey() + email; - String oldCode = redisHelper.get(redisKey, String.class); - if (oldCode == null) { - String code = RandomUtil.randomNumbers(6); - // 存入缓存 - if (!redisHelper.set(redisKey, code, properties.getCaptcha().getExpireTime())) { - throw new BadRequestException("服务异常, 请联系网站负责人"); - } - // 存在就再次发送原来的验证码 - content = KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", code)); - } else { - content = - KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", oldCode)); - } - SystemSendEmailArgs sendEmailRequest = - new SystemSendEmailArgs(Collections.singletonList(email), SystemConst.CURRENT_APP_TITLE, content); - sendEmail(sendEmailRequest); + /** + * 发送给邮箱验证码 + */ + public void sendCaptcha(SystemCaptchaBizEnum biEnum, String email) { + if (biEnum == null) { + throw new BadRequestException("biEnum必填"); } + String content; + String redisKey = biEnum.getRedisKey() + email; + String oldCode = redisHelper.get(redisKey, String.class); + if (oldCode == null) { + String code = RandomUtil.randomNumbers(6); + // 存入缓存 + if (!redisHelper.set(redisKey, code, properties.getCaptcha().getExpireTime())) { + throw new BadRequestException("服务异常, 请联系网站负责人"); + } + // 存在就再次发送原来的验证码 + content = KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", code)); + } else { + content = + KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", oldCode)); + } + SystemSendEmailArgs sendEmailRequest = + new SystemSendEmailArgs(Collections.singletonList(email), SystemConst.CURRENT_APP_TITLE, content); + sendEmail(sendEmailRequest); + } - public SystemEmailConfigTb getLastEmailConfig() { - SystemEmailConfigTb systemEmailConfigTb = systemEmailConfigMapper.selectById(1L); - return systemEmailConfigTb == null ? new SystemEmailConfigTb() : systemEmailConfigTb; - } + public SystemEmailConfigTb getLastEmailConfig() { + SystemEmailConfigTb systemEmailConfigTb = systemEmailConfigMapper.selectById(1L); + return systemEmailConfigTb == null ? new SystemEmailConfigTb() : systemEmailConfigTb; + } - public void checkEmailCaptcha(SystemCheckEmailCaptchaArgs args) { - SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode()); - if (biEnum == null) { - throw new BadRequestException("不支持的业务"); - } - this.checkEmailCaptchaV1(biEnum, args.getEmail(), args.getCode()); + public void checkEmailCaptcha(SystemCheckEmailCaptchaArgs args) { + SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode()); + if (biEnum == null) { + throw new BadRequestException("不支持的业务"); } + this.checkEmailCaptchaV1(biEnum, args.getEmail(), args.getCode()); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java index 5a152bf2..9187bdbf 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java @@ -29,129 +29,129 @@ import cn.odboy.util.KitPageUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import jakarta.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.List; import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemJobService { - @Autowired - private SystemJobMapper systemJobMapper; - @Autowired - private SystemUserJobService systemUserJobService; + @Autowired + private SystemJobMapper systemJobMapper; + @Autowired + private SystemUserJobService systemUserJobService; - /** - * 创建 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveJob(SystemCreateJobArgs args) { - SystemJobTb job = this.getJobByName(args.getName()); - if (job != null) { - throw new BadRequestException("职位名称已存在"); - } - SystemJobTb systemJobTb = KitBeanUtil.copyToClass(args, SystemJobTb.class); - systemJobMapper.insert(systemJobTb); + /** + * 创建 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveJob(SystemCreateJobArgs args) { + SystemJobTb job = this.getJobByName(args.getName()); + if (job != null) { + throw new BadRequestException("职位名称已存在"); } + SystemJobTb systemJobTb = KitBeanUtil.copyToClass(args, SystemJobTb.class); + systemJobMapper.insert(systemJobTb); + } - /** - * 编辑 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateJobById(SystemJobTb args) { - SystemJobTb job = systemJobMapper.selectById(args.getId()); - SystemJobTb old = this.getJobByName(args.getName()); - if (old != null && !old.getId().equals(args.getId())) { - throw new BadRequestException("职位名称已存在"); - } - args.setId(job.getId()); - systemJobMapper.updateById(args); + /** + * 编辑 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateJobById(SystemJobTb args) { + SystemJobTb job = systemJobMapper.selectById(args.getId()); + SystemJobTb old = this.getJobByName(args.getName()); + if (old != null && !old.getId().equals(args.getId())) { + throw new BadRequestException("职位名称已存在"); } + args.setId(job.getId()); + systemJobMapper.updateById(args); + } - /** - * 删除 -> TestPassed - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteJobByIds(Set ids) { - // 验证是否被用户关联 - this.verifyBindRelationByIds(ids); - systemJobMapper.deleteByIds(ids); - } + /** + * 删除 -> TestPassed + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteJobByIds(Set ids) { + // 验证是否被用户关联 + this.verifyBindRelationByIds(ids); + systemJobMapper.deleteByIds(ids); + } - /** - * 分页查询 -> TestPassed - * - * @param args 条件 - * @param page 分页参数 - */ - public KitPageResult searchJobByArgs(SystemQueryJobArgs args, Page page) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQueryParams(args, wrapper); - Page selectPage = systemJobMapper.selectPage(page, wrapper); - return KitPageUtil.toPage(selectPage); - } + /** + * 分页查询 -> TestPassed + * + * @param args 条件 + * @param page 分页参数 + */ + public KitPageResult searchJobByArgs(SystemQueryJobArgs args, Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(args, wrapper); + Page selectPage = systemJobMapper.selectPage(page, wrapper); + return KitPageUtil.toPage(selectPage); + } - /** - * 查询全部数据 -> TestPassed - */ - public List queryJobByArgs(SystemQueryJobArgs args) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQueryParams(args, wrapper); - return systemJobMapper.selectList(wrapper); - } + /** + * 查询全部数据 -> TestPassed + */ + public List queryJobByArgs(SystemQueryJobArgs args) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(args, wrapper); + return systemJobMapper.selectList(wrapper); + } - /** - * 验证是否被用户关联 -> TestPassed - * - * @param ids / - */ - public void verifyBindRelationByIds(Set ids) { - if (systemUserJobService.countUserByJobIds(ids) > 0) { - throw new BadRequestException("所选的岗位中存在用户关联, 请解除关联再试!"); - } + /** + * 验证是否被用户关联 -> TestPassed + * + * @param ids / + */ + public void verifyBindRelationByIds(Set ids) { + if (systemUserJobService.countUserByJobIds(ids) > 0) { + throw new BadRequestException("所选的岗位中存在用户关联, 请解除关联再试!"); } + } - public SystemJobTb getJobByName(String name) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemJobTb::getName, name); - return systemJobMapper.selectOne(wrapper); - } + public SystemJobTb getJobByName(String name) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemJobTb::getName, name); + return systemJobMapper.selectOne(wrapper); + } - public void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper wrapper) { - if (args != null) { - wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName()); - wrapper.eq(args.getEnabled() != null, SystemJobTb::getEnabled, args.getEnabled()); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemJobTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); - } - } - wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId); + public void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper wrapper) { + if (args != null) { + wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName()); + wrapper.eq(args.getEnabled() != null, SystemJobTb::getEnabled, args.getEnabled()); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemJobTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + } } + wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId); + } - public void exportJobXlsx(HttpServletResponse response, SystemQueryJobArgs args) { - List systemJobTbs = this.queryJobByArgs(args); - List rowVos = new ArrayList<>(); - for (SystemJobTb dataObject : systemJobTbs) { - SystemJobExportRowVo rowVo = new SystemJobExportRowVo(); - rowVo.setName(dataObject.getName()); - rowVo.setEnabled(dataObject.getEnabled() ? "启用" : "停用"); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - KitExcelExporter.exportSimple(response, "岗位数据", SystemJobExportRowVo.class, rowVos); + public void exportJobXlsx(HttpServletResponse response, SystemQueryJobArgs args) { + List systemJobTbs = this.queryJobByArgs(args); + List rowVos = new ArrayList<>(); + for (SystemJobTb dataObject : systemJobTbs) { + SystemJobExportRowVo rowVo = new SystemJobExportRowVo(); + rowVo.setName(dataObject.getName()); + rowVo.setEnabled(dataObject.getEnabled() ? "启用" : "停用"); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); } + KitExcelExporter.exportSimple(response, "岗位数据", SystemJobExportRowVo.class, rowVos); + } - public List listByIds(Set jobIds) { - return systemJobMapper.selectByIds(jobIds); - } + public List listByIds(Set jobIds) { + return systemJobMapper.selectByIds(jobIds); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java index 2db33d35..560ca012 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java @@ -36,142 +36,142 @@ import cn.odboy.util.KitPageUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.multipart.MultipartFile; import jakarta.servlet.http.HttpServletResponse; import java.io.File; import java.util.Date; import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; @Service public class SystemLocalStorageService { - @Autowired - private SystemLocalStorageMapper systemLocalStorageMapper; - @Autowired - private KitFileLocalUploadHelper fileUploadPathHelper; - @Autowired - private AppProperties properties; + @Autowired + private SystemLocalStorageMapper systemLocalStorageMapper; + @Autowired + private KitFileLocalUploadHelper fileUploadPathHelper; + @Autowired + private AppProperties properties; - /** - * 上传 -> TestPassed - * - * @param name 文件名称 - * @param multipartFile 文件 - * @return / - */ - @Transactional(rollbackFor = Exception.class) - public SystemLocalStorageTb uploadFile(String name, MultipartFile multipartFile) { - long size = multipartFile.getSize(); - KitFileUtil.checkSize(properties.getOss().getMaxSize(), size); - String suffix = KitFileUtil.getSuffix(multipartFile.getOriginalFilename()); - String type = KitFileUtil.getFileType(suffix); - String uploadDateStr = DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT); - File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath() + uploadDateStr + File.separator); - if (file == null) { - throw new BadRequestException("上传失败"); - } - try { - String formatSize = KitFileUtil.getSize(size); - String prefixName = - StrUtil.isBlank(name) ? KitFileUtil.getPrefix(multipartFile.getOriginalFilename()) : name; - SystemLocalStorageTb localStorage = new SystemLocalStorageTb(); - localStorage.setRealName(file.getName()); - localStorage.setName(prefixName); - localStorage.setSuffix(suffix); - localStorage.setPath(file.getPath()); - localStorage.setType(type); - localStorage.setSize(formatSize); - localStorage.setDateGroup(uploadDateStr); - systemLocalStorageMapper.insert(localStorage); - return localStorage; - } catch (Exception e) { - KitFileUtil.del(file); - throw e; - } + /** + * 上传 -> TestPassed + * + * @param name 文件名称 + * @param multipartFile 文件 + * @return / + */ + @Transactional(rollbackFor = Exception.class) + public SystemLocalStorageTb uploadFile(String name, MultipartFile multipartFile) { + long size = multipartFile.getSize(); + KitFileUtil.checkSize(properties.getOss().getMaxSize(), size); + String suffix = KitFileUtil.getSuffix(multipartFile.getOriginalFilename()); + String type = KitFileUtil.getFileType(suffix); + String uploadDateStr = DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT); + File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath() + uploadDateStr + File.separator); + if (file == null) { + throw new BadRequestException("上传失败"); } + try { + String formatSize = KitFileUtil.getSize(size); + String prefixName = + StrUtil.isBlank(name) ? KitFileUtil.getPrefix(multipartFile.getOriginalFilename()) : name; + SystemLocalStorageTb localStorage = new SystemLocalStorageTb(); + localStorage.setRealName(file.getName()); + localStorage.setName(prefixName); + localStorage.setSuffix(suffix); + localStorage.setPath(file.getPath()); + localStorage.setType(type); + localStorage.setSize(formatSize); + localStorage.setDateGroup(uploadDateStr); + systemLocalStorageMapper.insert(localStorage); + return localStorage; + } catch (Exception e) { + KitFileUtil.del(file); + throw e; + } + } - /** - * 编辑 -> TestPassed - * - * @param args 文件信息 - */ - @Transactional(rollbackFor = Exception.class) - public void updateLocalStorageById(SystemLocalStorageTb args) { - SystemLocalStorageTb localStorage = systemLocalStorageMapper.selectById(args.getId()); - localStorage.copy(args); - systemLocalStorageMapper.insertOrUpdate(localStorage); - } + /** + * 编辑 -> TestPassed + * + * @param args 文件信息 + */ + @Transactional(rollbackFor = Exception.class) + public void updateLocalStorageById(SystemLocalStorageTb args) { + SystemLocalStorageTb localStorage = systemLocalStorageMapper.selectById(args.getId()); + localStorage.copy(args); + systemLocalStorageMapper.insertOrUpdate(localStorage); + } - /** - * 多选删除 -> TestPassed - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteFileByIds(Long[] ids) { - for (Long id : ids) { - SystemLocalStorageTb storage = systemLocalStorageMapper.selectById(id); - try { - KitFileUtil.del(storage.getPath()); - systemLocalStorageMapper.deleteById(storage); - } catch (IORuntimeException e) { - throw new BadRequestException("删除文件 " + storage.getName() + " 失败"); - } - } + /** + * 多选删除 -> TestPassed + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteFileByIds(Long[] ids) { + for (Long id : ids) { + SystemLocalStorageTb storage = systemLocalStorageMapper.selectById(id); + try { + KitFileUtil.del(storage.getPath()); + systemLocalStorageMapper.deleteById(storage); + } catch (IORuntimeException e) { + throw new BadRequestException("删除文件 " + storage.getName() + " 失败"); + } } + } - /** - * 分页查询 -> TestPassed - * - * @param args 条件 - * @param page 分页参数 - * @return / - */ - public KitPageResult searchLocalStorage(SystemQueryStorageArgs args, - Page page) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQueryParams(args, wrapper); - Page selectPage = systemLocalStorageMapper.selectPage(page, wrapper); - return KitPageUtil.toPage(selectPage); - } + /** + * 分页查询 -> TestPassed + * + * @param args 条件 + * @param page 分页参数 + * @return / + */ + public KitPageResult searchLocalStorage(SystemQueryStorageArgs args, + Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(args, wrapper); + Page selectPage = systemLocalStorageMapper.selectPage(page, wrapper); + return KitPageUtil.toPage(selectPage); + } - private void injectQueryParams(SystemQueryStorageArgs args, LambdaQueryWrapper wrapper) { - if (args != null) { - wrapper.and(StrUtil.isNotBlank(args.getBlurry()), - c -> c.like(SystemLocalStorageTb::getName, args.getBlurry()).or() - .like(SystemLocalStorageTb::getSuffix, args.getBlurry()).or() - .like(SystemLocalStorageTb::getType, args.getBlurry()).or() - .like(SystemLocalStorageTb::getCreateBy, args.getBlurry())); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemLocalStorageTb::getUpdateTime, args.getCreateTime().get(0), - args.getCreateTime().get(1)); - } - } - wrapper.orderByDesc(SystemLocalStorageTb::getId); + private void injectQueryParams(SystemQueryStorageArgs args, LambdaQueryWrapper wrapper) { + if (args != null) { + wrapper.and(StrUtil.isNotBlank(args.getBlurry()), + c -> c.like(SystemLocalStorageTb::getName, args.getBlurry()).or() + .like(SystemLocalStorageTb::getSuffix, args.getBlurry()).or() + .like(SystemLocalStorageTb::getType, args.getBlurry()).or() + .like(SystemLocalStorageTb::getCreateBy, args.getBlurry())); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemLocalStorageTb::getUpdateTime, args.getCreateTime().get(0), + args.getCreateTime().get(1)); + } } + wrapper.orderByDesc(SystemLocalStorageTb::getId); + } - public List queryLocalStorageByArgs(SystemQueryStorageArgs args) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQueryParams(args, wrapper); - return systemLocalStorageMapper.selectList(wrapper); - } + public List queryLocalStorageByArgs(SystemQueryStorageArgs args) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(args, wrapper); + return systemLocalStorageMapper.selectList(wrapper); + } - public SystemLocalStorageTb uploadPictureV1(MultipartFile file) { - // 判断文件是否为图片 - String suffix = KitFileUtil.getSuffix(file.getOriginalFilename()); - if (!FileTypeEnum.IMAGE.getCode().equals(KitFileUtil.getFileType(suffix))) { - throw new BadRequestException("只能上传图片"); - } - return KitSpringBeanHolder.getBean(SystemLocalStorageService.class).uploadFile(null, file); + public SystemLocalStorageTb uploadPictureV1(MultipartFile file) { + // 判断文件是否为图片 + String suffix = KitFileUtil.getSuffix(file.getOriginalFilename()); + if (!FileTypeEnum.IMAGE.getCode().equals(KitFileUtil.getFileType(suffix))) { + throw new BadRequestException("只能上传图片"); } + return KitSpringBeanHolder.getBean(SystemLocalStorageService.class).uploadFile(null, file); + } - public void exportLocalStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) { - List systemLocalStorageTbs = this.queryLocalStorageByArgs(args); - List rowVos = - KitBeanUtil.copyToList(systemLocalStorageTbs, SystemLocalStorageExportRowVo.class); - KitExcelExporter.exportSimple(response, "文件上传记录数据", SystemLocalStorageExportRowVo.class, rowVos); - } + public void exportLocalStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) { + List systemLocalStorageTbs = this.queryLocalStorageByArgs(args); + List rowVos = + KitBeanUtil.copyToList(systemLocalStorageTbs, SystemLocalStorageExportRowVo.class); + KitExcelExporter.exportSimple(response, "文件上传记录数据", SystemLocalStorageExportRowVo.class, rowVos); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java index c47ae878..085e46c3 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java @@ -36,9 +36,6 @@ import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import jakarta.servlet.http.HttpServletResponse; import java.lang.reflect.Field; import java.util.ArrayList; @@ -49,428 +46,431 @@ import java.util.List; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemMenuService { - @Autowired - private SystemMenuMapper systemMenuMapper; - @Autowired - private SystemRoleMenuService systemRoleMenuService; - @Autowired - private SystemUserRoleService systemUserRoleService; + @Autowired + private SystemMenuMapper systemMenuMapper; + @Autowired + private SystemRoleMenuService systemRoleMenuService; + @Autowired + private SystemUserRoleService systemUserRoleService; - /** - * 创建 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveMenu(SystemMenuTb args) { - if (this.getMenuByTitle(args.getTitle()) != null) { - throw new BadRequestException("菜单标题已存在"); - } - if (StrUtil.isNotBlank(args.getComponentName())) { - if (this.getMenuByComponentName(args.getComponentName()) != null) { - throw new BadRequestException("菜单组件名称已存在"); - } - } - if (Long.valueOf(0L).equals(args.getPid())) { - args.setPid(null); - } - if (args.getIFrame()) { - if (!(args.getPath().toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTP) || args.getPath() - .toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTPS))) { - throw new BadRequestException(SystemTransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST); - } - } - systemMenuMapper.insert(args); - // 计算子节点数目 - args.setSubCount(0); - // 更新父节点菜单数目 - this.updateMenuSubCnt(args.getPid()); + /** + * 创建 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveMenu(SystemMenuTb args) { + if (this.getMenuByTitle(args.getTitle()) != null) { + throw new BadRequestException("菜单标题已存在"); } - - /** - * 编辑 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateMenuById(SystemMenuTb args) { - if (args.getId().equals(args.getPid())) { - throw new BadRequestException("上级不能为自己"); - } - SystemMenuTb menu = systemMenuMapper.selectById(args.getId()); - if (args.getIFrame()) { - if (!(args.getPath().toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTP) || args.getPath() - .toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTPS))) { - throw new BadRequestException(SystemTransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST); - } - } - SystemMenuTb menu1 = this.getMenuByTitle(args.getTitle()); - if (menu1 != null && !menu1.getId().equals(menu.getId())) { - throw new BadRequestException("菜单标题已存在"); - } - if (args.getPid().equals(0L)) { - args.setPid(null); - } - // 记录的父节点ID - Long oldPid = menu.getPid(); - Long newPid = args.getPid(); - if (StrUtil.isNotBlank(args.getComponentName())) { - menu1 = this.getMenuByComponentName(args.getComponentName()); - if (menu1 != null && !menu1.getId().equals(menu.getId())) { - throw new BadRequestException("菜单组件名称已存在"); - } - } - menu.setTitle(args.getTitle()); - menu.setComponent(args.getComponent()); - menu.setPath(args.getPath()); - menu.setIcon(args.getIcon()); - menu.setIFrame(args.getIFrame()); - menu.setPid(args.getPid()); - menu.setMenuSort(args.getMenuSort()); - menu.setCache(args.getCache()); - menu.setHidden(args.getHidden()); - menu.setComponentName(args.getComponentName()); - menu.setPermission(args.getPermission()); - menu.setType(args.getType()); - // auto fill - menu.setUpdateBy(null); - menu.setUpdateTime(null); - systemMenuMapper.insertOrUpdate(menu); - // 计算父级菜单节点数目 - this.updateMenuSubCnt(oldPid); - this.updateMenuSubCnt(newPid); + if (StrUtil.isNotBlank(args.getComponentName())) { + if (this.getMenuByComponentName(args.getComponentName()) != null) { + throw new BadRequestException("菜单组件名称已存在"); + } } - - /** - * 删除 - */ - @Transactional(rollbackFor = Exception.class) - public void deleteMenuByIds(Set ids) { - Set menuSet = new HashSet<>(); - for (Long id : ids) { - List menuList = this.listMenuByPid(id); - menuSet.add(this.getMenuVoById(id)); - menuSet = this.queryChildMenuByArgs(menuList, menuSet); - } - List menuIds = - menuSet.stream().map(SystemMenuVo::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); - if (CollUtil.isNotEmpty(menuIds)) { - systemRoleMenuService.deleteRoleMenuByMenuIds(menuIds); - systemMenuMapper.deleteByIds(menuIds); - } - for (SystemMenuVo menu : menuSet) { - this.updateMenuSubCnt(menu.getPid()); - } + if (Long.valueOf(0L).equals(args.getPid())) { + args.setPid(null); } - - private SystemMenuVo getMenuVoById(Long id) { - return KitBeanUtil.copyToClass(systemMenuMapper.selectById(id), SystemMenuVo.class); + if (args.getIFrame()) { + if (!(args.getPath().toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTP) || args.getPath() + .toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTPS))) { + throw new BadRequestException(SystemTransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST); + } } + systemMenuMapper.insert(args); + // 计算子节点数目 + args.setSubCount(0); + // 更新父节点菜单数目 + this.updateMenuSubCnt(args.getPid()); + } - @Transactional(rollbackFor = Exception.class) - public void updateMenuSubCnt(Long menuId) { - if (menuId != null) { - long count = this.countMenuByPid(menuId); - LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); - wrapper.eq(SystemMenuTb::getId, menuId); - wrapper.set(SystemMenuTb::getSubCount, count); - systemMenuMapper.update(wrapper); + /** + * 编辑 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateMenuById(SystemMenuTb args) { + if (args.getId().equals(args.getPid())) { + throw new BadRequestException("上级不能为自己"); + } + SystemMenuTb menu = systemMenuMapper.selectById(args.getId()); + if (args.getIFrame()) { + if (!(args.getPath().toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTP) || args.getPath() + .toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTPS))) { + throw new BadRequestException(SystemTransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST); + } + } + SystemMenuTb menu1 = this.getMenuByTitle(args.getTitle()); + if (menu1 != null && !menu1.getId().equals(menu.getId())) { + throw new BadRequestException("菜单标题已存在"); + } + if (args.getPid().equals(0L)) { + args.setPid(null); + } + // 记录的父节点ID + Long oldPid = menu.getPid(); + Long newPid = args.getPid(); + if (StrUtil.isNotBlank(args.getComponentName())) { + menu1 = this.getMenuByComponentName(args.getComponentName()); + if (menu1 != null && !menu1.getId().equals(menu.getId())) { + throw new BadRequestException("菜单组件名称已存在"); + } + } + menu.setTitle(args.getTitle()); + menu.setComponent(args.getComponent()); + menu.setPath(args.getPath()); + menu.setIcon(args.getIcon()); + menu.setIFrame(args.getIFrame()); + menu.setPid(args.getPid()); + menu.setMenuSort(args.getMenuSort()); + menu.setCache(args.getCache()); + menu.setHidden(args.getHidden()); + menu.setComponentName(args.getComponentName()); + menu.setPermission(args.getPermission()); + menu.setType(args.getType()); + // auto fill + menu.setUpdateBy(null); + menu.setUpdateTime(null); + systemMenuMapper.insertOrUpdate(menu); + // 计算父级菜单节点数目 + this.updateMenuSubCnt(oldPid); + this.updateMenuSubCnt(newPid); + } + + /** + * 删除 + */ + @Transactional(rollbackFor = Exception.class) + public void deleteMenuByIds(Set ids) { + Set menuSet = new HashSet<>(); + for (Long id : ids) { + List menuList = this.listMenuByPid(id); + menuSet.add(this.getMenuVoById(id)); + menuSet = this.queryChildMenuByArgs(menuList, menuSet); + } + List menuIds = + menuSet.stream().map(SystemMenuVo::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); + if (CollUtil.isNotEmpty(menuIds)) { + systemRoleMenuService.deleteRoleMenuByMenuIds(menuIds); + systemMenuMapper.deleteByIds(menuIds); + } + for (SystemMenuVo menu : menuSet) { + this.updateMenuSubCnt(menu.getPid()); + } + } + + private SystemMenuVo getMenuVoById(Long id) { + return KitBeanUtil.copyToClass(systemMenuMapper.selectById(id), SystemMenuVo.class); + } + + @Transactional(rollbackFor = Exception.class) + public void updateMenuSubCnt(Long menuId) { + if (menuId != null) { + long count = this.countMenuByPid(menuId); + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(SystemMenuTb::getId, menuId); + wrapper.set(SystemMenuTb::getSubCount, count); + systemMenuMapper.update(wrapper); + } + } + + /** + * 查询全部数据 + * + * @param args 条件 + * @param isQuery / + * @return / + * @throws Exception / + */ + public List queryAllMenu(SystemQueryMenuArgs args, Boolean isQuery) throws Exception { + if (Boolean.TRUE.equals(isQuery)) { + args.setPidIsNull(true); + List fields = KitClassUtil.getAllFields(args.getClass(), new ArrayList<>()); + for (Field field : fields) { + //设置对象的访问权限, 保证对private的属性的访问 + field.setAccessible(true); + Object val = field.get(args); + if ("pidIsNull".equals(field.getName())) { + continue; } - } - - /** - * 查询全部数据 - * - * @param args 条件 - * @param isQuery / - * @return / - * @throws Exception / - */ - public List queryAllMenu(SystemQueryMenuArgs args, Boolean isQuery) throws Exception { - if (Boolean.TRUE.equals(isQuery)) { - args.setPidIsNull(true); - List fields = KitClassUtil.getAllFields(args.getClass(), new ArrayList<>()); - for (Field field : fields) { - //设置对象的访问权限, 保证对private的属性的访问 - field.setAccessible(true); - Object val = field.get(args); - if ("pidIsNull".equals(field.getName())) { - continue; - } - // 如果有查询条件, 则不指定pidIsNull - if (ObjectUtil.isNotNull(val)) { - args.setPidIsNull(null); - break; - } - } + // 如果有查询条件, 则不指定pidIsNull + if (ObjectUtil.isNotNull(val)) { + args.setPidIsNull(null); + break; } - return this.queryMenuByArgs(args); + } } + return this.queryMenuByArgs(args); + } - /** - * 根据当前用户获取菜单 - * - * @param currentUserId / - * @return / - */ - public List listMenuByUserId(Long currentUserId) { - List roles = systemUserRoleService.queryRoleVoByUsersId(currentUserId); - Set roleIds = roles.stream().map(SystemRoleVo::getId).collect(Collectors.toSet()); - return new ArrayList<>(systemRoleMenuService.queryMenuByRoleIds(roleIds)); + /** + * 根据当前用户获取菜单 + * + * @param currentUserId / + * @return / + */ + public List listMenuByUserId(Long currentUserId) { + List roles = systemUserRoleService.queryRoleVoByUsersId(currentUserId); + Set roleIds = roles.stream().map(SystemRoleVo::getId).collect(Collectors.toSet()); + return new ArrayList<>(systemRoleMenuService.queryMenuByRoleIds(roleIds)); + } + + /** + * 获取所有子节点, 包含自身ID + * + * @param menuList / + * @param menuSet / + * @return / + */ + public Set queryChildMenuByArgs(List menuList, Set menuSet) { + for (SystemMenuVo menu : menuList) { + menuSet.add(menu); + List menus = this.listMenuByPid(menu.getId()); + if (CollUtil.isNotEmpty(menus)) { + queryChildMenuByArgs(menus, menuSet); + } } + return menuSet; + } - /** - * 获取所有子节点, 包含自身ID - * - * @param menuList / - * @param menuSet / - * @return / - */ - public Set queryChildMenuByArgs(List menuList, Set menuSet) { - for (SystemMenuVo menu : menuList) { - menuSet.add(menu); - List menus = this.listMenuByPid(menu.getId()); - if (CollUtil.isNotEmpty(menus)) { - queryChildMenuByArgs(menus, menuSet); - } + /** + * 懒加载菜单数据 + * + * @param pid / + * @return / + */ + public List listMenuByPid(Long pid) { + List menus; + if (pid != null && !pid.equals(0L)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemMenuTb::getPid, pid); + wrapper.orderByAsc(SystemMenuTb::getMenuSort); + return KitBeanUtil.copyToList(systemMenuMapper.selectList(wrapper), SystemMenuVo.class); + } else { + menus = this.listRootMenu(); + } + return menus; + } + + /** + * 根据ID获取同级与上级数据 + * + * @param menu / + * @param menus / + * @return / + */ + public List querySuperiorMenuByArgs(SystemMenuVo menu, List menus) { + if (menu.getPid() == null) { + menus.addAll(this.listRootMenu()); + return menus; + } + menus.addAll(this.listMenuByPid(menu.getPid())); + return querySuperiorMenuByArgs(this.getMenuVoById(menu.getPid()), menus); + } + + /** + * 构建菜单树 + * + * @param menus 原始数据 + * @return / + */ + public List buildMenuTree(List menus) { + List trees = new ArrayList<>(); + Set ids = new HashSet<>(); + for (SystemMenuVo menu : menus) { + if (menu.getPid() == null) { + trees.add(menu); + } + for (SystemMenuVo it : menus) { + if (menu.getId().equals(it.getPid())) { + if (menu.getChildren() == null) { + menu.setChildren(new ArrayList<>()); + } + menu.getChildren().add(it); + ids.add(it.getId()); } - return menuSet; + } } - - /** - * 懒加载菜单数据 - * - * @param pid / - * @return / - */ - public List listMenuByPid(Long pid) { - List menus; - if (pid != null && !pid.equals(0L)) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemMenuTb::getPid, pid); - wrapper.orderByAsc(SystemMenuTb::getMenuSort); - return KitBeanUtil.copyToList(systemMenuMapper.selectList(wrapper), SystemMenuVo.class); - } else { - menus = this.listRootMenu(); - } - return menus; + if (CollUtil.isNotEmpty(trees)) { + trees = menus.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList()); } + return trees; + } - /** - * 根据ID获取同级与上级数据 - * - * @param menu / - * @param menus / - * @return / - */ - public List querySuperiorMenuByArgs(SystemMenuVo menu, List menus) { - if (menu.getPid() == null) { - menus.addAll(this.listRootMenu()); - return menus; - } - menus.addAll(this.listMenuByPid(menu.getPid())); - return querySuperiorMenuByArgs(this.getMenuVoById(menu.getPid()), menus); - } - - /** - * 构建菜单树 - * - * @param menus 原始数据 - * @return / - */ - public List buildMenuTree(List menus) { - List trees = new ArrayList<>(); - Set ids = new HashSet<>(); - for (SystemMenuVo menu : menus) { - if (menu.getPid() == null) { - trees.add(menu); - } - for (SystemMenuVo it : menus) { - if (menu.getId().equals(it.getPid())) { - if (menu.getChildren() == null) { - menu.setChildren(new ArrayList<>()); - } - menu.getChildren().add(it); - ids.add(it.getId()); - } - } - } - if (CollUtil.isNotEmpty(trees)) { - trees = menus.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList()); - } - return trees; - } - - /** - * 构建菜单树 - * - * @param menus / - * @return / - */ - public List buildMenuVo(List menus) { - List list = new LinkedList<>(); - for (SystemMenuVo menu : menus) { - if (menu != null) { - List menuList = menu.getChildren(); - SystemMenuRouterVo menuVo = new SystemMenuRouterVo(); - menuVo.setName( - ObjectUtil.isNotEmpty(menu.getComponentName()) ? menu.getComponentName() : menu.getTitle()); - // 一级目录需要加斜杠, 不然会报警告 - menuVo.setPath(menu.getPid() == null ? "/" + menu.getPath() : menu.getPath()); - menuVo.setHidden(menu.getHidden()); - // 如果不是外链 - if (!menu.getIFrame()) { - if (menu.getPid() == null) { - menuVo.setComponent(StrUtil.isEmpty(menu.getComponent()) ? "Layout" : menu.getComponent()); - // 如果不是一级菜单,并且菜单类型为目录,则代表是多级菜单 - } else if (menu.getType() == 0) { - menuVo.setComponent(StrUtil.isEmpty(menu.getComponent()) ? "ParentView" : menu.getComponent()); - } else if (StrUtil.isNotBlank(menu.getComponent())) { - menuVo.setComponent(menu.getComponent()); - } - } - menuVo.setMeta(new SystemMenuMetaVo(menu.getTitle(), menu.getIcon(), !menu.getCache())); - if (CollUtil.isNotEmpty(menuList)) { - menuVo.setAlwaysShow(true); - menuVo.setRedirect("noredirect"); - menuVo.setChildren(buildMenuVo(menuList)); - // 处理是一级菜单并且没有子菜单的情况 - } else if (menu.getPid() == null) { - SystemMenuRouterVo menuVo1 = getMenuVo(menu, menuVo); - menuVo.setName(null); - menuVo.setMeta(null); - menuVo.setComponent("Layout"); - List list1 = new ArrayList<>(); - list1.add(menuVo1); - menuVo.setChildren(list1); - } - list.add(menuVo); - } - } - return list; - } - - /** - * 获取 MenuResponse - * - * @param menu / - * @param menuVo / - * @return / - */ - private SystemMenuRouterVo getMenuVo(SystemMenuVo menu, SystemMenuRouterVo menuVo) { - SystemMenuRouterVo menuVo1 = new SystemMenuRouterVo(); - menuVo1.setMeta(menuVo.getMeta()); - // 非外链 + /** + * 构建菜单树 + * + * @param menus / + * @return / + */ + public List buildMenuVo(List menus) { + List list = new LinkedList<>(); + for (SystemMenuVo menu : menus) { + if (menu != null) { + List menuList = menu.getChildren(); + SystemMenuRouterVo menuVo = new SystemMenuRouterVo(); + menuVo.setName( + ObjectUtil.isNotEmpty(menu.getComponentName()) ? menu.getComponentName() : menu.getTitle()); + // 一级目录需要加斜杠, 不然会报警告 + menuVo.setPath(menu.getPid() == null ? "/" + menu.getPath() : menu.getPath()); + menuVo.setHidden(menu.getHidden()); + // 如果不是外链 if (!menu.getIFrame()) { - menuVo1.setPath("index"); - menuVo1.setName(menuVo.getName()); - menuVo1.setComponent(menuVo.getComponent()); - } else { - menuVo1.setPath(menu.getPath()); + if (menu.getPid() == null) { + menuVo.setComponent(StrUtil.isEmpty(menu.getComponent()) ? "Layout" : menu.getComponent()); + // 如果不是一级菜单,并且菜单类型为目录,则代表是多级菜单 + } else if (menu.getType() == 0) { + menuVo.setComponent(StrUtil.isEmpty(menu.getComponent()) ? "ParentView" : menu.getComponent()); + } else if (StrUtil.isNotBlank(menu.getComponent())) { + menuVo.setComponent(menu.getComponent()); + } } - return menuVo1; - } - - public List listMenuByIds(List ids) { - return KitBeanUtil.copyToList(systemMenuMapper.selectByIds(ids), SystemMenuVo.class); - } - - private SystemMenuTb getMenuByComponentName(String componentName) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemMenuTb::getComponentName, componentName); - return systemMenuMapper.selectOne(wrapper); - } - - private SystemMenuTb getMenuByTitle(String title) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemMenuTb::getTitle, title); - return systemMenuMapper.selectOne(wrapper); - } - - private Long countMenuByPid(Long pid) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemMenuTb::getPid, pid); - return systemMenuMapper.selectCount(wrapper); - } - - private List queryMenuByArgs(SystemQueryMenuArgs args) { - KitValidUtil.notNull(args); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.isNull(args.getPidIsNull() != null, SystemMenuTb::getPid); - wrapper.eq(args.getPid() != null, SystemMenuTb::getPid, args.getPid()); - wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemMenuTb::getTitle, args.getBlurry()).or() - .like(SystemMenuTb::getComponentName, args.getBlurry()).or() - .like(SystemMenuTb::getPermission, args.getBlurry())); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemMenuTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + menuVo.setMeta(new SystemMenuMetaVo(menu.getTitle(), menu.getIcon(), !menu.getCache())); + if (CollUtil.isNotEmpty(menuList)) { + menuVo.setAlwaysShow(true); + menuVo.setRedirect("noredirect"); + menuVo.setChildren(buildMenuVo(menuList)); + // 处理是一级菜单并且没有子菜单的情况 + } else if (menu.getPid() == null) { + SystemMenuRouterVo menuVo1 = getMenuVo(menu, menuVo); + menuVo.setName(null); + menuVo.setMeta(null); + menuVo.setComponent("Layout"); + List list1 = new ArrayList<>(); + list1.add(menuVo1); + menuVo.setChildren(list1); } - wrapper.orderByAsc(SystemMenuTb::getMenuSort); - return systemMenuMapper.selectList(wrapper); + list.add(menuVo); + } } + return list; + } - private List listRootMenu() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.isNull(SystemMenuTb::getPid); - wrapper.orderByAsc(SystemMenuTb::getMenuSort); - return KitBeanUtil.copyToList(systemMenuMapper.selectList(wrapper), SystemMenuVo.class); + /** + * 获取 MenuResponse + * + * @param menu / + * @param menuVo / + * @return / + */ + private SystemMenuRouterVo getMenuVo(SystemMenuVo menu, SystemMenuRouterVo menuVo) { + SystemMenuRouterVo menuVo1 = new SystemMenuRouterVo(); + menuVo1.setMeta(menuVo.getMeta()); + // 非外链 + if (!menu.getIFrame()) { + menuVo1.setPath("index"); + menuVo1.setName(menuVo.getName()); + menuVo1.setComponent(menuVo.getComponent()); + } else { + menuVo1.setPath(menu.getPath()); } + return menuVo1; + } - public List buildFrontMenus() { - List originMenus = this.listMenuByUserId(KitSecurityHelper.getCurrentUserId()); - List targetMenus = this.buildMenuTree(originMenus); - return this.buildMenuVo(targetMenus); + public List listMenuByIds(List ids) { + return KitBeanUtil.copyToList(systemMenuMapper.selectByIds(ids), SystemMenuVo.class); + } + + private SystemMenuTb getMenuByComponentName(String componentName) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemMenuTb::getComponentName, componentName); + return systemMenuMapper.selectOne(wrapper); + } + + private SystemMenuTb getMenuByTitle(String title) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemMenuTb::getTitle, title); + return systemMenuMapper.selectOne(wrapper); + } + + private Long countMenuByPid(Long pid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemMenuTb::getPid, pid); + return systemMenuMapper.selectCount(wrapper); + } + + private List queryMenuByArgs(SystemQueryMenuArgs args) { + KitValidUtil.notNull(args); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.isNull(args.getPidIsNull() != null, SystemMenuTb::getPid); + wrapper.eq(args.getPid() != null, SystemMenuTb::getPid, args.getPid()); + wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemMenuTb::getTitle, args.getBlurry()).or() + .like(SystemMenuTb::getComponentName, args.getBlurry()).or() + .like(SystemMenuTb::getPermission, args.getBlurry())); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemMenuTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); } + wrapper.orderByAsc(SystemMenuTb::getMenuSort); + return systemMenuMapper.selectList(wrapper); + } - public Set listChildMenuSetByMenuId(Long id) { - Set menuSet = new HashSet<>(); - List menuList = this.listMenuByPid(id); - menuSet.add(this.getMenuVoById(id)); - menuSet = this.queryChildMenuByArgs(menuList, menuSet); - return menuSet.stream().map(SystemMenuVo::getId).collect(Collectors.toSet()); - } + private List listRootMenu() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.isNull(SystemMenuTb::getPid); + wrapper.orderByAsc(SystemMenuTb::getMenuSort); + return KitBeanUtil.copyToList(systemMenuMapper.selectList(wrapper), SystemMenuVo.class); + } - public List listMenuSuperior(List ids) { - Set menus; - List systemMenuTbs; - if (CollUtil.isNotEmpty(ids)) { - menus = new LinkedHashSet<>(this.listMenuByIds(ids)); - for (SystemMenuVo menu : menus) { - List menuList = this.querySuperiorMenuByArgs(menu, new ArrayList<>()); - for (SystemMenuVo data : menuList) { - if (data.getId().equals(menu.getPid())) { - data.setSubCount(data.getSubCount() - 1); - } - } - menus.addAll(menuList); - } - // 编辑菜单时不显示自己以及自己下级的数据, 避免出现PID数据环形问题 - menus = menus.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toSet()); - List newMenuList = new ArrayList<>(menus); - systemMenuTbs = this.buildMenuTree(newMenuList); - } else { - systemMenuTbs = this.listMenuByPid(null); + public List buildFrontMenus() { + List originMenus = this.listMenuByUserId(KitSecurityHelper.getCurrentUserId()); + List targetMenus = this.buildMenuTree(originMenus); + return this.buildMenuVo(targetMenus); + } + + public Set listChildMenuSetByMenuId(Long id) { + Set menuSet = new HashSet<>(); + List menuList = this.listMenuByPid(id); + menuSet.add(this.getMenuVoById(id)); + menuSet = this.queryChildMenuByArgs(menuList, menuSet); + return menuSet.stream().map(SystemMenuVo::getId).collect(Collectors.toSet()); + } + + public List listMenuSuperior(List ids) { + Set menus; + List systemMenuTbs; + if (CollUtil.isNotEmpty(ids)) { + menus = new LinkedHashSet<>(this.listMenuByIds(ids)); + for (SystemMenuVo menu : menus) { + List menuList = this.querySuperiorMenuByArgs(menu, new ArrayList<>()); + for (SystemMenuVo data : menuList) { + if (data.getId().equals(menu.getPid())) { + data.setSubCount(data.getSubCount() - 1); + } } - return systemMenuTbs; + menus.addAll(menuList); + } + // 编辑菜单时不显示自己以及自己下级的数据, 避免出现PID数据环形问题 + menus = menus.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toSet()); + List newMenuList = new ArrayList<>(menus); + systemMenuTbs = this.buildMenuTree(newMenuList); + } else { + systemMenuTbs = this.listMenuByPid(null); } + return systemMenuTbs; + } - public void exportMenuXlsx(HttpServletResponse response, SystemQueryMenuArgs args) throws Exception { - List systemMenuTbs = this.queryAllMenu(args, false); - List rowVos = new ArrayList<>(); - for (SystemMenuTb dataObject : systemMenuTbs) { - SystemMenuExportRowVo rowVo = new SystemMenuExportRowVo(); - rowVo.setTitle(dataObject.getTitle()); - rowVo.setType(dataObject.getType() == null ? "目录" : dataObject.getType() == 1 ? "菜单" : "按钮"); - rowVo.setPermission(dataObject.getPermission()); - rowVo.setIFrame(dataObject.getIFrame() ? SystemYesOrNoChConst.YES_STR : SystemYesOrNoChConst.NO_STR); - rowVo.setHidden(dataObject.getHidden() ? SystemYesOrNoChConst.NO_STR : SystemYesOrNoChConst.YES_STR); - rowVo.setCache(dataObject.getCache() ? SystemYesOrNoChConst.YES_STR : SystemYesOrNoChConst.NO_STR); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - KitExcelExporter.exportSimple(response, "菜单数据", SystemMenuExportRowVo.class, rowVos); + public void exportMenuXlsx(HttpServletResponse response, SystemQueryMenuArgs args) throws Exception { + List systemMenuTbs = this.queryAllMenu(args, false); + List rowVos = new ArrayList<>(); + for (SystemMenuTb dataObject : systemMenuTbs) { + SystemMenuExportRowVo rowVo = new SystemMenuExportRowVo(); + rowVo.setTitle(dataObject.getTitle()); + rowVo.setType(dataObject.getType() == null ? "目录" : dataObject.getType() == 1 ? "菜单" : "按钮"); + rowVo.setPermission(dataObject.getPermission()); + rowVo.setIFrame(dataObject.getIFrame() ? SystemYesOrNoChConst.YES_STR : SystemYesOrNoChConst.NO_STR); + rowVo.setHidden(dataObject.getHidden() ? SystemYesOrNoChConst.NO_STR : SystemYesOrNoChConst.YES_STR); + rowVo.setCache(dataObject.getCache() ? SystemYesOrNoChConst.YES_STR : SystemYesOrNoChConst.NO_STR); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); } + KitExcelExporter.exportSimple(response, "菜单数据", SystemMenuExportRowVo.class, rowVos); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java index 9dd6fc74..e506233d 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java @@ -20,6 +20,13 @@ import cn.hutool.core.date.DateUtil; import cn.odboy.constant.SystemConst; import cn.odboy.util.KitFileUtil; import cn.odboy.util.KitIPUtil; +import java.lang.management.ManagementFactory; +import java.text.DecimalFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import oshi.SystemInfo; @@ -32,184 +39,177 @@ import oshi.software.os.OSFileStore; import oshi.software.os.OperatingSystem; import oshi.util.FormatUtil; import oshi.util.Util; -import java.lang.management.ManagementFactory; -import java.text.DecimalFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; @Slf4j @Service public class SystemMonitorService { - private final DecimalFormat df = new DecimalFormat("0.00"); + private final DecimalFormat df = new DecimalFormat("0.00"); - /** - * 查询服务器监控信息 -> TestPassed - * - * @return Map - */ - public Map getServerMonitorInfo() { - Map resultMap = new LinkedHashMap<>(8); - try { - SystemInfo si = new SystemInfo(); - OperatingSystem os = si.getOperatingSystem(); - HardwareAbstractionLayer hal = si.getHardware(); - // 系统信息 - resultMap.put("sys", getSystemInfo(os)); - // cpu 信息 - resultMap.put("cpu", getCpuInfo(hal.getProcessor())); - // 内存信息 - resultMap.put("memory", getMemoryInfo(hal.getMemory())); - // 交换区信息 - resultMap.put("swap", getSwapInfo(hal.getMemory())); - // 磁盘 - resultMap.put("disk", getDiskInfo(os)); - resultMap.put("time", DateUtil.format(new Date(), "HH:mm:ss")); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return resultMap; + /** + * 查询服务器监控信息 -> TestPassed + * + * @return Map + */ + public Map getServerMonitorInfo() { + Map resultMap = new LinkedHashMap<>(8); + try { + SystemInfo si = new SystemInfo(); + OperatingSystem os = si.getOperatingSystem(); + HardwareAbstractionLayer hal = si.getHardware(); + // 系统信息 + resultMap.put("sys", getSystemInfo(os)); + // cpu 信息 + resultMap.put("cpu", getCpuInfo(hal.getProcessor())); + // 内存信息 + resultMap.put("memory", getMemoryInfo(hal.getMemory())); + // 交换区信息 + resultMap.put("swap", getSwapInfo(hal.getMemory())); + // 磁盘 + resultMap.put("disk", getDiskInfo(os)); + resultMap.put("time", DateUtil.format(new Date(), "HH:mm:ss")); + } catch (Exception e) { + log.error(e.getMessage(), e); } + return resultMap; + } - /** - * 获取磁盘信息 - * - * @return / - */ - private Map getDiskInfo(OperatingSystem os) { - Map diskInfo = new LinkedHashMap<>(); - FileSystem fileSystem = os.getFileSystem(); - List fsArray = fileSystem.getFileStores(); - String osName = System.getProperty("os.name"); - long available = 0, total = 0; - for (OSFileStore fs : fsArray) { - // windows 需要将所有磁盘分区累加, linux 和 mac 直接累加会出现磁盘重复的问题, 待修复 - if (osName.toLowerCase().startsWith(SystemConst.WIN)) { - available += fs.getUsableSpace(); - total += fs.getTotalSpace(); - } else { - available = fs.getUsableSpace(); - total = fs.getTotalSpace(); - break; - } - } - long used = total - available; - diskInfo.put("total", total > 0 ? KitFileUtil.getSize(total) : "?"); - diskInfo.put("available", KitFileUtil.getSize(available)); - diskInfo.put("used", KitFileUtil.getSize(used)); - if (total != 0) { - diskInfo.put("usageRate", df.format(used / (double)total * 100)); - } else { - diskInfo.put("usageRate", 0); - } - return diskInfo; + /** + * 获取磁盘信息 + * + * @return / + */ + private Map getDiskInfo(OperatingSystem os) { + Map diskInfo = new LinkedHashMap<>(); + FileSystem fileSystem = os.getFileSystem(); + List fsArray = fileSystem.getFileStores(); + String osName = System.getProperty("os.name"); + long available = 0, total = 0; + for (OSFileStore fs : fsArray) { + // windows 需要将所有磁盘分区累加, linux 和 mac 直接累加会出现磁盘重复的问题, 待修复 + if (osName.toLowerCase().startsWith(SystemConst.WIN)) { + available += fs.getUsableSpace(); + total += fs.getTotalSpace(); + } else { + available = fs.getUsableSpace(); + total = fs.getTotalSpace(); + break; + } } + long used = total - available; + diskInfo.put("total", total > 0 ? KitFileUtil.getSize(total) : "?"); + diskInfo.put("available", KitFileUtil.getSize(available)); + diskInfo.put("used", KitFileUtil.getSize(used)); + if (total != 0) { + diskInfo.put("usageRate", df.format(used / (double) total * 100)); + } else { + diskInfo.put("usageRate", 0); + } + return diskInfo; + } - /** - * 获取交换区信息 - * - * @param memory / - * @return / - */ - private Map getSwapInfo(GlobalMemory memory) { - Map swapInfo = new LinkedHashMap<>(); - VirtualMemory virtualMemory = memory.getVirtualMemory(); - long total = virtualMemory.getSwapTotal(); - long used = virtualMemory.getSwapUsed(); - swapInfo.put("total", FormatUtil.formatBytes(total)); - swapInfo.put("used", FormatUtil.formatBytes(used)); - swapInfo.put("available", FormatUtil.formatBytes(total - used)); - if (used == 0) { - swapInfo.put("usageRate", 0); - } else { - swapInfo.put("usageRate", df.format(used / (double)total * 100)); - } - return swapInfo; + /** + * 获取交换区信息 + * + * @param memory / + * @return / + */ + private Map getSwapInfo(GlobalMemory memory) { + Map swapInfo = new LinkedHashMap<>(); + VirtualMemory virtualMemory = memory.getVirtualMemory(); + long total = virtualMemory.getSwapTotal(); + long used = virtualMemory.getSwapUsed(); + swapInfo.put("total", FormatUtil.formatBytes(total)); + swapInfo.put("used", FormatUtil.formatBytes(used)); + swapInfo.put("available", FormatUtil.formatBytes(total - used)); + if (used == 0) { + swapInfo.put("usageRate", 0); + } else { + swapInfo.put("usageRate", df.format(used / (double) total * 100)); } + return swapInfo; + } - /** - * 获取内存信息 - * - * @param memory / - * @return / - */ - private Map getMemoryInfo(GlobalMemory memory) { - Map memoryInfo = new LinkedHashMap<>(); - memoryInfo.put("total", FormatUtil.formatBytes(memory.getTotal())); - memoryInfo.put("available", FormatUtil.formatBytes(memory.getAvailable())); - memoryInfo.put("used", FormatUtil.formatBytes(memory.getTotal() - memory.getAvailable())); - memoryInfo.put("usageRate", - df.format((memory.getTotal() - memory.getAvailable()) / (double)memory.getTotal() * 100)); - return memoryInfo; - } + /** + * 获取内存信息 + * + * @param memory / + * @return / + */ + private Map getMemoryInfo(GlobalMemory memory) { + Map memoryInfo = new LinkedHashMap<>(); + memoryInfo.put("total", FormatUtil.formatBytes(memory.getTotal())); + memoryInfo.put("available", FormatUtil.formatBytes(memory.getAvailable())); + memoryInfo.put("used", FormatUtil.formatBytes(memory.getTotal() - memory.getAvailable())); + memoryInfo.put("usageRate", + df.format((memory.getTotal() - memory.getAvailable()) / (double) memory.getTotal() * 100)); + return memoryInfo; + } - /** - * 获取Cpu相关信息 - * - * @param processor / - * @return / - */ - private Map getCpuInfo(CentralProcessor processor) { - Map cpuInfo = new LinkedHashMap<>(); - cpuInfo.put("name", processor.getProcessorIdentifier().getName()); - cpuInfo.put("package", processor.getPhysicalPackageCount() + "个物理CPU"); - cpuInfo.put("core", processor.getPhysicalProcessorCount() + "个物理核心"); - cpuInfo.put("coreNumber", processor.getPhysicalProcessorCount()); - cpuInfo.put("logic", processor.getLogicalProcessorCount() + "个逻辑CPU"); - // CPU信息 - long[] prevTicks = processor.getSystemCpuLoadTicks(); - // 默认等待300毫秒... - long time = 300; - Util.sleep(time); - long[] ticks = processor.getSystemCpuLoadTicks(); - long minCpuLoadTick = 1000; - while (Arrays.toString(prevTicks).equals(Arrays.toString(ticks)) && time < minCpuLoadTick) { - time += 25; - Util.sleep(25); - ticks = processor.getSystemCpuLoadTicks(); - } - long user = - ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()]; - long nice = - ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()]; - long sys = - ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()]; - long idle = - ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()]; - long ioWait = - ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()]; - long irq = - ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()]; - long softIrq = - ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()]; - long steal = - ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()]; - long totalCpu = user + nice + sys + idle + ioWait + irq + softIrq + steal; - cpuInfo.put("used", df.format(100d * user / totalCpu + 100d * sys / totalCpu)); - cpuInfo.put("idle", df.format(100d * idle / totalCpu)); - return cpuInfo; + /** + * 获取Cpu相关信息 + * + * @param processor / + * @return / + */ + private Map getCpuInfo(CentralProcessor processor) { + Map cpuInfo = new LinkedHashMap<>(); + cpuInfo.put("name", processor.getProcessorIdentifier().getName()); + cpuInfo.put("package", processor.getPhysicalPackageCount() + "个物理CPU"); + cpuInfo.put("core", processor.getPhysicalProcessorCount() + "个物理核心"); + cpuInfo.put("coreNumber", processor.getPhysicalProcessorCount()); + cpuInfo.put("logic", processor.getLogicalProcessorCount() + "个逻辑CPU"); + // CPU信息 + long[] prevTicks = processor.getSystemCpuLoadTicks(); + // 默认等待300毫秒... + long time = 300; + Util.sleep(time); + long[] ticks = processor.getSystemCpuLoadTicks(); + long minCpuLoadTick = 1000; + while (Arrays.toString(prevTicks).equals(Arrays.toString(ticks)) && time < minCpuLoadTick) { + time += 25; + Util.sleep(25); + ticks = processor.getSystemCpuLoadTicks(); } + long user = + ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()]; + long nice = + ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()]; + long sys = + ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()]; + long idle = + ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()]; + long ioWait = + ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()]; + long irq = + ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()]; + long softIrq = + ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()]; + long steal = + ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()]; + long totalCpu = user + nice + sys + idle + ioWait + irq + softIrq + steal; + cpuInfo.put("used", df.format(100d * user / totalCpu + 100d * sys / totalCpu)); + cpuInfo.put("idle", df.format(100d * idle / totalCpu)); + return cpuInfo; + } - /** - * 获取系统相关信息,系统、运行天数、系统IP - * - * @param os / - * @return / - */ - private Map getSystemInfo(OperatingSystem os) { - Map systemInfo = new LinkedHashMap<>(); - // jvm 运行时间 - long time = ManagementFactory.getRuntimeMXBean().getStartTime(); - Date date = new Date(time); - // 计算项目运行时间 - String formatBetween = DateUtil.formatBetween(date, new Date(), Level.HOUR); - // 系统信息 - systemInfo.put("os", os.toString()); - systemInfo.put("day", formatBetween); - systemInfo.put("ip", KitIPUtil.getLocalIp()); - return systemInfo; - } + /** + * 获取系统相关信息,系统、运行天数、系统IP + * + * @param os / + * @return / + */ + private Map getSystemInfo(OperatingSystem os) { + Map systemInfo = new LinkedHashMap<>(); + // jvm 运行时间 + long time = ManagementFactory.getRuntimeMXBean().getStartTime(); + Date date = new Date(time); + // 计算项目运行时间 + String formatBetween = DateUtil.formatBetween(date, new Date(), Level.HOUR); + // 系统信息 + systemInfo.put("os", os.toString()); + systemInfo.put("day", formatBetween); + systemInfo.put("ip", KitIPUtil.getLocalIp()); + return systemInfo; + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java index 337cdf16..1742dbe1 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java @@ -14,16 +14,16 @@ import org.springframework.stereotype.Service; @Service public class SystemOperationLogService { - @Autowired - private SystemOperationLogMapper systemOperationLogMapper; + @Autowired + private SystemOperationLogMapper systemOperationLogMapper; - /** - * 查询用户操作日志 - */ - public IPage searchUserLog(KitPageArgs pageArgs) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemOperationLogTb::getUsername, KitSecurityHelper.getCurrentUsername()); - Page page = new Page<>(pageArgs.getPage(), pageArgs.getSize()); - return systemOperationLogMapper.selectPage(page, wrapper); - } + /** + * 查询用户操作日志 + */ + public IPage searchUserLog(KitPageArgs pageArgs) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemOperationLogTb::getUsername, KitSecurityHelper.getCurrentUsername()); + Page page = new Page<>(pageArgs.getPage(), pageArgs.getSize()); + return systemOperationLogMapper.selectPage(page, wrapper); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOssStorageService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOssStorageService.java index 4d60ac4c..34696e7f 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOssStorageService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOssStorageService.java @@ -21,9 +21,9 @@ import cn.odboy.system.dal.model.request.SystemQueryStorageArgs; import cn.odboy.system.dal.model.response.SystemOssStorageVo; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; -import org.springframework.web.multipart.MultipartFile; import jakarta.servlet.http.HttpServletResponse; import java.util.List; +import org.springframework.web.multipart.MultipartFile; /** *

@@ -35,13 +35,13 @@ import java.util.List; */ public interface SystemOssStorageService extends IService { - KitPageResult searchOssStorage(SystemQueryStorageArgs args, Page page); + KitPageResult searchOssStorage(SystemQueryStorageArgs args, Page page); - List queryOssStorage(SystemQueryStorageArgs args); + List queryOssStorage(SystemQueryStorageArgs args); - String uploadFile(MultipartFile file); + String uploadFile(MultipartFile file); - void deleteFileByIds(Long[] ids); + void deleteFileByIds(Long[] ids); - void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args); + void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args); } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java index 241407d9..7a8c6a75 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java @@ -38,283 +38,283 @@ import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.quartz.CronExpression; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import jakarta.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; +import org.quartz.CronExpression; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemQuartzJobService { - @Autowired - private SystemQuartzJobMapper systemQuartzJobMapper; - @Autowired - private SystemQuartzLogMapper systemQuartzLogMapper; - @Autowired - private QuartzManage quartzManage; - @Autowired - private KitRedisHelper redisHelper; + @Autowired + private SystemQuartzJobMapper systemQuartzJobMapper; + @Autowired + private SystemQuartzLogMapper systemQuartzLogMapper; + @Autowired + private QuartzManage quartzManage; + @Autowired + private KitRedisHelper redisHelper; - /** - * 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义 - * - * @param beanName Bean名称 - */ - private void checkBean(String beanName) { - // 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类 - // 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。 - if (!KitSpringBeanHolder.getAllServiceBeanName().contains(beanName)) { - throw new BadRequestException("非法的 Bean,请重新输入!"); - } + /** + * 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义 + * + * @param beanName Bean名称 + */ + private void checkBean(String beanName) { + // 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类 + // 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。 + if (!KitSpringBeanHolder.getAllServiceBeanName().contains(beanName)) { + throw new BadRequestException("非法的 Bean,请重新输入!"); } + } - /** - * 创建 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void createJob(SystemQuartzJobVo args) { - if (args.getId() != null) { - throw new BadRequestException("无效参数id"); - } - // 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义 - checkBean(args.getBeanName()); - if (!CronExpression.isValidExpression(args.getCronExpression())) { - throw new BadRequestException("cron表达式格式错误"); - } - SystemQuartzJobTb record = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class); - systemQuartzJobMapper.insert(record); - quartzManage.addJob(args); + /** + * 创建 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void createJob(SystemQuartzJobVo args) { + if (args.getId() != null) { + throw new BadRequestException("无效参数id"); } + // 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义 + checkBean(args.getBeanName()); + if (!CronExpression.isValidExpression(args.getCronExpression())) { + throw new BadRequestException("cron表达式格式错误"); + } + SystemQuartzJobTb record = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class); + systemQuartzJobMapper.insert(record); + quartzManage.addJob(args); + } - /** - * 修改任务并重新调度 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateQuartzJobResumeCron(SystemUpdateQuartzJobArgs args) { - // 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义 - checkBean(args.getBeanName()); - if (!CronExpression.isValidExpression(args.getCronExpression())) { - throw new BadRequestException("cron表达式格式错误"); - } - if (StrUtil.isNotBlank(args.getSubTask())) { - List tasks = Arrays.asList(args.getSubTask().split("[,,]")); - if (tasks.contains(args.getId().toString())) { - throw new BadRequestException("子任务中不能添加当前任务ID"); - } - } - SystemQuartzJobTb jobTb = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class); - systemQuartzJobMapper.insertOrUpdate(jobTb); - SystemQuartzJobVo jobVo = KitBeanUtil.copyToClass(args, SystemQuartzJobVo.class); - quartzManage.updateJobCron(jobVo); + /** + * 修改任务并重新调度 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateQuartzJobResumeCron(SystemUpdateQuartzJobArgs args) { + // 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义 + checkBean(args.getBeanName()); + if (!CronExpression.isValidExpression(args.getCronExpression())) { + throw new BadRequestException("cron表达式格式错误"); } + if (StrUtil.isNotBlank(args.getSubTask())) { + List tasks = Arrays.asList(args.getSubTask().split("[,,]")); + if (tasks.contains(args.getId().toString())) { + throw new BadRequestException("子任务中不能添加当前任务ID"); + } + } + SystemQuartzJobTb jobTb = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class); + systemQuartzJobMapper.insertOrUpdate(jobTb); + SystemQuartzJobVo jobVo = KitBeanUtil.copyToClass(args, SystemQuartzJobVo.class); + quartzManage.updateJobCron(jobVo); + } - /** - * 更改定时任务状态 - * - * @param quartzJob / - */ - @Transactional(rollbackFor = Exception.class) - public void switchQuartzJobStatus(SystemQuartzJobVo quartzJob) { - // 置换暂停状态 - if (quartzJob.getIsPause()) { - quartzManage.resumeJob(quartzJob); - quartzJob.setIsPause(false); - } else { - quartzManage.pauseJob(quartzJob); - quartzJob.setIsPause(true); - } - SystemQuartzJobTb quartzJobTb = KitBeanUtil.copyToClass(quartzJob, SystemQuartzJobTb.class); - systemQuartzJobMapper.insertOrUpdate(quartzJobTb); + /** + * 更改定时任务状态 + * + * @param quartzJob / + */ + @Transactional(rollbackFor = Exception.class) + public void switchQuartzJobStatus(SystemQuartzJobVo quartzJob) { + // 置换暂停状态 + if (quartzJob.getIsPause()) { + quartzManage.resumeJob(quartzJob); + quartzJob.setIsPause(false); + } else { + quartzManage.pauseJob(quartzJob); + quartzJob.setIsPause(true); } + SystemQuartzJobTb quartzJobTb = KitBeanUtil.copyToClass(quartzJob, SystemQuartzJobTb.class); + systemQuartzJobMapper.insertOrUpdate(quartzJobTb); + } - /** - * 立即执行定时任务 - * - * @param quartzJob / - */ - public void startQuartzJob(SystemQuartzJobVo quartzJob) { - quartzManage.runJobNow(quartzJob); - } + /** + * 立即执行定时任务 + * + * @param quartzJob / + */ + public void startQuartzJob(SystemQuartzJobVo quartzJob) { + quartzManage.runJobNow(quartzJob); + } - /** - * 删除任务 - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteJobByIds(Set ids) { - for (Long id : ids) { - SystemQuartzJobTb quartzJob = systemQuartzJobMapper.selectById(id); - quartzManage.deleteJob(quartzJob); - systemQuartzJobMapper.deleteById(quartzJob); - } + /** + * 删除任务 + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteJobByIds(Set ids) { + for (Long id : ids) { + SystemQuartzJobTb quartzJob = systemQuartzJobMapper.selectById(id); + quartzManage.deleteJob(quartzJob); + systemQuartzJobMapper.deleteById(quartzJob); } + } - /** - * 执行子任务 - * - * @param tasks / - * @throws InterruptedException / - */ - @Transactional(rollbackFor = Exception.class) - public void startSubQuartJob(String[] tasks) throws InterruptedException { - for (String id : tasks) { - if (StrUtil.isBlank(id)) { - // 如果是手动清除子任务id, 会出现id为空字符串的问题 - continue; - } - SystemQuartzJobVo quartzJob = systemQuartzJobMapper.selectVoById(id); - if (quartzJob == null) { - // 防止子任务不存在 - continue; - } - // 执行任务 - String uuid = IdUtil.simpleUUID(); - quartzJob.setUuid(uuid); - // 执行任务 - startQuartzJob(quartzJob); - // 获取执行状态, 如果执行失败则停止后面的子任务执行 - Boolean result = redisHelper.get(uuid, Boolean.class); - while (result == null) { - // 休眠5秒, 再次获取子任务执行情况 - Thread.sleep(5000); - result = redisHelper.get(uuid, Boolean.class); - } - if (!result) { - redisHelper.del(uuid); - break; - } - } + /** + * 执行子任务 + * + * @param tasks / + * @throws InterruptedException / + */ + @Transactional(rollbackFor = Exception.class) + public void startSubQuartJob(String[] tasks) throws InterruptedException { + for (String id : tasks) { + if (StrUtil.isBlank(id)) { + // 如果是手动清除子任务id, 会出现id为空字符串的问题 + continue; + } + SystemQuartzJobVo quartzJob = systemQuartzJobMapper.selectVoById(id); + if (quartzJob == null) { + // 防止子任务不存在 + continue; + } + // 执行任务 + String uuid = IdUtil.simpleUUID(); + quartzJob.setUuid(uuid); + // 执行任务 + startQuartzJob(quartzJob); + // 获取执行状态, 如果执行失败则停止后面的子任务执行 + Boolean result = redisHelper.get(uuid, Boolean.class); + while (result == null) { + // 休眠5秒, 再次获取子任务执行情况 + Thread.sleep(5000); + result = redisHelper.get(uuid, Boolean.class); + } + if (!result) { + redisHelper.del(uuid); + break; + } } + } - /** - * 分页查询 - * - * @param args 条件 - * @param page 分页参数 - * @return / - */ - public KitPageResult searchQuartzJobByArgs(SystemQueryQuartzJobArgs args, - Page page) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQuartzJobQueryParams(args, wrapper); - return KitPageUtil.toPage(systemQuartzJobMapper.selectPage(page, wrapper)); - } + /** + * 分页查询 + * + * @param args 条件 + * @param page 分页参数 + * @return / + */ + public KitPageResult searchQuartzJobByArgs(SystemQueryQuartzJobArgs args, + Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQuartzJobQueryParams(args, wrapper); + return KitPageUtil.toPage(systemQuartzJobMapper.selectPage(page, wrapper)); + } - private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args, - LambdaQueryWrapper wrapper) { - KitValidUtil.notNull(args); - wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName, args.getJobName()); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); - } - wrapper.orderByDesc(SystemQuartzJobTb::getId); + private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args, + LambdaQueryWrapper wrapper) { + KitValidUtil.notNull(args); + wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName, args.getJobName()); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); } + wrapper.orderByDesc(SystemQuartzJobTb::getId); + } - private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, - LambdaQueryWrapper wrapper) { - if (args != null) { - wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName()); - wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess()); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemQuartzLogTb::getCreateTime, args.getCreateTime().get(0), - args.getCreateTime().get(1)); - } - } - wrapper.orderByDesc(SystemQuartzLogTb::getId); + private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, + LambdaQueryWrapper wrapper) { + if (args != null) { + wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName()); + wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess()); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemQuartzLogTb::getCreateTime, args.getCreateTime().get(0), + args.getCreateTime().get(1)); + } } + wrapper.orderByDesc(SystemQuartzLogTb::getId); + } - /** - * 分页查询日志 - * - * @param args 条件 - * @param page 分页参数 - * @return / - */ - public KitPageResult searchQuartzLogByArgs(SystemQueryQuartzJobArgs args, - Page page) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQuartzLogQueryParams(args, wrapper); - return KitPageUtil.toPage(systemQuartzLogMapper.selectPage(page, wrapper)); - } + /** + * 分页查询日志 + * + * @param args 条件 + * @param page 分页参数 + * @return / + */ + public KitPageResult searchQuartzLogByArgs(SystemQueryQuartzJobArgs args, + Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQuartzLogQueryParams(args, wrapper); + return KitPageUtil.toPage(systemQuartzLogMapper.selectPage(page, wrapper)); + } - /** - * 查询全部 - * - * @param args 条件 - * @return / - */ - public List queryQuartzJobByArgs(SystemQueryQuartzJobArgs args) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQuartzJobQueryParams(args, wrapper); - return systemQuartzJobMapper.selectList(wrapper); - } + /** + * 查询全部 + * + * @param args 条件 + * @return / + */ + public List queryQuartzJobByArgs(SystemQueryQuartzJobArgs args) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQuartzJobQueryParams(args, wrapper); + return systemQuartzJobMapper.selectList(wrapper); + } - /** - * 查询全部 - * - * @param args 条件 - * @return / - */ - public List queryQuartzLogByArgs(SystemQueryQuartzJobArgs args) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQuartzLogQueryParams(args, wrapper); - return systemQuartzLogMapper.selectList(wrapper); - } + /** + * 查询全部 + * + * @param args 条件 + * @return / + */ + public List queryQuartzLogByArgs(SystemQueryQuartzJobArgs args) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQuartzLogQueryParams(args, wrapper); + return systemQuartzLogMapper.selectList(wrapper); + } - public SystemQuartzJobVo getQuartzJobById(Long id) { - return KitBeanUtil.copyToClass(systemQuartzJobMapper.selectById(id), SystemQuartzJobVo.class); - } + public SystemQuartzJobVo getQuartzJobById(Long id) { + return KitBeanUtil.copyToClass(systemQuartzJobMapper.selectById(id), SystemQuartzJobVo.class); + } - public List listEnableQuartzJob() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemQuartzJobTb::getIsPause, 0); - return KitBeanUtil.copyToList(systemQuartzJobMapper.selectList(wrapper), SystemQuartzJobVo.class); - } + public List listEnableQuartzJob() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemQuartzJobTb::getIsPause, 0); + return KitBeanUtil.copyToList(systemQuartzJobMapper.selectList(wrapper), SystemQuartzJobVo.class); + } - public void exportQuartzJobXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) { - List systemQuartzJobTbs = this.queryQuartzJobByArgs(args); - List rowVos = new ArrayList<>(); - for (SystemQuartzJobTb dataObject : systemQuartzJobTbs) { - SystemQuartzJobExportRowVo rowVo = new SystemQuartzJobExportRowVo(); - rowVo.setJobName(dataObject.getJobName()); - rowVo.setBeanName(dataObject.getBeanName()); - rowVo.setMethodName(dataObject.getMethodName()); - rowVo.setParams(dataObject.getParams()); - rowVo.setCronExpression(dataObject.getCronExpression()); - rowVo.setIsPause(dataObject.getIsPause() ? "暂停中" : "运行中"); - rowVo.setDescription(dataObject.getDescription()); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - KitExcelExporter.exportSimple(response, "定时任务数据", SystemQuartzJobExportRowVo.class, rowVos); + public void exportQuartzJobXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) { + List systemQuartzJobTbs = this.queryQuartzJobByArgs(args); + List rowVos = new ArrayList<>(); + for (SystemQuartzJobTb dataObject : systemQuartzJobTbs) { + SystemQuartzJobExportRowVo rowVo = new SystemQuartzJobExportRowVo(); + rowVo.setJobName(dataObject.getJobName()); + rowVo.setBeanName(dataObject.getBeanName()); + rowVo.setMethodName(dataObject.getMethodName()); + rowVo.setParams(dataObject.getParams()); + rowVo.setCronExpression(dataObject.getCronExpression()); + rowVo.setIsPause(dataObject.getIsPause() ? "暂停中" : "运行中"); + rowVo.setDescription(dataObject.getDescription()); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); } + KitExcelExporter.exportSimple(response, "定时任务数据", SystemQuartzJobExportRowVo.class, rowVos); + } - public void exportQuartzLogXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) { - List systemQuartzLogTbs = this.queryQuartzLogByArgs(args); - List rowVos = new ArrayList<>(); - for (SystemQuartzLogTb dataObject : systemQuartzLogTbs) { - SystemQuartzLogExportRowVo rowVo = new SystemQuartzLogExportRowVo(); - rowVo.setJobName(dataObject.getJobName()); - rowVo.setBeanName(dataObject.getBeanName()); - rowVo.setMethodName(dataObject.getMethodName()); - rowVo.setParams(dataObject.getParams()); - rowVo.setCronExpression(dataObject.getCronExpression()); - rowVo.setExceptionDetail(dataObject.getExceptionDetail()); - rowVo.setTime(dataObject.getTime()); - rowVo.setStatus(dataObject.getIsSuccess() ? "成功" : "失败"); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - KitExcelExporter.exportSimple(response, "定时任务日志数据", SystemQuartzLogExportRowVo.class, rowVos); + public void exportQuartzLogXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) { + List systemQuartzLogTbs = this.queryQuartzLogByArgs(args); + List rowVos = new ArrayList<>(); + for (SystemQuartzLogTb dataObject : systemQuartzLogTbs) { + SystemQuartzLogExportRowVo rowVo = new SystemQuartzLogExportRowVo(); + rowVo.setJobName(dataObject.getJobName()); + rowVo.setBeanName(dataObject.getBeanName()); + rowVo.setMethodName(dataObject.getMethodName()); + rowVo.setParams(dataObject.getParams()); + rowVo.setCronExpression(dataObject.getCronExpression()); + rowVo.setExceptionDetail(dataObject.getExceptionDetail()); + rowVo.setTime(dataObject.getTime()); + rowVo.setStatus(dataObject.getIsSuccess() ? "成功" : "失败"); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); } + KitExcelExporter.exportSimple(response, "定时任务日志数据", SystemQuartzLogExportRowVo.class, rowVos); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java index 7285175e..172dbdb0 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java @@ -21,67 +21,67 @@ import cn.odboy.system.dal.dataobject.SystemRoleDeptTb; import cn.odboy.system.dal.mysql.SystemDeptMapper; import cn.odboy.system.dal.mysql.SystemRoleDeptMapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemRoleDeptService { - @Autowired - private SystemRoleDeptMapper systemRoleDeptMapper; - @Autowired - private SystemDeptMapper systemDeptMapper; + @Autowired + private SystemRoleDeptMapper systemRoleDeptMapper; + @Autowired + private SystemDeptMapper systemDeptMapper; - @Transactional(rollbackFor = Exception.class) - public void batchDeleteRoleDept(Set roleIds) { - if (CollUtil.isNotEmpty(roleIds)) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemRoleDeptTb::getRoleId, roleIds); - systemRoleDeptMapper.delete(wrapper); - } + @Transactional(rollbackFor = Exception.class) + public void batchDeleteRoleDept(Set roleIds) { + if (CollUtil.isNotEmpty(roleIds)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemRoleDeptTb::getRoleId, roleIds); + systemRoleDeptMapper.delete(wrapper); + } + } + + @Transactional(rollbackFor = Exception.class) + public void batchInsertRoleDept(Set depts, Long id) { + if (CollUtil.isNotEmpty(depts)) { + List records = new ArrayList<>(); + for (SystemDeptTb dept : depts) { + SystemRoleDeptTb record = new SystemRoleDeptTb(); + record.setRoleId(id); + record.setDeptId(dept.getId()); + records.add(record); + } + systemRoleDeptMapper.insert(records); + } + } + + /** + * 根据部门ID统计角色数量 + * + * @param deptIds 部门ID集合 + * @return / + */ + public Long countRoleByDeptIds(Set deptIds) { + if (CollUtil.isEmpty(deptIds)) { + return 0L; } - @Transactional(rollbackFor = Exception.class) - public void batchInsertRoleDept(Set depts, Long id) { - if (CollUtil.isNotEmpty(depts)) { - List records = new ArrayList<>(); - for (SystemDeptTb dept : depts) { - SystemRoleDeptTb record = new SystemRoleDeptTb(); - record.setRoleId(id); - record.setDeptId(dept.getId()); - records.add(record); - } - systemRoleDeptMapper.insert(records); - } - } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemRoleDeptTb::getDeptId, deptIds); + return systemRoleDeptMapper.selectCount(wrapper); + } - /** - * 根据部门ID统计角色数量 - * - * @param deptIds 部门ID集合 - * @return / - */ - public Long countRoleByDeptIds(Set deptIds) { - if (CollUtil.isEmpty(deptIds)) { - return 0L; - } - - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemRoleDeptTb::getDeptId, deptIds); - return systemRoleDeptMapper.selectCount(wrapper); - } - - /** - * 根据角色id查询部门信息 - * - * @param roleId 角色id - * @return / - */ - public Set listUserDeptByRoleId(Long roleId) { - return systemRoleDeptMapper.listUserDeptByRoleId(roleId); - } + /** + * 根据角色id查询部门信息 + * + * @param roleId 角色id + * @return / + */ + public Set listUserDeptByRoleId(Long roleId) { + return systemRoleDeptMapper.listUserDeptByRoleId(roleId); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleMenuService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleMenuService.java index c86ef87b..2dde9009 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleMenuService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleMenuService.java @@ -23,82 +23,82 @@ import cn.odboy.system.dal.mysql.SystemMenuMapper; import cn.odboy.system.dal.mysql.SystemRoleMenuMapper; import cn.odboy.util.KitBeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemRoleMenuService { - @Autowired - private SystemRoleMenuMapper systemRoleMenuMapper; - @Autowired - private SystemMenuMapper systemMenuMapper; + @Autowired + private SystemRoleMenuMapper systemRoleMenuMapper; + @Autowired + private SystemMenuMapper systemMenuMapper; - @Transactional(rollbackFor = Exception.class) - public void deleteRoleMenuByRoleId(Long roleId) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemRoleMenuTb::getRoleId, roleId); - systemRoleMenuMapper.delete(wrapper); + @Transactional(rollbackFor = Exception.class) + public void deleteRoleMenuByRoleId(Long roleId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemRoleMenuTb::getRoleId, roleId); + systemRoleMenuMapper.delete(wrapper); + } + + @Transactional(rollbackFor = Exception.class) + public void batchInsertRoleMenu(Set menus, Long roleId) { + if (CollUtil.isNotEmpty(menus)) { + List records = new ArrayList<>(); + for (SystemMenuVo menu : menus) { + SystemRoleMenuTb record = new SystemRoleMenuTb(); + record.setMenuId(menu.getId()); + record.setRoleId(roleId); + records.add(record); + } + systemRoleMenuMapper.insert(records); } + } - @Transactional(rollbackFor = Exception.class) - public void batchInsertRoleMenu(Set menus, Long roleId) { - if (CollUtil.isNotEmpty(menus)) { - List records = new ArrayList<>(); - for (SystemMenuVo menu : menus) { - SystemRoleMenuTb record = new SystemRoleMenuTb(); - record.setMenuId(menu.getId()); - record.setRoleId(roleId); - records.add(record); - } - systemRoleMenuMapper.insert(records); - } + @Transactional(rollbackFor = Exception.class) + public void batchDeleteRoleMenu(Set roleIds) { + if (CollUtil.isNotEmpty(roleIds)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemRoleMenuTb::getRoleId, roleIds); + systemRoleMenuMapper.delete(wrapper); } + } - @Transactional(rollbackFor = Exception.class) - public void batchDeleteRoleMenu(Set roleIds) { - if (CollUtil.isNotEmpty(roleIds)) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemRoleMenuTb::getRoleId, roleIds); - systemRoleMenuMapper.delete(wrapper); - } + public LinkedHashSet queryMenuByRoleIds(Set roleIds) { + if (CollUtil.isEmpty(roleIds)) { + return new LinkedHashSet<>(); } - - public LinkedHashSet queryMenuByRoleIds(Set roleIds) { - if (CollUtil.isEmpty(roleIds)) { - return new LinkedHashSet<>(); - } - LambdaQueryWrapper roleMenuWrapper = new LambdaQueryWrapper<>(); - roleMenuWrapper.in(SystemRoleMenuTb::getRoleId, roleIds); - List menuIds = systemRoleMenuMapper.selectList(roleMenuWrapper).stream().map(SystemRoleMenuTb::getMenuId) - .collect(Collectors.toList()); - if (CollUtil.isEmpty(menuIds)) { - return new LinkedHashSet<>(); - } - LambdaQueryWrapper menuWrapper = new LambdaQueryWrapper<>(); - menuWrapper.in(SystemMenuTb::getId, menuIds); - // 排除"按钮" - menuWrapper.ne(SystemMenuTb::getType, 2); - menuWrapper.orderByAsc(SystemMenuTb::getMenuSort); - - List systemMenuTbs = systemMenuMapper.selectList(menuWrapper); - List systemMenuVos = KitBeanUtil.copyToList(systemMenuTbs, SystemMenuVo.class); - return new LinkedHashSet<>(systemMenuVos); + LambdaQueryWrapper roleMenuWrapper = new LambdaQueryWrapper<>(); + roleMenuWrapper.in(SystemRoleMenuTb::getRoleId, roleIds); + List menuIds = systemRoleMenuMapper.selectList(roleMenuWrapper).stream().map(SystemRoleMenuTb::getMenuId) + .collect(Collectors.toList()); + if (CollUtil.isEmpty(menuIds)) { + return new LinkedHashSet<>(); } + LambdaQueryWrapper menuWrapper = new LambdaQueryWrapper<>(); + menuWrapper.in(SystemMenuTb::getId, menuIds); + // 排除"按钮" + menuWrapper.ne(SystemMenuTb::getType, 2); + menuWrapper.orderByAsc(SystemMenuTb::getMenuSort); - @Transactional(rollbackFor = Exception.class) - public void deleteRoleMenuByMenuIds(List menuIds) { - if (CollUtil.isEmpty(menuIds)) { - return; - } - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemRoleMenuTb::getMenuId, menuIds); - systemRoleMenuMapper.delete(wrapper); + List systemMenuTbs = systemMenuMapper.selectList(menuWrapper); + List systemMenuVos = KitBeanUtil.copyToList(systemMenuTbs, SystemMenuVo.class); + return new LinkedHashSet<>(systemMenuVos); + } + + @Transactional(rollbackFor = Exception.class) + public void deleteRoleMenuByMenuIds(List menuIds) { + if (CollUtil.isEmpty(menuIds)) { + return; } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemRoleMenuTb::getMenuId, menuIds); + systemRoleMenuMapper.delete(wrapper); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java index c9d52fcd..71cb3033 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java @@ -36,9 +36,6 @@ import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import jakarta.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.Collections; @@ -46,254 +43,257 @@ import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemRoleService { - @Autowired - private SystemRoleMapper systemRoleMapper; - @Autowired - private SystemRoleMenuService systemRoleMenuService; - @Autowired - private SystemRoleDeptService systemRoleDeptService; - @Autowired - private SystemUserRoleService systemUserRoleService; + @Autowired + private SystemRoleMapper systemRoleMapper; + @Autowired + private SystemRoleMenuService systemRoleMenuService; + @Autowired + private SystemRoleDeptService systemRoleDeptService; + @Autowired + private SystemUserRoleService systemUserRoleService; - /** - * 创建 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveRole(SystemCreateRoleArgs args) { - checkRoleLevels(args.getLevel()); - if (this.countRoleByName(args.getName()) > 0) { - throw new BadRequestException("角色名称已存在"); - } - SystemRoleTb roleTb = KitBeanUtil.copyToClass(args, SystemRoleTb.class); - systemRoleMapper.insert(roleTb); - // 判断是否有部门数据, 若有, 则需创建关联 - if (CollUtil.isNotEmpty(args.getDepts())) { - systemRoleDeptService.batchInsertRoleDept(args.getDepts(), roleTb.getId()); - } + /** + * 创建 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveRole(SystemCreateRoleArgs args) { + checkRoleLevels(args.getLevel()); + if (this.countRoleByName(args.getName()) > 0) { + throw new BadRequestException("角色名称已存在"); } + SystemRoleTb roleTb = KitBeanUtil.copyToClass(args, SystemRoleTb.class); + systemRoleMapper.insert(roleTb); + // 判断是否有部门数据, 若有, 则需创建关联 + if (CollUtil.isNotEmpty(args.getDepts())) { + systemRoleDeptService.batchInsertRoleDept(args.getDepts(), roleTb.getId()); + } + } - private SystemRoleTb getRoleByName(String name) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemRoleTb::getName, name); - return systemRoleMapper.selectOne(wrapper); - } + private SystemRoleTb getRoleByName(String name) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemRoleTb::getName, name); + return systemRoleMapper.selectOne(wrapper); + } - private long countRoleByName(String name) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemRoleTb::getName, name); - return systemRoleMapper.selectCount(wrapper); - } + private long countRoleByName(String name) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemRoleTb::getName, name); + return systemRoleMapper.selectCount(wrapper); + } - /** - * 修改 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateRoleById(SystemRoleVo args) { - checkRoleLevels(args.getLevel()); - SystemRoleTb role = this.getRoleTbById(args.getId()); - SystemRoleTb role1 = this.getRoleByName(args.getName()); - if (role1 != null && !role1.getId().equals(role.getId())) { - throw new BadRequestException("角色名称已存在"); - } - role.setName(args.getName()); - role.setDescription(args.getDescription()); - role.setDataScope(args.getDataScope()); - role.setLevel(args.getLevel()); - // 更新 - systemRoleMapper.insertOrUpdate(role); - // 删除关联部门数据 - systemRoleDeptService.batchDeleteRoleDept(Collections.singleton(args.getId())); - // 判断是否有部门数据, 若有, 则需更新关联 - if (CollUtil.isNotEmpty(args.getDepts())) { - systemRoleDeptService.batchInsertRoleDept(args.getDepts(), args.getId()); - } + /** + * 修改 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateRoleById(SystemRoleVo args) { + checkRoleLevels(args.getLevel()); + SystemRoleTb role = this.getRoleTbById(args.getId()); + SystemRoleTb role1 = this.getRoleByName(args.getName()); + if (role1 != null && !role1.getId().equals(role.getId())) { + throw new BadRequestException("角色名称已存在"); } + role.setName(args.getName()); + role.setDescription(args.getDescription()); + role.setDataScope(args.getDataScope()); + role.setLevel(args.getLevel()); + // 更新 + systemRoleMapper.insertOrUpdate(role); + // 删除关联部门数据 + systemRoleDeptService.batchDeleteRoleDept(Collections.singleton(args.getId())); + // 判断是否有部门数据, 若有, 则需更新关联 + if (CollUtil.isNotEmpty(args.getDepts())) { + systemRoleDeptService.batchInsertRoleDept(args.getDepts(), args.getId()); + } + } - private SystemRoleTb getRoleTbById(Long id) { - return systemRoleMapper.selectById(id); - } + private SystemRoleTb getRoleTbById(Long id) { + return systemRoleMapper.selectById(id); + } - /** - * 修改绑定的菜单 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateBindMenuById(SystemRoleVo args) { - SystemRoleTb role = systemRoleMapper.selectById(args.getId()); - checkRoleLevels(role.getLevel()); - // 更新菜单 - systemRoleMenuService.deleteRoleMenuByRoleId(role.getId()); - // 判断是否为空 - Set menus = args.getMenus(); - if (CollUtil.isNotEmpty(menus)) { - systemRoleMenuService.batchInsertRoleMenu(menus, role.getId()); - } + /** + * 修改绑定的菜单 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateBindMenuById(SystemRoleVo args) { + SystemRoleTb role = systemRoleMapper.selectById(args.getId()); + checkRoleLevels(role.getLevel()); + // 更新菜单 + systemRoleMenuService.deleteRoleMenuByRoleId(role.getId()); + // 判断是否为空 + Set menus = args.getMenus(); + if (CollUtil.isNotEmpty(menus)) { + systemRoleMenuService.batchInsertRoleMenu(menus, role.getId()); } + } - /** - * 删除 - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteRoleByIds(Set ids) { - List roleLevels = systemRoleMapper.selectByIds(ids).stream().map(SystemRoleTb::getLevel).distinct() - .collect(Collectors.toList()); - for (Integer roleLevel : roleLevels) { - checkRoleLevels(roleLevel); - } - // 验证是否被用户关联 - this.verifyBindRelationByIds(ids); - // 删除角色 - systemRoleMapper.deleteByIds(ids); - // 删除角色部门关联数据、角色菜单关联数据 - systemRoleDeptService.batchDeleteRoleDept(ids); - systemRoleMenuService.batchDeleteRoleMenu(ids); + /** + * 删除 + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteRoleByIds(Set ids) { + List roleLevels = systemRoleMapper.selectByIds(ids).stream().map(SystemRoleTb::getLevel).distinct() + .collect(Collectors.toList()); + for (Integer roleLevel : roleLevels) { + checkRoleLevels(roleLevel); } + // 验证是否被用户关联 + this.verifyBindRelationByIds(ids); + // 删除角色 + systemRoleMapper.deleteByIds(ids); + // 删除角色部门关联数据、角色菜单关联数据 + systemRoleDeptService.batchDeleteRoleDept(ids); + systemRoleMenuService.batchDeleteRoleMenu(ids); + } - /** - * 查询全部角色 - */ - public List listAllRole() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.orderByAsc(SystemRoleTb::getLevel); - return systemRoleMapper.selectList(wrapper); - } + /** + * 查询全部角色 + */ + public List listAllRole() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.orderByAsc(SystemRoleTb::getLevel); + return systemRoleMapper.selectList(wrapper); + } - /** - * 根据条件查询全部角色 - * - * @param args 条件 - * @param rolePage 分页参数 - * @return / - */ - public List queryRoleByArgs(SystemQueryRoleArgs args, Page rolePage) { - KitValidUtil.notNull(args); - // 查询角色基本信息 - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemRoleTb::getName, args.getBlurry()).or() - .like(SystemRoleTb::getDescription, args.getBlurry())); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); - } - wrapper.orderByAsc(SystemRoleTb::getLevel); - List roles; - if (rolePage == null) { - roles = systemRoleMapper.selectList(wrapper); - } else { - Page page = systemRoleMapper.selectPage(rolePage, wrapper); - roles = page.getRecords(); - } - return roles.stream().map(systemUserRoleService::convertToRoleVo).collect(Collectors.toList()); + /** + * 根据条件查询全部角色 + * + * @param args 条件 + * @param rolePage 分页参数 + * @return / + */ + public List queryRoleByArgs(SystemQueryRoleArgs args, Page rolePage) { + KitValidUtil.notNull(args); + // 查询角色基本信息 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemRoleTb::getName, args.getBlurry()).or() + .like(SystemRoleTb::getDescription, args.getBlurry())); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); } + wrapper.orderByAsc(SystemRoleTb::getLevel); + List roles; + if (rolePage == null) { + roles = systemRoleMapper.selectList(wrapper); + } else { + Page page = systemRoleMapper.selectPage(rolePage, wrapper); + roles = page.getRecords(); + } + return roles.stream().map(systemUserRoleService::convertToRoleVo).collect(Collectors.toList()); + } - /** - * 分页查询角色 - * - * @param args 条件 - * @param page 分页条件 - * @return / - */ - public KitPageResult searchRoleByArgs(SystemQueryRoleArgs args, Page page) { - List roles = this.queryRoleByArgs(args, page); - Long total = this.countRoleByArgs(args); - return KitPageUtil.toPage(roles, total); - } + /** + * 分页查询角色 + * + * @param args 条件 + * @param page 分页条件 + * @return / + */ + public KitPageResult searchRoleByArgs(SystemQueryRoleArgs args, Page page) { + List roles = this.queryRoleByArgs(args, page); + Long total = this.countRoleByArgs(args); + return KitPageUtil.toPage(roles, total); + } - /** - * 获取用户权限信息 - * - * @param user 用户信息 - * @return 权限信息 - */ - public List buildUserRolePermissions(SystemUserVo user) { - Set permissions = new HashSet<>(); - // 如果是管理员直接返回 - if (user.getIsAdmin()) { - permissions.add("admin"); - return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); - } - List roles = systemUserRoleService.queryRoleVoByUsersId(user.getId()); - permissions = roles.stream().flatMap(role -> role.getMenus().stream()).map(SystemMenuVo::getPermission) - .filter(StrUtil::isNotBlank).collect(Collectors.toSet()); - return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); + /** + * 获取用户权限信息 + * + * @param user 用户信息 + * @return 权限信息 + */ + public List buildUserRolePermissions(SystemUserVo user) { + Set permissions = new HashSet<>(); + // 如果是管理员直接返回 + if (user.getIsAdmin()) { + permissions.add("admin"); + return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); } + List roles = systemUserRoleService.queryRoleVoByUsersId(user.getId()); + permissions = roles.stream().flatMap(role -> role.getMenus().stream()).map(SystemMenuVo::getPermission) + .filter(StrUtil::isNotBlank).collect(Collectors.toSet()); + return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); + } - /** - * 验证是否被用户关联 - * - * @param ids / - */ - public void verifyBindRelationByIds(Set ids) { - if (systemUserRoleService.countUserByRoleIds(ids) > 0) { - throw new BadRequestException("所选角色存在用户关联, 请解除关联再试!"); - } + /** + * 验证是否被用户关联 + * + * @param ids / + */ + public void verifyBindRelationByIds(Set ids) { + if (systemUserRoleService.countUserByRoleIds(ids) > 0) { + throw new BadRequestException("所选角色存在用户关联, 请解除关联再试!"); } + } - public Long countRoleByArgs(SystemQueryRoleArgs args) { - KitValidUtil.notNull(args); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemRoleTb::getName, args.getBlurry()).or() - .like(SystemRoleTb::getDescription, args.getBlurry())); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); - } - return systemRoleMapper.selectCount(wrapper); + public Long countRoleByArgs(SystemQueryRoleArgs args) { + KitValidUtil.notNull(args); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemRoleTb::getName, args.getBlurry()).or() + .like(SystemRoleTb::getDescription, args.getBlurry())); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); } + return systemRoleMapper.selectCount(wrapper); + } - public SystemRoleVo getRoleById(Long id) { - SystemRoleTb roleTb = systemRoleMapper.selectById(id); - if (roleTb == null) { - return null; - } - return systemUserRoleService.convertToRoleVo(roleTb); + public SystemRoleVo getRoleById(Long id) { + SystemRoleTb roleTb = systemRoleMapper.selectById(id); + if (roleTb == null) { + return null; } + return systemUserRoleService.convertToRoleVo(roleTb); + } - public Dict getCurrentUserRoleLevel() { - return Dict.create().set("level", checkRoleLevels(null)); - } + public Dict getCurrentUserRoleLevel() { + return Dict.create().set("level", checkRoleLevels(null)); + } - /** - * 检查用户的角色级别 - * - * @return / - */ - private int checkRoleLevels(Integer level) { - List levels = systemUserRoleService.queryRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream() - .map(SystemRoleVo::getLevel).collect(Collectors.toList()); - int min = Collections.min(levels); - if (level != null) { - if (level < min) { - throw new BadRequestException("权限不足, 你的角色级别:" + min + ", 低于操作的角色级别:" + level); - } - } - return min; + /** + * 检查用户的角色级别 + * + * @return / + */ + private int checkRoleLevels(Integer level) { + List levels = systemUserRoleService.queryRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream() + .map(SystemRoleVo::getLevel).collect(Collectors.toList()); + int min = Collections.min(levels); + if (level != null) { + if (level < min) { + throw new BadRequestException("权限不足, 你的角色级别:" + min + ", 低于操作的角色级别:" + level); + } } + return min; + } - public void exportRoleXlsx(HttpServletResponse response, SystemQueryRoleArgs args) { - List systemRoleVos = this.queryRoleByArgs(args, null); - List rowVos = new ArrayList<>(); - for (SystemRoleVo dataObject : systemRoleVos) { - SystemRoleExportRowVo rowVo = new SystemRoleExportRowVo(); - rowVo.setName(dataObject.getName()); - rowVo.setLevel(dataObject.getLevel()); - rowVo.setDescription(dataObject.getDescription()); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - KitExcelExporter.exportSimple(response, "部门数据", SystemRoleExportRowVo.class, rowVos); + public void exportRoleXlsx(HttpServletResponse response, SystemQueryRoleArgs args) { + List systemRoleVos = this.queryRoleByArgs(args, null); + List rowVos = new ArrayList<>(); + for (SystemRoleVo dataObject : systemRoleVos) { + SystemRoleExportRowVo rowVo = new SystemRoleExportRowVo(); + rowVo.setName(dataObject.getName()); + rowVo.setLevel(dataObject.getLevel()); + rowVo.setDescription(dataObject.getDescription()); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); } + KitExcelExporter.exportSimple(response, "部门数据", SystemRoleExportRowVo.class, rowVos); + } - public List listByIds(Set roleIds) { - return systemRoleMapper.selectByIds(roleIds); - } + public List listByIds(Set roleIds) { + return systemRoleMapper.selectByIds(roleIds); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java index 986789d2..e051ae16 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java @@ -3,19 +3,19 @@ package cn.odboy.system.service; import cn.odboy.system.dal.dataobject.SystemUserTb; import cn.odboy.system.dal.mysql.SystemUserMapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Set; @Service public class SystemUserDeptService { - @Autowired - private SystemUserMapper systemUserMapper; + @Autowired + private SystemUserMapper systemUserMapper; - public long countUserByDeptIds(Set deptIds) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemUserTb::getDeptId, deptIds); - return systemUserMapper.selectCount(wrapper); - } + public long countUserByDeptIds(Set deptIds) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemUserTb::getDeptId, deptIds); + return systemUserMapper.selectCount(wrapper); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java index c0b9057e..ed5c0bab 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java @@ -20,58 +20,58 @@ import cn.odboy.system.dal.dataobject.SystemJobTb; import cn.odboy.system.dal.dataobject.SystemUserJobTb; import cn.odboy.system.dal.mysql.SystemUserJobMapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemUserJobService { - @Autowired - private SystemUserJobMapper systemUserJobMapper; + @Autowired + private SystemUserJobMapper systemUserJobMapper; - @Transactional(rollbackFor = Exception.class) - public void batchInsertUserJob(Set jobs, Long userId) { - if (CollUtil.isNotEmpty(jobs)) { - List records = new ArrayList<>(); - for (SystemJobTb job : jobs) { - SystemUserJobTb record = new SystemUserJobTb(); - record.setUserId(userId); - record.setJobId(job.getId()); - records.add(record); - } - systemUserJobMapper.insert(records); - } + @Transactional(rollbackFor = Exception.class) + public void batchInsertUserJob(Set jobs, Long userId) { + if (CollUtil.isNotEmpty(jobs)) { + List records = new ArrayList<>(); + for (SystemJobTb job : jobs) { + SystemUserJobTb record = new SystemUserJobTb(); + record.setUserId(userId); + record.setJobId(job.getId()); + records.add(record); + } + systemUserJobMapper.insert(records); } + } - @Transactional(rollbackFor = Exception.class) - public void batchDeleteUserJob(Set userIds) { - if (CollUtil.isNotEmpty(userIds)) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemUserJobTb::getUserId, userIds); - systemUserJobMapper.delete(wrapper); - } + @Transactional(rollbackFor = Exception.class) + public void batchDeleteUserJob(Set userIds) { + if (CollUtil.isNotEmpty(userIds)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemUserJobTb::getUserId, userIds); + systemUserJobMapper.delete(wrapper); } + } - /** - * 根据岗位ID统计用户数量 - * - * @param jobIds 岗位ID集合 - * @return / - */ - public Long countUserByJobIds(Set jobIds) { - if (CollUtil.isEmpty(jobIds)) { - return 0L; - } - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemUserJobTb::getJobId, jobIds); - return systemUserJobMapper.selectCount(wrapper); + /** + * 根据岗位ID统计用户数量 + * + * @param jobIds 岗位ID集合 + * @return / + */ + public Long countUserByJobIds(Set jobIds) { + if (CollUtil.isEmpty(jobIds)) { + return 0L; } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemUserJobTb::getJobId, jobIds); + return systemUserJobMapper.selectCount(wrapper); + } - public Set listUserJobByUserId(Long userId) { - return systemUserJobMapper.listUserJobByUserId(userId); - } + public Set listUserJobByUserId(Long userId) { + return systemUserJobMapper.listUserJobByUserId(userId); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java index c53a4c7f..0e82aabe 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java @@ -28,135 +28,135 @@ import cn.odboy.system.dal.mysql.SystemUserRoleMapper; import cn.odboy.system.framework.permission.core.KitSecurityHelper; import cn.odboy.util.KitBeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemUserRoleService { - @Autowired - private SystemRoleMapper systemRoleMapper; - @Autowired - private SystemUserRoleMapper systemUserRoleMapper; - @Autowired - private SystemRoleMenuService systemRoleMenuService; - @Autowired - private SystemRoleDeptService systemRoleDeptService; + @Autowired + private SystemRoleMapper systemRoleMapper; + @Autowired + private SystemUserRoleMapper systemUserRoleMapper; + @Autowired + private SystemRoleMenuService systemRoleMenuService; + @Autowired + private SystemRoleDeptService systemRoleDeptService; - @Transactional(rollbackFor = Exception.class) - public void batchInsertUserRole(Set roles, Long userId) { - if (CollUtil.isNotEmpty(roles)) { - List records = new ArrayList<>(); - for (SystemRoleTb role : roles) { - SystemUserRoleTb record = new SystemUserRoleTb(); - record.setUserId(userId); - record.setRoleId(role.getId()); - records.add(record); - } - systemUserRoleMapper.insert(records); - } + @Transactional(rollbackFor = Exception.class) + public void batchInsertUserRole(Set roles, Long userId) { + if (CollUtil.isNotEmpty(roles)) { + List records = new ArrayList<>(); + for (SystemRoleTb role : roles) { + SystemUserRoleTb record = new SystemUserRoleTb(); + record.setUserId(userId); + record.setRoleId(role.getId()); + records.add(record); + } + systemUserRoleMapper.insert(records); } + } - @Transactional(rollbackFor = Exception.class) - public void batchDeleteUserRole(Set userIds) { - if (CollUtil.isNotEmpty(userIds)) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemUserRoleTb::getUserId, userIds); - systemUserRoleMapper.delete(wrapper); - } + @Transactional(rollbackFor = Exception.class) + public void batchDeleteUserRole(Set userIds) { + if (CollUtil.isNotEmpty(userIds)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemUserRoleTb::getUserId, userIds); + systemUserRoleMapper.delete(wrapper); } + } - /** - * 转换为SystemRoleVo并关联查询菜单和部门信息 - * - * @param role 角色基本信息 - * @return 包含关联信息的SystemRoleVo - */ - public SystemRoleVo convertToRoleVo(SystemRoleTb role) { - if (role == null) { - return null; - } - SystemRoleVo roleVo = KitBeanUtil.copyToClass(role, SystemRoleVo.class); - // 查询关联的菜单信息 - Set menus = systemRoleMenuService.queryMenuByRoleIds(Collections.singleton(role.getId())); - roleVo.setMenus(menus); - // 查询关联的部门信息 - Set depts = systemRoleDeptService.listUserDeptByRoleId(role.getId()); - roleVo.setDepts(depts); - return roleVo; + /** + * 转换为SystemRoleVo并关联查询菜单和部门信息 + * + * @param role 角色基本信息 + * @return 包含关联信息的SystemRoleVo + */ + public SystemRoleVo convertToRoleVo(SystemRoleTb role) { + if (role == null) { + return null; } + SystemRoleVo roleVo = KitBeanUtil.copyToClass(role, SystemRoleVo.class); + // 查询关联的菜单信息 + Set menus = systemRoleMenuService.queryMenuByRoleIds(Collections.singleton(role.getId())); + roleVo.setMenus(menus); + // 查询关联的部门信息 + Set depts = systemRoleDeptService.listUserDeptByRoleId(role.getId()); + roleVo.setDepts(depts); + return roleVo; + } - /** - * 根据用户ID查询 - * - * @param userId 用户ID - * @return / - */ - public List queryRoleVoByUsersId(Long userId) { - Set roles = this.listUserRoleByUserId(userId); - return roles.stream().map(this::convertToRoleVo).collect(Collectors.toList()); - } + /** + * 根据用户ID查询 + * + * @param userId 用户ID + * @return / + */ + public List queryRoleVoByUsersId(Long userId) { + Set roles = this.listUserRoleByUserId(userId); + return roles.stream().map(this::convertToRoleVo).collect(Collectors.toList()); + } - /** - * 根据角色查询角色级别 - * - * @param roles / - * @return / - */ - public Integer getDeptLevelByRoles(Set roles) { - if (CollUtil.isEmpty(roles)) { - // 最小权限 - return Integer.MAX_VALUE; - } - List roleIds = - roles.stream().map(SystemRoleTb::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); - if (CollUtil.isEmpty(roleIds)) { - // 最小权限 - return Integer.MAX_VALUE; - } - List roleLevels = systemRoleMapper.selectList( - new LambdaQueryWrapper().select(SystemRoleTb::getLevel).isNotNull(SystemRoleTb::getLevel) - .in(SystemRoleTb::getId, roleIds)).stream().map(SystemRoleTb::getLevel).distinct() - .collect(Collectors.toList()); - if (CollUtil.isEmpty(roleLevels)) { - // 最小权限 - return Integer.MAX_VALUE; - } - return Collections.min(roleLevels); + /** + * 根据角色查询角色级别 + * + * @param roles / + * @return / + */ + public Integer getDeptLevelByRoles(Set roles) { + if (CollUtil.isEmpty(roles)) { + // 最小权限 + return Integer.MAX_VALUE; } + List roleIds = + roles.stream().map(SystemRoleTb::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); + if (CollUtil.isEmpty(roleIds)) { + // 最小权限 + return Integer.MAX_VALUE; + } + List roleLevels = systemRoleMapper.selectList( + new LambdaQueryWrapper().select(SystemRoleTb::getLevel).isNotNull(SystemRoleTb::getLevel) + .in(SystemRoleTb::getId, roleIds)).stream().map(SystemRoleTb::getLevel).distinct() + .collect(Collectors.toList()); + if (CollUtil.isEmpty(roleLevels)) { + // 最小权限 + return Integer.MAX_VALUE; + } + return Collections.min(roleLevels); + } - /** - * 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误 - * - * @param args / - */ - public void checkLevel(SystemUserVo args) { - Integer currentLevel = Collections.min( - this.queryRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream().map(SystemRoleVo::getLevel) - .collect(Collectors.toList())); - Integer optLevel = this.getDeptLevelByRoles(args.getRoles()); - if (currentLevel > optLevel) { - throw new BadRequestException("角色权限不足"); - } + /** + * 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误 + * + * @param args / + */ + public void checkLevel(SystemUserVo args) { + Integer currentLevel = Collections.min( + this.queryRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream().map(SystemRoleVo::getLevel) + .collect(Collectors.toList())); + Integer optLevel = this.getDeptLevelByRoles(args.getRoles()); + if (currentLevel > optLevel) { + throw new BadRequestException("角色权限不足"); } + } - public long countUserByRoleIds(Set ids) { - if (CollUtil.isEmpty(ids)) { - return 0L; - } - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemUserRoleTb::getRoleId, ids); - return systemUserRoleMapper.selectCount(wrapper); + public long countUserByRoleIds(Set ids) { + if (CollUtil.isEmpty(ids)) { + return 0L; } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemUserRoleTb::getRoleId, ids); + return systemUserRoleMapper.selectCount(wrapper); + } - public Set listUserRoleByUserId(Long userId) { - return systemUserRoleMapper.listUserRoleByUserId(userId); - } + public Set listUserRoleByUserId(Long userId) { + return systemUserRoleMapper.listUserRoleByUserId(userId); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java index 9cb16728..1fa9abfc 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java @@ -47,12 +47,6 @@ import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.ObjectUtils; -import org.springframework.web.multipart.MultipartFile; import jakarta.servlet.http.HttpServletResponse; import java.io.File; import java.util.ArrayList; @@ -63,449 +57,455 @@ import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; +import org.springframework.web.multipart.MultipartFile; @Service public class SystemUserService { - @Autowired - private SystemUserMapper systemUserMapper; - @Autowired - private SystemDeptService systemDeptService; - @Autowired - private SystemUserJobService systemUserJobService; - @Autowired - private SystemUserRoleService systemUserRoleService; - @Autowired - private SystemEmailService systemEmailService; - @Autowired - private SystemDataService systemDataService; - @Autowired - private SystemUserInfoDAO systemUserInfoDAO; - @Autowired - private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; - @Autowired - private KitFileLocalUploadHelper fileUploadPathHelper; - @Autowired - private AppProperties properties; - @Autowired - private PasswordEncoder passwordEncoder; + @Autowired + private SystemUserMapper systemUserMapper; + @Autowired + private SystemDeptService systemDeptService; + @Autowired + private SystemUserJobService systemUserJobService; + @Autowired + private SystemUserRoleService systemUserRoleService; + @Autowired + private SystemEmailService systemEmailService; + @Autowired + private SystemDataService systemDataService; + @Autowired + private SystemUserInfoDAO systemUserInfoDAO; + @Autowired + private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; + @Autowired + private KitFileLocalUploadHelper fileUploadPathHelper; + @Autowired + private AppProperties properties; + @Autowired + private PasswordEncoder passwordEncoder; - /** - * 新增用户 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveUser(SystemUserVo args) { - systemUserRoleService.checkLevel(args); - SystemUserTb record = KitBeanUtil.copyToClass(args, SystemUserTb.class); - // 默认密码 123456 - record.setPassword(passwordEncoder.encode("123456")); - record.setDeptId(args.getDept().getId()); - if (this.getUserByUsername(record.getUsername()) != null) { - throw new BadRequestException("用户名已存在"); - } - if (this.getUserByEmail(record.getEmail()) != null) { - throw new BadRequestException("邮箱已存在"); - } - if (this.getUserByPhone(record.getPhone()) != null) { - throw new BadRequestException("手机号已存在"); - } - // 保存用户 - systemUserMapper.insert(record); - // 保存用户岗位 - systemUserJobService.batchInsertUserJob(args.getJobs(), record.getId()); - // 保存用户角色 - systemUserRoleService.batchInsertUserRole(args.getRoles(), record.getId()); + /** + * 新增用户 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveUser(SystemUserVo args) { + systemUserRoleService.checkLevel(args); + SystemUserTb record = KitBeanUtil.copyToClass(args, SystemUserTb.class); + // 默认密码 123456 + record.setPassword(passwordEncoder.encode("123456")); + record.setDeptId(args.getDept().getId()); + if (this.getUserByUsername(record.getUsername()) != null) { + throw new BadRequestException("用户名已存在"); } - - /** - * 编辑用户 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateUserById(SystemUserVo args) { - systemUserRoleService.checkLevel(args); - SystemUserTb user = systemUserMapper.selectById(args.getId()); - SystemUserTb user1 = this.getUserByUsername(args.getUsername()); - SystemUserTb user2 = this.getUserByEmail(args.getEmail()); - SystemUserTb user3 = this.getUserByPhone(args.getPhone()); - if (user1 != null && !user.getId().equals(user1.getId())) { - throw new BadRequestException("用户名已存在"); - } - if (user2 != null && !user.getId().equals(user2.getId())) { - throw new BadRequestException("邮箱已存在"); - } - if (user3 != null && !user.getId().equals(user3.getId())) { - throw new BadRequestException("手机号已存在"); - } - // 如果用户被禁用, 则清除用户登录信息 - if (!args.getEnabled()) { - systemUserOnlineInfoDAO.kickOutByUsername(args.getUsername()); - } - user.setDeptId(args.getDept().getId()); - user.setUsername(args.getUsername()); - user.setEmail(args.getEmail()); - user.setEnabled(args.getEnabled()); - user.setPhone(args.getPhone()); - user.setNickName(args.getNickName()); - user.setGender(args.getGender()); - systemUserMapper.updateById(user); - // 清除用户登录缓存 - systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); - // 更新用户岗位 - systemUserJobService.batchDeleteUserJob(Collections.singleton(args.getId())); - systemUserJobService.batchInsertUserJob(args.getJobs(), args.getId()); - // 更新用户角色 - systemUserRoleService.batchDeleteUserRole(Collections.singleton(args.getId())); - systemUserRoleService.batchInsertUserRole(args.getRoles(), args.getId()); + if (this.getUserByEmail(record.getEmail()) != null) { + throw new BadRequestException("邮箱已存在"); } - - /** - * 用户自助修改资料 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateUserCenterInfoById(SystemUserTb args) { - if (!args.getId().equals(KitSecurityHelper.getCurrentUserId())) { - throw new BadRequestException("不能修改他人资料"); - } - SystemUserTb user = systemUserMapper.selectById(args.getId()); - SystemUserTb user1 = this.getUserByPhone(args.getPhone()); - if (user1 != null && !user.getId().equals(user1.getId())) { - throw new BadRequestException("手机号已存在"); - } - user.setNickName(args.getNickName()); - user.setPhone(args.getPhone()); - user.setGender(args.getGender()); - systemUserMapper.insertOrUpdate(user); - systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); + if (this.getUserByPhone(record.getPhone()) != null) { + throw new BadRequestException("手机号已存在"); } + // 保存用户 + systemUserMapper.insert(record); + // 保存用户岗位 + systemUserJobService.batchInsertUserJob(args.getJobs(), record.getId()); + // 保存用户角色 + systemUserRoleService.batchInsertUserRole(args.getRoles(), record.getId()); + } - /** - * 删除用户 - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteUserByIds(Set ids) { - Long currentUserId = KitSecurityHelper.getCurrentUserId(); - // 校验权限 - for (Long id : ids) { - Integer currentLevel = Collections.min( - systemUserRoleService.queryRoleVoByUsersId(currentUserId).stream().map(SystemRoleVo::getLevel) - .collect(Collectors.toList())); - Integer optLevel = Collections.min( - systemUserRoleService.queryRoleVoByUsersId(id).stream().map(SystemRoleVo::getLevel) - .collect(Collectors.toList())); - if (currentLevel > optLevel) { - throw new BadRequestException("角色权限不足, 不能删除:" + this.getUserById(id).getUsername()); - } - } - // 清理缓存 - List usernameList = systemUserMapper.selectByIds(ids).stream().map(SystemUserTb::getUsername).distinct() - .collect(Collectors.toList()); - for (String username : usernameList) { - systemUserInfoDAO.deleteUserLoginInfoByUserName(username); - } - // 删除用户 - systemUserMapper.deleteByIds(ids); - // 删除用户岗位 - systemUserJobService.batchDeleteUserJob(ids); - // 删除用户角色 - systemUserRoleService.batchDeleteUserRole(ids); + /** + * 编辑用户 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateUserById(SystemUserVo args) { + systemUserRoleService.checkLevel(args); + SystemUserTb user = systemUserMapper.selectById(args.getId()); + SystemUserTb user1 = this.getUserByUsername(args.getUsername()); + SystemUserTb user2 = this.getUserByEmail(args.getEmail()); + SystemUserTb user3 = this.getUserByPhone(args.getPhone()); + if (user1 != null && !user.getId().equals(user1.getId())) { + throw new BadRequestException("用户名已存在"); } - - /** - * 修改密码 - * - * @param username 用户名 - * @param args 参数 - */ - @Transactional(rollbackFor = Exception.class) - public void updateUserPasswordByUsername(String username, SystemUpdateUserPasswordArgs args) throws Exception { - String oldPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getOldPass()); - String newPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getNewPass()); - SystemUserTb user = this.getUserByUsername(username); - if (!passwordEncoder.matches(oldPass, user.getPassword())) { - throw new BadRequestException("修改失败,旧密码错误"); - } - if (passwordEncoder.matches(newPass, user.getPassword())) { - throw new BadRequestException("新密码不能与旧密码相同"); - } - String encryptPassword = passwordEncoder.encode(newPass); - systemUserMapper.updateUserPasswordByUsername(username, encryptPassword); - systemUserInfoDAO.deleteUserLoginInfoByUserName(username); + if (user2 != null && !user.getId().equals(user2.getId())) { + throw new BadRequestException("邮箱已存在"); } - - /** - * 重置密码 - * - * @param ids 用户id - */ - @Transactional(rollbackFor = Exception.class) - public void resetUserPasswordByIds(Set ids) { - String defaultPwd = passwordEncoder.encode("123456"); - List users = systemUserMapper.selectByIds(ids); - // 清除缓存 - for (SystemUserTb user : users) { - // 清除缓存 - systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); - // 强制退出 - systemUserOnlineInfoDAO.kickOutByUsername(user.getUsername()); - } - // 重置密码 - systemUserMapper.updateUserPasswordByUserIds(defaultPwd, ids); + if (user3 != null && !user.getId().equals(user3.getId())) { + throw new BadRequestException("手机号已存在"); } - - /** - * 修改头像 - * - * @param multipartFile 文件 - * @return / - */ - @Transactional(rollbackFor = Exception.class) - public Map updateUserAvatar(MultipartFile multipartFile) { - SystemUserTb user = this.getUserByUsername(KitSecurityHelper.getCurrentUsername()); - String username = user.getUsername(); - if (StrUtil.isBlank(username)) { - throw new BadRequestException("异常用户数据, 请联系管理员处理"); - } - // 文件大小验证 - KitFileUtil.checkSize(fileUploadPathHelper.getAvatarMaxSize(), multipartFile.getSize()); - // 验证文件上传的格式 - String image = "gif jpg png jpeg"; - String fileType = KitFileUtil.getSuffix(multipartFile.getOriginalFilename()); - if (fileType != null && !image.contains(fileType)) { - throw new BadRequestException("文件格式错误!, 仅支持 " + image + " 格式"); - } - String oldPath = user.getAvatarPath(); - File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath()); - user.setAvatarPath(Objects.requireNonNull(file).getPath()); - user.setAvatarName(file.getName()); - systemUserMapper.insertOrUpdate(user); - if (StrUtil.isNotBlank(oldPath)) { - KitFileUtil.del(oldPath); - } - systemUserInfoDAO.deleteUserLoginInfoByUserName(username); - return new HashMap<>(1) {{ - put("avatar", file.getName()); - }}; + // 如果用户被禁用, 则清除用户登录信息 + if (!args.getEnabled()) { + systemUserOnlineInfoDAO.kickOutByUsername(args.getUsername()); } + user.setDeptId(args.getDept().getId()); + user.setUsername(args.getUsername()); + user.setEmail(args.getEmail()); + user.setEnabled(args.getEnabled()); + user.setPhone(args.getPhone()); + user.setNickName(args.getNickName()); + user.setGender(args.getGender()); + systemUserMapper.updateById(user); + // 清除用户登录缓存 + systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); + // 更新用户岗位 + systemUserJobService.batchDeleteUserJob(Collections.singleton(args.getId())); + systemUserJobService.batchInsertUserJob(args.getJobs(), args.getId()); + // 更新用户角色 + systemUserRoleService.batchDeleteUserRole(Collections.singleton(args.getId())); + systemUserRoleService.batchInsertUserRole(args.getRoles(), args.getId()); + } - /** - * 修改邮箱 - * - * @param username 用户名 - * @param args 参数 - * @param code 验证码 - */ - @Transactional(rollbackFor = Exception.class) - public void updateUserEmailByUsername(String username, SystemUserTb args, String code) throws Exception { - String password = - KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword()); - SystemUserTb user = this.getUserByUsername(username); - if (!passwordEncoder.matches(password, user.getPassword())) { - throw new BadRequestException("密码错误"); - } - systemEmailService.checkEmailCaptchaV1(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, args.getEmail(), code); - systemUserMapper.updateUserEmailByUsername(username, args.getEmail()); - systemUserInfoDAO.deleteUserLoginInfoByUserName(username); + /** + * 用户自助修改资料 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateUserCenterInfoById(SystemUserTb args) { + if (!args.getId().equals(KitSecurityHelper.getCurrentUserId())) { + throw new BadRequestException("不能修改他人资料"); } - - /** - * 查询全部 - * - * @param args 条件 - * @param page 分页参数 - * @return / - */ - public KitPageResult searchUserByArgs(SystemQueryUserArgs args, Page page) { - // 查询用户基本信息 - LambdaQueryWrapper wrapper = this.buildUserQueryWrapper(args); - IPage userPage = systemUserMapper.selectPage(page, wrapper); - List users = userPage.getRecords(); - // 转换为SystemUserVo并关联查询 - List userVos = - users.stream().map(m -> this.convertToUserVo(m, false)).collect(Collectors.toList()); - return KitPageUtil.toPage(userVos, userPage.getTotal()); + SystemUserTb user = systemUserMapper.selectById(args.getId()); + SystemUserTb user1 = this.getUserByPhone(args.getPhone()); + if (user1 != null && !user.getId().equals(user1.getId())) { + throw new BadRequestException("手机号已存在"); } + user.setNickName(args.getNickName()); + user.setPhone(args.getPhone()); + user.setGender(args.getGender()); + systemUserMapper.insertOrUpdate(user); + systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); + } - public long countUserByArgs(SystemQueryUserArgs args) { - LambdaQueryWrapper wrapper = this.buildUserQueryWrapper(args); - return systemUserMapper.selectCount(wrapper); + /** + * 删除用户 + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteUserByIds(Set ids) { + Long currentUserId = KitSecurityHelper.getCurrentUserId(); + // 校验权限 + for (Long id : ids) { + Integer currentLevel = Collections.min( + systemUserRoleService.queryRoleVoByUsersId(currentUserId).stream().map(SystemRoleVo::getLevel) + .collect(Collectors.toList())); + Integer optLevel = Collections.min( + systemUserRoleService.queryRoleVoByUsersId(id).stream().map(SystemRoleVo::getLevel) + .collect(Collectors.toList())); + if (currentLevel > optLevel) { + throw new BadRequestException("角色权限不足, 不能删除:" + this.getUserById(id).getUsername()); + } } - - /** - * 根据ID查询 - * - * @param id ID - * @return / - */ - public SystemUserTb getUserById(long id) { - return systemUserMapper.selectById(id); + // 清理缓存 + List usernameList = systemUserMapper.selectByIds(ids).stream().map(SystemUserTb::getUsername).distinct() + .collect(Collectors.toList()); + for (String username : usernameList) { + systemUserInfoDAO.deleteUserLoginInfoByUserName(username); } + // 删除用户 + systemUserMapper.deleteByIds(ids); + // 删除用户岗位 + systemUserJobService.batchDeleteUserJob(ids); + // 删除用户角色 + systemUserRoleService.batchDeleteUserRole(ids); + } - public List queryUserMetadataOptions(KitPageArgs pageArgs) { - SystemQueryUserArgs args = pageArgs.getArgs(); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.select(SystemUserTb::getId, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone); - wrapper.and(c -> { - c.eq(SystemUserTb::getPhone, args.getBlurry()); - c.or(); - c.eq(SystemUserTb::getEmail, args.getBlurry()); - c.or(); - c.like(SystemUserTb::getUsername, args.getBlurry()); - c.or(); - c.like(SystemUserTb::getNickName, args.getBlurry()); + /** + * 修改密码 + * + * @param username 用户名 + * @param args 参数 + */ + @Transactional(rollbackFor = Exception.class) + public void updateUserPasswordByUsername(String username, SystemUpdateUserPasswordArgs args) throws Exception { + String oldPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getOldPass()); + String newPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getNewPass()); + SystemUserTb user = this.getUserByUsername(username); + if (!passwordEncoder.matches(oldPass, user.getPassword())) { + throw new BadRequestException("修改失败,旧密码错误"); + } + if (passwordEncoder.matches(newPass, user.getPassword())) { + throw new BadRequestException("新密码不能与旧密码相同"); + } + String encryptPassword = passwordEncoder.encode(newPass); + systemUserMapper.updateUserPasswordByUsername(username, encryptPassword); + systemUserInfoDAO.deleteUserLoginInfoByUserName(username); + } + + /** + * 重置密码 + * + * @param ids 用户id + */ + @Transactional(rollbackFor = Exception.class) + public void resetUserPasswordByIds(Set ids) { + String defaultPwd = passwordEncoder.encode("123456"); + List users = systemUserMapper.selectByIds(ids); + // 清除缓存 + for (SystemUserTb user : users) { + // 清除缓存 + systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); + // 强制退出 + systemUserOnlineInfoDAO.kickOutByUsername(user.getUsername()); + } + // 重置密码 + systemUserMapper.updateUserPasswordByUserIds(defaultPwd, ids); + } + + /** + * 修改头像 + * + * @param multipartFile 文件 + * @return / + */ + @Transactional(rollbackFor = Exception.class) + public Map updateUserAvatar(MultipartFile multipartFile) { + SystemUserTb user = this.getUserByUsername(KitSecurityHelper.getCurrentUsername()); + String username = user.getUsername(); + if (StrUtil.isBlank(username)) { + throw new BadRequestException("异常用户数据, 请联系管理员处理"); + } + // 文件大小验证 + KitFileUtil.checkSize(fileUploadPathHelper.getAvatarMaxSize(), multipartFile.getSize()); + // 验证文件上传的格式 + String image = "gif jpg png jpeg"; + String fileType = KitFileUtil.getSuffix(multipartFile.getOriginalFilename()); + if (fileType != null && !image.contains(fileType)) { + throw new BadRequestException("文件格式错误!, 仅支持 " + image + " 格式"); + } + String oldPath = user.getAvatarPath(); + File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath()); + user.setAvatarPath(Objects.requireNonNull(file).getPath()); + user.setAvatarName(file.getName()); + systemUserMapper.insertOrUpdate(user); + if (StrUtil.isNotBlank(oldPath)) { + KitFileUtil.del(oldPath); + } + systemUserInfoDAO.deleteUserLoginInfoByUserName(username); + return new HashMap<>(1) {{ + put("avatar", file.getName()); + }}; + } + + /** + * 修改邮箱 + * + * @param username 用户名 + * @param args 参数 + * @param code 验证码 + */ + @Transactional(rollbackFor = Exception.class) + public void updateUserEmailByUsername(String username, SystemUserTb args, String code) throws Exception { + String password = + KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword()); + SystemUserTb user = this.getUserByUsername(username); + if (!passwordEncoder.matches(password, user.getPassword())) { + throw new BadRequestException("密码错误"); + } + systemEmailService.checkEmailCaptchaV1(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, args.getEmail(), code); + systemUserMapper.updateUserEmailByUsername(username, args.getEmail()); + systemUserInfoDAO.deleteUserLoginInfoByUserName(username); + } + + /** + * 查询全部 + * + * @param args 条件 + * @param page 分页参数 + * @return / + */ + public KitPageResult searchUserByArgs(SystemQueryUserArgs args, Page page) { + // 查询用户基本信息 + LambdaQueryWrapper wrapper = this.buildUserQueryWrapper(args); + IPage userPage = systemUserMapper.selectPage(page, wrapper); + List users = userPage.getRecords(); + // 转换为SystemUserVo并关联查询 + List userVos = + users.stream().map(m -> this.convertToUserVo(m, false)).collect(Collectors.toList()); + return KitPageUtil.toPage(userVos, userPage.getTotal()); + } + + public long countUserByArgs(SystemQueryUserArgs args) { + LambdaQueryWrapper wrapper = this.buildUserQueryWrapper(args); + return systemUserMapper.selectCount(wrapper); + } + + /** + * 根据ID查询 + * + * @param id ID + * @return / + */ + public SystemUserTb getUserById(long id) { + return systemUserMapper.selectById(id); + } + + public List queryUserMetadataOptions(KitPageArgs pageArgs) { + SystemQueryUserArgs args = pageArgs.getArgs(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.select(SystemUserTb::getId, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone); + wrapper.and(c -> { + c.eq(SystemUserTb::getPhone, args.getBlurry()); + c.or(); + c.eq(SystemUserTb::getEmail, args.getBlurry()); + c.or(); + c.like(SystemUserTb::getUsername, args.getBlurry()); + c.or(); + c.like(SystemUserTb::getNickName, args.getBlurry()); + }); + return systemUserMapper.selectPage(new Page<>(pageArgs.getPage(), 50), wrapper).getRecords().stream().map(m -> { + Map ext = new HashMap<>(1); + ext.put("id", m.getId()); + ext.put("deptId", m.getDeptId()); + ext.put("email", m.getEmail()); + ext.put("phone", m.getPhone()); + return KitSelectOptionVo.builder().label(m.getNickName()).value(String.valueOf(m.getId())).ext(ext).build(); + }).collect(Collectors.toList()); + } + + /** + * 构建用户查询条件 + * + * @param args 查询条件 + * @return / + */ + private LambdaQueryWrapper buildUserQueryWrapper(SystemQueryUserArgs args) { + KitValidUtil.notNull(args); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (args.getId() != null) { + wrapper.eq(SystemUserTb::getId, args.getId()); + } + if (args.getEnabled() != null) { + wrapper.eq(SystemUserTb::getEnabled, args.getEnabled()); + } + if (CollUtil.isNotEmpty(args.getDeptIds())) { + wrapper.in(SystemUserTb::getDeptId, args.getDeptIds()); + } + if (StrUtil.isNotBlank(args.getBlurry())) { + wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or() + .like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry())); + } + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + } + wrapper.orderByDesc(SystemUserTb::getCreateTime); + return wrapper; + } + + /** + * 转换为SystemUserVo并关联查询部门、角色、岗位信息 + * + * @param user 用户基本信息 + * @param includePassword 是否包含用户密码 + * @return 包含关联信息的SystemUserVo + */ + private SystemUserVo convertToUserVo(SystemUserTb user, boolean includePassword) { + if (user == null) { + return null; + } + if (!includePassword) { + // 查询用户时,清空密码 + user.setPassword(null); + } + SystemUserVo userVo = KitBeanUtil.copyToClass(user, SystemUserVo.class); + // 查询关联的部门信息 + if (user.getDeptId() != null) { + userVo.setDept(systemDeptService.getDeptVoById(user.getDeptId())); + } + // 查询关联的岗位信息 + userVo.setJobs(systemUserJobService.listUserJobByUserId(user.getId())); + // 查询关联的角色信息 + userVo.setRoles(systemUserRoleService.listUserRoleByUserId(user.getId())); + return userVo; + } + + public SystemUserTb getUserByUsername(String username) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getUsername, username); + wrapper.eq(SystemUserTb::getEnabled, 1); + return systemUserMapper.selectOne(wrapper); + } + + public SystemUserVo getUserVoWithPasswordByUsername(String username) { + return this.convertToUserVo(this.getUserByUsername(username), true); + } + + public SystemUserVo getUserVoByUsername(String username) { + return this.convertToUserVo(this.getUserByUsername(username), false); + } + + public SystemUserTb getUserByEmail(String email) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getEmail, email); + wrapper.eq(SystemUserTb::getEnabled, 1); + return systemUserMapper.selectOne(wrapper); + } + + public SystemUserTb getUserByPhone(String phone) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getPhone, phone); + wrapper.eq(SystemUserTb::getEnabled, 1); + return systemUserMapper.selectOne(wrapper); + } + + public KitPageResult aggregationSearchUserByArgs(Page page, SystemQueryUserArgs args, + String currentUsername) { + if (!ObjectUtils.isEmpty(args.getDeptId())) { + args.getDeptIds().add(args.getDeptId()); + // 先查找是否存在子节点 + List data = systemDeptService.listDeptByPid(args.getDeptId()); + Map> deptPidMap = + systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); + // 然后把子节点的ID都加入到集合中 + args.getDeptIds().addAll(systemDeptService.queryChildDeptIdByDeptIds(data, deptPidMap)); + } + // 数据权限 + List dataScopes = systemDataService.queryDeptIdByArgs(this.getUserVoByUsername(currentUsername)); + // args.getDeptIds() 不为空并且数据权限不为空则取交集 + if (!CollUtil.isEmpty(args.getDeptIds()) && !CollUtil.isEmpty(dataScopes)) { + // 取交集 + args.getDeptIds().retainAll(dataScopes); + if (!CollUtil.isEmpty(args.getDeptIds())) { + return this.searchUserByArgs(args, page); + } + } else { + // 否则取并集 + args.getDeptIds().addAll(dataScopes); + return this.searchUserByArgs(args, page); + } + return KitPageUtil.emptyData(); + } + + public void exportUserXlsx(HttpServletResponse response, SystemQueryUserArgs args) { + long totalCount = this.countUserByArgs(args); + KitExcelExporter.exportByPage(response, "用户数据", SystemUserExportRowVo.class, totalCount, + (long pageNum, long pageSize) -> { + KitPageResult pageResult = this.searchUserByArgs(args, new Page<>(pageNum, pageSize)); + List rowVos = new ArrayList<>(); + for (SystemUserVo dataObject : pageResult.getContent()) { + SystemUserExportRowVo rowVo = new SystemUserExportRowVo(); + rowVo.setUsername(dataObject.getUsername()); + rowVo.setRoles( + dataObject.getRoles().stream().map(SystemRoleTb::getName).collect(Collectors.joining(","))); + rowVo.setDept(dataObject.getDept().getName()); + rowVo.setJobs( + dataObject.getJobs().stream().map(SystemJobTb::getName).collect(Collectors.joining(","))); + rowVo.setEmail(dataObject.getEmail()); + rowVo.setStatus(dataObject.getEnabled() ? SystemZhConst.ENABLE_STR : SystemZhConst.DISABLE_STR); + rowVo.setMobile(dataObject.getPhone()); + rowVo.setUpdatePwdTime(dataObject.getPwdResetTime()); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); + } + return rowVos; }); - return systemUserMapper.selectPage(new Page<>(pageArgs.getPage(), 50), wrapper).getRecords().stream().map(m -> { - Map ext = new HashMap<>(1); - ext.put("id", m.getId()); - ext.put("deptId", m.getDeptId()); - ext.put("email", m.getEmail()); - ext.put("phone", m.getPhone()); - return KitSelectOptionVo.builder().label(m.getNickName()).value(String.valueOf(m.getId())).ext(ext).build(); - }).collect(Collectors.toList()); - } - - /** - * 构建用户查询条件 - * - * @param args 查询条件 - * @return / - */ - private LambdaQueryWrapper buildUserQueryWrapper(SystemQueryUserArgs args) { - KitValidUtil.notNull(args); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - if (args.getId() != null) { - wrapper.eq(SystemUserTb::getId, args.getId()); - } - if (args.getEnabled() != null) { - wrapper.eq(SystemUserTb::getEnabled, args.getEnabled()); - } - if (CollUtil.isNotEmpty(args.getDeptIds())) { - wrapper.in(SystemUserTb::getDeptId, args.getDeptIds()); - } - if (StrUtil.isNotBlank(args.getBlurry())) { - wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or() - .like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry())); - } - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); - } - wrapper.orderByDesc(SystemUserTb::getCreateTime); - return wrapper; - } - - /** - * 转换为SystemUserVo并关联查询部门、角色、岗位信息 - * - * @param user 用户基本信息 - * @param includePassword 是否包含用户密码 - * @return 包含关联信息的SystemUserVo - */ - private SystemUserVo convertToUserVo(SystemUserTb user, boolean includePassword) { - if (user == null) { - return null; - } - if (!includePassword) { - // 查询用户时,清空密码 - user.setPassword(null); - } - SystemUserVo userVo = KitBeanUtil.copyToClass(user, SystemUserVo.class); - // 查询关联的部门信息 - if (user.getDeptId() != null) { - userVo.setDept(systemDeptService.getDeptVoById(user.getDeptId())); - } - // 查询关联的岗位信息 - userVo.setJobs(systemUserJobService.listUserJobByUserId(user.getId())); - // 查询关联的角色信息 - userVo.setRoles(systemUserRoleService.listUserRoleByUserId(user.getId())); - return userVo; - } - - public SystemUserTb getUserByUsername(String username) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemUserTb::getUsername, username); - wrapper.eq(SystemUserTb::getEnabled, 1); - return systemUserMapper.selectOne(wrapper); - } - - public SystemUserVo getUserVoWithPasswordByUsername(String username) { - return this.convertToUserVo(this.getUserByUsername(username), true); - } - - public SystemUserVo getUserVoByUsername(String username) { - return this.convertToUserVo(this.getUserByUsername(username), false); - } - - public SystemUserTb getUserByEmail(String email) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemUserTb::getEmail, email); - wrapper.eq(SystemUserTb::getEnabled, 1); - return systemUserMapper.selectOne(wrapper); - } - - public SystemUserTb getUserByPhone(String phone) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemUserTb::getPhone, phone); - wrapper.eq(SystemUserTb::getEnabled, 1); - return systemUserMapper.selectOne(wrapper); - } - - public KitPageResult aggregationSearchUserByArgs(Page page, SystemQueryUserArgs args, - String currentUsername) { - if (!ObjectUtils.isEmpty(args.getDeptId())) { - args.getDeptIds().add(args.getDeptId()); - // 先查找是否存在子节点 - List data = systemDeptService.listDeptByPid(args.getDeptId()); - Map> deptPidMap = - systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); - // 然后把子节点的ID都加入到集合中 - args.getDeptIds().addAll(systemDeptService.queryChildDeptIdByDeptIds(data, deptPidMap)); - } - // 数据权限 - List dataScopes = systemDataService.queryDeptIdByArgs(this.getUserVoByUsername(currentUsername)); - // args.getDeptIds() 不为空并且数据权限不为空则取交集 - if (!CollUtil.isEmpty(args.getDeptIds()) && !CollUtil.isEmpty(dataScopes)) { - // 取交集 - args.getDeptIds().retainAll(dataScopes); - if (!CollUtil.isEmpty(args.getDeptIds())) { - return this.searchUserByArgs(args, page); - } - } else { - // 否则取并集 - args.getDeptIds().addAll(dataScopes); - return this.searchUserByArgs(args, page); - } - return KitPageUtil.emptyData(); - } - - public void exportUserXlsx(HttpServletResponse response, SystemQueryUserArgs args) { - long totalCount = this.countUserByArgs(args); - KitExcelExporter.exportByPage(response, "用户数据", SystemUserExportRowVo.class, totalCount, - (long pageNum, long pageSize) -> { - KitPageResult pageResult = this.searchUserByArgs(args, new Page<>(pageNum, pageSize)); - List rowVos = new ArrayList<>(); - for (SystemUserVo dataObject : pageResult.getContent()) { - SystemUserExportRowVo rowVo = new SystemUserExportRowVo(); - rowVo.setUsername(dataObject.getUsername()); - rowVo.setRoles( - dataObject.getRoles().stream().map(SystemRoleTb::getName).collect(Collectors.joining(","))); - rowVo.setDept(dataObject.getDept().getName()); - rowVo.setJobs( - dataObject.getJobs().stream().map(SystemJobTb::getName).collect(Collectors.joining(","))); - rowVo.setEmail(dataObject.getEmail()); - rowVo.setStatus(dataObject.getEnabled() ? SystemZhConst.ENABLE_STR : SystemZhConst.DISABLE_STR); - rowVo.setMobile(dataObject.getPhone()); - rowVo.setUpdatePwdTime(dataObject.getPwdResetTime()); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - return rowVos; - }); - } + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemMinioStorageServiceImpl.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemMinioStorageServiceImpl.java index ded396f3..b34a1501 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemMinioStorageServiceImpl.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemMinioStorageServiceImpl.java @@ -39,13 +39,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import jakarta.servlet.http.HttpServletResponse; +import java.io.File; +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import jakarta.servlet.http.HttpServletResponse; -import java.io.File; -import java.util.List; /** *

@@ -59,110 +59,110 @@ import java.util.List; public class SystemMinioStorageServiceImpl extends ServiceImpl implements SystemOssStorageService { - @Autowired - private MinioRepository minioRepository; - @Autowired - private AppProperties properties; - @Autowired - private KitFileLocalUploadHelper fileLocalUploadHelper; - @Autowired - private SystemOssStorageMapper systemOssStorageMapper; + @Autowired + private MinioRepository minioRepository; + @Autowired + private AppProperties properties; + @Autowired + private KitFileLocalUploadHelper fileLocalUploadHelper; + @Autowired + private SystemOssStorageMapper systemOssStorageMapper; - @Override - public KitPageResult searchOssStorage(SystemQueryStorageArgs args, - Page page) { - IPage ossStorageTbs = this.selectOssStorageByArgs(args, page); - for (SystemOssStorageVo storageVo : ossStorageTbs.getRecords()) { - storageVo.setFileSizeDesc(KitFileUtil.getSize(storageVo.getFileSize())); - } - return KitPageUtil.toPage(ossStorageTbs); + @Override + public KitPageResult searchOssStorage(SystemQueryStorageArgs args, + Page page) { + IPage ossStorageTbs = this.selectOssStorageByArgs(args, page); + for (SystemOssStorageVo storageVo : ossStorageTbs.getRecords()) { + storageVo.setFileSizeDesc(KitFileUtil.getSize(storageVo.getFileSize())); } + return KitPageUtil.toPage(ossStorageTbs); + } - private IPage selectOssStorageByArgs(SystemQueryStorageArgs args, - Page page) { - KitValidUtil.notNull(args); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.and(StrUtil.isNotBlank(args.getBlurry()), - c -> c.like(SystemOssStorageTb::getFileName, args.getBlurry()).or() - .like(SystemOssStorageTb::getFilePrefix, args.getBlurry()).or() - .like(SystemOssStorageTb::getFileMime, args.getBlurry()).or() - .like(SystemOssStorageTb::getFileMd5, args.getBlurry())); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemOssStorageTb::getUpdateTime, args.getCreateTime().get(0), - args.getCreateTime().get(1)); - } - wrapper.orderByAsc(SystemOssStorageTb::getId); - return systemOssStorageMapper.selectPage(page, wrapper) - .convert(i -> KitBeanUtil.copyToClass(i, SystemOssStorageVo.class)); + private IPage selectOssStorageByArgs(SystemQueryStorageArgs args, + Page page) { + KitValidUtil.notNull(args); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.and(StrUtil.isNotBlank(args.getBlurry()), + c -> c.like(SystemOssStorageTb::getFileName, args.getBlurry()).or() + .like(SystemOssStorageTb::getFilePrefix, args.getBlurry()).or() + .like(SystemOssStorageTb::getFileMime, args.getBlurry()).or() + .like(SystemOssStorageTb::getFileMd5, args.getBlurry())); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemOssStorageTb::getUpdateTime, args.getCreateTime().get(0), + args.getCreateTime().get(1)); } + wrapper.orderByAsc(SystemOssStorageTb::getId); + return systemOssStorageMapper.selectPage(page, wrapper) + .convert(i -> KitBeanUtil.copyToClass(i, SystemOssStorageVo.class)); + } - @Override - public List queryOssStorage(SystemQueryStorageArgs args) { - // 防止刷数据 - Page page = new Page<>(1, 500); - return searchOssStorage(args, page).getContent(); - } + @Override + public List queryOssStorage(SystemQueryStorageArgs args) { + // 防止刷数据 + Page page = new Page<>(1, 500); + return searchOssStorage(args, page).getContent(); + } - @Override - @Transactional(rollbackFor = Exception.class) - public String uploadFile(MultipartFile file) { - String originalFilename = file.getOriginalFilename(); - if (StrUtil.isBlank(originalFilename)) { - throw new BadRequestException("文件名不能为空"); - } - StorageOSSModel ossConfig = properties.getOss(); - long fileSize = file.getSize(); - String contentType = file.getContentType(); - KitFileUtil.checkSize(ossConfig.getMaxSize(), fileSize); - // 按天分组 - String nowDateStr = KitDateUtil.getNowDateStr(); - // 上传到本地临时目录 - File tempFile = KitFileUtil.upload(file, fileLocalUploadHelper.getPath() + nowDateStr + File.separator); - if (tempFile == null) { - throw new BadRequestException("上传失败"); - } - // 校验文件md5, 看是否已存在云端(不确定, 可能云端已经删除, 但是正常来说云端是不允许私自删除的, 所以这里忽略云端不存在的情况) - String md5 = KitFileUtil.getMd5(tempFile); - SystemOssStorageTb systemOssStorageTb = this.getOssStorageByMd5(md5); - if (systemOssStorageTb != null) { - // 重新生成7天链接 - return minioRepository.generatePreviewUrl(systemOssStorageTb.getObjectName()); - } - // 上传到OSS - SystemOssStorageTb storageTb = minioRepository.upload(tempFile, originalFilename, fileSize, contentType, md5); - if (storageTb == null) { - throw new BadRequestException("文件上传失败"); - } - save(storageTb); - return minioRepository.generatePreviewUrl(storageTb.getObjectName()); + @Override + @Transactional(rollbackFor = Exception.class) + public String uploadFile(MultipartFile file) { + String originalFilename = file.getOriginalFilename(); + if (StrUtil.isBlank(originalFilename)) { + throw new BadRequestException("文件名不能为空"); } + StorageOSSModel ossConfig = properties.getOss(); + long fileSize = file.getSize(); + String contentType = file.getContentType(); + KitFileUtil.checkSize(ossConfig.getMaxSize(), fileSize); + // 按天分组 + String nowDateStr = KitDateUtil.getNowDateStr(); + // 上传到本地临时目录 + File tempFile = KitFileUtil.upload(file, fileLocalUploadHelper.getPath() + nowDateStr + File.separator); + if (tempFile == null) { + throw new BadRequestException("上传失败"); + } + // 校验文件md5, 看是否已存在云端(不确定, 可能云端已经删除, 但是正常来说云端是不允许私自删除的, 所以这里忽略云端不存在的情况) + String md5 = KitFileUtil.getMd5(tempFile); + SystemOssStorageTb systemOssStorageTb = this.getOssStorageByMd5(md5); + if (systemOssStorageTb != null) { + // 重新生成7天链接 + return minioRepository.generatePreviewUrl(systemOssStorageTb.getObjectName()); + } + // 上传到OSS + SystemOssStorageTb storageTb = minioRepository.upload(tempFile, originalFilename, fileSize, contentType, md5); + if (storageTb == null) { + throw new BadRequestException("文件上传失败"); + } + save(storageTb); + return minioRepository.generatePreviewUrl(storageTb.getObjectName()); + } - /** - * 多选删除 - * - * @param ids / - */ - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteFileByIds(Long[] ids) { - for (Long id : ids) { - SystemOssStorageTb storage = getById(id); - minioRepository.removeBucketFile(storage.getObjectName()); - removeById(storage); - } + /** + * 多选删除 + * + * @param ids / + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteFileByIds(Long[] ids) { + for (Long id : ids) { + SystemOssStorageTb storage = getById(id); + minioRepository.removeBucketFile(storage.getObjectName()); + removeById(storage); } + } - @Override - public void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) { - List systemOssStorageVos = this.queryOssStorage(args); - // KitXlsxExportUtil.exportFile(response, "OSS文件上传记录数据", systemOssStorageVos, SystemOssStorageExportRowVo.class, - // (dataObject) -> CollUtil.newArrayList(KitBeanUtil.copyProperties(dataObject, SystemOssStorageExportRowVo.class))); - List rowVos = - KitBeanUtil.copyToList(systemOssStorageVos, SystemOssStorageExportRowVo.class); - KitExcelExporter.exportSimple(response, "OSS文件上传记录数据", SystemOssStorageExportRowVo.class, rowVos); - } + @Override + public void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) { + List systemOssStorageVos = this.queryOssStorage(args); + // KitXlsxExportUtil.exportFile(response, "OSS文件上传记录数据", systemOssStorageVos, SystemOssStorageExportRowVo.class, + // (dataObject) -> CollUtil.newArrayList(KitBeanUtil.copyProperties(dataObject, SystemOssStorageExportRowVo.class))); + List rowVos = + KitBeanUtil.copyToList(systemOssStorageVos, SystemOssStorageExportRowVo.class); + KitExcelExporter.exportSimple(response, "OSS文件上传记录数据", SystemOssStorageExportRowVo.class, rowVos); + } - private SystemOssStorageTb getOssStorageByMd5(String md5) { - return lambdaQuery().eq(SystemOssStorageTb::getFileMd5, md5).one(); - } + private SystemOssStorageTb getOssStorageByMd5(String md5) { + return lambdaQuery().eq(SystemOssStorageTb::getFileMd5, md5).one(); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemQuartzJobVo.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemQuartzJobVo.java index caf2e513..3dcf0f8c 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemQuartzJobVo.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemQuartzJobVo.java @@ -8,6 +8,7 @@ import lombok.Setter; @Getter @Setter public class SystemQuartzJobVo extends KitBaseUserTimeTb { + private Long id; @ApiModelProperty(value = "定时器名称") private String jobName; diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDictDetailMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDictDetailMapper.java index 98aa735c..d3efd959 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDictDetailMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDictDetailMapper.java @@ -21,9 +21,9 @@ import cn.odboy.system.dal.model.response.SystemDictDetailVo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.util.List; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import java.util.List; /** * 字典明细 Mapper @@ -33,7 +33,7 @@ import java.util.List; @Mapper public interface SystemDictDetailMapper extends BaseMapper { - IPage selectPageByArgs(Page page, @Param("args") SystemQueryDictDetailArgs args); + IPage selectPageByArgs(Page page, @Param("args") SystemQueryDictDetailArgs args); - List listDictDetailByName(@Param("name") String name); + List listDictDetailByName(@Param("name") String name); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleDeptMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleDeptMapper.java index b5dafd08..ead99b10 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleDeptMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleDeptMapper.java @@ -18,7 +18,6 @@ package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemDeptTb; import cn.odboy.system.dal.dataobject.SystemRoleDeptTb; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import java.util.List; import java.util.Set; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserJobMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserJobMapper.java index 5cc06b8b..f8f2365b 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserJobMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserJobMapper.java @@ -21,7 +21,6 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import java.util.Set; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; -import org.apache.ibatis.annotations.Select; /** * 用户职位关联 Mapper diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/OperationLogAspect.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/OperationLogAspect.java index 416c761d..0612414a 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/OperationLogAspect.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/OperationLogAspect.java @@ -48,7 +48,8 @@ import org.springframework.stereotype.Component; @Component public class OperationLogAspect { - @Autowired private SystemOperationLogMapper systemOperationLogMapper; + @Autowired + private SystemOperationLogMapper systemOperationLogMapper; @Around("@annotation(operationLog)") public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog) diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/local/MultipartConfig.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/local/MultipartConfig.java index a4ae4a2b..69ae7d07 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/local/MultipartConfig.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/local/MultipartConfig.java @@ -22,7 +22,6 @@ import java.io.File; import javax.servlet.MultipartConfigElement; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.web.servlet.MultipartConfigFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -31,6 +30,7 @@ import org.springframework.util.unit.DataSize; @Slf4j @Configuration public class MultipartConfig { + @Autowired private AppProperties properties; @@ -53,4 +53,4 @@ public class MultipartConfig { factory.setLocation(location); return factory.createMultipartConfig(); } -} \ No newline at end of file +} diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java index 2859ac41..6f93ddc4 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java @@ -14,13 +14,13 @@ import cn.odboy.system.framework.permission.core.handler.UserDetailsHandler; import cn.odboy.util.KitBeanUtil; import cn.odboy.util.KitRsaEncryptUtil; import cn.odboy.util.KitValidUtil; +import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; -import javax.servlet.http.HttpServletRequest; /** * 用户认证 @@ -28,76 +28,76 @@ import javax.servlet.http.HttpServletRequest; @Service public class SystemAuthService { - @Autowired - private AppProperties properties; - @Autowired - private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; - @Autowired - private TokenProvider tokenProvider; - @Autowired - private PasswordEncoder passwordEncoder; - @Autowired - private UserDetailsHandler userDetailsService; - @Autowired - private SystemCaptchaService systemCaptchaService; + @Autowired + private AppProperties properties; + @Autowired + private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; + @Autowired + private TokenProvider tokenProvider; + @Autowired + private PasswordEncoder passwordEncoder; + @Autowired + private UserDetailsHandler userDetailsService; + @Autowired + private SystemCaptchaService systemCaptchaService; - /** - * 登录 -> TestPassed - */ - public SystemAuthVo doLogin(SystemUserLoginArgs loginArgs, HttpServletRequest request) throws Exception { - KitValidUtil.notNull(loginArgs); + /** + * 登录 -> TestPassed + */ + public SystemAuthVo doLogin(SystemUserLoginArgs loginArgs, HttpServletRequest request) throws Exception { + KitValidUtil.notNull(loginArgs); - // 密码解密 - String password = - KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginArgs.getPassword()); - // 校验验证码 - systemCaptchaService.validate(loginArgs.getUuid(), loginArgs.getCode()); - // 获取用户信息 - SystemUserJwtVo jwtUser = userDetailsService.loadUserByUsername(loginArgs.getUsername()); - // 验证用户密码 - if (!passwordEncoder.matches(password, jwtUser.getPassword())) { - throw new BadRequestException("登录密码错误"); - } - - // 登录验证 - Authentication authentication = - new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities()); - SecurityContextHolder.getContext().setAuthentication(authentication); - - // 生成令牌 - String token = tokenProvider.createToken(jwtUser); - // 返回 token 与 用户信息 - SystemAuthVo authInfo = new SystemAuthVo(); - authInfo.setToken(String.format("%s %s", SystemConst.TOKEN_PREFIX, token)); - /// 这里是为了清空密码 - authInfo.setUser(KitBeanUtil.copyToClass(jwtUser, SystemUserInfoVo.class)); - - if (properties.getLogin().isSingle()) { - // 踢掉之前已经登录的token - systemUserOnlineInfoDAO.kickOutByUsername(loginArgs.getUsername()); - } - // 保存在线信息 - systemUserOnlineInfoDAO.saveUserJwtModelByToken(jwtUser, token, request); - // 返回登录信息 - return authInfo; + // 密码解密 + String password = + KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginArgs.getPassword()); + // 校验验证码 + systemCaptchaService.validate(loginArgs.getUuid(), loginArgs.getCode()); + // 获取用户信息 + SystemUserJwtVo jwtUser = userDetailsService.loadUserByUsername(loginArgs.getUsername()); + // 验证用户密码 + if (!passwordEncoder.matches(password, jwtUser.getPassword())) { + throw new BadRequestException("登录密码错误"); } - /** - * 获取当前登录人信息 -> TestPassed - */ - public SystemUserJwtVo getCurrentUserInfo() { - SystemUserJwtVo jwtUser = (SystemUserJwtVo)KitSecurityHelper.getCurrentUser(); - if (jwtUser.getUser() != null) { - jwtUser.getUser().setPassword(null); - } - return jwtUser; - } + // 登录验证 + Authentication authentication = + new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities()); + SecurityContextHolder.getContext().setAuthentication(authentication); - /** - * 退出登录 -> TestPassed - */ - public void doLogout(HttpServletRequest request) { - String token = tokenProvider.getToken(request); - systemUserOnlineInfoDAO.logoutByToken(token); + // 生成令牌 + String token = tokenProvider.createToken(jwtUser); + // 返回 token 与 用户信息 + SystemAuthVo authInfo = new SystemAuthVo(); + authInfo.setToken(String.format("%s %s", SystemConst.TOKEN_PREFIX, token)); + /// 这里是为了清空密码 + authInfo.setUser(KitBeanUtil.copyToClass(jwtUser, SystemUserInfoVo.class)); + + if (properties.getLogin().isSingle()) { + // 踢掉之前已经登录的token + systemUserOnlineInfoDAO.kickOutByUsername(loginArgs.getUsername()); } + // 保存在线信息 + systemUserOnlineInfoDAO.saveUserJwtModelByToken(jwtUser, token, request); + // 返回登录信息 + return authInfo; + } + + /** + * 获取当前登录人信息 -> TestPassed + */ + public SystemUserJwtVo getCurrentUserInfo() { + SystemUserJwtVo jwtUser = (SystemUserJwtVo) KitSecurityHelper.getCurrentUser(); + if (jwtUser.getUser() != null) { + jwtUser.getUser().setPassword(null); + } + return jwtUser; + } + + /** + * 退出登录 -> TestPassed + */ + public void doLogout(HttpServletRequest request) { + String token = tokenProvider.getToken(request); + systemUserOnlineInfoDAO.logoutByToken(token); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java index 2a6776e3..6f1e9613 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java @@ -10,9 +10,9 @@ import cn.odboy.framework.redis.KitRedisHelper; import cn.odboy.system.dal.model.response.SystemCaptchaVo; import cn.odboy.system.dal.redis.SystemCacheKey; import com.wf.captcha.base.Captcha; +import java.util.concurrent.TimeUnit; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.concurrent.TimeUnit; /** * 验证码 @@ -20,50 +20,49 @@ import java.util.concurrent.TimeUnit; @Service public class SystemCaptchaService { - @Autowired - private KitRedisHelper redisHelper; - @Autowired - private AppProperties properties; + @Autowired + private KitRedisHelper redisHelper; + @Autowired + private AppProperties properties; - /** - * 获取登录验证码 -> TestPassed - */ - public SystemCaptchaVo getLoginCaptcha() { - // 获取运算的结果 - Captcha captcha = properties.getLogin().getCaptchaSetting().getCaptcha(); - String uuid = SystemCacheKey.CAPTCHA_LOGIN + IdUtil.simpleUUID(); - //当验证码类型为 arithmetic时且长度 >= 2 时, captcha.text()的结果有几率为浮点型 - String captchaValue = captcha.text(); - if (captcha.getCharType() - 1 == CaptchaCodeEnum.ARITHMETIC.ordinal() && captchaValue.contains( - SystemConst.SYMBOL_DOT)) { - captchaValue = captchaValue.split("\\.")[0]; - } - // 保存 - redisHelper.set(uuid, captchaValue, properties.getLogin().getCaptchaSetting().getExpiration(), - TimeUnit.MINUTES); - // 验证码信息 - SystemCaptchaVo captchaVo = new SystemCaptchaVo(); - captchaVo.setUuid(uuid); - captchaVo.setImg(captcha.toBase64()); - return captchaVo; + /** + * 获取登录验证码 -> TestPassed + */ + public SystemCaptchaVo getLoginCaptcha() { + // 获取运算的结果 + Captcha captcha = properties.getLogin().getCaptchaSetting().getCaptcha(); + String uuid = SystemCacheKey.CAPTCHA_LOGIN + IdUtil.simpleUUID(); + //当验证码类型为 arithmetic时且长度 >= 2 时, captcha.text()的结果有几率为浮点型 + String captchaValue = captcha.text(); + if (captcha.getCharType() - 1 == CaptchaCodeEnum.ARITHMETIC.ordinal() && captchaValue.contains( + SystemConst.SYMBOL_DOT)) { + captchaValue = captchaValue.split("\\.")[0]; } + // 保存 + redisHelper.set(uuid, captchaValue, properties.getLogin().getCaptchaSetting().getExpiration(), TimeUnit.MINUTES); + // 验证码信息 + SystemCaptchaVo captchaVo = new SystemCaptchaVo(); + captchaVo.setUuid(uuid); + captchaVo.setImg(captcha.toBase64()); + return captchaVo; + } - /** - * 验证验证码 -> TestPassed - * - * @param uuid 验证码uuid - * @param inputCode 用户输入的验证码 - */ - public void validate(String uuid, String inputCode) { - // 查询验证码 - String code = redisHelper.get(uuid, String.class); - if (StrUtil.isBlank(code)) { - throw new BadRequestException("验证码不存在或已过期"); - } - // 清除验证码 - redisHelper.del(uuid); - if (StrUtil.isBlank(inputCode) || !code.equalsIgnoreCase(inputCode)) { - throw new BadRequestException("验证码错误"); - } + /** + * 验证验证码 -> TestPassed + * + * @param uuid 验证码uuid + * @param inputCode 用户输入的验证码 + */ + public void validate(String uuid, String inputCode) { + // 查询验证码 + String code = redisHelper.get(uuid, String.class); + if (StrUtil.isBlank(code)) { + throw new BadRequestException("验证码不存在或已过期"); } + // 清除验证码 + redisHelper.del(uuid); + if (StrUtil.isBlank(inputCode) || !code.equalsIgnoreCase(inputCode)) { + throw new BadRequestException("验证码错误"); + } + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java index bc83e539..beb91250 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java @@ -20,14 +20,14 @@ import cn.odboy.system.constant.SystemDataScopeEnum; import cn.odboy.system.dal.dataobject.SystemDeptTb; import cn.odboy.system.dal.dataobject.SystemRoleTb; import cn.odboy.system.dal.model.response.SystemUserVo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** * 数据权限 @@ -37,61 +37,60 @@ import java.util.stream.Collectors; @Service public class SystemDataService { - @Autowired - private SystemUserRoleService systemUserRoleService; - @Autowired - private SystemDeptService systemDeptService; - @Autowired - private SystemRoleDeptService systemRoleDeptService; + @Autowired + private SystemUserRoleService systemUserRoleService; + @Autowired + private SystemDeptService systemDeptService; + @Autowired + private SystemRoleDeptService systemRoleDeptService; - /** - * 获取数据权限 -> TestPassed - * - * @param user / - * @return / - */ - public List queryDeptIdByArgs(SystemUserVo user) { - List deptIds = new ArrayList<>(); - // 查询用户角色 - Set roleList = systemUserRoleService.listUserRoleByUserId(user.getId()); - // 获取对应的部门ID - for (SystemRoleTb role : roleList) { - SystemDataScopeEnum dataScopeEnum = SystemDataScopeEnum.find(role.getDataScope()); - switch (Objects.requireNonNull(dataScopeEnum)) { - case THIS_LEVEL: - Long currentDeptId = user.getDept().getId(); - deptIds.add(currentDeptId); - break; - case CUSTOMIZE: - // 优化 283ms -> 51 ms - List customDeptIds = this.queryCustomDataPermissionByArgs(deptIds, role.getId()); - deptIds.addAll(customDeptIds); - break; - default: - return new ArrayList<>(); - } - } - return deptIds.stream().distinct().collect(Collectors.toList()); + /** + * 获取数据权限 -> TestPassed + * + * @param user / + * @return / + */ + public List queryDeptIdByArgs(SystemUserVo user) { + List deptIds = new ArrayList<>(); + // 查询用户角色 + Set roleList = systemUserRoleService.listUserRoleByUserId(user.getId()); + // 获取对应的部门ID + for (SystemRoleTb role : roleList) { + SystemDataScopeEnum dataScopeEnum = SystemDataScopeEnum.find(role.getDataScope()); + switch (Objects.requireNonNull(dataScopeEnum)) { + case THIS_LEVEL: + Long currentDeptId = user.getDept().getId(); + deptIds.add(currentDeptId); + break; + case CUSTOMIZE: + // 优化 283ms -> 51 ms + List customDeptIds = this.queryCustomDataPermissionByArgs(deptIds, role.getId()); + deptIds.addAll(customDeptIds); + break; + default: + return new ArrayList<>(); + } } + return deptIds.stream().distinct().collect(Collectors.toList()); + } - /** - * 获取自定义的数据权限 -> TestPassed - * - * @param deptIds 部门ID(外部数据) - * @param roleId 角色ID - * @return 数据权限ID(所有部门ID数据) - */ - private List queryCustomDataPermissionByArgs(List deptIds, Long roleId) { - Set deptList = systemRoleDeptService.listUserDeptByRoleId(roleId); - Map> deptPidMap = - systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); - for (SystemDeptTb dept : deptList) { - deptIds.add(dept.getId()); - List deptChildren = deptPidMap.getOrDefault(dept.getId(), null); - if (CollUtil.isNotEmpty(deptChildren)) { - deptIds.addAll(systemDeptService.queryChildDeptIdByDeptIds(deptChildren, deptPidMap)); - } - } - return deptIds; + /** + * 获取自定义的数据权限 -> TestPassed + * + * @param deptIds 部门ID(外部数据) + * @param roleId 角色ID + * @return 数据权限ID(所有部门ID数据) + */ + private List queryCustomDataPermissionByArgs(List deptIds, Long roleId) { + Set deptList = systemRoleDeptService.listUserDeptByRoleId(roleId); + Map> deptPidMap = systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); + for (SystemDeptTb dept : deptList) { + deptIds.add(dept.getId()); + List deptChildren = deptPidMap.getOrDefault(dept.getId(), null); + if (CollUtil.isNotEmpty(deptChildren)) { + deptIds.addAll(systemDeptService.queryChildDeptIdByDeptIds(deptChildren, deptPidMap)); + } } + return deptIds; + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java index e7a7f069..37221ce4 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java @@ -36,10 +36,6 @@ import cn.odboy.util.KitClassUtil; import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import javax.servlet.http.HttpServletResponse; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collections; @@ -51,458 +47,462 @@ import java.util.Map; import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemDeptService { - @Autowired - private SystemDeptMapper systemDeptMapper; - @Autowired - private SystemUserDeptService systemUserDeptService; - @Autowired - private SystemRoleDeptService systemRoleDeptService; + @Autowired + private SystemDeptMapper systemDeptMapper; + @Autowired + private SystemUserDeptService systemUserDeptService; + @Autowired + private SystemRoleDeptService systemRoleDeptService; - /** - * 创建 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveDept(SystemCreateDeptArgs args) { - KitValidUtil.notNull(args); + /** + * 创建 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveDept(SystemCreateDeptArgs args) { + KitValidUtil.notNull(args); - SystemDeptTb record = KitBeanUtil.copyToClass(args, SystemDeptTb.class); - systemDeptMapper.insert(record); + SystemDeptTb record = KitBeanUtil.copyToClass(args, SystemDeptTb.class); + systemDeptMapper.insert(record); - this.updateDeptSubCnt(args.getPid()); + this.updateDeptSubCnt(args.getPid()); + } + + /** + * 编辑 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateDeptById(SystemDeptTb args) { + KitValidUtil.notNull(args); + // 旧的父部门 + Long oldPid = this.getDeptById(args.getId()).getPid(); + // 新的父部门 + Long newPid = args.getPid(); + if (args.getPid() != null && args.getId().equals(args.getPid())) { + throw new BadRequestException("上级不能为自己"); } + SystemDeptTb dept = systemDeptMapper.selectById(args.getId()); + args.setId(dept.getId()); + systemDeptMapper.updateById(args); + this.updateDeptSubCnt(oldPid); + this.updateDeptSubCnt(newPid); + } - /** - * 编辑 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateDeptById(SystemDeptTb args) { - KitValidUtil.notNull(args); - // 旧的父部门 - Long oldPid = this.getDeptById(args.getId()).getPid(); - // 新的父部门 - Long newPid = args.getPid(); - if (args.getPid() != null && args.getId().equals(args.getPid())) { - throw new BadRequestException("上级不能为自己"); + /** + * 根据部门id获取部门信息 -> TestPassed + * + * @param id 部门id + * @return / + */ + private SystemDeptTb getDeptById(Long id) { + return systemDeptMapper.selectById(id); + } + + /** + * 删除 + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteDeptByIds(Set ids) { + // 获取部门, 和其所有子部门 + Set depts = this.traverseDeptByIdWithPids(ids); + // 验证是否被角色或用户关联 + this.verifyBindRelationByIds(depts); + for (SystemDeptVo dept : depts) { + systemDeptMapper.deleteById(dept.getId()); + this.updateDeptSubCnt(dept.getPid()); + } + } + + /** + * 更新父节点中子节点数目 -> TestPassed + * + * @param deptId / + */ + @Transactional(rollbackFor = Exception.class) + public void updateDeptSubCnt(Long deptId) { + if (deptId != null) { + long count = this.countDeptByPid(deptId); + systemDeptMapper.updateDeptSubCountById(count, deptId); + } + } + + private long countDeptByPid(Long pid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemDeptTb::getPid, pid); + return systemDeptMapper.selectCount(wrapper); + } + + /** + * 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表 + */ + private List deduplication(List list) { + List deptList = new ArrayList<>(); + // 使用 Set 存储所有部门的 id + Set idSet = list.stream().map(SystemDeptTb::getId).collect(Collectors.toSet()); + // 遍历部门列表, 筛选出没有父部门的部门 + for (SystemDeptTb dept : list) { + if (!idSet.contains(dept.getPid())) { + deptList.add(dept); + } + } + return deptList; + } + + private List queryDeptByArgs(SystemQueryDeptArgs args) { + KitValidUtil.notNull(args); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(CollUtil.isNotEmpty(args.getIds()), SystemDeptTb::getId, args.getIds()); + wrapper.like(StrUtil.isNotBlank(args.getName()), SystemDeptTb::getName, args.getName()); + wrapper.eq(args.getEnabled() != null, SystemDeptTb::getEnabled, args.getEnabled()); + wrapper.eq(args.getPid() != null, SystemDeptTb::getPid, args.getPid()); + wrapper.isNull(args.getPidIsNull() != null, SystemDeptTb::getPid); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemDeptTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + } + wrapper.orderByAsc(SystemDeptTb::getDeptSort); + return systemDeptMapper.selectList(wrapper); + } + + /** + * 查询所有数据 + * + * @param args 条件 + * @param isQuery / + * @return / + * @throws Exception / + */ + public List queryAllDeptByArgs(SystemQueryDeptArgs args, Boolean isQuery) throws Exception { + String dataScopeType = KitSecurityHelper.getDataScopeType(); + if (isQuery) { + if (dataScopeType.equals(SystemDataScopeEnum.ALL.getValue())) { + args.setPidIsNull(true); + } + List fields = KitClassUtil.getAllFields(args.getClass(), new ArrayList<>()); + List fieldNames = new ArrayList<>() {{ + add("pidIsNull"); + add("enabled"); + }}; + for (Field field : fields) { + // 设置对象的访问权限, 保证对private的属性的访问 + field.setAccessible(true); + Object val = field.get(args); + if (fieldNames.contains(field.getName())) { + continue; } - SystemDeptTb dept = systemDeptMapper.selectById(args.getId()); - args.setId(dept.getId()); - systemDeptMapper.updateById(args); - this.updateDeptSubCnt(oldPid); - this.updateDeptSubCnt(newPid); - } - - /** - * 根据部门id获取部门信息 -> TestPassed - * - * @param id 部门id - * @return / - */ - private SystemDeptTb getDeptById(Long id) { - return systemDeptMapper.selectById(id); - } - - /** - * 删除 - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteDeptByIds(Set ids) { - // 获取部门, 和其所有子部门 - Set depts = this.traverseDeptByIdWithPids(ids); - // 验证是否被角色或用户关联 - this.verifyBindRelationByIds(depts); - for (SystemDeptVo dept : depts) { - systemDeptMapper.deleteById(dept.getId()); - this.updateDeptSubCnt(dept.getPid()); + if (ObjectUtil.isNotNull(val)) { + args.setPidIsNull(null); + break; } + } } + // 数据权限 + args.setIds(KitSecurityHelper.getCurrentUserDataScope()); + List list = this.queryDeptByArgs(args); + // 如果为空, 就代表为自定义权限或者本级权限, 就需要去重, 不理解可以注释掉,看查询结果 + if (StrUtil.isBlank(dataScopeType)) { + return this.deduplication(list); + } + return list; + } - /** - * 更新父节点中子节点数目 -> TestPassed - * - * @param deptId / - */ - @Transactional(rollbackFor = Exception.class) - public void updateDeptSubCnt(Long deptId) { - if (deptId != null) { - long count = this.countDeptByPid(deptId); - systemDeptMapper.updateDeptSubCountById(count, deptId); + /** + * 根据ID查询 + * + * @param id / + * @return / + */ + public SystemDeptVo getDeptVoById(Long id) { + return KitBeanUtil.copyToClass(systemDeptMapper.selectById(id), SystemDeptVo.class); + } + + /** + * 获取部门下所有关联的部门 + * + * @param deptTbList / + * @param depts / + */ + private void queryRelationDeptByArgs(List deptTbList, Set depts) { + for (SystemDeptVo dept : deptTbList) { + depts.add(dept); + List deptList = this.listDeptVoByPid(dept.getId()); + if (CollUtil.isNotEmpty(deptList)) { + queryRelationDeptByArgs(deptList, depts); + } + } + } + + private List listDeptVoByPid(Long pid) { + return KitBeanUtil.copyToList(this.listDeptByPid(pid), SystemDeptVo.class); + } + + public List queryChildDeptIdByDeptIds(List deptList, Map> deptPidMap) { + List list = new ArrayList<>(); + for (SystemDeptTb systemDeptTb : deptList) { + if (systemDeptTb != null && systemDeptTb.getEnabled()) { + List deptList1 = deptPidMap.getOrDefault(systemDeptTb.getId(), null); + if (CollUtil.isNotEmpty(deptList1)) { + list.addAll(this.queryChildDeptIdByDeptIds(deptList1, deptPidMap)); } + list.add(systemDeptTb.getId()); + } } + return list; + } - private long countDeptByPid(Long pid) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemDeptTb::getPid, pid); - return systemDeptMapper.selectCount(wrapper); + /** + * 根据ID获取同级与上级数据 + * + * @param dept / + * @param deptList / + * @return / + */ + private List querySuperiorDeptByPid(SystemDeptVo dept, List deptList) { + if (dept.getPid() == null) { + deptList.addAll(this.listRootDept()); + return deptList; } + deptList.addAll(this.listDeptVoByPid(dept.getPid())); + return querySuperiorDeptByPid(this.getDeptVoById(dept.getPid()), deptList); + } - /** - * 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表 - */ - private List deduplication(List list) { - List deptList = new ArrayList<>(); - // 使用 Set 存储所有部门的 id - Set idSet = list.stream().map(SystemDeptTb::getId).collect(Collectors.toSet()); - // 遍历部门列表, 筛选出没有父部门的部门 - for (SystemDeptTb dept : list) { - if (!idSet.contains(dept.getPid())) { - deptList.add(dept); - } + private List listRootDept() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.isNull(SystemDeptTb::getPid); + return KitBeanUtil.copyToList(systemDeptMapper.selectList(wrapper), SystemDeptVo.class); + } + + /** + * 构建树形数据 + * + * @return / + */ + public KitPageResult searchDeptTree(List ids, Boolean exclude) { + Set deptSet1 = new LinkedHashSet<>(); + for (Long id : ids) { + // 同级数据 + SystemDeptVo dept = this.getDeptVoById(id); + // 上级数据 + List depts = this.querySuperiorDeptByPid(dept, new ArrayList<>()); + if (exclude) { + for (SystemDeptVo data : depts) { + if (data.getId().equals(dept.getPid())) { + data.setSubCount(data.getSubCount() - 1); + } } - return deptList; + // 编辑部门时不显示自己以及自己下级的数据, 避免出现PID数据环形问题 + depts = depts.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toList()); + } + deptSet1.addAll(depts); } - - private List queryDeptByArgs(SystemQueryDeptArgs args) { - KitValidUtil.notNull(args); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(CollUtil.isNotEmpty(args.getIds()), SystemDeptTb::getId, args.getIds()); - wrapper.like(StrUtil.isNotBlank(args.getName()), SystemDeptTb::getName, args.getName()); - wrapper.eq(args.getEnabled() != null, SystemDeptTb::getEnabled, args.getEnabled()); - wrapper.eq(args.getPid() != null, SystemDeptTb::getPid, args.getPid()); - wrapper.isNull(args.getPidIsNull() != null, SystemDeptTb::getPid); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemDeptTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + List deptList = new ArrayList<>(deptSet1); + // 构建部门树 + Set trees = new LinkedHashSet<>(); + Set deptSet = new LinkedHashSet<>(); + List deptNames = deptList.stream().map(SystemDeptVo::getName).collect(Collectors.toList()); + boolean isChild; + for (SystemDeptVo dept : deptList) { + isChild = false; + if (dept.getPid() == null) { + trees.add(dept); + } + for (SystemDeptVo it : deptList) { + if (it.getPid() != null && dept.getId().equals(it.getPid())) { + isChild = true; + if (dept.getChildren() == null) { + dept.setChildren(new ArrayList<>()); + } + dept.getChildren().add(it); } - wrapper.orderByAsc(SystemDeptTb::getDeptSort); - return systemDeptMapper.selectList(wrapper); + } + if (isChild) { + deptSet.add(dept); + } else if (dept.getPid() != null && !deptNames.contains(this.getDeptVoById(dept.getPid()).getName())) { + deptSet.add(dept); + } } + if (CollUtil.isEmpty(trees)) { + trees = deptSet; + } + KitPageResult baseResult = new KitPageResult<>(); + baseResult.setContent(CollUtil.isEmpty(trees) ? new ArrayList<>(deptSet) : new ArrayList<>(trees)); + baseResult.setTotalElements(deptSet.size()); + return baseResult; + } - /** - * 查询所有数据 - * - * @param args 条件 - * @param isQuery / - * @return / - * @throws Exception / - */ - public List queryAllDeptByArgs(SystemQueryDeptArgs args, Boolean isQuery) throws Exception { - String dataScopeType = KitSecurityHelper.getDataScopeType(); - if (isQuery) { - if (dataScopeType.equals(SystemDataScopeEnum.ALL.getValue())) { - args.setPidIsNull(true); - } - List fields = KitClassUtil.getAllFields(args.getClass(), new ArrayList<>()); - List fieldNames = new ArrayList<>() {{ - add("pidIsNull"); - add("enabled"); - }}; - for (Field field : fields) { - // 设置对象的访问权限, 保证对private的属性的访问 - field.setAccessible(true); - Object val = field.get(args); - if (fieldNames.contains(field.getName())) { - continue; - } - if (ObjectUtil.isNotNull(val)) { - args.setPidIsNull(null); - break; - } - } - } - // 数据权限 - args.setIds(KitSecurityHelper.getCurrentUserDataScope()); - List list = this.queryDeptByArgs(args); - // 如果为空, 就代表为自定义权限或者本级权限, 就需要去重, 不理解可以注释掉,看查询结果 - if (StrUtil.isBlank(dataScopeType)) { - return this.deduplication(list); - } - return list; + /** + * 验证是否被角色或用户关联 + * + * @param deptSet / + */ + public void verifyBindRelationByIds(Set deptSet) { + Set deptIds = deptSet.stream().map(SystemDeptVo::getId).collect(Collectors.toSet()); + if (systemUserDeptService.countUserByDeptIds(deptIds) > 0) { + throw new BadRequestException("所选部门存在用户关联,请解除后再试!"); } + if (systemRoleDeptService.countRoleByDeptIds(deptIds) > 0) { + throw new BadRequestException("所选部门存在角色关联,请解除后再试!"); + } + } - /** - * 根据ID查询 - * - * @param id / - * @return / - */ - public SystemDeptVo getDeptVoById(Long id) { - return KitBeanUtil.copyToClass(systemDeptMapper.selectById(id), SystemDeptVo.class); - } + private List listEnabledDepts() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemDeptTb::getEnabled, 1); + return systemDeptMapper.selectList(wrapper); + } - /** - * 获取部门下所有关联的部门 - * - * @param deptTbList / - * @param depts / - */ - private void queryRelationDeptByArgs(List deptTbList, Set depts) { - for (SystemDeptVo dept : deptTbList) { - depts.add(dept); - List deptList = this.listDeptVoByPid(dept.getId()); - if (CollUtil.isNotEmpty(deptList)) { - queryRelationDeptByArgs(deptList, depts); - } - } + /** + * 遍历所有部门和子部门 + * + * @param ids / + */ + public Set traverseDeptByIdWithPids(Set ids) { + Set depts = new HashSet<>(); + for (Long id : ids) { + // 根部门 + depts.add(this.getDeptVoById(id)); + // 子部门 + List deptList = this.listDeptVoByPid(id); + if (CollUtil.isNotEmpty(deptList)) { + queryRelationDeptByArgs(deptList, depts); + } } + return depts; + } - private List listDeptVoByPid(Long pid) { - return KitBeanUtil.copyToList(this.listDeptByPid(pid), SystemDeptVo.class); - } + public List listDeptSelectDataSource() { + List depts = this.listEnabledDepts(); + return buildDeptSelectOptions(depts); + } - public List queryChildDeptIdByDeptIds(List deptList, Map> deptPidMap) { - List list = new ArrayList<>(); - for (SystemDeptTb systemDeptTb : deptList) { - if (systemDeptTb != null && systemDeptTb.getEnabled()) { - List deptList1 = deptPidMap.getOrDefault(systemDeptTb.getId(), null); - if (CollUtil.isNotEmpty(deptList1)) { - list.addAll(this.queryChildDeptIdByDeptIds(deptList1, deptPidMap)); - } - list.add(systemDeptTb.getId()); - } - } - return list; + private List buildDeptSelectOptions(List depts) { + // 获取所有部门并按父子关系组织 + Map deptMap = + depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); + List options = new ArrayList<>(); + for (SystemDeptTb dept : depts) { + // 构建部门ID路径 + List pathIds = new ArrayList<>(); + buildDeptIdPath(dept, deptMap, pathIds); + // 反转路径,从顶级部门到当前部门 + Collections.reverse(pathIds); + SystemProductLineVo dto = new SystemProductLineVo(); + dto.setValue(dept.getId()); + dto.setIdPath(pathIds.stream().map(String::valueOf).collect(Collectors.joining("-"))); + // 保留名称路径用于显示 + dto.setLabel(buildNamePath(dept, deptMap)); + options.add(dto); } + // 按部门名称路径排序 + options.sort(Comparator.comparing(SystemProductLineVo::getLabel)); + return options; + } - /** - * 根据ID获取同级与上级数据 - * - * @param dept / - * @param deptList / - * @return / - */ - private List querySuperiorDeptByPid(SystemDeptVo dept, List deptList) { - if (dept.getPid() == null) { - deptList.addAll(this.listRootDept()); - return deptList; - } - deptList.addAll(this.listDeptVoByPid(dept.getPid())); - return querySuperiorDeptByPid(this.getDeptVoById(dept.getPid()), deptList); + private void buildDeptIdPath(SystemDeptTb dept, Map deptMap, List pathIds) { + pathIds.add(dept.getId()); + if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) { + buildDeptIdPath(deptMap.get(dept.getPid()), deptMap, pathIds); } + } - private List listRootDept() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.isNull(SystemDeptTb::getPid); - return KitBeanUtil.copyToList(systemDeptMapper.selectList(wrapper), SystemDeptVo.class); - } + private String buildNamePath(SystemDeptTb dept, Map deptMap) { + List pathNames = new ArrayList<>(); + buildDeptNamePath(dept, deptMap, pathNames); + Collections.reverse(pathNames); + return String.join(" / ", pathNames); + } - /** - * 构建树形数据 - * - * @return / - */ - public KitPageResult searchDeptTree(List ids, Boolean exclude) { - Set deptSet1 = new LinkedHashSet<>(); - for (Long id : ids) { - // 同级数据 - SystemDeptVo dept = this.getDeptVoById(id); - // 上级数据 - List depts = this.querySuperiorDeptByPid(dept, new ArrayList<>()); - if (exclude) { - for (SystemDeptVo data : depts) { - if (data.getId().equals(dept.getPid())) { - data.setSubCount(data.getSubCount() - 1); - } - } - // 编辑部门时不显示自己以及自己下级的数据, 避免出现PID数据环形问题 - depts = depts.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toList()); - } - deptSet1.addAll(depts); - } - List deptList = new ArrayList<>(deptSet1); - // 构建部门树 - Set trees = new LinkedHashSet<>(); - Set deptSet = new LinkedHashSet<>(); - List deptNames = deptList.stream().map(SystemDeptVo::getName).collect(Collectors.toList()); - boolean isChild; - for (SystemDeptVo dept : deptList) { - isChild = false; - if (dept.getPid() == null) { - trees.add(dept); - } - for (SystemDeptVo it : deptList) { - if (it.getPid() != null && dept.getId().equals(it.getPid())) { - isChild = true; - if (dept.getChildren() == null) { - dept.setChildren(new ArrayList<>()); - } - dept.getChildren().add(it); - } - } - if (isChild) { - deptSet.add(dept); - } else if (dept.getPid() != null && !deptNames.contains(this.getDeptVoById(dept.getPid()).getName())) { - deptSet.add(dept); - } - } - if (CollUtil.isEmpty(trees)) { - trees = deptSet; - } - KitPageResult baseResult = new KitPageResult<>(); - baseResult.setContent(CollUtil.isEmpty(trees) ? new ArrayList<>(deptSet) : new ArrayList<>(trees)); - baseResult.setTotalElements(deptSet.size()); - return baseResult; + private void buildDeptNamePath(SystemDeptTb dept, Map deptMap, List pathNames) { + pathNames.add(dept.getName()); + if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) { + buildDeptNamePath(deptMap.get(dept.getPid()), deptMap, pathNames); } + } - /** - * 验证是否被角色或用户关联 - * - * @param deptSet / - */ - public void verifyBindRelationByIds(Set deptSet) { - Set deptIds = deptSet.stream().map(SystemDeptVo::getId).collect(Collectors.toSet()); - if (systemUserDeptService.countUserByDeptIds(deptIds) > 0) { - throw new BadRequestException("所选部门存在用户关联,请解除后再试!"); - } - if (systemRoleDeptService.countRoleByDeptIds(deptIds) > 0) { - throw new BadRequestException("所选部门存在角色关联,请解除后再试!"); - } + public List listDeptSelectProDataSource() { + List depts = this.listEnabledDepts(); + // 获取所有部门并按父子关系组织 + Map deptMap = + depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); + List options = new ArrayList<>(); + // 构建树形结构 + for (SystemDeptTb dept : depts) { + // 只处理顶级部门(pid为null或0的部门) + if (dept.getPid() == null || dept.getPid() == 0) { + SystemProductLineTreeVo vo = buildDeptTreePro(dept, deptMap); + options.add(vo); + } } + // 按排序字段排序 + options.sort(Comparator.comparingInt(o -> { + Long id = Long.valueOf(o.getValue()); + return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0; + })); + return options; + } - private List listEnabledDepts() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemDeptTb::getEnabled, 1); - return systemDeptMapper.selectList(wrapper); + /** + * 递归构建部门树 + * + * @param dept 当前部门 + * @param deptMap 部门映射 + * @return SystemProductLineTreeVo 树节点 + */ + private SystemProductLineTreeVo buildDeptTreePro(SystemDeptTb dept, Map deptMap) { + SystemProductLineTreeVo vo = new SystemProductLineTreeVo(); + vo.setValue(String.valueOf(dept.getId())); + vo.setLabel(dept.getName()); + // 查找子部门 + List children = new ArrayList<>(); + for (SystemDeptTb childDept : deptMap.values()) { + if (dept.getId().equals(childDept.getPid())) { + children.add(buildDeptTreePro(childDept, deptMap)); + } } + // 子部门按排序字段排序 + children.sort(Comparator.comparingInt(o -> { + Long id = Long.valueOf(o.getValue()); + return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0; + })); + vo.setChildren(children); + return vo; + } - /** - * 遍历所有部门和子部门 - * - * @param ids / - */ - public Set traverseDeptByIdWithPids(Set ids) { - Set depts = new HashSet<>(); - for (Long id : ids) { - // 根部门 - depts.add(this.getDeptVoById(id)); - // 子部门 - List deptList = this.listDeptVoByPid(id); - if (CollUtil.isNotEmpty(deptList)) { - queryRelationDeptByArgs(deptList, depts); - } - } - return depts; - } + public List listDeptByPid(long pid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemDeptTb::getPid, pid); + return systemDeptMapper.selectList(wrapper); + } - public List listDeptSelectDataSource() { - List depts = this.listEnabledDepts(); - return buildDeptSelectOptions(depts); + public void exportDeptXlsx(HttpServletResponse response, SystemQueryDeptArgs args) throws Exception { + List systemDeptTbs = this.queryAllDeptByArgs(args, false); + List rowVos = new ArrayList<>(); + for (SystemDeptTb dataObject : systemDeptTbs) { + SystemDeptExportRowVo rowVo = new SystemDeptExportRowVo(); + rowVo.setName(dataObject.getName()); + rowVo.setEnabled(dataObject.getEnabled() ? SystemZhConst.ENABLE_STR : SystemZhConst.DISABLE_STR); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); } + KitExcelExporter.exportSimple(response, "部门数据", SystemDeptExportRowVo.class, rowVos); + } - private List buildDeptSelectOptions(List depts) { - // 获取所有部门并按父子关系组织 - Map deptMap = - depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); - List options = new ArrayList<>(); - for (SystemDeptTb dept : depts) { - // 构建部门ID路径 - List pathIds = new ArrayList<>(); - buildDeptIdPath(dept, deptMap, pathIds); - // 反转路径,从顶级部门到当前部门 - Collections.reverse(pathIds); - SystemProductLineVo dto = new SystemProductLineVo(); - dto.setValue(dept.getId()); - dto.setIdPath(pathIds.stream().map(String::valueOf).collect(Collectors.joining("-"))); - // 保留名称路径用于显示 - dto.setLabel(buildNamePath(dept, deptMap)); - options.add(dto); - } - // 按部门名称路径排序 - options.sort(Comparator.comparing(SystemProductLineVo::getLabel)); - return options; - } - - private void buildDeptIdPath(SystemDeptTb dept, Map deptMap, List pathIds) { - pathIds.add(dept.getId()); - if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) { - buildDeptIdPath(deptMap.get(dept.getPid()), deptMap, pathIds); - } - } - - private String buildNamePath(SystemDeptTb dept, Map deptMap) { - List pathNames = new ArrayList<>(); - buildDeptNamePath(dept, deptMap, pathNames); - Collections.reverse(pathNames); - return String.join(" / ", pathNames); - } - - private void buildDeptNamePath(SystemDeptTb dept, Map deptMap, List pathNames) { - pathNames.add(dept.getName()); - if (dept.getPid() != null && dept.getPid() != 0 && deptMap.containsKey(dept.getPid())) { - buildDeptNamePath(deptMap.get(dept.getPid()), deptMap, pathNames); - } - } - - public List listDeptSelectProDataSource() { - List depts = this.listEnabledDepts(); - // 获取所有部门并按父子关系组织 - Map deptMap = - depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); - List options = new ArrayList<>(); - // 构建树形结构 - for (SystemDeptTb dept : depts) { - // 只处理顶级部门(pid为null或0的部门) - if (dept.getPid() == null || dept.getPid() == 0) { - SystemProductLineTreeVo vo = buildDeptTreePro(dept, deptMap); - options.add(vo); - } - } - // 按排序字段排序 - options.sort(Comparator.comparingInt(o -> { - Long id = Long.valueOf(o.getValue()); - return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0; - })); - return options; - } - - /** - * 递归构建部门树 - * - * @param dept 当前部门 - * @param deptMap 部门映射 - * @return SystemProductLineTreeVo 树节点 - */ - private SystemProductLineTreeVo buildDeptTreePro(SystemDeptTb dept, Map deptMap) { - SystemProductLineTreeVo vo = new SystemProductLineTreeVo(); - vo.setValue(String.valueOf(dept.getId())); - vo.setLabel(dept.getName()); - // 查找子部门 - List children = new ArrayList<>(); - for (SystemDeptTb childDept : deptMap.values()) { - if (dept.getId().equals(childDept.getPid())) { - children.add(buildDeptTreePro(childDept, deptMap)); - } - } - // 子部门按排序字段排序 - children.sort(Comparator.comparingInt(o -> { - Long id = Long.valueOf(o.getValue()); - return deptMap.get(id) != null ? deptMap.get(id).getDeptSort() : 0; - })); - vo.setChildren(children); - return vo; - } - - public List listDeptByPid(long pid) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemDeptTb::getPid, pid); - return systemDeptMapper.selectList(wrapper); - } - - public void exportDeptXlsx(HttpServletResponse response, SystemQueryDeptArgs args) throws Exception { - List systemDeptTbs = this.queryAllDeptByArgs(args, false); - List rowVos = new ArrayList<>(); - for (SystemDeptTb dataObject : systemDeptTbs) { - SystemDeptExportRowVo rowVo = new SystemDeptExportRowVo(); - rowVo.setName(dataObject.getName()); - rowVo.setEnabled(dataObject.getEnabled() ? SystemZhConst.ENABLE_STR : SystemZhConst.DISABLE_STR); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - KitExcelExporter.exportSimple(response, "部门数据", SystemDeptExportRowVo.class, rowVos); - } - - public List listPidNonNull() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemDeptTb::getEnabled, 1); - wrapper.isNotNull(SystemDeptTb::getPid); - return systemDeptMapper.selectList(wrapper); - } + public List listPidNonNull() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemDeptTb::getEnabled, 1); + wrapper.isNotNull(SystemDeptTb::getPid); + return systemDeptMapper.selectList(wrapper); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java index f7fac543..718cc3eb 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java @@ -31,122 +31,122 @@ import cn.odboy.util.KitValidUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemDictDetailService { - @Autowired - private SystemDictDetailMapper systemDictDetailMapper; - @Autowired - private SystemDictMapper systemDictMapper; + @Autowired + private SystemDictDetailMapper systemDictDetailMapper; + @Autowired + private SystemDictMapper systemDictMapper; - /** - * 创建 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveDictDetail(SystemCreateDictDetailArgs args) { - KitValidUtil.notNull(args); - KitValidUtil.notNull(args.getDict()); - SystemDictDetailTb dictDetail = KitBeanUtil.copyToClass(args, SystemDictDetailTb.class); - dictDetail.setDictId(args.getDict().getId()); - systemDictDetailMapper.insert(dictDetail); + /** + * 创建 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveDictDetail(SystemCreateDictDetailArgs args) { + KitValidUtil.notNull(args); + KitValidUtil.notNull(args.getDict()); + SystemDictDetailTb dictDetail = KitBeanUtil.copyToClass(args, SystemDictDetailTb.class); + dictDetail.setDictId(args.getDict().getId()); + systemDictDetailMapper.insert(dictDetail); + } + + /** + * 编辑 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateDictDetailById(SystemDictDetailTb args) { + SystemDictDetailTb dictDetail = systemDictDetailMapper.selectById(args.getId()); + args.setId(dictDetail.getId()); + systemDictDetailMapper.insertOrUpdate(args); + } + + /** + * 删除 -> TestPassed + * + * @param id / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteDictDetailById(Long id) { + systemDictDetailMapper.deleteById(id); + } + + @Transactional(rollbackFor = Exception.class) + public void deleteDictDetailByDictIds(Set ids) { + if (CollUtil.isNotEmpty(ids)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemDictDetailTb::getDictId, ids); + systemDictDetailMapper.delete(wrapper); } + } - /** - * 编辑 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateDictDetailById(SystemDictDetailTb args) { - SystemDictDetailTb dictDetail = systemDictDetailMapper.selectById(args.getId()); - args.setId(dictDetail.getId()); - systemDictDetailMapper.insertOrUpdate(args); + /** + * 分页查询 -> TestPassed + * + * @param args 条件 + * @param page 分页参数 + * @return / + */ + public KitPageResult searchDictDetail(SystemQueryDictDetailArgs args, + Page page) { + IPage iPage = systemDictDetailMapper.selectPageByArgs(page, args); + List dictIds = + iPage.getRecords().stream().map(SystemDictDetailVo::getDictId).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(dictIds)) { + Map id2ItemMap = + systemDictMapper.selectByIds(dictIds).stream().collect(Collectors.toMap(SystemDictTb::getId, i -> i)); + for (SystemDictDetailVo record : iPage.getRecords()) { + record.setDict(id2ItemMap.get(record.getDictId())); + } } + return KitPageUtil.toPage(iPage); + } - /** - * 删除 -> TestPassed - * - * @param id / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteDictDetailById(Long id) { - systemDictDetailMapper.deleteById(id); + /** + * 根据字典名称获取字典详情 -> TestPassed + * + * @param name 字典名称 + * @return / + */ + public List listDictDetailByName(String name) { + if (StrUtil.isBlank(name)) { + return new ArrayList<>(); } - - @Transactional(rollbackFor = Exception.class) - public void deleteDictDetailByDictIds(Set ids) { - if (CollUtil.isNotEmpty(ids)) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemDictDetailTb::getDictId, ids); - systemDictDetailMapper.delete(wrapper); + List detailVos = systemDictDetailMapper.listDictDetailByName(name); + if (CollUtil.isNotEmpty(detailVos)) { + SystemDictDetailVo systemDictDetailVo = detailVos.stream().findFirst().orElse(null); + if (systemDictDetailVo != null) { + SystemDictTb systemDictTb = systemDictMapper.selectById(systemDictDetailVo.getDictId()); + if (systemDictTb != null) { + for (SystemDictDetailVo detailVo : detailVos) { + detailVo.setDict(systemDictTb); + } } + } } + return detailVos; + } - /** - * 分页查询 -> TestPassed - * - * @param args 条件 - * @param page 分页参数 - * @return / - */ - public KitPageResult searchDictDetail(SystemQueryDictDetailArgs args, - Page page) { - IPage iPage = systemDictDetailMapper.selectPageByArgs(page, args); - List dictIds = - iPage.getRecords().stream().map(SystemDictDetailVo::getDictId).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(dictIds)) { - Map id2ItemMap = - systemDictMapper.selectByIds(dictIds).stream().collect(Collectors.toMap(SystemDictTb::getId, i -> i)); - for (SystemDictDetailVo record : iPage.getRecords()) { - record.setDict(id2ItemMap.get(record.getDictId())); - } - } - return KitPageUtil.toPage(iPage); - } - - /** - * 根据字典名称获取字典详情 -> TestPassed - * - * @param name 字典名称 - * @return / - */ - public List listDictDetailByName(String name) { - if (StrUtil.isBlank(name)) { - return new ArrayList<>(); - } - List detailVos = systemDictDetailMapper.listDictDetailByName(name); - if (CollUtil.isNotEmpty(detailVos)) { - SystemDictDetailVo systemDictDetailVo = detailVos.stream().findFirst().orElse(null); - if (systemDictDetailVo != null) { - SystemDictTb systemDictTb = systemDictMapper.selectById(systemDictDetailVo.getDictId()); - if (systemDictTb != null) { - for (SystemDictDetailVo detailVo : detailVos) { - detailVo.setDict(systemDictTb); - } - } - } - } - return detailVos; - } - - public Map> getDictDetailMap(String dictName) { - String[] names = dictName.split("[,, ]"); - Map> dictMap = new HashMap<>(16); - for (String name : names) { - dictMap.put(name, this.listDictDetailByName(name)); - } - return dictMap; + public Map> getDictDetailMap(String dictName) { + String[] names = dictName.split("[,, ]"); + Map> dictMap = new HashMap<>(16); + for (String name : names) { + dictMap.put(name, this.listDictDetailByName(name)); } + return dictMap; + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictService.java index ba298b9b..471e9dd6 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictService.java @@ -29,111 +29,111 @@ import cn.odboy.util.KitPageUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.List; import java.util.Set; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemDictService { - @Autowired - private SystemDictMapper systemDictMapper; - @Autowired - private SystemDictDetailService systemDictDetailService; + @Autowired + private SystemDictMapper systemDictMapper; + @Autowired + private SystemDictDetailService systemDictDetailService; - /** - * 创建 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveDict(SystemCreateDictArgs args) { - SystemDictTb dictTb = KitBeanUtil.copyToClass(args, SystemDictTb.class); - systemDictMapper.insert(dictTb); - } + /** + * 创建 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveDict(SystemCreateDictArgs args) { + SystemDictTb dictTb = KitBeanUtil.copyToClass(args, SystemDictTb.class); + systemDictMapper.insert(dictTb); + } - /** - * 编辑 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateDictById(SystemDictTb args) { - SystemDictTb dict = systemDictMapper.selectById(args.getId()); - dict.setName(args.getName()); - dict.setDescription(args.getDescription()); - systemDictMapper.insertOrUpdate(dict); - } + /** + * 编辑 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateDictById(SystemDictTb args) { + SystemDictTb dict = systemDictMapper.selectById(args.getId()); + dict.setName(args.getName()); + dict.setDescription(args.getDescription()); + systemDictMapper.insertOrUpdate(dict); + } - /** - * 删除 -> TestPassed - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteDictByIds(Set ids) { - // 删除字典 - systemDictMapper.deleteByIds(ids); - // 删除字典详情 - systemDictDetailService.deleteDictDetailByDictIds(ids); - } + /** + * 删除 -> TestPassed + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteDictByIds(Set ids) { + // 删除字典 + systemDictMapper.deleteByIds(ids); + // 删除字典详情 + systemDictDetailService.deleteDictDetailByDictIds(ids); + } - /** - * 分页查询 -> TestPassed - * - * @param args 条件 - * @param page 分页参数 - * @return / - */ - public KitPageResult searchDict(SystemQueryDictArgs args, Page page) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQueryParams(args, wrapper); - Page selectPage = systemDictMapper.selectPage(page, wrapper); - return KitPageUtil.toPage(selectPage); - } + /** + * 分页查询 -> TestPassed + * + * @param args 条件 + * @param page 分页参数 + * @return / + */ + public KitPageResult searchDict(SystemQueryDictArgs args, Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(args, wrapper); + Page selectPage = systemDictMapper.selectPage(page, wrapper); + return KitPageUtil.toPage(selectPage); + } - private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper wrapper) { - if (args != null) { - wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or() - .like(SystemDictTb::getDescription, args.getBlurry())); - } + private void injectQueryParams(SystemQueryDictArgs args, LambdaQueryWrapper wrapper) { + if (args != null) { + wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemDictTb::getName, args.getBlurry()).or() + .like(SystemDictTb::getDescription, args.getBlurry())); } + } - public List queryDictByArgs(SystemQueryDictArgs args) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQueryParams(args, wrapper); - return systemDictMapper.selectList(wrapper); - } + public List queryDictByArgs(SystemQueryDictArgs args) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(args, wrapper); + return systemDictMapper.selectList(wrapper); + } - public void exportDictXlsx(HttpServletResponse response, SystemQueryDictArgs args) { - List systemDictTbs = this.queryDictByArgs(args); - List rowVos = new ArrayList<>(); - for (SystemDictTb dataObject : systemDictTbs) { - List dictDetails = systemDictDetailService.listDictDetailByName(dataObject.getName()); - if (CollUtil.isEmpty(dictDetails)) { - SystemDictExportRowVo rowVo = new SystemDictExportRowVo(); - rowVo.setName(dataObject.getName()); - rowVo.setDescription(dataObject.getDescription()); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVo.setLabel(""); - rowVo.setValue(""); - rowVos.add(rowVo); - continue; - } - for (SystemDictDetailVo dictDetail : dictDetails) { - SystemDictExportRowVo rowVo = new SystemDictExportRowVo(); - rowVo.setName(dataObject.getName()); - rowVo.setDescription(dataObject.getDescription()); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVo.setLabel(dictDetail.getLabel()); - rowVo.setValue(dictDetail.getValue()); - rowVos.add(rowVo); - } - } - KitExcelExporter.exportSimple(response, "字典数据", SystemDictExportRowVo.class, rowVos); + public void exportDictXlsx(HttpServletResponse response, SystemQueryDictArgs args) { + List systemDictTbs = this.queryDictByArgs(args); + List rowVos = new ArrayList<>(); + for (SystemDictTb dataObject : systemDictTbs) { + List dictDetails = systemDictDetailService.listDictDetailByName(dataObject.getName()); + if (CollUtil.isEmpty(dictDetails)) { + SystemDictExportRowVo rowVo = new SystemDictExportRowVo(); + rowVo.setName(dataObject.getName()); + rowVo.setDescription(dataObject.getDescription()); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVo.setLabel(""); + rowVo.setValue(""); + rowVos.add(rowVo); + continue; + } + for (SystemDictDetailVo dictDetail : dictDetails) { + SystemDictExportRowVo rowVo = new SystemDictExportRowVo(); + rowVo.setName(dataObject.getName()); + rowVo.setDescription(dataObject.getDescription()); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVo.setLabel(dictDetail.getLabel()); + rowVo.setValue(dictDetail.getValue()); + rowVos.add(rowVo); + } } + KitExcelExporter.exportSimple(response, "字典数据", SystemDictExportRowVo.class, rowVos); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemEmailService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemEmailService.java index d18e303b..bd872493 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemEmailService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemEmailService.java @@ -30,134 +30,134 @@ import cn.odboy.system.dal.model.request.SystemSendEmailArgs; import cn.odboy.system.dal.mysql.SystemEmailConfigMapper; import cn.odboy.util.KitDesEncryptUtil; import cn.odboy.util.KitResourceTemplateUtil; +import java.util.Collections; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import java.util.Collections; @Slf4j @Service public class SystemEmailService { - @Autowired - private SystemEmailConfigMapper systemEmailConfigMapper; - @Autowired - private KitRedisHelper redisHelper; - @Autowired - private AppProperties properties; + @Autowired + private SystemEmailConfigMapper systemEmailConfigMapper; + @Autowired + private KitRedisHelper redisHelper; + @Autowired + private AppProperties properties; - /** - * 更新邮件配置 -> TestPassed - * - * @param emailConfig 邮箱配置 - */ - @Transactional(rollbackFor = Exception.class) - public void updateEmailConfigById(SystemEmailConfigTb emailConfig) throws Exception { - SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig(); - if (!emailConfig.getPassword().equals(systemEmailConfigTb.getPassword())) { - // 对称加密 - systemEmailConfigTb.setPassword(KitDesEncryptUtil.desEncrypt(emailConfig.getPassword())); - } - systemEmailConfigTb.setId(1L); - systemEmailConfigMapper.insertOrUpdate(systemEmailConfigTb); + /** + * 更新邮件配置 -> TestPassed + * + * @param emailConfig 邮箱配置 + */ + @Transactional(rollbackFor = Exception.class) + public void updateEmailConfigById(SystemEmailConfigTb emailConfig) throws Exception { + SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig(); + if (!emailConfig.getPassword().equals(systemEmailConfigTb.getPassword())) { + // 对称加密 + systemEmailConfigTb.setPassword(KitDesEncryptUtil.desEncrypt(emailConfig.getPassword())); } + systemEmailConfigTb.setId(1L); + systemEmailConfigMapper.insertOrUpdate(systemEmailConfigTb); + } - /** - * 发送邮件 -> TestPassed - * - * @param sendEmailRequest 邮件发送的内容 - */ - public void sendEmail(SystemSendEmailArgs sendEmailRequest) { - SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig(); - if (systemEmailConfigTb.getId() == null) { - throw new BadRequestException("请先配置, 再操作"); - } - // 封装 - MailAccount account = new MailAccount(); - // 设置用户 - String user = systemEmailConfigTb.getFromUser().split("@")[0]; - account.setUser(user); - account.setHost(systemEmailConfigTb.getHost()); - account.setPort(Integer.parseInt(systemEmailConfigTb.getPort())); - account.setAuth(true); - try { - // 对称解密 - account.setPass(KitDesEncryptUtil.desDecrypt(systemEmailConfigTb.getPassword())); - } catch (Exception e) { - throw new BadRequestException(e.getMessage()); - } - account.setFrom(systemEmailConfigTb.getUser() + "<" + systemEmailConfigTb.getFromUser() + ">"); - // ssl方式发送 - account.setSslEnable(true); - // 使用STARTTLS安全连接 - account.setStarttlsEnable(true); - // 解决jdk8之后默认禁用部分tls协议, 导致邮件发送失败的问题 - account.setSslProtocols("TLSv1 TLSv1.1 TLSv1.2"); - String content = sendEmailRequest.getContent(); - // 发送 - try { - int size = sendEmailRequest.getTos().size(); - Mail.create(account).setTos(sendEmailRequest.getTos().toArray(new String[size])) - .setTitle(sendEmailRequest.getSubject()).setContent(content).setHtml(true) - // 关闭session - .setUseGlobalSession(false).send(); - } catch (Exception e) { - log.error("邮件发送失败", e); - throw new BadRequestException("邮件发送失败"); - } + /** + * 发送邮件 -> TestPassed + * + * @param sendEmailRequest 邮件发送的内容 + */ + public void sendEmail(SystemSendEmailArgs sendEmailRequest) { + SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig(); + if (systemEmailConfigTb.getId() == null) { + throw new BadRequestException("请先配置, 再操作"); } + // 封装 + MailAccount account = new MailAccount(); + // 设置用户 + String user = systemEmailConfigTb.getFromUser().split("@")[0]; + account.setUser(user); + account.setHost(systemEmailConfigTb.getHost()); + account.setPort(Integer.parseInt(systemEmailConfigTb.getPort())); + account.setAuth(true); + try { + // 对称解密 + account.setPass(KitDesEncryptUtil.desDecrypt(systemEmailConfigTb.getPassword())); + } catch (Exception e) { + throw new BadRequestException(e.getMessage()); + } + account.setFrom(systemEmailConfigTb.getUser() + "<" + systemEmailConfigTb.getFromUser() + ">"); + // ssl方式发送 + account.setSslEnable(true); + // 使用STARTTLS安全连接 + account.setStarttlsEnable(true); + // 解决jdk8之后默认禁用部分tls协议, 导致邮件发送失败的问题 + account.setSslProtocols("TLSv1 TLSv1.1 TLSv1.2"); + String content = sendEmailRequest.getContent(); + // 发送 + try { + int size = sendEmailRequest.getTos().size(); + Mail.create(account).setTos(sendEmailRequest.getTos().toArray(new String[size])) + .setTitle(sendEmailRequest.getSubject()).setContent(content).setHtml(true) + // 关闭session + .setUseGlobalSession(false).send(); + } catch (Exception e) { + log.error("邮件发送失败", e); + throw new BadRequestException("邮件发送失败"); + } + } - /** - * 校验邮箱验证码 -> TestPassed - */ - public void checkEmailCaptchaV1(SystemCaptchaBizEnum biEnum, String email, String code) { - String redisKey = biEnum.getRedisKey() + email; - String value = redisHelper.get(redisKey, String.class); - if (value == null || !value.equals(code)) { - throw new BadRequestException("无效验证码"); - } else { - redisHelper.del(redisKey); - } + /** + * 校验邮箱验证码 -> TestPassed + */ + public void checkEmailCaptchaV1(SystemCaptchaBizEnum biEnum, String email, String code) { + String redisKey = biEnum.getRedisKey() + email; + String value = redisHelper.get(redisKey, String.class); + if (value == null || !value.equals(code)) { + throw new BadRequestException("无效验证码"); + } else { + redisHelper.del(redisKey); } + } - /** - * 发送给邮箱验证码 - */ - public void sendCaptcha(SystemCaptchaBizEnum biEnum, String email) { - if (biEnum == null) { - throw new BadRequestException("biEnum必填"); - } - String content; - String redisKey = biEnum.getRedisKey() + email; - String oldCode = redisHelper.get(redisKey, String.class); - if (oldCode == null) { - String code = RandomUtil.randomNumbers(6); - // 存入缓存 - if (!redisHelper.set(redisKey, code, properties.getCaptcha().getExpireTime())) { - throw new BadRequestException("服务异常, 请联系网站负责人"); - } - // 存在就再次发送原来的验证码 - content = KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", code)); - } else { - content = - KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", oldCode)); - } - SystemSendEmailArgs sendEmailRequest = - new SystemSendEmailArgs(Collections.singletonList(email), SystemConst.CURRENT_APP_TITLE, content); - sendEmail(sendEmailRequest); + /** + * 发送给邮箱验证码 + */ + public void sendCaptcha(SystemCaptchaBizEnum biEnum, String email) { + if (biEnum == null) { + throw new BadRequestException("biEnum必填"); } + String content; + String redisKey = biEnum.getRedisKey() + email; + String oldCode = redisHelper.get(redisKey, String.class); + if (oldCode == null) { + String code = RandomUtil.randomNumbers(6); + // 存入缓存 + if (!redisHelper.set(redisKey, code, properties.getCaptcha().getExpireTime())) { + throw new BadRequestException("服务异常, 请联系网站负责人"); + } + // 存在就再次发送原来的验证码 + content = KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", code)); + } else { + content = + KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", oldCode)); + } + SystemSendEmailArgs sendEmailRequest = + new SystemSendEmailArgs(Collections.singletonList(email), SystemConst.CURRENT_APP_TITLE, content); + sendEmail(sendEmailRequest); + } - public SystemEmailConfigTb getLastEmailConfig() { - SystemEmailConfigTb systemEmailConfigTb = systemEmailConfigMapper.selectById(1L); - return systemEmailConfigTb == null ? new SystemEmailConfigTb() : systemEmailConfigTb; - } + public SystemEmailConfigTb getLastEmailConfig() { + SystemEmailConfigTb systemEmailConfigTb = systemEmailConfigMapper.selectById(1L); + return systemEmailConfigTb == null ? new SystemEmailConfigTb() : systemEmailConfigTb; + } - public void checkEmailCaptcha(SystemCheckEmailCaptchaArgs args) { - SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode()); - if (biEnum == null) { - throw new BadRequestException("不支持的业务"); - } - this.checkEmailCaptchaV1(biEnum, args.getEmail(), args.getCode()); + public void checkEmailCaptcha(SystemCheckEmailCaptchaArgs args) { + SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode()); + if (biEnum == null) { + throw new BadRequestException("不支持的业务"); } + this.checkEmailCaptchaV1(biEnum, args.getEmail(), args.getCode()); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java index 392ffdbf..8a1a2169 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java @@ -29,129 +29,129 @@ import cn.odboy.util.KitPageUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.List; import java.util.Set; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemJobService { - @Autowired - private SystemJobMapper systemJobMapper; - @Autowired - private SystemUserJobService systemUserJobService; + @Autowired + private SystemJobMapper systemJobMapper; + @Autowired + private SystemUserJobService systemUserJobService; - /** - * 创建 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveJob(SystemCreateJobArgs args) { - SystemJobTb job = this.getJobByName(args.getName()); - if (job != null) { - throw new BadRequestException("职位名称已存在"); - } - SystemJobTb systemJobTb = KitBeanUtil.copyToClass(args, SystemJobTb.class); - systemJobMapper.insert(systemJobTb); + /** + * 创建 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveJob(SystemCreateJobArgs args) { + SystemJobTb job = this.getJobByName(args.getName()); + if (job != null) { + throw new BadRequestException("职位名称已存在"); } + SystemJobTb systemJobTb = KitBeanUtil.copyToClass(args, SystemJobTb.class); + systemJobMapper.insert(systemJobTb); + } - /** - * 编辑 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateJobById(SystemJobTb args) { - SystemJobTb job = systemJobMapper.selectById(args.getId()); - SystemJobTb old = this.getJobByName(args.getName()); - if (old != null && !old.getId().equals(args.getId())) { - throw new BadRequestException("职位名称已存在"); - } - args.setId(job.getId()); - systemJobMapper.updateById(args); + /** + * 编辑 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateJobById(SystemJobTb args) { + SystemJobTb job = systemJobMapper.selectById(args.getId()); + SystemJobTb old = this.getJobByName(args.getName()); + if (old != null && !old.getId().equals(args.getId())) { + throw new BadRequestException("职位名称已存在"); } + args.setId(job.getId()); + systemJobMapper.updateById(args); + } - /** - * 删除 -> TestPassed - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteJobByIds(Set ids) { - // 验证是否被用户关联 - this.verifyBindRelationByIds(ids); - systemJobMapper.deleteByIds(ids); - } + /** + * 删除 -> TestPassed + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteJobByIds(Set ids) { + // 验证是否被用户关联 + this.verifyBindRelationByIds(ids); + systemJobMapper.deleteByIds(ids); + } - /** - * 分页查询 -> TestPassed - * - * @param args 条件 - * @param page 分页参数 - */ - public KitPageResult searchJobByArgs(SystemQueryJobArgs args, Page page) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQueryParams(args, wrapper); - Page selectPage = systemJobMapper.selectPage(page, wrapper); - return KitPageUtil.toPage(selectPage); - } + /** + * 分页查询 -> TestPassed + * + * @param args 条件 + * @param page 分页参数 + */ + public KitPageResult searchJobByArgs(SystemQueryJobArgs args, Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(args, wrapper); + Page selectPage = systemJobMapper.selectPage(page, wrapper); + return KitPageUtil.toPage(selectPage); + } - /** - * 查询全部数据 -> TestPassed - */ - public List queryJobByArgs(SystemQueryJobArgs args) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQueryParams(args, wrapper); - return systemJobMapper.selectList(wrapper); - } + /** + * 查询全部数据 -> TestPassed + */ + public List queryJobByArgs(SystemQueryJobArgs args) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(args, wrapper); + return systemJobMapper.selectList(wrapper); + } - /** - * 验证是否被用户关联 -> TestPassed - * - * @param ids / - */ - public void verifyBindRelationByIds(Set ids) { - if (systemUserJobService.countUserByJobIds(ids) > 0) { - throw new BadRequestException("所选的岗位中存在用户关联, 请解除关联再试!"); - } + /** + * 验证是否被用户关联 -> TestPassed + * + * @param ids / + */ + public void verifyBindRelationByIds(Set ids) { + if (systemUserJobService.countUserByJobIds(ids) > 0) { + throw new BadRequestException("所选的岗位中存在用户关联, 请解除关联再试!"); } + } - public SystemJobTb getJobByName(String name) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemJobTb::getName, name); - return systemJobMapper.selectOne(wrapper); - } + public SystemJobTb getJobByName(String name) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemJobTb::getName, name); + return systemJobMapper.selectOne(wrapper); + } - public void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper wrapper) { - if (args != null) { - wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName()); - wrapper.eq(args.getEnabled() != null, SystemJobTb::getEnabled, args.getEnabled()); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemJobTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); - } - } - wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId); + public void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper wrapper) { + if (args != null) { + wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName()); + wrapper.eq(args.getEnabled() != null, SystemJobTb::getEnabled, args.getEnabled()); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemJobTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + } } + wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId); + } - public void exportJobXlsx(HttpServletResponse response, SystemQueryJobArgs args) { - List systemJobTbs = this.queryJobByArgs(args); - List rowVos = new ArrayList<>(); - for (SystemJobTb dataObject : systemJobTbs) { - SystemJobExportRowVo rowVo = new SystemJobExportRowVo(); - rowVo.setName(dataObject.getName()); - rowVo.setEnabled(dataObject.getEnabled() ? "启用" : "停用"); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - KitExcelExporter.exportSimple(response, "岗位数据", SystemJobExportRowVo.class, rowVos); + public void exportJobXlsx(HttpServletResponse response, SystemQueryJobArgs args) { + List systemJobTbs = this.queryJobByArgs(args); + List rowVos = new ArrayList<>(); + for (SystemJobTb dataObject : systemJobTbs) { + SystemJobExportRowVo rowVo = new SystemJobExportRowVo(); + rowVo.setName(dataObject.getName()); + rowVo.setEnabled(dataObject.getEnabled() ? "启用" : "停用"); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); } + KitExcelExporter.exportSimple(response, "岗位数据", SystemJobExportRowVo.class, rowVos); + } - public List listByIds(Set jobIds) { - return systemJobMapper.selectByIds(jobIds); - } + public List listByIds(Set jobIds) { + return systemJobMapper.selectByIds(jobIds); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java index aef880cd..a9938b07 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java @@ -36,142 +36,142 @@ import cn.odboy.util.KitPageUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.io.File; +import java.util.Date; +import java.util.List; +import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletResponse; -import java.io.File; -import java.util.Date; -import java.util.List; @Service public class SystemLocalStorageService { - @Autowired - private SystemLocalStorageMapper systemLocalStorageMapper; - @Autowired - private KitFileLocalUploadHelper fileUploadPathHelper; - @Autowired - private AppProperties properties; + @Autowired + private SystemLocalStorageMapper systemLocalStorageMapper; + @Autowired + private KitFileLocalUploadHelper fileUploadPathHelper; + @Autowired + private AppProperties properties; - /** - * 上传 -> TestPassed - * - * @param name 文件名称 - * @param multipartFile 文件 - * @return / - */ - @Transactional(rollbackFor = Exception.class) - public SystemLocalStorageTb uploadFile(String name, MultipartFile multipartFile) { - long size = multipartFile.getSize(); - KitFileUtil.checkSize(properties.getOss().getMaxSize(), size); - String suffix = KitFileUtil.getSuffix(multipartFile.getOriginalFilename()); - String type = KitFileUtil.getFileType(suffix); - String uploadDateStr = DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT); - File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath() + uploadDateStr + File.separator); - if (file == null) { - throw new BadRequestException("上传失败"); - } - try { - String formatSize = KitFileUtil.getSize(size); - String prefixName = - StrUtil.isBlank(name) ? KitFileUtil.getPrefix(multipartFile.getOriginalFilename()) : name; - SystemLocalStorageTb localStorage = new SystemLocalStorageTb(); - localStorage.setRealName(file.getName()); - localStorage.setName(prefixName); - localStorage.setSuffix(suffix); - localStorage.setPath(file.getPath()); - localStorage.setType(type); - localStorage.setSize(formatSize); - localStorage.setDateGroup(uploadDateStr); - systemLocalStorageMapper.insert(localStorage); - return localStorage; - } catch (Exception e) { - KitFileUtil.del(file); - throw e; - } + /** + * 上传 -> TestPassed + * + * @param name 文件名称 + * @param multipartFile 文件 + * @return / + */ + @Transactional(rollbackFor = Exception.class) + public SystemLocalStorageTb uploadFile(String name, MultipartFile multipartFile) { + long size = multipartFile.getSize(); + KitFileUtil.checkSize(properties.getOss().getMaxSize(), size); + String suffix = KitFileUtil.getSuffix(multipartFile.getOriginalFilename()); + String type = KitFileUtil.getFileType(suffix); + String uploadDateStr = DateUtil.format(new Date(), DatePattern.PURE_DATE_FORMAT); + File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath() + uploadDateStr + File.separator); + if (file == null) { + throw new BadRequestException("上传失败"); } + try { + String formatSize = KitFileUtil.getSize(size); + String prefixName = + StrUtil.isBlank(name) ? KitFileUtil.getPrefix(multipartFile.getOriginalFilename()) : name; + SystemLocalStorageTb localStorage = new SystemLocalStorageTb(); + localStorage.setRealName(file.getName()); + localStorage.setName(prefixName); + localStorage.setSuffix(suffix); + localStorage.setPath(file.getPath()); + localStorage.setType(type); + localStorage.setSize(formatSize); + localStorage.setDateGroup(uploadDateStr); + systemLocalStorageMapper.insert(localStorage); + return localStorage; + } catch (Exception e) { + KitFileUtil.del(file); + throw e; + } + } - /** - * 编辑 -> TestPassed - * - * @param args 文件信息 - */ - @Transactional(rollbackFor = Exception.class) - public void updateLocalStorageById(SystemLocalStorageTb args) { - SystemLocalStorageTb localStorage = systemLocalStorageMapper.selectById(args.getId()); - localStorage.copy(args); - systemLocalStorageMapper.insertOrUpdate(localStorage); - } + /** + * 编辑 -> TestPassed + * + * @param args 文件信息 + */ + @Transactional(rollbackFor = Exception.class) + public void updateLocalStorageById(SystemLocalStorageTb args) { + SystemLocalStorageTb localStorage = systemLocalStorageMapper.selectById(args.getId()); + localStorage.copy(args); + systemLocalStorageMapper.insertOrUpdate(localStorage); + } - /** - * 多选删除 -> TestPassed - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteFileByIds(Long[] ids) { - for (Long id : ids) { - SystemLocalStorageTb storage = systemLocalStorageMapper.selectById(id); - try { - KitFileUtil.del(storage.getPath()); - systemLocalStorageMapper.deleteById(storage); - } catch (IORuntimeException e) { - throw new BadRequestException("删除文件 " + storage.getName() + " 失败"); - } - } + /** + * 多选删除 -> TestPassed + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteFileByIds(Long[] ids) { + for (Long id : ids) { + SystemLocalStorageTb storage = systemLocalStorageMapper.selectById(id); + try { + KitFileUtil.del(storage.getPath()); + systemLocalStorageMapper.deleteById(storage); + } catch (IORuntimeException e) { + throw new BadRequestException("删除文件 " + storage.getName() + " 失败"); + } } + } - /** - * 分页查询 -> TestPassed - * - * @param args 条件 - * @param page 分页参数 - * @return / - */ - public KitPageResult searchLocalStorage(SystemQueryStorageArgs args, - Page page) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQueryParams(args, wrapper); - Page selectPage = systemLocalStorageMapper.selectPage(page, wrapper); - return KitPageUtil.toPage(selectPage); - } + /** + * 分页查询 -> TestPassed + * + * @param args 条件 + * @param page 分页参数 + * @return / + */ + public KitPageResult searchLocalStorage(SystemQueryStorageArgs args, + Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(args, wrapper); + Page selectPage = systemLocalStorageMapper.selectPage(page, wrapper); + return KitPageUtil.toPage(selectPage); + } - private void injectQueryParams(SystemQueryStorageArgs args, LambdaQueryWrapper wrapper) { - if (args != null) { - wrapper.and(StrUtil.isNotBlank(args.getBlurry()), - c -> c.like(SystemLocalStorageTb::getName, args.getBlurry()).or() - .like(SystemLocalStorageTb::getSuffix, args.getBlurry()).or() - .like(SystemLocalStorageTb::getType, args.getBlurry()).or() - .like(SystemLocalStorageTb::getCreateBy, args.getBlurry())); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemLocalStorageTb::getUpdateTime, args.getCreateTime().get(0), - args.getCreateTime().get(1)); - } - } - wrapper.orderByDesc(SystemLocalStorageTb::getId); + private void injectQueryParams(SystemQueryStorageArgs args, LambdaQueryWrapper wrapper) { + if (args != null) { + wrapper.and(StrUtil.isNotBlank(args.getBlurry()), + c -> c.like(SystemLocalStorageTb::getName, args.getBlurry()).or() + .like(SystemLocalStorageTb::getSuffix, args.getBlurry()).or() + .like(SystemLocalStorageTb::getType, args.getBlurry()).or() + .like(SystemLocalStorageTb::getCreateBy, args.getBlurry())); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemLocalStorageTb::getUpdateTime, args.getCreateTime().get(0), + args.getCreateTime().get(1)); + } } + wrapper.orderByDesc(SystemLocalStorageTb::getId); + } - public List queryLocalStorageByArgs(SystemQueryStorageArgs args) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQueryParams(args, wrapper); - return systemLocalStorageMapper.selectList(wrapper); - } + public List queryLocalStorageByArgs(SystemQueryStorageArgs args) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(args, wrapper); + return systemLocalStorageMapper.selectList(wrapper); + } - public SystemLocalStorageTb uploadPictureV1(MultipartFile file) { - // 判断文件是否为图片 - String suffix = KitFileUtil.getSuffix(file.getOriginalFilename()); - if (!FileTypeEnum.IMAGE.getCode().equals(KitFileUtil.getFileType(suffix))) { - throw new BadRequestException("只能上传图片"); - } - return KitSpringBeanHolder.getBean(SystemLocalStorageService.class).uploadFile(null, file); + public SystemLocalStorageTb uploadPictureV1(MultipartFile file) { + // 判断文件是否为图片 + String suffix = KitFileUtil.getSuffix(file.getOriginalFilename()); + if (!FileTypeEnum.IMAGE.getCode().equals(KitFileUtil.getFileType(suffix))) { + throw new BadRequestException("只能上传图片"); } + return KitSpringBeanHolder.getBean(SystemLocalStorageService.class).uploadFile(null, file); + } - public void exportLocalStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) { - List systemLocalStorageTbs = this.queryLocalStorageByArgs(args); - List rowVos = - KitBeanUtil.copyToList(systemLocalStorageTbs, SystemLocalStorageExportRowVo.class); - KitExcelExporter.exportSimple(response, "文件上传记录数据", SystemLocalStorageExportRowVo.class, rowVos); - } + public void exportLocalStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) { + List systemLocalStorageTbs = this.queryLocalStorageByArgs(args); + List rowVos = + KitBeanUtil.copyToList(systemLocalStorageTbs, SystemLocalStorageExportRowVo.class); + KitExcelExporter.exportSimple(response, "文件上传记录数据", SystemLocalStorageExportRowVo.class, rowVos); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java index 470cbd1f..28bbee2d 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java @@ -36,10 +36,6 @@ import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import javax.servlet.http.HttpServletResponse; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashSet; @@ -49,428 +45,432 @@ import java.util.List; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemMenuService { - @Autowired - private SystemMenuMapper systemMenuMapper; - @Autowired - private SystemRoleMenuService systemRoleMenuService; - @Autowired - private SystemUserRoleService systemUserRoleService; + @Autowired + private SystemMenuMapper systemMenuMapper; + @Autowired + private SystemRoleMenuService systemRoleMenuService; + @Autowired + private SystemUserRoleService systemUserRoleService; - /** - * 创建 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveMenu(SystemMenuTb args) { - if (this.getMenuByTitle(args.getTitle()) != null) { - throw new BadRequestException("菜单标题已存在"); - } - if (StrUtil.isNotBlank(args.getComponentName())) { - if (this.getMenuByComponentName(args.getComponentName()) != null) { - throw new BadRequestException("菜单组件名称已存在"); - } - } - if (Long.valueOf(0L).equals(args.getPid())) { - args.setPid(null); - } - if (args.getIFrame()) { - if (!(args.getPath().toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTP) || args.getPath() - .toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTPS))) { - throw new BadRequestException(SystemTransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST); - } - } - systemMenuMapper.insert(args); - // 计算子节点数目 - args.setSubCount(0); - // 更新父节点菜单数目 - this.updateMenuSubCnt(args.getPid()); + /** + * 创建 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveMenu(SystemMenuTb args) { + if (this.getMenuByTitle(args.getTitle()) != null) { + throw new BadRequestException("菜单标题已存在"); } - - /** - * 编辑 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateMenuById(SystemMenuTb args) { - if (args.getId().equals(args.getPid())) { - throw new BadRequestException("上级不能为自己"); - } - SystemMenuTb menu = systemMenuMapper.selectById(args.getId()); - if (args.getIFrame()) { - if (!(args.getPath().toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTP) || args.getPath() - .toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTPS))) { - throw new BadRequestException(SystemTransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST); - } - } - SystemMenuTb menu1 = this.getMenuByTitle(args.getTitle()); - if (menu1 != null && !menu1.getId().equals(menu.getId())) { - throw new BadRequestException("菜单标题已存在"); - } - if (args.getPid().equals(0L)) { - args.setPid(null); - } - // 记录的父节点ID - Long oldPid = menu.getPid(); - Long newPid = args.getPid(); - if (StrUtil.isNotBlank(args.getComponentName())) { - menu1 = this.getMenuByComponentName(args.getComponentName()); - if (menu1 != null && !menu1.getId().equals(menu.getId())) { - throw new BadRequestException("菜单组件名称已存在"); - } - } - menu.setTitle(args.getTitle()); - menu.setComponent(args.getComponent()); - menu.setPath(args.getPath()); - menu.setIcon(args.getIcon()); - menu.setIFrame(args.getIFrame()); - menu.setPid(args.getPid()); - menu.setMenuSort(args.getMenuSort()); - menu.setCache(args.getCache()); - menu.setHidden(args.getHidden()); - menu.setComponentName(args.getComponentName()); - menu.setPermission(args.getPermission()); - menu.setType(args.getType()); - // auto fill - menu.setUpdateBy(null); - menu.setUpdateTime(null); - systemMenuMapper.insertOrUpdate(menu); - // 计算父级菜单节点数目 - this.updateMenuSubCnt(oldPid); - this.updateMenuSubCnt(newPid); + if (StrUtil.isNotBlank(args.getComponentName())) { + if (this.getMenuByComponentName(args.getComponentName()) != null) { + throw new BadRequestException("菜单组件名称已存在"); + } } - - /** - * 删除 - */ - @Transactional(rollbackFor = Exception.class) - public void deleteMenuByIds(Set ids) { - Set menuSet = new HashSet<>(); - for (Long id : ids) { - List menuList = this.listMenuByPid(id); - menuSet.add(this.getMenuVoById(id)); - menuSet = this.queryChildMenuByArgs(menuList, menuSet); - } - List menuIds = - menuSet.stream().map(SystemMenuVo::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); - if (CollUtil.isNotEmpty(menuIds)) { - systemRoleMenuService.deleteRoleMenuByMenuIds(menuIds); - systemMenuMapper.deleteByIds(menuIds); - } - for (SystemMenuVo menu : menuSet) { - this.updateMenuSubCnt(menu.getPid()); - } + if (Long.valueOf(0L).equals(args.getPid())) { + args.setPid(null); } - - private SystemMenuVo getMenuVoById(Long id) { - return KitBeanUtil.copyToClass(systemMenuMapper.selectById(id), SystemMenuVo.class); + if (args.getIFrame()) { + if (!(args.getPath().toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTP) || args.getPath() + .toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTPS))) { + throw new BadRequestException(SystemTransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST); + } } + systemMenuMapper.insert(args); + // 计算子节点数目 + args.setSubCount(0); + // 更新父节点菜单数目 + this.updateMenuSubCnt(args.getPid()); + } - @Transactional(rollbackFor = Exception.class) - public void updateMenuSubCnt(Long menuId) { - if (menuId != null) { - long count = this.countMenuByPid(menuId); - LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); - wrapper.eq(SystemMenuTb::getId, menuId); - wrapper.set(SystemMenuTb::getSubCount, count); - systemMenuMapper.update(wrapper); + /** + * 编辑 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateMenuById(SystemMenuTb args) { + if (args.getId().equals(args.getPid())) { + throw new BadRequestException("上级不能为自己"); + } + SystemMenuTb menu = systemMenuMapper.selectById(args.getId()); + if (args.getIFrame()) { + if (!(args.getPath().toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTP) || args.getPath() + .toLowerCase().startsWith(SystemTransferProtocolConst.PREFIX_HTTPS))) { + throw new BadRequestException(SystemTransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST); + } + } + SystemMenuTb menu1 = this.getMenuByTitle(args.getTitle()); + if (menu1 != null && !menu1.getId().equals(menu.getId())) { + throw new BadRequestException("菜单标题已存在"); + } + if (args.getPid().equals(0L)) { + args.setPid(null); + } + // 记录的父节点ID + Long oldPid = menu.getPid(); + Long newPid = args.getPid(); + if (StrUtil.isNotBlank(args.getComponentName())) { + menu1 = this.getMenuByComponentName(args.getComponentName()); + if (menu1 != null && !menu1.getId().equals(menu.getId())) { + throw new BadRequestException("菜单组件名称已存在"); + } + } + menu.setTitle(args.getTitle()); + menu.setComponent(args.getComponent()); + menu.setPath(args.getPath()); + menu.setIcon(args.getIcon()); + menu.setIFrame(args.getIFrame()); + menu.setPid(args.getPid()); + menu.setMenuSort(args.getMenuSort()); + menu.setCache(args.getCache()); + menu.setHidden(args.getHidden()); + menu.setComponentName(args.getComponentName()); + menu.setPermission(args.getPermission()); + menu.setType(args.getType()); + // auto fill + menu.setUpdateBy(null); + menu.setUpdateTime(null); + systemMenuMapper.insertOrUpdate(menu); + // 计算父级菜单节点数目 + this.updateMenuSubCnt(oldPid); + this.updateMenuSubCnt(newPid); + } + + /** + * 删除 + */ + @Transactional(rollbackFor = Exception.class) + public void deleteMenuByIds(Set ids) { + Set menuSet = new HashSet<>(); + for (Long id : ids) { + List menuList = this.listMenuByPid(id); + menuSet.add(this.getMenuVoById(id)); + menuSet = this.queryChildMenuByArgs(menuList, menuSet); + } + List menuIds = + menuSet.stream().map(SystemMenuVo::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); + if (CollUtil.isNotEmpty(menuIds)) { + systemRoleMenuService.deleteRoleMenuByMenuIds(menuIds); + systemMenuMapper.deleteByIds(menuIds); + } + for (SystemMenuVo menu : menuSet) { + this.updateMenuSubCnt(menu.getPid()); + } + } + + private SystemMenuVo getMenuVoById(Long id) { + return KitBeanUtil.copyToClass(systemMenuMapper.selectById(id), SystemMenuVo.class); + } + + @Transactional(rollbackFor = Exception.class) + public void updateMenuSubCnt(Long menuId) { + if (menuId != null) { + long count = this.countMenuByPid(menuId); + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(SystemMenuTb::getId, menuId); + wrapper.set(SystemMenuTb::getSubCount, count); + systemMenuMapper.update(wrapper); + } + } + + /** + * 查询全部数据 + * + * @param args 条件 + * @param isQuery / + * @return / + * @throws Exception / + */ + public List queryAllMenu(SystemQueryMenuArgs args, Boolean isQuery) throws Exception { + if (Boolean.TRUE.equals(isQuery)) { + args.setPidIsNull(true); + List fields = KitClassUtil.getAllFields(args.getClass(), new ArrayList<>()); + for (Field field : fields) { + //设置对象的访问权限, 保证对private的属性的访问 + field.setAccessible(true); + Object val = field.get(args); + if ("pidIsNull".equals(field.getName())) { + continue; } - } - - /** - * 查询全部数据 - * - * @param args 条件 - * @param isQuery / - * @return / - * @throws Exception / - */ - public List queryAllMenu(SystemQueryMenuArgs args, Boolean isQuery) throws Exception { - if (Boolean.TRUE.equals(isQuery)) { - args.setPidIsNull(true); - List fields = KitClassUtil.getAllFields(args.getClass(), new ArrayList<>()); - for (Field field : fields) { - //设置对象的访问权限, 保证对private的属性的访问 - field.setAccessible(true); - Object val = field.get(args); - if ("pidIsNull".equals(field.getName())) { - continue; - } - // 如果有查询条件, 则不指定pidIsNull - if (ObjectUtil.isNotNull(val)) { - args.setPidIsNull(null); - break; - } - } + // 如果有查询条件, 则不指定pidIsNull + if (ObjectUtil.isNotNull(val)) { + args.setPidIsNull(null); + break; } - return this.queryMenuByArgs(args); + } } + return this.queryMenuByArgs(args); + } - /** - * 根据当前用户获取菜单 - * - * @param currentUserId / - * @return / - */ - public List listMenuByUserId(Long currentUserId) { - List roles = systemUserRoleService.queryRoleVoByUsersId(currentUserId); - Set roleIds = roles.stream().map(SystemRoleVo::getId).collect(Collectors.toSet()); - return new ArrayList<>(systemRoleMenuService.queryMenuByRoleIds(roleIds)); + /** + * 根据当前用户获取菜单 + * + * @param currentUserId / + * @return / + */ + public List listMenuByUserId(Long currentUserId) { + List roles = systemUserRoleService.queryRoleVoByUsersId(currentUserId); + Set roleIds = roles.stream().map(SystemRoleVo::getId).collect(Collectors.toSet()); + return new ArrayList<>(systemRoleMenuService.queryMenuByRoleIds(roleIds)); + } + + /** + * 获取所有子节点, 包含自身ID + * + * @param menuList / + * @param menuSet / + * @return / + */ + public Set queryChildMenuByArgs(List menuList, Set menuSet) { + for (SystemMenuVo menu : menuList) { + menuSet.add(menu); + List menus = this.listMenuByPid(menu.getId()); + if (CollUtil.isNotEmpty(menus)) { + queryChildMenuByArgs(menus, menuSet); + } } + return menuSet; + } - /** - * 获取所有子节点, 包含自身ID - * - * @param menuList / - * @param menuSet / - * @return / - */ - public Set queryChildMenuByArgs(List menuList, Set menuSet) { - for (SystemMenuVo menu : menuList) { - menuSet.add(menu); - List menus = this.listMenuByPid(menu.getId()); - if (CollUtil.isNotEmpty(menus)) { - queryChildMenuByArgs(menus, menuSet); - } + /** + * 懒加载菜单数据 + * + * @param pid / + * @return / + */ + public List listMenuByPid(Long pid) { + List menus; + if (pid != null && !pid.equals(0L)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemMenuTb::getPid, pid); + wrapper.orderByAsc(SystemMenuTb::getMenuSort); + return KitBeanUtil.copyToList(systemMenuMapper.selectList(wrapper), SystemMenuVo.class); + } else { + menus = this.listRootMenu(); + } + return menus; + } + + /** + * 根据ID获取同级与上级数据 + * + * @param menu / + * @param menus / + * @return / + */ + public List querySuperiorMenuByArgs(SystemMenuVo menu, List menus) { + if (menu.getPid() == null) { + menus.addAll(this.listRootMenu()); + return menus; + } + menus.addAll(this.listMenuByPid(menu.getPid())); + return querySuperiorMenuByArgs(this.getMenuVoById(menu.getPid()), menus); + } + + /** + * 构建菜单树 + * + * @param menus 原始数据 + * @return / + */ + public List buildMenuTree(List menus) { + List trees = new ArrayList<>(); + Set ids = new HashSet<>(); + for (SystemMenuVo menu : menus) { + if (menu.getPid() == null) { + trees.add(menu); + } + for (SystemMenuVo it : menus) { + if (menu.getId().equals(it.getPid())) { + if (menu.getChildren() == null) { + menu.setChildren(new ArrayList<>()); + } + menu.getChildren().add(it); + ids.add(it.getId()); } - return menuSet; + } } - - /** - * 懒加载菜单数据 - * - * @param pid / - * @return / - */ - public List listMenuByPid(Long pid) { - List menus; - if (pid != null && !pid.equals(0L)) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemMenuTb::getPid, pid); - wrapper.orderByAsc(SystemMenuTb::getMenuSort); - return KitBeanUtil.copyToList(systemMenuMapper.selectList(wrapper), SystemMenuVo.class); - } else { - menus = this.listRootMenu(); - } - return menus; + if (CollUtil.isNotEmpty(trees)) { + trees = menus.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList()); } + return trees; + } - /** - * 根据ID获取同级与上级数据 - * - * @param menu / - * @param menus / - * @return / - */ - public List querySuperiorMenuByArgs(SystemMenuVo menu, List menus) { - if (menu.getPid() == null) { - menus.addAll(this.listRootMenu()); - return menus; - } - menus.addAll(this.listMenuByPid(menu.getPid())); - return querySuperiorMenuByArgs(this.getMenuVoById(menu.getPid()), menus); - } - - /** - * 构建菜单树 - * - * @param menus 原始数据 - * @return / - */ - public List buildMenuTree(List menus) { - List trees = new ArrayList<>(); - Set ids = new HashSet<>(); - for (SystemMenuVo menu : menus) { - if (menu.getPid() == null) { - trees.add(menu); - } - for (SystemMenuVo it : menus) { - if (menu.getId().equals(it.getPid())) { - if (menu.getChildren() == null) { - menu.setChildren(new ArrayList<>()); - } - menu.getChildren().add(it); - ids.add(it.getId()); - } - } - } - if (CollUtil.isNotEmpty(trees)) { - trees = menus.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList()); - } - return trees; - } - - /** - * 构建菜单树 - * - * @param menus / - * @return / - */ - public List buildMenuVo(List menus) { - List list = new LinkedList<>(); - for (SystemMenuVo menu : menus) { - if (menu != null) { - List menuList = menu.getChildren(); - SystemMenuRouterVo menuVo = new SystemMenuRouterVo(); - menuVo.setName( - ObjectUtil.isNotEmpty(menu.getComponentName()) ? menu.getComponentName() : menu.getTitle()); - // 一级目录需要加斜杠, 不然会报警告 - menuVo.setPath(menu.getPid() == null ? "/" + menu.getPath() : menu.getPath()); - menuVo.setHidden(menu.getHidden()); - // 如果不是外链 - if (!menu.getIFrame()) { - if (menu.getPid() == null) { - menuVo.setComponent(StrUtil.isEmpty(menu.getComponent()) ? "Layout" : menu.getComponent()); - // 如果不是一级菜单,并且菜单类型为目录,则代表是多级菜单 - } else if (menu.getType() == 0) { - menuVo.setComponent(StrUtil.isEmpty(menu.getComponent()) ? "ParentView" : menu.getComponent()); - } else if (StrUtil.isNotBlank(menu.getComponent())) { - menuVo.setComponent(menu.getComponent()); - } - } - menuVo.setMeta(new SystemMenuMetaVo(menu.getTitle(), menu.getIcon(), !menu.getCache())); - if (CollUtil.isNotEmpty(menuList)) { - menuVo.setAlwaysShow(true); - menuVo.setRedirect("noredirect"); - menuVo.setChildren(buildMenuVo(menuList)); - // 处理是一级菜单并且没有子菜单的情况 - } else if (menu.getPid() == null) { - SystemMenuRouterVo menuVo1 = getMenuVo(menu, menuVo); - menuVo.setName(null); - menuVo.setMeta(null); - menuVo.setComponent("Layout"); - List list1 = new ArrayList<>(); - list1.add(menuVo1); - menuVo.setChildren(list1); - } - list.add(menuVo); - } - } - return list; - } - - /** - * 获取 MenuResponse - * - * @param menu / - * @param menuVo / - * @return / - */ - private SystemMenuRouterVo getMenuVo(SystemMenuVo menu, SystemMenuRouterVo menuVo) { - SystemMenuRouterVo menuVo1 = new SystemMenuRouterVo(); - menuVo1.setMeta(menuVo.getMeta()); - // 非外链 + /** + * 构建菜单树 + * + * @param menus / + * @return / + */ + public List buildMenuVo(List menus) { + List list = new LinkedList<>(); + for (SystemMenuVo menu : menus) { + if (menu != null) { + List menuList = menu.getChildren(); + SystemMenuRouterVo menuVo = new SystemMenuRouterVo(); + menuVo.setName( + ObjectUtil.isNotEmpty(menu.getComponentName()) ? menu.getComponentName() : menu.getTitle()); + // 一级目录需要加斜杠, 不然会报警告 + menuVo.setPath(menu.getPid() == null ? "/" + menu.getPath() : menu.getPath()); + menuVo.setHidden(menu.getHidden()); + // 如果不是外链 if (!menu.getIFrame()) { - menuVo1.setPath("index"); - menuVo1.setName(menuVo.getName()); - menuVo1.setComponent(menuVo.getComponent()); - } else { - menuVo1.setPath(menu.getPath()); + if (menu.getPid() == null) { + menuVo.setComponent(StrUtil.isEmpty(menu.getComponent()) ? "Layout" : menu.getComponent()); + // 如果不是一级菜单,并且菜单类型为目录,则代表是多级菜单 + } else if (menu.getType() == 0) { + menuVo.setComponent(StrUtil.isEmpty(menu.getComponent()) ? "ParentView" : menu.getComponent()); + } else if (StrUtil.isNotBlank(menu.getComponent())) { + menuVo.setComponent(menu.getComponent()); + } } - return menuVo1; - } - - public List listMenuByIds(List ids) { - return KitBeanUtil.copyToList(systemMenuMapper.selectByIds(ids), SystemMenuVo.class); - } - - private SystemMenuTb getMenuByComponentName(String componentName) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemMenuTb::getComponentName, componentName); - return systemMenuMapper.selectOne(wrapper); - } - - private SystemMenuTb getMenuByTitle(String title) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemMenuTb::getTitle, title); - return systemMenuMapper.selectOne(wrapper); - } - - private Long countMenuByPid(Long pid) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemMenuTb::getPid, pid); - return systemMenuMapper.selectCount(wrapper); - } - - private List queryMenuByArgs(SystemQueryMenuArgs args) { - KitValidUtil.notNull(args); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.isNull(args.getPidIsNull() != null, SystemMenuTb::getPid); - wrapper.eq(args.getPid() != null, SystemMenuTb::getPid, args.getPid()); - wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemMenuTb::getTitle, args.getBlurry()).or() - .like(SystemMenuTb::getComponentName, args.getBlurry()).or() - .like(SystemMenuTb::getPermission, args.getBlurry())); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemMenuTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + menuVo.setMeta(new SystemMenuMetaVo(menu.getTitle(), menu.getIcon(), !menu.getCache())); + if (CollUtil.isNotEmpty(menuList)) { + menuVo.setAlwaysShow(true); + menuVo.setRedirect("noredirect"); + menuVo.setChildren(buildMenuVo(menuList)); + // 处理是一级菜单并且没有子菜单的情况 + } else if (menu.getPid() == null) { + SystemMenuRouterVo menuVo1 = getMenuVo(menu, menuVo); + menuVo.setName(null); + menuVo.setMeta(null); + menuVo.setComponent("Layout"); + List list1 = new ArrayList<>(); + list1.add(menuVo1); + menuVo.setChildren(list1); } - wrapper.orderByAsc(SystemMenuTb::getMenuSort); - return systemMenuMapper.selectList(wrapper); + list.add(menuVo); + } } + return list; + } - private List listRootMenu() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.isNull(SystemMenuTb::getPid); - wrapper.orderByAsc(SystemMenuTb::getMenuSort); - return KitBeanUtil.copyToList(systemMenuMapper.selectList(wrapper), SystemMenuVo.class); + /** + * 获取 MenuResponse + * + * @param menu / + * @param menuVo / + * @return / + */ + private SystemMenuRouterVo getMenuVo(SystemMenuVo menu, SystemMenuRouterVo menuVo) { + SystemMenuRouterVo menuVo1 = new SystemMenuRouterVo(); + menuVo1.setMeta(menuVo.getMeta()); + // 非外链 + if (!menu.getIFrame()) { + menuVo1.setPath("index"); + menuVo1.setName(menuVo.getName()); + menuVo1.setComponent(menuVo.getComponent()); + } else { + menuVo1.setPath(menu.getPath()); } + return menuVo1; + } - public List buildFrontMenus() { - List originMenus = this.listMenuByUserId(KitSecurityHelper.getCurrentUserId()); - List targetMenus = this.buildMenuTree(originMenus); - return this.buildMenuVo(targetMenus); + public List listMenuByIds(List ids) { + return KitBeanUtil.copyToList(systemMenuMapper.selectByIds(ids), SystemMenuVo.class); + } + + private SystemMenuTb getMenuByComponentName(String componentName) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemMenuTb::getComponentName, componentName); + return systemMenuMapper.selectOne(wrapper); + } + + private SystemMenuTb getMenuByTitle(String title) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemMenuTb::getTitle, title); + return systemMenuMapper.selectOne(wrapper); + } + + private Long countMenuByPid(Long pid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemMenuTb::getPid, pid); + return systemMenuMapper.selectCount(wrapper); + } + + private List queryMenuByArgs(SystemQueryMenuArgs args) { + KitValidUtil.notNull(args); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.isNull(args.getPidIsNull() != null, SystemMenuTb::getPid); + wrapper.eq(args.getPid() != null, SystemMenuTb::getPid, args.getPid()); + wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemMenuTb::getTitle, args.getBlurry()).or() + .like(SystemMenuTb::getComponentName, args.getBlurry()).or() + .like(SystemMenuTb::getPermission, args.getBlurry())); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemMenuTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); } + wrapper.orderByAsc(SystemMenuTb::getMenuSort); + return systemMenuMapper.selectList(wrapper); + } - public Set listChildMenuSetByMenuId(Long id) { - Set menuSet = new HashSet<>(); - List menuList = this.listMenuByPid(id); - menuSet.add(this.getMenuVoById(id)); - menuSet = this.queryChildMenuByArgs(menuList, menuSet); - return menuSet.stream().map(SystemMenuVo::getId).collect(Collectors.toSet()); - } + private List listRootMenu() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.isNull(SystemMenuTb::getPid); + wrapper.orderByAsc(SystemMenuTb::getMenuSort); + return KitBeanUtil.copyToList(systemMenuMapper.selectList(wrapper), SystemMenuVo.class); + } - public List listMenuSuperior(List ids) { - Set menus; - List systemMenuTbs; - if (CollUtil.isNotEmpty(ids)) { - menus = new LinkedHashSet<>(this.listMenuByIds(ids)); - for (SystemMenuVo menu : menus) { - List menuList = this.querySuperiorMenuByArgs(menu, new ArrayList<>()); - for (SystemMenuVo data : menuList) { - if (data.getId().equals(menu.getPid())) { - data.setSubCount(data.getSubCount() - 1); - } - } - menus.addAll(menuList); - } - // 编辑菜单时不显示自己以及自己下级的数据, 避免出现PID数据环形问题 - menus = menus.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toSet()); - List newMenuList = new ArrayList<>(menus); - systemMenuTbs = this.buildMenuTree(newMenuList); - } else { - systemMenuTbs = this.listMenuByPid(null); + public List buildFrontMenus() { + List originMenus = this.listMenuByUserId(KitSecurityHelper.getCurrentUserId()); + List targetMenus = this.buildMenuTree(originMenus); + return this.buildMenuVo(targetMenus); + } + + public Set listChildMenuSetByMenuId(Long id) { + Set menuSet = new HashSet<>(); + List menuList = this.listMenuByPid(id); + menuSet.add(this.getMenuVoById(id)); + menuSet = this.queryChildMenuByArgs(menuList, menuSet); + return menuSet.stream().map(SystemMenuVo::getId).collect(Collectors.toSet()); + } + + public List listMenuSuperior(List ids) { + Set menus; + List systemMenuTbs; + if (CollUtil.isNotEmpty(ids)) { + menus = new LinkedHashSet<>(this.listMenuByIds(ids)); + for (SystemMenuVo menu : menus) { + List menuList = this.querySuperiorMenuByArgs(menu, new ArrayList<>()); + for (SystemMenuVo data : menuList) { + if (data.getId().equals(menu.getPid())) { + data.setSubCount(data.getSubCount() - 1); + } } - return systemMenuTbs; + menus.addAll(menuList); + } + // 编辑菜单时不显示自己以及自己下级的数据, 避免出现PID数据环形问题 + menus = menus.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toSet()); + List newMenuList = new ArrayList<>(menus); + systemMenuTbs = this.buildMenuTree(newMenuList); + } else { + systemMenuTbs = this.listMenuByPid(null); } + return systemMenuTbs; + } - public void exportMenuXlsx(HttpServletResponse response, SystemQueryMenuArgs args) throws Exception { - List systemMenuTbs = this.queryAllMenu(args, false); - List rowVos = new ArrayList<>(); - for (SystemMenuTb dataObject : systemMenuTbs) { - SystemMenuExportRowVo rowVo = new SystemMenuExportRowVo(); - rowVo.setTitle(dataObject.getTitle()); - rowVo.setType(dataObject.getType() == null ? "目录" : dataObject.getType() == 1 ? "菜单" : "按钮"); - rowVo.setPermission(dataObject.getPermission()); - rowVo.setIFrame(dataObject.getIFrame() ? SystemYesOrNoChConst.YES_STR : SystemYesOrNoChConst.NO_STR); - rowVo.setHidden(dataObject.getHidden() ? SystemYesOrNoChConst.NO_STR : SystemYesOrNoChConst.YES_STR); - rowVo.setCache(dataObject.getCache() ? SystemYesOrNoChConst.YES_STR : SystemYesOrNoChConst.NO_STR); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - KitExcelExporter.exportSimple(response, "菜单数据", SystemMenuExportRowVo.class, rowVos); + public void exportMenuXlsx(HttpServletResponse response, SystemQueryMenuArgs args) throws Exception { + List systemMenuTbs = this.queryAllMenu(args, false); + List rowVos = new ArrayList<>(); + for (SystemMenuTb dataObject : systemMenuTbs) { + SystemMenuExportRowVo rowVo = new SystemMenuExportRowVo(); + rowVo.setTitle(dataObject.getTitle()); + rowVo.setType(dataObject.getType() == null ? "目录" : dataObject.getType() == 1 ? "菜单" : "按钮"); + rowVo.setPermission(dataObject.getPermission()); + rowVo.setIFrame(dataObject.getIFrame() ? SystemYesOrNoChConst.YES_STR : SystemYesOrNoChConst.NO_STR); + rowVo.setHidden(dataObject.getHidden() ? SystemYesOrNoChConst.NO_STR : SystemYesOrNoChConst.YES_STR); + rowVo.setCache(dataObject.getCache() ? SystemYesOrNoChConst.YES_STR : SystemYesOrNoChConst.NO_STR); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); } + KitExcelExporter.exportSimple(response, "菜单数据", SystemMenuExportRowVo.class, rowVos); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java index a58f1636..94901e13 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java @@ -20,6 +20,13 @@ import cn.hutool.core.date.DateUtil; import cn.odboy.constant.SystemConst; import cn.odboy.util.KitFileUtil; import cn.odboy.util.KitIPUtil; +import java.lang.management.ManagementFactory; +import java.text.DecimalFormat; +import java.util.Arrays; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import oshi.SystemInfo; @@ -32,184 +39,177 @@ import oshi.software.os.OSFileStore; import oshi.software.os.OperatingSystem; import oshi.util.FormatUtil; import oshi.util.Util; -import java.lang.management.ManagementFactory; -import java.text.DecimalFormat; -import java.util.Arrays; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; @Slf4j @Service public class SystemMonitorService { - private final DecimalFormat df = new DecimalFormat("0.00"); + private final DecimalFormat df = new DecimalFormat("0.00"); - /** - * 查询服务器监控信息 -> TestPassed - * - * @return Map - */ - public Map getServerMonitorInfo() { - Map resultMap = new LinkedHashMap<>(8); - try { - SystemInfo si = new SystemInfo(); - OperatingSystem os = si.getOperatingSystem(); - HardwareAbstractionLayer hal = si.getHardware(); - // 系统信息 - resultMap.put("sys", getSystemInfo(os)); - // cpu 信息 - resultMap.put("cpu", getCpuInfo(hal.getProcessor())); - // 内存信息 - resultMap.put("memory", getMemoryInfo(hal.getMemory())); - // 交换区信息 - resultMap.put("swap", getSwapInfo(hal.getMemory())); - // 磁盘 - resultMap.put("disk", getDiskInfo(os)); - resultMap.put("time", DateUtil.format(new Date(), "HH:mm:ss")); - } catch (Exception e) { - log.error(e.getMessage(), e); - } - return resultMap; + /** + * 查询服务器监控信息 -> TestPassed + * + * @return Map + */ + public Map getServerMonitorInfo() { + Map resultMap = new LinkedHashMap<>(8); + try { + SystemInfo si = new SystemInfo(); + OperatingSystem os = si.getOperatingSystem(); + HardwareAbstractionLayer hal = si.getHardware(); + // 系统信息 + resultMap.put("sys", getSystemInfo(os)); + // cpu 信息 + resultMap.put("cpu", getCpuInfo(hal.getProcessor())); + // 内存信息 + resultMap.put("memory", getMemoryInfo(hal.getMemory())); + // 交换区信息 + resultMap.put("swap", getSwapInfo(hal.getMemory())); + // 磁盘 + resultMap.put("disk", getDiskInfo(os)); + resultMap.put("time", DateUtil.format(new Date(), "HH:mm:ss")); + } catch (Exception e) { + log.error(e.getMessage(), e); } + return resultMap; + } - /** - * 获取磁盘信息 - * - * @return / - */ - private Map getDiskInfo(OperatingSystem os) { - Map diskInfo = new LinkedHashMap<>(); - FileSystem fileSystem = os.getFileSystem(); - List fsArray = fileSystem.getFileStores(); - String osName = System.getProperty("os.name"); - long available = 0, total = 0; - for (OSFileStore fs : fsArray) { - // windows 需要将所有磁盘分区累加, linux 和 mac 直接累加会出现磁盘重复的问题, 待修复 - if (osName.toLowerCase().startsWith(SystemConst.WIN)) { - available += fs.getUsableSpace(); - total += fs.getTotalSpace(); - } else { - available = fs.getUsableSpace(); - total = fs.getTotalSpace(); - break; - } - } - long used = total - available; - diskInfo.put("total", total > 0 ? KitFileUtil.getSize(total) : "?"); - diskInfo.put("available", KitFileUtil.getSize(available)); - diskInfo.put("used", KitFileUtil.getSize(used)); - if (total != 0) { - diskInfo.put("usageRate", df.format(used / (double)total * 100)); - } else { - diskInfo.put("usageRate", 0); - } - return diskInfo; + /** + * 获取磁盘信息 + * + * @return / + */ + private Map getDiskInfo(OperatingSystem os) { + Map diskInfo = new LinkedHashMap<>(); + FileSystem fileSystem = os.getFileSystem(); + List fsArray = fileSystem.getFileStores(); + String osName = System.getProperty("os.name"); + long available = 0, total = 0; + for (OSFileStore fs : fsArray) { + // windows 需要将所有磁盘分区累加, linux 和 mac 直接累加会出现磁盘重复的问题, 待修复 + if (osName.toLowerCase().startsWith(SystemConst.WIN)) { + available += fs.getUsableSpace(); + total += fs.getTotalSpace(); + } else { + available = fs.getUsableSpace(); + total = fs.getTotalSpace(); + break; + } } + long used = total - available; + diskInfo.put("total", total > 0 ? KitFileUtil.getSize(total) : "?"); + diskInfo.put("available", KitFileUtil.getSize(available)); + diskInfo.put("used", KitFileUtil.getSize(used)); + if (total != 0) { + diskInfo.put("usageRate", df.format(used / (double) total * 100)); + } else { + diskInfo.put("usageRate", 0); + } + return diskInfo; + } - /** - * 获取交换区信息 - * - * @param memory / - * @return / - */ - private Map getSwapInfo(GlobalMemory memory) { - Map swapInfo = new LinkedHashMap<>(); - VirtualMemory virtualMemory = memory.getVirtualMemory(); - long total = virtualMemory.getSwapTotal(); - long used = virtualMemory.getSwapUsed(); - swapInfo.put("total", FormatUtil.formatBytes(total)); - swapInfo.put("used", FormatUtil.formatBytes(used)); - swapInfo.put("available", FormatUtil.formatBytes(total - used)); - if (used == 0) { - swapInfo.put("usageRate", 0); - } else { - swapInfo.put("usageRate", df.format(used / (double)total * 100)); - } - return swapInfo; + /** + * 获取交换区信息 + * + * @param memory / + * @return / + */ + private Map getSwapInfo(GlobalMemory memory) { + Map swapInfo = new LinkedHashMap<>(); + VirtualMemory virtualMemory = memory.getVirtualMemory(); + long total = virtualMemory.getSwapTotal(); + long used = virtualMemory.getSwapUsed(); + swapInfo.put("total", FormatUtil.formatBytes(total)); + swapInfo.put("used", FormatUtil.formatBytes(used)); + swapInfo.put("available", FormatUtil.formatBytes(total - used)); + if (used == 0) { + swapInfo.put("usageRate", 0); + } else { + swapInfo.put("usageRate", df.format(used / (double) total * 100)); } + return swapInfo; + } - /** - * 获取内存信息 - * - * @param memory / - * @return / - */ - private Map getMemoryInfo(GlobalMemory memory) { - Map memoryInfo = new LinkedHashMap<>(); - memoryInfo.put("total", FormatUtil.formatBytes(memory.getTotal())); - memoryInfo.put("available", FormatUtil.formatBytes(memory.getAvailable())); - memoryInfo.put("used", FormatUtil.formatBytes(memory.getTotal() - memory.getAvailable())); - memoryInfo.put("usageRate", - df.format((memory.getTotal() - memory.getAvailable()) / (double)memory.getTotal() * 100)); - return memoryInfo; - } + /** + * 获取内存信息 + * + * @param memory / + * @return / + */ + private Map getMemoryInfo(GlobalMemory memory) { + Map memoryInfo = new LinkedHashMap<>(); + memoryInfo.put("total", FormatUtil.formatBytes(memory.getTotal())); + memoryInfo.put("available", FormatUtil.formatBytes(memory.getAvailable())); + memoryInfo.put("used", FormatUtil.formatBytes(memory.getTotal() - memory.getAvailable())); + memoryInfo.put("usageRate", + df.format((memory.getTotal() - memory.getAvailable()) / (double) memory.getTotal() * 100)); + return memoryInfo; + } - /** - * 获取Cpu相关信息 - * - * @param processor / - * @return / - */ - private Map getCpuInfo(CentralProcessor processor) { - Map cpuInfo = new LinkedHashMap<>(); - cpuInfo.put("name", processor.getProcessorIdentifier().getName()); - cpuInfo.put("package", processor.getPhysicalPackageCount() + "个物理CPU"); - cpuInfo.put("core", processor.getPhysicalProcessorCount() + "个物理核心"); - cpuInfo.put("coreNumber", processor.getPhysicalProcessorCount()); - cpuInfo.put("logic", processor.getLogicalProcessorCount() + "个逻辑CPU"); - // CPU信息 - long[] prevTicks = processor.getSystemCpuLoadTicks(); - // 默认等待300毫秒... - long time = 300; - Util.sleep(time); - long[] ticks = processor.getSystemCpuLoadTicks(); - long minCpuLoadTick = 1000; - while (Arrays.toString(prevTicks).equals(Arrays.toString(ticks)) && time < minCpuLoadTick) { - time += 25; - Util.sleep(25); - ticks = processor.getSystemCpuLoadTicks(); - } - long user = - ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()]; - long nice = - ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()]; - long sys = - ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()]; - long idle = - ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()]; - long ioWait = - ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()]; - long irq = - ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()]; - long softIrq = - ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()]; - long steal = - ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()]; - long totalCpu = user + nice + sys + idle + ioWait + irq + softIrq + steal; - cpuInfo.put("used", df.format(100d * user / totalCpu + 100d * sys / totalCpu)); - cpuInfo.put("idle", df.format(100d * idle / totalCpu)); - return cpuInfo; + /** + * 获取Cpu相关信息 + * + * @param processor / + * @return / + */ + private Map getCpuInfo(CentralProcessor processor) { + Map cpuInfo = new LinkedHashMap<>(); + cpuInfo.put("name", processor.getProcessorIdentifier().getName()); + cpuInfo.put("package", processor.getPhysicalPackageCount() + "个物理CPU"); + cpuInfo.put("core", processor.getPhysicalProcessorCount() + "个物理核心"); + cpuInfo.put("coreNumber", processor.getPhysicalProcessorCount()); + cpuInfo.put("logic", processor.getLogicalProcessorCount() + "个逻辑CPU"); + // CPU信息 + long[] prevTicks = processor.getSystemCpuLoadTicks(); + // 默认等待300毫秒... + long time = 300; + Util.sleep(time); + long[] ticks = processor.getSystemCpuLoadTicks(); + long minCpuLoadTick = 1000; + while (Arrays.toString(prevTicks).equals(Arrays.toString(ticks)) && time < minCpuLoadTick) { + time += 25; + Util.sleep(25); + ticks = processor.getSystemCpuLoadTicks(); } + long user = + ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()]; + long nice = + ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()]; + long sys = + ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()]; + long idle = + ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()]; + long ioWait = + ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()]; + long irq = + ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()]; + long softIrq = + ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()]; + long steal = + ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()]; + long totalCpu = user + nice + sys + idle + ioWait + irq + softIrq + steal; + cpuInfo.put("used", df.format(100d * user / totalCpu + 100d * sys / totalCpu)); + cpuInfo.put("idle", df.format(100d * idle / totalCpu)); + return cpuInfo; + } - /** - * 获取系统相关信息,系统、运行天数、系统IP - * - * @param os / - * @return / - */ - private Map getSystemInfo(OperatingSystem os) { - Map systemInfo = new LinkedHashMap<>(); - // jvm 运行时间 - long time = ManagementFactory.getRuntimeMXBean().getStartTime(); - Date date = new Date(time); - // 计算项目运行时间 - String formatBetween = DateUtil.formatBetween(date, new Date(), Level.HOUR); - // 系统信息 - systemInfo.put("os", os.toString()); - systemInfo.put("day", formatBetween); - systemInfo.put("ip", KitIPUtil.getLocalIp()); - return systemInfo; - } + /** + * 获取系统相关信息,系统、运行天数、系统IP + * + * @param os / + * @return / + */ + private Map getSystemInfo(OperatingSystem os) { + Map systemInfo = new LinkedHashMap<>(); + // jvm 运行时间 + long time = ManagementFactory.getRuntimeMXBean().getStartTime(); + Date date = new Date(time); + // 计算项目运行时间 + String formatBetween = DateUtil.formatBetween(date, new Date(), Level.HOUR); + // 系统信息 + systemInfo.put("os", os.toString()); + systemInfo.put("day", formatBetween); + systemInfo.put("ip", KitIPUtil.getLocalIp()); + return systemInfo; + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java index 337cdf16..1742dbe1 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java @@ -14,16 +14,16 @@ import org.springframework.stereotype.Service; @Service public class SystemOperationLogService { - @Autowired - private SystemOperationLogMapper systemOperationLogMapper; + @Autowired + private SystemOperationLogMapper systemOperationLogMapper; - /** - * 查询用户操作日志 - */ - public IPage searchUserLog(KitPageArgs pageArgs) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemOperationLogTb::getUsername, KitSecurityHelper.getCurrentUsername()); - Page page = new Page<>(pageArgs.getPage(), pageArgs.getSize()); - return systemOperationLogMapper.selectPage(page, wrapper); - } + /** + * 查询用户操作日志 + */ + public IPage searchUserLog(KitPageArgs pageArgs) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemOperationLogTb::getUsername, KitSecurityHelper.getCurrentUsername()); + Page page = new Page<>(pageArgs.getPage(), pageArgs.getSize()); + return systemOperationLogMapper.selectPage(page, wrapper); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOssStorageService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOssStorageService.java index 5234b0a6..4b557483 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOssStorageService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOssStorageService.java @@ -21,9 +21,9 @@ import cn.odboy.system.dal.model.request.SystemQueryStorageArgs; import cn.odboy.system.dal.model.response.SystemOssStorageVo; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; -import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletResponse; import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.web.multipart.MultipartFile; /** *

@@ -35,13 +35,13 @@ import java.util.List; */ public interface SystemOssStorageService extends IService { - KitPageResult searchOssStorage(SystemQueryStorageArgs args, Page page); + KitPageResult searchOssStorage(SystemQueryStorageArgs args, Page page); - List queryOssStorage(SystemQueryStorageArgs args); + List queryOssStorage(SystemQueryStorageArgs args); - String uploadFile(MultipartFile file); + String uploadFile(MultipartFile file); - void deleteFileByIds(Long[] ids); + void deleteFileByIds(Long[] ids); - void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args); + void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java index fb2de69b..a15314bb 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java @@ -38,283 +38,283 @@ import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.quartz.CronExpression; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; +import javax.servlet.http.HttpServletResponse; +import org.quartz.CronExpression; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemQuartzJobService { - @Autowired - private SystemQuartzJobMapper systemQuartzJobMapper; - @Autowired - private SystemQuartzLogMapper systemQuartzLogMapper; - @Autowired - private QuartzManage quartzManage; - @Autowired - private KitRedisHelper redisHelper; + @Autowired + private SystemQuartzJobMapper systemQuartzJobMapper; + @Autowired + private SystemQuartzLogMapper systemQuartzLogMapper; + @Autowired + private QuartzManage quartzManage; + @Autowired + private KitRedisHelper redisHelper; - /** - * 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义 - * - * @param beanName Bean名称 - */ - private void checkBean(String beanName) { - // 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类 - // 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。 - if (!KitSpringBeanHolder.getAllServiceBeanName().contains(beanName)) { - throw new BadRequestException("非法的 Bean,请重新输入!"); - } + /** + * 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义 + * + * @param beanName Bean名称 + */ + private void checkBean(String beanName) { + // 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类 + // 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。 + if (!KitSpringBeanHolder.getAllServiceBeanName().contains(beanName)) { + throw new BadRequestException("非法的 Bean,请重新输入!"); } + } - /** - * 创建 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void createJob(SystemQuartzJobVo args) { - if (args.getId() != null) { - throw new BadRequestException("无效参数id"); - } - // 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义 - checkBean(args.getBeanName()); - if (!CronExpression.isValidExpression(args.getCronExpression())) { - throw new BadRequestException("cron表达式格式错误"); - } - SystemQuartzJobTb record = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class); - systemQuartzJobMapper.insert(record); - quartzManage.addJob(args); + /** + * 创建 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void createJob(SystemQuartzJobVo args) { + if (args.getId() != null) { + throw new BadRequestException("无效参数id"); } + // 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义 + checkBean(args.getBeanName()); + if (!CronExpression.isValidExpression(args.getCronExpression())) { + throw new BadRequestException("cron表达式格式错误"); + } + SystemQuartzJobTb record = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class); + systemQuartzJobMapper.insert(record); + quartzManage.addJob(args); + } - /** - * 修改任务并重新调度 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateQuartzJobResumeCron(SystemUpdateQuartzJobArgs args) { - // 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义 - checkBean(args.getBeanName()); - if (!CronExpression.isValidExpression(args.getCronExpression())) { - throw new BadRequestException("cron表达式格式错误"); - } - if (StrUtil.isNotBlank(args.getSubTask())) { - List tasks = Arrays.asList(args.getSubTask().split("[,,]")); - if (tasks.contains(args.getId().toString())) { - throw new BadRequestException("子任务中不能添加当前任务ID"); - } - } - SystemQuartzJobTb jobTb = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class); - systemQuartzJobMapper.insertOrUpdate(jobTb); - SystemQuartzJobVo jobVo = KitBeanUtil.copyToClass(args, SystemQuartzJobVo.class); - quartzManage.updateJobCron(jobVo); + /** + * 修改任务并重新调度 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateQuartzJobResumeCron(SystemUpdateQuartzJobArgs args) { + // 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义 + checkBean(args.getBeanName()); + if (!CronExpression.isValidExpression(args.getCronExpression())) { + throw new BadRequestException("cron表达式格式错误"); } + if (StrUtil.isNotBlank(args.getSubTask())) { + List tasks = Arrays.asList(args.getSubTask().split("[,,]")); + if (tasks.contains(args.getId().toString())) { + throw new BadRequestException("子任务中不能添加当前任务ID"); + } + } + SystemQuartzJobTb jobTb = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class); + systemQuartzJobMapper.insertOrUpdate(jobTb); + SystemQuartzJobVo jobVo = KitBeanUtil.copyToClass(args, SystemQuartzJobVo.class); + quartzManage.updateJobCron(jobVo); + } - /** - * 更改定时任务状态 - * - * @param quartzJob / - */ - @Transactional(rollbackFor = Exception.class) - public void switchQuartzJobStatus(SystemQuartzJobVo quartzJob) { - // 置换暂停状态 - if (quartzJob.getIsPause()) { - quartzManage.resumeJob(quartzJob); - quartzJob.setIsPause(false); - } else { - quartzManage.pauseJob(quartzJob); - quartzJob.setIsPause(true); - } - SystemQuartzJobTb quartzJobTb = KitBeanUtil.copyToClass(quartzJob, SystemQuartzJobTb.class); - systemQuartzJobMapper.insertOrUpdate(quartzJobTb); + /** + * 更改定时任务状态 + * + * @param quartzJob / + */ + @Transactional(rollbackFor = Exception.class) + public void switchQuartzJobStatus(SystemQuartzJobVo quartzJob) { + // 置换暂停状态 + if (quartzJob.getIsPause()) { + quartzManage.resumeJob(quartzJob); + quartzJob.setIsPause(false); + } else { + quartzManage.pauseJob(quartzJob); + quartzJob.setIsPause(true); } + SystemQuartzJobTb quartzJobTb = KitBeanUtil.copyToClass(quartzJob, SystemQuartzJobTb.class); + systemQuartzJobMapper.insertOrUpdate(quartzJobTb); + } - /** - * 立即执行定时任务 - * - * @param quartzJob / - */ - public void startQuartzJob(SystemQuartzJobVo quartzJob) { - quartzManage.runJobNow(quartzJob); - } + /** + * 立即执行定时任务 + * + * @param quartzJob / + */ + public void startQuartzJob(SystemQuartzJobVo quartzJob) { + quartzManage.runJobNow(quartzJob); + } - /** - * 删除任务 - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteJobByIds(Set ids) { - for (Long id : ids) { - SystemQuartzJobTb quartzJob = systemQuartzJobMapper.selectById(id); - quartzManage.deleteJob(quartzJob); - systemQuartzJobMapper.deleteById(quartzJob); - } + /** + * 删除任务 + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteJobByIds(Set ids) { + for (Long id : ids) { + SystemQuartzJobTb quartzJob = systemQuartzJobMapper.selectById(id); + quartzManage.deleteJob(quartzJob); + systemQuartzJobMapper.deleteById(quartzJob); } + } - /** - * 执行子任务 - * - * @param tasks / - * @throws InterruptedException / - */ - @Transactional(rollbackFor = Exception.class) - public void startSubQuartJob(String[] tasks) throws InterruptedException { - for (String id : tasks) { - if (StrUtil.isBlank(id)) { - // 如果是手动清除子任务id, 会出现id为空字符串的问题 - continue; - } - SystemQuartzJobVo quartzJob = systemQuartzJobMapper.selectVoById(id); - if (quartzJob == null) { - // 防止子任务不存在 - continue; - } - // 执行任务 - String uuid = IdUtil.simpleUUID(); - quartzJob.setUuid(uuid); - // 执行任务 - startQuartzJob(quartzJob); - // 获取执行状态, 如果执行失败则停止后面的子任务执行 - Boolean result = redisHelper.get(uuid, Boolean.class); - while (result == null) { - // 休眠5秒, 再次获取子任务执行情况 - Thread.sleep(5000); - result = redisHelper.get(uuid, Boolean.class); - } - if (!result) { - redisHelper.del(uuid); - break; - } - } + /** + * 执行子任务 + * + * @param tasks / + * @throws InterruptedException / + */ + @Transactional(rollbackFor = Exception.class) + public void startSubQuartJob(String[] tasks) throws InterruptedException { + for (String id : tasks) { + if (StrUtil.isBlank(id)) { + // 如果是手动清除子任务id, 会出现id为空字符串的问题 + continue; + } + SystemQuartzJobVo quartzJob = systemQuartzJobMapper.selectVoById(id); + if (quartzJob == null) { + // 防止子任务不存在 + continue; + } + // 执行任务 + String uuid = IdUtil.simpleUUID(); + quartzJob.setUuid(uuid); + // 执行任务 + startQuartzJob(quartzJob); + // 获取执行状态, 如果执行失败则停止后面的子任务执行 + Boolean result = redisHelper.get(uuid, Boolean.class); + while (result == null) { + // 休眠5秒, 再次获取子任务执行情况 + Thread.sleep(5000); + result = redisHelper.get(uuid, Boolean.class); + } + if (!result) { + redisHelper.del(uuid); + break; + } } + } - /** - * 分页查询 - * - * @param args 条件 - * @param page 分页参数 - * @return / - */ - public KitPageResult searchQuartzJobByArgs(SystemQueryQuartzJobArgs args, - Page page) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQuartzJobQueryParams(args, wrapper); - return KitPageUtil.toPage(systemQuartzJobMapper.selectPage(page, wrapper)); - } + /** + * 分页查询 + * + * @param args 条件 + * @param page 分页参数 + * @return / + */ + public KitPageResult searchQuartzJobByArgs(SystemQueryQuartzJobArgs args, + Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQuartzJobQueryParams(args, wrapper); + return KitPageUtil.toPage(systemQuartzJobMapper.selectPage(page, wrapper)); + } - private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args, - LambdaQueryWrapper wrapper) { - KitValidUtil.notNull(args); - wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName, args.getJobName()); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); - } - wrapper.orderByDesc(SystemQuartzJobTb::getId); + private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args, + LambdaQueryWrapper wrapper) { + KitValidUtil.notNull(args); + wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName, args.getJobName()); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); } + wrapper.orderByDesc(SystemQuartzJobTb::getId); + } - private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, - LambdaQueryWrapper wrapper) { - if (args != null) { - wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName()); - wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess()); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemQuartzLogTb::getCreateTime, args.getCreateTime().get(0), - args.getCreateTime().get(1)); - } - } - wrapper.orderByDesc(SystemQuartzLogTb::getId); + private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, + LambdaQueryWrapper wrapper) { + if (args != null) { + wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName()); + wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess()); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemQuartzLogTb::getCreateTime, args.getCreateTime().get(0), + args.getCreateTime().get(1)); + } } + wrapper.orderByDesc(SystemQuartzLogTb::getId); + } - /** - * 分页查询日志 - * - * @param args 条件 - * @param page 分页参数 - * @return / - */ - public KitPageResult searchQuartzLogByArgs(SystemQueryQuartzJobArgs args, - Page page) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQuartzLogQueryParams(args, wrapper); - return KitPageUtil.toPage(systemQuartzLogMapper.selectPage(page, wrapper)); - } + /** + * 分页查询日志 + * + * @param args 条件 + * @param page 分页参数 + * @return / + */ + public KitPageResult searchQuartzLogByArgs(SystemQueryQuartzJobArgs args, + Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQuartzLogQueryParams(args, wrapper); + return KitPageUtil.toPage(systemQuartzLogMapper.selectPage(page, wrapper)); + } - /** - * 查询全部 - * - * @param args 条件 - * @return / - */ - public List queryQuartzJobByArgs(SystemQueryQuartzJobArgs args) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQuartzJobQueryParams(args, wrapper); - return systemQuartzJobMapper.selectList(wrapper); - } + /** + * 查询全部 + * + * @param args 条件 + * @return / + */ + public List queryQuartzJobByArgs(SystemQueryQuartzJobArgs args) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQuartzJobQueryParams(args, wrapper); + return systemQuartzJobMapper.selectList(wrapper); + } - /** - * 查询全部 - * - * @param args 条件 - * @return / - */ - public List queryQuartzLogByArgs(SystemQueryQuartzJobArgs args) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - this.injectQuartzLogQueryParams(args, wrapper); - return systemQuartzLogMapper.selectList(wrapper); - } + /** + * 查询全部 + * + * @param args 条件 + * @return / + */ + public List queryQuartzLogByArgs(SystemQueryQuartzJobArgs args) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQuartzLogQueryParams(args, wrapper); + return systemQuartzLogMapper.selectList(wrapper); + } - public SystemQuartzJobVo getQuartzJobById(Long id) { - return KitBeanUtil.copyToClass(systemQuartzJobMapper.selectById(id), SystemQuartzJobVo.class); - } + public SystemQuartzJobVo getQuartzJobById(Long id) { + return KitBeanUtil.copyToClass(systemQuartzJobMapper.selectById(id), SystemQuartzJobVo.class); + } - public List listEnableQuartzJob() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemQuartzJobTb::getIsPause, 0); - return KitBeanUtil.copyToList(systemQuartzJobMapper.selectList(wrapper), SystemQuartzJobVo.class); - } + public List listEnableQuartzJob() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemQuartzJobTb::getIsPause, 0); + return KitBeanUtil.copyToList(systemQuartzJobMapper.selectList(wrapper), SystemQuartzJobVo.class); + } - public void exportQuartzJobXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) { - List systemQuartzJobTbs = this.queryQuartzJobByArgs(args); - List rowVos = new ArrayList<>(); - for (SystemQuartzJobTb dataObject : systemQuartzJobTbs) { - SystemQuartzJobExportRowVo rowVo = new SystemQuartzJobExportRowVo(); - rowVo.setJobName(dataObject.getJobName()); - rowVo.setBeanName(dataObject.getBeanName()); - rowVo.setMethodName(dataObject.getMethodName()); - rowVo.setParams(dataObject.getParams()); - rowVo.setCronExpression(dataObject.getCronExpression()); - rowVo.setIsPause(dataObject.getIsPause() ? "暂停中" : "运行中"); - rowVo.setDescription(dataObject.getDescription()); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - KitExcelExporter.exportSimple(response, "定时任务数据", SystemQuartzJobExportRowVo.class, rowVos); + public void exportQuartzJobXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) { + List systemQuartzJobTbs = this.queryQuartzJobByArgs(args); + List rowVos = new ArrayList<>(); + for (SystemQuartzJobTb dataObject : systemQuartzJobTbs) { + SystemQuartzJobExportRowVo rowVo = new SystemQuartzJobExportRowVo(); + rowVo.setJobName(dataObject.getJobName()); + rowVo.setBeanName(dataObject.getBeanName()); + rowVo.setMethodName(dataObject.getMethodName()); + rowVo.setParams(dataObject.getParams()); + rowVo.setCronExpression(dataObject.getCronExpression()); + rowVo.setIsPause(dataObject.getIsPause() ? "暂停中" : "运行中"); + rowVo.setDescription(dataObject.getDescription()); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); } + KitExcelExporter.exportSimple(response, "定时任务数据", SystemQuartzJobExportRowVo.class, rowVos); + } - public void exportQuartzLogXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) { - List systemQuartzLogTbs = this.queryQuartzLogByArgs(args); - List rowVos = new ArrayList<>(); - for (SystemQuartzLogTb dataObject : systemQuartzLogTbs) { - SystemQuartzLogExportRowVo rowVo = new SystemQuartzLogExportRowVo(); - rowVo.setJobName(dataObject.getJobName()); - rowVo.setBeanName(dataObject.getBeanName()); - rowVo.setMethodName(dataObject.getMethodName()); - rowVo.setParams(dataObject.getParams()); - rowVo.setCronExpression(dataObject.getCronExpression()); - rowVo.setExceptionDetail(dataObject.getExceptionDetail()); - rowVo.setTime(dataObject.getTime()); - rowVo.setStatus(dataObject.getIsSuccess() ? "成功" : "失败"); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - KitExcelExporter.exportSimple(response, "定时任务日志数据", SystemQuartzLogExportRowVo.class, rowVos); + public void exportQuartzLogXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) { + List systemQuartzLogTbs = this.queryQuartzLogByArgs(args); + List rowVos = new ArrayList<>(); + for (SystemQuartzLogTb dataObject : systemQuartzLogTbs) { + SystemQuartzLogExportRowVo rowVo = new SystemQuartzLogExportRowVo(); + rowVo.setJobName(dataObject.getJobName()); + rowVo.setBeanName(dataObject.getBeanName()); + rowVo.setMethodName(dataObject.getMethodName()); + rowVo.setParams(dataObject.getParams()); + rowVo.setCronExpression(dataObject.getCronExpression()); + rowVo.setExceptionDetail(dataObject.getExceptionDetail()); + rowVo.setTime(dataObject.getTime()); + rowVo.setStatus(dataObject.getIsSuccess() ? "成功" : "失败"); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); } + KitExcelExporter.exportSimple(response, "定时任务日志数据", SystemQuartzLogExportRowVo.class, rowVos); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java index 316ccbc5..517f7c57 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java @@ -20,65 +20,65 @@ import cn.odboy.system.dal.dataobject.SystemDeptTb; import cn.odboy.system.dal.dataobject.SystemRoleDeptTb; import cn.odboy.system.dal.mysql.SystemRoleDeptMapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemRoleDeptService { - @Autowired - private SystemRoleDeptMapper systemRoleDeptMapper; + @Autowired + private SystemRoleDeptMapper systemRoleDeptMapper; - @Transactional(rollbackFor = Exception.class) - public void batchDeleteRoleDept(Set roleIds) { - if (CollUtil.isNotEmpty(roleIds)) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemRoleDeptTb::getRoleId, roleIds); - systemRoleDeptMapper.delete(wrapper); - } + @Transactional(rollbackFor = Exception.class) + public void batchDeleteRoleDept(Set roleIds) { + if (CollUtil.isNotEmpty(roleIds)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemRoleDeptTb::getRoleId, roleIds); + systemRoleDeptMapper.delete(wrapper); + } + } + + @Transactional(rollbackFor = Exception.class) + public void batchInsertRoleDept(Set depts, Long id) { + if (CollUtil.isNotEmpty(depts)) { + List records = new ArrayList<>(); + for (SystemDeptTb dept : depts) { + SystemRoleDeptTb record = new SystemRoleDeptTb(); + record.setRoleId(id); + record.setDeptId(dept.getId()); + records.add(record); + } + systemRoleDeptMapper.insert(records); + } + } + + /** + * 根据部门ID统计角色数量 + * + * @param deptIds 部门ID集合 + * @return / + */ + public Long countRoleByDeptIds(Set deptIds) { + if (CollUtil.isEmpty(deptIds)) { + return 0L; } - @Transactional(rollbackFor = Exception.class) - public void batchInsertRoleDept(Set depts, Long id) { - if (CollUtil.isNotEmpty(depts)) { - List records = new ArrayList<>(); - for (SystemDeptTb dept : depts) { - SystemRoleDeptTb record = new SystemRoleDeptTb(); - record.setRoleId(id); - record.setDeptId(dept.getId()); - records.add(record); - } - systemRoleDeptMapper.insert(records); - } - } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemRoleDeptTb::getDeptId, deptIds); + return systemRoleDeptMapper.selectCount(wrapper); + } - /** - * 根据部门ID统计角色数量 - * - * @param deptIds 部门ID集合 - * @return / - */ - public Long countRoleByDeptIds(Set deptIds) { - if (CollUtil.isEmpty(deptIds)) { - return 0L; - } - - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemRoleDeptTb::getDeptId, deptIds); - return systemRoleDeptMapper.selectCount(wrapper); - } - - /** - * 根据角色id查询部门信息 - * - * @param roleId 角色id - * @return / - */ - public Set listUserDeptByRoleId(Long roleId) { - return systemRoleDeptMapper.listUserDeptByRoleId(roleId); - } + /** + * 根据角色id查询部门信息 + * + * @param roleId 角色id + * @return / + */ + public Set listUserDeptByRoleId(Long roleId) { + return systemRoleDeptMapper.listUserDeptByRoleId(roleId); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleMenuService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleMenuService.java index c86ef87b..2dde9009 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleMenuService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleMenuService.java @@ -23,82 +23,82 @@ import cn.odboy.system.dal.mysql.SystemMenuMapper; import cn.odboy.system.dal.mysql.SystemRoleMenuMapper; import cn.odboy.util.KitBeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemRoleMenuService { - @Autowired - private SystemRoleMenuMapper systemRoleMenuMapper; - @Autowired - private SystemMenuMapper systemMenuMapper; + @Autowired + private SystemRoleMenuMapper systemRoleMenuMapper; + @Autowired + private SystemMenuMapper systemMenuMapper; - @Transactional(rollbackFor = Exception.class) - public void deleteRoleMenuByRoleId(Long roleId) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemRoleMenuTb::getRoleId, roleId); - systemRoleMenuMapper.delete(wrapper); + @Transactional(rollbackFor = Exception.class) + public void deleteRoleMenuByRoleId(Long roleId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemRoleMenuTb::getRoleId, roleId); + systemRoleMenuMapper.delete(wrapper); + } + + @Transactional(rollbackFor = Exception.class) + public void batchInsertRoleMenu(Set menus, Long roleId) { + if (CollUtil.isNotEmpty(menus)) { + List records = new ArrayList<>(); + for (SystemMenuVo menu : menus) { + SystemRoleMenuTb record = new SystemRoleMenuTb(); + record.setMenuId(menu.getId()); + record.setRoleId(roleId); + records.add(record); + } + systemRoleMenuMapper.insert(records); } + } - @Transactional(rollbackFor = Exception.class) - public void batchInsertRoleMenu(Set menus, Long roleId) { - if (CollUtil.isNotEmpty(menus)) { - List records = new ArrayList<>(); - for (SystemMenuVo menu : menus) { - SystemRoleMenuTb record = new SystemRoleMenuTb(); - record.setMenuId(menu.getId()); - record.setRoleId(roleId); - records.add(record); - } - systemRoleMenuMapper.insert(records); - } + @Transactional(rollbackFor = Exception.class) + public void batchDeleteRoleMenu(Set roleIds) { + if (CollUtil.isNotEmpty(roleIds)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemRoleMenuTb::getRoleId, roleIds); + systemRoleMenuMapper.delete(wrapper); } + } - @Transactional(rollbackFor = Exception.class) - public void batchDeleteRoleMenu(Set roleIds) { - if (CollUtil.isNotEmpty(roleIds)) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemRoleMenuTb::getRoleId, roleIds); - systemRoleMenuMapper.delete(wrapper); - } + public LinkedHashSet queryMenuByRoleIds(Set roleIds) { + if (CollUtil.isEmpty(roleIds)) { + return new LinkedHashSet<>(); } - - public LinkedHashSet queryMenuByRoleIds(Set roleIds) { - if (CollUtil.isEmpty(roleIds)) { - return new LinkedHashSet<>(); - } - LambdaQueryWrapper roleMenuWrapper = new LambdaQueryWrapper<>(); - roleMenuWrapper.in(SystemRoleMenuTb::getRoleId, roleIds); - List menuIds = systemRoleMenuMapper.selectList(roleMenuWrapper).stream().map(SystemRoleMenuTb::getMenuId) - .collect(Collectors.toList()); - if (CollUtil.isEmpty(menuIds)) { - return new LinkedHashSet<>(); - } - LambdaQueryWrapper menuWrapper = new LambdaQueryWrapper<>(); - menuWrapper.in(SystemMenuTb::getId, menuIds); - // 排除"按钮" - menuWrapper.ne(SystemMenuTb::getType, 2); - menuWrapper.orderByAsc(SystemMenuTb::getMenuSort); - - List systemMenuTbs = systemMenuMapper.selectList(menuWrapper); - List systemMenuVos = KitBeanUtil.copyToList(systemMenuTbs, SystemMenuVo.class); - return new LinkedHashSet<>(systemMenuVos); + LambdaQueryWrapper roleMenuWrapper = new LambdaQueryWrapper<>(); + roleMenuWrapper.in(SystemRoleMenuTb::getRoleId, roleIds); + List menuIds = systemRoleMenuMapper.selectList(roleMenuWrapper).stream().map(SystemRoleMenuTb::getMenuId) + .collect(Collectors.toList()); + if (CollUtil.isEmpty(menuIds)) { + return new LinkedHashSet<>(); } + LambdaQueryWrapper menuWrapper = new LambdaQueryWrapper<>(); + menuWrapper.in(SystemMenuTb::getId, menuIds); + // 排除"按钮" + menuWrapper.ne(SystemMenuTb::getType, 2); + menuWrapper.orderByAsc(SystemMenuTb::getMenuSort); - @Transactional(rollbackFor = Exception.class) - public void deleteRoleMenuByMenuIds(List menuIds) { - if (CollUtil.isEmpty(menuIds)) { - return; - } - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemRoleMenuTb::getMenuId, menuIds); - systemRoleMenuMapper.delete(wrapper); + List systemMenuTbs = systemMenuMapper.selectList(menuWrapper); + List systemMenuVos = KitBeanUtil.copyToList(systemMenuTbs, SystemMenuVo.class); + return new LinkedHashSet<>(systemMenuVos); + } + + @Transactional(rollbackFor = Exception.class) + public void deleteRoleMenuByMenuIds(List menuIds) { + if (CollUtil.isEmpty(menuIds)) { + return; } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemRoleMenuTb::getMenuId, menuIds); + systemRoleMenuMapper.delete(wrapper); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java index b13e0fc7..1b6fe46d 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java @@ -36,260 +36,260 @@ import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemRoleService { - @Autowired - private SystemRoleMapper systemRoleMapper; - @Autowired - private SystemRoleMenuService systemRoleMenuService; - @Autowired - private SystemRoleDeptService systemRoleDeptService; - @Autowired - private SystemUserRoleService systemUserRoleService; + @Autowired + private SystemRoleMapper systemRoleMapper; + @Autowired + private SystemRoleMenuService systemRoleMenuService; + @Autowired + private SystemRoleDeptService systemRoleDeptService; + @Autowired + private SystemUserRoleService systemUserRoleService; - /** - * 创建 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveRole(SystemCreateRoleArgs args) { - checkRoleLevels(args.getLevel()); - if (this.countRoleByName(args.getName()) > 0) { - throw new BadRequestException("角色名称已存在"); - } - SystemRoleTb roleTb = KitBeanUtil.copyToClass(args, SystemRoleTb.class); - systemRoleMapper.insert(roleTb); - // 判断是否有部门数据, 若有, 则需创建关联 - if (CollUtil.isNotEmpty(args.getDepts())) { - systemRoleDeptService.batchInsertRoleDept(args.getDepts(), roleTb.getId()); - } + /** + * 创建 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveRole(SystemCreateRoleArgs args) { + checkRoleLevels(args.getLevel()); + if (this.countRoleByName(args.getName()) > 0) { + throw new BadRequestException("角色名称已存在"); } + SystemRoleTb roleTb = KitBeanUtil.copyToClass(args, SystemRoleTb.class); + systemRoleMapper.insert(roleTb); + // 判断是否有部门数据, 若有, 则需创建关联 + if (CollUtil.isNotEmpty(args.getDepts())) { + systemRoleDeptService.batchInsertRoleDept(args.getDepts(), roleTb.getId()); + } + } - private SystemRoleTb getRoleByName(String name) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemRoleTb::getName, name); - return systemRoleMapper.selectOne(wrapper); - } + private SystemRoleTb getRoleByName(String name) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemRoleTb::getName, name); + return systemRoleMapper.selectOne(wrapper); + } - private long countRoleByName(String name) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemRoleTb::getName, name); - return systemRoleMapper.selectCount(wrapper); - } + private long countRoleByName(String name) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemRoleTb::getName, name); + return systemRoleMapper.selectCount(wrapper); + } - /** - * 修改 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateRoleById(SystemRoleVo args) { - checkRoleLevels(args.getLevel()); - SystemRoleTb role = this.getRoleTbById(args.getId()); - SystemRoleTb role1 = this.getRoleByName(args.getName()); - if (role1 != null && !role1.getId().equals(role.getId())) { - throw new BadRequestException("角色名称已存在"); - } - role.setName(args.getName()); - role.setDescription(args.getDescription()); - role.setDataScope(args.getDataScope()); - role.setLevel(args.getLevel()); - // 更新 - systemRoleMapper.insertOrUpdate(role); - // 删除关联部门数据 - systemRoleDeptService.batchDeleteRoleDept(Collections.singleton(args.getId())); - // 判断是否有部门数据, 若有, 则需更新关联 - if (CollUtil.isNotEmpty(args.getDepts())) { - systemRoleDeptService.batchInsertRoleDept(args.getDepts(), args.getId()); - } + /** + * 修改 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateRoleById(SystemRoleVo args) { + checkRoleLevels(args.getLevel()); + SystemRoleTb role = this.getRoleTbById(args.getId()); + SystemRoleTb role1 = this.getRoleByName(args.getName()); + if (role1 != null && !role1.getId().equals(role.getId())) { + throw new BadRequestException("角色名称已存在"); } + role.setName(args.getName()); + role.setDescription(args.getDescription()); + role.setDataScope(args.getDataScope()); + role.setLevel(args.getLevel()); + // 更新 + systemRoleMapper.insertOrUpdate(role); + // 删除关联部门数据 + systemRoleDeptService.batchDeleteRoleDept(Collections.singleton(args.getId())); + // 判断是否有部门数据, 若有, 则需更新关联 + if (CollUtil.isNotEmpty(args.getDepts())) { + systemRoleDeptService.batchInsertRoleDept(args.getDepts(), args.getId()); + } + } - private SystemRoleTb getRoleTbById(Long id) { - return systemRoleMapper.selectById(id); - } + private SystemRoleTb getRoleTbById(Long id) { + return systemRoleMapper.selectById(id); + } - /** - * 修改绑定的菜单 -> TestPassed - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateBindMenuById(SystemRoleVo args) { - SystemRoleTb role = systemRoleMapper.selectById(args.getId()); - checkRoleLevels(role.getLevel()); - // 更新菜单 - systemRoleMenuService.deleteRoleMenuByRoleId(role.getId()); - // 判断是否为空 - Set menus = args.getMenus(); - if (CollUtil.isNotEmpty(menus)) { - systemRoleMenuService.batchInsertRoleMenu(menus, role.getId()); - } + /** + * 修改绑定的菜单 -> TestPassed + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateBindMenuById(SystemRoleVo args) { + SystemRoleTb role = systemRoleMapper.selectById(args.getId()); + checkRoleLevels(role.getLevel()); + // 更新菜单 + systemRoleMenuService.deleteRoleMenuByRoleId(role.getId()); + // 判断是否为空 + Set menus = args.getMenus(); + if (CollUtil.isNotEmpty(menus)) { + systemRoleMenuService.batchInsertRoleMenu(menus, role.getId()); } + } - /** - * 删除 -> TestPassed - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteRoleByIds(Set ids) { - List roleLevels = systemRoleMapper.selectByIds(ids).stream().map(SystemRoleTb::getLevel).distinct() - .collect(Collectors.toList()); - for (Integer roleLevel : roleLevels) { - checkRoleLevels(roleLevel); - } - // 验证是否被用户关联 - this.verifyBindRelationByIds(ids); - // 删除角色 - systemRoleMapper.deleteByIds(ids); - // 删除角色部门关联数据、角色菜单关联数据 - systemRoleDeptService.batchDeleteRoleDept(ids); - systemRoleMenuService.batchDeleteRoleMenu(ids); + /** + * 删除 -> TestPassed + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteRoleByIds(Set ids) { + List roleLevels = systemRoleMapper.selectByIds(ids).stream().map(SystemRoleTb::getLevel).distinct() + .collect(Collectors.toList()); + for (Integer roleLevel : roleLevels) { + checkRoleLevels(roleLevel); } + // 验证是否被用户关联 + this.verifyBindRelationByIds(ids); + // 删除角色 + systemRoleMapper.deleteByIds(ids); + // 删除角色部门关联数据、角色菜单关联数据 + systemRoleDeptService.batchDeleteRoleDept(ids); + systemRoleMenuService.batchDeleteRoleMenu(ids); + } - /** - * 查询全部角色 -> TestPassed - */ - public List listAllRole() { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.orderByAsc(SystemRoleTb::getLevel); - return systemRoleMapper.selectList(wrapper); - } + /** + * 查询全部角色 -> TestPassed + */ + public List listAllRole() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.orderByAsc(SystemRoleTb::getLevel); + return systemRoleMapper.selectList(wrapper); + } - /** - * 根据条件查询全部角色 -> TestPassed - * - * @param args 条件 - * @param rolePage 分页参数 - * @return / - */ - public List queryRoleByArgs(SystemQueryRoleArgs args, Page rolePage) { - KitValidUtil.notNull(args); - // 查询角色基本信息 - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemRoleTb::getName, args.getBlurry()).or() - .like(SystemRoleTb::getDescription, args.getBlurry())); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); - } - wrapper.orderByAsc(SystemRoleTb::getLevel); - List roles; - if (rolePage == null) { - roles = systemRoleMapper.selectList(wrapper); - } else { - Page page = systemRoleMapper.selectPage(rolePage, wrapper); - roles = page.getRecords(); - } - return roles.stream().map(systemUserRoleService::convertToRoleVo).collect(Collectors.toList()); + /** + * 根据条件查询全部角色 -> TestPassed + * + * @param args 条件 + * @param rolePage 分页参数 + * @return / + */ + public List queryRoleByArgs(SystemQueryRoleArgs args, Page rolePage) { + KitValidUtil.notNull(args); + // 查询角色基本信息 + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemRoleTb::getName, args.getBlurry()).or() + .like(SystemRoleTb::getDescription, args.getBlurry())); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); } + wrapper.orderByAsc(SystemRoleTb::getLevel); + List roles; + if (rolePage == null) { + roles = systemRoleMapper.selectList(wrapper); + } else { + Page page = systemRoleMapper.selectPage(rolePage, wrapper); + roles = page.getRecords(); + } + return roles.stream().map(systemUserRoleService::convertToRoleVo).collect(Collectors.toList()); + } - /** - * 分页查询角色 -> TestPassed - * - * @param args 条件 - * @param page 分页条件 - * @return / - */ - public KitPageResult searchRoleByArgs(SystemQueryRoleArgs args, Page page) { - List roles = this.queryRoleByArgs(args, page); - Long total = this.countRoleByArgs(args); - return KitPageUtil.toPage(roles, total); - } + /** + * 分页查询角色 -> TestPassed + * + * @param args 条件 + * @param page 分页条件 + * @return / + */ + public KitPageResult searchRoleByArgs(SystemQueryRoleArgs args, Page page) { + List roles = this.queryRoleByArgs(args, page); + Long total = this.countRoleByArgs(args); + return KitPageUtil.toPage(roles, total); + } - /** - * 获取用户权限信息 -> TestPassed - * - * @param user 用户信息 - * @return 权限信息 - */ - public List buildUserRolePermissions(SystemUserVo user) { - Set permissions = new HashSet<>(); - // 如果是管理员直接返回 - if (user.getIsAdmin()) { - permissions.add("admin"); - return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); - } - List roles = systemUserRoleService.queryRoleVoByUsersId(user.getId()); - permissions = roles.stream().flatMap(role -> role.getMenus().stream()).map(SystemMenuVo::getPermission) - .filter(StrUtil::isNotBlank).collect(Collectors.toSet()); - return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); + /** + * 获取用户权限信息 -> TestPassed + * + * @param user 用户信息 + * @return 权限信息 + */ + public List buildUserRolePermissions(SystemUserVo user) { + Set permissions = new HashSet<>(); + // 如果是管理员直接返回 + if (user.getIsAdmin()) { + permissions.add("admin"); + return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); } + List roles = systemUserRoleService.queryRoleVoByUsersId(user.getId()); + permissions = roles.stream().flatMap(role -> role.getMenus().stream()).map(SystemMenuVo::getPermission) + .filter(StrUtil::isNotBlank).collect(Collectors.toSet()); + return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); + } - /** - * 验证是否被用户关联 -> TestPassed - * - * @param ids / - */ - public void verifyBindRelationByIds(Set ids) { - if (systemUserRoleService.countUserByRoleIds(ids) > 0) { - throw new BadRequestException("所选角色存在用户关联, 请解除关联再试!"); - } + /** + * 验证是否被用户关联 -> TestPassed + * + * @param ids / + */ + public void verifyBindRelationByIds(Set ids) { + if (systemUserRoleService.countUserByRoleIds(ids) > 0) { + throw new BadRequestException("所选角色存在用户关联, 请解除关联再试!"); } + } - public Long countRoleByArgs(SystemQueryRoleArgs args) { - KitValidUtil.notNull(args); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemRoleTb::getName, args.getBlurry()).or() - .like(SystemRoleTb::getDescription, args.getBlurry())); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); - } - return systemRoleMapper.selectCount(wrapper); + public Long countRoleByArgs(SystemQueryRoleArgs args) { + KitValidUtil.notNull(args); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.and(StrUtil.isNotBlank(args.getBlurry()), c -> c.like(SystemRoleTb::getName, args.getBlurry()).or() + .like(SystemRoleTb::getDescription, args.getBlurry())); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemRoleTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); } + return systemRoleMapper.selectCount(wrapper); + } - public SystemRoleVo getRoleById(Long id) { - SystemRoleTb roleTb = systemRoleMapper.selectById(id); - if (roleTb == null) { - return null; - } - return systemUserRoleService.convertToRoleVo(roleTb); + public SystemRoleVo getRoleById(Long id) { + SystemRoleTb roleTb = systemRoleMapper.selectById(id); + if (roleTb == null) { + return null; } + return systemUserRoleService.convertToRoleVo(roleTb); + } - public Dict getCurrentUserRoleLevel() { - return Dict.create().set("level", checkRoleLevels(null)); - } + public Dict getCurrentUserRoleLevel() { + return Dict.create().set("level", checkRoleLevels(null)); + } - /** - * 检查用户的角色级别 -> TestPassed - * - * @return / - */ - private int checkRoleLevels(Integer level) { - List levels = systemUserRoleService.queryRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream() - .map(SystemRoleVo::getLevel).collect(Collectors.toList()); - int min = Collections.min(levels); - if (level != null) { - if (level < min) { - throw new BadRequestException("权限不足, 你的角色级别:" + min + ", 低于操作的角色级别:" + level); - } - } - return min; + /** + * 检查用户的角色级别 -> TestPassed + * + * @return / + */ + private int checkRoleLevels(Integer level) { + List levels = systemUserRoleService.queryRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream() + .map(SystemRoleVo::getLevel).collect(Collectors.toList()); + int min = Collections.min(levels); + if (level != null) { + if (level < min) { + throw new BadRequestException("权限不足, 你的角色级别:" + min + ", 低于操作的角色级别:" + level); + } } + return min; + } - public void exportRoleXlsx(HttpServletResponse response, SystemQueryRoleArgs args) { - List systemRoleVos = this.queryRoleByArgs(args, null); - List rowVos = new ArrayList<>(); - for (SystemRoleVo dataObject : systemRoleVos) { - SystemRoleExportRowVo rowVo = new SystemRoleExportRowVo(); - rowVo.setName(dataObject.getName()); - rowVo.setLevel(dataObject.getLevel()); - rowVo.setDescription(dataObject.getDescription()); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - KitExcelExporter.exportSimple(response, "部门数据", SystemRoleExportRowVo.class, rowVos); + public void exportRoleXlsx(HttpServletResponse response, SystemQueryRoleArgs args) { + List systemRoleVos = this.queryRoleByArgs(args, null); + List rowVos = new ArrayList<>(); + for (SystemRoleVo dataObject : systemRoleVos) { + SystemRoleExportRowVo rowVo = new SystemRoleExportRowVo(); + rowVo.setName(dataObject.getName()); + rowVo.setLevel(dataObject.getLevel()); + rowVo.setDescription(dataObject.getDescription()); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); } + KitExcelExporter.exportSimple(response, "部门数据", SystemRoleExportRowVo.class, rowVos); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java index 986789d2..e051ae16 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java @@ -3,19 +3,19 @@ package cn.odboy.system.service; import cn.odboy.system.dal.dataobject.SystemUserTb; import cn.odboy.system.dal.mysql.SystemUserMapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.Set; @Service public class SystemUserDeptService { - @Autowired - private SystemUserMapper systemUserMapper; + @Autowired + private SystemUserMapper systemUserMapper; - public long countUserByDeptIds(Set deptIds) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemUserTb::getDeptId, deptIds); - return systemUserMapper.selectCount(wrapper); - } + public long countUserByDeptIds(Set deptIds) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemUserTb::getDeptId, deptIds); + return systemUserMapper.selectCount(wrapper); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java index c0b9057e..ed5c0bab 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java @@ -20,58 +20,58 @@ import cn.odboy.system.dal.dataobject.SystemJobTb; import cn.odboy.system.dal.dataobject.SystemUserJobTb; import cn.odboy.system.dal.mysql.SystemUserJobMapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemUserJobService { - @Autowired - private SystemUserJobMapper systemUserJobMapper; + @Autowired + private SystemUserJobMapper systemUserJobMapper; - @Transactional(rollbackFor = Exception.class) - public void batchInsertUserJob(Set jobs, Long userId) { - if (CollUtil.isNotEmpty(jobs)) { - List records = new ArrayList<>(); - for (SystemJobTb job : jobs) { - SystemUserJobTb record = new SystemUserJobTb(); - record.setUserId(userId); - record.setJobId(job.getId()); - records.add(record); - } - systemUserJobMapper.insert(records); - } + @Transactional(rollbackFor = Exception.class) + public void batchInsertUserJob(Set jobs, Long userId) { + if (CollUtil.isNotEmpty(jobs)) { + List records = new ArrayList<>(); + for (SystemJobTb job : jobs) { + SystemUserJobTb record = new SystemUserJobTb(); + record.setUserId(userId); + record.setJobId(job.getId()); + records.add(record); + } + systemUserJobMapper.insert(records); } + } - @Transactional(rollbackFor = Exception.class) - public void batchDeleteUserJob(Set userIds) { - if (CollUtil.isNotEmpty(userIds)) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemUserJobTb::getUserId, userIds); - systemUserJobMapper.delete(wrapper); - } + @Transactional(rollbackFor = Exception.class) + public void batchDeleteUserJob(Set userIds) { + if (CollUtil.isNotEmpty(userIds)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemUserJobTb::getUserId, userIds); + systemUserJobMapper.delete(wrapper); } + } - /** - * 根据岗位ID统计用户数量 - * - * @param jobIds 岗位ID集合 - * @return / - */ - public Long countUserByJobIds(Set jobIds) { - if (CollUtil.isEmpty(jobIds)) { - return 0L; - } - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemUserJobTb::getJobId, jobIds); - return systemUserJobMapper.selectCount(wrapper); + /** + * 根据岗位ID统计用户数量 + * + * @param jobIds 岗位ID集合 + * @return / + */ + public Long countUserByJobIds(Set jobIds) { + if (CollUtil.isEmpty(jobIds)) { + return 0L; } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemUserJobTb::getJobId, jobIds); + return systemUserJobMapper.selectCount(wrapper); + } - public Set listUserJobByUserId(Long userId) { - return systemUserJobMapper.listUserJobByUserId(userId); - } + public Set listUserJobByUserId(Long userId) { + return systemUserJobMapper.listUserJobByUserId(userId); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java index 1ca2321f..b4291d5f 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java @@ -28,135 +28,135 @@ import cn.odboy.system.dal.mysql.SystemUserRoleMapper; import cn.odboy.system.framework.permission.core.KitSecurityHelper; import cn.odboy.util.KitBeanUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class SystemUserRoleService { - @Autowired - private SystemRoleMapper systemRoleMapper; - @Autowired - private SystemUserRoleMapper systemUserRoleMapper; - @Autowired - private SystemRoleMenuService systemRoleMenuService; - @Autowired - private SystemRoleDeptService systemRoleDeptService; + @Autowired + private SystemRoleMapper systemRoleMapper; + @Autowired + private SystemUserRoleMapper systemUserRoleMapper; + @Autowired + private SystemRoleMenuService systemRoleMenuService; + @Autowired + private SystemRoleDeptService systemRoleDeptService; - @Transactional(rollbackFor = Exception.class) - public void batchInsertUserRole(Set roles, Long userId) { - if (CollUtil.isNotEmpty(roles)) { - List records = new ArrayList<>(); - for (SystemRoleTb role : roles) { - SystemUserRoleTb record = new SystemUserRoleTb(); - record.setUserId(userId); - record.setRoleId(role.getId()); - records.add(record); - } - systemUserRoleMapper.insert(records); - } + @Transactional(rollbackFor = Exception.class) + public void batchInsertUserRole(Set roles, Long userId) { + if (CollUtil.isNotEmpty(roles)) { + List records = new ArrayList<>(); + for (SystemRoleTb role : roles) { + SystemUserRoleTb record = new SystemUserRoleTb(); + record.setUserId(userId); + record.setRoleId(role.getId()); + records.add(record); + } + systemUserRoleMapper.insert(records); } + } - @Transactional(rollbackFor = Exception.class) - public void batchDeleteUserRole(Set userIds) { - if (CollUtil.isNotEmpty(userIds)) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemUserRoleTb::getUserId, userIds); - systemUserRoleMapper.delete(wrapper); - } + @Transactional(rollbackFor = Exception.class) + public void batchDeleteUserRole(Set userIds) { + if (CollUtil.isNotEmpty(userIds)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemUserRoleTb::getUserId, userIds); + systemUserRoleMapper.delete(wrapper); } + } - /** - * 转换为SystemRoleVo并关联查询菜单和部门信息 - * - * @param role 角色基本信息 - * @return 包含关联信息的SystemRoleVo - */ - public SystemRoleVo convertToRoleVo(SystemRoleTb role) { - if (role == null) { - return null; - } - SystemRoleVo roleVo = KitBeanUtil.copyToClass(role, SystemRoleVo.class); - // 查询关联的菜单信息 - Set menus = systemRoleMenuService.queryMenuByRoleIds(Collections.singleton(role.getId())); - roleVo.setMenus(menus); - // 查询关联的部门信息 - Set depts = systemRoleDeptService.listUserDeptByRoleId(role.getId()); - roleVo.setDepts(depts); - return roleVo; + /** + * 转换为SystemRoleVo并关联查询菜单和部门信息 + * + * @param role 角色基本信息 + * @return 包含关联信息的SystemRoleVo + */ + public SystemRoleVo convertToRoleVo(SystemRoleTb role) { + if (role == null) { + return null; } + SystemRoleVo roleVo = KitBeanUtil.copyToClass(role, SystemRoleVo.class); + // 查询关联的菜单信息 + Set menus = systemRoleMenuService.queryMenuByRoleIds(Collections.singleton(role.getId())); + roleVo.setMenus(menus); + // 查询关联的部门信息 + Set depts = systemRoleDeptService.listUserDeptByRoleId(role.getId()); + roleVo.setDepts(depts); + return roleVo; + } - /** - * 根据用户ID查询 - * - * @param userId 用户ID - * @return / - */ - public List queryRoleVoByUsersId(Long userId) { - Set roles = this.listUserRoleByUserId(userId); - return roles.stream().map(this::convertToRoleVo).collect(Collectors.toList()); - } + /** + * 根据用户ID查询 + * + * @param userId 用户ID + * @return / + */ + public List queryRoleVoByUsersId(Long userId) { + Set roles = this.listUserRoleByUserId(userId); + return roles.stream().map(this::convertToRoleVo).collect(Collectors.toList()); + } - /** - * 根据角色查询角色级别 -> TestPassed - * - * @param roles / - * @return / - */ - public Integer getDeptLevelByRoles(Set roles) { - if (CollUtil.isEmpty(roles)) { - // 最小权限 - return Integer.MAX_VALUE; - } - List roleIds = - roles.stream().map(SystemRoleTb::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); - if (CollUtil.isEmpty(roleIds)) { - // 最小权限 - return Integer.MAX_VALUE; - } - List roleLevels = systemRoleMapper.selectList( - new LambdaQueryWrapper().select(SystemRoleTb::getLevel).isNotNull(SystemRoleTb::getLevel) - .in(SystemRoleTb::getId, roleIds)).stream().map(SystemRoleTb::getLevel).distinct() - .collect(Collectors.toList()); - if (CollUtil.isEmpty(roleLevels)) { - // 最小权限 - return Integer.MAX_VALUE; - } - return Collections.min(roleLevels); + /** + * 根据角色查询角色级别 -> TestPassed + * + * @param roles / + * @return / + */ + public Integer getDeptLevelByRoles(Set roles) { + if (CollUtil.isEmpty(roles)) { + // 最小权限 + return Integer.MAX_VALUE; } + List roleIds = + roles.stream().map(SystemRoleTb::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); + if (CollUtil.isEmpty(roleIds)) { + // 最小权限 + return Integer.MAX_VALUE; + } + List roleLevels = systemRoleMapper.selectList( + new LambdaQueryWrapper().select(SystemRoleTb::getLevel).isNotNull(SystemRoleTb::getLevel) + .in(SystemRoleTb::getId, roleIds)).stream().map(SystemRoleTb::getLevel).distinct() + .collect(Collectors.toList()); + if (CollUtil.isEmpty(roleLevels)) { + // 最小权限 + return Integer.MAX_VALUE; + } + return Collections.min(roleLevels); + } - /** - * 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误 - * - * @param args / - */ - public void checkLevel(SystemUserVo args) { - Integer currentLevel = Collections.min( - this.queryRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream().map(SystemRoleVo::getLevel) - .collect(Collectors.toList())); - Integer optLevel = this.getDeptLevelByRoles(args.getRoles()); - if (currentLevel > optLevel) { - throw new BadRequestException("角色权限不足"); - } + /** + * 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误 + * + * @param args / + */ + public void checkLevel(SystemUserVo args) { + Integer currentLevel = Collections.min( + this.queryRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream().map(SystemRoleVo::getLevel) + .collect(Collectors.toList())); + Integer optLevel = this.getDeptLevelByRoles(args.getRoles()); + if (currentLevel > optLevel) { + throw new BadRequestException("角色权限不足"); } + } - public long countUserByRoleIds(Set ids) { - if (CollUtil.isEmpty(ids)) { - return 0L; - } - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.in(SystemUserRoleTb::getRoleId, ids); - return systemUserRoleMapper.selectCount(wrapper); + public long countUserByRoleIds(Set ids) { + if (CollUtil.isEmpty(ids)) { + return 0L; } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemUserRoleTb::getRoleId, ids); + return systemUserRoleMapper.selectCount(wrapper); + } - public Set listUserRoleByUserId(Long userId) { - return systemUserRoleMapper.listUserRoleByUserId(userId); - } + public Set listUserRoleByUserId(Long userId) { + return systemUserRoleMapper.listUserRoleByUserId(userId); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java index 0943c00b..6d16f3ec 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java @@ -47,13 +47,6 @@ import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.ObjectUtils; -import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletResponse; import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -63,449 +56,456 @@ import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import javax.servlet.http.HttpServletResponse; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ObjectUtils; +import org.springframework.web.multipart.MultipartFile; @Service public class SystemUserService { - @Autowired - private SystemUserMapper systemUserMapper; - @Autowired - private SystemDeptService systemDeptService; - @Autowired - private SystemUserJobService systemUserJobService; - @Autowired - private SystemUserRoleService systemUserRoleService; - @Autowired - private SystemEmailService systemEmailService; - @Autowired - private SystemDataService systemDataService; - @Autowired - private SystemUserInfoDAO systemUserInfoDAO; - @Autowired - private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; - @Autowired - private KitFileLocalUploadHelper fileUploadPathHelper; - @Autowired - private AppProperties properties; - @Autowired - private PasswordEncoder passwordEncoder; + @Autowired + private SystemUserMapper systemUserMapper; + @Autowired + private SystemDeptService systemDeptService; + @Autowired + private SystemUserJobService systemUserJobService; + @Autowired + private SystemUserRoleService systemUserRoleService; + @Autowired + private SystemEmailService systemEmailService; + @Autowired + private SystemDataService systemDataService; + @Autowired + private SystemUserInfoDAO systemUserInfoDAO; + @Autowired + private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; + @Autowired + private KitFileLocalUploadHelper fileUploadPathHelper; + @Autowired + private AppProperties properties; + @Autowired + private PasswordEncoder passwordEncoder; - /** - * 新增用户 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void saveUser(SystemUserVo args) { - systemUserRoleService.checkLevel(args); - SystemUserTb record = KitBeanUtil.copyToClass(args, SystemUserTb.class); - // 默认密码 123456 - record.setPassword(passwordEncoder.encode("123456")); - record.setDeptId(args.getDept().getId()); - if (this.getUserByUsername(record.getUsername()) != null) { - throw new BadRequestException("用户名已存在"); - } - if (this.getUserByEmail(record.getEmail()) != null) { - throw new BadRequestException("邮箱已存在"); - } - if (this.getUserByPhone(record.getPhone()) != null) { - throw new BadRequestException("手机号已存在"); - } - // 保存用户 - systemUserMapper.insert(record); - // 保存用户岗位 - systemUserJobService.batchInsertUserJob(args.getJobs(), record.getId()); - // 保存用户角色 - systemUserRoleService.batchInsertUserRole(args.getRoles(), record.getId()); + /** + * 新增用户 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void saveUser(SystemUserVo args) { + systemUserRoleService.checkLevel(args); + SystemUserTb record = KitBeanUtil.copyToClass(args, SystemUserTb.class); + // 默认密码 123456 + record.setPassword(passwordEncoder.encode("123456")); + record.setDeptId(args.getDept().getId()); + if (this.getUserByUsername(record.getUsername()) != null) { + throw new BadRequestException("用户名已存在"); } - - /** - * 编辑用户 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateUserById(SystemUserVo args) { - systemUserRoleService.checkLevel(args); - SystemUserTb user = systemUserMapper.selectById(args.getId()); - SystemUserTb user1 = this.getUserByUsername(args.getUsername()); - SystemUserTb user2 = this.getUserByEmail(args.getEmail()); - SystemUserTb user3 = this.getUserByPhone(args.getPhone()); - if (user1 != null && !user.getId().equals(user1.getId())) { - throw new BadRequestException("用户名已存在"); - } - if (user2 != null && !user.getId().equals(user2.getId())) { - throw new BadRequestException("邮箱已存在"); - } - if (user3 != null && !user.getId().equals(user3.getId())) { - throw new BadRequestException("手机号已存在"); - } - // 如果用户被禁用, 则清除用户登录信息 - if (!args.getEnabled()) { - systemUserOnlineInfoDAO.kickOutByUsername(args.getUsername()); - } - user.setDeptId(args.getDept().getId()); - user.setUsername(args.getUsername()); - user.setEmail(args.getEmail()); - user.setEnabled(args.getEnabled()); - user.setPhone(args.getPhone()); - user.setNickName(args.getNickName()); - user.setGender(args.getGender()); - systemUserMapper.updateById(user); - // 清除用户登录缓存 - systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); - // 更新用户岗位 - systemUserJobService.batchDeleteUserJob(Collections.singleton(args.getId())); - systemUserJobService.batchInsertUserJob(args.getJobs(), args.getId()); - // 更新用户角色 - systemUserRoleService.batchDeleteUserRole(Collections.singleton(args.getId())); - systemUserRoleService.batchInsertUserRole(args.getRoles(), args.getId()); + if (this.getUserByEmail(record.getEmail()) != null) { + throw new BadRequestException("邮箱已存在"); } - - /** - * 用户自助修改资料 - * - * @param args / - */ - @Transactional(rollbackFor = Exception.class) - public void updateUserCenterInfoById(SystemUserTb args) { - if (!args.getId().equals(KitSecurityHelper.getCurrentUserId())) { - throw new BadRequestException("不能修改他人资料"); - } - SystemUserTb user = systemUserMapper.selectById(args.getId()); - SystemUserTb user1 = this.getUserByPhone(args.getPhone()); - if (user1 != null && !user.getId().equals(user1.getId())) { - throw new BadRequestException("手机号已存在"); - } - user.setNickName(args.getNickName()); - user.setPhone(args.getPhone()); - user.setGender(args.getGender()); - systemUserMapper.insertOrUpdate(user); - systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); + if (this.getUserByPhone(record.getPhone()) != null) { + throw new BadRequestException("手机号已存在"); } + // 保存用户 + systemUserMapper.insert(record); + // 保存用户岗位 + systemUserJobService.batchInsertUserJob(args.getJobs(), record.getId()); + // 保存用户角色 + systemUserRoleService.batchInsertUserRole(args.getRoles(), record.getId()); + } - /** - * 删除用户 - * - * @param ids / - */ - @Transactional(rollbackFor = Exception.class) - public void deleteUserByIds(Set ids) { - Long currentUserId = KitSecurityHelper.getCurrentUserId(); - // 校验权限 - for (Long id : ids) { - Integer currentLevel = Collections.min( - systemUserRoleService.queryRoleVoByUsersId(currentUserId).stream().map(SystemRoleVo::getLevel) - .collect(Collectors.toList())); - Integer optLevel = Collections.min( - systemUserRoleService.queryRoleVoByUsersId(id).stream().map(SystemRoleVo::getLevel) - .collect(Collectors.toList())); - if (currentLevel > optLevel) { - throw new BadRequestException("角色权限不足, 不能删除:" + this.getUserById(id).getUsername()); - } - } - // 清理缓存 - List usernameList = systemUserMapper.selectByIds(ids).stream().map(SystemUserTb::getUsername).distinct() - .collect(Collectors.toList()); - for (String username : usernameList) { - systemUserInfoDAO.deleteUserLoginInfoByUserName(username); - } - // 删除用户 - systemUserMapper.deleteByIds(ids); - // 删除用户岗位 - systemUserJobService.batchDeleteUserJob(ids); - // 删除用户角色 - systemUserRoleService.batchDeleteUserRole(ids); + /** + * 编辑用户 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateUserById(SystemUserVo args) { + systemUserRoleService.checkLevel(args); + SystemUserTb user = systemUserMapper.selectById(args.getId()); + SystemUserTb user1 = this.getUserByUsername(args.getUsername()); + SystemUserTb user2 = this.getUserByEmail(args.getEmail()); + SystemUserTb user3 = this.getUserByPhone(args.getPhone()); + if (user1 != null && !user.getId().equals(user1.getId())) { + throw new BadRequestException("用户名已存在"); } - - /** - * 修改密码 - * - * @param username 用户名 - * @param args 参数 - */ - @Transactional(rollbackFor = Exception.class) - public void updateUserPasswordByUsername(String username, SystemUpdateUserPasswordArgs args) throws Exception { - String oldPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getOldPass()); - String newPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getNewPass()); - SystemUserTb user = this.getUserByUsername(username); - if (!passwordEncoder.matches(oldPass, user.getPassword())) { - throw new BadRequestException("修改失败,旧密码错误"); - } - if (passwordEncoder.matches(newPass, user.getPassword())) { - throw new BadRequestException("新密码不能与旧密码相同"); - } - String encryptPassword = passwordEncoder.encode(newPass); - systemUserMapper.updateUserPasswordByUsername(username, encryptPassword); - systemUserInfoDAO.deleteUserLoginInfoByUserName(username); + if (user2 != null && !user.getId().equals(user2.getId())) { + throw new BadRequestException("邮箱已存在"); } - - /** - * 重置密码 - * - * @param ids 用户id - */ - @Transactional(rollbackFor = Exception.class) - public void resetUserPasswordByIds(Set ids) { - String defaultPwd = passwordEncoder.encode("123456"); - List users = systemUserMapper.selectByIds(ids); - // 清除缓存 - for (SystemUserTb user : users) { - // 清除缓存 - systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); - // 强制退出 - systemUserOnlineInfoDAO.kickOutByUsername(user.getUsername()); - } - // 重置密码 - systemUserMapper.updateUserPasswordByUserIds(defaultPwd, ids); + if (user3 != null && !user.getId().equals(user3.getId())) { + throw new BadRequestException("手机号已存在"); } - - /** - * 修改头像 - * - * @param multipartFile 文件 - * @return / - */ - @Transactional(rollbackFor = Exception.class) - public Map updateUserAvatar(MultipartFile multipartFile) { - SystemUserTb user = this.getUserByUsername(KitSecurityHelper.getCurrentUsername()); - String username = user.getUsername(); - if (StrUtil.isBlank(username)) { - throw new BadRequestException("异常用户数据, 请联系管理员处理"); - } - // 文件大小验证 - KitFileUtil.checkSize(fileUploadPathHelper.getAvatarMaxSize(), multipartFile.getSize()); - // 验证文件上传的格式 - String image = "gif jpg png jpeg"; - String fileType = KitFileUtil.getSuffix(multipartFile.getOriginalFilename()); - if (fileType != null && !image.contains(fileType)) { - throw new BadRequestException("文件格式错误!, 仅支持 " + image + " 格式"); - } - String oldPath = user.getAvatarPath(); - File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath()); - user.setAvatarPath(Objects.requireNonNull(file).getPath()); - user.setAvatarName(file.getName()); - systemUserMapper.insertOrUpdate(user); - if (StrUtil.isNotBlank(oldPath)) { - KitFileUtil.del(oldPath); - } - systemUserInfoDAO.deleteUserLoginInfoByUserName(username); - return new HashMap<>(1) {{ - put("avatar", file.getName()); - }}; + // 如果用户被禁用, 则清除用户登录信息 + if (!args.getEnabled()) { + systemUserOnlineInfoDAO.kickOutByUsername(args.getUsername()); } + user.setDeptId(args.getDept().getId()); + user.setUsername(args.getUsername()); + user.setEmail(args.getEmail()); + user.setEnabled(args.getEnabled()); + user.setPhone(args.getPhone()); + user.setNickName(args.getNickName()); + user.setGender(args.getGender()); + systemUserMapper.updateById(user); + // 清除用户登录缓存 + systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); + // 更新用户岗位 + systemUserJobService.batchDeleteUserJob(Collections.singleton(args.getId())); + systemUserJobService.batchInsertUserJob(args.getJobs(), args.getId()); + // 更新用户角色 + systemUserRoleService.batchDeleteUserRole(Collections.singleton(args.getId())); + systemUserRoleService.batchInsertUserRole(args.getRoles(), args.getId()); + } - /** - * 修改邮箱 - * - * @param username 用户名 - * @param args 参数 - * @param code 验证码 - */ - @Transactional(rollbackFor = Exception.class) - public void updateUserEmailByUsername(String username, SystemUserTb args, String code) throws Exception { - String password = - KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword()); - SystemUserTb user = this.getUserByUsername(username); - if (!passwordEncoder.matches(password, user.getPassword())) { - throw new BadRequestException("密码错误"); - } - systemEmailService.checkEmailCaptchaV1(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, args.getEmail(), code); - systemUserMapper.updateUserEmailByUsername(username, args.getEmail()); - systemUserInfoDAO.deleteUserLoginInfoByUserName(username); + /** + * 用户自助修改资料 + * + * @param args / + */ + @Transactional(rollbackFor = Exception.class) + public void updateUserCenterInfoById(SystemUserTb args) { + if (!args.getId().equals(KitSecurityHelper.getCurrentUserId())) { + throw new BadRequestException("不能修改他人资料"); } - - /** - * 查询全部 - * - * @param args 条件 - * @param page 分页参数 - * @return / - */ - public KitPageResult searchUserByArgs(SystemQueryUserArgs args, Page page) { - // 查询用户基本信息 - LambdaQueryWrapper wrapper = this.buildUserQueryWrapper(args); - IPage userPage = systemUserMapper.selectPage(page, wrapper); - List users = userPage.getRecords(); - // 转换为SystemUserVo并关联查询 - List userVos = - users.stream().map(m -> this.convertToUserVo(m, false)).collect(Collectors.toList()); - return KitPageUtil.toPage(userVos, userPage.getTotal()); + SystemUserTb user = systemUserMapper.selectById(args.getId()); + SystemUserTb user1 = this.getUserByPhone(args.getPhone()); + if (user1 != null && !user.getId().equals(user1.getId())) { + throw new BadRequestException("手机号已存在"); } + user.setNickName(args.getNickName()); + user.setPhone(args.getPhone()); + user.setGender(args.getGender()); + systemUserMapper.insertOrUpdate(user); + systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); + } - public long countUserByArgs(SystemQueryUserArgs args) { - LambdaQueryWrapper wrapper = this.buildUserQueryWrapper(args); - return systemUserMapper.selectCount(wrapper); + /** + * 删除用户 + * + * @param ids / + */ + @Transactional(rollbackFor = Exception.class) + public void deleteUserByIds(Set ids) { + Long currentUserId = KitSecurityHelper.getCurrentUserId(); + // 校验权限 + for (Long id : ids) { + Integer currentLevel = Collections.min( + systemUserRoleService.queryRoleVoByUsersId(currentUserId).stream().map(SystemRoleVo::getLevel) + .collect(Collectors.toList())); + Integer optLevel = Collections.min( + systemUserRoleService.queryRoleVoByUsersId(id).stream().map(SystemRoleVo::getLevel) + .collect(Collectors.toList())); + if (currentLevel > optLevel) { + throw new BadRequestException("角色权限不足, 不能删除:" + this.getUserById(id).getUsername()); + } } - - /** - * 根据ID查询 - * - * @param id ID - * @return / - */ - public SystemUserTb getUserById(long id) { - return systemUserMapper.selectById(id); + // 清理缓存 + List usernameList = systemUserMapper.selectByIds(ids).stream().map(SystemUserTb::getUsername).distinct() + .collect(Collectors.toList()); + for (String username : usernameList) { + systemUserInfoDAO.deleteUserLoginInfoByUserName(username); } + // 删除用户 + systemUserMapper.deleteByIds(ids); + // 删除用户岗位 + systemUserJobService.batchDeleteUserJob(ids); + // 删除用户角色 + systemUserRoleService.batchDeleteUserRole(ids); + } - public List queryUserMetadataOptions(KitPageArgs pageArgs) { - SystemQueryUserArgs args = pageArgs.getArgs(); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.select(SystemUserTb::getId, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone); - wrapper.and(c -> { - c.eq(SystemUserTb::getPhone, args.getBlurry()); - c.or(); - c.eq(SystemUserTb::getEmail, args.getBlurry()); - c.or(); - c.like(SystemUserTb::getUsername, args.getBlurry()); - c.or(); - c.like(SystemUserTb::getNickName, args.getBlurry()); + /** + * 修改密码 + * + * @param username 用户名 + * @param args 参数 + */ + @Transactional(rollbackFor = Exception.class) + public void updateUserPasswordByUsername(String username, SystemUpdateUserPasswordArgs args) throws Exception { + String oldPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getOldPass()); + String newPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getNewPass()); + SystemUserTb user = this.getUserByUsername(username); + if (!passwordEncoder.matches(oldPass, user.getPassword())) { + throw new BadRequestException("修改失败,旧密码错误"); + } + if (passwordEncoder.matches(newPass, user.getPassword())) { + throw new BadRequestException("新密码不能与旧密码相同"); + } + String encryptPassword = passwordEncoder.encode(newPass); + systemUserMapper.updateUserPasswordByUsername(username, encryptPassword); + systemUserInfoDAO.deleteUserLoginInfoByUserName(username); + } + + /** + * 重置密码 + * + * @param ids 用户id + */ + @Transactional(rollbackFor = Exception.class) + public void resetUserPasswordByIds(Set ids) { + String defaultPwd = passwordEncoder.encode("123456"); + List users = systemUserMapper.selectByIds(ids); + // 清除缓存 + for (SystemUserTb user : users) { + // 清除缓存 + systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); + // 强制退出 + systemUserOnlineInfoDAO.kickOutByUsername(user.getUsername()); + } + // 重置密码 + systemUserMapper.updateUserPasswordByUserIds(defaultPwd, ids); + } + + /** + * 修改头像 + * + * @param multipartFile 文件 + * @return / + */ + @Transactional(rollbackFor = Exception.class) + public Map updateUserAvatar(MultipartFile multipartFile) { + SystemUserTb user = this.getUserByUsername(KitSecurityHelper.getCurrentUsername()); + String username = user.getUsername(); + if (StrUtil.isBlank(username)) { + throw new BadRequestException("异常用户数据, 请联系管理员处理"); + } + // 文件大小验证 + KitFileUtil.checkSize(fileUploadPathHelper.getAvatarMaxSize(), multipartFile.getSize()); + // 验证文件上传的格式 + String image = "gif jpg png jpeg"; + String fileType = KitFileUtil.getSuffix(multipartFile.getOriginalFilename()); + if (fileType != null && !image.contains(fileType)) { + throw new BadRequestException("文件格式错误!, 仅支持 " + image + " 格式"); + } + String oldPath = user.getAvatarPath(); + File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath()); + user.setAvatarPath(Objects.requireNonNull(file).getPath()); + user.setAvatarName(file.getName()); + systemUserMapper.insertOrUpdate(user); + if (StrUtil.isNotBlank(oldPath)) { + KitFileUtil.del(oldPath); + } + systemUserInfoDAO.deleteUserLoginInfoByUserName(username); + return new HashMap<>(1) {{ + put("avatar", file.getName()); + }}; + } + + /** + * 修改邮箱 + * + * @param username 用户名 + * @param args 参数 + * @param code 验证码 + */ + @Transactional(rollbackFor = Exception.class) + public void updateUserEmailByUsername(String username, SystemUserTb args, String code) throws Exception { + String password = + KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword()); + SystemUserTb user = this.getUserByUsername(username); + if (!passwordEncoder.matches(password, user.getPassword())) { + throw new BadRequestException("密码错误"); + } + systemEmailService.checkEmailCaptchaV1(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, args.getEmail(), code); + systemUserMapper.updateUserEmailByUsername(username, args.getEmail()); + systemUserInfoDAO.deleteUserLoginInfoByUserName(username); + } + + /** + * 查询全部 + * + * @param args 条件 + * @param page 分页参数 + * @return / + */ + public KitPageResult searchUserByArgs(SystemQueryUserArgs args, Page page) { + // 查询用户基本信息 + LambdaQueryWrapper wrapper = this.buildUserQueryWrapper(args); + IPage userPage = systemUserMapper.selectPage(page, wrapper); + List users = userPage.getRecords(); + // 转换为SystemUserVo并关联查询 + List userVos = + users.stream().map(m -> this.convertToUserVo(m, false)).collect(Collectors.toList()); + return KitPageUtil.toPage(userVos, userPage.getTotal()); + } + + public long countUserByArgs(SystemQueryUserArgs args) { + LambdaQueryWrapper wrapper = this.buildUserQueryWrapper(args); + return systemUserMapper.selectCount(wrapper); + } + + /** + * 根据ID查询 + * + * @param id ID + * @return / + */ + public SystemUserTb getUserById(long id) { + return systemUserMapper.selectById(id); + } + + public List queryUserMetadataOptions(KitPageArgs pageArgs) { + SystemQueryUserArgs args = pageArgs.getArgs(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.select(SystemUserTb::getId, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone); + wrapper.and(c -> { + c.eq(SystemUserTb::getPhone, args.getBlurry()); + c.or(); + c.eq(SystemUserTb::getEmail, args.getBlurry()); + c.or(); + c.like(SystemUserTb::getUsername, args.getBlurry()); + c.or(); + c.like(SystemUserTb::getNickName, args.getBlurry()); + }); + return systemUserMapper.selectPage(new Page<>(pageArgs.getPage(), 50), wrapper).getRecords().stream().map(m -> { + Map ext = new HashMap<>(1); + ext.put("id", m.getId()); + ext.put("deptId", m.getDeptId()); + ext.put("email", m.getEmail()); + ext.put("phone", m.getPhone()); + return KitSelectOptionVo.builder().label(m.getNickName()).value(String.valueOf(m.getId())).ext(ext).build(); + }).collect(Collectors.toList()); + } + + /** + * 构建用户查询条件 + * + * @param args 查询条件 + * @return / + */ + private LambdaQueryWrapper buildUserQueryWrapper(SystemQueryUserArgs args) { + KitValidUtil.notNull(args); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (args.getId() != null) { + wrapper.eq(SystemUserTb::getId, args.getId()); + } + if (args.getEnabled() != null) { + wrapper.eq(SystemUserTb::getEnabled, args.getEnabled()); + } + if (CollUtil.isNotEmpty(args.getDeptIds())) { + wrapper.in(SystemUserTb::getDeptId, args.getDeptIds()); + } + if (StrUtil.isNotBlank(args.getBlurry())) { + wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or() + .like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry())); + } + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + } + wrapper.orderByDesc(SystemUserTb::getCreateTime); + return wrapper; + } + + /** + * 转换为SystemUserVo并关联查询部门、角色、岗位信息 + * + * @param user 用户基本信息 + * @param includePassword 是否包含用户密码 + * @return 包含关联信息的SystemUserVo + */ + private SystemUserVo convertToUserVo(SystemUserTb user, boolean includePassword) { + if (user == null) { + return null; + } + if (!includePassword) { + // 查询用户时,清空密码 + user.setPassword(null); + } + SystemUserVo userVo = KitBeanUtil.copyToClass(user, SystemUserVo.class); + // 查询关联的部门信息 + if (user.getDeptId() != null) { + userVo.setDept(systemDeptService.getDeptVoById(user.getDeptId())); + } + // 查询关联的岗位信息 + userVo.setJobs(systemUserJobService.listUserJobByUserId(user.getId())); + // 查询关联的角色信息 + userVo.setRoles(systemUserRoleService.listUserRoleByUserId(user.getId())); + return userVo; + } + + public SystemUserTb getUserByUsername(String username) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getUsername, username); + wrapper.eq(SystemUserTb::getEnabled, 1); + return systemUserMapper.selectOne(wrapper); + } + + public SystemUserVo getUserVoWithPasswordByUsername(String username) { + return this.convertToUserVo(this.getUserByUsername(username), true); + } + + public SystemUserVo getUserVoByUsername(String username) { + return this.convertToUserVo(this.getUserByUsername(username), false); + } + + public SystemUserTb getUserByEmail(String email) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getEmail, email); + wrapper.eq(SystemUserTb::getEnabled, 1); + return systemUserMapper.selectOne(wrapper); + } + + public SystemUserTb getUserByPhone(String phone) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getPhone, phone); + wrapper.eq(SystemUserTb::getEnabled, 1); + return systemUserMapper.selectOne(wrapper); + } + + public KitPageResult aggregationSearchUserByArgs(Page page, SystemQueryUserArgs args, + String currentUsername) { + if (!ObjectUtils.isEmpty(args.getDeptId())) { + args.getDeptIds().add(args.getDeptId()); + // 先查找是否存在子节点 + List data = systemDeptService.listDeptByPid(args.getDeptId()); + Map> deptPidMap = + systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); + // 然后把子节点的ID都加入到集合中 + args.getDeptIds().addAll(systemDeptService.queryChildDeptIdByDeptIds(data, deptPidMap)); + } + // 数据权限 + List dataScopes = systemDataService.queryDeptIdByArgs(this.getUserVoByUsername(currentUsername)); + // args.getDeptIds() 不为空并且数据权限不为空则取交集 + if (!CollUtil.isEmpty(args.getDeptIds()) && !CollUtil.isEmpty(dataScopes)) { + // 取交集 + args.getDeptIds().retainAll(dataScopes); + if (!CollUtil.isEmpty(args.getDeptIds())) { + return this.searchUserByArgs(args, page); + } + } else { + // 否则取并集 + args.getDeptIds().addAll(dataScopes); + return this.searchUserByArgs(args, page); + } + return KitPageUtil.emptyData(); + } + + public void exportUserXlsx(HttpServletResponse response, SystemQueryUserArgs args) { + long totalCount = this.countUserByArgs(args); + KitExcelExporter.exportByPage(response, "用户数据", SystemUserExportRowVo.class, totalCount, + (long pageNum, long pageSize) -> { + KitPageResult pageResult = this.searchUserByArgs(args, new Page<>(pageNum, pageSize)); + List rowVos = new ArrayList<>(); + for (SystemUserVo dataObject : pageResult.getContent()) { + SystemUserExportRowVo rowVo = new SystemUserExportRowVo(); + rowVo.setUsername(dataObject.getUsername()); + rowVo.setRoles( + dataObject.getRoles().stream().map(SystemRoleTb::getName).collect(Collectors.joining(","))); + rowVo.setDept(dataObject.getDept().getName()); + rowVo.setJobs( + dataObject.getJobs().stream().map(SystemJobTb::getName).collect(Collectors.joining(","))); + rowVo.setEmail(dataObject.getEmail()); + rowVo.setStatus(dataObject.getEnabled() ? SystemZhConst.ENABLE_STR : SystemZhConst.DISABLE_STR); + rowVo.setMobile(dataObject.getPhone()); + rowVo.setUpdatePwdTime(dataObject.getPwdResetTime()); + rowVo.setCreateTime(dataObject.getCreateTime()); + rowVos.add(rowVo); + } + return rowVos; }); - return systemUserMapper.selectPage(new Page<>(pageArgs.getPage(), 50), wrapper).getRecords().stream().map(m -> { - Map ext = new HashMap<>(1); - ext.put("id", m.getId()); - ext.put("deptId", m.getDeptId()); - ext.put("email", m.getEmail()); - ext.put("phone", m.getPhone()); - return KitSelectOptionVo.builder().label(m.getNickName()).value(String.valueOf(m.getId())).ext(ext).build(); - }).collect(Collectors.toList()); - } - - /** - * 构建用户查询条件 - * - * @param args 查询条件 - * @return / - */ - private LambdaQueryWrapper buildUserQueryWrapper(SystemQueryUserArgs args) { - KitValidUtil.notNull(args); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - if (args.getId() != null) { - wrapper.eq(SystemUserTb::getId, args.getId()); - } - if (args.getEnabled() != null) { - wrapper.eq(SystemUserTb::getEnabled, args.getEnabled()); - } - if (CollUtil.isNotEmpty(args.getDeptIds())) { - wrapper.in(SystemUserTb::getDeptId, args.getDeptIds()); - } - if (StrUtil.isNotBlank(args.getBlurry())) { - wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or() - .like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry())); - } - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); - } - wrapper.orderByDesc(SystemUserTb::getCreateTime); - return wrapper; - } - - /** - * 转换为SystemUserVo并关联查询部门、角色、岗位信息 - * - * @param user 用户基本信息 - * @param includePassword 是否包含用户密码 - * @return 包含关联信息的SystemUserVo - */ - private SystemUserVo convertToUserVo(SystemUserTb user, boolean includePassword) { - if (user == null) { - return null; - } - if (!includePassword) { - // 查询用户时,清空密码 - user.setPassword(null); - } - SystemUserVo userVo = KitBeanUtil.copyToClass(user, SystemUserVo.class); - // 查询关联的部门信息 - if (user.getDeptId() != null) { - userVo.setDept(systemDeptService.getDeptVoById(user.getDeptId())); - } - // 查询关联的岗位信息 - userVo.setJobs(systemUserJobService.listUserJobByUserId(user.getId())); - // 查询关联的角色信息 - userVo.setRoles(systemUserRoleService.listUserRoleByUserId(user.getId())); - return userVo; - } - - public SystemUserTb getUserByUsername(String username) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemUserTb::getUsername, username); - wrapper.eq(SystemUserTb::getEnabled, 1); - return systemUserMapper.selectOne(wrapper); - } - - public SystemUserVo getUserVoWithPasswordByUsername(String username) { - return this.convertToUserVo(this.getUserByUsername(username), true); - } - - public SystemUserVo getUserVoByUsername(String username) { - return this.convertToUserVo(this.getUserByUsername(username), false); - } - - public SystemUserTb getUserByEmail(String email) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemUserTb::getEmail, email); - wrapper.eq(SystemUserTb::getEnabled, 1); - return systemUserMapper.selectOne(wrapper); - } - - public SystemUserTb getUserByPhone(String phone) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemUserTb::getPhone, phone); - wrapper.eq(SystemUserTb::getEnabled, 1); - return systemUserMapper.selectOne(wrapper); - } - - public KitPageResult aggregationSearchUserByArgs(Page page, SystemQueryUserArgs args, - String currentUsername) { - if (!ObjectUtils.isEmpty(args.getDeptId())) { - args.getDeptIds().add(args.getDeptId()); - // 先查找是否存在子节点 - List data = systemDeptService.listDeptByPid(args.getDeptId()); - Map> deptPidMap = - systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); - // 然后把子节点的ID都加入到集合中 - args.getDeptIds().addAll(systemDeptService.queryChildDeptIdByDeptIds(data, deptPidMap)); - } - // 数据权限 - List dataScopes = systemDataService.queryDeptIdByArgs(this.getUserVoByUsername(currentUsername)); - // args.getDeptIds() 不为空并且数据权限不为空则取交集 - if (!CollUtil.isEmpty(args.getDeptIds()) && !CollUtil.isEmpty(dataScopes)) { - // 取交集 - args.getDeptIds().retainAll(dataScopes); - if (!CollUtil.isEmpty(args.getDeptIds())) { - return this.searchUserByArgs(args, page); - } - } else { - // 否则取并集 - args.getDeptIds().addAll(dataScopes); - return this.searchUserByArgs(args, page); - } - return KitPageUtil.emptyData(); - } - - public void exportUserXlsx(HttpServletResponse response, SystemQueryUserArgs args) { - long totalCount = this.countUserByArgs(args); - KitExcelExporter.exportByPage(response, "用户数据", SystemUserExportRowVo.class, totalCount, - (long pageNum, long pageSize) -> { - KitPageResult pageResult = this.searchUserByArgs(args, new Page<>(pageNum, pageSize)); - List rowVos = new ArrayList<>(); - for (SystemUserVo dataObject : pageResult.getContent()) { - SystemUserExportRowVo rowVo = new SystemUserExportRowVo(); - rowVo.setUsername(dataObject.getUsername()); - rowVo.setRoles( - dataObject.getRoles().stream().map(SystemRoleTb::getName).collect(Collectors.joining(","))); - rowVo.setDept(dataObject.getDept().getName()); - rowVo.setJobs( - dataObject.getJobs().stream().map(SystemJobTb::getName).collect(Collectors.joining(","))); - rowVo.setEmail(dataObject.getEmail()); - rowVo.setStatus(dataObject.getEnabled() ? SystemZhConst.ENABLE_STR : SystemZhConst.DISABLE_STR); - rowVo.setMobile(dataObject.getPhone()); - rowVo.setUpdatePwdTime(dataObject.getPwdResetTime()); - rowVo.setCreateTime(dataObject.getCreateTime()); - rowVos.add(rowVo); - } - return rowVos; - }); - } + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemMinioStorageServiceImpl.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemMinioStorageServiceImpl.java index 5ac7dc3b..cf4d3e20 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemMinioStorageServiceImpl.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemMinioStorageServiceImpl.java @@ -39,13 +39,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import java.io.File; +import java.util.List; +import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletResponse; -import java.io.File; -import java.util.List; /** *

@@ -59,110 +59,110 @@ import java.util.List; public class SystemMinioStorageServiceImpl extends ServiceImpl implements SystemOssStorageService { - @Autowired - private MinioRepository minioRepository; - @Autowired - private AppProperties properties; - @Autowired - private KitFileLocalUploadHelper fileLocalUploadHelper; - @Autowired - private SystemOssStorageMapper systemOssStorageMapper; + @Autowired + private MinioRepository minioRepository; + @Autowired + private AppProperties properties; + @Autowired + private KitFileLocalUploadHelper fileLocalUploadHelper; + @Autowired + private SystemOssStorageMapper systemOssStorageMapper; - @Override - public KitPageResult searchOssStorage(SystemQueryStorageArgs args, - Page page) { - IPage ossStorageTbs = this.selectOssStorageByArgs(args, page); - for (SystemOssStorageVo storageVo : ossStorageTbs.getRecords()) { - storageVo.setFileSizeDesc(KitFileUtil.getSize(storageVo.getFileSize())); - } - return KitPageUtil.toPage(ossStorageTbs); + @Override + public KitPageResult searchOssStorage(SystemQueryStorageArgs args, + Page page) { + IPage ossStorageTbs = this.selectOssStorageByArgs(args, page); + for (SystemOssStorageVo storageVo : ossStorageTbs.getRecords()) { + storageVo.setFileSizeDesc(KitFileUtil.getSize(storageVo.getFileSize())); } + return KitPageUtil.toPage(ossStorageTbs); + } - private IPage selectOssStorageByArgs(SystemQueryStorageArgs args, - Page page) { - KitValidUtil.notNull(args); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.and(StrUtil.isNotBlank(args.getBlurry()), - c -> c.like(SystemOssStorageTb::getFileName, args.getBlurry()).or() - .like(SystemOssStorageTb::getFilePrefix, args.getBlurry()).or() - .like(SystemOssStorageTb::getFileMime, args.getBlurry()).or() - .like(SystemOssStorageTb::getFileMd5, args.getBlurry())); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemOssStorageTb::getUpdateTime, args.getCreateTime().get(0), - args.getCreateTime().get(1)); - } - wrapper.orderByAsc(SystemOssStorageTb::getId); - return systemOssStorageMapper.selectPage(page, wrapper) - .convert(i -> KitBeanUtil.copyToClass(i, SystemOssStorageVo.class)); + private IPage selectOssStorageByArgs(SystemQueryStorageArgs args, + Page page) { + KitValidUtil.notNull(args); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.and(StrUtil.isNotBlank(args.getBlurry()), + c -> c.like(SystemOssStorageTb::getFileName, args.getBlurry()).or() + .like(SystemOssStorageTb::getFilePrefix, args.getBlurry()).or() + .like(SystemOssStorageTb::getFileMime, args.getBlurry()).or() + .like(SystemOssStorageTb::getFileMd5, args.getBlurry())); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemOssStorageTb::getUpdateTime, args.getCreateTime().get(0), + args.getCreateTime().get(1)); } + wrapper.orderByAsc(SystemOssStorageTb::getId); + return systemOssStorageMapper.selectPage(page, wrapper) + .convert(i -> KitBeanUtil.copyToClass(i, SystemOssStorageVo.class)); + } - @Override - public List queryOssStorage(SystemQueryStorageArgs args) { - // 防止刷数据 - Page page = new Page<>(1, 500); - return searchOssStorage(args, page).getContent(); - } + @Override + public List queryOssStorage(SystemQueryStorageArgs args) { + // 防止刷数据 + Page page = new Page<>(1, 500); + return searchOssStorage(args, page).getContent(); + } - @Override - @Transactional(rollbackFor = Exception.class) - public String uploadFile(MultipartFile file) { - String originalFilename = file.getOriginalFilename(); - if (StrUtil.isBlank(originalFilename)) { - throw new BadRequestException("文件名不能为空"); - } - StorageOSSModel ossConfig = properties.getOss(); - long fileSize = file.getSize(); - String contentType = file.getContentType(); - KitFileUtil.checkSize(ossConfig.getMaxSize(), fileSize); - // 按天分组 - String nowDateStr = KitDateUtil.getNowDateStr(); - // 上传到本地临时目录 - File tempFile = KitFileUtil.upload(file, fileLocalUploadHelper.getPath() + nowDateStr + File.separator); - if (tempFile == null) { - throw new BadRequestException("上传失败"); - } - // 校验文件md5, 看是否已存在云端(不确定, 可能云端已经删除, 但是正常来说云端是不允许私自删除的, 所以这里忽略云端不存在的情况) - String md5 = KitFileUtil.getMd5(tempFile); - SystemOssStorageTb systemOssStorageTb = this.getOssStorageByMd5(md5); - if (systemOssStorageTb != null) { - // 重新生成7天链接 - return minioRepository.generatePreviewUrl(systemOssStorageTb.getObjectName()); - } - // 上传到OSS - SystemOssStorageTb storageTb = minioRepository.upload(tempFile, originalFilename, fileSize, contentType, md5); - if (storageTb == null) { - throw new BadRequestException("文件上传失败"); - } - save(storageTb); - return minioRepository.generatePreviewUrl(storageTb.getObjectName()); + @Override + @Transactional(rollbackFor = Exception.class) + public String uploadFile(MultipartFile file) { + String originalFilename = file.getOriginalFilename(); + if (StrUtil.isBlank(originalFilename)) { + throw new BadRequestException("文件名不能为空"); } + StorageOSSModel ossConfig = properties.getOss(); + long fileSize = file.getSize(); + String contentType = file.getContentType(); + KitFileUtil.checkSize(ossConfig.getMaxSize(), fileSize); + // 按天分组 + String nowDateStr = KitDateUtil.getNowDateStr(); + // 上传到本地临时目录 + File tempFile = KitFileUtil.upload(file, fileLocalUploadHelper.getPath() + nowDateStr + File.separator); + if (tempFile == null) { + throw new BadRequestException("上传失败"); + } + // 校验文件md5, 看是否已存在云端(不确定, 可能云端已经删除, 但是正常来说云端是不允许私自删除的, 所以这里忽略云端不存在的情况) + String md5 = KitFileUtil.getMd5(tempFile); + SystemOssStorageTb systemOssStorageTb = this.getOssStorageByMd5(md5); + if (systemOssStorageTb != null) { + // 重新生成7天链接 + return minioRepository.generatePreviewUrl(systemOssStorageTb.getObjectName()); + } + // 上传到OSS + SystemOssStorageTb storageTb = minioRepository.upload(tempFile, originalFilename, fileSize, contentType, md5); + if (storageTb == null) { + throw new BadRequestException("文件上传失败"); + } + save(storageTb); + return minioRepository.generatePreviewUrl(storageTb.getObjectName()); + } - /** - * 多选删除 - * - * @param ids / - */ - @Override - @Transactional(rollbackFor = Exception.class) - public void deleteFileByIds(Long[] ids) { - for (Long id : ids) { - SystemOssStorageTb storage = getById(id); - minioRepository.removeBucketFile(storage.getObjectName()); - removeById(storage); - } + /** + * 多选删除 + * + * @param ids / + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteFileByIds(Long[] ids) { + for (Long id : ids) { + SystemOssStorageTb storage = getById(id); + minioRepository.removeBucketFile(storage.getObjectName()); + removeById(storage); } + } - @Override - public void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) { - List systemOssStorageVos = this.queryOssStorage(args); - // KitXlsxExportUtil.exportFile(response, "OSS文件上传记录数据", systemOssStorageVos, SystemOssStorageExportRowVo.class, - // (dataObject) -> CollUtil.newArrayList(KitBeanUtil.copyProperties(dataObject, SystemOssStorageExportRowVo.class))); - List rowVos = - KitBeanUtil.copyToList(systemOssStorageVos, SystemOssStorageExportRowVo.class); - KitExcelExporter.exportSimple(response, "OSS文件上传记录数据", SystemOssStorageExportRowVo.class, rowVos); - } + @Override + public void exportOssStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) { + List systemOssStorageVos = this.queryOssStorage(args); + // KitXlsxExportUtil.exportFile(response, "OSS文件上传记录数据", systemOssStorageVos, SystemOssStorageExportRowVo.class, + // (dataObject) -> CollUtil.newArrayList(KitBeanUtil.copyProperties(dataObject, SystemOssStorageExportRowVo.class))); + List rowVos = + KitBeanUtil.copyToList(systemOssStorageVos, SystemOssStorageExportRowVo.class); + KitExcelExporter.exportSimple(response, "OSS文件上传记录数据", SystemOssStorageExportRowVo.class, rowVos); + } - private SystemOssStorageTb getOssStorageByMd5(String md5) { - return lambdaQuery().eq(SystemOssStorageTb::getFileMd5, md5).one(); - } + private SystemOssStorageTb getOssStorageByMd5(String md5) { + return lambdaQuery().eq(SystemOssStorageTb::getFileMd5, md5).one(); + } } From 7425577126da3aa5ecafa4afd299c6051183ab40 Mon Sep 17 00:00:00 2001 From: Odboy Date: Wed, 14 Jan 2026 22:29:12 +0800 Subject: [PATCH 03/14] =?UTF-8?q?refactor(system):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E6=A8=A1=E5=9D=97=E4=B8=AD=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=92=8C=E8=A7=92=E8=89=B2=E7=9B=B8=E5=85=B3=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/system/user/center.vue | 2 +- .../SystemDictDetailController.java | 7 - .../system/dal/mysql/SystemRoleMapper.java | 3 + .../system/dal/mysql/SystemUserMapper.java | 4 + .../dal/mysql/SystemUserRoleMapper.java | 2 + .../service/SystemDictDetailService.java | 10 - .../system/service/SystemJobService.java | 4 - .../system/service/SystemMenuService.java | 2 +- .../system/service/SystemRoleService.java | 4 +- .../system/service/SystemUserRoleService.java | 19 +- .../system/service/SystemUserService.java | 186 ++++++++++-------- .../resources/mapper/SystemRoleMapper.xml | 13 ++ .../resources/mapper/SystemUserMapper.xml | 15 ++ .../resources/mapper/SystemUserRoleMapper.xml | 6 + 14 files changed, 155 insertions(+), 122 deletions(-) create mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleMapper.xml create mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserMapper.xml diff --git a/cutejava-front/src/views/system/user/center.vue b/cutejava-front/src/views/system/user/center.vue index 417f2d6e..bf16d427 100644 --- a/cutejava-front/src/views/system/user/center.vue +++ b/cutejava-front/src/views/system/user/center.vue @@ -104,7 +104,7 @@ diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictDetailController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictDetailController.java index fa6ff6cc..508881f8 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictDetailController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictDetailController.java @@ -54,13 +54,6 @@ public class SystemDictDetailController { return ResponseEntity.ok(systemDictDetailService.searchDictDetail(pageArgs.getArgs(), page)); } - @ApiOperation("查询多个字典详情") - @GetMapping(value = "/getDictDetailMaps") - public ResponseEntity>> getDictDetailMaps(@RequestParam String dictName) { - Map> dictMap = systemDictDetailService.getDictDetailMap(dictName); - return ResponseEntity.ok(dictMap); - } - @OperationLog @ApiOperation("新增字典详情") @PostMapping(value = "/saveDictDetail") diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleMapper.java index ffe20a7d..25a566ed 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleMapper.java @@ -17,7 +17,9 @@ package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemRoleTb; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import java.util.List; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 角色 Mapper @@ -27,4 +29,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface SystemRoleMapper extends BaseMapper { + List listRoleLevelByRoleIds(@Param("roleIds") List roleIds); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserMapper.java index 097da24b..f1ada109 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserMapper.java @@ -18,8 +18,10 @@ package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemUserTb; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import java.util.List; import java.util.Set; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 用户 Mapper @@ -49,4 +51,6 @@ public interface SystemUserMapper extends BaseMapper { wrapper.set(SystemUserTb::getPassword, password); update(null, wrapper); } + + List listUsernameByIds(@Param("userIds") Set userIds); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserRoleMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserRoleMapper.java index f7deb075..149b07a4 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserRoleMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserRoleMapper.java @@ -18,6 +18,7 @@ package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemRoleTb; import cn.odboy.system.dal.dataobject.SystemUserRoleTb; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import java.util.List; import java.util.Set; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -26,4 +27,5 @@ import org.apache.ibatis.annotations.Param; public interface SystemUserRoleMapper extends BaseMapper { Set listUserRoleByUserId(@Param("userId") Long userId); + List listUserRoleLevelByUserId(@Param("userId") Long userId); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java index 718cc3eb..04cc2c0f 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java @@ -32,7 +32,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -140,13 +139,4 @@ public class SystemDictDetailService { } return detailVos; } - - public Map> getDictDetailMap(String dictName) { - String[] names = dictName.split("[,, ]"); - Map> dictMap = new HashMap<>(16); - for (String name : names) { - dictMap.put(name, this.listDictDetailByName(name)); - } - return dictMap; - } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java index 8a1a2169..3944c3de 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java @@ -150,8 +150,4 @@ public class SystemJobService { } KitExcelExporter.exportSimple(response, "岗位数据", SystemJobExportRowVo.class, rowVos); } - - public List listByIds(Set jobIds) { - return systemJobMapper.selectByIds(jobIds); - } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java index 28bbee2d..3e0ab847 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java @@ -218,7 +218,7 @@ public class SystemMenuService { * @return / */ public List listMenuByUserId(Long currentUserId) { - List roles = systemUserRoleService.queryRoleVoByUsersId(currentUserId); + List roles = systemUserRoleService.listRoleVoByUsersId(currentUserId); Set roleIds = roles.stream().map(SystemRoleVo::getId).collect(Collectors.toSet()); return new ArrayList<>(systemRoleMenuService.queryMenuByRoleIds(roleIds)); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java index 1b6fe46d..25bce45f 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java @@ -222,7 +222,7 @@ public class SystemRoleService { permissions.add("admin"); return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); } - List roles = systemUserRoleService.queryRoleVoByUsersId(user.getId()); + List roles = systemUserRoleService.listRoleVoByUsersId(user.getId()); permissions = roles.stream().flatMap(role -> role.getMenus().stream()).map(SystemMenuVo::getPermission) .filter(StrUtil::isNotBlank).collect(Collectors.toSet()); return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); @@ -268,7 +268,7 @@ public class SystemRoleService { * @return / */ private int checkRoleLevels(Integer level) { - List levels = systemUserRoleService.queryRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream() + List levels = systemUserRoleService.listRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream() .map(SystemRoleVo::getLevel).collect(Collectors.toList()); int min = Collections.min(levels); if (level != null) { diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java index b4291d5f..9408f1f8 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java @@ -99,7 +99,7 @@ public class SystemUserRoleService { * @param userId 用户ID * @return / */ - public List queryRoleVoByUsersId(Long userId) { + public List listRoleVoByUsersId(Long userId) { Set roles = this.listUserRoleByUserId(userId); return roles.stream().map(this::convertToRoleVo).collect(Collectors.toList()); } @@ -115,16 +115,12 @@ public class SystemUserRoleService { // 最小权限 return Integer.MAX_VALUE; } - List roleIds = - roles.stream().map(SystemRoleTb::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); + List roleIds = roles.stream().map(SystemRoleTb::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); if (CollUtil.isEmpty(roleIds)) { // 最小权限 return Integer.MAX_VALUE; } - List roleLevels = systemRoleMapper.selectList( - new LambdaQueryWrapper().select(SystemRoleTb::getLevel).isNotNull(SystemRoleTb::getLevel) - .in(SystemRoleTb::getId, roleIds)).stream().map(SystemRoleTb::getLevel).distinct() - .collect(Collectors.toList()); + List roleLevels = systemRoleMapper.listRoleLevelByRoleIds(roleIds); if (CollUtil.isEmpty(roleLevels)) { // 最小权限 return Integer.MAX_VALUE; @@ -138,9 +134,8 @@ public class SystemUserRoleService { * @param args / */ public void checkLevel(SystemUserVo args) { - Integer currentLevel = Collections.min( - this.queryRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream().map(SystemRoleVo::getLevel) - .collect(Collectors.toList())); + List roleLevels = systemUserRoleMapper.listUserRoleLevelByUserId(KitSecurityHelper.getCurrentUserId()); + Integer currentLevel = Collections.min(roleLevels); Integer optLevel = this.getDeptLevelByRoles(args.getRoles()); if (currentLevel > optLevel) { throw new BadRequestException("角色权限不足"); @@ -159,4 +154,8 @@ public class SystemUserRoleService { public Set listUserRoleByUserId(Long userId) { return systemUserRoleMapper.listUserRoleByUserId(userId); } + + public List listUserRoleLevelByUserId(Long userId) { + return systemUserRoleMapper.listUserRoleLevelByUserId(userId); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java index 6d16f3ec..f69b450a 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java @@ -32,7 +32,6 @@ import cn.odboy.system.dal.dataobject.SystemUserTb; import cn.odboy.system.dal.model.export.SystemUserExportRowVo; import cn.odboy.system.dal.model.request.SystemQueryUserArgs; import cn.odboy.system.dal.model.request.SystemUpdateUserPasswordArgs; -import cn.odboy.system.dal.model.response.SystemRoleVo; import cn.odboy.system.dal.model.response.SystemUserVo; import cn.odboy.system.dal.mysql.SystemUserMapper; import cn.odboy.system.dal.redis.SystemUserInfoDAO; @@ -42,7 +41,6 @@ import cn.odboy.util.KitBeanUtil; import cn.odboy.util.KitFileUtil; import cn.odboy.util.KitPageUtil; import cn.odboy.util.KitRsaEncryptUtil; -import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -91,7 +89,7 @@ public class SystemUserService { private PasswordEncoder passwordEncoder; /** - * 新增用户 + * 新增用户 -> TestPassed * * @param args / */ @@ -102,13 +100,13 @@ public class SystemUserService { // 默认密码 123456 record.setPassword(passwordEncoder.encode("123456")); record.setDeptId(args.getDept().getId()); - if (this.getUserByUsername(record.getUsername()) != null) { + if (this.existUserWithUsername(record.getUsername())) { throw new BadRequestException("用户名已存在"); } - if (this.getUserByEmail(record.getEmail()) != null) { + if (this.existUserWithEmail(record.getEmail())) { throw new BadRequestException("邮箱已存在"); } - if (this.getUserByPhone(record.getPhone()) != null) { + if (this.existUserWithPhone(record.getPhone())) { throw new BadRequestException("手机号已存在"); } // 保存用户 @@ -119,8 +117,29 @@ public class SystemUserService { systemUserRoleService.batchInsertUserRole(args.getRoles(), record.getId()); } + private boolean existUserWithPhone(String phone) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getPhone, phone); + wrapper.eq(SystemUserTb::getEnabled, 1); + return systemUserMapper.exists(wrapper); + } + + private boolean existUserWithEmail(String email) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getEmail, email); + wrapper.eq(SystemUserTb::getEnabled, 1); + return systemUserMapper.exists(wrapper); + } + + private boolean existUserWithUsername(String username) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getUsername, username); + wrapper.eq(SystemUserTb::getEnabled, 1); + return systemUserMapper.exists(wrapper); + } + /** - * 编辑用户 + * 编辑用户 -> TestPassed * * @param args / */ @@ -128,16 +147,13 @@ public class SystemUserService { public void updateUserById(SystemUserVo args) { systemUserRoleService.checkLevel(args); SystemUserTb user = systemUserMapper.selectById(args.getId()); - SystemUserTb user1 = this.getUserByUsername(args.getUsername()); - SystemUserTb user2 = this.getUserByEmail(args.getEmail()); - SystemUserTb user3 = this.getUserByPhone(args.getPhone()); - if (user1 != null && !user.getId().equals(user1.getId())) { + if (this.existUserWithUsernameNeSelf(args.getUsername(), user.getId())) { throw new BadRequestException("用户名已存在"); } - if (user2 != null && !user.getId().equals(user2.getId())) { + if (this.existUserWithEmailNeSelf(args.getEmail(), user.getId())) { throw new BadRequestException("邮箱已存在"); } - if (user3 != null && !user.getId().equals(user3.getId())) { + if (this.existUserWithPhoneNeSelf(args.getPhone(), user.getId())) { throw new BadRequestException("手机号已存在"); } // 如果用户被禁用, 则清除用户登录信息 @@ -162,8 +178,29 @@ public class SystemUserService { systemUserRoleService.batchInsertUserRole(args.getRoles(), args.getId()); } + private boolean existUserWithPhoneNeSelf(String phone, Long currentUserId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getPhone, phone); + wrapper.ne(SystemUserTb::getId, currentUserId); + return systemUserMapper.exists(wrapper); + } + + private boolean existUserWithEmailNeSelf(String email, Long currentUserId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getEmail, email); + wrapper.ne(SystemUserTb::getId, currentUserId); + return systemUserMapper.exists(wrapper); + } + + private boolean existUserWithUsernameNeSelf(String username, Long currentUserId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getUsername, username); + wrapper.ne(SystemUserTb::getId, currentUserId); + return systemUserMapper.exists(wrapper); + } + /** - * 用户自助修改资料 + * 用户自助修改资料 -> TestPassed * * @param args / */ @@ -173,19 +210,18 @@ public class SystemUserService { throw new BadRequestException("不能修改他人资料"); } SystemUserTb user = systemUserMapper.selectById(args.getId()); - SystemUserTb user1 = this.getUserByPhone(args.getPhone()); - if (user1 != null && !user.getId().equals(user1.getId())) { + if (this.existUserWithPhoneNeSelf(args.getPhone(), user.getId())) { throw new BadRequestException("手机号已存在"); } user.setNickName(args.getNickName()); user.setPhone(args.getPhone()); user.setGender(args.getGender()); - systemUserMapper.insertOrUpdate(user); + systemUserMapper.updateById(user); systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); } /** - * 删除用户 + * 删除用户 -> TestPassed * * @param ids / */ @@ -194,19 +230,15 @@ public class SystemUserService { Long currentUserId = KitSecurityHelper.getCurrentUserId(); // 校验权限 for (Long id : ids) { - Integer currentLevel = Collections.min( - systemUserRoleService.queryRoleVoByUsersId(currentUserId).stream().map(SystemRoleVo::getLevel) - .collect(Collectors.toList())); - Integer optLevel = Collections.min( - systemUserRoleService.queryRoleVoByUsersId(id).stream().map(SystemRoleVo::getLevel) - .collect(Collectors.toList())); + Integer currentLevel = Collections.min(systemUserRoleService.listUserRoleLevelByUserId(currentUserId)); + Integer optLevel = Collections.min(systemUserRoleService.listUserRoleLevelByUserId(id)); if (currentLevel > optLevel) { - throw new BadRequestException("角色权限不足, 不能删除:" + this.getUserById(id).getUsername()); + SystemUserTb systemUserTb = systemUserMapper.selectById(id); + throw new BadRequestException("角色权限不足, 不能删除:" + systemUserTb.getUsername()); } } // 清理缓存 - List usernameList = systemUserMapper.selectByIds(ids).stream().map(SystemUserTb::getUsername).distinct() - .collect(Collectors.toList()); + List usernameList = systemUserMapper.listUsernameByIds(ids); for (String username : usernameList) { systemUserInfoDAO.deleteUserLoginInfoByUserName(username); } @@ -219,7 +251,7 @@ public class SystemUserService { } /** - * 修改密码 + * 修改密码 -> TestPassed * * @param username 用户名 * @param args 参数 @@ -241,27 +273,27 @@ public class SystemUserService { } /** - * 重置密码 + * 重置密码 -> TestPassed * * @param ids 用户id */ @Transactional(rollbackFor = Exception.class) public void resetUserPasswordByIds(Set ids) { String defaultPwd = passwordEncoder.encode("123456"); - List users = systemUserMapper.selectByIds(ids); + List users = systemUserMapper.listUsernameByIds(ids); // 清除缓存 - for (SystemUserTb user : users) { + for (String username : users) { // 清除缓存 - systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); + systemUserInfoDAO.deleteUserLoginInfoByUserName(username); // 强制退出 - systemUserOnlineInfoDAO.kickOutByUsername(user.getUsername()); + systemUserOnlineInfoDAO.kickOutByUsername(username); } // 重置密码 systemUserMapper.updateUserPasswordByUserIds(defaultPwd, ids); } /** - * 修改头像 + * 修改头像 -> TestPassed * * @param multipartFile 文件 * @return / @@ -271,7 +303,7 @@ public class SystemUserService { SystemUserTb user = this.getUserByUsername(KitSecurityHelper.getCurrentUsername()); String username = user.getUsername(); if (StrUtil.isBlank(username)) { - throw new BadRequestException("异常用户数据, 请联系管理员处理"); + throw new BadRequestException("异常用户数据, 请联系管理员处理!"); } // 文件大小验证 KitFileUtil.checkSize(fileUploadPathHelper.getAvatarMaxSize(), multipartFile.getSize()); @@ -279,13 +311,13 @@ public class SystemUserService { String image = "gif jpg png jpeg"; String fileType = KitFileUtil.getSuffix(multipartFile.getOriginalFilename()); if (fileType != null && !image.contains(fileType)) { - throw new BadRequestException("文件格式错误!, 仅支持 " + image + " 格式"); + throw new BadRequestException("文件格式错误, 仅支持 " + image + " 格式!"); } String oldPath = user.getAvatarPath(); File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath()); user.setAvatarPath(Objects.requireNonNull(file).getPath()); user.setAvatarName(file.getName()); - systemUserMapper.insertOrUpdate(user); + systemUserMapper.updateById(user); if (StrUtil.isNotBlank(oldPath)) { KitFileUtil.del(oldPath); } @@ -296,7 +328,7 @@ public class SystemUserService { } /** - * 修改邮箱 + * 修改邮箱 -> TestPassed * * @param username 用户名 * @param args 参数 @@ -304,8 +336,7 @@ public class SystemUserService { */ @Transactional(rollbackFor = Exception.class) public void updateUserEmailByUsername(String username, SystemUserTb args, String code) throws Exception { - String password = - KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword()); + String password = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword()); SystemUserTb user = this.getUserByUsername(username); if (!passwordEncoder.matches(password, user.getPassword())) { throw new BadRequestException("密码错误"); @@ -316,7 +347,7 @@ public class SystemUserService { } /** - * 查询全部 + * 查询全部 -> TestPassed * * @param args 条件 * @param page 分页参数 @@ -328,8 +359,7 @@ public class SystemUserService { IPage userPage = systemUserMapper.selectPage(page, wrapper); List users = userPage.getRecords(); // 转换为SystemUserVo并关联查询 - List userVos = - users.stream().map(m -> this.convertToUserVo(m, false)).collect(Collectors.toList()); + List userVos = users.stream().map(m -> this.convertToUserVo(m, false)).collect(Collectors.toList()); return KitPageUtil.toPage(userVos, userPage.getTotal()); } @@ -338,16 +368,6 @@ public class SystemUserService { return systemUserMapper.selectCount(wrapper); } - /** - * 根据ID查询 - * - * @param id ID - * @return / - */ - public SystemUserTb getUserById(long id) { - return systemUserMapper.selectById(id); - } - public List queryUserMetadataOptions(KitPageArgs pageArgs) { SystemQueryUserArgs args = pageArgs.getArgs(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); @@ -372,36 +392,37 @@ public class SystemUserService { } /** - * 构建用户查询条件 + * 构建用户查询条件 -> TestPassed * * @param args 查询条件 * @return / */ private LambdaQueryWrapper buildUserQueryWrapper(SystemQueryUserArgs args) { - KitValidUtil.notNull(args); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - if (args.getId() != null) { - wrapper.eq(SystemUserTb::getId, args.getId()); - } - if (args.getEnabled() != null) { - wrapper.eq(SystemUserTb::getEnabled, args.getEnabled()); - } - if (CollUtil.isNotEmpty(args.getDeptIds())) { - wrapper.in(SystemUserTb::getDeptId, args.getDeptIds()); - } - if (StrUtil.isNotBlank(args.getBlurry())) { - wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or() - .like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry())); - } - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + if (args != null) { + if (args.getId() != null) { + wrapper.eq(SystemUserTb::getId, args.getId()); + } + if (args.getEnabled() != null) { + wrapper.eq(SystemUserTb::getEnabled, args.getEnabled()); + } + if (CollUtil.isNotEmpty(args.getDeptIds())) { + wrapper.in(SystemUserTb::getDeptId, args.getDeptIds()); + } + if (StrUtil.isNotBlank(args.getBlurry())) { + wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or() + .like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry())); + } + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + } } wrapper.orderByDesc(SystemUserTb::getCreateTime); return wrapper; } /** - * 转换为SystemUserVo并关联查询部门、角色、岗位信息 + * 转换为SystemUserVo并关联查询部门、角色、岗位信息 -> TestPassed * * @param user 用户基本信息 * @param includePassword 是否包含用户密码 @@ -442,28 +463,16 @@ public class SystemUserService { return this.convertToUserVo(this.getUserByUsername(username), false); } - public SystemUserTb getUserByEmail(String email) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemUserTb::getEmail, email); - wrapper.eq(SystemUserTb::getEnabled, 1); - return systemUserMapper.selectOne(wrapper); - } - - public SystemUserTb getUserByPhone(String phone) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemUserTb::getPhone, phone); - wrapper.eq(SystemUserTb::getEnabled, 1); - return systemUserMapper.selectOne(wrapper); - } - + /** + * 聚合查询 -> TestPassed + */ public KitPageResult aggregationSearchUserByArgs(Page page, SystemQueryUserArgs args, String currentUsername) { if (!ObjectUtils.isEmpty(args.getDeptId())) { args.getDeptIds().add(args.getDeptId()); // 先查找是否存在子节点 List data = systemDeptService.listDeptByPid(args.getDeptId()); - Map> deptPidMap = - systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); + Map> deptPidMap = systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); // 然后把子节点的ID都加入到集合中 args.getDeptIds().addAll(systemDeptService.queryChildDeptIdByDeptIds(data, deptPidMap)); } @@ -484,6 +493,9 @@ public class SystemUserService { return KitPageUtil.emptyData(); } + /** + * 导出 -> TestPassed + */ public void exportUserXlsx(HttpServletResponse response, SystemQueryUserArgs args) { long totalCount = this.countUserByArgs(args); KitExcelExporter.exportByPage(response, "用户数据", SystemUserExportRowVo.class, totalCount, diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleMapper.xml new file mode 100644 index 00000000..f2b977fc --- /dev/null +++ b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleMapper.xml @@ -0,0 +1,13 @@ + + + + + diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserMapper.xml new file mode 100644 index 00000000..87c7aad5 --- /dev/null +++ b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserMapper.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserRoleMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserRoleMapper.xml index 177b248e..c2ab58c6 100644 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserRoleMapper.xml +++ b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserRoleMapper.xml @@ -7,4 +7,10 @@ LEFT JOIN system_users_roles t2 ON t1.role_id = t2.role_id WHERE t2.user_id = #{userId} + From 252ae3765f80e4191b5d58f36de2bc50ebd44a2e Mon Sep 17 00:00:00 2001 From: Odboy Date: Wed, 14 Jan 2026 22:35:33 +0800 Subject: [PATCH 04/14] =?UTF-8?q?docs(SystemUserRoleService):=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=94=A8=E6=88=B7=E8=A7=92=E8=89=B2=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E7=B1=BB=E7=9A=84Java=E6=96=87=E6=A1=A3=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为批量绑定用户角色方法添加测试通过标记注释 - 为批量解绑用户角色方法添加测试通过标记注释 - 为根据用户ID查询方法添加测试通过标记注释 - 为权限检查方法添加测试通过标记注释 - 为根据用户id列举角色方法添加完整JavaDoc注释 - 为根据用户id列举角色级别方法添加完整JavaDoc注释 --- .../system/service/SystemUserRoleService.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java index 9408f1f8..d882fbea 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java @@ -50,6 +50,9 @@ public class SystemUserRoleService { @Autowired private SystemRoleDeptService systemRoleDeptService; + /** + * 批量绑定用户角色 -> TestPassed + */ @Transactional(rollbackFor = Exception.class) public void batchInsertUserRole(Set roles, Long userId) { if (CollUtil.isNotEmpty(roles)) { @@ -64,6 +67,9 @@ public class SystemUserRoleService { } } + /** + * 批量解绑用户角色 -> TestPassed + */ @Transactional(rollbackFor = Exception.class) public void batchDeleteUserRole(Set userIds) { if (CollUtil.isNotEmpty(userIds)) { @@ -94,7 +100,7 @@ public class SystemUserRoleService { } /** - * 根据用户ID查询 + * 根据用户ID查询 -> TestPassed * * @param userId 用户ID * @return / @@ -129,7 +135,7 @@ public class SystemUserRoleService { } /** - * 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误 + * 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误 -> TestPassed * * @param args / */ @@ -151,10 +157,22 @@ public class SystemUserRoleService { return systemUserRoleMapper.selectCount(wrapper); } + /** + * 根据用户id列举角色 -> TestPassed + * + * @param userId / + * @return / + */ public Set listUserRoleByUserId(Long userId) { return systemUserRoleMapper.listUserRoleByUserId(userId); } + /** + * 根据用户id列举角色级别 -> TestPassed + * + * @param userId / + * @return / + */ public List listUserRoleLevelByUserId(Long userId) { return systemUserRoleMapper.listUserRoleLevelByUserId(userId); } From bba40ae048d5c4fdca290f8e218b41160578f02e Mon Sep 17 00:00:00 2001 From: Odboy Date: Wed, 14 Jan 2026 22:37:02 +0800 Subject: [PATCH 05/14] =?UTF-8?q?feat(SystemUserJobService):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=94=A8=E6=88=B7=E5=B2=97=E4=BD=8D=E7=BB=91=E5=AE=9A?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=B5=8B=E8=AF=95=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/SystemUserJobService.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java index ed5c0bab..b7966eef 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java @@ -33,6 +33,9 @@ public class SystemUserJobService { @Autowired private SystemUserJobMapper systemUserJobMapper; + /** + * 批量绑定用户岗位 -> TestPassed + */ @Transactional(rollbackFor = Exception.class) public void batchInsertUserJob(Set jobs, Long userId) { if (CollUtil.isNotEmpty(jobs)) { @@ -47,6 +50,9 @@ public class SystemUserJobService { } } + /** + * 批量解绑用户岗位 -> TestPassed + */ @Transactional(rollbackFor = Exception.class) public void batchDeleteUserJob(Set userIds) { if (CollUtil.isNotEmpty(userIds)) { @@ -57,9 +63,9 @@ public class SystemUserJobService { } /** - * 根据岗位ID统计用户数量 + * 根据岗位ID统计用户数量 -> TestPassed * - * @param jobIds 岗位ID集合 + * @param jobIds / * @return / */ public Long countUserByJobIds(Set jobIds) { @@ -71,6 +77,12 @@ public class SystemUserJobService { return systemUserJobMapper.selectCount(wrapper); } + /** + * 根据用户id列举岗位 -> TestPassed + * + * @param userId / + * @return / + */ public Set listUserJobByUserId(Long userId) { return systemUserJobMapper.listUserJobByUserId(userId); } From 4fc51fa0b5d7400960d9741e7c3f5b1e593c0a47 Mon Sep 17 00:00:00 2001 From: Odboy Date: Wed, 14 Jan 2026 22:45:14 +0800 Subject: [PATCH 06/14] =?UTF-8?q?refactor(system):=20=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E6=96=B9=E6=B3=95=E5=91=BD=E5=90=8D=E8=A7=84?= =?UTF-8?q?=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/odboy/system/service/SystemAuthService.java | 4 ++-- .../odboy/system/service/SystemCaptchaService.java | 4 ++-- .../cn/odboy/system/service/SystemDataService.java | 6 +++--- .../cn/odboy/system/service/SystemDeptService.java | 12 ++++++------ .../system/service/SystemDictDetailService.java | 2 +- .../cn/odboy/system/service/SystemJobService.java | 9 ++++++++- .../cn/odboy/system/service/SystemMenuService.java | 8 ++++---- .../odboy/system/service/SystemMonitorService.java | 10 +++++----- .../odboy/system/service/SystemQuartzJobService.java | 4 ++-- .../cn/odboy/system/service/SystemRoleService.java | 2 +- .../odboy/system/service/SystemUserDeptService.java | 3 +++ 11 files changed, 37 insertions(+), 27 deletions(-) diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java index 6f93ddc4..cab708b6 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java @@ -52,7 +52,7 @@ public class SystemAuthService { KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginArgs.getPassword()); // 校验验证码 systemCaptchaService.validate(loginArgs.getUuid(), loginArgs.getCode()); - // 获取用户信息 + // 查询用户信息 SystemUserJwtVo jwtUser = userDetailsService.loadUserByUsername(loginArgs.getUsername()); // 验证用户密码 if (!passwordEncoder.matches(password, jwtUser.getPassword())) { @@ -83,7 +83,7 @@ public class SystemAuthService { } /** - * 获取当前登录人信息 -> TestPassed + * 查询当前登录人信息 -> TestPassed */ public SystemUserJwtVo getCurrentUserInfo() { SystemUserJwtVo jwtUser = (SystemUserJwtVo) KitSecurityHelper.getCurrentUser(); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java index 6f1e9613..09a05676 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java @@ -26,10 +26,10 @@ public class SystemCaptchaService { private AppProperties properties; /** - * 获取登录验证码 -> TestPassed + * 查询登录验证码 -> TestPassed */ public SystemCaptchaVo getLoginCaptcha() { - // 获取运算的结果 + // 查询运算的结果 Captcha captcha = properties.getLogin().getCaptchaSetting().getCaptcha(); String uuid = SystemCacheKey.CAPTCHA_LOGIN + IdUtil.simpleUUID(); //当验证码类型为 arithmetic时且长度 >= 2 时, captcha.text()的结果有几率为浮点型 diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java index beb91250..7be790ab 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java @@ -45,7 +45,7 @@ public class SystemDataService { private SystemRoleDeptService systemRoleDeptService; /** - * 获取数据权限 -> TestPassed + * 查询数据权限 -> TestPassed * * @param user / * @return / @@ -54,7 +54,7 @@ public class SystemDataService { List deptIds = new ArrayList<>(); // 查询用户角色 Set roleList = systemUserRoleService.listUserRoleByUserId(user.getId()); - // 获取对应的部门ID + // 查询对应的部门ID for (SystemRoleTb role : roleList) { SystemDataScopeEnum dataScopeEnum = SystemDataScopeEnum.find(role.getDataScope()); switch (Objects.requireNonNull(dataScopeEnum)) { @@ -75,7 +75,7 @@ public class SystemDataService { } /** - * 获取自定义的数据权限 -> TestPassed + * 查询自定义的数据权限 -> TestPassed * * @param deptIds 部门ID(外部数据) * @param roleId 角色ID diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java index 37221ce4..c7b71484 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java @@ -100,7 +100,7 @@ public class SystemDeptService { } /** - * 根据部门id获取部门信息 -> TestPassed + * 根据部门id查询部门信息 -> TestPassed * * @param id 部门id * @return / @@ -116,7 +116,7 @@ public class SystemDeptService { */ @Transactional(rollbackFor = Exception.class) public void deleteDeptByIds(Set ids) { - // 获取部门, 和其所有子部门 + // 查询部门, 和其所有子部门 Set depts = this.traverseDeptByIdWithPids(ids); // 验证是否被角色或用户关联 this.verifyBindRelationByIds(depts); @@ -229,7 +229,7 @@ public class SystemDeptService { } /** - * 获取部门下所有关联的部门 + * 查询部门下所有关联的部门 * * @param deptTbList / * @param depts / @@ -263,7 +263,7 @@ public class SystemDeptService { } /** - * 根据ID获取同级与上级数据 + * 根据ID查询同级与上级数据 * * @param dept / * @param deptList / @@ -388,7 +388,7 @@ public class SystemDeptService { } private List buildDeptSelectOptions(List depts) { - // 获取所有部门并按父子关系组织 + // 查询所有部门并按父子关系组织 Map deptMap = depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); List options = new ArrayList<>(); @@ -433,7 +433,7 @@ public class SystemDeptService { public List listDeptSelectProDataSource() { List depts = this.listEnabledDepts(); - // 获取所有部门并按父子关系组织 + // 查询所有部门并按父子关系组织 Map deptMap = depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); List options = new ArrayList<>(); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java index 04cc2c0f..49571b5c 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java @@ -116,7 +116,7 @@ public class SystemDictDetailService { } /** - * 根据字典名称获取字典详情 -> TestPassed + * 根据字典名称查询字典详情 -> TestPassed * * @param name 字典名称 * @return / diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java index 3944c3de..23dab240 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java @@ -121,13 +121,17 @@ public class SystemJobService { } } + /** + * 根据岗位名称查询启用的岗位信息 -> TestPassed + */ public SystemJobTb getJobByName(String name) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SystemJobTb::getName, name); + wrapper.eq(SystemJobTb::getEnabled, 1); return systemJobMapper.selectOne(wrapper); } - public void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper wrapper) { + private void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper wrapper) { if (args != null) { wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName()); wrapper.eq(args.getEnabled() != null, SystemJobTb::getEnabled, args.getEnabled()); @@ -138,6 +142,9 @@ public class SystemJobService { wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId); } + /** + * 导出岗位数据 -> TestPassed + */ public void exportJobXlsx(HttpServletResponse response, SystemQueryJobArgs args) { List systemJobTbs = this.queryJobByArgs(args); List rowVos = new ArrayList<>(); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java index 3e0ab847..38dd0e40 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java @@ -212,7 +212,7 @@ public class SystemMenuService { } /** - * 根据当前用户获取菜单 + * 根据当前用户查询菜单 * * @param currentUserId / * @return / @@ -224,7 +224,7 @@ public class SystemMenuService { } /** - * 获取所有子节点, 包含自身ID + * 查询所有子节点, 包含自身ID * * @param menuList / * @param menuSet / @@ -261,7 +261,7 @@ public class SystemMenuService { } /** - * 根据ID获取同级与上级数据 + * 根据ID查询同级与上级数据 * * @param menu / * @param menus / @@ -355,7 +355,7 @@ public class SystemMenuService { } /** - * 获取 MenuResponse + * 查询 MenuResponse * * @param menu / * @param menuVo / diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java index 94901e13..f5bffc9e 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java @@ -75,7 +75,7 @@ public class SystemMonitorService { } /** - * 获取磁盘信息 + * 查询磁盘信息 * * @return / */ @@ -109,7 +109,7 @@ public class SystemMonitorService { } /** - * 获取交换区信息 + * 查询交换区信息 * * @param memory / * @return / @@ -131,7 +131,7 @@ public class SystemMonitorService { } /** - * 获取内存信息 + * 查询内存信息 * * @param memory / * @return / @@ -147,7 +147,7 @@ public class SystemMonitorService { } /** - * 获取Cpu相关信息 + * 查询Cpu相关信息 * * @param processor / * @return / @@ -194,7 +194,7 @@ public class SystemMonitorService { } /** - * 获取系统相关信息,系统、运行天数、系统IP + * 查询系统相关信息,系统、运行天数、系统IP * * @param os / * @return / diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java index a15314bb..89b1cf6d 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java @@ -182,10 +182,10 @@ public class SystemQuartzJobService { quartzJob.setUuid(uuid); // 执行任务 startQuartzJob(quartzJob); - // 获取执行状态, 如果执行失败则停止后面的子任务执行 + // 查询执行状态, 如果执行失败则停止后面的子任务执行 Boolean result = redisHelper.get(uuid, Boolean.class); while (result == null) { - // 休眠5秒, 再次获取子任务执行情况 + // 休眠5秒, 再次查询子任务执行情况 Thread.sleep(5000); result = redisHelper.get(uuid, Boolean.class); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java index 25bce45f..b6e23088 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java @@ -210,7 +210,7 @@ public class SystemRoleService { } /** - * 获取用户权限信息 -> TestPassed + * 查询用户权限信息 -> TestPassed * * @param user 用户信息 * @return 权限信息 diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java index e051ae16..76580ef4 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java @@ -13,6 +13,9 @@ public class SystemUserDeptService { @Autowired private SystemUserMapper systemUserMapper; + /** + * 根据部门id统计用户数量 -> TestPassed + */ public long countUserByDeptIds(Set deptIds) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(SystemUserTb::getDeptId, deptIds); From 6c79c5a0d0acd397311f9f428473c2342e4c0c11 Mon Sep 17 00:00:00 2001 From: Odboy Date: Wed, 14 Jan 2026 22:49:31 +0800 Subject: [PATCH 07/14] =?UTF-8?q?refactor(job):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E8=81=8C=E4=BD=8D=E6=9C=8D=E5=8A=A1=E4=B8=AD=E7=9A=84=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=A3=80=E6=9F=A5=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/service/SystemJobService.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java index 23dab240..e509f2ae 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java @@ -52,8 +52,7 @@ public class SystemJobService { */ @Transactional(rollbackFor = Exception.class) public void saveJob(SystemCreateJobArgs args) { - SystemJobTb job = this.getJobByName(args.getName()); - if (job != null) { + if (this.existJobWithName(args.getName())) { throw new BadRequestException("职位名称已存在"); } SystemJobTb systemJobTb = KitBeanUtil.copyToClass(args, SystemJobTb.class); @@ -68,8 +67,7 @@ public class SystemJobService { @Transactional(rollbackFor = Exception.class) public void updateJobById(SystemJobTb args) { SystemJobTb job = systemJobMapper.selectById(args.getId()); - SystemJobTb old = this.getJobByName(args.getName()); - if (old != null && !old.getId().equals(args.getId())) { + if (this.existJobWithNameNeSelf(args.getName(), job.getId())) { throw new BadRequestException("职位名称已存在"); } args.setId(job.getId()); @@ -122,13 +120,22 @@ public class SystemJobService { } /** - * 根据岗位名称查询启用的岗位信息 -> TestPassed + * 根据岗位名称查询岗位是否存在 -> TestPassed */ - public SystemJobTb getJobByName(String name) { + private boolean existJobWithName(String name) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SystemJobTb::getName, name); - wrapper.eq(SystemJobTb::getEnabled, 1); - return systemJobMapper.selectOne(wrapper); + return systemJobMapper.exists(wrapper); + } + + /** + * 根据岗位名称和岗位id查询岗位是否存在 -> TestPassed + */ + private boolean existJobWithNameNeSelf(String name, Long currentJobId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemJobTb::getName, name); + wrapper.ne(SystemJobTb::getId, currentJobId); + return systemJobMapper.exists(wrapper); } private void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper wrapper) { From 40f4657d6f52bc05b9b44997ac89334a8555d082 Mon Sep 17 00:00:00 2001 From: Odboy Date: Wed, 14 Jan 2026 22:53:10 +0800 Subject: [PATCH 08/14] =?UTF-8?q?refactor(storage):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E5=AD=98=E5=82=A8=E6=9C=8D=E5=8A=A1=E7=9A=84?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/cn/odboy/util/KitFileUtil.java | 18 ++++++++++--- .../main/java/cn/odboy/util/KitFileUtil.java | 12 +++++++++ .../SystemLocalStorageController.java | 2 +- .../dal/dataobject/SystemLocalStorageTb.java | 7 +---- .../service/SystemLocalStorageService.java | 26 +++++++++++++------ 5 files changed, 47 insertions(+), 18 deletions(-) diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/util/KitFileUtil.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/util/KitFileUtil.java index 3b029042..911ad3f4 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/util/KitFileUtil.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/util/KitFileUtil.java @@ -23,11 +23,15 @@ import static cn.odboy.constant.SystemConst.SYMBOL_SUBTRACT; import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.poi.excel.BigExcelWriter; import cn.hutool.poi.excel.ExcelUtil; import cn.odboy.constant.FileTypeEnum; import cn.odboy.constant.SystemConst; import cn.odboy.framework.exception.BadRequestException; +import jakarta.servlet.ServletOutputStream; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -42,9 +46,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; -import jakarta.servlet.ServletOutputStream; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; import lombok.experimental.UtilityClass; import lombok.extern.slf4j.Slf4j; import org.apache.poi.util.IOUtils; @@ -386,4 +387,15 @@ public final class KitFileUtil extends FileUtil { public static String getMd5(File file) { return getMd5(getByte(file)); } + + /** + * 获取文件名前缀 + * + * @param originalFilename 原始文件名 + * @param firstName 首选文件名,如果不为空,则返回 + * @return / + */ + public static String getPrefix(String originalFilename, String firstName) { + return StrUtil.isBlank(firstName) ? getPrefix(originalFilename) : firstName; + } } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitFileUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitFileUtil.java index a2a8df19..597f7db7 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitFileUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitFileUtil.java @@ -23,6 +23,7 @@ import static cn.odboy.constant.SystemConst.SYMBOL_SUBTRACT; import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.poi.excel.BigExcelWriter; import cn.hutool.poi.excel.ExcelUtil; import cn.odboy.constant.FileTypeEnum; @@ -386,4 +387,15 @@ public final class KitFileUtil extends FileUtil { public static String getMd5(File file) { return getMd5(getByte(file)); } + + /** + * 获取文件名前缀 + * + * @param originalFilename 原始文件名 + * @param firstName 首选文件名,如果不为空,则返回 + * @return / + */ + public static String getPrefix(String originalFilename, String firstName) { + return StrUtil.isBlank(firstName) ? getPrefix(originalFilename) : firstName; + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemLocalStorageController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemLocalStorageController.java index 4ebaa181..32cdd47d 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemLocalStorageController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemLocalStorageController.java @@ -74,7 +74,7 @@ public class SystemLocalStorageController { @ApiOperation("上传图片") @PostMapping("/uploadPicture") public ResponseEntity uploadPicture(@RequestParam MultipartFile file) { - SystemLocalStorageTb localStorage = localStorageService.uploadPictureV1(file); + SystemLocalStorageTb localStorage = localStorageService.uploadPicture(file); return ResponseEntity.ok(localStorage); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemLocalStorageTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemLocalStorageTb.java index bded4f86..92739b24 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemLocalStorageTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemLocalStorageTb.java @@ -16,7 +16,6 @@ package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitBaseUserTimeTb; -import cn.odboy.util.KitBeanUtil; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -46,8 +45,4 @@ public class SystemLocalStorageTb extends KitBaseUserTimeTb { private String size; @ApiModelProperty(value = "日期分组") private String dateGroup; - - public void copy(SystemLocalStorageTb source) { - KitBeanUtil.copyToTarget(source, this); - } -} \ No newline at end of file +} diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java index a9938b07..437bcc68 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java @@ -22,7 +22,6 @@ import cn.hutool.core.io.IORuntimeException; import cn.hutool.core.util.StrUtil; import cn.odboy.base.KitPageResult; import cn.odboy.constant.FileTypeEnum; -import cn.odboy.framework.context.KitSpringBeanHolder; import cn.odboy.framework.exception.BadRequestException; import cn.odboy.framework.properties.AppProperties; import cn.odboy.framework.server.core.KitFileLocalUploadHelper; @@ -40,11 +39,14 @@ import java.io.File; import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +@Slf4j @Service public class SystemLocalStorageService { @@ -54,6 +56,9 @@ public class SystemLocalStorageService { private KitFileLocalUploadHelper fileUploadPathHelper; @Autowired private AppProperties properties; + @Lazy + @Autowired + private SystemLocalStorageService localStorageService; /** * 上传 -> TestPassed @@ -75,8 +80,7 @@ public class SystemLocalStorageService { } try { String formatSize = KitFileUtil.getSize(size); - String prefixName = - StrUtil.isBlank(name) ? KitFileUtil.getPrefix(multipartFile.getOriginalFilename()) : name; + String prefixName = KitFileUtil.getPrefix(multipartFile.getOriginalFilename(), name); SystemLocalStorageTb localStorage = new SystemLocalStorageTb(); localStorage.setRealName(file.getName()); localStorage.setName(prefixName); @@ -88,6 +92,7 @@ public class SystemLocalStorageService { systemLocalStorageMapper.insert(localStorage); return localStorage; } catch (Exception e) { + log.error("上传文件失败", e); KitFileUtil.del(file); throw e; } @@ -100,9 +105,7 @@ public class SystemLocalStorageService { */ @Transactional(rollbackFor = Exception.class) public void updateLocalStorageById(SystemLocalStorageTb args) { - SystemLocalStorageTb localStorage = systemLocalStorageMapper.selectById(args.getId()); - localStorage.copy(args); - systemLocalStorageMapper.insertOrUpdate(localStorage); + systemLocalStorageMapper.updateById(args); } /** @@ -159,15 +162,22 @@ public class SystemLocalStorageService { return systemLocalStorageMapper.selectList(wrapper); } - public SystemLocalStorageTb uploadPictureV1(MultipartFile file) { + /** + * 上传图片 + */ + @Transactional(rollbackFor = Exception.class) + public SystemLocalStorageTb uploadPicture(MultipartFile file) { // 判断文件是否为图片 String suffix = KitFileUtil.getSuffix(file.getOriginalFilename()); if (!FileTypeEnum.IMAGE.getCode().equals(KitFileUtil.getFileType(suffix))) { throw new BadRequestException("只能上传图片"); } - return KitSpringBeanHolder.getBean(SystemLocalStorageService.class).uploadFile(null, file); + return localStorageService.uploadFile(null, file); } + /** + * 导出文件上传记录 + */ public void exportLocalStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) { List systemLocalStorageTbs = this.queryLocalStorageByArgs(args); List rowVos = From bb664df62f5a8af9a0a97b0630ecfce17faaa187 Mon Sep 17 00:00:00 2001 From: Odboy Date: Wed, 14 Jan 2026 23:15:17 +0800 Subject: [PATCH 09/14] =?UTF-8?q?refactor(quartz):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E7=9B=B8=E5=85=B3=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=92=8C=E6=8E=A7=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SystemDeptController.java | 2 +- .../controller/SystemDictController.java | 2 +- .../SystemDictDetailController.java | 11 - .../controller/SystemJobController.java | 2 +- .../SystemLocalStorageController.java | 2 +- .../controller/SystemMenuController.java | 2 +- .../controller/SystemOnlineController.java | 2 +- .../controller/SystemQuartzJobController.java | 13 +- .../controller/SystemRoleController.java | 2 +- .../controller/SystemUserController.java | 2 +- .../system/dal/dataobject/SystemDeptTb.java | 2 +- .../system/dal/dataobject/SystemJobTb.java | 2 +- .../dal/dataobject/SystemLocalStorageTb.java | 7 +- .../system/dal/dataobject/SystemMenuTb.java | 2 +- .../system/dal/dataobject/SystemRoleTb.java | 2 +- .../system/dal/dataobject/SystemUserTb.java | 4 +- .../model/request/SystemCreateRoleArgs.java | 2 +- .../model/request/SystemSendEmailArgs.java | 2 +- .../model/response/SystemSimpleUserVo.java | 2 +- .../dal/mysql/SystemQuartzJobMapper.java | 5 - .../system/dal/mysql/SystemRoleMapper.java | 3 + .../system/dal/mysql/SystemUserMapper.java | 4 + .../dal/mysql/SystemUserRoleMapper.java | 2 + .../dal/redis/SystemUserOnlineInfoDAO.java | 4 +- .../framework/quartz/ActiveJobRegister.java | 7 +- .../system/framework/quartz/QuartzManage.java | 36 ++-- .../system/service/SystemAuthService.java | 4 +- .../system/service/SystemCaptchaService.java | 7 +- .../system/service/SystemDataService.java | 9 +- .../system/service/SystemDeptService.java | 14 +- .../service/SystemDictDetailService.java | 12 +- .../system/service/SystemDictService.java | 2 +- .../system/service/SystemJobService.java | 34 ++-- .../service/SystemLocalStorageService.java | 34 +++- .../system/service/SystemMenuService.java | 12 +- .../system/service/SystemMonitorService.java | 10 +- .../service/SystemOperationLogService.java | 2 +- .../service/SystemOssStorageService.java | 2 +- .../service/SystemQuartzJobService.java | 84 ++++---- .../system/service/SystemRoleDeptService.java | 3 - .../system/service/SystemRoleService.java | 30 ++- .../system/service/SystemUserDeptService.java | 3 + .../system/service/SystemUserJobService.java | 16 +- .../system/service/SystemUserRoleService.java | 43 ++-- .../system/service/SystemUserService.java | 188 ++++++++++-------- .../impl/SystemMinioStorageServiceImpl.java | 2 +- .../src/main/resources/logback.xml | 78 ++++---- .../controller/SystemQuartzJobController.java | 11 +- .../dal/mysql/SystemQuartzJobMapper.java | 5 - .../framework/quartz/ActiveJobRegister.java | 7 +- .../system/framework/quartz/QuartzManage.java | 34 ++-- .../service/SystemLocalStorageService.java | 10 +- .../system/service/SystemMonitorService.java | 10 +- .../service/SystemOperationLogService.java | 2 +- .../service/SystemQuartzJobService.java | 78 ++++---- 55 files changed, 468 insertions(+), 404 deletions(-) diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDeptController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDeptController.java index 266ca03a..b6b009a0 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDeptController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDeptController.java @@ -26,9 +26,9 @@ import cn.odboy.system.service.SystemDeptService; import cn.odboy.util.KitPageUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import jakarta.servlet.http.HttpServletResponse; import java.util.List; import java.util.Set; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictController.java index 1bd4485e..e3d3e9ae 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictController.java @@ -25,9 +25,9 @@ import cn.odboy.system.service.SystemDictService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import jakarta.servlet.http.HttpServletResponse; import java.util.List; import java.util.Set; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictDetailController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictDetailController.java index 0b7cd08f..2434da94 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictDetailController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictDetailController.java @@ -26,17 +26,13 @@ import cn.odboy.system.service.SystemDictDetailService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import java.util.List; -import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; 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.RequestParam; import org.springframework.web.bind.annotation.RestController; @RestController @@ -54,13 +50,6 @@ public class SystemDictDetailController { return ResponseEntity.ok(systemDictDetailService.searchDictDetail(pageArgs.getArgs(), page)); } - @ApiOperation("查询多个字典详情") - @GetMapping(value = "/getDictDetailMaps") - public ResponseEntity>> getDictDetailMaps(@RequestParam String dictName) { - Map> dictMap = systemDictDetailService.getDictDetailMap(dictName); - return ResponseEntity.ok(dictMap); - } - @OperationLog @ApiOperation("新增字典详情") @PostMapping(value = "/saveDictDetail") diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemJobController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemJobController.java index 2147717f..0ab929cf 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemJobController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemJobController.java @@ -25,8 +25,8 @@ import cn.odboy.system.service.SystemJobService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import jakarta.servlet.http.HttpServletResponse; import java.util.Set; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemLocalStorageController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemLocalStorageController.java index 938b7d18..a0a5246e 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemLocalStorageController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemLocalStorageController.java @@ -74,7 +74,7 @@ public class SystemLocalStorageController { @ApiOperation("上传图片") @PostMapping("/uploadPicture") public ResponseEntity uploadPicture(@RequestParam MultipartFile file) { - SystemLocalStorageTb localStorage = localStorageService.uploadPictureV1(file); + SystemLocalStorageTb localStorage = localStorageService.uploadPicture(file); return ResponseEntity.ok(localStorage); } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMenuController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMenuController.java index dcbcae27..992eebd3 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMenuController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMenuController.java @@ -27,9 +27,9 @@ import cn.odboy.system.service.SystemMenuService; import cn.odboy.util.KitPageUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import jakarta.servlet.http.HttpServletResponse; import java.util.List; import java.util.Set; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOnlineController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOnlineController.java index 5a0f5d91..2ccc1927 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOnlineController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOnlineController.java @@ -24,8 +24,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import jakarta.servlet.http.HttpServletResponse; import java.util.Set; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemQuartzJobController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemQuartzJobController.java index d366d25b..f0d4c69a 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemQuartzJobController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemQuartzJobController.java @@ -24,11 +24,12 @@ import cn.odboy.system.dal.model.request.SystemUpdateQuartzJobArgs; import cn.odboy.system.dal.model.response.SystemQuartzJobVo; import cn.odboy.system.framework.operalog.OperationLog; import cn.odboy.system.service.SystemQuartzJobService; +import cn.odboy.util.KitBeanUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import jakarta.servlet.http.HttpServletResponse; import java.util.Set; +import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -86,7 +87,7 @@ public class SystemQuartzJobController { @ApiOperation("新增定时任务") @PostMapping(value = "/createQuartzJob") @PreAuthorize("@el.check('quartzJob:add')") - public ResponseEntity createQuartzJob(@Validated @RequestBody SystemQuartzJobVo args) { + public ResponseEntity createQuartzJob(@Validated @RequestBody SystemQuartzJobTb args) { systemQuartzJobService.createJob(args); return ResponseEntity.ok(null); } @@ -106,7 +107,9 @@ public class SystemQuartzJobController { @PostMapping(value = "/switchQuartzJobStatus/{id}") @PreAuthorize("@el.check('quartzJob:edit')") public ResponseEntity switchQuartzJobStatus(@PathVariable Long id) { - systemQuartzJobService.switchQuartzJobStatus(systemQuartzJobService.getQuartzJobById(id)); + SystemQuartzJobTb quartzJobTb = systemQuartzJobService.getQuartzJobById(id); + SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(quartzJobTb, SystemQuartzJobVo.class); + systemQuartzJobService.switchQuartzJobStatus(quartzJobVo); return ResponseEntity.ok(null); } @@ -115,7 +118,9 @@ public class SystemQuartzJobController { @PostMapping(value = "/startQuartzJob/{id}") @PreAuthorize("@el.check('quartzJob:edit')") public ResponseEntity startQuartzJob(@PathVariable Long id) { - systemQuartzJobService.startQuartzJob(systemQuartzJobService.getQuartzJobById(id)); + SystemQuartzJobTb quartzJobTb = systemQuartzJobService.getQuartzJobById(id); + SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(quartzJobTb, SystemQuartzJobVo.class); + systemQuartzJobService.startQuartzJob(quartzJobVo); return ResponseEntity.ok(null); } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemRoleController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemRoleController.java index 9fa710f3..d90d44e5 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemRoleController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemRoleController.java @@ -27,9 +27,9 @@ import cn.odboy.system.service.SystemRoleService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import jakarta.servlet.http.HttpServletResponse; import java.util.List; import java.util.Set; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemUserController.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemUserController.java index 2a7274f1..aa1358c9 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemUserController.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemUserController.java @@ -30,9 +30,9 @@ import cn.odboy.system.service.SystemUserService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import jakarta.servlet.http.HttpServletResponse; import java.util.List; import java.util.Set; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDeptTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDeptTb.java index 4c454a28..7d79f580 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDeptTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDeptTb.java @@ -20,9 +20,9 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; +import java.util.Objects; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import java.util.Objects; import lombok.Getter; import lombok.Setter; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemJobTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemJobTb.java index 0e9a12fb..53fa0274 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemJobTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemJobTb.java @@ -20,9 +20,9 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; +import java.util.Objects; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import java.util.Objects; import lombok.Getter; import lombok.Setter; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemLocalStorageTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemLocalStorageTb.java index 92c19c3b..cb3b2e7b 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemLocalStorageTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemLocalStorageTb.java @@ -16,7 +16,6 @@ package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitBaseUserTimeTb; -import cn.odboy.util.KitBeanUtil; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -46,8 +45,4 @@ public class SystemLocalStorageTb extends KitBaseUserTimeTb { private String size; @ApiModelProperty(value = "日期分组") private String dateGroup; - - public void copy(SystemLocalStorageTb source) { - KitBeanUtil.copyToTarget(source, this); - } -} \ No newline at end of file +} diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemMenuTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemMenuTb.java index a1b38205..0a9f3aa3 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemMenuTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemMenuTb.java @@ -21,8 +21,8 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; -import jakarta.validation.constraints.NotNull; import java.util.Objects; +import jakarta.validation.constraints.NotNull; import lombok.Getter; import lombok.Setter; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleTb.java index 54fc4884..8372251a 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleTb.java @@ -23,9 +23,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; +import java.util.Objects; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import java.util.Objects; import lombok.Getter; import lombok.Setter; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserTb.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserTb.java index 01085ac8..31ea896b 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserTb.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserTb.java @@ -21,11 +21,11 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; +import java.util.Date; +import java.util.Objects; import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import java.util.Date; -import java.util.Objects; import lombok.Getter; import lombok.Setter; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateRoleArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateRoleArgs.java index c195955a..4a8f6496 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateRoleArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemCreateRoleArgs.java @@ -17,9 +17,9 @@ package cn.odboy.system.dal.model.request; import cn.odboy.base.KitObject; import cn.odboy.system.dal.dataobject.SystemDeptTb; +import java.util.Set; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; -import java.util.Set; import lombok.Data; import lombok.EqualsAndHashCode; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemSendEmailArgs.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemSendEmailArgs.java index ef1d03e2..3069250f 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemSendEmailArgs.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/request/SystemSendEmailArgs.java @@ -16,9 +16,9 @@ package cn.odboy.system.dal.model.request; import io.swagger.annotations.ApiModelProperty; +import java.util.List; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotEmpty; -import java.util.List; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemSimpleUserVo.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemSimpleUserVo.java index 7585556c..fd60f0c1 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemSimpleUserVo.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/response/SystemSimpleUserVo.java @@ -52,4 +52,4 @@ public class SystemSimpleUserVo extends KitObject { private Boolean enabled; @ApiModelProperty(value = "是否为admin账号", hidden = true) private Boolean isAdmin = false; -} +} \ No newline at end of file diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemQuartzJobMapper.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemQuartzJobMapper.java index c420ffe1..333270ea 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemQuartzJobMapper.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemQuartzJobMapper.java @@ -16,8 +16,6 @@ package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemQuartzJobTb; -import cn.odboy.system.dal.model.response.SystemQuartzJobVo; -import cn.odboy.util.KitBeanUtil; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; @@ -29,7 +27,4 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface SystemQuartzJobMapper extends BaseMapper { - default SystemQuartzJobVo selectVoById(String id) { - return KitBeanUtil.copyToClass(selectById(id), SystemQuartzJobVo.class); - } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleMapper.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleMapper.java index c9bb0662..e4097313 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleMapper.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleMapper.java @@ -17,7 +17,9 @@ package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemRoleTb; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import java.util.List; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 角色 Mapper @@ -27,4 +29,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface SystemRoleMapper extends BaseMapper { + List listRoleLevelByRoleIds(@Param("roleIds") List roleIds); } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserMapper.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserMapper.java index 4bfdd651..bc91dbba 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserMapper.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserMapper.java @@ -18,8 +18,10 @@ package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemUserTb; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import java.util.List; import java.util.Set; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 用户 Mapper @@ -49,4 +51,6 @@ public interface SystemUserMapper extends BaseMapper { wrapper.set(SystemUserTb::getPassword, password); update(null, wrapper); } + + List listUsernameByIds(@Param("userIds") Set userIds); } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserRoleMapper.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserRoleMapper.java index cc6cf958..9ac6c281 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserRoleMapper.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemUserRoleMapper.java @@ -18,6 +18,7 @@ package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemRoleTb; import cn.odboy.system.dal.dataobject.SystemUserRoleTb; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import java.util.List; import java.util.Set; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -26,4 +27,5 @@ import org.apache.ibatis.annotations.Param; public interface SystemUserRoleMapper extends BaseMapper { Set listUserRoleByUserId(@Param("userId") Long userId); + List listUserRoleLevelByUserId(@Param("userId") Long userId); } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java index 17f6d339..4590eb5c 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java @@ -15,14 +15,14 @@ import cn.odboy.util.KitIPUtil; import cn.odboy.util.KitPageUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.metadata.IPage; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/ActiveJobRegister.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/ActiveJobRegister.java index 5ddc3b19..fb9997c9 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/ActiveJobRegister.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/ActiveJobRegister.java @@ -15,8 +15,10 @@ */ package cn.odboy.system.framework.quartz; +import cn.odboy.system.dal.dataobject.SystemQuartzJobTb; import cn.odboy.system.dal.model.response.SystemQuartzJobVo; import cn.odboy.system.service.SystemQuartzJobService; +import cn.odboy.util.KitBeanUtil; import java.util.List; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -40,8 +42,9 @@ public class ActiveJobRegister implements ApplicationRunner { */ @Override public void run(ApplicationArguments applicationArguments) { - List quartzJobs = systemQuartzJobService.listEnableQuartzJob(); - quartzJobs.forEach(quartzManage::addJob); + List quartzJobTbs = systemQuartzJobService.listEnableQuartzJob(); + List quartzJobVos = KitBeanUtil.copyToList(quartzJobTbs, SystemQuartzJobVo.class); + quartzJobVos.forEach(quartzManage::addJob); log.info("Timing task injection complete"); } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/QuartzManage.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/QuartzManage.java index 3057ba88..2e0cc2aa 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/QuartzManage.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/QuartzManage.java @@ -18,8 +18,9 @@ package cn.odboy.system.framework.quartz; import cn.odboy.framework.exception.BadRequestException; import cn.odboy.system.dal.dataobject.SystemQuartzJobTb; import cn.odboy.system.dal.model.response.SystemQuartzJobVo; -import jakarta.annotation.Resource; +import cn.odboy.util.KitBeanUtil; import java.util.Date; +import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.quartz.CronScheduleBuilder; import org.quartz.CronTrigger; @@ -45,12 +46,17 @@ public class QuartzManage { public void addJob(SystemQuartzJobVo quartzJob) { try { + String uuid = JOB_NAME + quartzJob.getId(); // 构建job信息 - JobDetail jobDetail = - JobBuilder.newJob(ExecutionJobBean.class).withIdentity(JOB_NAME + quartzJob.getId()).build(); + JobDetail jobDetail = JobBuilder.newJob(ExecutionJobBean.class) + .withIdentity(uuid) + .build(); // 通过触发器名和cron 表达式创建 Trigger - Trigger trigger = TriggerBuilder.newTrigger().withIdentity(JOB_NAME + quartzJob.getId()).startNow() - .withSchedule(CronScheduleBuilder.cronSchedule(quartzJob.getCronExpression())).build(); + Trigger trigger = TriggerBuilder.newTrigger() + .withIdentity(uuid) + .startNow() + .withSchedule(CronScheduleBuilder.cronSchedule(quartzJob.getCronExpression())) + .build(); trigger.getJobDataMap().put(SystemQuartzJobTb.JOB_KEY, quartzJob); // 重置启动时间 ((CronTriggerImpl) trigger).setStartTime(new Date()); @@ -75,24 +81,25 @@ public class QuartzManage { * * @param quartzJob / */ - public void updateJobCron(SystemQuartzJobVo quartzJob) { + public void updateJobCron(SystemQuartzJobTb quartzJob) { try { - TriggerKey triggerKey = TriggerKey.triggerKey(JOB_NAME + quartzJob.getId()); + SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(quartzJob, SystemQuartzJobVo.class); + TriggerKey triggerKey = TriggerKey.triggerKey(JOB_NAME + quartzJobVo.getId()); CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey); // 如果不存在则创建一个定时任务 if (trigger == null) { - addJob(quartzJob); + addJob(quartzJobVo); trigger = (CronTrigger) scheduler.getTrigger(triggerKey); } - CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(quartzJob.getCronExpression()); + CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(quartzJobVo.getCronExpression()); trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build(); // 重置启动时间 ((CronTriggerImpl) trigger).setStartTime(new Date()); - trigger.getJobDataMap().put(SystemQuartzJobTb.JOB_KEY, quartzJob); + trigger.getJobDataMap().put(SystemQuartzJobTb.JOB_KEY, quartzJobVo); scheduler.rescheduleJob(triggerKey, trigger); // 暂停任务 - if (quartzJob.getIsPause()) { - pauseJob(quartzJob); + if (quartzJobVo.getIsPause()) { + pauseJob(quartzJobVo); } } catch (Exception e) { log.error("更新定时任务失败", e); @@ -144,7 +151,8 @@ public class QuartzManage { */ public void runJobNow(SystemQuartzJobVo quartzJob) { try { - TriggerKey triggerKey = TriggerKey.triggerKey(JOB_NAME + quartzJob.getId()); + String uuid = JOB_NAME + quartzJob.getId(); + TriggerKey triggerKey = TriggerKey.triggerKey(uuid); CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey); // 如果不存在则创建一个定时任务 if (trigger == null) { @@ -152,7 +160,7 @@ public class QuartzManage { } JobDataMap dataMap = new JobDataMap(); dataMap.put(SystemQuartzJobTb.JOB_KEY, quartzJob); - JobKey jobKey = JobKey.jobKey(JOB_NAME + quartzJob.getId()); + JobKey jobKey = JobKey.jobKey(uuid); scheduler.triggerJob(jobKey, dataMap); } catch (Exception e) { log.error("定时任务执行失败", e); diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java index ce820994..cac9c36c 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemAuthService.java @@ -52,7 +52,7 @@ public class SystemAuthService { KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginArgs.getPassword()); // 校验验证码 systemCaptchaService.validate(loginArgs.getUuid(), loginArgs.getCode()); - // 获取用户信息 + // 查询用户信息 SystemUserJwtVo jwtUser = userDetailsService.loadUserByUsername(loginArgs.getUsername()); // 验证用户密码 if (!passwordEncoder.matches(password, jwtUser.getPassword())) { @@ -83,7 +83,7 @@ public class SystemAuthService { } /** - * 获取当前登录人信息 -> TestPassed + * 查询当前登录人信息 -> TestPassed */ public SystemUserJwtVo getCurrentUserInfo() { SystemUserJwtVo jwtUser = (SystemUserJwtVo) KitSecurityHelper.getCurrentUser(); diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java index 308d5129..09a05676 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemCaptchaService.java @@ -26,10 +26,10 @@ public class SystemCaptchaService { private AppProperties properties; /** - * 获取登录验证码 -> TestPassed + * 查询登录验证码 -> TestPassed */ public SystemCaptchaVo getLoginCaptcha() { - // 获取运算的结果 + // 查询运算的结果 Captcha captcha = properties.getLogin().getCaptchaSetting().getCaptcha(); String uuid = SystemCacheKey.CAPTCHA_LOGIN + IdUtil.simpleUUID(); //当验证码类型为 arithmetic时且长度 >= 2 时, captcha.text()的结果有几率为浮点型 @@ -39,8 +39,7 @@ public class SystemCaptchaService { captchaValue = captchaValue.split("\\.")[0]; } // 保存 - redisHelper.set(uuid, captchaValue, properties.getLogin().getCaptchaSetting().getExpiration(), - TimeUnit.MINUTES); + redisHelper.set(uuid, captchaValue, properties.getLogin().getCaptchaSetting().getExpiration(), TimeUnit.MINUTES); // 验证码信息 SystemCaptchaVo captchaVo = new SystemCaptchaVo(); captchaVo.setUuid(uuid); diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java index 17fd9f30..6a775d19 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDataService.java @@ -45,7 +45,7 @@ public class SystemDataService { private SystemRoleDeptService systemRoleDeptService; /** - * 获取数据权限 -> TestPassed + * 查询数据权限 -> TestPassed * * @param user / * @return / @@ -54,7 +54,7 @@ public class SystemDataService { List deptIds = new ArrayList<>(); // 查询用户角色 Set roleList = systemUserRoleService.listUserRoleByUserId(user.getId()); - // 获取对应的部门ID + // 查询对应的部门ID for (SystemRoleTb role : roleList) { SystemDataScopeEnum dataScopeEnum = SystemDataScopeEnum.find(role.getDataScope()); switch (Objects.requireNonNull(dataScopeEnum)) { @@ -75,7 +75,7 @@ public class SystemDataService { } /** - * 获取自定义的数据权限 -> TestPassed + * 查询自定义的数据权限 -> TestPassed * * @param deptIds 部门ID(外部数据) * @param roleId 角色ID @@ -83,8 +83,7 @@ public class SystemDataService { */ private List queryCustomDataPermissionByArgs(List deptIds, Long roleId) { Set deptList = systemRoleDeptService.listUserDeptByRoleId(roleId); - Map> deptPidMap = - systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); + Map> deptPidMap = systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); for (SystemDeptTb dept : deptList) { deptIds.add(dept.getId()); List deptChildren = deptPidMap.getOrDefault(dept.getId(), null); diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java index f92bb582..0ff14e22 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDeptService.java @@ -36,7 +36,6 @@ import cn.odboy.util.KitClassUtil; import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import jakarta.servlet.http.HttpServletResponse; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.Collections; @@ -48,6 +47,7 @@ import java.util.Map; import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -100,7 +100,7 @@ public class SystemDeptService { } /** - * 根据部门id获取部门信息 -> TestPassed + * 根据部门id查询部门信息 -> TestPassed * * @param id 部门id * @return / @@ -116,7 +116,7 @@ public class SystemDeptService { */ @Transactional(rollbackFor = Exception.class) public void deleteDeptByIds(Set ids) { - // 获取部门, 和其所有子部门 + // 查询部门, 和其所有子部门 Set depts = this.traverseDeptByIdWithPids(ids); // 验证是否被角色或用户关联 this.verifyBindRelationByIds(depts); @@ -229,7 +229,7 @@ public class SystemDeptService { } /** - * 获取部门下所有关联的部门 + * 查询部门下所有关联的部门 * * @param deptTbList / * @param depts / @@ -263,7 +263,7 @@ public class SystemDeptService { } /** - * 根据ID获取同级与上级数据 + * 根据ID查询同级与上级数据 * * @param dept / * @param deptList / @@ -388,7 +388,7 @@ public class SystemDeptService { } private List buildDeptSelectOptions(List depts) { - // 获取所有部门并按父子关系组织 + // 查询所有部门并按父子关系组织 Map deptMap = depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); List options = new ArrayList<>(); @@ -433,7 +433,7 @@ public class SystemDeptService { public List listDeptSelectProDataSource() { List depts = this.listEnabledDepts(); - // 获取所有部门并按父子关系组织 + // 查询所有部门并按父子关系组织 Map deptMap = depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); List options = new ArrayList<>(); diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java index 863e9f45..031379a8 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictDetailService.java @@ -32,7 +32,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -117,7 +116,7 @@ public class SystemDictDetailService { } /** - * 根据字典名称获取字典详情 -> TestPassed + * 根据字典名称查询字典详情 -> TestPassed * * @param name 字典名称 * @return / @@ -140,13 +139,4 @@ public class SystemDictDetailService { } return detailVos; } - - public Map> getDictDetailMap(String dictName) { - String[] names = dictName.split("[,, ]"); - Map> dictMap = new HashMap<>(16); - for (String name : names) { - dictMap.put(name, this.listDictDetailByName(name)); - } - return dictMap; - } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictService.java index a6b81a75..d2a9d6b7 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemDictService.java @@ -29,10 +29,10 @@ import cn.odboy.util.KitPageUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import jakarta.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.List; import java.util.Set; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java index 9187bdbf..79d283bd 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemJobService.java @@ -29,10 +29,10 @@ import cn.odboy.util.KitPageUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import jakarta.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.List; import java.util.Set; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -52,8 +52,7 @@ public class SystemJobService { */ @Transactional(rollbackFor = Exception.class) public void saveJob(SystemCreateJobArgs args) { - SystemJobTb job = this.getJobByName(args.getName()); - if (job != null) { + if (this.existJobWithName(args.getName())) { throw new BadRequestException("职位名称已存在"); } SystemJobTb systemJobTb = KitBeanUtil.copyToClass(args, SystemJobTb.class); @@ -68,8 +67,7 @@ public class SystemJobService { @Transactional(rollbackFor = Exception.class) public void updateJobById(SystemJobTb args) { SystemJobTb job = systemJobMapper.selectById(args.getId()); - SystemJobTb old = this.getJobByName(args.getName()); - if (old != null && !old.getId().equals(args.getId())) { + if (this.existJobWithNameNeSelf(args.getName(), job.getId())) { throw new BadRequestException("职位名称已存在"); } args.setId(job.getId()); @@ -121,13 +119,26 @@ public class SystemJobService { } } - public SystemJobTb getJobByName(String name) { + /** + * 根据岗位名称查询岗位是否存在 -> TestPassed + */ + private boolean existJobWithName(String name) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SystemJobTb::getName, name); - return systemJobMapper.selectOne(wrapper); + return systemJobMapper.exists(wrapper); } - public void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper wrapper) { + /** + * 根据岗位名称和岗位id查询岗位是否存在 -> TestPassed + */ + private boolean existJobWithNameNeSelf(String name, Long currentJobId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemJobTb::getName, name); + wrapper.ne(SystemJobTb::getId, currentJobId); + return systemJobMapper.exists(wrapper); + } + + private void injectQueryParams(SystemQueryJobArgs args, LambdaQueryWrapper wrapper) { if (args != null) { wrapper.like(StrUtil.isNotBlank(args.getName()), SystemJobTb::getName, args.getName()); wrapper.eq(args.getEnabled() != null, SystemJobTb::getEnabled, args.getEnabled()); @@ -138,6 +149,9 @@ public class SystemJobService { wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId); } + /** + * 导出岗位数据 -> TestPassed + */ public void exportJobXlsx(HttpServletResponse response, SystemQueryJobArgs args) { List systemJobTbs = this.queryJobByArgs(args); List rowVos = new ArrayList<>(); @@ -150,8 +164,4 @@ public class SystemJobService { } KitExcelExporter.exportSimple(response, "岗位数据", SystemJobExportRowVo.class, rowVos); } - - public List listByIds(Set jobIds) { - return systemJobMapper.selectByIds(jobIds); - } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java index 560ca012..14e0f978 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java @@ -22,7 +22,6 @@ import cn.hutool.core.io.IORuntimeException; import cn.hutool.core.util.StrUtil; import cn.odboy.base.KitPageResult; import cn.odboy.constant.FileTypeEnum; -import cn.odboy.framework.context.KitSpringBeanHolder; import cn.odboy.framework.exception.BadRequestException; import cn.odboy.framework.properties.AppProperties; import cn.odboy.framework.server.core.KitFileLocalUploadHelper; @@ -36,15 +35,18 @@ import cn.odboy.util.KitPageUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import jakarta.servlet.http.HttpServletResponse; import java.io.File; import java.util.Date; import java.util.List; +import jakarta.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +@Slf4j @Service public class SystemLocalStorageService { @@ -54,6 +56,9 @@ public class SystemLocalStorageService { private KitFileLocalUploadHelper fileUploadPathHelper; @Autowired private AppProperties properties; + @Lazy + @Autowired + private SystemLocalStorageService localStorageService; /** * 上传 -> TestPassed @@ -75,8 +80,7 @@ public class SystemLocalStorageService { } try { String formatSize = KitFileUtil.getSize(size); - String prefixName = - StrUtil.isBlank(name) ? KitFileUtil.getPrefix(multipartFile.getOriginalFilename()) : name; + String prefixName = KitFileUtil.getPrefix(multipartFile.getOriginalFilename(), name); SystemLocalStorageTb localStorage = new SystemLocalStorageTb(); localStorage.setRealName(file.getName()); localStorage.setName(prefixName); @@ -88,6 +92,7 @@ public class SystemLocalStorageService { systemLocalStorageMapper.insert(localStorage); return localStorage; } catch (Exception e) { + log.error("上传文件失败", e); KitFileUtil.del(file); throw e; } @@ -100,9 +105,7 @@ public class SystemLocalStorageService { */ @Transactional(rollbackFor = Exception.class) public void updateLocalStorageById(SystemLocalStorageTb args) { - SystemLocalStorageTb localStorage = systemLocalStorageMapper.selectById(args.getId()); - localStorage.copy(args); - systemLocalStorageMapper.insertOrUpdate(localStorage); + systemLocalStorageMapper.updateById(args); } /** @@ -153,25 +156,34 @@ public class SystemLocalStorageService { wrapper.orderByDesc(SystemLocalStorageTb::getId); } + /** + * 查询文件上传记录 -> TestPassed + */ public List queryLocalStorageByArgs(SystemQueryStorageArgs args) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); this.injectQueryParams(args, wrapper); return systemLocalStorageMapper.selectList(wrapper); } - public SystemLocalStorageTb uploadPictureV1(MultipartFile file) { + /** + * 上传图片 -> TestPassed + */ + @Transactional(rollbackFor = Exception.class) + public SystemLocalStorageTb uploadPicture(MultipartFile file) { // 判断文件是否为图片 String suffix = KitFileUtil.getSuffix(file.getOriginalFilename()); if (!FileTypeEnum.IMAGE.getCode().equals(KitFileUtil.getFileType(suffix))) { throw new BadRequestException("只能上传图片"); } - return KitSpringBeanHolder.getBean(SystemLocalStorageService.class).uploadFile(null, file); + return localStorageService.uploadFile(null, file); } + /** + * 导出文件上传记录 -> TestPassed + */ public void exportLocalStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) { List systemLocalStorageTbs = this.queryLocalStorageByArgs(args); - List rowVos = - KitBeanUtil.copyToList(systemLocalStorageTbs, SystemLocalStorageExportRowVo.class); + List rowVos = KitBeanUtil.copyToList(systemLocalStorageTbs, SystemLocalStorageExportRowVo.class); KitExcelExporter.exportSimple(response, "文件上传记录数据", SystemLocalStorageExportRowVo.class, rowVos); } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java index 085e46c3..cf68f9e4 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMenuService.java @@ -36,7 +36,6 @@ import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import jakarta.servlet.http.HttpServletResponse; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashSet; @@ -46,6 +45,7 @@ import java.util.List; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -212,19 +212,19 @@ public class SystemMenuService { } /** - * 根据当前用户获取菜单 + * 根据当前用户查询菜单 * * @param currentUserId / * @return / */ public List listMenuByUserId(Long currentUserId) { - List roles = systemUserRoleService.queryRoleVoByUsersId(currentUserId); + List roles = systemUserRoleService.listRoleVoByUsersId(currentUserId); Set roleIds = roles.stream().map(SystemRoleVo::getId).collect(Collectors.toSet()); return new ArrayList<>(systemRoleMenuService.queryMenuByRoleIds(roleIds)); } /** - * 获取所有子节点, 包含自身ID + * 查询所有子节点, 包含自身ID * * @param menuList / * @param menuSet / @@ -261,7 +261,7 @@ public class SystemMenuService { } /** - * 根据ID获取同级与上级数据 + * 根据ID查询同级与上级数据 * * @param menu / * @param menus / @@ -355,7 +355,7 @@ public class SystemMenuService { } /** - * 获取 MenuResponse + * 查询 MenuResponse * * @param menu / * @param menuVo / diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java index e506233d..ca998310 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java @@ -75,7 +75,7 @@ public class SystemMonitorService { } /** - * 获取磁盘信息 + * 查询磁盘信息 -> TestPassed * * @return / */ @@ -109,7 +109,7 @@ public class SystemMonitorService { } /** - * 获取交换区信息 + * 查询交换区信息 -> TestPassed * * @param memory / * @return / @@ -131,7 +131,7 @@ public class SystemMonitorService { } /** - * 获取内存信息 + * 查询内存信息 -> TestPassed * * @param memory / * @return / @@ -147,7 +147,7 @@ public class SystemMonitorService { } /** - * 获取Cpu相关信息 + * 查询Cpu相关信息 -> TestPassed * * @param processor / * @return / @@ -194,7 +194,7 @@ public class SystemMonitorService { } /** - * 获取系统相关信息,系统、运行天数、系统IP + * 查询系统相关信息,系统、运行天数、系统IP -> TestPassed * * @param os / * @return / diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java index 1742dbe1..3b3b7481 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java @@ -18,7 +18,7 @@ public class SystemOperationLogService { private SystemOperationLogMapper systemOperationLogMapper; /** - * 查询用户操作日志 + * 查询用户操作日志 -> TestPassed */ public IPage searchUserLog(KitPageArgs pageArgs) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOssStorageService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOssStorageService.java index 34696e7f..10e66194 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOssStorageService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOssStorageService.java @@ -21,8 +21,8 @@ import cn.odboy.system.dal.model.request.SystemQueryStorageArgs; import cn.odboy.system.dal.model.response.SystemOssStorageVo; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; -import jakarta.servlet.http.HttpServletResponse; import java.util.List; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.web.multipart.MultipartFile; /** diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java index 7a8c6a75..237ef652 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java @@ -34,15 +34,14 @@ import cn.odboy.system.dal.mysql.SystemQuartzLogMapper; import cn.odboy.system.framework.quartz.QuartzManage; import cn.odboy.util.KitBeanUtil; import cn.odboy.util.KitPageUtil; -import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import jakarta.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Set; +import jakarta.servlet.http.HttpServletResponse; import org.quartz.CronExpression; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -79,7 +78,7 @@ public class SystemQuartzJobService { * @param args / */ @Transactional(rollbackFor = Exception.class) - public void createJob(SystemQuartzJobVo args) { + public void createJob(SystemQuartzJobTb args) { if (args.getId() != null) { throw new BadRequestException("无效参数id"); } @@ -88,9 +87,9 @@ public class SystemQuartzJobService { if (!CronExpression.isValidExpression(args.getCronExpression())) { throw new BadRequestException("cron表达式格式错误"); } - SystemQuartzJobTb record = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class); - systemQuartzJobMapper.insert(record); - quartzManage.addJob(args); + systemQuartzJobMapper.insert(args); + SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(args, SystemQuartzJobVo.class); + quartzManage.addJob(quartzJobVo); } /** @@ -112,28 +111,27 @@ public class SystemQuartzJobService { } } SystemQuartzJobTb jobTb = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class); - systemQuartzJobMapper.insertOrUpdate(jobTb); - SystemQuartzJobVo jobVo = KitBeanUtil.copyToClass(args, SystemQuartzJobVo.class); - quartzManage.updateJobCron(jobVo); + systemQuartzJobMapper.updateById(jobTb); + quartzManage.updateJobCron(jobTb); } /** * 更改定时任务状态 * - * @param quartzJob / + * @param quartzJobVo / */ @Transactional(rollbackFor = Exception.class) - public void switchQuartzJobStatus(SystemQuartzJobVo quartzJob) { + public void switchQuartzJobStatus(SystemQuartzJobVo quartzJobVo) { // 置换暂停状态 - if (quartzJob.getIsPause()) { - quartzManage.resumeJob(quartzJob); - quartzJob.setIsPause(false); + if (quartzJobVo.getIsPause()) { + quartzManage.resumeJob(quartzJobVo); + quartzJobVo.setIsPause(false); } else { - quartzManage.pauseJob(quartzJob); - quartzJob.setIsPause(true); + quartzManage.pauseJob(quartzJobVo); + quartzJobVo.setIsPause(true); } - SystemQuartzJobTb quartzJobTb = KitBeanUtil.copyToClass(quartzJob, SystemQuartzJobTb.class); - systemQuartzJobMapper.insertOrUpdate(quartzJobTb); + SystemQuartzJobTb record = KitBeanUtil.copyToClass(quartzJobVo, SystemQuartzJobTb.class); + systemQuartzJobMapper.updateById(record); } /** @@ -172,20 +170,20 @@ public class SystemQuartzJobService { // 如果是手动清除子任务id, 会出现id为空字符串的问题 continue; } - SystemQuartzJobVo quartzJob = systemQuartzJobMapper.selectVoById(id); - if (quartzJob == null) { + SystemQuartzJobTb quartzJobTb = systemQuartzJobMapper.selectById(id); + if (quartzJobTb == null) { // 防止子任务不存在 continue; } + SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(quartzJobTb, SystemQuartzJobVo.class); // 执行任务 String uuid = IdUtil.simpleUUID(); - quartzJob.setUuid(uuid); - // 执行任务 - startQuartzJob(quartzJob); - // 获取执行状态, 如果执行失败则停止后面的子任务执行 + quartzJobVo.setUuid(uuid); + startQuartzJob(quartzJobVo); + // 查询执行状态, 如果执行失败则停止后面的子任务执行 Boolean result = redisHelper.get(uuid, Boolean.class); while (result == null) { - // 休眠5秒, 再次获取子任务执行情况 + // 休眠5秒, 再次查询子任务执行情况 Thread.sleep(5000); result = redisHelper.get(uuid, Boolean.class); } @@ -203,25 +201,23 @@ public class SystemQuartzJobService { * @param page 分页参数 * @return / */ - public KitPageResult searchQuartzJobByArgs(SystemQueryQuartzJobArgs args, - Page page) { + public KitPageResult searchQuartzJobByArgs(SystemQueryQuartzJobArgs args, Page page) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); this.injectQuartzJobQueryParams(args, wrapper); return KitPageUtil.toPage(systemQuartzJobMapper.selectPage(page, wrapper)); } - private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args, - LambdaQueryWrapper wrapper) { - KitValidUtil.notNull(args); - wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName, args.getJobName()); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper wrapper) { + if (args != null) { + wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName, args.getJobName()); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + } } wrapper.orderByDesc(SystemQuartzJobTb::getId); } - private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, - LambdaQueryWrapper wrapper) { + private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper wrapper) { if (args != null) { wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName()); wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess()); @@ -271,16 +267,15 @@ public class SystemQuartzJobService { return systemQuartzLogMapper.selectList(wrapper); } - public SystemQuartzJobVo getQuartzJobById(Long id) { - return KitBeanUtil.copyToClass(systemQuartzJobMapper.selectById(id), SystemQuartzJobVo.class); - } - - public List listEnableQuartzJob() { + public List listEnableQuartzJob() { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SystemQuartzJobTb::getIsPause, 0); - return KitBeanUtil.copyToList(systemQuartzJobMapper.selectList(wrapper), SystemQuartzJobVo.class); + return systemQuartzJobMapper.selectList(wrapper); } + /** + * 导出定时任务数据 -> TestPassed + */ public void exportQuartzJobXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) { List systemQuartzJobTbs = this.queryQuartzJobByArgs(args); List rowVos = new ArrayList<>(); @@ -299,6 +294,9 @@ public class SystemQuartzJobService { KitExcelExporter.exportSimple(response, "定时任务数据", SystemQuartzJobExportRowVo.class, rowVos); } + /** + * 导出定时任务日志数据 -> TestPassed + */ public void exportQuartzLogXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) { List systemQuartzLogTbs = this.queryQuartzLogByArgs(args); List rowVos = new ArrayList<>(); @@ -317,4 +315,8 @@ public class SystemQuartzJobService { } KitExcelExporter.exportSimple(response, "定时任务日志数据", SystemQuartzLogExportRowVo.class, rowVos); } + + public SystemQuartzJobTb getQuartzJobById(Long id) { + return systemQuartzJobMapper.selectById(id); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java index 172dbdb0..517f7c57 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java @@ -18,7 +18,6 @@ package cn.odboy.system.service; import cn.hutool.core.collection.CollUtil; import cn.odboy.system.dal.dataobject.SystemDeptTb; import cn.odboy.system.dal.dataobject.SystemRoleDeptTb; -import cn.odboy.system.dal.mysql.SystemDeptMapper; import cn.odboy.system.dal.mysql.SystemRoleDeptMapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import java.util.ArrayList; @@ -33,8 +32,6 @@ public class SystemRoleDeptService { @Autowired private SystemRoleDeptMapper systemRoleDeptMapper; - @Autowired - private SystemDeptMapper systemDeptMapper; @Transactional(rollbackFor = Exception.class) public void batchDeleteRoleDept(Set roleIds) { diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java index 71cb3033..2a0b88fe 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleService.java @@ -36,13 +36,13 @@ import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import jakarta.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -60,7 +60,7 @@ public class SystemRoleService { private SystemUserRoleService systemUserRoleService; /** - * 创建 + * 创建 -> TestPassed * * @param args / */ @@ -91,7 +91,7 @@ public class SystemRoleService { } /** - * 修改 + * 修改 -> TestPassed * * @param args / */ @@ -122,7 +122,7 @@ public class SystemRoleService { } /** - * 修改绑定的菜单 + * 修改绑定的菜单 -> TestPassed * * @param args / */ @@ -140,7 +140,7 @@ public class SystemRoleService { } /** - * 删除 + * 删除 -> TestPassed * * @param ids / */ @@ -161,7 +161,7 @@ public class SystemRoleService { } /** - * 查询全部角色 + * 查询全部角色 -> TestPassed */ public List listAllRole() { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); @@ -170,7 +170,7 @@ public class SystemRoleService { } /** - * 根据条件查询全部角色 + * 根据条件查询全部角色 -> TestPassed * * @param args 条件 * @param rolePage 分页参数 @@ -197,7 +197,7 @@ public class SystemRoleService { } /** - * 分页查询角色 + * 分页查询角色 -> TestPassed * * @param args 条件 * @param page 分页条件 @@ -210,7 +210,7 @@ public class SystemRoleService { } /** - * 获取用户权限信息 + * 查询用户权限信息 -> TestPassed * * @param user 用户信息 * @return 权限信息 @@ -222,14 +222,14 @@ public class SystemRoleService { permissions.add("admin"); return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); } - List roles = systemUserRoleService.queryRoleVoByUsersId(user.getId()); + List roles = systemUserRoleService.listRoleVoByUsersId(user.getId()); permissions = roles.stream().flatMap(role -> role.getMenus().stream()).map(SystemMenuVo::getPermission) .filter(StrUtil::isNotBlank).collect(Collectors.toSet()); return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); } /** - * 验证是否被用户关联 + * 验证是否被用户关联 -> TestPassed * * @param ids / */ @@ -263,12 +263,12 @@ public class SystemRoleService { } /** - * 检查用户的角色级别 + * 检查用户的角色级别 -> TestPassed * * @return / */ private int checkRoleLevels(Integer level) { - List levels = systemUserRoleService.queryRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream() + List levels = systemUserRoleService.listRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream() .map(SystemRoleVo::getLevel).collect(Collectors.toList()); int min = Collections.min(levels); if (level != null) { @@ -292,8 +292,4 @@ public class SystemRoleService { } KitExcelExporter.exportSimple(response, "部门数据", SystemRoleExportRowVo.class, rowVos); } - - public List listByIds(Set roleIds) { - return systemRoleMapper.selectByIds(roleIds); - } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java index e051ae16..76580ef4 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserDeptService.java @@ -13,6 +13,9 @@ public class SystemUserDeptService { @Autowired private SystemUserMapper systemUserMapper; + /** + * 根据部门id统计用户数量 -> TestPassed + */ public long countUserByDeptIds(Set deptIds) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.in(SystemUserTb::getDeptId, deptIds); diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java index ed5c0bab..b7966eef 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java @@ -33,6 +33,9 @@ public class SystemUserJobService { @Autowired private SystemUserJobMapper systemUserJobMapper; + /** + * 批量绑定用户岗位 -> TestPassed + */ @Transactional(rollbackFor = Exception.class) public void batchInsertUserJob(Set jobs, Long userId) { if (CollUtil.isNotEmpty(jobs)) { @@ -47,6 +50,9 @@ public class SystemUserJobService { } } + /** + * 批量解绑用户岗位 -> TestPassed + */ @Transactional(rollbackFor = Exception.class) public void batchDeleteUserJob(Set userIds) { if (CollUtil.isNotEmpty(userIds)) { @@ -57,9 +63,9 @@ public class SystemUserJobService { } /** - * 根据岗位ID统计用户数量 + * 根据岗位ID统计用户数量 -> TestPassed * - * @param jobIds 岗位ID集合 + * @param jobIds / * @return / */ public Long countUserByJobIds(Set jobIds) { @@ -71,6 +77,12 @@ public class SystemUserJobService { return systemUserJobMapper.selectCount(wrapper); } + /** + * 根据用户id列举岗位 -> TestPassed + * + * @param userId / + * @return / + */ public Set listUserJobByUserId(Long userId) { return systemUserJobMapper.listUserJobByUserId(userId); } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java index 0e82aabe..d882fbea 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java @@ -50,6 +50,9 @@ public class SystemUserRoleService { @Autowired private SystemRoleDeptService systemRoleDeptService; + /** + * 批量绑定用户角色 -> TestPassed + */ @Transactional(rollbackFor = Exception.class) public void batchInsertUserRole(Set roles, Long userId) { if (CollUtil.isNotEmpty(roles)) { @@ -64,6 +67,9 @@ public class SystemUserRoleService { } } + /** + * 批量解绑用户角色 -> TestPassed + */ @Transactional(rollbackFor = Exception.class) public void batchDeleteUserRole(Set userIds) { if (CollUtil.isNotEmpty(userIds)) { @@ -94,18 +100,18 @@ public class SystemUserRoleService { } /** - * 根据用户ID查询 + * 根据用户ID查询 -> TestPassed * * @param userId 用户ID * @return / */ - public List queryRoleVoByUsersId(Long userId) { + public List listRoleVoByUsersId(Long userId) { Set roles = this.listUserRoleByUserId(userId); return roles.stream().map(this::convertToRoleVo).collect(Collectors.toList()); } /** - * 根据角色查询角色级别 + * 根据角色查询角色级别 -> TestPassed * * @param roles / * @return / @@ -115,16 +121,12 @@ public class SystemUserRoleService { // 最小权限 return Integer.MAX_VALUE; } - List roleIds = - roles.stream().map(SystemRoleTb::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); + List roleIds = roles.stream().map(SystemRoleTb::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); if (CollUtil.isEmpty(roleIds)) { // 最小权限 return Integer.MAX_VALUE; } - List roleLevels = systemRoleMapper.selectList( - new LambdaQueryWrapper().select(SystemRoleTb::getLevel).isNotNull(SystemRoleTb::getLevel) - .in(SystemRoleTb::getId, roleIds)).stream().map(SystemRoleTb::getLevel).distinct() - .collect(Collectors.toList()); + List roleLevels = systemRoleMapper.listRoleLevelByRoleIds(roleIds); if (CollUtil.isEmpty(roleLevels)) { // 最小权限 return Integer.MAX_VALUE; @@ -133,14 +135,13 @@ public class SystemUserRoleService { } /** - * 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误 + * 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误 -> TestPassed * * @param args / */ public void checkLevel(SystemUserVo args) { - Integer currentLevel = Collections.min( - this.queryRoleVoByUsersId(KitSecurityHelper.getCurrentUserId()).stream().map(SystemRoleVo::getLevel) - .collect(Collectors.toList())); + List roleLevels = systemUserRoleMapper.listUserRoleLevelByUserId(KitSecurityHelper.getCurrentUserId()); + Integer currentLevel = Collections.min(roleLevels); Integer optLevel = this.getDeptLevelByRoles(args.getRoles()); if (currentLevel > optLevel) { throw new BadRequestException("角色权限不足"); @@ -156,7 +157,23 @@ public class SystemUserRoleService { return systemUserRoleMapper.selectCount(wrapper); } + /** + * 根据用户id列举角色 -> TestPassed + * + * @param userId / + * @return / + */ public Set listUserRoleByUserId(Long userId) { return systemUserRoleMapper.listUserRoleByUserId(userId); } + + /** + * 根据用户id列举角色级别 -> TestPassed + * + * @param userId / + * @return / + */ + public List listUserRoleLevelByUserId(Long userId) { + return systemUserRoleMapper.listUserRoleLevelByUserId(userId); + } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java index 1fa9abfc..aa439fde 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserService.java @@ -32,7 +32,6 @@ import cn.odboy.system.dal.dataobject.SystemUserTb; import cn.odboy.system.dal.model.export.SystemUserExportRowVo; import cn.odboy.system.dal.model.request.SystemQueryUserArgs; import cn.odboy.system.dal.model.request.SystemUpdateUserPasswordArgs; -import cn.odboy.system.dal.model.response.SystemRoleVo; import cn.odboy.system.dal.model.response.SystemUserVo; import cn.odboy.system.dal.mysql.SystemUserMapper; import cn.odboy.system.dal.redis.SystemUserInfoDAO; @@ -42,12 +41,10 @@ import cn.odboy.util.KitBeanUtil; import cn.odboy.util.KitFileUtil; import cn.odboy.util.KitPageUtil; import cn.odboy.util.KitRsaEncryptUtil; -import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import jakarta.servlet.http.HttpServletResponse; import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -57,6 +54,7 @@ import java.util.Map; import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; @@ -91,7 +89,7 @@ public class SystemUserService { private PasswordEncoder passwordEncoder; /** - * 新增用户 + * 新增用户 -> TestPassed * * @param args / */ @@ -102,13 +100,13 @@ public class SystemUserService { // 默认密码 123456 record.setPassword(passwordEncoder.encode("123456")); record.setDeptId(args.getDept().getId()); - if (this.getUserByUsername(record.getUsername()) != null) { + if (this.existUserWithUsername(record.getUsername())) { throw new BadRequestException("用户名已存在"); } - if (this.getUserByEmail(record.getEmail()) != null) { + if (this.existUserWithEmail(record.getEmail())) { throw new BadRequestException("邮箱已存在"); } - if (this.getUserByPhone(record.getPhone()) != null) { + if (this.existUserWithPhone(record.getPhone())) { throw new BadRequestException("手机号已存在"); } // 保存用户 @@ -119,8 +117,29 @@ public class SystemUserService { systemUserRoleService.batchInsertUserRole(args.getRoles(), record.getId()); } + private boolean existUserWithPhone(String phone) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getPhone, phone); + wrapper.eq(SystemUserTb::getEnabled, 1); + return systemUserMapper.exists(wrapper); + } + + private boolean existUserWithEmail(String email) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getEmail, email); + wrapper.eq(SystemUserTb::getEnabled, 1); + return systemUserMapper.exists(wrapper); + } + + private boolean existUserWithUsername(String username) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getUsername, username); + wrapper.eq(SystemUserTb::getEnabled, 1); + return systemUserMapper.exists(wrapper); + } + /** - * 编辑用户 + * 编辑用户 -> TestPassed * * @param args / */ @@ -128,16 +147,13 @@ public class SystemUserService { public void updateUserById(SystemUserVo args) { systemUserRoleService.checkLevel(args); SystemUserTb user = systemUserMapper.selectById(args.getId()); - SystemUserTb user1 = this.getUserByUsername(args.getUsername()); - SystemUserTb user2 = this.getUserByEmail(args.getEmail()); - SystemUserTb user3 = this.getUserByPhone(args.getPhone()); - if (user1 != null && !user.getId().equals(user1.getId())) { + if (this.existUserWithUsernameNeSelf(args.getUsername(), user.getId())) { throw new BadRequestException("用户名已存在"); } - if (user2 != null && !user.getId().equals(user2.getId())) { + if (this.existUserWithEmailNeSelf(args.getEmail(), user.getId())) { throw new BadRequestException("邮箱已存在"); } - if (user3 != null && !user.getId().equals(user3.getId())) { + if (this.existUserWithPhoneNeSelf(args.getPhone(), user.getId())) { throw new BadRequestException("手机号已存在"); } // 如果用户被禁用, 则清除用户登录信息 @@ -162,8 +178,29 @@ public class SystemUserService { systemUserRoleService.batchInsertUserRole(args.getRoles(), args.getId()); } + private boolean existUserWithPhoneNeSelf(String phone, Long currentUserId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getPhone, phone); + wrapper.ne(SystemUserTb::getId, currentUserId); + return systemUserMapper.exists(wrapper); + } + + private boolean existUserWithEmailNeSelf(String email, Long currentUserId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getEmail, email); + wrapper.ne(SystemUserTb::getId, currentUserId); + return systemUserMapper.exists(wrapper); + } + + private boolean existUserWithUsernameNeSelf(String username, Long currentUserId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getUsername, username); + wrapper.ne(SystemUserTb::getId, currentUserId); + return systemUserMapper.exists(wrapper); + } + /** - * 用户自助修改资料 + * 用户自助修改资料 -> TestPassed * * @param args / */ @@ -173,19 +210,18 @@ public class SystemUserService { throw new BadRequestException("不能修改他人资料"); } SystemUserTb user = systemUserMapper.selectById(args.getId()); - SystemUserTb user1 = this.getUserByPhone(args.getPhone()); - if (user1 != null && !user.getId().equals(user1.getId())) { + if (this.existUserWithPhoneNeSelf(args.getPhone(), user.getId())) { throw new BadRequestException("手机号已存在"); } user.setNickName(args.getNickName()); user.setPhone(args.getPhone()); user.setGender(args.getGender()); - systemUserMapper.insertOrUpdate(user); + systemUserMapper.updateById(user); systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); } /** - * 删除用户 + * 删除用户 -> TestPassed * * @param ids / */ @@ -194,19 +230,15 @@ public class SystemUserService { Long currentUserId = KitSecurityHelper.getCurrentUserId(); // 校验权限 for (Long id : ids) { - Integer currentLevel = Collections.min( - systemUserRoleService.queryRoleVoByUsersId(currentUserId).stream().map(SystemRoleVo::getLevel) - .collect(Collectors.toList())); - Integer optLevel = Collections.min( - systemUserRoleService.queryRoleVoByUsersId(id).stream().map(SystemRoleVo::getLevel) - .collect(Collectors.toList())); + Integer currentLevel = Collections.min(systemUserRoleService.listUserRoleLevelByUserId(currentUserId)); + Integer optLevel = Collections.min(systemUserRoleService.listUserRoleLevelByUserId(id)); if (currentLevel > optLevel) { - throw new BadRequestException("角色权限不足, 不能删除:" + this.getUserById(id).getUsername()); + SystemUserTb systemUserTb = systemUserMapper.selectById(id); + throw new BadRequestException("角色权限不足, 不能删除:" + systemUserTb.getUsername()); } } // 清理缓存 - List usernameList = systemUserMapper.selectByIds(ids).stream().map(SystemUserTb::getUsername).distinct() - .collect(Collectors.toList()); + List usernameList = systemUserMapper.listUsernameByIds(ids); for (String username : usernameList) { systemUserInfoDAO.deleteUserLoginInfoByUserName(username); } @@ -219,7 +251,7 @@ public class SystemUserService { } /** - * 修改密码 + * 修改密码 -> TestPassed * * @param username 用户名 * @param args 参数 @@ -241,27 +273,27 @@ public class SystemUserService { } /** - * 重置密码 + * 重置密码 -> TestPassed * * @param ids 用户id */ @Transactional(rollbackFor = Exception.class) public void resetUserPasswordByIds(Set ids) { String defaultPwd = passwordEncoder.encode("123456"); - List users = systemUserMapper.selectByIds(ids); + List users = systemUserMapper.listUsernameByIds(ids); // 清除缓存 - for (SystemUserTb user : users) { + for (String username : users) { // 清除缓存 - systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); + systemUserInfoDAO.deleteUserLoginInfoByUserName(username); // 强制退出 - systemUserOnlineInfoDAO.kickOutByUsername(user.getUsername()); + systemUserOnlineInfoDAO.kickOutByUsername(username); } // 重置密码 systemUserMapper.updateUserPasswordByUserIds(defaultPwd, ids); } /** - * 修改头像 + * 修改头像 -> TestPassed * * @param multipartFile 文件 * @return / @@ -271,7 +303,7 @@ public class SystemUserService { SystemUserTb user = this.getUserByUsername(KitSecurityHelper.getCurrentUsername()); String username = user.getUsername(); if (StrUtil.isBlank(username)) { - throw new BadRequestException("异常用户数据, 请联系管理员处理"); + throw new BadRequestException("异常用户数据, 请联系管理员处理!"); } // 文件大小验证 KitFileUtil.checkSize(fileUploadPathHelper.getAvatarMaxSize(), multipartFile.getSize()); @@ -279,13 +311,13 @@ public class SystemUserService { String image = "gif jpg png jpeg"; String fileType = KitFileUtil.getSuffix(multipartFile.getOriginalFilename()); if (fileType != null && !image.contains(fileType)) { - throw new BadRequestException("文件格式错误!, 仅支持 " + image + " 格式"); + throw new BadRequestException("文件格式错误, 仅支持 " + image + " 格式!"); } String oldPath = user.getAvatarPath(); File file = KitFileUtil.upload(multipartFile, fileUploadPathHelper.getPath()); user.setAvatarPath(Objects.requireNonNull(file).getPath()); user.setAvatarName(file.getName()); - systemUserMapper.insertOrUpdate(user); + systemUserMapper.updateById(user); if (StrUtil.isNotBlank(oldPath)) { KitFileUtil.del(oldPath); } @@ -296,7 +328,7 @@ public class SystemUserService { } /** - * 修改邮箱 + * 修改邮箱 -> TestPassed * * @param username 用户名 * @param args 参数 @@ -304,8 +336,7 @@ public class SystemUserService { */ @Transactional(rollbackFor = Exception.class) public void updateUserEmailByUsername(String username, SystemUserTb args, String code) throws Exception { - String password = - KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword()); + String password = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword()); SystemUserTb user = this.getUserByUsername(username); if (!passwordEncoder.matches(password, user.getPassword())) { throw new BadRequestException("密码错误"); @@ -316,7 +347,7 @@ public class SystemUserService { } /** - * 查询全部 + * 查询全部 -> TestPassed * * @param args 条件 * @param page 分页参数 @@ -328,8 +359,7 @@ public class SystemUserService { IPage userPage = systemUserMapper.selectPage(page, wrapper); List users = userPage.getRecords(); // 转换为SystemUserVo并关联查询 - List userVos = - users.stream().map(m -> this.convertToUserVo(m, false)).collect(Collectors.toList()); + List userVos = users.stream().map(m -> this.convertToUserVo(m, false)).collect(Collectors.toList()); return KitPageUtil.toPage(userVos, userPage.getTotal()); } @@ -338,16 +368,6 @@ public class SystemUserService { return systemUserMapper.selectCount(wrapper); } - /** - * 根据ID查询 - * - * @param id ID - * @return / - */ - public SystemUserTb getUserById(long id) { - return systemUserMapper.selectById(id); - } - public List queryUserMetadataOptions(KitPageArgs pageArgs) { SystemQueryUserArgs args = pageArgs.getArgs(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); @@ -372,36 +392,37 @@ public class SystemUserService { } /** - * 构建用户查询条件 + * 构建用户查询条件 -> TestPassed * * @param args 查询条件 * @return / */ private LambdaQueryWrapper buildUserQueryWrapper(SystemQueryUserArgs args) { - KitValidUtil.notNull(args); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - if (args.getId() != null) { - wrapper.eq(SystemUserTb::getId, args.getId()); - } - if (args.getEnabled() != null) { - wrapper.eq(SystemUserTb::getEnabled, args.getEnabled()); - } - if (CollUtil.isNotEmpty(args.getDeptIds())) { - wrapper.in(SystemUserTb::getDeptId, args.getDeptIds()); - } - if (StrUtil.isNotBlank(args.getBlurry())) { - wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or() - .like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry())); - } - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + if (args != null) { + if (args.getId() != null) { + wrapper.eq(SystemUserTb::getId, args.getId()); + } + if (args.getEnabled() != null) { + wrapper.eq(SystemUserTb::getEnabled, args.getEnabled()); + } + if (CollUtil.isNotEmpty(args.getDeptIds())) { + wrapper.in(SystemUserTb::getDeptId, args.getDeptIds()); + } + if (StrUtil.isNotBlank(args.getBlurry())) { + wrapper.and(w -> w.like(SystemUserTb::getUsername, args.getBlurry()).or() + .like(SystemUserTb::getNickName, args.getBlurry()).or().like(SystemUserTb::getEmail, args.getBlurry())); + } + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemUserTb::getCreateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + } } wrapper.orderByDesc(SystemUserTb::getCreateTime); return wrapper; } /** - * 转换为SystemUserVo并关联查询部门、角色、岗位信息 + * 转换为SystemUserVo并关联查询部门、角色、岗位信息 -> TestPassed * * @param user 用户基本信息 * @param includePassword 是否包含用户密码 @@ -442,28 +463,16 @@ public class SystemUserService { return this.convertToUserVo(this.getUserByUsername(username), false); } - public SystemUserTb getUserByEmail(String email) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemUserTb::getEmail, email); - wrapper.eq(SystemUserTb::getEnabled, 1); - return systemUserMapper.selectOne(wrapper); - } - - public SystemUserTb getUserByPhone(String phone) { - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.eq(SystemUserTb::getPhone, phone); - wrapper.eq(SystemUserTb::getEnabled, 1); - return systemUserMapper.selectOne(wrapper); - } - + /** + * 聚合查询 -> TestPassed + */ public KitPageResult aggregationSearchUserByArgs(Page page, SystemQueryUserArgs args, String currentUsername) { if (!ObjectUtils.isEmpty(args.getDeptId())) { args.getDeptIds().add(args.getDeptId()); // 先查找是否存在子节点 List data = systemDeptService.listDeptByPid(args.getDeptId()); - Map> deptPidMap = - systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); + Map> deptPidMap = systemDeptService.listPidNonNull().stream().collect(Collectors.groupingBy(SystemDeptTb::getPid)); // 然后把子节点的ID都加入到集合中 args.getDeptIds().addAll(systemDeptService.queryChildDeptIdByDeptIds(data, deptPidMap)); } @@ -484,6 +493,9 @@ public class SystemUserService { return KitPageUtil.emptyData(); } + /** + * 导出 -> TestPassed + */ public void exportUserXlsx(HttpServletResponse response, SystemQueryUserArgs args) { long totalCount = this.countUserByArgs(args); KitExcelExporter.exportByPage(response, "用户数据", SystemUserExportRowVo.class, totalCount, diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemMinioStorageServiceImpl.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemMinioStorageServiceImpl.java index b34a1501..ce6373db 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemMinioStorageServiceImpl.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemMinioStorageServiceImpl.java @@ -39,9 +39,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import jakarta.servlet.http.HttpServletResponse; import java.io.File; import java.util.List; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; diff --git a/cutejava-springboot3/cutejava-starter/src/main/resources/logback.xml b/cutejava-springboot3/cutejava-starter/src/main/resources/logback.xml index 6e9cdd7a..51c5437f 100644 --- a/cutejava-springboot3/cutejava-starter/src/main/resources/logback.xml +++ b/cutejava-springboot3/cutejava-starter/src/main/resources/logback.xml @@ -1,44 +1,40 @@ - CuteJava - - - - - - - - - - - - - - - - - ${log.pattern} - ${log.charset} - - - - - ${log.home}/${log.name}.log - - ${log.home}/${log.name}.log.%d{yyyy-MM-dd}.%i.log - 90 - 100MB - - - ${log.pattern} - - - - - - - - - + CuteJava + + + + + + + + + + + + + + + ${log.pattern} + ${log.charset} + + + + ${log.home}/${log.name}.log + + ${log.home}/${log.name}.log.%d{yyyy-MM-dd}.%i.log + 90 + 100MB + + + ${log.pattern} + + + + + + + + \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemQuartzJobController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemQuartzJobController.java index 3c513b29..56e305d8 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemQuartzJobController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemQuartzJobController.java @@ -24,6 +24,7 @@ import cn.odboy.system.dal.model.request.SystemUpdateQuartzJobArgs; import cn.odboy.system.dal.model.response.SystemQuartzJobVo; import cn.odboy.system.framework.operalog.OperationLog; import cn.odboy.system.service.SystemQuartzJobService; +import cn.odboy.util.KitBeanUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -86,7 +87,7 @@ public class SystemQuartzJobController { @ApiOperation("新增定时任务") @PostMapping(value = "/createQuartzJob") @PreAuthorize("@el.check('quartzJob:add')") - public ResponseEntity createQuartzJob(@Validated @RequestBody SystemQuartzJobVo args) { + public ResponseEntity createQuartzJob(@Validated @RequestBody SystemQuartzJobTb args) { systemQuartzJobService.createJob(args); return ResponseEntity.ok(null); } @@ -106,7 +107,9 @@ public class SystemQuartzJobController { @PostMapping(value = "/switchQuartzJobStatus/{id}") @PreAuthorize("@el.check('quartzJob:edit')") public ResponseEntity switchQuartzJobStatus(@PathVariable Long id) { - systemQuartzJobService.switchQuartzJobStatus(systemQuartzJobService.getQuartzJobById(id)); + SystemQuartzJobTb quartzJobTb = systemQuartzJobService.getQuartzJobById(id); + SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(quartzJobTb, SystemQuartzJobVo.class); + systemQuartzJobService.switchQuartzJobStatus(quartzJobVo); return ResponseEntity.ok(null); } @@ -115,7 +118,9 @@ public class SystemQuartzJobController { @PostMapping(value = "/startQuartzJob/{id}") @PreAuthorize("@el.check('quartzJob:edit')") public ResponseEntity startQuartzJob(@PathVariable Long id) { - systemQuartzJobService.startQuartzJob(systemQuartzJobService.getQuartzJobById(id)); + SystemQuartzJobTb quartzJobTb = systemQuartzJobService.getQuartzJobById(id); + SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(quartzJobTb, SystemQuartzJobVo.class); + systemQuartzJobService.startQuartzJob(quartzJobVo); return ResponseEntity.ok(null); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemQuartzJobMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemQuartzJobMapper.java index 0b1cfb82..64c70147 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemQuartzJobMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemQuartzJobMapper.java @@ -16,8 +16,6 @@ package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemQuartzJobTb; -import cn.odboy.system.dal.model.response.SystemQuartzJobVo; -import cn.odboy.util.KitBeanUtil; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; @@ -29,7 +27,4 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface SystemQuartzJobMapper extends BaseMapper { - default SystemQuartzJobVo selectVoById(String id) { - return KitBeanUtil.copyToClass(selectById(id), SystemQuartzJobVo.class); - } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/ActiveJobRegister.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/ActiveJobRegister.java index 3f5427c0..d3d5999c 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/ActiveJobRegister.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/ActiveJobRegister.java @@ -15,8 +15,10 @@ */ package cn.odboy.system.framework.quartz; +import cn.odboy.system.dal.dataobject.SystemQuartzJobTb; import cn.odboy.system.dal.model.response.SystemQuartzJobVo; import cn.odboy.system.service.SystemQuartzJobService; +import cn.odboy.util.KitBeanUtil; import java.util.List; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -40,8 +42,9 @@ public class ActiveJobRegister implements ApplicationRunner { */ @Override public void run(ApplicationArguments applicationArguments) { - List quartzJobs = systemQuartzJobService.listEnableQuartzJob(); - quartzJobs.forEach(quartzManage::addJob); + List quartzJobTbs = systemQuartzJobService.listEnableQuartzJob(); + List quartzJobVos = KitBeanUtil.copyToList(quartzJobTbs, SystemQuartzJobVo.class); + quartzJobVos.forEach(quartzManage::addJob); log.info("Timing task injection complete"); } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/QuartzManage.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/QuartzManage.java index fa6d0006..21768809 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/QuartzManage.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/QuartzManage.java @@ -18,6 +18,7 @@ package cn.odboy.system.framework.quartz; import cn.odboy.framework.exception.BadRequestException; import cn.odboy.system.dal.dataobject.SystemQuartzJobTb; import cn.odboy.system.dal.model.response.SystemQuartzJobVo; +import cn.odboy.util.KitBeanUtil; import java.util.Date; import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; @@ -45,12 +46,17 @@ public class QuartzManage { public void addJob(SystemQuartzJobVo quartzJob) { try { + String uuid = JOB_NAME + quartzJob.getId(); // 构建job信息 - JobDetail jobDetail = - JobBuilder.newJob(ExecutionJobBean.class).withIdentity(JOB_NAME + quartzJob.getId()).build(); + JobDetail jobDetail = JobBuilder.newJob(ExecutionJobBean.class) + .withIdentity(uuid) + .build(); // 通过触发器名和cron 表达式创建 Trigger - Trigger trigger = TriggerBuilder.newTrigger().withIdentity(JOB_NAME + quartzJob.getId()).startNow() - .withSchedule(CronScheduleBuilder.cronSchedule(quartzJob.getCronExpression())).build(); + Trigger trigger = TriggerBuilder.newTrigger() + .withIdentity(uuid) + .startNow() + .withSchedule(CronScheduleBuilder.cronSchedule(quartzJob.getCronExpression())) + .build(); trigger.getJobDataMap().put(SystemQuartzJobTb.JOB_KEY, quartzJob); // 重置启动时间 ((CronTriggerImpl) trigger).setStartTime(new Date()); @@ -75,24 +81,25 @@ public class QuartzManage { * * @param quartzJob / */ - public void updateJobCron(SystemQuartzJobVo quartzJob) { + public void updateJobCron(SystemQuartzJobTb quartzJob) { try { - TriggerKey triggerKey = TriggerKey.triggerKey(JOB_NAME + quartzJob.getId()); + SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(quartzJob, SystemQuartzJobVo.class); + TriggerKey triggerKey = TriggerKey.triggerKey(JOB_NAME + quartzJobVo.getId()); CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey); // 如果不存在则创建一个定时任务 if (trigger == null) { - addJob(quartzJob); + addJob(quartzJobVo); trigger = (CronTrigger) scheduler.getTrigger(triggerKey); } - CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(quartzJob.getCronExpression()); + CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(quartzJobVo.getCronExpression()); trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build(); // 重置启动时间 ((CronTriggerImpl) trigger).setStartTime(new Date()); - trigger.getJobDataMap().put(SystemQuartzJobTb.JOB_KEY, quartzJob); + trigger.getJobDataMap().put(SystemQuartzJobTb.JOB_KEY, quartzJobVo); scheduler.rescheduleJob(triggerKey, trigger); // 暂停任务 - if (quartzJob.getIsPause()) { - pauseJob(quartzJob); + if (quartzJobVo.getIsPause()) { + pauseJob(quartzJobVo); } } catch (Exception e) { log.error("更新定时任务失败", e); @@ -144,7 +151,8 @@ public class QuartzManage { */ public void runJobNow(SystemQuartzJobVo quartzJob) { try { - TriggerKey triggerKey = TriggerKey.triggerKey(JOB_NAME + quartzJob.getId()); + String uuid = JOB_NAME + quartzJob.getId(); + TriggerKey triggerKey = TriggerKey.triggerKey(uuid); CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey); // 如果不存在则创建一个定时任务 if (trigger == null) { @@ -152,7 +160,7 @@ public class QuartzManage { } JobDataMap dataMap = new JobDataMap(); dataMap.put(SystemQuartzJobTb.JOB_KEY, quartzJob); - JobKey jobKey = JobKey.jobKey(JOB_NAME + quartzJob.getId()); + JobKey jobKey = JobKey.jobKey(uuid); scheduler.triggerJob(jobKey, dataMap); } catch (Exception e) { log.error("定时任务执行失败", e); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java index 437bcc68..7cd58900 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemLocalStorageService.java @@ -156,6 +156,9 @@ public class SystemLocalStorageService { wrapper.orderByDesc(SystemLocalStorageTb::getId); } + /** + * 查询文件上传记录 -> TestPassed + */ public List queryLocalStorageByArgs(SystemQueryStorageArgs args) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); this.injectQueryParams(args, wrapper); @@ -163,7 +166,7 @@ public class SystemLocalStorageService { } /** - * 上传图片 + * 上传图片 -> TestPassed */ @Transactional(rollbackFor = Exception.class) public SystemLocalStorageTb uploadPicture(MultipartFile file) { @@ -176,12 +179,11 @@ public class SystemLocalStorageService { } /** - * 导出文件上传记录 + * 导出文件上传记录 -> TestPassed */ public void exportLocalStorageXlsx(HttpServletResponse response, SystemQueryStorageArgs args) { List systemLocalStorageTbs = this.queryLocalStorageByArgs(args); - List rowVos = - KitBeanUtil.copyToList(systemLocalStorageTbs, SystemLocalStorageExportRowVo.class); + List rowVos = KitBeanUtil.copyToList(systemLocalStorageTbs, SystemLocalStorageExportRowVo.class); KitExcelExporter.exportSimple(response, "文件上传记录数据", SystemLocalStorageExportRowVo.class, rowVos); } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java index f5bffc9e..6dc6dbb7 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemMonitorService.java @@ -75,7 +75,7 @@ public class SystemMonitorService { } /** - * 查询磁盘信息 + * 查询磁盘信息 -> TestPassed * * @return / */ @@ -109,7 +109,7 @@ public class SystemMonitorService { } /** - * 查询交换区信息 + * 查询交换区信息 -> TestPassed * * @param memory / * @return / @@ -131,7 +131,7 @@ public class SystemMonitorService { } /** - * 查询内存信息 + * 查询内存信息 -> TestPassed * * @param memory / * @return / @@ -147,7 +147,7 @@ public class SystemMonitorService { } /** - * 查询Cpu相关信息 + * 查询Cpu相关信息 -> TestPassed * * @param processor / * @return / @@ -194,7 +194,7 @@ public class SystemMonitorService { } /** - * 查询系统相关信息,系统、运行天数、系统IP + * 查询系统相关信息,系统、运行天数、系统IP -> TestPassed * * @param os / * @return / diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java index 1742dbe1..3b3b7481 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemOperationLogService.java @@ -18,7 +18,7 @@ public class SystemOperationLogService { private SystemOperationLogMapper systemOperationLogMapper; /** - * 查询用户操作日志 + * 查询用户操作日志 -> TestPassed */ public IPage searchUserLog(KitPageArgs pageArgs) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java index 89b1cf6d..d71d2cef 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java @@ -34,7 +34,6 @@ import cn.odboy.system.dal.mysql.SystemQuartzLogMapper; import cn.odboy.system.framework.quartz.QuartzManage; import cn.odboy.util.KitBeanUtil; import cn.odboy.util.KitPageUtil; -import cn.odboy.util.KitValidUtil; import cn.odboy.util.xlsx.KitExcelExporter; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -79,7 +78,7 @@ public class SystemQuartzJobService { * @param args / */ @Transactional(rollbackFor = Exception.class) - public void createJob(SystemQuartzJobVo args) { + public void createJob(SystemQuartzJobTb args) { if (args.getId() != null) { throw new BadRequestException("无效参数id"); } @@ -88,9 +87,9 @@ public class SystemQuartzJobService { if (!CronExpression.isValidExpression(args.getCronExpression())) { throw new BadRequestException("cron表达式格式错误"); } - SystemQuartzJobTb record = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class); - systemQuartzJobMapper.insert(record); - quartzManage.addJob(args); + systemQuartzJobMapper.insert(args); + SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(args, SystemQuartzJobVo.class); + quartzManage.addJob(quartzJobVo); } /** @@ -112,28 +111,27 @@ public class SystemQuartzJobService { } } SystemQuartzJobTb jobTb = KitBeanUtil.copyToClass(args, SystemQuartzJobTb.class); - systemQuartzJobMapper.insertOrUpdate(jobTb); - SystemQuartzJobVo jobVo = KitBeanUtil.copyToClass(args, SystemQuartzJobVo.class); - quartzManage.updateJobCron(jobVo); + systemQuartzJobMapper.updateById(jobTb); + quartzManage.updateJobCron(jobTb); } /** * 更改定时任务状态 * - * @param quartzJob / + * @param quartzJobVo / */ @Transactional(rollbackFor = Exception.class) - public void switchQuartzJobStatus(SystemQuartzJobVo quartzJob) { + public void switchQuartzJobStatus(SystemQuartzJobVo quartzJobVo) { // 置换暂停状态 - if (quartzJob.getIsPause()) { - quartzManage.resumeJob(quartzJob); - quartzJob.setIsPause(false); + if (quartzJobVo.getIsPause()) { + quartzManage.resumeJob(quartzJobVo); + quartzJobVo.setIsPause(false); } else { - quartzManage.pauseJob(quartzJob); - quartzJob.setIsPause(true); + quartzManage.pauseJob(quartzJobVo); + quartzJobVo.setIsPause(true); } - SystemQuartzJobTb quartzJobTb = KitBeanUtil.copyToClass(quartzJob, SystemQuartzJobTb.class); - systemQuartzJobMapper.insertOrUpdate(quartzJobTb); + SystemQuartzJobTb record = KitBeanUtil.copyToClass(quartzJobVo, SystemQuartzJobTb.class); + systemQuartzJobMapper.updateById(record); } /** @@ -172,16 +170,16 @@ public class SystemQuartzJobService { // 如果是手动清除子任务id, 会出现id为空字符串的问题 continue; } - SystemQuartzJobVo quartzJob = systemQuartzJobMapper.selectVoById(id); - if (quartzJob == null) { + SystemQuartzJobTb quartzJobTb = systemQuartzJobMapper.selectById(id); + if (quartzJobTb == null) { // 防止子任务不存在 continue; } + SystemQuartzJobVo quartzJobVo = KitBeanUtil.copyToClass(quartzJobTb, SystemQuartzJobVo.class); // 执行任务 String uuid = IdUtil.simpleUUID(); - quartzJob.setUuid(uuid); - // 执行任务 - startQuartzJob(quartzJob); + quartzJobVo.setUuid(uuid); + startQuartzJob(quartzJobVo); // 查询执行状态, 如果执行失败则停止后面的子任务执行 Boolean result = redisHelper.get(uuid, Boolean.class); while (result == null) { @@ -203,25 +201,23 @@ public class SystemQuartzJobService { * @param page 分页参数 * @return / */ - public KitPageResult searchQuartzJobByArgs(SystemQueryQuartzJobArgs args, - Page page) { + public KitPageResult searchQuartzJobByArgs(SystemQueryQuartzJobArgs args, Page page) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); this.injectQuartzJobQueryParams(args, wrapper); return KitPageUtil.toPage(systemQuartzJobMapper.selectPage(page, wrapper)); } - private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args, - LambdaQueryWrapper wrapper) { - KitValidUtil.notNull(args); - wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName, args.getJobName()); - if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { - wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper wrapper) { + if (args != null) { + wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzJobTb::getJobName, args.getJobName()); + if (CollUtil.isNotEmpty(args.getCreateTime()) && args.getCreateTime().size() >= 2) { + wrapper.between(SystemQuartzJobTb::getUpdateTime, args.getCreateTime().get(0), args.getCreateTime().get(1)); + } } wrapper.orderByDesc(SystemQuartzJobTb::getId); } - private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, - LambdaQueryWrapper wrapper) { + private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs args, LambdaQueryWrapper wrapper) { if (args != null) { wrapper.like(StrUtil.isNotBlank(args.getJobName()), SystemQuartzLogTb::getJobName, args.getJobName()); wrapper.eq(args.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, args.getIsSuccess()); @@ -271,16 +267,15 @@ public class SystemQuartzJobService { return systemQuartzLogMapper.selectList(wrapper); } - public SystemQuartzJobVo getQuartzJobById(Long id) { - return KitBeanUtil.copyToClass(systemQuartzJobMapper.selectById(id), SystemQuartzJobVo.class); - } - - public List listEnableQuartzJob() { + public List listEnableQuartzJob() { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SystemQuartzJobTb::getIsPause, 0); - return KitBeanUtil.copyToList(systemQuartzJobMapper.selectList(wrapper), SystemQuartzJobVo.class); + return systemQuartzJobMapper.selectList(wrapper); } + /** + * 导出定时任务数据 -> TestPassed + */ public void exportQuartzJobXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) { List systemQuartzJobTbs = this.queryQuartzJobByArgs(args); List rowVos = new ArrayList<>(); @@ -299,6 +294,9 @@ public class SystemQuartzJobService { KitExcelExporter.exportSimple(response, "定时任务数据", SystemQuartzJobExportRowVo.class, rowVos); } + /** + * 导出定时任务日志数据 -> TestPassed + */ public void exportQuartzLogXlsx(HttpServletResponse response, SystemQueryQuartzJobArgs args) { List systemQuartzLogTbs = this.queryQuartzLogByArgs(args); List rowVos = new ArrayList<>(); @@ -317,4 +315,8 @@ public class SystemQuartzJobService { } KitExcelExporter.exportSimple(response, "定时任务日志数据", SystemQuartzLogExportRowVo.class, rowVos); } + + public SystemQuartzJobTb getQuartzJobById(Long id) { + return systemQuartzJobMapper.selectById(id); + } } From 0c57ef3d845a08c79fc01fa43ed538f5f9b5841b Mon Sep 17 00:00:00 2001 From: Odboy Date: Wed, 14 Jan 2026 23:27:03 +0800 Subject: [PATCH 10/14] =?UTF-8?q?fix(quartz):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1=E5=8F=82=E6=95=B0=E4=BC=A0?= =?UTF-8?q?=E9=80=92=E5=92=8C=E6=96=87=E6=A1=A3=E6=B3=A8=E9=87=8A=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 QuartzRunnable 中空字符串参数改为 null 值传递 - 为 SystemQuartzJobService 中的方法添加 TestPassed 标记注释 - 添加查询启用定时任务和根据ID查询定时任务的新方法 - 修复前端用户中心页面请求耗时显示的空值问题 - 在定时任务界面添加 Cron 表达式在线生成链接 - 统一后端服务层中查询方法的注释描述用词 --- .../src/views/system/quartzJob/index.vue | 1 + .../src/views/system/user/center.vue | 4 +-- .../framework/quartz/core/QuartzRunnable.java | 2 +- .../service/SystemQuartzJobService.java | 29 +++++++++++-------- .../system/service/SystemUserJobService.java | 2 +- .../system/service/SystemUserRoleService.java | 4 +-- .../framework/quartz/core/QuartzRunnable.java | 2 +- .../service/SystemQuartzJobService.java | 29 +++++++++++-------- .../system/service/SystemUserJobService.java | 2 +- .../system/service/SystemUserRoleService.java | 4 +-- 10 files changed, 45 insertions(+), 34 deletions(-) diff --git a/cutejava-front/src/views/system/quartzJob/index.vue b/cutejava-front/src/views/system/quartzJob/index.vue index 5881f689..6c38fdbc 100644 --- a/cutejava-front/src/views/system/quartzJob/index.vue +++ b/cutejava-front/src/views/system/quartzJob/index.vue @@ -28,6 +28,7 @@ >日志 + Cron在线表达式生成 diff --git a/cutejava-front/src/views/system/user/center.vue b/cutejava-front/src/views/system/user/center.vue index bf16d427..dabee521 100644 --- a/cutejava-front/src/views/system/user/center.vue +++ b/cutejava-front/src/views/system/user/center.vue @@ -105,8 +105,8 @@ { if (StringUtils.isNotBlank(params)) { return method.invoke(target, params); } else { - return method.invoke(target, ""); + return method.invoke(target, null); } } } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java index 237ef652..d460616e 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java @@ -73,7 +73,7 @@ public class SystemQuartzJobService { } /** - * 创建 + * 创建 -> TestPassed * * @param args / */ @@ -93,7 +93,7 @@ public class SystemQuartzJobService { } /** - * 修改任务并重新调度 + * 修改任务并重新调度 -> TestPassed * * @param args / */ @@ -116,7 +116,7 @@ public class SystemQuartzJobService { } /** - * 更改定时任务状态 + * 更改定时任务状态 -> TestPassed * * @param quartzJobVo / */ @@ -135,7 +135,7 @@ public class SystemQuartzJobService { } /** - * 立即执行定时任务 + * 立即执行定时任务 -> TestPassed * * @param quartzJob / */ @@ -144,7 +144,7 @@ public class SystemQuartzJobService { } /** - * 删除任务 + * 删除任务 -> TestPassed * * @param ids / */ @@ -158,7 +158,7 @@ public class SystemQuartzJobService { } /** - * 执行子任务 + * 执行子任务 -> TestPassed * * @param tasks / * @throws InterruptedException / @@ -195,7 +195,7 @@ public class SystemQuartzJobService { } /** - * 分页查询 + * 分页查询 -> TestPassed * * @param args 条件 * @param page 分页参数 @@ -230,21 +230,20 @@ public class SystemQuartzJobService { } /** - * 分页查询日志 + * 分页查询日志 -> TestPassed * * @param args 条件 * @param page 分页参数 * @return / */ - public KitPageResult searchQuartzLogByArgs(SystemQueryQuartzJobArgs args, - Page page) { + public KitPageResult searchQuartzLogByArgs(SystemQueryQuartzJobArgs args, Page page) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); this.injectQuartzLogQueryParams(args, wrapper); return KitPageUtil.toPage(systemQuartzLogMapper.selectPage(page, wrapper)); } /** - * 查询全部 + * 查询全部 -> TestPassed * * @param args 条件 * @return / @@ -256,7 +255,7 @@ public class SystemQuartzJobService { } /** - * 查询全部 + * 查询全部 -> TestPassed * * @param args 条件 * @return / @@ -267,6 +266,9 @@ public class SystemQuartzJobService { return systemQuartzLogMapper.selectList(wrapper); } + /** + * 查询启用的定时任务 -> TestPassed + */ public List listEnableQuartzJob() { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SystemQuartzJobTb::getIsPause, 0); @@ -316,6 +318,9 @@ public class SystemQuartzJobService { KitExcelExporter.exportSimple(response, "定时任务日志数据", SystemQuartzLogExportRowVo.class, rowVos); } + /** + * 根据任务id查询定时任务 -> TestPassed + */ public SystemQuartzJobTb getQuartzJobById(Long id) { return systemQuartzJobMapper.selectById(id); } diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java index b7966eef..3dde0bbe 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java @@ -78,7 +78,7 @@ public class SystemUserJobService { } /** - * 根据用户id列举岗位 -> TestPassed + * 根据用户id查询岗位 -> TestPassed * * @param userId / * @return / diff --git a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java index d882fbea..769c21c1 100644 --- a/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java +++ b/cutejava-springboot3/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java @@ -158,7 +158,7 @@ public class SystemUserRoleService { } /** - * 根据用户id列举角色 -> TestPassed + * 根据用户id查询角色 -> TestPassed * * @param userId / * @return / @@ -168,7 +168,7 @@ public class SystemUserRoleService { } /** - * 根据用户id列举角色级别 -> TestPassed + * 根据用户id查询角色级别 -> TestPassed * * @param userId / * @return / diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/quartz/core/QuartzRunnable.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/quartz/core/QuartzRunnable.java index 109284ef..0f6ddedf 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/quartz/core/QuartzRunnable.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/quartz/core/QuartzRunnable.java @@ -49,7 +49,7 @@ public class QuartzRunnable implements Callable { if (StringUtils.isNotBlank(params)) { return method.invoke(target, params); } else { - return method.invoke(target, ""); + return method.invoke(target, null); } } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java index d71d2cef..c1b68465 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemQuartzJobService.java @@ -73,7 +73,7 @@ public class SystemQuartzJobService { } /** - * 创建 + * 创建 -> TestPassed * * @param args / */ @@ -93,7 +93,7 @@ public class SystemQuartzJobService { } /** - * 修改任务并重新调度 + * 修改任务并重新调度 -> TestPassed * * @param args / */ @@ -116,7 +116,7 @@ public class SystemQuartzJobService { } /** - * 更改定时任务状态 + * 更改定时任务状态 -> TestPassed * * @param quartzJobVo / */ @@ -135,7 +135,7 @@ public class SystemQuartzJobService { } /** - * 立即执行定时任务 + * 立即执行定时任务 -> TestPassed * * @param quartzJob / */ @@ -144,7 +144,7 @@ public class SystemQuartzJobService { } /** - * 删除任务 + * 删除任务 -> TestPassed * * @param ids / */ @@ -158,7 +158,7 @@ public class SystemQuartzJobService { } /** - * 执行子任务 + * 执行子任务 -> TestPassed * * @param tasks / * @throws InterruptedException / @@ -195,7 +195,7 @@ public class SystemQuartzJobService { } /** - * 分页查询 + * 分页查询 -> TestPassed * * @param args 条件 * @param page 分页参数 @@ -230,21 +230,20 @@ public class SystemQuartzJobService { } /** - * 分页查询日志 + * 分页查询日志 -> TestPassed * * @param args 条件 * @param page 分页参数 * @return / */ - public KitPageResult searchQuartzLogByArgs(SystemQueryQuartzJobArgs args, - Page page) { + public KitPageResult searchQuartzLogByArgs(SystemQueryQuartzJobArgs args, Page page) { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); this.injectQuartzLogQueryParams(args, wrapper); return KitPageUtil.toPage(systemQuartzLogMapper.selectPage(page, wrapper)); } /** - * 查询全部 + * 查询全部 -> TestPassed * * @param args 条件 * @return / @@ -256,7 +255,7 @@ public class SystemQuartzJobService { } /** - * 查询全部 + * 查询全部 -> TestPassed * * @param args 条件 * @return / @@ -267,6 +266,9 @@ public class SystemQuartzJobService { return systemQuartzLogMapper.selectList(wrapper); } + /** + * 查询启用的定时任务 -> TestPassed + */ public List listEnableQuartzJob() { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(SystemQuartzJobTb::getIsPause, 0); @@ -316,6 +318,9 @@ public class SystemQuartzJobService { KitExcelExporter.exportSimple(response, "定时任务日志数据", SystemQuartzLogExportRowVo.class, rowVos); } + /** + * 根据任务id查询定时任务 -> TestPassed + */ public SystemQuartzJobTb getQuartzJobById(Long id) { return systemQuartzJobMapper.selectById(id); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java index b7966eef..3dde0bbe 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java @@ -78,7 +78,7 @@ public class SystemUserJobService { } /** - * 根据用户id列举岗位 -> TestPassed + * 根据用户id查询岗位 -> TestPassed * * @param userId / * @return / diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java index d882fbea..769c21c1 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java @@ -158,7 +158,7 @@ public class SystemUserRoleService { } /** - * 根据用户id列举角色 -> TestPassed + * 根据用户id查询角色 -> TestPassed * * @param userId / * @return / @@ -168,7 +168,7 @@ public class SystemUserRoleService { } /** - * 根据用户id列举角色级别 -> TestPassed + * 根据用户id查询角色级别 -> TestPassed * * @param userId / * @return / From ff723a6044d3d970bd4687aafb73667303e479f6 Mon Sep 17 00:00:00 2001 From: Odboy Date: Wed, 14 Jan 2026 23:29:31 +0800 Subject: [PATCH 11/14] =?UTF-8?q?chore(framework):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=89=88=E6=9D=83=E5=B9=B4=E4=BB=BD=E8=87=B32026=E5=B9=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cn/odboy/annotation/AnonymousAccess.java | 2 +- .../annotation/AnonymousDeleteMapping.java | 2 +- .../odboy/annotation/AnonymousGetMapping.java | 2 +- .../annotation/AnonymousPatchMapping.java | 2 +- .../annotation/AnonymousPostMapping.java | 2 +- .../odboy/annotation/AnonymousPutMapping.java | 2 +- .../src/main/java/cn/odboy/base/KitArgs.java | 2 +- .../cn/odboy/base/KitBaseCreateTimeTb.java | 2 +- .../java/cn/odboy/base/KitBaseTimeTb.java | 2 +- .../cn/odboy/base/KitBaseUpdateTimeTb.java | 2 +- .../odboy/base/KitBaseUserCreateTimeTb.java | 2 +- .../cn/odboy/base/KitBaseUserTimeLogicTb.java | 2 +- .../java/cn/odboy/base/KitBaseUserTimeTb.java | 2 +- .../main/java/cn/odboy/base/KitObject.java | 2 +- .../main/java/cn/odboy/base/KitPageArgs.java | 2 +- .../java/cn/odboy/base/KitPageResult.java | 2 +- .../java/cn/odboy/base/KitSelectOptionVo.java | 2 +- .../cn/odboy/constant/CaptchaCodeEnum.java | 2 +- .../java/cn/odboy/constant/FileTypeEnum.java | 2 +- .../cn/odboy/constant/RequestMethodEnum.java | 2 +- .../java/cn/odboy/constant/SystemConst.java | 2 +- .../context/BeanLoadFinishListener.java | 4 +- .../framework/context/BootApplication.java | 4 +- .../framework/context/KitRequestHolder.java | 2 +- .../framework/context/KitScriptHelper.java | 2 +- .../context/KitSpringBeanHolder.java | 2 +- .../exception/BadRequestException.java | 2 +- .../framework/exception/ServerException.java | 2 +- .../framework/exception/handler/ApiError.java | 2 +- .../handler/GlobalExceptionHandler.java | 2 +- .../logging/ExecutionTimeStatisticsFace.java | 2 +- .../ExecutionTimeStatisticsFaceAspect.java | 2 +- .../controller/HealthCheckController.java | 2 +- .../service/KitHealthCheckPointService.java | 2 +- .../mybatisplus/config/DataTypeEnum.java | 2 +- .../mybatisplus/config/KitMpQTypeEnum.java | 2 +- .../mybatisplus/config/KitMpQuery.java | 2 +- .../config/MpCustomP6SpyLogger.java | 4 +- .../config/MpInsertBatchSqlInjector.java | 4 +- .../mybatisplus/config/MybatisPlusConfig.java | 2 +- .../config/RemoveDruidAdConfig.java | 2 +- .../mybatisplus/core/KitMpAnyQUtil.java | 2 +- .../mybatisplus/core/KitMpCmdGenUtil.java | 4 +- .../mybatisplus/core/KitMpQUtil.java | 2 +- .../core/interfaces/KitMpMapper.java | 2 +- .../core/interfaces/KitMpService.java | 2 +- .../core/interfaces/KitMpServiceImpl.java | 2 +- .../framework/properties/AppProperties.java | 2 +- .../properties/model/CaptchaModel.java | 2 +- .../model/ContentRsaEncodeSettingModel.java | 2 +- .../properties/model/JwtAuthSettingModel.java | 2 +- .../properties/model/OSSConfigModel.java | 2 +- .../properties/model/StorageOSSModel.java | 2 +- .../model/ThreadPoolSettingModel.java | 2 +- .../model/UserLoginCaptchaSettingModel.java | 2 +- .../model/UserLoginSettingModel.java | 2 +- .../framework/quartz/config/QuartzConfig.java | 2 +- .../framework/quartz/core/QuartzRunnable.java | 2 +- .../odboy/framework/redis/KitRedisHelper.java | 2 +- .../framework/redis/RedisConfiguration.java | 4 +- .../server/config/AsyncTheadPoolConfig.java | 2 +- .../DateStringArraysToListDateConverter.java | 2 +- .../converters/DateStringToDateConverter.java | 2 +- .../server/core/ConfigurerAdapter.java | 2 +- .../server/core/KitFileLocalUploadHelper.java | 2 +- .../config/UndertowWebSocketConfig.java | 17 +++++++- .../config/WebSocketEndpointConfig.java | 2 +- .../websocket/context/KitWsClientManager.java | 2 +- .../websocket/context/KitWsMessage.java | 2 +- .../websocket/context/KitWsServer.java | 2 +- .../framework/websocket/model/WsSidVo.java | 2 +- .../websocket/util/WsMessageUtil.java | 2 +- .../java/cn/odboy/util/KitAnonTagUtil.java | 2 +- .../cn/odboy/util/KitBase64SecretUtil.java | 2 +- .../main/java/cn/odboy/util/KitBeanUtil.java | 15 +++++++ .../java/cn/odboy/util/KitBigDecimalUtil.java | 2 +- .../java/cn/odboy/util/KitBrowserUtil.java | 2 +- .../main/java/cn/odboy/util/KitClassUtil.java | 2 +- .../main/java/cn/odboy/util/KitCloseUtil.java | 2 +- .../main/java/cn/odboy/util/KitCollUtil.java | 2 +- .../main/java/cn/odboy/util/KitDateUtil.java | 2 +- .../java/cn/odboy/util/KitDesEncryptUtil.java | 2 +- .../cn/odboy/util/KitDistributedIdUtil.java | 2 +- .../main/java/cn/odboy/util/KitFileUtil.java | 2 +- .../main/java/cn/odboy/util/KitIPUtil.java | 2 +- .../main/java/cn/odboy/util/KitJsonUtil.java | 2 +- .../main/java/cn/odboy/util/KitListUtil.java | 2 +- .../java/cn/odboy/util/KitLogFmtUtil.java | 2 +- .../main/java/cn/odboy/util/KitPageUtil.java | 2 +- .../odboy/util/KitResourceTemplateUtil.java | 2 +- .../odboy/util/KitReturnValueHandleUtil.java | 2 +- .../java/cn/odboy/util/KitRsaEncryptUtil.java | 2 +- .../java/cn/odboy/util/KitStringUtil.java | 2 +- .../java/cn/odboy/util/KitSystemUtil.java | 2 +- .../main/java/cn/odboy/util/KitValidUtil.java | 4 +- .../system/constant/SystemCaptchaBizEnum.java | 2 +- .../system/constant/SystemDataScopeEnum.java | 2 +- .../constant/SystemTransferProtocolConst.java | 2 +- .../system/constant/SystemYesOrNoChConst.java | 15 +++++++ .../odboy/system/constant/SystemZhConst.java | 15 +++++++ .../controller/SystemAuthController.java | 2 +- .../controller/SystemCaptchaController.java | 2 +- .../controller/SystemComponentController.java | 2 +- .../controller/SystemDeptController.java | 2 +- .../controller/SystemDictController.java | 2 +- .../SystemDictDetailController.java | 2 +- .../controller/SystemEmailController.java | 2 +- .../controller/SystemJobController.java | 2 +- .../SystemLocalStorageController.java | 2 +- .../controller/SystemMenuController.java | 2 +- .../controller/SystemMonitorController.java | 2 +- .../controller/SystemOnlineController.java | 2 +- .../SystemOperationLogController.java | 15 +++++++ .../SystemOssStorageController.java | 2 +- .../controller/SystemQuartzJobController.java | 2 +- .../controller/SystemRoleController.java | 2 +- .../controller/SystemUserController.java | 2 +- .../system/dal/dataobject/SystemDeptTb.java | 2 +- .../dal/dataobject/SystemDictDetailTb.java | 2 +- .../system/dal/dataobject/SystemDictTb.java | 2 +- .../dal/dataobject/SystemEmailConfigTb.java | 2 +- .../system/dal/dataobject/SystemJobTb.java | 2 +- .../dal/dataobject/SystemLocalStorageTb.java | 2 +- .../system/dal/dataobject/SystemMenuTb.java | 2 +- .../dal/dataobject/SystemOperationLogTb.java | 2 +- .../dal/dataobject/SystemOssStorageTb.java | 2 +- .../dal/dataobject/SystemQuartzJobTb.java | 2 +- .../dal/dataobject/SystemQuartzLogTb.java | 2 +- .../dal/dataobject/SystemRoleDeptTb.java | 4 +- .../dal/dataobject/SystemRoleMenuTb.java | 15 +++++++ .../system/dal/dataobject/SystemRoleTb.java | 2 +- .../dal/dataobject/SystemUserJobTb.java | 15 +++++++ .../dal/dataobject/SystemUserRoleTb.java | 4 +- .../system/dal/dataobject/SystemUserTb.java | 2 +- .../model/export/SystemDeptExportRowVo.java | 15 +++++++ .../model/export/SystemDictExportRowVo.java | 15 +++++++ .../model/export/SystemJobExportRowVo.java | 15 +++++++ .../export/SystemLocalStorageExportRowVo.java | 15 +++++++ .../model/export/SystemMenuExportRowVo.java | 15 +++++++ .../export/SystemOssStorageExportRowVo.java | 15 +++++++ .../export/SystemQuartzJobExportRowVo.java | 15 +++++++ .../export/SystemQuartzLogExportRowVo.java | 15 +++++++ .../model/export/SystemRoleExportRowVo.java | 15 +++++++ .../model/export/SystemUserExportRowVo.java | 15 +++++++ .../export/SystemUserOnlineExportRowVo.java | 17 +++++++- .../request/SystemCheckEmailCaptchaArgs.java | 2 +- .../model/request/SystemCreateDeptArgs.java | 2 +- .../model/request/SystemCreateDictArgs.java | 2 +- .../request/SystemCreateDictDetailArgs.java | 2 +- .../model/request/SystemCreateJobArgs.java | 2 +- .../model/request/SystemCreateRoleArgs.java | 2 +- .../model/request/SystemQueryDeptArgs.java | 2 +- .../model/request/SystemQueryDictArgs.java | 2 +- .../request/SystemQueryDictDetailArgs.java | 4 +- .../dal/model/request/SystemQueryJobArgs.java | 2 +- .../model/request/SystemQueryMenuArgs.java | 2 +- .../request/SystemQueryOperationLogArgs.java | 15 +++++++ .../request/SystemQueryQuartzJobArgs.java | 2 +- .../model/request/SystemQueryRoleArgs.java | 2 +- .../model/request/SystemQueryStorageArgs.java | 2 +- .../model/request/SystemQueryUserArgs.java | 2 +- .../model/request/SystemSendEmailArgs.java | 2 +- .../request/SystemUpdateQuartzJobArgs.java | 2 +- .../request/SystemUpdateUserPasswordArgs.java | 2 +- .../model/request/SystemUserLoginArgs.java | 2 +- .../dal/model/response/SystemAuthVo.java | 15 +++++++ .../dal/model/response/SystemCaptchaVo.java | 15 +++++++ .../dal/model/response/SystemDeptVo.java | 15 +++++++ .../model/response/SystemDictDetailVo.java | 4 +- .../dal/model/response/SystemMenuMetaVo.java | 2 +- .../model/response/SystemMenuRouterVo.java | 2 +- .../dal/model/response/SystemMenuVo.java | 15 +++++++ .../model/response/SystemOssStorageVo.java | 2 +- .../response/SystemProductLineTreeVo.java | 2 +- .../model/response/SystemProductLineVo.java | 2 +- .../dal/model/response/SystemQuartzJobVo.java | 15 +++++++ .../dal/model/response/SystemRoleCodeVo.java | 2 +- .../dal/model/response/SystemRoleVo.java | 15 +++++++ .../model/response/SystemSimpleUserVo.java | 4 +- .../dal/model/response/SystemUserInfoVo.java | 2 +- .../dal/model/response/SystemUserJwtVo.java | 2 +- .../model/response/SystemUserOnlineVo.java | 2 +- .../dal/model/response/SystemUserVo.java | 15 +++++++ .../system/dal/mysql/SystemDeptMapper.java | 2 +- .../dal/mysql/SystemDictDetailMapper.java | 2 +- .../system/dal/mysql/SystemDictMapper.java | 2 +- .../dal/mysql/SystemEmailConfigMapper.java | 2 +- .../system/dal/mysql/SystemJobMapper.java | 2 +- .../dal/mysql/SystemLocalStorageMapper.java | 2 +- .../system/dal/mysql/SystemMenuMapper.java | 2 +- .../dal/mysql/SystemOperationLogMapper.java | 2 +- .../dal/mysql/SystemOssStorageMapper.java | 2 +- .../dal/mysql/SystemQuartzJobMapper.java | 2 +- .../dal/mysql/SystemQuartzLogMapper.java | 2 +- .../dal/mysql/SystemRoleDeptMapper.java | 2 +- .../system/dal/mysql/SystemRoleMapper.java | 2 +- .../dal/mysql/SystemRoleMenuMapper.java | 2 +- .../system/dal/mysql/SystemUserJobMapper.java | 2 +- .../system/dal/mysql/SystemUserMapper.java | 2 +- .../dal/mysql/SystemUserRoleMapper.java | 2 +- .../system/dal/redis/SystemCacheKey.java | 42 +------------------ .../system/dal/redis/SystemRedisKey.java | 15 +++++++ .../system/dal/redis/SystemUserInfoDAO.java | 15 +++++++ .../dal/redis/SystemUserOnlineInfoDAO.java | 15 +++++++ .../system/framework/bizlock/BizLock.java | 2 +- .../framework/bizlock/BizLockAspect.java | 4 +- .../mybatisplus/MpMetaObjectHandler.java | 2 +- .../framework/operalog/OperationLog.java | 2 +- .../operalog/OperationLogAspect.java | 2 +- .../permission/config/AuthorityConfig.java | 2 +- .../config/SpringSecurityConfig.java | 4 +- .../permission/config/TokenConfigurer.java | 2 +- .../permission/core/KitSecurityHelper.java | 2 +- .../core/handler/JwtAccessDeniedHandler.java | 2 +- .../handler/JwtAuthenticationEntryPoint.java | 2 +- .../permission/core/handler/TokenFilter.java | 2 +- .../core/handler/TokenProvider.java | 2 +- .../core/handler/UserDetailsHandler.java | 2 +- .../framework/quartz/ActiveJobRegister.java | 2 +- .../framework/quartz/ExecutionJobBean.java | 2 +- .../system/framework/quartz/QuartzManage.java | 2 +- .../storage/OssStorageConfiguration.java | 2 +- .../storage/local/MultipartConfig.java | 4 +- .../storage/minio/MinioRepository.java | 2 +- .../java/cn/odboy/system/job/TestTask.java | 2 +- .../system/openapi/OpenCaptchaController.java | 2 +- .../system/service/SystemAuthService.java | 20 +++++++++ .../system/service/SystemCaptchaService.java | 15 +++++++ .../system/service/SystemDataService.java | 2 +- .../system/service/SystemDeptService.java | 2 +- .../service/SystemDictDetailService.java | 2 +- .../system/service/SystemDictService.java | 2 +- .../system/service/SystemEmailService.java | 2 +- .../system/service/SystemJobService.java | 2 +- .../service/SystemLocalStorageService.java | 2 +- .../system/service/SystemMenuService.java | 2 +- .../system/service/SystemMonitorService.java | 2 +- .../service/SystemOperationLogService.java | 15 +++++++ .../service/SystemOssStorageService.java | 2 +- .../service/SystemQuartzJobService.java | 2 +- .../system/service/SystemRoleDeptService.java | 24 +++++++---- .../system/service/SystemRoleMenuService.java | 2 +- .../system/service/SystemRoleService.java | 2 +- .../system/service/SystemUserDeptService.java | 15 +++++++ .../system/service/SystemUserJobService.java | 2 +- .../system/service/SystemUserRoleService.java | 2 +- .../system/service/SystemUserService.java | 2 +- .../impl/SystemMinioStorageServiceImpl.java | 2 +- .../java/cn/odboy/system/util/KitSqlUtil.java | 2 +- .../src/main/java/cn/odboy/AppRun.java | 2 +- .../src/main/java/cn/odboy/GenCode.java | 2 +- .../java/cn/odboy/HealthCheckPointer.java | 2 +- .../java/cn/odboy/MyBatisMapperTests.java | 2 +- .../java/cn/odboy/SystemApplicationTests.java | 2 +- .../cn/odboy/util/KitDesEncryptUtilTest.java | 2 +- .../java/cn/odboy/util/KitFileUtilTest.java | 2 +- .../java/cn/odboy/util/KitStringUtilTest.java | 2 +- .../java/cn/odboy/util/WorkTimeTests.java | 2 +- .../cn/odboy/annotation/AnonymousAccess.java | 2 +- .../annotation/AnonymousDeleteMapping.java | 2 +- .../odboy/annotation/AnonymousGetMapping.java | 2 +- .../annotation/AnonymousPatchMapping.java | 2 +- .../annotation/AnonymousPostMapping.java | 2 +- .../odboy/annotation/AnonymousPutMapping.java | 2 +- .../src/main/java/cn/odboy/base/KitArgs.java | 2 +- .../cn/odboy/base/KitBaseCreateTimeTb.java | 2 +- .../java/cn/odboy/base/KitBaseTimeTb.java | 2 +- .../cn/odboy/base/KitBaseUpdateTimeTb.java | 2 +- .../odboy/base/KitBaseUserCreateTimeTb.java | 2 +- .../cn/odboy/base/KitBaseUserTimeLogicTb.java | 2 +- .../java/cn/odboy/base/KitBaseUserTimeTb.java | 2 +- .../main/java/cn/odboy/base/KitObject.java | 2 +- .../main/java/cn/odboy/base/KitPageArgs.java | 2 +- .../java/cn/odboy/base/KitPageResult.java | 2 +- .../java/cn/odboy/base/KitSelectOptionVo.java | 2 +- .../cn/odboy/constant/CaptchaCodeEnum.java | 2 +- .../java/cn/odboy/constant/FileTypeEnum.java | 2 +- .../cn/odboy/constant/RequestMethodEnum.java | 2 +- .../java/cn/odboy/constant/SystemConst.java | 2 +- .../context/BeanLoadFinishListener.java | 4 +- .../framework/context/BootApplication.java | 4 +- .../framework/context/KitRequestHolder.java | 2 +- .../framework/context/KitScriptHelper.java | 2 +- .../context/KitSpringBeanHolder.java | 2 +- .../cn/odboy/framework/doc/SwaggerConfig.java | 2 +- .../exception/BadRequestException.java | 2 +- .../framework/exception/ServerException.java | 2 +- .../framework/exception/handler/ApiError.java | 2 +- .../handler/GlobalExceptionHandler.java | 2 +- .../logging/ExecutionTimeStatisticsFace.java | 2 +- .../ExecutionTimeStatisticsFaceAspect.java | 2 +- .../controller/HealthCheckController.java | 2 +- .../service/KitHealthCheckPointService.java | 2 +- .../mybatisplus/config/DataTypeEnum.java | 2 +- .../mybatisplus/config/KitMpQTypeEnum.java | 2 +- .../mybatisplus/config/KitMpQuery.java | 2 +- .../config/MpCustomP6SpyLogger.java | 4 +- .../config/MpInsertBatchSqlInjector.java | 4 +- .../mybatisplus/config/MybatisPlusConfig.java | 2 +- .../config/RemoveDruidAdConfig.java | 2 +- .../mybatisplus/core/KitMpAnyQUtil.java | 2 +- .../mybatisplus/core/KitMpCmdGenUtil.java | 4 +- .../mybatisplus/core/KitMpQUtil.java | 2 +- .../core/interfaces/KitMpMapper.java | 2 +- .../core/interfaces/KitMpService.java | 2 +- .../core/interfaces/KitMpServiceImpl.java | 2 +- .../framework/properties/AppProperties.java | 2 +- .../properties/model/CaptchaModel.java | 2 +- .../model/ContentRsaEncodeSettingModel.java | 2 +- .../properties/model/JwtAuthSettingModel.java | 2 +- .../properties/model/OSSConfigModel.java | 2 +- .../properties/model/StorageOSSModel.java | 2 +- .../model/SwaggerApiDocSettingModel.java | 2 +- .../model/ThreadPoolSettingModel.java | 2 +- .../model/UserLoginCaptchaSettingModel.java | 2 +- .../model/UserLoginSettingModel.java | 2 +- .../framework/quartz/config/QuartzConfig.java | 2 +- .../framework/quartz/core/QuartzRunnable.java | 2 +- .../odboy/framework/redis/KitRedisHelper.java | 2 +- .../framework/redis/RedisConfiguration.java | 4 +- .../server/config/AsyncTheadPoolConfig.java | 2 +- .../DateStringArraysToListDateConverter.java | 2 +- .../converters/DateStringToDateConverter.java | 2 +- .../server/core/ConfigurerAdapter.java | 2 +- .../server/core/KitFileLocalUploadHelper.java | 2 +- .../config/UndertowWebSocketConfig.java | 17 +++++++- .../config/WebSocketEndpointConfig.java | 2 +- .../websocket/context/KitWsClientManager.java | 2 +- .../websocket/context/KitWsMessage.java | 2 +- .../websocket/context/KitWsServer.java | 2 +- .../framework/websocket/model/WsSidVo.java | 2 +- .../websocket/util/WsMessageUtil.java | 2 +- .../java/cn/odboy/util/KitAnonTagUtil.java | 2 +- .../cn/odboy/util/KitBase64SecretUtil.java | 2 +- .../main/java/cn/odboy/util/KitBeanUtil.java | 15 +++++++ .../java/cn/odboy/util/KitBigDecimalUtil.java | 2 +- .../java/cn/odboy/util/KitBrowserUtil.java | 2 +- .../main/java/cn/odboy/util/KitClassUtil.java | 2 +- .../main/java/cn/odboy/util/KitCloseUtil.java | 2 +- .../main/java/cn/odboy/util/KitCollUtil.java | 2 +- .../main/java/cn/odboy/util/KitDateUtil.java | 2 +- .../java/cn/odboy/util/KitDesEncryptUtil.java | 2 +- .../cn/odboy/util/KitDistributedIdUtil.java | 2 +- .../main/java/cn/odboy/util/KitFileUtil.java | 2 +- .../main/java/cn/odboy/util/KitIPUtil.java | 2 +- .../main/java/cn/odboy/util/KitJsonUtil.java | 2 +- .../main/java/cn/odboy/util/KitListUtil.java | 2 +- .../java/cn/odboy/util/KitLogFmtUtil.java | 2 +- .../main/java/cn/odboy/util/KitPageUtil.java | 2 +- .../odboy/util/KitResourceTemplateUtil.java | 2 +- .../odboy/util/KitReturnValueHandleUtil.java | 2 +- .../java/cn/odboy/util/KitRsaEncryptUtil.java | 2 +- .../java/cn/odboy/util/KitStringUtil.java | 2 +- .../java/cn/odboy/util/KitSystemUtil.java | 2 +- .../main/java/cn/odboy/util/KitValidUtil.java | 4 +- .../system/constant/SystemCaptchaBizEnum.java | 2 +- .../system/constant/SystemDataScopeEnum.java | 2 +- .../constant/SystemTransferProtocolConst.java | 2 +- .../system/constant/SystemYesOrNoChConst.java | 15 +++++++ .../odboy/system/constant/SystemZhConst.java | 15 +++++++ .../controller/SystemAuthController.java | 2 +- .../controller/SystemCaptchaController.java | 2 +- .../controller/SystemComponentController.java | 2 +- .../controller/SystemDeptController.java | 2 +- .../controller/SystemDictController.java | 2 +- .../SystemDictDetailController.java | 2 +- .../controller/SystemEmailController.java | 2 +- .../controller/SystemJobController.java | 2 +- .../SystemLocalStorageController.java | 2 +- .../controller/SystemMenuController.java | 2 +- .../controller/SystemMonitorController.java | 2 +- .../controller/SystemOnlineController.java | 2 +- .../SystemOperationLogController.java | 15 +++++++ .../SystemOssStorageController.java | 2 +- .../controller/SystemQuartzJobController.java | 2 +- .../controller/SystemRoleController.java | 2 +- .../controller/SystemUserController.java | 2 +- .../system/dal/dataobject/SystemDeptTb.java | 4 +- .../dal/dataobject/SystemDictDetailTb.java | 4 +- .../system/dal/dataobject/SystemDictTb.java | 4 +- .../dal/dataobject/SystemEmailConfigTb.java | 2 +- .../system/dal/dataobject/SystemJobTb.java | 4 +- .../dal/dataobject/SystemLocalStorageTb.java | 2 +- .../system/dal/dataobject/SystemMenuTb.java | 2 +- .../dal/dataobject/SystemOperationLogTb.java | 2 +- .../dal/dataobject/SystemOssStorageTb.java | 2 +- .../dal/dataobject/SystemQuartzJobTb.java | 4 +- .../dal/dataobject/SystemQuartzLogTb.java | 2 +- .../dal/dataobject/SystemRoleDeptTb.java | 4 +- .../dal/dataobject/SystemRoleMenuTb.java | 15 +++++++ .../system/dal/dataobject/SystemRoleTb.java | 2 +- .../dal/dataobject/SystemUserJobTb.java | 15 +++++++ .../dal/dataobject/SystemUserRoleTb.java | 4 +- .../system/dal/dataobject/SystemUserTb.java | 4 +- .../model/export/SystemDeptExportRowVo.java | 15 +++++++ .../model/export/SystemDictExportRowVo.java | 15 +++++++ .../model/export/SystemJobExportRowVo.java | 15 +++++++ .../export/SystemLocalStorageExportRowVo.java | 15 +++++++ .../model/export/SystemMenuExportRowVo.java | 15 +++++++ .../export/SystemOssStorageExportRowVo.java | 15 +++++++ .../export/SystemQuartzJobExportRowVo.java | 15 +++++++ .../export/SystemQuartzLogExportRowVo.java | 15 +++++++ .../model/export/SystemRoleExportRowVo.java | 15 +++++++ .../model/export/SystemUserExportRowVo.java | 15 +++++++ .../export/SystemUserOnlineExportRowVo.java | 17 +++++++- .../request/SystemCheckEmailCaptchaArgs.java | 2 +- .../model/request/SystemCreateDeptArgs.java | 2 +- .../model/request/SystemCreateDictArgs.java | 2 +- .../request/SystemCreateDictDetailArgs.java | 2 +- .../model/request/SystemCreateJobArgs.java | 2 +- .../model/request/SystemCreateRoleArgs.java | 2 +- .../model/request/SystemQueryDeptArgs.java | 2 +- .../model/request/SystemQueryDictArgs.java | 2 +- .../request/SystemQueryDictDetailArgs.java | 4 +- .../dal/model/request/SystemQueryJobArgs.java | 2 +- .../model/request/SystemQueryMenuArgs.java | 2 +- .../request/SystemQueryOperationLogArgs.java | 15 +++++++ .../request/SystemQueryQuartzJobArgs.java | 2 +- .../model/request/SystemQueryRoleArgs.java | 2 +- .../model/request/SystemQueryStorageArgs.java | 2 +- .../model/request/SystemQueryUserArgs.java | 2 +- .../model/request/SystemSendEmailArgs.java | 2 +- .../request/SystemUpdateQuartzJobArgs.java | 2 +- .../request/SystemUpdateUserPasswordArgs.java | 2 +- .../model/request/SystemUserLoginArgs.java | 2 +- .../dal/model/response/SystemAuthVo.java | 15 +++++++ .../dal/model/response/SystemCaptchaVo.java | 15 +++++++ .../dal/model/response/SystemDeptVo.java | 15 +++++++ .../model/response/SystemDictDetailVo.java | 4 +- .../dal/model/response/SystemMenuMetaVo.java | 2 +- .../model/response/SystemMenuRouterVo.java | 2 +- .../dal/model/response/SystemMenuVo.java | 15 +++++++ .../model/response/SystemOssStorageVo.java | 2 +- .../response/SystemProductLineTreeVo.java | 2 +- .../model/response/SystemProductLineVo.java | 2 +- .../dal/model/response/SystemQuartzJobVo.java | 15 +++++++ .../dal/model/response/SystemRoleCodeVo.java | 2 +- .../dal/model/response/SystemRoleVo.java | 15 +++++++ .../model/response/SystemSimpleUserVo.java | 4 +- .../dal/model/response/SystemUserInfoVo.java | 2 +- .../dal/model/response/SystemUserJwtVo.java | 2 +- .../model/response/SystemUserOnlineVo.java | 2 +- .../dal/model/response/SystemUserVo.java | 15 +++++++ .../system/dal/mysql/SystemDeptMapper.java | 2 +- .../dal/mysql/SystemDictDetailMapper.java | 2 +- .../system/dal/mysql/SystemDictMapper.java | 2 +- .../dal/mysql/SystemEmailConfigMapper.java | 2 +- .../system/dal/mysql/SystemJobMapper.java | 2 +- .../dal/mysql/SystemLocalStorageMapper.java | 2 +- .../system/dal/mysql/SystemMenuMapper.java | 2 +- .../dal/mysql/SystemOperationLogMapper.java | 2 +- .../dal/mysql/SystemOssStorageMapper.java | 2 +- .../dal/mysql/SystemQuartzJobMapper.java | 2 +- .../dal/mysql/SystemQuartzLogMapper.java | 2 +- .../dal/mysql/SystemRoleDeptMapper.java | 2 +- .../system/dal/mysql/SystemRoleMapper.java | 2 +- .../dal/mysql/SystemRoleMenuMapper.java | 2 +- .../system/dal/mysql/SystemUserJobMapper.java | 2 +- .../system/dal/mysql/SystemUserMapper.java | 2 +- .../dal/mysql/SystemUserRoleMapper.java | 2 +- .../system/dal/redis/SystemCacheKey.java | 42 +------------------ .../system/dal/redis/SystemRedisKey.java | 15 +++++++ .../system/dal/redis/SystemUserInfoDAO.java | 15 +++++++ .../dal/redis/SystemUserOnlineInfoDAO.java | 15 +++++++ .../system/framework/bizlock/BizLock.java | 2 +- .../framework/bizlock/BizLockAspect.java | 4 +- .../mybatisplus/MpMetaObjectHandler.java | 2 +- .../framework/operalog/OperationLog.java | 2 +- .../operalog/OperationLogAspect.java | 2 +- .../permission/config/AuthorityConfig.java | 2 +- .../config/SpringSecurityConfig.java | 2 +- .../permission/config/TokenConfigurer.java | 2 +- .../permission/core/KitSecurityHelper.java | 2 +- .../core/handler/JwtAccessDeniedHandler.java | 2 +- .../handler/JwtAuthenticationEntryPoint.java | 2 +- .../permission/core/handler/TokenFilter.java | 2 +- .../core/handler/TokenProvider.java | 2 +- .../core/handler/UserDetailsHandler.java | 2 +- .../framework/quartz/ActiveJobRegister.java | 2 +- .../framework/quartz/ExecutionJobBean.java | 2 +- .../system/framework/quartz/QuartzManage.java | 2 +- .../storage/OssStorageConfiguration.java | 2 +- .../storage/local/MultipartConfig.java | 2 +- .../storage/minio/MinioRepository.java | 2 +- .../java/cn/odboy/system/job/TestTask.java | 2 +- .../system/openapi/OpenCaptchaController.java | 2 +- .../system/service/SystemAuthService.java | 20 +++++++++ .../system/service/SystemCaptchaService.java | 15 +++++++ .../system/service/SystemDataService.java | 2 +- .../system/service/SystemDeptService.java | 2 +- .../service/SystemDictDetailService.java | 2 +- .../system/service/SystemDictService.java | 2 +- .../system/service/SystemEmailService.java | 2 +- .../system/service/SystemJobService.java | 2 +- .../service/SystemLocalStorageService.java | 2 +- .../system/service/SystemMenuService.java | 2 +- .../system/service/SystemMonitorService.java | 2 +- .../service/SystemOperationLogService.java | 15 +++++++ .../service/SystemOssStorageService.java | 2 +- .../service/SystemQuartzJobService.java | 2 +- .../system/service/SystemRoleDeptService.java | 24 +++++++---- .../system/service/SystemRoleMenuService.java | 2 +- .../system/service/SystemRoleService.java | 2 +- .../system/service/SystemUserDeptService.java | 15 +++++++ .../system/service/SystemUserJobService.java | 2 +- .../system/service/SystemUserRoleService.java | 2 +- .../system/service/SystemUserService.java | 2 +- .../impl/SystemMinioStorageServiceImpl.java | 2 +- .../java/cn/odboy/system/util/KitSqlUtil.java | 2 +- .../task/constant/TaskChangeTypeEnum.java | 2 +- .../odboy/task/constant/TaskStatusEnum.java | 2 +- .../task/controller/TaskTestsController.java | 2 +- .../java/cn/odboy/task/core/TaskJobBean.java | 2 +- .../java/cn/odboy/task/core/TaskManage.java | 2 +- .../cn/odboy/task/core/TaskStepExecutor.java | 2 +- .../task/core/impl/TaskStepNodeBuildJava.java | 2 +- .../core/impl/TaskStepNodeDeployJava.java | 2 +- .../task/core/impl/TaskStepNodeInit.java | 2 +- .../core/impl/TaskStepNodeMergeBranch.java | 2 +- .../dal/dataobject/TaskInstanceDetailTb.java | 2 +- .../dal/dataobject/TaskInstanceInfoTb.java | 2 +- .../dataobject/TaskInstanceStepDetailTb.java | 2 +- .../dal/dataobject/TaskTemplateInfoTb.java | 2 +- .../task/dal/model/TaskInstanceNodeVo.java | 2 +- .../task/dal/model/TaskTemplateInfoVo.java | 2 +- .../TaskTemplateNodeOperateButtonVo.java | 4 +- .../task/dal/model/TaskTemplateNodeVo.java | 2 +- .../dal/mysql/TaskInstanceDetailMapper.java | 2 +- .../dal/mysql/TaskInstanceInfoMapper.java | 2 +- .../mysql/TaskInstanceStepDetailMapper.java | 2 +- .../dal/mysql/TaskTemplateInfoMapper.java | 2 +- .../service/TaskInstanceDetailService.java | 2 +- .../task/service/TaskInstanceInfoService.java | 2 +- .../TaskInstanceStepDetailService.java | 2 +- .../task/service/TaskTemplateInfoService.java | 2 +- .../task/constant/TaskChangeTypeEnum.java | 2 +- .../odboy/task/constant/TaskStatusEnum.java | 2 +- .../task/controller/TaskTestsController.java | 2 +- .../java/cn/odboy/task/core/TaskJobBean.java | 2 +- .../java/cn/odboy/task/core/TaskManage.java | 2 +- .../cn/odboy/task/core/TaskStepExecutor.java | 2 +- .../task/core/impl/TaskStepNodeBuildJava.java | 2 +- .../core/impl/TaskStepNodeDeployJava.java | 2 +- .../task/core/impl/TaskStepNodeInit.java | 2 +- .../core/impl/TaskStepNodeMergeBranch.java | 2 +- .../dal/dataobject/TaskInstanceDetailTb.java | 2 +- .../dal/dataobject/TaskInstanceInfoTb.java | 2 +- .../dataobject/TaskInstanceStepDetailTb.java | 2 +- .../dal/dataobject/TaskTemplateInfoTb.java | 2 +- .../task/dal/model/TaskInstanceNodeVo.java | 2 +- .../task/dal/model/TaskTemplateInfoVo.java | 2 +- .../TaskTemplateNodeOperateButtonVo.java | 4 +- .../task/dal/model/TaskTemplateNodeVo.java | 2 +- .../dal/mysql/TaskInstanceDetailMapper.java | 2 +- .../dal/mysql/TaskInstanceInfoMapper.java | 2 +- .../mysql/TaskInstanceStepDetailMapper.java | 2 +- .../dal/mysql/TaskTemplateInfoMapper.java | 2 +- .../service/TaskInstanceDetailService.java | 4 +- .../task/service/TaskInstanceInfoService.java | 4 +- .../TaskInstanceStepDetailService.java | 2 +- .../task/service/TaskTemplateInfoService.java | 2 +- .../src/main/java/cn/odboy/AppRun.java | 2 +- .../src/main/java/cn/odboy/GenCode.java | 2 +- .../java/cn/odboy/HealthCheckPointer.java | 2 +- .../java/cn/odboy/MyBatisMapperTests.java | 2 +- .../java/cn/odboy/SystemApplicationTests.java | 2 +- .../cn/odboy/util/KitDesEncryptUtilTest.java | 2 +- .../java/cn/odboy/util/KitFileUtilTest.java | 2 +- .../java/cn/odboy/util/KitStringUtilTest.java | 2 +- .../java/cn/odboy/util/WorkTimeTests.java | 2 +- 570 files changed, 1580 insertions(+), 636 deletions(-) diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousAccess.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousAccess.java index 12109384..a85c6e53 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousAccess.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousAccess.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousDeleteMapping.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousDeleteMapping.java index aef7e180..cb9d7ce8 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousDeleteMapping.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousDeleteMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousGetMapping.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousGetMapping.java index ced09a02..8e10707c 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousGetMapping.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousGetMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPatchMapping.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPatchMapping.java index 7eb2c9fc..c3e6ed0f 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPatchMapping.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPatchMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPostMapping.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPostMapping.java index c3022bef..7a43f104 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPostMapping.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPostMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPutMapping.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPutMapping.java index 987618bd..b5f185ca 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPutMapping.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPutMapping.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitArgs.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitArgs.java index 097177da..c51cf1c3 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitArgs.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitArgs.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseCreateTimeTb.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseCreateTimeTb.java index 8c755c88..e1a1bed9 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseCreateTimeTb.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseCreateTimeTb.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseTimeTb.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseTimeTb.java index 6593aab8..7d5d428d 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseTimeTb.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseTimeTb.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUpdateTimeTb.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUpdateTimeTb.java index ad290bff..0ba57fa1 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUpdateTimeTb.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUpdateTimeTb.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserCreateTimeTb.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserCreateTimeTb.java index 88430bfc..c03a1e33 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserCreateTimeTb.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserCreateTimeTb.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeLogicTb.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeLogicTb.java index 5029c76f..9d1c99de 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeLogicTb.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeLogicTb.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeTb.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeTb.java index 6a55d66a..96652bc3 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeTb.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeTb.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitObject.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitObject.java index ada1e818..615cf630 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitObject.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitObject.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitPageArgs.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitPageArgs.java index 982779f0..96fdf401 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitPageArgs.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitPageArgs.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitPageResult.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitPageResult.java index 1f469a90..e40fda1c 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitPageResult.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitPageResult.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitSelectOptionVo.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitSelectOptionVo.java index bfa1eaf2..2b712e9a 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitSelectOptionVo.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/base/KitSelectOptionVo.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/CaptchaCodeEnum.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/CaptchaCodeEnum.java index f10030df..2e9e1e51 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/CaptchaCodeEnum.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/CaptchaCodeEnum.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/FileTypeEnum.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/FileTypeEnum.java index 337eb970..fd95343e 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/FileTypeEnum.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/FileTypeEnum.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/RequestMethodEnum.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/RequestMethodEnum.java index afcd77bf..e4bf5b10 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/RequestMethodEnum.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/RequestMethodEnum.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/SystemConst.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/SystemConst.java index dfe5dc18..8e79d47c 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/SystemConst.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/constant/SystemConst.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/context/BeanLoadFinishListener.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/context/BeanLoadFinishListener.java index 46d3d278..969a19e3 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/context/BeanLoadFinishListener.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/context/BeanLoadFinishListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,4 +35,4 @@ public class BeanLoadFinishListener implements ApplicationListener %s;", RED, now, RESET, GREEN, Thread.currentThread().getName(), BLUE, elapsed, RESET, sql); } -} \ No newline at end of file +} diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MpInsertBatchSqlInjector.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MpInsertBatchSqlInjector.java index 504d8629..3c5fe44d 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MpInsertBatchSqlInjector.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MpInsertBatchSqlInjector.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,4 +42,4 @@ public class MpInsertBatchSqlInjector extends DefaultSqlInjector { methodList.add(new AlwaysUpdateSomeColumnById(i -> i.getFieldFill() != FieldFill.INSERT)); return methodList; } -} \ No newline at end of file +} diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MybatisPlusConfig.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MybatisPlusConfig.java index 812875dd..8a43e558 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MybatisPlusConfig.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MybatisPlusConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/RemoveDruidAdConfig.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/RemoveDruidAdConfig.java index 92275c9f..70d57d88 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/RemoveDruidAdConfig.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/RemoveDruidAdConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpAnyQUtil.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpAnyQUtil.java index efa02dd6..1c2cd08b 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpAnyQUtil.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpAnyQUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpCmdGenUtil.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpCmdGenUtil.java index c24f1b46..3e219e93 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpCmdGenUtil.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpCmdGenUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -210,4 +210,4 @@ public class KitMpCmdGenUtil { .serviceImpl("service.impl").controller("controller") .pathInfo(Collections.singletonMap(OutputFile.xml, mapperPath)); } -} \ No newline at end of file +} diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpQUtil.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpQUtil.java index 3103ff22..125f8312 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpQUtil.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpQUtil.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpMapper.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpMapper.java index 2bd4a2c9..ec61e36c 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpMapper.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpMapper.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpService.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpService.java index 5610b2f5..b30ea30b 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpService.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpService.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpServiceImpl.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpServiceImpl.java index 9be39c97..ac0e1f04 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpServiceImpl.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpServiceImpl.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/AppProperties.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/AppProperties.java index b91ef77c..80749ddb 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/AppProperties.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/AppProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/CaptchaModel.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/CaptchaModel.java index d55448a6..5c43beec 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/CaptchaModel.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/CaptchaModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ContentRsaEncodeSettingModel.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ContentRsaEncodeSettingModel.java index 77430f95..6715946f 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ContentRsaEncodeSettingModel.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ContentRsaEncodeSettingModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/JwtAuthSettingModel.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/JwtAuthSettingModel.java index 03072879..db09e5f8 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/JwtAuthSettingModel.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/JwtAuthSettingModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/OSSConfigModel.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/OSSConfigModel.java index b88d6967..7acb41ea 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/OSSConfigModel.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/OSSConfigModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/StorageOSSModel.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/StorageOSSModel.java index 5261b425..64486555 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/StorageOSSModel.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/StorageOSSModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ThreadPoolSettingModel.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ThreadPoolSettingModel.java index 76d8bc7f..189ab2fb 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ThreadPoolSettingModel.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ThreadPoolSettingModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginCaptchaSettingModel.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginCaptchaSettingModel.java index be6b46a5..2f2c1535 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginCaptchaSettingModel.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginCaptchaSettingModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginSettingModel.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginSettingModel.java index 917601c1..9e0df68b 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginSettingModel.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginSettingModel.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/quartz/config/QuartzConfig.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/quartz/config/QuartzConfig.java index c61848c2..c8289c84 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/quartz/config/QuartzConfig.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/quartz/config/QuartzConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/quartz/core/QuartzRunnable.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/quartz/core/QuartzRunnable.java index 218d6f66..d9fe23dc 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/quartz/core/QuartzRunnable.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/quartz/core/QuartzRunnable.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/redis/KitRedisHelper.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/redis/KitRedisHelper.java index af0ba20a..c4963f0a 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/redis/KitRedisHelper.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/redis/KitRedisHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/redis/RedisConfiguration.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/redis/RedisConfiguration.java index 9eff808a..dd0696f5 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/redis/RedisConfiguration.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/redis/RedisConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -194,4 +194,4 @@ public class RedisConfiguration { return JSON.parseObject(str, clazz); } } -} \ No newline at end of file +} diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/config/AsyncTheadPoolConfig.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/config/AsyncTheadPoolConfig.java index 97f5465c..281d1e7b 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/config/AsyncTheadPoolConfig.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/config/AsyncTheadPoolConfig.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringArraysToListDateConverter.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringArraysToListDateConverter.java index ea239380..89c711df 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringArraysToListDateConverter.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringArraysToListDateConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringToDateConverter.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringToDateConverter.java index 5f96d041..93587068 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringToDateConverter.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringToDateConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/core/ConfigurerAdapter.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/core/ConfigurerAdapter.java index 8cdd9bbc..e1cda590 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/core/ConfigurerAdapter.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/core/ConfigurerAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/core/KitFileLocalUploadHelper.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/core/KitFileLocalUploadHelper.java index e76f110c..8a74ca81 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/core/KitFileLocalUploadHelper.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/server/core/KitFileLocalUploadHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2021-2025 Odboy + * Copyright 2021-2026 Odboy * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/websocket/config/UndertowWebSocketConfig.java b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/websocket/config/UndertowWebSocketConfig.java index c25a58e2..69d3f475 100644 --- a/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/websocket/config/UndertowWebSocketConfig.java +++ b/cutejava-springboot3/cutejava-framework/src/main/java/cn/odboy/framework/websocket/config/UndertowWebSocketConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2021-2026 Odboy + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package cn.odboy.framework.websocket.config; import io.undertow.server.DefaultByteBufferPool; @@ -41,4 +56,4 @@ public class UndertowWebSocketConfig implements WebServerFactoryCustomizer