From 7c35a79c955b66ad92e89c9b8944e14d2d84580a Mon Sep 17 00:00:00 2001 From: ZhengJie <201507802@qq.com> Date: Tue, 5 May 2020 20:58:02 +0800 Subject: [PATCH] =?UTF-8?q?[=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD](el-admin?= =?UTF-8?q?=20v2.5):=20v2.5=20beta?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 详情 https://www.ydyno.com/archives/1225.html --- LICENSE | 2 +- .../zhengjie/annotation/AnonymousAccess.java | 15 + .../java/me/zhengjie/annotation/Limit.java | 16 +- .../java/me/zhengjie/annotation/Query.java | 15 + .../java/me/zhengjie/aspect/LimitAspect.java | 15 + .../java/me/zhengjie/aspect/LimitType.java | 15 + .../main/java/me/zhengjie/base/BaseDTO.java | 13 +- .../java/me/zhengjie/base/BaseEntity.java | 52 +-- .../java/me/zhengjie/base/BaseMapper.java | 15 + .../me/zhengjie/config/AuditorConfig.java | 16 +- .../zhengjie/config/ElPermissionConfig.java | 15 + .../me/zhengjie/config/FileProperties.java | 15 + .../java/me/zhengjie/config/RedisConfig.java | 15 + .../me/zhengjie/config/SwaggerConfig.java | 23 +- .../exception/BadRequestException.java | 15 + .../exception/EntityExistException.java | 15 + .../exception/EntityNotFoundException.java | 15 + .../zhengjie/exception/handler/ApiError.java | 16 +- .../handler/GlobalExceptionHandler.java | 16 +- .../me/zhengjie/utils/ElAdminConstant.java | 19 +- .../java/me/zhengjie/utils/EncryptUtils.java | 17 +- .../main/java/me/zhengjie/utils/FileUtil.java | 15 + .../main/java/me/zhengjie/utils/PageUtil.java | 15 + .../java/me/zhengjie/utils/QueryHelp.java | 15 + .../java/me/zhengjie/utils/RedisUtils.java | 15 + .../java/me/zhengjie/utils/RequestHolder.java | 15 + .../java/me/zhengjie/utils/SecurityUtils.java | 15 + .../zhengjie/utils/SpringContextHolder.java | 15 + .../java/me/zhengjie/utils/StringUtils.java | 37 ++ .../java/me/zhengjie/utils/ThrowableUtil.java | 15 + .../me/zhengjie/utils/TranslatorUtil.java | 15 + .../me/zhengjie/utils/ValidationUtil.java | 15 + .../java/me/zhengjie/domain/ColumnInfo.java | 55 ++- .../java/me/zhengjie/domain/GenConfig.java | 53 ++- .../java/me/zhengjie/domain/vo/TableInfo.java | 15 + .../repository/ColumnInfoRepository.java | 15 + .../repository/GenConfigRepository.java | 15 + .../me/zhengjie/rest/GenConfigController.java | 21 +- .../me/zhengjie/rest/GeneratorController.java | 23 +- .../me/zhengjie/service/GenConfigService.java | 15 + .../me/zhengjie/service/GeneratorService.java | 17 +- .../service/impl/GenConfigServiceImpl.java | 27 +- .../service/impl/GeneratorServiceImpl.java | 26 +- .../main/java/me/zhengjie/utils/ColUtil.java | 15 + .../main/java/me/zhengjie/utils/GenUtil.java | 15 + .../main/java/me/zhengjie/aop/log/Log.java | 15 + .../java/me/zhengjie/aspect/LogAspect.java | 16 +- .../src/main/java/me/zhengjie/domain/Log.java | 30 +- .../me/zhengjie/repository/LogRepository.java | 28 +- .../java/me/zhengjie/rest/LogController.java | 23 +- .../java/me/zhengjie/service/LogService.java | 15 + .../me/zhengjie/service/dto/LogErrorDTO.java | 15 + .../service/dto/LogQueryCriteria.java | 15 + .../me/zhengjie/service/dto/LogSmallDTO.java | 15 + .../zhengjie/service/impl/LogServiceImpl.java | 26 +- .../service/mapper/LogErrorMapper.java | 15 + .../service/mapper/LogSmallMapper.java | 15 + eladmin-monitor/README.md | 33 -- eladmin-monitor/pom.xml | 81 ---- .../src/main/java/me/zhengjie/MonitorRun.java | 20 - .../zhengjie/res/ServerMonitorController.java | 65 ---- eladmin-monitor/src/main/resources/banner.txt | 8 - .../src/main/resources/config/application.yml | 2 - .../src/main/resources/logback.xml | 17 - .../test/java/me/zhengjie/SystemInfoTest.java | 364 ------------------ eladmin-system/pom.xml | 8 + .../src/main/java/me/zhengjie/AppRun.java | 19 +- .../me/zhengjie/config/ConfigurerAdapter.java | 15 + .../java/me/zhengjie/config/DataScope.java | 15 + .../me/zhengjie/config/WebSocketConfig.java | 15 + .../config/thread/AsyncTaskExecutePool.java | 15 + .../config/thread/AsyncTaskProperties.java | 15 + .../config/thread/TheadFactoryName.java | 15 + .../config/thread/ThreadPoolExecutorUtil.java | 15 + .../me/zhengjie/modules/mnt/domain/App.java | 71 ++-- .../zhengjie/modules/mnt/domain/Database.java | 57 ++- .../zhengjie/modules/mnt/domain/Deploy.java | 54 +-- .../modules/mnt/domain/DeployHistory.java | 54 +-- .../modules/mnt/domain/ServerDeploy.java | 38 +- .../modules/mnt/repository/AppRepository.java | 15 + .../mnt/repository/DatabaseRepository.java | 15 + .../repository/DeployHistoryRepository.java | 15 + .../mnt/repository/DeployRepository.java | 15 + .../repository/ServerDeployRepository.java | 15 + .../modules/mnt/rest/AppController.java | 23 +- .../modules/mnt/rest/DatabaseController.java | 26 +- .../modules/mnt/rest/DeployController.java | 25 +- .../mnt/rest/DeployHistoryController.java | 23 +- .../mnt/rest/ServerDeployController.java | 23 +- .../modules/mnt/service/AppService.java | 15 + .../modules/mnt/service/DatabaseService.java | 15 + .../mnt/service/DeployHistoryService.java | 15 + .../modules/mnt/service/DeployService.java | 15 + .../mnt/service/ServerDeployService.java | 15 + .../modules/mnt/service/dto/AppDto.java | 29 +- .../mnt/service/dto/AppQueryCriteria.java | 16 +- .../modules/mnt/service/dto/DatabaseDto.java | 28 +- .../service/dto/DatabaseQueryCriteria.java | 16 +- .../modules/mnt/service/dto/DeployDto.java | 27 +- .../mnt/service/dto/DeployHistoryDto.java | 16 +- .../dto/DeployHistoryQueryCriteria.java | 15 + .../mnt/service/dto/DeployQueryCriteria.java | 15 + .../mnt/service/dto/ServerDeployDto.java | 28 +- .../dto/ServerDeployQueryCriteria.java | 16 +- .../mnt/service/impl/AppServiceImpl.java | 27 +- .../mnt/service/impl/DatabaseServiceImpl.java | 30 +- .../impl/DeployHistoryServiceImpl.java | 24 +- .../mnt/service/impl/DeployServiceImpl.java | 29 +- .../service/impl/ServerDeployServiceImpl.java | 27 +- .../modules/mnt/service/mapper/AppMapper.java | 15 + .../mnt/service/mapper/DatabaseMapper.java | 15 + .../service/mapper/DeployHistoryMapper.java | 15 + .../mnt/service/mapper/DeployMapper.java | 15 + .../service/mapper/ServerDeployMapper.java | 15 + .../modules/mnt/util/ExecuteShellUtil.java | 15 + .../modules/mnt/util/ScpClientUtil.java | 15 + .../zhengjie/modules/mnt/util/SqlUtils.java | 15 + .../zhengjie/modules/mnt/util/ZipUtils.java | 15 + .../modules/mnt/websocket/MsgType.java | 19 +- .../modules/mnt/websocket/SocketMsg.java | 19 +- .../mnt/websocket/WebSocketServer.java | 19 +- .../monitor/config/VisitsInitialization.java | 27 -- .../modules/monitor/domain/Server.java | 107 ----- .../modules/monitor/domain/Visits.java | 40 -- .../modules/monitor/domain/vo/RedisVo.java | 24 -- .../monitor/repository/ServerRepository.java | 12 - .../monitor/repository/VisitsRepository.java | 31 -- .../monitor/rest/ServerController.java | 66 ---- .../monitor/rest/VisitsController.java | 47 --- .../monitor/service/ServerService.java | 59 --- .../monitor/service/VisitsService.java | 35 -- .../monitor/service/dto/ServerDTO.java | 49 --- .../service/dto/ServerQueryCriteria.java | 15 - .../service/impl/ServerServiceImpl.java | 101 ----- .../service/impl/VisitsServiceImpl.java | 90 ----- .../monitor/service/mapper/ServerMapper.java | 16 - .../modules/quartz/config/JobRunner.java | 24 +- .../modules/quartz/config/QuartzConfig.java | 15 + .../modules/quartz/domain/QuartzJob.java | 67 ++-- .../modules/quartz/domain/QuartzLog.java | 47 ++- .../repository/QuartzJobRepository.java | 15 + .../repository/QuartzLogRepository.java | 15 + .../quartz/rest/QuartzJobController.java | 25 +- .../quartz/service/QuartzJobService.java | 15 + .../quartz/service/dto/JobQueryCriteria.java | 16 +- .../service/impl/QuartzJobServiceImpl.java | 40 +- .../modules/quartz/task/TestTask.java | 23 +- .../modules/quartz/task/VisitsTask.java | 22 -- .../modules/quartz/utils/ExecutionJob.java | 64 ++- .../modules/quartz/utils/QuartzManage.java | 15 + .../modules/quartz/utils/QuartzRunnable.java | 21 +- .../security/config/SecurityConfig.java | 26 +- .../security/config/SecurityProperties.java | 15 + .../rest/AuthorizationController.java | 28 +- .../security/rest/OnlineController.java | 21 +- .../security/JwtAccessDeniedHandler.java | 15 + .../security/JwtAuthenticationEntryPoint.java | 15 + .../security/security/TokenConfigurer.java | 21 +- .../security/security/TokenFilter.java | 21 +- .../security/security/TokenProvider.java | 22 +- .../security/service/OnlineUserService.java | 25 +- .../service/UserDetailsServiceImpl.java | 23 +- .../security/service/dto/AuthUserDto.java | 15 + .../security/service/dto/JwtUserDto.java | 15 + .../security/service/dto/OnlineUserDto.java | 17 +- .../zhengjie/modules/system/domain/Dept.java | 54 ++- .../zhengjie/modules/system/domain/Dict.java | 45 ++- .../modules/system/domain/DictDetail.java | 54 +-- .../zhengjie/modules/system/domain/Job.java | 46 ++- .../zhengjie/modules/system/domain/Menu.java | 86 +++-- .../zhengjie/modules/system/domain/Role.java | 73 ++-- .../zhengjie/modules/system/domain/User.java | 118 +++--- .../modules/system/domain/UserAvatar.java | 45 --- .../modules/system/domain/vo/MenuMetaVo.java | 15 + .../modules/system/domain/vo/MenuVo.java | 15 + .../modules/system/domain/vo/UserPassVo.java | 15 + .../system/repository/DeptRepository.java | 17 +- .../repository/DictDetailRepository.java | 15 + .../system/repository/DictRepository.java | 15 + .../system/repository/JobRepository.java | 22 ++ .../system/repository/MenuRepository.java | 23 +- .../system/repository/RoleRepository.java | 22 +- .../repository/UserAvatarRepository.java | 13 - .../system/repository/UserRepository.java | 19 +- .../modules/system/rest/DeptController.java | 24 +- .../modules/system/rest/DictController.java | 27 +- .../system/rest/DictDetailController.java | 26 +- .../modules/system/rest/JobController.java | 30 +- .../rest/LimitController.java | 17 +- .../modules/system/rest/MenuController.java | 33 +- .../system/rest/MonitorController.java | 46 +++ .../modules/system/rest/RoleController.java | 27 +- .../modules/system/rest/UserController.java | 35 +- .../modules/system/rest/VerifyController.java | 74 ++++ .../modules/system/service/DeptService.java | 15 + .../system/service/DictDetailService.java | 15 + .../modules/system/service/DictService.java | 15 + .../modules/system/service/JobService.java | 15 + .../modules/system/service/MenuService.java | 15 + .../system/service/MonitorService.java | 31 ++ .../modules/system/service/RoleService.java | 15 + .../modules/system/service/UserService.java | 15 + .../modules/system/service/VerifyService.java | 41 ++ .../modules/system/service/dto/DeptDto.java | 37 +- .../system/service/dto/DeptQueryCriteria.java | 15 + .../system/service/dto/DeptSmallDto.java | 15 + .../system/service/dto/DictDetailDto.java | 27 +- .../service/dto/DictDetailQueryCriteria.java | 15 + .../modules/system/service/dto/DictDto.java | 28 +- .../system/service/dto/DictQueryCriteria.java | 15 + .../system/service/dto/DictSmallDto.java | 15 + .../modules/system/service/dto/JobDto.java | 26 +- .../system/service/dto/JobQueryCriteria.java | 22 +- .../system/service/dto/JobSmallDto.java | 15 + .../modules/system/service/dto/MenuDto.java | 35 +- .../system/service/dto/MenuQueryCriteria.java | 18 +- .../modules/system/service/dto/RoleDto.java | 39 +- .../system/service/dto/RoleQueryCriteria.java | 15 + .../system/service/dto/RoleSmallDto.java | 15 + .../modules/system/service/dto/UserDto.java | 77 ++-- .../system/service/dto/UserQueryCriteria.java | 15 + .../system/service/impl/DeptServiceImpl.java | 23 +- .../service/impl/DictDetailServiceImpl.java | 23 +- .../system/service/impl/DictServiceImpl.java | 28 +- .../system/service/impl/JobServiceImpl.java | 44 ++- .../system/service/impl/MenuServiceImpl.java | 48 ++- .../service/impl/MonitorServiceImpl.java | 172 +++++++++ .../system/service/impl/RoleServiceImpl.java | 52 +-- .../system/service/impl/UserServiceImpl.java | 54 +-- .../service/impl/VerifyServiceImpl.java | 83 ++++ .../system/service/mapper/DeptMapper.java | 15 + .../service/mapper/DeptSmallMapper.java | 15 + .../service/mapper/DictDetailMapper.java | 15 + .../system/service/mapper/DictMapper.java | 15 + .../service/mapper/DictSmallMapper.java | 15 + .../system/service/mapper/JobMapper.java | 25 +- .../system/service/mapper/JobSmallMapper.java | 15 + .../system/service/mapper/MenuMapper.java | 15 + .../system/service/mapper/RoleMapper.java | 15 + .../service/mapper/RoleSmallMapper.java | 15 + .../system/service/mapper/UserMapper.java | 25 +- .../main/resources/config/application-dev.yml | 6 - .../resources/config/application-prod.yml | 6 - .../src/main/resources/config/application.yml | 5 +- .../main/resources/template/email/email.ftl | 11 +- .../template/generator/admin/Controller.ftl | 19 +- .../template/generator/admin/Dto.ftl | 19 +- .../template/generator/admin/Entity.ftl | 28 +- .../template/generator/admin/Mapper.ftl | 19 +- .../generator/admin/QueryCriteria.ftl | 19 +- .../template/generator/admin/Repository.ftl | 19 +- .../template/generator/admin/Service.ftl | 19 +- .../template/generator/admin/ServiceImpl.ftl | 32 +- .../me/zhengjie/config/MultipartConfig.java | 15 + .../java/me/zhengjie/domain/AlipayConfig.java | 47 ++- .../java/me/zhengjie/domain/EmailConfig.java | 31 +- .../java/me/zhengjie/domain/LocalStorage.java | 56 +-- .../main/java/me/zhengjie/domain/Picture.java | 30 +- .../java/me/zhengjie/domain/QiniuConfig.java | 33 +- .../java/me/zhengjie/domain/QiniuContent.java | 33 +- .../me/zhengjie/domain/VerificationCode.java | 55 --- .../java/me/zhengjie/domain/vo/EmailVo.java | 16 +- .../java/me/zhengjie/domain/vo/TradeVo.java | 16 +- .../zhengjie/repository/AliPayRepository.java | 15 + .../zhengjie/repository/EmailRepository.java | 15 + .../repository/LocalStorageRepository.java | 15 + .../repository/PictureRepository.java | 15 + .../repository/QiNiuConfigRepository.java | 15 + .../repository/QiniuContentRepository.java | 15 + .../VerificationCodeRepository.java | 20 - .../me/zhengjie/rest/AliPayController.java | 23 +- .../me/zhengjie/rest/EmailController.java | 21 +- .../zhengjie/rest/LocalStorageController.java | 23 +- .../me/zhengjie/rest/PictureController.java | 21 +- .../me/zhengjie/rest/QiniuController.java | 21 +- .../rest/VerificationCodeController.java | 59 --- .../me/zhengjie/service/AliPayService.java | 15 + .../me/zhengjie/service/EmailService.java | 18 +- .../zhengjie/service/LocalStorageService.java | 15 + .../me/zhengjie/service/PictureService.java | 15 + .../me/zhengjie/service/QiNiuService.java | 15 + .../service/VerificationCodeService.java | 24 -- .../zhengjie/service/dto/LocalStorageDto.java | 29 +- .../dto/LocalStorageQueryCriteria.java | 17 +- .../service/dto/PictureQueryCriteria.java | 16 +- .../service/dto/QiniuQueryCriteria.java | 15 + .../service/impl/AliPayServiceImpl.java | 21 +- .../service/impl/EmailServiceImpl.java | 21 +- .../service/impl/LocalStorageServiceImpl.java | 31 +- .../service/impl/PictureServiceImpl.java | 25 +- .../service/impl/QiNiuServiceImpl.java | 23 +- .../impl/VerificationCodeServiceImpl.java | 87 ----- .../service/mapper/LocalStorageMapper.java | 15 + .../me/zhengjie/utils/AliPayStatusEnum.java | 15 + .../java/me/zhengjie/utils/AlipayUtils.java | 15 + .../java/me/zhengjie/utils/QiNiuUtil.java | 15 + pom.xml | 1 - 297 files changed, 5096 insertions(+), 2853 deletions(-) rename {eladmin-system => eladmin-common}/src/main/java/me/zhengjie/config/AuditorConfig.java (52%) delete mode 100644 eladmin-monitor/README.md delete mode 100644 eladmin-monitor/pom.xml delete mode 100644 eladmin-monitor/src/main/java/me/zhengjie/MonitorRun.java delete mode 100644 eladmin-monitor/src/main/java/me/zhengjie/res/ServerMonitorController.java delete mode 100644 eladmin-monitor/src/main/resources/banner.txt delete mode 100644 eladmin-monitor/src/main/resources/config/application.yml delete mode 100644 eladmin-monitor/src/main/resources/logback.xml delete mode 100644 eladmin-monitor/src/test/java/me/zhengjie/SystemInfoTest.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/config/VisitsInitialization.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/Server.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/Visits.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/vo/RedisVo.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/repository/ServerRepository.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/repository/VisitsRepository.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/ServerController.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/VisitsController.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/ServerService.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/VisitsService.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/dto/ServerDTO.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/dto/ServerQueryCriteria.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/impl/ServerServiceImpl.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/impl/VisitsServiceImpl.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/mapper/ServerMapper.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/VisitsTask.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/system/domain/UserAvatar.java delete mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserAvatarRepository.java rename eladmin-system/src/main/java/me/zhengjie/modules/{monitor => system}/rest/LimitController.java (61%) create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MonitorController.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/system/rest/VerifyController.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/system/service/MonitorService.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/system/service/VerifyService.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MonitorServiceImpl.java create mode 100644 eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/VerifyServiceImpl.java delete mode 100644 eladmin-tools/src/main/java/me/zhengjie/domain/VerificationCode.java delete mode 100644 eladmin-tools/src/main/java/me/zhengjie/repository/VerificationCodeRepository.java delete mode 100644 eladmin-tools/src/main/java/me/zhengjie/rest/VerificationCodeController.java delete mode 100644 eladmin-tools/src/main/java/me/zhengjie/service/VerificationCodeService.java delete mode 100644 eladmin-tools/src/main/java/me/zhengjie/service/impl/VerificationCodeServiceImpl.java diff --git a/LICENSE b/LICENSE index e8aef483..ca38718f 100644 --- a/LICENSE +++ b/LICENSE @@ -176,7 +176,7 @@ recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2019 Zheng Jie + Copyright 2019-2020 Zheng Jie Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/eladmin-common/src/main/java/me/zhengjie/annotation/AnonymousAccess.java b/eladmin-common/src/main/java/me/zhengjie/annotation/AnonymousAccess.java index 46d5ab0c..d5021aa9 100644 --- a/eladmin-common/src/main/java/me/zhengjie/annotation/AnonymousAccess.java +++ b/eladmin-common/src/main/java/me/zhengjie/annotation/AnonymousAccess.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.annotation; import java.lang.annotation.ElementType; diff --git a/eladmin-common/src/main/java/me/zhengjie/annotation/Limit.java b/eladmin-common/src/main/java/me/zhengjie/annotation/Limit.java index a00008fc..58b41cf8 100644 --- a/eladmin-common/src/main/java/me/zhengjie/annotation/Limit.java +++ b/eladmin-common/src/main/java/me/zhengjie/annotation/Limit.java @@ -1,7 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.annotation; import me.zhengjie.aspect.LimitType; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; diff --git a/eladmin-common/src/main/java/me/zhengjie/annotation/Query.java b/eladmin-common/src/main/java/me/zhengjie/annotation/Query.java index 6a2d866f..2a7eb183 100644 --- a/eladmin-common/src/main/java/me/zhengjie/annotation/Query.java +++ b/eladmin-common/src/main/java/me/zhengjie/annotation/Query.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.annotation; import java.lang.annotation.ElementType; diff --git a/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java b/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java index f495e85a..908e022f 100644 --- a/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java +++ b/eladmin-common/src/main/java/me/zhengjie/aspect/LimitAspect.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.aspect; import com.google.common.collect.ImmutableList; diff --git a/eladmin-common/src/main/java/me/zhengjie/aspect/LimitType.java b/eladmin-common/src/main/java/me/zhengjie/aspect/LimitType.java index 1c304eea..e788adc7 100644 --- a/eladmin-common/src/main/java/me/zhengjie/aspect/LimitType.java +++ b/eladmin-common/src/main/java/me/zhengjie/aspect/LimitType.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.aspect; /** diff --git a/eladmin-common/src/main/java/me/zhengjie/base/BaseDTO.java b/eladmin-common/src/main/java/me/zhengjie/base/BaseDTO.java index e6b5c30d..d4dfb838 100644 --- a/eladmin-common/src/main/java/me/zhengjie/base/BaseDTO.java +++ b/eladmin-common/src/main/java/me/zhengjie/base/BaseDTO.java @@ -13,18 +13,11 @@ import java.sql.Timestamp; @Setter public class BaseDTO implements Serializable { - private Boolean isDelete; + private String createBy; + + private String updatedBy; private Timestamp createTime; private Timestamp updateTime; - - @Override - public String toString() { - return "BaseDTO{" + - "isDelete=" + isDelete + - ", createTime=" + createTime + - ", updateTime=" + updateTime + - '}'; - } } diff --git a/eladmin-common/src/main/java/me/zhengjie/base/BaseEntity.java b/eladmin-common/src/main/java/me/zhengjie/base/BaseEntity.java index 246c3c90..5f6fbfbd 100644 --- a/eladmin-common/src/main/java/me/zhengjie/base/BaseEntity.java +++ b/eladmin-common/src/main/java/me/zhengjie/base/BaseEntity.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.base; +import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -8,7 +24,6 @@ import org.hibernate.annotations.UpdateTimestamp; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.jpa.domain.support.AuditingEntityListener; - import javax.persistence.Column; import javax.persistence.EntityListeners; import javax.persistence.MappedSuperclass; @@ -17,6 +32,7 @@ import java.lang.reflect.Field; import java.sql.Timestamp; /** + * 通用字段, is_del 根据需求自行添加 * @author Zheng Jie * @Date 2019年10月24日20:46:32 */ @@ -26,38 +42,30 @@ import java.sql.Timestamp; @EntityListeners(AuditingEntityListener.class) public class BaseEntity implements Serializable { - /** 删除标识 **/ - @Column(name = "is_delete", columnDefinition = "bit default 0") - private Boolean isDelete = false; - - /** - * 创建人 - */ @CreatedBy @Column(name = "create_by", updatable = false) - private String createdBy; + @ApiModelProperty(value = "创建人", hidden = true) + private String createBy; - /** - * 创建时间 - */ - @CreationTimestamp - @Column(name = "create_time", updatable = false) - private Timestamp createTime; - - /** - * 更新人 - */ @LastModifiedBy @Column(name = "update_by") + @ApiModelProperty(value = "更新人", hidden = true) private String updatedBy; - /** - * 更新时间 - */ + @CreationTimestamp + @Column(name = "create_time", updatable = false) + @ApiModelProperty(value = "创建时间", hidden = true) + private Timestamp createTime; + @UpdateTimestamp @Column(name = "update_time") + @ApiModelProperty(value = "更新时间", hidden = true) private Timestamp updateTime; + /* 分组校验 */ + public @interface Create {} + + /* 分组校验 */ public @interface Update {} @Override diff --git a/eladmin-common/src/main/java/me/zhengjie/base/BaseMapper.java b/eladmin-common/src/main/java/me/zhengjie/base/BaseMapper.java index 7671325b..e8bb825d 100644 --- a/eladmin-common/src/main/java/me/zhengjie/base/BaseMapper.java +++ b/eladmin-common/src/main/java/me/zhengjie/base/BaseMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.base; import java.util.List; diff --git a/eladmin-system/src/main/java/me/zhengjie/config/AuditorConfig.java b/eladmin-common/src/main/java/me/zhengjie/config/AuditorConfig.java similarity index 52% rename from eladmin-system/src/main/java/me/zhengjie/config/AuditorConfig.java rename to eladmin-common/src/main/java/me/zhengjie/config/AuditorConfig.java index 8b238c9c..71826add 100644 --- a/eladmin-system/src/main/java/me/zhengjie/config/AuditorConfig.java +++ b/eladmin-common/src/main/java/me/zhengjie/config/AuditorConfig.java @@ -1,9 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.config; import me.zhengjie.utils.SecurityUtils; import org.springframework.data.domain.AuditorAware; import org.springframework.stereotype.Component; - import java.util.Optional; /** diff --git a/eladmin-common/src/main/java/me/zhengjie/config/ElPermissionConfig.java b/eladmin-common/src/main/java/me/zhengjie/config/ElPermissionConfig.java index 530cc49a..9ae1fd5d 100644 --- a/eladmin-common/src/main/java/me/zhengjie/config/ElPermissionConfig.java +++ b/eladmin-common/src/main/java/me/zhengjie/config/ElPermissionConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.config; import me.zhengjie.utils.SecurityUtils; diff --git a/eladmin-common/src/main/java/me/zhengjie/config/FileProperties.java b/eladmin-common/src/main/java/me/zhengjie/config/FileProperties.java index 8097be77..00d5f878 100644 --- a/eladmin-common/src/main/java/me/zhengjie/config/FileProperties.java +++ b/eladmin-common/src/main/java/me/zhengjie/config/FileProperties.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.config; import lombok.Data; diff --git a/eladmin-common/src/main/java/me/zhengjie/config/RedisConfig.java b/eladmin-common/src/main/java/me/zhengjie/config/RedisConfig.java index c6be7dda..6f66e9c1 100644 --- a/eladmin-common/src/main/java/me/zhengjie/config/RedisConfig.java +++ b/eladmin-common/src/main/java/me/zhengjie/config/RedisConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.config; import cn.hutool.core.lang.Assert; diff --git a/eladmin-common/src/main/java/me/zhengjie/config/SwaggerConfig.java b/eladmin-common/src/main/java/me/zhengjie/config/SwaggerConfig.java index 8f0d0376..e5e16216 100644 --- a/eladmin-common/src/main/java/me/zhengjie/config/SwaggerConfig.java +++ b/eladmin-common/src/main/java/me/zhengjie/config/SwaggerConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.config; import com.fasterxml.classmate.TypeResolver; @@ -27,11 +42,10 @@ import static com.google.common.collect.Lists.newArrayList; import static springfox.documentation.schema.AlternateTypeRules.newRule; /** - * api页面 /swagger-ui.html + * api页面 /doc.html * @author Zheng Jie * @date 2018-11-23 */ - @Configuration @EnableSwagger2 public class SwaggerConfig { @@ -68,8 +82,9 @@ public class SwaggerConfig { private ApiInfo apiInfo() { return new ApiInfoBuilder() - .title("eladmin 接口文档") - .version("2.3") + .description("一个简单且易上手的 Spring boot 后台管理框架") + .title("EL-ADMIN 接口文档") + .version("2.4") .build(); } diff --git a/eladmin-common/src/main/java/me/zhengjie/exception/BadRequestException.java b/eladmin-common/src/main/java/me/zhengjie/exception/BadRequestException.java index d17b18dd..900453bd 100644 --- a/eladmin-common/src/main/java/me/zhengjie/exception/BadRequestException.java +++ b/eladmin-common/src/main/java/me/zhengjie/exception/BadRequestException.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.exception; import lombok.Getter; diff --git a/eladmin-common/src/main/java/me/zhengjie/exception/EntityExistException.java b/eladmin-common/src/main/java/me/zhengjie/exception/EntityExistException.java index 5ade7950..03f9bf2a 100644 --- a/eladmin-common/src/main/java/me/zhengjie/exception/EntityExistException.java +++ b/eladmin-common/src/main/java/me/zhengjie/exception/EntityExistException.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.exception; import org.springframework.util.StringUtils; diff --git a/eladmin-common/src/main/java/me/zhengjie/exception/EntityNotFoundException.java b/eladmin-common/src/main/java/me/zhengjie/exception/EntityNotFoundException.java index 295bb280..bcdc9562 100644 --- a/eladmin-common/src/main/java/me/zhengjie/exception/EntityNotFoundException.java +++ b/eladmin-common/src/main/java/me/zhengjie/exception/EntityNotFoundException.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.exception; import org.springframework.util.StringUtils; diff --git a/eladmin-common/src/main/java/me/zhengjie/exception/handler/ApiError.java b/eladmin-common/src/main/java/me/zhengjie/exception/handler/ApiError.java index 9cabb324..5112730b 100644 --- a/eladmin-common/src/main/java/me/zhengjie/exception/handler/ApiError.java +++ b/eladmin-common/src/main/java/me/zhengjie/exception/handler/ApiError.java @@ -1,8 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.exception.handler; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; - import java.time.LocalDateTime; /** diff --git a/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java b/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java index 95ee4113..56d73f7d 100644 --- a/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java +++ b/eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.exception.handler; import lombok.extern.slf4j.Slf4j; @@ -7,7 +22,6 @@ import me.zhengjie.exception.EntityNotFoundException; import me.zhengjie.utils.ThrowableUtil; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.security.access.AccessDeniedException; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.web.bind.MethodArgumentNotValidException; import org.springframework.web.bind.annotation.ExceptionHandler; diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java b/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java index 22f37a36..ae6bcd1a 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/ElAdminConstant.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; /** @@ -7,10 +22,6 @@ package me.zhengjie.utils; */ public class ElAdminConstant { - public static final String RESET_PASS = "重置密码"; - - public static final String RESET_MAIL = "重置邮箱"; - /** * 用于IP定位转换 */ diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java b/eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java index 6bb85dc3..1e638008 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/EncryptUtils.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import javax.crypto.Cipher; @@ -14,7 +29,7 @@ import java.nio.charset.StandardCharsets; */ public class EncryptUtils { - private static String strParam = "Passw0rd"; + private static final String strParam = "Passw0rd"; private static Cipher cipher; diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java b/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java index 1aa922d7..fe039489 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import cn.hutool.core.codec.Base64; diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/PageUtil.java b/eladmin-common/src/main/java/me/zhengjie/utils/PageUtil.java index 09a50417..44db68dd 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/PageUtil.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/PageUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import org.springframework.data.domain.Page; diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java b/eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java index b00b53d8..6ae81a7c 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import cn.hutool.core.collection.CollUtil; diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/RedisUtils.java b/eladmin-common/src/main/java/me/zhengjie/utils/RedisUtils.java index 28651fa2..55e36174 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/RedisUtils.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/RedisUtils.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import org.springframework.beans.factory.annotation.Value; diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/RequestHolder.java b/eladmin-common/src/main/java/me/zhengjie/utils/RequestHolder.java index f9458838..71a4b9e5 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/RequestHolder.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/RequestHolder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import org.springframework.web.context.request.RequestContextHolder; diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/SecurityUtils.java b/eladmin-common/src/main/java/me/zhengjie/utils/SecurityUtils.java index 3856603f..2c27a445 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/SecurityUtils.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/SecurityUtils.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import cn.hutool.json.JSONObject; diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/SpringContextHolder.java b/eladmin-common/src/main/java/me/zhengjie/utils/SpringContextHolder.java index fd255348..8da0dab7 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/SpringContextHolder.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/SpringContextHolder.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import lombok.extern.slf4j.Slf4j; diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java b/eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java index 4934a496..b380e6af 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/StringUtils.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import cn.hutool.core.io.resource.ClassPathResource; @@ -195,4 +210,26 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils { } return weekDays[w]; } + + /** + * 获取当前机器的IP + * @return / + */ + public static String getLocalIp(){ + InetAddress addr; + try { + addr = InetAddress.getLocalHost(); + } catch (UnknownHostException e) { + return "unknown"; + } + byte[] ipAddr = addr.getAddress(); + StringBuilder ipAddrStr = new StringBuilder(); + for (int i = 0; i < ipAddr.length; i++) { + if (i > 0) { + ipAddrStr.append("."); + } + ipAddrStr.append(ipAddr[i] & 0xFF); + } + return ipAddrStr.toString(); + } } diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/ThrowableUtil.java b/eladmin-common/src/main/java/me/zhengjie/utils/ThrowableUtil.java index 3c1f3f7a..24b50106 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/ThrowableUtil.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/ThrowableUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import me.zhengjie.exception.BadRequestException; diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/TranslatorUtil.java b/eladmin-common/src/main/java/me/zhengjie/utils/TranslatorUtil.java index ad5c6e2c..f2bd5d2d 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/TranslatorUtil.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/TranslatorUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import cn.hutool.json.JSONArray; diff --git a/eladmin-common/src/main/java/me/zhengjie/utils/ValidationUtil.java b/eladmin-common/src/main/java/me/zhengjie/utils/ValidationUtil.java index 5511e326..57a4913d 100644 --- a/eladmin-common/src/main/java/me/zhengjie/utils/ValidationUtil.java +++ b/eladmin-common/src/main/java/me/zhengjie/utils/ValidationUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import cn.hutool.core.util.ObjectUtil; diff --git a/eladmin-generator/src/main/java/me/zhengjie/domain/ColumnInfo.java b/eladmin-generator/src/main/java/me/zhengjie/domain/ColumnInfo.java index 0f298764..fdb962a4 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/domain/ColumnInfo.java +++ b/eladmin-generator/src/main/java/me/zhengjie/domain/ColumnInfo.java @@ -1,62 +1,83 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.domain; -import lombok.Data; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; import me.zhengjie.utils.GenUtil; import javax.persistence.*; +import java.io.Serializable; /** * 列的数据信息 * @author Zheng Jie * @date 2019-01-02 */ -@Data +@Getter +@Setter @Entity @NoArgsConstructor -@Table(name = "column_config") -public class ColumnInfo { +@Table(name = "code_column_config") +public class ColumnInfo implements Serializable { @Id + @Column(name = "column_id") + @ApiModelProperty(value = "ID", hidden = true) @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") private Long id; + @ApiModelProperty(value = "表名") private String tableName; - /** 数据库字段名称 */ + @ApiModelProperty(value = "数据库字段名称") private String columnName; - /** 数据库字段类型 */ + @ApiModelProperty(value = "数据库字段类型") private String columnType; - /** 数据库字段键类型 */ + @ApiModelProperty(value = "数据库字段键类型") private String keyType; - /** 字段额外的参数 */ + @ApiModelProperty(value = "字段额外的参数") private String extra; - /** 数据库字段描述 */ + @ApiModelProperty(value = "数据库字段描述") private String remark; - /** 必填 */ + @ApiModelProperty(value = "是否必填") private Boolean notNull; - /** 是否在列表显示 */ + @ApiModelProperty(value = "是否在列表显示") private Boolean listShow; - /** 是否表单显示 */ + @ApiModelProperty(value = "是否表单显示") private Boolean formShow; - /** 表单类型 */ + @ApiModelProperty(value = "表单类型") private String formType; - /** 查询 1:模糊 2:精确 */ + @ApiModelProperty(value = "查询 1:模糊 2:精确") private String queryType; - /** 字典名称 */ + @ApiModelProperty(value = "字典名称") private String dictName; - /** 日期注解 */ + @ApiModelProperty(value = "日期注解") private String dateAnnotation; public ColumnInfo(String tableName, String columnName, Boolean notNull, String columnType, String remark, String keyType, String extra) { diff --git a/eladmin-generator/src/main/java/me/zhengjie/domain/GenConfig.java b/eladmin-generator/src/main/java/me/zhengjie/domain/GenConfig.java index dc68745c..a2d67063 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/domain/GenConfig.java +++ b/eladmin-generator/src/main/java/me/zhengjie/domain/GenConfig.java @@ -1,61 +1,78 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.domain; -import lombok.Data; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; import javax.persistence.*; import javax.validation.constraints.NotBlank; +import java.io.Serializable; /** * 代码生成配置 * @author Zheng Jie * @date 2019-01-03 */ -@Data +@Getter +@Setter @Entity @NoArgsConstructor -@Table(name = "gen_config") -public class GenConfig { +@Table(name = "code_gen_config") +public class GenConfig implements Serializable { public GenConfig(String tableName) { - this.cover = false; - this.moduleName = "eladmin-system"; this.tableName = tableName; } @Id + @Column(name = "config_id") + @ApiModelProperty(value = "ID", hidden = true) @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") private Long id; @NotBlank + @ApiModelProperty(value = "表名") private String tableName; - /** 接口名称 **/ + @ApiModelProperty(value = "接口名称") private String apiAlias; - /** 包路径 */ @NotBlank + @ApiModelProperty(value = "包路径") private String pack; - /** 模块名 */ - @Column(name = "module_name") @NotBlank + @ApiModelProperty(value = "模块名") private String moduleName; - /** 前端文件路径 */ @NotBlank + @ApiModelProperty(value = "前端文件路径") private String path; - /** 前端文件路径 */ - @Column(name = "api_path") + @ApiModelProperty(value = "前端文件路径") private String apiPath; - /** 作者 */ + @ApiModelProperty(value = "作者") private String author; - /** 表前缀 */ + @ApiModelProperty(value = "表前缀") private String prefix; - /** 是否覆盖 */ - private Boolean cover; + @ApiModelProperty(value = "是否覆盖") + private Boolean cover = false; } diff --git a/eladmin-generator/src/main/java/me/zhengjie/domain/vo/TableInfo.java b/eladmin-generator/src/main/java/me/zhengjie/domain/vo/TableInfo.java index 7b5df94e..1d3967b5 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/domain/vo/TableInfo.java +++ b/eladmin-generator/src/main/java/me/zhengjie/domain/vo/TableInfo.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.domain.vo; import lombok.AllArgsConstructor; diff --git a/eladmin-generator/src/main/java/me/zhengjie/repository/ColumnInfoRepository.java b/eladmin-generator/src/main/java/me/zhengjie/repository/ColumnInfoRepository.java index 4e8ea1f7..4638be26 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/repository/ColumnInfoRepository.java +++ b/eladmin-generator/src/main/java/me/zhengjie/repository/ColumnInfoRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.repository; import me.zhengjie.domain.ColumnInfo; diff --git a/eladmin-generator/src/main/java/me/zhengjie/repository/GenConfigRepository.java b/eladmin-generator/src/main/java/me/zhengjie/repository/GenConfigRepository.java index 7e029af6..18c9a0c8 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/repository/GenConfigRepository.java +++ b/eladmin-generator/src/main/java/me/zhengjie/repository/GenConfigRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.repository; import me.zhengjie.domain.GenConfig; diff --git a/eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java b/eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java index 934c5131..0996e46d 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java +++ b/eladmin-generator/src/main/java/me/zhengjie/rest/GenConfigController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.domain.GenConfig; import me.zhengjie.service.GenConfigService; import org.springframework.http.HttpStatus; @@ -14,16 +30,13 @@ import org.springframework.web.bind.annotation.*; * @date 2019-01-14 */ @RestController +@RequiredArgsConstructor @RequestMapping("/api/genConfig") @Api(tags = "系统:代码生成器配置管理") public class GenConfigController { private final GenConfigService genConfigService; - public GenConfigController(GenConfigService genConfigService) { - this.genConfigService = genConfigService; - } - @ApiOperation("查询") @GetMapping(value = "/{tableName}") public ResponseEntity get(@PathVariable String tableName){ diff --git a/eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java b/eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java index e8cf332d..8da7ad0d 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java +++ b/eladmin-generator/src/main/java/me/zhengjie/rest/GeneratorController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.domain.ColumnInfo; import me.zhengjie.exception.BadRequestException; import me.zhengjie.service.GenConfigService; @@ -20,22 +36,17 @@ import java.util.List; * @date 2019-01-02 */ @RestController +@RequiredArgsConstructor @RequestMapping("/api/generator") @Api(tags = "系统:代码生成管理") public class GeneratorController { private final GeneratorService generatorService; - private final GenConfigService genConfigService; @Value("${generator.enabled}") private Boolean generatorEnabled; - public GeneratorController(GeneratorService generatorService, GenConfigService genConfigService) { - this.generatorService = generatorService; - this.genConfigService = genConfigService; - } - @ApiOperation("查询数据库数据") @GetMapping(value = "/tables/all") public ResponseEntity getTables(){ diff --git a/eladmin-generator/src/main/java/me/zhengjie/service/GenConfigService.java b/eladmin-generator/src/main/java/me/zhengjie/service/GenConfigService.java index 3b0faacd..b5711f48 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/service/GenConfigService.java +++ b/eladmin-generator/src/main/java/me/zhengjie/service/GenConfigService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service; import me.zhengjie.domain.GenConfig; diff --git a/eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java b/eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java index d340c893..5697100d 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java +++ b/eladmin-generator/src/main/java/me/zhengjie/service/GeneratorService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service; import me.zhengjie.domain.GenConfig; @@ -32,7 +47,7 @@ public interface GeneratorService { /** * 同步表数据 * @param columnInfos / - * @param columnInfoList + * @param columnInfoList / */ @Async void sync(List columnInfos, List columnInfoList); diff --git a/eladmin-generator/src/main/java/me/zhengjie/service/impl/GenConfigServiceImpl.java b/eladmin-generator/src/main/java/me/zhengjie/service/impl/GenConfigServiceImpl.java index 59dd95db..50319e1c 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/service/impl/GenConfigServiceImpl.java +++ b/eladmin-generator/src/main/java/me/zhengjie/service/impl/GenConfigServiceImpl.java @@ -1,12 +1,25 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.impl; +import lombok.RequiredArgsConstructor; import me.zhengjie.domain.GenConfig; import me.zhengjie.repository.GenConfigRepository; import me.zhengjie.service.GenConfigService; import me.zhengjie.utils.StringUtils; -import org.springframework.cache.annotation.CacheConfig; -import org.springframework.cache.annotation.CachePut; -import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import java.io.File; @@ -15,17 +28,12 @@ import java.io.File; * @date 2019-01-14 */ @Service -@CacheConfig(cacheNames = "genConfig") +@RequiredArgsConstructor public class GenConfigServiceImpl implements GenConfigService { private final GenConfigRepository genConfigRepository; - public GenConfigServiceImpl(GenConfigRepository genConfigRepository) { - this.genConfigRepository = genConfigRepository; - } - @Override - @Cacheable(key = "#p0") public GenConfig find(String tableName) { GenConfig genConfig = genConfigRepository.findByTableName(tableName); if(genConfig == null){ @@ -35,7 +43,6 @@ public class GenConfigServiceImpl implements GenConfigService { } @Override - @CachePut(key = "#p0") public GenConfig update(String tableName, GenConfig genConfig) { // 如果 api 路径为空,则自动生成路径 if(StringUtils.isBlank(genConfig.getApiPath())){ diff --git a/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java b/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java index 42427695..6a94fb46 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java +++ b/eladmin-generator/src/main/java/me/zhengjie/service/impl/GeneratorServiceImpl.java @@ -1,8 +1,24 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ZipUtil; +import lombok.RequiredArgsConstructor; import me.zhengjie.domain.GenConfig; import me.zhengjie.domain.ColumnInfo; import me.zhengjie.domain.vo.TableInfo; @@ -33,7 +49,7 @@ import java.util.stream.Collectors; * @date 2019-01-02 */ @Service -@SuppressWarnings({"unchecked","all"}) +@RequiredArgsConstructor public class GeneratorServiceImpl implements GeneratorService { @PersistenceContext @@ -41,10 +57,6 @@ public class GeneratorServiceImpl implements GeneratorService { private final ColumnInfoRepository columnInfoRepository; - public GeneratorServiceImpl(ColumnInfoRepository columnInfoRepository) { - this.columnInfoRepository = columnInfoRepository; - } - @Override public Object getTables() { // 使用预编译防止sql注入 @@ -117,7 +129,7 @@ public class GeneratorServiceImpl implements GeneratorService { // 第一种情况,数据库类字段改变或者新增字段 for (ColumnInfo columnInfo : columnInfoList) { // 根据字段名称查找 - List columns = new ArrayList(columnInfos.stream().filter(c-> c.getColumnName().equals(columnInfo.getColumnName())).collect(Collectors.toList())); + List columns = columnInfos.stream().filter(c -> c.getColumnName().equals(columnInfo.getColumnName())).collect(Collectors.toList()); // 如果能找到,就修改部分可能被字段 if(CollectionUtil.isNotEmpty(columns)){ ColumnInfo column = columns.get(0); @@ -136,7 +148,7 @@ public class GeneratorServiceImpl implements GeneratorService { // 第二种情况,数据库字段删除了 for (ColumnInfo columnInfo : columnInfos) { // 根据字段名称查找 - List columns = new ArrayList(columnInfoList.stream().filter(c-> c.getColumnName().equals(columnInfo.getColumnName())).collect(Collectors.toList())); + List columns = columnInfoList.stream().filter(c -> c.getColumnName().equals(columnInfo.getColumnName())).collect(Collectors.toList()); // 如果找不到,就代表字段被删除了,则需要删除该字段 if(CollectionUtil.isEmpty(columns)){ columnInfoRepository.delete(columnInfo); diff --git a/eladmin-generator/src/main/java/me/zhengjie/utils/ColUtil.java b/eladmin-generator/src/main/java/me/zhengjie/utils/ColUtil.java index 9a119f2a..f396d755 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/utils/ColUtil.java +++ b/eladmin-generator/src/main/java/me/zhengjie/utils/ColUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import org.apache.commons.configuration.*; diff --git a/eladmin-generator/src/main/java/me/zhengjie/utils/GenUtil.java b/eladmin-generator/src/main/java/me/zhengjie/utils/GenUtil.java index 1ed06c35..caa7dc95 100644 --- a/eladmin-generator/src/main/java/me/zhengjie/utils/GenUtil.java +++ b/eladmin-generator/src/main/java/me/zhengjie/utils/GenUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import cn.hutool.core.util.StrUtil; diff --git a/eladmin-logging/src/main/java/me/zhengjie/aop/log/Log.java b/eladmin-logging/src/main/java/me/zhengjie/aop/log/Log.java index 3b6f7e0a..cda0a800 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/aop/log/Log.java +++ b/eladmin-logging/src/main/java/me/zhengjie/aop/log/Log.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.aop.log; import java.lang.annotation.ElementType; diff --git a/eladmin-logging/src/main/java/me/zhengjie/aspect/LogAspect.java b/eladmin-logging/src/main/java/me/zhengjie/aspect/LogAspect.java index 69ad7412..a50a855f 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/aspect/LogAspect.java +++ b/eladmin-logging/src/main/java/me/zhengjie/aspect/LogAspect.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.aspect; import lombok.extern.slf4j.Slf4j; @@ -14,7 +29,6 @@ import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Pointcut; import org.springframework.stereotype.Component; - import javax.servlet.http.HttpServletRequest; /** diff --git a/eladmin-logging/src/main/java/me/zhengjie/domain/Log.java b/eladmin-logging/src/main/java/me/zhengjie/domain/Log.java index ac0facc5..88dad027 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/domain/Log.java +++ b/eladmin-logging/src/main/java/me/zhengjie/domain/Log.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.domain; -import lombok.Data; +import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; import org.hibernate.annotations.CreationTimestamp; import javax.persistence.*; import java.io.Serializable; @@ -12,12 +28,14 @@ import java.sql.Timestamp; * @date 2018-11-24 */ @Entity -@Data -@Table(name = "log") +@Getter +@Setter +@Table(name = "sys_log") @NoArgsConstructor public class Log implements Serializable { @Id + @Column(name = "log_id") @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @@ -31,19 +49,15 @@ public class Log implements Serializable { private String method; /** 参数 */ - @Column(columnDefinition = "text") private String params; /** 日志类型 */ - @Column(name = "log_type") private String logType; /** 请求ip */ - @Column(name = "request_ip") private String requestIp; /** 地址 */ - @Column(name = "address") private String address; /** 浏览器 */ @@ -53,12 +67,10 @@ public class Log implements Serializable { private Long time; /** 异常详细 */ - @Column(name = "exception_detail", columnDefinition = "text") private byte[] exceptionDetail; /** 创建日期 */ @CreationTimestamp - @Column(name = "create_time") private Timestamp createTime; public Log(String logType, Long time) { diff --git a/eladmin-logging/src/main/java/me/zhengjie/repository/LogRepository.java b/eladmin-logging/src/main/java/me/zhengjie/repository/LogRepository.java index e5eefe99..f7fc10e5 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/repository/LogRepository.java +++ b/eladmin-logging/src/main/java/me/zhengjie/repository/LogRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.repository; import me.zhengjie.domain.Log; @@ -7,8 +22,6 @@ import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; -import javax.transaction.Transactional; - /** * @author Zheng Jie * @date 2018-11-24 @@ -16,20 +29,11 @@ import javax.transaction.Transactional; @Repository public interface LogRepository extends JpaRepository, JpaSpecificationExecutor { - /** - * 获取一个时间段的IP记录 - * @param date1 startTime - * @param date2 entTime - * @return IP数目 - */ - @Query(value = "select count(*) FROM (select request_ip FROM log where create_time between ?1 and ?2 GROUP BY request_ip) as s",nativeQuery = true) - Long findIp(String date1, String date2); - /** * 根据日志类型删除信息 * @param logType 日志类型 */ - @Query(nativeQuery = true,value = "delete from log where log_type = ?1") @Modifying + @Query(value = "delete from sys_log where log_type = ?1", nativeQuery = true) void deleteByLogType(String logType); } diff --git a/eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java b/eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java index c2977c7d..f65678e3 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java +++ b/eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.service.LogService; import me.zhengjie.service.dto.LogQueryCriteria; @@ -19,16 +35,13 @@ import java.io.IOException; * @date 2018-11-24 */ @RestController +@RequiredArgsConstructor @RequestMapping("/api/logs") -@Api(tags = "监控:日志管理") +@Api(tags = "系统:日志管理") public class LogController { private final LogService logService; - public LogController(LogService logService) { - this.logService = logService; - } - @Log("导出数据") @ApiOperation("导出数据") @GetMapping(value = "/download") diff --git a/eladmin-logging/src/main/java/me/zhengjie/service/LogService.java b/eladmin-logging/src/main/java/me/zhengjie/service/LogService.java index fb1a0549..d74dce68 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/service/LogService.java +++ b/eladmin-logging/src/main/java/me/zhengjie/service/LogService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service; import me.zhengjie.domain.Log; diff --git a/eladmin-logging/src/main/java/me/zhengjie/service/dto/LogErrorDTO.java b/eladmin-logging/src/main/java/me/zhengjie/service/dto/LogErrorDTO.java index 286f2b8e..bc0d4ec2 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/service/dto/LogErrorDTO.java +++ b/eladmin-logging/src/main/java/me/zhengjie/service/dto/LogErrorDTO.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.dto; import lombok.Data; diff --git a/eladmin-logging/src/main/java/me/zhengjie/service/dto/LogQueryCriteria.java b/eladmin-logging/src/main/java/me/zhengjie/service/dto/LogQueryCriteria.java index 40ac94c0..c01812c4 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/service/dto/LogQueryCriteria.java +++ b/eladmin-logging/src/main/java/me/zhengjie/service/dto/LogQueryCriteria.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.dto; import lombok.Data; diff --git a/eladmin-logging/src/main/java/me/zhengjie/service/dto/LogSmallDTO.java b/eladmin-logging/src/main/java/me/zhengjie/service/dto/LogSmallDTO.java index 91ca642a..d074fd15 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/service/dto/LogSmallDTO.java +++ b/eladmin-logging/src/main/java/me/zhengjie/service/dto/LogSmallDTO.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.dto; import lombok.Data; diff --git a/eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java b/eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java index 8c2022d2..68af1f10 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java +++ b/eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java @@ -1,8 +1,24 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.impl; import cn.hutool.core.lang.Dict; import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSONObject; +import lombok.RequiredArgsConstructor; import me.zhengjie.domain.Log; import me.zhengjie.repository.LogRepository; import me.zhengjie.service.LogService; @@ -17,7 +33,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; - import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.lang.reflect.Method; @@ -31,21 +46,14 @@ import java.util.Map; * @date 2018-11-24 */ @Service +@RequiredArgsConstructor @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class LogServiceImpl implements LogService { private final LogRepository logRepository; - private final LogErrorMapper logErrorMapper; - private final LogSmallMapper logSmallMapper; - public LogServiceImpl(LogRepository logRepository, LogErrorMapper logErrorMapper, LogSmallMapper logSmallMapper) { - this.logRepository = logRepository; - this.logErrorMapper = logErrorMapper; - this.logSmallMapper = logSmallMapper; - } - @Override public Object queryAll(LogQueryCriteria criteria, Pageable pageable){ Page page = logRepository.findAll(((root, criteriaQuery, cb) -> QueryHelp.getPredicate(root, criteria, cb)),pageable); diff --git a/eladmin-logging/src/main/java/me/zhengjie/service/mapper/LogErrorMapper.java b/eladmin-logging/src/main/java/me/zhengjie/service/mapper/LogErrorMapper.java index 8e033ac1..6272382f 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/service/mapper/LogErrorMapper.java +++ b/eladmin-logging/src/main/java/me/zhengjie/service/mapper/LogErrorMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-logging/src/main/java/me/zhengjie/service/mapper/LogSmallMapper.java b/eladmin-logging/src/main/java/me/zhengjie/service/mapper/LogSmallMapper.java index 630be522..8873ea7f 100644 --- a/eladmin-logging/src/main/java/me/zhengjie/service/mapper/LogSmallMapper.java +++ b/eladmin-logging/src/main/java/me/zhengjie/service/mapper/LogSmallMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-monitor/README.md b/eladmin-monitor/README.md deleted file mode 100644 index b646a2f6..00000000 --- a/eladmin-monitor/README.md +++ /dev/null @@ -1,33 +0,0 @@ -

el-admin 客户端监控模块

-
- -[![AUR](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg)](https://github.com/elunez/eladmin/blob/master/LICENSE) -[![star](https://gitee.com/elunez/eladmin/badge/star.svg?theme=white)](https://gitee.com/elunez/eladmin) -[![GitHub stars](https://img.shields.io/github/stars/elunez/eladmin.svg?style=social&label=Stars)](https://github.com/elunez/eladmin) -[![GitHub forks](https://img.shields.io/github/forks/elunez/eladmin.svg?style=social&label=Fork)](https://github.com/elunez/eladmin) - -
- -#### 项目简介 -希望通过简单的配置即可实现对服务器CPU、内存、磁盘以及交换区占用情况的监控 - -**开发文档** [https://docs.auauz.net/](https://docs.auauz.net) - -**体验地址** [https://auauz.net/](https://auauz.net/) - -**账号密码** ```admin/123456```(默认密码都是123456) - -#### 项目源码 - -| | 后端源码 | 前端源码 | -|--- |--- | --- | -| github | https://github.com/elunez/eladmin | https://github.com/elunez/eladmin-qd | -| 码云 | https://gitee.com/elunez/eladmin | https://gitee.com/elunez/eladmin-qt | - -#### 使用说明 -- 将打包好的eladmin-monitor-2.2.jar 放到服务器上,执行 nohup java -jar eladmin-monitor-2.2.jar & 即可 - -#### 项目捐赠 -项目的发展离不开你的支持,请作者喝杯咖啡吧 ☕! [Donate](https://docs.auauz.net/#/jz) -#### 反馈交流 -- QQ交流群:891137268 diff --git a/eladmin-monitor/pom.xml b/eladmin-monitor/pom.xml deleted file mode 100644 index 8e57dd82..00000000 --- a/eladmin-monitor/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - org.springframework.boot - spring-boot-starter-parent - 2.1.0.RELEASE - - - - 4.0.0 - - eladmin-monitor - 2.4 - - 客户端监控模块 - - - UTF-8 - - 5.5.0 - - - - - org.springframework.boot - spring-boot-starter-web - - - - com.github.oshi - oshi-core - 4.4.2 - - - junit - junit - 4.11 - test - - - - - - public - aliyun nexus - http://maven.aliyun.com/nexus/content/groups/public/ - - true - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - - - - - - true - src/main/resources - - - - diff --git a/eladmin-monitor/src/main/java/me/zhengjie/MonitorRun.java b/eladmin-monitor/src/main/java/me/zhengjie/MonitorRun.java deleted file mode 100644 index dce56478..00000000 --- a/eladmin-monitor/src/main/java/me/zhengjie/MonitorRun.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.zhengjie; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.scheduling.annotation.EnableAsync; - -/** - * - * @author: Zhang houying - * @date: 2019/11/3 - */ -@EnableAsync -@SpringBootApplication -public class MonitorRun { - - public static void main(String[] args) { - SpringApplication.run(MonitorRun.class, args); - } - -} diff --git a/eladmin-monitor/src/main/java/me/zhengjie/res/ServerMonitorController.java b/eladmin-monitor/src/main/java/me/zhengjie/res/ServerMonitorController.java deleted file mode 100644 index e120537b..00000000 --- a/eladmin-monitor/src/main/java/me/zhengjie/res/ServerMonitorController.java +++ /dev/null @@ -1,65 +0,0 @@ -package me.zhengjie.res; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import oshi.SystemInfo; -import oshi.hardware.CentralProcessor; -import oshi.hardware.GlobalMemory; -import oshi.hardware.HardwareAbstractionLayer; -import oshi.hardware.VirtualMemory; -import oshi.software.os.OSFileStore; -import oshi.software.os.OperatingSystem; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; - -/** - * @author Zhang houying - * @date 2019-11-03 - */ -@RestController -@RequestMapping("/api/serverMonitor") -public class ServerMonitorController { - - - private static final double GB = 1024 * 1024 * 1024.00; - - @GetMapping - public ResponseEntity getServerInfo() { - Map resultMap = new HashMap<>(8); - try { - SystemInfo si = new SystemInfo(); - HardwareAbstractionLayer hal = si.getHardware(); - CentralProcessor processor = hal.getProcessor(); - long[] prevTicks = processor.getSystemCpuLoadTicks(); - TimeUnit.SECONDS.sleep(1); - resultMap.put("cpuRate", processor.getSystemCpuLoadBetweenTicks(prevTicks)); - resultMap.put("cpuCore", processor.getLogicalProcessorCount()); - GlobalMemory memory = hal.getMemory(); - resultMap.put("memTotal", memory.getTotal() / GB); - resultMap.put("memUsed", (memory.getTotal() - memory.getAvailable()) / GB); - double diskTotal = 0; - double diskUsable = 0; - OperatingSystem os = si.getOperatingSystem(); - OSFileStore[] fsArray = os.getFileSystem().getFileStores(); - for (OSFileStore fs : fsArray) { - long usable = fs.getUsableSpace(); - long total = fs.getTotalSpace(); - diskTotal += total / GB; - diskUsable += usable / GB; - } - resultMap.put("diskTotal", diskTotal); - resultMap.put("diskUsed", diskTotal - diskUsable); - VirtualMemory vm = memory.getVirtualMemory(); - resultMap.put("swapTotal", vm.getSwapTotal() / GB); - resultMap.put("swapUsed", vm.getSwapUsed() / GB); - } catch (Exception e) { - e.printStackTrace(); - } - return new ResponseEntity<>(resultMap, HttpStatus.OK); - } - -} diff --git a/eladmin-monitor/src/main/resources/banner.txt b/eladmin-monitor/src/main/resources/banner.txt deleted file mode 100644 index d0f401a8..00000000 --- a/eladmin-monitor/src/main/resources/banner.txt +++ /dev/null @@ -1,8 +0,0 @@ - _ _ _ - | | | | (_) - ___| |______ __ _ __| |_ __ ___ _ _ __ - / _ | |______/ _` |/ _` | '_ ` _ \| | '_ \ - | __| | | (_| | (_| | | | | | | | | | | - \___|_| \__,_|\__,_|_| |_| |_|_|_| |_| - - :: Spring Boot :: (v2.1.0.RELEASE) \ No newline at end of file diff --git a/eladmin-monitor/src/main/resources/config/application.yml b/eladmin-monitor/src/main/resources/config/application.yml deleted file mode 100644 index 5830057e..00000000 --- a/eladmin-monitor/src/main/resources/config/application.yml +++ /dev/null @@ -1,2 +0,0 @@ -server: - port: 8777 diff --git a/eladmin-monitor/src/main/resources/logback.xml b/eladmin-monitor/src/main/resources/logback.xml deleted file mode 100644 index 154d76b1..00000000 --- a/eladmin-monitor/src/main/resources/logback.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - elAdmin Monitor - - - - - %black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta(%logger{36}) - %gray(%msg%n) - utf-8 - - - - - - - - diff --git a/eladmin-monitor/src/test/java/me/zhengjie/SystemInfoTest.java b/eladmin-monitor/src/test/java/me/zhengjie/SystemInfoTest.java deleted file mode 100644 index 996fa8fb..00000000 --- a/eladmin-monitor/src/test/java/me/zhengjie/SystemInfoTest.java +++ /dev/null @@ -1,364 +0,0 @@ -/** - * MIT License - *

- * Copyright (c) 2010 - 2020 The OSHI Project Contributors: https://github.com/oshi/oshi/graphs/contributors - *

- * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - *

- * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - *

- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package me.zhengjie; - -import static org.junit.Assert.assertFalse; - -import java.time.Instant; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import oshi.PlatformEnum; -import oshi.SystemInfo; -import oshi.hardware.CentralProcessor; -import oshi.hardware.CentralProcessor.TickType; -import oshi.hardware.ComputerSystem; -import oshi.hardware.Display; -import oshi.hardware.GlobalMemory; -import oshi.hardware.HWDiskStore; -import oshi.hardware.HWPartition; -import oshi.hardware.HardwareAbstractionLayer; -import oshi.hardware.NetworkIF; -import oshi.hardware.PhysicalMemory; -import oshi.hardware.PowerSource; -import oshi.hardware.Sensors; -import oshi.hardware.SoundCard; -import oshi.hardware.UsbDevice; -import oshi.hardware.VirtualMemory; -import oshi.software.os.FileSystem; -import oshi.software.os.NetworkParams; -import oshi.software.os.OSFileStore; -import oshi.software.os.OSProcess; -import oshi.software.os.OSService; -import oshi.software.os.OperatingSystem; -import oshi.software.os.OperatingSystem.ProcessSort; -import oshi.util.FormatUtil; -import oshi.util.Util; - -/** - * A demonstration of access to many of OSHI's capabilities - */ -public class SystemInfoTest { - - private static final Logger logger = LoggerFactory.getLogger(SystemInfoTest.class); - - static List oshi = new ArrayList<>(); - - /** - * Test that this platform is implemented.. - */ - @Test - public void testPlatformEnum() { - assertFalse(PlatformEnum.UNKNOWN.equals(SystemInfo.getCurrentPlatformEnum())); - // Exercise the main method - main(null); - } - - /** - * The main method, demonstrating use of classes. - * - * @param args the arguments (unused) - */ - public static void main(String[] args) { - logger.info("Initializing System..."); - SystemInfo si = new SystemInfo(); - - HardwareAbstractionLayer hal = si.getHardware(); - OperatingSystem os = si.getOperatingSystem(); - - printOperatingSystem(os); - - logger.info("Checking computer system..."); - printComputerSystem(hal.getComputerSystem()); - - logger.info("Checking Processor..."); - printProcessor(hal.getProcessor()); - - logger.info("Checking Memory..."); - printMemory(hal.getMemory()); - - logger.info("Checking CPU..."); - printCpu(hal.getProcessor()); - - logger.info("Checking Processes..."); - printProcesses(os, hal.getMemory()); - - logger.info("Checking Services..."); - printServices(os); - - logger.info("Checking Sensors..."); - printSensors(hal.getSensors()); - - logger.info("Checking Power sources..."); - printPowerSources(hal.getPowerSources()); - - logger.info("Checking Disks..."); - printDisks(hal.getDiskStores()); - - logger.info("Checking File System..."); - printFileSystem(os.getFileSystem()); - - logger.info("Checking Network interfaces..."); - printNetworkInterfaces(hal.getNetworkIFs()); - - logger.info("Checking Network parameters..."); - printNetworkParameters(os.getNetworkParams()); - - // hardware: displays - logger.info("Checking Displays..."); - printDisplays(hal.getDisplays()); - - // hardware: USB devices - logger.info("Checking USB Devices..."); - printUsbDevices(hal.getUsbDevices(true)); - - logger.info("Checking Sound Cards..."); - printSoundCards(hal.getSoundCards()); - - StringBuilder output = new StringBuilder(); - for (int i = 0; i < oshi.size(); i++) { - output.append(oshi.get(i)); - if (oshi.get(i) != null && !oshi.get(i).endsWith("\n")) { - output.append('\n'); - } - } - logger.info("Printing Operating System and Hardware Info:{}{}", '\n', output); - } - - private static void printOperatingSystem(final OperatingSystem os) { - oshi.add(String.valueOf(os)); - oshi.add("Booted: " + Instant.ofEpochSecond(os.getSystemBootTime())); - oshi.add("Uptime: " + FormatUtil.formatElapsedSecs(os.getSystemUptime())); - oshi.add("Running with" + (os.isElevated() ? "" : "out") + " elevated permissions."); - } - - private static void printComputerSystem(final ComputerSystem computerSystem) { - oshi.add("system: " + computerSystem.toString()); - oshi.add(" firmware: " + computerSystem.getFirmware().toString()); - oshi.add(" baseboard: " + computerSystem.getBaseboard().toString()); - } - - private static void printProcessor(CentralProcessor processor) { - oshi.add(processor.toString()); - } - - private static void printMemory(GlobalMemory memory) { - oshi.add("Memory: \n " + memory.toString()); - VirtualMemory vm = memory.getVirtualMemory(); - oshi.add("Swap: \n " + vm.toString()); - PhysicalMemory[] pmArray = memory.getPhysicalMemory(); - if (pmArray.length > 0) { - oshi.add("Physical Memory: "); - for (PhysicalMemory pm : pmArray) { - oshi.add(" " + pm.toString()); - } - } - } - - private static void printCpu(CentralProcessor processor) { - oshi.add("Context Switches/Interrupts: " + processor.getContextSwitches() + " / " + processor.getInterrupts()); - - long[] prevTicks = processor.getSystemCpuLoadTicks(); - long[][] prevProcTicks = processor.getProcessorCpuLoadTicks(); - oshi.add("CPU, IOWait, and IRQ ticks @ 0 sec:" + Arrays.toString(prevTicks)); - // Wait a second... - Util.sleep(1000); - long[] ticks = processor.getSystemCpuLoadTicks(); - oshi.add("CPU, IOWait, and IRQ ticks @ 1 sec:" + Arrays.toString(ticks)); - long user = ticks[TickType.USER.getIndex()] - prevTicks[TickType.USER.getIndex()]; - long nice = ticks[TickType.NICE.getIndex()] - prevTicks[TickType.NICE.getIndex()]; - long sys = ticks[TickType.SYSTEM.getIndex()] - prevTicks[TickType.SYSTEM.getIndex()]; - long idle = ticks[TickType.IDLE.getIndex()] - prevTicks[TickType.IDLE.getIndex()]; - long iowait = ticks[TickType.IOWAIT.getIndex()] - prevTicks[TickType.IOWAIT.getIndex()]; - long irq = ticks[TickType.IRQ.getIndex()] - prevTicks[TickType.IRQ.getIndex()]; - long softirq = ticks[TickType.SOFTIRQ.getIndex()] - prevTicks[TickType.SOFTIRQ.getIndex()]; - long steal = ticks[TickType.STEAL.getIndex()] - prevTicks[TickType.STEAL.getIndex()]; - long totalCpu = user + nice + sys + idle + iowait + irq + softirq + steal; - - oshi.add(String.format( - "User: %.1f%% Nice: %.1f%% System: %.1f%% Idle: %.1f%% IOwait: %.1f%% IRQ: %.1f%% SoftIRQ: %.1f%% Steal: %.1f%%", - 100d * user / totalCpu, 100d * nice / totalCpu, 100d * sys / totalCpu, 100d * idle / totalCpu, - 100d * iowait / totalCpu, 100d * irq / totalCpu, 100d * softirq / totalCpu, 100d * steal / totalCpu)); - oshi.add(String.format("CPU load: %.1f%%", processor.getSystemCpuLoadBetweenTicks(prevTicks) * 100)); - double[] loadAverage = processor.getSystemLoadAverage(3); - oshi.add("CPU load averages:" + (loadAverage[0] < 0 ? " N/A" : String.format(" %.2f", loadAverage[0])) - + (loadAverage[1] < 0 ? " N/A" : String.format(" %.2f", loadAverage[1])) - + (loadAverage[2] < 0 ? " N/A" : String.format(" %.2f", loadAverage[2]))); - // per core CPU - StringBuilder procCpu = new StringBuilder("CPU load per processor:"); - double[] load = processor.getProcessorCpuLoadBetweenTicks(prevProcTicks); - for (double avg : load) { - procCpu.append(String.format(" %.1f%%", avg * 100)); - } - oshi.add(procCpu.toString()); - long freq = processor.getProcessorIdentifier().getVendorFreq(); - if (freq > 0) { - oshi.add("Vendor Frequency: " + FormatUtil.formatHertz(freq)); - } - freq = processor.getMaxFreq(); - if (freq > 0) { - oshi.add("Max Frequency: " + FormatUtil.formatHertz(freq)); - } - long[] freqs = processor.getCurrentFreq(); - if (freqs[0] > 0) { - StringBuilder sb = new StringBuilder("Current Frequencies: "); - for (int i = 0; i < freqs.length; i++) { - if (i > 0) { - sb.append(", "); - } - sb.append(FormatUtil.formatHertz(freqs[i])); - } - oshi.add(sb.toString()); - } - } - - private static void printProcesses(OperatingSystem os, GlobalMemory memory) { - oshi.add("My PID: " + os.getProcessId() + " with affinity " - + Long.toBinaryString(os.getProcessAffinityMask(os.getProcessId()))); - oshi.add("Processes: " + os.getProcessCount() + ", Threads: " + os.getThreadCount()); - // Sort by highest CPU - List procs = Arrays.asList(os.getProcesses(5, ProcessSort.CPU)); - - oshi.add(" PID %CPU %MEM VSZ RSS Name"); - for (int i = 0; i < procs.size() && i < 5; i++) { - OSProcess p = procs.get(i); - oshi.add(String.format(" %5d %5.1f %4.1f %9s %9s %s", p.getProcessID(), - 100d * (p.getKernelTime() + p.getUserTime()) / p.getUpTime(), - 100d * p.getResidentSetSize() / memory.getTotal(), FormatUtil.formatBytes(p.getVirtualSize()), - FormatUtil.formatBytes(p.getResidentSetSize()), p.getName())); - } - } - - private static void printServices(OperatingSystem os) { - oshi.add("Services: "); - oshi.add(" PID State Name"); - // DO 5 each of running and stopped - int i = 0; - for (OSService s : os.getServices()) { - if (s.getState().equals(OSService.State.RUNNING) && i++ < 5) { - oshi.add(String.format(" %5d %7s %s", s.getProcessID(), s.getState(), s.getName())); - } - } - i = 0; - for (OSService s : os.getServices()) { - if (s.getState().equals(OSService.State.STOPPED) && i++ < 5) { - oshi.add(String.format(" %5d %7s %s", s.getProcessID(), s.getState(), s.getName())); - } - } - } - - private static void printSensors(Sensors sensors) { - oshi.add("Sensors: " + sensors.toString()); - } - - private static void printPowerSources(PowerSource[] powerSources) { - StringBuilder sb = new StringBuilder("Power Sources: "); - if (powerSources.length == 0) { - sb.append("Unknown"); - } - for (PowerSource powerSource : powerSources) { - sb.append("\n ").append(powerSource.toString()); - } - oshi.add(sb.toString()); - } - - private static void printDisks(HWDiskStore[] diskStores) { - oshi.add("Disks:"); - for (HWDiskStore disk : diskStores) { - oshi.add(" " + disk.toString()); - - HWPartition[] partitions = disk.getPartitions(); - for (HWPartition part : partitions) { - oshi.add(" |-- " + part.toString()); - } - } - - } - - private static void printFileSystem(FileSystem fileSystem) { - oshi.add("File System:"); - - oshi.add(String.format(" File Descriptors: %d/%d", fileSystem.getOpenFileDescriptors(), - fileSystem.getMaxFileDescriptors())); - - OSFileStore[] fsArray = fileSystem.getFileStores(); - for (OSFileStore fs : fsArray) { - long usable = fs.getUsableSpace(); - long total = fs.getTotalSpace(); - oshi.add(String.format( - " %s (%s) [%s] %s of %s free (%.1f%%), %s of %s files free (%.1f%%) is %s " - + (fs.getLogicalVolume() != null && fs.getLogicalVolume().length() > 0 ? "[%s]" : "%s") - + " and is mounted at %s", - fs.getName(), fs.getDescription().isEmpty() ? "file system" : fs.getDescription(), fs.getType(), - FormatUtil.formatBytes(usable), FormatUtil.formatBytes(fs.getTotalSpace()), 100d * usable / total, - FormatUtil.formatValue(fs.getFreeInodes(), ""), FormatUtil.formatValue(fs.getTotalInodes(), ""), - 100d * fs.getFreeInodes() / fs.getTotalInodes(), fs.getVolume(), fs.getLogicalVolume(), - fs.getMount())); - } - } - - private static void printNetworkInterfaces(NetworkIF[] networkIFs) { - StringBuilder sb = new StringBuilder("Network Interfaces:"); - if (networkIFs.length == 0) { - sb.append(" Unknown"); - } - for (NetworkIF net : networkIFs) { - sb.append("\n ").append(net.toString()); - } - oshi.add(sb.toString()); - } - - private static void printNetworkParameters(NetworkParams networkParams) { - oshi.add("Network parameters:\n " + networkParams.toString()); - } - - private static void printDisplays(Display[] displays) { - oshi.add("Displays:"); - int i = 0; - for (Display display : displays) { - oshi.add(" Display " + i + ":"); - oshi.add(String.valueOf(display)); - i++; - } - } - - private static void printUsbDevices(UsbDevice[] usbDevices) { - oshi.add("USB Devices:"); - for (UsbDevice usbDevice : usbDevices) { - oshi.add(String.valueOf(usbDevice)); - } - } - - private static void printSoundCards(SoundCard[] cards) { - oshi.add("Sound Cards:"); - for (SoundCard card : cards) { - oshi.add(" " + String.valueOf(card)); - } - } -} \ No newline at end of file diff --git a/eladmin-system/pom.xml b/eladmin-system/pom.xml index d62bb4f8..f861a1c6 100644 --- a/eladmin-system/pom.xml +++ b/eladmin-system/pom.xml @@ -14,6 +14,8 @@ 0.10.6 + + 5.5.0 @@ -77,6 +79,12 @@ 0.1.55 + + com.github.oshi + oshi-core + 4.7.1 + + diff --git a/eladmin-system/src/main/java/me/zhengjie/AppRun.java b/eladmin-system/src/main/java/me/zhengjie/AppRun.java index 36ec4f0c..d0540c4f 100644 --- a/eladmin-system/src/main/java/me/zhengjie/AppRun.java +++ b/eladmin-system/src/main/java/me/zhengjie/AppRun.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie; +import io.swagger.annotations.Api; import me.zhengjie.annotation.AnonymousAccess; import me.zhengjie.utils.SpringContextHolder; import org.springframework.boot.SpringApplication; @@ -20,9 +36,10 @@ import org.springframework.web.bind.annotation.RestController; */ @EnableAsync @RestController -@EnableJpaAuditing(auditorAwareRef = "auditorAware") +@Api(hidden = true) @SpringBootApplication @EnableTransactionManagement +@EnableJpaAuditing(auditorAwareRef = "auditorAware") public class AppRun { public static void main(String[] args) { diff --git a/eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java b/eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java index 00827251..962a9932 100644 --- a/eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java +++ b/eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.config; import org.springframework.context.annotation.Bean; diff --git a/eladmin-system/src/main/java/me/zhengjie/config/DataScope.java b/eladmin-system/src/main/java/me/zhengjie/config/DataScope.java index 99de2835..80965b6b 100644 --- a/eladmin-system/src/main/java/me/zhengjie/config/DataScope.java +++ b/eladmin-system/src/main/java/me/zhengjie/config/DataScope.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.config; import me.zhengjie.modules.system.domain.Dept; diff --git a/eladmin-system/src/main/java/me/zhengjie/config/WebSocketConfig.java b/eladmin-system/src/main/java/me/zhengjie/config/WebSocketConfig.java index 66bd61f5..197f7651 100644 --- a/eladmin-system/src/main/java/me/zhengjie/config/WebSocketConfig.java +++ b/eladmin-system/src/main/java/me/zhengjie/config/WebSocketConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.config; import org.springframework.context.annotation.Bean; diff --git a/eladmin-system/src/main/java/me/zhengjie/config/thread/AsyncTaskExecutePool.java b/eladmin-system/src/main/java/me/zhengjie/config/thread/AsyncTaskExecutePool.java index b1e3f609..8df107ec 100644 --- a/eladmin-system/src/main/java/me/zhengjie/config/thread/AsyncTaskExecutePool.java +++ b/eladmin-system/src/main/java/me/zhengjie/config/thread/AsyncTaskExecutePool.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.config.thread; import lombok.extern.slf4j.Slf4j; diff --git a/eladmin-system/src/main/java/me/zhengjie/config/thread/AsyncTaskProperties.java b/eladmin-system/src/main/java/me/zhengjie/config/thread/AsyncTaskProperties.java index f836fa09..21fdfd8e 100644 --- a/eladmin-system/src/main/java/me/zhengjie/config/thread/AsyncTaskProperties.java +++ b/eladmin-system/src/main/java/me/zhengjie/config/thread/AsyncTaskProperties.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.config.thread; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/config/thread/TheadFactoryName.java b/eladmin-system/src/main/java/me/zhengjie/config/thread/TheadFactoryName.java index 482be948..4cc8ae91 100644 --- a/eladmin-system/src/main/java/me/zhengjie/config/thread/TheadFactoryName.java +++ b/eladmin-system/src/main/java/me/zhengjie/config/thread/TheadFactoryName.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.config.thread; import org.springframework.stereotype.Component; diff --git a/eladmin-system/src/main/java/me/zhengjie/config/thread/ThreadPoolExecutorUtil.java b/eladmin-system/src/main/java/me/zhengjie/config/thread/ThreadPoolExecutorUtil.java index 92627465..9a36abd3 100644 --- a/eladmin-system/src/main/java/me/zhengjie/config/thread/ThreadPoolExecutorUtil.java +++ b/eladmin-system/src/main/java/me/zhengjie/config/thread/ThreadPoolExecutorUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.config.thread; import me.zhengjie.utils.SpringContextHolder; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/App.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/App.java index a167130e..cf5789c9 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/App.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/App.java @@ -1,75 +1,66 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.domain; -import lombok.Data; +import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; -import org.hibernate.annotations.CreationTimestamp; - +import lombok.Getter; +import lombok.Setter; +import me.zhengjie.base.BaseEntity; import javax.persistence.*; import java.io.Serializable; -import java.sql.Timestamp; /** * @author zhanghouying * @date 2019-08-24 */ @Entity -@Data +@Getter +@Setter @Table(name="mnt_app") -public class App implements Serializable { +public class App extends BaseEntity implements Serializable { - /** - * 应用编号 - */ @Id + @Column(name = "app_id") + @ApiModelProperty(value = "ID", hidden = true) @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - /** - * 应用名称 - */ - @Column(name = "name") + @ApiModelProperty(value = "名称") private String name; - /** - * 端口 - */ - @Column(name = "port") + @ApiModelProperty(value = "端口") private int port; - /** - * 上传目录 - */ - @Column(name = "upload_path") + @ApiModelProperty(value = "上传路径") private String uploadPath; - /** - * 部署目录 - */ - @Column(name = "deploy_path") + @ApiModelProperty(value = "部署路径") private String deployPath; - /** - * 备份目录 - */ - @Column(name = "backup_path") + @ApiModelProperty(value = "备份路径") private String backupPath; - /** - * 启动脚本 - */ - @Column(name = "start_script") + @ApiModelProperty(value = "启动脚本") private String startScript; - /** - * 部署脚本 - */ - @Column(name = "deploy_script") + @ApiModelProperty(value = "部署脚本") private String deployScript; - @CreationTimestamp - private Timestamp createTime; - public void copy(App source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/Database.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/Database.java index 51f2eee7..6b3a68a6 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/Database.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/Database.java @@ -1,57 +1,56 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.domain; -import lombok.Data; +import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; -import org.hibernate.annotations.CreationTimestamp; - +import lombok.Getter; +import lombok.Setter; +import me.zhengjie.base.BaseEntity; import javax.persistence.*; import java.io.Serializable; -import java.sql.Timestamp; /** * @author zhanghouying * @date 2019-08-24 */ @Entity -@Data +@Getter +@Setter @Table(name="mnt_database") -public class Database implements Serializable { +public class Database extends BaseEntity implements Serializable { - /** - * id - */ @Id - @Column(name = "id") + @Column(name = "db_id") + @ApiModelProperty(value = "ID", hidden = true) private String id; - /** - * 数据库名称 - */ - @Column(name = "name",nullable = false) + @ApiModelProperty(value = "数据库名称") private String name; - /** - * 数据库连接地址 - */ - @Column(name = "jdbc_url",nullable = false) + @ApiModelProperty(value = "数据库连接地址") private String jdbcUrl; - /** - * 数据库密码 - */ - @Column(name = "pwd",nullable = false) + @ApiModelProperty(value = "数据库密码") private String pwd; - /** - * 用户名 - */ - @Column(name = "user_name",nullable = false) + @ApiModelProperty(value = "用户名") private String userName; - @CreationTimestamp - private Timestamp createTime; - public void copy(Database source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/Deploy.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/Deploy.java index 99bda169..bcf61e54 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/Deploy.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/Deploy.java @@ -1,13 +1,28 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.domain; -import lombok.Data; +import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; -import org.hibernate.annotations.CreationTimestamp; - +import lombok.Getter; +import lombok.Setter; +import me.zhengjie.base.BaseEntity; import javax.persistence.*; import java.io.Serializable; -import java.sql.Timestamp; import java.util.Set; /** @@ -15,34 +30,29 @@ import java.util.Set; * @date 2019-08-24 */ @Entity -@Data +@Getter +@Setter @Table(name="mnt_deploy") -public class Deploy implements Serializable { +public class Deploy extends BaseEntity implements Serializable { - /** - * 部署编号 - */ @Id + @Column(name = "deploy_id") + @ApiModelProperty(value = "ID", hidden = true) @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - /** - * 应用编号 - */ + @ManyToMany + @ApiModelProperty(name = "服务器", hidden = true) + @JoinTable(name = "mnt_deploy_server", + joinColumns = {@JoinColumn(name = "deploy_id",referencedColumnName = "deploy_id")}, + inverseJoinColumns = {@JoinColumn(name = "server_id",referencedColumnName = "server_id")}) + private Set deploys; + @ManyToOne @JoinColumn(name = "app_id") + @ApiModelProperty(value = "应用编号") private App app; - /** - * 服务器 - */ - @ManyToMany - @JoinTable(name = "mnt_deploy_server", joinColumns = {@JoinColumn(name = "deploy_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "server_id",referencedColumnName = "id")}) - private Set deploys; - - @CreationTimestamp - private Timestamp createTime; - public void copy(Deploy source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/DeployHistory.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/DeployHistory.java index d7d4e22f..6e07e136 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/DeployHistory.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/DeployHistory.java @@ -1,10 +1,26 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.domain; -import lombok.Data; +import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; +import lombok.Getter; +import lombok.Setter; import org.hibernate.annotations.CreationTimestamp; - import javax.persistence.*; import java.io.Serializable; import java.sql.Timestamp; @@ -14,46 +30,30 @@ import java.sql.Timestamp; * @date 2019-08-24 */ @Entity -@Data +@Getter +@Setter @Table(name="mnt_deploy_history") public class DeployHistory implements Serializable { - /** - * 编号 - */ @Id - @Column(name = "id") + @Column(name = "history_id") + @ApiModelProperty(value = "ID", hidden = true) private String id; - /** - * 应用名称 - */ - @Column(name = "app_name",nullable = false) + @ApiModelProperty(value = "应用名称") private String appName; - /** - * 部署IP - */ - @Column(name = "ip",nullable = false) + @ApiModelProperty(value = "IP") private String ip; - /** - * 部署时间 - */ - @Column(name = "deploy_date") @CreationTimestamp + @ApiModelProperty(value = "部署时间") private Timestamp deployDate; - /** - * 部署人员 - */ - @Column(name = "deploy_user",nullable = false) + @ApiModelProperty(value = "部署者") private String deployUser; - /** - * 部署编号 - */ - @Column(name = "deploy_id",nullable = false) + @ApiModelProperty(value = "部署ID") private Long deployId; public void copy(DeployHistory source){ diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/ServerDeploy.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/ServerDeploy.java index cf49ecce..adf44833 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/ServerDeploy.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/domain/ServerDeploy.java @@ -1,40 +1,60 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.domain; -import lombok.Data; +import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; -import org.hibernate.annotations.CreationTimestamp; - +import lombok.Getter; +import lombok.Setter; +import me.zhengjie.base.BaseEntity; import javax.persistence.*; import java.io.Serializable; -import java.sql.Timestamp; /** * @author zhanghouying * @date 2019-08-24 */ @Entity -@Data +@Getter +@Setter @Table(name="mnt_server") -public class ServerDeploy implements Serializable { +public class ServerDeploy extends BaseEntity implements Serializable { @Id + @Column(name = "server_id") + @ApiModelProperty(value = "ID", hidden = true) @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @ApiModelProperty(value = "服务器名称") private String name; + @ApiModelProperty(value = "IP") private String ip; + @ApiModelProperty(value = "端口") private Integer port; + @ApiModelProperty(value = "账号") private String account; + @ApiModelProperty(value = "密码") private String password; - @CreationTimestamp - private Timestamp createTime; - public void copy(ServerDeploy source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/AppRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/AppRepository.java index 341fe4bc..41e5f5c9 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/AppRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/AppRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.repository; import me.zhengjie.modules.mnt.domain.App; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/DatabaseRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/DatabaseRepository.java index dc6109f1..695e0adc 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/DatabaseRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/DatabaseRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.repository; import me.zhengjie.modules.mnt.domain.Database; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/DeployHistoryRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/DeployHistoryRepository.java index e95637a0..3c8980ec 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/DeployHistoryRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/DeployHistoryRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.repository; import me.zhengjie.modules.mnt.domain.DeployHistory; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/DeployRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/DeployRepository.java index df5aa19b..2ea44986 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/DeployRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/DeployRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.repository; import me.zhengjie.modules.mnt.domain.Deploy; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerDeployRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerDeployRepository.java index a7db416a..15acfe70 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerDeployRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/repository/ServerDeployRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.repository; import me.zhengjie.modules.mnt.domain.ServerDeploy; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/AppController.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/AppController.java index 95014e1f..ffd95e8b 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/AppController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/AppController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.modules.mnt.domain.App; import me.zhengjie.modules.mnt.service.AppService; @@ -20,17 +36,14 @@ import java.util.Set; * @author zhanghouying * @date 2019-08-24 */ -@Api(tags = "应用管理") @RestController +@Api(tags = "运维:应用管理") +@RequiredArgsConstructor @RequestMapping("/api/app") public class AppController { private final AppService appService; - public AppController(AppService appService){ - this.appService = appService; - } - @Log("导出应用数据") @ApiOperation("导出应用数据") @GetMapping(value = "/download") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DatabaseController.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DatabaseController.java index 72cf248b..d508fb0d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DatabaseController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DatabaseController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.mnt.domain.Database; @@ -27,19 +43,15 @@ import java.util.Set; * @author zhanghouying * @date 2019-08-24 */ -@Api(tags = "数据库管理") +@Api(tags = "运维:数据库管理") @RestController +@RequiredArgsConstructor @RequestMapping("/api/database") public class DatabaseController { - private String fileSavePath = System.getProperty("java.io.tmpdir"); - + private final String fileSavePath = System.getProperty("java.io.tmpdir"); private final DatabaseService databaseService; - public DatabaseController(DatabaseService databaseService) { - this.databaseService = databaseService; - } - @Log("导出数据库数据") @ApiOperation("导出数据库数据") @GetMapping(value = "/download") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployController.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployController.java index c5dda473..2d8fb8d8 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.modules.mnt.domain.Deploy; import me.zhengjie.modules.mnt.domain.DeployHistory; @@ -28,18 +44,15 @@ import java.util.Set; * @author zhanghouying * @date 2019-08-24 */ -@Api(tags = "部署管理") @RestController +@Api(tags = "运维:部署管理") +@RequiredArgsConstructor @RequestMapping("/api/deploy") public class DeployController { - private String fileSavePath = System.getProperty("java.io.tmpdir"); - + private final String fileSavePath = System.getProperty("java.io.tmpdir"); private final DeployService deployService; - public DeployController(DeployService deployService) { - this.deployService = deployService; - } @Log("导出部署数据") @ApiOperation("导出部署数据") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployHistoryController.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployHistoryController.java index 7a646fae..a9111c22 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployHistoryController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/DeployHistoryController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.modules.mnt.service.DeployHistoryService; import me.zhengjie.modules.mnt.service.dto.DeployHistoryQueryCriteria; @@ -18,17 +34,14 @@ import java.util.Set; * @author zhanghouying * @date 2019-08-24 */ -@Api(tags = "部署历史管理") @RestController +@RequiredArgsConstructor +@Api(tags = "运维:部署历史管理") @RequestMapping("/api/deployHistory") public class DeployHistoryController { private final DeployHistoryService deployhistoryService; - public DeployHistoryController(DeployHistoryService deployhistoryService) { - this.deployhistoryService = deployhistoryService; - } - @Log("导出部署历史数据") @ApiOperation("导出部署历史数据") @GetMapping(value = "/download") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/ServerDeployController.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/ServerDeployController.java index 3d70a8fb..8c561bb7 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/ServerDeployController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/rest/ServerDeployController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.modules.mnt.domain.ServerDeploy; import me.zhengjie.modules.mnt.service.ServerDeployService; @@ -20,17 +36,14 @@ import java.util.Set; * @author zhanghouying * @date 2019-08-24 */ -@Api(tags = "服务器管理") @RestController +@Api(tags = "运维:服务器管理") +@RequiredArgsConstructor @RequestMapping("/api/serverDeploy") public class ServerDeployController { private final ServerDeployService serverDeployService; - public ServerDeployController(ServerDeployService serverDeployService) { - this.serverDeployService = serverDeployService; - } - @Log("导出服务器数据") @ApiOperation("导出服务器数据") @GetMapping(value = "/download") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/AppService.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/AppService.java index e2aaa93b..896554ea 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/AppService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/AppService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service; import me.zhengjie.modules.mnt.domain.App; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/DatabaseService.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/DatabaseService.java index 3ca46ae4..49a26eeb 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/DatabaseService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/DatabaseService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service; import me.zhengjie.modules.mnt.domain.Database; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/DeployHistoryService.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/DeployHistoryService.java index 10150696..bd43aed3 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/DeployHistoryService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/DeployHistoryService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service; import me.zhengjie.modules.mnt.domain.DeployHistory; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/DeployService.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/DeployService.java index 7332cb73..317e117f 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/DeployService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/DeployService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service; import me.zhengjie.modules.mnt.domain.Deploy; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/ServerDeployService.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/ServerDeployService.java index 927de74c..c5bba0ab 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/ServerDeployService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/ServerDeployService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service; import me.zhengjie.modules.mnt.domain.ServerDeploy; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/AppDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/AppDto.java index a9f52b09..c6fd6f74 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/AppDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/AppDto.java @@ -1,17 +1,32 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.dto; -import lombok.Data; - +import lombok.Getter; +import lombok.Setter; +import me.zhengjie.base.BaseDTO; import java.io.Serializable; -import java.sql.Timestamp; - /** * @author zhanghouying * @date 2019-08-24 */ -@Data -public class AppDto implements Serializable { +@Getter +@Setter +public class AppDto extends BaseDTO implements Serializable { /** * 应用编号 @@ -53,6 +68,4 @@ public class AppDto implements Serializable { */ private String deployScript; - private Timestamp createTime; - } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/AppQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/AppQueryCriteria.java index 7a036789..17f358f7 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/AppQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/AppQueryCriteria.java @@ -1,8 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.dto; import lombok.Data; import me.zhengjie.annotation.Query; - import java.sql.Timestamp; import java.util.List; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DatabaseDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DatabaseDto.java index b03132af..689b06b9 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DatabaseDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DatabaseDto.java @@ -1,16 +1,32 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.dto; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.zhengjie.base.BaseDTO; import java.io.Serializable; -import java.sql.Timestamp; - /** * @author zhanghouying * @date 2019-08-24 */ -@Data -public class DatabaseDto implements Serializable { +@Getter +@Setter +public class DatabaseDto extends BaseDTO implements Serializable { /** * id @@ -36,6 +52,4 @@ public class DatabaseDto implements Serializable { * 用户名 */ private String userName; - - private Timestamp createTime; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DatabaseQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DatabaseQueryCriteria.java index 81bccddb..53d619d4 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DatabaseQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DatabaseQueryCriteria.java @@ -1,8 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.dto; import lombok.Data; import me.zhengjie.annotation.Query; - import java.sql.Timestamp; import java.util.List; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployDto.java index 0344a261..d1732ee7 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployDto.java @@ -1,9 +1,25 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.dto; import cn.hutool.core.collection.CollectionUtil; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.zhengjie.base.BaseDTO; import java.io.Serializable; -import java.sql.Timestamp; import java.util.Set; import java.util.stream.Collectors; @@ -12,8 +28,9 @@ import java.util.stream.Collectors; * @author zhanghouying * @date 2019-08-24 */ -@Data -public class DeployDto implements Serializable { +@Getter +@Setter +public class DeployDto extends BaseDTO implements Serializable { /** * 部署编号 @@ -34,8 +51,6 @@ public class DeployDto implements Serializable { */ private String status; - private Timestamp createTime; - public String getServers() { if(CollectionUtil.isNotEmpty(deploys)){ return deploys.stream().map(ServerDeployDto::getName).collect(Collectors.joining(",")); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployHistoryDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployHistoryDto.java index 1dd0939f..a9f480cf 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployHistoryDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployHistoryDto.java @@ -1,10 +1,24 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.dto; import lombok.Data; import java.io.Serializable; import java.sql.Timestamp; - /** * @author zhanghouying * @date 2019-08-24 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployHistoryQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployHistoryQueryCriteria.java index 68562c23..c34f1242 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployHistoryQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployHistoryQueryCriteria.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.dto; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployQueryCriteria.java index b687ddb8..c404620a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/DeployQueryCriteria.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.dto; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployDto.java index acdc830d..7d323784 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployDto.java @@ -1,16 +1,32 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.dto; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.zhengjie.base.BaseDTO; import java.io.Serializable; -import java.sql.Timestamp; - /** * @author zhanghouying * @date 2019-08-24 */ -@Data -public class ServerDeployDto implements Serializable { +@Getter +@Setter +public class ServerDeployDto extends BaseDTO implements Serializable { private Long id; @@ -23,6 +39,4 @@ public class ServerDeployDto implements Serializable { private String account; private String password; - - private Timestamp createTime; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployQueryCriteria.java index 9c26efc7..bb8bd412 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/ServerDeployQueryCriteria.java @@ -1,8 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.dto; import lombok.Data; import me.zhengjie.annotation.Query; - import java.sql.Timestamp; import java.util.List; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/AppServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/AppServiceImpl.java index c62f53c2..afd1da95 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/AppServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/AppServiceImpl.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.impl; +import lombok.RequiredArgsConstructor; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.mnt.domain.App; import me.zhengjie.modules.mnt.repository.AppRepository; @@ -25,17 +41,12 @@ import java.util.*; * @date 2019-08-24 */ @Service +@RequiredArgsConstructor @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class AppServiceImpl implements AppService { - private AppRepository appRepository; - - private AppMapper appMapper; - - public AppServiceImpl(AppRepository appRepository, AppMapper appMapper) { - this.appMapper = appMapper; - this.appRepository = appRepository; - } + private final AppRepository appRepository; + private final AppMapper appMapper; @Override public Object queryAll(AppQueryCriteria criteria, Pageable pageable){ diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DatabaseServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DatabaseServiceImpl.java index da8955c0..bbac10fe 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DatabaseServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DatabaseServiceImpl.java @@ -1,6 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.impl; import cn.hutool.core.util.IdUtil; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.zhengjie.modules.mnt.domain.Database; import me.zhengjie.modules.mnt.repository.DatabaseRepository; @@ -18,7 +34,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; - import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.*; @@ -27,19 +42,14 @@ import java.util.*; * @author zhanghouying * @date 2019-08-24 */ -@Service @Slf4j +@Service +@RequiredArgsConstructor @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class DatabaseServiceImpl implements DatabaseService { - private DatabaseRepository databaseRepository; - - private DatabaseMapper databaseMapper; - - public DatabaseServiceImpl(DatabaseRepository databaseRepository,DatabaseMapper databaseMapper){ - this.databaseMapper = databaseMapper; - this.databaseRepository = databaseRepository; - } + private final DatabaseRepository databaseRepository; + private final DatabaseMapper databaseMapper; @Override public Object queryAll(DatabaseQueryCriteria criteria, Pageable pageable){ diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployHistoryServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployHistoryServiceImpl.java index 0306c81c..27d8eb98 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployHistoryServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployHistoryServiceImpl.java @@ -1,6 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.impl; import cn.hutool.core.util.IdUtil; +import lombok.RequiredArgsConstructor; import me.zhengjie.modules.mnt.domain.DeployHistory; import me.zhengjie.modules.mnt.repository.DeployHistoryRepository; import me.zhengjie.modules.mnt.service.DeployHistoryService; @@ -16,7 +32,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; - import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.*; @@ -26,18 +41,13 @@ import java.util.*; * @date 2019-08-24 */ @Service +@RequiredArgsConstructor @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class DeployHistoryServiceImpl implements DeployHistoryService { private final DeployHistoryRepository deployhistoryRepository; - private final DeployHistoryMapper deployhistoryMapper; - public DeployHistoryServiceImpl(DeployHistoryRepository deployhistoryRepository, DeployHistoryMapper deployhistoryMapper) { - this.deployhistoryRepository = deployhistoryRepository; - this.deployhistoryMapper = deployhistoryMapper; - } - @Override public Object queryAll(DeployHistoryQueryCriteria criteria, Pageable pageable){ Page page = deployhistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java index 03a746bb..0f66577a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/DeployServiceImpl.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.impl; import cn.hutool.core.date.DatePattern; import cn.hutool.core.date.DateUtil; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.mnt.domain.App; @@ -35,29 +51,18 @@ import java.util.*; */ @Slf4j @Service +@RequiredArgsConstructor @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class DeployServiceImpl implements DeployService { private final String FILE_SEPARATOR = "/"; - private final DeployRepository deployRepository; - private final DeployMapper deployMapper; - private final ServerDeployService serverDeployService; - private final DeployHistoryService deployHistoryService; - // 循环次数 private final Integer count = 30; - public DeployServiceImpl(DeployRepository deployRepository, DeployMapper deployMapper, ServerDeployService serverDeployService, DeployHistoryService deployHistoryService) { - this.deployRepository = deployRepository; - this.deployMapper = deployMapper; - this.serverDeployService = serverDeployService; - this.deployHistoryService = deployHistoryService; - } - @Override public Object queryAll(DeployQueryCriteria criteria, Pageable pageable) { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerDeployServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerDeployServiceImpl.java index ba65bd58..fd16faf1 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerDeployServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/impl/ServerDeployServiceImpl.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.impl; +import lombok.RequiredArgsConstructor; import me.zhengjie.modules.mnt.domain.ServerDeploy; import me.zhengjie.modules.mnt.repository.ServerDeployRepository; import me.zhengjie.modules.mnt.service.ServerDeployService; @@ -25,17 +41,12 @@ import java.util.*; * @date 2019-08-24 */ @Service +@RequiredArgsConstructor @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class ServerDeployServiceImpl implements ServerDeployService { - private ServerDeployRepository serverDeployRepository; - - private ServerDeployMapper serverDeployMapper; - - public ServerDeployServiceImpl(ServerDeployRepository serverDeployRepository,ServerDeployMapper serverDeployMapper){ - this.serverDeployRepository = serverDeployRepository; - this.serverDeployMapper = serverDeployMapper; - } + private final ServerDeployRepository serverDeployRepository; + private final ServerDeployMapper serverDeployMapper; @Override public Object queryAll(ServerDeployQueryCriteria criteria, Pageable pageable){ diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/AppMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/AppMapper.java index e03c0bcc..4e9e1905 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/AppMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/AppMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DatabaseMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DatabaseMapper.java index 872c7849..05bb096d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DatabaseMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DatabaseMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DeployHistoryMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DeployHistoryMapper.java index 30538b64..cd0ac991 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DeployHistoryMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DeployHistoryMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DeployMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DeployMapper.java index 2071775a..a5e3ae47 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DeployMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/DeployMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/ServerDeployMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/ServerDeployMapper.java index 7fdf4a5b..a393a879 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/ServerDeployMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/mapper/ServerDeployMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ExecuteShellUtil.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ExecuteShellUtil.java index 708c2430..9c99f459 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ExecuteShellUtil.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ExecuteShellUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.util; import cn.hutool.core.io.IoUtil; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ScpClientUtil.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ScpClientUtil.java index 0736ddc7..0348790a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ScpClientUtil.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ScpClientUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.util; import ch.ethz.ssh2.Connection; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/SqlUtils.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/SqlUtils.java index d30aa865..2cefe910 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/SqlUtils.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/SqlUtils.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.util; import cn.hutool.crypto.SecureUtil; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ZipUtils.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ZipUtils.java index b0e0697a..84044e96 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ZipUtils.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/util/ZipUtils.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.util; import java.io.*; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/MsgType.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/MsgType.java index 5981a97d..2fc473da 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/MsgType.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/MsgType.java @@ -1,8 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.websocket; /** - * @author: ZhangHouYing - * @date: 2019-08-10 9:56 + * @author ZhangHouYing + * @date 2019-08-10 9:56 */ public enum MsgType { /** 连接 */ diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/SocketMsg.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/SocketMsg.java index 8a3fc9ee..ade33a24 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/SocketMsg.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/SocketMsg.java @@ -1,10 +1,25 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.websocket; import lombok.Data; /** - * @author: ZhangHouYing - * @date: 2019-08-10 9:55 + * @author ZhangHouYing + * @date 2019-08-10 9:55 */ @Data public class SocketMsg { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/WebSocketServer.java b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/WebSocketServer.java index dad338d2..1aa94181 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/WebSocketServer.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/mnt/websocket/WebSocketServer.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.mnt.websocket; import com.alibaba.fastjson.JSONObject; @@ -11,8 +26,8 @@ import java.io.IOException; import java.util.Objects; import java.util.concurrent.CopyOnWriteArraySet; /** - * @author: ZhangHouYing - * @date: 2019-08-10 15:46 + * @author ZhangHouYing + * @date 2019-08-10 15:46 */ @ServerEndpoint("/webSocket/{sid}") @Slf4j diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/config/VisitsInitialization.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/config/VisitsInitialization.java deleted file mode 100644 index f27e32e3..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/config/VisitsInitialization.java +++ /dev/null @@ -1,27 +0,0 @@ -package me.zhengjie.modules.monitor.config; - -import me.zhengjie.modules.monitor.service.VisitsService; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; -import org.springframework.stereotype.Component; - -/** - * 初始化站点统计 - * @author Zheng Jie - */ -@Component -public class VisitsInitialization implements ApplicationRunner { - - private final VisitsService visitsService; - - public VisitsInitialization(VisitsService visitsService) { - this.visitsService = visitsService; - } - - @Override - public void run(ApplicationArguments args){ - System.out.println("--------------- 初始化站点统计,如果存在今日统计则跳过 ---------------"); - visitsService.save(); - System.out.println("--------------- 初始化站点统计完成 ---------------"); - } -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/Server.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/Server.java deleted file mode 100644 index bcfca370..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/Server.java +++ /dev/null @@ -1,107 +0,0 @@ -package me.zhengjie.modules.monitor.domain; - -import lombok.Data; -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.bean.copier.CopyOptions; -import javax.persistence.*; -import java.io.Serializable; - -/** -* @author Zhang houying -* @date 2019-11-03 -*/ -@Entity -@Data -@Table(name="monitor_server") -public class Server implements Serializable { - - /** - * 编号 - */ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") - private Integer id; - - /** - * 名称 - */ - @Column(name = "name") - private String name; - - /** - * IP地址 - */ - @Column(name = "address",nullable = false) - private String address; - - /** - * 访问端口 - */ - @Column(name = "port") - private Integer port; - - /** - * 状态 - */ - @Column(name = "state") - private String state; - - /** - * CPU使用率 - */ - @Column(name = "cpu_rate") - private Double cpuRate; - - /** - * CPU内核数 - */ - @Column(name = "cpu_core") - private Integer cpuCore; - - /** - * 内存总数 - */ - @Column(name = "mem_total") - private Double memTotal; - - /** - * 内存使用量 - */ - @Column(name = "mem_used") - private Double memUsed; - - /** - * 磁盘总量 - */ - @Column(name = "disk_total") - private Double diskTotal; - - /** - * 磁盘使用量 - */ - @Column(name = "disk_used") - private Double diskUsed; - - /** - * 交换区总量 - */ - @Column(name = "swap_total") - private Double swapTotal; - - /** - * 交换区使用量 - */ - @Column(name = "swap_used") - private Double swapUsed; - - /** - * 排序 - */ - @Column(name = "sort") - private Integer sort; - - public void copy(Server source){ - BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); - } -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/Visits.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/Visits.java deleted file mode 100644 index 7072fedf..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/Visits.java +++ /dev/null @@ -1,40 +0,0 @@ -package me.zhengjie.modules.monitor.domain; - -import lombok.Data; -import org.hibernate.annotations.CreationTimestamp; - -import javax.persistence.*; -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * pv 与 ip 统计 - * - * @author Zheng Jie - * @date 2018-12-13 - */ -@Entity -@Data -@Table(name = "visits") -public class Visits implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @Column(unique = true) - private String date; - - @Column(name = "pv_counts") - private Long pvCounts; - - @Column(name = "ip_counts") - private Long ipCounts; - - @CreationTimestamp - @Column(name = "create_time") - private Timestamp createTime; - - @Column(name = "week_day") - private String weekDay; -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/vo/RedisVo.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/vo/RedisVo.java deleted file mode 100644 index 019a92c0..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/vo/RedisVo.java +++ /dev/null @@ -1,24 +0,0 @@ -package me.zhengjie.modules.monitor.domain.vo; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -import javax.validation.constraints.NotBlank; -import java.io.Serializable; - -/** - * @author Zheng Jie - * @date 2018-12-10 - */ -@Data -@AllArgsConstructor -@NoArgsConstructor -public class RedisVo implements Serializable { - - @NotBlank - private String key; - - @NotBlank - private String value; -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/repository/ServerRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/repository/ServerRepository.java deleted file mode 100644 index 4a878163..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/repository/ServerRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package me.zhengjie.modules.monitor.repository; - -import me.zhengjie.modules.monitor.domain.Server; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; - -/** -* @author Zhang houying -* @date 2019-11-03 -*/ -public interface ServerRepository extends JpaRepository, JpaSpecificationExecutor { -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/repository/VisitsRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/repository/VisitsRepository.java deleted file mode 100644 index 8c13338f..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/repository/VisitsRepository.java +++ /dev/null @@ -1,31 +0,0 @@ -package me.zhengjie.modules.monitor.repository; - -import me.zhengjie.modules.monitor.domain.Visits; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; -import org.springframework.stereotype.Repository; -import java.util.List; - -/** - * @author Zheng Jie - * @date 2018-12-13 - */ -@Repository -public interface VisitsRepository extends JpaRepository { - - /** - * findByDate - * @param date 日期 - * @return Visits - */ - Visits findByDate(String date); - - /** - * 获得一个时间段的记录 - * @param date1 日期1 - * @param date2 日期2 - * @return List - */ - @Query(value = "select * FROM visits where create_time between ?1 and ?2",nativeQuery = true) - List findAllVisits(String date1, String date2); -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/ServerController.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/ServerController.java deleted file mode 100644 index 7bc005ed..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/ServerController.java +++ /dev/null @@ -1,66 +0,0 @@ -package me.zhengjie.modules.monitor.rest; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import me.zhengjie.aop.log.Log; -import me.zhengjie.modules.monitor.domain.Server; -import me.zhengjie.modules.monitor.service.ServerService; -import me.zhengjie.modules.monitor.service.dto.ServerQueryCriteria; -import org.springframework.data.domain.Pageable; -import org.springframework.http.HttpStatus; -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.Set; - -/** -* @author Zhang houying -* @date 2019-11-03 -*/ -@Api(tags = "服务监控管理") -@RestController -@RequestMapping("/api/server") -public class ServerController { - - private final ServerService serverService; - - public ServerController(ServerService serverService) { - this.serverService = serverService; - } - - @GetMapping - @Log("查询服务监控") - @ApiOperation("查询服务监控") - @PreAuthorize("@el.check('server:list')") - public ResponseEntity getServers(ServerQueryCriteria criteria, Pageable pageable){ - return new ResponseEntity<>(serverService.queryAll(criteria,pageable),HttpStatus.OK); - } - - @PostMapping - @Log("新增服务监控") - @ApiOperation("新增服务监控") - @PreAuthorize("@el.check('server:add')") - public ResponseEntity create(@Validated @RequestBody Server resources){ - return new ResponseEntity<>(serverService.create(resources),HttpStatus.CREATED); - } - - @PutMapping - @Log("修改服务监控") - @ApiOperation("修改服务监控") - @PreAuthorize("@el.check('server:edit')") - public ResponseEntity update(@Validated @RequestBody Server resources){ - serverService.update(resources); - return new ResponseEntity<>(HttpStatus.NO_CONTENT); - } - - @DeleteMapping - @Log("删除服务监控") - @ApiOperation("删除服务监控") - @PreAuthorize("@el.check('server:del')") - public ResponseEntity delete(@RequestBody Set ids){ - serverService.delete(ids); - return new ResponseEntity<>(HttpStatus.OK); - } -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/VisitsController.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/VisitsController.java deleted file mode 100644 index 26374f75..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/VisitsController.java +++ /dev/null @@ -1,47 +0,0 @@ -package me.zhengjie.modules.monitor.rest; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import me.zhengjie.modules.monitor.service.VisitsService; -import me.zhengjie.utils.RequestHolder; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author Zheng Jie - * @date 2018-12-13 - */ -@RestController -@RequestMapping("/api/visits") -@Api(tags = "系统:访问记录管理") -public class VisitsController { - - private final VisitsService visitsService; - - public VisitsController(VisitsService visitsService) { - this.visitsService = visitsService; - } - - @PostMapping - @ApiOperation("创建访问记录") - public ResponseEntity create(){ - visitsService.count(RequestHolder.getHttpServletRequest()); - return new ResponseEntity<>(HttpStatus.CREATED); - } - - @GetMapping - @ApiOperation("查询") - public ResponseEntity get(){ - return new ResponseEntity<>(visitsService.get(),HttpStatus.OK); - } - - @GetMapping(value = "/chartData") - @ApiOperation("查询图表数据") - public ResponseEntity getChartData(){ - return new ResponseEntity<>(visitsService.getChartData(),HttpStatus.OK); - } -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/ServerService.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/ServerService.java deleted file mode 100644 index b9269e59..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/ServerService.java +++ /dev/null @@ -1,59 +0,0 @@ -package me.zhengjie.modules.monitor.service; - -import me.zhengjie.modules.monitor.domain.Server; -import me.zhengjie.modules.monitor.service.dto.ServerDTO; -import me.zhengjie.modules.monitor.service.dto.ServerQueryCriteria; -import org.springframework.data.domain.Pageable; - -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** -* @author Zhang houying -* @date 2019-11-03 -*/ -public interface ServerService { - - /** - * 查询数据分页 - * @param criteria 条件参数 - * @param pageable 分页参数 - * @return Map - */ - Map queryAll(ServerQueryCriteria criteria, Pageable pageable); - - /** - * 查询所有数据不分页 - * @param criteria 条件参数 - * @return List - */ - List queryAll(ServerQueryCriteria criteria); - - /** - * 根据ID查询 - * @param id ID - * @return ServerDTO - */ - ServerDTO findById(Integer id); - - /** - * 创建服务监控 - * @param resources / - * @return / - */ - ServerDTO create(Server resources); - - /** - * 编辑服务监控 - * @param resources / - */ - void update(Server resources); - - /** - * 删除 - * @param id / - */ - void delete(Set id); - -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/VisitsService.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/VisitsService.java deleted file mode 100644 index a403b089..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/VisitsService.java +++ /dev/null @@ -1,35 +0,0 @@ -package me.zhengjie.modules.monitor.service; - -import org.springframework.scheduling.annotation.Async; -import javax.servlet.http.HttpServletRequest; - -/** - * @author Zheng Jie - * @date 2018-12-13 - */ -public interface VisitsService { - - /** - * 提供给定时任务,每天0点执行 - */ - void save(); - - /** - * 新增记录 - * @param request / - */ - @Async - void count(HttpServletRequest request); - - /** - * 获取数据 - * @return / - */ - Object get(); - - /** - * getChartData - * @return / - */ - Object getChartData(); -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/dto/ServerDTO.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/dto/ServerDTO.java deleted file mode 100644 index a78c9fa8..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/dto/ServerDTO.java +++ /dev/null @@ -1,49 +0,0 @@ -package me.zhengjie.modules.monitor.service.dto; - -import lombok.Data; -import java.io.Serializable; - - -/** -* @author Zhang houying -* @date 2019-11-03 -*/ -@Data -public class ServerDTO implements Serializable { - - private Integer id; - - private String name; - - private String address; - - private Integer port; - - private String state; - - /** CPU使用率 */ - private Float cpuRate; - - /** CPU内核数 */ - private Integer cpuCore; - - /** 内存总数 */ - private Float memTotal; - - /** 内存使用量 */ - private Float memUsed; - - /** 磁盘总量 */ - private Float diskTotal; - - /** 磁盘使用量 */ - private Float diskUsed; - - /** 交换区总量 */ - private Float swapTotal; - - /** 交换区使用量 */ - private Float swapUsed; - - private Integer sort; -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/dto/ServerQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/dto/ServerQueryCriteria.java deleted file mode 100644 index 217e87f6..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/dto/ServerQueryCriteria.java +++ /dev/null @@ -1,15 +0,0 @@ -package me.zhengjie.modules.monitor.service.dto; - -import lombok.Data; -import me.zhengjie.annotation.Query; - -/** -* @author Zhang houying -* @date 2019-11-03 -*/ -@Data -public class ServerQueryCriteria{ - - @Query(blurry = "name,address") - private String blurry; -} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/impl/ServerServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/impl/ServerServiceImpl.java deleted file mode 100644 index 479eae26..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/impl/ServerServiceImpl.java +++ /dev/null @@ -1,101 +0,0 @@ -package me.zhengjie.modules.monitor.service.impl; - -import cn.hutool.http.HttpUtil; -import com.alibaba.fastjson.JSONObject; -import me.zhengjie.modules.monitor.domain.Server; -import me.zhengjie.modules.monitor.repository.ServerRepository; -import me.zhengjie.modules.monitor.service.ServerService; -import me.zhengjie.modules.monitor.service.dto.ServerDTO; -import me.zhengjie.modules.monitor.service.dto.ServerQueryCriteria; -import me.zhengjie.modules.monitor.service.mapper.ServerMapper; -import me.zhengjie.utils.PageUtil; -import me.zhengjie.utils.QueryHelp; -import me.zhengjie.utils.ValidationUtil; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** -* @author Zhang houying -* @date 2019-11-03 -*/ -@Service -@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) -public class ServerServiceImpl implements ServerService { - - private final ServerRepository serverRepository; - - private final ServerMapper serverMapper; - - public ServerServiceImpl(ServerRepository serverRepository, ServerMapper serverMapper) { - this.serverRepository = serverRepository; - this.serverMapper = serverMapper; - } - - @Override - public Map queryAll(ServerQueryCriteria criteria, Pageable pageable){ - Page page = serverRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - page.forEach(server -> { - try { - server.setState("1"); - String url = String.format("http://%s:%d/api/serverMonitor",server.getAddress(),server.getPort()); - String res = HttpUtil.get(url,3000); - JSONObject obj = JSONObject.parseObject(res); - server.setCpuRate(obj.getDouble("cpuRate")); - server.setCpuCore(obj.getInteger("cpuCore")); - server.setMemTotal(obj.getDouble("memTotal")); - server.setMemUsed(obj.getDouble("memUsed")); - server.setDiskTotal(obj.getDouble("diskTotal")); - server.setDiskUsed(obj.getDouble("diskUsed")); - server.setSwapTotal(obj.getDouble("swapTotal")); - server.setSwapUsed(obj.getDouble("swapUsed")); - } catch (Exception e) { - server.setState("0"); - e.printStackTrace(); - } - }); - - return PageUtil.toPage(page.map(serverMapper::toDto)); - } - - @Override - public List queryAll(ServerQueryCriteria criteria){ - return serverMapper.toDto(serverRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); - } - - @Override - public ServerDTO findById(Integer id) { - Server server = serverRepository.findById(id).orElseGet(Server::new); - ValidationUtil.isNull(server.getId(),"Server","id",id); - return serverMapper.toDto(server); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public ServerDTO create(Server resources) { - return serverMapper.toDto(serverRepository.save(resources)); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void update(Server resources) { - Server server = serverRepository.findById(resources.getId()).orElseGet(Server::new); - ValidationUtil.isNull( server.getId(),"Server","id",resources.getId()); - server.copy(resources); - serverRepository.save(server); - } - - @Override - @Transactional(rollbackFor = Exception.class) - public void delete(Set ids) { - for (Integer id : ids) { - serverRepository.deleteById(id); - } - } - -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/impl/VisitsServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/impl/VisitsServiceImpl.java deleted file mode 100644 index 213f5eb3..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/impl/VisitsServiceImpl.java +++ /dev/null @@ -1,90 +0,0 @@ -package me.zhengjie.modules.monitor.service.impl; - -import lombok.extern.slf4j.Slf4j; -import me.zhengjie.modules.monitor.domain.Visits; -import me.zhengjie.modules.monitor.repository.VisitsRepository; -import me.zhengjie.modules.monitor.service.VisitsService; -import me.zhengjie.repository.LogRepository; -import me.zhengjie.utils.StringUtils; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; -import javax.servlet.http.HttpServletRequest; -import java.time.LocalDate; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -/** - * @author Zheng Jie - * @date 2018-12-13 - */ -@Slf4j -@Service -@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) -public class VisitsServiceImpl implements VisitsService { - - private final VisitsRepository visitsRepository; - - private final LogRepository logRepository; - - public VisitsServiceImpl(VisitsRepository visitsRepository, LogRepository logRepository) { - this.visitsRepository = visitsRepository; - this.logRepository = logRepository; - } - - @Override - public void save() { - LocalDate localDate = LocalDate.now(); - Visits visits = visitsRepository.findByDate(localDate.toString()); - if(visits == null){ - visits = new Visits(); - visits.setWeekDay(StringUtils.getWeekDay()); - visits.setPvCounts(1L); - visits.setIpCounts(1L); - visits.setDate(localDate.toString()); - visitsRepository.save(visits); - } - } - - @Override - public void count(HttpServletRequest request) { - LocalDate localDate = LocalDate.now(); - Visits visits = visitsRepository.findByDate(localDate.toString()); - visits.setPvCounts(visits.getPvCounts()+1); - long ipCounts = logRepository.findIp(localDate.toString(), localDate.plusDays(1).toString()); - visits.setIpCounts(ipCounts); - visitsRepository.save(visits); - } - - @Override - public Object get() { - Map map = new HashMap<>(4); - LocalDate localDate = LocalDate.now(); - Visits visits = visitsRepository.findByDate(localDate.toString()); - List list = visitsRepository.findAllVisits(localDate.minusDays(6).toString(),localDate.plusDays(1).toString()); - - long recentVisits = 0, recentIp = 0; - for (Visits data : list) { - recentVisits += data.getPvCounts(); - recentIp += data.getIpCounts(); - } - map.put("newVisits",visits.getPvCounts()); - map.put("newIp",visits.getIpCounts()); - map.put("recentVisits",recentVisits); - map.put("recentIp",recentIp); - return map; - } - - @Override - public Object getChartData() { - Map map = new HashMap<>(3); - LocalDate localDate = LocalDate.now(); - List list = visitsRepository.findAllVisits(localDate.minusDays(6).toString(),localDate.plusDays(1).toString()); - map.put("weekDays",list.stream().map(Visits::getWeekDay).collect(Collectors.toList())); - map.put("visitsData",list.stream().map(Visits::getPvCounts).collect(Collectors.toList())); - map.put("ipData",list.stream().map(Visits::getIpCounts).collect(Collectors.toList())); - return map; - } -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/mapper/ServerMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/mapper/ServerMapper.java deleted file mode 100644 index 45b88fb8..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/mapper/ServerMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package me.zhengjie.modules.monitor.service.mapper; - -import me.zhengjie.base.BaseMapper; -import me.zhengjie.modules.monitor.domain.Server; -import me.zhengjie.modules.monitor.service.dto.ServerDTO; -import org.mapstruct.Mapper; -import org.mapstruct.ReportingPolicy; - -/** -* @author Zhang houying -* @date 2019-11-03 -*/ -@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface ServerMapper extends BaseMapper { - -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/config/JobRunner.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/config/JobRunner.java index 557df43c..e770570c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/config/JobRunner.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/config/JobRunner.java @@ -1,12 +1,27 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.config; +import lombok.RequiredArgsConstructor; import me.zhengjie.modules.quartz.domain.QuartzJob; import me.zhengjie.modules.quartz.repository.QuartzJobRepository; import me.zhengjie.modules.quartz.utils.QuartzManage; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.stereotype.Component; - import java.util.List; /** @@ -14,17 +29,12 @@ import java.util.List; * @date 2019-01-07 */ @Component +@RequiredArgsConstructor public class JobRunner implements ApplicationRunner { private final QuartzJobRepository quartzJobRepository; - private final QuartzManage quartzManage; - public JobRunner(QuartzJobRepository quartzJobRepository, QuartzManage quartzManage) { - this.quartzJobRepository = quartzJobRepository; - this.quartzManage = quartzManage; - } - /** * 项目启动时重新激活启用的定时任务 * @param applicationArguments / diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/config/QuartzConfig.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/config/QuartzConfig.java index 085534ab..a1e7f2e7 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/config/QuartzConfig.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/config/QuartzConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.config; import org.quartz.Scheduler; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzJob.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzJob.java index 6b664796..7d678a1e 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzJob.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzJob.java @@ -1,13 +1,28 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; -import org.hibernate.annotations.CreationTimestamp; +import me.zhengjie.base.BaseEntity; import javax.persistence.*; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; -import java.sql.Timestamp; /** * @author Zheng Jie @@ -16,51 +31,51 @@ import java.sql.Timestamp; @Getter @Setter @Entity -@Table(name = "quartz_job") -public class QuartzJob implements Serializable { +@Table(name = "sys_quartz_job") +public class QuartzJob extends BaseEntity implements Serializable { public static final String JOB_KEY = "JOB_KEY"; @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "job_id") @NotNull(groups = {Update.class}) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - /** 定时器名称 */ - @Column(name = "job_name") + @ApiModelProperty(value = "定时器名称") private String jobName; - /** Bean名称 */ - @Column(name = "bean_name") @NotBlank + @ApiModelProperty(value = "Bean名称") private String beanName; - /** 方法名称 */ - @Column(name = "method_name") @NotBlank + @ApiModelProperty(value = "方法名称") private String methodName; - /** 参数 */ - @Column(name = "params") + @ApiModelProperty(value = "参数") private String params; - /** cron表达式 */ - @Column(name = "cron_expression") @NotBlank + @ApiModelProperty(value = "cron表达式") private String cronExpression; - /** 状态 */ - @Column(name = "is_pause") + @ApiModelProperty(value = "状态,暂时或启动") private Boolean isPause = false; - /** 备注 */ - @Column(name = "remark") + @ApiModelProperty(value = "负责人") + private String personInCharge; + + @ApiModelProperty(value = "报警邮箱") + private String email; + + @ApiModelProperty(value = "子任务") + private String subTask; + + @ApiModelProperty(value = "失败后暂停") + private Boolean pauseAfterFailure; + @NotBlank - private String remark; - - @Column(name = "create_time") - @CreationTimestamp - private Timestamp createTime; - - public @interface Update {} + @ApiModelProperty(value = "备注") + private String description; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzLog.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzLog.java index a20c2f67..4de57ec1 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzLog.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzLog.java @@ -1,8 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; - import javax.persistence.*; import java.io.Serializable; import java.sql.Timestamp; @@ -13,46 +28,40 @@ import java.sql.Timestamp; */ @Entity @Data -@Table(name = "quartz_log") +@Table(name = "sys_quartz_log") public class QuartzLog implements Serializable { @Id + @Column(name = "log_id") + @ApiModelProperty(value = "ID", hidden = true) @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - /** 任务名称 */ - @Column(name = "job_name") + @ApiModelProperty(value = "任务名称", hidden = true) private String jobName; - /** Bean名称 */ - @Column(name = "baen_name") + @ApiModelProperty(value = "bean名称", hidden = true) private String beanName; - /** 方法名称 */ - @Column(name = "method_name") + @ApiModelProperty(value = "方法名称", hidden = true) private String methodName; - /** 参数 */ - @Column(name = "params") + @ApiModelProperty(value = "参数", hidden = true) private String params; - /** cron表达式 */ - @Column(name = "cron_expression") + @ApiModelProperty(value = "cron表达式", hidden = true) private String cronExpression; - /** 状态 */ - @Column(name = "is_success") + @ApiModelProperty(value = "状态", hidden = true) private Boolean isSuccess; - /** 异常详细 */ - @Column(name = "exception_detail",columnDefinition = "text") + @ApiModelProperty(value = "异常详情", hidden = true) private String exceptionDetail; - /** 耗时(毫秒) */ + @ApiModelProperty(value = "执行耗时", hidden = true) private Long time; - /** 创建日期 */ @CreationTimestamp - @Column(name = "create_time") + @ApiModelProperty(value = "创建时间", hidden = true) private Timestamp createTime; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/repository/QuartzJobRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/repository/QuartzJobRepository.java index e4143f9d..79b222be 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/repository/QuartzJobRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/repository/QuartzJobRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.repository; import me.zhengjie.modules.quartz.domain.QuartzJob; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/repository/QuartzLogRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/repository/QuartzLogRepository.java index f0722a82..db724aa4 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/repository/QuartzLogRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/repository/QuartzLogRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.repository; import me.zhengjie.modules.quartz.domain.QuartzLog; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java index 4b487366..5ede702b 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.zhengjie.aop.log.Log; import me.zhengjie.exception.BadRequestException; @@ -14,7 +30,6 @@ 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; @@ -25,18 +40,14 @@ import java.util.Set; */ @Slf4j @RestController -@Api(tags = "系统:定时任务管理") +@RequiredArgsConstructor @RequestMapping("/api/jobs") +@Api(tags = "系统:定时任务管理") public class QuartzJobController { private static final String ENTITY_NAME = "quartzJob"; - private final QuartzJobService quartzJobService; - public QuartzJobController(QuartzJobService quartzJobService) { - this.quartzJobService = quartzJobService; - } - @Log("查询定时任务") @ApiOperation("查询定时任务") @GetMapping diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/QuartzJobService.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/QuartzJobService.java index a8c83881..fc57d0c9 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/QuartzJobService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/QuartzJobService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.service; import me.zhengjie.modules.quartz.domain.QuartzJob; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/dto/JobQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/dto/JobQueryCriteria.java index b9351dd0..6cec0f19 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/dto/JobQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/dto/JobQueryCriteria.java @@ -1,8 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.service.dto; import lombok.Data; import me.zhengjie.annotation.Query; - import java.sql.Timestamp; import java.util.List; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/QuartzJobServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/QuartzJobServiceImpl.java index c331468a..90cc7cb7 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/QuartzJobServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/QuartzJobServiceImpl.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.service.impl; +import lombok.RequiredArgsConstructor; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.quartz.domain.QuartzJob; import me.zhengjie.modules.quartz.domain.QuartzLog; @@ -20,7 +36,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; - import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.*; @@ -29,23 +44,16 @@ import java.util.*; * @author Zheng Jie * @date 2019-01-07 */ +@RequiredArgsConstructor @Service(value = "quartzJobService") @CacheConfig(cacheNames = "quartzJob") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class QuartzJobServiceImpl implements QuartzJobService { private final QuartzJobRepository quartzJobRepository; - private final QuartzLogRepository quartzLogRepository; - private final QuartzManage quartzManage; - public QuartzJobServiceImpl(QuartzJobRepository quartzJobRepository, QuartzLogRepository quartzLogRepository, QuartzManage quartzManage) { - this.quartzJobRepository = quartzJobRepository; - this.quartzLogRepository = quartzLogRepository; - this.quartzManage = quartzManage; - } - @Override @Cacheable public Object queryAll(JobQueryCriteria criteria, Pageable pageable){ @@ -91,9 +99,6 @@ public class QuartzJobServiceImpl implements QuartzJobService { @CacheEvict(allEntries = true) @Transactional(rollbackFor = Exception.class) public void update(QuartzJob resources) { - if(resources.getId().equals(1L)){ - throw new BadRequestException("该任务不可操作"); - } if (!CronExpression.isValidExpression(resources.getCronExpression())){ throw new BadRequestException("cron表达式格式错误"); } @@ -104,9 +109,6 @@ public class QuartzJobServiceImpl implements QuartzJobService { @Override @CacheEvict(allEntries = true) public void updateIsPause(QuartzJob quartzJob) { - if(quartzJob.getId().equals(1L)){ - throw new BadRequestException("该任务不可操作"); - } if (quartzJob.getIsPause()) { quartzManage.resumeJob(quartzJob); quartzJob.setIsPause(false); @@ -119,9 +121,6 @@ public class QuartzJobServiceImpl implements QuartzJobService { @Override public void execution(QuartzJob quartzJob) { - if(quartzJob.getId().equals(1L)){ - throw new BadRequestException("该任务不可操作"); - } quartzManage.runJobNow(quartzJob); } @@ -130,9 +129,6 @@ public class QuartzJobServiceImpl implements QuartzJobService { @Transactional(rollbackFor = Exception.class) public void delete(Set ids) { for (Long id : ids) { - if(id.equals(1L)){ - throw new BadRequestException("更新访客记录不可删除,你可以在后台代码中取消该限制"); - } QuartzJob quartzJob = findById(id); quartzManage.deleteJob(quartzJob); quartzJobRepository.delete(quartzJob); @@ -150,7 +146,7 @@ public class QuartzJobServiceImpl implements QuartzJobService { map.put("参数", quartzJob.getParams()); map.put("表达式", quartzJob.getCronExpression()); map.put("状态", quartzJob.getIsPause() ? "暂停中" : "运行中"); - map.put("描述", quartzJob.getRemark()); + map.put("描述", quartzJob.getDescription()); map.put("创建日期", quartzJob.getCreateTime()); list.add(map); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/TestTask.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/TestTask.java index 757703bb..da1c8ff4 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/TestTask.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/TestTask.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.task; import lombok.extern.slf4j.Slf4j; @@ -13,10 +28,14 @@ import org.springframework.stereotype.Component; public class TestTask { public void run(){ - log.info("执行成功"); + log.info("run 执行成功"); } public void run1(String str){ - log.info("执行成功,参数为: {}" + str); + log.info("run1 执行成功,参数为: {}" + str); + } + + public void run2(){ + log.info("run2 执行成功"); } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/VisitsTask.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/VisitsTask.java deleted file mode 100644 index 47bb66c7..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/VisitsTask.java +++ /dev/null @@ -1,22 +0,0 @@ -package me.zhengjie.modules.quartz.task; - -import me.zhengjie.modules.monitor.service.VisitsService; -import org.springframework.stereotype.Component; - -/** - * @author Zheng Jie - * @date 2018-12-25 - */ -@Component -public class VisitsTask { - - private final VisitsService visitsService; - - public VisitsTask(VisitsService visitsService) { - this.visitsService = visitsService; - } - - public void run(){ - visitsService.save(); - } -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/ExecutionJob.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/ExecutionJob.java index 5d112534..355969d4 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/ExecutionJob.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/ExecutionJob.java @@ -1,11 +1,31 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.utils; -import me.zhengjie.config.thread.TheadFactoryName; +import cn.hutool.extra.template.Template; +import cn.hutool.extra.template.TemplateConfig; +import cn.hutool.extra.template.TemplateEngine; +import cn.hutool.extra.template.TemplateUtil; import me.zhengjie.config.thread.ThreadPoolExecutorUtil; +import me.zhengjie.domain.vo.EmailVo; import me.zhengjie.modules.quartz.domain.QuartzJob; import me.zhengjie.modules.quartz.domain.QuartzLog; import me.zhengjie.modules.quartz.repository.QuartzLogRepository; import me.zhengjie.modules.quartz.service.QuartzJobService; +import me.zhengjie.service.EmailService; import me.zhengjie.utils.SpringContextHolder; import me.zhengjie.utils.ThrowableUtil; import org.quartz.JobExecutionContext; @@ -13,6 +33,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.quartz.QuartzJobBean; + +import java.util.*; import java.util.concurrent.*; /** @@ -23,14 +45,14 @@ import java.util.concurrent.*; @Async public class ExecutionJob extends QuartzJobBean { - private Logger logger = LoggerFactory.getLogger(this.getClass()); + private final Logger logger = LoggerFactory.getLogger(this.getClass()); /** 该处仅供参考 */ private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll(); @Override @SuppressWarnings("unchecked") - protected void executeInternal(JobExecutionContext context) { + public void executeInternal(JobExecutionContext context) { QuartzJob quartzJob = (QuartzJob) context.getMergedJobDataMap().get(QuartzJob.JOB_KEY); // 获取spring bean QuartzLogRepository quartzLogRepository = SpringContextHolder.getBean(QuartzLogRepository.class); @@ -55,6 +77,13 @@ public class ExecutionJob extends QuartzJobBean { // 任务状态 log.setIsSuccess(true); logger.info("任务执行完毕,任务名称:{} 总共耗时:{} 毫秒", quartzJob.getJobName(), times); + // 判断是否存在子任务 + if(quartzJob.getSubTask() != null){ + String[] tasks = quartzJob.getSubTask().split("[,,]"); + for (String id : tasks) { + quartzJobService.execution(quartzJobService.findById(Long.parseLong(id))); + } + } } catch (Exception e) { logger.error("任务执行失败,任务名称:{}" + quartzJob.getJobName(), e); long times = System.currentTimeMillis() - startTime; @@ -62,11 +91,34 @@ public class ExecutionJob extends QuartzJobBean { // 任务状态 0:成功 1:失败 log.setIsSuccess(false); log.setExceptionDetail(ThrowableUtil.getStackTrace(e)); - quartzJob.setIsPause(false); - //更新状态 - quartzJobService.updateIsPause(quartzJob); + // 任务如果失败了则暂停 + if(quartzJob.getPauseAfterFailure() != null && quartzJob.getPauseAfterFailure()){ + quartzJob.setIsPause(false); + //更新状态 + quartzJobService.updateIsPause(quartzJob); + } + if(quartzJob.getEmail() != null){ + EmailService emailService = SpringContextHolder.getBean(EmailService.class); + // 邮箱报警 + EmailVo emailVo = taskAlarm(quartzJob, ThrowableUtil.getStackTrace(e)); + emailService.send(emailVo, emailService.find()); + } } finally { quartzLogRepository.save(log); } } + + private EmailVo taskAlarm(QuartzJob quartzJob, String msg) { + EmailVo emailVo = new EmailVo(); + emailVo.setSubject("定时任务【"+ quartzJob.getJobName() +"】执行失败,请尽快处理!"); + Map data = new HashMap<>(); + data.put("task", quartzJob); + data.put("msg", msg); + TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); + Template template = engine.getTemplate("email/taskAlarm.ftl"); + emailVo.setContent(template.render(data)); + List emails = Arrays.asList(quartzJob.getEmail().split("[,,]")); + emailVo.setTos(emails); + return emailVo; + } } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzManage.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzManage.java index 21ed2135..b96cbe74 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzManage.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzManage.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.utils; import lombok.extern.slf4j.Slf4j; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzRunnable.java b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzRunnable.java index f3f8720c..24f999b2 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzRunnable.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzRunnable.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.quartz.utils; import lombok.extern.slf4j.Slf4j; @@ -14,9 +29,9 @@ import java.util.concurrent.Callable; @Slf4j public class QuartzRunnable implements Callable { - private Object target; - private Method method; - private String params; + private final Object target; + private final Method method; + private final String params; QuartzRunnable(String beanName, String methodName, String params) throws NoSuchMethodException, SecurityException { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityConfig.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityConfig.java index bb9e5aae..5857f5e4 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityConfig.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityConfig.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.config; +import lombok.RequiredArgsConstructor; import me.zhengjie.annotation.AnonymousAccess; import me.zhengjie.modules.security.security.*; import org.springframework.context.ApplicationContext; @@ -28,6 +44,7 @@ import java.util.Set; */ @Configuration @EnableWebSecurity +@RequiredArgsConstructor @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true) public class SecurityConfig extends WebSecurityConfigurerAdapter { @@ -37,15 +54,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { private final JwtAccessDeniedHandler jwtAccessDeniedHandler; private final ApplicationContext applicationContext; - - public SecurityConfig(TokenProvider tokenProvider, CorsFilter corsFilter, JwtAuthenticationEntryPoint authenticationErrorHandler, JwtAccessDeniedHandler jwtAccessDeniedHandler, ApplicationContext applicationContext) { - this.tokenProvider = tokenProvider; - this.corsFilter = corsFilter; - this.authenticationErrorHandler = authenticationErrorHandler; - this.jwtAccessDeniedHandler = jwtAccessDeniedHandler; - this.applicationContext = applicationContext; - } - @Bean GrantedAuthorityDefaults grantedAuthorityDefaults() { // 去除 ROLE_ 前缀 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityProperties.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityProperties.java index 65aaca18..1949fe72 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityProperties.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SecurityProperties.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.config; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java index 10098643..e89658c6 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.rest; import cn.hutool.core.util.IdUtil; @@ -6,6 +21,7 @@ import cn.hutool.crypto.asymmetric.RSA; import com.wf.captcha.ArithmeticCaptcha; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.zhengjie.annotation.AnonymousAccess; import me.zhengjie.aop.log.Log; @@ -25,7 +41,6 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; @@ -41,6 +56,7 @@ import java.util.concurrent.TimeUnit; @Slf4j @RestController @RequestMapping("/auth") +@RequiredArgsConstructor @Api(tags = "系统:系统授权接口") public class AuthorizationController { @@ -52,20 +68,10 @@ public class AuthorizationController { private Boolean singleLogin; private final SecurityProperties properties; private final RedisUtils redisUtils; - private final UserDetailsService userDetailsService; private final OnlineUserService onlineUserService; private final TokenProvider tokenProvider; private final AuthenticationManagerBuilder authenticationManagerBuilder; - public AuthorizationController(SecurityProperties properties, RedisUtils redisUtils, UserDetailsService userDetailsService, OnlineUserService onlineUserService, TokenProvider tokenProvider, AuthenticationManagerBuilder authenticationManagerBuilder) { - this.properties = properties; - this.redisUtils = redisUtils; - this.userDetailsService = userDetailsService; - this.onlineUserService = onlineUserService; - this.tokenProvider = tokenProvider; - this.authenticationManagerBuilder = authenticationManagerBuilder; - } - @Log("用户登录") @ApiOperation("登录授权") @AnonymousAccess diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/OnlineController.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/OnlineController.java index aa8d60fd..564ab363 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/OnlineController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/OnlineController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.modules.security.service.OnlineUserService; import me.zhengjie.utils.EncryptUtils; @@ -19,16 +35,13 @@ import java.util.Set; * @author Zheng Jie */ @RestController +@RequiredArgsConstructor @RequestMapping("/auth/online") @Api(tags = "系统:在线用户管理") public class OnlineController { private final OnlineUserService onlineUserService; - public OnlineController(OnlineUserService onlineUserService) { - this.onlineUserService = onlineUserService; - } - @ApiOperation("查询在线用户") @GetMapping @PreAuthorize("@el.check()") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/security/JwtAccessDeniedHandler.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/security/JwtAccessDeniedHandler.java index fc9ea698..8b3f8c17 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/security/JwtAccessDeniedHandler.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/security/JwtAccessDeniedHandler.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.security; import org.springframework.security.access.AccessDeniedException; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/security/JwtAuthenticationEntryPoint.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/security/JwtAuthenticationEntryPoint.java index 6f33d313..2ec7e645 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/security/JwtAuthenticationEntryPoint.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/security/JwtAuthenticationEntryPoint.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.security; import org.springframework.security.core.AuthenticationException; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/security/TokenConfigurer.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/security/TokenConfigurer.java index d78378d8..32a3beb6 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/security/TokenConfigurer.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/security/TokenConfigurer.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.security; +import lombok.RequiredArgsConstructor; import org.springframework.security.config.annotation.SecurityConfigurerAdapter; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.web.DefaultSecurityFilterChain; @@ -8,14 +24,11 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic /** * @author / */ +@RequiredArgsConstructor public class TokenConfigurer extends SecurityConfigurerAdapter { private final TokenProvider tokenProvider; - public TokenConfigurer(TokenProvider tokenProvider){ - this.tokenProvider = tokenProvider; - } - @Override public void configure(HttpSecurity http) { TokenFilter customFilter = new TokenFilter(tokenProvider); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/security/TokenFilter.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/security/TokenFilter.java index 57b1e17c..cc07f534 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/security/TokenFilter.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/security/TokenFilter.java @@ -1,6 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.security; import io.jsonwebtoken.ExpiredJwtException; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.zhengjie.modules.security.config.SecurityProperties; import me.zhengjie.modules.security.service.dto.OnlineUserDto; @@ -21,14 +37,11 @@ import java.io.IOException; * @author / */ @Slf4j +@RequiredArgsConstructor public class TokenFilter extends GenericFilterBean { private final TokenProvider tokenProvider; - TokenFilter(TokenProvider tokenProvider) { - this.tokenProvider = tokenProvider; - } - @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/security/TokenProvider.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/security/TokenProvider.java index efe58768..37885494 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/security/TokenProvider.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/security/TokenProvider.java @@ -1,9 +1,25 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.security; import cn.hutool.core.util.ObjectUtil; import io.jsonwebtoken.*; import io.jsonwebtoken.io.Decoders; import io.jsonwebtoken.security.Keys; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.zhengjie.modules.security.config.SecurityProperties; import org.springframework.beans.factory.InitializingBean; @@ -26,17 +42,13 @@ import java.util.stream.Collectors; */ @Slf4j @Component +@RequiredArgsConstructor public class TokenProvider implements InitializingBean { private final SecurityProperties properties; private static final String AUTHORITIES_KEY = "auth"; private Key key; - public TokenProvider(SecurityProperties properties) { - this.properties = properties; - } - - @Override public void afterPropertiesSet() { byte[] keyBytes = Decoders.BASE64.decode(properties.getBase64Secret()); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/OnlineUserService.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/OnlineUserService.java index 7f96f34b..fbc492e2 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/OnlineUserService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/OnlineUserService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.service; import lombok.extern.slf4j.Slf4j; @@ -14,14 +29,14 @@ import java.util.*; /** * @author Zheng Jie - * @Date 2019年10月26日21:56:27 + * @date 2019年10月26日21:56:27 */ @Service @Slf4j public class OnlineUserService { private final SecurityProperties properties; - private RedisUtils redisUtils; + private final RedisUtils redisUtils; public OnlineUserService(SecurityProperties properties, RedisUtils redisUtils) { this.properties = properties; @@ -35,13 +50,13 @@ public class OnlineUserService { * @param request / */ public void save(JwtUserDto jwtUserDto, String token, HttpServletRequest request){ - String job = jwtUserDto.getUser().getDept().getName() + "/" + jwtUserDto.getUser().getJob().getName(); + String dept = jwtUserDto.getUser().getDept().getName(); String ip = StringUtils.getIp(request); String browser = StringUtils.getBrowser(request); String address = StringUtils.getCityInfo(ip); OnlineUserDto onlineUserDto = null; try { - onlineUserDto = new OnlineUserDto(jwtUserDto.getUsername(), jwtUserDto.getUser().getNickName(), job, browser , ip, address, EncryptUtils.desEncrypt(token), new Date()); + onlineUserDto = new OnlineUserDto(jwtUserDto.getUsername(), jwtUserDto.getUser().getNickName(), dept, browser , ip, address, EncryptUtils.desEncrypt(token), new Date()); } catch (Exception e) { e.printStackTrace(); } @@ -114,7 +129,7 @@ public class OnlineUserService { for (OnlineUserDto user : all) { Map map = new LinkedHashMap<>(); map.put("用户名", user.getUserName()); - map.put("岗位", user.getJob()); + map.put("部门", user.getDept()); map.put("登录IP", user.getIp()); map.put("登录地点", user.getAddress()); map.put("浏览器", user.getBrowser()); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/UserDetailsServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/UserDetailsServiceImpl.java index eeafe833..fffbd25d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/UserDetailsServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/UserDetailsServiceImpl.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.service; +import lombok.RequiredArgsConstructor; import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.EntityNotFoundException; import me.zhengjie.modules.security.service.dto.JwtUserDto; @@ -16,19 +32,14 @@ import org.springframework.transaction.annotation.Transactional; * @author Zheng Jie * @date 2018-11-22 */ +@RequiredArgsConstructor @Service("userDetailsService") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class UserDetailsServiceImpl implements UserDetailsService { private final UserService userService; - private final RoleService roleService; - public UserDetailsServiceImpl(UserService userService, RoleService roleService) { - this.userService = userService; - this.roleService = roleService; - } - @Override public JwtUserDto loadUserByUsername(String username) { UserDto user; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/AuthUserDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/AuthUserDto.java index 1c01caf4..2f3b6087 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/AuthUserDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/AuthUserDto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.service.dto; import lombok.Getter; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/JwtUserDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/JwtUserDto.java index b224641f..e3fd827c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/JwtUserDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/JwtUserDto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.service.dto; import com.fasterxml.jackson.annotation.JsonIgnore; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/OnlineUserDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/OnlineUserDto.java index e635d1e0..290ab6d6 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/OnlineUserDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/OnlineUserDto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.security.service.dto; import lombok.AllArgsConstructor; @@ -27,7 +42,7 @@ public class OnlineUserDto { /** * 岗位 */ - private String job; + private String dept; /** * 浏览器 diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dept.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dept.java index 711283bb..d75621ea 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dept.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dept.java @@ -1,14 +1,29 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.domain; import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; -import org.hibernate.annotations.CreationTimestamp; +import me.zhengjie.base.BaseEntity; import javax.persistence.*; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; -import java.sql.Timestamp; import java.util.Objects; import java.util.Set; @@ -19,35 +34,32 @@ import java.util.Set; @Entity @Getter @Setter -@Table(name="dept") -public class Dept implements Serializable { +@Table(name="sys_dept") +public class Dept extends BaseEntity implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") + @Column(name = "dept_id") @NotNull(groups = Update.class) + @ApiModelProperty(value = "ID", hidden = true) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(name = "name",nullable = false) - @NotBlank - private String name; - - @NotNull - private Boolean enabled; - - @Column(name = "pid",nullable = false) - @NotNull - private Long pid; - @JsonIgnore @ManyToMany(mappedBy = "depts") + @ApiModelProperty(value = "角色") private Set roles; - @Column(name = "create_time") - @CreationTimestamp - private Timestamp createTime; + @NotBlank + @ApiModelProperty(value = "部门名称") + private String name; - public @interface Update {} + @NotNull + @ApiModelProperty(value = "是否启用") + private Boolean enabled; + + @NotNull + @ApiModelProperty(value = "上级部门") + private Long pid; @Override public boolean equals(Object o) { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dict.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dict.java index cbdde2c4..689cf2e3 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dict.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dict.java @@ -1,14 +1,28 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; import me.zhengjie.base.BaseEntity; -import org.hibernate.annotations.CreationTimestamp; import javax.persistence.*; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; -import java.sql.Timestamp; import java.util.List; /** @@ -18,28 +32,23 @@ import java.util.List; @Entity @Getter @Setter -@Table(name="dict") -public class Dict implements Serializable { +@Table(name="sys_dict") +public class Dict extends BaseEntity implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") + @Column(name = "dict_id") @NotNull(groups = Update.class) + @ApiModelProperty(value = "ID", hidden = true) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(name = "name",nullable = false,unique = true) - @NotBlank - private String name; - - @Column(name = "remark") - private String remark; - - @Column(name = "create_time") - @CreationTimestamp - private Timestamp createTime; - @OneToMany(mappedBy = "dict",cascade={CascadeType.PERSIST,CascadeType.REMOVE}) private List dictDetails; - public @interface Update {} + @NotBlank + @ApiModelProperty(value = "名称") + private String name; + + @ApiModelProperty(value = "描述") + private String description; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/DictDetail.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/DictDetail.java index 52200e9c..554dde61 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/DictDetail.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/DictDetail.java @@ -1,12 +1,27 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; -import org.hibernate.annotations.CreationTimestamp; +import me.zhengjie.base.BaseEntity; import javax.persistence.*; import javax.validation.constraints.NotNull; import java.io.Serializable; -import java.sql.Timestamp; /** * @author Zheng Jie @@ -15,34 +30,27 @@ import java.sql.Timestamp; @Entity @Getter @Setter -@Table(name="dict_detail") -public class DictDetail implements Serializable { +@Table(name="sys_dict_detail") +public class DictDetail extends BaseEntity implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") + @Column(name = "detail_id") @NotNull(groups = Update.class) + @ApiModelProperty(value = "ID", hidden = true) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - /** 字典标签 */ - @Column(name = "label",nullable = false) - private String label; - - /** 字典值 */ - @Column(name = "value",nullable = false) - private String value; - - /** 排序 */ - @Column(name = "sort") - private Integer sort = 999; - - @ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name = "dict_id") + @ManyToOne(fetch=FetchType.LAZY) + @ApiModelProperty(value = "字典", hidden = true) private Dict dict; - @Column(name = "create_time") - @CreationTimestamp - private Timestamp createTime; + @ApiModelProperty(value = "字典标签") + private String label; - public @interface Update {} + @ApiModelProperty(value = "字典值") + private String value; + + @ApiModelProperty(value = "排序") + private Integer dictSort = 999; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Job.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Job.java index 272cf424..a802919f 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Job.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Job.java @@ -1,15 +1,30 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; -import org.hibernate.annotations.CreationTimestamp; +import me.zhengjie.base.BaseEntity; import javax.persistence.*; import javax.persistence.Entity; import javax.persistence.Table; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import java.io.Serializable; -import java.sql.Timestamp; /** * @author Zheng Jie @@ -18,34 +33,25 @@ import java.sql.Timestamp; @Entity @Getter @Setter -@Table(name="job") -public class Job implements Serializable { +@Table(name="sys_job") +public class Job extends BaseEntity implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") + @Column(name = "job_id") @NotNull(groups = Update.class) + @ApiModelProperty(value = "ID", hidden = true) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(name = "name",nullable = false) @NotBlank + @ApiModelProperty(value = "岗位名称") private String name; - @Column(unique = true) @NotNull - private Long sort; + @ApiModelProperty(value = "岗位排序") + private Long jobSort; - @Column(name = "enabled",nullable = false) @NotNull + @ApiModelProperty(value = "是否启用") private Boolean enabled; - - @OneToOne - @JoinColumn(name = "dept_id") - private Dept dept; - - @Column(name = "create_time") - @CreationTimestamp - private Timestamp createTime; - - public @interface Update {} } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Menu.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Menu.java index 4b1f5003..1899edfa 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Menu.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Menu.java @@ -1,8 +1,25 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.domain; import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; +import me.zhengjie.base.BaseEntity; import org.hibernate.annotations.CreationTimestamp; import javax.persistence.*; import javax.validation.constraints.NotBlank; @@ -19,62 +36,61 @@ import java.util.Set; @Entity @Getter @Setter -@Table(name = "menu") -public class Menu implements Serializable { +@Table(name = "sys_menu") +public class Menu extends BaseEntity implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "menu_id") @NotNull(groups = {Update.class}) + @ApiModelProperty(value = "ID", hidden = true) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @JsonIgnore + @ManyToMany(mappedBy = "menus") + @ApiModelProperty(value = "菜单角色") + private Set roles; + @NotBlank - private String name; + @ApiModelProperty(value = "菜单标题") + private String title; - @Column(unique = true) - private Long sort = 999L; - - @Column(name = "path") - private String path; - - private String component; - - /** 类型,目录、菜单、按钮 */ - @Column(name = "type") - private Integer type; - - /** 权限 */ - @Column(name = "permission") - private String permission; - - @Column(unique = true,name = "component_name") + @Column(name = "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; @Column(columnDefinition = "bit(1) default 0") + @ApiModelProperty(value = "缓存") private Boolean cache; @Column(columnDefinition = "bit(1) default 0") + @ApiModelProperty(value = "是否隐藏") private Boolean hidden; - /** 上级菜单ID */ - @Column(name = "pid",nullable = false) + @ApiModelProperty(value = "上级菜单") private Long pid; - /** 是否为外链 true/false */ - @Column(name = "i_frame") + @ApiModelProperty(value = "外链菜单") private Boolean iFrame; - @ManyToMany(mappedBy = "menus") - @JsonIgnore - private Set roles; - - @Column(name = "create_time") - @CreationTimestamp - private Timestamp createTime; - - public @interface Update {} - @Override public boolean equals(Object o) { if (this == o) { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Role.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Role.java index ea13ddf2..4ef298c6 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Role.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Role.java @@ -1,8 +1,25 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.domain; import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; +import me.zhengjie.base.BaseEntity; import org.hibernate.annotations.CreationTimestamp; import javax.persistence.*; import javax.validation.constraints.NotBlank; @@ -17,53 +34,51 @@ import java.util.Set; * @author Zheng Jie * @date 2018-11-22 */ -@Entity -@Table(name = "role") @Getter @Setter -public class Role implements Serializable { +@Entity +@Table(name = "sys_role") +public class Role extends BaseEntity implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "role_id") @NotNull(groups = {Update.class}) + @GeneratedValue(strategy = GenerationType.IDENTITY) + @ApiModelProperty(value = "ID", hidden = true) private Long id; - @Column(nullable = false) - @NotBlank - private String name; - - /** 数据权限类型 全部 、 本级 、 自定义 */ - @Column(name = "data_scope") - private String dataScope = "本级"; - - /** 数值越小,级别越大 */ - @Column(name = "level") - private Integer level = 3; - - @Column - private String remark; - - /** 权限 */ - @Column(name = "permission") - private String permission; - @JsonIgnore @ManyToMany(mappedBy = "roles") + @ApiModelProperty(value = "用户", hidden = true) private Set users; @ManyToMany - @JoinTable(name = "roles_menus", joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "menu_id",referencedColumnName = "id")}) + @JoinTable(name = "sys_roles_menus", + joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "role_id")}, + inverseJoinColumns = {@JoinColumn(name = "menu_id",referencedColumnName = "menu_id")}) + @ApiModelProperty(value = "菜单", hidden = true) private Set menus; @ManyToMany - @JoinTable(name = "roles_depts", joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "dept_id",referencedColumnName = "id")}) + @JoinTable(name = "sys_roles_depts", + joinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "role_id")}, + inverseJoinColumns = {@JoinColumn(name = "dept_id",referencedColumnName = "dept_id")}) + @ApiModelProperty(value = "部门", hidden = true) private Set depts; - @Column(name = "create_time") - @CreationTimestamp - private Timestamp createTime; + @NotBlank + @ApiModelProperty(value = "名称", hidden = true) + private String name; - public @interface Update {} + @ApiModelProperty(value = "数据权限,全部 、 本级 、 自定义") + private String dataScope = "本级"; + + @Column(name = "level") + @ApiModelProperty(value = "级别,数值越小,级别越大") + private Integer level = 3; + + @ApiModelProperty(value = "描述") + private String description; @Override public boolean equals(Object o) { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java index 856ddc7f..6ee29e84 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/User.java @@ -1,15 +1,29 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; -import org.hibernate.annotations.CreationTimestamp; +import me.zhengjie.base.BaseEntity; import javax.persistence.*; import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; -import javax.validation.constraints.Pattern; import java.io.Serializable; -import java.sql.Timestamp; import java.util.Date; import java.util.Objects; import java.util.Set; @@ -21,61 +35,75 @@ import java.util.Set; @Entity @Getter @Setter -@Table(name="user") -public class User implements Serializable { +@Table(name="sys_user") +public class User extends BaseEntity implements Serializable { @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "user_id") @NotNull(groups = Update.class) + @GeneratedValue(strategy = GenerationType.IDENTITY) + @ApiModelProperty(value = "ID", hidden = true) private Long id; - @NotBlank - @Column(unique = true) - private String username; - - /** 用户昵称 */ - @NotBlank - private String nickName; - - /** 性别 */ - private String sex; - - @OneToOne - @JoinColumn(name = "avatar_id") - private UserAvatar userAvatar; - - @NotBlank - @Email - private String email; - - @NotBlank - private String phone; - - @NotNull - private Boolean enabled; - - private String password; - - @Column(name = "create_time") - @CreationTimestamp - private Timestamp createTime; - - @Column(name = "last_password_reset_time") - private Date lastPasswordResetTime; - @ManyToMany - @JoinTable(name = "users_roles", joinColumns = {@JoinColumn(name = "user_id",referencedColumnName = "id")}, inverseJoinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "id")}) + @ApiModelProperty(value = "用户角色") + @JoinTable(name = "sys_users_roles", + joinColumns = {@JoinColumn(name = "user_id",referencedColumnName = "user_id")}, + inverseJoinColumns = {@JoinColumn(name = "role_id",referencedColumnName = "role_id")}) private Set roles; - @OneToOne - @JoinColumn(name = "job_id") - private Job job; + @ManyToMany + @ApiModelProperty(value = "用户岗位") + @JoinTable(name = "sys_users_jobs", + joinColumns = {@JoinColumn(name = "user_id",referencedColumnName = "user_id")}, + inverseJoinColumns = {@JoinColumn(name = "job_id",referencedColumnName = "job_id")}) + private Set jobs; @OneToOne @JoinColumn(name = "dept_id") + @ApiModelProperty(value = "用户部门") private Dept dept; - public @interface Update {} + @NotBlank + @Column(unique = true) + @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; + + @Column(name = "pwd_reset_time") + @ApiModelProperty(value = "最后修改密码的时间", hidden = true) + private Date pwdResetTime; @Override public boolean equals(Object o) { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/UserAvatar.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/UserAvatar.java deleted file mode 100644 index 216668a2..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/UserAvatar.java +++ /dev/null @@ -1,45 +0,0 @@ -package me.zhengjie.modules.system.domain; - -import cn.hutool.core.util.ObjectUtil; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import me.zhengjie.base.BaseEntity; -import org.hibernate.annotations.CreationTimestamp; - -import javax.persistence.*; -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * @author Zheng Jie - * @date 2019年9月7日 16:16:59 - */ -@Entity -@Getter -@Setter -@NoArgsConstructor -@Table(name = "user_avatar") -public class UserAvatar implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - private String realName; - - private String path; - - private String size; - - @Column(name = "create_time") - @CreationTimestamp - private Timestamp createTime; - - public UserAvatar(UserAvatar userAvatar,String realName, String path, String size) { - this.id = ObjectUtil.isNotEmpty(userAvatar) ? userAvatar.getId() : null; - this.realName = realName; - this.path = path; - this.size = size; - } -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuMetaVo.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuMetaVo.java index 00856fb1..647baa88 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuMetaVo.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuMetaVo.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.domain.vo; import lombok.AllArgsConstructor; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuVo.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuVo.java index c511c3db..f3352a0e 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuVo.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/MenuVo.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.domain.vo; import com.fasterxml.jackson.annotation.JsonInclude; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/UserPassVo.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/UserPassVo.java index 86288673..fccb100f 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/UserPassVo.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/vo/UserPassVo.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.domain.vo; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DeptRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DeptRepository.java index 579fb636..fc24abcd 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DeptRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DeptRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.repository; import me.zhengjie.modules.system.domain.Dept; @@ -26,7 +41,7 @@ public interface DeptRepository extends JpaRepository, JpaSpecificat * @param id ID * @return / */ - @Query(value = "select name from dept where id = ?1",nativeQuery = true) + @Query(value = "select name from sys_dept where dept_id = ?1",nativeQuery = true) String findNameById(Long id); /** diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictDetailRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictDetailRepository.java index b394a7ba..b24f0196 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictDetailRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictDetailRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.repository; import me.zhengjie.modules.system.domain.DictDetail; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictRepository.java index f472a014..5f19c7dd 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/DictRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.repository; import me.zhengjie.modules.system.domain.Dict; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/JobRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/JobRepository.java index 46f42739..82755aa6 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/JobRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/JobRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.repository; import me.zhengjie.modules.system.domain.Job; @@ -9,4 +24,11 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; * @date 2019-03-29 */ public interface JobRepository extends JpaRepository, JpaSpecificationExecutor { + + /** + * 根据名称查询 + * @param name 名称 + * @return / + */ + Job findByName(String name); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/MenuRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/MenuRepository.java index aeffb601..4887c50d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/MenuRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/MenuRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.repository; import me.zhengjie.modules.system.domain.Menu; @@ -15,11 +30,11 @@ import java.util.Set; public interface MenuRepository extends JpaRepository, JpaSpecificationExecutor { /** - * 根据菜单名称查询 - * @param name 菜单名称 + * 根据菜单标题查询 + * @param title 菜单标题 * @return / */ - Menu findByName(String name); + Menu findByTitle(String title); /** * 根据组件名称查询 @@ -41,5 +56,5 @@ public interface MenuRepository extends JpaRepository, JpaSpecificat * @param type 类型 * @return / */ - LinkedHashSet findByRoles_IdInAndTypeNotOrderBySortAsc(Set roleIds, int type); + LinkedHashSet findByRoles_IdInAndTypeNotOrderByMenuSortAsc(Set roleIds, int type); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/RoleRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/RoleRepository.java index 155145f8..e94b3ef5 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/RoleRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/RoleRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.repository; import me.zhengjie.modules.system.domain.Role; @@ -35,11 +50,4 @@ public interface RoleRepository extends JpaRepository, JpaSpecificat @Modifying @Query(value = "delete from roles_menus where menu_id = ?1",nativeQuery = true) void untiedMenu(Long id); - - /** - * 根据角色权限查询 - * @param permission / - * @return / - */ - Role findByPermission(String permission); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserAvatarRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserAvatarRepository.java deleted file mode 100644 index 1e7e058c..00000000 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserAvatarRepository.java +++ /dev/null @@ -1,13 +0,0 @@ -package me.zhengjie.modules.system.repository; - -import me.zhengjie.modules.system.domain.UserAvatar; -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; - -/** - * @author Zheng Jie - * @date 2018-11-22 - */ -public interface UserAvatarRepository extends JpaRepository, JpaSpecificationExecutor { - -} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserRepository.java index acf1224e..7396909e 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/UserRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.repository; import me.zhengjie.modules.system.domain.User; @@ -34,7 +49,7 @@ public interface UserRepository extends JpaRepository, JpaSpecificat * @param lastPasswordResetTime / */ @Modifying - @Query(value = "update user set password = ?2 , last_password_reset_time = ?3 where username = ?1",nativeQuery = true) + @Query(value = "update sys_user set password = ?2 , pwd_reset_time = ?3 where username = ?1",nativeQuery = true) void updatePass(String username, String pass, Date lastPasswordResetTime); /** @@ -43,6 +58,6 @@ public interface UserRepository extends JpaRepository, JpaSpecificat * @param email 邮箱 */ @Modifying - @Query(value = "update user set email = ?2 where username = ?1",nativeQuery = true) + @Query(value = "update sys_user set email = ?2 where username = ?1",nativeQuery = true) void updateEmail(String username, String email); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DeptController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DeptController.java index d3c2301d..26ff1081 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DeptController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DeptController.java @@ -1,8 +1,24 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.rest; import cn.hutool.core.collection.CollectionUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.config.DataScope; import me.zhengjie.exception.BadRequestException; @@ -27,21 +43,15 @@ import java.util.Set; * @date 2019-03-25 */ @RestController +@RequiredArgsConstructor @Api(tags = "系统:部门管理") @RequestMapping("/api/dept") public class DeptController { private final DeptService deptService; - private final DataScope dataScope; - private static final String ENTITY_NAME = "dept"; - public DeptController(DeptService deptService, DataScope dataScope) { - this.deptService = deptService; - this.dataScope = dataScope; - } - @Log("导出部门数据") @ApiOperation("导出部门数据") @GetMapping(value = "/download") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java index 4e2d8107..831162a5 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.system.domain.Dict; @@ -13,7 +29,6 @@ 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; @@ -22,19 +37,15 @@ import java.util.Set; * @author Zheng Jie * @date 2019-04-10 */ -@Api(tags = "系统:字典管理") @RestController +@RequiredArgsConstructor +@Api(tags = "系统:字典管理") @RequestMapping("/api/dict") public class DictController { private final DictService dictService; - private static final String ENTITY_NAME = "dict"; - public DictController(DictService dictService) { - this.dictService = dictService; - } - @Log("导出字典数据") @ApiOperation("导出字典数据") @GetMapping(value = "/download") @@ -55,7 +66,7 @@ public class DictController { @ApiOperation("查询字典") @GetMapping @PreAuthorize("@el.check('dict:list')") - public ResponseEntity getDicts(DictQueryCriteria resources, Pageable pageable){ + public ResponseEntity getByQuery(DictQueryCriteria resources, Pageable pageable){ return new ResponseEntity<>(dictService.queryAll(resources,pageable),HttpStatus.OK); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java index 9638d9d5..606b0b47 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/DictDetailController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.system.domain.DictDetail; @@ -23,23 +39,19 @@ import java.util.Map; * @date 2019-04-10 */ @RestController +@RequiredArgsConstructor @Api(tags = "系统:字典详情管理") @RequestMapping("/api/dictDetail") public class DictDetailController { private final DictDetailService dictDetailService; - private static final String ENTITY_NAME = "dictDetail"; - public DictDetailController(DictDetailService dictDetailService) { - this.dictDetailService = dictDetailService; - } - @Log("查询字典详情") @ApiOperation("查询字典详情") @GetMapping public ResponseEntity getDictDetails(DictDetailQueryCriteria criteria, - @PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){ + @PageableDefault(sort = {"dictSort"}, direction = Sort.Direction.ASC) Pageable pageable){ return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK); } @@ -47,7 +59,7 @@ public class DictDetailController { @ApiOperation("查询多个字典详情") @GetMapping(value = "/map") public ResponseEntity getDictDetailMaps(DictDetailQueryCriteria criteria, - @PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){ + @PageableDefault(sort = {"dictSort"}, direction = Sort.Direction.ASC) Pageable pageable){ String[] names = criteria.getDictName().split(","); Map map = new HashMap<>(names.length); for (String name : names) { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/JobController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/JobController.java index 70d2b3b6..8f009d24 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/JobController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/JobController.java @@ -1,9 +1,24 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; -import me.zhengjie.config.DataScope; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.system.domain.Job; import me.zhengjie.modules.system.service.JobService; @@ -23,22 +38,15 @@ import java.util.Set; * @author Zheng Jie * @date 2019-03-29 */ -@Api(tags = "系统:岗位管理") @RestController +@RequiredArgsConstructor +@Api(tags = "系统:岗位管理") @RequestMapping("/api/job") public class JobController { private final JobService jobService; - - private final DataScope dataScope; - private static final String ENTITY_NAME = "job"; - public JobController(JobService jobService, DataScope dataScope) { - this.jobService = jobService; - this.dataScope = dataScope; - } - @Log("导出岗位数据") @ApiOperation("导出岗位数据") @GetMapping(value = "/download") @@ -52,8 +60,6 @@ public class JobController { @GetMapping @PreAuthorize("@el.check('job:list','user:list')") public ResponseEntity getJobs(JobQueryCriteria criteria, Pageable pageable){ - // 数据权限 - criteria.setDeptIds(dataScope.getDeptIds()); return new ResponseEntity<>(jobService.queryAll(criteria, pageable),HttpStatus.OK); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/LimitController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/LimitController.java similarity index 61% rename from eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/LimitController.java rename to eladmin-system/src/main/java/me/zhengjie/modules/system/rest/LimitController.java index 9b1b8310..c5b65536 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/LimitController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/LimitController.java @@ -1,4 +1,19 @@ -package me.zhengjie.modules.monitor.rest; +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java index f9aef38d..7dd4e002 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MenuController.java @@ -1,23 +1,36 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.modules.system.domain.Menu; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.system.service.MenuService; import me.zhengjie.modules.system.service.RoleService; -import me.zhengjie.modules.system.service.UserService; import me.zhengjie.modules.system.service.dto.MenuDto; import me.zhengjie.modules.system.service.dto.MenuQueryCriteria; -import me.zhengjie.modules.system.service.dto.UserDto; import me.zhengjie.utils.SecurityUtils; import org.springframework.http.HttpStatus; 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.HashSet; @@ -28,26 +41,18 @@ import java.util.Set; * @author Zheng Jie * @date 2018-12-03 */ -@Api(tags = "系统:菜单管理") + @RestController +@RequiredArgsConstructor +@Api(tags = "系统:菜单管理") @RequestMapping("/api/menus") @SuppressWarnings("unchecked") public class MenuController { private final MenuService menuService; - - private final UserService userService; - private final RoleService roleService; - private static final String ENTITY_NAME = "menu"; - public MenuController(MenuService menuService, UserService userService, RoleService roleService) { - this.menuService = menuService; - this.userService = userService; - this.roleService = roleService; - } - @Log("导出菜单数据") @ApiOperation("导出菜单数据") @GetMapping(value = "/download") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MonitorController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MonitorController.java new file mode 100644 index 00000000..baf28732 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/MonitorController.java @@ -0,0 +1,46 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import me.zhengjie.aop.log.Log; +import me.zhengjie.modules.system.service.MonitorService; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +/** + * @author Zheng Jie + * @date 2020-05-02 + */ +@RestController +@RequiredArgsConstructor +@Api(tags = "系统-服务监控管理") +@RequestMapping("/api/monitor") +public class MonitorController { + + private final MonitorService serverService; + + @GetMapping + @ApiOperation("查询服务监控") + @PreAuthorize("@el.check('monitor:list')") + public ResponseEntity getServers(){ + return new ResponseEntity<>(serverService.getServers(),HttpStatus.OK); + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java index 7be44fb3..6ed00489 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/RoleController.java @@ -1,17 +1,31 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.rest; import cn.hutool.core.lang.Dict; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.modules.system.domain.Role; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.system.service.RoleService; -import me.zhengjie.modules.system.service.UserService; import me.zhengjie.modules.system.service.dto.RoleDto; import me.zhengjie.modules.system.service.dto.RoleQueryCriteria; import me.zhengjie.modules.system.service.dto.RoleSmallDto; -import me.zhengjie.modules.system.service.dto.UserDto; import me.zhengjie.utils.SecurityUtils; import me.zhengjie.utils.ThrowableUtil; import org.springframework.data.domain.Pageable; @@ -33,21 +47,16 @@ import java.util.stream.Collectors; * @author Zheng Jie * @date 2018-12-03 */ -@Api(tags = "系统:角色管理") @RestController +@RequiredArgsConstructor +@Api(tags = "系统:角色管理") @RequestMapping("/api/roles") public class RoleController { private final RoleService roleService; - private final UserService userService; private static final String ENTITY_NAME = "role"; - public RoleController(RoleService roleService, UserService userService) { - this.roleService = roleService; - this.userService = userService; - } - @ApiOperation("获取单个role") @GetMapping(value = "/{id}") @PreAuthorize("@el.check('roles:list')") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java index 01adc42f..d3a5bf6e 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java @@ -1,12 +1,27 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.rest; import cn.hutool.crypto.asymmetric.KeyType; import cn.hutool.crypto.asymmetric.RSA; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.config.DataScope; -import me.zhengjie.domain.VerificationCode; import me.zhengjie.modules.system.domain.User; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.system.domain.vo.UserPassVo; @@ -15,9 +30,10 @@ import me.zhengjie.modules.system.service.RoleService; import me.zhengjie.modules.system.service.dto.RoleSmallDto; import me.zhengjie.modules.system.service.dto.UserDto; import me.zhengjie.modules.system.service.dto.UserQueryCriteria; -import me.zhengjie.service.VerificationCodeService; +import me.zhengjie.modules.system.service.VerifyService; import me.zhengjie.utils.*; import me.zhengjie.modules.system.service.UserService; +import me.zhengjie.utils.enums.CodeEnum; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; @@ -41,6 +57,7 @@ import java.util.stream.Collectors; @Api(tags = "系统:用户管理") @RestController @RequestMapping("/api/users") +@RequiredArgsConstructor public class UserController { @Value("${rsa.private_key}") @@ -50,16 +67,7 @@ public class UserController { private final DataScope dataScope; private final DeptService deptService; private final RoleService roleService; - private final VerificationCodeService verificationCodeService; - - public UserController(PasswordEncoder passwordEncoder, UserService userService, DataScope dataScope, DeptService deptService, RoleService roleService, VerificationCodeService verificationCodeService) { - this.passwordEncoder = passwordEncoder; - this.userService = userService; - this.dataScope = dataScope; - this.deptService = deptService; - this.roleService = roleService; - this.verificationCodeService = verificationCodeService; - } + private final VerifyService verificationCodeService; @Log("导出用户数据") @ApiOperation("导出用户数据") @@ -187,8 +195,7 @@ public class UserController { if(!passwordEncoder.matches(password, userDto.getPassword())){ throw new BadRequestException("密码错误"); } - VerificationCode verificationCode = new VerificationCode(code, ElAdminConstant.RESET_MAIL,"email",user.getEmail()); - verificationCodeService.validated(verificationCode); + verificationCodeService.validated(CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey() + user.getEmail(), code); userService.updateEmail(userDto.getUsername(),user.getEmail()); return new ResponseEntity<>(HttpStatus.OK); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/VerifyController.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/VerifyController.java new file mode 100644 index 00000000..0bd452a4 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/VerifyController.java @@ -0,0 +1,74 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.rest; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import me.zhengjie.domain.vo.EmailVo; +import me.zhengjie.service.EmailService; +import me.zhengjie.modules.system.service.VerifyService; +import me.zhengjie.utils.enums.CodeBiEnum; +import me.zhengjie.utils.enums.CodeEnum; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import java.util.Objects; + +/** + * @author Zheng Jie + * @date 2018-12-26 + */ +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/code") +@Api(tags = "系统:验证码管理") +public class VerifyController { + + private final VerifyService verificationCodeService; + private final EmailService emailService; + + @PostMapping(value = "/resetEmail") + @ApiOperation("重置邮箱,发送验证码") + public ResponseEntity resetEmail(@RequestParam String email){ + EmailVo emailVo = verificationCodeService.sendEmail(email, CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey()); + emailService.send(emailVo,emailService.find()); + return new ResponseEntity<>(HttpStatus.OK); + } + + @PostMapping(value = "/email/resetPass") + @ApiOperation("重置密码,发送验证码") + public ResponseEntity resetPass(@RequestParam String email){ + EmailVo emailVo = verificationCodeService.sendEmail(email, CodeEnum.EMAIL_RESET_PWD_CODE.getKey()); + emailService.send(emailVo,emailService.find()); + return new ResponseEntity<>(HttpStatus.OK); + } + + @GetMapping(value = "/validated") + @ApiOperation("验证码验证") + public ResponseEntity validated(@RequestParam String email, @RequestParam String code, @RequestParam Integer codeBi){ + CodeBiEnum biEnum = CodeBiEnum.find(codeBi); + switch (Objects.requireNonNull(biEnum)){ + case ONE: + verificationCodeService.validated(CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey() + email ,code); + break; + case TWO: + verificationCodeService.validated(CodeEnum.EMAIL_RESET_PWD_CODE.getKey() + email ,code); + break; + } + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DeptService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DeptService.java index b898c800..46e1e62a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DeptService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DeptService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service; import me.zhengjie.modules.system.domain.Dept; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictDetailService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictDetailService.java index fe570705..95bd94a3 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictDetailService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictDetailService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service; import me.zhengjie.modules.system.domain.DictDetail; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictService.java index 35dcb959..0ade0728 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service; import me.zhengjie.modules.system.domain.Dict; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/JobService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/JobService.java index d0eb9f6a..ad1b2dbb 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/JobService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/JobService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service; import me.zhengjie.modules.system.domain.Job; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/MenuService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/MenuService.java index 90ab9288..f5896e16 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/MenuService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/MenuService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service; import me.zhengjie.modules.system.domain.Menu; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/MonitorService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/MonitorService.java new file mode 100644 index 00000000..478225ae --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/MonitorService.java @@ -0,0 +1,31 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service; + +import java.util.Map; + +/** + * @author Zheng Jie + * @date 2020-05-02 + */ +public interface MonitorService { + + /** + * 查询数据分页 + * @return Map + */ + Map getServers(); +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/RoleService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/RoleService.java index 03d3701f..e6fde42a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/RoleService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/RoleService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service; import me.zhengjie.modules.system.domain.Role; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java index f019753f..37cf013d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service; import me.zhengjie.modules.system.domain.User; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/VerifyService.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/VerifyService.java new file mode 100644 index 00000000..4ca39b9d --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/VerifyService.java @@ -0,0 +1,41 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service; + +import me.zhengjie.domain.vo.EmailVo; + +/** + * @author Zheng Jie + * @date 2018-12-26 + */ +public interface VerifyService { + + /** + * 发送验证码 + * @param email / + * @param key / + * @return / + */ + EmailVo sendEmail(String email, String key); + + + /** + * 验证 + * @param code / + * @param key / + */ + void validated(String key, String code); +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptDto.java index d77e9c81..58da06dd 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptDto.java @@ -1,34 +1,45 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import com.fasterxml.jackson.annotation.JsonInclude; -import lombok.Data; import lombok.Getter; import lombok.Setter; -import javax.validation.constraints.NotNull; +import me.zhengjie.base.BaseDTO; import java.io.Serializable; -import java.sql.Timestamp; import java.util.List; /** * @author Zheng Jie * @date 2019-03-25 */ -@Data -public class DeptDto implements Serializable { +@Getter +@Setter +public class DeptDto extends BaseDTO implements Serializable { private Long id; - private String name; - - @NotNull - private Boolean enabled; - - private Long pid; - @JsonInclude(JsonInclude.Include.NON_EMPTY) private List children; - private Timestamp createTime; + private String name; + + private Boolean enabled; + + private Long pid; public String getLabel() { return name; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptQueryCriteria.java index 688be144..acdcec27 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptQueryCriteria.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptSmallDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptSmallDto.java index 13ff737c..4dc64e58 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptSmallDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DeptSmallDto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDetailDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDetailDto.java index 1ef66a71..541493ce 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDetailDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDetailDto.java @@ -1,8 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Getter; import lombok.Setter; - +import me.zhengjie.base.BaseDTO; import java.io.Serializable; import java.sql.Timestamp; @@ -12,17 +27,15 @@ import java.sql.Timestamp; */ @Getter @Setter -public class DictDetailDto implements Serializable { +public class DictDetailDto extends BaseDTO implements Serializable { private Long id; + private DictSmallDto dict; + private String label; private String value; - private Integer sort; - - private DictSmallDto dict; - - private Timestamp createTime; + private Integer dictSort; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDetailQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDetailQueryCriteria.java index 4678d8a9..91a01b1d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDetailQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDetailQueryCriteria.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDto.java index ea462abb..048b4a19 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictDto.java @@ -1,10 +1,24 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Getter; import lombok.Setter; - +import me.zhengjie.base.BaseDTO; import java.io.Serializable; -import java.sql.Timestamp; import java.util.List; /** @@ -13,15 +27,13 @@ import java.util.List; */ @Getter @Setter -public class DictDto implements Serializable { +public class DictDto extends BaseDTO implements Serializable { private Long id; - private String name; - - private String remark; - private List dictDetails; - private Timestamp createTime; + private String name; + + private String description; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictQueryCriteria.java index c336754a..6c13dad6 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictQueryCriteria.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictSmallDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictSmallDto.java index 4448307f..98fc6eeb 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictSmallDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/DictSmallDto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Getter; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobDto.java index f8900357..f2153e0e 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobDto.java @@ -1,8 +1,24 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import me.zhengjie.base.BaseDTO; import java.io.Serializable; import java.sql.Timestamp; @@ -14,22 +30,16 @@ import java.sql.Timestamp; @Getter @Setter @NoArgsConstructor -public class JobDto implements Serializable { +public class JobDto extends BaseDTO implements Serializable { private Long id; - private Long sort; + private Integer jobSort; private String name; private Boolean enabled; - private DeptDto dept; - - private String deptSuperiorName; - - private Timestamp createTime; - public JobDto(String name, Boolean enabled) { this.name = name; this.enabled = enabled; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobQueryCriteria.java index 1e90cfbd..ee851dc6 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobQueryCriteria.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Data; @@ -5,7 +20,6 @@ import lombok.NoArgsConstructor; import me.zhengjie.annotation.Query; import java.sql.Timestamp; import java.util.List; -import java.util.Set; /** * @author Zheng Jie @@ -21,12 +35,6 @@ public class JobQueryCriteria { @Query private Boolean enabled; - @Query(propName = "id", joinName = "dept") - private Long deptId; - - @Query(propName = "id", joinName = "dept", type = Query.Type.IN) - private Set deptIds; - @Query(type = Query.Type.BETWEEN) private List createTime; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobSmallDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobSmallDto.java index d71bf344..09cfa624 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobSmallDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/JobSmallDto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/MenuDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/MenuDto.java index 8b2319a2..a2ac0b6d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/MenuDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/MenuDto.java @@ -1,26 +1,45 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.zhengjie.base.BaseDTO; import java.io.Serializable; -import java.sql.Timestamp; import java.util.List; /** * @author Zheng Jie * @date 2018-12-17 */ -@Data -public class MenuDto implements Serializable { +@Getter +@Setter +public class MenuDto extends BaseDTO implements Serializable { private Long id; + private List children; + private Integer type; private String permission; - private String name; + private String title; - private Long sort; + private Integer menuSort; private String path; @@ -37,8 +56,4 @@ public class MenuDto implements Serializable { private String componentName; private String icon; - - private List children; - - private Timestamp createTime; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/MenuQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/MenuQueryCriteria.java index 55f5c158..577485b6 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/MenuQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/MenuQueryCriteria.java @@ -1,8 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Data; import me.zhengjie.annotation.Query; - import java.sql.Timestamp; import java.util.List; @@ -13,7 +27,7 @@ import java.util.List; @Data public class MenuQueryCriteria { - @Query(blurry = "name,path,component") + @Query(blurry = "title,path,component") private String blurry; @Query(type = Query.Type.BETWEEN) diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleDto.java index 2b3a97b7..247ee2f5 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleDto.java @@ -1,32 +1,45 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.zhengjie.base.BaseDTO; import java.io.Serializable; -import java.sql.Timestamp; import java.util.Set; /** * @author Zheng Jie * @date 2018-11-23 */ -@Data -public class RoleDto implements Serializable { +@Getter +@Setter +public class RoleDto extends BaseDTO implements Serializable { private Long id; + private Set menus; + + private Set depts; + private String name; private String dataScope; private Integer level; - private String remark; - - private String permission; - - private Set menus; - - private Set depts; - - private Timestamp createTime; + private String description; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleQueryCriteria.java index 6546b03c..f7e540a8 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleQueryCriteria.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleSmallDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleSmallDto.java index 9d5a1d50..99215e63 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleSmallDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/RoleSmallDto.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java index 0ea939fe..4af03b98 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java @@ -1,54 +1,67 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import com.fasterxml.jackson.annotation.JsonIgnore; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import org.springframework.security.core.GrantedAuthority; - +import lombok.Getter; +import lombok.Setter; +import me.zhengjie.base.BaseDTO; import java.io.Serializable; -import java.sql.Timestamp; import java.util.Date; -import java.util.List; import java.util.Set; /** * @author Zheng Jie * @date 2018-11-23 */ -@Data -public class UserDto implements Serializable { +@Getter +@Setter +public class UserDto extends BaseDTO implements Serializable { - @ApiModelProperty(hidden = true) private Long id; - private String username; - - private String nickName; - - private String sex; - - private String avatar; - - private String email; - - private String phone; - - private Boolean enabled; - - @JsonIgnore - private String password; - - private Date lastPasswordResetTime; - - @ApiModelProperty(hidden = true) private Set roles; - @ApiModelProperty(hidden = true) - private JobSmallDto job; + private Set jobs; private DeptSmallDto dept; private Long deptId; - private Timestamp createTime; + private String username; + + private String nickName; + + private String email; + + private String phone; + + private String gender; + + private String avatarName; + + private String avatarPath; + + @JsonIgnore + private String password; + + private Boolean enabled; + + @JsonIgnore + private Boolean isAdmin = false; + + private Date pwdResetTime; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserQueryCriteria.java index ed2fe3b3..5809545c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserQueryCriteria.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserQueryCriteria.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.dto; import lombok.Data; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DeptServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DeptServiceImpl.java index e0381010..31fec577 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DeptServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DeptServiceImpl.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.impl; +import lombok.RequiredArgsConstructor; import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.system.domain.Dept; import me.zhengjie.modules.system.service.dto.DeptDto; @@ -27,19 +43,14 @@ import java.util.stream.Collectors; * @date 2019-03-25 */ @Service +@RequiredArgsConstructor @CacheConfig(cacheNames = "dept") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class DeptServiceImpl implements DeptService { private final DeptRepository deptRepository; - private final DeptMapper deptMapper; - public DeptServiceImpl(DeptRepository deptRepository, DeptMapper deptMapper) { - this.deptRepository = deptRepository; - this.deptMapper = deptMapper; - } - @Override @Cacheable public List queryAll(DeptQueryCriteria criteria) { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java index 2ea7ccb0..53a078eb 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictDetailServiceImpl.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.impl; +import lombok.RequiredArgsConstructor; import me.zhengjie.modules.system.domain.DictDetail; import me.zhengjie.modules.system.service.dto.DictDetailQueryCriteria; import me.zhengjie.utils.PageUtil; @@ -24,19 +40,14 @@ import java.util.Map; * @date 2019-04-10 */ @Service +@RequiredArgsConstructor @CacheConfig(cacheNames = "dictDetail") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class DictDetailServiceImpl implements DictDetailService { private final DictDetailRepository dictDetailRepository; - private final DictDetailMapper dictDetailMapper; - public DictDetailServiceImpl(DictDetailRepository dictDetailRepository, DictDetailMapper dictDetailMapper) { - this.dictDetailRepository = dictDetailRepository; - this.dictDetailMapper = dictDetailMapper; - } - @Override @Cacheable public Map queryAll(DictDetailQueryCriteria criteria, Pageable pageable) { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictServiceImpl.java index 3e996e95..bcea6634 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DictServiceImpl.java @@ -1,6 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.impl; import cn.hutool.core.collection.CollectionUtil; +import lombok.RequiredArgsConstructor; import me.zhengjie.modules.system.domain.Dict; import me.zhengjie.modules.system.service.dto.DictDetailDto; import me.zhengjie.modules.system.service.dto.DictQueryCriteria; @@ -20,7 +36,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; - import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.*; @@ -30,19 +45,14 @@ import java.util.*; * @date 2019-04-10 */ @Service +@RequiredArgsConstructor @CacheConfig(cacheNames = "dict") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class DictServiceImpl implements DictService { private final DictRepository dictRepository; - private final DictMapper dictMapper; - public DictServiceImpl(DictRepository dictRepository, DictMapper dictMapper) { - this.dictRepository = dictRepository; - this.dictMapper = dictMapper; - } - @Override @Cacheable public Map queryAll(DictQueryCriteria dict, Pageable pageable){ @@ -98,7 +108,7 @@ public class DictServiceImpl implements DictService { for (DictDetailDto dictDetail : dictDTO.getDictDetails()) { Map map = new LinkedHashMap<>(); map.put("字典名称", dictDTO.getName()); - map.put("字典描述", dictDTO.getRemark()); + map.put("字典描述", dictDTO.getDescription()); map.put("字典标签", dictDetail.getLabel()); map.put("字典值", dictDetail.getValue()); map.put("创建日期", dictDetail.getCreateTime()); @@ -107,7 +117,7 @@ public class DictServiceImpl implements DictService { } else { Map map = new LinkedHashMap<>(); map.put("字典名称", dictDTO.getName()); - map.put("字典描述", dictDTO.getRemark()); + map.put("字典描述", dictDTO.getDescription()); map.put("字典标签", null); map.put("字典值", null); map.put("创建日期", dictDTO.getCreateTime()); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/JobServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/JobServiceImpl.java index 60b935de..cd58f9cb 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/JobServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/JobServiceImpl.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.impl; +import lombok.RequiredArgsConstructor; +import me.zhengjie.exception.EntityExistException; import me.zhengjie.modules.system.domain.Job; -import me.zhengjie.modules.system.repository.DeptRepository; import me.zhengjie.modules.system.service.dto.JobQueryCriteria; import me.zhengjie.utils.FileUtil; import me.zhengjie.utils.PageUtil; @@ -19,7 +35,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; - import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.*; @@ -29,31 +44,19 @@ import java.util.*; * @date 2019-03-29 */ @Service +@RequiredArgsConstructor @CacheConfig(cacheNames = "job") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class JobServiceImpl implements JobService { private final JobRepository jobRepository; - private final JobMapper jobMapper; - private final DeptRepository deptRepository; - - public JobServiceImpl(JobRepository jobRepository, JobMapper jobMapper, DeptRepository deptRepository) { - this.jobRepository = jobRepository; - this.jobMapper = jobMapper; - this.deptRepository = deptRepository; - } - @Override @Cacheable public Map queryAll(JobQueryCriteria criteria, Pageable pageable) { Page page = jobRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); - List jobs = new ArrayList<>(); - for (Job job : page.getContent()) { - jobs.add(jobMapper.toDto(job,deptRepository.findNameById(job.getDept().getPid()))); - } - return PageUtil.toPage(jobs,page.getTotalElements()); + return PageUtil.toPage(page.map(jobMapper::toDto).getContent(),page.getTotalElements()); } @Override @@ -75,6 +78,10 @@ public class JobServiceImpl implements JobService { @CacheEvict(allEntries = true) @Transactional(rollbackFor = Exception.class) public JobDto create(Job resources) { + Job job = jobRepository.findByName(resources.getName()); + if(job != null){ + throw new EntityExistException(Job.class,"name",resources.getName()); + } return jobMapper.toDto(jobRepository.save(resources)); } @@ -83,6 +90,10 @@ public class JobServiceImpl implements JobService { @Transactional(rollbackFor = Exception.class) public void update(Job resources) { Job job = jobRepository.findById(resources.getId()).orElseGet(Job::new); + Job old = jobRepository.findByName(resources.getName()); + if(old != null && !old.getId().equals(resources.getId())){ + throw new EntityExistException(Job.class,"name",resources.getName()); + } ValidationUtil.isNull( job.getId(),"Job","id",resources.getId()); resources.setId(job.getId()); jobRepository.save(resources); @@ -103,7 +114,6 @@ public class JobServiceImpl implements JobService { for (JobDto jobDTO : jobDtos) { Map map = new LinkedHashMap<>(); map.put("岗位名称", jobDTO.getName()); - map.put("所属部门", jobDTO.getDept().getName()); map.put("岗位状态", jobDTO.getEnabled() ? "启用" : "停用"); map.put("创建日期", jobDTO.getCreateTime()); list.add(map); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java index 8abada3a..50dd02dd 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.impl; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import lombok.RequiredArgsConstructor; import me.zhengjie.modules.system.domain.Menu; import me.zhengjie.modules.system.domain.vo.MenuMetaVo; import me.zhengjie.modules.system.domain.vo.MenuVo; @@ -33,26 +49,18 @@ import java.util.stream.Collectors; * @author Zheng Jie */ @Service +@RequiredArgsConstructor @CacheConfig(cacheNames = "menu") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class MenuServiceImpl implements MenuService { private final MenuRepository menuRepository; - private final MenuMapper menuMapper; - private final RoleService roleService; - public MenuServiceImpl(MenuRepository menuRepository, MenuMapper menuMapper, RoleService roleService) { - this.menuRepository = menuRepository; - this.menuMapper = menuMapper; - this.roleService = roleService; - } - @Override @Cacheable public List queryAll(MenuQueryCriteria criteria){ -// Sort sort = new Sort(Sort.Direction.DESC,"id"); return menuMapper.toDto(menuRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); } @@ -67,15 +75,15 @@ public class MenuServiceImpl implements MenuService { @Override public List findByRoles(List roles) { Set roleIds = roles.stream().map(RoleSmallDto::getId).collect(Collectors.toSet()); - LinkedHashSet menus = menuRepository.findByRoles_IdInAndTypeNotOrderBySortAsc(roleIds, 2); + LinkedHashSet menus = menuRepository.findByRoles_IdInAndTypeNotOrderByMenuSortAsc(roleIds, 2); return menus.stream().map(menuMapper::toDto).collect(Collectors.toList()); } @Override @CacheEvict(allEntries = true) public MenuDto create(Menu resources) { - if(menuRepository.findByName(resources.getName()) != null){ - throw new EntityExistException(Menu.class,"name",resources.getName()); + if(menuRepository.findByTitle(resources.getTitle()) != null){ + throw new EntityExistException(Menu.class,"title",resources.getTitle()); } if(StringUtils.isNotBlank(resources.getComponentName())){ if(menuRepository.findByComponentName(resources.getComponentName()) != null){ @@ -106,10 +114,10 @@ public class MenuServiceImpl implements MenuService { throw new BadRequestException("外链必须以http://或者https://开头"); } } - Menu menu1 = menuRepository.findByName(resources.getName()); + Menu menu1 = menuRepository.findByTitle(resources.getTitle()); if(menu1 != null && !menu1.getId().equals(menu.getId())){ - throw new EntityExistException(Menu.class,"name",resources.getName()); + throw new EntityExistException(Menu.class,"title",resources.getTitle()); } if(StringUtils.isNotBlank(resources.getComponentName())){ @@ -118,13 +126,13 @@ public class MenuServiceImpl implements MenuService { throw new EntityExistException(Menu.class,"componentName",resources.getComponentName()); } } - menu.setName(resources.getName()); + menu.setTitle(resources.getTitle()); menu.setComponent(resources.getComponent()); menu.setPath(resources.getPath()); menu.setIcon(resources.getIcon()); menu.setIFrame(resources.getIFrame()); menu.setPid(resources.getPid()); - menu.setSort(resources.getSort()); + menu.setMenuSort(resources.getMenuSort()); menu.setCache(resources.getCache()); menu.setHidden(resources.getHidden()); menu.setComponentName(resources.getComponentName()); @@ -165,7 +173,7 @@ public class MenuServiceImpl implements MenuService { List menuList = menuRepository.findByPid(menu.getId()); Map map = new HashMap<>(16); map.put("id",menu.getId()); - map.put("label",menu.getName()); + map.put("label",menu.getTitle()); if(menuList!=null && menuList.size()!=0){ map.put("children",getMenuTree(menuList)); } @@ -216,7 +224,7 @@ public class MenuServiceImpl implements MenuService { if (menuDTO!=null){ List menuDtoList = menuDTO.getChildren(); MenuVo menuVo = new MenuVo(); - menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponentName()) ? menuDTO.getComponentName() : menuDTO.getName()); + menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponentName()) ? menuDTO.getComponentName() : menuDTO.getTitle()); // 一级目录需要加斜杠,不然会报警告 menuVo.setPath(menuDTO.getPid() == 0 ? "/" + menuDTO.getPath() :menuDTO.getPath()); menuVo.setHidden(menuDTO.getHidden()); @@ -228,7 +236,7 @@ public class MenuServiceImpl implements MenuService { menuVo.setComponent(menuDTO.getComponent()); } } - menuVo.setMeta(new MenuMetaVo(menuDTO.getName(),menuDTO.getIcon(),!menuDTO.getCache())); + menuVo.setMeta(new MenuMetaVo(menuDTO.getTitle(),menuDTO.getIcon(),!menuDTO.getCache())); if(menuDtoList !=null && menuDtoList.size()!=0){ menuVo.setAlwaysShow(true); menuVo.setRedirect("noredirect"); @@ -271,7 +279,7 @@ public class MenuServiceImpl implements MenuService { List> list = new ArrayList<>(); for (MenuDto menuDTO : menuDtos) { Map map = new LinkedHashMap<>(); - map.put("菜单名称", menuDTO.getName()); + map.put("菜单标题", menuDTO.getTitle()); map.put("菜单类型", menuDTO.getType() == 0 ? "目录" : menuDTO.getType() == 1 ? "菜单" : "按钮"); map.put("权限标识", menuDTO.getPermission()); map.put("外链菜单", menuDTO.getIFrame() ? "是" : "否"); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MonitorServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MonitorServiceImpl.java new file mode 100644 index 00000000..70e7500f --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MonitorServiceImpl.java @@ -0,0 +1,172 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.impl; + +import cn.hutool.core.date.BetweenFormater; +import cn.hutool.core.date.DateUtil; +import me.zhengjie.modules.system.service.MonitorService; +import me.zhengjie.utils.FileUtil; +import me.zhengjie.utils.StringUtils; +import org.springframework.stereotype.Service; +import oshi.SystemInfo; +import oshi.hardware.*; +import oshi.software.os.FileSystem; +import oshi.software.os.OSFileStore; +import oshi.software.os.OperatingSystem; +import oshi.util.FormatUtil; +import oshi.util.Util; +import java.lang.management.ManagementFactory; +import java.text.DecimalFormat; +import java.util.*; + +/** +* @author Zheng Jie +* @date 2020-05-02 +*/ +@Service +public class MonitorServiceImpl implements MonitorService { + + private final DecimalFormat df = new DecimalFormat("0.00"); + + @Override + public Map getServers(){ + Map resultMap = new LinkedHashMap<>(8); + try { + SystemInfo si = new SystemInfo(); + OperatingSystem os = si.getOperatingSystem(); + HardwareAbstractionLayer hal = si.getHardware(); + // 系统信息 + resultMap.put("sys", getSystemInfo(os)); + // cpu 信息 + resultMap.put("cpu", getCpuInfo(hal.getProcessor())); + // 内存信息 + resultMap.put("memory", getMemoryInfo(hal.getMemory())); + // 交换区信息 + resultMap.put("swap", getSwapInfo(hal.getMemory())); + // 磁盘 + resultMap.put("disk", getDiskInfo(hal.getDiskStores(), os)); + resultMap.put("time", DateUtil.format(new Date(), "HH:mm:ss")); + } catch (Exception e) { + e.printStackTrace(); + } + return resultMap; + } + + /** + * 获取磁盘信息 + * @param diskStores / + * @return / + */ + private Map getDiskInfo(HWDiskStore[] diskStores, OperatingSystem os) { + Map diskInfo = new LinkedHashMap<>(); + long total = 0; + for (HWDiskStore disk : diskStores) { + boolean readwrite = disk.getReads() > 0 || disk.getWrites() > 0; + total = disk.getSize(); + diskInfo.put("reads", readwrite ? FormatUtil.formatBytes(disk.getReadBytes()) : "?"); + diskInfo.put("writes", readwrite ? FormatUtil.formatBytes(disk.getWriteBytes()) : "?"); + break; + } + FileSystem fileSystem = os.getFileSystem(); + OSFileStore[] fsArray = fileSystem.getFileStores(); + for (OSFileStore fs : fsArray){ + diskInfo.put("total", fs.getTotalSpace() > 0 ? FileUtil.getSize(fs.getTotalSpace()) : "?"); + long used = fs.getTotalSpace() - fs.getUsableSpace(); + diskInfo.put("available", FileUtil.getSize(fs.getUsableSpace())); + diskInfo.put("used", FileUtil.getSize(used)); + diskInfo.put("usageRate", df.format(used/(double)fs.getTotalSpace() * 100)); + } + return diskInfo; + } + + /** + * 获取交换区信息 + * @param memory / + * @return / + */ + private Map getSwapInfo(GlobalMemory memory) { + Map swapInfo = new LinkedHashMap<>(); + swapInfo.put("total", FormatUtil.formatBytes(memory.getVirtualMemory().getSwapTotal())); + swapInfo.put("used", FormatUtil.formatBytes(memory.getVirtualMemory().getSwapUsed())); + swapInfo.put("available", FormatUtil.formatBytes(memory.getVirtualMemory().getSwapTotal() - memory.getVirtualMemory().getSwapUsed())); + swapInfo.put("usageRate", df.format(memory.getVirtualMemory().getSwapUsed()/(double)memory.getVirtualMemory().getSwapTotal() * 100)); + return swapInfo; + } + + /** + * 获取内存信息 + * @param memory / + * @return / + */ + private Map getMemoryInfo(GlobalMemory memory) { + Map memoryInfo = new LinkedHashMap<>(); + memoryInfo.put("total", FormatUtil.formatBytes(memory.getTotal())); + memoryInfo.put("available", FormatUtil.formatBytes(memory.getAvailable())); + memoryInfo.put("used", FormatUtil.formatBytes(memory.getTotal() - memory.getAvailable())); + memoryInfo.put("usageRate", df.format((memory.getTotal() - memory.getAvailable())/(double)memory.getTotal() * 100)); + return memoryInfo; + } + + /** + * 获取Cpu相关信息 + * @param processor / + * @return / + */ + private Map getCpuInfo(CentralProcessor processor) { + Map cpuInfo = new LinkedHashMap<>(); + cpuInfo.put("name", processor.getProcessorIdentifier().getName()); + cpuInfo.put("package", processor.getPhysicalPackageCount() + "个物理CPU"); + cpuInfo.put("core", processor.getPhysicalProcessorCount() + "个物理核心"); + cpuInfo.put("coreNumber", processor.getPhysicalProcessorCount()); + cpuInfo.put("logic", processor.getLogicalProcessorCount() + "个逻辑CPU"); + // CPU信息 + long[] prevTicks = processor.getSystemCpuLoadTicks(); + // 等待1秒... + Util.sleep(1000); + long[] ticks = processor.getSystemCpuLoadTicks(); + long user = ticks[CentralProcessor.TickType.USER.getIndex()] - prevTicks[CentralProcessor.TickType.USER.getIndex()]; + long nice = ticks[CentralProcessor.TickType.NICE.getIndex()] - prevTicks[CentralProcessor.TickType.NICE.getIndex()]; + long sys = ticks[CentralProcessor.TickType.SYSTEM.getIndex()] - prevTicks[CentralProcessor.TickType.SYSTEM.getIndex()]; + long idle = ticks[CentralProcessor.TickType.IDLE.getIndex()] - prevTicks[CentralProcessor.TickType.IDLE.getIndex()]; + long iowait = ticks[CentralProcessor.TickType.IOWAIT.getIndex()] - prevTicks[CentralProcessor.TickType.IOWAIT.getIndex()]; + long irq = ticks[CentralProcessor.TickType.IRQ.getIndex()] - prevTicks[CentralProcessor.TickType.IRQ.getIndex()]; + long softirq = ticks[CentralProcessor.TickType.SOFTIRQ.getIndex()] - prevTicks[CentralProcessor.TickType.SOFTIRQ.getIndex()]; + long steal = ticks[CentralProcessor.TickType.STEAL.getIndex()] - prevTicks[CentralProcessor.TickType.STEAL.getIndex()]; + long totalCpu = user + nice + sys + idle + iowait + irq + softirq + steal; + cpuInfo.put("used", df.format(100d * user / totalCpu + 100d * sys / totalCpu)); + cpuInfo.put("idle", df.format(100d * idle / totalCpu)); + return cpuInfo; + } + + /** + * 获取系统相关信息,系统、运行天数、系统IP + * @param os / + * @return / + */ + private Map getSystemInfo(OperatingSystem os){ + Map systemInfo = new LinkedHashMap<>(); + // jvm 运行时间 + long time = ManagementFactory.getRuntimeMXBean().getStartTime(); + Date date = new Date(time); + // 计算项目运行时间 + String formatBetween = DateUtil.formatBetween(date, new Date(),BetweenFormater.Level.HOUR); + // 系统信息 + systemInfo.put("os", os.toString()); + systemInfo.put("day", formatBetween); + systemInfo.put("ip", StringUtils.getLocalIp()); + return systemInfo; + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/RoleServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/RoleServiceImpl.java index cc47139e..fe97ff0a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/RoleServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/RoleServiceImpl.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.impl; +import lombok.RequiredArgsConstructor; import me.zhengjie.modules.system.domain.Menu; import me.zhengjie.modules.system.domain.Role; import me.zhengjie.exception.EntityExistException; @@ -22,7 +38,6 @@ import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; - import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.*; @@ -33,22 +48,15 @@ import java.util.stream.Collectors; * @date 2018-12-03 */ @Service +@RequiredArgsConstructor @CacheConfig(cacheNames = "role") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class RoleServiceImpl implements RoleService { private final RoleRepository roleRepository; - private final RoleMapper roleMapper; - private final RoleSmallMapper roleSmallMapper; - public RoleServiceImpl(RoleRepository roleRepository, RoleMapper roleMapper, RoleSmallMapper roleSmallMapper) { - this.roleRepository = roleRepository; - this.roleMapper = roleMapper; - this.roleSmallMapper = roleSmallMapper; - } - @Override @Cacheable public Object queryAll(Pageable pageable) { @@ -98,16 +106,11 @@ public class RoleServiceImpl implements RoleService { if(role1 != null && !role1.getId().equals(role.getId())){ throw new EntityExistException(Role.class,"username",resources.getName()); } - role1 = roleRepository.findByPermission(resources.getPermission()); - if(role1 != null && !role1.getId().equals(role.getId())){ - throw new EntityExistException(Role.class,"permission",resources.getPermission()); - } role.setName(resources.getName()); - role.setRemark(resources.getRemark()); + role.setDescription(resources.getDescription()); role.setDataScope(resources.getDataScope()); role.setDepts(resources.getDepts()); role.setLevel(resources.getLevel()); - role.setPermission(resources.getPermission()); roleRepository.save(role); } @@ -154,13 +157,17 @@ public class RoleServiceImpl implements RoleService { @Override @Cacheable(key = "'loadPermissionByUser:' + #p0.username") public List mapToGrantedAuthorities(UserDto user) { + Set permissions = new HashSet<>(); + // 如果是管理员直接返回 + if(user.getIsAdmin()){ + permissions.add("admin"); + return permissions.stream().map(SimpleGrantedAuthority::new) + .collect(Collectors.toList()); + } Set roles = roleRepository.findByUsers_Id(user.getId()); - Set permissions = roles.stream().filter(role -> StringUtils.isNotBlank(role.getPermission())).map(Role::getPermission).collect(Collectors.toSet()); - permissions.addAll( - roles.stream().flatMap(role -> role.getMenus().stream()) - .filter(menu -> StringUtils.isNotBlank(menu.getPermission())) - .map(Menu::getPermission).collect(Collectors.toSet()) - ); + permissions = roles.stream().flatMap(role -> role.getMenus().stream()) + .filter(menu -> StringUtils.isNotBlank(menu.getPermission())) + .map(Menu::getPermission).collect(Collectors.toSet()); return permissions.stream().map(SimpleGrantedAuthority::new) .collect(Collectors.toList()); } @@ -171,9 +178,8 @@ public class RoleServiceImpl implements RoleService { for (RoleDto role : roles) { Map map = new LinkedHashMap<>(); map.put("角色名称", role.getName()); - map.put("默认权限", role.getPermission()); map.put("角色级别", role.getLevel()); - map.put("描述", role.getRemark()); + map.put("描述", role.getDescription()); map.put("创建日期", role.getCreateTime()); list.add(map); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java index 1b51fc74..2eb34b2d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java @@ -1,13 +1,28 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.impl; +import lombok.RequiredArgsConstructor; import me.zhengjie.config.FileProperties; import me.zhengjie.modules.system.domain.User; import me.zhengjie.exception.EntityExistException; import me.zhengjie.exception.EntityNotFoundException; -import me.zhengjie.modules.system.domain.UserAvatar; -import me.zhengjie.modules.system.repository.UserAvatarRepository; import me.zhengjie.modules.system.repository.UserRepository; import me.zhengjie.modules.system.service.UserService; +import me.zhengjie.modules.system.service.dto.JobSmallDto; import me.zhengjie.modules.system.service.dto.RoleSmallDto; import me.zhengjie.modules.system.service.dto.UserDto; import me.zhengjie.modules.system.service.dto.UserQueryCriteria; @@ -33,6 +48,7 @@ import java.util.stream.Collectors; * @date 2018-11-23 */ @Service +@RequiredArgsConstructor @CacheConfig(cacheNames = "user") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class UserServiceImpl implements UserService { @@ -40,15 +56,7 @@ public class UserServiceImpl implements UserService { private final UserRepository userRepository; private final UserMapper userMapper; private final RedisUtils redisUtils; - private final UserAvatarRepository userAvatarRepository; private final FileProperties properties; - public UserServiceImpl(UserRepository userRepository, UserMapper userMapper, RedisUtils redisUtils, UserAvatarRepository userAvatarRepository, FileProperties properties) { - this.userRepository = userRepository; - this.userMapper = userMapper; - this.redisUtils = redisUtils; - this.userAvatarRepository = userAvatarRepository; - this.properties = properties; - } @Override @Cacheable @@ -115,10 +123,10 @@ public class UserServiceImpl implements UserService { user.setEnabled(resources.getEnabled()); user.setRoles(resources.getRoles()); user.setDept(resources.getDept()); - user.setJob(resources.getJob()); + user.setJobs(resources.getJobs()); user.setPhone(resources.getPhone()); user.setNickName(resources.getNickName()); - user.setSex(resources.getSex()); + user.setGender(resources.getGender()); userRepository.save(user); } @@ -129,7 +137,7 @@ public class UserServiceImpl implements UserService { User user = userRepository.findById(resources.getId()).orElseGet(User::new); user.setNickName(resources.getNickName()); user.setPhone(resources.getPhone()); - user.setSex(resources.getSex()); + user.setGender(resources.getGender()); userRepository.save(user); } @@ -170,15 +178,10 @@ public class UserServiceImpl implements UserService { @Transactional(rollbackFor = Exception.class) public void updateAvatar(MultipartFile multipartFile) { User user = userRepository.findByUsername(SecurityUtils.getCurrentUsername()); - UserAvatar userAvatar = user.getUserAvatar(); - String oldPath = ""; - if(userAvatar != null){ - oldPath = userAvatar.getPath(); - } + String oldPath = user.getAvatarPath(); File file = FileUtil.upload(multipartFile, properties.getPath().getAvatar()); - assert file != null; - userAvatar = userAvatarRepository.save(new UserAvatar(userAvatar,file.getName(), file.getPath(), FileUtil.getSize(multipartFile.getSize()))); - user.setUserAvatar(userAvatar); + user.setAvatarPath(Objects.requireNonNull(file).getPath()); + user.setAvatarName(file.getName()); userRepository.save(user); if(StringUtils.isNotBlank(oldPath)){ FileUtil.del(oldPath); @@ -199,14 +202,13 @@ public class UserServiceImpl implements UserService { List roles = userDTO.getRoles().stream().map(RoleSmallDto::getName).collect(Collectors.toList()); Map map = new LinkedHashMap<>(); map.put("用户名", userDTO.getUsername()); - map.put("头像", userDTO.getAvatar()); + map.put("角色", roles); + map.put("部门", userDTO.getDept().getName()); + map.put("岗位", userDTO.getJobs().stream().map(JobSmallDto::getName).toString()); map.put("邮箱", userDTO.getEmail()); map.put("状态", userDTO.getEnabled() ? "启用" : "禁用"); map.put("手机号码", userDTO.getPhone()); - map.put("角色", roles); - map.put("部门", userDTO.getDept().getName()); - map.put("岗位", userDTO.getJob().getName()); - map.put("最后修改密码的时间", userDTO.getLastPasswordResetTime()); + map.put("修改密码的时间", userDTO.getPwdResetTime()); map.put("创建日期", userDTO.getCreateTime()); list.add(map); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/VerifyServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/VerifyServiceImpl.java new file mode 100644 index 00000000..6939e86b --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/VerifyServiceImpl.java @@ -0,0 +1,83 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.impl; + +import cn.hutool.core.lang.Dict; +import cn.hutool.core.util.RandomUtil; +import cn.hutool.extra.template.Template; +import cn.hutool.extra.template.TemplateConfig; +import cn.hutool.extra.template.TemplateEngine; +import cn.hutool.extra.template.TemplateUtil; +import lombok.RequiredArgsConstructor; +import me.zhengjie.domain.vo.EmailVo; +import me.zhengjie.exception.BadRequestException; +import me.zhengjie.modules.system.service.VerifyService; +import me.zhengjie.utils.RedisUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +import java.util.Collections; + +/** + * @author Zheng Jie + * @date 2018-12-26 + */ +@Service +@RequiredArgsConstructor +@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) +public class VerifyServiceImpl implements VerifyService { + + @Value("${code.expiration}") + private Long expiration; + private final RedisUtils redisUtils; + + @Override + @Transactional(rollbackFor = Exception.class) + public EmailVo sendEmail(String email, String key) { + EmailVo emailVo; + String content; + String redisKey = key + email; + // 如果不存在有效的验证码,就创建一个新的 + TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); + Template template = engine.getTemplate("email/email.ftl"); + Object oldCode = redisUtils.get(redisKey); + if(oldCode == null){ + String code = RandomUtil.randomNumbers (6); + // 存入缓存 + if(!redisUtils.set(redisKey, code, expiration)){ + throw new BadRequestException("服务异常,请联系网站负责人"); + } + content = template.render(Dict.create().set("code",code)); + emailVo = new EmailVo(Collections.singletonList(email),"EL-ADMIN后台管理系统",content); + // 存在就再次发送原来的验证码 + } else { + content = template.render(Dict.create().set("code",oldCode)); + emailVo = new EmailVo(Collections.singletonList(email),"EL-ADMIN后台管理系统",content); + } + return emailVo; + } + + @Override + public void validated(String key, String code) { + Object value = redisUtils.get(key); + if(value == null || !value.toString().equals(code)){ + throw new BadRequestException("无效验证码"); + } else { + redisUtils.del(key); + } + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DeptMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DeptMapper.java index 190df4c3..2885d788 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DeptMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DeptMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DeptSmallMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DeptSmallMapper.java index 48073faf..5fb40791 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DeptSmallMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DeptSmallMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictDetailMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictDetailMapper.java index 482ff43b..8832a04d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictDetailMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictDetailMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictMapper.java index 819cd58c..54bfa490 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictSmallMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictSmallMapper.java index ef48a885..e834adcc 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictSmallMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/DictSmallMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/JobMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/JobMapper.java index 1938ef49..388d05a2 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/JobMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/JobMapper.java @@ -1,10 +1,24 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.mapper; import me.zhengjie.base.BaseMapper; import me.zhengjie.modules.system.domain.Job; import me.zhengjie.modules.system.service.dto.JobDto; import org.mapstruct.Mapper; -import org.mapstruct.Mapping; import org.mapstruct.ReportingPolicy; /** @@ -13,13 +27,4 @@ import org.mapstruct.ReportingPolicy; */ @Mapper(componentModel = "spring",uses = {DeptMapper.class},unmappedTargetPolicy = ReportingPolicy.IGNORE) public interface JobMapper extends BaseMapper { - - /** - * 转Dto - * @param job 原始数据 - * @param deptSuperiorName / - * @return / - */ - @Mapping(source = "deptSuperiorName", target = "deptSuperiorName") - JobDto toDto(Job job, String deptSuperiorName); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/JobSmallMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/JobSmallMapper.java index 57dfe336..e73f99f0 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/JobSmallMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/JobSmallMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/MenuMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/MenuMapper.java index 68fb1460..4d704cdb 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/MenuMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/MenuMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleMapper.java index 39b7f32c..0bda9dc1 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleSmallMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleSmallMapper.java index b2c854d1..17ea9592 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleSmallMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/RoleSmallMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/UserMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/UserMapper.java index 8a42fbb5..eac3331e 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/UserMapper.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapper/UserMapper.java @@ -1,10 +1,24 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.modules.system.service.mapper; import me.zhengjie.base.BaseMapper; import me.zhengjie.modules.system.domain.User; import me.zhengjie.modules.system.service.dto.UserDto; import org.mapstruct.Mapper; -import org.mapstruct.Mapping; import org.mapstruct.ReportingPolicy; /** @@ -13,13 +27,4 @@ import org.mapstruct.ReportingPolicy; */ @Mapper(componentModel = "spring",uses = {RoleMapper.class, DeptMapper.class, JobMapper.class},unmappedTargetPolicy = ReportingPolicy.IGNORE) public interface UserMapper extends BaseMapper { - - /** - * 转换 - * @param user 原始数据 - * @return / - */ - @Override - @Mapping(source = "user.userAvatar.realName",target = "avatar") - UserDto toDto(User user); } diff --git a/eladmin-system/src/main/resources/config/application-dev.yml b/eladmin-system/src/main/resources/config/application-dev.yml index df73af38..40c63840 100644 --- a/eladmin-system/src/main/resources/config/application-dev.yml +++ b/eladmin-system/src/main/resources/config/application-dev.yml @@ -35,12 +35,6 @@ spring: url-pattern: /* exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*" - #配置 Jpa - jpa: - hibernate: - # 生产环境设置成 none,避免程序运行时自动更新数据库结构 - ddl-auto: update - #jwt jwt: header: Authorization diff --git a/eladmin-system/src/main/resources/config/application-prod.yml b/eladmin-system/src/main/resources/config/application-prod.yml index ec98ac13..3df2fd4c 100644 --- a/eladmin-system/src/main/resources/config/application-prod.yml +++ b/eladmin-system/src/main/resources/config/application-prod.yml @@ -37,12 +37,6 @@ spring: url-pattern: /* exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*" - #配置 Jpa - jpa: - hibernate: - # 生产环境设置成 none,避免程序运行时自动更新数据库结构 - ddl-auto: none - #jwt jwt: header: Authorization diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml index fcc71dd0..271051ce 100644 --- a/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin-system/src/main/resources/config/application.yml @@ -17,6 +17,7 @@ spring: jpa: properties: hibernate: + ddl-auto: none dialect: org.hibernate.dialect.MySQL5InnoDBDialect open-in-view: true @@ -45,9 +46,9 @@ qiniu: # 文件大小 /M max-size: 15 -#邮箱验证码有效时间/分钟 +#邮箱验证码有效时间/秒 code: - expiration: 5 + expiration: 300 #登录图形验证码有效时间/分钟 loginCode: diff --git a/eladmin-system/src/main/resources/template/email/email.ftl b/eladmin-system/src/main/resources/template/email/email.ftl index 3a186358..2f82fcb5 100644 --- a/eladmin-system/src/main/resources/template/email/email.ftl +++ b/eladmin-system/src/main/resources/template/email/email.ftl @@ -21,7 +21,7 @@

尊敬的用户,您好:

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

-

${code}

-
- Copyright ©${.now?string("yyyy")} EL-ADMIN 后台管理系统 All Rights Reserved. + Copyright ©${.now?string("yyyy")} EL-ADMIN 后台管理系统 All Rights Reserved.
diff --git a/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl b/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl index 70a6970a..703bc479 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Controller.ftl @@ -1,3 +1,18 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* 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 ${package}.rest; import me.zhengjie.aop.log.Log; @@ -15,9 +30,11 @@ import java.io.IOException; import javax.servlet.http.HttpServletResponse; /** +* @website https://docs.auauz.net +* @description / * @author ${author} * @date ${date} -*/ +**/ @Api(tags = "${apiAlias}管理") @RestController @RequestMapping("/api/${changeClassName}") diff --git a/eladmin-system/src/main/resources/template/generator/admin/Dto.ftl b/eladmin-system/src/main/resources/template/generator/admin/Dto.ftl index dc478f5e..481e8c52 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Dto.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Dto.ftl @@ -1,3 +1,18 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* 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 ${package}.service.dto; import lombok.Data; @@ -14,9 +29,11 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; /** +* @website https://docs.auauz.net +* @description / * @author ${author} * @date ${date} -*/ +**/ @Data public class ${className}Dto implements Serializable { <#if columns??> diff --git a/eladmin-system/src/main/resources/template/generator/admin/Entity.ftl b/eladmin-system/src/main/resources/template/generator/admin/Entity.ftl index 34d18934..ad138ab5 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Entity.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Entity.ftl @@ -1,7 +1,23 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* 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 ${package}.domain; import lombok.Data; import cn.hutool.core.bean.BeanUtil; +import io.swagger.annotations.ApiModelProperty; import cn.hutool.core.bean.copier.CopyOptions; import javax.persistence.*; <#if isNotNullColumns??> @@ -21,9 +37,11 @@ import java.math.BigDecimal; import java.io.Serializable; /** +* @website https://docs.auauz.net +* @description / * @author ${author} * @date ${date} -*/ +**/ @Entity @Data @Table(name="${tableName}") @@ -31,9 +49,6 @@ public class ${className} implements Serializable { <#if columns??> <#list columns as column> - <#if column.remark != ''> - /** ${column.remark} */ - <#if column.columnKey = 'PRI'> @Id <#if auto> @@ -55,6 +70,11 @@ public class ${className} implements Serializable { @UpdateTimestamp + <#if column.remark != ''> + @ApiModelProperty(value = "${column.remark}") + <#else> + @ApiModelProperty(value = "${column.changeColumnName}") + private ${column.columnType} ${column.changeColumnName}; diff --git a/eladmin-system/src/main/resources/template/generator/admin/Mapper.ftl b/eladmin-system/src/main/resources/template/generator/admin/Mapper.ftl index c1ac5a0f..670ab65b 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Mapper.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Mapper.ftl @@ -1,3 +1,18 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* 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 ${package}.service.mapper; import me.zhengjie.base.BaseMapper; @@ -7,9 +22,11 @@ import org.mapstruct.Mapper; import org.mapstruct.ReportingPolicy; /** +* @website https://docs.auauz.net +* @description / * @author ${author} * @date ${date} -*/ +**/ @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) public interface ${className}Mapper extends BaseMapper<${className}Dto, ${className}> { diff --git a/eladmin-system/src/main/resources/template/generator/admin/QueryCriteria.ftl b/eladmin-system/src/main/resources/template/generator/admin/QueryCriteria.ftl index c7fa4b95..8c42ce1e 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/QueryCriteria.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/QueryCriteria.ftl @@ -1,3 +1,18 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* 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 ${package}.service.dto; import lombok.Data; @@ -15,9 +30,11 @@ import me.zhengjie.annotation.Query; /** +* @website https://docs.auauz.net +* @description / * @author ${author} * @date ${date} -*/ +**/ @Data public class ${className}QueryCriteria{ <#if queryColumns??> diff --git a/eladmin-system/src/main/resources/template/generator/admin/Repository.ftl b/eladmin-system/src/main/resources/template/generator/admin/Repository.ftl index e1b7f28f..e05c08e0 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Repository.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Repository.ftl @@ -1,3 +1,18 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* 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 ${package}.repository; import ${package}.domain.${className}; @@ -5,9 +20,11 @@ import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; /** +* @website https://docs.auauz.net +* @description / * @author ${author} * @date ${date} -*/ +**/ public interface ${className}Repository extends JpaRepository<${className}, ${pkColumnType}>, JpaSpecificationExecutor<${className}> { <#if columns??> <#list columns as column> diff --git a/eladmin-system/src/main/resources/template/generator/admin/Service.ftl b/eladmin-system/src/main/resources/template/generator/admin/Service.ftl index 4ba4a0e7..4d4659b7 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/Service.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/Service.ftl @@ -1,3 +1,18 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* 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 ${package}.service; import ${package}.domain.${className}; @@ -10,9 +25,11 @@ import java.io.IOException; import javax.servlet.http.HttpServletResponse; /** +* @website https://docs.auauz.net +* @description / * @author ${author} * @date ${date} -*/ +**/ public interface ${className}Service { /** diff --git a/eladmin-system/src/main/resources/template/generator/admin/ServiceImpl.ftl b/eladmin-system/src/main/resources/template/generator/admin/ServiceImpl.ftl index 10b47094..d47bf194 100644 --- a/eladmin-system/src/main/resources/template/generator/admin/ServiceImpl.ftl +++ b/eladmin-system/src/main/resources/template/generator/admin/ServiceImpl.ftl @@ -1,3 +1,18 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* 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 ${package}.service.impl; import ${package}.domain.${className}; @@ -27,10 +42,6 @@ import cn.hutool.core.util.IdUtil; <#if !auto && pkColumnType = 'String'> import cn.hutool.core.util.IdUtil; -// 默认不使用缓存 -//import org.springframework.cache.annotation.CacheConfig; -//import org.springframework.cache.annotation.CacheEvict; -//import org.springframework.cache.annotation.Cacheable; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import me.zhengjie.utils.PageUtil; @@ -43,11 +54,12 @@ import java.util.ArrayList; import java.util.LinkedHashMap; /** +* @website https://docs.auauz.net +* @description / * @author ${author} * @date ${date} -*/ +**/ @Service -//@CacheConfig(cacheNames = "${changeClassName}") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class ${className}ServiceImpl implements ${className}Service { @@ -61,20 +73,17 @@ public class ${className}ServiceImpl implements ${className}Service { } @Override - //@Cacheable public Map queryAll(${className}QueryCriteria criteria, Pageable pageable){ Page<${className}> page = ${changeClassName}Repository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); return PageUtil.toPage(page.map(${changeClassName}Mapper::toDto)); } @Override - //@Cacheable public List<${className}Dto> queryAll(${className}QueryCriteria criteria){ return ${changeClassName}Mapper.toDto(${changeClassName}Repository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); } @Override - //@Cacheable(key = "#p0") public ${className}Dto findById(${pkColumnType} ${pkChangeColName}) { ${className} ${changeClassName} = ${changeClassName}Repository.findById(${pkChangeColName}).orElseGet(${className}::new); ValidationUtil.isNull(${changeClassName}.get${pkCapitalColName}(),"${className}","${pkChangeColName}",${pkChangeColName}); @@ -82,7 +91,6 @@ public class ${className}ServiceImpl implements ${className}Service { } @Override - //@CacheEvict(allEntries = true) @Transactional(rollbackFor = Exception.class) public ${className}Dto create(${className} resources) { <#if !auto && pkColumnType = 'Long'> @@ -105,7 +113,6 @@ public class ${className}ServiceImpl implements ${className}Service { } @Override - //@CacheEvict(allEntries = true) @Transactional(rollbackFor = Exception.class) public void update(${className} resources) { ${className} ${changeClassName} = ${changeClassName}Repository.findById(resources.get${pkCapitalColName}()).orElseGet(${className}::new); @@ -128,7 +135,6 @@ public class ${className}ServiceImpl implements ${className}Service { } @Override - //@CacheEvict(allEntries = true) public void deleteAll(${pkColumnType}[] ids) { for (${pkColumnType} ${pkChangeColName} : ids) { ${changeClassName}Repository.deleteById(${pkChangeColName}); @@ -153,4 +159,4 @@ public class ${className}ServiceImpl implements ${className}Service { } FileUtil.downloadExcel(list, response); } -} +} \ No newline at end of file diff --git a/eladmin-tools/src/main/java/me/zhengjie/config/MultipartConfig.java b/eladmin-tools/src/main/java/me/zhengjie/config/MultipartConfig.java index f0893fc3..33412bd5 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/config/MultipartConfig.java +++ b/eladmin-tools/src/main/java/me/zhengjie/config/MultipartConfig.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.config; import org.springframework.boot.web.servlet.MultipartConfigFactory; diff --git a/eladmin-tools/src/main/java/me/zhengjie/domain/AlipayConfig.java b/eladmin-tools/src/main/java/me/zhengjie/domain/AlipayConfig.java index 9b39ede1..def695d9 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/domain/AlipayConfig.java +++ b/eladmin-tools/src/main/java/me/zhengjie/domain/AlipayConfig.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.persistence.*; import javax.validation.constraints.NotBlank; @@ -12,54 +28,49 @@ import java.io.Serializable; */ @Data @Entity -@Table(name = "alipay_config") +@Table(name = "tool_alipay_config") public class AlipayConfig implements Serializable { @Id + @Column(name = "config_id") + @ApiModelProperty(value = "ID", hidden = true) private Long id; - /** 应用ID,APPID,收款账号既是APPID对应支付宝账号 */ @NotBlank - @Column(name = "app_id") + @ApiModelProperty(value = "应用ID") private String appId; - /** 商户私钥,您的PKCS8格式RSA2私钥 */ @NotBlank - @Column(name = "private_key", columnDefinition = "text") + @ApiModelProperty(value = "商户私钥") private String privateKey; - /** 支付宝公钥 */ @NotBlank - @Column(name = "public_key", columnDefinition = "text") + @ApiModelProperty(value = "支付宝公钥") private String publicKey; - /** 签名方式,固定格式 */ - @Column(name = "sign_type") + @ApiModelProperty(value = "签名方式") private String signType="RSA2"; - /** 支付宝开放安全地址,一般不会变 */ @Column(name = "gateway_url") + @ApiModelProperty(value = "支付宝开放安全地址", hidden = true) private String gatewayUrl = "https://openapi.alipaydev.com/gateway.do"; - /** 编码,固定格式 */ + @ApiModelProperty(value = "编码", hidden = true) private String charset= "utf-8"; - /** 异步通知地址 */ @NotBlank - @Column(name = "notify_url") + @ApiModelProperty(value = "异步通知地址") private String notifyUrl; - /** 订单完成后返回的页面 */ @NotBlank - @Column(name = "return_url") + @ApiModelProperty(value = "订单完成后返回的页面") private String returnUrl; - /** 类型,固定格式 */ + @ApiModelProperty(value = "类型") private String format="JSON"; - /** 商户号 */ @NotBlank - @Column(name = "sys_service_provider_id") + @ApiModelProperty(value = "商户号") private String sysServiceProviderId; } diff --git a/eladmin-tools/src/main/java/me/zhengjie/domain/EmailConfig.java b/eladmin-tools/src/main/java/me/zhengjie/domain/EmailConfig.java index d3c38057..b4fc1e6d 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/domain/EmailConfig.java +++ b/eladmin-tools/src/main/java/me/zhengjie/domain/EmailConfig.java @@ -1,7 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; - import javax.persistence.*; import javax.validation.constraints.NotBlank; import java.io.Serializable; @@ -13,29 +28,31 @@ import java.io.Serializable; */ @Entity @Data -@Table(name = "email_config") +@Table(name = "tool_email_config") public class EmailConfig implements Serializable { @Id + @Column(name = "config_id") + @ApiModelProperty(value = "ID", hidden = true) private Long id; - /** 邮件服务器SMTP地址 */ @NotBlank + @ApiModelProperty(value = "邮件服务器SMTP地址") private String host; - /** 邮件服务器 SMTP 端口 */ @NotBlank + @ApiModelProperty(value = "邮件服务器 SMTP 端口") private String port; - /** 发件者用户名,默认为发件人邮箱前缀 */ @NotBlank + @ApiModelProperty(value = "发件者用户名") private String user; @NotBlank + @ApiModelProperty(value = "密码") private String pass; - /** 收件人 */ @NotBlank - @Column(name = "from_user") + @ApiModelProperty(value = "收件人") private String fromUser; } diff --git a/eladmin-tools/src/main/java/me/zhengjie/domain/LocalStorage.java b/eladmin-tools/src/main/java/me/zhengjie/domain/LocalStorage.java index ea5b4af7..59fd0ab8 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/domain/LocalStorage.java +++ b/eladmin-tools/src/main/java/me/zhengjie/domain/LocalStorage.java @@ -1,13 +1,27 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.*; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; -import org.hibernate.annotations.CreationTimestamp; - +import me.zhengjie.base.BaseEntity; import javax.persistence.*; import java.io.Serializable; -import java.sql.Timestamp; /** * @author Zheng Jie @@ -16,55 +30,41 @@ import java.sql.Timestamp; @Getter @Setter @Entity -@Table(name="local_storage") +@Table(name="tool_local_storage") @NoArgsConstructor -public class LocalStorage implements Serializable { +public class LocalStorage extends BaseEntity implements Serializable { @Id + @Column(name = "storage_id") + @ApiModelProperty(value = "ID", hidden = true) @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") private Long id; - /** 真实文件名 */ - @Column(name = "real_name") + @ApiModelProperty(value = "真实文件名") private String realName; - /**文件名 */ - @Column(name = "name") + @ApiModelProperty(value = "文件名") private String name; - /**后缀 */ - @Column(name = "suffix") + @ApiModelProperty(value = "后缀") private String suffix; - /** 路径 */ - @Column(name = "path") + @ApiModelProperty(value = "路径") private String path; - /** 类型 */ - @Column(name = "type") + @ApiModelProperty(value = "类型") private String type; - /** 大小 */ - @Column(name = "size") + @ApiModelProperty(value = "大小") private String size; - /** 操作人 */ - @Column(name = "operate") - private String operate; - - @Column(name = "create_time") - @CreationTimestamp - private Timestamp createTime; - - public LocalStorage(String realName,String name, String suffix, String path, String type, String size, String operate) { + public LocalStorage(String realName,String name, String suffix, String path, String type, String size) { this.realName = realName; this.name = name; this.suffix = suffix; this.path = path; this.type = type; this.size = size; - this.operate = operate; } public void copy(LocalStorage source){ diff --git a/eladmin-tools/src/main/java/me/zhengjie/domain/Picture.java b/eladmin-tools/src/main/java/me/zhengjie/domain/Picture.java index b829c9a0..737cdb06 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/domain/Picture.java +++ b/eladmin-tools/src/main/java/me/zhengjie/domain/Picture.java @@ -1,8 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.hibernate.annotations.CreationTimestamp; - import javax.persistence.*; import java.io.Serializable; import java.sql.Timestamp; @@ -15,30 +30,39 @@ import java.sql.Timestamp; */ @Data @Entity -@Table(name = "picture") +@Table(name = "tool_picture") public class Picture implements Serializable { @Id + @Column(name = "picture_id") + @ApiModelProperty(value = "ID", hidden = true) @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @ApiModelProperty(value = "文件名") private String filename; + @ApiModelProperty(value = "图片url") private String url; + @ApiModelProperty(value = "图片大小") private String size; + @ApiModelProperty(value = "图片高") private String height; + @ApiModelProperty(value = "图片宽") private String width; @Column(name = "delete_url") + @ApiModelProperty(value = "用于删除的url") private String delete; + @ApiModelProperty(value = "创建者") private String username; @CreationTimestamp - @Column(name = "create_time") + @ApiModelProperty(value = "创建时间") private Timestamp createTime; /** 用于检测文件是否重复 */ diff --git a/eladmin-tools/src/main/java/me/zhengjie/domain/QiniuConfig.java b/eladmin-tools/src/main/java/me/zhengjie/domain/QiniuConfig.java index d713c9fe..0247e673 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/domain/QiniuConfig.java +++ b/eladmin-tools/src/main/java/me/zhengjie/domain/QiniuConfig.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.persistence.*; import javax.validation.constraints.NotBlank; @@ -12,24 +28,24 @@ import java.io.Serializable; */ @Data @Entity -@Table(name = "qiniu_config") +@Table(name = "tool_qiniu_config") public class QiniuConfig implements Serializable { @Id + @Column(name = "config_id") + @ApiModelProperty(value = "ID") private Long id; - /** 一个账号最多拥有两对密钥(Access/Secret Key) */ @NotBlank - @Column(name = "access_key", columnDefinition = "text") + @ApiModelProperty(value = "accessKey") private String accessKey; - /** 一个账号最多拥有两对密钥(Access/Secret Key) */ @NotBlank - @Column(name = "secret_key", columnDefinition = "text") + @ApiModelProperty(value = "secretKey") private String secretKey; - /** 存储空间名称作为唯一的 Bucket 识别符 */ @NotBlank + @ApiModelProperty(value = "存储空间名称作为唯一的 Bucket 识别符") private String bucket; /** @@ -41,12 +57,13 @@ public class QiniuConfig implements Serializable { * 东南亚 Zone.zoneAs0() */ @NotBlank + @ApiModelProperty(value = "Zone表示与机房的对应关系") private String zone; - /** 外链域名,可自定义,需在七牛云绑定 */ @NotBlank + @ApiModelProperty(value = "外链域名,可自定义,需在七牛云绑定") private String host; - /** 空间类型:公开/私有 */ + @ApiModelProperty(value = "空间类型:公开/私有") private String type = "公开"; } diff --git a/eladmin-tools/src/main/java/me/zhengjie/domain/QiniuContent.java b/eladmin-tools/src/main/java/me/zhengjie/domain/QiniuContent.java index d584b344..db69a6a6 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/domain/QiniuContent.java +++ b/eladmin-tools/src/main/java/me/zhengjie/domain/QiniuContent.java @@ -1,8 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.domain; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import org.hibernate.annotations.UpdateTimestamp; - import javax.persistence.*; import java.io.Serializable; import java.sql.Timestamp; @@ -14,32 +29,36 @@ import java.sql.Timestamp; */ @Data @Entity -@Table(name = "qiniu_content") +@Table(name = "tool_qiniu_content") public class QiniuContent implements Serializable { @Id + @Column(name = "content_id") + @ApiModelProperty(value = "ID", hidden = true) @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - /** 文件名 */ @Column(name = "name") + @ApiModelProperty(value = "文件名") private String key; - /** 空间名 */ + @ApiModelProperty(value = "空间名") private String bucket; - /** 大小 */ + @ApiModelProperty(value = "大小") private String size; - /** 文件地址 */ + @ApiModelProperty(value = "文件地址") private String url; + @ApiModelProperty(value = "文件类型") private String suffix; - /** 空间类型:公开/私有 */ + @ApiModelProperty(value = "空间类型:公开/私有") private String type = "公开"; @UpdateTimestamp + @ApiModelProperty(value = "创建或更新时间") @Column(name = "update_time") private Timestamp updateTime; } diff --git a/eladmin-tools/src/main/java/me/zhengjie/domain/VerificationCode.java b/eladmin-tools/src/main/java/me/zhengjie/domain/VerificationCode.java deleted file mode 100644 index 0d1ad76f..00000000 --- a/eladmin-tools/src/main/java/me/zhengjie/domain/VerificationCode.java +++ /dev/null @@ -1,55 +0,0 @@ -package me.zhengjie.domain; - -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; -import org.hibernate.annotations.CreationTimestamp; - -import javax.persistence.*; -import javax.validation.constraints.NotBlank; -import java.io.Serializable; -import java.sql.Timestamp; - -/** - * @author Zheng Jie - * @date 2018-12-26 - */ -@Data -@Entity -@AllArgsConstructor -@NoArgsConstructor -@Table(name = "verification_code") -public class VerificationCode implements Serializable { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - private String code; - - /** 使用场景,自己定义 */ - private String scenes; - - /** true 为有效,false 为无效,验证时状态+时间+具体的邮箱或者手机号 */ - private Boolean status = true; - - /** 类型 :phone 和 email */ - @NotBlank - private String type; - - /** 具体的phone与email */ - @NotBlank - private String value; - - /** 创建日期 */ - @CreationTimestamp - @Column(name = "create_time") - private Timestamp createTime; - - public VerificationCode(String code, String scenes, @NotBlank String type, @NotBlank String value) { - this.code = code; - this.scenes = scenes; - this.type = type; - this.value = value; - } -} diff --git a/eladmin-tools/src/main/java/me/zhengjie/domain/vo/EmailVo.java b/eladmin-tools/src/main/java/me/zhengjie/domain/vo/EmailVo.java index 43cd181d..1fb759f5 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/domain/vo/EmailVo.java +++ b/eladmin-tools/src/main/java/me/zhengjie/domain/vo/EmailVo.java @@ -1,9 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.domain.vo; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; - import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotEmpty; import java.util.List; diff --git a/eladmin-tools/src/main/java/me/zhengjie/domain/vo/TradeVo.java b/eladmin-tools/src/main/java/me/zhengjie/domain/vo/TradeVo.java index 2d8dcdbb..01c1c2fd 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/domain/vo/TradeVo.java +++ b/eladmin-tools/src/main/java/me/zhengjie/domain/vo/TradeVo.java @@ -1,8 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.domain.vo; import io.swagger.annotations.ApiModelProperty; import lombok.Data; - import javax.validation.constraints.NotBlank; import java.sql.Date; import java.sql.Timestamp; diff --git a/eladmin-tools/src/main/java/me/zhengjie/repository/AliPayRepository.java b/eladmin-tools/src/main/java/me/zhengjie/repository/AliPayRepository.java index 732435b3..61183b43 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/repository/AliPayRepository.java +++ b/eladmin-tools/src/main/java/me/zhengjie/repository/AliPayRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.repository; import me.zhengjie.domain.AlipayConfig; diff --git a/eladmin-tools/src/main/java/me/zhengjie/repository/EmailRepository.java b/eladmin-tools/src/main/java/me/zhengjie/repository/EmailRepository.java index d5fb22fc..7765602c 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/repository/EmailRepository.java +++ b/eladmin-tools/src/main/java/me/zhengjie/repository/EmailRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.repository; import me.zhengjie.domain.EmailConfig; diff --git a/eladmin-tools/src/main/java/me/zhengjie/repository/LocalStorageRepository.java b/eladmin-tools/src/main/java/me/zhengjie/repository/LocalStorageRepository.java index 15554451..8c1e85af 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/repository/LocalStorageRepository.java +++ b/eladmin-tools/src/main/java/me/zhengjie/repository/LocalStorageRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.repository; import me.zhengjie.domain.LocalStorage; diff --git a/eladmin-tools/src/main/java/me/zhengjie/repository/PictureRepository.java b/eladmin-tools/src/main/java/me/zhengjie/repository/PictureRepository.java index 62fe84b6..c8334e02 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/repository/PictureRepository.java +++ b/eladmin-tools/src/main/java/me/zhengjie/repository/PictureRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.repository; import me.zhengjie.domain.Picture; diff --git a/eladmin-tools/src/main/java/me/zhengjie/repository/QiNiuConfigRepository.java b/eladmin-tools/src/main/java/me/zhengjie/repository/QiNiuConfigRepository.java index 60f76138..9379f55b 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/repository/QiNiuConfigRepository.java +++ b/eladmin-tools/src/main/java/me/zhengjie/repository/QiNiuConfigRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.repository; import me.zhengjie.domain.QiniuConfig; diff --git a/eladmin-tools/src/main/java/me/zhengjie/repository/QiniuContentRepository.java b/eladmin-tools/src/main/java/me/zhengjie/repository/QiniuContentRepository.java index f6fdb1da..55f813f5 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/repository/QiniuContentRepository.java +++ b/eladmin-tools/src/main/java/me/zhengjie/repository/QiniuContentRepository.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.repository; import me.zhengjie.domain.QiniuContent; diff --git a/eladmin-tools/src/main/java/me/zhengjie/repository/VerificationCodeRepository.java b/eladmin-tools/src/main/java/me/zhengjie/repository/VerificationCodeRepository.java deleted file mode 100644 index c602a45e..00000000 --- a/eladmin-tools/src/main/java/me/zhengjie/repository/VerificationCodeRepository.java +++ /dev/null @@ -1,20 +0,0 @@ -package me.zhengjie.repository; - -import me.zhengjie.domain.VerificationCode; -import org.springframework.data.jpa.repository.JpaRepository; - -/** - * @author Zheng Jie - * @date 2018-12-26 - */ -public interface VerificationCodeRepository extends JpaRepository { - - /** - * 获取有效的验证码 - * @param scenes 业务场景,如重置密码,重置邮箱等等 - * @param type 类型 - * @param value 值 - * @return VerificationCode - */ - VerificationCode findByScenesAndTypeAndValueAndStatusIsTrue(String scenes, String type, String value); -} diff --git a/eladmin-tools/src/main/java/me/zhengjie/rest/AliPayController.java b/eladmin-tools/src/main/java/me/zhengjie/rest/AliPayController.java index 8e83f9ea..0a8bfda4 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/rest/AliPayController.java +++ b/eladmin-tools/src/main/java/me/zhengjie/rest/AliPayController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.zhengjie.annotation.AnonymousAccess; import me.zhengjie.aop.log.Log; @@ -26,19 +42,14 @@ import java.util.Map; */ @Slf4j @RestController +@RequiredArgsConstructor @RequestMapping("/api/aliPay") @Api(tags = "工具:支付宝管理") public class AliPayController { private final AlipayUtils alipayUtils; - private final AliPayService alipayService; - public AliPayController(AlipayUtils alipayUtils, AliPayService alipayService) { - this.alipayUtils = alipayUtils; - this.alipayService = alipayService; - } - @GetMapping public ResponseEntity get(){ return new ResponseEntity<>(alipayService.find(),HttpStatus.OK); diff --git a/eladmin-tools/src/main/java/me/zhengjie/rest/EmailController.java b/eladmin-tools/src/main/java/me/zhengjie/rest/EmailController.java index a203c974..f580e5c6 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/rest/EmailController.java +++ b/eladmin-tools/src/main/java/me/zhengjie/rest/EmailController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.domain.vo.EmailVo; import me.zhengjie.domain.EmailConfig; @@ -17,16 +33,13 @@ import org.springframework.web.bind.annotation.*; * @date 2018/09/28 6:55:53 */ @RestController +@RequiredArgsConstructor @RequestMapping("api/email") @Api(tags = "工具:邮件管理") public class EmailController { private final EmailService emailService; - public EmailController(EmailService emailService) { - this.emailService = emailService; - } - @GetMapping public ResponseEntity get(){ return new ResponseEntity<>(emailService.find(),HttpStatus.OK); diff --git a/eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java b/eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java index f2de414c..8938772b 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java +++ b/eladmin-tools/src/main/java/me/zhengjie/rest/LocalStorageController.java @@ -1,5 +1,21 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.rest; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.domain.LocalStorage; import me.zhengjie.service.LocalStorageService; @@ -20,17 +36,14 @@ import java.io.IOException; * @author Zheng Jie * @date 2019-09-05 */ -@Api(tags = "工具:本地存储管理") @RestController +@RequiredArgsConstructor +@Api(tags = "工具:本地存储管理") @RequestMapping("/api/localStorage") public class LocalStorageController { private final LocalStorageService localStorageService; - public LocalStorageController(LocalStorageService localStorageService) { - this.localStorageService = localStorageService; - } - @ApiOperation("查询文件") @GetMapping @PreAuthorize("@el.check('storage:list')") diff --git a/eladmin-tools/src/main/java/me/zhengjie/rest/PictureController.java b/eladmin-tools/src/main/java/me/zhengjie/rest/PictureController.java index 9cb4604f..6614391c 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/rest/PictureController.java +++ b/eladmin-tools/src/main/java/me/zhengjie/rest/PictureController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import me.zhengjie.aop.log.Log; import me.zhengjie.domain.Picture; import me.zhengjie.service.PictureService; @@ -21,16 +37,13 @@ import java.io.IOException; * @date 2018/09/20 14:13:32 */ @RestController +@RequiredArgsConstructor @RequestMapping("/api/pictures") @Api(tags = "工具:免费图床管理") public class PictureController { private final PictureService pictureService; - public PictureController(PictureService pictureService) { - this.pictureService = pictureService; - } - @Log("查询图片") @PreAuthorize("@el.check('pictures:list')") @GetMapping diff --git a/eladmin-tools/src/main/java/me/zhengjie/rest/QiniuController.java b/eladmin-tools/src/main/java/me/zhengjie/rest/QiniuController.java index 66bba898..5c234ea6 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/rest/QiniuController.java +++ b/eladmin-tools/src/main/java/me/zhengjie/rest/QiniuController.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.rest; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.zhengjie.aop.log.Log; import me.zhengjie.domain.QiniuConfig; @@ -26,16 +42,13 @@ import java.util.Map; */ @Slf4j @RestController +@RequiredArgsConstructor @RequestMapping("/api/qiNiuContent") @Api(tags = "工具:七牛云存储管理") public class QiniuController { private final QiNiuService qiNiuService; - public QiniuController(QiNiuService qiNiuService) { - this.qiNiuService = qiNiuService; - } - @GetMapping(value = "/config") public ResponseEntity get(){ return new ResponseEntity<>(qiNiuService.find(), HttpStatus.OK); diff --git a/eladmin-tools/src/main/java/me/zhengjie/rest/VerificationCodeController.java b/eladmin-tools/src/main/java/me/zhengjie/rest/VerificationCodeController.java deleted file mode 100644 index 4657f0cc..00000000 --- a/eladmin-tools/src/main/java/me/zhengjie/rest/VerificationCodeController.java +++ /dev/null @@ -1,59 +0,0 @@ -package me.zhengjie.rest; - -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import me.zhengjie.domain.VerificationCode; -import me.zhengjie.domain.vo.EmailVo; -import me.zhengjie.service.EmailService; -import me.zhengjie.service.VerificationCodeService; -import me.zhengjie.utils.ElAdminConstant; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; - -/** - * @author Zheng Jie - * @date 2018-12-26 - */ -@RestController -@RequestMapping("/api/code") -@Api(tags = "工具:验证码管理") -public class VerificationCodeController { - - private final VerificationCodeService verificationCodeService; - - private final EmailService emailService; - - public VerificationCodeController(VerificationCodeService verificationCodeService, EmailService emailService) { - this.verificationCodeService = verificationCodeService; - this.emailService = emailService; - } - - @PostMapping(value = "/resetEmail") - @ApiOperation("重置邮箱,发送验证码") - public ResponseEntity resetEmail(@RequestBody VerificationCode code) throws Exception { - code.setScenes(ElAdminConstant.RESET_MAIL); - EmailVo emailVo = verificationCodeService.sendEmail(code); - emailService.send(emailVo,emailService.find()); - return new ResponseEntity<>(HttpStatus.OK); - } - - @PostMapping(value = "/email/resetPass") - @ApiOperation("重置密码,发送验证码") - public ResponseEntity resetPass(@RequestParam String email) throws Exception { - VerificationCode code = new VerificationCode(); - code.setType("email"); - code.setValue(email); - code.setScenes(ElAdminConstant.RESET_MAIL); - EmailVo emailVo = verificationCodeService.sendEmail(code); - emailService.send(emailVo,emailService.find()); - return new ResponseEntity<>(HttpStatus.OK); - } - - @GetMapping(value = "/validated") - @ApiOperation("验证码验证") - public ResponseEntity validated(VerificationCode code){ - verificationCodeService.validated(code); - return new ResponseEntity<>(HttpStatus.OK); - } -} diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/AliPayService.java b/eladmin-tools/src/main/java/me/zhengjie/service/AliPayService.java index 7d729205..79351634 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/AliPayService.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/AliPayService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service; import me.zhengjie.domain.vo.TradeVo; diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/EmailService.java b/eladmin-tools/src/main/java/me/zhengjie/service/EmailService.java index a8e05d3e..3932dd78 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/EmailService.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/EmailService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service; import me.zhengjie.domain.vo.EmailVo; @@ -30,6 +45,5 @@ public interface EmailService { * @param emailConfig 邮件配置 * @throws Exception / */ - @Async - void send(EmailVo emailVo, EmailConfig emailConfig) throws Exception; + void send(EmailVo emailVo, EmailConfig emailConfig); } diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/LocalStorageService.java b/eladmin-tools/src/main/java/me/zhengjie/service/LocalStorageService.java index 9be71cfb..9ac8f2e2 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/LocalStorageService.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/LocalStorageService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service; import me.zhengjie.domain.LocalStorage; diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/PictureService.java b/eladmin-tools/src/main/java/me/zhengjie/service/PictureService.java index bf43709d..fd3723ef 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/PictureService.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/PictureService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service; import me.zhengjie.domain.Picture; diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/QiNiuService.java b/eladmin-tools/src/main/java/me/zhengjie/service/QiNiuService.java index d24985e3..ac612198 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/QiNiuService.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/QiNiuService.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service; import me.zhengjie.domain.QiniuConfig; diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/VerificationCodeService.java b/eladmin-tools/src/main/java/me/zhengjie/service/VerificationCodeService.java deleted file mode 100644 index 058947f5..00000000 --- a/eladmin-tools/src/main/java/me/zhengjie/service/VerificationCodeService.java +++ /dev/null @@ -1,24 +0,0 @@ -package me.zhengjie.service; - -import me.zhengjie.domain.VerificationCode; -import me.zhengjie.domain.vo.EmailVo; - -/** - * @author Zheng Jie - * @date 2018-12-26 - */ -public interface VerificationCodeService { - - /** - * 发送邮件验证码 - * @param code 验证码 - * @return EmailVo - */ - EmailVo sendEmail(VerificationCode code); - - /** - * 验证 - * @param code 验证码 - */ - void validated(VerificationCode code); -} diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/dto/LocalStorageDto.java b/eladmin-tools/src/main/java/me/zhengjie/service/dto/LocalStorageDto.java index 25399071..14221c2a 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/dto/LocalStorageDto.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/dto/LocalStorageDto.java @@ -1,15 +1,32 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.dto; -import lombok.Data; +import lombok.Getter; +import lombok.Setter; +import me.zhengjie.base.BaseDTO; import java.io.Serializable; -import java.sql.Timestamp; /** * @author Zheng Jie * @date 2019-09-05 */ -@Data -public class LocalStorageDto implements Serializable { +@Getter +@Setter +public class LocalStorageDto extends BaseDTO implements Serializable { private Long id; @@ -22,8 +39,4 @@ public class LocalStorageDto implements Serializable { private String type; private String size; - - private String operate; - - private Timestamp createTime; } \ No newline at end of file diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/dto/LocalStorageQueryCriteria.java b/eladmin-tools/src/main/java/me/zhengjie/service/dto/LocalStorageQueryCriteria.java index 35a4c471..bea1cc7c 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/dto/LocalStorageQueryCriteria.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/dto/LocalStorageQueryCriteria.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.dto; import lombok.Data; @@ -13,7 +28,7 @@ import me.zhengjie.annotation.Query; @Data public class LocalStorageQueryCriteria{ - @Query(blurry = "name,suffix,type,operate,size") + @Query(blurry = "name,suffix,type,createBy,size") private String blurry; @Query(type = Query.Type.BETWEEN) diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/dto/PictureQueryCriteria.java b/eladmin-tools/src/main/java/me/zhengjie/service/dto/PictureQueryCriteria.java index 44b8363e..e7d4f1b1 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/dto/PictureQueryCriteria.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/dto/PictureQueryCriteria.java @@ -1,8 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.dto; import lombok.Data; import me.zhengjie.annotation.Query; - import java.sql.Timestamp; import java.util.List; diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/dto/QiniuQueryCriteria.java b/eladmin-tools/src/main/java/me/zhengjie/service/dto/QiniuQueryCriteria.java index 4b73eb9b..f5c2240b 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/dto/QiniuQueryCriteria.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/dto/QiniuQueryCriteria.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.dto; import lombok.Data; diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/impl/AliPayServiceImpl.java b/eladmin-tools/src/main/java/me/zhengjie/service/impl/AliPayServiceImpl.java index 791c2cd8..b035ee04 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/impl/AliPayServiceImpl.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/impl/AliPayServiceImpl.java @@ -1,9 +1,25 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.impl; import com.alipay.api.AlipayClient; import com.alipay.api.DefaultAlipayClient; import com.alipay.api.request.AlipayTradePagePayRequest; import com.alipay.api.request.AlipayTradeWapPayRequest; +import lombok.RequiredArgsConstructor; import me.zhengjie.domain.vo.TradeVo; import me.zhengjie.domain.AlipayConfig; import me.zhengjie.exception.BadRequestException; @@ -22,6 +38,7 @@ import java.util.Optional; * @date 2018-12-31 */ @Service +@RequiredArgsConstructor @CacheConfig(cacheNames = "alipay") @SuppressWarnings("all") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) @@ -29,10 +46,6 @@ public class AliPayServiceImpl implements AliPayService { private final AliPayRepository alipayRepository; - public AliPayServiceImpl(AliPayRepository alipayRepository) { - this.alipayRepository = alipayRepository; - } - @Override public String toPayAsPc(AlipayConfig alipay, TradeVo trade) throws Exception { diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/impl/EmailServiceImpl.java b/eladmin-tools/src/main/java/me/zhengjie/service/impl/EmailServiceImpl.java index fee562de..73043e9e 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/impl/EmailServiceImpl.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/impl/EmailServiceImpl.java @@ -1,7 +1,23 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.impl; import cn.hutool.extra.mail.Mail; import cn.hutool.extra.mail.MailAccount; +import lombok.RequiredArgsConstructor; import me.zhengjie.domain.EmailConfig; import me.zhengjie.domain.vo.EmailVo; import me.zhengjie.exception.BadRequestException; @@ -21,16 +37,13 @@ import java.util.Optional; * @date 2018-12-26 */ @Service +@RequiredArgsConstructor @CacheConfig(cacheNames = "email") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class EmailServiceImpl implements EmailService { private final EmailRepository emailRepository; - public EmailServiceImpl(EmailRepository emailRepository) { - this.emailRepository = emailRepository; - } - @Override @CachePut(key = "'1'") @Transactional(rollbackFor = Exception.class) diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/impl/LocalStorageServiceImpl.java b/eladmin-tools/src/main/java/me/zhengjie/service/impl/LocalStorageServiceImpl.java index 861e31e6..671e549a 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/impl/LocalStorageServiceImpl.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/impl/LocalStorageServiceImpl.java @@ -1,6 +1,22 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.impl; import cn.hutool.core.util.ObjectUtil; +import lombok.RequiredArgsConstructor; import me.zhengjie.config.FileProperties; import me.zhengjie.domain.LocalStorage; import me.zhengjie.service.dto.LocalStorageDto; @@ -22,11 +38,9 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; - import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.web.multipart.MultipartFile; - import javax.servlet.http.HttpServletResponse; /** @@ -34,21 +48,15 @@ import javax.servlet.http.HttpServletResponse; * @date 2019-09-05 */ @Service +@RequiredArgsConstructor @CacheConfig(cacheNames = "localStorage") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class LocalStorageServiceImpl implements LocalStorageService { private final LocalStorageRepository localStorageRepository; - private final LocalStorageMapper localStorageMapper; - private final FileProperties properties; - public LocalStorageServiceImpl(LocalStorageRepository localStorageRepository, LocalStorageMapper localStorageMapper, FileProperties properties) { - this.localStorageRepository = localStorageRepository; - this.localStorageMapper = localStorageMapper; - this.properties = properties; - } @Override @Cacheable @@ -90,8 +98,7 @@ public class LocalStorageServiceImpl implements LocalStorageService { suffix, file.getPath(), type, - FileUtil.getSize(multipartFile.getSize()), - SecurityUtils.getCurrentUsername() + FileUtil.getSize(multipartFile.getSize()) ); return localStorageMapper.toDto(localStorageRepository.save(localStorage)); }catch (Exception e){ @@ -130,7 +137,7 @@ public class LocalStorageServiceImpl implements LocalStorageService { map.put("备注名", localStorageDTO.getName()); map.put("文件类型", localStorageDTO.getType()); map.put("文件大小", localStorageDTO.getSize()); - map.put("操作人", localStorageDTO.getOperate()); + map.put("创建者", localStorageDTO.getCreateBy()); map.put("创建日期", localStorageDTO.getCreateTime()); list.add(map); } diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/impl/PictureServiceImpl.java b/eladmin-tools/src/main/java/me/zhengjie/service/impl/PictureServiceImpl.java index 8d0e2b43..58824d79 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/impl/PictureServiceImpl.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/impl/PictureServiceImpl.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.impl; import cn.hutool.http.HttpRequest; @@ -5,6 +20,7 @@ import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSON; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.zhengjie.domain.Picture; import me.zhengjie.repository.PictureRepository; @@ -29,6 +45,7 @@ import java.util.*; * @date 2018-12-27 */ @Slf4j +@RequiredArgsConstructor @Service(value = "pictureService") @CacheConfig(cacheNames = "picture") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) @@ -36,19 +53,11 @@ public class PictureServiceImpl implements PictureService { @Value("${smms.token}") private String token; - private final PictureRepository pictureRepository; - private static final String SUCCESS = "success"; - private static final String CODE = "code"; - private static final String MSG = "message"; - public PictureServiceImpl(PictureRepository pictureRepository) { - this.pictureRepository = pictureRepository; - } - @Override public Object queryAll(PictureQueryCriteria criteria, Pageable pageable){ return PageUtil.toPage(pictureRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable)); diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/impl/QiNiuServiceImpl.java b/eladmin-tools/src/main/java/me/zhengjie/service/impl/QiNiuServiceImpl.java index e50bee3b..e9405ee4 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/impl/QiNiuServiceImpl.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/impl/QiNiuServiceImpl.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.impl; import com.alibaba.fastjson.JSON; @@ -9,6 +24,7 @@ import com.qiniu.storage.UploadManager; import com.qiniu.storage.model.DefaultPutRet; import com.qiniu.storage.model.FileInfo; import com.qiniu.util.Auth; +import lombok.RequiredArgsConstructor; import me.zhengjie.domain.QiniuConfig; import me.zhengjie.domain.QiniuContent; import me.zhengjie.repository.QiniuContentRepository; @@ -40,19 +56,14 @@ import java.util.*; * @date 2018-12-31 */ @Service +@RequiredArgsConstructor @CacheConfig(cacheNames = "qiNiu") @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) public class QiNiuServiceImpl implements QiNiuService { private final QiNiuConfigRepository qiNiuConfigRepository; - private final QiniuContentRepository qiniuContentRepository; - public QiNiuServiceImpl(QiNiuConfigRepository qiNiuConfigRepository, QiniuContentRepository qiniuContentRepository) { - this.qiNiuConfigRepository = qiNiuConfigRepository; - this.qiniuContentRepository = qiniuContentRepository; - } - @Value("${qiniu.max-size}") private Long maxSize; diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/impl/VerificationCodeServiceImpl.java b/eladmin-tools/src/main/java/me/zhengjie/service/impl/VerificationCodeServiceImpl.java deleted file mode 100644 index bb47fe5d..00000000 --- a/eladmin-tools/src/main/java/me/zhengjie/service/impl/VerificationCodeServiceImpl.java +++ /dev/null @@ -1,87 +0,0 @@ -package me.zhengjie.service.impl; - -import cn.hutool.core.lang.Dict; -import cn.hutool.core.util.RandomUtil; -import cn.hutool.extra.template.Template; -import cn.hutool.extra.template.TemplateConfig; -import cn.hutool.extra.template.TemplateEngine; -import cn.hutool.extra.template.TemplateUtil; -import me.zhengjie.domain.vo.EmailVo; -import me.zhengjie.domain.VerificationCode; -import me.zhengjie.exception.BadRequestException; -import me.zhengjie.repository.VerificationCodeRepository; -import me.zhengjie.service.VerificationCodeService; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; -import java.util.Collections; -import java.util.concurrent.*; - -/** - * @author Zheng Jie - * @date 2018-12-26 - */ -@Service -@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) -public class VerificationCodeServiceImpl implements VerificationCodeService { - - private final VerificationCodeRepository verificationCodeRepository; - - @Value("${code.expiration}") - private Integer expiration; - - public VerificationCodeServiceImpl(VerificationCodeRepository verificationCodeRepository) { - this.verificationCodeRepository = verificationCodeRepository; - } - - @Override - @Transactional(rollbackFor = Exception.class) - public EmailVo sendEmail(VerificationCode code) { - EmailVo emailVo; - String content; - VerificationCode verificationCode = verificationCodeRepository.findByScenesAndTypeAndValueAndStatusIsTrue(code.getScenes(),code.getType(),code.getValue()); - // 如果不存在有效的验证码,就创建一个新的 - TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig("template", TemplateConfig.ResourceMode.CLASSPATH)); - Template template = engine.getTemplate("email/email.ftl"); - if(verificationCode == null){ - code.setCode(RandomUtil.randomNumbers (6)); - content = template.render(Dict.create().set("code",code.getCode())); - emailVo = new EmailVo(Collections.singletonList(code.getValue()),"eladmin后台管理系统",content); - timedDestruction(verificationCodeRepository.save(code)); - // 存在就再次发送原来的验证码 - } else { - content = template.render(Dict.create().set("code",verificationCode.getCode())); - emailVo = new EmailVo(Collections.singletonList(verificationCode.getValue()),"eladmin后台管理系统",content); - } - return emailVo; - } - - @Override - public void validated(VerificationCode code) { - VerificationCode verificationCode = verificationCodeRepository.findByScenesAndTypeAndValueAndStatusIsTrue(code.getScenes(),code.getType(),code.getValue()); - if(verificationCode == null || !verificationCode.getCode().equals(code.getCode())){ - throw new BadRequestException("无效验证码"); - } else { - verificationCode.setStatus(false); - verificationCodeRepository.save(verificationCode); - } - } - - /** - * 定时任务,指定分钟后改变验证码状态 - * @param verifyCode 验证码 - */ - private void timedDestruction(VerificationCode verifyCode) { - //以下示例为程序调用结束继续运行 - ScheduledExecutorService executorService = Executors.newSingleThreadScheduledExecutor(); - try { - executorService.schedule(() -> { - verifyCode.setStatus(false); - verificationCodeRepository.save(verifyCode); - }, expiration * 60 * 1000L, TimeUnit.MILLISECONDS); - }catch (Exception e){ - e.printStackTrace(); - } - } -} diff --git a/eladmin-tools/src/main/java/me/zhengjie/service/mapper/LocalStorageMapper.java b/eladmin-tools/src/main/java/me/zhengjie/service/mapper/LocalStorageMapper.java index bb0935a9..8fd83bc1 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/service/mapper/LocalStorageMapper.java +++ b/eladmin-tools/src/main/java/me/zhengjie/service/mapper/LocalStorageMapper.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.service.mapper; import me.zhengjie.base.BaseMapper; diff --git a/eladmin-tools/src/main/java/me/zhengjie/utils/AliPayStatusEnum.java b/eladmin-tools/src/main/java/me/zhengjie/utils/AliPayStatusEnum.java index fab42914..e833315c 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/utils/AliPayStatusEnum.java +++ b/eladmin-tools/src/main/java/me/zhengjie/utils/AliPayStatusEnum.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; /** diff --git a/eladmin-tools/src/main/java/me/zhengjie/utils/AlipayUtils.java b/eladmin-tools/src/main/java/me/zhengjie/utils/AlipayUtils.java index bf38d29b..c4bfc7c5 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/utils/AlipayUtils.java +++ b/eladmin-tools/src/main/java/me/zhengjie/utils/AlipayUtils.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import com.alipay.api.AlipayApiException; diff --git a/eladmin-tools/src/main/java/me/zhengjie/utils/QiNiuUtil.java b/eladmin-tools/src/main/java/me/zhengjie/utils/QiNiuUtil.java index 73a401cf..ba2bd533 100644 --- a/eladmin-tools/src/main/java/me/zhengjie/utils/QiNiuUtil.java +++ b/eladmin-tools/src/main/java/me/zhengjie/utils/QiNiuUtil.java @@ -1,3 +1,18 @@ +/* + * Copyright 2019-2020 Zheng Jie + * + * 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 me.zhengjie.utils; import com.qiniu.storage.Region; diff --git a/pom.xml b/pom.xml index e8a58730..7b14c861 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,6 @@ eladmin-logging eladmin-system eladmin-tools - eladmin-monitor eladmin-generator