From 1d911e679ef12dfbf690334bee4d2bf57cb1923f Mon Sep 17 00:00:00 2001 From: Odboy Date: Mon, 22 Dec 2025 22:41:11 +0800 Subject: [PATCH] =?UTF-8?q?style(framework):=20=E4=BC=98=E5=8C=96=E6=A1=86?= =?UTF-8?q?=E6=9E=B6=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F=E5=92=8C=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 更新pom.xml中的阿里云仓库地址为HTTPS协议 - 重构注解类的import语句,移除通配符导入并规范排列 - 简化匿名访问注解的代码结构,移除多余空行 - 调整基础实体类的字段注解格式,合并为单行声明 - 优化常量类和枚举类的代码格式,移除多余空行 - 重构启动类的日志输出格式,改进字符串拼接方式 - 规范工具类的import顺序和代码结构 - 优化Swagger配置类的代码格式和注解排列 --- README.MD | 23 +++- .../cn/odboy/annotation/AnonymousAccess.java | 11 +- .../annotation/AnonymousDeleteMapping.java | 15 +-- .../odboy/annotation/AnonymousGetMapping.java | 15 +-- .../annotation/AnonymousPatchMapping.java | 15 +-- .../annotation/AnonymousPostMapping.java | 15 +-- .../odboy/annotation/AnonymousPutMapping.java | 15 +-- .../src/main/java/cn/odboy/base/KitArgs.java | 10 +- .../cn/odboy/base/KitBaseCreateTimeTb.java | 7 +- .../java/cn/odboy/base/KitBaseTimeTb.java | 11 +- .../cn/odboy/base/KitBaseUpdateTimeTb.java | 7 +- .../odboy/base/KitBaseUserCreateTimeTb.java | 23 +--- .../cn/odboy/base/KitBaseUserTimeLogicTb.java | 28 ++-- .../java/cn/odboy/base/KitBaseUserTimeTb.java | 32 ++--- .../main/java/cn/odboy/base/KitObject.java | 1 - .../main/java/cn/odboy/base/KitPageArgs.java | 20 +-- .../java/cn/odboy/base/KitPageResult.java | 6 +- .../java/cn/odboy/base/KitSelectOptionVo.java | 8 +- .../cn/odboy/constant/CaptchaCodeEnum.java | 1 - .../java/cn/odboy/constant/FileTypeEnum.java | 2 - .../cn/odboy/constant/RequestMethodEnum.java | 8 -- .../java/cn/odboy/constant/SystemConst.java | 5 - .../context/BeanLoadFinishListener.java | 1 - .../framework/context/BootApplication.java | 15 ++- .../framework/context/KitRequestHolder.java | 11 +- .../framework/context/KitScriptHelper.java | 4 +- .../context/KitSpringBeanHolder.java | 18 +-- .../cn/odboy/framework/doc/SwaggerConfig.java | 50 +++---- .../exception/BadRequestException.java | 2 - .../framework/exception/ServerException.java | 2 - .../framework/exception/handler/ApiError.java | 4 - .../handler/GlobalExceptionHandler.java | 2 - .../logging/ExecutionTimeStatisticsFace.java | 9 +- .../ExecutionTimeStatisticsFaceAspect.java | 10 +- .../controller/HealthCheckController.java | 5 +- .../service/KitHealthCheckPointService.java | 2 - .../mybatisplus/config/DataTypeEnum.java | 4 +- .../mybatisplus/config/KitMpQTypeEnum.java | 1 - .../mybatisplus/config/KitMpQuery.java | 3 - .../config/MpCustomP6SpyLogger.java | 8 +- .../config/MpInsertBatchSqlInjector.java | 4 +- .../mybatisplus/config/MybatisPlusConfig.java | 1 - .../config/RemoveDruidAdConfig.java | 25 ++-- .../mybatisplus/core/KitMpAnyQUtil.java | 5 +- .../mybatisplus/core/KitMpCmdGenUtil.java | 51 ++++--- .../mybatisplus/core/KitMpQUtil.java | 40 +++--- .../core/interfaces/KitMpMapper.java | 19 +-- .../core/interfaces/KitMpService.java | 22 +--- .../core/interfaces/KitMpServiceImpl.java | 16 ++- .../framework/properties/AppProperties.java | 11 +- .../properties/model/CaptchaModel.java | 1 - .../model/ContentRsaEncodeSettingModel.java | 1 - .../properties/model/JwtAuthSettingModel.java | 4 - .../properties/model/OSSConfigModel.java | 1 - .../properties/model/StorageOSSModel.java | 1 - .../model/SwaggerApiDocSettingModel.java | 1 - .../model/ThreadPoolSettingModel.java | 1 - .../model/UserLoginCaptchaSettingModel.java | 19 +-- .../model/UserLoginSettingModel.java | 1 - .../framework/quartz/config/QuartzConfig.java | 2 - .../framework/quartz/core/QuartzRunnable.java | 9 +- .../odboy/framework/redis/KitRedisHelper.java | 34 ++--- .../framework/redis/RedisConfiguration.java | 18 ++- .../server/config/AsyncTheadPoolConfig.java | 19 +-- .../DateStringArraysToListDateConverter.java | 9 +- .../converters/DateStringToDateConverter.java | 9 +- .../server/core/ConfigurerAdapter.java | 17 +-- .../server/core/KitFileLocalUploadHelper.java | 4 +- .../config/UndertowWebSocketConfig.java | 10 +- .../config/WebSocketEndpointConfig.java | 2 - .../websocket/context/KitWsClientManager.java | 4 +- .../websocket/context/KitWsMessage.java | 1 - .../websocket/context/KitWsServer.java | 19 +-- .../framework/websocket/model/WsSidVo.java | 1 - .../websocket/util/WsMessageUtil.java | 1 - .../java/cn/odboy/util/KitAnonTagUtil.java | 21 +-- .../cn/odboy/util/KitBase64SecretUtil.java | 5 +- .../java/cn/odboy/util/KitBigDecimalUtil.java | 9 +- .../java/cn/odboy/util/KitBrowserUtil.java | 8 +- .../main/java/cn/odboy/util/KitClassUtil.java | 5 +- .../main/java/cn/odboy/util/KitCloseUtil.java | 6 +- .../main/java/cn/odboy/util/KitCollUtil.java | 26 ++-- .../main/java/cn/odboy/util/KitDateUtil.java | 21 +-- .../java/cn/odboy/util/KitDesEncryptUtil.java | 8 +- .../cn/odboy/util/KitDistributedIdUtil.java | 26 ++-- .../main/java/cn/odboy/util/KitFileUtil.java | 48 ++++--- .../main/java/cn/odboy/util/KitIPUtil.java | 14 +- .../main/java/cn/odboy/util/KitJsonUtil.java | 10 +- .../main/java/cn/odboy/util/KitListUtil.java | 13 +- .../java/cn/odboy/util/KitLogFmtUtil.java | 1 - .../main/java/cn/odboy/util/KitPageUtil.java | 5 +- .../odboy/util/KitResourceTemplateUtil.java | 4 +- .../odboy/util/KitReturnValueHandleUtil.java | 7 +- .../java/cn/odboy/util/KitRsaEncryptUtil.java | 17 +-- .../java/cn/odboy/util/KitStringUtil.java | 27 ++-- .../java/cn/odboy/util/KitSystemUtil.java | 2 - .../main/java/cn/odboy/util/KitValidUtil.java | 11 +- cutejava/cutejava-module-system/pom.xml | 2 - .../system/constant/SystemCaptchaBizEnum.java | 10 +- .../system/constant/SystemDataScopeEnum.java | 11 +- .../constant/TransferProtocolConst.java | 1 - .../controller/SystemAuthController.java | 43 +++--- .../controller/SystemCaptchaController.java | 10 +- .../controller/SystemComponentController.java | 4 +- .../controller/SystemDeptController.java | 35 ++--- .../controller/SystemDictController.java | 22 ++-- .../SystemDictDetailController.java | 29 ++-- .../controller/SystemEmailController.java | 7 +- .../controller/SystemJobController.java | 23 ++-- .../SystemLocalStorageController.java | 19 +-- .../controller/SystemMenuController.java | 31 +++-- .../controller/SystemMonitorController.java | 7 +- .../controller/SystemOnlineController.java | 23 ++-- .../SystemOssStorageController.java | 19 +-- .../controller/SystemQuartzJobController.java | 25 ++-- .../controller/SystemRoleController.java | 28 ++-- .../controller/SystemUserController.java | 108 ++++++++------- .../system/dal/dataobject/SystemDeptTb.java | 51 ++----- .../dal/dataobject/SystemDictDetailTb.java | 33 ++--- .../system/dal/dataobject/SystemDictTb.java | 29 ++-- .../dal/dataobject/SystemEmailConfigTb.java | 33 +---- .../system/dal/dataobject/SystemJobTb.java | 30 ++--- .../dal/dataobject/SystemLocalStorageTb.java | 34 ++--- .../system/dal/dataobject/SystemMenuTb.java | 77 +++-------- .../dal/dataobject/SystemOperationLogTb.java | 46 +++---- .../dal/dataobject/SystemOssStorageTb.java | 53 ++------ .../dal/dataobject/SystemQuartzJobTb.java | 73 +++-------- .../dal/dataobject/SystemQuartzLogTb.java | 52 +++----- .../dal/dataobject/SystemRoleDeptTb.java | 30 +++++ .../dal/dataobject/SystemRoleMenuTb.java | 5 +- .../system/dal/dataobject/SystemRoleTb.java | 57 +++----- .../dal/dataobject/SystemUserJobTb.java | 17 +++ .../dal/dataobject/SystemUserRoleTb.java | 30 +++++ .../system/dal/dataobject/SystemUserTb.java | 89 ++++--------- .../model/SystemCheckEmailCaptchaArgs.java | 13 +- .../dal/model/SystemCreateDeptArgs.java | 12 +- .../dal/model/SystemCreateDictArgs.java | 7 +- .../dal/model/SystemCreateDictDetailArgs.java | 18 +-- .../system/dal/model/SystemCreateJobArgs.java | 12 +- .../dal/model/SystemCreateRoleArgs.java | 17 +-- .../system/dal/model/SystemMenuMetaVo.java | 13 +- .../odboy/system/dal/model/SystemMenuVo.java | 36 ++--- .../system/dal/model/SystemOssStorageVo.java | 1 - .../dal/model/SystemProductLineTreeVo.java | 4 +- .../system/dal/model/SystemProductLineVo.java | 1 - .../system/dal/model/SystemQueryDeptArgs.java | 28 +--- .../system/dal/model/SystemQueryDictArgs.java | 13 +- .../dal/model/SystemQueryDictDetailArgs.java | 8 +- .../system/dal/model/SystemQueryJobArgs.java | 26 +--- .../system/dal/model/SystemQueryMenuArgs.java | 20 +-- .../dal/model/SystemQueryQuartzJobArgs.java | 24 +--- .../system/dal/model/SystemQueryRoleArgs.java | 24 +--- .../dal/model/SystemQueryStorageArgs.java | 20 +-- .../system/dal/model/SystemQueryUserArgs.java | 38 ++---- .../system/dal/model/SystemRoleCodeVo.java | 5 +- .../system/dal/model/SystemSendEmailArgs.java | 23 +--- .../system/dal/model/SystemSimpleUserVo.java | 40 ++---- .../dal/model/SystemUpdateQuartzJobArgs.java | 21 +-- .../model/SystemUpdateUserPasswordArgs.java | 9 +- .../system/dal/model/SystemUserInfoVo.java | 6 +- .../system/dal/model/SystemUserJwtVo.java | 20 +-- .../system/dal/model/SystemUserLoginArgs.java | 22 +--- .../system/dal/model/SystemUserOnlineVo.java | 39 ++---- .../system/dal/mysql/SystemDeptMapper.java | 55 +++++--- .../dal/mysql/SystemDictDetailMapper.java | 10 +- .../system/dal/mysql/SystemDictMapper.java | 27 ++-- .../dal/mysql/SystemEmailConfigMapper.java | 4 +- .../system/dal/mysql/SystemJobMapper.java | 35 ++++- .../dal/mysql/SystemLocalStorageMapper.java | 34 ++++- .../system/dal/mysql/SystemMenuMapper.java | 74 ++++++++--- .../dal/mysql/SystemOperationLogMapper.java | 4 +- .../dal/mysql/SystemOssStorageMapper.java | 12 +- .../dal/mysql/SystemQuartzJobMapper.java | 13 +- .../dal/mysql/SystemQuartzLogMapper.java | 9 +- .../dal/mysql/SystemRoleDeptMapper.java | 13 +- .../system/dal/mysql/SystemRoleMapper.java | 36 ++--- .../dal/mysql/SystemRoleMenuMapper.java | 13 +- .../system/dal/mysql/SystemUserJobMapper.java | 13 +- .../system/dal/mysql/SystemUserMapper.java | 64 +++++---- .../dal/mysql/SystemUserRoleMapper.java | 13 +- .../system/dal/redis/SystemCacheKey.java | 12 -- .../system/dal/redis/SystemRedisKey.java | 11 -- .../system/dal/redis/SystemUserInfoDAO.java | 4 +- .../dal/redis/SystemUserOnlineInfoDAO.java | 38 +++--- .../system/framework/bizlock/BizLock.java | 12 +- .../framework/bizlock/BizLockAspect.java | 13 +- .../mybatisplus/MpMetaObjectHandler.java | 6 +- .../framework/operalog/OperationLog.java | 8 +- .../operalog/OperationLogAspect.java | 12 +- .../operalog/annotaions/OperationLog.java | 7 +- .../core/SystemOperationLogAspect.java | 11 +- .../permission/config/AuthorityConfig.java | 11 +- .../config/SpringSecurityConfig.java | 46 ++++--- .../permission/config/TokenConfigurer.java | 1 - .../permission/core/CsSecurityHelper.java | 11 +- .../core/handler/JwtAccessDeniedHandler.java | 15 +-- .../handler/JwtAuthenticationEntryPoint.java | 15 +-- .../permission/core/handler/TokenFilter.java | 17 ++- .../core/handler/TokenProvider.java | 22 ++-- .../core/handler/UserDetailsHandler.java | 18 +-- .../framework/quartz/ActiveJobRegister.java | 14 +- .../framework/quartz/ExecutionJobBean.java | 18 ++- .../system/framework/quartz/QuartzManage.java | 32 ++--- .../storage/OssStorageConfiguration.java | 7 +- .../storage/local/MultipartConfig.java | 12 +- .../storage/minio/MinioRepository.java | 75 +++++------ .../java/cn/odboy/system/job/TestTask.java | 2 - .../system/service/SystemDataService.java | 21 ++- .../system/service/SystemDeptService.java | 104 +++++++-------- .../service/SystemDictDetailService.java | 24 ++-- .../system/service/SystemDictService.java | 27 ++-- .../system/service/SystemEmailService.java | 30 ++--- .../system/service/SystemJobService.java | 27 ++-- .../service/SystemLocalStorageService.java | 34 ++--- .../system/service/SystemMenuService.java | 76 +++++------ .../system/service/SystemMonitorService.java | 39 ++++-- .../service/SystemOssStorageService.java | 12 +- .../service/SystemQuartzJobService.java | 98 +++++++++----- .../system/service/SystemRoleDeptService.java | 76 +++++++++++ .../system/service/SystemRoleMenuService.java | 87 ++++++++++++ .../system/service/SystemRoleService.java | 79 ++++++----- .../system/service/SystemUserJobService.java | 56 ++++++++ .../system/service/SystemUserRoleService.java | 56 ++++++++ .../system/service/SystemUserService.java | 105 +++++++-------- .../impl/SystemOssStorageServiceImpl.java | 58 +++++--- .../java/cn/odboy/system/util/KitSqlUtil.java | 9 +- .../resources/mapper/SystemDeptMapper.xml | 109 --------------- .../mapper/SystemDictDetailMapper.xml | 7 - .../resources/mapper/SystemDictMapper.xml | 18 --- .../main/resources/mapper/SystemJobMapper.xml | 26 ---- .../mapper/SystemLocalStorageMapper.xml | 23 ---- .../resources/mapper/SystemMenuMapper.xml | 124 ------------------ .../mapper/SystemOssStorageMapper.xml | 23 ---- .../mapper/SystemQuartzJobMapper.xml | 23 ---- .../mapper/SystemQuartzLogMapper.xml | 21 --- .../resources/mapper/SystemRoleDeptMapper.xml | 19 --- .../resources/mapper/SystemRoleMapper.xml | 105 ++++++--------- .../resources/mapper/SystemRoleMenuMapper.xml | 23 ---- .../resources/mapper/SystemUserJobMapper.xml | 18 --- .../resources/mapper/SystemUserMapper.xml | 99 +++++--------- .../resources/mapper/SystemUserRoleMapper.xml | 19 --- .../template/SystemEmailCaptchaTemplate.ftl | 35 +++-- .../SystemQuartzJobTaskAlarmTemplate.ftl | 77 ++++++----- cutejava/cutejava-module-task-v1/pom.xml | 2 - .../task/constant/TaskChangeTypeEnum.java | 12 +- .../task/controller/TaskTestsController.java | 9 +- .../java/cn/odboy/task/core/TaskJobBean.java | 60 +++++---- .../java/cn/odboy/task/core/TaskManage.java | 57 ++++---- .../cn/odboy/task/core/TaskStepExecutor.java | 3 +- .../task/core/impl/TaskStepNodeBuildJava.java | 4 +- .../core/impl/TaskStepNodeDeployJava.java | 4 +- .../task/core/impl/TaskStepNodeInit.java | 6 +- .../core/impl/TaskStepNodeMergeBranch.java | 6 +- .../dal/dataobject/TaskInstanceDetailTb.java | 61 +++------ .../dal/dataobject/TaskInstanceInfoTb.java | 86 ++++-------- .../dataobject/TaskInstanceStepDetailTb.java | 35 ++--- .../dal/dataobject/TaskTemplateInfoTb.java | 40 ++---- .../task/dal/model/TaskInstanceInfoVo.java | 3 +- .../task/dal/model/TaskInstanceNodeVo.java | 4 +- .../TaskTemplateNodeOperateButtonVo.java | 6 +- .../task/dal/model/TaskTemplateNodeVo.java | 6 +- .../dal/mysql/TaskInstanceDetailMapper.java | 4 +- .../dal/mysql/TaskInstanceInfoMapper.java | 4 +- .../mysql/TaskInstanceStepDetailMapper.java | 4 +- .../dal/mysql/TaskTemplateInfoMapper.java | 3 +- .../service/TaskInstanceDetailService.java | 89 +++++++++++-- .../task/service/TaskInstanceInfoService.java | 91 +++++++++++-- .../TaskInstanceStepDetailService.java | 42 +++++- .../task/service/TaskTemplateInfoService.java | 17 ++- .../impl/TaskInstanceDetailServiceImpl.java | 91 ------------- .../impl/TaskInstanceInfoServiceImpl.java | 94 ------------- .../TaskInstanceStepDetailServiceImpl.java | 68 ---------- .../impl/TaskTemplateInfoServiceImpl.java | 40 ------ .../mapper/TaskInstanceDetailMapper.xml | 1 - .../mapper/TaskInstanceInfoMapper.xml | 1 - cutejava/cutejava-module-task-v2/pom.xml | 2 - .../task/constant/TaskChangeTypeEnum.java | 12 +- .../task/controller/TaskTestsController.java | 9 +- .../java/cn/odboy/task/core/TaskJobBean.java | 1 - .../java/cn/odboy/task/core/TaskManage.java | 8 -- .../cn/odboy/task/core/TaskStepExecutor.java | 3 +- .../task/core/impl/TaskStepNodeBuildJava.java | 4 +- .../core/impl/TaskStepNodeDeployJava.java | 4 +- .../task/core/impl/TaskStepNodeInit.java | 6 +- .../core/impl/TaskStepNodeMergeBranch.java | 6 +- .../dal/dataobject/TaskInstanceDetailTb.java | 61 +++------ .../dal/dataobject/TaskInstanceInfoTb.java | 86 ++++-------- .../dataobject/TaskInstanceStepDetailTb.java | 35 ++--- .../dal/dataobject/TaskTemplateInfoTb.java | 40 ++---- .../task/dal/model/TaskInstanceInfoVo.java | 3 +- .../task/dal/model/TaskInstanceNodeVo.java | 4 +- .../TaskTemplateNodeOperateButtonVo.java | 6 +- .../task/dal/model/TaskTemplateNodeVo.java | 6 +- .../dal/mysql/TaskInstanceDetailMapper.java | 4 +- .../dal/mysql/TaskInstanceInfoMapper.java | 4 +- .../mysql/TaskInstanceStepDetailMapper.java | 4 +- .../dal/mysql/TaskTemplateInfoMapper.java | 3 +- .../service/TaskInstanceDetailService.java | 88 +++++++++++-- .../task/service/TaskInstanceInfoService.java | 80 +++++++++-- .../TaskInstanceStepDetailService.java | 42 +++++- .../task/service/TaskTemplateInfoService.java | 17 ++- .../impl/TaskInstanceDetailServiceImpl.java | 103 --------------- .../impl/TaskInstanceInfoServiceImpl.java | 94 ------------- .../TaskInstanceStepDetailServiceImpl.java | 68 ---------- .../impl/TaskTemplateInfoServiceImpl.java | 40 ------ .../mapper/TaskInstanceDetailMapper.xml | 1 - .../mapper/TaskInstanceInfoMapper.xml | 1 - cutejava/cutejava-starter/pom.xml | 3 - .../src/main/java/cn/odboy/AppRun.java | 5 +- .../src/main/java/cn/odboy/GenCode.java | 5 +- .../java/cn/odboy/HealthCheckPointer.java | 4 +- .../java/cn/odboy/MyBatisMapperTests.java | 20 ++- .../java/cn/odboy/SystemApplicationTests.java | 14 +- .../cn/odboy/util/KitDesEncryptUtilTest.java | 2 - .../java/cn/odboy/util/KitFileUtilTest.java | 7 +- .../java/cn/odboy/util/KitStringUtilTest.java | 9 +- .../java/cn/odboy/util/WorkTimeTests.java | 1 - cutejava/pom.xml | 4 +- 318 files changed, 3008 insertions(+), 4352 deletions(-) create mode 100644 cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleDeptTb.java create mode 100644 cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserJobTb.java create mode 100644 cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserRoleTb.java create mode 100644 cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java create mode 100644 cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleMenuService.java create mode 100644 cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java create mode 100644 cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java delete mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemDeptMapper.xml delete mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemDictMapper.xml delete mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemJobMapper.xml delete mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemLocalStorageMapper.xml delete mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemMenuMapper.xml delete mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemOssStorageMapper.xml delete mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemQuartzJobMapper.xml delete mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemQuartzLogMapper.xml delete mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleDeptMapper.xml delete mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleMenuMapper.xml delete mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserJobMapper.xml delete mode 100644 cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserRoleMapper.xml delete mode 100644 cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskInstanceDetailServiceImpl.java delete mode 100644 cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskInstanceInfoServiceImpl.java delete mode 100644 cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskInstanceStepDetailServiceImpl.java delete mode 100644 cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskTemplateInfoServiceImpl.java delete mode 100644 cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskInstanceDetailServiceImpl.java delete mode 100644 cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskInstanceInfoServiceImpl.java delete mode 100644 cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskInstanceStepDetailServiceImpl.java delete mode 100644 cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskTemplateInfoServiceImpl.java diff --git a/README.MD b/README.MD index d1e24815..f82cd03a 100644 --- a/README.MD +++ b/README.MD @@ -11,6 +11,7 @@ [https://github.com/odboy-tianjun/cutejava](https://github.com/odboy-tianjun/cutejava) #### 项目文档 + [https://cutejava-doc.odboy.cn/](https://cutejava-doc.odboy.cn/) #### 编码规范 @@ -22,12 +23,26 @@ - 消息队列/Socket传输类名,以`Message`结尾 - ~~常用的辅助类的类名, 以`Cs`开头~~ - 常用的辅助类的类名, 以`Kit`开头。Kit有套件、装备等意思。 -- 查询分页、查询列表的方法,一律为同一个方法名 - - 查询分页:queryUser(args, page) - - 查询列表:queryUser(args) - - MapperXml:这样mapper.xml文件中的实现方法只需要写一个queryUser - 枚举类名,以`Enum`结尾 - 拒绝过度包装 +- 命名规则(Mapper or Service) + - 简单查询:get + 名词 + - 列表查询:list + 名词 + - 复杂查询:query + 名词 + By + 条件 + - 搜索(分页)功能:search + 名词 + - 统计计数:count + By + 条件 + - 存在检查:exists + By + 条件 + - 例子: 查询分页、查询列表的方法 + - 分页:searchUser(args, page) + - 列表:listUser + (args) + - 单个:getUser + by + (args) + - Mapper + - 分页与列表共用 + - selectUserByArgs(args, page) + - selectUserByArgs(args) + - MapperXml selectUserByArgs + - 单个:getUser + by + (args) + - 统计计数:count + By + (args) #### 主要特性 diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousAccess.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousAccess.java index 9d539f21..19c4c75c 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousAccess.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousAccess.java @@ -15,7 +15,12 @@ */ package cn.odboy.annotation; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * 用于标记匿名访问方法 @@ -24,6 +29,4 @@ import java.lang.annotation.*; @Documented @Target({ElementType.METHOD, ElementType.ANNOTATION_TYPE}) @Retention(RetentionPolicy.RUNTIME) -public @interface AnonymousAccess { - -} +public @interface AnonymousAccess {} diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousDeleteMapping.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousDeleteMapping.java index 3bb92e05..fdfdc450 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousDeleteMapping.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousDeleteMapping.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.annotation; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import org.springframework.core.annotation.AliasFor; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import java.lang.annotation.*; - /** * Annotation for mapping HTTP {@code DELETE} requests onto specific handler methods. 支持匿名访问 DeleteMapping * @@ -37,37 +39,30 @@ import java.lang.annotation.*; @Documented @RequestMapping(method = RequestMethod.DELETE) public @interface AnonymousDeleteMapping { - /** * Alias for {@link RequestMapping#name}. */ @AliasFor(annotation = RequestMapping.class) String name() default ""; - /** * Alias for {@link RequestMapping#value}. */ @AliasFor(annotation = RequestMapping.class) String[] value() default {}; - /** * Alias for {@link RequestMapping#path}. */ @AliasFor(annotation = RequestMapping.class) String[] path() default {}; - /** * Alias for {@link RequestMapping#params}. */ @AliasFor(annotation = RequestMapping.class) String[] params() default {}; - /** * Alias for {@link RequestMapping#headers}. */ @AliasFor(annotation = RequestMapping.class) String[] headers() default {}; - /** * Alias for {@link RequestMapping#consumes}. */ @AliasFor(annotation = RequestMapping.class) String[] consumes() default {}; - /** * Alias for {@link RequestMapping#produces}. */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousGetMapping.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousGetMapping.java index 06b5690a..de74d263 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousGetMapping.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousGetMapping.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.annotation; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import org.springframework.core.annotation.AliasFor; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import java.lang.annotation.*; - /** * Annotation for mapping HTTP {@code GET} requests onto specific handler methods. *

@@ -35,39 +37,32 @@ import java.lang.annotation.*; @Documented @RequestMapping(method = RequestMethod.GET) public @interface AnonymousGetMapping { - /** * Alias for {@link RequestMapping#name}. */ @AliasFor(annotation = RequestMapping.class) String name() default ""; - /** * Alias for {@link RequestMapping#value}. */ @AliasFor(annotation = RequestMapping.class) String[] value() default {}; - /** * Alias for {@link RequestMapping#path}. */ @AliasFor(annotation = RequestMapping.class) String[] path() default {}; - /** * Alias for {@link RequestMapping#params}. */ @AliasFor(annotation = RequestMapping.class) String[] params() default {}; - /** * Alias for {@link RequestMapping#headers}. */ @AliasFor(annotation = RequestMapping.class) String[] headers() default {}; - /** * Alias for {@link RequestMapping#consumes}. * * @since 4.3.5 */ @AliasFor(annotation = RequestMapping.class) String[] consumes() default {}; - /** * Alias for {@link RequestMapping#produces}. */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPatchMapping.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPatchMapping.java index 81746e3c..0f14da80 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPatchMapping.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPatchMapping.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.annotation; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import org.springframework.core.annotation.AliasFor; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import java.lang.annotation.*; - /** * Annotation for mapping HTTP {@code PATCH} requests onto specific handler methods. 支持匿名访问 PatchMapping * @@ -37,37 +39,30 @@ import java.lang.annotation.*; @Documented @RequestMapping(method = RequestMethod.PATCH) public @interface AnonymousPatchMapping { - /** * Alias for {@link RequestMapping#name}. */ @AliasFor(annotation = RequestMapping.class) String name() default ""; - /** * Alias for {@link RequestMapping#value}. */ @AliasFor(annotation = RequestMapping.class) String[] value() default {}; - /** * Alias for {@link RequestMapping#path}. */ @AliasFor(annotation = RequestMapping.class) String[] path() default {}; - /** * Alias for {@link RequestMapping#params}. */ @AliasFor(annotation = RequestMapping.class) String[] params() default {}; - /** * Alias for {@link RequestMapping#headers}. */ @AliasFor(annotation = RequestMapping.class) String[] headers() default {}; - /** * Alias for {@link RequestMapping#consumes}. */ @AliasFor(annotation = RequestMapping.class) String[] consumes() default {}; - /** * Alias for {@link RequestMapping#produces}. */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPostMapping.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPostMapping.java index 4da396bb..172e0f7f 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPostMapping.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPostMapping.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.annotation; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import org.springframework.core.annotation.AliasFor; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import java.lang.annotation.*; - /** * Annotation for mapping HTTP {@code POST} requests onto specific handler methods. 支持匿名访问 PostMapping * @@ -37,37 +39,30 @@ import java.lang.annotation.*; @Documented @RequestMapping(method = RequestMethod.POST) public @interface AnonymousPostMapping { - /** * Alias for {@link RequestMapping#name}. */ @AliasFor(annotation = RequestMapping.class) String name() default ""; - /** * Alias for {@link RequestMapping#value}. */ @AliasFor(annotation = RequestMapping.class) String[] value() default {}; - /** * Alias for {@link RequestMapping#path}. */ @AliasFor(annotation = RequestMapping.class) String[] path() default {}; - /** * Alias for {@link RequestMapping#params}. */ @AliasFor(annotation = RequestMapping.class) String[] params() default {}; - /** * Alias for {@link RequestMapping#headers}. */ @AliasFor(annotation = RequestMapping.class) String[] headers() default {}; - /** * Alias for {@link RequestMapping#consumes}. */ @AliasFor(annotation = RequestMapping.class) String[] consumes() default {}; - /** * Alias for {@link RequestMapping#produces}. */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPutMapping.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPutMapping.java index 9641f8d0..320df975 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPutMapping.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/annotation/AnonymousPutMapping.java @@ -13,15 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.annotation; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import org.springframework.core.annotation.AliasFor; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import java.lang.annotation.*; - /** * Annotation for mapping HTTP {@code PUT} requests onto specific handler methods. 支持匿名访问 PutMapping * @@ -37,37 +39,30 @@ import java.lang.annotation.*; @Documented @RequestMapping(method = RequestMethod.PUT) public @interface AnonymousPutMapping { - /** * Alias for {@link RequestMapping#name}. */ @AliasFor(annotation = RequestMapping.class) String name() default ""; - /** * Alias for {@link RequestMapping#value}. */ @AliasFor(annotation = RequestMapping.class) String[] value() default {}; - /** * Alias for {@link RequestMapping#path}. */ @AliasFor(annotation = RequestMapping.class) String[] path() default {}; - /** * Alias for {@link RequestMapping#params}. */ @AliasFor(annotation = RequestMapping.class) String[] params() default {}; - /** * Alias for {@link RequestMapping#headers}. */ @AliasFor(annotation = RequestMapping.class) String[] headers() default {}; - /** * Alias for {@link RequestMapping#consumes}. */ @AliasFor(annotation = RequestMapping.class) String[] consumes() default {}; - /** * Alias for {@link RequestMapping#produces}. */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitArgs.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitArgs.java index 3c64bf31..fc531663 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitArgs.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitArgs.java @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.base; +import javax.validation.constraints.NotNull; import lombok.Getter; import lombok.Setter; -import javax.validation.constraints.NotNull; - /** * 通用参数 * @@ -31,14 +29,12 @@ public class KitArgs { @Getter @Setter public static class FindByLongId extends KitObject { - @NotNull(message = "id必填") - private Long id; + @NotNull(message = "id必填") private Long id; } @Getter @Setter public static class DeleteById extends KitObject { - @NotNull(message = "id必填") - private Long id; + @NotNull(message = "id必填") private Long id; } } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseCreateTimeTb.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseCreateTimeTb.java index 5bdc24b6..127b9789 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseCreateTimeTb.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseCreateTimeTb.java @@ -13,23 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.base; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModelProperty; +import java.util.Date; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; -import java.util.Date; - @Getter @Setter @EqualsAndHashCode(callSuper = false) public class KitBaseCreateTimeTb extends KitObject { - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date createTime; } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseTimeTb.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseTimeTb.java index 111348db..e67dcac6 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseTimeTb.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseTimeTb.java @@ -13,27 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.base; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModelProperty; +import java.util.Date; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; -import java.util.Date; - @Getter @Setter @EqualsAndHashCode(callSuper = false) public class KitBaseTimeTb extends KitObject { - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date createTime; - @TableField(fill = FieldFill.INSERT_UPDATE) - @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) - private Date updateTime; + @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date updateTime; } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUpdateTimeTb.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUpdateTimeTb.java index 97908ae3..5158b49b 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUpdateTimeTb.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUpdateTimeTb.java @@ -13,23 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.base; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModelProperty; +import java.util.Date; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; -import java.util.Date; - @Getter @Setter @EqualsAndHashCode(callSuper = false) public class KitBaseUpdateTimeTb extends KitObject { @TableField(fill = FieldFill.INSERT_UPDATE) - @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) - private Date updateTime; + @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date updateTime; } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserCreateTimeTb.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserCreateTimeTb.java index 690d6e86..629b93c8 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserCreateTimeTb.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserCreateTimeTb.java @@ -13,33 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.base; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModelProperty; +import java.lang.reflect.Field; +import java.util.Date; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.builder.ToStringBuilder; import org.springframework.data.annotation.CreatedBy; -import java.lang.reflect.Field; -import java.util.Date; - @Getter @Setter @EqualsAndHashCode(callSuper = false) public class KitBaseUserCreateTimeTb extends KitObject { - - @CreatedBy - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建人", hidden = true) - private String createBy; - - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @CreatedBy @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建人", hidden = true) private String + createBy; + @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date createTime; @Override @@ -58,10 +51,8 @@ public class KitBaseUserCreateTimeTb extends KitObject { } /* 分组校验 */ - public @interface Create { - } + public @interface Create {} /* 分组校验 */ - public @interface Update { - } + public @interface Update {} } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeLogicTb.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeLogicTb.java index d3569589..abb04525 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeLogicTb.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeLogicTb.java @@ -13,20 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.base; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableLogic; import io.swagger.annotations.ApiModelProperty; +import java.util.Date; import lombok.Getter; import lombok.Setter; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.LastModifiedBy; -import java.util.Date; - /** * 逻辑删除通用模型 * @@ -36,22 +34,14 @@ import java.util.Date; @Getter @Setter public class KitBaseUserTimeLogicTb extends KitObject { - @CreatedBy - @TableField(value = "create_by", fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建人", hidden = true) - private String createBy; - @LastModifiedBy - @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) - @ApiModelProperty(value = "更新人", hidden = true) - private String updateBy; - @TableField(value = "create_time", fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间", hidden = true) + @CreatedBy @TableField(value = "create_by", fill = FieldFill.INSERT) + @ApiModelProperty(value = "创建人", hidden = true) private String createBy; + @LastModifiedBy @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE) + @ApiModelProperty(value = "更新人", hidden = true) private String updateBy; + @TableField(value = "create_time", fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间", hidden = true) private Date createTime; @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) - @ApiModelProperty(value = "更新时间", hidden = true) - private Date updateTime; - @ApiModelProperty(value = "数据有效性", hidden = true) - @TableLogic - @TableField("available") - private Integer available; + @ApiModelProperty(value = "更新时间", hidden = true) private Date updateTime; + @ApiModelProperty(value = "数据有效性", hidden = true) @TableLogic @TableField("available") private Integer + available; } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeTb.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeTb.java index 0867d6b6..f255e64b 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeTb.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitBaseUserTimeTb.java @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.base; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModelProperty; +import java.lang.reflect.Field; +import java.util.Date; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; @@ -26,31 +27,18 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.LastModifiedBy; -import java.lang.reflect.Field; -import java.util.Date; - @Getter @Setter @EqualsAndHashCode(callSuper = false) public class KitBaseUserTimeTb extends KitObject { - - @CreatedBy - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建人", hidden = true) - private String createBy; - - @LastModifiedBy - @TableField(fill = FieldFill.INSERT_UPDATE) - @ApiModelProperty(value = "更新人", hidden = true) + @CreatedBy @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建人", hidden = true) private String + createBy; + @LastModifiedBy @TableField(fill = FieldFill.INSERT_UPDATE) @ApiModelProperty(value = "更新人", hidden = true) private String updateBy; - - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date createTime; - @TableField(fill = FieldFill.INSERT_UPDATE) - @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) - private Date updateTime; + @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date updateTime; @Override public String toString() { @@ -68,10 +56,8 @@ public class KitBaseUserTimeTb extends KitObject { } /* 分组校验 */ - public @interface Create { - } + public @interface Create {} /* 分组校验 */ - public @interface Update { - } + public @interface Update {} } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitObject.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitObject.java index 5af930a1..e194c30f 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitObject.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitObject.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.base; import java.io.Serializable; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitPageArgs.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitPageArgs.java index 3f5e2da9..5fb068a2 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitPageArgs.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitPageArgs.java @@ -13,18 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.base; import io.swagger.annotations.ApiModelProperty; +import java.io.Serializable; +import javax.validation.constraints.Min; +import javax.validation.constraints.NotNull; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotNull; -import java.io.Serializable; - /** * 数据分页参数 * @@ -35,13 +33,9 @@ import java.io.Serializable; @NoArgsConstructor @AllArgsConstructor public class KitPageArgs implements Serializable { - @NotNull(message = "参数page不能为空") - @Min(value = 1, message = "参数page最小值为1") - @ApiModelProperty(value = "页码", example = "1") - private Integer page; - @NotNull(message = "参数size不能为空") - @Min(value = 1, message = "参数size最小值为1") - @ApiModelProperty(value = "每页数据量", example = "10") - private Integer size; + @NotNull(message = "参数page不能为空") @Min(value = 1, message = "参数page最小值为1") + @ApiModelProperty(value = "页码", example = "1") private Integer page; + @NotNull(message = "参数size不能为空") @Min(value = 1, message = "参数size最小值为1") + @ApiModelProperty(value = "每页数据量", example = "10") private Integer size; private T args; } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitPageResult.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitPageResult.java index 88ee1a48..78edd50a 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitPageResult.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitPageResult.java @@ -13,18 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.base; import com.baomidou.mybatisplus.core.metadata.IPage; +import java.util.ArrayList; +import java.util.List; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; -import java.util.ArrayList; -import java.util.List; - /** * 结果封装类 */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitSelectOptionVo.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitSelectOptionVo.java index fd37e725..84c3d64a 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitSelectOptionVo.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/base/KitSelectOptionVo.java @@ -13,12 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.base; -import lombok.*; - import java.util.Map; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; /** * 元数据选项 diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/CaptchaCodeEnum.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/CaptchaCodeEnum.java index 59d31da9..9cfe140a 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/CaptchaCodeEnum.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/CaptchaCodeEnum.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.constant; /** diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/FileTypeEnum.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/FileTypeEnum.java index b4620200..61fb6aaf 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/FileTypeEnum.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/FileTypeEnum.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.constant; import lombok.AllArgsConstructor; @@ -24,7 +23,6 @@ import lombok.Getter; public enum FileTypeEnum { /* 文件类型 */ IMAGE("image", "图片"), DOC("doc", "文档"), VOICE("voice", "音频"), VIDEO("video", "视频"), OTHER("other", "其他"); - private final String code; private final String description; } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/RequestMethodEnum.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/RequestMethodEnum.java index 74b1d5a8..5dc24b39 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/RequestMethodEnum.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/RequestMethodEnum.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.constant; import lombok.AllArgsConstructor; @@ -22,37 +21,30 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum RequestMethodEnum { - /** * 搜寻 @AnonymousGetMapping */ GET("GET"), - /** * 搜寻 @AnonymousPostMapping */ POST("POST"), - /** * 搜寻 @AnonymousPutMapping */ PUT("PUT"), - /** * 搜寻 @AnonymousPatchMapping */ PATCH("PATCH"), - /** * 搜寻 @AnonymousDeleteMapping */ DELETE("DELETE"), - /** * 否则就是所有 Request 接口都放行 */ ALL("All"); - /** * Request 类型 */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/SystemConst.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/SystemConst.java index b789f5b4..0773b662 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/SystemConst.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/constant/SystemConst.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.constant; /** @@ -24,22 +23,18 @@ public interface SystemConst { * win 系统 */ String WIN = "win"; - /** * mac 系统 */ String MAC = "mac"; - /** * 请求头名称 */ String HEADER_NAME = "Authorization"; - /** * Token前缀 */ String TOKEN_PREFIX = "Bearer"; - /** * 小数点 */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/BeanLoadFinishListener.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/BeanLoadFinishListener.java index 02865ec7..fe53a12d 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/BeanLoadFinishListener.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/BeanLoadFinishListener.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.context; import lombok.extern.slf4j.Slf4j; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/BootApplication.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/BootApplication.java index f92dac8b..8b020a14 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/BootApplication.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/BootApplication.java @@ -13,18 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.context; import cn.hutool.core.util.StrUtil; +import java.net.InetAddress; +import java.net.UnknownHostException; import lombok.extern.slf4j.Slf4j; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.Bean; import org.springframework.core.env.Environment; -import java.net.InetAddress; -import java.net.UnknownHostException; - /** * 主要目的是输出应用的服务地址 * @@ -37,9 +35,12 @@ public class BootApplication { Environment env = application.getEnvironment(); String ip = InetAddress.getLocalHost().getHostAddress(); String port = env.getProperty("server.port"); - String path = StrUtil.isEmpty(env.getProperty("config.servlet.context-path")) ? "" : env.getProperty("config.servlet.context-path"); - log.info( - "\n----------------------------------------------------------\n\t" + "Application is running! Access URLs:\n\t" + "Local: \t\thttp://localhost:" + port + path + "/\n\t" + "External: \thttp://" + ip + ":" + port + path + "/\n\t" + "Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n" + "----------------------------------------------------------"); + String path = StrUtil.isEmpty(env.getProperty("config.servlet.context-path")) ? "" + : env.getProperty("config.servlet.context-path"); + log.info("\n----------------------------------------------------------\n\t" + + "Application is running! Access URLs:\n\t" + "Local: \t\thttp://localhost:" + port + path + "/\n\t" + + "External: \thttp://" + ip + ":" + port + path + "/\n\t" + "Swagger文档: \thttp://" + ip + ":" + port + + path + "/doc.html\n" + "----------------------------------------------------------"); } @Bean diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/KitRequestHolder.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/KitRequestHolder.java index f7e9ca85..0eab3251 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/KitRequestHolder.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/KitRequestHolder.java @@ -1,4 +1,3 @@ - /* * Copyright 2021-2025 Odboy * @@ -14,21 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.context; +import java.util.Objects; +import javax.servlet.http.HttpServletRequest; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import javax.servlet.http.HttpServletRequest; -import java.util.Objects; - /** * 获取 HttpServletRequest */ public class KitRequestHolder { - public static HttpServletRequest getHttpServletRequest() { - return ((ServletRequestAttributes)Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); + return ((ServletRequestAttributes)Objects.requireNonNull( + RequestContextHolder.getRequestAttributes())).getRequest(); } } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/KitScriptHelper.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/KitScriptHelper.java index 6a7b7261..413781c6 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/KitScriptHelper.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/KitScriptHelper.java @@ -13,16 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.context; +import java.util.Map; import lombok.extern.slf4j.Slf4j; import org.mozilla.javascript.Context; import org.mozilla.javascript.Scriptable; import org.springframework.stereotype.Component; -import java.util.Map; - /** * 脚本工具 * diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/KitSpringBeanHolder.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/KitSpringBeanHolder.java index a9985df6..89d53e10 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/KitSpringBeanHolder.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/context/KitSpringBeanHolder.java @@ -13,9 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.context; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeansException; import org.springframework.beans.factory.DisposableBean; @@ -24,14 +26,9 @@ import org.springframework.context.ApplicationContextAware; import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - @Slf4j @SuppressWarnings({"unchecked", "all"}) public class KitSpringBeanHolder implements ApplicationContextAware, DisposableBean { - private static final List CALL_BACKS = new ArrayList<>(); private static ApplicationContext applicationContext = null; private static boolean addCallback = true; @@ -109,8 +106,8 @@ public class KitSpringBeanHolder implements ApplicationContextAware, DisposableB */ private static void assertContextInjected() { if (applicationContext == null) { - throw new IllegalStateException( - "applicaitonContext属性未注入, 请在applicationContext" + ".xml中定义SpringContextHolder或在SpringBoot启动类中注册SpringContextHolder."); + throw new IllegalStateException("applicaitonContext属性未注入, 请在applicationContext" + + ".xml中定义SpringContextHolder或在SpringBoot启动类中注册SpringContextHolder."); } } @@ -139,7 +136,8 @@ public class KitSpringBeanHolder implements ApplicationContextAware, DisposableB @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { if (KitSpringBeanHolder.applicationContext != null) { - log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + KitSpringBeanHolder.applicationContext); + log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + + KitSpringBeanHolder.applicationContext); } KitSpringBeanHolder.applicationContext = applicationContext; if (addCallback) { @@ -152,12 +150,10 @@ public class KitSpringBeanHolder implements ApplicationContextAware, DisposableB } interface CallBack { - /** * 回调执行方法 */ void executor(); - /** * 本回调任务名称 * diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/doc/SwaggerConfig.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/doc/SwaggerConfig.java index aa1bc6f0..9683484b 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/doc/SwaggerConfig.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/doc/SwaggerConfig.java @@ -13,12 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.doc; import cn.odboy.constant.SystemConst; import cn.odboy.framework.properties.AppProperties; import cn.odboy.util.KitAnonTagUtil; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; import org.springframework.beans.BeansException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -30,7 +35,11 @@ import org.springframework.util.ReflectionUtils; import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; -import springfox.documentation.service.*; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.ApiKey; +import springfox.documentation.service.AuthorizationScope; +import springfox.documentation.service.SecurityReference; +import springfox.documentation.service.SecurityScheme; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.service.contexts.SecurityContext; import springfox.documentation.spring.web.plugins.Docket; @@ -38,25 +47,15 @@ import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider; import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider; import springfox.documentation.swagger2.annotations.EnableSwagger2; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - /** * api页面 /doc.html */ @Configuration @EnableSwagger2 public class SwaggerConfig { - @Value("${server.servlet.context-path:}") - private String apiPath; - @Autowired - private AppProperties properties; - @Autowired - private ApplicationContext applicationContext; + @Value("${server.servlet.context-path:}") private String apiPath; + @Autowired private AppProperties properties; + @Autowired private ApplicationContext applicationContext; /** * 解决Springfox与SpringBoot集成后, WebMvcRequestHandlerProvider和WebFluxRequestHandlerProvider冲突问题 @@ -67,7 +66,6 @@ public class SwaggerConfig { @SuppressWarnings({"unchecked", "all"}) public static BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() { return new BeanPostProcessor() { - @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) { @@ -76,8 +74,10 @@ public class SwaggerConfig { return bean; } - private void customizeSpringfoxHandlerMappings(List mappings) { - List filteredMappings = mappings.stream().filter(mapping -> mapping.getPatternParser() == null).collect(Collectors.toList()); + private void customizeSpringfoxHandlerMappings( + List mappings) { + List filteredMappings = mappings.stream().filter(mapping -> mapping.getPatternParser() == null) + .collect(Collectors.toList()); mappings.clear(); mappings.addAll(filteredMappings); } @@ -99,14 +99,15 @@ public class SwaggerConfig { @Bean public Docket createRestApi() { - return new Docket(DocumentationType.SWAGGER_2).enable(properties.getSwagger().getEnabled()).pathMapping("/").apiInfo(apiInfo()).select() - .paths(PathSelectors.regex("^(?!/error).*")).paths(PathSelectors.any()).build() + return new Docket(DocumentationType.SWAGGER_2).enable(properties.getSwagger().getEnabled()).pathMapping("/") + .apiInfo(apiInfo()).select().paths(PathSelectors.regex("^(?!/error).*")).paths(PathSelectors.any()).build() //添加登陆认证 .securitySchemes(securitySchemes()).securityContexts(securityContexts()); } private ApiInfo apiInfo() { - return new ApiInfoBuilder().description("一个简单且易上手的自动化运维平台").title("CuteJava 接口文档").version("1.4.1").build(); + return new ApiInfoBuilder().description("一个简单且易上手的自动化运维平台").title("CuteJava 接口文档") + .version("1.4.1").build(); } private List securitySchemes() { @@ -128,9 +129,10 @@ public class SwaggerConfig { Set urls = KitAnonTagUtil.getAllAnonymousUrl(applicationContext); urls = urls.stream().filter(url -> !"/".equals(url)).collect(Collectors.toSet()); String regExp = "^(?!" + apiPath + String.join("|" + apiPath, urls) + ").*$"; - return SecurityContext.builder().securityReferences(defaultAuth()).operationSelector(o -> o.requestMappingPattern() - // 排除不需要认证的接口 - .matches(regExp)).build(); + return SecurityContext.builder().securityReferences(defaultAuth()) + .operationSelector(o -> o.requestMappingPattern() + // 排除不需要认证的接口 + .matches(regExp)).build(); } private List defaultAuth() { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/BadRequestException.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/BadRequestException.java index 9fa1d8d7..edb80bfe 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/BadRequestException.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/BadRequestException.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.exception; import lombok.Getter; @@ -26,7 +25,6 @@ import static org.springframework.http.HttpStatus.BAD_REQUEST; */ @Getter public class BadRequestException extends RuntimeException { - private Integer status = BAD_REQUEST.value(); public BadRequestException(String msg) { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/ServerException.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/ServerException.java index 3e061b6f..9a71814d 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/ServerException.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/ServerException.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.exception; import lombok.Getter; @@ -23,7 +22,6 @@ import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR; @Getter public class ServerException extends RuntimeException { - private Integer status = INTERNAL_SERVER_ERROR.value(); public ServerException(String msg) { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/handler/ApiError.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/handler/ApiError.java index c941a029..4cacdf3c 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/handler/ApiError.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/handler/ApiError.java @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.exception.handler; import lombok.Data; @Data public final class ApiError { - private Integer status = 400; private Long timestamp; private String message; @@ -42,5 +40,3 @@ public final class ApiError { return apiError; } } - - diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/handler/GlobalExceptionHandler.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/handler/GlobalExceptionHandler.java index fba3713c..da62c889 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/handler/GlobalExceptionHandler.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/exception/handler/GlobalExceptionHandler.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.exception.handler; import cn.hutool.core.exceptions.ExceptionUtil; @@ -36,7 +35,6 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; @Slf4j @RestControllerAdvice public class GlobalExceptionHandler { - /** * 处理所有不可知的异常 */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/logging/ExecutionTimeStatisticsFace.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/logging/ExecutionTimeStatisticsFace.java index e395b380..8892b533 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/logging/ExecutionTimeStatisticsFace.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/logging/ExecutionTimeStatisticsFace.java @@ -13,10 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.logging; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * 统计执行时长 @@ -32,7 +36,6 @@ public @interface ExecutionTimeStatisticsFace { * 接口描述 */ String description(); - /** * 是否展示异常日志 */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/logging/ExecutionTimeStatisticsFaceAspect.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/logging/ExecutionTimeStatisticsFaceAspect.java index 33098f65..334a4581 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/logging/ExecutionTimeStatisticsFaceAspect.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/logging/ExecutionTimeStatisticsFaceAspect.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.logging; import cn.hutool.core.date.TimeInterval; @@ -34,15 +33,18 @@ import org.springframework.stereotype.Component; @Component public class ExecutionTimeStatisticsFaceAspect { @Around("@annotation(executionTimeStatisticsFace)") - public Object aroundFace(ProceedingJoinPoint joinPoint, ExecutionTimeStatisticsFace executionTimeStatisticsFace) throws Throwable { + public Object aroundFace(ProceedingJoinPoint joinPoint, ExecutionTimeStatisticsFace executionTimeStatisticsFace) + throws Throwable { TimeInterval timeInterval = new TimeInterval(); try { Object proceed = joinPoint.proceed(); - log.info("[{}] 接口执行成功,耗时: {} ms", executionTimeStatisticsFace.description(), timeInterval.intervalMs()); + log.info("[{}] 接口执行成功,耗时: {} ms", executionTimeStatisticsFace.description(), + timeInterval.intervalMs()); return proceed; } catch (Exception e) { if (executionTimeStatisticsFace.showErrLog()) { - log.error("[{}] 接口执行失败,耗时: {} ms", executionTimeStatisticsFace.description(), timeInterval.intervalMs(), e); + log.error("[{}] 接口执行失败,耗时: {} ms", executionTimeStatisticsFace.description(), + timeInterval.intervalMs(), e); } throw e; } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/monitor/controller/HealthCheckController.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/monitor/controller/HealthCheckController.java index 4678e5e5..3ef405c3 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/monitor/controller/HealthCheckController.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/monitor/controller/HealthCheckController.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.monitor.controller; import cn.odboy.annotation.AnonymousGetMapping; @@ -31,8 +30,7 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("/healthCheck") @Api(tags = "系统:健康检查接口") public class HealthCheckController { - @Autowired - private KitHealthCheckPointService kitHealthCheckPointService; + @Autowired private KitHealthCheckPointService kitHealthCheckPointService; /** * 就绪检查 @@ -49,7 +47,6 @@ public class HealthCheckController { public ResponseEntity doLiveness() { return kitHealthCheckPointService.doLiveness(); } - // /** // * 访问首页提示 // */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/monitor/service/KitHealthCheckPointService.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/monitor/service/KitHealthCheckPointService.java index 5bc653f2..0be89fe5 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/monitor/service/KitHealthCheckPointService.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/monitor/service/KitHealthCheckPointService.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.monitor.service; import org.springframework.http.ResponseEntity; @@ -23,7 +22,6 @@ public interface KitHealthCheckPointService { * 就绪检查 */ ResponseEntity doReadiness(); - /** * 存活检查 */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/DataTypeEnum.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/DataTypeEnum.java index b227d6a6..ebc17e56 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/DataTypeEnum.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/DataTypeEnum.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.mybatisplus.config; import cn.odboy.framework.exception.BadRequestException; @@ -94,7 +93,8 @@ public enum DataTypeEnum { private String aliasPrefix; private String aliasSuffix; - DataTypeEnum(String feature, String desc, String driver, String keywordPrefix, String keywordSuffix, String aliasPrefix, String aliasSuffix) { + DataTypeEnum(String feature, String desc, String driver, String keywordPrefix, String keywordSuffix, + String aliasPrefix, String aliasSuffix) { this.feature = feature; this.desc = desc; this.driver = driver; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/KitMpQTypeEnum.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/KitMpQTypeEnum.java index ca02032a..c51b50c4 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/KitMpQTypeEnum.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/KitMpQTypeEnum.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.mybatisplus.config; /** diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/KitMpQuery.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/KitMpQuery.java index c660a854..08dadb40 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/KitMpQuery.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/KitMpQuery.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.mybatisplus.config; import java.lang.annotation.ElementType; @@ -33,12 +32,10 @@ public @interface KitMpQuery { * 基本对象的属性名 */ String propName() default ""; - /** * 查询方式 */ KitMpQTypeEnum type() default KitMpQTypeEnum.EQUAL; - /** * 多字段模糊搜索, 仅支持String类型字段, 多个用逗号隔开, 如@MpQuery(blurry = "email,username") */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MpCustomP6SpyLogger.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MpCustomP6SpyLogger.java index 58e10452..37fa8063 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MpCustomP6SpyLogger.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MpCustomP6SpyLogger.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.mybatisplus.config; import cn.hutool.core.util.StrUtil; @@ -55,13 +54,14 @@ public class MpCustomP6SpyLogger implements MessageFormattingStrategy { * @return 格式化后的sql */ @Override - public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) { + public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, + String sql, String url) { // 去掉换行和多余空格 if (StrUtil.isNotBlank(sql)) { sql = sql.replaceAll("\\s+", " ").trim(); } // 格式化并加上颜色 - return String.format("CuteJava - %s%s%s %s[%s] %sREVIEW_SQL [Interval: %dms]%s -> %s;", RED, now, RESET, GREEN, Thread.currentThread().getName(), BLUE, - elapsed, RESET, sql); + return String.format("CuteJava - %s%s%s %s[%s] %sREVIEW_SQL [Interval: %dms]%s -> %s;", RED, now, RESET, GREEN, + Thread.currentThread().getName(), BLUE, elapsed, RESET, sql); } } \ No newline at end of file diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MpInsertBatchSqlInjector.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MpInsertBatchSqlInjector.java index 6cf2cacf..71bcff71 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MpInsertBatchSqlInjector.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MpInsertBatchSqlInjector.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.mybatisplus.config; import com.baomidou.mybatisplus.annotation.FieldFill; @@ -22,9 +21,8 @@ import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector; import com.baomidou.mybatisplus.core.metadata.TableInfo; import com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById; import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn; -import org.apache.ibatis.session.Configuration; - import java.util.List; +import org.apache.ibatis.session.Configuration; /** * 批量插入SQL注入器 diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MybatisPlusConfig.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MybatisPlusConfig.java index be54eea8..b119884d 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MybatisPlusConfig.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/MybatisPlusConfig.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.mybatisplus.config; import com.baomidou.mybatisplus.annotation.DbType; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/RemoveDruidAdConfig.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/RemoveDruidAdConfig.java index b03dfd72..f5abd6e0 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/RemoveDruidAdConfig.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/config/RemoveDruidAdConfig.java @@ -13,12 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.mybatisplus.config; import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties; import com.alibaba.druid.util.Utils; +import java.io.IOException; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import org.springframework.boot.autoconfigure.AutoConfigureAfter; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; @@ -26,18 +34,13 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import javax.servlet.*; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - @Configuration @SuppressWarnings({"unchecked", "all"}) @ConditionalOnWebApplication @AutoConfigureAfter(DruidDataSourceAutoConfigure.class) -@ConditionalOnProperty(name = "spring.datasource.druid.stat-view-servlet.enabled", havingValue = "true", matchIfMissing = true) +@ConditionalOnProperty(name = "spring.datasource.druid.stat-view-servlet.enabled", havingValue = "true", + matchIfMissing = true) public class RemoveDruidAdConfig { - /** * 方法名: removeDruidAdFilterRegistrationBean 方法描述 除去页面底部的广告 * @@ -46,15 +49,12 @@ public class RemoveDruidAdConfig { */ @Bean public FilterRegistrationBean removeDruidAdFilterRegistrationBean(DruidStatProperties properties) { - // 获取web监控页面的参数 DruidStatProperties.StatViewServlet config = properties.getStatViewServlet(); // 提取common.js的配置路径 String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*"; String commonJsPattern = pattern.replaceAll("\\*", "js/common.js"); - final String filePath = "support/http/resources/js/common.js"; - //创建filter进行过滤 Filter filter = new Filter() { @Override @@ -62,7 +62,8 @@ public class RemoveDruidAdConfig { } @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest)request; HttpServletResponse httpResponse = (HttpServletResponse)response; if (httpRequest.getRequestURI().endsWith("js/common.js")) { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpAnyQUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpAnyQUtil.java index 644a89c6..e33d4a33 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpAnyQUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpAnyQUtil.java @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.mybatisplus.core; import cn.hutool.core.bean.BeanUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; - import java.util.ArrayList; import java.util.List; @@ -69,7 +67,8 @@ public class KitMpAnyQUtil { return baseMapper.selectPage(page, queryWrapper); } - public static Page selectPage(BaseMapper baseMapper, Page page, Object queryParams, Class mapperClazz) { + public static Page selectPage(BaseMapper baseMapper, Page page, Object queryParams, + Class mapperClazz) { QueryWrapper queryWrapper = KitMpQUtil.build(queryParams); Page tPage = baseMapper.selectPage(page, queryWrapper); Page mapperTarget = new Page<>(); diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpCmdGenUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpCmdGenUtil.java index 6ada1734..46fb5d7d 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpCmdGenUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/KitMpCmdGenUtil.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.mybatisplus.core; import cn.hutool.core.util.StrUtil; @@ -21,7 +20,12 @@ import cn.odboy.base.KitBaseUserTimeTb; import cn.odboy.framework.exception.BadRequestException; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.generator.FastAutoGenerator; -import com.baomidou.mybatisplus.generator.config.*; +import com.baomidou.mybatisplus.generator.config.DataSourceConfig; +import com.baomidou.mybatisplus.generator.config.GlobalConfig; +import com.baomidou.mybatisplus.generator.config.IDbQuery; +import com.baomidou.mybatisplus.generator.config.OutputFile; +import com.baomidou.mybatisplus.generator.config.PackageConfig; +import com.baomidou.mybatisplus.generator.config.StrategyConfig; import com.baomidou.mybatisplus.generator.config.querys.MySqlQuery; import com.baomidou.mybatisplus.generator.config.rules.DateType; import com.baomidou.mybatisplus.generator.config.rules.DbColumnType; @@ -29,13 +33,12 @@ import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; import com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine; import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; import com.baomidou.mybatisplus.generator.keywords.MySqlKeyWordsHandler; -import lombok.Data; -import org.apache.ibatis.annotations.Mapper; - import java.sql.Types; import java.util.Collections; import java.util.List; import java.util.function.Consumer; +import lombok.Data; +import org.apache.ibatis.annotations.Mapper; /** * 代码生成器入口 @@ -67,14 +70,16 @@ public class KitMpCmdGenUtil { private static Consumer getEntityConfigConsumer() { return strategyConfigBuilder -> strategyConfigBuilder.entityBuilder().enableLombok() // 如果不需要生成注解, 去掉.enableTableFieldAnnotation() - .enableTableFieldAnnotation().enableFileOverride().naming(NamingStrategy.underline_to_camel).columnNaming(NamingStrategy.underline_to_camel) - .idType(IdType.AUTO); + .enableTableFieldAnnotation().enableFileOverride().naming(NamingStrategy.underline_to_camel) + .columnNaming(NamingStrategy.underline_to_camel).idType(IdType.AUTO); } private static Consumer getStrategyConfigConsumer(List tableNames) { - return strategyConfigBuilder -> strategyConfigBuilder.enableCapitalMode().enableSkipView().disableSqlFilter().addInclude(tableNames) + return strategyConfigBuilder -> strategyConfigBuilder.enableCapitalMode().enableSkipView().disableSqlFilter() + .addInclude(tableNames) // 实体类生成策略 - .entityBuilder().superClass(KitBaseUserTimeTb.class).addIgnoreColumns("create_time", "update_time", "create_by", "update_by") + .entityBuilder().superClass(KitBaseUserTimeTb.class) + .addIgnoreColumns("create_time", "update_time", "create_by", "update_by") // 开启生成实体时生成字段注解。 // 会在实体类的属性前,添加[@TableField("nickname")] .enableTableFieldAnnotation().disableSerialVersionUID() @@ -99,13 +104,13 @@ public class KitMpCmdGenUtil { private static Consumer getGlobalConfigConsumer() { String outputDir = projectRootPath + "CodeGen"; - return globalConfigBuilder -> globalConfigBuilder.enableSwagger().outputDir(outputDir).author("codegen").commentDate("yyyy-MM-dd") - .dateType(DateType.TIME_PACK); + return globalConfigBuilder -> globalConfigBuilder.enableSwagger().outputDir(outputDir).author("codegen") + .commentDate("yyyy-MM-dd").dateType(DateType.TIME_PACK); } private static Consumer getStrategyConfigConsumer() { - return strategyConfigBuilder -> strategyConfigBuilder.mapperBuilder().mapperAnnotation(Mapper.class).formatMapperFileName("%sMapper") - .formatXmlFileName("%sMapper").entityBuilder().formatFileName("%sTb"); + return strategyConfigBuilder -> strategyConfigBuilder.mapperBuilder().mapperAnnotation(Mapper.class) + .formatMapperFileName("%sMapper").formatXmlFileName("%sMapper").entityBuilder().formatFileName("%sTb"); } private static Consumer getDataSourceConfigConsumer() { @@ -138,7 +143,8 @@ public class KitMpCmdGenUtil { this.parentModuleName = moduleName; // 1.数据库配置 DataSourceConfig.Builder dataSourceConfigBuilder = - new DataSourceConfig.Builder(this.databaseUrl, this.databaseUsername, this.databasePassword).driverClassName(this.driverClassName); + new DataSourceConfig.Builder(this.databaseUrl, this.databaseUsername, + this.databasePassword).driverClassName(this.driverClassName); dataSourceConfigBuilder.dbQuery(DB_QUERY); dataSourceConfigBuilder.keyWordsHandler(new MySqlKeyWordsHandler()); // 1.1.快速生成器 @@ -168,7 +174,8 @@ public class KitMpCmdGenUtil { fastAutoGenerator.strategyConfig(getStrategyConfigConsumer(tableNames)); if (tablePrefix != null) { // 表前缀, 可多个 - fastAutoGenerator.strategyConfig(strategyConfigBuilder -> strategyConfigBuilder.addTablePrefix(tablePrefix)); + fastAutoGenerator.strategyConfig( + strategyConfigBuilder -> strategyConfigBuilder.addTablePrefix(tablePrefix)); } // 5.1.Entity策略配置 // 生成实体时生成字段的注解, 包括@TableId注解等 @@ -178,10 +185,13 @@ public class KitMpCmdGenUtil { fastAutoGenerator.strategyConfig(getEntityConfigConsumer()); // 5.2.Controller策略配置 // 开启生成@RestController控制器 - fastAutoGenerator.strategyConfig(strategyConfigBuilder -> strategyConfigBuilder.controllerBuilder().enableRestStyle()); - // 如果不需要生成Controller, fastAutoGenerator.templateConfig(templateConfig -> templateConfig.controller(""))。5.3.Service策略配置:格式化service接口和实现类的文件名称, 去掉默认的ServiceName前面的I fastAutoGenerator.strategyConfig( - strategyConfigBuilder -> strategyConfigBuilder.serviceBuilder().formatServiceFileName("%sService").formatServiceImplFileName("%sServiceImpl")); + strategyConfigBuilder -> strategyConfigBuilder.controllerBuilder().enableRestStyle()); + // 如果不需要生成Controller, fastAutoGenerator.templateConfig(templateConfig -> templateConfig.controller(""))。5.3 + // .Service策略配置:格式化service接口和实现类的文件名称, 去掉默认的ServiceName前面的I + fastAutoGenerator.strategyConfig( + strategyConfigBuilder -> strategyConfigBuilder.serviceBuilder().formatServiceFileName("%sService") + .formatServiceImplFileName("%sServiceImpl")); // 5.4.Mapper策略配置 // 格式化 mapper文件名,格式化xml实现类文件名称 fastAutoGenerator.strategyConfig(getStrategyConfigConsumer()); @@ -194,8 +204,9 @@ public class KitMpCmdGenUtil { if (StrUtil.isBlank(this.parentModuleName)) { throw new BadRequestException("模块名称必填"); } - return packageConfigBuilder -> packageConfigBuilder.parent(this.parentPackageName).moduleName(this.parentModuleName).entity("dal.dataobject") - .mapper("dal.mysql").service("service").serviceImpl("service.impl").controller("controller") + return packageConfigBuilder -> packageConfigBuilder.parent(this.parentPackageName) + .moduleName(this.parentModuleName).entity("dal.dataobject").mapper("dal.mysql").service("service") + .serviceImpl("service.impl").controller("controller") .pathInfo(Collections.singletonMap(OutputFile.xml, mapperPath)); } } \ No newline at end of file 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 daa304ba..c2c909df 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.mybatisplus.core; import cn.hutool.core.collection.CollectionUtil; @@ -27,13 +26,16 @@ 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 lombok.extern.slf4j.Slf4j; - +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import java.util.Optional; +import java.util.stream.Collectors; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; -import java.lang.reflect.Field; -import java.util.*; -import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; /** * 查询条件创建工具 @@ -78,7 +80,8 @@ public class KitMpQUtil { return StrUtil.toUnderlineCase(attributeName); } - private static void handleWrapper(KitMpQuery q, QueryWrapper queryWrapper, String attributeName, Object fieldVal) { + private static void handleWrapper(KitMpQuery q, QueryWrapper queryWrapper, String attributeName, + Object fieldVal) { switch (q.type()) { case EQUAL: queryWrapper.eq(attributeName, fieldVal); @@ -124,7 +127,8 @@ public class KitMpQUtil { } } - private static void handleInOrNotQuery(boolean b, QueryWrapper queryWrapper, String attributeName, Object fieldVal) { + private static void handleInOrNotQuery(boolean b, QueryWrapper queryWrapper, String attributeName, + Object fieldVal) { Collection wrapNotInVal = (Collection)fieldVal; if (CollectionUtil.isNotEmpty(wrapNotInVal)) { Optional anyValOptional = wrapNotInVal.stream().findAny(); @@ -149,7 +153,8 @@ public class KitMpQUtil { } } - private static void handleBetweenQuery(QueryWrapper queryWrapper, Object fieldVal, String finalAttributeName) { + private static void handleBetweenQuery(QueryWrapper queryWrapper, Object fieldVal, + String finalAttributeName) { if (fieldVal instanceof List) { List between = new ArrayList<>((List)fieldVal); int minLength = 2; @@ -172,7 +177,8 @@ public class KitMpQUtil { * @param / */ private static void handleBlurryQuery(QueryWrapper queryWrapper, String blurry, Object fieldVal) { - List blurryList = Arrays.stream(blurry.split(",")).filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList()); + List blurryList = + Arrays.stream(blurry.split(",")).filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList()); queryWrapper.and(wrapper -> { for (String blurryItem : blurryList) { String column = StrUtil.toUnderlineCase(blurryItem); @@ -209,14 +215,10 @@ public class KitMpQUtil { @TableName("test_domain") private static class TestDomain { - @NotNull(groups = KitBaseUserTimeTb.Update.class) - @TableId(value = "user_id", type = IdType.AUTO) - private Long id; - @TableField(value = "dept_id") - private Long deptId; - @NotBlank - private String username; - @NotBlank - private String nickName; + @NotNull(groups = KitBaseUserTimeTb.Update.class) @TableId(value = "user_id", type = IdType.AUTO) private Long + id; + @TableField(value = "dept_id") private Long deptId; + @NotBlank private String username; + @NotBlank private String nickName; } } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpMapper.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpMapper.java index fed74bed..c644c42d 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpMapper.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpMapper.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.mybatisplus.core.interfaces; import cn.hutool.core.bean.BeanUtil; @@ -26,15 +25,14 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Param; -import org.springframework.data.domain.Pageable; - import java.lang.reflect.Field; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.domain.Pageable; /** * 公共抽象Mapper接口类 @@ -50,7 +48,6 @@ public interface KitMpMapper extends BaseMapper { * @return 影响的行数 */ int insertBatchSomeColumn(List entityList); - /** * 根据id全量更新 * @@ -58,7 +55,6 @@ public interface KitMpMapper extends BaseMapper { * @return 影响的行数 */ int alwaysUpdateSomeColumnById(@Param("et") E entity); - /** * 获取字典 * @@ -98,7 +94,6 @@ public interface KitMpMapper extends BaseMapper { } return result; } - /** * 条件查询列表, 并返回期望的对象 * @@ -113,7 +108,6 @@ public interface KitMpMapper extends BaseMapper { } return BeanUtil.copyToList(list, clazz); } - /** * 条件查询列表, 并返回期望的对象 * @@ -128,7 +122,6 @@ public interface KitMpMapper extends BaseMapper { } return BeanUtil.copyToList(list, clazz); } - /** * 条件查询分页列表, 并返回期望的对象 * @@ -137,7 +130,8 @@ public interface KitMpMapper extends BaseMapper { * @param clazz 期望的对象类型 * @return IPage */ - default KitPageResult queryFeatureClazzPage(Pageable pageable, LambdaQueryWrapper wrapper, Class clazz) { + default KitPageResult queryFeatureClazzPage(Pageable pageable, LambdaQueryWrapper wrapper, + Class clazz) { int pageNumber = pageable.getPageNumber(); int pageSize = pageable.getPageSize(); pageNumber = pageNumber <= 0 ? 1 : pageNumber; @@ -148,7 +142,6 @@ public interface KitMpMapper extends BaseMapper { } return new KitPageResult<>(BeanUtil.copyToList(pageInfo.getRecords(), clazz), pageInfo.getTotal()); } - /** * 条件查询分页列表, 并返回期望的对象 * @@ -157,7 +150,8 @@ public interface KitMpMapper extends BaseMapper { * @param clazz 期望的对象类型 * @return IPage */ - default KitPageResult queryFeatureClazzPage(Pageable pageable, LambdaQueryChainWrapper wrapper, Class clazz) { + default KitPageResult queryFeatureClazzPage(Pageable pageable, LambdaQueryChainWrapper wrapper, + Class clazz) { int pageNumber = pageable.getPageNumber(); int pageSize = pageable.getPageSize(); pageNumber = pageNumber <= 0 ? 1 : pageNumber; @@ -168,7 +162,6 @@ public interface KitMpMapper extends BaseMapper { } return new KitPageResult<>(BeanUtil.copyToList(pageInfo.getRecords(), clazz), pageInfo.getTotal()); } - /** * 获取目标类 * diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpService.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpService.java index d75208ef..a3d2450b 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpService.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpService.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.mybatisplus.core.interfaces; import cn.odboy.base.KitPageResult; @@ -21,7 +20,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.service.IService; - import java.io.Serializable; import java.util.Collection; import java.util.List; @@ -34,38 +32,22 @@ import java.util.List; */ public interface KitMpService extends IService { int saveFeatureClazz(G resources); - int saveFeatureClazzList(List resources); - int modifyFeatureClazzById(G resources); - boolean modifyFeatureClazzListById(Collection resources, int batchSize); - G queryFeatureClazzById(Serializable id, Class targetClazz); - T queryClazzByArgs(LambdaQueryWrapper wrapper, SFunction orderColumn); - G queryFeatureClazzByArgs(LambdaQueryWrapper wrapper, SFunction orderColumn, Class clazz); - List queryFeatureClazzListByIds(List ids, Class targetClazz); - List queryClazzListByArgs(Q criteria); - List queryClazzListByArgs(LambdaQueryWrapper wrapper); - List queryFeatureClazzListByArgs(Q criteria, Class targetClazz); - List queryFeatureClazzListByArgs(LambdaQueryWrapper wrapper, Class targetClazz); - KitPageResult queryClazzPageByArgs(LambdaQueryWrapper wrapper, IPage pageable); - - KitPageResult queryFeatureClazzPageByArgs(LambdaQueryWrapper wrapper, IPage pageable, Class targetClazz); - + KitPageResult queryFeatureClazzPageByArgs(LambdaQueryWrapper wrapper, IPage pageable, + Class targetClazz); KitPageResult queryFeatureClazzPageByArgs(Q criteria, IPage pageable, Class targetClazz); - KitPageResult queryClazzPageByArgs(Q criteria, IPage pageable); - int modifyClazzByArgs(LambdaQueryWrapper wrapper, T entity); - int removeClazzByArgs(LambdaQueryWrapper wrapper); } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpServiceImpl.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpServiceImpl.java index 75a881f2..70f5da5e 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpServiceImpl.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/mybatisplus/core/interfaces/KitMpServiceImpl.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.mybatisplus.core.interfaces; import cn.hutool.core.bean.BeanUtil; @@ -27,11 +26,10 @@ import com.baomidou.mybatisplus.core.enums.SqlMethod; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.apache.ibatis.binding.MapperMethod; - import java.io.Serializable; import java.util.Collection; import java.util.List; +import org.apache.ibatis.binding.MapperMethod; /** * 公共抽象Mapper接口类 @@ -138,7 +136,8 @@ public class KitMpServiceImpl, T> extends ServiceImpl List queryFeatureClazzListByIds(List ids, Class targetClazz) { List entitys = this.listByIds(ids); - return entitys == null || entitys.isEmpty() ? CollUtil.newArrayList() : BeanUtil.copyToList(entitys, targetClazz); + return entitys == null || entitys.isEmpty() ? CollUtil.newArrayList() + : BeanUtil.copyToList(entitys, targetClazz); } /** @@ -209,18 +208,21 @@ public class KitMpServiceImpl, T> extends ServiceImpl KitPageResult queryFeatureClazzPageByArgs(LambdaQueryWrapper wrapper, IPage pageable, Class targetClazz) { + public KitPageResult queryFeatureClazzPageByArgs(LambdaQueryWrapper wrapper, IPage pageable, + Class targetClazz) { if (wrapper == null) { wrapper = new LambdaQueryWrapper<>(); } IPage originPageData = baseMapper.selectPage(pageable, wrapper); - return new KitPageResult<>(BeanUtil.copyToList(originPageData.getRecords(), targetClazz), originPageData.getTotal()); + return new KitPageResult<>(BeanUtil.copyToList(originPageData.getRecords(), targetClazz), + originPageData.getTotal()); } public KitPageResult queryFeatureClazzPageByArgs(Q criteria, IPage pageable, Class targetClazz) { QueryWrapper wrapper = KitMpQUtil.build(criteria); IPage originPageData = baseMapper.selectPage(pageable, wrapper); - return new KitPageResult<>(BeanUtil.copyToList(originPageData.getRecords(), targetClazz), originPageData.getTotal()); + return new KitPageResult<>(BeanUtil.copyToList(originPageData.getRecords(), targetClazz), + originPageData.getTotal()); } public KitPageResult queryClazzPageByArgs(Q criteria, IPage pageable) { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/AppProperties.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/AppProperties.java index f43fe927..8a2c8f5c 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/AppProperties.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/AppProperties.java @@ -13,10 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.properties; -import cn.odboy.framework.properties.model.*; +import cn.odboy.framework.properties.model.CaptchaModel; +import cn.odboy.framework.properties.model.ContentRsaEncodeSettingModel; +import cn.odboy.framework.properties.model.JwtAuthSettingModel; +import cn.odboy.framework.properties.model.StorageOSSModel; +import cn.odboy.framework.properties.model.SwaggerApiDocSettingModel; +import cn.odboy.framework.properties.model.ThreadPoolSettingModel; +import cn.odboy.framework.properties.model.UserLoginSettingModel; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @@ -39,5 +44,3 @@ public class AppProperties { private CaptchaModel captcha; private StorageOSSModel oss; } - - diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/CaptchaModel.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/CaptchaModel.java index e73289d3..43a576e0 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/CaptchaModel.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/CaptchaModel.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.properties.model; import cn.odboy.base.KitObject; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ContentRsaEncodeSettingModel.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ContentRsaEncodeSettingModel.java index e8ebaca4..8314996b 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ContentRsaEncodeSettingModel.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ContentRsaEncodeSettingModel.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.properties.model; import cn.odboy.base.KitObject; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/JwtAuthSettingModel.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/JwtAuthSettingModel.java index af2e001f..df2f75cf 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/JwtAuthSettingModel.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/JwtAuthSettingModel.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.properties.model; import cn.odboy.base.KitObject; @@ -30,17 +29,14 @@ public class JwtAuthSettingModel extends KitObject { * 必须使用最少88位的Base64对该令牌进行编码 */ private String base64Secret; - /** * 令牌过期时间 此处单位/毫秒 */ private Long tokenValidityInSeconds; - /** * token 续期检查 */ private Long detect; - /** * 续期时间 */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/OSSConfigModel.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/OSSConfigModel.java index 6826e02e..5a0e846f 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/OSSConfigModel.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/OSSConfigModel.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.properties.model; import cn.odboy.base.KitObject; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/StorageOSSModel.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/StorageOSSModel.java index e2fc9834..e9675120 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/StorageOSSModel.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/StorageOSSModel.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.properties.model; import lombok.Getter; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/SwaggerApiDocSettingModel.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/SwaggerApiDocSettingModel.java index 35086c05..75e3d49a 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/SwaggerApiDocSettingModel.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/SwaggerApiDocSettingModel.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.properties.model; import cn.odboy.base.KitObject; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ThreadPoolSettingModel.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ThreadPoolSettingModel.java index b281df1f..5131ddcb 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ThreadPoolSettingModel.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/ThreadPoolSettingModel.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.properties.model; import cn.odboy.base.KitObject; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginCaptchaSettingModel.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginCaptchaSettingModel.java index 22757c8e..77e9c0fc 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginCaptchaSettingModel.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginCaptchaSettingModel.java @@ -13,20 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.properties.model; import cn.hutool.core.util.StrUtil; import cn.odboy.base.KitObject; import cn.odboy.constant.CaptchaCodeEnum; import cn.odboy.framework.exception.BadRequestException; -import com.wf.captcha.*; +import com.wf.captcha.ArithmeticCaptcha; +import com.wf.captcha.ChineseCaptcha; +import com.wf.captcha.ChineseGifCaptcha; +import com.wf.captcha.GifCaptcha; +import com.wf.captcha.SpecCaptcha; import com.wf.captcha.base.Captcha; +import java.awt.Font; import lombok.Getter; import lombok.Setter; -import java.awt.*; - /** * 验证码配置 * @@ -36,32 +38,26 @@ import java.awt.*; @Setter public class UserLoginCaptchaSettingModel extends KitObject { private CaptchaCodeEnum codeType; - /** * 验证码有效期 分钟 */ private Long expiration = 5L; - /** * 验证码内容长度 */ private int length = 4; - /** * 验证码宽度 */ private int width = 111; - /** * 验证码高度 */ private int height = 36; - /** * 验证码字体 */ private String fontName; - /** * 字体大小 */ @@ -116,15 +112,12 @@ public class UserLoginCaptchaSettingModel extends KitObject { // 生成随机数字和运算符 int n1 = num(1, 10), n2 = num(1, 10); int opt = num(3); - // 计算结果 int res = new int[] {n1 + n2, n1 - n2, n1 * n2}[opt]; // 转换为字符运算符 char optChar = "+-x".charAt(opt); - this.setArithmeticString(String.format("%s%c%s=?", n1, optChar, n2)); this.chars = String.valueOf(res); - return chars.toCharArray(); } } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginSettingModel.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginSettingModel.java index 9fe412d4..7519d0ee 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginSettingModel.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/properties/model/UserLoginSettingModel.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.properties.model; import cn.odboy.base.KitObject; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/quartz/config/QuartzConfig.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/quartz/config/QuartzConfig.java index 96327801..2ef9afc5 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/quartz/config/QuartzConfig.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/quartz/config/QuartzConfig.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.quartz.config; import lombok.extern.slf4j.Slf4j; @@ -38,7 +37,6 @@ public class QuartzConfig { */ @Component("quartzJobFactory") public static class QuartzJobFactory extends AdaptableJobFactory { - private final AutowireCapableBeanFactory autowireCapableBeanFactory; @Autowired 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 42d9028e..ae613bf8 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 @@ -13,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.quartz.core; import cn.odboy.framework.context.KitSpringBeanHolder; +import java.lang.reflect.Method; +import java.util.concurrent.Callable; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.util.ReflectionUtils; -import java.lang.reflect.Method; -import java.util.concurrent.Callable; - /** * 执行定时任务 */ @@ -33,7 +31,8 @@ public class QuartzRunnable implements Callable { private final Method method; private final String params; - public QuartzRunnable(String beanName, String methodName, String params) throws NoSuchMethodException, SecurityException { + public QuartzRunnable(String beanName, String methodName, String params) + throws NoSuchMethodException, SecurityException { this.target = KitSpringBeanHolder.getBean(beanName); this.params = params; if (StringUtils.isNotBlank(params)) { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/redis/KitRedisHelper.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/redis/KitRedisHelper.java index 442dc4ff..ddcd52a4 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/redis/KitRedisHelper.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/redis/KitRedisHelper.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.redis; import cn.hutool.core.util.ObjUtil; @@ -21,23 +20,32 @@ import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson2.JSON; import com.google.common.collect.Lists; import com.google.common.collect.Sets; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.core.*; +import org.springframework.data.redis.core.ConvertingCursor; +import org.springframework.data.redis.core.Cursor; +import org.springframework.data.redis.core.RedisCallback; +import org.springframework.data.redis.core.RedisConnectionUtils; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.stereotype.Component; -import java.util.*; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - @Component @SuppressWarnings({"unchecked", "all"}) public class KitRedisHelper { private static final Logger log = LoggerFactory.getLogger(KitRedisHelper.class); - private RedisTemplate redisTemplate; public KitRedisHelper(RedisTemplate redisTemplate) { @@ -205,14 +213,13 @@ public class KitRedisHelper { public void scanDel(String pattern) { ScanOptions options = ScanOptions.scanOptions().match(pattern).build(); try (Cursor cursor = redisTemplate.executeWithStickyConnection( - (RedisCallback>)connection -> (Cursor)new ConvertingCursor<>(connection.scan(options), - redisTemplate.getKeySerializer()::deserialize))) { + (RedisCallback>)connection -> (Cursor)new ConvertingCursor<>( + connection.scan(options), redisTemplate.getKeySerializer()::deserialize))) { while (cursor.hasNext()) { redisTemplate.delete(cursor.next()); } } } - // ============================String============================= /** @@ -295,7 +302,8 @@ public class KitRedisHelper { public List multiGet(List keys) { List list = redisTemplate.opsForValue().multiGet(Sets.newHashSet(keys)); List resultList = Lists.newArrayList(); - Optional.ofNullable(list).ifPresent(e -> list.forEach(ele -> Optional.ofNullable(ele).ifPresent(resultList::add))); + Optional.ofNullable(list) + .ifPresent(e -> list.forEach(ele -> Optional.ofNullable(ele).ifPresent(resultList::add))); return resultList; } @@ -364,7 +372,6 @@ public class KitRedisHelper { return false; } } - // ================================Map================================= /** @@ -510,7 +517,6 @@ public class KitRedisHelper { public double hdecr(String key, String item, double by) { return redisTemplate.opsForHash().increment(key, item, -by); } - // ============================set============================= /** @@ -612,7 +618,6 @@ public class KitRedisHelper { return 0; } } - // ===============================list================================= /** @@ -785,7 +790,6 @@ public class KitRedisHelper { } long count = redisTemplate.delete(keys); } - // ============================incr============================= /** diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/redis/RedisConfiguration.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/redis/RedisConfiguration.java index 5376e9d5..4157d8f4 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/redis/RedisConfiguration.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/redis/RedisConfiguration.java @@ -13,12 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.redis; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONFactory; import com.alibaba.fastjson2.JSONWriter; +import java.nio.charset.StandardCharsets; +import java.time.Duration; +import java.util.HashMap; +import java.util.Map; import lombok.extern.slf4j.Slf4j; import org.apache.commons.codec.digest.MurmurHash3; import org.springframework.boot.autoconfigure.AutoConfigureBefore; @@ -40,11 +43,6 @@ import org.springframework.data.redis.serializer.RedisSerializer; import org.springframework.data.redis.serializer.SerializationException; import org.springframework.data.redis.serializer.StringRedisSerializer; -import java.nio.charset.StandardCharsets; -import java.time.Duration; -import java.util.HashMap; -import java.util.Map; - @Slf4j @Configuration @EnableCaching @@ -54,7 +52,8 @@ public class RedisConfiguration extends CachingConfigurerSupport { * 自动识别json对象白名单配置(仅允许解析的包名, 范围越小越安全)
未配置可能导致, 登录失败, 反复登录等问题 */ private static final String[] WHITELIST_STR = - {"org.springframework", "cn.odboy.system.dal.dataobject", "cn.odboy.system.dal.model", "cn.odboy.task.dal.dataobject", "cn.odboy.task.dal.model",}; + {"org.springframework", "cn.odboy.system.dal.dataobject", "cn.odboy.system.dal.model", + "cn.odboy.task.dal.dataobject", "cn.odboy.task.dal.model",}; /** * 设置 redis 数据默认过期时间,默认2小时 设置@cacheable 序列化方式 @@ -63,7 +62,8 @@ public class RedisConfiguration extends CachingConfigurerSupport { public RedisCacheConfiguration redisCacheConfiguration() { FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer<>(Object.class); RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig(); - configuration = configuration.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(fastJsonRedisSerializer)) + configuration = configuration.serializeValuesWith( + RedisSerializationContext.SerializationPair.fromSerializer(fastJsonRedisSerializer)) .entryTtl(Duration.ofHours(2)); return configuration; } @@ -102,7 +102,6 @@ public class RedisConfiguration extends CachingConfigurerSupport { /** * 自定义缓存key生成策略 */ - @Bean @Override public KeyGenerator keyGenerator() { @@ -162,7 +161,6 @@ public class RedisConfiguration extends CachingConfigurerSupport { * @param */ static class FastJsonRedisSerializer implements RedisSerializer { - private final Class clazz; FastJsonRedisSerializer(Class clazz) { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/config/AsyncTheadPoolConfig.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/config/AsyncTheadPoolConfig.java index 753fe96f..bef07249 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/config/AsyncTheadPoolConfig.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/config/AsyncTheadPoolConfig.java @@ -13,12 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.server.config; import cn.odboy.framework.properties.AppProperties; import cn.odboy.framework.properties.model.ThreadPoolSettingModel; import com.alibaba.ttl.TtlRunnable; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.Executor; +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicInteger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -26,17 +31,13 @@ import org.springframework.scheduling.annotation.AsyncConfigurer; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import java.util.concurrent.*; -import java.util.concurrent.atomic.AtomicInteger; - /** * 创建自定义的线程池 */ @EnableAsync @Configuration public class AsyncTheadPoolConfig implements AsyncConfigurer { - @Autowired - private AppProperties properties; + @Autowired private AppProperties properties; /** * 自定义线程池, 用法 @Async @@ -49,8 +50,10 @@ public class AsyncTheadPoolConfig implements AsyncConfigurer { // 自定义工厂 ThreadFactory factory = r -> new Thread(r, "DefaultAsync-" + new AtomicInteger(1).getAndIncrement()); // 自定义线程池 - return new ThreadPoolExecutor(asyncTaskPool.getCorePoolSize(), asyncTaskPool.getMaxPoolSize(), asyncTaskPool.getKeepAliveSeconds(), TimeUnit.SECONDS, - new ArrayBlockingQueue<>(asyncTaskPool.getQueueCapacity()), factory, new ThreadPoolExecutor.CallerRunsPolicy()); + return new ThreadPoolExecutor(asyncTaskPool.getCorePoolSize(), asyncTaskPool.getMaxPoolSize(), + asyncTaskPool.getKeepAliveSeconds(), TimeUnit.SECONDS, + new ArrayBlockingQueue<>(asyncTaskPool.getQueueCapacity()), factory, + new ThreadPoolExecutor.CallerRunsPolicy()); } /** diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringArraysToListDateConverter.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringArraysToListDateConverter.java index 73af6e4c..03319720 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringArraysToListDateConverter.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringArraysToListDateConverter.java @@ -13,12 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.server.converters; -import org.springframework.core.convert.converter.Converter; -import org.springframework.stereotype.Component; - import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Arrays; @@ -26,10 +22,13 @@ import java.util.Collections; import java.util.Date; import java.util.List; import java.util.stream.Collectors; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; @Component public class DateStringArraysToListDateConverter implements Converter> { - private static final ThreadLocal SDF = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + private static final ThreadLocal SDF = + ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); @Override public List convert(String[] source) { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringToDateConverter.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringToDateConverter.java index 7ba1651f..c6f2a671 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringToDateConverter.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/converters/DateStringToDateConverter.java @@ -13,20 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.server.converters; import cn.hutool.core.util.StrUtil; -import org.springframework.core.convert.converter.Converter; -import org.springframework.stereotype.Component; - import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import org.springframework.core.convert.converter.Converter; +import org.springframework.stereotype.Component; @Component public class DateStringToDateConverter implements Converter { - private static final ThreadLocal SDF = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); + private static final ThreadLocal SDF = + ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")); @Override public Date convert(String source) { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/core/ConfigurerAdapter.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/core/ConfigurerAdapter.java index fb1ee728..b8804cb1 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/core/ConfigurerAdapter.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/core/ConfigurerAdapter.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.server.core; import cn.odboy.framework.server.converters.DateStringArraysToListDateConverter; @@ -21,6 +20,9 @@ import cn.odboy.framework.server.converters.DateStringToDateConverter; import com.alibaba.fastjson2.JSONWriter; import com.alibaba.fastjson2.support.config.FastJsonConfig; import com.alibaba.fastjson2.support.spring.http.converter.FastJsonHttpMessageConverter; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -35,10 +37,6 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.List; - /** * 跨越、静态资源映射、Http消息转换 * @@ -48,12 +46,9 @@ import java.util.List; @Configuration @EnableWebMvc public class ConfigurerAdapter implements WebMvcConfigurer { - @Autowired - private DateStringArraysToListDateConverter dateStringArraysToListDateConverter; - @Autowired - private DateStringToDateConverter dateStringToDateConverter; - @Autowired - private KitFileLocalUploadHelper fileUploadPathHelper; + @Autowired private DateStringArraysToListDateConverter dateStringArraysToListDateConverter; + @Autowired private DateStringToDateConverter dateStringToDateConverter; + @Autowired private KitFileLocalUploadHelper fileUploadPathHelper; @Bean public CorsFilter corsFilter() { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/core/KitFileLocalUploadHelper.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/core/KitFileLocalUploadHelper.java index bee9707c..7e54b1df 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/core/KitFileLocalUploadHelper.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/server/core/KitFileLocalUploadHelper.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.server.core; import cn.odboy.constant.SystemConst; @@ -34,8 +33,7 @@ public class KitFileLocalUploadHelper { private static final String PATH_WINDOWS = "C:\\${appName}\\file\\"; private static final String PATH_MAC = "/Users/odboy/${appName}/file/"; private static final String PATH_LINUX = "/home/${appName}/file/"; - @Value("${spring.application.name}") - private String appName; + @Value("${spring.application.name}") private String appName; public String getPath() { String os = System.getProperty("os.name"); diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/config/UndertowWebSocketConfig.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/config/UndertowWebSocketConfig.java index f49cadfd..85e30af8 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/config/UndertowWebSocketConfig.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/config/UndertowWebSocketConfig.java @@ -7,7 +7,8 @@ import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.stereotype.Component; /** - * 解决启动io.undertow.websockets.jsr UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used的警告 + * 解决启动io.undertow.websockets.jsr UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be + * used的警告 * * @author odboy * @date 2025-10-30 @@ -31,11 +32,12 @@ public class UndertowWebSocketConfig implements WebServerFactoryCustomizer { WebSocketDeploymentInfo webSocketDeploymentInfo = new WebSocketDeploymentInfo(); - webSocketDeploymentInfo.setBuffers(new DefaultByteBufferPool(false, bufferSize, maxPoolSize, threadLocalCacheSize)); - deploymentInfo.addServletContextAttribute("io.undertow.websockets.jsr.WebSocketDeploymentInfo", webSocketDeploymentInfo); + webSocketDeploymentInfo.setBuffers( + new DefaultByteBufferPool(false, bufferSize, maxPoolSize, threadLocalCacheSize)); + deploymentInfo.addServletContextAttribute("io.undertow.websockets.jsr.WebSocketDeploymentInfo", + webSocketDeploymentInfo); }); } } \ No newline at end of file diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/config/WebSocketEndpointConfig.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/config/WebSocketEndpointConfig.java index c7231204..eb51deb0 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/config/WebSocketEndpointConfig.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/config/WebSocketEndpointConfig.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.websocket.config; import org.springframework.context.annotation.Bean; @@ -28,7 +27,6 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter; */ @Configuration public class WebSocketEndpointConfig { - @Bean public ServerEndpointExporter serverEndpointExporter() { return new ServerEndpointExporter(); diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsClientManager.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsClientManager.java index 3123c732..67514d12 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsClientManager.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsClientManager.java @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.websocket.context; -import lombok.extern.slf4j.Slf4j; - import java.util.Collection; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import lombok.extern.slf4j.Slf4j; /** * WebSocket客户端管理 diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsMessage.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsMessage.java index 54f4a829..2592a814 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsMessage.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsMessage.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.websocket.context; import cn.odboy.base.KitObject; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsServer.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsServer.java index 0ce6efb3..c8a86607 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsServer.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/context/KitWsServer.java @@ -13,20 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.websocket.context; import com.alibaba.fastjson2.JSON; +import java.io.IOException; +import java.util.Objects; +import javax.websocket.OnClose; +import javax.websocket.OnError; +import javax.websocket.OnMessage; +import javax.websocket.OnOpen; +import javax.websocket.Session; +import javax.websocket.server.PathParam; +import javax.websocket.server.ServerEndpoint; import lombok.Getter; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import javax.websocket.*; -import javax.websocket.server.PathParam; -import javax.websocket.server.ServerEndpoint; -import java.io.IOException; -import java.util.Objects; - @Slf4j @Component @ServerEndpoint("/websocket/{sid}") @@ -62,7 +64,8 @@ public class KitWsServer { KitWsMessage wsMessage = JSON.parseObject(message, KitWsMessage.class); String bizCode = wsMessage.getBizCode(); Object data = wsMessage.getData(); - log.info("收到来 sid={} 的信息: message={}, bizCode={}, data={}", sid, message, bizCode, JSON.toJSONString(data)); + log.info("收到来 sid={} 的信息: message={}, bizCode={}, data={}", sid, message, bizCode, + JSON.toJSONString(data)); } /** diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/model/WsSidVo.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/model/WsSidVo.java index 7200669a..b5d5355b 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/model/WsSidVo.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/model/WsSidVo.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.websocket.model; import cn.odboy.base.KitObject; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/util/WsMessageUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/util/WsMessageUtil.java index ff733b6a..ed3ab69e 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/util/WsMessageUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/framework/websocket/util/WsMessageUtil.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.framework.websocket.util; import cn.odboy.framework.exception.BadRequestException; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitAnonTagUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitAnonTagUtil.java index f1f85611..5dc4a612 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitAnonTagUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitAnonTagUtil.java @@ -1,4 +1,3 @@ - /* * Copyright 2021-2025 Odboy * @@ -14,11 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import cn.odboy.annotation.AnonymousAccess; import cn.odboy.constant.RequestMethodEnum; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import lombok.experimental.UtilityClass; import org.springframework.context.ApplicationContext; import org.springframework.web.bind.annotation.RequestMethod; @@ -27,14 +32,11 @@ import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; import org.springframework.web.servlet.mvc.method.RequestMappingInfo; import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; -import java.util.*; - /** * 匿名标记工具 */ @UtilityClass public class KitAnonTagUtil { - /** * 获取匿名标记的URL * @@ -42,7 +44,8 @@ public class KitAnonTagUtil { * @return / */ public static Map> getAnonymousUrl(final ApplicationContext applicationContext) { - RequestMappingHandlerMapping requestMappingHandlerMapping = (RequestMappingHandlerMapping)applicationContext.getBean("requestMappingHandlerMapping"); + RequestMappingHandlerMapping requestMappingHandlerMapping = + (RequestMappingHandlerMapping)applicationContext.getBean("requestMappingHandlerMapping"); Map handlerMethodMap = requestMappingHandlerMapping.getHandlerMethods(); Map> anonymousUrls = new HashMap<>(8); // 获取匿名标记 @@ -56,8 +59,10 @@ public class KitAnonTagUtil { HandlerMethod handlerMethod = infoEntry.getValue(); AnonymousAccess anonymousAccess = handlerMethod.getMethodAnnotation(AnonymousAccess.class); if (null != anonymousAccess && infoEntry.getKey() != null) { - List requestMethods = new ArrayList<>(infoEntry.getKey().getMethodsCondition().getMethods()); - RequestMethodEnum request = RequestMethodEnum.find(requestMethods.isEmpty() ? RequestMethodEnum.ALL.getType() : requestMethods.get(0).name()); + List requestMethods = + new ArrayList<>(infoEntry.getKey().getMethodsCondition().getMethods()); + RequestMethodEnum request = RequestMethodEnum.find( + requestMethods.isEmpty() ? RequestMethodEnum.ALL.getType() : requestMethods.get(0).name()); PatternsRequestCondition patternsCondition = infoEntry.getKey().getPatternsCondition(); if (patternsCondition != null) { switch (Objects.requireNonNull(request)) { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitBase64SecretUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitBase64SecretUtil.java index 1c9370d4..e117beb9 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitBase64SecretUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitBase64SecretUtil.java @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import cn.hutool.core.codec.Base64Encoder; import cn.hutool.core.util.IdUtil; -import lombok.experimental.UtilityClass; - import java.nio.charset.StandardCharsets; +import lombok.experimental.UtilityClass; /** * 加密令牌生成工具 @@ -30,7 +28,6 @@ import java.nio.charset.StandardCharsets; */ @UtilityClass public final class KitBase64SecretUtil { - public static String build() { // 128位uuid return Base64Encoder.encode(getLongUuid(4).getBytes(StandardCharsets.UTF_8)); diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitBigDecimalUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitBigDecimalUtil.java index da393275..cbcc7a9b 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitBigDecimalUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitBigDecimalUtil.java @@ -1,4 +1,3 @@ - /* * Copyright 2021-2025 Odboy * @@ -14,20 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; -import lombok.experimental.UtilityClass; - import java.math.BigDecimal; import java.math.RoundingMode; +import lombok.experimental.UtilityClass; /** * 计算类 */ @UtilityClass public final class KitBigDecimalUtil { - /** * 将对象转换为 BigDecimal * @@ -139,15 +135,12 @@ public final class KitBigDecimalUtil { public static void main(String[] args) { BigDecimal num1 = new BigDecimal("10.123"); BigDecimal num2 = new BigDecimal("2.456"); - System.out.println("加法结果: " + add(num1, num2)); System.out.println("减法结果: " + subtract(num1, num2)); System.out.println("乘法结果: " + multiply(num1, num2)); System.out.println("除法结果: " + divide(num1, num2)); - Long cents = 12345L; System.out.println("分转元结果: " + centsToYuan(cents)); - BigDecimal yuan = new BigDecimal("123.45"); System.out.println("元转分结果: " + yuanToCents(yuan)); } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitBrowserUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitBrowserUtil.java index 41c67646..994e198d 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitBrowserUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitBrowserUtil.java @@ -13,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import cn.hutool.http.useragent.UserAgent; import cn.hutool.http.useragent.UserAgentUtil; -import lombok.experimental.UtilityClass; -import lombok.extern.slf4j.Slf4j; - -import javax.servlet.http.HttpServletRequest; import java.net.InetAddress; import java.net.UnknownHostException; +import javax.servlet.http.HttpServletRequest; +import lombok.experimental.UtilityClass; +import lombok.extern.slf4j.Slf4j; /** * 浏览器 相关 diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitClassUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitClassUtil.java index 9574530e..8f8e8f6a 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitClassUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitClassUtil.java @@ -1,4 +1,3 @@ - /* * Copyright 2021-2025 Odboy * @@ -14,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; -import lombok.experimental.UtilityClass; - import java.lang.reflect.Field; import java.util.Arrays; import java.util.List; +import lombok.experimental.UtilityClass; /** * 类 相关 diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitCloseUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitCloseUtil.java index f9e22228..8deb8881 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitCloseUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitCloseUtil.java @@ -1,4 +1,3 @@ - /* * Copyright 2021-2025 Odboy * @@ -14,19 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; -import lombok.experimental.UtilityClass; - import java.io.Closeable; +import lombok.experimental.UtilityClass; /** * 用于关闭各种连接, 缺啥补啥 */ @UtilityClass public final class KitCloseUtil { - public static void close(Closeable closeable) { if (null != closeable) { try { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitCollUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitCollUtil.java index 96563fe2..7f1361a2 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitCollUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitCollUtil.java @@ -13,20 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import cn.odboy.base.KitSelectOptionVo; import com.alibaba.fastjson2.JSON; -import lombok.experimental.UtilityClass; - import java.lang.reflect.Field; import java.math.BigDecimal; import java.math.RoundingMode; -import java.util.*; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; +import lombok.experimental.UtilityClass; /** * 集合工具 @@ -61,7 +64,8 @@ public final class KitCollUtil extends cn.hutool.core.collection.CollUtil { * @param / * @return / */ - public static > List streamAscSort(List data, Function keyExtractor) { + public static > List streamAscSort(List data, + Function keyExtractor) { return data.stream().sorted(Comparator.comparing(keyExtractor)).collect(Collectors.toList()); } @@ -76,7 +80,8 @@ public final class KitCollUtil extends cn.hutool.core.collection.CollUtil { * @param / * @return / */ - public static > List streamDescSort(List data, Function keyExtractor) { + public static > List streamDescSort(List data, + Function keyExtractor) { return data.stream().sorted(Comparator.comparing(keyExtractor).reversed()).collect(Collectors.toList()); } @@ -93,7 +98,8 @@ public final class KitCollUtil extends cn.hutool.core.collection.CollUtil { * @param / * @return / */ - public static Map streamToMap(List data, Function keyMapper, Function valueMapper) { + public static Map streamToMap(List data, Function keyMapper, + Function valueMapper) { // 根据key去重再并流 return streamDistinct(data, keyMapper).stream().collect(Collectors.toMap(keyMapper, valueMapper)); } @@ -185,7 +191,8 @@ public final class KitCollUtil extends cn.hutool.core.collection.CollUtil { * @return / */ public static BigDecimal streamBigDecimalAvg(List data) { - return data.stream().filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(data.size()), 6, RoundingMode.FLOOR); + return data.stream().filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add) + .divide(BigDecimal.valueOf(data.size()), 6, RoundingMode.FLOOR); } public static void main(String[] args) { @@ -204,7 +211,8 @@ public final class KitCollUtil extends cn.hutool.core.collection.CollUtil { System.out.println(JSON.toJSONString(selectOptions2)); List selectOptions3 = KitCollUtil.streamDistinct(testData, KitSelectOptionVo::getValue); System.out.println(JSON.toJSONString(selectOptions3)); - Map selectMap1 = KitCollUtil.streamToMap(testData, KitSelectOptionVo::getValue, KitSelectOptionVo::getLabel); + Map selectMap1 = + KitCollUtil.streamToMap(testData, KitSelectOptionVo::getValue, KitSelectOptionVo::getLabel); System.out.println(JSON.toJSONString(selectMap1)); // 这只是一个示范 BigDecimal total1 = KitCollUtil.streamBigDecimalAdd(testData, "value"); diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitDateUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitDateUtil.java index 0805736d..48bd63ed 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitDateUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitDateUtil.java @@ -13,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; -import lombok.experimental.UtilityClass; - import java.util.Date; +import lombok.experimental.UtilityClass; /** * 时间相关工具 @@ -69,32 +67,24 @@ public class KitDateUtil { // 什么都不返回 return ""; } - long betweenSeconds = DateUtil.between(startTime, endTime, cn.hutool.core.date.DateUnit.SECOND); - long days = betweenSeconds / (24 * 60 * 60); long hours = (betweenSeconds % (24 * 60 * 60)) / (60 * 60); long minutes = (betweenSeconds % (60 * 60)) / 60; long seconds = betweenSeconds % 60; - StringBuilder result = new StringBuilder(); - if (days > 0) { result.append(days).append("天"); } - if (hours > 0) { result.append(hours).append("时"); } - if (minutes > 0) { result.append(minutes).append("分"); } - if (seconds > 0 || result.length() == 0) { result.append(seconds).append("秒"); } - return result.toString(); } @@ -110,41 +100,32 @@ public class KitDateUtil { // 什么都不返回 return ""; } - long betweenMs = DateUtil.betweenMs(startTime, endTime); long days = betweenMs / (24 * 60 * 60 * 1000); long hours = (betweenMs % (24 * 60 * 60 * 1000)) / (60 * 60 * 1000); long minutes = (betweenMs % (60 * 60 * 1000)) / (60 * 1000); long seconds = (betweenMs % (60 * 1000)) / 1000; long milliseconds = betweenMs % 1000; - StringBuilder result = new StringBuilder(); - if (days > 0) { result.append(days).append("天"); } - if (hours > 0) { result.append(hours).append("时"); } - if (minutes > 0) { result.append(minutes).append("分"); } - if (seconds > 0) { result.append(seconds).append("秒"); } - if (milliseconds > 0) { result.append(milliseconds).append("毫秒"); } - // 如果所有单位都是0,则显示0毫秒 if (result.length() == 0) { result.append("0毫秒"); } - return result.toString(); } } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitDesEncryptUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitDesEncryptUtil.java index c5af74e6..7c1a988d 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitDesEncryptUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitDesEncryptUtil.java @@ -13,24 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; -import lombok.experimental.UtilityClass; - +import java.nio.charset.StandardCharsets; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.DESKeySpec; import javax.crypto.spec.IvParameterSpec; -import java.nio.charset.StandardCharsets; +import lombok.experimental.UtilityClass; /** * DES加密 */ @UtilityClass public final class KitDesEncryptUtil { - private static final String STR_PARAM = "Passw0rd"; private static final IvParameterSpec IV = new IvParameterSpec(STR_PARAM.getBytes(StandardCharsets.UTF_8)); @@ -94,4 +91,3 @@ public final class KitDesEncryptUtil { return b2; } } - diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitDistributedIdUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitDistributedIdUtil.java index 5287bc67..55b92071 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitDistributedIdUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitDistributedIdUtil.java @@ -13,11 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import cn.odboy.framework.exception.BadRequestException; - import java.util.concurrent.atomic.AtomicLong; /** @@ -43,7 +41,6 @@ public final class KitDistributedIdUtil { * 序列号所占位数 */ private final long sequenceBits; - /** * 数据中心 ID 最大值 */ @@ -56,7 +53,6 @@ public final class KitDistributedIdUtil { * 序列号最大值 */ private final long sequenceMask; - /** * 机器 ID 向左移位数 */ @@ -69,7 +65,6 @@ public final class KitDistributedIdUtil { * 时间戳向左移位数 */ private final long timestampLeftShift; - /** * 数据中心 ID */ @@ -96,21 +91,20 @@ public final class KitDistributedIdUtil { * @param workerIdBits 机器 ID 所占位数 * @param sequenceBits 序列号所占位数 */ - public KitDistributedIdUtil(long dataCenterId, long workerId, long dataCenterIdBits, long workerIdBits, long sequenceBits) { + public KitDistributedIdUtil(long dataCenterId, long workerId, long dataCenterIdBits, long workerIdBits, + long sequenceBits) { this.dataCenterIdBits = dataCenterIdBits; this.workerIdBits = workerIdBits; this.sequenceBits = sequenceBits; - this.maxDataCenterId = ~(-1L << dataCenterIdBits); this.maxWorkerId = ~(-1L << workerIdBits); this.sequenceMask = ~(-1L << sequenceBits); - this.workerIdShift = sequenceBits; this.dataCenterIdShift = sequenceBits + workerIdBits; this.timestampLeftShift = sequenceBits + workerIdBits + dataCenterIdBits; - if (dataCenterId > maxDataCenterId || dataCenterId < 0) { - throw new IllegalArgumentException("Data center ID can't be greater than " + maxDataCenterId + " or less than 0"); + throw new IllegalArgumentException( + "Data center ID can't be greater than " + maxDataCenterId + " or less than 0"); } if (workerId > maxWorkerId || workerId < 0) { throw new IllegalArgumentException("Worker ID can't be greater than " + maxWorkerId + " or less than 0"); @@ -151,12 +145,12 @@ public final class KitDistributedIdUtil { */ public long nextId() { long currentTimestamp = System.currentTimeMillis(); - // 如果当前时间戳小于上一次生成 ID 的时间戳, 说明时钟回拨,抛出异常 if (currentTimestamp < lastTimestamp.get()) { - throw new BadRequestException("Clock moved backwards. Refusing to generate id for " + (lastTimestamp.get() - currentTimestamp) + " milliseconds"); + throw new BadRequestException( + "Clock moved backwards. Refusing to generate id for " + (lastTimestamp.get() - currentTimestamp) + + " milliseconds"); } - long lastTimestampValue = lastTimestamp.get(); if (currentTimestamp == lastTimestampValue) { // 同一毫秒内,序列号自增 @@ -165,12 +159,14 @@ public final class KitDistributedIdUtil { // 序列号溢出,等待下一毫秒 currentTimestamp = waitNextMillis(lastTimestampValue); } - return ((currentTimestamp - START_TIMESTAMP) << timestampLeftShift) | (dataCenterId << dataCenterIdShift) | (workerId << workerIdShift) | seq; + return ((currentTimestamp - START_TIMESTAMP) << timestampLeftShift) | (dataCenterId << dataCenterIdShift) | + (workerId << workerIdShift) | seq; } else { // 时间戳改变,重置序列号 sequence.set(0L); lastTimestamp.set(currentTimestamp); - return ((currentTimestamp - START_TIMESTAMP) << timestampLeftShift) | (dataCenterId << dataCenterIdShift) | (workerId << workerIdShift); + return ((currentTimestamp - START_TIMESTAMP) << timestampLeftShift) | (dataCenterId << dataCenterIdShift) | + (workerId << workerIdShift); } } 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 de533011..282c63e0 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import cn.hutool.core.io.IoUtil; @@ -23,16 +22,11 @@ import cn.hutool.poi.excel.ExcelUtil; import cn.odboy.constant.FileTypeEnum; import cn.odboy.constant.SystemConst; import cn.odboy.framework.exception.BadRequestException; -import lombok.experimental.UtilityClass; -import lombok.extern.slf4j.Slf4j; -import org.apache.poi.util.IOUtils; -import org.apache.poi.xssf.streaming.SXSSFSheet; -import org.springframework.web.multipart.MultipartFile; - -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.nio.file.Files; import java.security.MessageDigest; import java.text.DecimalFormat; @@ -42,8 +36,19 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import lombok.experimental.UtilityClass; +import lombok.extern.slf4j.Slf4j; +import org.apache.poi.util.IOUtils; +import org.apache.poi.xssf.streaming.SXSSFSheet; +import org.springframework.web.multipart.MultipartFile; -import static cn.odboy.constant.SystemConst.*; +import static cn.odboy.constant.SystemConst.SYMBOL_ADD; +import static cn.odboy.constant.SystemConst.SYMBOL_AT; +import static cn.odboy.constant.SystemConst.SYMBOL_EQUAL; +import static cn.odboy.constant.SystemConst.SYMBOL_SUBTRACT; /** * File工具类, 扩展 hutool 工具包 @@ -51,7 +56,6 @@ import static cn.odboy.constant.SystemConst.*; @Slf4j @UtilityClass public final class KitFileUtil extends cn.hutool.core.io.FileUtil { - /** * 系统临时目录 *
@@ -75,7 +79,6 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil { * 定义KB的计算常量 */ private static final int KB = 1024; - /** * 格式化小数 */ @@ -191,8 +194,8 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil { if (value instanceof String) { String strValue = (String)value; // 检查并处理以特殊字符开头的值 - if (strValue.startsWith(SYMBOL_EQUAL) || strValue.startsWith(SYMBOL_ADD) || strValue.startsWith(SYMBOL_SUBTRACT) || strValue.startsWith( - SYMBOL_AT)) { + if (strValue.startsWith(SYMBOL_EQUAL) || strValue.startsWith(SYMBOL_ADD) || + strValue.startsWith(SYMBOL_SUBTRACT) || strValue.startsWith(SYMBOL_AT)) { // 添加单引号前缀 strValue = "'" + strValue; } @@ -324,7 +327,8 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil { * @param response / * @param file / */ - public static void downloadFile(HttpServletRequest request, HttpServletResponse response, File file, boolean deleteOnExit) { + public static void downloadFile(HttpServletRequest request, HttpServletResponse response, File file, + boolean deleteOnExit) { response.setCharacterEncoding(request.getCharacterEncoding()); response.setContentType("application/octet-stream"); FileInputStream fis = null; @@ -358,10 +362,8 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil { public static String verifyFilename(String fileName) { // 过滤掉特殊字符 fileName = fileName.replaceAll("[\\\\/:*?\"<>|~\\s]", ""); - // 去掉文件名开头和结尾的空格和点 fileName = fileName.trim().replaceAll("^[. ]+|[. ]+$", ""); - // 不允许文件名超过255(在Mac和Linux中)或260(在Windows中)个字符 int maxFileNameLength = 255; if (System.getProperty(SystemConst.PROPERTY_OS_NAME).startsWith(SystemConst.OS_NAME_WINDOWS)) { @@ -370,19 +372,15 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil { if (fileName.length() > maxFileNameLength) { fileName = fileName.substring(0, maxFileNameLength); } - // 过滤掉控制字符 fileName = fileName.replaceAll("[\\p{Cntrl}]", ""); - // 过滤掉 ".." 路径 fileName = fileName.replaceAll("\\.{2,}", ""); - // 去掉文件名开头的 ".." fileName = fileName.replaceAll("^\\.+/", ""); - // 保留文件名中最后一个 "." 字符,过滤掉其他 "." - fileName = fileName.replaceAll("^(.*)(\\.[^.]*)$", "$1").replaceAll("\\.", "") + fileName.replaceAll("^(.*)(\\.[^.]*)$", "$2"); - + fileName = fileName.replaceAll("^(.*)(\\.[^.]*)$", "$1").replaceAll("\\.", "") + + fileName.replaceAll("^(.*)(\\.[^.]*)$", "$2"); return fileName; } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitIPUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitIPUtil.java index 5f318219..2cf6a207 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitIPUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitIPUtil.java @@ -13,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import cn.odboy.framework.context.KitSpringBeanHolder; -import lombok.experimental.UtilityClass; -import net.dreamlu.mica.ip2region.core.Ip2regionSearcher; -import net.dreamlu.mica.ip2region.core.IpInfo; - import java.net.InetAddress; import java.net.NetworkInterface; import java.util.Enumeration; +import lombok.experimental.UtilityClass; +import net.dreamlu.mica.ip2region.core.Ip2regionSearcher; +import net.dreamlu.mica.ip2region.core.IpInfo; /** * IP地址 相关 @@ -55,10 +53,12 @@ public final class KitIPUtil { try { InetAddress candidateAddress = null; // 遍历所有的网络接口 - for (Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements(); ) { + for (Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); + interfaces.hasMoreElements(); ) { NetworkInterface anInterface = interfaces.nextElement(); // 在所有的接口下再遍历IP - for (Enumeration inetAddresses = anInterface.getInetAddresses(); inetAddresses.hasMoreElements(); ) { + for (Enumeration inetAddresses = anInterface.getInetAddresses(); + inetAddresses.hasMoreElements(); ) { InetAddress inetAddr = inetAddresses.nextElement(); // 排除loopback类型地址 if (!inetAddr.isLoopbackAddress()) { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitJsonUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitJsonUtil.java index bba25a2e..23aa8ed9 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitJsonUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitJsonUtil.java @@ -13,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.TypeReference; -import lombok.experimental.UtilityClass; - import java.util.List; import java.util.Map; +import lombok.experimental.UtilityClass; /** * Json工具 @@ -32,13 +30,11 @@ import java.util.Map; @UtilityClass public final class KitJsonUtil { public static Map toMap(String jsonStr, Class kClass, Class vClass) { - return JSON.parseObject(jsonStr, new TypeReference>() { - }); + return JSON.parseObject(jsonStr, new TypeReference>() {}); } public static List toList(String jsonStr, Class vClass) { - return JSON.parseObject(jsonStr, new TypeReference>() { - }); + return JSON.parseObject(jsonStr, new TypeReference>() {}); } public static void main(String[] args) { diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitListUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitListUtil.java index 6a0f1de9..fc587574 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitListUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitListUtil.java @@ -13,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import cn.hutool.core.date.DateTime; import cn.odboy.base.KitBaseUserTimeTb; -import lombok.experimental.UtilityClass; - import java.util.ArrayList; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; +import lombok.experimental.UtilityClass; /** * List 工具 @@ -40,13 +38,14 @@ public final class KitListUtil { * @param classifier 对象T属性表达式, 比如: User::getName */ public static List distinctByArgs(List items, Function classifier) { - return items.stream().collect(Collectors.groupingBy(classifier)).values().stream().map(monitorItem -> monitorItem.iterator().next()) - .collect(Collectors.toList()); + return items.stream().collect(Collectors.groupingBy(classifier)).values().stream() + .map(monitorItem -> monitorItem.iterator().next()).collect(Collectors.toList()); } /** - * list转map, 保留新值 -> Map userMap = items.stream().collect(Collectors.toMap(User::getName, user -> user))
list转map, 保留旧值 -> Map userMap = users.stream().collect(Collectors.toMap(User::getName, user -> user, (existing, replacement) -> existing)); + * list转map, 保留新值 -> Map userMap = items.stream().collect(Collectors.toMap(User::getName, user -> + * user))
list转map, 保留旧值 -> Map userMap = users.stream().collect(Collectors.toMap(User::getName, + * user -> user, (existing, replacement) -> existing)); */ public static void main(String[] args) { List entities = new ArrayList<>(); diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitLogFmtUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitLogFmtUtil.java index d6402947..2f5e984c 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitLogFmtUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitLogFmtUtil.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import lombok.experimental.UtilityClass; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitPageUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitPageUtil.java index 40227de6..f0541ef1 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitPageUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitPageUtil.java @@ -13,18 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import cn.odboy.base.KitPageResult; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import lombok.experimental.UtilityClass; - import java.util.ArrayList; import java.util.Collections; import java.util.List; +import lombok.experimental.UtilityClass; /** * 分页工具 @@ -33,7 +31,6 @@ import java.util.List; */ @UtilityClass public final class KitPageUtil extends cn.hutool.core.util.PageUtil { - /** * List 分页 */ diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitResourceTemplateUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitResourceTemplateUtil.java index d62cf1de..f78a1f5f 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitResourceTemplateUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitResourceTemplateUtil.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import cn.hutool.core.lang.Dict; @@ -34,7 +33,8 @@ import lombok.experimental.UtilityClass; public class KitResourceTemplateUtil { public static String render(String moduleName, String filename, Dict params) { String path = StrUtil.isBlank(moduleName) ? "template" : "template/" + moduleName; - TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig(path, TemplateConfig.ResourceMode.CLASSPATH)); + TemplateEngine engine = + TemplateUtil.createEngine(new TemplateConfig(path, TemplateConfig.ResourceMode.CLASSPATH)); Template template = engine.getTemplate(filename); return template.render(params); } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitReturnValueHandleUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitReturnValueHandleUtil.java index 5a44daa4..56b46ec3 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitReturnValueHandleUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitReturnValueHandleUtil.java @@ -1,4 +1,3 @@ - /* * Copyright 2021-2025 Odboy * @@ -14,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.reflect.MethodSignature; - import java.lang.reflect.Method; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Set; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.reflect.MethodSignature; /** * 返回值处理 工具 diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitRsaEncryptUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitRsaEncryptUtil.java index 920557f0..4d742de3 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitRsaEncryptUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitRsaEncryptUtil.java @@ -13,26 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; -import lombok.experimental.UtilityClass; -import org.apache.commons.codec.binary.Base64; - -import javax.crypto.Cipher; import java.io.ByteArrayOutputStream; -import java.security.*; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.NoSuchAlgorithmException; +import java.security.PrivateKey; +import java.security.PublicKey; import java.security.interfaces.RSAPrivateKey; import java.security.interfaces.RSAPublicKey; import java.security.spec.PKCS8EncodedKeySpec; import java.security.spec.X509EncodedKeySpec; +import javax.crypto.Cipher; +import lombok.experimental.UtilityClass; +import org.apache.commons.codec.binary.Base64; /** * Rsa 工具类, 公钥私钥生成, 加解密 */ @UtilityClass public final class KitRsaEncryptUtil { - private static final String SRC = "123456"; public static void main(String[] args) throws Exception { @@ -194,7 +196,6 @@ public final class KitRsaEncryptUtil { * RSA密钥对对象 */ public static class RsaKeyPair { - private final String publicKey; private final String privateKey; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitStringUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitStringUtil.java index f6b186e2..27d3580c 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitStringUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitStringUtil.java @@ -1,4 +1,3 @@ - /* * Copyright 2021-2025 Odboy * @@ -14,14 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; -import lombok.experimental.UtilityClass; -import lombok.extern.slf4j.Slf4j; - import java.util.Calendar; import java.util.Date; +import lombok.experimental.UtilityClass; +import lombok.extern.slf4j.Slf4j; /** * 字符串工具类, 继承org.apache.commons.lang3.StringUtils类 @@ -29,26 +26,23 @@ import java.util.Date; @Slf4j @UtilityClass public final class KitStringUtil { - private static final char SEPARATOR = '_'; /** * 驼峰命名法工具 * - * @return toCamelCase(" hello_world ") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld" toUnderScoreCase("helloWorld") = "hello_world" + * @return toCamelCase(" hello_world ") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld" + * toUnderScoreCase("helloWorld") = "hello_world" */ public static String toCamelCase(String s) { if (s == null) { return null; } - s = s.toLowerCase(); - StringBuilder sb = new StringBuilder(s.length()); boolean upperCase = false; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); - if (c == SEPARATOR) { upperCase = true; } else if (upperCase) { @@ -58,14 +52,14 @@ public final class KitStringUtil { sb.append(c); } } - return sb.toString(); } /** * 驼峰命名法工具 * - * @return toCamelCase(" hello_world ") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld" toUnderScoreCase("helloWorld") = "hello_world" + * @return toCamelCase(" hello_world ") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld" + * toUnderScoreCase("helloWorld") = "hello_world" */ public static String toCapitalizeCamelCase(String s) { if (s == null) { @@ -78,24 +72,21 @@ public final class KitStringUtil { /** * 驼峰命名法工具 * - * @return toCamelCase(" hello_world ") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld" toUnderScoreCase("helloWorld") = "hello_world" + * @return toCamelCase(" hello_world ") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld" + * toUnderScoreCase("helloWorld") = "hello_world" */ public static String toUnderScoreCase(String s) { if (s == null) { return null; } - StringBuilder sb = new StringBuilder(); boolean upperCase = false; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); - boolean nextUpperCase = true; - if (i < (s.length() - 1)) { nextUpperCase = Character.isUpperCase(s.charAt(i + 1)); } - if ((i > 0) && Character.isUpperCase(c)) { if (!upperCase || !nextUpperCase) { sb.append(SEPARATOR); @@ -104,10 +95,8 @@ public final class KitStringUtil { } else { upperCase = false; } - sb.append(Character.toLowerCase(c)); } - return sb.toString(); } diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitSystemUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitSystemUtil.java index 8bf56b2d..a237de44 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitSystemUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitSystemUtil.java @@ -1,4 +1,3 @@ - /* * Copyright 2021-2025 Odboy * @@ -14,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import oshi.SystemInfo; diff --git a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitValidUtil.java b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitValidUtil.java index 39f2d9ad..fd1a9f10 100644 --- a/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitValidUtil.java +++ b/cutejava/cutejava-framework/src/main/java/cn/odboy/util/KitValidUtil.java @@ -13,19 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import cn.odboy.framework.exception.BadRequestException; -import lombok.experimental.UtilityClass; - +import java.util.Set; +import java.util.stream.Collectors; import javax.validation.ConstraintViolation; import javax.validation.Validation; import javax.validation.Validator; import javax.validation.ValidatorFactory; import javax.validation.groups.Default; -import java.util.Set; -import java.util.stream.Collectors; +import lombok.experimental.UtilityClass; /** * Bean验证工具 @@ -46,7 +44,8 @@ public final class KitValidUtil { public static void validate(T object) { Set> violations = VALIDATOR.validate(object, Default.class); if (!violations.isEmpty()) { - throw new BadRequestException(violations.stream().map(ConstraintViolation::getMessage).collect(Collectors.joining(","))); + throw new BadRequestException( + violations.stream().map(ConstraintViolation::getMessage).collect(Collectors.joining(","))); } } } \ No newline at end of file diff --git a/cutejava/cutejava-module-system/pom.xml b/cutejava/cutejava-module-system/pom.xml index 7027d3b4..1a7f874a 100644 --- a/cutejava/cutejava-module-system/pom.xml +++ b/cutejava/cutejava-module-system/pom.xml @@ -7,10 +7,8 @@ 1.4.1 4.0.0 - cutejava-module-system 核心模块 - cn.odboy diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/SystemCaptchaBizEnum.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/SystemCaptchaBizEnum.java index 63d3fb0d..a25b865a 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/SystemCaptchaBizEnum.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/SystemCaptchaBizEnum.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.constant; import lombok.AllArgsConstructor; @@ -25,19 +24,14 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum SystemCaptchaBizEnum { - /* 通过手机号码重置邮箱 */ - PHONE_RESET_EMAIL_CODE("10000", "phone_reset_email_code_", "SystemEmailCaptchaTemplate.ftl", "通过手机号码重置邮箱"), - - /* 通过旧邮箱重置邮箱 */ + PHONE_RESET_EMAIL_CODE("10000", "phone_reset_email_code_", "SystemEmailCaptchaTemplate.ftl", + "通过手机号码重置邮箱"), /* 通过旧邮箱重置邮箱 */ EMAIL_RESET_EMAIL_CODE("10001", "email_reset_email_code_", "SystemEmailCaptchaTemplate.ftl", "通过旧邮箱重置邮箱"), - /* 通过手机号码重置密码 */ PHONE_RESET_PWD_CODE("10002", "phone_reset_pwd_code_", "SystemEmailCaptchaTemplate.ftl", "通过手机号码重置密码"), - /* 通过邮箱重置密码 */ EMAIL_RESET_PWD_CODE("10003", "email_reset_pwd_code_", "SystemEmailCaptchaTemplate.ftl", "通过邮箱重置密码"); - /** * 业务编码 */ diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/SystemDataScopeEnum.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/SystemDataScopeEnum.java index 3a05153a..7d9dc29e 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/SystemDataScopeEnum.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/SystemDataScopeEnum.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.constant; import lombok.AllArgsConstructor; @@ -25,16 +24,10 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum SystemDataScopeEnum { - /* 全部的数据权限 */ - ALL("全部", "全部的数据权限"), - - /* 自己部门的数据权限 */ - THIS_LEVEL("本级", "自己部门的数据权限"), - - /* 自定义的数据权限 */ + ALL("全部", "全部的数据权限"), /* 自己部门的数据权限 */ + THIS_LEVEL("本级", "自己部门的数据权限"), /* 自定义的数据权限 */ CUSTOMIZE("自定义", "自定义的数据权限"); - private final String value; private final String description; diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/TransferProtocolConst.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/TransferProtocolConst.java index ed555213..607247a3 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/TransferProtocolConst.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/constant/TransferProtocolConst.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.constant; public interface TransferProtocolConst { diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemAuthController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemAuthController.java index 53af0711..16800d1d 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemAuthController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemAuthController.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.hutool.core.bean.BeanUtil; @@ -37,6 +36,10 @@ import cn.odboy.util.KitRsaEncryptUtil; import com.wf.captcha.base.Captcha; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -50,11 +53,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - /** * 授权、根据token获取用户详细信息 */ @@ -63,24 +61,20 @@ import java.util.concurrent.TimeUnit; @RequestMapping("/auth") @Api(tags = "系统:系统授权接口") public class SystemAuthController { - @Autowired - private KitRedisHelper redisHelper; - @Autowired - private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; - @Autowired - private TokenProvider tokenProvider; - @Autowired - private AppProperties properties; - @Autowired - private PasswordEncoder passwordEncoder; - @Autowired - private UserDetailsHandler userDetailsService; + @Autowired private KitRedisHelper redisHelper; + @Autowired private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; + @Autowired private TokenProvider tokenProvider; + @Autowired private AppProperties properties; + @Autowired private PasswordEncoder passwordEncoder; + @Autowired private UserDetailsHandler userDetailsService; @ApiOperation("登录授权") @AnonymousPostMapping(value = "/login") - public ResponseEntity> login(@Validated @RequestBody SystemUserLoginArgs loginRequest, HttpServletRequest request) throws Exception { + public ResponseEntity> login(@Validated @RequestBody SystemUserLoginArgs loginRequest, + HttpServletRequest request) throws Exception { // 密码解密 - String password = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginRequest.getPassword()); + String password = + KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginRequest.getPassword()); // 查询验证码 String code = redisHelper.get(loginRequest.getUuid(), String.class); // 清除验证码 @@ -97,7 +91,8 @@ public class SystemAuthController { if (!passwordEncoder.matches(password, jwtUser.getPassword())) { throw new BadRequestException("登录密码错误"); } - Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities()); + Authentication authentication = + new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities()); SecurityContextHolder.getContext().setAuthentication(authentication); // 生成令牌 String token = tokenProvider.createToken(jwtUser); @@ -132,11 +127,13 @@ public class SystemAuthController { 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)) { + 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); + redisHelper.set(uuid, captchaValue, properties.getLogin().getCaptchaSetting().getExpiration(), + TimeUnit.MINUTES); // 验证码信息 Map imgResult = new HashMap(2) {{ put("img", captcha.toBase64()); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemCaptchaController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemCaptchaController.java index cc30120e..3a276fd7 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemCaptchaController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemCaptchaController.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.odboy.framework.exception.BadRequestException; @@ -25,14 +24,17 @@ import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; +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 @RequestMapping("/api/captcha") @Api(tags = "系统:验证码管理") public class SystemCaptchaController { - @Autowired - private SystemEmailService systemEmailService; + @Autowired private SystemEmailService systemEmailService; @ApiOperation("重置邮箱, 发送验证码") @PostMapping(value = "/sendResetEmailCaptcha") diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemComponentController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemComponentController.java index f152ed71..274f102f 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemComponentController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemComponentController.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.odboy.system.service.SystemDeptService; @@ -30,8 +29,7 @@ import org.springframework.web.bind.annotation.RestController; @Api(tags = "系统:组件数据源") @RequestMapping("/api/component") public class SystemComponentController { - @Autowired - private SystemDeptService systemDeptService; + @Autowired private SystemDeptService systemDeptService; @ApiOperation("查询部门下拉选择数据源") @PostMapping(value = "/queryDeptSelectDataSource") diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDeptController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDeptController.java index 11c17286..018f889f 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDeptController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDeptController.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.odboy.base.KitPageArgs; @@ -25,39 +24,43 @@ import cn.odboy.system.service.SystemDeptService; import cn.odboy.util.KitPageUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -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.*; - -import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.LinkedHashSet; 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.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 @Api(tags = "系统:部门管理") @RequestMapping("/api/dept") public class SystemDeptController { - @Autowired - private SystemDeptService systemDeptService; + @Autowired private SystemDeptService systemDeptService; @ApiOperation("导出部门数据") @GetMapping(value = "/download") @PreAuthorize("@el.check('dept:list')") public void exportDept(HttpServletResponse response, SystemQueryDeptArgs criteria) throws Exception { - systemDeptService.exportDeptExcel(systemDeptService.queryAllDept(criteria, false), response); + systemDeptService.exportDeptExcel(systemDeptService.findAllDept(criteria, false), response); } @ApiOperation("查询部门") @PostMapping @PreAuthorize("@el.check('user:list','dept:list')") - public ResponseEntity> queryDept(@Validated @RequestBody KitPageArgs args) throws Exception { + public ResponseEntity> queryDept( + @Validated @RequestBody KitPageArgs args) throws Exception { SystemQueryDeptArgs criteria = args.getArgs(); - List depts = systemDeptService.queryAllDept(criteria, true); + List depts = systemDeptService.findAllDept(criteria, true); return ResponseEntity.ok(KitPageUtil.toPage(depts)); } @@ -65,11 +68,11 @@ public class SystemDeptController { @PostMapping("/queryDeptSuperiorTree") @PreAuthorize("@el.check('user:list','dept:list')") public ResponseEntity> queryDeptSuperiorTree(@RequestBody List ids, - @RequestParam(defaultValue = "false") Boolean exclude) { + @RequestParam(defaultValue = "false") Boolean exclude) { Set deptSet = new LinkedHashSet<>(); for (Long id : ids) { // 同级数据 - SystemDeptTb dept = systemDeptService.queryDeptById(id); + SystemDeptTb dept = systemDeptService.getDeptById(id); // 上级数据 List depts = systemDeptService.querySuperiorDeptListByPid(dept, new ArrayList<>()); if (exclude) { @@ -98,7 +101,7 @@ public class SystemDeptController { @PostMapping(value = "/modifyDept") @PreAuthorize("@el.check('dept:edit')") public ResponseEntity modifyDept(@Validated(SystemDeptTb.Update.class) @RequestBody SystemDeptTb args) { - systemDeptService.modifyDept(args); + systemDeptService.updateDept(args); return ResponseEntity.ok(null); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictController.java index 22eb66ad..9fd5704c 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemDictController.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.odboy.base.KitPageArgs; @@ -25,23 +24,25 @@ 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 java.io.IOException; +import java.util.List; +import java.util.Set; +import javax.servlet.http.HttpServletResponse; 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.*; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.List; -import java.util.Set; +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.RestController; @RestController @Api(tags = "系统:字典管理") @RequestMapping("/api/dict") public class SystemDictController { - @Autowired - private SystemDictService systemDictService; + @Autowired private SystemDictService systemDictService; @ApiOperation("导出字典数据") @GetMapping(value = "/download") @@ -60,7 +61,8 @@ public class SystemDictController { @ApiOperation("查询字典") @PostMapping @PreAuthorize("@el.check('dict:list')") - public ResponseEntity> queryDictByArgs(@Validated @RequestBody KitPageArgs args) { + public ResponseEntity> queryDictByArgs( + @Validated @RequestBody KitPageArgs args) { Page page; SystemQueryDictArgs criteria = args.getArgs(); if (args.getSize() != null) { 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 a32ee741..9c4da8f8 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.odboy.base.KitPageArgs; @@ -25,34 +24,39 @@ 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.HashMap; +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.*; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; +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 @Api(tags = "系统:字典详情管理") @RequestMapping("/api/dictDetail") public class SystemDictDetailController { - @Autowired - private SystemDictDetailService systemDictDetailService; + @Autowired private SystemDictDetailService systemDictDetailService; @ApiOperation("查询字典详情") @PostMapping - public ResponseEntity> queryDictDetailByCrud(@Validated @RequestBody KitPageArgs args) { + public ResponseEntity> queryDictDetailByCrud( + @Validated @RequestBody KitPageArgs args) { return queryDictDetailByArgs(args); } @ApiOperation("查询字典详情") @PostMapping(value = "/queryDictDetailByArgs") - public ResponseEntity> queryDictDetailByArgs(@Validated @RequestBody KitPageArgs args) { + public ResponseEntity> queryDictDetailByArgs( + @Validated @RequestBody KitPageArgs args) { SystemQueryDictDetailArgs criteria = args.getArgs(); - Page page = new Page<>(args.getPage(), args.getSize()); + Page page = new Page<>(args.getPage(), args.getSize()); return ResponseEntity.ok(systemDictDetailService.queryDictDetailByArgs(criteria, page)); } @@ -78,7 +82,8 @@ public class SystemDictDetailController { @ApiOperation("修改字典详情") @PostMapping(value = "/modifyDictDetailById") @PreAuthorize("@el.check('dict:edit')") - public ResponseEntity modifyDictDetailById(@Validated(SystemDictDetailTb.Update.class) @RequestBody SystemDictDetailTb args) { + public ResponseEntity modifyDictDetailById( + @Validated(SystemDictDetailTb.Update.class) @RequestBody SystemDictDetailTb args) { systemDictDetailService.modifyDictDetailById(args); return ResponseEntity.ok(null); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemEmailController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemEmailController.java index 67235bb7..5977e858 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemEmailController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemEmailController.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.odboy.system.dal.dataobject.SystemEmailConfigTb; @@ -36,8 +35,7 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("api/email") @Api(tags = "工具:邮件管理") public class SystemEmailController { - @Autowired - private SystemEmailService systemEmailService; + @Autowired private SystemEmailService systemEmailService; @ApiOperation("查询配置") @PostMapping(value = "/getLastEmailConfig") @@ -47,7 +45,8 @@ public class SystemEmailController { @ApiOperation("配置邮件") @PostMapping(value = "/modifyEmailConfig") - public ResponseEntity modifyEmailConfig(@Validated @RequestBody SystemEmailConfigTb emailConfig) throws Exception { + public ResponseEntity modifyEmailConfig(@Validated @RequestBody SystemEmailConfigTb emailConfig) + throws Exception { systemEmailService.modifyEmailConfig(emailConfig); return ResponseEntity.ok(null); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemJobController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemJobController.java index 5363c1b2..02880689 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemJobController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemJobController.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.odboy.base.KitPageArgs; @@ -25,22 +24,24 @@ 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.io.IOException; +import java.util.Set; +import javax.servlet.http.HttpServletResponse; 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.*; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Set; +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.RestController; @RestController @Api(tags = "系统:岗位管理") @RequestMapping("/api/job") public class SystemJobController { - @Autowired - private SystemJobService systemJobService; + @Autowired private SystemJobService systemJobService; @ApiOperation("导出岗位数据") @GetMapping(value = "/download") @@ -52,7 +53,8 @@ public class SystemJobController { @ApiOperation("查询岗位") @PostMapping(value = "/queryAllEnableJob") @PreAuthorize("@el.check('job:list','user:list')") - public ResponseEntity> queryJobByArgs(@Validated @RequestBody KitPageArgs args) { + public ResponseEntity> queryJobByArgs( + @Validated @RequestBody KitPageArgs args) { SystemQueryJobArgs criteria = args.getArgs(); Page page = new Page<>(criteria.getPage(), criteria.getSize()); return ResponseEntity.ok(systemJobService.queryJobByArgs(criteria, page)); @@ -61,7 +63,8 @@ public class SystemJobController { @ApiOperation("查询岗位") @PostMapping @PreAuthorize("@el.check('job:list','user:list')") - public ResponseEntity> queryJobByCrud(@Validated @RequestBody KitPageArgs args) { + public ResponseEntity> queryJobByCrud( + @Validated @RequestBody KitPageArgs args) { return queryJobByArgs(args); } 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 a50be464..b27c1286 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.odboy.base.KitPageArgs; @@ -27,27 +26,31 @@ import cn.odboy.util.KitFileUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; 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.*; +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; import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - @RestController @Api(tags = "工具:本地存储管理") @RequestMapping("/api/localStorage") public class SystemLocalStorageController { - @Autowired - private SystemLocalStorageService localStorageService; + @Autowired private SystemLocalStorageService localStorageService; @ApiOperation("查询文件") @PostMapping @PreAuthorize("@el.check('storage:list')") - public ResponseEntity> queryLocalStorage(@Validated @RequestBody KitPageArgs args) { + public ResponseEntity> queryLocalStorage( + @Validated @RequestBody KitPageArgs args) { SystemQueryStorageArgs criteria = args.getArgs(); Page page = new Page<>(criteria.getPage(), criteria.getSize()); return ResponseEntity.ok(localStorageService.queryLocalStorage(criteria, page)); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMenuController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMenuController.java index 0255075b..3a15f2f1 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMenuController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMenuController.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.hutool.core.collection.CollectionUtil; @@ -29,24 +28,30 @@ import cn.odboy.system.service.SystemMenuService; import cn.odboy.util.KitPageUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashSet; +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.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.servlet.http.HttpServletResponse; -import java.util.*; -import java.util.stream.Collectors; +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 @Api(tags = "系统:菜单管理") @RequestMapping("/api/menu") public class SystemMenuController { - @Autowired - private SystemMenuService systemMenuService; - @Autowired - private SystemMenuMapper systemMenuMapper; + @Autowired private SystemMenuService systemMenuService; + @Autowired private SystemMenuMapper systemMenuMapper; @ApiOperation("导出菜单数据") @GetMapping(value = "/download") @@ -85,14 +90,16 @@ public class SystemMenuController { @PostMapping @ApiOperation("查询菜单") @PreAuthorize("@el.check('menu:list')") - public ResponseEntity> queryAllMenuByCrud(@Validated @RequestBody KitPageArgs args) throws Exception { + public ResponseEntity> queryAllMenuByCrud( + @Validated @RequestBody KitPageArgs args) throws Exception { return queryAllMenu(args); } @PostMapping(value = "/queryMenuByArgs") @ApiOperation("查询菜单") @PreAuthorize("@el.check('menu:list')") - public ResponseEntity> queryAllMenu(@Validated @RequestBody KitPageArgs args) throws Exception { + public ResponseEntity> queryAllMenu( + @Validated @RequestBody KitPageArgs args) throws Exception { SystemQueryMenuArgs criteria = args.getArgs(); List menuList = systemMenuService.queryAllMenu(criteria, true); return ResponseEntity.ok(KitPageUtil.toPage(menuList)); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMonitorController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMonitorController.java index a9260d8e..b5dfffb2 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMonitorController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemMonitorController.java @@ -13,12 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.odboy.system.service.SystemMonitorService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; @@ -26,14 +26,11 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.Map; - @RestController @Api(tags = "系统-服务监控管理") @RequestMapping("/api/monitor") public class SystemMonitorController { - @Autowired - private SystemMonitorService systemMonitorService; + @Autowired private SystemMonitorService systemMonitorService; @PostMapping(value = "/queryServerMonitorInfo") @ApiOperation("查询服务监控") diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOnlineController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOnlineController.java index 61fd91ec..2a607da4 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOnlineController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOnlineController.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.odboy.base.KitPageArgs; @@ -25,27 +24,30 @@ 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.io.IOException; +import java.util.Set; +import javax.servlet.http.HttpServletResponse; 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.*; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Set; +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.RestController; @RestController @RequestMapping("/api/user/online") @Api(tags = "系统:在线用户管理") public class SystemOnlineController { - @Autowired - private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; + @Autowired private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; @ApiOperation("查询在线用户") @PostMapping @PreAuthorize("@el.check()") - public ResponseEntity> queryOnlineUser(@Validated @RequestBody KitPageArgs args) { + public ResponseEntity> queryOnlineUser( + @Validated @RequestBody KitPageArgs args) { IPage page = new Page<>(args.getPage(), args.getSize()); return ResponseEntity.ok(systemUserOnlineInfoDAO.queryUserOnlineModelPage(args.getArgs(), page)); } @@ -54,7 +56,8 @@ public class SystemOnlineController { @GetMapping(value = "/download") @PreAuthorize("@el.check()") public void exportOnlineUser(HttpServletResponse response, String username) throws IOException { - systemUserOnlineInfoDAO.downloadUserOnlineModelExcel(systemUserOnlineInfoDAO.queryUserOnlineModelListByUsername(username), response); + systemUserOnlineInfoDAO.downloadUserOnlineModelExcel( + systemUserOnlineInfoDAO.queryUserOnlineModelListByUsername(username), response); } @ApiOperation("踢出用户") diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOssStorageController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOssStorageController.java index ce5fdd4f..ea07828d 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOssStorageController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemOssStorageController.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.odboy.base.KitPageArgs; @@ -25,29 +24,33 @@ import cn.odboy.system.service.SystemOssStorageService; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; 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.*; +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; import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - @Slf4j @RestController @Api(tags = "工具:OSS存储管理") @RequestMapping("/api/ossStorage") public class SystemOssStorageController { - @Autowired - private SystemOssStorageService systemOssStorageService; + @Autowired private SystemOssStorageService systemOssStorageService; @ApiOperation("查询文件") @PostMapping @PreAuthorize("@el.check('storage:list')") - public ResponseEntity> queryOssStorage(@Validated @RequestBody KitPageArgs args) { + public ResponseEntity> queryOssStorage( + @Validated @RequestBody KitPageArgs args) { SystemQueryStorageArgs criteria = args.getArgs(); Page page = new Page<>(criteria.getPage(), criteria.getSize()); return ResponseEntity.ok(systemOssStorageService.queryOssStorage(criteria, page)); 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 4edc2bb4..4b109383 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.odboy.base.KitPageArgs; @@ -28,29 +27,34 @@ 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.io.IOException; +import java.util.Set; +import javax.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; 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.*; - -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.Set; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; @Slf4j @RestController @RequestMapping("/api/quartzJob") @Api(tags = "系统:定时任务管理") public class SystemQuartzJobController { - @Autowired - private SystemQuartzJobService systemQuartzJobService; + @Autowired private SystemQuartzJobService systemQuartzJobService; @ApiOperation("查询定时任务") @PostMapping @PreAuthorize("@el.check('quartzJob:list')") - public ResponseEntity> queryQuartzJobByCrud(@Validated @RequestBody KitPageArgs args) { + public ResponseEntity> queryQuartzJobByCrud( + @Validated @RequestBody KitPageArgs args) { SystemQueryQuartzJobArgs criteria = args.getArgs(); Page page = new Page<>(criteria.getPage(), criteria.getSize()); return ResponseEntity.ok(systemQuartzJobService.queryQuartzJobByArgs(criteria, page)); @@ -94,7 +98,8 @@ public class SystemQuartzJobController { @ApiOperation("修改定时任务") @PutMapping @PreAuthorize("@el.check('quartzJob:edit')") - public ResponseEntity updateQuartzJob(@Validated(SystemQuartzJobTb.Update.class) @RequestBody SystemUpdateQuartzJobArgs args) { + public ResponseEntity updateQuartzJob( + @Validated(SystemQuartzJobTb.Update.class) @RequestBody SystemUpdateQuartzJobArgs args) { // 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义 checkBean(args.getBeanName()); systemQuartzJobService.modifyQuartzJobResumeCron(args); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemRoleController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemRoleController.java index 29290cbc..27399661 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemRoleController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemRoleController.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.hutool.core.lang.Dict; @@ -28,25 +27,27 @@ 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 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.*; - -import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Collections; 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.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.RestController; @RestController @Api(tags = "系统:角色管理") @RequestMapping("/api/role") public class SystemRoleController { - @Autowired - private SystemRoleService systemRoleService; + @Autowired private SystemRoleService systemRoleService; @ApiOperation("获取单个role") @PostMapping(value = "/queryRoleById") @@ -72,7 +73,8 @@ public class SystemRoleController { @ApiOperation("查询角色") @PostMapping @PreAuthorize("@el.check('roles:list')") - public ResponseEntity> queryRoleByArgs(@Validated @RequestBody KitPageArgs args) { + public ResponseEntity> queryRoleByArgs( + @Validated @RequestBody KitPageArgs args) { SystemQueryRoleArgs criteria = args.getArgs(); Page page = new Page<>(criteria.getPage(), criteria.getSize()); return ResponseEntity.ok(systemRoleService.queryRoleByArgs(criteria, page)); @@ -132,8 +134,8 @@ public class SystemRoleController { * @return / */ private int checkRoleLevels(Integer level) { - List levels = - systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()); + List levels = systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream() + .map(SystemRoleTb::getLevel).collect(Collectors.toList()); int min = Collections.min(levels); if (level != null) { if (level < min) { diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemUserController.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemUserController.java index 63fe9a57..e46b7ddb 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemUserController.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/controller/SystemUserController.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.controller; import cn.hutool.core.collection.CollectionUtil; @@ -29,13 +28,25 @@ import cn.odboy.system.dal.dataobject.SystemUserTb; import cn.odboy.system.dal.model.SystemQueryUserArgs; import cn.odboy.system.dal.model.SystemUpdateUserPasswordArgs; import cn.odboy.system.framework.permission.core.CsSecurityHelper; -import cn.odboy.system.service.*; +import cn.odboy.system.service.SystemDataService; +import cn.odboy.system.service.SystemDeptService; +import cn.odboy.system.service.SystemEmailService; +import cn.odboy.system.service.SystemRoleService; +import cn.odboy.system.service.SystemUserService; import cn.odboy.util.KitPageUtil; import cn.odboy.util.KitRsaEncryptUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; @@ -43,32 +54,26 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.util.CollectionUtils; import org.springframework.util.ObjectUtils; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +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; import org.springframework.web.multipart.MultipartFile; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.*; -import java.util.stream.Collectors; - @Api(tags = "系统:用户管理") @RestController @RequestMapping("/api/user") public class SystemUserController { - @Autowired - private PasswordEncoder passwordEncoder; - @Autowired - private SystemUserService systemUserService; - @Autowired - private SystemDataService systemDataService; - @Autowired - private SystemDeptService systemDeptService; - @Autowired - private SystemRoleService systemRoleService; - @Autowired - private SystemEmailService systemEmailService; - @Autowired - private AppProperties properties; + @Autowired private PasswordEncoder passwordEncoder; + @Autowired private SystemUserService systemUserService; + @Autowired private SystemDataService systemDataService; + @Autowired private SystemDeptService systemDeptService; + @Autowired private SystemRoleService systemRoleService; + @Autowired private SystemEmailService systemEmailService; + @Autowired private AppProperties properties; @ApiOperation("导出用户数据") @GetMapping(value = "/download") @@ -80,7 +85,8 @@ public class SystemUserController { @ApiOperation("查询用户") @PostMapping @PreAuthorize("@el.check('user:list')") - public ResponseEntity> queryUserByArgs(@Validated @RequestBody KitPageArgs args) { + public ResponseEntity> queryUserByArgs( + @Validated @RequestBody KitPageArgs args) { Page page = new Page<>(args.getPage(), args.getSize()); SystemQueryUserArgs criteria = args.getArgs(); if (!ObjectUtils.isEmpty(criteria.getDeptId())) { @@ -91,7 +97,8 @@ public class SystemUserController { criteria.getDeptIds().addAll(systemDeptService.queryChildDeptIdListByDeptIds(data)); } // 数据权限 - List dataScopes = systemDataService.queryDeptIdListByArgs(systemUserService.getUserByUsername(CsSecurityHelper.getCurrentUsername())); + List dataScopes = systemDataService.findDeptIdListByArgs( + systemUserService.getUserByUsername(CsSecurityHelper.getCurrentUsername())); // criteria.getDeptIds() 不为空并且数据权限不为空则取交集 if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) { // 取交集 @@ -129,7 +136,8 @@ public class SystemUserController { @ApiOperation("修改用户:个人中心") @PostMapping(value = "modifyUserCenterInfoById") - public ResponseEntity modifyUserCenterInfoById(@Validated(SystemUserTb.Update.class) @RequestBody SystemUserTb args) { + public ResponseEntity modifyUserCenterInfoById( + @Validated(SystemUserTb.Update.class) @RequestBody SystemUserTb args) { if (!args.getId().equals(CsSecurityHelper.getCurrentUserId())) { throw new BadRequestException("不能修改他人资料"); } @@ -143,10 +151,14 @@ public class SystemUserController { public ResponseEntity removeUserByIds(@RequestBody Set ids) { for (Long id : ids) { Integer currentLevel = Collections.min( - systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList())); - Integer optLevel = Collections.min(systemRoleService.queryRoleByUsersId(id).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList())); + systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream() + .map(SystemRoleTb::getLevel).collect(Collectors.toList())); + Integer optLevel = Collections.min( + systemRoleService.queryRoleByUsersId(id).stream().map(SystemRoleTb::getLevel) + .collect(Collectors.toList())); if (currentLevel > optLevel) { - throw new BadRequestException("角色权限不足, 不能删除:" + systemUserService.getUserById(id).getUsername()); + throw new BadRequestException( + "角色权限不足, 不能删除:" + systemUserService.getUserById(id).getUsername()); } } systemUserService.removeUserByIds(ids); @@ -155,9 +167,12 @@ public class SystemUserController { @ApiOperation("修改密码") @PostMapping(value = "/modifyUserPasswordByUsername") - public ResponseEntity modifyUserPasswordByUsername(@RequestBody SystemUpdateUserPasswordArgs passVo) throws Exception { - String oldPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getOldPass()); - String newPass = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getNewPass()); + public ResponseEntity modifyUserPasswordByUsername(@RequestBody SystemUpdateUserPasswordArgs passVo) + throws Exception { + String oldPass = + KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getOldPass()); + String newPass = + KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getNewPass()); SystemUserTb user = systemUserService.getUserByUsername(CsSecurityHelper.getCurrentUsername()); if (!passwordEncoder.matches(oldPass, user.getPassword())) { throw new BadRequestException("修改失败,旧密码错误"); @@ -185,8 +200,10 @@ public class SystemUserController { @ApiOperation("修改邮箱") @PostMapping(value = "/modifyUserEmailByUsername/{code}") - public ResponseEntity modifyUserEmailByUsername(@PathVariable String code, @RequestBody SystemUserTb args) throws Exception { - String password = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword()); + public ResponseEntity modifyUserEmailByUsername(@PathVariable String code, @RequestBody SystemUserTb args) + throws Exception { + String password = + KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword()); SystemUserTb user = systemUserService.getUserByUsername(CsSecurityHelper.getCurrentUsername()); if (!passwordEncoder.matches(password, user.getPassword())) { throw new BadRequestException("密码错误"); @@ -203,7 +220,8 @@ public class SystemUserController { */ private void checkLevel(SystemUserTb args) { Integer currentLevel = Collections.min( - systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList())); + systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream() + .map(SystemRoleTb::getLevel).collect(Collectors.toList())); Integer optLevel = systemRoleService.getDeptLevelByRoles(args.getRoles()); if (currentLevel > optLevel) { throw new BadRequestException("角色权限不足"); @@ -214,27 +232,7 @@ public class SystemUserController { @PostMapping(value = "/queryUserMetadataOptions") @PreAuthorize("@el.check('user:list')") public ResponseEntity> queryUserMetadataOptions(@Validated @RequestBody KitPageArgs args) { - int maxPageSize = 50; - SystemQueryUserArgs criteria = args.getArgs(); - LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); - wrapper.and(c -> { - c.eq(SystemUserTb::getPhone, criteria.getBlurry()); - c.or(); - c.eq(SystemUserTb::getEmail, criteria.getBlurry()); - c.or(); - c.like(SystemUserTb::getUsername, criteria.getBlurry()); - c.or(); - c.like(SystemUserTb::getNickName, criteria.getBlurry()); - }); - List collect = - systemUserService.queryUserByBlurry(wrapper, new Page<>(criteria.getPage(), maxPageSize)).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()); + List collect = systemUserService.queryUserMetadataOptions(args); return ResponseEntity.ok(collect); } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDeptTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDeptTb.java index 0e9894a2..dc69ed6d 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDeptTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDeptTb.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitBaseUserTimeTb; @@ -23,50 +22,28 @@ 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 javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.util.List; import java.util.Objects; import java.util.Set; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; @Getter @Setter @TableName("system_dept") public class SystemDeptTb extends KitBaseUserTimeTb { - - @NotNull(groups = Update.class) - @TableId(value = "dept_id", type = IdType.AUTO) - @ApiModelProperty(value = "ID", hidden = true) - private Long id; - - @TableField(exist = false) - @JSONField(serialize = false) - @ApiModelProperty(value = "角色") - private Set roles; - - @TableField(exist = false) - @ApiModelProperty(value = "子部门") - private List children; - - @ApiModelProperty(value = "排序") - private Integer deptSort; - - @NotBlank - @ApiModelProperty(value = "部门名称") - private String name; - - @NotNull - @ApiModelProperty(value = "是否启用") - private Boolean enabled; - - @ApiModelProperty(value = "上级部门") - private Long pid; - - @ApiModelProperty(value = "子节点数目", hidden = true) - private Integer subCount = 0; + @NotNull(groups = Update.class) @TableId(value = "dept_id", type = IdType.AUTO) + @ApiModelProperty(value = "ID", hidden = true) private Long id; + @TableField(exist = false) @JSONField(serialize = false) @ApiModelProperty(value = "角色") private Set + roles; + @TableField(exist = false) @ApiModelProperty(value = "子部门") private List children; + @ApiModelProperty(value = "排序") private Integer deptSort; + @NotBlank @ApiModelProperty(value = "部门名称") private String name; + @NotNull @ApiModelProperty(value = "是否启用") private Boolean enabled; + @ApiModelProperty(value = "上级部门") private Long pid; + @ApiModelProperty(value = "子节点数目", hidden = true) private Integer subCount = 0; @Override public boolean equals(Object o) { diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictDetailTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictDetailTb.java index efa08c29..e67da9ad 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictDetailTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictDetailTb.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitBaseUserTimeTb; @@ -22,35 +21,19 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotNull; import lombok.Getter; import lombok.Setter; -import javax.validation.constraints.NotNull; - @Getter @Setter @TableName("system_dict_detail") public class SystemDictDetailTb extends KitBaseUserTimeTb { - - @NotNull(groups = Update.class) - @ApiModelProperty(value = "ID", hidden = true) - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @TableField(value = "dict_id") - @ApiModelProperty(hidden = true) - private Long dictId; - - @TableField(exist = false) - @ApiModelProperty(value = "字典") - private SystemDictTb dict; - - @ApiModelProperty(value = "字典标签") - private String label; - - @ApiModelProperty(value = "字典值") - private String value; - - @ApiModelProperty(value = "排序") - private Integer dictSort = 999; + @NotNull(groups = Update.class) @ApiModelProperty(value = "ID", hidden = true) + @TableId(value = "id", type = IdType.AUTO) private Long id; + @TableField(value = "dict_id") @ApiModelProperty(hidden = true) private Long dictId; + @TableField(exist = false) @ApiModelProperty(value = "字典") private SystemDictTb dict; + @ApiModelProperty(value = "字典标签") private String label; + @ApiModelProperty(value = "字典值") private String value; + @ApiModelProperty(value = "排序") private Integer dictSort = 999; } \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictTb.java index aed6b1e5..c1134916 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemDictTb.java @@ -13,33 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitBaseUserTimeTb; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.FieldStrategy; +import com.baomidou.mybatisplus.annotation.IdType; +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 javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; @Getter @Setter @TableName("system_dict") public class SystemDictTb extends KitBaseUserTimeTb { - - @NotNull(groups = Update.class) - @ApiModelProperty(value = "ID", hidden = true) - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @NotBlank - @ApiModelProperty(value = "名称") - private String name; - - @ApiModelProperty(value = "描述") - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private String description; + @NotNull(groups = Update.class) @ApiModelProperty(value = "ID", hidden = true) + @TableId(value = "id", type = IdType.AUTO) private Long id; + @NotBlank @ApiModelProperty(value = "名称") private String name; + @ApiModelProperty(value = "描述") @TableField(updateStrategy = FieldStrategy.ALWAYS) private String description; } \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemEmailConfigTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemEmailConfigTb.java index 36f748c3..dbe5394a 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemEmailConfigTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemEmailConfigTb.java @@ -13,18 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitObject; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Data; import lombok.EqualsAndHashCode; -import javax.validation.constraints.NotBlank; - /** * 邮件配置类,数据存覆盖式存入数据存 */ @@ -32,27 +30,10 @@ import javax.validation.constraints.NotBlank; @TableName("system_email_config") @EqualsAndHashCode(callSuper = false) public class SystemEmailConfigTb extends KitObject { - - @TableId("config_id") - private Long id; - - @NotBlank - @ApiModelProperty(value = "邮件服务器SMTP地址") - private String host; - - @NotBlank - @ApiModelProperty(value = "邮件服务器 SMTP 端口") - private String port; - - @NotBlank - @ApiModelProperty(value = "发件者用户名") - private String user; - - @NotBlank - @ApiModelProperty(value = "密码") - private String password; - - @NotBlank - @ApiModelProperty(value = "收件人") - private String fromUser; + @TableId("config_id") private Long id; + @NotBlank @ApiModelProperty(value = "邮件服务器SMTP地址") private String host; + @NotBlank @ApiModelProperty(value = "邮件服务器 SMTP 端口") private String port; + @NotBlank @ApiModelProperty(value = "发件者用户名") private String user; + @NotBlank @ApiModelProperty(value = "密码") private String password; + @NotBlank @ApiModelProperty(value = "收件人") private String fromUser; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemJobTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemJobTb.java index 27eeb374..626f8763 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemJobTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemJobTb.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitBaseUserTimeTb; @@ -21,34 +20,21 @@ 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 java.util.Objects; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; -import java.util.Objects; +import lombok.Getter; +import lombok.Setter; @Getter @Setter @TableName("system_job") public class SystemJobTb extends KitBaseUserTimeTb { - - @NotNull(groups = Update.class) - @TableId(value = "id", type = IdType.AUTO) - @ApiModelProperty(value = "ID", hidden = true) - private Long id; - - @NotBlank - @ApiModelProperty(value = "岗位名称") - private String name; - - @NotNull - @ApiModelProperty(value = "岗位排序") - private Long jobSort; - - @NotNull - @ApiModelProperty(value = "是否启用") - private Boolean enabled; + @NotNull(groups = Update.class) @TableId(value = "id", type = IdType.AUTO) + @ApiModelProperty(value = "ID", hidden = true) private Long id; + @NotBlank @ApiModelProperty(value = "岗位名称") private String name; + @NotNull @ApiModelProperty(value = "岗位排序") private Long jobSort; + @NotNull @ApiModelProperty(value = "是否启用") private Boolean enabled; @Override public boolean equals(Object o) { 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 723d79dd..f8b0f2c2 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.dataobject; import cn.hutool.core.bean.BeanUtil; @@ -30,31 +29,14 @@ import lombok.Setter; @Setter @TableName("system_local_storage") public class SystemLocalStorageTb extends KitBaseUserTimeTb { - - @TableId(value = "id", type = IdType.AUTO) - @ApiModelProperty(value = "ID", hidden = true) - private Long id; - - @ApiModelProperty(value = "真实文件名") - private String realName; - - @ApiModelProperty(value = "文件名") - private String name; - - @ApiModelProperty(value = "后缀") - private String suffix; - - @ApiModelProperty(value = "路径") - private String path; - - @ApiModelProperty(value = "类型") - private String type; - - @ApiModelProperty(value = "大小") - private String size; - - @ApiModelProperty(value = "日期分组") - private String dateGroup; + @TableId(value = "id", type = IdType.AUTO) @ApiModelProperty(value = "ID", hidden = true) private Long id; + @ApiModelProperty(value = "真实文件名") private String realName; + @ApiModelProperty(value = "文件名") private String name; + @ApiModelProperty(value = "后缀") private String suffix; + @ApiModelProperty(value = "路径") private String path; + @ApiModelProperty(value = "类型") private String type; + @ApiModelProperty(value = "大小") private String size; + @ApiModelProperty(value = "日期分组") private String dateGroup; public void copy(SystemLocalStorageTb source) { BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true)); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemMenuTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemMenuTb.java index 9ad5f662..4f00ee81 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemMenuTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemMenuTb.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitBaseUserTimeTb; @@ -23,71 +22,35 @@ 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 javax.validation.constraints.NotNull; import java.util.List; import java.util.Objects; import java.util.Set; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; @Getter @Setter @TableName("system_menu") public class SystemMenuTb extends KitBaseUserTimeTb { - - @NotNull(groups = {Update.class}) - @TableId(value = "menu_id", type = IdType.AUTO) - @ApiModelProperty(value = "ID", hidden = true) - private Long id; - - @TableField(exist = false) - @JSONField(serialize = false) - @ApiModelProperty(value = "菜单角色") + @NotNull(groups = {Update.class}) @TableId(value = "menu_id", type = IdType.AUTO) + @ApiModelProperty(value = "ID", hidden = true) private Long id; + @TableField(exist = false) @JSONField(serialize = false) @ApiModelProperty(value = "菜单角色") private Set roles; - - @TableField(exist = false) - private List children; - - @ApiModelProperty(value = "菜单标题") - private String title; - - @TableField(value = "name") - @ApiModelProperty(value = "菜单组件名称") - private String componentName; - - @ApiModelProperty(value = "排序") - private Integer menuSort = 999; - - @ApiModelProperty(value = "组件路径") - private String component; - - @ApiModelProperty(value = "路由地址") - private String path; - - @ApiModelProperty(value = "菜单类型,目录、菜单、按钮") - private Integer type; - - @ApiModelProperty(value = "权限标识") - private String permission; - - @ApiModelProperty(value = "菜单图标") - private String icon; - - @ApiModelProperty(value = "缓存") - private Boolean cache; - - @ApiModelProperty(value = "是否隐藏") - private Boolean hidden; - - @ApiModelProperty(value = "上级菜单") - private Long pid; - - @ApiModelProperty(value = "子节点数目", hidden = true) - private Integer subCount = 0; - - @ApiModelProperty(value = "外链菜单") - private Boolean iFrame; + @TableField(exist = false) private List children; + @ApiModelProperty(value = "菜单标题") private String title; + @TableField(value = "name") @ApiModelProperty(value = "菜单组件名称") private String componentName; + @ApiModelProperty(value = "排序") private Integer menuSort = 999; + @ApiModelProperty(value = "组件路径") private String component; + @ApiModelProperty(value = "路由地址") private String path; + @ApiModelProperty(value = "菜单类型,目录、菜单、按钮") private Integer type; + @ApiModelProperty(value = "权限标识") private String permission; + @ApiModelProperty(value = "菜单图标") private String icon; + @ApiModelProperty(value = "缓存") private Boolean cache; + @ApiModelProperty(value = "是否隐藏") private Boolean hidden; + @ApiModelProperty(value = "上级菜单") private Long pid; + @ApiModelProperty(value = "子节点数目", hidden = true) private Integer subCount = 0; + @ApiModelProperty(value = "外链菜单") private Boolean iFrame; @Override public boolean equals(Object o) { diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemOperationLogTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemOperationLogTb.java index 1d5ba991..57de7d72 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemOperationLogTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemOperationLogTb.java @@ -13,19 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitObject; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +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; - /** *

* 系统审计日志 @@ -40,62 +42,48 @@ import java.util.Date; @TableName("system_operation_log") @ApiModel(value = "SystemOperationLog对象", description = "审计日志") public class SystemOperationLogTb extends KitObject { - /** * id */ - @ApiModelProperty("id") - @TableId(value = "id", type = IdType.AUTO) - private Long id; - + @ApiModelProperty("id") @TableId(value = "id", type = IdType.AUTO) private Long id; /** * 业务名称 */ - @TableField("biz_name") - private String bizName; + @TableField("biz_name") private String bizName; /** * 业务方法 */ - @TableField("method") - private String method; + @TableField("method") private String method; /** * 业务参数 */ - @TableField("params") - private String params; + @TableField("params") private String params; /** * 访问来源IP */ - @TableField("request_ip") - private String requestIp; + @TableField("request_ip") private String requestIp; /** * 执行时间 */ - @TableField("execute_time") - private Long executeTime; + @TableField("execute_time") private Long executeTime; /** * 用户名 */ - @TableField("username") - private String username; + @TableField("username") private String username; /** * 访问来源地址 */ - @TableField("address") - private String address; + @TableField("address") private String address; /** * 浏览器信息 */ - @TableField("browser_info") - private String browserInfo; + @TableField("browser_info") private String browserInfo; /** * 异常详情 */ - @TableField("exception_detail") - private String exceptionDetail; + @TableField("exception_detail") private String exceptionDetail; /** * 创建时间 */ - @TableField(value = "create_time", fill = FieldFill.INSERT) - private Date createTime; + @TableField(value = "create_time", fill = FieldFill.INSERT) private Date createTime; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemOssStorageTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemOssStorageTb.java index 966adb43..5a090601 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemOssStorageTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemOssStorageTb.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitBaseUserTimeTb; @@ -39,43 +38,17 @@ import lombok.Setter; @TableName("system_oss_storage") @ApiModel(value = "SystemOssStorage对象", description = "OSS存储") public class SystemOssStorageTb extends KitBaseUserTimeTb { - @ApiModelProperty("ID") - @TableId(value = "id", type = IdType.AUTO) - private Long id; - @TableField("service_type") - @ApiModelProperty("类型,比如minio") - private String serviceType; - @TableField("endpoint") - @ApiModelProperty("服务地址") - private String endpoint; - @TableField("bucket_name") - @ApiModelProperty("存储桶名称") - private String bucketName; - @TableField("file_name") - @ApiModelProperty("完整文件名称") - private String fileName; - @TableField("file_size") - @ApiModelProperty("文件大小, 单位:字节") - private Long fileSize; - @TableField("file_mime") - @ApiModelProperty("文件类型") - private String fileMime; - @ApiModelProperty("短文件名") - @TableField("file_prefix") - private String filePrefix; - @ApiModelProperty("文件后缀") - @TableField("file_suffix") - private String fileSuffix; - @TableField("file_md5") - @ApiModelProperty("文件md5") - private String fileMd5; - @TableField("file_url") - @ApiModelProperty("文件链接") - private String fileUrl; - @TableField("file_code") - @ApiModelProperty("文件编码") - private String fileCode; - @TableField("object_name") - @ApiModelProperty("对象路径") - private String objectName; + @ApiModelProperty("ID") @TableId(value = "id", type = IdType.AUTO) private Long id; + @TableField("service_type") @ApiModelProperty("类型,比如minio") private String serviceType; + @TableField("endpoint") @ApiModelProperty("服务地址") private String endpoint; + @TableField("bucket_name") @ApiModelProperty("存储桶名称") private String bucketName; + @TableField("file_name") @ApiModelProperty("完整文件名称") private String fileName; + @TableField("file_size") @ApiModelProperty("文件大小, 单位:字节") private Long fileSize; + @TableField("file_mime") @ApiModelProperty("文件类型") private String fileMime; + @ApiModelProperty("短文件名") @TableField("file_prefix") private String filePrefix; + @ApiModelProperty("文件后缀") @TableField("file_suffix") private String fileSuffix; + @TableField("file_md5") @ApiModelProperty("文件md5") private String fileMd5; + @TableField("file_url") @ApiModelProperty("文件链接") private String fileUrl; + @TableField("file_code") @ApiModelProperty("文件编码") private String fileCode; + @TableField("object_name") @ApiModelProperty("对象路径") private String objectName; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzJobTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzJobTb.java index c914f719..3bd23363 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzJobTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzJobTb.java @@ -13,68 +13,37 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitBaseUserTimeTb; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.FieldStrategy; +import com.baomidou.mybatisplus.annotation.IdType; +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 javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; @Getter @Setter @TableName("system_quartz_job") public class SystemQuartzJobTb extends KitBaseUserTimeTb { - public static final String JOB_KEY = "JOB_KEY"; - - @TableId(value = "id", type = IdType.AUTO) - @NotNull(groups = {Update.class}) - private Long id; - - @TableField(exist = false) - @ApiModelProperty(value = "用于子任务唯一标识", hidden = true) - private String uuid; - - @ApiModelProperty(value = "定时器名称") - private String jobName; - - @NotBlank - @ApiModelProperty(value = "Bean名称") - private String beanName; - - @NotBlank - @ApiModelProperty(value = "方法名称") - private String methodName; - - @ApiModelProperty(value = "参数") - private String params; - - @NotBlank - @ApiModelProperty(value = "cron表达式") - private String cronExpression; - - @ApiModelProperty(value = "状态:暂停或启动") - private Boolean isPause = false; - - @ApiModelProperty(value = "负责人") - private String personInCharge; - - @ApiModelProperty(value = "报警邮箱") - private String email; - - @ApiModelProperty(value = "子任务") - private String subTask; - - @ApiModelProperty(value = "失败后暂停") - private Boolean pauseAfterFailure; - - @NotBlank - @ApiModelProperty(value = "备注") - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private String description; + @TableId(value = "id", type = IdType.AUTO) @NotNull(groups = {Update.class}) private Long id; + @TableField(exist = false) @ApiModelProperty(value = "用于子任务唯一标识", hidden = true) private String uuid; + @ApiModelProperty(value = "定时器名称") private String jobName; + @NotBlank @ApiModelProperty(value = "Bean名称") private String beanName; + @NotBlank @ApiModelProperty(value = "方法名称") private String methodName; + @ApiModelProperty(value = "参数") private String params; + @NotBlank @ApiModelProperty(value = "cron表达式") private String cronExpression; + @ApiModelProperty(value = "状态:暂停或启动") private Boolean isPause = false; + @ApiModelProperty(value = "负责人") private String personInCharge; + @ApiModelProperty(value = "报警邮箱") private String email; + @ApiModelProperty(value = "子任务") private String subTask; + @ApiModelProperty(value = "失败后暂停") private Boolean pauseAfterFailure; + @NotBlank @ApiModelProperty(value = "备注") @TableField(updateStrategy = FieldStrategy.ALWAYS) private String + description; } \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzLogTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzLogTb.java index 825bcda3..28695494 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzLogTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemQuartzLogTb.java @@ -13,51 +13,31 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitObject; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +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") @EqualsAndHashCode(callSuper = false) public class SystemQuartzLogTb extends KitObject { - - @TableId(value = "id", type = IdType.AUTO) - @ApiModelProperty(value = "ID", hidden = true) - private Long id; - - @ApiModelProperty(value = "任务名称", hidden = true) - private String jobName; - - @ApiModelProperty(value = "bean名称", hidden = true) - private String beanName; - - @ApiModelProperty(value = "方法名称", hidden = true) - private String methodName; - - @ApiModelProperty(value = "参数", hidden = true) - private String params; - - @ApiModelProperty(value = "cron表达式", hidden = true) - private String cronExpression; - - @ApiModelProperty(value = "状态", hidden = true) - private Boolean isSuccess; - - @ApiModelProperty(value = "异常详情", hidden = true) - private String exceptionDetail; - - @ApiModelProperty(value = "执行耗时", hidden = true) - private Long time; - - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间", hidden = true) - private Date createTime; + @TableId(value = "id", type = IdType.AUTO) @ApiModelProperty(value = "ID", hidden = true) private Long id; + @ApiModelProperty(value = "任务名称", hidden = true) private String jobName; + @ApiModelProperty(value = "bean名称", hidden = true) private String beanName; + @ApiModelProperty(value = "方法名称", hidden = true) private String methodName; + @ApiModelProperty(value = "参数", hidden = true) private String params; + @ApiModelProperty(value = "cron表达式", hidden = true) private String cronExpression; + @ApiModelProperty(value = "状态", hidden = true) private Boolean isSuccess; + @ApiModelProperty(value = "异常详情", hidden = true) private String exceptionDetail; + @ApiModelProperty(value = "执行耗时", hidden = true) private Long time; + @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间", hidden = true) private Date createTime; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleDeptTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleDeptTb.java new file mode 100644 index 00000000..e1107881 --- /dev/null +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleDeptTb.java @@ -0,0 +1,30 @@ +/* + * Copyright 2021-2025 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.system.dal.dataobject; + +import cn.odboy.base.KitObject; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@TableName("system_roles_depts") +public class SystemRoleDeptTb extends KitObject { + @TableField(value = "role_id") private Long roleId; + @TableField(value = "dept_id") private Long deptId; +} \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleMenuTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleMenuTb.java index 25a6287d..ec0d1838 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleMenuTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleMenuTb.java @@ -1,5 +1,6 @@ package cn.odboy.system.dal.dataobject; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Getter; import lombok.Setter; @@ -11,6 +12,6 @@ import lombok.Setter; @Setter @TableName("system_roles_menus") public class SystemRoleMenuTb { - private Long menuId; - private Long roleId; + @TableField(value = "role_id") private Long roleId; + @TableField(value = "menu_id") private Long menuId; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleTb.java index e393285c..cbf3eaf4 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemRoleTb.java @@ -13,20 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitBaseUserTimeTb; import cn.odboy.system.constant.SystemDataScopeEnum; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.FieldStrategy; +import com.baomidou.mybatisplus.annotation.IdType; +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 javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.util.Objects; import java.util.Set; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; /** * 角色 @@ -35,37 +37,16 @@ import java.util.Set; @Setter @TableName("system_role") public class SystemRoleTb extends KitBaseUserTimeTb { - - @NotNull(groups = {Update.class}) - @TableId(value = "role_id", type = IdType.AUTO) - @ApiModelProperty(value = "ID", hidden = true) - private Long id; - - @TableField(exist = false) - @ApiModelProperty(value = "用户", hidden = true) - private Set users; - - @TableField(exist = false) - @ApiModelProperty(value = "菜单", hidden = true) - private Set menus; - - @TableField(exist = false) - @ApiModelProperty(value = "部门", hidden = true) - private Set depts; - - @NotBlank - @ApiModelProperty(value = "名称", hidden = true) - private String name; - - @ApiModelProperty(value = "数据权限,全部 、 本级 、 自定义") - private String dataScope = SystemDataScopeEnum.THIS_LEVEL.getValue(); - - @ApiModelProperty(value = "级别,数值越小,级别越大") - private Integer level = 3; - - @ApiModelProperty(value = "描述") - @TableField(updateStrategy = FieldStrategy.ALWAYS) - private String description; + @NotNull(groups = {Update.class}) @TableId(value = "role_id", type = IdType.AUTO) + @ApiModelProperty(value = "ID", hidden = true) private Long id; + @TableField(exist = false) @ApiModelProperty(value = "用户", hidden = true) private Set users; + @TableField(exist = false) @ApiModelProperty(value = "菜单", hidden = true) private Set menus; + @TableField(exist = false) @ApiModelProperty(value = "部门", hidden = true) private Set depts; + @NotBlank @ApiModelProperty(value = "名称", hidden = true) private String name; + @ApiModelProperty(value = "数据权限,全部 、 本级 、 自定义") private String dataScope = + SystemDataScopeEnum.THIS_LEVEL.getValue(); + @ApiModelProperty(value = "级别,数值越小,级别越大") private Integer level = 3; + @ApiModelProperty(value = "描述") @TableField(updateStrategy = FieldStrategy.ALWAYS) private String description; @Override public boolean equals(Object o) { diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserJobTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserJobTb.java new file mode 100644 index 00000000..e898048d --- /dev/null +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserJobTb.java @@ -0,0 +1,17 @@ +package cn.odboy.system.dal.dataobject; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Getter; +import lombok.Setter; + +/** + * 角色菜单 + */ +@Getter +@Setter +@TableName("system_users_jobs") +public class SystemUserJobTb { + @TableField(value = "user_id") private Long userId; + @TableField(value = "job_id") private Long jobId; +} diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserRoleTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserRoleTb.java new file mode 100644 index 00000000..c3be28bd --- /dev/null +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserRoleTb.java @@ -0,0 +1,30 @@ +/* + * Copyright 2021-2025 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.system.dal.dataobject; + +import cn.odboy.base.KitObject; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@TableName("system_users_roles") +public class SystemUserRoleTb extends KitObject { + @TableField(value = "user_id") private Long userId; + @TableField(value = "role_id") private Long roleId; +} \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserTb.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserTb.java index ec2c06c2..cd9cc1e3 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserTb.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/dataobject/SystemUserTb.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.dataobject; import cn.odboy.base.KitBaseUserTimeTb; @@ -22,80 +21,36 @@ 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 javax.validation.constraints.Email; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.util.Date; import java.util.Objects; import java.util.Set; +import javax.validation.constraints.Email; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.Setter; @Getter @Setter @TableName("system_user") public class SystemUserTb extends KitBaseUserTimeTb { - - @NotNull(groups = Update.class) - @TableId(value = "user_id", type = IdType.AUTO) - @ApiModelProperty(value = "ID", hidden = true) - private Long id; - - @TableField(exist = false) - @ApiModelProperty(value = "用户角色") - private Set roles; - - @TableField(exist = false) - @ApiModelProperty(value = "用户岗位") - private Set jobs; - - @TableField(value = "dept_id") - @ApiModelProperty(hidden = true) - private Long deptId; - - @ApiModelProperty(value = "用户部门") - @TableField(exist = false) - private SystemDeptTb dept; - - @NotBlank - @ApiModelProperty(value = "用户名称") - private String username; - - @NotBlank - @ApiModelProperty(value = "用户昵称") - private String nickName; - - @Email - @NotBlank - @ApiModelProperty(value = "邮箱") - private String email; - - @NotBlank - @ApiModelProperty(value = "电话号码") - private String phone; - - @ApiModelProperty(value = "用户性别") - private String gender; - - @ApiModelProperty(value = "头像真实名称", hidden = true) - private String avatarName; - - @ApiModelProperty(value = "头像存储的路径", hidden = true) - private String avatarPath; - - @ApiModelProperty(value = "密码") - private String password; - - @NotNull - @ApiModelProperty(value = "是否启用") - private Boolean enabled; - - @ApiModelProperty(value = "是否为admin账号", hidden = true) - private Boolean isAdmin = false; - - @ApiModelProperty(value = "最后修改密码的时间", hidden = true) - private Date pwdResetTime; + @NotNull(groups = Update.class) @TableId(value = "user_id", type = IdType.AUTO) + @ApiModelProperty(value = "ID", hidden = true) private Long id; + @TableField(exist = false) @ApiModelProperty(value = "用户角色") private Set roles; + @TableField(exist = false) @ApiModelProperty(value = "用户岗位") private Set jobs; + @TableField(value = "dept_id") @ApiModelProperty(hidden = true) private Long deptId; + @ApiModelProperty(value = "用户部门") @TableField(exist = false) private SystemDeptTb dept; + @NotBlank @ApiModelProperty(value = "用户名称") private String username; + @NotBlank @ApiModelProperty(value = "用户昵称") private String nickName; + @Email @NotBlank @ApiModelProperty(value = "邮箱") private String email; + @NotBlank @ApiModelProperty(value = "电话号码") private String phone; + @ApiModelProperty(value = "用户性别") private String gender; + @ApiModelProperty(value = "头像真实名称", hidden = true) private String avatarName; + @ApiModelProperty(value = "头像存储的路径", hidden = true) private String avatarPath; + @ApiModelProperty(value = "密码") private String password; + @NotNull @ApiModelProperty(value = "是否启用") private Boolean enabled; + @ApiModelProperty(value = "是否为admin账号", hidden = true) private Boolean isAdmin = false; + @ApiModelProperty(value = "最后修改密码的时间", hidden = true) private Date pwdResetTime; @Override public boolean equals(Object o) { diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCheckEmailCaptchaArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCheckEmailCaptchaArgs.java index 090f77bb..d333a318 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCheckEmailCaptchaArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCheckEmailCaptchaArgs.java @@ -13,22 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.base.KitObject; +import javax.validation.constraints.NotBlank; import lombok.Getter; import lombok.Setter; -import javax.validation.constraints.NotBlank; - @Getter @Setter public class SystemCheckEmailCaptchaArgs extends KitObject { - @NotBlank(message = "邮箱不能为空") - private String email; - @NotBlank(message = "验证码不能为空") - private String code; - @NotBlank(message = "验证码业务标识不能为空") - private String bizCode; + @NotBlank(message = "邮箱不能为空") private String email; + @NotBlank(message = "验证码不能为空") private String code; + @NotBlank(message = "验证码业务标识不能为空") private String bizCode; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateDeptArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateDeptArgs.java index a7660f48..d4500279 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateDeptArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateDeptArgs.java @@ -13,23 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.base.KitObject; -import lombok.Data; -import lombok.EqualsAndHashCode; - import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class SystemCreateDeptArgs extends KitObject { - @NotBlank(message = "部门名称必填") - private String name; - @NotNull(message = "部门排序必填") - private Integer deptSort; + @NotBlank(message = "部门名称必填") private String name; + @NotNull(message = "部门排序必填") private Integer deptSort; private Boolean enabled; private String isTop; private Long pid; diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateDictArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateDictArgs.java index 30c72787..2eb998cf 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateDictArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateDictArgs.java @@ -13,19 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.base.KitObject; +import javax.validation.constraints.NotBlank; import lombok.Data; import lombok.EqualsAndHashCode; -import javax.validation.constraints.NotBlank; - @Data @EqualsAndHashCode(callSuper = false) public class SystemCreateDictArgs extends KitObject { - @NotBlank(message = "字典名称必填") - private String name; + @NotBlank(message = "字典名称必填") private String name; private String description; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateDictDetailArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateDictDetailArgs.java index 722b6ae2..aa71324b 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateDictDetailArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateDictDetailArgs.java @@ -13,26 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.base.KitObject; import cn.odboy.system.dal.dataobject.SystemDictTb; -import lombok.Data; -import lombok.EqualsAndHashCode; - import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class SystemCreateDictDetailArgs extends KitObject { - @NotNull(message = "参数dict必填") - private SystemDictTb dict; - @NotBlank(message = "字典标签必填") - private String label; - @NotBlank(message = "字典值必填") - private String value; - @NotNull(message = "字典排序必填") - private Integer dictSort; + @NotNull(message = "参数dict必填") private SystemDictTb dict; + @NotBlank(message = "字典标签必填") private String label; + @NotBlank(message = "字典值必填") private String value; + @NotNull(message = "字典排序必填") private Integer dictSort; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateJobArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateJobArgs.java index b5c5ea6a..cda4a7e5 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateJobArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateJobArgs.java @@ -13,22 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.base.KitObject; -import lombok.Data; -import lombok.EqualsAndHashCode; - import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class SystemCreateJobArgs extends KitObject { - @NotBlank(message = "职位名称必填") - private String name; - @NotNull(message = "职位排序必填") - private Integer jobSort; + @NotBlank(message = "职位名称必填") private String name; + @NotNull(message = "职位排序必填") private Integer jobSort; private Boolean enabled; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateRoleArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateRoleArgs.java index 8f36b28a..6f011475 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateRoleArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemCreateRoleArgs.java @@ -13,27 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.base.KitObject; import cn.odboy.system.dal.dataobject.SystemDeptTb; -import lombok.Data; -import lombok.EqualsAndHashCode; - +import java.util.Set; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; -import java.util.Set; +import lombok.Data; +import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class SystemCreateRoleArgs extends KitObject { - @NotBlank(message = "角色名称必填") - private String name; - @NotNull(message = "角色级别必填") - private Integer level; - @NotBlank(message = "数据范围必填") - private String dataScope; + @NotBlank(message = "角色名称必填") private String name; + @NotNull(message = "角色级别必填") private Integer level; + @NotBlank(message = "数据范围必填") private String dataScope; private String description; /** * 关联的部门 diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemMenuMetaVo.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemMenuMetaVo.java index 0a50b03b..14e5cf3b 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemMenuMetaVo.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemMenuMetaVo.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.base.KitObject; @@ -26,13 +25,7 @@ import lombok.EqualsAndHashCode; @AllArgsConstructor @EqualsAndHashCode(callSuper = false) public class SystemMenuMetaVo extends KitObject { - - @ApiModelProperty(value = "菜单标题") - private String title; - - @ApiModelProperty(value = "菜单图标") - private String icon; - - @ApiModelProperty(value = "缓存") - private Boolean noCache; + @ApiModelProperty(value = "菜单标题") private String title; + @ApiModelProperty(value = "菜单图标") private String icon; + @ApiModelProperty(value = "缓存") private Boolean noCache; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemMenuVo.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemMenuVo.java index e12020e9..bb6540d1 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemMenuVo.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemMenuVo.java @@ -13,44 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.base.KitObject; import io.swagger.annotations.ApiModelProperty; +import java.util.List; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.List; - /** * 构建前端路由时用到 */ @Data @EqualsAndHashCode(callSuper = false) public class SystemMenuVo extends KitObject { - - @ApiModelProperty(value = "菜单名称") - private String name; - - @ApiModelProperty(value = "路径") - private String path; - - @ApiModelProperty(value = "隐藏状态") - private Boolean hidden; - - @ApiModelProperty(value = "重定向") - private String redirect; - - @ApiModelProperty(value = "组件") - private String component; - - @ApiModelProperty(value = "总是显示") - private Boolean alwaysShow; - - @ApiModelProperty(value = "元数据") - private SystemMenuMetaVo meta; - - @ApiModelProperty(value = "子路由") - private List children; + @ApiModelProperty(value = "菜单名称") private String name; + @ApiModelProperty(value = "路径") private String path; + @ApiModelProperty(value = "隐藏状态") private Boolean hidden; + @ApiModelProperty(value = "重定向") private String redirect; + @ApiModelProperty(value = "组件") private String component; + @ApiModelProperty(value = "总是显示") private Boolean alwaysShow; + @ApiModelProperty(value = "元数据") private SystemMenuMetaVo meta; + @ApiModelProperty(value = "子路由") private List children; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemOssStorageVo.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemOssStorageVo.java index bd9a1977..3e2690bd 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemOssStorageVo.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemOssStorageVo.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.system.dal.dataobject.SystemOssStorageTb; diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemProductLineTreeVo.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemProductLineTreeVo.java index a623253f..00361c04 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemProductLineTreeVo.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemProductLineTreeVo.java @@ -13,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.base.KitObject; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; - @Getter @Setter public class SystemProductLineTreeVo extends KitObject { diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemProductLineVo.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemProductLineVo.java index 24934e75..e0722418 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemProductLineVo.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemProductLineVo.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.base.KitObject; diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryDeptArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryDeptArgs.java index b35df09d..3ce12173 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryDeptArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryDeptArgs.java @@ -13,33 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; import java.util.List; +import lombok.Data; @Data public class SystemQueryDeptArgs { - - @ApiModelProperty(value = "部门id集合") - private List ids; - - @ApiModelProperty(value = "部门名称") - private String name; - - @ApiModelProperty(value = "是否启用") - private Boolean enabled; - - @ApiModelProperty(value = "上级部门") - private Long pid; - - @ApiModelProperty(value = "PID为空查询") - private Boolean pidIsNull; - - @ApiModelProperty(value = "创建时间") - private List createTime; + @ApiModelProperty(value = "部门id集合") private List ids; + @ApiModelProperty(value = "部门名称") private String name; + @ApiModelProperty(value = "是否启用") private Boolean enabled; + @ApiModelProperty(value = "上级部门") private Long pid; + @ApiModelProperty(value = "PID为空查询") private Boolean pidIsNull; + @ApiModelProperty(value = "创建时间") private List createTime; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryDictArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryDictArgs.java index 344ed67d..96bb0fd1 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryDictArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryDictArgs.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import io.swagger.annotations.ApiModelProperty; @@ -21,13 +20,7 @@ import lombok.Data; @Data public class SystemQueryDictArgs { - - @ApiModelProperty(value = "模糊查询") - private String blurry; - - @ApiModelProperty(value = "页码", example = "1") - private Integer page = 1; - - @ApiModelProperty(value = "每页数据量", example = "10") - private Integer size = 10; + @ApiModelProperty(value = "模糊查询") private String blurry; + @ApiModelProperty(value = "页码", example = "1") private Integer page = 1; + @ApiModelProperty(value = "每页数据量", example = "10") private Integer size = 10; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryDictDetailArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryDictDetailArgs.java index 48391961..3088ba6f 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryDictDetailArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryDictDetailArgs.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.base.KitObject; @@ -24,9 +23,6 @@ import lombok.Setter; @Getter @Setter public class SystemQueryDictDetailArgs extends KitObject { - @ApiModelProperty(value = "标签") - private String label; - - @ApiModelProperty(value = "字典名称") - private String dictName; + @ApiModelProperty(value = "标签") private String label; + @ApiModelProperty(value = "字典名称") private String dictName; } \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryJobArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryJobArgs.java index 874a788a..fb87c125 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryJobArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryJobArgs.java @@ -13,32 +13,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; 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 public class SystemQueryJobArgs { - - @ApiModelProperty(value = "岗位名称") - private String name; - - @ApiModelProperty(value = "是否启用") - private Boolean enabled; - - @ApiModelProperty(value = "创建时间") - private List createTime; - - @ApiModelProperty(value = "页码", example = "1") - private Integer page = 1; - - @ApiModelProperty(value = "每页数据量", example = "10") - private Integer size = 10; + @ApiModelProperty(value = "岗位名称") private String name; + @ApiModelProperty(value = "是否启用") private Boolean enabled; + @ApiModelProperty(value = "创建时间") private List createTime; + @ApiModelProperty(value = "页码", example = "1") private Integer page = 1; + @ApiModelProperty(value = "每页数据量", example = "10") private Integer size = 10; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryMenuArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryMenuArgs.java index 67f41b87..5bf1cd8d 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryMenuArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryMenuArgs.java @@ -13,27 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; import java.util.List; +import lombok.Data; @Data public class SystemQueryMenuArgs { - - @ApiModelProperty(value = "模糊查询") - private String blurry; - - @ApiModelProperty(value = "创建时间") - private List createTime; - - @ApiModelProperty(value = "PID为空查询") - private Boolean pidIsNull; - - @ApiModelProperty(value = "PID") - private Long pid; + @ApiModelProperty(value = "模糊查询") private String blurry; + @ApiModelProperty(value = "创建时间") private List createTime; + @ApiModelProperty(value = "PID为空查询") private Boolean pidIsNull; + @ApiModelProperty(value = "PID") private Long pid; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryQuartzJobArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryQuartzJobArgs.java index c6f541e7..cd0b765e 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryQuartzJobArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryQuartzJobArgs.java @@ -13,30 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; import java.util.List; +import lombok.Data; @Data public class SystemQueryQuartzJobArgs { - - @ApiModelProperty(value = "定时任务名称") - private String jobName; - - @ApiModelProperty(value = "是否成功") - private Boolean isSuccess; - - @ApiModelProperty(value = "创建时间") - private List createTime; - - @ApiModelProperty(value = "页码", example = "1") - private Integer page = 1; - - @ApiModelProperty(value = "每页数据量", example = "10") - private Integer size = 10; + @ApiModelProperty(value = "定时任务名称") private String jobName; + @ApiModelProperty(value = "是否成功") private Boolean isSuccess; + @ApiModelProperty(value = "创建时间") private List createTime; + @ApiModelProperty(value = "页码", example = "1") private Integer page = 1; + @ApiModelProperty(value = "每页数据量", example = "10") private Integer size = 10; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryRoleArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryRoleArgs.java index 382d9878..cc6f1759 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryRoleArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryRoleArgs.java @@ -13,30 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; import java.util.List; +import lombok.Data; @Data public class SystemQueryRoleArgs { - - @ApiModelProperty(value = "模糊查询") - private String blurry; - - @ApiModelProperty(value = "创建时间") - private List createTime; - - @ApiModelProperty(value = "页码", example = "1") - private Integer page = 1; - - @ApiModelProperty(value = "每页数据量", example = "10") - private Integer size = 10; - - @ApiModelProperty(value = "偏移量", hidden = true) - private long offset; + @ApiModelProperty(value = "模糊查询") private String blurry; + @ApiModelProperty(value = "创建时间") private List createTime; + @ApiModelProperty(value = "页码", example = "1") private Integer page = 1; + @ApiModelProperty(value = "每页数据量", example = "10") private Integer size = 10; + @ApiModelProperty(value = "偏移量", hidden = true) private long offset; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryStorageArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryStorageArgs.java index 30dc3b4c..5e85e06b 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryStorageArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryStorageArgs.java @@ -13,27 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; import java.util.List; +import lombok.Data; @Data public class SystemQueryStorageArgs { - - @ApiModelProperty(value = "模糊查询") - private String blurry; - - @ApiModelProperty(value = "创建时间") - private List createTime; - - @ApiModelProperty(value = "页码", example = "1") - private Integer page = 1; - - @ApiModelProperty(value = "每页数据量", example = "10") - private Integer size = 10; + @ApiModelProperty(value = "模糊查询") private String blurry; + @ApiModelProperty(value = "创建时间") private List createTime; + @ApiModelProperty(value = "页码", example = "1") private Integer page = 1; + @ApiModelProperty(value = "每页数据量", example = "10") private Integer size = 10; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryUserArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryUserArgs.java index 171a1ccb..24e123b4 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryUserArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemQueryUserArgs.java @@ -13,44 +13,26 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; 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) public class SystemQueryUserArgs extends KitObject { - - @ApiModelProperty(value = "ID") - private Long id; - - @ApiModelProperty(value = "多个ID") - private Set deptIds = new HashSet<>(); - - @ApiModelProperty(value = "模糊查询") - private String blurry; - - @ApiModelProperty(value = "是否启用") - private Boolean enabled; - - @ApiModelProperty(value = "部门ID") - private Long deptId; - - @ApiModelProperty(value = "创建时间") - private List createTime; - - @ApiModelProperty(value = "页码", example = "1") - private Integer page = 1; - - @ApiModelProperty(value = "每页数据量", example = "10") - private Integer size = 10; + @ApiModelProperty(value = "ID") private Long id; + @ApiModelProperty(value = "多个ID") private Set deptIds = new HashSet<>(); + @ApiModelProperty(value = "模糊查询") private String blurry; + @ApiModelProperty(value = "是否启用") private Boolean enabled; + @ApiModelProperty(value = "部门ID") private Long deptId; + @ApiModelProperty(value = "创建时间") private List createTime; + @ApiModelProperty(value = "页码", example = "1") private Integer page = 1; + @ApiModelProperty(value = "每页数据量", example = "10") private Integer size = 10; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemRoleCodeVo.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemRoleCodeVo.java index 36928680..6537e1c9 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemRoleCodeVo.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemRoleCodeVo.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import io.swagger.annotations.ApiModelProperty; @@ -29,7 +28,5 @@ import org.springframework.security.core.GrantedAuthority; @NoArgsConstructor @AllArgsConstructor public class SystemRoleCodeVo implements GrantedAuthority { - - @ApiModelProperty(value = "角色名") - private String authority; + @ApiModelProperty(value = "角色名") private String authority; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemSendEmailArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemSendEmailArgs.java index 34ff5b6e..699b3cf1 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemSendEmailArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemSendEmailArgs.java @@ -13,18 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import io.swagger.annotations.ApiModelProperty; +import java.util.List; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotEmpty; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotEmpty; -import java.util.List; - /** * 发送邮件时,接收参数的类 */ @@ -32,16 +30,7 @@ import java.util.List; @AllArgsConstructor @NoArgsConstructor public class SystemSendEmailArgs { - - @NotEmpty - @ApiModelProperty(value = "收件人") - private List tos; - - @NotBlank - @ApiModelProperty(value = "主题") - private String subject; - - @NotBlank - @ApiModelProperty(value = "内容") - private String content; + @NotEmpty @ApiModelProperty(value = "收件人") private List tos; + @NotBlank @ApiModelProperty(value = "主题") private String subject; + @NotBlank @ApiModelProperty(value = "内容") private String content; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemSimpleUserVo.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemSimpleUserVo.java index de6868a4..f01c836d 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemSimpleUserVo.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemSimpleUserVo.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.base.KitObject; @@ -22,37 +21,24 @@ import cn.odboy.system.dal.dataobject.SystemJobTb; import cn.odboy.system.dal.dataobject.SystemRoleTb; import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModelProperty; +import java.util.Set; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Set; - @Data @EqualsAndHashCode(callSuper = false) public class SystemSimpleUserVo extends KitObject { - @ApiModelProperty(value = "ID", hidden = true) - private Long id; - @ApiModelProperty(value = "用户角色") - private Set roles; - @ApiModelProperty(value = "用户岗位") - private Set jobs; + @ApiModelProperty(value = "ID", hidden = true) private Long id; + @ApiModelProperty(value = "用户角色") private Set roles; + @ApiModelProperty(value = "用户岗位") private Set jobs; private Long deptId; - @TableField(exist = false) - private SystemDeptTb dept; - @ApiModelProperty(value = "用户名称") - private String username; - @ApiModelProperty(value = "用户昵称") - private String nickName; - @ApiModelProperty(value = "邮箱") - private String email; - @ApiModelProperty(value = "电话号码") - private String phone; - @ApiModelProperty(value = "用户性别") - private String gender; - @ApiModelProperty(value = "头像真实名称", hidden = true) - private String avatarName; - @ApiModelProperty(value = "是否启用") - private Boolean enabled; - @ApiModelProperty(value = "是否为admin账号", hidden = true) - private Boolean isAdmin = false; + @TableField(exist = false) private SystemDeptTb dept; + @ApiModelProperty(value = "用户名称") private String username; + @ApiModelProperty(value = "用户昵称") private String nickName; + @ApiModelProperty(value = "邮箱") private String email; + @ApiModelProperty(value = "电话号码") private String phone; + @ApiModelProperty(value = "用户性别") private String gender; + @ApiModelProperty(value = "头像真实名称", hidden = true) private String avatarName; + @ApiModelProperty(value = "是否启用") private Boolean enabled; + @ApiModelProperty(value = "是否为admin账号", hidden = true) private Boolean isAdmin = false; } \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUpdateQuartzJobArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUpdateQuartzJobArgs.java index 18b75f94..f34821f4 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUpdateQuartzJobArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUpdateQuartzJobArgs.java @@ -13,35 +13,28 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.base.KitObject; -import lombok.Data; -import lombok.EqualsAndHashCode; - import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; @Data @EqualsAndHashCode(callSuper = false) public class SystemUpdateQuartzJobArgs extends KitObject { - @NotNull - private Long id; + @NotNull private Long id; private String uuid; private String jobName; - @NotBlank - private String beanName; - @NotBlank - private String methodName; + @NotBlank private String beanName; + @NotBlank private String methodName; private String params; - @NotBlank - private String cronExpression; + @NotBlank private String cronExpression; private Boolean isPause = false; private String personInCharge; private String email; private String subTask; private Boolean pauseAfterFailure; - @NotBlank - private String description; + @NotBlank private String description; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUpdateUserPasswordArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUpdateUserPasswordArgs.java index 646bd86e..d75d0607 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUpdateUserPasswordArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUpdateUserPasswordArgs.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import io.swagger.annotations.ApiModelProperty; @@ -24,10 +23,6 @@ import lombok.Data; */ @Data public class SystemUpdateUserPasswordArgs { - - @ApiModelProperty(value = "旧密码") - private String oldPass; - - @ApiModelProperty(value = "新密码") - private String newPass; + @ApiModelProperty(value = "旧密码") private String oldPass; + @ApiModelProperty(value = "新密码") private String newPass; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserInfoVo.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserInfoVo.java index fd80c326..50f56c55 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserInfoVo.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserInfoVo.java @@ -13,16 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; 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/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserJwtVo.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserJwtVo.java index 5975b1f5..09bec853 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserJwtVo.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserJwtVo.java @@ -13,32 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import cn.odboy.system.dal.dataobject.SystemUserTb; import com.alibaba.fastjson2.annotation.JSONField; import io.swagger.annotations.ApiModelProperty; +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; -import java.util.List; -import java.util.Set; -import java.util.stream.Collectors; - @Getter @AllArgsConstructor public class SystemUserJwtVo implements UserDetails { - - @ApiModelProperty(value = "用户") - private final SystemUserTb user; - - @ApiModelProperty(value = "数据权限") - private final List dataScopes; - - @ApiModelProperty(value = "角色") - private final List authorities; + @ApiModelProperty(value = "用户") private final SystemUserTb user; + @ApiModelProperty(value = "数据权限") private final List dataScopes; + @ApiModelProperty(value = "角色") private final List authorities; public Set getRoles() { return authorities.stream().map(SystemRoleCodeVo::getAuthority).collect(Collectors.toSet()); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserLoginArgs.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserLoginArgs.java index f0aee13e..475efdef 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserLoginArgs.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserLoginArgs.java @@ -13,30 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.NotBlank; import lombok.Getter; import lombok.Setter; -import javax.validation.constraints.NotBlank; - @Getter @Setter public class SystemUserLoginArgs { - - @NotBlank - @ApiModelProperty(value = "用户名") - private String username; - - @NotBlank - @ApiModelProperty(value = "密码") - private String password; - - @ApiModelProperty(value = "验证码") - private String code; - - @ApiModelProperty(value = "验证码的key") - private String uuid = ""; + @NotBlank @ApiModelProperty(value = "用户名") private String username; + @NotBlank @ApiModelProperty(value = "密码") private String password; + @ApiModelProperty(value = "验证码") private String code; + @ApiModelProperty(value = "验证码的key") private String uuid = ""; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserOnlineVo.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserOnlineVo.java index 5d410a9c..9f13e780 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserOnlineVo.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/model/SystemUserOnlineVo.java @@ -13,43 +13,24 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.model; import io.swagger.annotations.ApiModelProperty; -import lombok.Data; - import java.util.Date; +import lombok.Data; /** * 在线用户 */ @Data public class SystemUserOnlineVo { - @ApiModelProperty(value = "Token编号") - private String uid; - - @ApiModelProperty(value = "用户名") - private String userName; - - @ApiModelProperty(value = "昵称") - private String nickName; - - @ApiModelProperty(value = "岗位") - private String dept; - - @ApiModelProperty(value = "浏览器") - private String browser; - - @ApiModelProperty(value = "IP") - private String ip; - - @ApiModelProperty(value = "地址") - private String address; - - @ApiModelProperty(value = "token") - private String key; - - @ApiModelProperty(value = "登录时间") - private Date loginTime; + @ApiModelProperty(value = "Token编号") private String uid; + @ApiModelProperty(value = "用户名") private String userName; + @ApiModelProperty(value = "昵称") private String nickName; + @ApiModelProperty(value = "岗位") private String dept; + @ApiModelProperty(value = "浏览器") private String browser; + @ApiModelProperty(value = "IP") private String ip; + @ApiModelProperty(value = "地址") private String address; + @ApiModelProperty(value = "token") private String key; + @ApiModelProperty(value = "登录时间") private Date loginTime; } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDeptMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDeptMapper.java index 418e4573..0d902ae4 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDeptMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDeptMapper.java @@ -13,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; import cn.odboy.system.dal.dataobject.SystemDeptTb; import cn.odboy.system.dal.model.SystemQueryDeptArgs; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - import java.util.List; +import org.apache.ibatis.annotations.Mapper; /** * 部门 Mapper @@ -31,15 +31,40 @@ import java.util.List; */ @Mapper public interface SystemDeptMapper extends BaseMapper { - List selectDeptByArgs(@Param("criteria") SystemQueryDeptArgs criteria); - - List selectDeptByPid(@Param("pid") Long pid); - - int countDeptByPid(@Param("pid") Long pid); - - List selectDeptByPidIsNull(); - - List selectDeptByRoleId(@Param("roleId") Long roleId); - - void updateDeptSubCountById(@Param("count") Integer count, @Param("id") Long id); + default List selectDeptByPidIsNull() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.isNull(SystemDeptTb::getPid); + return selectList(wrapper); + } + default long countDeptByPid(Long pid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemDeptTb::getPid, pid); + return selectCount(wrapper); + } + default List queryDeptByArgs(SystemQueryDeptArgs criteria) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (criteria != null) { + wrapper.in(CollUtil.isNotEmpty(criteria.getIds()), SystemDeptTb::getId, criteria.getIds()); + wrapper.like(StrUtil.isNotBlank(criteria.getName()), SystemDeptTb::getName, criteria.getName()); + wrapper.eq(criteria.getEnabled() != null, SystemDeptTb::getEnabled, criteria.getEnabled()); + wrapper.eq(criteria.getPid() != null, SystemDeptTb::getPid, criteria.getPid()); + wrapper.isNull(criteria.getPidIsNull() != null, SystemDeptTb::getPid); + if (CollUtil.isNotEmpty(criteria.getCreateTime()) && criteria.getCreateTime().size() >= 2) { + wrapper.between(SystemDeptTb::getCreateTime, criteria.getCreateTime().get(0), + criteria.getCreateTime().get(1)); + } + } + wrapper.orderByAsc(SystemDeptTb::getDeptSort); + return selectList(wrapper); + } + default List selectEnabledDepts() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemDeptTb::getEnabled, 1); + return selectList(wrapper); + } + default List selectDeptByPid(long pid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemDeptTb::getPid, pid); + return selectList(wrapper); + } } 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 c3b2ec8e..fb5835ed 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemDictDetailTb; @@ -21,12 +20,10 @@ import cn.odboy.system.dal.model.SystemQueryDictDetailArgs; 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; -import java.util.Set; - /** * 字典明细 Mapper * @@ -34,9 +31,6 @@ import java.util.Set; */ @Mapper public interface SystemDictDetailMapper extends BaseMapper { - IPage selectDictDetailByArgs(@Param("criteria") SystemQueryDictDetailArgs criteria, Page page); - + IPage selectDictDetailByArgs(@Param("criteria") SystemQueryDictDetailArgs criteria, Page page); List selectDictDetailByArgs(@Param("criteria") SystemQueryDictDetailArgs criteria); - - void deleteDictDetailByDictIds(@Param("dictIds") Set dictIds); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDictMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDictMapper.java index 66b909f8..a2905dd8 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDictMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemDictMapper.java @@ -13,18 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; +import cn.hutool.core.util.StrUtil; import cn.odboy.system.dal.dataobject.SystemDictTb; import cn.odboy.system.dal.model.SystemQueryDictArgs; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - import java.util.List; +import org.apache.ibatis.annotations.Mapper; /** * 字典 Mapper @@ -33,7 +31,20 @@ import java.util.List; */ @Mapper public interface SystemDictMapper extends BaseMapper { - IPage selectDictByArgs(@Param("criteria") SystemQueryDictArgs criteria, Page page); - - List selectDictByArgs(@Param("criteria") SystemQueryDictArgs criteria); + default 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())); + } + } + default List selectDictByArgs(SystemQueryDictArgs args) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + injectQueryParams(args, wrapper); + return selectList(wrapper); + } + default List selectDictByArgs(SystemQueryDictArgs args, Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + injectQueryParams(args, wrapper); + return selectList(page, wrapper); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemEmailConfigMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemEmailConfigMapper.java index 14098fb0..f450846a 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemEmailConfigMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemEmailConfigMapper.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemEmailConfigTb; @@ -26,5 +25,4 @@ import org.apache.ibatis.annotations.Mapper; * @author odboy */ @Mapper -public interface SystemEmailConfigMapper extends BaseMapper { -} +public interface SystemEmailConfigMapper extends BaseMapper {} diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemJobMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemJobMapper.java index e0da6c78..b0d68dab 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemJobMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemJobMapper.java @@ -13,16 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; import cn.odboy.system.dal.dataobject.SystemJobTb; import cn.odboy.system.dal.model.SystemQueryJobArgs; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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; /** * 职位 Mapper @@ -31,7 +33,32 @@ import org.apache.ibatis.annotations.Param; */ @Mapper public interface SystemJobMapper extends BaseMapper { - SystemJobTb getJobByName(@Param("name") String name); + default SystemJobTb getJobByName(String name) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemJobTb::getName, name); + return selectOne(wrapper); + } + default void injectQueryParams(SystemQueryJobArgs criteria, LambdaQueryWrapper wrapper) { + if (criteria != null) { + wrapper.like(StrUtil.isNotBlank(criteria.getName()), SystemJobTb::getName, criteria.getName()); + wrapper.eq(criteria.getEnabled() != null, SystemJobTb::getEnabled, criteria.getEnabled()); + if (CollUtil.isNotEmpty(criteria.getCreateTime()) && criteria.getCreateTime().size() >= 2) { + wrapper.between(SystemJobTb::getCreateTime, criteria.getCreateTime().get(0), + criteria.getCreateTime().get(1)); + } + } + wrapper.orderByDesc(SystemJobTb::getJobSort, SystemJobTb::getId); + } - IPage selectJobByArgs(@Param("criteria") SystemQueryJobArgs criteria, Page page); + default IPage selectJobByArgs(SystemQueryJobArgs criteria, Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(criteria, wrapper); + return selectPage(page, wrapper); + } + + default List selectJobByArgs(SystemQueryJobArgs criteria) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQueryParams(criteria, wrapper); + return selectList(wrapper); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemLocalStorageMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemLocalStorageMapper.java index d6aeab32..caae3c85 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemLocalStorageMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemLocalStorageMapper.java @@ -13,16 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; import cn.odboy.system.dal.dataobject.SystemLocalStorageTb; import cn.odboy.system.dal.model.SystemQueryStorageArgs; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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; /** * 本地存储记录 Mapper @@ -31,5 +33,31 @@ import org.apache.ibatis.annotations.Param; */ @Mapper public interface SystemLocalStorageMapper extends BaseMapper { - IPage selectLocalStorageByArgs(@Param("criteria") SystemQueryStorageArgs criteria, Page page); + default void injectQueryParams(SystemQueryStorageArgs criteria, LambdaQueryWrapper wrapper) { + if (criteria != null) { + wrapper.and(StrUtil.isNotBlank(criteria.getBlurry()), + c -> c.like(SystemLocalStorageTb::getName, criteria.getBlurry()).or() + .like(SystemLocalStorageTb::getSuffix, criteria.getBlurry()).or() + .like(SystemLocalStorageTb::getType, criteria.getBlurry()).or() + .like(SystemLocalStorageTb::getCreateBy, criteria.getBlurry())); + if (CollUtil.isNotEmpty(criteria.getCreateTime()) && criteria.getCreateTime().size() >= 2) { + wrapper.between(SystemLocalStorageTb::getUpdateTime, criteria.getCreateTime().get(0), + criteria.getCreateTime().get(1)); + } + } + wrapper.orderByDesc(SystemLocalStorageTb::getId); + } + + default List selectLocalStorageByArgs(SystemQueryStorageArgs criteria) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + injectQueryParams(criteria, wrapper); + return selectList(wrapper); + } + + default IPage selectLocalStorageByArgs(SystemQueryStorageArgs criteria, + Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + injectQueryParams(criteria, wrapper); + return selectPage(page, wrapper); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemMenuMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemMenuMapper.java index 6cae722e..6c165781 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemMenuMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemMenuMapper.java @@ -13,18 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; import cn.odboy.system.dal.dataobject.SystemMenuTb; import cn.odboy.system.dal.model.SystemQueryMenuArgs; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.LinkedHashSet; import java.util.List; -import java.util.Set; +import org.apache.ibatis.annotations.Mapper; /** * 菜单 Mapper @@ -33,20 +32,61 @@ import java.util.Set; */ @Mapper public interface SystemMenuMapper extends BaseMapper { + default void updateMenuSubCntByMenuId(Long count, Long menuId) { + if (count != null) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(SystemMenuTb::getId, menuId); + wrapper.set(SystemMenuTb::getSubCount, count); + update(wrapper); + } + } + default SystemMenuTb getMenuByComponentName(String componentName) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemMenuTb::getComponentName, componentName); + return selectOne(wrapper); + } - List selectMenuByArgs(@Param("criteria") SystemQueryMenuArgs criteria); + default SystemMenuTb getMenuByTitle(String title) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemMenuTb::getTitle, title); + return selectOne(wrapper); + } - LinkedHashSet selectMenuByRoleIdsAndType(@Param("roleIds") Set roleIds, @Param("type") Integer type); + default Long countMenuByPid(Long pid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemMenuTb::getPid, pid); + return selectCount(wrapper); + } - List selectMenuByPidIsNullOrderByMenuSort(); + default List selectMenuByArgs(SystemQueryMenuArgs criteria) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (criteria != null) { + wrapper.isNull(criteria.getPidIsNull() != null, SystemMenuTb::getPid); + wrapper.eq(criteria.getPid() != null, SystemMenuTb::getPid, criteria.getPid()); + wrapper.and(StrUtil.isNotBlank(criteria.getBlurry()), + c -> c.like(SystemMenuTb::getTitle, criteria.getBlurry()).or() + .like(SystemMenuTb::getComponentName, criteria.getBlurry()).or() + .like(SystemMenuTb::getPermission, criteria.getBlurry())); + if (CollUtil.isNotEmpty(criteria.getCreateTime()) && criteria.getCreateTime().size() >= 2) { + wrapper.between(SystemMenuTb::getCreateTime, criteria.getCreateTime().get(0), + criteria.getCreateTime().get(1)); + } + } + wrapper.orderByAsc(SystemMenuTb::getMenuSort); + return selectList(wrapper); + } - List selectMenuByPidOrderByMenuSort(@Param("pid") Long pid); + default List selectMenuByPid(Long pid) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemMenuTb::getPid, pid); + wrapper.orderByAsc(SystemMenuTb::getMenuSort); + return selectList(wrapper); + } - SystemMenuTb getMenuByTitle(@Param("title") String title); - - SystemMenuTb getMenuByComponentName(@Param("name") String name); - - Integer countMenuByPid(@Param("pid") Long pid); - - void updateMenuSubCntByMenuId(@Param("count") int count, @Param("menuId") Long menuId); + default List selectMenuByPidIsNull() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.isNull(SystemMenuTb::getPid); + wrapper.orderByAsc(SystemMenuTb::getMenuSort); + return selectList(wrapper); + } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemOperationLogMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemOperationLogMapper.java index 2e72adc0..cbf16823 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemOperationLogMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemOperationLogMapper.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemOperationLogTb; @@ -21,5 +20,4 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; @Mapper -public interface SystemOperationLogMapper extends BaseMapper { -} +public interface SystemOperationLogMapper extends BaseMapper {} diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemOssStorageMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemOssStorageMapper.java index d2237011..66d1a1dd 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemOssStorageMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemOssStorageMapper.java @@ -13,18 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemOssStorageTb; -import cn.odboy.system.dal.model.SystemQueryStorageArgs; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; -import java.util.List; - /** *

* OSS存储 Mapper 接口 @@ -34,8 +28,4 @@ import java.util.List; * @since 2025-07-15 */ @Mapper -public interface SystemOssStorageMapper extends BaseMapper { - IPage selectOssStorageByArgs(SystemQueryStorageArgs criteria, Page page); - - List selectOssStorageByArgs(SystemQueryStorageArgs criteria); -} +public interface SystemOssStorageMapper extends BaseMapper {} 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 511d8220..2be2e86e 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 @@ -13,18 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemQuartzJobTb; -import cn.odboy.system.dal.model.SystemQueryQuartzJobArgs; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; /** * 定时任务 Mapper @@ -32,8 +25,4 @@ import java.util.List; * @author odboy */ @Mapper -public interface SystemQuartzJobMapper extends BaseMapper { - IPage selectQuartzJobByArgs(@Param("criteria") SystemQueryQuartzJobArgs criteria, Page page); - - List selectAllEnableQuartzJob(); -} +public interface SystemQuartzJobMapper extends BaseMapper {} diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemQuartzLogMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemQuartzLogMapper.java index 10fb6ae2..688992e5 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemQuartzLogMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemQuartzLogMapper.java @@ -13,16 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemQuartzLogTb; -import cn.odboy.system.dal.model.SystemQueryQuartzJobArgs; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; /** * 定时任务日志 Mapper @@ -30,6 +25,4 @@ import org.apache.ibatis.annotations.Param; * @author odboy */ @Mapper -public interface SystemQuartzLogMapper extends BaseMapper { - IPage selectQuartzLogByArgs(@Param("criteria") SystemQueryQuartzJobArgs criteria, Page page); -} +public interface SystemQuartzLogMapper extends BaseMapper {} 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 d268b811..96cef174 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 @@ -13,14 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - 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 org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.Set; /** * 角色部门关联 Mapper @@ -28,8 +25,4 @@ import java.util.Set; * @author odboy */ @Mapper -public interface SystemRoleDeptMapper { - void batchInsertRoleDept(@Param("depts") Set depts, @Param("roleId") Long roleId); - - void batchDeleteRoleDept(@Param("roleIds") Set roleIds); -} +public interface SystemRoleDeptMapper extends BaseMapper {} 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 f67c9b41..54625188 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 @@ -13,17 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; import cn.odboy.system.dal.dataobject.SystemRoleTb; import cn.odboy.system.dal.model.SystemQueryRoleArgs; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - import java.util.List; import java.util.Set; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 角色 Mapper @@ -32,19 +33,22 @@ import java.util.Set; */ @Mapper public interface SystemRoleMapper extends BaseMapper { - List selectAllRole(); - + default Long countRoleByArgs(SystemQueryRoleArgs criteria) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (criteria != null) { + wrapper.and(StrUtil.isNotBlank(criteria.getBlurry()), + c -> c.like(SystemRoleTb::getName, criteria.getBlurry()).or() + .like(SystemRoleTb::getDescription, criteria.getBlurry())); + if (CollUtil.isNotEmpty(criteria.getCreateTime()) && criteria.getCreateTime().size() >= 2) { + wrapper.between(SystemRoleTb::getCreateTime, criteria.getCreateTime().get(0), + criteria.getCreateTime().get(1)); + } + } + return selectCount(wrapper); + } List selectRoleByArgs(@Param("criteria") SystemQueryRoleArgs criteria); - - Long countRoleByArgs(@Param("criteria") SystemQueryRoleArgs criteria); - - SystemRoleTb getRoleByName(@Param("name") String name); - - SystemRoleTb getRoleById(@Param("roleId") Long roleId); - List selectRoleByUserId(@Param("userId") Long userId); - - Integer countRoleByDeptIds(@Param("deptIds") Set deptIds); - List selectRoleByMenuId(@Param("menuId") Long menuId); + SystemRoleTb getRoleById(@Param("roleId") Long roleId); + Integer countRoleByDeptIds(@Param("deptIds") Set deptIds); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleMenuMapper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleMenuMapper.java index 9c25acae..8acc1e5e 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleMenuMapper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/mysql/SystemRoleMenuMapper.java @@ -13,16 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; -import cn.odboy.system.dal.dataobject.SystemMenuTb; import cn.odboy.system.dal.dataobject.SystemRoleMenuTb; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.Set; /** * 角色菜单关联 Mapper @@ -30,10 +25,4 @@ import java.util.Set; * @author odboy */ @Mapper -public interface SystemRoleMenuMapper extends BaseMapper { - void batchInsertRoleMenu(@Param("menus") Set menus, @Param("roleId") Long roleId); - - void batchDeleteRoleMenu(@Param("roleIds") Set roleIds); - - void deleteRoleMenuByRoleId(@Param("roleId") Long roleId); -} +public interface SystemRoleMenuMapper extends BaseMapper {} 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 80403da5..a73f8ee0 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 @@ -13,14 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - 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 org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.Set; /** * 用户职位关联 Mapper @@ -28,8 +25,4 @@ import java.util.Set; * @author odboy */ @Mapper -public interface SystemUserJobMapper { - void batchInsertUserJob(@Param("jobs") Set jobs, @Param("userId") Long userId); - - void batchDeleteUserJob(@Param("userIds") Set userIds); -} +public interface SystemUserJobMapper extends BaseMapper {} 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 012b9bfe..328f9f37 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 @@ -13,47 +13,63 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.mysql; import cn.odboy.system.dal.dataobject.SystemUserTb; import cn.odboy.system.dal.model.SystemQueryUserArgs; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - import java.util.List; import java.util.Set; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; @Mapper public interface SystemUserMapper extends BaseMapper { List selectUserByArgs(@Param("criteria") SystemQueryUserArgs criteria); - IPage selectUserByArgs(@Param("criteria") SystemQueryUserArgs criteria, Page page); - - SystemUserTb getUserByUsername(@Param("username") String username); - - SystemUserTb getUserByEmail(@Param("email") String email); - - SystemUserTb getUserByPhone(@Param("phone") String phone); - List selectUserByRoleId(@Param("roleId") Long roleId); - List selectUserByDeptId(@Param("deptId") Long deptId); - List selectUserByMenuId(@Param("menuId") Long menuId); - Long countUserByJobIds(@Param("jobIds") Set jobIds); - - Long countUserByDeptIds(@Param("deptIds") Set deptIds); - Long countUserByRoleIds(@Param("roleIds") Set roleIds); - - void updateUserPasswordByUsername(@Param("username") String username, @Param("password") String password); - - void updateUserEmailByUsername(@Param("username") String username, @Param("email") String email); - - void batchUpdatePassword(@Param("password") String password, @Param("userIds") Set userIds); + SystemUserTb getUserByUsername(@Param("username") String username); + default long countUserByDeptIds(Set deptIds) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemUserTb::getDeptId, deptIds); + return selectCount(wrapper); + } + default SystemUserTb getUserByEmail(String email) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getEmail, email); + wrapper.eq(SystemUserTb::getEnabled, 1); + return selectOne(wrapper); + } + default SystemUserTb getUserByPhone(String phone) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemUserTb::getPhone, phone); + wrapper.eq(SystemUserTb::getEnabled, 1); + return selectOne(wrapper); + } + default void updateUserPasswordByUsername(String username, String password) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(SystemUserTb::getUsername, username); + wrapper.set(SystemUserTb::getPassword, password); + update(null, wrapper); + } + default void updateUserEmailByUsername(String username, String email) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(SystemUserTb::getUsername, username); + wrapper.set(SystemUserTb::getEmail, email); + update(null, wrapper); + } + default void updateUserPasswordByUserIds(String password, Set userIds) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.in(SystemUserTb::getId, userIds); + wrapper.set(SystemUserTb::getPassword, password); + update(null, wrapper); + } } 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 d42371c1..0069f695 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 @@ -13,18 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - 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 org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.Set; @Mapper -public interface SystemUserRoleMapper { - void batchInsertUserRole(@Param("roles") Set roles, @Param("userId") Long userId); - - void batchDeleteUserRole(@Param("userIds") Set userIds); -} +public interface SystemUserRoleMapper extends BaseMapper {} diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemCacheKey.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemCacheKey.java index 6c250c43..c8bb7bd9 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemCacheKey.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemCacheKey.java @@ -13,66 +13,54 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.dal.redis; /** * 关于缓存的Key集合 */ public interface SystemCacheKey { - /** * 用户 */ String USER_ID = "user::id:"; - /** * 数据 */ String DATA_USER = "data::user:"; - /** * 菜单 */ String MENU_ID = "menu::id:"; String MENU_USER = "menu::user:"; - /** * 角色授权 */ String ROLE_AUTH = "role::auth:"; String ROLE_USER = "role::user:"; - /** * 角色信息 */ String ROLE_ID = "role::id:"; - /** * 部门 */ String DEPT_ID = "dept::id:"; - /** * 岗位 */ String JOB_ID = "job::id:"; - /** * 数据字典 */ String DICT_NAME = "dict::name:"; - /** * 在线用户 */ String ONLINE_USER = "online::token:"; - /** * 登录验证码 */ String CAPTCHA_LOGIN = "captcha::login:"; - /** * 用户信息 */ diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemRedisKey.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemRedisKey.java index f7c63ae8..05f46060 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemRedisKey.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemRedisKey.java @@ -4,59 +4,48 @@ package cn.odboy.system.dal.redis; * 关于缓存的Key集合 */ public interface SystemRedisKey { - /** * 用户 */ String USER_ID = "user::id:"; - /** * 数据 */ String DATA_USER = "data::user:"; - /** * 菜单 */ String MENU_ID = "menu::id:"; String MENU_USER = "menu::user:"; - /** * 角色授权 */ String ROLE_AUTH = "role::auth:"; String ROLE_USER = "role::user:"; - /** * 角色信息 */ String ROLE_ID = "role::id:"; - /** * 部门 */ String DEPT_ID = "dept::id:"; - /** * 岗位 */ String JOB_ID = "job::id:"; - /** * 数据字典 */ String DICT_NAME = "dict::name:"; - /** * 在线用户 */ String ONLINE_USER = "online::token:"; - /** * 登录验证码 */ String CAPTCHA_LOGIN = "captcha::login:"; - /** * 用户信息 */ diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserInfoDAO.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserInfoDAO.java index 328f6774..a2e40f5e 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserInfoDAO.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserInfoDAO.java @@ -13,8 +13,7 @@ import org.springframework.stereotype.Component; */ @Component public class SystemUserInfoDAO { - @Autowired - private KitRedisHelper redisHelper; + @Autowired private KitRedisHelper redisHelper; /** * 添加缓存到Redis @@ -49,7 +48,6 @@ public class SystemUserInfoDAO { * @param username 用户名 * @return UserJwtVo */ - public SystemUserJwtVo getUserLoginInfoByUserName(String username) { if (StrUtil.isNotEmpty(username)) { // 获取数据 diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java index fd182c3d..95b2c4f7 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/dal/redis/SystemUserOnlineInfoDAO.java @@ -7,18 +7,26 @@ import cn.odboy.framework.redis.KitRedisHelper; import cn.odboy.system.dal.model.SystemUserJwtVo; import cn.odboy.system.dal.model.SystemUserOnlineVo; import cn.odboy.system.framework.permission.core.handler.TokenProvider; -import cn.odboy.util.*; +import cn.odboy.util.KitBrowserUtil; +import cn.odboy.util.KitDesEncryptUtil; +import cn.odboy.util.KitFileUtil; +import cn.odboy.util.KitIPUtil; +import cn.odboy.util.KitPageUtil; import com.baomidou.mybatisplus.core.metadata.IPage; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.*; -import java.util.concurrent.TimeUnit; - @Slf4j @Component @AllArgsConstructor @@ -34,7 +42,6 @@ public class SystemUserOnlineInfoDAO { * @param token / * @param request / */ - public void saveUserJwtModelByToken(SystemUserJwtVo userJwtVo, String token, HttpServletRequest request) { String dept = userJwtVo.getUser().getDept().getName(); String ip = KitBrowserUtil.getIp(request); @@ -65,7 +72,6 @@ public class SystemUserOnlineInfoDAO { * * @param token / */ - public void logoutByToken(String token) { String loginKey = tokenProvider.loginKey(token); redisHelper.del(loginKey); @@ -78,8 +84,8 @@ public class SystemUserOnlineInfoDAO { * @param response / * @throws IOException / */ - - public void downloadUserOnlineModelExcel(List all, HttpServletResponse response) throws IOException { + public void downloadUserOnlineModelExcel(List all, HttpServletResponse response) + throws IOException { List> list = new ArrayList<>(); for (SystemUserOnlineVo user : all) { Map map = new LinkedHashMap<>(); @@ -99,7 +105,6 @@ public class SystemUserOnlineInfoDAO { * * @param username / */ - public void kickOutByUsername(String username) { String loginKey = SystemRedisKey.ONLINE_USER + username + "*"; redisHelper.scanDel(loginKey); @@ -112,14 +117,15 @@ public class SystemUserOnlineInfoDAO { * @param pageable / * @return / */ - - public KitPageResult queryUserOnlineModelPage(SystemUserOnlineVo onlineVo, IPage pageable) { + public KitPageResult queryUserOnlineModelPage(SystemUserOnlineVo onlineVo, + IPage pageable) { String username = null; if (onlineVo != null) { username = onlineVo.getUserName(); } List onlineUserList = queryUserOnlineModelListByUsername(username); - List paging = KitPageUtil.softPaging(pageable.getCurrent(), pageable.getSize(), onlineUserList); + List paging = + KitPageUtil.softPaging(pageable.getCurrent(), pageable.getSize(), onlineUserList); return KitPageUtil.toPage(paging, onlineUserList.size()); } @@ -129,7 +135,6 @@ public class SystemUserOnlineInfoDAO { * @param username / * @return / */ - public List queryUserOnlineModelListByUsername(String username) { String loginKey = SystemRedisKey.ONLINE_USER + (StrUtil.isBlank(username) ? "" : "*" + username); List keys = redisHelper.scan(loginKey + "*"); @@ -148,7 +153,6 @@ public class SystemUserOnlineInfoDAO { * @param key / * @return / */ - public SystemUserOnlineVo queryUserOnlineModelByKey(String key) { return redisHelper.get(key, SystemUserOnlineVo.class); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/bizlock/BizLock.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/bizlock/BizLock.java index d679aace..d757a867 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/bizlock/BizLock.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/bizlock/BizLock.java @@ -13,10 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.bizlock; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.util.concurrent.TimeUnit; /** @@ -34,22 +38,18 @@ public @interface BizLock { * 业务名称 */ String bizName() default ""; - /** * 锁key,支持SpEL表达式 示例: #user.id - 获取参数user的id属性 #p0 - 获取第一个参数 #root.methodName - 获取方法名 */ String key() default ""; - /** * 锁持有时间(秒),默认60秒。锁的持有时间,超过这个时间锁会自动释放 */ long leaseTime() default 60; - /** * 时间单位,默认为秒 */ TimeUnit timeUnit() default TimeUnit.SECONDS; - /** * 获取锁失败后的异常信息 */ diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/bizlock/BizLockAspect.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/bizlock/BizLockAspect.java index 9bc76c99..3c2df924 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/bizlock/BizLockAspect.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/bizlock/BizLockAspect.java @@ -13,11 +13,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.bizlock; import cn.odboy.framework.exception.BadRequestException; import cn.odboy.framework.redis.KitRedisHelper; +import java.lang.reflect.Method; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @@ -28,8 +28,6 @@ import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.expression.spel.support.StandardEvaluationContext; import org.springframework.stereotype.Component; -import java.lang.reflect.Method; - @Aspect @Component public class BizLockAspect { @@ -60,16 +58,14 @@ public class BizLockAspect { private String parseLockKey(ProceedingJoinPoint joinPoint, BizLock bizLock) { // 如果key为空,使用默认格式: bizName:方法名 if (bizLock.key().isEmpty()) { - return String.format("%s:%s", bizLock.bizName(), ((MethodSignature)joinPoint.getSignature()).getMethod().getName()); + return String.format("%s:%s", bizLock.bizName(), + ((MethodSignature)joinPoint.getSignature()).getMethod().getName()); } - // 解析SpEL表达式 MethodSignature signature = (MethodSignature)joinPoint.getSignature(); Method method = signature.getMethod(); - // 创建SpEL上下文 StandardEvaluationContext context = new StandardEvaluationContext(); - // 设置方法参数 String[] parameterNames = signature.getParameterNames(); Object[] args = joinPoint.getArgs(); @@ -77,15 +73,12 @@ public class BizLockAspect { context.setVariable(parameterNames[i], args[i]); context.setVariable("p" + i, args[i]); // 支持#p0,#p1格式 } - // 设置方法相关信息 context.setVariable("methodName", method.getName()); context.setVariable("targetClass", joinPoint.getTarget().getClass().getName()); - // 解析表达式 Expression expression = parser.parseExpression(bizLock.key()); String value = expression.getValue(context, String.class); - // 组合最终的key: bizName:解析后的key return String.format("%s:%s", bizLock.bizName(), value); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/mybatisplus/MpMetaObjectHandler.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/mybatisplus/MpMetaObjectHandler.java index e87d1009..b7e8e053 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/mybatisplus/MpMetaObjectHandler.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/mybatisplus/MpMetaObjectHandler.java @@ -13,20 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.mybatisplus; import cn.hutool.core.date.DateTime; import cn.odboy.system.framework.permission.core.CsSecurityHelper; import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; +import java.util.Date; import org.apache.ibatis.reflection.MetaObject; import org.springframework.stereotype.Component; -import java.util.Date; - @Component public class MpMetaObjectHandler implements MetaObjectHandler { - @Override public void insertFill(MetaObject metaObject) { DateTime now = DateTime.now(); @@ -56,4 +53,3 @@ public class MpMetaObjectHandler implements MetaObjectHandler { this.strictUpdateFill(metaObject, "updateBy", String.class, username); } } - diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/OperationLog.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/OperationLog.java index b4d8e0d1..98891f89 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/OperationLog.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/OperationLog.java @@ -13,10 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.operalog; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * 捕捉操作日志 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 408b4d1f..609c431b 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.operalog; import cn.hutool.core.date.TimeInterval; @@ -28,6 +27,8 @@ import cn.odboy.util.KitBrowserUtil; import cn.odboy.util.KitIPUtil; import com.alibaba.fastjson2.JSON; import io.swagger.annotations.ApiOperation; +import java.lang.reflect.Method; +import javax.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -36,9 +37,6 @@ import org.aspectj.lang.reflect.MethodSignature; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.servlet.http.HttpServletRequest; -import java.lang.reflect.Method; - /** * 捕捉操作日志 * @@ -49,8 +47,7 @@ import java.lang.reflect.Method; @Aspect @Component public class OperationLogAspect { - @Autowired - private SystemOperationLogMapper systemOperationLogMapper; + @Autowired private SystemOperationLogMapper systemOperationLogMapper; @Around("@annotation(operationLog)") public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog) throws Throwable { @@ -84,7 +81,8 @@ public class OperationLogAspect { } } - private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation, TimeInterval timeInterval) { + private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation, + TimeInterval timeInterval) { long executeTime = timeInterval.intervalMs(); MethodSignature signature = (MethodSignature)joinPoint.getSignature(); String bizName = annotation.bizName(); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/annotaions/OperationLog.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/annotaions/OperationLog.java index 3fbee830..21cfbdaf 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/annotaions/OperationLog.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/annotaions/OperationLog.java @@ -15,7 +15,12 @@ */ package cn.odboy.system.framework.operalog.annotaions; -import java.lang.annotation.*; +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; /** * 捕捉操作日志 diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/core/SystemOperationLogAspect.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/core/SystemOperationLogAspect.java index 53c810a8..4d6ba8a6 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/core/SystemOperationLogAspect.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/operalog/core/SystemOperationLogAspect.java @@ -28,6 +28,8 @@ import cn.odboy.util.KitBrowserUtil; import cn.odboy.util.KitIPUtil; import com.alibaba.fastjson2.JSON; import io.swagger.annotations.ApiOperation; +import java.lang.reflect.Method; +import javax.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -36,9 +38,6 @@ import org.aspectj.lang.reflect.MethodSignature; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.servlet.http.HttpServletRequest; -import java.lang.reflect.Method; - /** * 捕捉操作日志 * @@ -49,8 +48,7 @@ import java.lang.reflect.Method; @Aspect @Component public class SystemOperationLogAspect { - @Autowired - private SystemOperationLogMapper systemOperationLogMapper; + @Autowired private SystemOperationLogMapper systemOperationLogMapper; @Around("@annotation(operationLog)") public Object operationLogCatch(ProceedingJoinPoint joinPoint, OperationLog operationLog) throws Throwable { @@ -86,7 +84,8 @@ public class SystemOperationLogAspect { } } - private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation, TimeInterval timeInterval) { + private SystemOperationLogTb getOperationLogTb(ProceedingJoinPoint joinPoint, OperationLog annotation, + TimeInterval timeInterval) { long executeTime = timeInterval.intervalMs(); MethodSignature signature = (MethodSignature)joinPoint.getSignature(); String bizName = annotation.bizName(); diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/config/AuthorityConfig.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/config/AuthorityConfig.java index d028465d..057f34b4 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/config/AuthorityConfig.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/config/AuthorityConfig.java @@ -13,20 +13,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.permission.config; import cn.odboy.system.framework.permission.core.CsSecurityHelper; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.stereotype.Service; - import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.stereotype.Service; @Service(value = "el") public class AuthorityConfig { - /** * 判断接口是否有权限 * @@ -35,7 +32,9 @@ public class AuthorityConfig { */ public Boolean check(String... permissions) { // 获取当前用户的所有权限 - List roleList = CsSecurityHelper.getCurrentUser().getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList()); + List roleList = + CsSecurityHelper.getCurrentUser().getAuthorities().stream().map(GrantedAuthority::getAuthority) + .collect(Collectors.toList()); // 判断当前用户的所有权限是否包含接口上定义的权限 return roleList.contains("admin") || Arrays.stream(permissions).anyMatch(roleList::contains); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/config/SpringSecurityConfig.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/config/SpringSecurityConfig.java index c0b68843..0ba1e47a 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/config/SpringSecurityConfig.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/config/SpringSecurityConfig.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.permission.config; import cn.odboy.constant.RequestMethodEnum; @@ -22,6 +21,8 @@ import cn.odboy.system.framework.permission.core.handler.JwtAccessDeniedHandler; import cn.odboy.system.framework.permission.core.handler.JwtAuthenticationEntryPoint; import cn.odboy.system.framework.permission.core.handler.TokenProvider; import cn.odboy.util.KitAnonTagUtil; +import java.util.Map; +import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.Bean; @@ -36,24 +37,15 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; import org.springframework.web.filter.CorsFilter; -import java.util.Map; -import java.util.Set; - @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) public class SpringSecurityConfig { - @Autowired - private TokenProvider tokenProvider; - @Autowired - private CorsFilter corsFilter; - @Autowired - private JwtAuthenticationEntryPoint authenticationErrorHandler; - @Autowired - private JwtAccessDeniedHandler jwtAccessDeniedHandler; - @Autowired - private ApplicationContext applicationContext; - @Autowired - private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; + @Autowired private TokenProvider tokenProvider; + @Autowired private CorsFilter corsFilter; + @Autowired private JwtAuthenticationEntryPoint authenticationErrorHandler; + @Autowired private JwtAccessDeniedHandler jwtAccessDeniedHandler; + @Autowired private ApplicationContext applicationContext; + @Autowired private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; @Bean public GrantedAuthorityDefaults grantedAuthorityDefaults() { @@ -75,7 +67,8 @@ public class SpringSecurityConfig { // 禁用 CSRF .csrf().disable().addFilter(corsFilter) // 授权异常 - .exceptionHandling().authenticationEntryPoint(authenticationErrorHandler).accessDeniedHandler(jwtAccessDeniedHandler) + .exceptionHandling().authenticationEntryPoint(authenticationErrorHandler) + .accessDeniedHandler(jwtAccessDeniedHandler) // 防止iframe 造成跨域 .and().headers().frameOptions().disable() // 不创建会话 @@ -83,8 +76,8 @@ public class SpringSecurityConfig { // 静态资源等等 .antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/websocket/**").permitAll() // swagger 文档 - .antMatchers("/swagger-ui.html").permitAll().antMatchers("/swagger-resources/**").permitAll().antMatchers("/webjars/**").permitAll() - .antMatchers("/*/api-docs").permitAll() + .antMatchers("/swagger-ui.html").permitAll().antMatchers("/swagger-resources/**").permitAll() + .antMatchers("/webjars/**").permitAll().antMatchers("/*/api-docs").permitAll() // 文件 .antMatchers("/avatar/**").permitAll().antMatchers("/file/**").permitAll() // 阿里巴巴 druid @@ -93,15 +86,20 @@ public class SpringSecurityConfig { .antMatchers(HttpMethod.OPTIONS, "/**").permitAll() // 自定义匿名访问所有url放行:允许匿名和带Token访问,细腻化到每个 Request 类型 // GET - .antMatchers(HttpMethod.GET, anonymousUrls.get(RequestMethodEnum.GET.getType()).toArray(new String[0])).permitAll() + .antMatchers(HttpMethod.GET, anonymousUrls.get(RequestMethodEnum.GET.getType()).toArray(new String[0])) + .permitAll() // POST - .antMatchers(HttpMethod.POST, anonymousUrls.get(RequestMethodEnum.POST.getType()).toArray(new String[0])).permitAll() + .antMatchers(HttpMethod.POST, anonymousUrls.get(RequestMethodEnum.POST.getType()).toArray(new String[0])) + .permitAll() // PUT - .antMatchers(HttpMethod.PUT, anonymousUrls.get(RequestMethodEnum.PUT.getType()).toArray(new String[0])).permitAll() + .antMatchers(HttpMethod.PUT, anonymousUrls.get(RequestMethodEnum.PUT.getType()).toArray(new String[0])) + .permitAll() // PATCH - .antMatchers(HttpMethod.PATCH, anonymousUrls.get(RequestMethodEnum.PATCH.getType()).toArray(new String[0])).permitAll() + .antMatchers(HttpMethod.PATCH, anonymousUrls.get(RequestMethodEnum.PATCH.getType()).toArray(new String[0])) + .permitAll() // DELETE - .antMatchers(HttpMethod.DELETE, anonymousUrls.get(RequestMethodEnum.DELETE.getType()).toArray(new String[0])).permitAll() + .antMatchers(HttpMethod.DELETE, + anonymousUrls.get(RequestMethodEnum.DELETE.getType()).toArray(new String[0])).permitAll() // 所有类型的接口都放行 .antMatchers(anonymousUrls.get(RequestMethodEnum.ALL.getType()).toArray(new String[0])).permitAll() // 所有请求都需要认证 diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/config/TokenConfigurer.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/config/TokenConfigurer.java index d479cae0..dc5997b1 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/config/TokenConfigurer.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/config/TokenConfigurer.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.permission.config; import cn.odboy.system.dal.redis.SystemUserOnlineInfoDAO; diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/CsSecurityHelper.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/CsSecurityHelper.java index d627b5ce..b74f602d 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/CsSecurityHelper.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/CsSecurityHelper.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.permission.core; import cn.hutool.core.collection.CollUtil; @@ -25,6 +24,9 @@ import cn.odboy.system.constant.SystemDataScopeEnum; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONObject; +import java.util.List; +import java.util.Objects; +import javax.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; @@ -32,10 +34,6 @@ import org.springframework.stereotype.Component; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import javax.servlet.http.HttpServletRequest; -import java.util.List; -import java.util.Objects; - /** * 获取当前登录的用户 */ @@ -122,7 +120,8 @@ public class CsSecurityHelper { * @return / */ public static String getToken() { - HttpServletRequest request = ((ServletRequestAttributes)Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest(); + HttpServletRequest request = ((ServletRequestAttributes)Objects.requireNonNull( + RequestContextHolder.getRequestAttributes())).getRequest(); String bearerToken = request.getHeader(SystemConst.HEADER_NAME); if (bearerToken != null && bearerToken.startsWith(SystemConst.TOKEN_PREFIX)) { // 去掉令牌前缀 diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/JwtAccessDeniedHandler.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/JwtAccessDeniedHandler.java index 79537e06..a47e5869 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/JwtAccessDeniedHandler.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/JwtAccessDeniedHandler.java @@ -13,30 +13,29 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.permission.core.handler; import cn.odboy.framework.exception.handler.ApiError; import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import org.springframework.http.HttpStatus; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.web.access.AccessDeniedHandler; import org.springframework.stereotype.Component; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - @Component public class JwtAccessDeniedHandler implements AccessDeniedHandler { - @Override - public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws IOException { + public void handle(HttpServletRequest request, HttpServletResponse response, + AccessDeniedException accessDeniedException) throws IOException { //当用户在没有授权的情况下访问受保护的REST资源时,将调用此方法发送403 Forbidden响应 response.setStatus(HttpStatus.FORBIDDEN.value()); response.setContentType("application/json;charset=UTF-8"); ObjectMapper objectMapper = new ObjectMapper(); - String jsonResponse = objectMapper.writeValueAsString(ApiError.error(HttpStatus.FORBIDDEN.value(), "禁止访问,您没有权限访问此资源")); + String jsonResponse = objectMapper.writeValueAsString( + ApiError.error(HttpStatus.FORBIDDEN.value(), "禁止访问,您没有权限访问此资源")); response.getWriter().write(jsonResponse); } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/JwtAuthenticationEntryPoint.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/JwtAuthenticationEntryPoint.java index 08910b7e..8aec275e 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/JwtAuthenticationEntryPoint.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/JwtAuthenticationEntryPoint.java @@ -13,33 +13,32 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.permission.core.handler; import cn.odboy.framework.exception.handler.ApiError; import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.IOException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpStatus; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.stereotype.Component; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - @Slf4j @Component public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint { - @Override - public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException { + public void commence(HttpServletRequest request, HttpServletResponse response, + AuthenticationException authException) throws IOException { // 当用户尝试访问安全的REST资源而不提供任何凭据时,将调用此方法发送401 响应 int code = HttpStatus.UNAUTHORIZED.value(); response.setStatus(code); response.setContentType("application/json;charset=UTF-8"); ObjectMapper objectMapper = new ObjectMapper(); - String jsonResponse = objectMapper.writeValueAsString(ApiError.error(HttpStatus.UNAUTHORIZED.value(), "登录状态已过期,请重新登录")); + String jsonResponse = objectMapper.writeValueAsString( + ApiError.error(HttpStatus.UNAUTHORIZED.value(), "登录状态已过期,请重新登录")); response.getWriter().write(jsonResponse); } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/TokenFilter.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/TokenFilter.java index 77bc6721..bd9df8a3 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/TokenFilter.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/TokenFilter.java @@ -13,25 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.permission.core.handler; import cn.hutool.core.util.StrUtil; import cn.odboy.constant.SystemConst; import cn.odboy.system.dal.model.SystemUserOnlineVo; import cn.odboy.system.dal.redis.SystemUserOnlineInfoDAO; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.util.StringUtils; -import org.springframework.web.filter.GenericFilterBean; - +import java.io.IOException; import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; -import java.io.IOException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.util.StringUtils; +import org.springframework.web.filter.GenericFilterBean; @Slf4j public class TokenFilter extends GenericFilterBean { @@ -48,7 +46,8 @@ public class TokenFilter extends GenericFilterBean { } @Override - public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException { + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) + throws ServletException, IOException { HttpServletRequest httpServletRequest = (HttpServletRequest)servletRequest; String token = resolveToken(httpServletRequest); // 对于 Token 为空的不需要去查 Redis diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/TokenProvider.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/TokenProvider.java index a4807779..5b90e356 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/TokenProvider.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/TokenProvider.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.permission.core.handler; import cn.hutool.core.date.DateField; @@ -29,6 +28,13 @@ import io.jsonwebtoken.JwtParser; import io.jsonwebtoken.Jwts; import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.crypto.SecretKey; +import javax.servlet.http.HttpServletRequest; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; @@ -37,23 +43,13 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.userdetails.User; import org.springframework.stereotype.Component; -import javax.crypto.SecretKey; -import javax.servlet.http.HttpServletRequest; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - @Slf4j @Component public class TokenProvider implements InitializingBean { public static final String AUTHORITIES_UUID_KEY = "uid"; public static final String AUTHORITIES_UID_KEY = "userId"; - @Autowired - private KitRedisHelper redisHelper; - @Autowired - private AppProperties properties; + @Autowired private KitRedisHelper redisHelper; + @Autowired private AppProperties properties; // 0.11.x版本 // private Key signingKey; // 0.12.x版本 diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/UserDetailsHandler.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/UserDetailsHandler.java index 7796c549..d16464f0 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/UserDetailsHandler.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/permission/core/handler/UserDetailsHandler.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.permission.core.handler; import cn.odboy.framework.exception.BadRequestException; @@ -24,27 +23,22 @@ import cn.odboy.system.dal.redis.SystemUserInfoDAO; import cn.odboy.system.service.SystemDataService; import cn.odboy.system.service.SystemRoleService; import cn.odboy.system.service.SystemUserService; +import java.util.List; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.stereotype.Service; -import java.util.List; - /** * TODO 通过用户名判断用户信息,并获取拥有的权限与部门 */ @Slf4j @Service("userDetailsService") public class UserDetailsHandler implements UserDetailsService { - @Autowired - private SystemRoleService systemRoleService; - @Autowired - private SystemUserService systemUserService; - @Autowired - private SystemDataService systemDataService; - @Autowired - private SystemUserInfoDAO systemUserInfoDAO; + @Autowired private SystemRoleService systemRoleService; + @Autowired private SystemUserService systemUserService; + @Autowired private SystemDataService systemDataService; + @Autowired private SystemUserInfoDAO systemUserInfoDAO; @Override public SystemUserJwtVo loadUserByUsername(String username) { @@ -60,7 +54,7 @@ public class UserDetailsHandler implements UserDetailsService { // 获取用户的权限 List authorities = systemRoleService.buildUserRolePermissions(user); // 初始化JwtUserDto - userJwtVo = new SystemUserJwtVo(user, systemDataService.queryDeptIdListByArgs(user), authorities); + userJwtVo = new SystemUserJwtVo(user, systemDataService.findDeptIdListByArgs(user), authorities); // 添加缓存数据 systemUserInfoDAO.saveUserLoginInfoByUserName(username, userJwtVo); } 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 a1147c06..1f9e09c3 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 @@ -13,26 +13,22 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.quartz; import cn.odboy.system.dal.dataobject.SystemQuartzJobTb; -import cn.odboy.system.dal.mysql.SystemQuartzJobMapper; +import cn.odboy.system.service.SystemQuartzJobService; +import java.util.List; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; -import java.util.List; - @Slf4j @Component public class ActiveJobRegister implements ApplicationRunner { - @Autowired - private SystemQuartzJobMapper quartzJobMapper; - @Autowired - private QuartzManage quartzManage; + @Autowired private SystemQuartzJobService systemQuartzJobService; + @Autowired private QuartzManage quartzManage; /** * 项目启动时重新激活启用的定时任务 @@ -41,7 +37,7 @@ public class ActiveJobRegister implements ApplicationRunner { */ @Override public void run(ApplicationArguments applicationArguments) { - List quartzJobs = quartzJobMapper.selectAllEnableQuartzJob(); + List quartzJobs = systemQuartzJobService.queryEnableQuartzJob(); quartzJobs.forEach(quartzManage::addJob); log.info("Timing task injection complete"); } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/ExecutionJobBean.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/ExecutionJobBean.java index 71c96aff..ca11031a 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/ExecutionJobBean.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/quartz/ExecutionJobBean.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.quartz; import cn.hutool.core.exceptions.ExceptionUtil; @@ -31,16 +30,15 @@ import cn.odboy.system.dal.model.SystemSendEmailArgs; import cn.odboy.system.dal.mysql.SystemQuartzLogMapper; import cn.odboy.system.service.SystemEmailService; import cn.odboy.system.service.SystemQuartzJobService; -import lombok.extern.slf4j.Slf4j; -import org.quartz.JobExecutionContext; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.scheduling.quartz.QuartzJobBean; - import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.Future; +import lombok.extern.slf4j.Slf4j; +import org.quartz.JobExecutionContext; +import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; +import org.springframework.scheduling.quartz.QuartzJobBean; @Slf4j public class ExecutionJobBean extends QuartzJobBean { @@ -57,9 +55,7 @@ public class ExecutionJobBean extends QuartzJobBean { SystemQuartzLogMapper quartzLogMapper = KitSpringBeanHolder.getBean(SystemQuartzLogMapper.class); SystemQuartzJobService systemQuartzJobService = KitSpringBeanHolder.getBean(SystemQuartzJobService.class); KitRedisHelper redisHelper = KitSpringBeanHolder.getBean(KitRedisHelper.class); - String uuid = quartzJob.getUuid(); - SystemQuartzLogTb quartzLog = new SystemQuartzLogTb(); quartzLog.setJobName(quartzJob.getJobName()); quartzLog.setBeanName(quartzJob.getBeanName()); @@ -69,7 +65,8 @@ public class ExecutionJobBean extends QuartzJobBean { quartzLog.setCronExpression(quartzJob.getCronExpression()); try { // 执行任务 - QuartzRunnable task = new QuartzRunnable(quartzJob.getBeanName(), quartzJob.getMethodName(), quartzJob.getParams()); + QuartzRunnable task = + new QuartzRunnable(quartzJob.getBeanName(), quartzJob.getMethodName(), quartzJob.getParams()); Future future = executor.submit(task); // 忽略任务执行结果 future.get(); @@ -122,7 +119,8 @@ public class ExecutionJobBean extends QuartzJobBean { Map data = new HashMap<>(16); data.put("task", quartzJob); data.put("msg", msg); - TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); + TemplateEngine engine = + TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); Template template = engine.getTemplate("SystemQuartzJobTaskAlarmTemplate.ftl"); sendEmailRequest.setContent(template.render(data)); List emails = Arrays.asList(quartzJob.getEmail().split("[,,]")); 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 349302a3..39a7c5eb 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 @@ -13,49 +13,50 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.quartz; import cn.odboy.framework.exception.BadRequestException; import cn.odboy.system.dal.dataobject.SystemQuartzJobTb; +import java.util.Date; +import javax.annotation.Resource; import lombok.extern.slf4j.Slf4j; -import org.quartz.*; +import org.quartz.CronScheduleBuilder; +import org.quartz.CronTrigger; +import org.quartz.JobBuilder; +import org.quartz.JobDataMap; +import org.quartz.JobDetail; +import org.quartz.JobKey; +import org.quartz.ObjectAlreadyExistsException; +import org.quartz.Scheduler; +import org.quartz.Trigger; +import org.quartz.TriggerBuilder; +import org.quartz.TriggerKey; import org.quartz.impl.triggers.CronTriggerImpl; import org.springframework.stereotype.Component; -import javax.annotation.Resource; -import java.util.Date; - @Slf4j @Component public class QuartzManage { - private static final String JOB_NAME = "TASK_"; - - @Resource - private Scheduler scheduler; + @Resource private Scheduler scheduler; public void addJob(SystemQuartzJobTb quartzJob) { try { // 构建job信息 - JobDetail jobDetail = JobBuilder.newJob(ExecutionJobBean.class).withIdentity(JOB_NAME + quartzJob.getId()).build(); - + JobDetail jobDetail = + JobBuilder.newJob(ExecutionJobBean.class).withIdentity(JOB_NAME + quartzJob.getId()).build(); // 通过触发器名和cron 表达式创建 Trigger Trigger trigger = TriggerBuilder.newTrigger().withIdentity(JOB_NAME + quartzJob.getId()).startNow() .withSchedule(CronScheduleBuilder.cronSchedule(quartzJob.getCronExpression())).build(); - trigger.getJobDataMap().put(SystemQuartzJobTb.JOB_KEY, quartzJob); - // 重置启动时间 ((CronTriggerImpl)trigger).setStartTime(new Date()); - // 执行定时任务,如果是持久化的,这里会报错,捕获输出 try { scheduler.scheduleJob(jobDetail, trigger); } catch (ObjectAlreadyExistsException e) { log.warn("定时任务已存在,跳过加载"); } - // 暂停任务 if (quartzJob.getIsPause()) { pauseJob(quartzJob); @@ -85,7 +86,6 @@ public class QuartzManage { // 重置启动时间 ((CronTriggerImpl)trigger).setStartTime(new Date()); trigger.getJobDataMap().put(SystemQuartzJobTb.JOB_KEY, quartzJob); - scheduler.rescheduleJob(triggerKey, trigger); // 暂停任务 if (quartzJob.getIsPause()) { diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/OssStorageConfiguration.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/OssStorageConfiguration.java index e018ea25..608c8c8e 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/OssStorageConfiguration.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/OssStorageConfiguration.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.storage; import cn.odboy.framework.exception.BadRequestException; @@ -28,14 +27,14 @@ import org.springframework.context.annotation.Configuration; @Slf4j @Configuration public class OssStorageConfiguration { - @Autowired - private AppProperties properties; + @Autowired private AppProperties properties; @Bean public MinioClient minioClient() { try { OSSConfigModel minio = properties.getOss().getMinio(); - return MinioClient.builder().endpoint(minio.getEndpoint()).credentials(minio.getAccessKey(), minio.getSecretKey()).build(); + return MinioClient.builder().endpoint(minio.getEndpoint()) + .credentials(minio.getAccessKey(), minio.getSecretKey()).build(); } catch (Exception e) { log.error("创建Minio客户端失败", e); throw new BadRequestException("创建Minio客户端失败"); 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 78133c4b..cb943c39 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 @@ -13,11 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.storage.local; import cn.odboy.framework.exception.BadRequestException; import cn.odboy.framework.properties.AppProperties; +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; @@ -26,16 +27,11 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.util.unit.DataSize; -import javax.servlet.MultipartConfigElement; -import java.io.File; - @Slf4j @Configuration public class MultipartConfig { - @Value("${spring.application.name}") - private String name; - @Autowired - private AppProperties properties; + @Value("${spring.application.name}") private String name; + @Autowired private AppProperties properties; /** * 文件上传临时路径 diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/minio/MinioRepository.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/minio/MinioRepository.java index 01ba9a1a..61af4ff0 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/minio/MinioRepository.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/framework/storage/minio/MinioRepository.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.framework.storage.minio; import cn.hutool.core.io.FastByteArrayOutputStream; @@ -30,30 +29,37 @@ import cn.odboy.framework.properties.model.StorageOSSModel; import cn.odboy.system.dal.dataobject.SystemOssStorageTb; import cn.odboy.util.KitDateUtil; import cn.odboy.util.KitFileUtil; -import io.minio.*; +import io.minio.BucketExistsArgs; +import io.minio.GetObjectArgs; +import io.minio.GetObjectResponse; +import io.minio.GetPresignedObjectUrlArgs; +import io.minio.ListObjectsArgs; +import io.minio.MakeBucketArgs; +import io.minio.MinioClient; +import io.minio.PutObjectArgs; +import io.minio.RemoveBucketArgs; +import io.minio.RemoveObjectArgs; +import io.minio.Result; import io.minio.http.Method; import io.minio.messages.Bucket; import io.minio.messages.Item; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.web.multipart.MultipartFile; - -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; @Slf4j @Component public class MinioRepository { - @Autowired - private AppProperties properties; - @Autowired - private MinioClient minioClient; + @Autowired private AppProperties properties; + @Autowired private MinioClient minioClient; /** * 检查存储bucket是否存在 @@ -136,19 +142,18 @@ public class MinioRepository { * @param md5 文件md5 * @return String 上传后的文件名,上传失败返回 null */ - public SystemOssStorageTb upload(File tempFile, String originalFilename, long fileSize, String contentType, String md5) { + public SystemOssStorageTb upload(File tempFile, String originalFilename, long fileSize, String contentType, + String md5) { StorageOSSModel ossConfig = properties.getOss(); OSSConfigModel ossMinioConfig = ossConfig.getMinio(); String type = FileTypeUtil.getType(tempFile); String prefix = KitFileUtil.getPrefix(tempFile); String suffix = KitFileUtil.getSuffix(tempFile); - String fileCode = IdUtil.fastSimpleUUID(); String fileName = fileCode + FileUtil.getSuffix(originalFilename); String objectName = KitDateUtil.getNowDateStr() + "/" + fileName; log.info("上传文件,原文件名:{},上传后文件名:{}", originalFilename, fileName); String fileUrl = ossMinioConfig.getEndpoint() + "/" + ossMinioConfig.getBucketName() + "/" + objectName; - SystemOssStorageTb systemOssStorageTb = new SystemOssStorageTb(); systemOssStorageTb.setServiceType("minio"); systemOssStorageTb.setEndpoint(ossMinioConfig.getEndpoint()); @@ -162,11 +167,9 @@ public class MinioRepository { systemOssStorageTb.setFileUrl(fileUrl); systemOssStorageTb.setFileCode(fileCode); systemOssStorageTb.setObjectName(objectName); - try (InputStream fileInputStream = KitFileUtil.getInputStream(tempFile)) { - PutObjectArgs objectArgs = - PutObjectArgs.builder().bucket(ossMinioConfig.getBucketName()).object(objectName).stream(fileInputStream, fileSize, -1).contentType(contentType) - .build(); + PutObjectArgs objectArgs = PutObjectArgs.builder().bucket(ossMinioConfig.getBucketName()).object(objectName) + .stream(fileInputStream, fileSize, -1).contentType(contentType).build(); minioClient.putObject(objectArgs); log.info("文件上传成功,并删除临时文件,文件名:{}", originalFilename); return systemOssStorageTb; @@ -193,19 +196,16 @@ public class MinioRepository { if (StrUtil.isBlank(originalFilename)) { throw new BadRequestException("文件名不能为空"); } - long size = file.getSize(); KitFileUtil.checkSize(properties.getOss().getMaxSize(), size); - String fileName = UUID.randomUUID() + FileUtil.getSuffix(originalFilename); // yyyy/MM/dd/fileName.xxx String objectName = KitDateUtil.getNowDateTimeStr() + "/" + fileName; - log.info("准备上传文件,原文件名:{},上传后文件名:{}", originalFilename, fileName); try (InputStream fileInputStream = file.getInputStream()) { PutObjectArgs objectArgs = - PutObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(objectName).stream(fileInputStream, file.getSize(), -1) - .contentType(file.getContentType()).build(); + PutObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(objectName) + .stream(fileInputStream, file.getSize(), -1).contentType(file.getContentType()).build(); // 使用重试机制进行上传 uploadWithRetry(objectArgs, 3); log.info("文件上传成功,objectName: {}", objectName); @@ -254,7 +254,8 @@ public class MinioRepository { } try { GetPresignedObjectUrlArgs presignedUrlArgs = - GetPresignedObjectUrlArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fullFileName).method(Method.GET) + GetPresignedObjectUrlArgs.builder().bucket(properties.getOss().getMinio().getBucketName()) + .object(fullFileName).method(Method.GET) // 设置 URL 过期时间为 7 天, 最大 7 天, 别挣扎了 .expiry(3600 * 24 * 7).build(); String url = minioClient.getPresignedObjectUrl(presignedUrlArgs); @@ -273,17 +274,16 @@ public class MinioRepository { * @param res HTTP 响应 */ public void download(String fileName, HttpServletResponse res) { - GetObjectArgs objectArgs = GetObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build(); - - try (GetObjectResponse response = minioClient.getObject(objectArgs); FastByteArrayOutputStream os = new FastByteArrayOutputStream()) { - + GetObjectArgs objectArgs = + GetObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build(); + try (GetObjectResponse response = minioClient.getObject(objectArgs); + FastByteArrayOutputStream os = new FastByteArrayOutputStream()) { byte[] buf = new byte[1024]; int len; while ((len = response.read(buf)) != -1) { os.write(buf, 0, len); } os.flush(); - byte[] bytes = os.toByteArray(); res.setCharacterEncoding("utf-8"); res.addHeader("Content-Disposition", "attachment;fileName=" + fileName); @@ -303,13 +303,12 @@ public class MinioRepository { * @param res HTTP 响应 */ public void downloadOptimizedVersion(String fileName, HttpServletResponse res) { - GetObjectArgs objectArgs = GetObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build(); - + GetObjectArgs objectArgs = + GetObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build(); try (GetObjectResponse response = minioClient.getObject(objectArgs)) { // 增大缓冲区 byte[] buf = new byte[1024 * 4]; int len; - // 分块下载并输出到响应流 try (ServletOutputStream stream = res.getOutputStream()) { res.setCharacterEncoding("utf-8"); @@ -317,7 +316,6 @@ public class MinioRepository { res.setHeader("Cache-Control", "no-store"); res.setHeader("Pragma", "no-cache"); res.setHeader("Expires", "0"); - while ((len = response.read(buf)) != -1) { stream.write(buf, 0, len); // 确保实时写入 @@ -337,7 +335,8 @@ public class MinioRepository { */ public List queryAllObjects() { try { - Iterable> results = minioClient.listObjects(ListObjectsArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).build()); + Iterable> results = minioClient.listObjects( + ListObjectsArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).build()); List items = new ArrayList<>(); for (Result result : results) { items.add(result.get()); @@ -357,7 +356,9 @@ public class MinioRepository { */ public boolean removeBucketFile(String fileName) { try { - minioClient.removeObject(RemoveObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName).build()); + minioClient.removeObject( + RemoveObjectArgs.builder().bucket(properties.getOss().getMinio().getBucketName()).object(fileName) + .build()); log.info("删除文件成功,fileName: {}", fileName); return true; } catch (Exception e) { diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/job/TestTask.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/job/TestTask.java index eb03b6db..7c0d2a6b 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/job/TestTask.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/job/TestTask.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.job; import lombok.extern.slf4j.Slf4j; @@ -22,7 +21,6 @@ import org.springframework.stereotype.Service; @Slf4j @Service public class TestTask { - public void run() { log.info("run 执行成功"); } 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 cfcb79aa..02b3d453 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service; import cn.hutool.core.collection.CollUtil; @@ -21,13 +20,12 @@ 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.dataobject.SystemUserTb; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** * 数据权限 Service @@ -36,10 +34,9 @@ import java.util.stream.Collectors; */ @Service public class SystemDataService { - @Autowired - private SystemRoleService systemRoleService; - @Autowired - private SystemDeptService systemDeptService; + @Autowired private SystemRoleService systemRoleService; + @Autowired private SystemDeptService systemDeptService; + @Autowired private SystemRoleDeptService systemRoleDeptService; /** * 获取数据权限 @@ -47,7 +44,7 @@ public class SystemDataService { * @param user / * @return / */ - public List queryDeptIdListByArgs(SystemUserTb user) { + public List findDeptIdListByArgs(SystemUserTb user) { List deptIds = new ArrayList<>(); // 查询用户角色 List roleList = systemRoleService.queryRoleByUsersId(user.getId()); @@ -59,7 +56,7 @@ public class SystemDataService { deptIds.add(user.getDept().getId()); break; case CUSTOMIZE: - deptIds.addAll(queryCustomDataPermissionList(deptIds, role)); + deptIds.addAll(this.findCustomDataPermissionList(deptIds, role)); break; default: return new ArrayList<>(); @@ -75,8 +72,8 @@ public class SystemDataService { * @param role 角色 * @return 数据权限ID */ - private List queryCustomDataPermissionList(List deptIds, SystemRoleTb role) { - List deptList = systemDeptService.queryDeptByRoleId(role.getId()); + private List findCustomDataPermissionList(List deptIds, SystemRoleTb role) { + List deptList = systemRoleDeptService.selectDeptByRoleId(role.getId()); for (SystemDeptTb dept : deptList) { deptIds.add(dept.getId()); List deptChildren = systemDeptService.queryDeptByPid(dept.getId()); 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 e0879cf9..ff10bec2 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service; import cn.hutool.core.bean.BeanUtil; @@ -22,6 +21,7 @@ import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.odboy.base.KitPageResult; +import cn.odboy.framework.context.KitSpringBeanHolder; import cn.odboy.framework.exception.BadRequestException; import cn.odboy.system.constant.SystemDataScopeEnum; import cn.odboy.system.dal.dataobject.SystemDeptTb; @@ -35,33 +35,36 @@ import cn.odboy.system.dal.mysql.SystemUserMapper; import cn.odboy.system.framework.permission.core.CsSecurityHelper; import cn.odboy.util.KitClassUtil; import cn.odboy.util.KitFileUtil; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +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; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; - @Service public class SystemDeptService { - @Autowired - private SystemDeptMapper systemDeptMapper; - @Autowired - private SystemUserMapper systemUserMapper; - @Autowired - private SystemRoleMapper systemRoleMapper; + @Autowired private SystemDeptMapper systemDeptMapper; + @Autowired private SystemUserMapper systemUserMapper; + @Autowired private SystemRoleMapper systemRoleMapper; /** * 创建 * * @param args / */ - @Transactional(rollbackFor = Exception.class) public void saveDept(SystemCreateDeptArgs args) { systemDeptMapper.insert(BeanUtil.copyProperties(args, SystemDeptTb.class)); @@ -73,11 +76,10 @@ public class SystemDeptService { * * @param args / */ - @Transactional(rollbackFor = Exception.class) - public void modifyDept(SystemDeptTb args) { + public void updateDept(SystemDeptTb args) { // 旧的部门 - Long oldPid = queryDeptById(args.getId()).getPid(); + Long oldPid = this.getDeptById(args.getId()).getPid(); Long newPid = args.getPid(); if (args.getPid() != null && args.getId().equals(args.getPid())) { throw new BadRequestException("上级不能为自己"); @@ -94,7 +96,6 @@ public class SystemDeptService { * * @param deptSet / */ - @Transactional(rollbackFor = Exception.class) public void removeDeptByIds(Set deptSet) { for (SystemDeptTb dept : deptSet) { @@ -130,11 +131,19 @@ public class SystemDeptService { @Transactional(rollbackFor = Exception.class) public void updateDeptSubCnt(Long deptId) { if (deptId != null) { - int count = systemDeptMapper.countDeptByPid(deptId); - systemDeptMapper.updateDeptSubCountById(count, deptId); + long count = systemDeptMapper.countDeptByPid(deptId); + KitSpringBeanHolder.getBean(SystemDeptService.class).updateDeptSubCountById(count, deptId); } } + @Transactional(rollbackFor = Exception.class) + public void updateDeptSubCountById(long count, Long deptId) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(SystemDeptTb::getId, deptId); + wrapper.set(SystemDeptTb::getSubCount, count); + systemDeptMapper.update(null, wrapper); + } + /** * 筛选出 list 中没有父部门(即 pid 不在其他部门 id 列表中的部门)的部门列表 */ @@ -159,8 +168,7 @@ public class SystemDeptService { * @return / * @throws Exception / */ - - public List queryAllDept(SystemQueryDeptArgs criteria, Boolean isQuery) throws Exception { + public List findAllDept(SystemQueryDeptArgs criteria, Boolean isQuery) throws Exception { String dataScopeType = CsSecurityHelper.getDataScopeType(); if (isQuery) { if (dataScopeType.equals(SystemDataScopeEnum.ALL.getValue())) { @@ -186,10 +194,10 @@ public class SystemDeptService { } // 数据权限 criteria.setIds(CsSecurityHelper.getCurrentUserDataScope()); - List list = systemDeptMapper.selectDeptByArgs(criteria); + List list = systemDeptMapper.queryDeptByArgs(criteria); // 如果为空, 就代表为自定义权限或者本级权限, 就需要去重, 不理解可以注释掉,看查询结果 if (StrUtil.isBlank(dataScopeType)) { - return deduplication(list); + return this.deduplication(list); } return list; } @@ -200,8 +208,7 @@ public class SystemDeptService { * @param id / * @return / */ - - public SystemDeptTb queryDeptById(Long id) { + public SystemDeptTb getDeptById(Long id) { return systemDeptMapper.selectById(id); } @@ -211,22 +218,10 @@ public class SystemDeptService { * @param pid / * @return / */ - public List queryDeptByPid(long pid) { return systemDeptMapper.selectDeptByPid(pid); } - /** - * 根据角色ID查询 - * - * @param id / - * @return / - */ - - public List queryDeptByRoleId(Long id) { - return systemDeptMapper.selectDeptByRoleId(id); - } - /** * 获取部门下所有关联的部门 * @@ -234,7 +229,6 @@ public class SystemDeptService { * @param depts / * @return / */ - public Set queryRelationDeptSet(List deptTbList, Set depts) { for (SystemDeptTb dept : deptTbList) { depts.add(dept); @@ -252,7 +246,6 @@ public class SystemDeptService { * @param deptList 、 * @return 、 */ - public List queryChildDeptIdListByDeptIds(List deptList) { List list = new ArrayList<>(); for (SystemDeptTb systemDeptTb : deptList) { @@ -274,14 +267,13 @@ public class SystemDeptService { * @param deptList / * @return / */ - public List querySuperiorDeptListByPid(SystemDeptTb dept, List deptList) { if (dept.getPid() == null) { deptList.addAll(systemDeptMapper.selectDeptByPidIsNull()); return deptList; } deptList.addAll(systemDeptMapper.selectDeptByPid(dept.getPid())); - return querySuperiorDeptListByPid(queryDeptById(dept.getPid()), deptList); + return querySuperiorDeptListByPid(this.getDeptById(dept.getPid()), deptList); } /** @@ -290,7 +282,6 @@ public class SystemDeptService { * @param deptList / * @return / */ - public KitPageResult buildDeptTree(List deptList) { Set trees = new LinkedHashSet<>(); Set deptSet = new LinkedHashSet<>(); @@ -312,7 +303,7 @@ public class SystemDeptService { } if (isChild) { deptSet.add(dept); - } else if (dept.getPid() != null && !deptNames.contains(queryDeptById(dept.getPid()).getName())) { + } else if (dept.getPid() != null && !deptNames.contains(this.getDeptById(dept.getPid()).getName())) { deptSet.add(dept); } } @@ -330,7 +321,6 @@ public class SystemDeptService { * * @param deptSet / */ - public void verifyBindRelationByIds(Set deptSet) { Set deptIds = deptSet.stream().map(SystemDeptTb::getId).collect(Collectors.toSet()); if (systemUserMapper.countUserByDeptIds(deptIds) > 0) { @@ -346,12 +336,11 @@ public class SystemDeptService { * * @param ids / */ - public Set traverseDeptByIdWithPids(Set ids) { Set depts = new HashSet<>(); for (Long id : ids) { // 根部门 - depts.add(queryDeptById(id)); + depts.add(this.getDeptById(id)); // 子部门 List deptList = queryDeptByPid(id); if (CollectionUtil.isNotEmpty(deptList)) { @@ -362,22 +351,21 @@ public class SystemDeptService { } public List queryDeptSelectDataSource() { - List depts = findEnabledDepts(); + List depts = systemDeptMapper.selectEnabledDepts(); return buildDeptSelectOptions(depts); } private List buildDeptSelectOptions(List depts) { // 获取所有部门并按父子关系组织 - Map deptMap = depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); + 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("-"))); @@ -385,7 +373,6 @@ public class SystemDeptService { dto.setLabel(buildNamePath(dept, deptMap)); options.add(dto); } - // 按部门名称路径排序 options.sort(Comparator.comparing(SystemProductLineVo::getLabel)); return options; @@ -412,14 +399,11 @@ public class SystemDeptService { } } - private List findEnabledDepts() { - return systemDeptMapper.selectList(new LambdaQueryWrapper().eq(SystemDeptTb::getEnabled, 1)); - } - public List queryDeptSelectProDataSource() { - List depts = findEnabledDepts(); + List depts = systemDeptMapper.selectEnabledDepts(); // 获取所有部门并按父子关系组织 - Map deptMap = depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); + Map deptMap = + depts.stream().collect(Collectors.toMap(SystemDeptTb::getId, Function.identity())); List options = new ArrayList<>(); // 构建树形结构 for (SystemDeptTb dept : depts) { 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 c67b78db..0d073a99 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 @@ -13,27 +13,27 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.odboy.base.KitPageResult; import cn.odboy.system.dal.dataobject.SystemDictDetailTb; import cn.odboy.system.dal.model.SystemCreateDictDetailArgs; import cn.odboy.system.dal.model.SystemQueryDictDetailArgs; import cn.odboy.system.dal.mysql.SystemDictDetailMapper; import cn.odboy.util.KitPageUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +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; -import java.util.List; - @Service public class SystemDictDetailService { - @Autowired - private SystemDictDetailMapper systemDictDetailMapper; + @Autowired private SystemDictDetailMapper systemDictDetailMapper; /** * 创建 @@ -64,7 +64,6 @@ public class SystemDictDetailService { * * @param id / */ - @Transactional(rollbackFor = Exception.class) public void removeDictDetailById(Long id) { systemDictDetailMapper.deleteById(id); @@ -77,8 +76,7 @@ public class SystemDictDetailService { * @param page 分页参数 * @return / */ - - public KitPageResult queryDictDetailByArgs(SystemQueryDictDetailArgs args, Page page) { + public KitPageResult queryDictDetailByArgs(SystemQueryDictDetailArgs args, Page page) { return KitPageUtil.toPage(systemDictDetailMapper.selectDictDetailByArgs(args, page)); } @@ -88,10 +86,18 @@ public class SystemDictDetailService { * @param name 字典名称 * @return / */ - public List queryDictDetailByName(String name) { SystemQueryDictDetailArgs args = new SystemQueryDictDetailArgs(); args.setDictName(name); return systemDictDetailMapper.selectDictDetailByArgs(args); } + + @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); + } + } } 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 14aae197..371ddb18 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service; import cn.hutool.core.bean.BeanUtil; @@ -29,27 +28,28 @@ import cn.odboy.system.dal.mysql.SystemDictMapper; import cn.odboy.util.KitFileUtil; import cn.odboy.util.KitPageUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +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; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.*; - @Service public class SystemDictService { - @Autowired - private SystemDictMapper systemDictMapper; - @Autowired - private SystemDictDetailMapper systemDictDetailMapper; + @Autowired private SystemDictMapper systemDictMapper; + @Autowired private SystemDictDetailMapper systemDictDetailMapper; + @Autowired private SystemDictDetailService systemDictDetailService; /** * 创建 * * @param args / */ - @Transactional(rollbackFor = Exception.class) public void saveDict(SystemCreateDictArgs args) { systemDictMapper.insert(BeanUtil.copyProperties(args, SystemDictTb.class)); @@ -60,7 +60,6 @@ public class SystemDictService { * * @param args / */ - @Transactional(rollbackFor = Exception.class) public void modifyDictById(SystemDictTb args) { SystemDictTb dict = systemDictMapper.selectById(args.getId()); @@ -74,13 +73,12 @@ public class SystemDictService { * * @param ids / */ - @Transactional(rollbackFor = Exception.class) public void removeDictByIds(Set ids) { // 删除字典 systemDictMapper.deleteByIds(ids); // 删除字典详情 - systemDictDetailMapper.deleteDictDetailByDictIds(ids); + systemDictDetailService.deleteDictDetailByDictIds(ids); } /** @@ -90,7 +88,6 @@ public class SystemDictService { * @param response / * @throws IOException / */ - public void exportDictExcel(List dicts, HttpServletResponse response) throws IOException { List> list = new ArrayList<>(); for (SystemDictTb dict : dicts) { @@ -127,7 +124,6 @@ public class SystemDictService { * @param page 分页参数 * @return / */ - public KitPageResult queryDictByArgs(SystemQueryDictArgs args, Page page) { return KitPageUtil.toPage(systemDictMapper.selectDictByArgs(args, page)); } @@ -138,7 +134,6 @@ public class SystemDictService { * @param args / * @return / */ - public List queryDictByArgs(SystemQueryDictArgs args) { return systemDictMapper.selectDictByArgs(args); } 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 26235357..24baa3a7 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service; import cn.hutool.core.lang.Dict; @@ -29,32 +28,26 @@ import cn.odboy.system.dal.model.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.beans.factory.annotation.Value; 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; - @Value("${spring.application.title}") - private String applicationTitle; + @Autowired private SystemEmailConfigMapper systemEmailConfigMapper; + @Autowired private KitRedisHelper redisHelper; + @Autowired private AppProperties properties; + @Value("${spring.application.title}") private String applicationTitle; /** * 更新邮件配置 * * @param emailConfig 邮箱配置 */ - @Transactional(rollbackFor = Exception.class) public void modifyEmailConfig(SystemEmailConfigTb emailConfig) throws Exception { SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig(); @@ -71,7 +64,6 @@ public class SystemEmailService { * * @param sendEmailRequest 邮件发送的内容 */ - public void sendEmail(SystemSendEmailArgs sendEmailRequest) { SystemEmailConfigTb systemEmailConfigTb = getLastEmailConfig(); if (systemEmailConfigTb.getId() == null) { @@ -102,8 +94,8 @@ public class SystemEmailService { // 发送 try { int size = sendEmailRequest.getTos().size(); - Mail.create(account).setTos(sendEmailRequest.getTos().toArray(new String[size])).setTitle(sendEmailRequest.getSubject()).setContent(content) - .setHtml(true) + Mail.create(account).setTos(sendEmailRequest.getTos().toArray(new String[size])) + .setTitle(sendEmailRequest.getSubject()).setContent(content).setHtml(true) // 关闭session .setUseGlobalSession(false).send(); } catch (Exception e) { @@ -115,7 +107,6 @@ public class SystemEmailService { /** * 校验邮箱验证码 */ - public void checkEmailCaptcha(SystemCaptchaBizEnum biEnum, String email, String code) { String redisKey = biEnum.getRedisKey() + email; String value = redisHelper.get(redisKey, String.class); @@ -129,7 +120,6 @@ public class SystemEmailService { /** * 发送给邮箱验证码 */ - public void sendCaptcha(SystemCaptchaBizEnum biEnum, String email) { if (biEnum == null) { throw new BadRequestException("biEnum必填"); @@ -146,9 +136,11 @@ public class SystemEmailService { // 存在就再次发送原来的验证码 content = KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", code)); } else { - content = KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", oldCode)); + content = + KitResourceTemplateUtil.render(null, biEnum.getTemplateName(), Dict.create().set("code", oldCode)); } - SystemSendEmailArgs sendEmailRequest = new SystemSendEmailArgs(Collections.singletonList(email), applicationTitle, content); + SystemSendEmailArgs sendEmailRequest = + new SystemSendEmailArgs(Collections.singletonList(email), applicationTitle, content); sendEmail(sendEmailRequest); } 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 4fda7dde..24dfaf0c 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service; import cn.hutool.core.bean.BeanUtil; @@ -27,27 +26,27 @@ import cn.odboy.system.dal.mysql.SystemUserMapper; import cn.odboy.util.KitFileUtil; import cn.odboy.util.KitPageUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +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; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.*; - @Service public class SystemJobService { - @Autowired - private SystemJobMapper systemJobMapper; - @Autowired - private SystemUserMapper systemUserMapper; + @Autowired private SystemJobMapper systemJobMapper; + @Autowired private SystemUserMapper systemUserMapper; /** * 创建 * * @param args / */ - @Transactional(rollbackFor = Exception.class) public void saveJob(SystemCreateJobArgs args) { SystemJobTb job = systemJobMapper.getJobByName(args.getName()); @@ -62,7 +61,6 @@ public class SystemJobService { * * @param args / */ - @Transactional(rollbackFor = Exception.class) public void modifyJobById(SystemJobTb args) { SystemJobTb job = systemJobMapper.selectById(args.getId()); @@ -79,7 +77,6 @@ public class SystemJobService { * * @param ids / */ - @Transactional(rollbackFor = Exception.class) public void removeJobByIds(Set ids) { systemJobMapper.deleteByIds(ids); @@ -92,7 +89,6 @@ public class SystemJobService { * @param response / * @throws IOException */ - public void exportJobExcel(List jobs, HttpServletResponse response) throws IOException { List> list = new ArrayList<>(); for (SystemJobTb job : jobs) { @@ -112,7 +108,6 @@ public class SystemJobService { * @param page 分页参数 * @return */ - public KitPageResult queryJobByArgs(SystemQueryJobArgs args, Page page) { return KitPageUtil.toPage(systemJobMapper.selectJobByArgs(args, page)); } @@ -123,9 +118,8 @@ public class SystemJobService { * @param args / * @return / */ - public List queryJobByArgs(SystemQueryJobArgs args) { - return systemJobMapper.selectJobByArgs(args, KitPageUtil.getCount(systemJobMapper)).getRecords(); + return systemJobMapper.selectJobByArgs(args); } /** @@ -133,7 +127,6 @@ public class SystemJobService { * * @param ids / */ - public void verifyBindRelationByIds(Set ids) { if (systemUserMapper.countUserByJobIds(ids) > 0) { throw new BadRequestException("所选的岗位中存在用户关联, 请解除关联再试!"); 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 cb004a0d..bb883cec 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service; import cn.hutool.core.date.DatePattern; @@ -30,24 +29,24 @@ import cn.odboy.system.dal.mysql.SystemLocalStorageMapper; import cn.odboy.util.KitFileUtil; import cn.odboy.util.KitPageUtil; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +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.io.IOException; -import java.util.*; - @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; /** * 上传 @@ -69,7 +68,8 @@ public class SystemLocalStorageService { } try { String formatSize = KitFileUtil.getSize(size); - String prefixName = StrUtil.isBlank(name) ? KitFileUtil.getPrefix(multipartFile.getOriginalFilename()) : name; + String prefixName = + StrUtil.isBlank(name) ? KitFileUtil.getPrefix(multipartFile.getOriginalFilename()) : name; SystemLocalStorageTb localStorage = new SystemLocalStorageTb(); localStorage.setRealName(file.getName()); localStorage.setName(prefixName); @@ -123,7 +123,8 @@ public class SystemLocalStorageService { * @param response / * @throws IOException / */ - public void exportLocalStorageExcel(List localStorages, HttpServletResponse response) throws IOException { + public void exportLocalStorageExcel(List localStorages, HttpServletResponse response) + throws IOException { List> list = new ArrayList<>(); for (SystemLocalStorageTb localStorage : localStorages) { Map map = new LinkedHashMap<>(); @@ -145,7 +146,8 @@ public class SystemLocalStorageService { * @param page 分页参数 * @return / */ - public KitPageResult queryLocalStorage(SystemQueryStorageArgs criteria, Page page) { + public KitPageResult queryLocalStorage(SystemQueryStorageArgs criteria, + Page page) { return KitPageUtil.toPage(systemLocalStorageMapper.selectLocalStorageByArgs(criteria, page)); } @@ -156,6 +158,6 @@ public class SystemLocalStorageService { * @return / */ public List queryLocalStorage(SystemQueryStorageArgs criteria) { - return systemLocalStorageMapper.selectLocalStorageByArgs(criteria, KitPageUtil.getCount(systemLocalStorageMapper)).getRecords(); + return systemLocalStorageMapper.selectLocalStorageByArgs(criteria); } } 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 4b1a4b99..a4269aa0 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service; import cn.hutool.core.collection.CollUtil; @@ -34,26 +33,30 @@ import cn.odboy.system.dal.mysql.SystemRoleMenuMapper; import cn.odboy.util.KitClassUtil; import cn.odboy.util.KitFileUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import java.io.IOException; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +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.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.lang.reflect.Field; -import java.util.*; -import java.util.stream.Collectors; - @Service public class SystemMenuService { private static final String YES_STR = "是"; private static final String NO_STR = "否"; - @Autowired - private SystemMenuMapper systemMenuMapper; - @Autowired - private SystemRoleMenuMapper systemRoleMenuMapper; - @Autowired - private SystemRoleService systemRoleService; + @Autowired private SystemMenuMapper systemMenuMapper; + @Autowired private SystemRoleMenuMapper systemRoleMenuMapper; + @Autowired private SystemRoleService systemRoleService; + @Autowired private SystemRoleMenuService systemRoleMenuService; /** * 创建 @@ -74,8 +77,8 @@ public class SystemMenuService { args.setPid(null); } if (args.getIFrame()) { - if (!(args.getPath().toLowerCase().startsWith(TransferProtocolConst.PREFIX_HTTP) || args.getPath().toLowerCase() - .startsWith(TransferProtocolConst.PREFIX_HTTPS))) { + if (!(args.getPath().toLowerCase().startsWith(TransferProtocolConst.PREFIX_HTTP) || + args.getPath().toLowerCase().startsWith(TransferProtocolConst.PREFIX_HTTPS))) { throw new BadRequestException(TransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST); } } @@ -91,7 +94,6 @@ public class SystemMenuService { * * @param args / */ - @Transactional(rollbackFor = Exception.class) public void modifyMenuById(SystemMenuTb args) { if (args.getId().equals(args.getPid())) { @@ -99,25 +101,21 @@ public class SystemMenuService { } SystemMenuTb menu = systemMenuMapper.selectById(args.getId()); if (args.getIFrame()) { - if (!(args.getPath().toLowerCase().startsWith(TransferProtocolConst.PREFIX_HTTP) || args.getPath().toLowerCase() - .startsWith(TransferProtocolConst.PREFIX_HTTPS))) { + if (!(args.getPath().toLowerCase().startsWith(TransferProtocolConst.PREFIX_HTTP) || + args.getPath().toLowerCase().startsWith(TransferProtocolConst.PREFIX_HTTPS))) { throw new BadRequestException(TransferProtocolConst.PREFIX_HTTPS_BAD_REQUEST); } } SystemMenuTb menu1 = systemMenuMapper.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 = systemMenuMapper.getMenuByComponentName(args.getComponentName()); if (menu1 != null && !menu1.getId().equals(menu.getId())) { @@ -156,7 +154,8 @@ public class SystemMenuService { menuSet.add(systemMenuMapper.selectById(id)); menuSet = this.queryChildMenu(menuList, menuSet); } - List menuIds = menuSet.stream().map(SystemMenuTb::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); + List menuIds = + menuSet.stream().map(SystemMenuTb::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList()); if (CollUtil.isNotEmpty(menuIds)) { KitSpringBeanHolder.getBean(SystemMenuService.class).removeRoleMenuByMenuIds(menuIds); systemMenuMapper.deleteByIds(menuIds); @@ -168,7 +167,11 @@ public class SystemMenuService { @Transactional(rollbackFor = Exception.class) public void removeRoleMenuByMenuIds(List menuIds) { - systemRoleMenuMapper.delete(new LambdaQueryWrapper().in(SystemRoleMenuTb::getMenuId, menuIds)); + if (CollUtil.isNotEmpty(menuIds)) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(SystemRoleMenuTb::getMenuId, menuIds); + systemRoleMenuMapper.delete(wrapper); + } } /** @@ -178,7 +181,6 @@ public class SystemMenuService { * @param response / * @throws IOException / */ - public void exportMenuExcel(List menus, HttpServletResponse response) throws IOException { List> list = new ArrayList<>(); for (SystemMenuTb menu : menus) { @@ -198,7 +200,7 @@ public class SystemMenuService { @Transactional(rollbackFor = Exception.class) public void updateMenuSubCnt(Long menuId) { if (menuId != null) { - int count = systemMenuMapper.countMenuByPid(menuId); + long count = systemMenuMapper.countMenuByPid(menuId); systemMenuMapper.updateMenuSubCntByMenuId(count, menuId); } } @@ -211,7 +213,6 @@ public class SystemMenuService { * @return / * @throws Exception / */ - public List queryAllMenu(SystemQueryMenuArgs criteria, Boolean isQuery) throws Exception { if (Boolean.TRUE.equals(isQuery)) { criteria.setPidIsNull(true); @@ -239,11 +240,10 @@ public class SystemMenuService { * @param currentUserId / * @return / */ - public List queryMenuListByUserId(Long currentUserId) { List roles = systemRoleService.queryRoleByUsersId(currentUserId); Set roleIds = roles.stream().map(SystemRoleTb::getId).collect(Collectors.toSet()); - return new ArrayList<>(systemMenuMapper.selectMenuByRoleIdsAndType(roleIds, 2)); + return new ArrayList<>(systemRoleMenuService.queryMenuByRoleIdsAndType(roleIds, 2)); } /** @@ -253,11 +253,10 @@ public class SystemMenuService { * @param menuSet / * @return / */ - public Set queryChildMenu(List menuList, Set menuSet) { for (SystemMenuTb menu : menuList) { menuSet.add(menu); - List menus = systemMenuMapper.selectMenuByPidOrderByMenuSort(menu.getId()); + List menus = systemMenuMapper.selectMenuByPid(menu.getId()); if (CollUtil.isNotEmpty(menus)) { queryChildMenu(menus, menuSet); } @@ -271,13 +270,12 @@ public class SystemMenuService { * @param pid / * @return / */ - public List queryMenuByPid(Long pid) { List menus; if (pid != null && !pid.equals(0L)) { - menus = systemMenuMapper.selectMenuByPidOrderByMenuSort(pid); + menus = systemMenuMapper.selectMenuByPid(pid); } else { - menus = systemMenuMapper.selectMenuByPidIsNullOrderByMenuSort(); + menus = systemMenuMapper.selectMenuByPidIsNull(); } return menus; } @@ -289,13 +287,12 @@ public class SystemMenuService { * @param menus / * @return / */ - public List querySuperiorMenuList(SystemMenuTb menu, List menus) { if (menu.getPid() == null) { - menus.addAll(systemMenuMapper.selectMenuByPidIsNullOrderByMenuSort()); + menus.addAll(systemMenuMapper.selectMenuByPidIsNull()); return menus; } - menus.addAll(systemMenuMapper.selectMenuByPidOrderByMenuSort(menu.getPid())); + menus.addAll(systemMenuMapper.selectMenuByPid(menu.getPid())); return querySuperiorMenuList(systemMenuMapper.selectById(menu.getPid()), menus); } @@ -305,7 +302,6 @@ public class SystemMenuService { * @param menus 原始数据 * @return / */ - public List buildMenuTree(List menus) { List trees = new ArrayList<>(); Set ids = new HashSet<>(); @@ -335,14 +331,14 @@ public class SystemMenuService { * @param menus / * @return / */ - public List buildMenuVo(List menus) { List list = new LinkedList<>(); menus.forEach(menu -> { if (menu != null) { List menuList = menu.getChildren(); SystemMenuVo menuVo = new SystemMenuVo(); - menuVo.setName(ObjectUtil.isNotEmpty(menu.getComponentName()) ? menu.getComponentName() : menu.getTitle()); + menuVo.setName( + ObjectUtil.isNotEmpty(menu.getComponentName()) ? menu.getComponentName() : menu.getTitle()); // 一级目录需要加斜杠, 不然会报警告 menuVo.setPath(menu.getPid() == null ? "/" + menu.getPath() : menu.getPath()); menuVo.setHidden(menu.getHidden()); 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 d0b39071..46059879 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service; import cn.hutool.core.date.BetweenFormatter.Level; @@ -21,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; @@ -34,10 +40,6 @@ 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.*; - @Slf4j @Service public class SystemMonitorService { @@ -138,7 +140,8 @@ public class SystemMonitorService { 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)); + memoryInfo.put("usageRate", + df.format((memory.getTotal() - memory.getAvailable()) / (double)memory.getTotal() * 100)); return memoryInfo; } @@ -167,14 +170,22 @@ public class SystemMonitorService { 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 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)); 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 03bdc859..b34b3923 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service; import cn.odboy.base.KitPageResult; @@ -22,11 +21,10 @@ import cn.odboy.system.dal.model.SystemOssStorageVo; import cn.odboy.system.dal.model.SystemQueryStorageArgs; 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.io.IOException; import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.web.multipart.MultipartFile; /** *

@@ -38,14 +36,8 @@ import java.util.List; */ public interface SystemOssStorageService extends IService { KitPageResult queryOssStorage(SystemQueryStorageArgs criteria, Page page); - List queryOssStorage(SystemQueryStorageArgs criteria); - void exportOssStorageExcel(List list, HttpServletResponse response) throws IOException; - String uploadFile(MultipartFile file); - void removeFileByIds(Long[] ids); - - SystemOssStorageTb getByMd5(String md5); } 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 d3034866..6ee37158 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 @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.StrUtil; import cn.odboy.base.KitPageResult; @@ -31,33 +31,33 @@ import cn.odboy.system.dal.mysql.SystemQuartzLogMapper; import cn.odboy.system.framework.quartz.QuartzManage; import cn.odboy.util.KitFileUtil; import cn.odboy.util.KitPageUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +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; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.*; - @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; /** * 创建 * * @param args / */ - @Transactional(rollbackFor = Exception.class) public void createJob(SystemQuartzJobTb args) { if (!CronExpression.isValidExpression(args.getCronExpression())) { @@ -72,7 +72,6 @@ public class SystemQuartzJobService { * * @param args / */ - @Transactional(rollbackFor = Exception.class) public void modifyQuartzJobResumeCron(SystemUpdateQuartzJobArgs args) { if (!CronExpression.isValidExpression(args.getCronExpression())) { @@ -94,7 +93,6 @@ public class SystemQuartzJobService { * * @param quartzJob / */ - @Transactional(rollbackFor = Exception.class) public void switchQuartzJobStatus(SystemQuartzJobTb quartzJob) { // 置换暂停状态 @@ -113,7 +111,6 @@ public class SystemQuartzJobService { * * @param quartzJob / */ - public void startQuartzJob(SystemQuartzJobTb quartzJob) { quartzManage.runJobNow(quartzJob); } @@ -123,7 +120,6 @@ public class SystemQuartzJobService { * * @param ids / */ - @Transactional(rollbackFor = Exception.class) public void removeJobByIds(Set ids) { for (Long id : ids) { @@ -139,7 +135,6 @@ public class SystemQuartzJobService { * @param tasks / * @throws InterruptedException / */ - @Transactional(rollbackFor = Exception.class) public void startSubQuartJob(String[] tasks) throws InterruptedException { for (String id : tasks) { @@ -178,8 +173,8 @@ public class SystemQuartzJobService { * @param response / * @throws IOException / */ - - public void exportQuartzJobExcel(List quartzJobs, HttpServletResponse response) throws IOException { + public void exportQuartzJobExcel(List quartzJobs, HttpServletResponse response) + throws IOException { List> list = new ArrayList<>(); for (SystemQuartzJobTb quartzJob : quartzJobs) { Map map = new LinkedHashMap<>(); @@ -203,8 +198,8 @@ public class SystemQuartzJobService { * @param response / * @throws IOException / */ - - public void exportQuartzLogExcel(List queryAllLog, HttpServletResponse response) throws IOException { + public void exportQuartzLogExcel(List queryAllLog, HttpServletResponse response) + throws IOException { List> list = new ArrayList<>(); for (SystemQuartzLogTb quartzLog : queryAllLog) { Map map = new LinkedHashMap<>(); @@ -229,9 +224,38 @@ public class SystemQuartzJobService { * @param page 分页参数 * @return / */ + public KitPageResult queryQuartzJobByArgs(SystemQueryQuartzJobArgs criteria, + Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQuartzJobQueryParams(criteria, wrapper); + return KitPageUtil.toPage(systemQuartzJobMapper.selectPage(page, wrapper)); + } - public KitPageResult queryQuartzJobByArgs(SystemQueryQuartzJobArgs criteria, Page page) { - return KitPageUtil.toPage(systemQuartzJobMapper.selectQuartzJobByArgs(criteria, page)); + private void injectQuartzJobQueryParams(SystemQueryQuartzJobArgs criteria, + LambdaQueryWrapper wrapper) { + if (criteria != null) { + wrapper.like(StrUtil.isNotBlank(criteria.getJobName()), SystemQuartzJobTb::getJobName, + criteria.getJobName()); + if (CollUtil.isNotEmpty(criteria.getCreateTime()) && criteria.getCreateTime().size() >= 2) { + wrapper.between(SystemQuartzJobTb::getUpdateTime, criteria.getCreateTime().get(0), + criteria.getCreateTime().get(1)); + } + } + wrapper.orderByDesc(SystemQuartzJobTb::getId); + } + + private void injectQuartzLogQueryParams(SystemQueryQuartzJobArgs criteria, + LambdaQueryWrapper wrapper) { + if (criteria != null) { + wrapper.like(StrUtil.isNotBlank(criteria.getJobName()), SystemQuartzLogTb::getJobName, + criteria.getJobName()); + wrapper.eq(criteria.getIsSuccess() != null, SystemQuartzLogTb::getIsSuccess, criteria.getIsSuccess()); + if (CollUtil.isNotEmpty(criteria.getCreateTime()) && criteria.getCreateTime().size() >= 2) { + wrapper.between(SystemQuartzLogTb::getCreateTime, criteria.getCreateTime().get(0), + criteria.getCreateTime().get(1)); + } + } + wrapper.orderByDesc(SystemQuartzLogTb::getId); } /** @@ -241,9 +265,11 @@ public class SystemQuartzJobService { * @param page 分页参数 * @return / */ - - public KitPageResult queryQuartzLogByArgs(SystemQueryQuartzJobArgs criteria, Page page) { - return KitPageUtil.toPage(systemQuartzLogMapper.selectQuartzLogByArgs(criteria, page)); + public KitPageResult queryQuartzLogByArgs(SystemQueryQuartzJobArgs criteria, + Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQuartzLogQueryParams(criteria, wrapper); + return KitPageUtil.toPage(systemQuartzLogMapper.selectPage(page, wrapper)); } /** @@ -252,9 +278,10 @@ public class SystemQuartzJobService { * @param criteria 条件 * @return / */ - public List queryQuartzJobByArgs(SystemQueryQuartzJobArgs criteria) { - return systemQuartzJobMapper.selectQuartzJobByArgs(criteria, KitPageUtil.getCount(systemQuartzJobMapper)).getRecords(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQuartzJobQueryParams(criteria, wrapper); + return systemQuartzJobMapper.selectList(wrapper); } /** @@ -263,12 +290,19 @@ public class SystemQuartzJobService { * @param criteria 条件 * @return / */ - public List queryQuartzLogByArgs(SystemQueryQuartzJobArgs criteria) { - return systemQuartzLogMapper.selectQuartzLogByArgs(criteria, KitPageUtil.getCount(systemQuartzLogMapper)).getRecords(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + this.injectQuartzLogQueryParams(criteria, wrapper); + return systemQuartzLogMapper.selectList(wrapper); } public SystemQuartzJobTb getQuartzJobById(Long id) { return systemQuartzJobMapper.selectById(id); } + + public List queryEnableQuartzJob() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemQuartzJobTb::getIsPause, 0); + return systemQuartzJobMapper.selectList(wrapper); + } } 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 new file mode 100644 index 00000000..e5e25f39 --- /dev/null +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleDeptService.java @@ -0,0 +1,76 @@ +/* + * Copyright 2021-2025 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.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; +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 SystemRoleDeptService { + @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 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 roleId / + * @return / + */ + public List selectDeptByRoleId(Long roleId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemRoleDeptTb::getRoleId, roleId); + List systemRoleDeptTbs = systemRoleDeptMapper.selectList(wrapper); + if (systemRoleDeptTbs.isEmpty()) { + return new ArrayList<>(); + } + List deptIds = systemRoleDeptTbs.stream().map(SystemRoleDeptTb::getDeptId).collect(Collectors.toList()); + return systemDeptMapper.selectByIds(deptIds); + } +} 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 new file mode 100644 index 00000000..dbfd4da9 --- /dev/null +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemRoleMenuService.java @@ -0,0 +1,87 @@ +/* + * Copyright 2021-2025 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.system.service; + +import cn.hutool.core.collection.CollUtil; +import cn.odboy.system.dal.dataobject.SystemMenuTb; +import cn.odboy.system.dal.dataobject.SystemRoleMenuTb; +import cn.odboy.system.dal.mysql.SystemMenuMapper; +import cn.odboy.system.dal.mysql.SystemRoleMenuMapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +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; + + @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 (SystemMenuTb 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); + } + } + + public LinkedHashSet queryMenuByRoleIdsAndType(Set roleIds, int menuType) { + 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); + return new LinkedHashSet<>(systemMenuMapper.selectList(menuWrapper)); + } +} 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 450c933f..9b565c14 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 @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service; import cn.hutool.core.bean.BeanUtil; @@ -28,61 +27,65 @@ import cn.odboy.system.dal.dataobject.SystemUserTb; import cn.odboy.system.dal.model.SystemCreateRoleArgs; import cn.odboy.system.dal.model.SystemQueryRoleArgs; import cn.odboy.system.dal.model.SystemRoleCodeVo; -import cn.odboy.system.dal.mysql.SystemRoleDeptMapper; import cn.odboy.system.dal.mysql.SystemRoleMapper; -import cn.odboy.system.dal.mysql.SystemRoleMenuMapper; import cn.odboy.system.dal.mysql.SystemUserMapper; import cn.odboy.util.KitFileUtil; import cn.odboy.util.KitPageUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +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; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.*; -import java.util.stream.Collectors; - @Service public class SystemRoleService { - @Autowired - private SystemRoleMapper systemRoleMapper; - @Autowired - private SystemRoleDeptMapper systemRoleDeptMapper; - @Autowired - private SystemRoleMenuMapper systemRoleMenuMapper; - @Autowired - private SystemUserMapper systemUserMapper; + @Autowired private SystemRoleMapper systemRoleMapper; + @Autowired private SystemRoleMenuService systemRoleMenuService; + @Autowired private SystemUserMapper systemUserMapper; + @Autowired private SystemRoleDeptService systemRoleDeptService; /** * 创建 * * @param args / */ - @Transactional(rollbackFor = Exception.class) public void saveRole(SystemCreateRoleArgs args) { - if (systemRoleMapper.getRoleByName(args.getName()) != null) { + if (this.getRoleByName(args.getName()) != null) { throw new BadRequestException("角色名称已存在"); } systemRoleMapper.insert(BeanUtil.copyProperties(args, SystemRoleTb.class)); // 判断是否有部门数据, 若有, 则需创建关联 if (CollectionUtil.isNotEmpty(args.getDepts())) { - systemRoleDeptMapper.batchInsertRoleDept(args.getDepts(), args.getId()); + systemRoleDeptService.batchInsertRoleDept(args.getDepts(), args.getId()); } } + private SystemRoleTb getRoleByName(String name) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(SystemRoleTb::getName, name); + return systemRoleMapper.selectOne(wrapper); + } + /** * 修改 * * @param args / */ - @Transactional(rollbackFor = Exception.class) public void modifyRoleById(SystemRoleTb args) { SystemRoleTb role = systemRoleMapper.selectById(args.getId()); - SystemRoleTb role1 = systemRoleMapper.getRoleByName(args.getName()); + SystemRoleTb role1 = this.getRoleByName(args.getName()); if (role1 != null && !role1.getId().equals(role.getId())) { throw new BadRequestException("角色名称已存在"); } @@ -94,10 +97,10 @@ public class SystemRoleService { // 更新 systemRoleMapper.insertOrUpdate(role); // 删除关联部门数据 - systemRoleDeptMapper.batchDeleteRoleDept(Collections.singleton(args.getId())); + systemRoleDeptService.batchDeleteRoleDept(Collections.singleton(args.getId())); // 判断是否有部门数据, 若有, 则需更新关联 if (CollectionUtil.isNotEmpty(args.getDepts())) { - systemRoleDeptMapper.batchInsertRoleDept(args.getDepts(), args.getId()); + systemRoleDeptService.batchInsertRoleDept(args.getDepts(), args.getId()); } } @@ -106,13 +109,12 @@ public class SystemRoleService { * * @param role / */ - public void modifyBindMenuById(SystemRoleTb role) { // 更新菜单 - systemRoleMenuMapper.deleteRoleMenuByRoleId(role.getId()); + systemRoleMenuService.deleteRoleMenuByRoleId(role.getId()); // 判断是否为空 if (CollUtil.isNotEmpty(role.getMenus())) { - systemRoleMenuMapper.batchInsertRoleMenu(role.getMenus(), role.getId()); + systemRoleMenuService.batchInsertRoleMenu(role.getMenus(), role.getId()); } } @@ -121,13 +123,12 @@ public class SystemRoleService { * * @param ids / */ - @Transactional(rollbackFor = Exception.class) public void removeRoleByIds(Set ids) { systemRoleMapper.deleteByIds(ids); // 删除角色部门关联数据、角色菜单关联数据 - systemRoleDeptMapper.batchDeleteRoleDept(ids); - systemRoleMenuMapper.batchDeleteRoleMenu(ids); + systemRoleDeptService.batchDeleteRoleDept(ids); + systemRoleMenuService.batchDeleteRoleMenu(ids); } /** @@ -137,7 +138,6 @@ public class SystemRoleService { * @param response / * @throws IOException */ - public void exportRoleExcel(List roles, HttpServletResponse response) throws IOException { List> list = new ArrayList<>(); for (SystemRoleTb role : roles) { @@ -156,9 +156,14 @@ public class SystemRoleService { * * @return */ - public List queryAllRole() { - return systemRoleMapper.selectAllRole(); + return this.selectAllRole(); + } + + private List selectAllRole() { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.orderByAsc(SystemRoleTb::getLevel); + return systemRoleMapper.selectList(wrapper); } /** @@ -167,7 +172,6 @@ public class SystemRoleService { * @param criteria 条件 * @return */ - public List queryRoleByArgs(SystemQueryRoleArgs criteria) { return systemRoleMapper.selectRoleByArgs(criteria); } @@ -179,7 +183,6 @@ public class SystemRoleService { * @param page 分页参数 * @return */ - public KitPageResult queryRoleByArgs(SystemQueryRoleArgs criteria, Page page) { criteria.setOffset(page.offset()); List roles = systemRoleMapper.selectRoleByArgs(criteria); @@ -193,7 +196,6 @@ public class SystemRoleService { * @param userId 用户ID * @return / */ - public List queryRoleByUsersId(Long userId) { return systemRoleMapper.selectRoleByUserId(userId); } @@ -204,7 +206,6 @@ public class SystemRoleService { * @param roles / * @return / */ - public Integer getDeptLevelByRoles(Set roles) { if (CollUtil.isEmpty(roles)) { return Integer.MAX_VALUE; @@ -222,7 +223,6 @@ public class SystemRoleService { * @param user 用户信息 * @return 权限信息 */ - public List buildUserRolePermissions(SystemUserTb user) { Set permissions = new HashSet<>(); // 如果是管理员直接返回 @@ -231,8 +231,8 @@ public class SystemRoleService { return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); } List roles = systemRoleMapper.selectRoleByUserId(user.getId()); - permissions = - roles.stream().flatMap(role -> role.getMenus().stream()).map(SystemMenuTb::getPermission).filter(StrUtil::isNotBlank).collect(Collectors.toSet()); + permissions = roles.stream().flatMap(role -> role.getMenus().stream()).map(SystemMenuTb::getPermission) + .filter(StrUtil::isNotBlank).collect(Collectors.toSet()); return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList()); } @@ -241,7 +241,6 @@ public class SystemRoleService { * * @param ids / */ - public void verifyBindRelationByIds(Set ids) { if (systemUserMapper.countUserByRoleIds(ids) > 0) { throw new BadRequestException("所选角色存在用户关联, 请解除关联再试!"); 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 new file mode 100644 index 00000000..56e9f24c --- /dev/null +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserJobService.java @@ -0,0 +1,56 @@ +/* + * Copyright 2021-2025 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.system.service; + +import cn.hutool.core.collection.CollUtil; +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 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; + + @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); + } + } +} 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 new file mode 100644 index 00000000..a2e6e710 --- /dev/null +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/SystemUserRoleService.java @@ -0,0 +1,56 @@ +/* + * Copyright 2021-2025 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.system.service; + +import cn.hutool.core.collection.CollUtil; +import cn.odboy.system.dal.dataobject.SystemRoleTb; +import cn.odboy.system.dal.dataobject.SystemUserRoleTb; +import cn.odboy.system.dal.mysql.SystemUserRoleMapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +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 SystemUserRoleService { + @Autowired private SystemUserRoleMapper systemUserRoleMapper; + + @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); + } + } +} 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 1a002bcc..e0643c60 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 @@ -13,20 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service; import cn.hutool.core.util.StrUtil; +import cn.odboy.base.KitPageArgs; import cn.odboy.base.KitPageResult; +import cn.odboy.base.KitSelectOptionVo; import cn.odboy.framework.exception.BadRequestException; import cn.odboy.framework.server.core.KitFileLocalUploadHelper; import cn.odboy.system.dal.dataobject.SystemJobTb; import cn.odboy.system.dal.dataobject.SystemRoleTb; import cn.odboy.system.dal.dataobject.SystemUserTb; import cn.odboy.system.dal.model.SystemQueryUserArgs; -import cn.odboy.system.dal.mysql.SystemUserJobMapper; import cn.odboy.system.dal.mysql.SystemUserMapper; -import cn.odboy.system.dal.mysql.SystemUserRoleMapper; import cn.odboy.system.dal.redis.SystemUserInfoDAO; import cn.odboy.system.dal.redis.SystemUserOnlineInfoDAO; import cn.odboy.system.framework.permission.core.CsSecurityHelper; @@ -35,38 +34,37 @@ import cn.odboy.util.KitPageUtil; 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.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +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.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.io.IOException; -import java.util.*; -import java.util.stream.Collectors; - @Service public class SystemUserService { - @Autowired - private SystemUserMapper systemUserMapper; - @Autowired - private SystemUserJobMapper systemUserJobMapper; - @Autowired - private SystemUserRoleMapper systemUserRoleMapper; - @Autowired - private SystemUserInfoDAO systemUserInfoDAO; - @Autowired - private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; - @Autowired - private KitFileLocalUploadHelper fileUploadPathHelper; + @Autowired private SystemUserMapper systemUserMapper; + @Autowired private SystemUserJobService systemUserJobService; + @Autowired private SystemUserRoleService systemUserRoleService; + @Autowired private SystemUserInfoDAO systemUserInfoDAO; + @Autowired private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO; + @Autowired private KitFileLocalUploadHelper fileUploadPathHelper; /** * 新增用户 * * @param args / */ - @Transactional(rollbackFor = Exception.class) public void saveUser(SystemUserTb args) { args.setDeptId(args.getDept().getId()); @@ -81,9 +79,9 @@ public class SystemUserService { } systemUserMapper.insert(args); // 保存用户岗位 - systemUserJobMapper.batchInsertUserJob(args.getJobs(), args.getId()); + systemUserJobService.batchInsertUserJob(args.getJobs(), args.getId()); // 保存用户角色 - systemUserRoleMapper.batchInsertUserRole(args.getRoles(), args.getId()); + systemUserRoleService.batchInsertUserRole(args.getRoles(), args.getId()); } /** @@ -92,7 +90,6 @@ public class SystemUserService { * @param args / * @throws Exception / */ - @Transactional(rollbackFor = Exception.class) public void modifyUserById(SystemUserTb args) { SystemUserTb user = systemUserMapper.selectById(args.getId()); @@ -126,11 +123,11 @@ public class SystemUserService { // 清除用户登录缓存 systemUserInfoDAO.deleteUserLoginInfoByUserName(user.getUsername()); // 更新用户岗位 - systemUserJobMapper.batchDeleteUserJob(Collections.singleton(args.getId())); - systemUserJobMapper.batchInsertUserJob(args.getJobs(), args.getId()); + systemUserJobService.batchDeleteUserJob(Collections.singleton(args.getId())); + systemUserJobService.batchInsertUserJob(args.getJobs(), args.getId()); // 更新用户角色 - systemUserRoleMapper.batchDeleteUserRole(Collections.singleton(args.getId())); - systemUserRoleMapper.batchInsertUserRole(args.getRoles(), args.getId()); + systemUserRoleService.batchDeleteUserRole(Collections.singleton(args.getId())); + systemUserRoleService.batchInsertUserRole(args.getRoles(), args.getId()); } /** @@ -138,7 +135,6 @@ public class SystemUserService { * * @param args / */ - @Transactional(rollbackFor = Exception.class) public void modifyUserCenterInfoById(SystemUserTb args) { SystemUserTb user = systemUserMapper.selectById(args.getId()); @@ -158,7 +154,6 @@ public class SystemUserService { * * @param ids / */ - @Transactional(rollbackFor = Exception.class) public void removeUserByIds(Set ids) { for (Long id : ids) { @@ -168,9 +163,9 @@ public class SystemUserService { } systemUserMapper.deleteByIds(ids); // 删除用户岗位 - systemUserJobMapper.batchDeleteUserJob(ids); + systemUserJobService.batchDeleteUserJob(ids); // 删除用户角色 - systemUserRoleMapper.batchDeleteUserRole(ids); + systemUserRoleService.batchDeleteUserRole(ids); } /** @@ -179,7 +174,6 @@ public class SystemUserService { * @param username 用户名 * @param encryptPassword 密码 */ - @Transactional(rollbackFor = Exception.class) public void modifyUserPasswordByUsername(String username, String encryptPassword) { systemUserMapper.updateUserPasswordByUsername(username, encryptPassword); @@ -192,7 +186,6 @@ public class SystemUserService { * @param ids 用户id * @param password 密码 */ - @Transactional(rollbackFor = Exception.class) public void resetUserPasswordByIds(Set ids, String password) { List users = systemUserMapper.selectByIds(ids); @@ -204,7 +197,7 @@ public class SystemUserService { systemUserOnlineInfoDAO.kickOutByUsername(user.getUsername()); }); // 重置密码 - systemUserMapper.batchUpdatePassword(password, ids); + systemUserMapper.updateUserPasswordByUserIds(password, ids); } /** @@ -213,7 +206,6 @@ public class SystemUserService { * @param multipartFile 文件 * @return / */ - @Transactional(rollbackFor = Exception.class) public Map modifyUserAvatar(MultipartFile multipartFile) { SystemUserTb user = systemUserMapper.getUserByUsername(CsSecurityHelper.getCurrentUsername()); @@ -249,7 +241,6 @@ public class SystemUserService { * @param username 用户名 * @param email 邮箱 */ - @Transactional(rollbackFor = Exception.class) public void modifyUserEmailByUsername(String username, String email) { systemUserMapper.updateUserEmailByUsername(username, email); @@ -263,7 +254,6 @@ public class SystemUserService { * @param response / * @throws IOException / */ - public void exportUserExcel(List users, HttpServletResponse response) throws IOException { List> list = new ArrayList<>(); for (SystemUserTb user : users) { @@ -290,7 +280,6 @@ public class SystemUserService { * @param page 分页参数 * @return / */ - public KitPageResult queryUserByArgs(SystemQueryUserArgs criteria, Page page) { IPage users = systemUserMapper.selectUserByArgs(criteria, page); return KitPageUtil.toPage(users); @@ -302,7 +291,6 @@ public class SystemUserService { * @param criteria 条件 * @return / */ - public List queryUserByArgs(SystemQueryUserArgs criteria) { return systemUserMapper.selectUserByArgs(criteria); } @@ -313,7 +301,6 @@ public class SystemUserService { * @param id ID * @return / */ - public SystemUserTb getUserById(long id) { return systemUserMapper.selectById(id); } @@ -328,18 +315,26 @@ public class SystemUserService { return systemUserMapper.getUserByUsername(username); } - /** - * 分页模糊查询 - * - * @param wrapper - * @param page - * @return - */ - public IPage queryUserByBlurry(LambdaQueryWrapper wrapper, Page page) { - return systemUserMapper.selectPage(page, wrapper); - } - - public List queryUserByUserIds(List userIds) { - return systemUserMapper.selectByIds(userIds); + public List queryUserMetadataOptions(KitPageArgs args) { + SystemQueryUserArgs criteria = args.getArgs(); + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.select(SystemUserTb::getId, SystemUserTb::getDeptId, SystemUserTb::getEmail, SystemUserTb::getPhone); + wrapper.and(c -> { + c.eq(SystemUserTb::getPhone, criteria.getBlurry()); + c.or(); + c.eq(SystemUserTb::getEmail, criteria.getBlurry()); + c.or(); + c.like(SystemUserTb::getUsername, criteria.getBlurry()); + c.or(); + c.like(SystemUserTb::getNickName, criteria.getBlurry()); + }); + return systemUserMapper.selectPage(new Page<>(criteria.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()); } } diff --git a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemOssStorageServiceImpl.java b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemOssStorageServiceImpl.java index 2b449310..584e37dd 100644 --- a/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemOssStorageServiceImpl.java +++ b/cutejava/cutejava-module-system/src/main/java/cn/odboy/system/service/impl/SystemOssStorageServiceImpl.java @@ -13,10 +13,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.system.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import cn.odboy.base.KitPageResult; import cn.odboy.framework.exception.BadRequestException; @@ -32,21 +32,21 @@ import cn.odboy.system.service.SystemOssStorageService; import cn.odboy.util.KitDateUtil; import cn.odboy.util.KitFileUtil; import cn.odboy.util.KitPageUtil; +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 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.io.IOException; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +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; /** *

@@ -57,17 +57,17 @@ import java.util.Map; * @since 2025-07-15 */ @Service -public class SystemOssStorageServiceImpl extends ServiceImpl implements SystemOssStorageService { - @Autowired - private MinioRepository minioRepository; - @Autowired - private AppProperties properties; - @Autowired - private KitFileLocalUploadHelper fileLocalUploadHelper; +public class SystemOssStorageServiceImpl extends ServiceImpl + implements SystemOssStorageService { + @Autowired private MinioRepository minioRepository; + @Autowired private AppProperties properties; + @Autowired private KitFileLocalUploadHelper fileLocalUploadHelper; + @Autowired private SystemOssStorageMapper systemOssStorageMapper; @Override - public KitPageResult queryOssStorage(SystemQueryStorageArgs criteria, Page page) { - IPage ossStorageTbs = baseMapper.selectOssStorageByArgs(criteria, page); + public KitPageResult queryOssStorage(SystemQueryStorageArgs criteria, + Page page) { + IPage ossStorageTbs = this.selectOssStorageByArgs(criteria, page); IPage convert = ossStorageTbs.convert(c -> { SystemOssStorageVo storageVo = BeanUtil.copyProperties(c, SystemOssStorageVo.class); storageVo.setFileSizeDesc(KitFileUtil.getSize(storageVo.getFileSize())); @@ -76,6 +76,24 @@ public class SystemOssStorageServiceImpl extends ServiceImpl selectOssStorageByArgs(SystemQueryStorageArgs criteria, + Page page) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if (criteria != null) { + wrapper.and(StrUtil.isNotBlank(criteria.getBlurry()), + c -> c.like(SystemOssStorageTb::getFileName, criteria.getBlurry()).or() + .like(SystemOssStorageTb::getFilePrefix, criteria.getBlurry()).or() + .like(SystemOssStorageTb::getFileMime, criteria.getBlurry()).or() + .like(SystemOssStorageTb::getFileMd5, criteria.getBlurry())); + if (CollUtil.isNotEmpty(criteria.getCreateTime()) && criteria.getCreateTime().size() >= 2) { + wrapper.between(SystemOssStorageTb::getUpdateTime, criteria.getCreateTime().get(0), + criteria.getCreateTime().get(1)); + } + } + wrapper.orderByAsc(SystemOssStorageTb::getId); + return systemOssStorageMapper.selectPage(page, wrapper); + } + @Override public List queryOssStorage(SystemQueryStorageArgs criteria) { // 防止刷数据 @@ -84,7 +102,8 @@ public class SystemOssStorageServiceImpl extends ServiceImpl ossStorages, HttpServletResponse response) throws IOException { + public void exportOssStorageExcel(List ossStorages, HttpServletResponse response) + throws IOException { List> list = new ArrayList<>(); for (SystemOssStorageVo ossStorage : ossStorages) { Map map = new LinkedHashMap<>(); @@ -121,7 +140,7 @@ public class SystemOssStorageServiceImpl extends ServiceImpl readSqlList(File sqlFile) throws Exception { List sqlList = Lists.newArrayList(); StringBuilder sb = new StringBuilder(); - try (BufferedReader reader = new BufferedReader(new InputStreamReader(Files.newInputStream(sqlFile.toPath()), StandardCharsets.UTF_8))) { + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(Files.newInputStream(sqlFile.toPath()), StandardCharsets.UTF_8))) { String tmp; while ((tmp = reader.readLine()) != null) { log.info("line:{}", tmp); diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemDeptMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemDeptMapper.xml deleted file mode 100644 index 80771426..00000000 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemDeptMapper.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - update system_dept - set sub_count = #{count} - where dept_id = #{id} - - \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemDictDetailMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemDictDetailMapper.xml index ffd1d405..4c7a3a72 100644 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemDictDetailMapper.xml +++ b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemDictDetailMapper.xml @@ -30,11 +30,4 @@ order by dd.dict_sort - - delete from system_dict_detail - where dict_id in - - #{item} - - \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemDictMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemDictMapper.xml deleted file mode 100644 index d14e6902..00000000 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemDictMapper.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemJobMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemJobMapper.xml deleted file mode 100644 index 570fe3b5..00000000 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemJobMapper.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemLocalStorageMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemLocalStorageMapper.xml deleted file mode 100644 index 1113a607..00000000 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemLocalStorageMapper.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemMenuMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemMenuMapper.xml deleted file mode 100644 index 2cf9617c..00000000 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemMenuMapper.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - update system_menu - set sub_count = #{count} - where menu_id = #{menuId} - - \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemOssStorageMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemOssStorageMapper.xml deleted file mode 100644 index 32ab4eae..00000000 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemOssStorageMapper.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemQuartzJobMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemQuartzJobMapper.xml deleted file mode 100644 index 7ff10a6b..00000000 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemQuartzJobMapper.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemQuartzLogMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemQuartzLogMapper.xml deleted file mode 100644 index 71b70a52..00000000 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemQuartzLogMapper.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleDeptMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleDeptMapper.xml deleted file mode 100644 index 91223480..00000000 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleDeptMapper.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - insert into system_roles_depts (role_id, dept_id) - values - - #{roleId}, #{item.id} - - - - - delete from system_roles_depts - where role_id in - - #{id} - - - \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleMapper.xml index 7ba162f0..f4f89959 100644 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleMapper.xml +++ b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleMapper.xml @@ -21,11 +21,6 @@ - - - SELECT role.role_id as id FROM system_role role, - system_roles_menus rm + system_roles_menus rm WHERE role.role_id = rm.role_id - AND rm.menu_id = #{menuId} + AND rm.menu_id = #{menuId} \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleMenuMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleMenuMapper.xml deleted file mode 100644 index 03d10c49..00000000 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemRoleMenuMapper.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - insert into system_roles_menus (role_id, menu_id) - values - - #{roleId}, #{item.id} - - - - delete from system_roles_menus - where role_id in - - #{id} - - - - delete - from system_roles_menus - where role_id = #{roleId} - - \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserJobMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserJobMapper.xml deleted file mode 100644 index 90b01767..00000000 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserJobMapper.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - insert into system_users_jobs (user_id, job_id) - values - - #{userId}, #{item.id} - - - - delete from system_users_jobs - where user_id in - - #{id} - - - \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserMapper.xml index 58995054..4a1aec47 100644 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserMapper.xml +++ b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserMapper.xml @@ -91,79 +91,56 @@ order by u.user_id desc - - - - update system_user - set password = #{password}, - pwd_reset_time = NOW() - where username = #{username} - - - update system_user - set email = #{email} - where username = #{username} - - - - update system_user set password = #{password} - where user_id in - - #{id} - - \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserRoleMapper.xml b/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserRoleMapper.xml deleted file mode 100644 index b1474653..00000000 --- a/cutejava/cutejava-module-system/src/main/resources/mapper/SystemUserRoleMapper.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - insert into system_users_roles (user_id, role_id) - values - - #{userId}, #{item.id} - - - - - delete from system_users_roles - where user_id in - - #{id} - - - \ No newline at end of file diff --git a/cutejava/cutejava-module-system/src/main/resources/template/SystemEmailCaptchaTemplate.ftl b/cutejava/cutejava-module-system/src/main/resources/template/SystemEmailCaptchaTemplate.ftl index b326253a..1e4a8513 100644 --- a/cutejava/cutejava-module-system/src/main/resources/template/SystemEmailCaptchaTemplate.ftl +++ b/cutejava/cutejava-module-system/src/main/resources/template/SystemEmailCaptchaTemplate.ftl @@ -1,12 +1,12 @@ - - + + -

-

尊敬的用户, 您好:

-

您正在申请邮箱验证,您的验证码为:

-

+

尊敬的用户, 您好:

+

您正在申请邮箱验证,您的验证码为:

+

${code}

-
-
-
- Copyright ©${.now?string("yyyy")} CuteJava - 后台管理系统 All Rights Reserved. -
- + Copyright ©${.now?string("yyyy")} CuteJava + 后台管理系统 All Rights Reserved.
+ diff --git a/cutejava/cutejava-module-system/src/main/resources/template/SystemQuartzJobTaskAlarmTemplate.ftl b/cutejava/cutejava-module-system/src/main/resources/template/SystemQuartzJobTaskAlarmTemplate.ftl index c5ecdbb8..f3d10d5c 100644 --- a/cutejava/cutejava-module-system/src/main/resources/template/SystemQuartzJobTaskAlarmTemplate.ftl +++ b/cutejava/cutejava-module-system/src/main/resources/template/SystemQuartzJobTaskAlarmTemplate.ftl @@ -1,12 +1,12 @@ - - + + -
-

任务信息:

- - - - - - - - - - - - - - - - - -
任务名称Bean名称执行方法参数内容Cron表达式描述内容
${task.jobName}${task.beanName}${task.methodName}${(task.params)!""}${task.cronExpression}${(task.description)!""}
-
-
-

异常信息:

-
任务信息:

+ + + + + + + + + + + + + + + + + +
任务名称Bean名称执行方法参数内容Cron表达式描述内容
${task.jobName}${task.beanName}${task.methodName}${(task.params)!""}${task.cronExpression}${(task.description)!""}
+
+
+

异常信息:

+
                 ${msg}
             
-
-
-
-
- Copyright ©${.now?string("yyyy")} CuteJava - 后台管理系统 All Rights Reserved. -
- + Copyright ©${.now?string("yyyy")} CuteJava + 后台管理系统 All Rights Reserved. + diff --git a/cutejava/cutejava-module-task-v1/pom.xml b/cutejava/cutejava-module-task-v1/pom.xml index 1ff3eccd..05b8d1e8 100644 --- a/cutejava/cutejava-module-task-v1/pom.xml +++ b/cutejava/cutejava-module-task-v1/pom.xml @@ -7,10 +7,8 @@ 1.4.1 4.0.0 - cutejava-module-task-v1 任务模块:强制停止任务线程 - cn.odboy diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/constant/TaskChangeTypeEnum.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/constant/TaskChangeTypeEnum.java index f8c0d70e..587de031 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/constant/TaskChangeTypeEnum.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/constant/TaskChangeTypeEnum.java @@ -27,11 +27,13 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum TaskChangeTypeEnum { - AppApply("AppApply", "申请应用"), AppContainerRestart("AppContainerRestart", "容器应用重启"), AppContainerDeploy("AppContainerDeploy", "容器应用部署"), - AppOffline("AppOffline", "应用下线"), AppChangeReplicas("AppChangeReplicas", "应用扩缩容"), AppUpgrade("AppUpgrade", "应用升配"), - AppDowngrade("AppDowngrade", "应用降配"), AppHostRestart("AppHostRestart", "主机应用重启"), AppHostDeploy("AppHostDeploy", "主机应用部署"), - AppContainerRollback("AppContainerRollback", "容器应用回滚"), AppHostRollback("AppHostRollback", "主机应用回滚"), - ResourceApply("ResourceApply", "申请资源"), ResourceOffline("ResourceOffline", "资源下线"), DataChange("DataChange", "数据变更"), + AppApply("AppApply", "申请应用"), AppContainerRestart("AppContainerRestart", "容器应用重启"), + AppContainerDeploy("AppContainerDeploy", "容器应用部署"), AppOffline("AppOffline", "应用下线"), + AppChangeReplicas("AppChangeReplicas", "应用扩缩容"), AppUpgrade("AppUpgrade", "应用升配"), + AppDowngrade("AppDowngrade", "应用降配"), AppHostRestart("AppHostRestart", "主机应用重启"), + AppHostDeploy("AppHostDeploy", "主机应用部署"), AppContainerRollback("AppContainerRollback", "容器应用回滚"), + AppHostRollback("AppHostRollback", "主机应用回滚"), ResourceApply("ResourceApply", "申请资源"), + ResourceOffline("ResourceOffline", "资源下线"), DataChange("DataChange", "数据变更"), HostnameApply("HostnameApply", "申请域名"), HostnameChange("HostnameChange", "域名变更"); private final String code; private final String name; diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/controller/TaskTestsController.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/controller/TaskTestsController.java index 080d0e1b..4c912b9e 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/controller/TaskTestsController.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/controller/TaskTestsController.java @@ -34,14 +34,14 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/api/task") public class TaskTestsController { - @Autowired - private TaskManage taskManage; + @Autowired private TaskManage taskManage; @AnonymousAccess @GetMapping(value = "/testCreate") public ResponseEntity testCreate() { TaskInstanceInfoTb instanceInfo = - taskManage.createJob("cutejava", TaskChangeTypeEnum.AppContainerDeploy, "java", "daily", "cutejava", "功能测试", null); + taskManage.createJob("cutejava", TaskChangeTypeEnum.AppContainerDeploy, "java", "daily", "cutejava", + "功能测试", null); log.info("任务创建成功,实例为:{}", JSON.toJSONString(instanceInfo)); return ResponseEntity.ok(instanceInfo); } @@ -50,7 +50,8 @@ public class TaskTestsController { @GetMapping(value = "/testCreateAfterStop") public ResponseEntity testCreateAfterStop() { TaskInstanceInfoTb instanceInfo = - taskManage.createJob("cutejava", TaskChangeTypeEnum.AppContainerDeploy, "java", "daily", "cutejava", "功能测试", null); + taskManage.createJob("cutejava", TaskChangeTypeEnum.AppContainerDeploy, "java", "daily", "cutejava", + "功能测试", null); log.info("任务创建成功,实例为:{}", JSON.toJSONString(instanceInfo)); ThreadUtil.execAsync(() -> { ThreadUtil.safeSleep(5000); diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/TaskJobBean.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/TaskJobBean.java index 853f6b27..6d3ed05d 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/TaskJobBean.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/TaskJobBean.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.task.core; import cn.hutool.core.util.StrUtil; @@ -29,17 +28,16 @@ import cn.odboy.task.service.TaskInstanceDetailService; import cn.odboy.task.service.TaskInstanceInfoService; import cn.odboy.task.service.TaskInstanceStepDetailService; import com.alibaba.fastjson2.JSON; -import lombok.extern.slf4j.Slf4j; -import org.quartz.InterruptableJob; -import org.quartz.JobDataMap; -import org.quartz.JobExecutionContext; -import org.springframework.scheduling.quartz.QuartzJobBean; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import lombok.extern.slf4j.Slf4j; +import org.quartz.InterruptableJob; +import org.quartz.JobDataMap; +import org.quartz.JobExecutionContext; +import org.springframework.scheduling.quartz.QuartzJobBean; @Slf4j public class TaskJobBean extends QuartzJobBean implements InterruptableJob { @@ -59,7 +57,8 @@ public class TaskJobBean extends QuartzJobBean implements InterruptableJob { this.workThread = Thread.currentThread(); // ========================== 获取代理类 ========================== TaskInstanceInfoService taskInstanceInfoService = KitSpringBeanHolder.getBean(TaskInstanceInfoService.class); - TaskInstanceDetailService taskInstanceDetailService = KitSpringBeanHolder.getBean(TaskInstanceDetailService.class); + TaskInstanceDetailService taskInstanceDetailService = + KitSpringBeanHolder.getBean(TaskInstanceDetailService.class); // ========================== 获取参数 ========================== JobDataMap dataMap = context.getMergedJobDataMap(); long id = dataMap.getLong(TaskJobKeys.ID); @@ -72,7 +71,8 @@ public class TaskJobBean extends QuartzJobBean implements InterruptableJob { if (StrUtil.isBlank(retryNodeCode)) { executeNormalTask(taskInstanceInfoService, taskInstanceDetailService, id, dataMap, taskTemplateNodeVos); } else { - executeRetryTask(taskInstanceInfoService, taskInstanceDetailService, id, dataMap, taskTemplateNodeVos, retryNodeCode); + executeRetryTask(taskInstanceInfoService, taskInstanceDetailService, id, dataMap, taskTemplateNodeVos, + retryNodeCode); } } @@ -85,15 +85,19 @@ public class TaskJobBean extends QuartzJobBean implements InterruptableJob { * @param dataMap 数据映射 * @param taskTemplateNodeVos 模板节点列表 */ - private void executeNormalTask(TaskInstanceInfoService taskInstanceInfoService, TaskInstanceDetailService taskInstanceDetailService, long id, - JobDataMap dataMap, List taskTemplateNodeVos) { + private void executeNormalTask(TaskInstanceInfoService taskInstanceInfoService, + TaskInstanceDetailService taskInstanceDetailService, long id, JobDataMap dataMap, + List taskTemplateNodeVos) { // ========================== 初始化执行明细 ========================== List taskInstanceDetails = - taskTemplateNodeVos.stream().map(taskTemplateNodeVo -> buildTaskInstanceDetail(id, taskTemplateNodeVo)).collect(Collectors.toList()); + taskTemplateNodeVos.stream().map(taskTemplateNodeVo -> buildTaskInstanceDetail(id, taskTemplateNodeVo)) + .collect(Collectors.toList()); taskInstanceDetailService.saveBatch(taskInstanceDetails); - Map codeIdMap = taskInstanceDetails.stream().collect(Collectors.toMap(TaskInstanceDetailTb::getBizCode, TaskInstanceDetailTb::getId)); + Map codeIdMap = taskInstanceDetails.stream() + .collect(Collectors.toMap(TaskInstanceDetailTb::getBizCode, TaskInstanceDetailTb::getId)); // ========================== 顺序执行 ========================== - executeTaskSteps(taskInstanceInfoService, taskInstanceDetailService, id, dataMap, taskTemplateNodeVos, codeIdMap); + executeTaskSteps(taskInstanceInfoService, taskInstanceDetailService, id, dataMap, taskTemplateNodeVos, + codeIdMap); } /** @@ -106,8 +110,9 @@ public class TaskJobBean extends QuartzJobBean implements InterruptableJob { * @param taskTemplateNodeVos 模板节点列表 * @param retryNodeCode 重试节点编码 */ - private void executeRetryTask(TaskInstanceInfoService taskInstanceInfoService, TaskInstanceDetailService taskInstanceDetailService, long id, - JobDataMap dataMap, List taskTemplateNodeVos, String retryNodeCode) { + private void executeRetryTask(TaskInstanceInfoService taskInstanceInfoService, + TaskInstanceDetailService taskInstanceDetailService, long id, JobDataMap dataMap, + List taskTemplateNodeVos, String retryNodeCode) { boolean isFound = false; // ========================== 初始化执行明细 ========================== List taskInstanceDetails = new ArrayList<>(); @@ -127,18 +132,24 @@ public class TaskJobBean extends QuartzJobBean implements InterruptableJob { isFound = true; } } - TaskInstanceStepDetailService taskInstanceStepDetailService = KitSpringBeanHolder.getBean(TaskInstanceStepDetailService.class); - List bizCodeList = taskInstanceDetails.stream().map(TaskInstanceDetailTb::getBizCode).distinct().collect(Collectors.toList()); - List taskInstanceDetailTbs = taskInstanceDetailService.queryByInstanceIdAndBizCodeList(id, bizCodeList); - List taskInstanceDetailIds = taskInstanceDetailTbs.stream().map(TaskInstanceDetailTb::getId).collect(Collectors.toList()); + TaskInstanceStepDetailService taskInstanceStepDetailService = + KitSpringBeanHolder.getBean(TaskInstanceStepDetailService.class); + List bizCodeList = + taskInstanceDetails.stream().map(TaskInstanceDetailTb::getBizCode).distinct().collect(Collectors.toList()); + List taskInstanceDetailTbs = + taskInstanceDetailService.queryByInstanceIdAndBizCodeList(id, bizCodeList); + List taskInstanceDetailIds = + taskInstanceDetailTbs.stream().map(TaskInstanceDetailTb::getId).collect(Collectors.toList()); // 根据ID删除明细 taskInstanceDetailService.removeByIds(taskInstanceDetailIds); // 根据明细删除步骤 taskInstanceStepDetailService.removeByInstanceDetailIds(taskInstanceDetailIds); taskInstanceDetailService.saveBatch(taskInstanceDetails); - Map codeIdMap = taskInstanceDetails.stream().collect(Collectors.toMap(TaskInstanceDetailTb::getBizCode, TaskInstanceDetailTb::getId)); + Map codeIdMap = taskInstanceDetails.stream() + .collect(Collectors.toMap(TaskInstanceDetailTb::getBizCode, TaskInstanceDetailTb::getId)); // ========================== 顺序执行 ========================== - executeTaskSteps(taskInstanceInfoService, taskInstanceDetailService, id, dataMap, taskTemplateNodeRetryList, codeIdMap); + executeTaskSteps(taskInstanceInfoService, taskInstanceDetailService, id, dataMap, taskTemplateNodeRetryList, + codeIdMap); } /** @@ -169,8 +180,9 @@ public class TaskJobBean extends QuartzJobBean implements InterruptableJob { * @param taskTemplateNodes 需要执行的任务节点列表 * @param codeIdMap 节点编码与明细ID映射 */ - private void executeTaskSteps(TaskInstanceInfoService taskInstanceInfoService, TaskInstanceDetailService taskInstanceDetailService, Long id, - JobDataMap dataMap, List taskTemplateNodes, Map codeIdMap) { + private void executeTaskSteps(TaskInstanceInfoService taskInstanceInfoService, + TaskInstanceDetailService taskInstanceDetailService, Long id, JobDataMap dataMap, + List taskTemplateNodes, Map codeIdMap) { try { for (TaskTemplateNodeVo taskTemplateNodeVo : taskTemplateNodes) { String code = taskTemplateNodeVo.getCode(); diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/TaskManage.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/TaskManage.java index e04ddcff..f6d100fb 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/TaskManage.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/TaskManage.java @@ -33,15 +33,23 @@ import cn.odboy.task.service.TaskInstanceInfoService; import cn.odboy.task.service.TaskTemplateInfoService; import cn.odboy.util.KitDateUtil; import com.alibaba.fastjson2.JSON; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.quartz.*; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; - import java.util.ArrayList; import java.util.Date; import java.util.List; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.quartz.JobBuilder; +import org.quartz.JobDataMap; +import org.quartz.JobDetail; +import org.quartz.JobKey; +import org.quartz.ObjectAlreadyExistsException; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.Trigger; +import org.quartz.TriggerBuilder; +import org.quartz.TriggerKey; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; @Slf4j @Component @@ -64,8 +72,8 @@ public class TaskManage { * @param dataMap 任务参数 */ @Transactional(rollbackFor = Exception.class) - public TaskInstanceInfoTb createJob(String contextName, TaskChangeTypeEnum changeTypeEnum, String language, String envAlias, String source, String reason, - JobDataMap dataMap) { + public TaskInstanceInfoTb createJob(String contextName, TaskChangeTypeEnum changeTypeEnum, String language, + String envAlias, String source, String reason, JobDataMap dataMap) { if (StrUtil.isBlank(contextName)) { throw new BadRequestException("参数contextName必填"); } @@ -85,7 +93,8 @@ public class TaskManage { dataMap = new JobDataMap(); } // ========================== 获取任务编排模板 ========================== - TaskTemplateInfoVo taskInstanceInfoVo = taskTemplateInfoService.getTemplateInfoByECL(envAlias, contextName, language, changeTypeEnum.getCode()); + TaskTemplateInfoVo taskInstanceInfoVo = + taskTemplateInfoService.getTemplateInfoByECL(envAlias, contextName, language, changeTypeEnum.getCode()); if (taskInstanceInfoVo == null) { throw new BadRequestException("没有查询到任务编排模板"); } @@ -103,7 +112,8 @@ public class TaskManage { // ========================== 创建任务 ========================== TaskManage taskManage = KitSpringBeanHolder.getBean(TaskManage.class); TaskInstanceInfoTb newInstance = - taskManage.saveTaskInstanceInfoTb(contextName, changeTypeEnum, language, envAlias, source, reason, dataMap, templateInfo); + taskManage.saveTaskInstanceInfoTb(contextName, changeTypeEnum, language, envAlias, source, reason, dataMap, + templateInfo); dataMap.put(TaskJobKeys.ID, newInstance.getId()); // 应用名、资源类型 dataMap.put(TaskJobKeys.CONTEXT_NAME, contextName); @@ -117,8 +127,8 @@ public class TaskManage { } @Transactional(rollbackFor = Exception.class) - public TaskInstanceInfoTb saveTaskInstanceInfoTb(String contextName, TaskChangeTypeEnum changeTypeEnum, String language, String envAlias, String source, - String reason, JobDataMap dataMap, String templateInfo) { + public TaskInstanceInfoTb saveTaskInstanceInfoTb(String contextName, TaskChangeTypeEnum changeTypeEnum, + String language, String envAlias, String source, String reason, JobDataMap dataMap, String templateInfo) { TaskInstanceInfoTb newInstance = new TaskInstanceInfoTb(); newInstance.setContextName(contextName); newInstance.setLanguage(language); @@ -154,15 +164,12 @@ public class TaskManage { @Transactional(rollbackFor = Exception.class) public void stopJob(Long instanceId) { TaskInstanceInfoTb taskInstanceInfoTb = taskInstanceInfoService.getRunningById(instanceId); - String changeType = taskInstanceInfoTb.getChangeType(); String contextName = taskInstanceInfoTb.getContextName(); - taskInstanceInfoTb.setStatus(TaskStatusEnum.Fail.getCode()); taskInstanceInfoTb.setErrorMessage("任务被中断"); taskInstanceInfoTb.setFinishTime(new Date()); taskInstanceInfoService.updateById(taskInstanceInfoTb); - try { JobKey jobKey = JobKey.jobKey(changeType, contextName); TriggerKey triggerKey = TriggerKey.triggerKey(changeType, contextName); @@ -208,22 +215,22 @@ public class TaskManage { public TaskInstanceInfoVo getLastInfo(String contextName, String language, String envAlias, String changeType) { TaskInstanceInfoVo record = new TaskInstanceInfoVo(); - - TaskInstanceInfoTb historyInstance = taskInstanceInfoService.getLastHistoryInstance(contextName, language, envAlias, changeType); + TaskInstanceInfoTb historyInstance = + taskInstanceInfoService.getLastHistoryInstance(contextName, language, envAlias, changeType); if (historyInstance == null) { // 仅返回模板 - TaskTemplateInfoVo templateInfo = taskTemplateInfoService.getTemplateInfoByECL(envAlias, contextName, language, changeType); + TaskTemplateInfoVo templateInfo = + taskTemplateInfoService.getTemplateInfoByECL(envAlias, contextName, language, changeType); if (templateInfo == null) { throw new BadRequestException("没有查询到任务编排模板"); } record.setTemplate(templateInfo.getTemplateInfo()); return record; } - record = BeanUtil.copyProperties(historyInstance, TaskInstanceInfoVo.class); record.setHistory(buildNodeList(record)); - - TaskInstanceInfoTb runningInstance = taskInstanceInfoService.getLastRunningInstance(contextName, language, envAlias, changeType); + TaskInstanceInfoTb runningInstance = + taskInstanceInfoService.getLastRunningInstance(contextName, language, envAlias, changeType); if (runningInstance != null) { TaskInstanceInfoVo taskInstanceInfoVo = BeanUtil.copyProperties(runningInstance, TaskInstanceInfoVo.class); record.setCurrent(buildNodeList(taskInstanceInfoVo)); @@ -233,7 +240,6 @@ public class TaskManage { private List buildNodeList(TaskInstanceInfoVo record) { List records = new ArrayList<>(); - // 节点明细 List taskInstanceDetails = taskInstanceDetailService.queryByInstanceId(record.getId()); for (TaskInstanceDetailTb taskInstanceDetail : taskInstanceDetails) { @@ -243,16 +249,17 @@ public class TaskManage { instanceNodeVo.setStartTime(taskInstanceDetail.getStartTime()); instanceNodeVo.setFinishTime(taskInstanceDetail.getFinishTime()); if (taskInstanceDetail.getFinishTime() == null) { - instanceNodeVo.setDurationDesc(KitDateUtil.formatSecondsDuration(taskInstanceDetail.getStartTime(), new Date())); + instanceNodeVo.setDurationDesc( + KitDateUtil.formatSecondsDuration(taskInstanceDetail.getStartTime(), new Date())); } else { - instanceNodeVo.setDurationDesc(KitDateUtil.formatSecondsDuration(taskInstanceDetail.getStartTime(), taskInstanceDetail.getFinishTime())); + instanceNodeVo.setDurationDesc(KitDateUtil.formatSecondsDuration(taskInstanceDetail.getStartTime(), + taskInstanceDetail.getFinishTime())); } instanceNodeVo.setRunningDesc(taskInstanceDetail.getExecuteInfo()); instanceNodeVo.setStatus(taskInstanceDetail.getExecuteStatus()); instanceNodeVo.setStatusDesc(TaskStatusEnum.getDesc(taskInstanceDetail.getExecuteStatus())); records.add(instanceNodeVo); } - return records; } } diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/TaskStepExecutor.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/TaskStepExecutor.java index 3d53c8e4..f362f4f7 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/TaskStepExecutor.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/TaskStepExecutor.java @@ -25,5 +25,6 @@ public interface TaskStepExecutor { * @param jobDataMap 执行参数 * @param taskTemplateNode 任务节点信息 */ - void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) throws BadRequestException; + void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) + throws BadRequestException; } diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeBuildJava.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeBuildJava.java index 58df89ed..57e8a66c 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeBuildJava.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeBuildJava.java @@ -26,9 +26,9 @@ import org.springframework.stereotype.Component; @Slf4j @Component public class TaskStepNodeBuildJava implements TaskStepExecutor { - @Override - public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) throws BadRequestException { + public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) + throws BadRequestException { ThreadUtil.sleep(2000); } } diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeDeployJava.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeDeployJava.java index fb97818b..8194be2f 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeDeployJava.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeDeployJava.java @@ -26,9 +26,9 @@ import org.springframework.stereotype.Component; @Slf4j @Component public class TaskStepNodeDeployJava implements TaskStepExecutor { - @Override - public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) throws BadRequestException { + public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) + throws BadRequestException { ThreadUtil.sleep(5000); } } diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeInit.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeInit.java index ef9c0936..2850b098 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeInit.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeInit.java @@ -27,11 +27,11 @@ import org.springframework.stereotype.Component; @Slf4j @Component public class TaskStepNodeInit implements TaskStepExecutor { - @Autowired - private TaskInstanceStepDetailService stepDetailService; + @Autowired private TaskInstanceStepDetailService stepDetailService; @Override - public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) throws BadRequestException { + public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) + throws BadRequestException { stepDetailService.success(instanceDetailId, "开始初始化"); stepDetailService.success(instanceDetailId, "初始化完毕后,放入了一些参数"); jobDataMap.put("ExcuseMe", "Hello World!"); diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeMergeBranch.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeMergeBranch.java index 117be979..565de0b8 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeMergeBranch.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/core/impl/TaskStepNodeMergeBranch.java @@ -28,11 +28,11 @@ import org.springframework.stereotype.Component; @Slf4j @Component public class TaskStepNodeMergeBranch implements TaskStepExecutor { - @Autowired - private TaskInstanceStepDetailService stepDetailService; + @Autowired private TaskInstanceStepDetailService stepDetailService; @Override - public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) throws BadRequestException { + public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) + throws BadRequestException { ThreadUtil.sleep(3000); stepDetailService.fail(instanceDetailId, "执行失败测试"); // stepDetailService.success(instanceDetailId, "执行成功"); diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceDetailTb.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceDetailTb.java index 6bad1066..a28f2814 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceDetailTb.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceDetailTb.java @@ -17,17 +17,20 @@ package cn.odboy.task.dal.dataobject; import cn.odboy.base.KitObject; import com.alibaba.fastjson2.annotation.JSONField; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 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; - /** *

* 任务实例明细 @@ -42,72 +45,44 @@ import java.util.Date; @TableName("task_instance_detail") @ApiModel(value = "TaskInstanceDetailTb对象", description = "任务实例明细") public class TaskInstanceDetailTb extends KitObject { - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date createTime; - /** * id */ - @ApiModelProperty("id") - @TableId(value = "id", type = IdType.ASSIGN_ID) - @JsonSerialize(using = ToStringSerializer.class) - @JSONField(format = "string") - private Long id; - + @ApiModelProperty("id") @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) @JSONField(format = "string") private Long id; /** * 任务实例id */ - @TableField("instance_id") - @ApiModelProperty("任务实例id") - private Long instanceId; - + @TableField("instance_id") @ApiModelProperty("任务实例id") private Long instanceId; /** * 开始时间 */ - @ApiModelProperty("开始时间") - @TableField("start_time") - private Date startTime; - + @ApiModelProperty("开始时间") @TableField("start_time") private Date startTime; /** * 结束时间 */ - @ApiModelProperty("结束时间") - @TableField("finish_time") - private Date finishTime; - + @ApiModelProperty("结束时间") @TableField("finish_time") private Date finishTime; /** * 业务编码 */ - @TableField("biz_code") - @ApiModelProperty("业务编码") - private String bizCode; - + @TableField("biz_code") @ApiModelProperty("业务编码") private String bizCode; /** * 业务名称(步骤) */ - @TableField("biz_name") - @ApiModelProperty("业务名称(步骤)") - private String bizName; - + @TableField("biz_name") @ApiModelProperty("业务名称(步骤)") private String bizName; /** * 执行参数 */ - @ApiModelProperty("执行参数") - @TableField("execute_params") - private String executeParams; - + @ApiModelProperty("执行参数") @TableField("execute_params") private String executeParams; /** * 执行信息 */ - @ApiModelProperty("执行信息") - @TableField("execute_info") - private String executeInfo; - + @ApiModelProperty("执行信息") @TableField("execute_info") private String executeInfo; /** * 执行状态(running进行中 success成功 fail失败) */ - @TableField("execute_status") - @ApiModelProperty("执行状态(running进行中 success成功 fail失败)") - private String executeStatus; + @TableField("execute_status") @ApiModelProperty("执行状态(running进行中 success成功 fail失败)") private String + executeStatus; } diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceInfoTb.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceInfoTb.java index 70a3a63d..c68f8426 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceInfoTb.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceInfoTb.java @@ -17,18 +17,21 @@ package cn.odboy.task.dal.dataobject; import cn.odboy.base.KitObject; import com.alibaba.fastjson2.annotation.JSONField; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.util.Date; import lombok.Getter; import lombok.Setter; import lombok.ToString; import org.springframework.data.annotation.CreatedBy; -import java.util.Date; - /** *

* 任务实例 @@ -43,102 +46,59 @@ import java.util.Date; @TableName("task_instance_info") @ApiModel(value = "TaskInstanceInfoTb对象", description = "任务实例") public class TaskInstanceInfoTb extends KitObject { - @CreatedBy - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建人", hidden = true) - private String createBy; - - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @CreatedBy @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建人", hidden = true) private String + createBy; + @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date createTime; - @TableField(fill = FieldFill.INSERT_UPDATE) - @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) - private Date updateTime; - + @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date updateTime; /** * id, @JsonSerialize和@JSONField,用于处理大数精度丢失问题 */ - @ApiModelProperty("id") - @TableId(value = "id", type = IdType.ASSIGN_ID) - @JsonSerialize(using = ToStringSerializer.class) - @JSONField(format = "string") - private Long id; - + @ApiModelProperty("id") @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) @JSONField(format = "string") private Long id; /** * 名称 */ - @ApiModelProperty("名称") - @TableField("context_name") - private String contextName; - + @ApiModelProperty("名称") @TableField("context_name") private String contextName; /** * 语言 */ - @ApiModelProperty("语言") - @TableField("`language`") - private String language; - + @ApiModelProperty("语言") @TableField("`language`") private String language; /** * 变更类型 */ - @ApiModelProperty("变更类型") - @TableField("change_type") - private String changeType; - + @ApiModelProperty("变更类型") @TableField("change_type") private String changeType; /** * 环境别名 */ - @TableField("env_alias") - @ApiModelProperty("环境别名") - private String envAlias; - + @TableField("env_alias") @ApiModelProperty("环境别名") private String envAlias; /** * 状态(running进行中 success成功 fail失败) */ - @TableField("`status`") - @ApiModelProperty("状态(running进行中 success成功 fail失败)") - private String status; - + @TableField("`status`") @ApiModelProperty("状态(running进行中 success成功 fail失败)") private String status; /** * 完成时间 */ - @ApiModelProperty("完成时间") - @TableField("finish_time") - private Date finishTime; - + @ApiModelProperty("完成时间") @TableField("finish_time") private Date finishTime; /** * 来源 */ - @ApiModelProperty("来源") - @TableField("`source`") - private String source; - + @ApiModelProperty("来源") @TableField("`source`") private String source; /** * 变更原因 */ - @TableField("reason") - @ApiModelProperty("变更原因") - private String reason; - + @TableField("reason") @ApiModelProperty("变更原因") private String reason; /** * 任务模板 */ - @TableField("template") - @ApiModelProperty("template") - private String template; - + @TableField("template") @ApiModelProperty("template") private String template; /** * QuartzJob参数 */ - @TableField("job_data") - @ApiModelProperty("QuartzJob参数") - private String jobData; - + @TableField("job_data") @ApiModelProperty("QuartzJob参数") private String jobData; /** * 异常信息 */ - @TableField("error_message") - @ApiModelProperty("异常信息") - private String errorMessage; + @TableField("error_message") @ApiModelProperty("异常信息") private String errorMessage; } diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceStepDetailTb.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceStepDetailTb.java index 79541349..abef4c11 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceStepDetailTb.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceStepDetailTb.java @@ -17,17 +17,20 @@ package cn.odboy.task.dal.dataobject; import cn.odboy.base.KitObject; import com.alibaba.fastjson2.annotation.JSONField; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 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; - /** *

* 任务实例步骤明细 @@ -42,37 +45,23 @@ import java.util.Date; @TableName("task_instance_step_detail") @ApiModel(value = "TaskInstanceStepDetailTb对象", description = "") public class TaskInstanceStepDetailTb extends KitObject { - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date createTime; - /** * id */ - @ApiModelProperty("id") - @TableId(value = "id", type = IdType.ASSIGN_ID) - @JsonSerialize(using = ToStringSerializer.class) - @JSONField(format = "string") - private Long id; - + @ApiModelProperty("id") @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) @JSONField(format = "string") private Long id; /** * task_instance_detail表id */ - @TableField("instance_detail_id") - @ApiModelProperty("task_instance_detail表id") - private Long instanceDetailId; - + @TableField("instance_detail_id") @ApiModelProperty("task_instance_detail表id") private Long instanceDetailId; /** * 步骤描述 */ - @TableField("step_desc") - @ApiModelProperty("步骤描述") - private String stepDesc; - + @TableField("step_desc") @ApiModelProperty("步骤描述") private String stepDesc; /** * 状态(success成功 fail失败) */ - @TableField("step_status") - @ApiModelProperty("状态(success成功 fail失败)") - private String stepStatus; + @TableField("step_status") @ApiModelProperty("状态(success成功 fail失败)") private String stepStatus; } diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskTemplateInfoTb.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskTemplateInfoTb.java index d7b4ca85..70ded132 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskTemplateInfoTb.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/dataobject/TaskTemplateInfoTb.java @@ -40,60 +40,36 @@ import lombok.ToString; @TableName("task_template_info") @ApiModel(value = "TaskTemplateInfoTb对象", description = "任务模板") public class TaskTemplateInfoTb extends KitBaseUserTimeTb { - /** * id */ - @ApiModelProperty("id") - @TableId(value = "id", type = IdType.AUTO) - private Long id; - + @ApiModelProperty("id") @TableId(value = "id", type = IdType.AUTO) private Long id; /** * 数据有效性 */ - @TableField("available") - @ApiModelProperty("数据有效性") - private Boolean available; - + @TableField("available") @ApiModelProperty("数据有效性") private Boolean available; /** * 变更类型 */ - @ApiModelProperty("变更类型") - @TableField("change_type") - private String changeType; - + @ApiModelProperty("变更类型") @TableField("change_type") private String changeType; /** * 流水线名称 */ - @TableField("`name`") - @ApiModelProperty("流水线名称") - private String name; - + @TableField("`name`") @ApiModelProperty("流水线名称") private String name; /** * 流水线描述 */ - @ApiModelProperty("流水线描述") - @TableField("`description`") - private String description; - + @ApiModelProperty("流水线描述") @TableField("`description`") private String description; /** * 流水线模板内容 */ - @TableField("template") - @ApiModelProperty("流水线模板内容") - private String template; - + @TableField("template") @ApiModelProperty("流水线模板内容") private String template; /** * 环境别名 */ - @TableField("env_alias") - @ApiModelProperty("环境别名") - private String envAlias; - + @TableField("env_alias") @ApiModelProperty("环境别名") private String envAlias; /** * 应用为语言,资源为类型 */ - @TableField("`language`") - @ApiModelProperty("应用为语言,资源为类型") - private String language; + @TableField("`language`") @ApiModelProperty("应用为语言,资源为类型") private String language; } diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskInstanceInfoVo.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskInstanceInfoVo.java index 0bfdff33..0072a506 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskInstanceInfoVo.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskInstanceInfoVo.java @@ -1,11 +1,10 @@ package cn.odboy.task.dal.model; import cn.odboy.task.dal.dataobject.TaskInstanceInfoTb; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; - /** * 任务实例数据 * diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskInstanceNodeVo.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskInstanceNodeVo.java index 1b268f47..ea1ca05a 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskInstanceNodeVo.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskInstanceNodeVo.java @@ -13,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.task.dal.model; import cn.odboy.base.KitObject; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; - /** * 任务节点数据 * diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeOperateButtonVo.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeOperateButtonVo.java index b1c52ab2..a63ebb2a 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeOperateButtonVo.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeOperateButtonVo.java @@ -13,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.task.dal.model; import cn.odboy.base.KitObject; -import lombok.Getter; -import lombok.Setter; - import java.util.HashMap; import java.util.Map; +import lombok.Getter; +import lombok.Setter; /** * 流水线节点控制按钮 diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeVo.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeVo.java index b9602442..ffd8690b 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeVo.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeVo.java @@ -13,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.task.dal.model; import cn.odboy.base.KitObject; -import lombok.Getter; -import lombok.Setter; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import lombok.Getter; +import lombok.Setter; /** * 任务节点模板 diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceDetailMapper.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceDetailMapper.java index c79849e5..9536b3dd 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceDetailMapper.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceDetailMapper.java @@ -28,6 +28,4 @@ import org.apache.ibatis.annotations.Mapper; * @since 2025-09-26 */ @Mapper -public interface TaskInstanceDetailMapper extends BaseMapper { - -} +public interface TaskInstanceDetailMapper extends BaseMapper {} diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceInfoMapper.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceInfoMapper.java index 682b0b8c..7fb0336b 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceInfoMapper.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceInfoMapper.java @@ -28,6 +28,4 @@ import org.apache.ibatis.annotations.Mapper; * @since 2025-09-26 */ @Mapper -public interface TaskInstanceInfoMapper extends BaseMapper { - -} +public interface TaskInstanceInfoMapper extends BaseMapper {} diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceStepDetailMapper.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceStepDetailMapper.java index 67451484..29cdf5ae 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceStepDetailMapper.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceStepDetailMapper.java @@ -28,6 +28,4 @@ import org.apache.ibatis.annotations.Mapper; * @since 2025-09-28 */ @Mapper -public interface TaskInstanceStepDetailMapper extends BaseMapper { - -} +public interface TaskInstanceStepDetailMapper extends BaseMapper {} diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskTemplateInfoMapper.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskTemplateInfoMapper.java index e11efa8d..50419cfa 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskTemplateInfoMapper.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/dal/mysql/TaskTemplateInfoMapper.java @@ -38,6 +38,7 @@ public interface TaskTemplateInfoMapper extends BaseMapper { * @param changeType 变更类型 * @return / */ - TaskTemplateInfoVo selectTemplateInfoByECL(@Param("envAlias") String envAlias, @Param("contextName") String contextName, @Param("language") String language, + TaskTemplateInfoVo selectTemplateInfoByECL(@Param("envAlias") String envAlias, + @Param("contextName") String contextName, @Param("language") String language, @Param("changeType") String changeType); } diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskInstanceDetailService.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskInstanceDetailService.java index 5e892de6..1ab378d6 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskInstanceDetailService.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskInstanceDetailService.java @@ -15,30 +15,95 @@ */ package cn.odboy.task.service; +import cn.hutool.core.collection.CollUtil; +import cn.odboy.task.constant.TaskStatusEnum; import cn.odboy.task.dal.dataobject.TaskInstanceDetailTb; -import com.baomidou.mybatisplus.extension.service.IService; -import org.quartz.JobDataMap; - +import cn.odboy.task.dal.mysql.TaskInstanceDetailMapper; +import com.alibaba.fastjson2.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import java.util.Date; import java.util.List; +import org.quartz.JobDataMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** *

- * 任务实例明细 服务类 + * 任务实例明细 *

* * @author codegen - * @since 2025-09-26 + * @since 2025-09-28 */ -public interface TaskInstanceDetailService extends IService { - void fastFailWithInfo(Long instanceId, String code, String message); +@Service +public class TaskInstanceDetailService { + @Autowired private TaskInstanceDetailMapper taskInstanceDetailMapper; - void fastSuccess(Long instanceId, String code); + public void fastFailWithInfo(Long instanceId, String code, String executeInfo) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(TaskInstanceDetailTb::getInstanceId, instanceId); + wrapper.eq(TaskInstanceDetailTb::getBizCode, code); + wrapper.set(TaskInstanceDetailTb::getFinishTime, new Date()); + wrapper.set(TaskInstanceDetailTb::getExecuteInfo, executeInfo); + wrapper.set(TaskInstanceDetailTb::getExecuteStatus, TaskStatusEnum.Fail.getCode()); + taskInstanceDetailMapper.update(null, wrapper); + } - void fastSuccessWithInfo(Long instanceId, String code, String executeInfo); + public void fastSuccess(Long instanceId, String code) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(TaskInstanceDetailTb::getInstanceId, instanceId); + wrapper.eq(TaskInstanceDetailTb::getBizCode, code); + wrapper.set(TaskInstanceDetailTb::getFinishTime, new Date()); + wrapper.set(TaskInstanceDetailTb::getExecuteInfo, TaskStatusEnum.Success.getName()); + wrapper.set(TaskInstanceDetailTb::getExecuteStatus, TaskStatusEnum.Success.getCode()); + taskInstanceDetailMapper.update(null, wrapper); + } - void fastStart(Long instanceId, String code, JobDataMap dataMap); + public void fastSuccessWithInfo(Long instanceId, String code, String executeInfo) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(TaskInstanceDetailTb::getInstanceId, instanceId); + wrapper.eq(TaskInstanceDetailTb::getBizCode, code); + wrapper.set(TaskInstanceDetailTb::getFinishTime, new Date()); + wrapper.set(TaskInstanceDetailTb::getExecuteInfo, + executeInfo == null ? TaskStatusEnum.Success.getName() : executeInfo); + wrapper.set(TaskInstanceDetailTb::getExecuteStatus, TaskStatusEnum.Success.getCode()); + taskInstanceDetailMapper.update(null, wrapper); + } - List queryByInstanceIdAndBizCodeList(Long instanceId, List bizCodes); + public void fastStart(Long instanceId, String code, JobDataMap dataMap) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(TaskInstanceDetailTb::getInstanceId, instanceId); + wrapper.eq(TaskInstanceDetailTb::getBizCode, code); + wrapper.set(TaskInstanceDetailTb::getStartTime, new Date()); + wrapper.set(TaskInstanceDetailTb::getExecuteInfo, TaskStatusEnum.Running.getName()); + wrapper.set(TaskInstanceDetailTb::getExecuteParams, JSON.toJSONString(dataMap)); + wrapper.set(TaskInstanceDetailTb::getExecuteStatus, TaskStatusEnum.Running.getCode()); + taskInstanceDetailMapper.update(null, wrapper); + } - List queryByInstanceId(Long instanceId); + public List queryByInstanceIdAndBizCodeList(Long instanceId, List bizCodeList) { + if (CollUtil.isEmpty(bizCodeList)) { + return CollUtil.newArrayList(); + } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(TaskInstanceDetailTb::getInstanceId, instanceId); + wrapper.in(TaskInstanceDetailTb::getBizCode, bizCodeList); + return taskInstanceDetailMapper.selectList(wrapper); + } + + public List queryByInstanceId(Long instanceId) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(TaskInstanceDetailTb::getInstanceId, instanceId); + wrapper.orderByAsc(TaskInstanceDetailTb::getId); + return taskInstanceDetailMapper.selectList(wrapper); + } + + public void saveBatch(List taskInstanceDetails) { + taskInstanceDetailMapper.insert(taskInstanceDetails); + } + + public void removeByIds(List taskInstanceDetailIds) { + taskInstanceDetailMapper.deleteByIds(taskInstanceDetailIds); + } } diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskInstanceInfoService.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskInstanceInfoService.java index 57c6d53c..512755d7 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskInstanceInfoService.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskInstanceInfoService.java @@ -15,28 +15,101 @@ */ package cn.odboy.task.service; +import cn.odboy.task.constant.TaskStatusEnum; import cn.odboy.task.dal.dataobject.TaskInstanceInfoTb; -import com.baomidou.mybatisplus.extension.service.IService; +import cn.odboy.task.dal.mysql.TaskInstanceInfoMapper; +import com.alibaba.fastjson2.JSON; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import java.util.Date; import org.quartz.JobDataMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** *

- * 任务实例 服务类 + * 任务实例 服务实现类 *

* * @author codegen * @since 2025-09-26 */ -public interface TaskInstanceInfoService extends IService { - TaskInstanceInfoTb getRunningById(Long instanceId); +@Service +public class TaskInstanceInfoService { + @Autowired private TaskInstanceInfoMapper taskInstanceInfoMapper; - void fastFailWithMessage(Long id, String errorMessage); + public TaskInstanceInfoTb getRunningById(Long id) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(TaskInstanceInfoTb::getId, id); + wrapper.eq(TaskInstanceInfoTb::getStatus, TaskStatusEnum.Running.getCode()); + wrapper.orderByDesc(TaskInstanceInfoTb::getId); + return taskInstanceInfoMapper.selectOne(wrapper); + } - void fastFailWithMessageData(Long id, String errorMessage, JobDataMap dataMap); + @Transactional(rollbackFor = Exception.class) + public void fastFailWithMessage(Long id, String errorMessage) { + TaskInstanceInfoTb updRecord = new TaskInstanceInfoTb(); + updRecord.setId(id); + updRecord.setFinishTime(new Date()); + updRecord.setStatus(TaskStatusEnum.Fail.getCode()); + updRecord.setErrorMessage(errorMessage); + taskInstanceInfoMapper.updateById(updRecord); + } - void fastSuccessWithData(Long id, JobDataMap dataMap); + @Transactional(rollbackFor = Exception.class) + public void fastFailWithMessageData(Long id, String errorMessage, JobDataMap dataMap) { + TaskInstanceInfoTb updRecord = new TaskInstanceInfoTb(); + updRecord.setId(id); + updRecord.setFinishTime(new Date()); + updRecord.setStatus(TaskStatusEnum.Fail.getCode()); + updRecord.setErrorMessage(errorMessage); + updRecord.setJobData(JSON.toJSONString(dataMap)); + taskInstanceInfoMapper.updateById(updRecord); + } - TaskInstanceInfoTb getLastRunningInstance(String contextName, String language, String envAlias, String changeType); + @Transactional(rollbackFor = Exception.class) + public void fastSuccessWithData(Long id, JobDataMap dataMap) { + TaskInstanceInfoTb updRecord = new TaskInstanceInfoTb(); + updRecord.setId(id); + updRecord.setFinishTime(new Date()); + updRecord.setStatus(TaskStatusEnum.Success.getCode()); + updRecord.setJobData(JSON.toJSONString(dataMap)); + taskInstanceInfoMapper.updateById(updRecord); + } - TaskInstanceInfoTb getLastHistoryInstance(String contextName, String language, String envAlias, String changeType); + public TaskInstanceInfoTb getLastRunningInstance(String contextName, String language, String envAlias, + String changeType) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(TaskInstanceInfoTb::getContextName, contextName); + wrapper.eq(TaskInstanceInfoTb::getLanguage, language); + wrapper.eq(TaskInstanceInfoTb::getEnvAlias, envAlias); + wrapper.eq(TaskInstanceInfoTb::getChangeType, changeType); + wrapper.eq(TaskInstanceInfoTb::getStatus, TaskStatusEnum.Running.getCode()); + wrapper.orderByDesc(TaskInstanceInfoTb::getId); + return taskInstanceInfoMapper.selectOne(wrapper); + } + + public TaskInstanceInfoTb getLastHistoryInstance(String contextName, String language, String envAlias, + String changeType) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(TaskInstanceInfoTb::getContextName, contextName); + wrapper.eq(TaskInstanceInfoTb::getLanguage, language); + wrapper.eq(TaskInstanceInfoTb::getEnvAlias, envAlias); + wrapper.eq(TaskInstanceInfoTb::getChangeType, changeType); + wrapper.orderByDesc(TaskInstanceInfoTb::getId); + wrapper.last("LIMIT 1"); + return taskInstanceInfoMapper.selectOne(wrapper); + } + + public void save(TaskInstanceInfoTb newInstance) { + taskInstanceInfoMapper.insert(newInstance); + } + + public TaskInstanceInfoTb getById(Long id) { + return taskInstanceInfoMapper.selectById(id); + } + + public void updateById(TaskInstanceInfoTb taskInstanceInfoTb) { + taskInstanceInfoMapper.updateById(taskInstanceInfoTb); + } } diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskInstanceStepDetailService.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskInstanceStepDetailService.java index 105ab133..5fc17068 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskInstanceStepDetailService.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskInstanceStepDetailService.java @@ -15,27 +15,41 @@ */ package cn.odboy.task.service; +import cn.hutool.core.collection.CollUtil; +import cn.odboy.framework.exception.BadRequestException; +import cn.odboy.task.constant.TaskStatusEnum; import cn.odboy.task.dal.dataobject.TaskInstanceStepDetailTb; -import com.baomidou.mybatisplus.extension.service.IService; - +import cn.odboy.task.dal.mysql.TaskInstanceStepDetailMapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** *

- * 任务实例步骤明细 服务类 + * 任务实例步骤明细 服务实现类 *

* * @author codegen * @since 2025-09-28 */ -public interface TaskInstanceStepDetailService extends IService { +@Service +public class TaskInstanceStepDetailService { + @Autowired private TaskInstanceStepDetailMapper taskInstanceStepDetailMapper; + /** * 步骤执行成功 * * @param instanceDetailId 任务实例明细id * @param stepDesc 步骤描述 */ - void success(Long instanceDetailId, String stepDesc); + public void success(Long instanceDetailId, String stepDesc) { + TaskInstanceStepDetailTb stepDetail = new TaskInstanceStepDetailTb(); + stepDetail.setInstanceDetailId(instanceDetailId); + stepDetail.setStepDesc(stepDesc); + stepDetail.setStepStatus(TaskStatusEnum.Success.getCode()); + taskInstanceStepDetailMapper.insert(stepDetail); + } /** * 步骤执行失败 @@ -43,12 +57,26 @@ public interface TaskInstanceStepDetailService extends IService instanceDetailIds); + public void removeByInstanceDetailIds(List instanceDetailIds) { + if (CollUtil.isNotEmpty(instanceDetailIds)) { + return; + } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(TaskInstanceStepDetailTb::getInstanceDetailId, instanceDetailIds); + taskInstanceStepDetailMapper.delete(wrapper); + } } diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskTemplateInfoService.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskTemplateInfoService.java index 6277818a..960b0716 100644 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskTemplateInfoService.java +++ b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/TaskTemplateInfoService.java @@ -15,18 +15,25 @@ */ package cn.odboy.task.service; -import cn.odboy.task.dal.dataobject.TaskTemplateInfoTb; import cn.odboy.task.dal.model.TaskTemplateInfoVo; -import com.baomidou.mybatisplus.extension.service.IService; +import cn.odboy.task.dal.mysql.TaskTemplateInfoMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** *

- * 任务模板 服务类 + * 任务模板 *

* * @author codegen * @since 2025-09-28 */ -public interface TaskTemplateInfoService extends IService { - TaskTemplateInfoVo getTemplateInfoByECL(String envAlias, String contextName, String language, String changeType); +@Service +public class TaskTemplateInfoService { + @Autowired private TaskTemplateInfoMapper taskTemplateInfoMapper; + + public TaskTemplateInfoVo getTemplateInfoByECL(String envAlias, String contextName, String language, + String changeType) { + return taskTemplateInfoMapper.selectTemplateInfoByECL(envAlias, contextName, language, changeType); + } } diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskInstanceDetailServiceImpl.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskInstanceDetailServiceImpl.java deleted file mode 100644 index bd8cdb88..00000000 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskInstanceDetailServiceImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2021-2025 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.task.service.impl; - -import cn.hutool.core.collection.CollUtil; -import cn.odboy.task.constant.TaskStatusEnum; -import cn.odboy.task.dal.dataobject.TaskInstanceDetailTb; -import cn.odboy.task.dal.mysql.TaskInstanceDetailMapper; -import cn.odboy.task.service.TaskInstanceDetailService; -import com.alibaba.fastjson2.JSON; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.quartz.JobDataMap; -import org.springframework.stereotype.Service; - -import java.util.Date; -import java.util.List; - -/** - *

- * 任务实例明细 服务实现类 - *

- * - * @author codegen - * @since 2025-09-26 - */ -@Service -public class TaskInstanceDetailServiceImpl extends ServiceImpl implements TaskInstanceDetailService { - - @Override - public void fastFailWithInfo(Long instanceId, String code, String executeInfo) { - TaskInstanceDetailTb updRecord = new TaskInstanceDetailTb(); - updRecord.setFinishTime(new Date()); - updRecord.setExecuteInfo(executeInfo); - updRecord.setExecuteStatus(TaskStatusEnum.Fail.getCode()); - lambdaUpdate().eq(TaskInstanceDetailTb::getInstanceId, instanceId).eq(TaskInstanceDetailTb::getBizCode, code).update(updRecord); - } - - @Override - public void fastSuccess(Long instanceId, String code) { - TaskInstanceDetailTb updRecord = new TaskInstanceDetailTb(); - updRecord.setFinishTime(new Date()); - updRecord.setExecuteInfo("执行成功"); - updRecord.setExecuteStatus(TaskStatusEnum.Success.getCode()); - lambdaUpdate().eq(TaskInstanceDetailTb::getInstanceId, instanceId).eq(TaskInstanceDetailTb::getBizCode, code).update(updRecord); - } - - @Override - public void fastSuccessWithInfo(Long instanceId, String code, String executeInfo) { - TaskInstanceDetailTb updRecord = new TaskInstanceDetailTb(); - updRecord.setFinishTime(new Date()); - updRecord.setExecuteInfo(executeInfo == null ? "执行成功" : executeInfo); - updRecord.setExecuteStatus(TaskStatusEnum.Success.getCode()); - lambdaUpdate().eq(TaskInstanceDetailTb::getInstanceId, instanceId).eq(TaskInstanceDetailTb::getBizCode, code).update(updRecord); - } - - @Override - public void fastStart(Long instanceId, String code, JobDataMap dataMap) { - TaskInstanceDetailTb updRecord = new TaskInstanceDetailTb(); - updRecord.setStartTime(new Date()); - updRecord.setExecuteInfo("运行中"); - updRecord.setExecuteParams(JSON.toJSONString(dataMap)); - updRecord.setExecuteStatus(TaskStatusEnum.Running.getCode()); - lambdaUpdate().eq(TaskInstanceDetailTb::getInstanceId, instanceId).eq(TaskInstanceDetailTb::getBizCode, code).update(updRecord); - } - - @Override - public List queryByInstanceIdAndBizCodeList(Long instanceId, List bizCodeList) { - if (CollUtil.isEmpty(bizCodeList)) { - return CollUtil.newArrayList(); - } - return lambdaQuery().eq(TaskInstanceDetailTb::getInstanceId, instanceId).in(TaskInstanceDetailTb::getBizCode, bizCodeList).list(); - } - - @Override - public List queryByInstanceId(Long instanceId) { - return lambdaQuery().eq(TaskInstanceDetailTb::getInstanceId, instanceId).orderByAsc(TaskInstanceDetailTb::getId).list(); - } -} diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskInstanceInfoServiceImpl.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskInstanceInfoServiceImpl.java deleted file mode 100644 index c898bb31..00000000 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskInstanceInfoServiceImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2021-2025 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.task.service.impl; - -import cn.odboy.task.constant.TaskStatusEnum; -import cn.odboy.task.dal.dataobject.TaskInstanceInfoTb; -import cn.odboy.task.dal.mysql.TaskInstanceInfoMapper; -import cn.odboy.task.service.TaskInstanceInfoService; -import com.alibaba.fastjson2.JSON; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.quartz.JobDataMap; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Date; - -/** - *

- * 任务实例 服务实现类 - *

- * - * @author codegen - * @since 2025-09-26 - */ -@Service -public class TaskInstanceInfoServiceImpl extends ServiceImpl implements TaskInstanceInfoService { - - @Override - public TaskInstanceInfoTb getRunningById(Long id) { - return lambdaQuery().eq(TaskInstanceInfoTb::getId, id).eq(TaskInstanceInfoTb::getStatus, TaskStatusEnum.Running.getCode()) - .orderByDesc(TaskInstanceInfoTb::getId).one(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void fastFailWithMessage(Long id, String errorMessage) { - TaskInstanceInfoTb updRecord = new TaskInstanceInfoTb(); - updRecord.setId(id); - updRecord.setFinishTime(new Date()); - updRecord.setStatus(TaskStatusEnum.Fail.getCode()); - updRecord.setErrorMessage(errorMessage); - updateById(updRecord); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void fastFailWithMessageData(Long id, String errorMessage, JobDataMap dataMap) { - TaskInstanceInfoTb updRecord = new TaskInstanceInfoTb(); - updRecord.setId(id); - updRecord.setFinishTime(new Date()); - updRecord.setStatus(TaskStatusEnum.Fail.getCode()); - updRecord.setErrorMessage(errorMessage); - updRecord.setJobData(JSON.toJSONString(dataMap)); - updateById(updRecord); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void fastSuccessWithData(Long id, JobDataMap dataMap) { - TaskInstanceInfoTb updRecord = new TaskInstanceInfoTb(); - updRecord.setId(id); - updRecord.setFinishTime(new Date()); - updRecord.setStatus(TaskStatusEnum.Success.getCode()); - updRecord.setJobData(JSON.toJSONString(dataMap)); - updateById(updRecord); - } - - @Override - public TaskInstanceInfoTb getLastRunningInstance(String contextName, String language, String envAlias, String changeType) { - return lambdaQuery().eq(TaskInstanceInfoTb::getContextName, contextName).eq(TaskInstanceInfoTb::getLanguage, language) - .eq(TaskInstanceInfoTb::getEnvAlias, envAlias).eq(TaskInstanceInfoTb::getChangeType, changeType) - .eq(TaskInstanceInfoTb::getStatus, TaskStatusEnum.Running.getCode()).orderByDesc(TaskInstanceInfoTb::getId).one(); - } - - @Override - public TaskInstanceInfoTb getLastHistoryInstance(String contextName, String language, String envAlias, String changeType) { - return lambdaQuery().eq(TaskInstanceInfoTb::getContextName, contextName).eq(TaskInstanceInfoTb::getLanguage, language) - .eq(TaskInstanceInfoTb::getEnvAlias, envAlias).eq(TaskInstanceInfoTb::getChangeType, changeType).orderByDesc(TaskInstanceInfoTb::getId) - .last("LIMIT 1").one(); - } -} diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskInstanceStepDetailServiceImpl.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskInstanceStepDetailServiceImpl.java deleted file mode 100644 index 6800757f..00000000 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskInstanceStepDetailServiceImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2021-2025 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.task.service.impl; - -import cn.hutool.core.collection.CollUtil; -import cn.odboy.framework.exception.BadRequestException; -import cn.odboy.task.constant.TaskStatusEnum; -import cn.odboy.task.dal.dataobject.TaskInstanceStepDetailTb; -import cn.odboy.task.dal.mysql.TaskInstanceStepDetailMapper; -import cn.odboy.task.service.TaskInstanceStepDetailService; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 任务实例步骤明细 服务实现类 - *

- * - * @author codegen - * @since 2025-09-28 - */ -@Service -public class TaskInstanceStepDetailServiceImpl extends ServiceImpl - implements TaskInstanceStepDetailService { - - @Override - public void success(Long instanceDetailId, String stepDesc) { - TaskInstanceStepDetailTb stepDetail = new TaskInstanceStepDetailTb(); - stepDetail.setInstanceDetailId(instanceDetailId); - stepDetail.setStepDesc(stepDesc); - stepDetail.setStepStatus(TaskStatusEnum.Success.getCode()); - save(stepDetail); - } - - @Override - public void fail(Long instanceDetailId, String stepDesc) { - TaskInstanceStepDetailTb stepDetail = new TaskInstanceStepDetailTb(); - stepDetail.setInstanceDetailId(instanceDetailId); - stepDetail.setStepDesc(stepDesc); - stepDetail.setStepStatus(TaskStatusEnum.Fail.getCode()); - save(stepDetail); - throw new BadRequestException(stepDesc); - } - - @Override - public void removeByInstanceDetailIds(List instanceDetailIds) { - if (CollUtil.isEmpty(instanceDetailIds)) { - return; - } - remove(new LambdaQueryWrapper().in(TaskInstanceStepDetailTb::getInstanceDetailId, instanceDetailIds)); - } -} diff --git a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskTemplateInfoServiceImpl.java b/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskTemplateInfoServiceImpl.java deleted file mode 100644 index 2a8ed83f..00000000 --- a/cutejava/cutejava-module-task-v1/src/main/java/cn/odboy/task/service/impl/TaskTemplateInfoServiceImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2021-2025 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.task.service.impl; - -import cn.odboy.task.dal.dataobject.TaskTemplateInfoTb; -import cn.odboy.task.dal.model.TaskTemplateInfoVo; -import cn.odboy.task.dal.mysql.TaskTemplateInfoMapper; -import cn.odboy.task.service.TaskTemplateInfoService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; - -/** - *

- * 任务模板 服务实现类 - *

- * - * @author codegen - * @since 2025-09-28 - */ -@Service -public class TaskTemplateInfoServiceImpl extends ServiceImpl implements TaskTemplateInfoService { - - @Override - public TaskTemplateInfoVo getTemplateInfoByECL(String envAlias, String contextName, String language, String changeType) { - return baseMapper.selectTemplateInfoByECL(envAlias, contextName, language, changeType); - } -} diff --git a/cutejava/cutejava-module-task-v1/src/main/resources/mapper/TaskInstanceDetailMapper.xml b/cutejava/cutejava-module-task-v1/src/main/resources/mapper/TaskInstanceDetailMapper.xml index 9c151269..794721f9 100644 --- a/cutejava/cutejava-module-task-v1/src/main/resources/mapper/TaskInstanceDetailMapper.xml +++ b/cutejava/cutejava-module-task-v1/src/main/resources/mapper/TaskInstanceDetailMapper.xml @@ -1,5 +1,4 @@ - diff --git a/cutejava/cutejava-module-task-v1/src/main/resources/mapper/TaskInstanceInfoMapper.xml b/cutejava/cutejava-module-task-v1/src/main/resources/mapper/TaskInstanceInfoMapper.xml index 4896649c..aba16383 100644 --- a/cutejava/cutejava-module-task-v1/src/main/resources/mapper/TaskInstanceInfoMapper.xml +++ b/cutejava/cutejava-module-task-v1/src/main/resources/mapper/TaskInstanceInfoMapper.xml @@ -1,5 +1,4 @@ - diff --git a/cutejava/cutejava-module-task-v2/pom.xml b/cutejava/cutejava-module-task-v2/pom.xml index 4e6df824..b5752e8f 100644 --- a/cutejava/cutejava-module-task-v2/pom.xml +++ b/cutejava/cutejava-module-task-v2/pom.xml @@ -7,10 +7,8 @@ 1.4.1 4.0.0 - cutejava-module-task-v2 任务模块V2:根据任务标记停止轮询检查 - cn.odboy diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/constant/TaskChangeTypeEnum.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/constant/TaskChangeTypeEnum.java index f8c0d70e..587de031 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/constant/TaskChangeTypeEnum.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/constant/TaskChangeTypeEnum.java @@ -27,11 +27,13 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum TaskChangeTypeEnum { - AppApply("AppApply", "申请应用"), AppContainerRestart("AppContainerRestart", "容器应用重启"), AppContainerDeploy("AppContainerDeploy", "容器应用部署"), - AppOffline("AppOffline", "应用下线"), AppChangeReplicas("AppChangeReplicas", "应用扩缩容"), AppUpgrade("AppUpgrade", "应用升配"), - AppDowngrade("AppDowngrade", "应用降配"), AppHostRestart("AppHostRestart", "主机应用重启"), AppHostDeploy("AppHostDeploy", "主机应用部署"), - AppContainerRollback("AppContainerRollback", "容器应用回滚"), AppHostRollback("AppHostRollback", "主机应用回滚"), - ResourceApply("ResourceApply", "申请资源"), ResourceOffline("ResourceOffline", "资源下线"), DataChange("DataChange", "数据变更"), + AppApply("AppApply", "申请应用"), AppContainerRestart("AppContainerRestart", "容器应用重启"), + AppContainerDeploy("AppContainerDeploy", "容器应用部署"), AppOffline("AppOffline", "应用下线"), + AppChangeReplicas("AppChangeReplicas", "应用扩缩容"), AppUpgrade("AppUpgrade", "应用升配"), + AppDowngrade("AppDowngrade", "应用降配"), AppHostRestart("AppHostRestart", "主机应用重启"), + AppHostDeploy("AppHostDeploy", "主机应用部署"), AppContainerRollback("AppContainerRollback", "容器应用回滚"), + AppHostRollback("AppHostRollback", "主机应用回滚"), ResourceApply("ResourceApply", "申请资源"), + ResourceOffline("ResourceOffline", "资源下线"), DataChange("DataChange", "数据变更"), HostnameApply("HostnameApply", "申请域名"), HostnameChange("HostnameChange", "域名变更"); private final String code; private final String name; diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/controller/TaskTestsController.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/controller/TaskTestsController.java index 080d0e1b..4c912b9e 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/controller/TaskTestsController.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/controller/TaskTestsController.java @@ -34,14 +34,14 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/api/task") public class TaskTestsController { - @Autowired - private TaskManage taskManage; + @Autowired private TaskManage taskManage; @AnonymousAccess @GetMapping(value = "/testCreate") public ResponseEntity testCreate() { TaskInstanceInfoTb instanceInfo = - taskManage.createJob("cutejava", TaskChangeTypeEnum.AppContainerDeploy, "java", "daily", "cutejava", "功能测试", null); + taskManage.createJob("cutejava", TaskChangeTypeEnum.AppContainerDeploy, "java", "daily", "cutejava", + "功能测试", null); log.info("任务创建成功,实例为:{}", JSON.toJSONString(instanceInfo)); return ResponseEntity.ok(instanceInfo); } @@ -50,7 +50,8 @@ public class TaskTestsController { @GetMapping(value = "/testCreateAfterStop") public ResponseEntity testCreateAfterStop() { TaskInstanceInfoTb instanceInfo = - taskManage.createJob("cutejava", TaskChangeTypeEnum.AppContainerDeploy, "java", "daily", "cutejava", "功能测试", null); + taskManage.createJob("cutejava", TaskChangeTypeEnum.AppContainerDeploy, "java", "daily", "cutejava", + "功能测试", null); log.info("任务创建成功,实例为:{}", JSON.toJSONString(instanceInfo)); ThreadUtil.execAsync(() -> { ThreadUtil.safeSleep(5000); diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/TaskJobBean.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/TaskJobBean.java index be791866..18a74995 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/TaskJobBean.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/TaskJobBean.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.task.core; import cn.hutool.core.thread.ThreadUtil; diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/TaskManage.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/TaskManage.java index 7d3a136a..7a045fa9 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/TaskManage.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/TaskManage.java @@ -164,15 +164,12 @@ public class TaskManage { @Transactional(rollbackFor = Exception.class) public void stopJob(Long instanceId) { TaskInstanceInfoTb taskInstanceInfoTb = taskInstanceInfoService.getRunningById(instanceId); - String changeType = taskInstanceInfoTb.getChangeType(); String contextName = taskInstanceInfoTb.getContextName(); - taskInstanceInfoTb.setStatus(TaskStatusEnum.Fail.getCode()); taskInstanceInfoTb.setErrorMessage("任务被中断"); taskInstanceInfoTb.setFinishTime(new Date()); taskInstanceInfoService.updateById(taskInstanceInfoTb); - try { JobKey jobKey = JobKey.jobKey(changeType, contextName); TriggerKey triggerKey = TriggerKey.triggerKey(changeType, contextName); @@ -218,7 +215,6 @@ public class TaskManage { public TaskInstanceInfoVo getLastInfo(String contextName, String language, String envAlias, String changeType) { TaskInstanceInfoVo record = new TaskInstanceInfoVo(); - TaskInstanceInfoTb historyInstance = taskInstanceInfoService.getLastHistoryInstance(contextName, language, envAlias, changeType); if (historyInstance == null) { @@ -231,10 +227,8 @@ public class TaskManage { record.setTemplate(templateInfo.getTemplateInfo()); return record; } - record = BeanUtil.copyProperties(historyInstance, TaskInstanceInfoVo.class); record.setHistory(buildNodeList(record)); - TaskInstanceInfoTb runningInstance = taskInstanceInfoService.getLastRunningInstance(contextName, language, envAlias, changeType); if (runningInstance != null) { @@ -246,7 +240,6 @@ public class TaskManage { private List buildNodeList(TaskInstanceInfoVo record) { List records = new ArrayList<>(); - // 节点明细 List taskInstanceDetails = taskInstanceDetailService.queryByInstanceId(record.getId()); for (TaskInstanceDetailTb taskInstanceDetail : taskInstanceDetails) { @@ -267,7 +260,6 @@ public class TaskManage { instanceNodeVo.setStatusDesc(TaskStatusEnum.getDesc(taskInstanceDetail.getExecuteStatus())); records.add(instanceNodeVo); } - return records; } } diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/TaskStepExecutor.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/TaskStepExecutor.java index 3d53c8e4..f362f4f7 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/TaskStepExecutor.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/TaskStepExecutor.java @@ -25,5 +25,6 @@ public interface TaskStepExecutor { * @param jobDataMap 执行参数 * @param taskTemplateNode 任务节点信息 */ - void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) throws BadRequestException; + void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) + throws BadRequestException; } diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeBuildJava.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeBuildJava.java index 58df89ed..57e8a66c 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeBuildJava.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeBuildJava.java @@ -26,9 +26,9 @@ import org.springframework.stereotype.Component; @Slf4j @Component public class TaskStepNodeBuildJava implements TaskStepExecutor { - @Override - public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) throws BadRequestException { + public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) + throws BadRequestException { ThreadUtil.sleep(2000); } } diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeDeployJava.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeDeployJava.java index fb97818b..8194be2f 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeDeployJava.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeDeployJava.java @@ -26,9 +26,9 @@ import org.springframework.stereotype.Component; @Slf4j @Component public class TaskStepNodeDeployJava implements TaskStepExecutor { - @Override - public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) throws BadRequestException { + public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) + throws BadRequestException { ThreadUtil.sleep(5000); } } diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeInit.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeInit.java index ef9c0936..2850b098 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeInit.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeInit.java @@ -27,11 +27,11 @@ import org.springframework.stereotype.Component; @Slf4j @Component public class TaskStepNodeInit implements TaskStepExecutor { - @Autowired - private TaskInstanceStepDetailService stepDetailService; + @Autowired private TaskInstanceStepDetailService stepDetailService; @Override - public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) throws BadRequestException { + public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) + throws BadRequestException { stepDetailService.success(instanceDetailId, "开始初始化"); stepDetailService.success(instanceDetailId, "初始化完毕后,放入了一些参数"); jobDataMap.put("ExcuseMe", "Hello World!"); diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeMergeBranch.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeMergeBranch.java index 117be979..565de0b8 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeMergeBranch.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/core/impl/TaskStepNodeMergeBranch.java @@ -28,11 +28,11 @@ import org.springframework.stereotype.Component; @Slf4j @Component public class TaskStepNodeMergeBranch implements TaskStepExecutor { - @Autowired - private TaskInstanceStepDetailService stepDetailService; + @Autowired private TaskInstanceStepDetailService stepDetailService; @Override - public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) throws BadRequestException { + public void execute(Long instanceDetailId, JobDataMap jobDataMap, TaskTemplateNodeVo taskTemplateNode) + throws BadRequestException { ThreadUtil.sleep(3000); stepDetailService.fail(instanceDetailId, "执行失败测试"); // stepDetailService.success(instanceDetailId, "执行成功"); diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceDetailTb.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceDetailTb.java index 6bad1066..a28f2814 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceDetailTb.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceDetailTb.java @@ -17,17 +17,20 @@ package cn.odboy.task.dal.dataobject; import cn.odboy.base.KitObject; import com.alibaba.fastjson2.annotation.JSONField; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 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; - /** *

* 任务实例明细 @@ -42,72 +45,44 @@ import java.util.Date; @TableName("task_instance_detail") @ApiModel(value = "TaskInstanceDetailTb对象", description = "任务实例明细") public class TaskInstanceDetailTb extends KitObject { - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date createTime; - /** * id */ - @ApiModelProperty("id") - @TableId(value = "id", type = IdType.ASSIGN_ID) - @JsonSerialize(using = ToStringSerializer.class) - @JSONField(format = "string") - private Long id; - + @ApiModelProperty("id") @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) @JSONField(format = "string") private Long id; /** * 任务实例id */ - @TableField("instance_id") - @ApiModelProperty("任务实例id") - private Long instanceId; - + @TableField("instance_id") @ApiModelProperty("任务实例id") private Long instanceId; /** * 开始时间 */ - @ApiModelProperty("开始时间") - @TableField("start_time") - private Date startTime; - + @ApiModelProperty("开始时间") @TableField("start_time") private Date startTime; /** * 结束时间 */ - @ApiModelProperty("结束时间") - @TableField("finish_time") - private Date finishTime; - + @ApiModelProperty("结束时间") @TableField("finish_time") private Date finishTime; /** * 业务编码 */ - @TableField("biz_code") - @ApiModelProperty("业务编码") - private String bizCode; - + @TableField("biz_code") @ApiModelProperty("业务编码") private String bizCode; /** * 业务名称(步骤) */ - @TableField("biz_name") - @ApiModelProperty("业务名称(步骤)") - private String bizName; - + @TableField("biz_name") @ApiModelProperty("业务名称(步骤)") private String bizName; /** * 执行参数 */ - @ApiModelProperty("执行参数") - @TableField("execute_params") - private String executeParams; - + @ApiModelProperty("执行参数") @TableField("execute_params") private String executeParams; /** * 执行信息 */ - @ApiModelProperty("执行信息") - @TableField("execute_info") - private String executeInfo; - + @ApiModelProperty("执行信息") @TableField("execute_info") private String executeInfo; /** * 执行状态(running进行中 success成功 fail失败) */ - @TableField("execute_status") - @ApiModelProperty("执行状态(running进行中 success成功 fail失败)") - private String executeStatus; + @TableField("execute_status") @ApiModelProperty("执行状态(running进行中 success成功 fail失败)") private String + executeStatus; } diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceInfoTb.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceInfoTb.java index 70a3a63d..c68f8426 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceInfoTb.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceInfoTb.java @@ -17,18 +17,21 @@ package cn.odboy.task.dal.dataobject; import cn.odboy.base.KitObject; import com.alibaba.fastjson2.annotation.JSONField; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; +import java.util.Date; import lombok.Getter; import lombok.Setter; import lombok.ToString; import org.springframework.data.annotation.CreatedBy; -import java.util.Date; - /** *

* 任务实例 @@ -43,102 +46,59 @@ import java.util.Date; @TableName("task_instance_info") @ApiModel(value = "TaskInstanceInfoTb对象", description = "任务实例") public class TaskInstanceInfoTb extends KitObject { - @CreatedBy - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建人", hidden = true) - private String createBy; - - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @CreatedBy @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建人", hidden = true) private String + createBy; + @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date createTime; - @TableField(fill = FieldFill.INSERT_UPDATE) - @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) - private Date updateTime; - + @ApiModelProperty(value = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date updateTime; /** * id, @JsonSerialize和@JSONField,用于处理大数精度丢失问题 */ - @ApiModelProperty("id") - @TableId(value = "id", type = IdType.ASSIGN_ID) - @JsonSerialize(using = ToStringSerializer.class) - @JSONField(format = "string") - private Long id; - + @ApiModelProperty("id") @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) @JSONField(format = "string") private Long id; /** * 名称 */ - @ApiModelProperty("名称") - @TableField("context_name") - private String contextName; - + @ApiModelProperty("名称") @TableField("context_name") private String contextName; /** * 语言 */ - @ApiModelProperty("语言") - @TableField("`language`") - private String language; - + @ApiModelProperty("语言") @TableField("`language`") private String language; /** * 变更类型 */ - @ApiModelProperty("变更类型") - @TableField("change_type") - private String changeType; - + @ApiModelProperty("变更类型") @TableField("change_type") private String changeType; /** * 环境别名 */ - @TableField("env_alias") - @ApiModelProperty("环境别名") - private String envAlias; - + @TableField("env_alias") @ApiModelProperty("环境别名") private String envAlias; /** * 状态(running进行中 success成功 fail失败) */ - @TableField("`status`") - @ApiModelProperty("状态(running进行中 success成功 fail失败)") - private String status; - + @TableField("`status`") @ApiModelProperty("状态(running进行中 success成功 fail失败)") private String status; /** * 完成时间 */ - @ApiModelProperty("完成时间") - @TableField("finish_time") - private Date finishTime; - + @ApiModelProperty("完成时间") @TableField("finish_time") private Date finishTime; /** * 来源 */ - @ApiModelProperty("来源") - @TableField("`source`") - private String source; - + @ApiModelProperty("来源") @TableField("`source`") private String source; /** * 变更原因 */ - @TableField("reason") - @ApiModelProperty("变更原因") - private String reason; - + @TableField("reason") @ApiModelProperty("变更原因") private String reason; /** * 任务模板 */ - @TableField("template") - @ApiModelProperty("template") - private String template; - + @TableField("template") @ApiModelProperty("template") private String template; /** * QuartzJob参数 */ - @TableField("job_data") - @ApiModelProperty("QuartzJob参数") - private String jobData; - + @TableField("job_data") @ApiModelProperty("QuartzJob参数") private String jobData; /** * 异常信息 */ - @TableField("error_message") - @ApiModelProperty("异常信息") - private String errorMessage; + @TableField("error_message") @ApiModelProperty("异常信息") private String errorMessage; } diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceStepDetailTb.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceStepDetailTb.java index 79541349..abef4c11 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceStepDetailTb.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskInstanceStepDetailTb.java @@ -17,17 +17,20 @@ package cn.odboy.task.dal.dataobject; import cn.odboy.base.KitObject; import com.alibaba.fastjson2.annotation.JSONField; -import com.baomidou.mybatisplus.annotation.*; +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; 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; - /** *

* 任务实例步骤明细 @@ -42,37 +45,23 @@ import java.util.Date; @TableName("task_instance_step_detail") @ApiModel(value = "TaskInstanceStepDetailTb对象", description = "") public class TaskInstanceStepDetailTb extends KitObject { - @TableField(fill = FieldFill.INSERT) - @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) + @TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date createTime; - /** * id */ - @ApiModelProperty("id") - @TableId(value = "id", type = IdType.ASSIGN_ID) - @JsonSerialize(using = ToStringSerializer.class) - @JSONField(format = "string") - private Long id; - + @ApiModelProperty("id") @TableId(value = "id", type = IdType.ASSIGN_ID) + @JsonSerialize(using = ToStringSerializer.class) @JSONField(format = "string") private Long id; /** * task_instance_detail表id */ - @TableField("instance_detail_id") - @ApiModelProperty("task_instance_detail表id") - private Long instanceDetailId; - + @TableField("instance_detail_id") @ApiModelProperty("task_instance_detail表id") private Long instanceDetailId; /** * 步骤描述 */ - @TableField("step_desc") - @ApiModelProperty("步骤描述") - private String stepDesc; - + @TableField("step_desc") @ApiModelProperty("步骤描述") private String stepDesc; /** * 状态(success成功 fail失败) */ - @TableField("step_status") - @ApiModelProperty("状态(success成功 fail失败)") - private String stepStatus; + @TableField("step_status") @ApiModelProperty("状态(success成功 fail失败)") private String stepStatus; } diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskTemplateInfoTb.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskTemplateInfoTb.java index d7b4ca85..70ded132 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskTemplateInfoTb.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/dataobject/TaskTemplateInfoTb.java @@ -40,60 +40,36 @@ import lombok.ToString; @TableName("task_template_info") @ApiModel(value = "TaskTemplateInfoTb对象", description = "任务模板") public class TaskTemplateInfoTb extends KitBaseUserTimeTb { - /** * id */ - @ApiModelProperty("id") - @TableId(value = "id", type = IdType.AUTO) - private Long id; - + @ApiModelProperty("id") @TableId(value = "id", type = IdType.AUTO) private Long id; /** * 数据有效性 */ - @TableField("available") - @ApiModelProperty("数据有效性") - private Boolean available; - + @TableField("available") @ApiModelProperty("数据有效性") private Boolean available; /** * 变更类型 */ - @ApiModelProperty("变更类型") - @TableField("change_type") - private String changeType; - + @ApiModelProperty("变更类型") @TableField("change_type") private String changeType; /** * 流水线名称 */ - @TableField("`name`") - @ApiModelProperty("流水线名称") - private String name; - + @TableField("`name`") @ApiModelProperty("流水线名称") private String name; /** * 流水线描述 */ - @ApiModelProperty("流水线描述") - @TableField("`description`") - private String description; - + @ApiModelProperty("流水线描述") @TableField("`description`") private String description; /** * 流水线模板内容 */ - @TableField("template") - @ApiModelProperty("流水线模板内容") - private String template; - + @TableField("template") @ApiModelProperty("流水线模板内容") private String template; /** * 环境别名 */ - @TableField("env_alias") - @ApiModelProperty("环境别名") - private String envAlias; - + @TableField("env_alias") @ApiModelProperty("环境别名") private String envAlias; /** * 应用为语言,资源为类型 */ - @TableField("`language`") - @ApiModelProperty("应用为语言,资源为类型") - private String language; + @TableField("`language`") @ApiModelProperty("应用为语言,资源为类型") private String language; } diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskInstanceInfoVo.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskInstanceInfoVo.java index 0bfdff33..0072a506 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskInstanceInfoVo.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskInstanceInfoVo.java @@ -1,11 +1,10 @@ package cn.odboy.task.dal.model; import cn.odboy.task.dal.dataobject.TaskInstanceInfoTb; +import java.util.List; import lombok.Getter; import lombok.Setter; -import java.util.List; - /** * 任务实例数据 * diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskInstanceNodeVo.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskInstanceNodeVo.java index 1b268f47..ea1ca05a 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskInstanceNodeVo.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskInstanceNodeVo.java @@ -13,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.task.dal.model; import cn.odboy.base.KitObject; +import java.util.Date; import lombok.Getter; import lombok.Setter; -import java.util.Date; - /** * 任务节点数据 * diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeOperateButtonVo.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeOperateButtonVo.java index b1c52ab2..a63ebb2a 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeOperateButtonVo.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeOperateButtonVo.java @@ -13,15 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.task.dal.model; import cn.odboy.base.KitObject; -import lombok.Getter; -import lombok.Setter; - import java.util.HashMap; import java.util.Map; +import lombok.Getter; +import lombok.Setter; /** * 流水线节点控制按钮 diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeVo.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeVo.java index b9602442..ffd8690b 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeVo.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/model/TaskTemplateNodeVo.java @@ -13,17 +13,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.task.dal.model; import cn.odboy.base.KitObject; -import lombok.Getter; -import lombok.Setter; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import lombok.Getter; +import lombok.Setter; /** * 任务节点模板 diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceDetailMapper.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceDetailMapper.java index c79849e5..9536b3dd 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceDetailMapper.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceDetailMapper.java @@ -28,6 +28,4 @@ import org.apache.ibatis.annotations.Mapper; * @since 2025-09-26 */ @Mapper -public interface TaskInstanceDetailMapper extends BaseMapper { - -} +public interface TaskInstanceDetailMapper extends BaseMapper {} diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceInfoMapper.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceInfoMapper.java index 682b0b8c..7fb0336b 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceInfoMapper.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceInfoMapper.java @@ -28,6 +28,4 @@ import org.apache.ibatis.annotations.Mapper; * @since 2025-09-26 */ @Mapper -public interface TaskInstanceInfoMapper extends BaseMapper { - -} +public interface TaskInstanceInfoMapper extends BaseMapper {} diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceStepDetailMapper.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceStepDetailMapper.java index 67451484..29cdf5ae 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceStepDetailMapper.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskInstanceStepDetailMapper.java @@ -28,6 +28,4 @@ import org.apache.ibatis.annotations.Mapper; * @since 2025-09-28 */ @Mapper -public interface TaskInstanceStepDetailMapper extends BaseMapper { - -} +public interface TaskInstanceStepDetailMapper extends BaseMapper {} diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskTemplateInfoMapper.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskTemplateInfoMapper.java index e11efa8d..50419cfa 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskTemplateInfoMapper.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/dal/mysql/TaskTemplateInfoMapper.java @@ -38,6 +38,7 @@ public interface TaskTemplateInfoMapper extends BaseMapper { * @param changeType 变更类型 * @return / */ - TaskTemplateInfoVo selectTemplateInfoByECL(@Param("envAlias") String envAlias, @Param("contextName") String contextName, @Param("language") String language, + TaskTemplateInfoVo selectTemplateInfoByECL(@Param("envAlias") String envAlias, + @Param("contextName") String contextName, @Param("language") String language, @Param("changeType") String changeType); } diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskInstanceDetailService.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskInstanceDetailService.java index f8c5e3a2..b4b7f83e 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskInstanceDetailService.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskInstanceDetailService.java @@ -15,32 +15,94 @@ */ package cn.odboy.task.service; +import cn.hutool.core.collection.CollUtil; +import cn.odboy.task.constant.TaskStatusEnum; import cn.odboy.task.dal.dataobject.TaskInstanceDetailTb; -import com.baomidou.mybatisplus.extension.service.IService; -import org.quartz.JobDataMap; - +import cn.odboy.task.dal.mysql.TaskInstanceDetailMapper; +import com.alibaba.fastjson2.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import java.util.Date; import java.util.List; +import org.quartz.JobDataMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** *

- * 任务实例明细 服务类 + * 任务实例明细 *

* * @author codegen * @since 2025-09-26 */ -public interface TaskInstanceDetailService extends IService { - TaskInstanceDetailTb getOneByInstanceIdAndCode(Long id, String code); +@Service +public class TaskInstanceDetailService { + @Autowired private TaskInstanceDetailMapper taskInstanceDetailMapper; - void fastFailWithInfo(Long instanceId, String code, String message); + public TaskInstanceDetailTb getOneByInstanceIdAndCode(Long id, String code) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(TaskInstanceDetailTb::getInstanceId, id); + wrapper.eq(TaskInstanceDetailTb::getBizCode, code); + return taskInstanceDetailMapper.selectOne(wrapper); + } - void fastSuccess(Long instanceId, String code); + public void fastFailWithInfo(Long instanceId, String code, String executeInfo) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(TaskInstanceDetailTb::getInstanceId, instanceId); + wrapper.eq(TaskInstanceDetailTb::getBizCode, code); + wrapper.set(TaskInstanceDetailTb::getFinishTime, new Date()); + wrapper.set(TaskInstanceDetailTb::getExecuteInfo, executeInfo); + wrapper.set(TaskInstanceDetailTb::getExecuteStatus, TaskStatusEnum.Fail.getCode()); + taskInstanceDetailMapper.update(null, wrapper); + } - void fastSuccessWithInfo(Long instanceId, String code, String executeInfo); + public void fastSuccess(Long instanceId, String code) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(TaskInstanceDetailTb::getInstanceId, instanceId); + wrapper.eq(TaskInstanceDetailTb::getBizCode, code); + wrapper.set(TaskInstanceDetailTb::getFinishTime, new Date()); + wrapper.set(TaskInstanceDetailTb::getExecuteInfo, TaskStatusEnum.Success.getName()); + wrapper.set(TaskInstanceDetailTb::getExecuteStatus, TaskStatusEnum.Success.getCode()); + taskInstanceDetailMapper.update(null, wrapper); + } - void fastStart(Long instanceId, String code, JobDataMap dataMap); + public void fastSuccessWithInfo(Long instanceId, String code, String executeInfo) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(TaskInstanceDetailTb::getInstanceId, instanceId); + wrapper.eq(TaskInstanceDetailTb::getBizCode, code); + wrapper.set(TaskInstanceDetailTb::getFinishTime, new Date()); + wrapper.set(TaskInstanceDetailTb::getExecuteInfo, + executeInfo == null ? TaskStatusEnum.Success.getName() : executeInfo); + wrapper.set(TaskInstanceDetailTb::getExecuteStatus, TaskStatusEnum.Success.getCode()); + taskInstanceDetailMapper.update(null, wrapper); + } - List queryByInstanceIdAndBizCodeList(Long instanceId, List bizCodes); + public void fastStart(Long instanceId, String code, JobDataMap dataMap) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(TaskInstanceDetailTb::getInstanceId, instanceId); + wrapper.eq(TaskInstanceDetailTb::getBizCode, code); + wrapper.set(TaskInstanceDetailTb::getFinishTime, new Date()); + wrapper.set(TaskInstanceDetailTb::getExecuteInfo, TaskStatusEnum.Running.getName()); + wrapper.set(TaskInstanceDetailTb::getExecuteParams, JSON.toJSONString(dataMap)); + wrapper.set(TaskInstanceDetailTb::getExecuteStatus, TaskStatusEnum.Running.getCode()); + taskInstanceDetailMapper.update(null, wrapper); + } - List queryByInstanceId(Long instanceId); -} + public List queryByInstanceIdAndBizCodeList(Long instanceId, List bizCodeList) { + if (CollUtil.isEmpty(bizCodeList)) { + return CollUtil.newArrayList(); + } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(TaskInstanceDetailTb::getInstanceId, instanceId); + wrapper.in(TaskInstanceDetailTb::getBizCode, bizCodeList); + return taskInstanceDetailMapper.selectList(wrapper); + } + + public List queryByInstanceId(Long instanceId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(TaskInstanceDetailTb::getInstanceId, instanceId); + wrapper.orderByAsc(TaskInstanceDetailTb::getId); + return taskInstanceDetailMapper.selectList(wrapper); + } +} \ No newline at end of file diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskInstanceInfoService.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskInstanceInfoService.java index 57c6d53c..579ea575 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskInstanceInfoService.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskInstanceInfoService.java @@ -15,28 +15,88 @@ */ package cn.odboy.task.service; +import cn.odboy.task.constant.TaskStatusEnum; import cn.odboy.task.dal.dataobject.TaskInstanceInfoTb; -import com.baomidou.mybatisplus.extension.service.IService; +import cn.odboy.task.dal.mysql.TaskInstanceInfoMapper; +import com.alibaba.fastjson2.JSON; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import java.util.Date; import org.quartz.JobDataMap; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; /** *

- * 任务实例 服务类 + * 任务实例 *

* * @author codegen * @since 2025-09-26 */ -public interface TaskInstanceInfoService extends IService { - TaskInstanceInfoTb getRunningById(Long instanceId); +@Service +public class TaskInstanceInfoService { + @Autowired private TaskInstanceInfoMapper taskInstanceInfoMapper; - void fastFailWithMessage(Long id, String errorMessage); + public TaskInstanceInfoTb getRunningById(Long id) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(TaskInstanceInfoTb::getStatus, TaskStatusEnum.Running.getCode()); + wrapper.orderByDesc(TaskInstanceInfoTb::getId); + return taskInstanceInfoMapper.selectOne(wrapper); + } - void fastFailWithMessageData(Long id, String errorMessage, JobDataMap dataMap); + @Transactional(rollbackFor = Exception.class) + public void fastFailWithMessage(Long id, String errorMessage) { + TaskInstanceInfoTb updRecord = new TaskInstanceInfoTb(); + updRecord.setId(id); + updRecord.setFinishTime(new Date()); + updRecord.setStatus(TaskStatusEnum.Fail.getCode()); + updRecord.setErrorMessage(errorMessage); + taskInstanceInfoMapper.updateById(updRecord); + } - void fastSuccessWithData(Long id, JobDataMap dataMap); + @Transactional(rollbackFor = Exception.class) + public void fastFailWithMessageData(Long id, String errorMessage, JobDataMap dataMap) { + TaskInstanceInfoTb updRecord = new TaskInstanceInfoTb(); + updRecord.setId(id); + updRecord.setFinishTime(new Date()); + updRecord.setStatus(TaskStatusEnum.Fail.getCode()); + updRecord.setErrorMessage(errorMessage); + updRecord.setJobData(JSON.toJSONString(dataMap)); + taskInstanceInfoMapper.updateById(updRecord); + } - TaskInstanceInfoTb getLastRunningInstance(String contextName, String language, String envAlias, String changeType); + @Transactional(rollbackFor = Exception.class) + public void fastSuccessWithData(Long id, JobDataMap dataMap) { + TaskInstanceInfoTb updRecord = new TaskInstanceInfoTb(); + updRecord.setId(id); + updRecord.setFinishTime(new Date()); + updRecord.setStatus(TaskStatusEnum.Success.getCode()); + updRecord.setJobData(JSON.toJSONString(dataMap)); + taskInstanceInfoMapper.updateById(updRecord); + } - TaskInstanceInfoTb getLastHistoryInstance(String contextName, String language, String envAlias, String changeType); -} + public TaskInstanceInfoTb getLastRunningInstance(String contextName, String language, String envAlias, + String changeType) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(TaskInstanceInfoTb::getContextName, contextName); + wrapper.eq(TaskInstanceInfoTb::getLanguage, language); + wrapper.eq(TaskInstanceInfoTb::getEnvAlias, envAlias); + wrapper.eq(TaskInstanceInfoTb::getChangeType, changeType); + wrapper.eq(TaskInstanceInfoTb::getStatus, TaskStatusEnum.Running.getCode()); + wrapper.orderByDesc(TaskInstanceInfoTb::getId); + return taskInstanceInfoMapper.selectOne(wrapper); + } + + public TaskInstanceInfoTb getLastHistoryInstance(String contextName, String language, String envAlias, + String changeType) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(TaskInstanceInfoTb::getContextName, contextName); + wrapper.eq(TaskInstanceInfoTb::getLanguage, language); + wrapper.eq(TaskInstanceInfoTb::getEnvAlias, envAlias); + wrapper.eq(TaskInstanceInfoTb::getChangeType, changeType); + wrapper.orderByDesc(TaskInstanceInfoTb::getId); + wrapper.last("LIMIT 1"); + return taskInstanceInfoMapper.selectOne(wrapper); + } +} \ No newline at end of file diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskInstanceStepDetailService.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskInstanceStepDetailService.java index 105ab133..6eb6f23d 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskInstanceStepDetailService.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskInstanceStepDetailService.java @@ -15,27 +15,41 @@ */ package cn.odboy.task.service; +import cn.hutool.core.collection.CollUtil; +import cn.odboy.framework.exception.BadRequestException; +import cn.odboy.task.constant.TaskStatusEnum; import cn.odboy.task.dal.dataobject.TaskInstanceStepDetailTb; -import com.baomidou.mybatisplus.extension.service.IService; - +import cn.odboy.task.dal.mysql.TaskInstanceStepDetailMapper; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** *

- * 任务实例步骤明细 服务类 + * 任务实例步骤明细 *

* * @author codegen * @since 2025-09-28 */ -public interface TaskInstanceStepDetailService extends IService { +@Service +public class TaskInstanceStepDetailService { + @Autowired private TaskInstanceStepDetailMapper taskInstanceStepDetailMapper; + /** * 步骤执行成功 * * @param instanceDetailId 任务实例明细id * @param stepDesc 步骤描述 */ - void success(Long instanceDetailId, String stepDesc); + public void success(Long instanceDetailId, String stepDesc) { + TaskInstanceStepDetailTb stepDetail = new TaskInstanceStepDetailTb(); + stepDetail.setInstanceDetailId(instanceDetailId); + stepDetail.setStepDesc(stepDesc); + stepDetail.setStepStatus(TaskStatusEnum.Success.getCode()); + taskInstanceStepDetailMapper.insert(stepDetail); + } /** * 步骤执行失败 @@ -43,12 +57,26 @@ public interface TaskInstanceStepDetailService extends IService instanceDetailIds); + public void removeByInstanceDetailIds(List instanceDetailIds) { + if (CollUtil.isEmpty(instanceDetailIds)) { + return; + } + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.in(TaskInstanceStepDetailTb::getInstanceDetailId, instanceDetailIds); + taskInstanceStepDetailMapper.delete(wrapper); + } } diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskTemplateInfoService.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskTemplateInfoService.java index 6277818a..960b0716 100644 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskTemplateInfoService.java +++ b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/TaskTemplateInfoService.java @@ -15,18 +15,25 @@ */ package cn.odboy.task.service; -import cn.odboy.task.dal.dataobject.TaskTemplateInfoTb; import cn.odboy.task.dal.model.TaskTemplateInfoVo; -import com.baomidou.mybatisplus.extension.service.IService; +import cn.odboy.task.dal.mysql.TaskTemplateInfoMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; /** *

- * 任务模板 服务类 + * 任务模板 *

* * @author codegen * @since 2025-09-28 */ -public interface TaskTemplateInfoService extends IService { - TaskTemplateInfoVo getTemplateInfoByECL(String envAlias, String contextName, String language, String changeType); +@Service +public class TaskTemplateInfoService { + @Autowired private TaskTemplateInfoMapper taskTemplateInfoMapper; + + public TaskTemplateInfoVo getTemplateInfoByECL(String envAlias, String contextName, String language, + String changeType) { + return taskTemplateInfoMapper.selectTemplateInfoByECL(envAlias, contextName, language, changeType); + } } diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskInstanceDetailServiceImpl.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskInstanceDetailServiceImpl.java deleted file mode 100644 index df41dabe..00000000 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskInstanceDetailServiceImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2021-2025 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.task.service.impl; - -import cn.hutool.core.collection.CollUtil; -import cn.odboy.task.constant.TaskStatusEnum; -import cn.odboy.task.dal.dataobject.TaskInstanceDetailTb; -import cn.odboy.task.dal.mysql.TaskInstanceDetailMapper; -import cn.odboy.task.service.TaskInstanceDetailService; -import com.alibaba.fastjson2.JSON; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import java.util.Date; -import java.util.List; -import org.quartz.JobDataMap; -import org.springframework.stereotype.Service; - -/** - *

- * 任务实例明细 服务实现类 - *

- * - * @author codegen - * @since 2025-09-26 - */ -@Service -public class TaskInstanceDetailServiceImpl extends ServiceImpl - implements TaskInstanceDetailService { - - @Override - public TaskInstanceDetailTb getOneByInstanceIdAndCode(Long id, String code) { - return lambdaQuery().eq(TaskInstanceDetailTb::getInstanceId, id).eq(TaskInstanceDetailTb::getBizCode, code) - .one(); - } - - @Override - public void fastFailWithInfo(Long instanceId, String code, String executeInfo) { - TaskInstanceDetailTb updRecord = new TaskInstanceDetailTb(); - updRecord.setFinishTime(new Date()); - updRecord.setExecuteInfo(executeInfo); - updRecord.setExecuteStatus(TaskStatusEnum.Fail.getCode()); - lambdaUpdate().eq(TaskInstanceDetailTb::getInstanceId, instanceId).eq(TaskInstanceDetailTb::getBizCode, code) - .update(updRecord); - } - - @Override - public void fastSuccess(Long instanceId, String code) { - TaskInstanceDetailTb updRecord = new TaskInstanceDetailTb(); - updRecord.setFinishTime(new Date()); - updRecord.setExecuteInfo("执行成功"); - updRecord.setExecuteStatus(TaskStatusEnum.Success.getCode()); - lambdaUpdate().eq(TaskInstanceDetailTb::getInstanceId, instanceId).eq(TaskInstanceDetailTb::getBizCode, code) - .update(updRecord); - } - - @Override - public void fastSuccessWithInfo(Long instanceId, String code, String executeInfo) { - TaskInstanceDetailTb updRecord = new TaskInstanceDetailTb(); - updRecord.setFinishTime(new Date()); - updRecord.setExecuteInfo(executeInfo == null ? "执行成功" : executeInfo); - updRecord.setExecuteStatus(TaskStatusEnum.Success.getCode()); - lambdaUpdate().eq(TaskInstanceDetailTb::getInstanceId, instanceId).eq(TaskInstanceDetailTb::getBizCode, code) - .update(updRecord); - } - - @Override - public void fastStart(Long instanceId, String code, JobDataMap dataMap) { - TaskInstanceDetailTb updRecord = new TaskInstanceDetailTb(); - updRecord.setStartTime(new Date()); - updRecord.setExecuteInfo("运行中"); - updRecord.setExecuteParams(JSON.toJSONString(dataMap)); - updRecord.setExecuteStatus(TaskStatusEnum.Running.getCode()); - lambdaUpdate().eq(TaskInstanceDetailTb::getInstanceId, instanceId).eq(TaskInstanceDetailTb::getBizCode, code) - .update(updRecord); - } - - @Override - public List queryByInstanceIdAndBizCodeList(Long instanceId, List bizCodeList) { - if (CollUtil.isEmpty(bizCodeList)) { - return CollUtil.newArrayList(); - } - return lambdaQuery().eq(TaskInstanceDetailTb::getInstanceId, instanceId) - .in(TaskInstanceDetailTb::getBizCode, bizCodeList).list(); - } - - @Override - public List queryByInstanceId(Long instanceId) { - return lambdaQuery().eq(TaskInstanceDetailTb::getInstanceId, instanceId).orderByAsc(TaskInstanceDetailTb::getId) - .list(); - } -} diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskInstanceInfoServiceImpl.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskInstanceInfoServiceImpl.java deleted file mode 100644 index c898bb31..00000000 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskInstanceInfoServiceImpl.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright 2021-2025 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.task.service.impl; - -import cn.odboy.task.constant.TaskStatusEnum; -import cn.odboy.task.dal.dataobject.TaskInstanceInfoTb; -import cn.odboy.task.dal.mysql.TaskInstanceInfoMapper; -import cn.odboy.task.service.TaskInstanceInfoService; -import com.alibaba.fastjson2.JSON; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.quartz.JobDataMap; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Date; - -/** - *

- * 任务实例 服务实现类 - *

- * - * @author codegen - * @since 2025-09-26 - */ -@Service -public class TaskInstanceInfoServiceImpl extends ServiceImpl implements TaskInstanceInfoService { - - @Override - public TaskInstanceInfoTb getRunningById(Long id) { - return lambdaQuery().eq(TaskInstanceInfoTb::getId, id).eq(TaskInstanceInfoTb::getStatus, TaskStatusEnum.Running.getCode()) - .orderByDesc(TaskInstanceInfoTb::getId).one(); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void fastFailWithMessage(Long id, String errorMessage) { - TaskInstanceInfoTb updRecord = new TaskInstanceInfoTb(); - updRecord.setId(id); - updRecord.setFinishTime(new Date()); - updRecord.setStatus(TaskStatusEnum.Fail.getCode()); - updRecord.setErrorMessage(errorMessage); - updateById(updRecord); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void fastFailWithMessageData(Long id, String errorMessage, JobDataMap dataMap) { - TaskInstanceInfoTb updRecord = new TaskInstanceInfoTb(); - updRecord.setId(id); - updRecord.setFinishTime(new Date()); - updRecord.setStatus(TaskStatusEnum.Fail.getCode()); - updRecord.setErrorMessage(errorMessage); - updRecord.setJobData(JSON.toJSONString(dataMap)); - updateById(updRecord); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void fastSuccessWithData(Long id, JobDataMap dataMap) { - TaskInstanceInfoTb updRecord = new TaskInstanceInfoTb(); - updRecord.setId(id); - updRecord.setFinishTime(new Date()); - updRecord.setStatus(TaskStatusEnum.Success.getCode()); - updRecord.setJobData(JSON.toJSONString(dataMap)); - updateById(updRecord); - } - - @Override - public TaskInstanceInfoTb getLastRunningInstance(String contextName, String language, String envAlias, String changeType) { - return lambdaQuery().eq(TaskInstanceInfoTb::getContextName, contextName).eq(TaskInstanceInfoTb::getLanguage, language) - .eq(TaskInstanceInfoTb::getEnvAlias, envAlias).eq(TaskInstanceInfoTb::getChangeType, changeType) - .eq(TaskInstanceInfoTb::getStatus, TaskStatusEnum.Running.getCode()).orderByDesc(TaskInstanceInfoTb::getId).one(); - } - - @Override - public TaskInstanceInfoTb getLastHistoryInstance(String contextName, String language, String envAlias, String changeType) { - return lambdaQuery().eq(TaskInstanceInfoTb::getContextName, contextName).eq(TaskInstanceInfoTb::getLanguage, language) - .eq(TaskInstanceInfoTb::getEnvAlias, envAlias).eq(TaskInstanceInfoTb::getChangeType, changeType).orderByDesc(TaskInstanceInfoTb::getId) - .last("LIMIT 1").one(); - } -} diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskInstanceStepDetailServiceImpl.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskInstanceStepDetailServiceImpl.java deleted file mode 100644 index 6800757f..00000000 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskInstanceStepDetailServiceImpl.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2021-2025 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.task.service.impl; - -import cn.hutool.core.collection.CollUtil; -import cn.odboy.framework.exception.BadRequestException; -import cn.odboy.task.constant.TaskStatusEnum; -import cn.odboy.task.dal.dataobject.TaskInstanceStepDetailTb; -import cn.odboy.task.dal.mysql.TaskInstanceStepDetailMapper; -import cn.odboy.task.service.TaskInstanceStepDetailService; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; - -import java.util.List; - -/** - *

- * 任务实例步骤明细 服务实现类 - *

- * - * @author codegen - * @since 2025-09-28 - */ -@Service -public class TaskInstanceStepDetailServiceImpl extends ServiceImpl - implements TaskInstanceStepDetailService { - - @Override - public void success(Long instanceDetailId, String stepDesc) { - TaskInstanceStepDetailTb stepDetail = new TaskInstanceStepDetailTb(); - stepDetail.setInstanceDetailId(instanceDetailId); - stepDetail.setStepDesc(stepDesc); - stepDetail.setStepStatus(TaskStatusEnum.Success.getCode()); - save(stepDetail); - } - - @Override - public void fail(Long instanceDetailId, String stepDesc) { - TaskInstanceStepDetailTb stepDetail = new TaskInstanceStepDetailTb(); - stepDetail.setInstanceDetailId(instanceDetailId); - stepDetail.setStepDesc(stepDesc); - stepDetail.setStepStatus(TaskStatusEnum.Fail.getCode()); - save(stepDetail); - throw new BadRequestException(stepDesc); - } - - @Override - public void removeByInstanceDetailIds(List instanceDetailIds) { - if (CollUtil.isEmpty(instanceDetailIds)) { - return; - } - remove(new LambdaQueryWrapper().in(TaskInstanceStepDetailTb::getInstanceDetailId, instanceDetailIds)); - } -} diff --git a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskTemplateInfoServiceImpl.java b/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskTemplateInfoServiceImpl.java deleted file mode 100644 index 2a8ed83f..00000000 --- a/cutejava/cutejava-module-task-v2/src/main/java/cn/odboy/task/service/impl/TaskTemplateInfoServiceImpl.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2021-2025 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.task.service.impl; - -import cn.odboy.task.dal.dataobject.TaskTemplateInfoTb; -import cn.odboy.task.dal.model.TaskTemplateInfoVo; -import cn.odboy.task.dal.mysql.TaskTemplateInfoMapper; -import cn.odboy.task.service.TaskTemplateInfoService; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; - -/** - *

- * 任务模板 服务实现类 - *

- * - * @author codegen - * @since 2025-09-28 - */ -@Service -public class TaskTemplateInfoServiceImpl extends ServiceImpl implements TaskTemplateInfoService { - - @Override - public TaskTemplateInfoVo getTemplateInfoByECL(String envAlias, String contextName, String language, String changeType) { - return baseMapper.selectTemplateInfoByECL(envAlias, contextName, language, changeType); - } -} diff --git a/cutejava/cutejava-module-task-v2/src/main/resources/mapper/TaskInstanceDetailMapper.xml b/cutejava/cutejava-module-task-v2/src/main/resources/mapper/TaskInstanceDetailMapper.xml index 9c151269..794721f9 100644 --- a/cutejava/cutejava-module-task-v2/src/main/resources/mapper/TaskInstanceDetailMapper.xml +++ b/cutejava/cutejava-module-task-v2/src/main/resources/mapper/TaskInstanceDetailMapper.xml @@ -1,5 +1,4 @@ - diff --git a/cutejava/cutejava-module-task-v2/src/main/resources/mapper/TaskInstanceInfoMapper.xml b/cutejava/cutejava-module-task-v2/src/main/resources/mapper/TaskInstanceInfoMapper.xml index 4896649c..aba16383 100644 --- a/cutejava/cutejava-module-task-v2/src/main/resources/mapper/TaskInstanceInfoMapper.xml +++ b/cutejava/cutejava-module-task-v2/src/main/resources/mapper/TaskInstanceInfoMapper.xml @@ -1,5 +1,4 @@ - diff --git a/cutejava/cutejava-starter/pom.xml b/cutejava/cutejava-starter/pom.xml index 66f75a22..da67bf5e 100644 --- a/cutejava/cutejava-starter/pom.xml +++ b/cutejava/cutejava-starter/pom.xml @@ -7,10 +7,8 @@ 1.4.1 4.0.0 - cutejava-starter 启动模块 - cn.odboy @@ -18,7 +16,6 @@ 1.4.1 - diff --git a/cutejava/cutejava-starter/src/main/java/cn/odboy/AppRun.java b/cutejava/cutejava-starter/src/main/java/cn/odboy/AppRun.java index 092d1cbe..8c0b76d4 100644 --- a/cutejava/cutejava-starter/src/main/java/cn/odboy/AppRun.java +++ b/cutejava/cutejava-starter/src/main/java/cn/odboy/AppRun.java @@ -13,22 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy; import cn.odboy.framework.context.BootApplication; import io.swagger.annotations.Api; +import java.net.UnknownHostException; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cache.annotation.EnableCaching; -import java.net.UnknownHostException; - @Api(hidden = true) @EnableCaching @SpringBootApplication public class AppRun extends BootApplication { - public static void main(String[] args) throws UnknownHostException { SpringApplication springApplication = new SpringApplication(AppRun.class); inited(springApplication.run(args)); diff --git a/cutejava/cutejava-starter/src/main/java/cn/odboy/GenCode.java b/cutejava/cutejava-starter/src/main/java/cn/odboy/GenCode.java index a6e3cd3f..ea8064de 100644 --- a/cutejava/cutejava-starter/src/main/java/cn/odboy/GenCode.java +++ b/cutejava/cutejava-starter/src/main/java/cn/odboy/GenCode.java @@ -13,11 +13,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy; import cn.odboy.framework.mybatisplus.core.KitMpCmdGenUtil; - import java.util.List; /** @@ -41,6 +39,7 @@ public class GenCode { } private static void genTaskCode(KitMpCmdGenUtil generator) { - generator.gen("task", "", List.of("task_instance_info", "task_instance_detail", "task_template_info", "task_instance_step_detail")); + generator.gen("task", "", + List.of("task_instance_info", "task_instance_detail", "task_template_info", "task_instance_step_detail")); } } diff --git a/cutejava/cutejava-starter/src/main/java/cn/odboy/HealthCheckPointer.java b/cutejava/cutejava-starter/src/main/java/cn/odboy/HealthCheckPointer.java index 6e5c3ed2..5da45267 100644 --- a/cutejava/cutejava-starter/src/main/java/cn/odboy/HealthCheckPointer.java +++ b/cutejava/cutejava-starter/src/main/java/cn/odboy/HealthCheckPointer.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy; import cn.odboy.framework.monitor.service.KitHealthCheckPointService; @@ -24,8 +23,7 @@ import org.springframework.stereotype.Component; @Component public class HealthCheckPointer implements KitHealthCheckPointService { - @Autowired - private SystemDictService systemDictService; + @Autowired private SystemDictService systemDictService; /** * 系统准备就绪 diff --git a/cutejava/cutejava-starter/src/test/java/cn/odboy/MyBatisMapperTests.java b/cutejava/cutejava-starter/src/test/java/cn/odboy/MyBatisMapperTests.java index 439fa05d..1c775267 100644 --- a/cutejava/cutejava-starter/src/test/java/cn/odboy/MyBatisMapperTests.java +++ b/cutejava/cutejava-starter/src/test/java/cn/odboy/MyBatisMapperTests.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy; import cn.hutool.core.date.DateTime; @@ -21,30 +20,27 @@ import cn.hutool.core.date.DateUtil; 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.Date; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import java.util.Date; - @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class MyBatisMapperTests { - @Autowired - private SystemUserMapper systemUserMapper; + @Autowired private SystemUserMapper systemUserMapper; @Test public void testMapper1() { // SELECT * FROM system_user WHERE (create_time > '2025-08-18T14:48:18.400+0800'); systemUserMapper.selectList(new LambdaQueryWrapper().gt(SystemUserTb::getCreateTime, new Date())); - // SELECT * FROM system_user WHERE (create_time > '2025-08-18T14:50:16.786+0800'); - systemUserMapper.selectList(new LambdaQueryWrapper().gt(SystemUserTb::getCreateTime, DateTime.now())); - + systemUserMapper.selectList( + new LambdaQueryWrapper().gt(SystemUserTb::getCreateTime, DateTime.now())); // SELECT * FROM system_user WHERE (create_time > '2025-08-18 14:53:46'); - systemUserMapper.selectList(new LambdaQueryWrapper().gt(SystemUserTb::getCreateTime, DateUtil.formatDateTime(new Date()))); - + systemUserMapper.selectList(new LambdaQueryWrapper().gt(SystemUserTb::getCreateTime, + DateUtil.formatDateTime(new Date()))); // SELECT * FROM system_user WHERE (create_time > '2025-08-18'); - systemUserMapper.selectList(new LambdaQueryWrapper().gt(SystemUserTb::getCreateTime, DateUtil.formatDate(new Date()))); + systemUserMapper.selectList( + new LambdaQueryWrapper().gt(SystemUserTb::getCreateTime, DateUtil.formatDate(new Date()))); } } - diff --git a/cutejava/cutejava-starter/src/test/java/cn/odboy/SystemApplicationTests.java b/cutejava/cutejava-starter/src/test/java/cn/odboy/SystemApplicationTests.java index d842c208..132891f6 100644 --- a/cutejava/cutejava-starter/src/test/java/cn/odboy/SystemApplicationTests.java +++ b/cutejava/cutejava-starter/src/test/java/cn/odboy/SystemApplicationTests.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy; import cn.hutool.core.collection.CollUtil; @@ -22,19 +21,16 @@ import cn.odboy.system.dal.dataobject.SystemJobTb; import cn.odboy.system.dal.dataobject.SystemRoleTb; import cn.odboy.system.dal.dataobject.SystemUserTb; import cn.odboy.system.service.SystemUserService; +import java.util.Set; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.security.crypto.password.PasswordEncoder; -import java.util.Set; - @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class SystemApplicationTests { - @Autowired - private PasswordEncoder passwordEncoder; - @Autowired - private SystemUserService systemUserService; + @Autowired private PasswordEncoder passwordEncoder; + @Autowired private SystemUserService systemUserService; public static void main(String[] args) { } @@ -43,15 +39,12 @@ public class SystemApplicationTests { public void contextLoads() { SystemDeptTb systemDept = new SystemDeptTb(); systemDept.setId(2L); - SystemJobTb systemJob = new SystemJobTb(); systemJob.setId(11L); Set systemJobs = CollUtil.newHashSet(systemJob); - SystemRoleTb systemRole = new SystemRoleTb(); systemRole.setId(2L); Set systemRoles = CollUtil.newHashSet(systemRole); - String pwd = passwordEncoder.encode("123456"); for (int i = 100; i < 200; i++) { SystemUserTb systemUser = new SystemUserTb(); @@ -67,4 +60,3 @@ public class SystemApplicationTests { } } } - diff --git a/cutejava/cutejava-starter/src/test/java/cn/odboy/util/KitDesEncryptUtilTest.java b/cutejava/cutejava-starter/src/test/java/cn/odboy/util/KitDesEncryptUtilTest.java index e9cb66cf..83d05e13 100644 --- a/cutejava/cutejava-starter/src/test/java/cn/odboy/util/KitDesEncryptUtilTest.java +++ b/cutejava/cutejava-starter/src/test/java/cn/odboy/util/KitDesEncryptUtilTest.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import lombok.SneakyThrows; @@ -24,7 +23,6 @@ import static cn.odboy.util.KitDesEncryptUtil.desEncrypt; import static org.junit.jupiter.api.Assertions.assertEquals; public class KitDesEncryptUtilTest { - @SneakyThrows public static void main(String[] args) { System.err.println(desEncrypt("abc12345678")); diff --git a/cutejava/cutejava-starter/src/test/java/cn/odboy/util/KitFileUtilTest.java b/cutejava/cutejava-starter/src/test/java/cn/odboy/util/KitFileUtilTest.java index b022afd0..73e1afd3 100644 --- a/cutejava/cutejava-starter/src/test/java/cn/odboy/util/KitFileUtilTest.java +++ b/cutejava/cutejava-starter/src/test/java/cn/odboy/util/KitFileUtilTest.java @@ -13,17 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; import org.junit.jupiter.api.Test; import org.springframework.mock.web.MockMultipartFile; -import static cn.odboy.util.KitFileUtil.*; +import static cn.odboy.util.KitFileUtil.getPrefix; +import static cn.odboy.util.KitFileUtil.getSize; +import static cn.odboy.util.KitFileUtil.getSuffix; +import static cn.odboy.util.KitFileUtil.toFile; import static org.junit.jupiter.api.Assertions.assertEquals; public class KitFileUtilTest { - @Test public void testToFile() { long retval = toFile(new MockMultipartFile("foo", (byte[])null)).getTotalSpace(); diff --git a/cutejava/cutejava-starter/src/test/java/cn/odboy/util/KitStringUtilTest.java b/cutejava/cutejava-starter/src/test/java/cn/odboy/util/KitStringUtilTest.java index b3aca1ff..b038246c 100644 --- a/cutejava/cutejava-starter/src/test/java/cn/odboy/util/KitStringUtilTest.java +++ b/cutejava/cutejava-starter/src/test/java/cn/odboy/util/KitStringUtilTest.java @@ -13,21 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.springframework.mock.web.MockHttpServletRequest; - import java.text.SimpleDateFormat; import java.util.Date; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springframework.mock.web.MockHttpServletRequest; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; public class KitStringUtilTest { - @Test public void testToCamelCase() { assertNull(KitStringUtil.toCamelCase(null)); diff --git a/cutejava/cutejava-starter/src/test/java/cn/odboy/util/WorkTimeTests.java b/cutejava/cutejava-starter/src/test/java/cn/odboy/util/WorkTimeTests.java index e1f63909..aebb7c97 100644 --- a/cutejava/cutejava-starter/src/test/java/cn/odboy/util/WorkTimeTests.java +++ b/cutejava/cutejava-starter/src/test/java/cn/odboy/util/WorkTimeTests.java @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package cn.odboy.util; /** diff --git a/cutejava/pom.xml b/cutejava/pom.xml index 025daa50..8a45e46d 100644 --- a/cutejava/pom.xml +++ b/cutejava/pom.xml @@ -396,7 +396,7 @@ public aliyun nexus - http://maven.aliyun.com/nexus/content/groups/public/ + https://maven.aliyun.com/nexus/content/groups/public/ true @@ -407,7 +407,7 @@ public aliyun nexus - http://maven.aliyun.com/nexus/content/groups/public/ + https://maven.aliyun.com/nexus/content/groups/public/ true