From f7ce534394d8439f1cbada8be2b52c8fe75e54e9 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 27 Jul 2023 14:08:05 +0800 Subject: [PATCH 001/244] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E7=9B=AE=E5=BD=95=EF=BC=8C=E4=B8=BA=E5=BE=AE=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=8C=96=E5=81=9A=E5=87=86=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- .../src/main/resources/application-prod.yml | 0 .../src/main/resources/application-test.yml | 0 dependencies/pom.xml | 3 +- .../sample => example/example_api}/pom.xml | 12 +- example/example_svc/pom.xml | 42 ++++ .../example/svc/UniExampleApplication.java | 8 +- .../svc}/controller/DLCacheController.java | 4 +- .../svc}/controller/DynamicDsController.java | 4 +- .../svc}/controller/DynamicTpController.java | 4 +- .../controller/SpringRetryController.java | 4 +- .../controller/TtlExecutorController.java | 4 +- .../src/main/resources/application-dev.yml | 56 ++++++ .../src/main/resources/application.yml | 4 +- .../src/main/resources/banner.txt | 0 .../src/main/resources/logback-spring.xml | 0 .../src/main/resources/spy.properties | 0 .../svc/UniExampleApplicationTests.java | 4 +- {business => example}/pom.xml | 14 +- framework/framework_api/pom.xml | 54 +++++ .../api}/advisor/ApiExceptionAdvisor.java | 4 +- .../api}/advisor/ApiResultAdvisor.java | 6 +- .../api}/advisor/FrameExceptionAdvisor.java | 4 +- .../framework/api}/annotation/ApiFormat.java | 2 +- .../framework/api}/bean/dto/SysLogDto.java | 2 +- .../framework/api}/bean/dto/SysUserDto.java | 4 +- .../framework/api}/bean/po/SysApi.java | 2 +- .../framework/api}/bean/po/SysDict.java | 2 +- .../framework/api}/bean/po/SysLog.java | 2 +- .../framework/api}/bean/po/SysMenu.java | 2 +- .../framework/api}/bean/po/SysRole.java | 2 +- .../framework/api}/bean/po/SysUser.java | 2 +- .../framework/api}/bean/vo/SysApiVo.java | 2 +- .../framework/api}/bean/vo/SysDictVo.java | 2 +- .../framework/api}/bean/vo/SysLogVo.java | 2 +- .../framework/api}/bean/vo/SysMenuVo.java | 2 +- .../framework/api}/bean/vo/SysRoleVo.java | 2 +- .../framework/api}/bean/vo/SysUserVo.java | 2 +- .../framework/api}/config/JacksonConfig.java | 2 +- .../framework/api}/config/PluginConfig.java | 2 +- .../framework/api}/config/RetryConfig.java | 4 +- .../framework/api}/config/SecurityConfig.java | 12 +- .../api}/config/ThreadPoolConfig.java | 2 +- .../framework/api}/config/UniBootConfig.java | 2 +- .../framework/api}/config/WebMvcConfig.java | 2 +- .../framework/api}/consts/KeyPrefix.java | 2 +- .../framework/api}/convert/SysApiConvert.java | 10 +- .../api}/convert/SysDictConvert.java | 16 +- .../framework/api}/convert/SysLogConvert.java | 8 +- .../api}/convert/SysMenuConvert.java | 10 +- .../api}/convert/SysRoleConvert.java | 10 +- .../api}/convert/SysUserConvert.java | 16 +- .../framework/api}/enums/AuthErrorEnum.java | 2 +- .../framework/api}/enums/AuthModelEnum.java | 2 +- .../framework/api}/enums/FrameErrorEnum.java | 2 +- .../api}/exception/RetryableException.java | 2 +- .../framework/api}/mapper/SysApiMapper.java | 8 +- .../framework/api}/mapper/SysDictMapper.java | 4 +- .../framework/api}/mapper/SysLogMapper.java | 4 +- .../framework/api}/mapper/SysMenuMapper.java | 8 +- .../framework/api}/mapper/SysRoleMapper.java | 10 +- .../framework/api}/mapper/SysUserMapper.java | 8 +- .../framework/api}/plugin/ApiLogHandler.java | 12 +- .../api}/plugin/ObjectFillHandler.java | 4 +- .../framework/api}/request/SysApiRequest.java | 2 +- .../api}/request/SysDictRequest.java | 2 +- .../framework/api}/request/SysLogRequest.java | 2 +- .../api}/request/SysMenuRequest.java | 2 +- .../api}/request/SysRoleRequest.java | 2 +- .../api}/request/SysUserRequest.java | 2 +- .../filter/JwtTokenAuthFilterService.java | 10 +- .../filter/RedisTokenAuthFilterService.java | 14 +- .../api}/security/filter/TokenAuthFilter.java | 4 +- .../filter/TokenAuthFilterService.java | 2 +- .../handler/JwtLoginSuccessHandleService.java | 12 +- .../security/handler/LoginFailureHandler.java | 6 +- .../handler/LoginSuccessHandleService.java | 4 +- .../security/handler/LoginSuccessHandler.java | 12 +- .../handler/NoAuthenticationHandler.java | 4 +- .../security/handler/NoAuthorityHandler.java | 4 +- .../RedisLoginSuccessHandleService.java | 14 +- .../handler/SignOutSuccessHandler.java | 14 +- .../security/voter/DataBaseRoleVoter.java | 10 +- .../framework/api}/service/SysApiService.java | 8 +- .../api}/service/SysDictService.java | 4 +- .../framework/api}/service/SysLogService.java | 4 +- .../api}/service/SysMenuService.java | 10 +- .../api}/service/SysRoleService.java | 10 +- .../api}/service/SysUserService.java | 8 +- .../api}/serviceimpl/SysApiServiceImpl.java | 14 +- .../api}/serviceimpl/SysDictServiceImpl.java | 8 +- .../api}/serviceimpl/SysLogServiceImpl.java | 8 +- .../api}/serviceimpl/SysMenuServiceImpl.java | 16 +- .../api}/serviceimpl/SysRoleServiceImpl.java | 16 +- .../api}/serviceimpl/SysUserServiceImpl.java | 14 +- .../framework/api}/util/SecurityUtil.java | 6 +- .../framework_svc}/pom.xml | 34 +--- .../svc/UniFrameworkApplication.java | 26 +++ .../svc}/controller/AuthController.java | 8 +- .../svc}/controller/CommonController.java | 8 +- .../svc}/controller/SysApiController.java | 27 ++- .../svc}/controller/SysDictController.java | 26 ++- .../svc}/controller/SysLogController.java | 16 +- .../svc}/controller/SysMenuController.java | 25 ++- .../svc}/controller/SysRoleController.java | 23 ++- .../svc}/controller/SysUserController.java | 39 ++-- .../framework/svc}/util/FileUploadUtil.java | 4 +- .../src/main/resources/application-dev.yml | 7 +- .../src/main/resources/application.yml | 113 +++++++++++ .../src/main/resources/banner.txt | 8 + .../src/main/resources/logback-spring.xml | 132 +++++++++++++ .../src/main/resources/spy.properties | 21 ++ .../framework/svc}/JasyptEncryptorTest.java | 2 +- .../svc/UniFrameworkApplicationTests.java | 20 ++ framework/pom.xml | 46 +---- .../main/resources/mapper/SysApiMapper.xml | 48 ----- .../main/resources/mapper/SysMenuMapper.xml | 83 -------- .../main/resources/mapper/SysRoleMapper.xml | 184 ------------------ .../main/resources/mapper/SysUserMapper.xml | 73 ------- pom.xml | 4 +- 120 files changed, 835 insertions(+), 821 deletions(-) delete mode 100644 application/src/main/resources/application-prod.yml delete mode 100644 application/src/main/resources/application-test.yml rename {business/sample => example/example_api}/pom.xml (59%) create mode 100644 example/example_svc/pom.xml rename application/src/main/java/com/github/cadecode/application/UniBootApplication.java => example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/UniExampleApplication.java (72%) rename {business/sample/src/main/java/com/github/cadecode/uniboot/business/sample => example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc}/controller/DLCacheController.java (93%) rename {business/sample/src/main/java/com/github/cadecode/uniboot/business/sample => example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc}/controller/DynamicDsController.java (91%) rename {business/sample/src/main/java/com/github/cadecode/uniboot/business/sample => example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc}/controller/DynamicTpController.java (88%) rename {business/sample/src/main/java/com/github/cadecode/uniboot/business/sample => example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc}/controller/SpringRetryController.java (96%) rename {business/sample/src/main/java/com/github/cadecode/uniboot/business/sample => example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc}/controller/TtlExecutorController.java (94%) create mode 100644 example/example_svc/src/main/resources/application-dev.yml rename {application => example/example_svc}/src/main/resources/application.yml (97%) rename {application => example/example_svc}/src/main/resources/banner.txt (100%) rename {application => example/example_svc}/src/main/resources/logback-spring.xml (100%) rename {application => example/example_svc}/src/main/resources/spy.properties (100%) rename application/src/test/java/com/github/cadecode/uniboot/ApplicationTests.java => example/example_svc/src/test/java/com/github/cadecode/uniboot/example/svc/UniExampleApplicationTests.java (71%) rename {business => example}/pom.xml (65%) create mode 100644 framework/framework_api/pom.xml rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/advisor/ApiExceptionAdvisor.java (90%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/advisor/ApiResultAdvisor.java (94%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/advisor/FrameExceptionAdvisor.java (96%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/annotation/ApiFormat.java (81%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/dto/SysLogDto.java (94%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/dto/SysUserDto.java (93%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/po/SysApi.java (93%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/po/SysDict.java (95%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/po/SysLog.java (96%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/po/SysMenu.java (96%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/po/SysRole.java (94%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/po/SysUser.java (95%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/vo/SysApiVo.java (92%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/vo/SysDictVo.java (94%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/vo/SysLogVo.java (94%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/vo/SysMenuVo.java (94%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/vo/SysRoleVo.java (93%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/bean/vo/SysUserVo.java (92%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/config/JacksonConfig.java (93%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/config/PluginConfig.java (87%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/config/RetryConfig.java (93%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/config/SecurityConfig.java (94%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/config/ThreadPoolConfig.java (99%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/config/UniBootConfig.java (94%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/config/WebMvcConfig.java (91%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/consts/KeyPrefix.java (83%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/convert/SysApiConvert.java (51%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/convert/SysDictConvert.java (50%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/convert/SysLogConvert.java (56%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/convert/SysMenuConvert.java (51%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/convert/SysRoleConvert.java (55%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/convert/SysUserConvert.java (50%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/enums/AuthErrorEnum.java (96%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/enums/AuthModelEnum.java (89%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/enums/FrameErrorEnum.java (96%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/exception/RetryableException.java (95%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/mapper/SysApiMapper.java (61%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/mapper/SysDictMapper.java (66%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/mapper/SysLogMapper.java (66%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/mapper/SysMenuMapper.java (65%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/mapper/SysRoleMapper.java (79%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/mapper/SysUserMapper.java (65%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/plugin/ApiLogHandler.java (89%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/plugin/ObjectFillHandler.java (79%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/request/SysApiRequest.java (92%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/request/SysDictRequest.java (95%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/request/SysLogRequest.java (91%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/request/SysMenuRequest.java (96%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/request/SysRoleRequest.java (94%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/request/SysUserRequest.java (97%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/security/filter/JwtTokenAuthFilterService.java (88%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/security/filter/RedisTokenAuthFilterService.java (80%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/security/filter/TokenAuthFilter.java (87%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/security/filter/TokenAuthFilterService.java (97%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/security/handler/JwtLoginSuccessHandleService.java (77%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/security/handler/LoginFailureHandler.java (88%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/security/handler/LoginSuccessHandleService.java (79%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/security/handler/LoginSuccessHandler.java (83%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/security/handler/NoAuthenticationHandler.java (89%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/security/handler/NoAuthorityHandler.java (89%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/security/handler/RedisLoginSuccessHandleService.java (76%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/security/handler/SignOutSuccessHandler.java (78%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/security/voter/DataBaseRoleVoter.java (89%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/service/SysApiService.java (62%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/service/SysDictService.java (61%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/service/SysLogService.java (61%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/service/SysMenuService.java (60%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/service/SysRoleService.java (76%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/service/SysUserService.java (65%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/serviceimpl/SysApiServiceImpl.java (71%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/serviceimpl/SysDictServiceImpl.java (53%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/serviceimpl/SysLogServiceImpl.java (53%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/serviceimpl/SysMenuServiceImpl.java (81%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/serviceimpl/SysRoleServiceImpl.java (85%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/serviceimpl/SysUserServiceImpl.java (78%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_api/src/main/java/com/github/cadecode/uniboot/framework/api}/util/SecurityUtil.java (93%) rename {application => framework/framework_svc}/pom.xml (54%) create mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/UniFrameworkApplication.java rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/controller/AuthController.java (90%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/controller/CommonController.java (92%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/controller/SysApiController.java (81%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/controller/SysDictController.java (76%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/controller/SysLogController.java (82%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/controller/SysMenuController.java (79%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/controller/SysRoleController.java (84%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/controller/SysUserController.java (77%) rename framework/{src/main/java/com/github/cadecode/uniboot/framework => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/util/FileUploadUtil.java (95%) rename {application => framework/framework_svc}/src/main/resources/application-dev.yml (88%) create mode 100644 framework/framework_svc/src/main/resources/application.yml create mode 100644 framework/framework_svc/src/main/resources/banner.txt create mode 100644 framework/framework_svc/src/main/resources/logback-spring.xml create mode 100644 framework/framework_svc/src/main/resources/spy.properties rename {application/src/test/java/com/github/cadecode/uniboot => framework/framework_svc/src/test/java/com/github/cadecode/uniboot/framework/svc}/JasyptEncryptorTest.java (92%) create mode 100644 framework/framework_svc/src/test/java/com/github/cadecode/uniboot/framework/svc/UniFrameworkApplicationTests.java delete mode 100644 framework/src/main/resources/mapper/SysApiMapper.xml delete mode 100644 framework/src/main/resources/mapper/SysMenuMapper.xml delete mode 100644 framework/src/main/resources/mapper/SysRoleMapper.xml delete mode 100644 framework/src/main/resources/mapper/SysUserMapper.xml diff --git a/README.md b/README.md index 9119e796..f195714a 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ ```sh ├── application ├── business - │ ├── sample + │ ├── example ├── common │ ├── core │ ├── plugin @@ -84,7 +84,7 @@ ```sh application # 项目启动入口,包含项目配置文件 business # 业务模块 - business/sample # 业务模块示例,包含用于模拟测试的 Controller、Service 等,可丢弃 + business/example # 业务模块示例,包含用于模拟测试的 Controller、Service 等,可丢弃 common # 通用模块 common/core # 通用核心模块,包含公共注解、常量、异常、工具类、抽象模板等 common/plugin # 通用插件模块,用于抽离各种组件、第三方库 diff --git a/application/src/main/resources/application-prod.yml b/application/src/main/resources/application-prod.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/application/src/main/resources/application-test.yml b/application/src/main/resources/application-test.yml deleted file mode 100644 index e69de29b..00000000 diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 0f34da91..a9990522 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -16,8 +16,7 @@ ../common ../framework - ../application - ../business + ../example diff --git a/business/sample/pom.xml b/example/example_api/pom.xml similarity index 59% rename from business/sample/pom.xml rename to example/example_api/pom.xml index dd218dff..aad69ee1 100644 --- a/business/sample/pom.xml +++ b/example/example_api/pom.xml @@ -4,17 +4,23 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> com.github.cadecode - uni-boot-business + uni-boot-example 2023.1.0 4.0.0 - uni-boot-business-sample + uni-boot-example-api + 微服务样例模块-API + + net.dreamlu + mica-auto + provided + com.github.cadecode - uni-boot-framework + uni-boot-framework-api diff --git a/example/example_svc/pom.xml b/example/example_svc/pom.xml new file mode 100644 index 00000000..26cb3862 --- /dev/null +++ b/example/example_svc/pom.xml @@ -0,0 +1,42 @@ + + + + com.github.cadecode + uni-boot-example + 2023.1.0 + + 4.0.0 + + uni-boot-example-svc + 微服务样例模块-SERVICE + + + + com.github.cadecode + uni-boot-example-api + + + com.github.cadecode + uni-boot-common-plugin-actuator + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.github.ulisesbocchio + jasypt-spring-boot-starter + + + diff --git a/application/src/main/java/com/github/cadecode/application/UniBootApplication.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/UniExampleApplication.java similarity index 72% rename from application/src/main/java/com/github/cadecode/application/UniBootApplication.java rename to example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/UniExampleApplication.java index b2f3d993..b407bb8a 100644 --- a/application/src/main/java/com/github/cadecode/application/UniBootApplication.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/UniExampleApplication.java @@ -1,4 +1,4 @@ -package com.github.cadecode.application; +package com.github.cadecode.uniboot.example.svc; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; @@ -13,14 +13,14 @@ @MapperScan("com.github.cadecode.**.mapper") @EnableAspectJAutoProxy(exposeProxy = true) @SpringBootApplication -public class UniBootApplication extends SpringBootServletInitializer { +public class UniExampleApplication extends SpringBootServletInitializer { public static void main(String[] args) { - SpringApplication.run(UniBootApplication.class, args); + SpringApplication.run(UniExampleApplication.class, args); } @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(UniBootApplication.class); + return application.sources(UniExampleApplication.class); } } diff --git a/business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/DLCacheController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DLCacheController.java similarity index 93% rename from business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/DLCacheController.java rename to example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DLCacheController.java index 7b13a068..07e21a0e 100644 --- a/business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/DLCacheController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DLCacheController.java @@ -1,7 +1,7 @@ -package com.github.cadecode.uniboot.business.sample.controller; +package com.github.cadecode.uniboot.example.svc.controller; import com.github.cadecode.uniboot.common.plugin.cache.consts.CacheConst; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/DynamicDsController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicDsController.java similarity index 91% rename from business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/DynamicDsController.java rename to example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicDsController.java index 850b1b54..68966dcd 100644 --- a/business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/DynamicDsController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicDsController.java @@ -1,7 +1,7 @@ -package com.github.cadecode.uniboot.business.sample.controller; +package com.github.cadecode.uniboot.example.svc.controller; import com.baomidou.dynamic.datasource.annotation.DS; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/DynamicTpController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicTpController.java similarity index 88% rename from business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/DynamicTpController.java rename to example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicTpController.java index 68e90a8d..543a50ec 100644 --- a/business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/DynamicTpController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicTpController.java @@ -1,6 +1,6 @@ -package com.github.cadecode.uniboot.business.sample.controller; +package com.github.cadecode.uniboot.example.svc.controller; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/SpringRetryController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/SpringRetryController.java similarity index 96% rename from business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/SpringRetryController.java rename to example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/SpringRetryController.java index dec63b1d..f84c2853 100644 --- a/business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/SpringRetryController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/SpringRetryController.java @@ -1,6 +1,6 @@ -package com.github.cadecode.uniboot.business.sample.controller; +package com.github.cadecode.uniboot.example.svc.controller; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/TtlExecutorController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/TtlExecutorController.java similarity index 94% rename from business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/TtlExecutorController.java rename to example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/TtlExecutorController.java index 8059b11f..c93e93af 100644 --- a/business/sample/src/main/java/com/github/cadecode/uniboot/business/sample/controller/TtlExecutorController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/TtlExecutorController.java @@ -1,8 +1,8 @@ -package com.github.cadecode.uniboot.business.sample.controller; +package com.github.cadecode.uniboot.example.svc.controller; import com.alibaba.ttl.TransmittableThreadLocal; import com.alibaba.ttl.threadpool.TtlExecutors; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/example/example_svc/src/main/resources/application-dev.yml b/example/example_svc/src/main/resources/application-dev.yml new file mode 100644 index 00000000..5cf0dbec --- /dev/null +++ b/example/example_svc/src/main/resources/application-dev.yml @@ -0,0 +1,56 @@ +server: + port: 8010 +spring: + redis: + host: localhost + port: 6379 + password: ENC(jIiKGruIMgDkKx5wj2gJRCROqPutkTvZ) + database: 0 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + dynamic: + primary: master + datasource: + master: + url: jdbc:p6spy:mysql://localhost:3306/demo?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: root + password: ENC(donQ3DazAc4/6B+NFSRdxw==) + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + slave1: + url: jdbc:p6spy:mysql://localhost:3306/demo_cluster?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: root + password: ENC(donQ3DazAc4/6B+NFSRdxw==) + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + +# 关闭 swagger 认证 +knife4j: + basic: + enable: false + +# uni-boot 配置 +uni-boot: + config: + name: ${spring.application.name} + version: 1.0.0 + swagger-on: true + dynamic-ds-on: false + file-base-path: D:/uniboot/file/temp/ + swagger: + title: Swagger 在线文档 + description: uni-boot-admin 在线文档 by swagger2 + name: Cade Li + url: https://github.com/cadecode/uni-boot-admin + email: cadecode@foxmail.com + version: ${uni-boot.config.version} + module: + all: com.github.cadecode.uniboot.framework + security: + auth-model: redis + token: + header: token + expiration: 86400 + secret: 12345678123456781234567812345678 + ignore-urls: /auth/login,/demo/**,/common/download** + cache: + dl: + allow-null-values: true diff --git a/application/src/main/resources/application.yml b/example/example_svc/src/main/resources/application.yml similarity index 97% rename from application/src/main/resources/application.yml rename to example/example_svc/src/main/resources/application.yml index d0a770f4..9626eaea 100644 --- a/application/src/main/resources/application.yml +++ b/example/example_svc/src/main/resources/application.yml @@ -6,7 +6,7 @@ spring: profiles: active: @profileActive@ application: - name: uni-boot-admin + name: uni-example lifecycle: timeout-per-shutdown-phase: 60s jackson: @@ -101,7 +101,7 @@ knife4j: # log config logging: file: - path: /log/uni_boot_admin + path: /log/uni_example # actuator management: diff --git a/application/src/main/resources/banner.txt b/example/example_svc/src/main/resources/banner.txt similarity index 100% rename from application/src/main/resources/banner.txt rename to example/example_svc/src/main/resources/banner.txt diff --git a/application/src/main/resources/logback-spring.xml b/example/example_svc/src/main/resources/logback-spring.xml similarity index 100% rename from application/src/main/resources/logback-spring.xml rename to example/example_svc/src/main/resources/logback-spring.xml diff --git a/application/src/main/resources/spy.properties b/example/example_svc/src/main/resources/spy.properties similarity index 100% rename from application/src/main/resources/spy.properties rename to example/example_svc/src/main/resources/spy.properties diff --git a/application/src/test/java/com/github/cadecode/uniboot/ApplicationTests.java b/example/example_svc/src/test/java/com/github/cadecode/uniboot/example/svc/UniExampleApplicationTests.java similarity index 71% rename from application/src/test/java/com/github/cadecode/uniboot/ApplicationTests.java rename to example/example_svc/src/test/java/com/github/cadecode/uniboot/example/svc/UniExampleApplicationTests.java index fdb1703f..28aa4899 100644 --- a/application/src/test/java/com/github/cadecode/uniboot/ApplicationTests.java +++ b/example/example_svc/src/test/java/com/github/cadecode/uniboot/example/svc/UniExampleApplicationTests.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot; +package com.github.cadecode.uniboot.example.svc; import org.junit.jupiter.api.Test; @@ -11,7 +11,7 @@ * @date 2022/5/8 */ @SpringBootTest -public class ApplicationTests { +public class UniExampleApplicationTests { @Test void contextLoads() { diff --git a/business/pom.xml b/example/pom.xml similarity index 65% rename from business/pom.xml rename to example/pom.xml index 001d9287..c3a82fed 100644 --- a/business/pom.xml +++ b/example/pom.xml @@ -11,18 +11,12 @@ 4.0.0 pom - uni-boot-business - 业务模块 + uni-boot-example + 微服务样例模块 - sample + example_api + example_svc - - - com.github.cadecode - uni-boot-framework - - - diff --git a/framework/framework_api/pom.xml b/framework/framework_api/pom.xml new file mode 100644 index 00000000..91885232 --- /dev/null +++ b/framework/framework_api/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + + com.github.cadecode + uni-boot-framework + 2023.1.0 + + + uni-boot-framework-api + + + + net.dreamlu + mica-auto + provided + + + com.github.cadecode + uni-boot-common-core + + + com.github.cadecode + uni-boot-common-plugin-swagger + + + com.github.cadecode + uni-boot-common-plugin-log + + + com.github.cadecode + uni-boot-common-plugin-mybatis + + + com.github.cadecode + uni-boot-common-plugin-datasource + + + com.github.cadecode + uni-boot-common-plugin-cache + + + com.github.cadecode + uni-boot-common-plugin-concurrent + + + + cn.hutool + hutool-http + + + diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/advisor/ApiExceptionAdvisor.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiExceptionAdvisor.java similarity index 90% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/advisor/ApiExceptionAdvisor.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiExceptionAdvisor.java index 7429b43a..b0682833 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/advisor/ApiExceptionAdvisor.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiExceptionAdvisor.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.advisor; +package com.github.cadecode.uniboot.framework.api.advisor; import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.enums.FrameErrorEnum; +import com.github.cadecode.uniboot.framework.api.enums.FrameErrorEnum; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/advisor/ApiResultAdvisor.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiResultAdvisor.java similarity index 94% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/advisor/ApiResultAdvisor.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiResultAdvisor.java index 476c1aa6..916f07b1 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/advisor/ApiResultAdvisor.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiResultAdvisor.java @@ -1,11 +1,11 @@ -package com.github.cadecode.uniboot.framework.advisor; +package com.github.cadecode.uniboot.framework.api.advisor; import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.enums.FrameErrorEnum; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.enums.FrameErrorEnum; import org.springframework.core.MethodParameter; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/advisor/FrameExceptionAdvisor.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/FrameExceptionAdvisor.java similarity index 96% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/advisor/FrameExceptionAdvisor.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/FrameExceptionAdvisor.java index 3958e58e..bd637f2d 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/advisor/FrameExceptionAdvisor.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/FrameExceptionAdvisor.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.advisor; +package com.github.cadecode.uniboot.framework.api.advisor; import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.concurrent.exception.RateLimitException; -import com.github.cadecode.uniboot.framework.enums.FrameErrorEnum; +import com.github.cadecode.uniboot.framework.api.enums.FrameErrorEnum; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.TypeMismatchException; import org.springframework.core.Ordered; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/annotation/ApiFormat.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/annotation/ApiFormat.java similarity index 81% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/annotation/ApiFormat.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/annotation/ApiFormat.java index 6cb19697..a10d1356 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/annotation/ApiFormat.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/annotation/ApiFormat.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.annotation; +package com.github.cadecode.uniboot.framework.api.annotation; import java.lang.annotation.*; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/dto/SysLogDto.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java similarity index 94% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/dto/SysLogDto.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java index 212a1985..d94675e7 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/dto/SysLogDto.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.bean.dto; +package com.github.cadecode.uniboot.framework.api.bean.dto; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; import lombok.AllArgsConstructor; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/dto/SysUserDto.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java similarity index 93% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/dto/SysUserDto.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java index d6c76441..927fe838 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/dto/SysUserDto.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java @@ -1,7 +1,7 @@ -package com.github.cadecode.uniboot.framework.bean.dto; +package com.github.cadecode.uniboot.framework.api.bean.dto; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.github.cadecode.uniboot.framework.bean.vo.SysMenuVo.SysMenuTreeVo; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysApi.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysApi.java similarity index 93% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysApi.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysApi.java index f6628baf..df1dd4e0 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysApi.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysApi.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.bean.po; +package com.github.cadecode.uniboot.framework.api.bean.po; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.IdType; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysDict.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysDict.java similarity index 95% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysDict.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysDict.java index 4c923a44..ac267b0c 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysDict.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysDict.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.bean.po; +package com.github.cadecode.uniboot.framework.api.bean.po; import com.baomidou.mybatisplus.annotation.*; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysLog.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysLog.java similarity index 96% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysLog.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysLog.java index 418a1d8d..f259f5d8 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysLog.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysLog.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.bean.po; +package com.github.cadecode.uniboot.framework.api.bean.po; import com.baomidou.mybatisplus.annotation.*; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysMenu.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysMenu.java similarity index 96% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysMenu.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysMenu.java index 72419e6a..fe343afb 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysMenu.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysMenu.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.bean.po; +package com.github.cadecode.uniboot.framework.api.bean.po; import com.baomidou.mybatisplus.annotation.*; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysRole.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysRole.java similarity index 94% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysRole.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysRole.java index 7f4b7a3a..9b6da23f 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysRole.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysRole.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.bean.po; +package com.github.cadecode.uniboot.framework.api.bean.po; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.IdType; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysUser.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysUser.java similarity index 95% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysUser.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysUser.java index 2be0d2f3..8f7a9d47 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/po/SysUser.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysUser.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.bean.po; +package com.github.cadecode.uniboot.framework.api.bean.po; import com.baomidou.mybatisplus.annotation.*; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysApiVo.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysApiVo.java similarity index 92% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysApiVo.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysApiVo.java index aabd5aaa..96e6b7a3 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysApiVo.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysApiVo.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.bean.vo; +package com.github.cadecode.uniboot.framework.api.bean.vo; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysDictVo.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysDictVo.java similarity index 94% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysDictVo.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysDictVo.java index 799b708d..2c910c09 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysDictVo.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysDictVo.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.bean.vo; +package com.github.cadecode.uniboot.framework.api.bean.vo; import lombok.Data; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysLogVo.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysLogVo.java similarity index 94% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysLogVo.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysLogVo.java index 9e575ea0..f362652a 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysLogVo.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysLogVo.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.bean.vo; +package com.github.cadecode.uniboot.framework.api.bean.vo; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; import lombok.Data; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysMenuVo.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysMenuVo.java similarity index 94% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysMenuVo.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysMenuVo.java index 03321116..10050cdd 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysMenuVo.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysMenuVo.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.bean.vo; +package com.github.cadecode.uniboot.framework.api.bean.vo; import lombok.Data; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysRoleVo.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysRoleVo.java similarity index 93% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysRoleVo.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysRoleVo.java index 6d4d3787..e867b9a0 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysRoleVo.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysRoleVo.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.bean.vo; +package com.github.cadecode.uniboot.framework.api.bean.vo; import lombok.Data; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysUserVo.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysUserVo.java similarity index 92% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysUserVo.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysUserVo.java index 5d57b9b4..43cca980 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/bean/vo/SysUserVo.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysUserVo.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.bean.vo; +package com.github.cadecode.uniboot.framework.api.bean.vo; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/JacksonConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/JacksonConfig.java similarity index 93% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/config/JacksonConfig.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/JacksonConfig.java index a6baca8b..2056c448 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/JacksonConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/JacksonConfig.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.config; +package com.github.cadecode.uniboot.framework.api.config; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/PluginConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/PluginConfig.java similarity index 87% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/config/PluginConfig.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/PluginConfig.java index 78c382e9..6dfdb5a1 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/PluginConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/PluginConfig.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.config; +package com.github.cadecode.uniboot.framework.api.config; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyService; import org.springframework.context.annotation.Configuration; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/RetryConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/RetryConfig.java similarity index 93% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/config/RetryConfig.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/RetryConfig.java index 1f82976b..ad3b9553 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/RetryConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/RetryConfig.java @@ -1,6 +1,6 @@ -package com.github.cadecode.uniboot.framework.config; +package com.github.cadecode.uniboot.framework.api.config; -import com.github.cadecode.uniboot.framework.exception.RetryableException; +import com.github.cadecode.uniboot.framework.api.exception.RetryableException; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/SecurityConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java similarity index 94% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/config/SecurityConfig.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java index 46c81719..89535e75 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/SecurityConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java @@ -1,12 +1,12 @@ -package com.github.cadecode.uniboot.framework.config; +package com.github.cadecode.uniboot.framework.api.config; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ArrayUtil; -import com.github.cadecode.uniboot.framework.config.SecurityConfig.SecurityProperties; -import com.github.cadecode.uniboot.framework.enums.AuthModelEnum; -import com.github.cadecode.uniboot.framework.security.filter.TokenAuthFilter; -import com.github.cadecode.uniboot.framework.security.handler.*; -import com.github.cadecode.uniboot.framework.security.voter.DataBaseRoleVoter; +import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; +import com.github.cadecode.uniboot.framework.api.security.filter.TokenAuthFilter; +import com.github.cadecode.uniboot.framework.api.security.handler.*; +import com.github.cadecode.uniboot.framework.api.security.voter.DataBaseRoleVoter; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/ThreadPoolConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/ThreadPoolConfig.java similarity index 99% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/config/ThreadPoolConfig.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/ThreadPoolConfig.java index df9101ad..76a62c04 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/ThreadPoolConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/ThreadPoolConfig.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.config; +package com.github.cadecode.uniboot.framework.api.config; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/UniBootConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/UniBootConfig.java similarity index 94% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/config/UniBootConfig.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/UniBootConfig.java index 7f79df0c..7a2b4add 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/UniBootConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/UniBootConfig.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.config; +package com.github.cadecode.uniboot.framework.api.config; import lombok.Data; import lombok.RequiredArgsConstructor; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/WebMvcConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/WebMvcConfig.java similarity index 91% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/config/WebMvcConfig.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/WebMvcConfig.java index 5918072d..1d521733 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/config/WebMvcConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/WebMvcConfig.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.config; +package com.github.cadecode.uniboot.framework.api.config; import com.github.cadecode.uniboot.common.core.web.convertor.ParamEnumConvertorFactory; import org.springframework.context.annotation.Configuration; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/consts/KeyPrefix.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/KeyPrefix.java similarity index 83% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/consts/KeyPrefix.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/KeyPrefix.java index 7674df0b..0541a9a0 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/consts/KeyPrefix.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/KeyPrefix.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.consts; +package com.github.cadecode.uniboot.framework.api.consts; /** * Redis key 命名前缀 diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysApiConvert.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysApiConvert.java similarity index 51% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysApiConvert.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysApiConvert.java index 7703f210..cf5db9ea 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysApiConvert.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysApiConvert.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.convert; +package com.github.cadecode.uniboot.framework.api.convert; -import com.github.cadecode.uniboot.framework.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.request.SysApiRequest.SysApiAddRequest; -import com.github.cadecode.uniboot.framework.request.SysApiRequest.SysApiUpdateRequest; +import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; +import com.github.cadecode.uniboot.framework.api.request.SysApiRequest.SysApiAddRequest; +import com.github.cadecode.uniboot.framework.api.request.SysApiRequest.SysApiUpdateRequest; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysDictConvert.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysDictConvert.java similarity index 50% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysDictConvert.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysDictConvert.java index e8313028..2a246b3a 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysDictConvert.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysDictConvert.java @@ -1,11 +1,11 @@ -package com.github.cadecode.uniboot.framework.convert; - -import com.github.cadecode.uniboot.framework.bean.po.SysDict; -import com.github.cadecode.uniboot.framework.bean.vo.SysDictVo.SysDictGetByTypeVo; -import com.github.cadecode.uniboot.framework.bean.vo.SysDictVo.SysDictPageVo; -import com.github.cadecode.uniboot.framework.bean.vo.SysDictVo.SysDictSuggestVo; -import com.github.cadecode.uniboot.framework.request.SysDictRequest.SysDictAddRequest; -import com.github.cadecode.uniboot.framework.request.SysDictRequest.SysDictUpdateRequest; +package com.github.cadecode.uniboot.framework.api.convert; + +import com.github.cadecode.uniboot.framework.api.bean.po.SysDict; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysDictVo.SysDictGetByTypeVo; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysDictVo.SysDictPageVo; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysDictVo.SysDictSuggestVo; +import com.github.cadecode.uniboot.framework.api.request.SysDictRequest.SysDictAddRequest; +import com.github.cadecode.uniboot.framework.api.request.SysDictRequest.SysDictUpdateRequest; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysLogConvert.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java similarity index 56% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysLogConvert.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java index 71eaf947..bb233bb6 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysLogConvert.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java @@ -1,8 +1,8 @@ -package com.github.cadecode.uniboot.framework.convert; +package com.github.cadecode.uniboot.framework.api.convert; -import com.github.cadecode.uniboot.framework.bean.dto.SysLogDto.SysLogInfoDto; -import com.github.cadecode.uniboot.framework.bean.po.SysLog; -import com.github.cadecode.uniboot.framework.bean.vo.SysLogVo.SysLogPageVo; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogInfoDto; +import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysLogVo.SysLogPageVo; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysMenuConvert.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysMenuConvert.java similarity index 51% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysMenuConvert.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysMenuConvert.java index ece6adef..d1499d77 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysMenuConvert.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysMenuConvert.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.convert; +package com.github.cadecode.uniboot.framework.api.convert; -import com.github.cadecode.uniboot.framework.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.bean.vo.SysMenuVo.SysMenuTreeVo; -import com.github.cadecode.uniboot.framework.request.SysMenuRequest.SysMenuAddRequest; -import com.github.cadecode.uniboot.framework.request.SysMenuRequest.SysMenuUpdateRequest; +import com.github.cadecode.uniboot.framework.api.bean.po.SysMenu; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; +import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest.SysMenuAddRequest; +import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest.SysMenuUpdateRequest; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysRoleConvert.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysRoleConvert.java similarity index 55% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysRoleConvert.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysRoleConvert.java index 15f90f0d..db7e38dd 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysRoleConvert.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysRoleConvert.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.convert; +package com.github.cadecode.uniboot.framework.api.convert; -import com.github.cadecode.uniboot.framework.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.bean.vo.SysRoleVo.SysRoleListVo; -import com.github.cadecode.uniboot.framework.request.SysRoleRequest.SysRoleAddRequest; -import com.github.cadecode.uniboot.framework.request.SysRoleRequest.SysRoleUpdateRequest; +import com.github.cadecode.uniboot.framework.api.bean.po.SysRole; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysRoleVo.SysRoleListVo; +import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleAddRequest; +import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleUpdateRequest; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysUserConvert.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysUserConvert.java similarity index 50% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysUserConvert.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysUserConvert.java index c80e5a59..b129b91c 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/convert/SysUserConvert.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysUserConvert.java @@ -1,11 +1,11 @@ -package com.github.cadecode.uniboot.framework.convert; - -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.bean.vo.SysUserVo.SysUserRolesVo; -import com.github.cadecode.uniboot.framework.request.SysUserRequest.SysUserAddRequest; -import com.github.cadecode.uniboot.framework.request.SysUserRequest.SysUserModifyInfoRequest; -import com.github.cadecode.uniboot.framework.request.SysUserRequest.SysUserUpdateRequest; +package com.github.cadecode.uniboot.framework.api.convert; + +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; +import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserAddRequest; +import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserModifyInfoRequest; +import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserUpdateRequest; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/enums/AuthErrorEnum.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/AuthErrorEnum.java similarity index 96% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/enums/AuthErrorEnum.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/AuthErrorEnum.java index 74409903..6640e834 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/enums/AuthErrorEnum.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/AuthErrorEnum.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.enums; +package com.github.cadecode.uniboot.framework.api.enums; import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; import com.github.cadecode.uniboot.common.core.web.response.ApiStatus; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/enums/AuthModelEnum.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/AuthModelEnum.java similarity index 89% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/enums/AuthModelEnum.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/AuthModelEnum.java index eb5e2522..55dfca24 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/enums/AuthModelEnum.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/AuthModelEnum.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.enums; +package com.github.cadecode.uniboot.framework.api.enums; import com.github.cadecode.uniboot.common.core.enums.ExtTypeCode; import lombok.Getter; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/enums/FrameErrorEnum.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/FrameErrorEnum.java similarity index 96% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/enums/FrameErrorEnum.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/FrameErrorEnum.java index 7077aca4..174b33cb 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/enums/FrameErrorEnum.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/FrameErrorEnum.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.enums; +package com.github.cadecode.uniboot.framework.api.enums; import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; import com.github.cadecode.uniboot.common.core.web.response.ApiStatus; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/exception/RetryableException.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/exception/RetryableException.java similarity index 95% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/exception/RetryableException.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/exception/RetryableException.java index 00372aa4..f1a97dbc 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/exception/RetryableException.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/exception/RetryableException.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.exception; +package com.github.cadecode.uniboot.framework.api.exception; import lombok.Getter; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysApiMapper.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysApiMapper.java similarity index 61% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysApiMapper.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysApiMapper.java index a7987aa8..22368f7c 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysApiMapper.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysApiMapper.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.mapper; +package com.github.cadecode.uniboot.framework.api.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.cadecode.uniboot.framework.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.request.SysApiRequest.SysApiRolesRequest; +import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; +import com.github.cadecode.uniboot.framework.api.request.SysApiRequest.SysApiRolesRequest; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysDictMapper.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysDictMapper.java similarity index 66% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysDictMapper.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysDictMapper.java index 6e7cbaa3..1594660e 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysDictMapper.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysDictMapper.java @@ -1,7 +1,7 @@ -package com.github.cadecode.uniboot.framework.mapper; +package com.github.cadecode.uniboot.framework.api.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.cadecode.uniboot.framework.bean.po.SysDict; +import com.github.cadecode.uniboot.framework.api.bean.po.SysDict; import org.apache.ibatis.annotations.Mapper; /** diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysLogMapper.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysLogMapper.java similarity index 66% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysLogMapper.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysLogMapper.java index 2e28c60a..bef3e7a6 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysLogMapper.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysLogMapper.java @@ -1,7 +1,7 @@ -package com.github.cadecode.uniboot.framework.mapper; +package com.github.cadecode.uniboot.framework.api.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.cadecode.uniboot.framework.bean.po.SysLog; +import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; import org.apache.ibatis.annotations.Mapper; /** diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysMenuMapper.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysMenuMapper.java similarity index 65% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysMenuMapper.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysMenuMapper.java index 46476d71..b479c079 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysMenuMapper.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysMenuMapper.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.mapper; +package com.github.cadecode.uniboot.framework.api.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.cadecode.uniboot.framework.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.bean.vo.SysMenuVo.SysMenuRolesVo; -import com.github.cadecode.uniboot.framework.request.SysMenuRequest.SysMenuRolesRequest; +import com.github.cadecode.uniboot.framework.api.bean.po.SysMenu; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuRolesVo; +import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest.SysMenuRolesRequest; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysRoleMapper.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysRoleMapper.java similarity index 79% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysRoleMapper.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysRoleMapper.java index 933e0c1d..04e0db7a 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysRoleMapper.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysRoleMapper.java @@ -1,10 +1,10 @@ -package com.github.cadecode.uniboot.framework.mapper; +package com.github.cadecode.uniboot.framework.api.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.cadecode.uniboot.framework.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.bean.vo.SysRoleVo.SysRoleUnionVo; -import com.github.cadecode.uniboot.framework.request.SysRoleRequest.SysRoleMappingRequest; -import com.github.cadecode.uniboot.framework.request.SysRoleRequest.SysRoleUnionRequest; +import com.github.cadecode.uniboot.framework.api.bean.po.SysRole; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysRoleVo.SysRoleUnionVo; +import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleMappingRequest; +import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleUnionRequest; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysUserMapper.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysUserMapper.java similarity index 65% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysUserMapper.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysUserMapper.java index 0a4a9349..efe83fa8 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/mapper/SysUserMapper.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysUserMapper.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.mapper; +package com.github.cadecode.uniboot.framework.api.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.cadecode.uniboot.framework.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.bean.vo.SysUserVo.SysUserRolesVo; -import com.github.cadecode.uniboot.framework.request.SysUserRequest.SysUserRolesRequest; +import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; +import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserRolesRequest; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/plugin/ApiLogHandler.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java similarity index 89% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/plugin/ApiLogHandler.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java index cb326c01..e2c86684 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/plugin/ApiLogHandler.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.plugin; +package com.github.cadecode.uniboot.framework.api.plugin; import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.util.ObjectUtil; @@ -9,11 +9,11 @@ import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.aspect.ApiLoggerAspect.BaseLogInfo; import com.github.cadecode.uniboot.common.plugin.log.handler.AbstractApiLogHandler; -import com.github.cadecode.uniboot.framework.bean.dto.SysLogDto.SysLogInfoDto; -import com.github.cadecode.uniboot.framework.bean.po.SysLog; -import com.github.cadecode.uniboot.framework.convert.SysLogConvert; -import com.github.cadecode.uniboot.framework.service.SysLogService; -import com.github.cadecode.uniboot.framework.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogInfoDto; +import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; +import com.github.cadecode.uniboot.framework.api.convert.SysLogConvert; +import com.github.cadecode.uniboot.framework.api.service.SysLogService; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/plugin/ObjectFillHandler.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ObjectFillHandler.java similarity index 79% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/plugin/ObjectFillHandler.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ObjectFillHandler.java index ece015ca..66919cc2 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/plugin/ObjectFillHandler.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ObjectFillHandler.java @@ -1,7 +1,7 @@ -package com.github.cadecode.uniboot.framework.plugin; +package com.github.cadecode.uniboot.framework.api.plugin; import com.github.cadecode.uniboot.common.plugin.mybatis.handler.AbstractObjectFillHandler; -import com.github.cadecode.uniboot.framework.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import org.apache.ibatis.reflection.MetaObject; import org.springframework.stereotype.Component; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysApiRequest.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysApiRequest.java similarity index 92% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysApiRequest.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysApiRequest.java index 5b0d6549..b1df34b5 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysApiRequest.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysApiRequest.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.request; +package com.github.cadecode.uniboot.framework.api.request; import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysDictRequest.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysDictRequest.java similarity index 95% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysDictRequest.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysDictRequest.java index d1c3496e..97fd3af0 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysDictRequest.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysDictRequest.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.request; +package com.github.cadecode.uniboot.framework.api.request; import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysLogRequest.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysLogRequest.java similarity index 91% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysLogRequest.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysLogRequest.java index d0b350b1..cb005cca 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysLogRequest.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysLogRequest.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.request; +package com.github.cadecode.uniboot.framework.api.request; import com.github.cadecode.uniboot.common.core.web.response.PageParams; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysMenuRequest.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysMenuRequest.java similarity index 96% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysMenuRequest.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysMenuRequest.java index c286e986..fd264795 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysMenuRequest.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysMenuRequest.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.request; +package com.github.cadecode.uniboot.framework.api.request; import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysRoleRequest.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysRoleRequest.java similarity index 94% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysRoleRequest.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysRoleRequest.java index c49c1238..dc01e59f 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysRoleRequest.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysRoleRequest.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.request; +package com.github.cadecode.uniboot.framework.api.request; import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysUserRequest.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysUserRequest.java similarity index 97% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysUserRequest.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysUserRequest.java index d5b576a9..fbced1e5 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/request/SysUserRequest.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysUserRequest.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.request; +package com.github.cadecode.uniboot.framework.api.request; import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/filter/JwtTokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java similarity index 88% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/security/filter/JwtTokenAuthFilterService.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java index cc3752b6..b73f23fe 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/filter/JwtTokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java @@ -1,13 +1,13 @@ -package com.github.cadecode.uniboot.framework.security.filter; +package com.github.cadecode.uniboot.framework.api.security.filter; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.core.util.TokenUtil; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.enums.AuthErrorEnum; -import com.github.cadecode.uniboot.framework.enums.AuthModelEnum; -import com.github.cadecode.uniboot.framework.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; +import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/filter/RedisTokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java similarity index 80% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/security/filter/RedisTokenAuthFilterService.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java index c200d56e..348d1bd1 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/filter/RedisTokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java @@ -1,15 +1,15 @@ -package com.github.cadecode.uniboot.framework.security.filter; +package com.github.cadecode.uniboot.framework.api.security.filter; import cn.hutool.core.util.StrUtil; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; import com.github.cadecode.uniboot.common.plugin.cache.util.RedisUtil; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.enums.AuthErrorEnum; -import com.github.cadecode.uniboot.framework.enums.AuthModelEnum; -import com.github.cadecode.uniboot.framework.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; +import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/filter/TokenAuthFilter.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilter.java similarity index 87% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/security/filter/TokenAuthFilter.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilter.java index 8a4c49a3..88303292 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/filter/TokenAuthFilter.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilter.java @@ -1,7 +1,7 @@ -package com.github.cadecode.uniboot.framework.security.filter; +package com.github.cadecode.uniboot.framework.api.security.filter; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyExecutor; -import com.github.cadecode.uniboot.framework.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/filter/TokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java similarity index 97% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/security/filter/TokenAuthFilterService.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java index eb6cd971..b223751d 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/filter/TokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.security.filter; +package com.github.cadecode.uniboot.framework.api.security.filter; import cn.hutool.core.util.CharsetUtil; import cn.hutool.extra.servlet.ServletUtil; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/JwtLoginSuccessHandleService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/JwtLoginSuccessHandleService.java similarity index 77% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/JwtLoginSuccessHandleService.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/JwtLoginSuccessHandleService.java index 39cf691a..555b27be 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/JwtLoginSuccessHandleService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/JwtLoginSuccessHandleService.java @@ -1,13 +1,13 @@ -package com.github.cadecode.uniboot.framework.security.handler; +package com.github.cadecode.uniboot.framework.api.security.handler; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.core.util.TokenUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.config.SecurityConfig; -import com.github.cadecode.uniboot.framework.enums.AuthModelEnum; -import com.github.cadecode.uniboot.framework.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.config.SecurityConfig; +import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Component; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/LoginFailureHandler.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginFailureHandler.java similarity index 88% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/LoginFailureHandler.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginFailureHandler.java index 2795d2d8..22466c63 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/LoginFailureHandler.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginFailureHandler.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.security.handler; +package com.github.cadecode.uniboot.framework.api.security.handler; import cn.hutool.core.util.CharsetUtil; import cn.hutool.extra.servlet.ServletUtil; @@ -6,8 +6,8 @@ import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.config.SecurityConfig; -import com.github.cadecode.uniboot.framework.enums.AuthErrorEnum; +import com.github.cadecode.uniboot.framework.api.config.SecurityConfig; +import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.AuthenticationFailureHandler; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/LoginSuccessHandleService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginSuccessHandleService.java similarity index 79% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/LoginSuccessHandleService.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginSuccessHandleService.java index d129fe81..e7855207 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/LoginSuccessHandleService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginSuccessHandleService.java @@ -1,8 +1,8 @@ -package com.github.cadecode.uniboot.framework.security.handler; +package com.github.cadecode.uniboot.framework.api.security.handler; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyService; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import org.springframework.security.core.Authentication; import javax.servlet.http.HttpServletRequest; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/LoginSuccessHandler.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginSuccessHandler.java similarity index 83% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/LoginSuccessHandler.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginSuccessHandler.java index 7dc81446..e5025cc7 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/LoginSuccessHandler.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginSuccessHandler.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.security.handler; +package com.github.cadecode.uniboot.framework.api.security.handler; import cn.hutool.core.net.NetUtil; import cn.hutool.core.util.CharsetUtil; @@ -7,11 +7,11 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyExecutor; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.config.SecurityConfig.SecurityProperties; -import com.github.cadecode.uniboot.framework.service.SysUserService; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; +import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.api.service.SysUserService; import lombok.RequiredArgsConstructor; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.AuthenticationSuccessHandler; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/NoAuthenticationHandler.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/NoAuthenticationHandler.java similarity index 89% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/NoAuthenticationHandler.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/NoAuthenticationHandler.java index 7be4102a..9b6e9422 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/NoAuthenticationHandler.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/NoAuthenticationHandler.java @@ -1,11 +1,11 @@ -package com.github.cadecode.uniboot.framework.security.handler; +package com.github.cadecode.uniboot.framework.api.security.handler; import cn.hutool.core.util.CharsetUtil; import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.http.ContentType; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.enums.AuthErrorEnum; +import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.stereotype.Component; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/NoAuthorityHandler.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/NoAuthorityHandler.java similarity index 89% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/NoAuthorityHandler.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/NoAuthorityHandler.java index 918e9996..7f0bedae 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/NoAuthorityHandler.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/NoAuthorityHandler.java @@ -1,11 +1,11 @@ -package com.github.cadecode.uniboot.framework.security.handler; +package com.github.cadecode.uniboot.framework.api.security.handler; import cn.hutool.core.util.CharsetUtil; import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.http.ContentType; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.enums.AuthErrorEnum; +import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.web.access.AccessDeniedHandler; import org.springframework.stereotype.Component; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/RedisLoginSuccessHandleService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/RedisLoginSuccessHandleService.java similarity index 76% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/RedisLoginSuccessHandleService.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/RedisLoginSuccessHandleService.java index 1d6c29fd..27cb6957 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/RedisLoginSuccessHandleService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/RedisLoginSuccessHandleService.java @@ -1,15 +1,15 @@ -package com.github.cadecode.uniboot.framework.security.handler; +package com.github.cadecode.uniboot.framework.api.security.handler; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; import com.github.cadecode.uniboot.common.plugin.cache.util.RedisUtil; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.config.SecurityConfig; -import com.github.cadecode.uniboot.framework.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.enums.AuthModelEnum; -import com.github.cadecode.uniboot.framework.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.config.SecurityConfig; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Component; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/SignOutSuccessHandler.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/SignOutSuccessHandler.java similarity index 78% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/SignOutSuccessHandler.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/SignOutSuccessHandler.java index 81037766..9d33ea4e 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/handler/SignOutSuccessHandler.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/SignOutSuccessHandler.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.security.handler; +package com.github.cadecode.uniboot.framework.api.security.handler; import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.StrUtil; @@ -8,12 +8,12 @@ import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; import com.github.cadecode.uniboot.common.plugin.cache.util.RedisUtil; -import com.github.cadecode.uniboot.framework.config.SecurityConfig; -import com.github.cadecode.uniboot.framework.config.SecurityConfig.SecurityProperties; -import com.github.cadecode.uniboot.framework.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.enums.AuthErrorEnum; -import com.github.cadecode.uniboot.framework.enums.AuthModelEnum; -import com.github.cadecode.uniboot.framework.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.api.config.SecurityConfig; +import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; +import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import lombok.RequiredArgsConstructor; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/voter/DataBaseRoleVoter.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java similarity index 89% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/security/voter/DataBaseRoleVoter.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java index 7198780d..520c163f 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/security/voter/DataBaseRoleVoter.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java @@ -1,10 +1,10 @@ -package com.github.cadecode.uniboot.framework.security.voter; +package com.github.cadecode.uniboot.framework.api.security.voter; import cn.hutool.core.util.ObjectUtil; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto; -import com.github.cadecode.uniboot.framework.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.service.SysApiService; -import com.github.cadecode.uniboot.framework.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; +import com.github.cadecode.uniboot.framework.api.service.SysApiService; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import lombok.RequiredArgsConstructor; import org.springframework.security.access.ConfigAttribute; import org.springframework.security.access.vote.RoleVoter; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysApiService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysApiService.java similarity index 62% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysApiService.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysApiService.java index efe02fd1..e0b7ac10 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysApiService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysApiService.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.service; +package com.github.cadecode.uniboot.framework.api.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.github.cadecode.uniboot.framework.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.request.SysApiRequest.SysApiRolesRequest; +import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; +import com.github.cadecode.uniboot.framework.api.request.SysApiRequest.SysApiRolesRequest; import com.github.pagehelper.PageInfo; import java.util.List; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysDictService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysDictService.java similarity index 61% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysDictService.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysDictService.java index 9920fcc2..0d7ad19f 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysDictService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysDictService.java @@ -1,7 +1,7 @@ -package com.github.cadecode.uniboot.framework.service; +package com.github.cadecode.uniboot.framework.api.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.github.cadecode.uniboot.framework.bean.po.SysDict; +import com.github.cadecode.uniboot.framework.api.bean.po.SysDict; /** * 系统字典服务 diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysLogService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysLogService.java similarity index 61% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysLogService.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysLogService.java index cd22a890..10760bab 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysLogService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysLogService.java @@ -1,7 +1,7 @@ -package com.github.cadecode.uniboot.framework.service; +package com.github.cadecode.uniboot.framework.api.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.github.cadecode.uniboot.framework.bean.po.SysLog; +import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; /** * 系统日志服务 diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysMenuService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysMenuService.java similarity index 60% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysMenuService.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysMenuService.java index bd73d3b5..7f0c9b82 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysMenuService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysMenuService.java @@ -1,10 +1,10 @@ -package com.github.cadecode.uniboot.framework.service; +package com.github.cadecode.uniboot.framework.api.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.github.cadecode.uniboot.framework.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.bean.vo.SysMenuVo.SysMenuRolesVo; -import com.github.cadecode.uniboot.framework.bean.vo.SysMenuVo.SysMenuTreeVo; -import com.github.cadecode.uniboot.framework.request.SysMenuRequest.SysMenuRolesRequest; +import com.github.cadecode.uniboot.framework.api.bean.po.SysMenu; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuRolesVo; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; +import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest.SysMenuRolesRequest; import com.github.pagehelper.PageInfo; import java.util.List; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysRoleService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysRoleService.java similarity index 76% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysRoleService.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysRoleService.java index 97199363..e07833e0 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysRoleService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysRoleService.java @@ -1,10 +1,10 @@ -package com.github.cadecode.uniboot.framework.service; +package com.github.cadecode.uniboot.framework.api.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.github.cadecode.uniboot.framework.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.bean.vo.SysRoleVo.SysRoleUnionVo; -import com.github.cadecode.uniboot.framework.request.SysRoleRequest.SysRoleMappingRequest; -import com.github.cadecode.uniboot.framework.request.SysRoleRequest.SysRoleUnionRequest; +import com.github.cadecode.uniboot.framework.api.bean.po.SysRole; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysRoleVo.SysRoleUnionVo; +import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleMappingRequest; +import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleUnionRequest; import com.github.pagehelper.PageInfo; import java.util.List; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysUserService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysUserService.java similarity index 65% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysUserService.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysUserService.java index 04cb9962..0fbd2bc7 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/service/SysUserService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysUserService.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.service; +package com.github.cadecode.uniboot.framework.api.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.github.cadecode.uniboot.framework.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.bean.vo.SysUserVo.SysUserRolesVo; -import com.github.cadecode.uniboot.framework.request.SysUserRequest.SysUserRolesRequest; +import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; +import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserRolesRequest; import com.github.pagehelper.PageInfo; import org.springframework.security.core.userdetails.UserDetailsService; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysApiServiceImpl.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysApiServiceImpl.java similarity index 71% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysApiServiceImpl.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysApiServiceImpl.java index 718509a4..49e8bea0 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysApiServiceImpl.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysApiServiceImpl.java @@ -1,12 +1,12 @@ -package com.github.cadecode.uniboot.framework.serviceimpl; +package com.github.cadecode.uniboot.framework.api.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.cadecode.uniboot.framework.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.mapper.SysApiMapper; -import com.github.cadecode.uniboot.framework.request.SysApiRequest.SysApiRolesRequest; -import com.github.cadecode.uniboot.framework.service.SysApiService; +import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.mapper.SysApiMapper; +import com.github.cadecode.uniboot.framework.api.request.SysApiRequest.SysApiRolesRequest; +import com.github.cadecode.uniboot.framework.api.service.SysApiService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.RequiredArgsConstructor; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysDictServiceImpl.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysDictServiceImpl.java similarity index 53% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysDictServiceImpl.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysDictServiceImpl.java index 72a82816..a6f0bc3a 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysDictServiceImpl.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysDictServiceImpl.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.serviceimpl; +package com.github.cadecode.uniboot.framework.api.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.cadecode.uniboot.framework.bean.po.SysDict; -import com.github.cadecode.uniboot.framework.mapper.SysDictMapper; -import com.github.cadecode.uniboot.framework.service.SysDictService; +import com.github.cadecode.uniboot.framework.api.bean.po.SysDict; +import com.github.cadecode.uniboot.framework.api.mapper.SysDictMapper; +import com.github.cadecode.uniboot.framework.api.service.SysDictService; import org.springframework.stereotype.Service; /** diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysLogServiceImpl.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysLogServiceImpl.java similarity index 53% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysLogServiceImpl.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysLogServiceImpl.java index f3a0802e..2b01b644 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysLogServiceImpl.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysLogServiceImpl.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.serviceimpl; +package com.github.cadecode.uniboot.framework.api.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.cadecode.uniboot.framework.bean.po.SysLog; -import com.github.cadecode.uniboot.framework.mapper.SysLogMapper; -import com.github.cadecode.uniboot.framework.service.SysLogService; +import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; +import com.github.cadecode.uniboot.framework.api.mapper.SysLogMapper; +import com.github.cadecode.uniboot.framework.api.service.SysLogService; import org.springframework.stereotype.Service; /** diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysMenuServiceImpl.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysMenuServiceImpl.java similarity index 81% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysMenuServiceImpl.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysMenuServiceImpl.java index dc399691..96021eed 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysMenuServiceImpl.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysMenuServiceImpl.java @@ -1,14 +1,14 @@ -package com.github.cadecode.uniboot.framework.serviceimpl; +package com.github.cadecode.uniboot.framework.api.serviceimpl; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.cadecode.uniboot.framework.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.bean.vo.SysMenuVo.SysMenuRolesVo; -import com.github.cadecode.uniboot.framework.bean.vo.SysMenuVo.SysMenuTreeVo; -import com.github.cadecode.uniboot.framework.convert.SysMenuConvert; -import com.github.cadecode.uniboot.framework.mapper.SysMenuMapper; -import com.github.cadecode.uniboot.framework.request.SysMenuRequest.SysMenuRolesRequest; -import com.github.cadecode.uniboot.framework.service.SysMenuService; +import com.github.cadecode.uniboot.framework.api.bean.po.SysMenu; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuRolesVo; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; +import com.github.cadecode.uniboot.framework.api.convert.SysMenuConvert; +import com.github.cadecode.uniboot.framework.api.mapper.SysMenuMapper; +import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest.SysMenuRolesRequest; +import com.github.cadecode.uniboot.framework.api.service.SysMenuService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.RequiredArgsConstructor; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysRoleServiceImpl.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysRoleServiceImpl.java similarity index 85% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysRoleServiceImpl.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysRoleServiceImpl.java index 5341b83c..9b2b642c 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysRoleServiceImpl.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysRoleServiceImpl.java @@ -1,13 +1,13 @@ -package com.github.cadecode.uniboot.framework.serviceimpl; +package com.github.cadecode.uniboot.framework.api.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.cadecode.uniboot.framework.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.bean.vo.SysRoleVo.SysRoleUnionVo; -import com.github.cadecode.uniboot.framework.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.mapper.SysRoleMapper; -import com.github.cadecode.uniboot.framework.request.SysRoleRequest.SysRoleMappingRequest; -import com.github.cadecode.uniboot.framework.request.SysRoleRequest.SysRoleUnionRequest; -import com.github.cadecode.uniboot.framework.service.SysRoleService; +import com.github.cadecode.uniboot.framework.api.bean.po.SysRole; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysRoleVo.SysRoleUnionVo; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.mapper.SysRoleMapper; +import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleMappingRequest; +import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleUnionRequest; +import com.github.cadecode.uniboot.framework.api.service.SysRoleService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.RequiredArgsConstructor; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysUserServiceImpl.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysUserServiceImpl.java similarity index 78% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysUserServiceImpl.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysUserServiceImpl.java index 9f354f91..314a7249 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/serviceimpl/SysUserServiceImpl.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysUserServiceImpl.java @@ -1,14 +1,14 @@ -package com.github.cadecode.uniboot.framework.serviceimpl; +package com.github.cadecode.uniboot.framework.api.serviceimpl; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.cadecode.uniboot.common.core.exception.ApiException; -import com.github.cadecode.uniboot.framework.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.bean.vo.SysUserVo.SysUserRolesVo; -import com.github.cadecode.uniboot.framework.convert.SysUserConvert; -import com.github.cadecode.uniboot.framework.mapper.SysUserMapper; -import com.github.cadecode.uniboot.framework.request.SysUserRequest.SysUserRolesRequest; -import com.github.cadecode.uniboot.framework.service.SysUserService; +import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; +import com.github.cadecode.uniboot.framework.api.convert.SysUserConvert; +import com.github.cadecode.uniboot.framework.api.mapper.SysUserMapper; +import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserRolesRequest; +import com.github.cadecode.uniboot.framework.api.service.SysUserService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.RequiredArgsConstructor; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/util/SecurityUtil.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java similarity index 93% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/util/SecurityUtil.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java index a77fe3dc..06411926 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/util/SecurityUtil.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.util; +package com.github.cadecode.uniboot.framework.api.util; import cn.hutool.core.lang.UUID; import cn.hutool.core.util.ObjectUtil; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.InitializingBean; import org.springframework.security.core.Authentication; diff --git a/application/pom.xml b/framework/framework_svc/pom.xml similarity index 54% rename from application/pom.xml rename to framework/framework_svc/pom.xml index 61d87b11..1437f77d 100644 --- a/application/pom.xml +++ b/framework/framework_svc/pom.xml @@ -2,30 +2,24 @@ + 4.0.0 - uni-boot-dependencies com.github.cadecode + uni-boot-framework 2023.1.0 - ../dependencies/pom.xml - 4.0.0 - uni-boot-application - 启动器模块 + uni-boot-framework-svc com.github.cadecode - uni-boot-framework + uni-boot-framework-api com.github.cadecode uni-boot-common-plugin-actuator - - com.github.cadecode - uni-boot-business-sample - org.springframework.boot @@ -45,24 +39,4 @@ - - - - org.springframework.boot - spring-boot-maven-plugin - 2.5.2 - - true - true - - - org.projectlombok - lombok - - - - - - - diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/UniFrameworkApplication.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/UniFrameworkApplication.java new file mode 100644 index 00000000..69c07936 --- /dev/null +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/UniFrameworkApplication.java @@ -0,0 +1,26 @@ +package com.github.cadecode.uniboot.framework.svc; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.context.annotation.EnableAspectJAutoProxy; + +/** + * 启动类 + */ +@MapperScan("com.github.cadecode.**.mapper") +@EnableAspectJAutoProxy(exposeProxy = true) +@SpringBootApplication +public class UniFrameworkApplication extends SpringBootServletInitializer { + + public static void main(String[] args) { + SpringApplication.run(UniFrameworkApplication.class, args); + } + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(UniFrameworkApplication.class); + } +} diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/AuthController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java similarity index 90% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/controller/AuthController.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java index 24211dc7..9cb0af69 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/AuthController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.controller; +package com.github.cadecode.uniboot.framework.svc.controller; import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpUtil; @@ -6,9 +6,9 @@ import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.config.SecurityConfig; -import com.github.cadecode.uniboot.framework.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.config.SecurityConfig; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/CommonController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/CommonController.java similarity index 92% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/controller/CommonController.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/CommonController.java index 6f6a8c39..161d2f61 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/CommonController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/CommonController.java @@ -1,12 +1,12 @@ -package com.github.cadecode.uniboot.framework.controller; +package com.github.cadecode.uniboot.framework.svc.controller; import cn.hutool.core.io.FileUtil; import cn.hutool.extra.servlet.ServletUtil; import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.common.core.util.AssertUtil; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.enums.FrameErrorEnum; -import com.github.cadecode.uniboot.framework.util.FileUploadUtil; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.enums.FrameErrorEnum; +import com.github.cadecode.uniboot.framework.svc.util.FileUploadUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysApiController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java similarity index 81% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysApiController.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java index 20c77775..45d53a3f 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysApiController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java @@ -1,15 +1,16 @@ -package com.github.cadecode.uniboot.framework.controller; +package com.github.cadecode.uniboot.framework.svc.controller; import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.bean.vo.SysApiVo.SysApiSwaggerVo; -import com.github.cadecode.uniboot.framework.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.convert.SysApiConvert; -import com.github.cadecode.uniboot.framework.service.SysApiService; -import com.github.cadecode.uniboot.framework.service.SysRoleService; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiSwaggerVo; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.convert.SysApiConvert; +import com.github.cadecode.uniboot.framework.api.request.SysApiRequest; +import com.github.cadecode.uniboot.framework.api.service.SysApiService; +import com.github.cadecode.uniboot.framework.api.service.SysRoleService; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -34,8 +35,6 @@ import java.util.Map; import java.util.stream.Collectors; -import static com.github.cadecode.uniboot.framework.request.SysApiRequest.*; - /** * API 管理 * @@ -61,7 +60,7 @@ public class SysApiController { @ApiOperation("查询API列表(带角色)") @PostMapping("page_roles_vo") - public PageResult pageRolesVo(@RequestBody @Valid SysApiRolesRequest request) { + public PageResult pageRolesVo(@RequestBody @Valid SysApiRequest.SysApiRolesRequest request) { PageInfo rolesVoPage = sysApiService.pageRolesVo(request); return new PageResult<>((int) rolesVoPage.getTotal(), rolesVoPage.getList()); } @@ -69,7 +68,7 @@ public PageResult pageRolesVo(@RequestBody @Valid SysApiRolesRequ @CacheEvict(cacheNames = KeyPrefix.API_ROLES, key = "'all'") @ApiOperation("更新API") @PostMapping("update") - public boolean update(@RequestBody @Valid SysApiUpdateRequest request) { + public boolean update(@RequestBody @Valid SysApiRequest.SysApiUpdateRequest request) { SysApi po = SysApiConvert.INSTANCE.requestToPo(request); return sysApiService.updateById(po); } @@ -77,7 +76,7 @@ public boolean update(@RequestBody @Valid SysApiUpdateRequest request) { @CacheEvict(cacheNames = KeyPrefix.API_ROLES, key = "'all'") @ApiOperation("添加API") @PostMapping("add") - public boolean add(@RequestBody @Valid SysApiAddRequest request) { + public boolean add(@RequestBody @Valid SysApiRequest.SysApiAddRequest request) { SysApi sysApi = SysApiConvert.INSTANCE.requestToPo(request); return sysApiService.save(sysApi); } diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysDictController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java similarity index 76% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysDictController.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java index 17b21df0..d4259452 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysDictController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java @@ -1,17 +1,15 @@ -package com.github.cadecode.uniboot.framework.controller; +package com.github.cadecode.uniboot.framework.svc.controller; import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.bean.po.SysDict; -import com.github.cadecode.uniboot.framework.bean.vo.SysDictVo.SysDictGetByTypeVo; -import com.github.cadecode.uniboot.framework.bean.vo.SysDictVo.SysDictPageVo; -import com.github.cadecode.uniboot.framework.bean.vo.SysDictVo.SysDictSuggestVo; -import com.github.cadecode.uniboot.framework.convert.SysDictConvert; -import com.github.cadecode.uniboot.framework.request.SysDictRequest.SysDictAddRequest; -import com.github.cadecode.uniboot.framework.request.SysDictRequest.SysDictPageRequest; -import com.github.cadecode.uniboot.framework.request.SysDictRequest.SysDictUpdateRequest; -import com.github.cadecode.uniboot.framework.service.SysDictService; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.bean.po.SysDict; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysDictVo.SysDictGetByTypeVo; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysDictVo.SysDictPageVo; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysDictVo.SysDictSuggestVo; +import com.github.cadecode.uniboot.framework.api.convert.SysDictConvert; +import com.github.cadecode.uniboot.framework.api.request.SysDictRequest; +import com.github.cadecode.uniboot.framework.api.service.SysDictService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; @@ -46,7 +44,7 @@ public class SysDictController { @ApiOperation("查询列表") @PostMapping("page") - public PageResult page(@RequestBody @Valid SysDictPageRequest request) { + public PageResult page(@RequestBody @Valid SysDictRequest.SysDictPageRequest request) { PageInfo pageInfo = PageHelper.startPage(request.getPageNumber(), request.getPageSize()) .doSelectPageInfo(() -> sysDictService.lambdaQuery() .likeRight(ObjectUtil.isNotEmpty(request.getName()), SysDict::getName, request.getName()) @@ -59,14 +57,14 @@ public PageResult page(@RequestBody @Valid SysDictPageRequest req @ApiOperation("添加") @PostMapping("add") - public boolean add(@RequestBody @Valid SysDictAddRequest request) { + public boolean add(@RequestBody @Valid SysDictRequest.SysDictAddRequest request) { SysDict po = SysDictConvert.INSTANCE.requestToPo(request); return sysDictService.save(po); } @ApiOperation("更新") @PostMapping("update") - public boolean update(@RequestBody @Valid SysDictUpdateRequest request) { + public boolean update(@RequestBody @Valid SysDictRequest.SysDictUpdateRequest request) { SysDict po = SysDictConvert.INSTANCE.requestToPo(request); return sysDictService.updateById(po); } diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysLogController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java similarity index 82% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysLogController.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java index 6b86ccce..f03073cd 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysLogController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java @@ -1,14 +1,14 @@ -package com.github.cadecode.uniboot.framework.controller; +package com.github.cadecode.uniboot.framework.svc.controller; import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.bean.po.SysLog; -import com.github.cadecode.uniboot.framework.bean.vo.SysLogVo.SysLogPageVo; -import com.github.cadecode.uniboot.framework.convert.SysLogConvert; -import com.github.cadecode.uniboot.framework.request.SysLogRequest.SysLogPageRequest; -import com.github.cadecode.uniboot.framework.service.SysLogService; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysLogVo.SysLogPageVo; +import com.github.cadecode.uniboot.framework.api.convert.SysLogConvert; +import com.github.cadecode.uniboot.framework.api.request.SysLogRequest; +import com.github.cadecode.uniboot.framework.api.service.SysLogService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; @@ -44,7 +44,7 @@ public class SysLogController { @ApiOperation("查询列表") @PostMapping("page") - public PageResult page(@RequestBody @Valid SysLogPageRequest request) { + public PageResult page(@RequestBody @Valid SysLogRequest.SysLogPageRequest request) { PageInfo pageInfo = PageHelper.startPage(request.getPageNumber(), request.getPageSize()) .doSelectPageInfo(() -> logService.lambdaQuery() .ge(ObjectUtil.isNotEmpty(request.getStartTime()), SysLog::getCreateTime, request.getStartTime()) diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysMenuController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java similarity index 79% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysMenuController.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java index 2c2850e0..fb54cc58 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysMenuController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java @@ -1,12 +1,13 @@ -package com.github.cadecode.uniboot.framework.controller; +package com.github.cadecode.uniboot.framework.svc.controller; import com.github.cadecode.uniboot.common.core.web.response.PageResult; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.bean.vo.SysMenuVo.SysMenuRolesVo; -import com.github.cadecode.uniboot.framework.convert.SysMenuConvert; -import com.github.cadecode.uniboot.framework.service.SysMenuService; -import com.github.cadecode.uniboot.framework.service.SysRoleService; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.bean.po.SysMenu; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuRolesVo; +import com.github.cadecode.uniboot.framework.api.convert.SysMenuConvert; +import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest; +import com.github.cadecode.uniboot.framework.api.service.SysMenuService; +import com.github.cadecode.uniboot.framework.api.service.SysRoleService; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -25,8 +26,6 @@ import java.util.List; import java.util.stream.Collectors; -import static com.github.cadecode.uniboot.framework.request.SysMenuRequest.*; - /** * 菜单管理API * @@ -47,14 +46,14 @@ public class SysMenuController { @ApiOperation("查询菜单列表(带角色)") @PostMapping("page_roles_vo") - public PageResult pageRolesVo(@RequestBody @Valid SysMenuRolesRequest request) { + public PageResult pageRolesVo(@RequestBody @Valid SysMenuRequest.SysMenuRolesRequest request) { PageInfo rolesVoPage = sysMenuService.pageRolesVo(request); return new PageResult<>((int) rolesVoPage.getTotal(), rolesVoPage.getList()); } @ApiOperation("更新菜单启用状态") @PostMapping("update_enable") - public boolean updateEnable(@RequestBody @Valid SysMenuUpdateEnableRequest request) { + public boolean updateEnable(@RequestBody @Valid SysMenuRequest.SysMenuUpdateEnableRequest request) { return sysMenuService.updateById(SysMenu.builder() .id(request.getId()) .enableFlag(request.getEnableFlag()) @@ -63,14 +62,14 @@ public boolean updateEnable(@RequestBody @Valid SysMenuUpdateEnableRequest reque @ApiOperation("更新菜单") @PostMapping("update") - public boolean update(@RequestBody @Valid SysMenuUpdateRequest request) { + public boolean update(@RequestBody @Valid SysMenuRequest.SysMenuUpdateRequest request) { SysMenu sysMenu = SysMenuConvert.INSTANCE.requestToPo(request); return sysMenuService.updateById(sysMenu); } @ApiOperation("添加菜单") @PostMapping("add") - public boolean add(@RequestBody @Valid SysMenuAddRequest request) { + public boolean add(@RequestBody @Valid SysMenuRequest.SysMenuAddRequest request) { SysMenu sysMenu = SysMenuConvert.INSTANCE.requestToPo(request); return sysMenuService.save(sysMenu); } diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysRoleController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java similarity index 84% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysRoleController.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java index dc7f43bb..ba97e92c 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysRoleController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java @@ -1,16 +1,15 @@ -package com.github.cadecode.uniboot.framework.controller; +package com.github.cadecode.uniboot.framework.svc.controller; import com.github.cadecode.uniboot.common.core.web.response.PageResult; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.bean.vo.SysRoleVo.SysRoleListVo; -import com.github.cadecode.uniboot.framework.bean.vo.SysRoleVo.SysRoleUnionVo; -import com.github.cadecode.uniboot.framework.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.convert.SysRoleConvert; -import com.github.cadecode.uniboot.framework.request.SysRoleRequest; -import com.github.cadecode.uniboot.framework.request.SysRoleRequest.SysRoleMappingRequest; -import com.github.cadecode.uniboot.framework.request.SysRoleRequest.SysRoleUnionRequest; -import com.github.cadecode.uniboot.framework.service.SysRoleService; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.bean.po.SysRole; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysRoleVo.SysRoleListVo; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysRoleVo.SysRoleUnionVo; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.convert.SysRoleConvert; +import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest; +import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleMappingRequest; +import com.github.cadecode.uniboot.framework.api.service.SysRoleService; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -90,7 +89,7 @@ public boolean removeApiMapping(@RequestBody @NotEmpty List pageUnionVo(@RequestBody @Valid SysRoleUnionRequest request) { + public PageResult pageUnionVo(@RequestBody @Valid SysRoleRequest.SysRoleUnionRequest request) { PageInfo page = sysRoleService.pageUnionVo(request); return new PageResult<>((int) page.getTotal(), page.getList()); } diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysUserController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java similarity index 77% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysUserController.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java index 26b3c509..f29d4752 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/controller/SysUserController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java @@ -1,19 +1,20 @@ -package com.github.cadecode.uniboot.framework.controller; +package com.github.cadecode.uniboot.framework.svc.controller; import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.common.core.web.response.PageResult; -import com.github.cadecode.uniboot.framework.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.bean.dto.SysUserDto.SysUserInfoDto; -import com.github.cadecode.uniboot.framework.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.bean.vo.SysMenuVo.SysMenuTreeVo; -import com.github.cadecode.uniboot.framework.bean.vo.SysUserVo.SysUserRolesVo; -import com.github.cadecode.uniboot.framework.convert.SysUserConvert; -import com.github.cadecode.uniboot.framework.service.SysMenuService; -import com.github.cadecode.uniboot.framework.service.SysRoleService; -import com.github.cadecode.uniboot.framework.service.SysUserService; -import com.github.cadecode.uniboot.framework.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserInfoDto; +import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; +import com.github.cadecode.uniboot.framework.api.convert.SysUserConvert; +import com.github.cadecode.uniboot.framework.api.request.SysUserRequest; +import com.github.cadecode.uniboot.framework.api.service.SysMenuService; +import com.github.cadecode.uniboot.framework.api.service.SysRoleService; +import com.github.cadecode.uniboot.framework.api.service.SysUserService; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -31,8 +32,6 @@ import javax.validation.constraints.NotEmpty; import java.util.List; -import static com.github.cadecode.uniboot.framework.request.SysUserRequest.*; - /** * 用户管理API * @@ -67,7 +66,7 @@ public SysUserInfoDto getInfo() { @ApiOperation("修改用户信息(用户中心)") @PostMapping("modify_info") - public boolean modifyInfo(@RequestBody @Valid SysUserModifyInfoRequest request) { + public boolean modifyInfo(@RequestBody @Valid SysUserRequest.SysUserModifyInfoRequest request) { SysUserDetailsDto userDetails = SecurityUtil.getUserDetails(null); SysUser po = SysUserConvert.INSTANCE.requestToPo(request); po.setId(userDetails.getId()); @@ -76,7 +75,7 @@ public boolean modifyInfo(@RequestBody @Valid SysUserModifyInfoRequest request) @ApiOperation("修改用户密码(用户中心)") @PostMapping("modify_pass") - public boolean modifyPass(@RequestBody @Valid SysUserModifyPassRequest request) { + public boolean modifyPass(@RequestBody @Valid SysUserRequest.SysUserModifyPassRequest request) { SysUserDetailsDto userDetails = SecurityUtil.getUserDetails(null); SysUser sysUser = sysUserService.lambdaQuery().select(SysUser::getPassword) .eq(SysUser::getId, userDetails.getId()).one(); @@ -98,14 +97,14 @@ public boolean modifyPass(@RequestBody @Valid SysUserModifyPassRequest request) @ApiOperation("查询用户列表(带角色)") @PostMapping("page_roles_vo") - public PageResult pageRolesVo(@RequestBody @Valid SysUserRolesRequest request) { + public PageResult pageRolesVo(@RequestBody @Valid SysUserRequest.SysUserRolesRequest request) { PageInfo rolesVoPage = sysUserService.pageRolesVo(request); return new PageResult<>((int) rolesVoPage.getTotal(), rolesVoPage.getList()); } @ApiOperation("更新用户启用状态") @PostMapping("update_enable") - public boolean updateEnable(@RequestBody @Valid SysUserUpdateEnableRequest request) { + public boolean updateEnable(@RequestBody @Valid SysUserRequest.SysUserUpdateEnableRequest request) { return sysUserService.updateById(SysUser.builder() .id(request.getId()) .enableFlag(request.getEnableFlag()) @@ -114,7 +113,7 @@ public boolean updateEnable(@RequestBody @Valid SysUserUpdateEnableRequest reque @ApiOperation("更新用户") @PostMapping("update") - public boolean update(@RequestBody @Valid SysUserUpdateRequest request) { + public boolean update(@RequestBody @Valid SysUserRequest.SysUserUpdateRequest request) { String encodePass = null; if (ObjectUtil.isNotEmpty(request.getPassword())) { encodePass = passwordEncoder.encode(request.getPassword()); @@ -126,7 +125,7 @@ public boolean update(@RequestBody @Valid SysUserUpdateRequest request) { @ApiOperation("添加用户") @PostMapping("add") - public boolean add(@RequestBody @Valid SysUserAddRequest request) { + public boolean add(@RequestBody @Valid SysUserRequest.SysUserAddRequest request) { if (ObjectUtil.isNotEmpty(request.getPassword())) { request.setPassword(passwordEncoder.encode(request.getPassword())); } diff --git a/framework/src/main/java/com/github/cadecode/uniboot/framework/util/FileUploadUtil.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/util/FileUploadUtil.java similarity index 95% rename from framework/src/main/java/com/github/cadecode/uniboot/framework/util/FileUploadUtil.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/util/FileUploadUtil.java index ae161988..5bf28414 100644 --- a/framework/src/main/java/com/github/cadecode/uniboot/framework/util/FileUploadUtil.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/util/FileUploadUtil.java @@ -1,10 +1,10 @@ -package com.github.cadecode.uniboot.framework.util; +package com.github.cadecode.uniboot.framework.svc.util; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.file.FileNameUtil; import cn.hutool.core.lang.UUID; import cn.hutool.core.util.StrUtil; -import com.github.cadecode.uniboot.framework.config.UniBootConfig; +import com.github.cadecode.uniboot.framework.api.config.UniBootConfig; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; diff --git a/application/src/main/resources/application-dev.yml b/framework/framework_svc/src/main/resources/application-dev.yml similarity index 88% rename from application/src/main/resources/application-dev.yml rename to framework/framework_svc/src/main/resources/application-dev.yml index 4bdaec35..2d1227a1 100644 --- a/application/src/main/resources/application-dev.yml +++ b/framework/framework_svc/src/main/resources/application-dev.yml @@ -1,8 +1,6 @@ server: port: 8000 spring: - application: - name: ${uni-boot.config.name} redis: host: localhost port: 6379 @@ -32,7 +30,7 @@ knife4j: # uni-boot 配置 uni-boot: config: - name: UniBootAdmin + name: ${spring.application.name} version: 1.0.0 swagger-on: true dynamic-ds-on: false @@ -45,8 +43,7 @@ uni-boot: email: cadecode@foxmail.com version: ${uni-boot.config.version} module: - framework: com.github.cadecode.uniboot.framework.controller - sample: com.github.cadecode.uniboot.business.sample.controller + all: com.github.cadecode.uniboot.framework security: auth-model: redis token: diff --git a/framework/framework_svc/src/main/resources/application.yml b/framework/framework_svc/src/main/resources/application.yml new file mode 100644 index 00000000..fecc3c59 --- /dev/null +++ b/framework/framework_svc/src/main/resources/application.yml @@ -0,0 +1,113 @@ +server: + shutdown: graceful + +# spring config +spring: + profiles: + active: @profileActive@ + application: + name: uni-framework + lifecycle: + timeout-per-shutdown-phase: 60s + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + boot: + admin: + client: + url: http://127.0.0.1:1111 + # redis 公共配置 + redis: + lettuce: + pool: + max-active: 8 + min-idle: 0 + max-idle: 8 + max-wait: -1 + # 数据源公共配置 + datasource: + druid: + initialSize: 5 + minIdle: 10 + maxActive: 20 + maxWait: 60000 + timeBetweenEvictionRunsMillis: 60000 + minEvictableIdleTimeMillis: 300000 + maxEvictableIdleTimeMillis: 900000 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + allow: + url-pattern: /druid/* + login-username: dev + login-password: dev123 + filter: + stat: + enabled: true + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + dynamic: + tp: + collectorTypes: logging + logPath: ${logging.file.path} + monitorInterval: 10 + executors: + - threadPoolName: asyncExecutor + thread-name-prefix: asyncExecutor- + corePoolSize: 6 + maximumPoolSize: 8 + queueCapacity: 1000 + queueType: VariableLinkedBlockingQueue + rejectedHandlerType: CallerRunsPolicy + keepAliveTime: 50 + waitForTasksToCompleteOnShutdown: true + awaitTerminationSeconds: 300 + notifyEnabled: false + +# pagehelper +pagehelper: + reasonable: true + supportMethodsArguments: true + params: count=countSql + auto-dialect: true + auto-runtime-dialect: true + page-size-zero: true + +# mybatis plus 配置 +mybatis-plus: + mapper-locations: classpath*:mapper/**/*.xml + type-aliases-package: com.github.cadecode.**.bean,com.github.cadecode.**.mybatis.converter + type-enums-package: com.github.cadecode.**.enums + configuration: + map-underscore-to-camel-case: true + +# swagger配置 +knife4j: + enable: true + basic: + enable: true + username: dev + password: dev123 + +# log config +logging: + file: + path: /log/uni_framework + +# actuator +management: + endpoints: + web: + exposure: + include: '*' + + diff --git a/framework/framework_svc/src/main/resources/banner.txt b/framework/framework_svc/src/main/resources/banner.txt new file mode 100644 index 00000000..0799272a --- /dev/null +++ b/framework/framework_svc/src/main/resources/banner.txt @@ -0,0 +1,8 @@ + _ _ _ _ ___ ___ ___ ___ _____ + | | | | | \| | |_ _| | _ ) / _ \ / _ \ |_ _| + | |_| | | .` | | | | _ \ | (_) | | (_) | | | + \___/ |_|\_| |___| |___/ \___/ \___/ _|_|_ +_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| +"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-' + :: Spring Boot :: (${spring-boot.version}) + :: ${uni-boot.config.name} :: (${uni-boot.config.version}) diff --git a/framework/framework_svc/src/main/resources/logback-spring.xml b/framework/framework_svc/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..812f6b4c --- /dev/null +++ b/framework/framework_svc/src/main/resources/logback-spring.xml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${consolePattern} + UTF-8 + + + + + + + ${filePath}/debug.now.log + + + + ${filePath}/debug/debug.%d{yyyy-MM-dd}.%i.log + + ${history} + + 10MB + + + + ${filePattern} + UTF-8 + + + + DEBUG + ACCEPT + DENY + + + + + + ${filePath}/info.now.log + + ${filePath}/info/info.%d{yyyy-MM-dd}.%i.log + ${history} + 10MB + + + ${filePattern} + UTF-8 + + + INFO + ACCEPT + DENY + + + + + + ${filePath}/error.now.log + + ${filePath}/error/error.%d{yyyy-MM-dd}.%i.log + ${history} + 10MB + + + ${filePattern} + UTF-8 + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/framework_svc/src/main/resources/spy.properties b/framework/framework_svc/src/main/resources/spy.properties new file mode 100644 index 00000000..5b485971 --- /dev/null +++ b/framework/framework_svc/src/main/resources/spy.properties @@ -0,0 +1,21 @@ +# 配置日志拦截模块 +# 加入 MybatisPlus 日志 +modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory +# 设置日志打印格式 +logMessageFormat=com.p6spy.engine.spy.appender.CustomLineFormat +customLogMessageFormat===> P6Spy: %(executionTime) ms, connection%(connectionId), sql: %(sqlSingleLine) +# 设置日志系统 +# 使用 SLF4J 即系统日志 +appender=com.p6spy.engine.spy.appender.Slf4JLogger +# 设置 p6spy driver 代理 +deregisterdrivers=true +# 取消 JDBC URL 前缀 +useprefix=true +# 设置要排除的日志记录 +excludecategories=info,debug,result,commit,resultset +# 设置日期格式 +dateformat=yyyy-MM-dd HH:mm:ss +# 开启慢 SQL 记录 +outagedetection=true +# 设置慢 SQL 记录标准 2 秒 +outagedetectioninterval=2 diff --git a/application/src/test/java/com/github/cadecode/uniboot/JasyptEncryptorTest.java b/framework/framework_svc/src/test/java/com/github/cadecode/uniboot/framework/svc/JasyptEncryptorTest.java similarity index 92% rename from application/src/test/java/com/github/cadecode/uniboot/JasyptEncryptorTest.java rename to framework/framework_svc/src/test/java/com/github/cadecode/uniboot/framework/svc/JasyptEncryptorTest.java index 3d92777e..e4fa4fec 100644 --- a/application/src/test/java/com/github/cadecode/uniboot/JasyptEncryptorTest.java +++ b/framework/framework_svc/src/test/java/com/github/cadecode/uniboot/framework/svc/JasyptEncryptorTest.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot; +package com.github.cadecode.uniboot.framework.svc; import org.jasypt.encryption.StringEncryptor; import org.junit.jupiter.api.Test; diff --git a/framework/framework_svc/src/test/java/com/github/cadecode/uniboot/framework/svc/UniFrameworkApplicationTests.java b/framework/framework_svc/src/test/java/com/github/cadecode/uniboot/framework/svc/UniFrameworkApplicationTests.java new file mode 100644 index 00000000..c42ce07d --- /dev/null +++ b/framework/framework_svc/src/test/java/com/github/cadecode/uniboot/framework/svc/UniFrameworkApplicationTests.java @@ -0,0 +1,20 @@ +package com.github.cadecode.uniboot.framework.svc; + + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +/** + * 主测试类 + * + * @author Cade Li + * @date 2022/5/8 + */ +@SpringBootTest +public class UniFrameworkApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/framework/pom.xml b/framework/pom.xml index 1e5c7dc6..1ca613d5 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -9,47 +9,13 @@ ../dependencies/pom.xml 4.0.0 + + pom uni-boot-framework 系统框架模块 - - - net.dreamlu - mica-auto - provided - - - com.github.cadecode - uni-boot-common-core - - - com.github.cadecode - uni-boot-common-plugin-swagger - - - com.github.cadecode - uni-boot-common-plugin-log - - - com.github.cadecode - uni-boot-common-plugin-mybatis - - - com.github.cadecode - uni-boot-common-plugin-datasource - - - com.github.cadecode - uni-boot-common-plugin-cache - - - com.github.cadecode - uni-boot-common-plugin-concurrent - - - - cn.hutool - hutool-http - - + + framework_api + framework_svc + diff --git a/framework/src/main/resources/mapper/SysApiMapper.xml b/framework/src/main/resources/mapper/SysApiMapper.xml deleted file mode 100644 index 6b663323..00000000 --- a/framework/src/main/resources/mapper/SysApiMapper.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/framework/src/main/resources/mapper/SysMenuMapper.xml b/framework/src/main/resources/mapper/SysMenuMapper.xml deleted file mode 100644 index 83244006..00000000 --- a/framework/src/main/resources/mapper/SysMenuMapper.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/framework/src/main/resources/mapper/SysRoleMapper.xml b/framework/src/main/resources/mapper/SysRoleMapper.xml deleted file mode 100644 index c411937b..00000000 --- a/framework/src/main/resources/mapper/SysRoleMapper.xml +++ /dev/null @@ -1,184 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - DELETE FROM sys_role_user ru - WHERE ru.user_id IN ( - - #{id} - - ) - - - DELETE FROM sys_role_user ru - WHERE ru.role_id IN ( - - #{id} - - ) - - - DELETE FROM sys_role_menu rm - WHERE rm.menu_id IN ( - - #{id} - - ) - - - DELETE FROM sys_role_menu rm - WHERE rm.role_id IN ( - - #{id} - - ) - - - DELETE FROM sys_role_api ra - WHERE ra.api_id IN ( - - #{id} - - ) - - - DELETE FROM sys_role_api ra - WHERE ra.role_id IN ( - - #{id} - - ) - - - DELETE FROM sys_role_user ru - WHERE (ru.user_id, ru.role_id) IN ( - - (#{el.id}, #{el.roleId}) - - ) - - - DELETE FROM sys_role_menu rm - WHERE (rm.menu_id, rm.role_id) IN ( - - (#{el.id}, #{el.roleId}) - - ) - - - DELETE FROM sys_role_api ra - WHERE (ra.api_id, ra.role_id) IN ( - - (#{el.id}, #{el.roleId}) - - ) - - - INSERT INTO sys_role_user (user_id, role_id) - VALUES - - (#{el.id}, #{el.roleId}) - - - - INSERT INTO sys_role_menu (menu_id, role_id) - VALUES - - (#{el.id}, #{el.roleId}) - - - - INSERT INTO sys_role_api (api_id, role_id) - VALUES - - (#{el.id}, #{el.roleId}) - - - - diff --git a/framework/src/main/resources/mapper/SysUserMapper.xml b/framework/src/main/resources/mapper/SysUserMapper.xml deleted file mode 100644 index 1b5ea0f8..00000000 --- a/framework/src/main/resources/mapper/SysUserMapper.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pom.xml b/pom.xml index 8902e542..bc32bc49 100644 --- a/pom.xml +++ b/pom.xml @@ -69,12 +69,12 @@ com.github.cadecode - uni-boot-framework + uni-boot-framework-api ${uni.version} com.github.cadecode - uni-boot-business-sample + uni-boot-example-api ${uni.version} From bfd0d6a69613856ca459f42582eadeda76bc356d Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 27 Jul 2023 16:32:38 +0800 Subject: [PATCH 002/244] =?UTF-8?q?build:=20=E5=BC=95=E5=85=A5=20cloud=20?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=AE=A1=E7=90=86=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=20nacos=20=E7=89=88=20dynamicTp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/plugin/concurrent/pom.xml | 2 +- dependencies/pom.xml | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/common/plugin/concurrent/pom.xml b/common/plugin/concurrent/pom.xml index f0e000ab..8665a655 100644 --- a/common/plugin/concurrent/pom.xml +++ b/common/plugin/concurrent/pom.xml @@ -24,7 +24,7 @@ org.dromara.dynamictp - dynamic-tp-core + dynamic-tp-spring-cloud-starter-nacos diff --git a/dependencies/pom.xml b/dependencies/pom.xml index a9990522..14a9c4ef 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -21,6 +21,8 @@ 2.5.4 + 2020.0.5 + 2021.1 1.18.24 1.4.2.Final 5.8.12 @@ -94,6 +96,22 @@ pom import + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + ${spring-cloud-alibaba.version} + pom + import + cn.hutool @@ -174,6 +192,11 @@ dynamic-tp-core ${dynamic-tp.version} + + org.dromara.dynamictp + dynamic-tp-spring-cloud-starter-nacos + ${dynamic-tp.version} + org.dromara.dynamictp From ac27c24a9c7a5588cceb1dce8e270e56dfc7afdd Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 27 Jul 2023 16:33:53 +0800 Subject: [PATCH 003/244] =?UTF-8?q?feat:=20=E5=BC=95=E5=85=A5=20nacos?= =?UTF-8?q?=E3=80=81openFeign?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/example_api/pom.xml | 10 ++ example/example_svc/pom.xml | 26 +++- .../example/svc/UniExampleApplication.java | 4 + .../src/main/resources/application-dev.yml | 56 --------- .../src/main/resources/application.yml | 113 ------------------ .../src/main/resources/bootstrap.yml | 24 ++++ .../src/main/resources/logback-spring.xml | 34 +++--- framework/framework_api/pom.xml | 10 ++ framework/framework_svc/pom.xml | 26 +++- .../svc/UniFrameworkApplication.java | 4 + .../src/main/resources/application-dev.yml | 56 --------- .../src/main/resources/application.yml | 113 ------------------ .../src/main/resources/bootstrap.yml | 24 ++++ .../src/main/resources/logback-spring.xml | 34 +++--- 14 files changed, 152 insertions(+), 382 deletions(-) delete mode 100644 example/example_svc/src/main/resources/application-dev.yml delete mode 100644 example/example_svc/src/main/resources/application.yml create mode 100644 example/example_svc/src/main/resources/bootstrap.yml delete mode 100644 framework/framework_svc/src/main/resources/application-dev.yml delete mode 100644 framework/framework_svc/src/main/resources/application.yml create mode 100644 framework/framework_svc/src/main/resources/bootstrap.yml diff --git a/example/example_api/pom.xml b/example/example_api/pom.xml index aad69ee1..24815132 100644 --- a/example/example_api/pom.xml +++ b/example/example_api/pom.xml @@ -18,6 +18,16 @@ mica-auto provided + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + com.github.cadecode uni-boot-framework-api diff --git a/example/example_svc/pom.xml b/example/example_svc/pom.xml index 26cb3862..85970d24 100644 --- a/example/example_svc/pom.xml +++ b/example/example_svc/pom.xml @@ -13,21 +13,26 @@ 微服务样例模块-SERVICE + - com.github.cadecode - uni-boot-example-api + org.springframework.cloud + spring-cloud-starter-bootstrap - com.github.cadecode - uni-boot-common-plugin-actuator + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery - + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + org.springframework.boot spring-boot-starter-tomcat provided - + org.springframework.boot spring-boot-starter-test @@ -38,5 +43,14 @@ com.github.ulisesbocchio jasypt-spring-boot-starter + + + com.github.cadecode + uni-boot-common-plugin-actuator + + + com.github.cadecode + uni-boot-example-api + diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/UniExampleApplication.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/UniExampleApplication.java index b407bb8a..d6d21327 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/UniExampleApplication.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/UniExampleApplication.java @@ -5,12 +5,16 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.EnableAspectJAutoProxy; /** * 启动类 */ @MapperScan("com.github.cadecode.**.mapper") +@EnableFeignClients("com.github.cadecode") +@EnableDiscoveryClient @EnableAspectJAutoProxy(exposeProxy = true) @SpringBootApplication public class UniExampleApplication extends SpringBootServletInitializer { diff --git a/example/example_svc/src/main/resources/application-dev.yml b/example/example_svc/src/main/resources/application-dev.yml deleted file mode 100644 index 5cf0dbec..00000000 --- a/example/example_svc/src/main/resources/application-dev.yml +++ /dev/null @@ -1,56 +0,0 @@ -server: - port: 8010 -spring: - redis: - host: localhost - port: 6379 - password: ENC(jIiKGruIMgDkKx5wj2gJRCROqPutkTvZ) - database: 0 - datasource: - type: com.alibaba.druid.pool.DruidDataSource - dynamic: - primary: master - datasource: - master: - url: jdbc:p6spy:mysql://localhost:3306/demo?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai - username: root - password: ENC(donQ3DazAc4/6B+NFSRdxw==) - driver-class-name: com.p6spy.engine.spy.P6SpyDriver - slave1: - url: jdbc:p6spy:mysql://localhost:3306/demo_cluster?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai - username: root - password: ENC(donQ3DazAc4/6B+NFSRdxw==) - driver-class-name: com.p6spy.engine.spy.P6SpyDriver - -# 关闭 swagger 认证 -knife4j: - basic: - enable: false - -# uni-boot 配置 -uni-boot: - config: - name: ${spring.application.name} - version: 1.0.0 - swagger-on: true - dynamic-ds-on: false - file-base-path: D:/uniboot/file/temp/ - swagger: - title: Swagger 在线文档 - description: uni-boot-admin 在线文档 by swagger2 - name: Cade Li - url: https://github.com/cadecode/uni-boot-admin - email: cadecode@foxmail.com - version: ${uni-boot.config.version} - module: - all: com.github.cadecode.uniboot.framework - security: - auth-model: redis - token: - header: token - expiration: 86400 - secret: 12345678123456781234567812345678 - ignore-urls: /auth/login,/demo/**,/common/download** - cache: - dl: - allow-null-values: true diff --git a/example/example_svc/src/main/resources/application.yml b/example/example_svc/src/main/resources/application.yml deleted file mode 100644 index 9626eaea..00000000 --- a/example/example_svc/src/main/resources/application.yml +++ /dev/null @@ -1,113 +0,0 @@ -server: - shutdown: graceful - -# spring config -spring: - profiles: - active: @profileActive@ - application: - name: uni-example - lifecycle: - timeout-per-shutdown-phase: 60s - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 - boot: - admin: - client: - url: http://127.0.0.1:1111 - # redis 公共配置 - redis: - lettuce: - pool: - max-active: 8 - min-idle: 0 - max-idle: 8 - max-wait: -1 - # 数据源公共配置 - datasource: - druid: - initialSize: 5 - minIdle: 10 - maxActive: 20 - maxWait: 60000 - timeBetweenEvictionRunsMillis: 60000 - minEvictableIdleTimeMillis: 300000 - maxEvictableIdleTimeMillis: 900000 - validationQuery: SELECT 1 FROM DUAL - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - webStatFilter: - enabled: true - statViewServlet: - enabled: true - allow: - url-pattern: /druid/* - login-username: dev - login-password: dev123 - filter: - stat: - enabled: true - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: false - wall: - config: - multi-statement-allow: true - dynamic: - tp: - collectorTypes: logging - logPath: ${logging.file.path} - monitorInterval: 10 - executors: - - threadPoolName: asyncExecutor - thread-name-prefix: asyncExecutor- - corePoolSize: 6 - maximumPoolSize: 8 - queueCapacity: 1000 - queueType: VariableLinkedBlockingQueue - rejectedHandlerType: CallerRunsPolicy - keepAliveTime: 50 - waitForTasksToCompleteOnShutdown: true - awaitTerminationSeconds: 300 - notifyEnabled: false - -# pagehelper -pagehelper: - reasonable: true - supportMethodsArguments: true - params: count=countSql - auto-dialect: true - auto-runtime-dialect: true - page-size-zero: true - -# mybatis plus 配置 -mybatis-plus: - mapper-locations: classpath*:mapper/**/*.xml - type-aliases-package: com.github.cadecode.**.bean,com.github.cadecode.**.mybatis.converter - type-enums-package: com.github.cadecode.**.enums - configuration: - map-underscore-to-camel-case: true - -# swagger配置 -knife4j: - enable: true - basic: - enable: true - username: dev - password: dev123 - -# log config -logging: - file: - path: /log/uni_example - -# actuator -management: - endpoints: - web: - exposure: - include: '*' - - diff --git a/example/example_svc/src/main/resources/bootstrap.yml b/example/example_svc/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..1e244639 --- /dev/null +++ b/example/example_svc/src/main/resources/bootstrap.yml @@ -0,0 +1,24 @@ +logging: + file: + path: /log/uni_boot_admin/example + +spring: + application: + name: uni-boot-example + cloud: + nacos: + server-addr: localhost:8848 + username: nacos + password: nacos + discovery: + enabled: true + namespace: uni_dev + group: DEFAULT_GROUP + config: + enabled: true + namespace: uni_dev + group: DEFAULT_GROUP + file-extension: yml + shared-configs: + - shared-config.${spring.cloud.nacos.config.file-extension} + - shared-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/example/example_svc/src/main/resources/logback-spring.xml b/example/example_svc/src/main/resources/logback-spring.xml index 812f6b4c..9b734e71 100644 --- a/example/example_svc/src/main/resources/logback-spring.xml +++ b/example/example_svc/src/main/resources/logback-spring.xml @@ -8,23 +8,25 @@ - + - + - + - - + + + value="%red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%-15thread]) %highlight(%-5level) %cyan(%-50logger{50}) : %msg%n"/> - + @@ -105,28 +107,28 @@ additivity 指定是否将 root 的 appender 加入到 logger 中,默认为 true --> - - + + - + - - + + - - - - + + + + diff --git a/framework/framework_api/pom.xml b/framework/framework_api/pom.xml index 91885232..3657ba3d 100644 --- a/framework/framework_api/pom.xml +++ b/framework/framework_api/pom.xml @@ -17,6 +17,16 @@ mica-auto provided + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + com.github.cadecode uni-boot-common-core diff --git a/framework/framework_svc/pom.xml b/framework/framework_svc/pom.xml index 1437f77d..67623ea2 100644 --- a/framework/framework_svc/pom.xml +++ b/framework/framework_svc/pom.xml @@ -12,21 +12,26 @@ uni-boot-framework-svc + - com.github.cadecode - uni-boot-framework-api + org.springframework.cloud + spring-cloud-starter-bootstrap - com.github.cadecode - uni-boot-common-plugin-actuator + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery - + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + org.springframework.boot spring-boot-starter-tomcat provided - + org.springframework.boot spring-boot-starter-test @@ -37,6 +42,15 @@ com.github.ulisesbocchio jasypt-spring-boot-starter + + + com.github.cadecode + uni-boot-framework-api + + + com.github.cadecode + uni-boot-common-plugin-actuator + diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/UniFrameworkApplication.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/UniFrameworkApplication.java index 69c07936..ac4b7e81 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/UniFrameworkApplication.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/UniFrameworkApplication.java @@ -5,12 +5,16 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.EnableAspectJAutoProxy; /** * 启动类 */ @MapperScan("com.github.cadecode.**.mapper") +@EnableFeignClients("com.github.cadecode") +@EnableDiscoveryClient @EnableAspectJAutoProxy(exposeProxy = true) @SpringBootApplication public class UniFrameworkApplication extends SpringBootServletInitializer { diff --git a/framework/framework_svc/src/main/resources/application-dev.yml b/framework/framework_svc/src/main/resources/application-dev.yml deleted file mode 100644 index 2d1227a1..00000000 --- a/framework/framework_svc/src/main/resources/application-dev.yml +++ /dev/null @@ -1,56 +0,0 @@ -server: - port: 8000 -spring: - redis: - host: localhost - port: 6379 - password: ENC(jIiKGruIMgDkKx5wj2gJRCROqPutkTvZ) - database: 0 - datasource: - type: com.alibaba.druid.pool.DruidDataSource - dynamic: - primary: master - datasource: - master: - url: jdbc:p6spy:mysql://localhost:3306/demo?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai - username: root - password: ENC(donQ3DazAc4/6B+NFSRdxw==) - driver-class-name: com.p6spy.engine.spy.P6SpyDriver - slave1: - url: jdbc:p6spy:mysql://localhost:3306/demo_cluster?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai - username: root - password: ENC(donQ3DazAc4/6B+NFSRdxw==) - driver-class-name: com.p6spy.engine.spy.P6SpyDriver - -# 关闭 swagger 认证 -knife4j: - basic: - enable: false - -# uni-boot 配置 -uni-boot: - config: - name: ${spring.application.name} - version: 1.0.0 - swagger-on: true - dynamic-ds-on: false - file-base-path: D:/uniboot/file/temp/ - swagger: - title: Swagger 在线文档 - description: uni-boot-admin 在线文档 by swagger2 - name: Cade Li - url: https://github.com/cadecode/uni-boot-admin - email: cadecode@foxmail.com - version: ${uni-boot.config.version} - module: - all: com.github.cadecode.uniboot.framework - security: - auth-model: redis - token: - header: token - expiration: 86400 - secret: 12345678123456781234567812345678 - ignore-urls: /auth/login,/demo/**,/common/download** - cache: - dl: - allow-null-values: true diff --git a/framework/framework_svc/src/main/resources/application.yml b/framework/framework_svc/src/main/resources/application.yml deleted file mode 100644 index fecc3c59..00000000 --- a/framework/framework_svc/src/main/resources/application.yml +++ /dev/null @@ -1,113 +0,0 @@ -server: - shutdown: graceful - -# spring config -spring: - profiles: - active: @profileActive@ - application: - name: uni-framework - lifecycle: - timeout-per-shutdown-phase: 60s - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 - boot: - admin: - client: - url: http://127.0.0.1:1111 - # redis 公共配置 - redis: - lettuce: - pool: - max-active: 8 - min-idle: 0 - max-idle: 8 - max-wait: -1 - # 数据源公共配置 - datasource: - druid: - initialSize: 5 - minIdle: 10 - maxActive: 20 - maxWait: 60000 - timeBetweenEvictionRunsMillis: 60000 - minEvictableIdleTimeMillis: 300000 - maxEvictableIdleTimeMillis: 900000 - validationQuery: SELECT 1 FROM DUAL - testWhileIdle: true - testOnBorrow: false - testOnReturn: false - webStatFilter: - enabled: true - statViewServlet: - enabled: true - allow: - url-pattern: /druid/* - login-username: dev - login-password: dev123 - filter: - stat: - enabled: true - log-slow-sql: true - slow-sql-millis: 1000 - merge-sql: false - wall: - config: - multi-statement-allow: true - dynamic: - tp: - collectorTypes: logging - logPath: ${logging.file.path} - monitorInterval: 10 - executors: - - threadPoolName: asyncExecutor - thread-name-prefix: asyncExecutor- - corePoolSize: 6 - maximumPoolSize: 8 - queueCapacity: 1000 - queueType: VariableLinkedBlockingQueue - rejectedHandlerType: CallerRunsPolicy - keepAliveTime: 50 - waitForTasksToCompleteOnShutdown: true - awaitTerminationSeconds: 300 - notifyEnabled: false - -# pagehelper -pagehelper: - reasonable: true - supportMethodsArguments: true - params: count=countSql - auto-dialect: true - auto-runtime-dialect: true - page-size-zero: true - -# mybatis plus 配置 -mybatis-plus: - mapper-locations: classpath*:mapper/**/*.xml - type-aliases-package: com.github.cadecode.**.bean,com.github.cadecode.**.mybatis.converter - type-enums-package: com.github.cadecode.**.enums - configuration: - map-underscore-to-camel-case: true - -# swagger配置 -knife4j: - enable: true - basic: - enable: true - username: dev - password: dev123 - -# log config -logging: - file: - path: /log/uni_framework - -# actuator -management: - endpoints: - web: - exposure: - include: '*' - - diff --git a/framework/framework_svc/src/main/resources/bootstrap.yml b/framework/framework_svc/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..8840bf68 --- /dev/null +++ b/framework/framework_svc/src/main/resources/bootstrap.yml @@ -0,0 +1,24 @@ +logging: + file: + path: /log/uni_boot_admin/framework + +spring: + application: + name: uni-boot-framework + cloud: + nacos: + server-addr: localhost:8848 + username: nacos + password: nacos + discovery: + enabled: true + namespace: uni_dev + group: DEFAULT_GROUP + config: + enabled: true + namespace: uni_dev + group: DEFAULT_GROUP + file-extension: yml + shared-configs: + - shared-config.${spring.cloud.nacos.config.file-extension} + - shared-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/framework/framework_svc/src/main/resources/logback-spring.xml b/framework/framework_svc/src/main/resources/logback-spring.xml index 812f6b4c..9b734e71 100644 --- a/framework/framework_svc/src/main/resources/logback-spring.xml +++ b/framework/framework_svc/src/main/resources/logback-spring.xml @@ -8,23 +8,25 @@ - + - + - + - - + + + value="%red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%-15thread]) %highlight(%-5level) %cyan(%-50logger{50}) : %msg%n"/> - + @@ -105,28 +107,28 @@ additivity 指定是否将 root 的 appender 加入到 logger 中,默认为 true --> - - + + - + - - + + - - - - + + + + From a4276f0a93b3ca4c167faa9a08ae9d76706fe528 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 27 Jul 2023 17:07:25 +0800 Subject: [PATCH 004/244] =?UTF-8?q?docs:=20=E7=BB=B4=E6=8A=A4=20SQL=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=8C=E6=B7=BB=E5=8A=A0=20nacos=20v1.4.6?= =?UTF-8?q?=20SQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/sql/{ => framework}/data.sql | 0 .docs/sql/{ => framework}/schema.sql | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .docs/sql/{ => framework}/data.sql (100%) rename .docs/sql/{ => framework}/schema.sql (100%) diff --git a/.docs/sql/data.sql b/.docs/sql/framework/data.sql similarity index 100% rename from .docs/sql/data.sql rename to .docs/sql/framework/data.sql diff --git a/.docs/sql/schema.sql b/.docs/sql/framework/schema.sql similarity index 100% rename from .docs/sql/schema.sql rename to .docs/sql/framework/schema.sql From a67f4dd278c64813ae46f3dd84a66dfe672f247f Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 28 Jul 2023 09:34:26 +0800 Subject: [PATCH 005/244] =?UTF-8?q?fix:=20=E6=89=BE=E5=9B=9E=20framework?= =?UTF-8?q?=20mapper=20xml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/mapper/SysApiMapper.xml | 48 +++++ .../main/resources/mapper/SysMenuMapper.xml | 83 ++++++++ .../main/resources/mapper/SysRoleMapper.xml | 184 ++++++++++++++++++ .../main/resources/mapper/SysUserMapper.xml | 73 +++++++ 4 files changed, 388 insertions(+) create mode 100644 framework/framework_api/src/main/resources/mapper/SysApiMapper.xml create mode 100644 framework/framework_api/src/main/resources/mapper/SysMenuMapper.xml create mode 100644 framework/framework_api/src/main/resources/mapper/SysRoleMapper.xml create mode 100644 framework/framework_api/src/main/resources/mapper/SysUserMapper.xml diff --git a/framework/framework_api/src/main/resources/mapper/SysApiMapper.xml b/framework/framework_api/src/main/resources/mapper/SysApiMapper.xml new file mode 100644 index 00000000..668df50a --- /dev/null +++ b/framework/framework_api/src/main/resources/mapper/SysApiMapper.xml @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + diff --git a/framework/framework_api/src/main/resources/mapper/SysMenuMapper.xml b/framework/framework_api/src/main/resources/mapper/SysMenuMapper.xml new file mode 100644 index 00000000..c337910d --- /dev/null +++ b/framework/framework_api/src/main/resources/mapper/SysMenuMapper.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/framework_api/src/main/resources/mapper/SysRoleMapper.xml b/framework/framework_api/src/main/resources/mapper/SysRoleMapper.xml new file mode 100644 index 00000000..0865c118 --- /dev/null +++ b/framework/framework_api/src/main/resources/mapper/SysRoleMapper.xml @@ -0,0 +1,184 @@ + + + + + + + + + + + + + + + + + + + + + DELETE FROM sys_role_user ru + WHERE ru.user_id IN ( + + #{id} + + ) + + + DELETE FROM sys_role_user ru + WHERE ru.role_id IN ( + + #{id} + + ) + + + DELETE FROM sys_role_menu rm + WHERE rm.menu_id IN ( + + #{id} + + ) + + + DELETE FROM sys_role_menu rm + WHERE rm.role_id IN ( + + #{id} + + ) + + + DELETE FROM sys_role_api ra + WHERE ra.api_id IN ( + + #{id} + + ) + + + DELETE FROM sys_role_api ra + WHERE ra.role_id IN ( + + #{id} + + ) + + + DELETE FROM sys_role_user ru + WHERE (ru.user_id, ru.role_id) IN ( + + (#{el.id}, #{el.roleId}) + + ) + + + DELETE FROM sys_role_menu rm + WHERE (rm.menu_id, rm.role_id) IN ( + + (#{el.id}, #{el.roleId}) + + ) + + + DELETE FROM sys_role_api ra + WHERE (ra.api_id, ra.role_id) IN ( + + (#{el.id}, #{el.roleId}) + + ) + + + INSERT INTO sys_role_user (user_id, role_id) + VALUES + + (#{el.id}, #{el.roleId}) + + + + INSERT INTO sys_role_menu (menu_id, role_id) + VALUES + + (#{el.id}, #{el.roleId}) + + + + INSERT INTO sys_role_api (api_id, role_id) + VALUES + + (#{el.id}, #{el.roleId}) + + + + diff --git a/framework/framework_api/src/main/resources/mapper/SysUserMapper.xml b/framework/framework_api/src/main/resources/mapper/SysUserMapper.xml new file mode 100644 index 00000000..fcf420cf --- /dev/null +++ b/framework/framework_api/src/main/resources/mapper/SysUserMapper.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + From e8ad59b2fd2ee0f1d037f3733c8acad8c569a4d1 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 28 Jul 2023 10:56:23 +0800 Subject: [PATCH 006/244] =?UTF-8?q?feat:=20=E5=BC=95=E5=85=A5=20gateway=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=EF=BC=8C=E8=B0=83=E6=95=B4=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/sql/nacos_v1.4.6.sql | 218 ++++++++++++++++++ common/core/pom.xml | 11 +- dependencies/pom.xml | 1 + .../src/main/resources/bootstrap.yml | 4 + framework/framework_api/pom.xml | 10 +- framework/framework_svc/pom.xml | 6 + .../src/main/resources/bootstrap.yml | 4 + gateway/pom.xml | 78 +++++++ .../gateway/UniGatewayApplication.java | 28 +++ gateway/src/main/resources/banner.txt | 8 + gateway/src/main/resources/bootstrap.yml | 24 ++ gateway/src/main/resources/logback-spring.xml | 134 +++++++++++ gateway/src/main/resources/spy.properties | 21 ++ 13 files changed, 534 insertions(+), 13 deletions(-) create mode 100644 .docs/sql/nacos_v1.4.6.sql create mode 100644 gateway/pom.xml create mode 100644 gateway/src/main/java/com/github/cadecode/uniboot/gateway/UniGatewayApplication.java create mode 100644 gateway/src/main/resources/banner.txt create mode 100644 gateway/src/main/resources/bootstrap.yml create mode 100644 gateway/src/main/resources/logback-spring.xml create mode 100644 gateway/src/main/resources/spy.properties diff --git a/.docs/sql/nacos_v1.4.6.sql b/.docs/sql/nacos_v1.4.6.sql new file mode 100644 index 00000000..53bdb5a8 --- /dev/null +++ b/.docs/sql/nacos_v1.4.6.sql @@ -0,0 +1,218 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/******************************************/ +/* 数据库全名 = nacos_config */ +/* 表名称 = config_info */ +/******************************************/ +CREATE TABLE `config_info` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `data_id` varchar(255) NOT NULL COMMENT 'data_id', + `group_id` varchar(255) DEFAULT NULL, + `content` longtext NOT NULL COMMENT 'content', + `md5` varchar(32) DEFAULT NULL COMMENT 'md5', + `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', + `src_user` text COMMENT 'source user', + `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip', + `app_name` varchar(128) DEFAULT NULL, + `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段', + `c_desc` varchar(256) DEFAULT NULL, + `c_use` varchar(64) DEFAULT NULL, + `effect` varchar(64) DEFAULT NULL, + `type` varchar(64) DEFAULT NULL, + `c_schema` text, + PRIMARY KEY (`id`), + UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info'; + +/******************************************/ +/* 数据库全名 = nacos_config */ +/* 表名称 = config_info_aggr */ +/******************************************/ +CREATE TABLE `config_info_aggr` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `data_id` varchar(255) NOT NULL COMMENT 'data_id', + `group_id` varchar(255) NOT NULL COMMENT 'group_id', + `datum_id` varchar(255) NOT NULL COMMENT 'datum_id', + `content` longtext NOT NULL COMMENT '内容', + `gmt_modified` datetime NOT NULL COMMENT '修改时间', + `app_name` varchar(128) DEFAULT NULL, + `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_configinfoaggr_datagrouptenantdatum` (`data_id`,`group_id`,`tenant_id`,`datum_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='增加租户字段'; + + +/******************************************/ +/* 数据库全名 = nacos_config */ +/* 表名称 = config_info_beta */ +/******************************************/ +CREATE TABLE `config_info_beta` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `data_id` varchar(255) NOT NULL COMMENT 'data_id', + `group_id` varchar(128) NOT NULL COMMENT 'group_id', + `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name', + `content` longtext NOT NULL COMMENT 'content', + `beta_ips` varchar(1024) DEFAULT NULL COMMENT 'betaIps', + `md5` varchar(32) DEFAULT NULL COMMENT 'md5', + `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', + `src_user` text COMMENT 'source user', + `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip', + `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_configinfobeta_datagrouptenant` (`data_id`,`group_id`,`tenant_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_beta'; + +/******************************************/ +/* 数据库全名 = nacos_config */ +/* 表名称 = config_info_tag */ +/******************************************/ +CREATE TABLE `config_info_tag` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `data_id` varchar(255) NOT NULL COMMENT 'data_id', + `group_id` varchar(128) NOT NULL COMMENT 'group_id', + `tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id', + `tag_id` varchar(128) NOT NULL COMMENT 'tag_id', + `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name', + `content` longtext NOT NULL COMMENT 'content', + `md5` varchar(32) DEFAULT NULL COMMENT 'md5', + `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', + `src_user` text COMMENT 'source user', + `src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_configinfotag_datagrouptenanttag` (`data_id`,`group_id`,`tenant_id`,`tag_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_tag'; + +/******************************************/ +/* 数据库全名 = nacos_config */ +/* 表名称 = config_tags_relation */ +/******************************************/ +CREATE TABLE `config_tags_relation` ( + `id` bigint(20) NOT NULL COMMENT 'id', + `tag_name` varchar(128) NOT NULL COMMENT 'tag_name', + `tag_type` varchar(64) DEFAULT NULL COMMENT 'tag_type', + `data_id` varchar(255) NOT NULL COMMENT 'data_id', + `group_id` varchar(128) NOT NULL COMMENT 'group_id', + `tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id', + `nid` bigint(20) NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`nid`), + UNIQUE KEY `uk_configtagrelation_configidtag` (`id`,`tag_name`,`tag_type`), + KEY `idx_tenant_id` (`tenant_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_tag_relation'; + +/******************************************/ +/* 数据库全名 = nacos_config */ +/* 表名称 = group_capacity */ +/******************************************/ +CREATE TABLE `group_capacity` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `group_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Group ID,空字符表示整个集群', + `quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值', + `usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量', + `max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值', + `max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数,,0表示使用默认值', + `max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值', + `max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量', + `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_group_id` (`group_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='集群、各Group容量信息表'; + +/******************************************/ +/* 数据库全名 = nacos_config */ +/* 表名称 = his_config_info */ +/******************************************/ +CREATE TABLE `his_config_info` ( + `id` bigint(64) unsigned NOT NULL, + `nid` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + `data_id` varchar(255) NOT NULL, + `group_id` varchar(128) NOT NULL, + `app_name` varchar(128) DEFAULT NULL COMMENT 'app_name', + `content` longtext NOT NULL, + `md5` varchar(32) DEFAULT NULL, + `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `src_user` text, + `src_ip` varchar(50) DEFAULT NULL, + `op_type` char(10) DEFAULT NULL, + `tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段', + PRIMARY KEY (`nid`), + KEY `idx_gmt_create` (`gmt_create`), + KEY `idx_gmt_modified` (`gmt_modified`), + KEY `idx_did` (`data_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='多租户改造'; + + +/******************************************/ +/* 数据库全名 = nacos_config */ +/* 表名称 = tenant_capacity */ +/******************************************/ +CREATE TABLE `tenant_capacity` ( + `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键ID', + `tenant_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Tenant ID', + `quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '配额,0表示使用默认值', + `usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '使用量', + `max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个配置大小上限,单位为字节,0表示使用默认值', + `max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '聚合子配置最大个数', + `max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '单个聚合数据的子配置大小上限,单位为字节,0表示使用默认值', + `max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '最大变更历史数量', + `gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_tenant_id` (`tenant_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='租户容量信息表'; + + +CREATE TABLE `tenant_info` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', + `kp` varchar(128) NOT NULL COMMENT 'kp', + `tenant_id` varchar(128) default '' COMMENT 'tenant_id', + `tenant_name` varchar(128) default '' COMMENT 'tenant_name', + `tenant_desc` varchar(256) DEFAULT NULL COMMENT 'tenant_desc', + `create_source` varchar(32) DEFAULT NULL COMMENT 'create_source', + `gmt_create` bigint(20) NOT NULL COMMENT '创建时间', + `gmt_modified` bigint(20) NOT NULL COMMENT '修改时间', + PRIMARY KEY (`id`), + UNIQUE KEY `uk_tenant_info_kptenantid` (`kp`,`tenant_id`), + KEY `idx_tenant_id` (`tenant_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='tenant_info'; + +CREATE TABLE `users` ( + `username` varchar(50) NOT NULL PRIMARY KEY, + `password` varchar(500) NOT NULL, + `enabled` boolean NOT NULL +); + +CREATE TABLE `roles` ( + `username` varchar(50) NOT NULL, + `role` varchar(50) NOT NULL, + UNIQUE INDEX `idx_user_role` (`username` ASC, `role` ASC) USING BTREE +); + +CREATE TABLE `permissions` ( + `role` varchar(50) NOT NULL, + `resource` varchar(255) NOT NULL, + `action` varchar(8) NOT NULL, + UNIQUE INDEX `uk_role_permission` (`role`,`resource`,`action`) USING BTREE +); + +INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE); + +INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN'); diff --git a/common/core/pom.xml b/common/core/pom.xml index b8688fa0..a12421ea 100644 --- a/common/core/pom.xml +++ b/common/core/pom.xml @@ -18,12 +18,12 @@ mica-auto provided - + org.springframework.boot spring-boot-starter-web - + org.springframework.boot spring-boot-starter-aop @@ -33,12 +33,7 @@ org.springframework.boot spring-boot-starter-validation - - - org.springframework.boot - spring-boot-starter-security - - + org.springframework.boot spring-boot-configuration-processor diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 14a9c4ef..172597bd 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -17,6 +17,7 @@ ../common ../framework ../example + ../gateway diff --git a/example/example_svc/src/main/resources/bootstrap.yml b/example/example_svc/src/main/resources/bootstrap.yml index 1e244639..cafe4746 100644 --- a/example/example_svc/src/main/resources/bootstrap.yml +++ b/example/example_svc/src/main/resources/bootstrap.yml @@ -2,6 +2,10 @@ logging: file: path: /log/uni_boot_admin/example +server: + servlet: + context-path: /example + spring: application: name: uni-boot-example diff --git a/framework/framework_api/pom.xml b/framework/framework_api/pom.xml index 3657ba3d..973bf1bf 100644 --- a/framework/framework_api/pom.xml +++ b/framework/framework_api/pom.xml @@ -26,6 +26,11 @@ org.springframework.cloud spring-cloud-starter-loadbalancer + + + org.springframework.boot + spring-boot-starter-security + com.github.cadecode @@ -55,10 +60,5 @@ com.github.cadecode uni-boot-common-plugin-concurrent - - - cn.hutool - hutool-http - diff --git a/framework/framework_svc/pom.xml b/framework/framework_svc/pom.xml index 67623ea2..18173992 100644 --- a/framework/framework_svc/pom.xml +++ b/framework/framework_svc/pom.xml @@ -43,6 +43,12 @@ jasypt-spring-boot-starter + + + cn.hutool + hutool-http + + com.github.cadecode uni-boot-framework-api diff --git a/framework/framework_svc/src/main/resources/bootstrap.yml b/framework/framework_svc/src/main/resources/bootstrap.yml index 8840bf68..177ac15f 100644 --- a/framework/framework_svc/src/main/resources/bootstrap.yml +++ b/framework/framework_svc/src/main/resources/bootstrap.yml @@ -2,6 +2,10 @@ logging: file: path: /log/uni_boot_admin/framework +server: + servlet: + context-path: /framework + spring: application: name: uni-boot-framework diff --git a/gateway/pom.xml b/gateway/pom.xml new file mode 100644 index 00000000..627af658 --- /dev/null +++ b/gateway/pom.xml @@ -0,0 +1,78 @@ + + + + uni-boot-dependencies + com.github.cadecode + 2023.1.0 + ../dependencies/pom.xml + + 4.0.0 + + uni-boot-gateway + 流量网关 + + + + + org.springframework.cloud + spring-cloud-starter-bootstrap + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + + + org.springframework.cloud + spring-cloud-starter-gateway + + + + org.springframework.boot + spring-boot-starter-aop + + + + org.springframework.boot + spring-boot-configuration-processor + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.github.ulisesbocchio + jasypt-spring-boot-starter + + + + com.github.cadecode + uni-boot-common-plugin-actuator + + + + diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/UniGatewayApplication.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/UniGatewayApplication.java new file mode 100644 index 00000000..cc886afc --- /dev/null +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/UniGatewayApplication.java @@ -0,0 +1,28 @@ +package com.github.cadecode.uniboot.gateway; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.EnableAspectJAutoProxy; + +/** + * 启动类 + */ +@EnableFeignClients("com.github.cadecode") +@EnableDiscoveryClient +@EnableAspectJAutoProxy(exposeProxy = true) +@SpringBootApplication +public class UniGatewayApplication extends SpringBootServletInitializer { + + public static void main(String[] args) { + SpringApplication.run(UniGatewayApplication.class, args); + } + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(UniGatewayApplication.class); + } +} diff --git a/gateway/src/main/resources/banner.txt b/gateway/src/main/resources/banner.txt new file mode 100644 index 00000000..0799272a --- /dev/null +++ b/gateway/src/main/resources/banner.txt @@ -0,0 +1,8 @@ + _ _ _ _ ___ ___ ___ ___ _____ + | | | | | \| | |_ _| | _ ) / _ \ / _ \ |_ _| + | |_| | | .` | | | | _ \ | (_) | | (_) | | | + \___/ |_|\_| |___| |___/ \___/ \___/ _|_|_ +_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| +"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-' + :: Spring Boot :: (${spring-boot.version}) + :: ${uni-boot.config.name} :: (${uni-boot.config.version}) diff --git a/gateway/src/main/resources/bootstrap.yml b/gateway/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..4292ba12 --- /dev/null +++ b/gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,24 @@ +logging: + file: + path: /log/uni_boot_admin/gateway + +spring: + application: + name: uni-boot-gateway + cloud: + nacos: + server-addr: localhost:8848 + username: nacos + password: nacos + discovery: + enabled: true + namespace: uni_dev + group: DEFAULT_GROUP + config: + enabled: true + namespace: uni_dev + group: DEFAULT_GROUP + file-extension: yml + shared-configs: + - shared-config.${spring.cloud.nacos.config.file-extension} + - shared-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} diff --git a/gateway/src/main/resources/logback-spring.xml b/gateway/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..9b734e71 --- /dev/null +++ b/gateway/src/main/resources/logback-spring.xml @@ -0,0 +1,134 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${consolePattern} + UTF-8 + + + + + + + ${filePath}/debug.now.log + + + + ${filePath}/debug/debug.%d{yyyy-MM-dd}.%i.log + + ${history} + + 10MB + + + + ${filePattern} + UTF-8 + + + + DEBUG + ACCEPT + DENY + + + + + + ${filePath}/info.now.log + + ${filePath}/info/info.%d{yyyy-MM-dd}.%i.log + ${history} + 10MB + + + ${filePattern} + UTF-8 + + + INFO + ACCEPT + DENY + + + + + + ${filePath}/error.now.log + + ${filePath}/error/error.%d{yyyy-MM-dd}.%i.log + ${history} + 10MB + + + ${filePattern} + UTF-8 + + + ERROR + ACCEPT + DENY + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/gateway/src/main/resources/spy.properties b/gateway/src/main/resources/spy.properties new file mode 100644 index 00000000..5b485971 --- /dev/null +++ b/gateway/src/main/resources/spy.properties @@ -0,0 +1,21 @@ +# 配置日志拦截模块 +# 加入 MybatisPlus 日志 +modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory +# 设置日志打印格式 +logMessageFormat=com.p6spy.engine.spy.appender.CustomLineFormat +customLogMessageFormat===> P6Spy: %(executionTime) ms, connection%(connectionId), sql: %(sqlSingleLine) +# 设置日志系统 +# 使用 SLF4J 即系统日志 +appender=com.p6spy.engine.spy.appender.Slf4JLogger +# 设置 p6spy driver 代理 +deregisterdrivers=true +# 取消 JDBC URL 前缀 +useprefix=true +# 设置要排除的日志记录 +excludecategories=info,debug,result,commit,resultset +# 设置日期格式 +dateformat=yyyy-MM-dd HH:mm:ss +# 开启慢 SQL 记录 +outagedetection=true +# 设置慢 SQL 记录标准 2 秒 +outagedetectioninterval=2 From 90a229003d650ed13e344592d7f2b3461801e018 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 28 Jul 2023 16:17:07 +0800 Subject: [PATCH 007/244] =?UTF-8?q?refactor:=20=E6=8A=BD=E5=8F=96=20file?= =?UTF-8?q?=20=E4=B8=8A=E4=BC=A0=E7=9B=AE=E5=BD=95=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/api/config/UniBootConfig.java | 18 ++-------- .../svc/config/UniFrameworkConfig.java | 33 +++++++++++++++++++ .../framework/svc/util/FileUploadUtil.java | 16 ++++----- 3 files changed, 44 insertions(+), 23 deletions(-) create mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/UniFrameworkConfig.java diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/UniBootConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/UniBootConfig.java index 7a2b4add..60978c78 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/UniBootConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/UniBootConfig.java @@ -6,10 +6,9 @@ import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; -import java.util.List; - /** - * uni-boot-admin 主配置类,维护一些功能开关和全局变量 + * uni-boot-admin 通用配置类 + * 维护一些功能开关和全局变量 * * @author Cade Li * @date 2022/5/21 @@ -24,7 +23,7 @@ public class UniBootConfig { /** * 应用名称 */ - private String name = "uni-boot-admin"; + private String name; /** * 版本号 @@ -40,15 +39,4 @@ public class UniBootConfig { * 是否开启动态数据源配置 */ private boolean dynamicDsOn; - - /** - * 文件基本路径,以/结尾 - */ - private String fileBasePath; - - /** - * 可上传下载的扩展文件类型 - */ - private List allowedFileExtensions; - } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/UniFrameworkConfig.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/UniFrameworkConfig.java new file mode 100644 index 00000000..0ae66901 --- /dev/null +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/UniFrameworkConfig.java @@ -0,0 +1,33 @@ +package com.github.cadecode.uniboot.framework.svc.config; + +import lombok.Data; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +import java.util.List; + +/** + * uni-boot-admin framework 服务配置 + * + * @author Cade Li + * @since 2023/7/28 + */ +@Slf4j +@Data +@RequiredArgsConstructor +@Configuration +@ConfigurationProperties("uni-boot.framework") +public class UniFrameworkConfig { + + /** + * 文件基本路径,以/结尾 + */ + private String fileBasePath; + + /** + * 可上传下载的扩展文件类型 + */ + private List allowedFileExtensions; +} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/util/FileUploadUtil.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/util/FileUploadUtil.java index 5bf28414..f10bff88 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/util/FileUploadUtil.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/util/FileUploadUtil.java @@ -4,7 +4,7 @@ import cn.hutool.core.io.file.FileNameUtil; import cn.hutool.core.lang.UUID; import cn.hutool.core.util.StrUtil; -import com.github.cadecode.uniboot.framework.api.config.UniBootConfig; +import com.github.cadecode.uniboot.framework.svc.config.UniFrameworkConfig; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.InitializingBean; @@ -23,7 +23,7 @@ @Component public class FileUploadUtil implements InitializingBean { - private final UniBootConfig uniBootConfig; + private final UniFrameworkConfig uniFrameworkConfig; public static final String DEFAULT_FILE_BASE_PATH = "/uniboot/file/temp/"; public static final String DEFAULT_DOWNLOAD_API = "/common/download"; @@ -74,15 +74,15 @@ public static String renameByTime(String fileName) { @Override public void afterPropertiesSet() { - if (StrUtil.isEmpty(uniBootConfig.getFileBasePath())) { - uniBootConfig.setFileBasePath(DEFAULT_FILE_BASE_PATH); + if (StrUtil.isEmpty(uniFrameworkConfig.getFileBasePath())) { + uniFrameworkConfig.setFileBasePath(DEFAULT_FILE_BASE_PATH); log.info("Set uniboot config file base path to default {}", DEFAULT_FILE_BASE_PATH); } - UPLOAD_PATH = uniBootConfig.getFileBasePath() + "upload/"; - DOWNLOAD_PATH = uniBootConfig.getFileBasePath() + "download/"; + UPLOAD_PATH = uniFrameworkConfig.getFileBasePath() + "upload/"; + DOWNLOAD_PATH = uniFrameworkConfig.getFileBasePath() + "download/"; // 加入额外配置的后缀 - if (CollUtil.isNotEmpty(uniBootConfig.getAllowedFileExtensions())) { - ALLOWED_EXTENSIONS.addAll(uniBootConfig.getAllowedFileExtensions()); + if (CollUtil.isNotEmpty(uniFrameworkConfig.getAllowedFileExtensions())) { + ALLOWED_EXTENSIONS.addAll(uniFrameworkConfig.getAllowedFileExtensions()); } } } From 9e77d1ca64c749439242a71f34db8f5c7ce70f8a Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 29 Jul 2023 10:32:57 +0800 Subject: [PATCH 008/244] =?UTF-8?q?feat:=20=E6=8A=BD=E7=A6=BB=20security?= =?UTF-8?q?=20=E8=AE=A4=E8=AF=81=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=88=B0=20framework=20=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/log/aspect/ApiLoggerAspect.java | 6 +- .../log/handler/AbstractApiLogHandler.java | 2 +- .../src/main/resources/bootstrap.yml | 4 - .../framework/api/config/SecurityConfig.java | 153 ++++++------------ .../framework/api/feign/SysApiClient.java | 24 +++ .../framework/api/feign/SysLogClient.java | 23 +++ .../framework/api/plugin/ApiLogHandler.java | 14 +- .../api/security/voter/DataBaseRoleVoter.java | 10 +- .../framework/api/util/SecurityUtil.java | 6 +- .../svc/config/FrameSecurityConfig.java | 112 +++++++++++++ .../svc/controller/AuthController.java | 51 +++--- .../svc/controller/SysApiController.java | 13 +- .../svc/controller/SysDictController.java | 2 +- .../svc/controller/SysLogController.java | 13 +- .../svc/controller/SysMenuController.java | 4 +- .../svc/controller/SysRoleController.java | 2 +- .../svc/controller/SysUserController.java | 6 +- .../framework/svc}/mapper/SysApiMapper.java | 2 +- .../framework/svc}/mapper/SysDictMapper.java | 2 +- .../framework/svc}/mapper/SysLogMapper.java | 2 +- .../framework/svc}/mapper/SysMenuMapper.java | 2 +- .../framework/svc}/mapper/SysRoleMapper.java | 2 +- .../framework/svc}/mapper/SysUserMapper.java | 2 +- .../JwtLoginSuccessHandleService.java | 6 +- .../svc/security}/LoginFailureHandler.java | 6 +- .../security}/LoginSuccessHandleService.java | 2 +- .../svc/security}/LoginSuccessHandler.java | 4 +- .../RedisLoginSuccessHandleService.java | 6 +- .../svc/security}/SignOutSuccessHandler.java | 6 +- .../framework/svc}/service/SysApiService.java | 2 +- .../svc}/service/SysDictService.java | 2 +- .../framework/svc}/service/SysLogService.java | 2 +- .../svc}/service/SysMenuService.java | 2 +- .../svc}/service/SysRoleService.java | 2 +- .../svc}/service/SysUserService.java | 2 +- .../svc}/serviceimpl/SysApiServiceImpl.java | 9 +- .../svc}/serviceimpl/SysDictServiceImpl.java | 6 +- .../svc}/serviceimpl/SysLogServiceImpl.java | 6 +- .../svc}/serviceimpl/SysMenuServiceImpl.java | 6 +- .../svc}/serviceimpl/SysRoleServiceImpl.java | 6 +- .../svc}/serviceimpl/SysUserServiceImpl.java | 6 +- .../src/main/resources/bootstrap.yml | 4 - .../main/resources/mapper/SysApiMapper.xml | 2 +- .../main/resources/mapper/SysMenuMapper.xml | 2 +- .../main/resources/mapper/SysRoleMapper.xml | 2 +- .../main/resources/mapper/SysUserMapper.xml | 2 +- 46 files changed, 326 insertions(+), 224 deletions(-) create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysApiClient.java create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysLogClient.java create mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/mapper/SysApiMapper.java (92%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/mapper/SysDictMapper.java (84%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/mapper/SysLogMapper.java (84%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/mapper/SysMenuMapper.java (93%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/mapper/SysRoleMapper.java (96%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/mapper/SysUserMapper.java (93%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security}/JwtLoginSuccessHandleService.java (88%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security}/LoginFailureHandler.java (89%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security}/LoginSuccessHandleService.java (91%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security}/LoginSuccessHandler.java (95%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security}/RedisLoginSuccessHandleService.java (89%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security}/SignOutSuccessHandler.java (91%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/service/SysApiService.java (92%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/service/SysDictService.java (81%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/service/SysLogService.java (81%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/service/SysMenuService.java (93%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/service/SysRoleService.java (96%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/service/SysUserService.java (93%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/serviceimpl/SysApiServiceImpl.java (79%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/serviceimpl/SysDictServiceImpl.java (67%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/serviceimpl/SysLogServiceImpl.java (66%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/serviceimpl/SysMenuServiceImpl.java (94%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/serviceimpl/SysRoleServiceImpl.java (95%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/serviceimpl/SysUserServiceImpl.java (92%) rename framework/{framework_api => framework_svc}/src/main/resources/mapper/SysApiMapper.xml (97%) rename framework/{framework_api => framework_svc}/src/main/resources/mapper/SysMenuMapper.xml (98%) rename framework/{framework_api => framework_svc}/src/main/resources/mapper/SysRoleMapper.xml (99%) rename framework/{framework_api => framework_svc}/src/main/resources/mapper/SysUserMapper.xml (98%) diff --git a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java index 47c7a41b..a2f69052 100644 --- a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java +++ b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java @@ -101,7 +101,7 @@ public void handleLogger(ProceedingJoinPoint point, ApiLogger apiLogger, Object resultStr = JacksonUtil.toJson(result); } catch (Exception e) { resultStr = ExceptionUtil.stacktraceToString(e); - log.warn("API log [{}]: request result to json fail", apiLogger.type().getType(), e); + log.error("API log [{}]: request result to json fail", apiLogger.type().getType(), e); } } BaseLogInfo baseLogInfo = BaseLogInfo.builder().apiLogger(apiLogger).request(attributes.getRequest()) @@ -113,10 +113,10 @@ public void handleLogger(ProceedingJoinPoint point, ApiLogger apiLogger, Object try { apiLogHandler.save(apiLogger, logObj); } catch (Exception e) { - log.warn("API log [{}]: save async fail", apiLogger.type().getType(), e); + log.error("API log [{}]: save async fail", apiLogger.type().getType(), e); } } catch (Exception e) { - log.warn("API log [{}]: handle logger fail", apiLogger.type().getType(), e); + log.error("API log [{}]: handle logger fail", apiLogger.type().getType(), e); } } diff --git a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java index cea3f58a..5317958e 100644 --- a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java +++ b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java @@ -41,7 +41,7 @@ public static Map getRequestParams(JoinPoint joinPoint, ApiLogge return Collections.emptyMap(); } if (names.length != args.length) { - log.warn("API log [{}]: method [{}] param and the pass value do not match", apiLogger.type().getType(), methodSignature.getName()); + log.error("API log [{}]: method [{}] param and the pass value do not match", apiLogger.type().getType(), methodSignature.getName()); return Collections.emptyMap(); } Map map = new HashMap<>(); diff --git a/example/example_svc/src/main/resources/bootstrap.yml b/example/example_svc/src/main/resources/bootstrap.yml index cafe4746..1e244639 100644 --- a/example/example_svc/src/main/resources/bootstrap.yml +++ b/example/example_svc/src/main/resources/bootstrap.yml @@ -2,10 +2,6 @@ logging: file: path: /log/uni_boot_admin/example -server: - servlet: - context-path: /example - spring: application: name: uni-boot-example diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java index 89535e75..238cdc25 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java @@ -5,18 +5,18 @@ import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.api.security.filter.TokenAuthFilter; -import com.github.cadecode.uniboot.framework.api.security.handler.*; +import com.github.cadecode.uniboot.framework.api.security.handler.NoAuthenticationHandler; +import com.github.cadecode.uniboot.framework.api.security.handler.NoAuthorityHandler; import com.github.cadecode.uniboot.framework.api.security.voter.DataBaseRoleVoter; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.http.HttpMethod; import org.springframework.security.access.vote.UnanimousBased; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; @@ -24,9 +24,6 @@ import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.http.SessionCreationPolicy; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.access.expression.WebExpressionVoter; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; @@ -40,29 +37,13 @@ * @date 2022/5/27 */ @Slf4j -@Data @RequiredArgsConstructor @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) @EnableConfigurationProperties(SecurityProperties.class) +@ConditionalOnMissingBean(SecurityConfig.class) @Configuration -public class SecurityConfig { - - /** - * 登录路径 - */ - public static final String LOGIN_URL = "/login"; - - /** - * 登录参数 - */ - public static final String USERNAME_PARAMETER = "username"; - public static final String PASSWORD_PARAMETER = "password"; - - /** - * 注销路径 - */ - public static final String LOGOUT_URL = "/logout"; +public class SecurityConfig extends WebSecurityConfigurerAdapter { /** * 配置项 @@ -72,11 +53,8 @@ public class SecurityConfig { /** * 注入各种处理器 */ - private final LoginSuccessHandler loginSuccessHandler; - private final LoginFailureHandler loginFailureHandler; private final NoAuthenticationHandler noAuthenticationHandler; private final NoAuthorityHandler noAuthorityHandler; - private final SignOutSuccessHandler signOutSuccessHandler; /** * 注入 Token 过滤器 @@ -88,88 +66,50 @@ public class SecurityConfig { */ private final DataBaseRoleVoter dataBaseRoleVoter; - /** - * 注入 UserDetailsService - */ - private final UserDetailsService userDetailsService; - - /** - * 密码加密器 - */ - @Bean - public PasswordEncoder passwordEncoder() { - return new BCryptPasswordEncoder(); + @Override + protected void configure(HttpSecurity http) throws Exception { + // 关闭 csrf + http.csrf().disable(); + // 关闭 session 管理 + http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); + // 配置鉴权规则 + http.authorizeRequests() + // 尝试请求直接通过 + .antMatchers(HttpMethod.OPTIONS, "/**").permitAll() + .anyRequest().authenticated(); + // 配置异常处理 + http.exceptionHandling() + // 配置未登录处理器 + .authenticationEntryPoint(noAuthenticationHandler) + // 配置无权限处理器 + .accessDeniedHandler(noAuthorityHandler); + // 自定义的 accessDecisionManager + http.authorizeRequests() + .accessDecisionManager(new UnanimousBased( + Arrays.asList(new WebExpressionVoter(), dataBaseRoleVoter))); + // 配置 Token 校验过滤器 + http.addFilterBefore(tokenAuthFilter, UsernamePasswordAuthenticationFilter.class); + log.info("Config Security over,AuthModel:{}", properties.getAuthModel()); } - /** - * Security 配置 - */ - @Bean - public WebSecurityConfigurerAdapter webSecurityConfigurer(PasswordEncoder passwordEncoder) { - return new WebSecurityConfigurerAdapter() { - - @Override - protected void configure(AuthenticationManagerBuilder auth) throws Exception { - auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder); - } - - @Override - protected void configure(HttpSecurity http) throws Exception { - // 关闭 csrf - http.csrf().disable(); - // 关闭 session 管理 - http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); - // 配置鉴权规则 - http.authorizeRequests() - // 尝试请求直接通过 - .antMatchers(HttpMethod.OPTIONS, "/**").permitAll() - .anyRequest().authenticated(); - // 配置注销处理器 - http.logout().permitAll() - .logoutUrl(LOGOUT_URL) - .logoutSuccessHandler(signOutSuccessHandler); - // 配置异常处理 - http.exceptionHandling() - // 配置未登录处理器 - .authenticationEntryPoint(noAuthenticationHandler) - // 配置无权限处理器 - .accessDeniedHandler(noAuthorityHandler); - // 自定义的 accessDecisionManager - http.authorizeRequests() - .accessDecisionManager(new UnanimousBased( - Arrays.asList(new WebExpressionVoter(), dataBaseRoleVoter))); - // 配置登录处理器 - http.formLogin().permitAll() - .loginProcessingUrl(LOGIN_URL) - .usernameParameter(USERNAME_PARAMETER) - .passwordParameter(PASSWORD_PARAMETER) - .successHandler(loginSuccessHandler) - .failureHandler(loginFailureHandler); - // 配置 Token 校验过滤器 - http.addFilterBefore(tokenAuthFilter, UsernamePasswordAuthenticationFilter.class); - log.info("Config Security over,AuthModel:{}", properties.getAuthModel()); - } - - @Override - public void configure(WebSecurity web) { - // 忽略配置器 - IgnoredRequestConfigurer ignoring = web.ignoring(); - // 放行 swagger knife 文档 - ignoring.antMatchers("/doc.html", "/webjars/**", "/swagger-resources/**", "/v2/api-docs/**"); - // 放行其他框架 - ignoring.antMatchers("/error", "/druid/**", "/actuator/**"); - // 设置忽略的路径 - List ignoreUrls = properties.getIgnoreUrls(); - if (CollUtil.isNotEmpty(ignoreUrls)) { - log.info("Config Security ignore urls:{}", ignoreUrls); - ignoring.antMatchers(ArrayUtil.toArray(ignoreUrls, String.class)); - } - } - }; + @Override + public void configure(WebSecurity web) { + // 忽略配置器 + IgnoredRequestConfigurer ignoring = web.ignoring(); + // 放行 swagger knife 文档 + ignoring.antMatchers("/doc.html", "/webjars/**", "/swagger-resources/**", "/v2/api-docs/**"); + // 放行其他框架 + ignoring.antMatchers("/error", "/druid/**", "/actuator/**"); + // 设置忽略的路径 + List ignoreUrls = properties.getIgnoreUrls(); + if (CollUtil.isNotEmpty(ignoreUrls)) { + log.info("Config Security ignore urls:{}", ignoreUrls); + ignoring.antMatchers(ArrayUtil.toArray(ignoreUrls, String.class)); + } } /** - * Security 配置 + * Security 配置项 */ @Data @ConfigurationProperties("uni-boot.security") @@ -188,12 +128,11 @@ public static class SecurityProperties { /** * JWT Token 配置 */ - private TokenConfig token; - + private TokenConfig tokenConfig; } /** - * JWT 配置类 + * JWT 配置项 */ @Data public static class TokenConfig { diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysApiClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysApiClient.java new file mode 100644 index 00000000..85132884 --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysApiClient.java @@ -0,0 +1,24 @@ +package com.github.cadecode.uniboot.framework.api.feign; + +import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; + +import java.util.List; + +/** + * SysApi feign client + * + * @author Cade Li + * @since 2023/7/28 + */ +@FeignClient(contextId = "SysApiClient", name = "uni-boot-framework") +public interface SysApiClient { + + @Cacheable(cacheNames = KeyPrefix.API_ROLES, key = "'all'") + @PostMapping("system/api/list_roles_vo") + List listRolesVo(); + +} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysLogClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysLogClient.java new file mode 100644 index 00000000..e37d0201 --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysLogClient.java @@ -0,0 +1,23 @@ +package com.github.cadecode.uniboot.framework.api.feign; + +import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import javax.validation.constraints.NotEmpty; +import java.util.List; + +/** + * SysLog feign client + * + * @author Cade Li + * @since 2023/7/28 + */ +@FeignClient(contextId = "SysLogClient", name = "uni-boot-framework") +public interface SysLogClient { + + @PostMapping("system/log/save") + boolean save(@RequestBody @NotEmpty List poList); + +} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java index e2c86684..154f3ffe 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java @@ -12,7 +12,7 @@ import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogInfoDto; import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; import com.github.cadecode.uniboot.framework.api.convert.SysLogConvert; -import com.github.cadecode.uniboot.framework.api.service.SysLogService; +import com.github.cadecode.uniboot.framework.api.feign.SysLogClient; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -22,6 +22,8 @@ import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; +import java.util.Collections; + /** * Api Log 处理器实现 * @@ -33,7 +35,7 @@ @Component public class ApiLogHandler extends AbstractApiLogHandler { - private final SysLogService sysLogService; + private final SysLogClient sysLogClient; /** * 构造 LogInfo @@ -49,7 +51,7 @@ public SysLogInfoDto generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogI paramsJson = JacksonUtil.toJson(getRequestParams(point, apiLogger)); } catch (Exception e) { paramsJson = ExceptionUtil.stacktraceToString(e); - log.warn("API log [{}]: request params to json fail", apiLogger.type().getType(), e); + log.error("API log [{}]: request params to json fail", apiLogger.type().getType(), e); } // 获取描述 String description = apiLogger.description(); @@ -94,6 +96,10 @@ public void save(ApiLogger apiLogger, Object o) { if (!apiLogger.saveResult()) { po.setResult(null); } - sysLogService.save(po); + try { + sysLogClient.save(Collections.singletonList(po)); + } catch (Exception e) { + log.error("API log [{}]: save fail", apiLogger.type().getType(), e); + } } } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java index 520c163f..524e6a95 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java @@ -1,9 +1,9 @@ package com.github.cadecode.uniboot.framework.api.security.voter; import cn.hutool.core.util.ObjectUtil; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.api.service.SysApiService; +import com.github.cadecode.uniboot.framework.api.feign.SysApiClient; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import lombok.RequiredArgsConstructor; import org.springframework.security.access.ConfigAttribute; @@ -31,7 +31,7 @@ public class DataBaseRoleVoter extends RoleVoter { // ant 匹配器 private final AntPathMatcher antPathMatcher = new AntPathMatcher(); - private final SysApiService sysApiService; + private final SysApiClient sysApiClient; @Override public int vote(Authentication authentication, Object object, Collection attributes) { @@ -42,9 +42,9 @@ public int vote(Authentication authentication, Object object, Collection sysApiRolesVos = sysApiService.listRolesVo(); + List sysApiRolesVos = sysApiClient.listRolesVo(); // 获取用户角色 - SysUserDto.SysUserDetailsDto sysUserDetailsDto = SecurityUtil.getUserDetails(authentication); + SysUserDetailsDto sysUserDetailsDto = SecurityUtil.getUserDetails(authentication); List roles = sysUserDetailsDto.getRoles(); // 获取与 url 相同的配置,不存在与 url 相同配置则使用 spring mvc ant 风格匹配 SysApiRolesVo sysApiRolesVo = sysApiRolesVos.stream() diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java index 06411926..0cd888a9 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java @@ -32,15 +32,15 @@ public class SecurityUtil implements InitializingBean { // 从 SecurityConfig 获取 token 配置 public static String getHeader() { - return PROPERTIES.getToken().getHeader(); + return PROPERTIES.getTokenConfig().getHeader(); } public static Long getExpiration() { - return PROPERTIES.getToken().getExpiration(); + return PROPERTIES.getTokenConfig().getExpiration(); } public static String getSecret() { - return PROPERTIES.getToken().getSecret(); + return PROPERTIES.getTokenConfig().getSecret(); } /** diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java new file mode 100644 index 00000000..a16380e9 --- /dev/null +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java @@ -0,0 +1,112 @@ +package com.github.cadecode.uniboot.framework.svc.config; + +import com.github.cadecode.uniboot.framework.api.config.SecurityConfig; +import com.github.cadecode.uniboot.framework.api.security.filter.TokenAuthFilter; +import com.github.cadecode.uniboot.framework.api.security.handler.NoAuthenticationHandler; +import com.github.cadecode.uniboot.framework.api.security.handler.NoAuthorityHandler; +import com.github.cadecode.uniboot.framework.api.security.voter.DataBaseRoleVoter; +import com.github.cadecode.uniboot.framework.svc.security.LoginFailureHandler; +import com.github.cadecode.uniboot.framework.svc.security.LoginSuccessHandler; +import com.github.cadecode.uniboot.framework.svc.security.SignOutSuccessHandler; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity.IgnoredRequestConfigurer; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; + +/** + * SecurityConfig 补充配置 + * 登录认证相关配置 + * + * @author Cade Li + * @since 2023/7/28 + */ +@Slf4j +@Configuration +public class FrameSecurityConfig extends SecurityConfig { + + /** + * 登录参数 + */ + public static final String USERNAME_PARAMETER = "username"; + public static final String PASSWORD_PARAMETER = "password"; + + /** + * 登录路径 + */ + public static final String LOGIN_URL = "/login"; + + /** + * 注销路径 + */ + public static final String LOGOUT_URL = "/logout"; + + /** + * 注入各种处理器 + */ + private final LoginSuccessHandler loginSuccessHandler; + private final LoginFailureHandler loginFailureHandler; + private final SignOutSuccessHandler signOutSuccessHandler; + + /** + * 注入 UserDetailsService + */ + private final UserDetailsService userDetailsService; + + private static final PasswordEncoder PASSWORD_ENCODER = new BCryptPasswordEncoder(); + + public FrameSecurityConfig(SecurityProperties properties, NoAuthenticationHandler noAuthenticationHandler, + NoAuthorityHandler noAuthorityHandler, TokenAuthFilter tokenAuthFilter, + DataBaseRoleVoter dataBaseRoleVoter, LoginSuccessHandler loginSuccessHandler, + LoginFailureHandler loginFailureHandler, SignOutSuccessHandler signOutSuccessHandler, + UserDetailsService userDetailsService) { + super(properties, noAuthenticationHandler, noAuthorityHandler, tokenAuthFilter, dataBaseRoleVoter); + this.loginSuccessHandler = loginSuccessHandler; + this.loginFailureHandler = loginFailureHandler; + this.signOutSuccessHandler = signOutSuccessHandler; + this.userDetailsService = userDetailsService; + } + + /** + * 密码加密器 + */ + @Bean + public PasswordEncoder passwordEncoder() { + return PASSWORD_ENCODER; + } + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + auth.userDetailsService(userDetailsService).passwordEncoder(PASSWORD_ENCODER); + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + super.configure(http); + // 配置注销处理器 + http.logout().permitAll() + .logoutUrl(LOGOUT_URL) + .logoutSuccessHandler(signOutSuccessHandler); + // 配置登录处理器 + http.formLogin().permitAll() + .loginProcessingUrl(LOGIN_URL) + .usernameParameter(USERNAME_PARAMETER) + .passwordParameter(PASSWORD_PARAMETER) + .successHandler(loginSuccessHandler) + .failureHandler(loginFailureHandler); + log.info("Config Security login url:{}, logout url:{}", LOGIN_URL, LOGOUT_URL); + } + + @Override + public void configure(WebSecurity web) { + super.configure(web); + IgnoredRequestConfigurer ignoring = web.ignoring(); + // 放行 framework 服务公共接口 + ignoring.antMatchers("/auth/login", "/system/log/save", "/system/api/list_roles_vo"); + } +} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java index 9cb0af69..9d2c3ef9 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java @@ -1,26 +1,19 @@ package com.github.cadecode.uniboot.framework.svc.controller; -import cn.hutool.http.HttpResponse; -import cn.hutool.http.HttpUtil; -import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.api.config.SecurityConfig; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - /** * 认证API * @@ -35,34 +28,34 @@ @RequestMapping("auth") public class AuthController { - /** - * 复用Security login接口,方便swagger展示 - */ + private final AuthClient authClient; + @ApiLogger(type = LogTypeEnum.AUTH, enableSave = true, description = "用户登录") @ApiOperation("登录") @PostMapping("login") - public ApiResult login(HttpServletRequest request, HttpServletResponse response, - @RequestParam String username, @RequestParam String password) { - String replacedURL = request.getRequestURL().toString().replace("/auth/login", SecurityConfig.LOGIN_URL); - HttpResponse loginRes = HttpUtil.createPost(replacedURL) - .form(SecurityConfig.USERNAME_PARAMETER, username) - .form(SecurityConfig.PASSWORD_PARAMETER, password) - .execute(); - response.addHeader(SecurityUtil.getHeader(), loginRes.header(SecurityUtil.getHeader())); - return JacksonUtil.toBean(loginRes.body(), ApiResult.class); + public ApiResult login(@RequestParam String username, @RequestParam String password) { + return authClient.login(username, password); } - /** - * 复用Security logout接口,方便swagger展示 - */ @ApiLogger(type = LogTypeEnum.AUTH, enableSave = true, description = "用户注销") @ApiOperation("注销") @PostMapping("logout") - public ApiResult logout(HttpServletRequest request, HttpServletResponse response) { - String replacedURL = request.getRequestURL().toString().replace("/auth/logout", SecurityConfig.LOGOUT_URL); - HttpResponse loginRes = HttpUtil.createPost(replacedURL) - .header(SecurityUtil.getHeader(), request.getHeader(SecurityUtil.getHeader())) - .execute(); - return JacksonUtil.toBean(loginRes.body(), ApiResult.class); + public ApiResult logout() { + return authClient.logout(); + } + + /** + * 使用 feign 调用 Security login/logout 接口 + * 1. 方便在 swagger 展示和调试 + * 2. 方便对接口进行 log 等监控 + */ + @FeignClient(contextId = "AuthClient", name = "uni-boot-framework") + public interface AuthClient { + + @PostMapping("login") + ApiResult login(@RequestParam("username") String username, @RequestParam("password") String password); + + @PostMapping("logout") + ApiResult logout(); } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java index 45d53a3f..b6cb6a71 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java @@ -9,8 +9,8 @@ import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; import com.github.cadecode.uniboot.framework.api.convert.SysApiConvert; import com.github.cadecode.uniboot.framework.api.request.SysApiRequest; -import com.github.cadecode.uniboot.framework.api.service.SysApiService; -import com.github.cadecode.uniboot.framework.api.service.SysRoleService; +import com.github.cadecode.uniboot.framework.svc.service.SysApiService; +import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -120,4 +120,13 @@ public List listSwaggerVo() { .sorted(Comparator.comparing(SysApiSwaggerVo::getUrl)) .collect(Collectors.toList()); } + + + // For feign client + @ApiFormat(false) + @ApiOperation("查询API列表-全部") + @PostMapping("list_roles_vo") + public List listRolesVo() { + return sysApiService.listRolesVo(); + } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java index d4259452..b871e76a 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java @@ -9,7 +9,7 @@ import com.github.cadecode.uniboot.framework.api.bean.vo.SysDictVo.SysDictSuggestVo; import com.github.cadecode.uniboot.framework.api.convert.SysDictConvert; import com.github.cadecode.uniboot.framework.api.request.SysDictRequest; -import com.github.cadecode.uniboot.framework.api.service.SysDictService; +import com.github.cadecode.uniboot.framework.svc.service.SysDictService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java index f03073cd..514786ad 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java @@ -7,8 +7,8 @@ import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; import com.github.cadecode.uniboot.framework.api.bean.vo.SysLogVo.SysLogPageVo; import com.github.cadecode.uniboot.framework.api.convert.SysLogConvert; -import com.github.cadecode.uniboot.framework.api.request.SysLogRequest; -import com.github.cadecode.uniboot.framework.api.service.SysLogService; +import com.github.cadecode.uniboot.framework.api.request.SysLogRequest.SysLogPageRequest; +import com.github.cadecode.uniboot.framework.svc.service.SysLogService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; @@ -44,7 +44,7 @@ public class SysLogController { @ApiOperation("查询列表") @PostMapping("page") - public PageResult page(@RequestBody @Valid SysLogRequest.SysLogPageRequest request) { + public PageResult page(@RequestBody @Valid SysLogPageRequest request) { PageInfo pageInfo = PageHelper.startPage(request.getPageNumber(), request.getPageSize()) .doSelectPageInfo(() -> logService.lambdaQuery() .ge(ObjectUtil.isNotEmpty(request.getStartTime()), SysLog::getCreateTime, request.getStartTime()) @@ -65,4 +65,11 @@ public boolean delete(@RequestBody @NotEmpty List idList) { return logService.removeBatchByIds(idList); } + // For feign client + @ApiFormat(false) + @ApiOperation("添加") + @PostMapping("save") + public boolean save(@RequestBody @NotEmpty List poList) { + return logService.saveBatch(poList); + } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java index fb54cc58..360075f5 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java @@ -6,8 +6,8 @@ import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuRolesVo; import com.github.cadecode.uniboot.framework.api.convert.SysMenuConvert; import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest; -import com.github.cadecode.uniboot.framework.api.service.SysMenuService; -import com.github.cadecode.uniboot.framework.api.service.SysRoleService; +import com.github.cadecode.uniboot.framework.svc.service.SysMenuService; +import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java index ba97e92c..bb6a1fa3 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java @@ -9,7 +9,7 @@ import com.github.cadecode.uniboot.framework.api.convert.SysRoleConvert; import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest; import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleMappingRequest; -import com.github.cadecode.uniboot.framework.api.service.SysRoleService; +import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java index f29d4752..19c4ba3c 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java @@ -11,10 +11,10 @@ import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; import com.github.cadecode.uniboot.framework.api.convert.SysUserConvert; import com.github.cadecode.uniboot.framework.api.request.SysUserRequest; -import com.github.cadecode.uniboot.framework.api.service.SysMenuService; -import com.github.cadecode.uniboot.framework.api.service.SysRoleService; -import com.github.cadecode.uniboot.framework.api.service.SysUserService; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.svc.service.SysMenuService; +import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; +import com.github.cadecode.uniboot.framework.svc.service.SysUserService; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysApiMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysApiMapper.java similarity index 92% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysApiMapper.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysApiMapper.java index 22368f7c..40242751 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysApiMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysApiMapper.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.mapper; +package com.github.cadecode.uniboot.framework.svc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysDictMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysDictMapper.java similarity index 84% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysDictMapper.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysDictMapper.java index 1594660e..2b25612f 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysDictMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysDictMapper.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.mapper; +package com.github.cadecode.uniboot.framework.svc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.cadecode.uniboot.framework.api.bean.po.SysDict; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysLogMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysLogMapper.java similarity index 84% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysLogMapper.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysLogMapper.java index bef3e7a6..bf5eadec 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysLogMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysLogMapper.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.mapper; +package com.github.cadecode.uniboot.framework.svc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysMenuMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysMenuMapper.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysMenuMapper.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysMenuMapper.java index b479c079..67c44c8f 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysMenuMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysMenuMapper.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.mapper; +package com.github.cadecode.uniboot.framework.svc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.cadecode.uniboot.framework.api.bean.po.SysMenu; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysRoleMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysRoleMapper.java similarity index 96% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysRoleMapper.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysRoleMapper.java index 04e0db7a..272c6954 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysRoleMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysRoleMapper.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.mapper; +package com.github.cadecode.uniboot.framework.svc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.cadecode.uniboot.framework.api.bean.po.SysRole; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysUserMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysUserMapper.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysUserMapper.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysUserMapper.java index efe83fa8..ca29137d 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/mapper/SysUserMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysUserMapper.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.mapper; +package com.github.cadecode.uniboot.framework.svc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/JwtLoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java similarity index 88% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/JwtLoginSuccessHandleService.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java index 555b27be..77053672 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/JwtLoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java @@ -1,13 +1,13 @@ -package com.github.cadecode.uniboot.framework.api.security.handler; +package com.github.cadecode.uniboot.framework.svc.security; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.core.util.TokenUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.api.config.SecurityConfig; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Component; @@ -32,7 +32,7 @@ public ApiResult getResult(HttpServletRequest request, HttpSe SecurityUtil.getExpiration(), SecurityUtil.getSecret()); // token 放在请求头 response.addHeader(SecurityUtil.getHeader(), jwtToken); - return ApiResult.ok(sysUserDetailsDto).path(SecurityConfig.LOGOUT_URL); + return ApiResult.ok(sysUserDetailsDto).path(FrameSecurityConfig.LOGOUT_URL); } @Override diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginFailureHandler.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginFailureHandler.java similarity index 89% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginFailureHandler.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginFailureHandler.java index 22466c63..7592ec88 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginFailureHandler.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginFailureHandler.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.security.handler; +package com.github.cadecode.uniboot.framework.svc.security; import cn.hutool.core.util.CharsetUtil; import cn.hutool.extra.servlet.ServletUtil; @@ -6,8 +6,8 @@ import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.api.config.SecurityConfig; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; +import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import org.springframework.security.authentication.BadCredentialsException; import org.springframework.security.core.AuthenticationException; import org.springframework.security.web.authentication.AuthenticationFailureHandler; @@ -28,7 +28,7 @@ public class LoginFailureHandler implements AuthenticationFailureHandler { @Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) { - ApiResult result = ApiResult.error(AuthErrorEnum.TOKEN_CREATE_ERROR).path(SecurityConfig.LOGIN_URL); + ApiResult result = ApiResult.error(AuthErrorEnum.TOKEN_CREATE_ERROR).path(FrameSecurityConfig.LOGIN_URL); response.setStatus(AuthErrorEnum.TOKEN_CREATE_ERROR.getStatus()); Throwable cause = exception.getCause() == null ? exception : exception.getCause(); if (cause instanceof ApiException) { diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandleService.java similarity index 91% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginSuccessHandleService.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandleService.java index e7855207..3798c5e7 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandleService.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.security.handler; +package com.github.cadecode.uniboot.framework.svc.security; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyService; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginSuccessHandler.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java similarity index 95% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginSuccessHandler.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java index e5025cc7..4be2833d 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/LoginSuccessHandler.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.security.handler; +package com.github.cadecode.uniboot.framework.svc.security; import cn.hutool.core.net.NetUtil; import cn.hutool.core.util.CharsetUtil; @@ -11,7 +11,7 @@ import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; -import com.github.cadecode.uniboot.framework.api.service.SysUserService; +import com.github.cadecode.uniboot.framework.svc.service.SysUserService; import lombok.RequiredArgsConstructor; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.AuthenticationSuccessHandler; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/RedisLoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java similarity index 89% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/RedisLoginSuccessHandleService.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java index 27cb6957..d3558760 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/RedisLoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.security.handler; +package com.github.cadecode.uniboot.framework.svc.security; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; @@ -6,10 +6,10 @@ import com.github.cadecode.uniboot.common.plugin.cache.util.RedisUtil; import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.api.config.SecurityConfig; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Component; @@ -37,7 +37,7 @@ public ApiResult getResult(HttpServletRequest requ // 生成存放登录信息的 redis key String loginUserKey = KeyGeneUtil.key(KeyPrefix.LOGIN_USER, uuidToken); RedisUtil.set(loginUserKey, sysUserDetailsDto, SecurityUtil.getExpiration(), TimeUnit.SECONDS); - return ApiResult.ok(sysUserDetailsDto).path(SecurityConfig.LOGOUT_URL); + return ApiResult.ok(sysUserDetailsDto).path(FrameSecurityConfig.LOGOUT_URL); } @Override diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/SignOutSuccessHandler.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java similarity index 91% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/SignOutSuccessHandler.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java index 9d33ea4e..4b1b8b43 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/SignOutSuccessHandler.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.security.handler; +package com.github.cadecode.uniboot.framework.svc.security; import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.StrUtil; @@ -8,12 +8,12 @@ import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; import com.github.cadecode.uniboot.common.plugin.cache.util.RedisUtil; -import com.github.cadecode.uniboot.framework.api.config.SecurityConfig; import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import lombok.RequiredArgsConstructor; import org.springframework.security.core.Authentication; import org.springframework.security.web.authentication.logout.LogoutSuccessHandler; @@ -44,7 +44,7 @@ public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse resp RedisUtil.del(loginUserKey); } // 写入响应 - ApiResult result = ApiResult.error(AuthErrorEnum.TOKEN_LOGOUT).path(SecurityConfig.LOGOUT_URL); + ApiResult result = ApiResult.error(AuthErrorEnum.TOKEN_LOGOUT).path(FrameSecurityConfig.LOGOUT_URL); response.setStatus(AuthErrorEnum.TOKEN_LOGOUT.getStatus()); ServletUtil.write(response, JacksonUtil.toJson(result), ContentType.JSON.toString(CharsetUtil.CHARSET_UTF_8)); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysApiService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysApiService.java similarity index 92% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysApiService.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysApiService.java index e0b7ac10..37535e4b 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysApiService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysApiService.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.service; +package com.github.cadecode.uniboot.framework.svc.service; import com.baomidou.mybatisplus.extension.service.IService; import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysDictService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysDictService.java similarity index 81% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysDictService.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysDictService.java index 0d7ad19f..86bd0573 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysDictService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysDictService.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.service; +package com.github.cadecode.uniboot.framework.svc.service; import com.baomidou.mybatisplus.extension.service.IService; import com.github.cadecode.uniboot.framework.api.bean.po.SysDict; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysLogService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysLogService.java similarity index 81% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysLogService.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysLogService.java index 10760bab..a1df6d61 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysLogService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysLogService.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.service; +package com.github.cadecode.uniboot.framework.svc.service; import com.baomidou.mybatisplus.extension.service.IService; import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysMenuService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysMenuService.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysMenuService.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysMenuService.java index 7f0c9b82..a8f94624 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysMenuService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysMenuService.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.service; +package com.github.cadecode.uniboot.framework.svc.service; import com.baomidou.mybatisplus.extension.service.IService; import com.github.cadecode.uniboot.framework.api.bean.po.SysMenu; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysRoleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysRoleService.java similarity index 96% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysRoleService.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysRoleService.java index e07833e0..b13af840 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysRoleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysRoleService.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.service; +package com.github.cadecode.uniboot.framework.svc.service; import com.baomidou.mybatisplus.extension.service.IService; import com.github.cadecode.uniboot.framework.api.bean.po.SysRole; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysUserService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysUserService.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysUserService.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysUserService.java index 0fbd2bc7..4916d6a3 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/service/SysUserService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysUserService.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.service; +package com.github.cadecode.uniboot.framework.svc.service; import com.baomidou.mybatisplus.extension.service.IService; import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysApiServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysApiServiceImpl.java similarity index 79% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysApiServiceImpl.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysApiServiceImpl.java index 49e8bea0..7238eec6 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysApiServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysApiServiceImpl.java @@ -1,16 +1,14 @@ -package com.github.cadecode.uniboot.framework.api.serviceimpl; +package com.github.cadecode.uniboot.framework.svc.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.api.mapper.SysApiMapper; import com.github.cadecode.uniboot.framework.api.request.SysApiRequest.SysApiRolesRequest; -import com.github.cadecode.uniboot.framework.api.service.SysApiService; +import com.github.cadecode.uniboot.framework.svc.mapper.SysApiMapper; +import com.github.cadecode.uniboot.framework.svc.service.SysApiService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.RequiredArgsConstructor; -import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; import java.util.List; @@ -27,7 +25,6 @@ public class SysApiServiceImpl extends ServiceImpl impleme private final SysApiMapper sysApiMapper; - @Cacheable(cacheNames = KeyPrefix.API_ROLES, key = "'all'") @Override public List listRolesVo() { return sysApiMapper.selectRolesVo(null); diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysDictServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysDictServiceImpl.java similarity index 67% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysDictServiceImpl.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysDictServiceImpl.java index a6f0bc3a..97a73ce6 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysDictServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysDictServiceImpl.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.api.serviceimpl; +package com.github.cadecode.uniboot.framework.svc.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.cadecode.uniboot.framework.api.bean.po.SysDict; -import com.github.cadecode.uniboot.framework.api.mapper.SysDictMapper; -import com.github.cadecode.uniboot.framework.api.service.SysDictService; +import com.github.cadecode.uniboot.framework.svc.mapper.SysDictMapper; +import com.github.cadecode.uniboot.framework.svc.service.SysDictService; import org.springframework.stereotype.Service; /** diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysLogServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysLogServiceImpl.java similarity index 66% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysLogServiceImpl.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysLogServiceImpl.java index 2b01b644..b4630b7f 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysLogServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysLogServiceImpl.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.api.serviceimpl; +package com.github.cadecode.uniboot.framework.svc.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; -import com.github.cadecode.uniboot.framework.api.mapper.SysLogMapper; -import com.github.cadecode.uniboot.framework.api.service.SysLogService; +import com.github.cadecode.uniboot.framework.svc.mapper.SysLogMapper; +import com.github.cadecode.uniboot.framework.svc.service.SysLogService; import org.springframework.stereotype.Service; /** diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysMenuServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java similarity index 94% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysMenuServiceImpl.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java index 96021eed..114f3a7c 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysMenuServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.serviceimpl; +package com.github.cadecode.uniboot.framework.svc.serviceimpl; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -6,9 +6,9 @@ import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuRolesVo; import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; import com.github.cadecode.uniboot.framework.api.convert.SysMenuConvert; -import com.github.cadecode.uniboot.framework.api.mapper.SysMenuMapper; import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest.SysMenuRolesRequest; -import com.github.cadecode.uniboot.framework.api.service.SysMenuService; +import com.github.cadecode.uniboot.framework.svc.mapper.SysMenuMapper; +import com.github.cadecode.uniboot.framework.svc.service.SysMenuService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.RequiredArgsConstructor; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysRoleServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java similarity index 95% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysRoleServiceImpl.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java index 9b2b642c..34599127 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysRoleServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java @@ -1,13 +1,13 @@ -package com.github.cadecode.uniboot.framework.api.serviceimpl; +package com.github.cadecode.uniboot.framework.svc.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.cadecode.uniboot.framework.api.bean.po.SysRole; import com.github.cadecode.uniboot.framework.api.bean.vo.SysRoleVo.SysRoleUnionVo; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.api.mapper.SysRoleMapper; import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleMappingRequest; import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleUnionRequest; -import com.github.cadecode.uniboot.framework.api.service.SysRoleService; +import com.github.cadecode.uniboot.framework.svc.mapper.SysRoleMapper; +import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.RequiredArgsConstructor; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysUserServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java similarity index 92% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysUserServiceImpl.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java index 314a7249..01adf9ea 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/serviceimpl/SysUserServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.serviceimpl; +package com.github.cadecode.uniboot.framework.svc.serviceimpl; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -6,9 +6,9 @@ import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; import com.github.cadecode.uniboot.framework.api.convert.SysUserConvert; -import com.github.cadecode.uniboot.framework.api.mapper.SysUserMapper; import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserRolesRequest; -import com.github.cadecode.uniboot.framework.api.service.SysUserService; +import com.github.cadecode.uniboot.framework.svc.mapper.SysUserMapper; +import com.github.cadecode.uniboot.framework.svc.service.SysUserService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.RequiredArgsConstructor; diff --git a/framework/framework_svc/src/main/resources/bootstrap.yml b/framework/framework_svc/src/main/resources/bootstrap.yml index 177ac15f..8840bf68 100644 --- a/framework/framework_svc/src/main/resources/bootstrap.yml +++ b/framework/framework_svc/src/main/resources/bootstrap.yml @@ -2,10 +2,6 @@ logging: file: path: /log/uni_boot_admin/framework -server: - servlet: - context-path: /framework - spring: application: name: uni-boot-framework diff --git a/framework/framework_api/src/main/resources/mapper/SysApiMapper.xml b/framework/framework_svc/src/main/resources/mapper/SysApiMapper.xml similarity index 97% rename from framework/framework_api/src/main/resources/mapper/SysApiMapper.xml rename to framework/framework_svc/src/main/resources/mapper/SysApiMapper.xml index 668df50a..7783197b 100644 --- a/framework/framework_api/src/main/resources/mapper/SysApiMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/SysApiMapper.xml @@ -1,6 +1,6 @@ - + diff --git a/framework/framework_api/src/main/resources/mapper/SysMenuMapper.xml b/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml similarity index 98% rename from framework/framework_api/src/main/resources/mapper/SysMenuMapper.xml rename to framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml index c337910d..6e169ab7 100644 --- a/framework/framework_api/src/main/resources/mapper/SysMenuMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml @@ -1,6 +1,6 @@ - + diff --git a/framework/framework_api/src/main/resources/mapper/SysRoleMapper.xml b/framework/framework_svc/src/main/resources/mapper/SysRoleMapper.xml similarity index 99% rename from framework/framework_api/src/main/resources/mapper/SysRoleMapper.xml rename to framework/framework_svc/src/main/resources/mapper/SysRoleMapper.xml index 0865c118..48bfef8e 100644 --- a/framework/framework_api/src/main/resources/mapper/SysRoleMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/SysRoleMapper.xml @@ -1,6 +1,6 @@ - + diff --git a/framework/framework_api/src/main/resources/mapper/SysUserMapper.xml b/framework/framework_svc/src/main/resources/mapper/SysUserMapper.xml similarity index 98% rename from framework/framework_api/src/main/resources/mapper/SysUserMapper.xml rename to framework/framework_svc/src/main/resources/mapper/SysUserMapper.xml index fcf420cf..d9a3b93b 100644 --- a/framework/framework_api/src/main/resources/mapper/SysUserMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/SysUserMapper.xml @@ -1,6 +1,6 @@ - + From 5448b098ecaca20102425a59109f3986e0a6bba9 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 29 Jul 2023 10:33:23 +0800 Subject: [PATCH 009/244] =?UTF-8?q?refactor:=20log=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/cadecode/uniboot/common/core/util/JacksonUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/util/JacksonUtil.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/util/JacksonUtil.java index e79c6ff5..4c421c19 100644 --- a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/util/JacksonUtil.java +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/util/JacksonUtil.java @@ -188,7 +188,7 @@ public static T toBean(String json, boolean typing, TypeReference typeRef public void afterPropertiesSet() { PROJECT_OBJECT_MAPPER = objectMapper; if (Objects.isNull(PROJECT_OBJECT_MAPPER)) { - log.warn("Bean objectMapper not found, use default config by JacksonUtil"); + log.debug("Bean objectMapper not found, use default config by JacksonUtil"); PROJECT_OBJECT_MAPPER = new ObjectMapper(); // 定义日期格式 String STANDARD_FORMAT = "yyyy-MM-dd HH:mm:ss"; From b44a321d5a18a5e7e55a401ddfb252627a6f2ab7 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 29 Jul 2023 14:05:31 +0800 Subject: [PATCH 010/244] =?UTF-8?q?feat:=20=E5=8D=87=E7=BA=A7=20knife4j=20?= =?UTF-8?q?=E5=88=B0=203.0.3=EF=BC=8C=E7=BB=9F=E4=B8=80=E9=9B=86=E6=88=90?= =?UTF-8?q?=E5=88=B0=20gateway=20swagger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../swagger/config/SwaggerAutoConfig.java | 2 - dependencies/pom.xml | 2 +- gateway/pom.xml | 5 ++ .../gateway/config/GatewaySwaggerConfig.java | 72 +++++++++++++++++++ .../gateway/controller/SwaggerController.java | 59 +++++++++++++++ 5 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 gateway/src/main/java/com/github/cadecode/uniboot/gateway/config/GatewaySwaggerConfig.java create mode 100644 gateway/src/main/java/com/github/cadecode/uniboot/gateway/controller/SwaggerController.java diff --git a/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/config/SwaggerAutoConfig.java b/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/config/SwaggerAutoConfig.java index b9fb601a..503cb15b 100644 --- a/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/config/SwaggerAutoConfig.java +++ b/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/config/SwaggerAutoConfig.java @@ -10,7 +10,6 @@ import org.springframework.context.annotation.Import; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; /** * Swagger WebMvc 配置 @@ -19,7 +18,6 @@ * @since 2023/6/8 */ @RequiredArgsConstructor -@EnableSwagger2WebMvc @EnableKnife4j @Configuration @Import(SwaggerRegisterKit.class) diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 172597bd..6c219f84 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -30,7 +30,7 @@ 31.0.1-jre 1.0.0-alpha-4 2.3.2 - 2.0.9 + 3.0.3 2.2.0 1.4.0 3.5.1 diff --git a/gateway/pom.xml b/gateway/pom.xml index 627af658..c55cd72e 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -68,6 +68,11 @@ com.github.ulisesbocchio jasypt-spring-boot-starter + + + com.github.xiaoymin + knife4j-spring-boot-starter + com.github.cadecode diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/config/GatewaySwaggerConfig.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/config/GatewaySwaggerConfig.java new file mode 100644 index 00000000..a8be4281 --- /dev/null +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/config/GatewaySwaggerConfig.java @@ -0,0 +1,72 @@ +package com.github.cadecode.uniboot.gateway.config; + +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; +import lombok.RequiredArgsConstructor; +import org.springframework.cloud.gateway.config.GatewayProperties; +import org.springframework.cloud.gateway.route.RouteLocator; +import org.springframework.cloud.gateway.support.NameUtils; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import springfox.documentation.swagger.web.SwaggerResource; +import springfox.documentation.swagger.web.SwaggerResourcesProvider; + +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * Gateway swagger 聚合配置 + * + * @author Cade Li + * @since 2023/7/29 + */ +@RequiredArgsConstructor +@EnableKnife4j +@Configuration +public class GatewaySwaggerConfig { + + /** + * 网关路由 + */ + private final RouteLocator routeLocator; + + private final GatewayProperties gatewayProperties; + + @Primary + @Bean + public SwaggerResourcesProvider resourcesProvider() { + return new SwaggerResourcesProvider() { + /** + * 聚合服务接口 + */ + @Override + public List get() { + Set routeSet = new HashSet<>(); + // 获取网关中配置的 route + routeLocator.getRoutes().subscribe(o -> routeSet.add(o.getId())); + return gatewayProperties.getRoutes().stream() + .filter(o -> routeSet.contains(o.getId())) + .flatMap(o -> o.getPredicates().stream() + .filter(p -> "Path".equalsIgnoreCase(p.getName())) + .map(p -> geneSwaggerResource(o.getId(), p.getArgs())) + .collect(Collectors.toList()) + .stream()) + .collect(Collectors.toList()); + } + + }; + } + + private SwaggerResource geneSwaggerResource(String name, Map args) { + // 获取 swagger2 location + String location = args.get(NameUtils.GENERATED_NAME_PREFIX + "0").replace("/**", "/v2/api-docs"); + SwaggerResource swaggerResource = new SwaggerResource(); + swaggerResource.setName(name); + swaggerResource.setLocation(location); + swaggerResource.setSwaggerVersion("2.0"); + return swaggerResource; + } +} diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/controller/SwaggerController.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/controller/SwaggerController.java new file mode 100644 index 00000000..71289621 --- /dev/null +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/controller/SwaggerController.java @@ -0,0 +1,59 @@ +package com.github.cadecode.uniboot.gateway.controller; + +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Autowired; +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 reactor.core.publisher.Mono; +import springfox.documentation.swagger.web.*; + +import java.util.Optional; + +/** + * Swagger 网关统一接口 + * + * @author Cade Li + * @since 2023/7/29 + */ +@RequiredArgsConstructor +@RestController +@RequestMapping("/swagger-resources") +public class SwaggerController { + + private final SwaggerResourcesProvider resourcesProvider; + + private SecurityConfiguration securityConfiguration; + + private UiConfiguration uiConfiguration; + + @Autowired(required = false) + public void setSecurityConfiguration(SecurityConfiguration securityConfiguration) { + this.securityConfiguration = securityConfiguration; + } + + @Autowired(required = false) + public void setUiConfiguration(UiConfiguration uiConfiguration) { + this.uiConfiguration = uiConfiguration; + } + + @GetMapping("/configuration/security") + public Mono> securityConfiguration() { + return Mono.just(new ResponseEntity<>(Optional.ofNullable(securityConfiguration) + .orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK)); + } + + @GetMapping("/configuration/ui") + public Mono> uiConfiguration() { + return Mono.just(new ResponseEntity<>(Optional.ofNullable(uiConfiguration) + .orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK)); + } + + @SuppressWarnings("rawtypes") + @GetMapping("") + public Mono swaggerResources() { + return Mono.just((new ResponseEntity<>(resourcesProvider.get(), HttpStatus.OK))); + } +} From 805997fdafd04c83dda5320e19c706222fbe45aa Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 29 Jul 2023 20:15:14 +0800 Subject: [PATCH 011/244] =?UTF-8?q?fix:=20rpc=20=E8=B0=83=E7=94=A8=20login?= =?UTF-8?q?=20=E8=8E=B7=E5=8F=96=E8=AF=B7=E6=B1=82=E5=A4=B4=E4=B8=AD=20tok?= =?UTF-8?q?en?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../svc/controller/AuthController.java | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java index 9d2c3ef9..197a7ea5 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java @@ -1,9 +1,15 @@ package com.github.cadecode.uniboot.framework.svc.controller; +import cn.hutool.core.io.IoUtil; +import cn.hutool.core.util.CharsetUtil; +import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; +import feign.Response; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -14,6 +20,9 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + /** * 认证API * @@ -33,8 +42,14 @@ public class AuthController { @ApiLogger(type = LogTypeEnum.AUTH, enableSave = true, description = "用户登录") @ApiOperation("登录") @PostMapping("login") - public ApiResult login(@RequestParam String username, @RequestParam String password) { - return authClient.login(username, password); + public ApiResult login(HttpServletResponse sResponse, @RequestParam String username, @RequestParam String password) throws IOException { + // 从 rpc 调用中获取 header token 设置到响应 + Response rResponse = authClient.login(username, password); + String token = rResponse.headers().get(SecurityUtil.getHeader()).stream().findFirst().get(); + sResponse.addHeader(SecurityUtil.getHeader(), token); + // 获取 rpc 结果 + String body = IoUtil.read(rResponse.body().asReader(CharsetUtil.CHARSET_UTF_8)); + return JacksonUtil.toBean(body, ApiResult.class); } @ApiLogger(type = LogTypeEnum.AUTH, enableSave = true, description = "用户注销") @@ -52,10 +67,10 @@ public ApiResult logout() { @FeignClient(contextId = "AuthClient", name = "uni-boot-framework") public interface AuthClient { - @PostMapping("login") - ApiResult login(@RequestParam("username") String username, @RequestParam("password") String password); + @PostMapping(FrameSecurityConfig.LOGIN_URL) + Response login(@RequestParam("username") String username, @RequestParam("password") String password); - @PostMapping("logout") + @PostMapping(FrameSecurityConfig.LOGOUT_URL) ApiResult logout(); } } From adfebc04cebb42833295680e0546a041d0aed583 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 29 Jul 2023 20:40:22 +0800 Subject: [PATCH 012/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20const=20Sv?= =?UTF-8?q?cName=20=E7=BB=B4=E6=8A=A4=E6=9C=8D=E5=8A=A1=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/api/consts/SvcName.java | 15 +++++++++++++++ .../uniboot/framework/api/feign/SysApiClient.java | 3 ++- .../uniboot/framework/api/feign/SysLogClient.java | 3 ++- 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SvcName.java diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SvcName.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SvcName.java new file mode 100644 index 00000000..3f7174b4 --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SvcName.java @@ -0,0 +1,15 @@ +package com.github.cadecode.uniboot.framework.api.consts; + +/** + * 服务名称 + * + * @author Cade Li + * @since 2023/7/29 + */ +public interface SvcName { + + String FRAMEWORK = "uni-boot-framework"; + + String EXAMPLE = "uni-boot-example"; + +} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysApiClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysApiClient.java index 85132884..f4480db2 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysApiClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysApiClient.java @@ -2,6 +2,7 @@ import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.consts.SvcName; import org.springframework.cache.annotation.Cacheable; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -14,7 +15,7 @@ * @author Cade Li * @since 2023/7/28 */ -@FeignClient(contextId = "SysApiClient", name = "uni-boot-framework") +@FeignClient(contextId = "SysApiClient", name = SvcName.FRAMEWORK) public interface SysApiClient { @Cacheable(cacheNames = KeyPrefix.API_ROLES, key = "'all'") diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysLogClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysLogClient.java index e37d0201..53251c3c 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysLogClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysLogClient.java @@ -1,6 +1,7 @@ package com.github.cadecode.uniboot.framework.api.feign; import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; +import com.github.cadecode.uniboot.framework.api.consts.SvcName; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -14,7 +15,7 @@ * @author Cade Li * @since 2023/7/28 */ -@FeignClient(contextId = "SysLogClient", name = "uni-boot-framework") +@FeignClient(contextId = "SysLogClient", name = SvcName.FRAMEWORK) public interface SysLogClient { @PostMapping("system/log/save") From f330278bd71e62daae06aa084e78d3c82c71fc4a Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 29 Jul 2023 22:39:02 +0800 Subject: [PATCH 013/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20feign=20?= =?UTF-8?q?=E6=8B=A6=E6=88=AA=E5=99=A8=EF=BC=8C=E4=BC=A0=E9=80=92=20token?= =?UTF-8?q?=E3=80=81=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../svc/controller/RpcExampleController.java | 36 +++++++++++++ .../framework/api/config/FeignConfig.java | 53 +++++++++++++++++++ .../framework/api/consts/SecurityConst.java | 12 +++++ .../framework/api/feign/ExampleClient.java | 20 +++++++ .../filter/JwtTokenAuthFilterService.java | 2 +- .../filter/RedisTokenAuthFilterService.java | 2 +- .../filter/TokenAuthFilterService.java | 20 ++++++- .../svc/controller/ExampleController.java | 35 ++++++++++++ 8 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/ExampleClient.java create mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/ExampleController.java diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java new file mode 100644 index 00000000..b83f28b0 --- /dev/null +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java @@ -0,0 +1,36 @@ +package com.github.cadecode.uniboot.example.svc.controller; + +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.feign.ExampleClient; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * RPC 测试 + * + * @author Cade Li + * @since 2023/7/29 + */ +@ApiFormat +@Slf4j +@RequiredArgsConstructor +@Api(tags = "RPC 测试") +@RestController +@RequestMapping("rpc_example") +public class RpcExampleController { + + private final ExampleClient exampleClient; + + @ApiOperation("传递字符串") + @PostMapping("test_str") + public String testStr(@RequestParam String str) { + return exampleClient.testStr(str); + } + +} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java new file mode 100644 index 00000000..539bd0fc --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java @@ -0,0 +1,53 @@ +package com.github.cadecode.uniboot.framework.api.config; + +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.EscapeUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.servlet.ServletUtil; +import com.github.cadecode.uniboot.common.core.util.JacksonUtil; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import feign.RequestInterceptor; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; + +/** + * OpenFeign 配置类 + * + * @author Cade Li + * @since 2023/7/29 + */ +@Configuration +public class FeignConfig { + + @Bean + public RequestInterceptor requestInterceptor() { + return requestTemplate -> { + // 获取请求对象 + HttpServletRequest sRequest = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + if (ObjectUtil.isNull(sRequest)) { + return; + } + // 传递用户 token + String token = SecurityUtil.getTokenFromRequest(sRequest); + if (StrUtil.isNotEmpty(token)) { + requestTemplate.header(SecurityUtil.getHeader(), token); + } + // 传递用户详细信息 + String userDetailsJson = ServletUtil.getHeader(sRequest, SecurityConst.USER_DETAILS, CharsetUtil.CHARSET_UTF_8); + if (StrUtil.isEmpty(userDetailsJson)) { + SysUserDetailsDto userDetailsDto = SecurityUtil.getUserDetails(null); + userDetailsJson = JacksonUtil.toJson(userDetailsDto); + } + requestTemplate.header(SecurityConst.USER_DETAILS, EscapeUtil.escape(userDetailsJson)); + // 配置客户端 IP + requestTemplate.header("X-Forwarded-For", ServletUtil.getClientIP(sRequest)); + }; + } +} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java new file mode 100644 index 00000000..e237178d --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java @@ -0,0 +1,12 @@ +package com.github.cadecode.uniboot.framework.api.consts; + +/** + * Security 常量 + * + * @author Cade Li + * @since 2023/7/29 + */ +public interface SecurityConst { + + String USER_DETAILS = "feign-user-details"; +} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/ExampleClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/ExampleClient.java new file mode 100644 index 00000000..d02aba22 --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/ExampleClient.java @@ -0,0 +1,20 @@ +package com.github.cadecode.uniboot.framework.api.feign; + +import com.github.cadecode.uniboot.framework.api.consts.SvcName; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * 测试 feign client + * + * @author Cade Li + * @since 2023/7/28 + */ +@FeignClient(contextId = "ExampleClient", name = SvcName.FRAMEWORK) +public interface ExampleClient { + + @PostMapping("example/test_str") + String testStr(@RequestParam("str") String str); + +} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java index b73f23fe..300d7ebc 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java @@ -28,7 +28,7 @@ public class JwtTokenAuthFilterService extends TokenAuthFilterService { @Override - public void filter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { + public void handler(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String requestURI = request.getRequestURI(); String jwtToken = SecurityUtil.getTokenFromRequest(request); // token 不存在 diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java index 348d1bd1..90bc9ee9 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java @@ -32,7 +32,7 @@ public class RedisTokenAuthFilterService extends TokenAuthFilterService { @Override - public void filter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { + public void handler(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { String requestURI = request.getRequestURI(); String uuidToken = SecurityUtil.getTokenFromRequest(request); // token 不存在 diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java index b223751d..559f7fa8 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java @@ -1,12 +1,16 @@ package com.github.cadecode.uniboot.framework.api.security.filter; import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.EscapeUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.http.ContentType; import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyService; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; @@ -54,5 +58,19 @@ protected void writeResponse(HttpServletResponse response, ApiErrorCode errorCod ServletUtil.write(response, JacksonUtil.toJson(result), ContentType.JSON.toString(CharsetUtil.CHARSET_UTF_8)); } - public abstract void filter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException; + public void filter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { + String escapedJson = ServletUtil.getHeader(request, SecurityConst.USER_DETAILS, CharsetUtil.CHARSET_UTF_8); + if (ObjectUtil.isNotEmpty(escapedJson)) { + SysUserDetailsDto userDetailsDto = JacksonUtil.toBean(EscapeUtil.unescape(escapedJson), SysUserDetailsDto.class); + if (ObjectUtil.isNotNull(userDetailsDto)) { + setAuthentication(request, userDetailsDto); + filterChain.doFilter(request, response); + return; + } + } + handler(request, response, filterChain); + } + + public abstract void handler(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException; + } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/ExampleController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/ExampleController.java new file mode 100644 index 00000000..959b363f --- /dev/null +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/ExampleController.java @@ -0,0 +1,35 @@ +package com.github.cadecode.uniboot.framework.svc.controller; + +import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * 测试接口 + * + * @author Cade Li + * @since 2023/7/29 + */ +@ApiFormat +@Slf4j +@RequiredArgsConstructor +@Api(tags = "测试接口") +@RestController +@RequestMapping("example") +public class ExampleController { + + // For feign client + @ApiFormat(false) + @ApiOperation("传递字符串") + @PostMapping("test_str") + public String testStr(@RequestParam String str) { + return str; + } + +} From 32ed99f94acfd2e161b9a338664db1cf66b289e7 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 30 Jul 2023 11:28:37 +0800 Subject: [PATCH 014/244] =?UTF-8?q?refactor:=20=E6=B3=A8=E9=87=8A=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/security/filter/TokenAuthFilterService.java | 11 ++++++++--- .../api/security/voter/DataBaseRoleVoter.java | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java index 559f7fa8..191bf9bd 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java @@ -58,10 +58,15 @@ protected void writeResponse(HttpServletResponse response, ApiErrorCode errorCod ServletUtil.write(response, JacksonUtil.toJson(result), ContentType.JSON.toString(CharsetUtil.CHARSET_UTF_8)); } + /** + * 模板方法 + * 由 handler 方法提供处理 + */ public void filter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { - String escapedJson = ServletUtil.getHeader(request, SecurityConst.USER_DETAILS, CharsetUtil.CHARSET_UTF_8); - if (ObjectUtil.isNotEmpty(escapedJson)) { - SysUserDetailsDto userDetailsDto = JacksonUtil.toBean(EscapeUtil.unescape(escapedJson), SysUserDetailsDto.class); + // 从请求头中提取来自其他服务调用传递得用户信息 + String escapedUserDetailsJson = ServletUtil.getHeader(request, SecurityConst.USER_DETAILS, CharsetUtil.CHARSET_UTF_8); + if (ObjectUtil.isNotEmpty(escapedUserDetailsJson)) { + SysUserDetailsDto userDetailsDto = JacksonUtil.toBean(EscapeUtil.unescape(escapedUserDetailsJson), SysUserDetailsDto.class); if (ObjectUtil.isNotNull(userDetailsDto)) { setAuthentication(request, userDetailsDto); filterChain.doFilter(request, response); diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java index 524e6a95..3cb39724 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java @@ -35,6 +35,7 @@ public class DataBaseRoleVoter extends RoleVoter { @Override public int vote(Authentication authentication, Object object, Collection attributes) { + // 若当前请求没有被认证就弃权 if (!SecurityUtil.isAuthenticated(authentication)) { return ACCESS_ABSTAIN; } From 47f980e6b4d6f2305b7b0429f81d533f0880c4a3 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 30 Jul 2023 11:45:46 +0800 Subject: [PATCH 015/244] =?UTF-8?q?refactor:=20feign=20=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E7=B1=BB=E5=8C=85=E5=90=8D=E4=BF=AE=E6=94=B9=E4=B8=BA=20feignc?= =?UTF-8?q?lient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/example/svc/controller/RpcExampleController.java | 2 +- .../framework/api/{feign => feignclient}/ExampleClient.java | 2 +- .../framework/api/{feign => feignclient}/SysApiClient.java | 2 +- .../framework/api/{feign => feignclient}/SysLogClient.java | 2 +- .../cadecode/uniboot/framework/api/plugin/ApiLogHandler.java | 2 +- .../uniboot/framework/api/security/voter/DataBaseRoleVoter.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) rename framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/{feign => feignclient}/ExampleClient.java (89%) rename framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/{feign => feignclient}/SysApiClient.java (92%) rename framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/{feign => feignclient}/SysLogClient.java (91%) diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java index b83f28b0..f9513e3a 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.example.svc.controller; import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.api.feign.ExampleClient; +import com.github.cadecode.uniboot.framework.api.feignclient.ExampleClient; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/ExampleClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/ExampleClient.java similarity index 89% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/ExampleClient.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/ExampleClient.java index d02aba22..f2b31ecb 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/ExampleClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/ExampleClient.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.feign; +package com.github.cadecode.uniboot.framework.api.feignclient; import com.github.cadecode.uniboot.framework.api.consts.SvcName; import org.springframework.cloud.openfeign.FeignClient; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysApiClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java similarity index 92% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysApiClient.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java index f4480db2..2b9b33d2 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysApiClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.feign; +package com.github.cadecode.uniboot.framework.api.feignclient; import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysLogClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java similarity index 91% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysLogClient.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java index 53251c3c..c158f5ef 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/SysLogClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.feign; +package com.github.cadecode.uniboot.framework.api.feignclient; import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; import com.github.cadecode.uniboot.framework.api.consts.SvcName; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java index 154f3ffe..4ab0766a 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java @@ -12,7 +12,7 @@ import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogInfoDto; import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; import com.github.cadecode.uniboot.framework.api.convert.SysLogConvert; -import com.github.cadecode.uniboot.framework.api.feign.SysLogClient; +import com.github.cadecode.uniboot.framework.api.feignclient.SysLogClient; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java index 3cb39724..88427767 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java @@ -3,7 +3,7 @@ import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.api.feign.SysApiClient; +import com.github.cadecode.uniboot.framework.api.feignclient.SysApiClient; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import lombok.RequiredArgsConstructor; import org.springframework.security.access.ConfigAttribute; From e237d80e45ab314e6171e3af273081f0295bf65b Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 31 Jul 2023 09:21:57 +0800 Subject: [PATCH 016/244] =?UTF-8?q?feat:=20=E4=BD=BF=E7=94=A8=E4=BA=8C?= =?UTF-8?q?=E7=BA=A7=E7=BC=93=E5=AD=98=E4=BD=9C=E4=B8=BA=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E7=AE=A1=E7=90=86=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/cache/config/CacheConfig.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/config/CacheConfig.java b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/config/CacheConfig.java index e8fab68d..7aae7fd6 100644 --- a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/config/CacheConfig.java +++ b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/config/CacheConfig.java @@ -64,7 +64,6 @@ public RedisCacheManager redisCacheManager5m(RedisTemplate redis * * @return RedisCacheManager 实例 */ - @Primary @Bean(name = CacheConst.RCM_30M) public RedisCacheManager redisCacheManager30m(RedisTemplate redisTemplate) { return geneRedisCacheManager(redisTemplate, 30); @@ -81,6 +80,10 @@ private static RedisCacheManager geneRedisCacheManager(RedisTemplate redisTemplate) { return new DLCacheManager(cacheProperties, redisTemplate); From f06edd8694bba6dfe789f95a1a04015609ae699d Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 31 Jul 2023 15:37:50 +0800 Subject: [PATCH 017/244] =?UTF-8?q?refactor:=20=E9=99=8D=E4=BD=8E=E4=BA=8C?= =?UTF-8?q?=E7=BA=A7=E7=BC=93=E5=AD=98=E8=8E=B7=E5=8F=96=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=97=B6=E7=9A=84=20log=20=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/cache/l2cache/cache/DLCache.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCache.java b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCache.java index 4d78715d..db272491 100644 --- a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCache.java +++ b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCache.java @@ -63,7 +63,7 @@ protected Object lookup(Object key) { // val 是 toStoreValue 包装过的值,为 null 则 key 不存在 // 因为存储的 null 值被包装成了 DLCacheNullVal.INSTANCE if (ObjectUtil.isNotNull(val)) { - log.debug("DLCache local get cache, key:{}, value:{}", key, val); + log.trace("DLCache local get cache, key:{}, value:{}", key, val); return val; } val = redisTemplate.opsForValue().get(redisKey); From d3cb87d6bb3ba01d8ac12b355aa0ea08b0652004 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 31 Jul 2023 15:38:13 +0800 Subject: [PATCH 018/244] =?UTF-8?q?fix:=20feign=20=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E5=99=A8=E9=9D=9E=E8=AF=B7=E6=B1=82=E6=8E=A5=E5=8F=A3=E5=86=85?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E7=94=A8=E8=8E=B7=E5=8F=96=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E6=97=B6=E7=A9=BA=E6=8C=87=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cadecode/uniboot/framework/api/config/FeignConfig.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java index 539bd0fc..91a125b1 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java @@ -30,7 +30,12 @@ public class FeignConfig { public RequestInterceptor requestInterceptor() { return requestTemplate -> { // 获取请求对象 - HttpServletRequest sRequest = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + // 非请求接口内的调用 + if (ObjectUtil.isNull(requestAttributes)) { + return; + } + HttpServletRequest sRequest = requestAttributes.getRequest(); if (ObjectUtil.isNull(sRequest)) { return; } From 6d26bfc48a0908b4339da2e9c43789f045fd575d Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 31 Jul 2023 16:18:06 +0800 Subject: [PATCH 019/244] =?UTF-8?q?refactor:=20=E7=B1=BB=E5=90=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ObjectFillHandler.java => MybatisFillHandler.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/{ObjectFillHandler.java => MybatisFillHandler.java} (83%) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ObjectFillHandler.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/MybatisFillHandler.java similarity index 83% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ObjectFillHandler.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/MybatisFillHandler.java index 66919cc2..6139bff9 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ObjectFillHandler.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/MybatisFillHandler.java @@ -6,13 +6,13 @@ import org.springframework.stereotype.Component; /** - * 对象填充处理器 + * mybatis plus 对象填充处理器 * * @author Cade Li * @since 2023/6/8 */ @Component -public class ObjectFillHandler extends AbstractObjectFillHandler { +public class MybatisFillHandler extends AbstractObjectFillHandler { @Override public void updateUser(MetaObject metaObject) { this.setFieldValByName("updateUser", SecurityUtil.getUsername(), metaObject); From 9abadf7a6e144a921deb902a5825dde83bd189b1 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 31 Jul 2023 21:32:21 +0800 Subject: [PATCH 020/244] =?UTF-8?q?refactor:=20=E5=8F=96=E6=B6=88=20token?= =?UTF-8?q?=20header=20=E5=8F=AF=E9=85=8D=E7=BD=AE=E9=A1=B9=EF=BC=8C?= =?UTF-8?q?=E6=8C=87=E5=AE=9A=E4=B8=BA=20token?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/api/config/FeignConfig.java | 6 +++--- .../uniboot/framework/api/config/SecurityConfig.java | 5 ----- .../uniboot/framework/api/consts/SecurityConst.java | 4 +++- .../api/security/filter/JwtTokenAuthFilterService.java | 3 ++- .../api/security/filter/TokenAuthFilterService.java | 2 +- .../uniboot/framework/api/util/SecurityUtil.java | 9 +++------ .../uniboot/framework/svc/controller/AuthController.java | 6 +++--- .../svc/security/JwtLoginSuccessHandleService.java | 3 ++- .../svc/security/RedisLoginSuccessHandleService.java | 3 ++- .../framework/svc/security/SignOutSuccessHandler.java | 4 ++-- 10 files changed, 21 insertions(+), 24 deletions(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java index 91a125b1..c94833dc 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java @@ -42,15 +42,15 @@ public RequestInterceptor requestInterceptor() { // 传递用户 token String token = SecurityUtil.getTokenFromRequest(sRequest); if (StrUtil.isNotEmpty(token)) { - requestTemplate.header(SecurityUtil.getHeader(), token); + requestTemplate.header(SecurityConst.HEAD_TOKEN, token); } // 传递用户详细信息 - String userDetailsJson = ServletUtil.getHeader(sRequest, SecurityConst.USER_DETAILS, CharsetUtil.CHARSET_UTF_8); + String userDetailsJson = ServletUtil.getHeader(sRequest, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); if (StrUtil.isEmpty(userDetailsJson)) { SysUserDetailsDto userDetailsDto = SecurityUtil.getUserDetails(null); userDetailsJson = JacksonUtil.toJson(userDetailsDto); } - requestTemplate.header(SecurityConst.USER_DETAILS, EscapeUtil.escape(userDetailsJson)); + requestTemplate.header(SecurityConst.HEAD_USER_DETAILS, EscapeUtil.escape(userDetailsJson)); // 配置客户端 IP requestTemplate.header("X-Forwarded-For", ServletUtil.getClientIP(sRequest)); }; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java index 238cdc25..9538707c 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java @@ -137,11 +137,6 @@ public static class SecurityProperties { @Data public static class TokenConfig { - /** - * token 请求头字段 - */ - private String header; - /** * token 过期时间,单位秒 */ diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java index e237178d..3c949107 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java @@ -8,5 +8,7 @@ */ public interface SecurityConst { - String USER_DETAILS = "feign-user-details"; + String HEAD_TOKEN = "token"; + + String HEAD_USER_DETAILS = "inner-user-details"; } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java index 300d7ebc..b769569b 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java @@ -5,6 +5,7 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.core.util.TokenUtil; import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; @@ -62,7 +63,7 @@ public void handler(HttpServletRequest request, HttpServletResponse response, Fi String newJwtToken = TokenUtil.generateToken(sysUserDetailsDto.getId(), sysUserDetailsDto.getUsername(), sysUserDetailsDto.getRoles(), SecurityUtil.getExpiration(), SecurityUtil.getSecret()); // token 放在请求头 - response.addHeader(SecurityUtil.getHeader(), newJwtToken); + response.addHeader(SecurityConst.HEAD_TOKEN, newJwtToken); } filterChain.doFilter(request, response); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java index 191bf9bd..b6a7a1e6 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java @@ -64,7 +64,7 @@ protected void writeResponse(HttpServletResponse response, ApiErrorCode errorCod */ public void filter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { // 从请求头中提取来自其他服务调用传递得用户信息 - String escapedUserDetailsJson = ServletUtil.getHeader(request, SecurityConst.USER_DETAILS, CharsetUtil.CHARSET_UTF_8); + String escapedUserDetailsJson = ServletUtil.getHeader(request, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); if (ObjectUtil.isNotEmpty(escapedUserDetailsJson)) { SysUserDetailsDto userDetailsDto = JacksonUtil.toBean(EscapeUtil.unescape(escapedUserDetailsJson), SysUserDetailsDto.class); if (ObjectUtil.isNotNull(userDetailsDto)) { diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java index 0cd888a9..13830d91 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.InitializingBean; import org.springframework.security.core.Authentication; @@ -31,10 +32,6 @@ public class SecurityUtil implements InitializingBean { // 从 SecurityConfig 获取 token 配置 - public static String getHeader() { - return PROPERTIES.getTokenConfig().getHeader(); - } - public static Long getExpiration() { return PROPERTIES.getTokenConfig().getExpiration(); } @@ -53,13 +50,13 @@ public static String getTokenFromRequest(HttpServletRequest request) { Cookie[] cookies = request.getCookies(); if (ObjectUtil.isNotEmpty(cookies)) { Optional optionalCookie = Arrays.stream(cookies) - .filter(c -> ObjectUtil.equal(c.getName(), getHeader())) + .filter(c -> ObjectUtil.equal(c.getName(), SecurityConst.HEAD_TOKEN)) .findAny(); if (optionalCookie.isPresent()) { return optionalCookie.get().getValue(); } } - return request.getHeader(getHeader()); + return request.getHeader(SecurityConst.HEAD_TOKEN); } /** diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java index 197a7ea5..dc2b4dde 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java @@ -7,7 +7,7 @@ import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import feign.Response; import io.swagger.annotations.Api; @@ -45,8 +45,8 @@ public class AuthController { public ApiResult login(HttpServletResponse sResponse, @RequestParam String username, @RequestParam String password) throws IOException { // 从 rpc 调用中获取 header token 设置到响应 Response rResponse = authClient.login(username, password); - String token = rResponse.headers().get(SecurityUtil.getHeader()).stream().findFirst().get(); - sResponse.addHeader(SecurityUtil.getHeader(), token); + String token = rResponse.headers().get(SecurityConst.HEAD_TOKEN).stream().findFirst().get(); + sResponse.addHeader(SecurityConst.HEAD_TOKEN, token); // 获取 rpc 结果 String body = IoUtil.read(rResponse.body().asReader(CharsetUtil.CHARSET_UTF_8)); return JacksonUtil.toBean(body, ApiResult.class); diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java index 77053672..7529f002 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java @@ -5,6 +5,7 @@ import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; @@ -31,7 +32,7 @@ public ApiResult getResult(HttpServletRequest request, HttpSe String jwtToken = TokenUtil.generateToken(sysUserDetailsDto.getId(), sysUserDetailsDto.getUsername(), sysUserDetailsDto.getRoles(), SecurityUtil.getExpiration(), SecurityUtil.getSecret()); // token 放在请求头 - response.addHeader(SecurityUtil.getHeader(), jwtToken); + response.addHeader(SecurityConst.HEAD_TOKEN, jwtToken); return ApiResult.ok(sysUserDetailsDto).path(FrameSecurityConfig.LOGOUT_URL); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java index d3558760..d6a1c522 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java @@ -7,6 +7,7 @@ import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; @@ -33,7 +34,7 @@ public ApiResult getResult(HttpServletRequest requ // 生成 uuid token String uuidToken = SecurityUtil.generateUUID(); // token 放在请求头 - response.addHeader(SecurityUtil.getHeader(), uuidToken); + response.addHeader(SecurityConst.HEAD_TOKEN, uuidToken); // 生成存放登录信息的 redis key String loginUserKey = KeyGeneUtil.key(KeyPrefix.LOGIN_USER, uuidToken); RedisUtil.set(loginUserKey, sysUserDetailsDto, SecurityUtil.getExpiration(), TimeUnit.SECONDS); diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java index 4b1b8b43..4584f4ad 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java @@ -10,9 +10,9 @@ import com.github.cadecode.uniboot.common.plugin.cache.util.RedisUtil; import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import lombok.RequiredArgsConstructor; import org.springframework.security.core.Authentication; @@ -38,7 +38,7 @@ public class SignOutSuccessHandler implements LogoutSuccessHandler { public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { // 删除保存登录信息的 redis key - String uuidToken = request.getHeader(SecurityUtil.getHeader()); + String uuidToken = request.getHeader(SecurityConst.HEAD_TOKEN); if (StrUtil.isNotEmpty(uuidToken) && properties.getAuthModel() == AuthModelEnum.REDIS) { String loginUserKey = KeyGeneUtil.key(KeyPrefix.LOGIN_USER, uuidToken); RedisUtil.del(loginUserKey); From 7d41866a4cb120aa22521b00b8c316fa3e714c38 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 31 Jul 2023 21:35:27 +0800 Subject: [PATCH 021/244] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=20securi?= =?UTF-8?q?ty=20ignore=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/svc/config/FrameSecurityConfig.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java index a16380e9..6bb962b4 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java @@ -106,7 +106,9 @@ protected void configure(HttpSecurity http) throws Exception { public void configure(WebSecurity web) { super.configure(web); IgnoredRequestConfigurer ignoring = web.ignoring(); - // 放行 framework 服务公共接口 - ignoring.antMatchers("/auth/login", "/system/log/save", "/system/api/list_roles_vo"); + // 放行登录接口 + ignoring.antMatchers("/auth/login"); + // 放行接口权限表查询接口 + ignoring.antMatchers("/system/api/list_roles_vo"); } } From c072dab4dcb2e7f9822f9fef5a8422260a187754 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 1 Aug 2023 10:41:03 +0800 Subject: [PATCH 022/244] =?UTF-8?q?feat:=20=E5=AE=9A=E4=B9=89=20feign=20cl?= =?UTF-8?q?ient=20=E8=A3=85=E9=A5=B0=E5=99=A8=EF=BC=8C=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E8=AF=B7=E6=B1=82=E4=B8=8E=E5=93=8D=E5=BA=94=E7=9A=84=E6=8B=A6?= =?UTF-8?q?=E6=88=AA=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/api/config/FeignConfig.java | 68 +++++++--------- .../api/feign/FeignClientDecorator.java | 79 +++++++++++++++++++ .../framework/api/util/RequestUtil.java | 33 ++++++++ 3 files changed, 139 insertions(+), 41 deletions(-) create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignClientDecorator.java create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java index c94833dc..c42207e2 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java @@ -1,21 +1,17 @@ package com.github.cadecode.uniboot.framework.api.config; -import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.EscapeUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.servlet.ServletUtil; -import com.github.cadecode.uniboot.common.core.util.JacksonUtil; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; -import feign.RequestInterceptor; +import com.github.cadecode.uniboot.framework.api.feign.FeignClientDecorator; +import feign.Client; +import feign.Client.Default; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory; +import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; +import org.springframework.cloud.client.loadbalancer.LoadBalancerProperties; +import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; +import org.springframework.cloud.openfeign.loadbalancer.FeignBlockingLoadBalancerClient; +import org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - -import javax.servlet.http.HttpServletRequest; /** * OpenFeign 配置类 @@ -26,33 +22,23 @@ @Configuration public class FeignConfig { + // 覆盖 feign 配置 + // org.springframework.cloud.openfeign.loadbalancer.DefaultFeignLoadBalancerConfiguration + + @Bean + @ConditionalOnProperty(value = "spring.cloud.loadbalancer.retry.enabled", havingValue = "false") + public Client feignClient(LoadBalancerClient loadBalancerClient, LoadBalancerProperties properties, + LoadBalancerClientFactory loadBalancerClientFactory) { + FeignClientDecorator decorator = new FeignClientDecorator(new Default(null, null)); + return new FeignBlockingLoadBalancerClient(decorator, loadBalancerClient, properties, loadBalancerClientFactory); + } + @Bean - public RequestInterceptor requestInterceptor() { - return requestTemplate -> { - // 获取请求对象 - ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - // 非请求接口内的调用 - if (ObjectUtil.isNull(requestAttributes)) { - return; - } - HttpServletRequest sRequest = requestAttributes.getRequest(); - if (ObjectUtil.isNull(sRequest)) { - return; - } - // 传递用户 token - String token = SecurityUtil.getTokenFromRequest(sRequest); - if (StrUtil.isNotEmpty(token)) { - requestTemplate.header(SecurityConst.HEAD_TOKEN, token); - } - // 传递用户详细信息 - String userDetailsJson = ServletUtil.getHeader(sRequest, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); - if (StrUtil.isEmpty(userDetailsJson)) { - SysUserDetailsDto userDetailsDto = SecurityUtil.getUserDetails(null); - userDetailsJson = JacksonUtil.toJson(userDetailsDto); - } - requestTemplate.header(SecurityConst.HEAD_USER_DETAILS, EscapeUtil.escape(userDetailsJson)); - // 配置客户端 IP - requestTemplate.header("X-Forwarded-For", ServletUtil.getClientIP(sRequest)); - }; + @ConditionalOnProperty(value = "spring.cloud.loadbalancer.retry.enabled", havingValue = "true", matchIfMissing = true) + public Client feignRetryClient(LoadBalancerClient loadBalancerClient, LoadBalancedRetryFactory loadBalancedRetryFactory, + LoadBalancerProperties properties, LoadBalancerClientFactory loadBalancerClientFactory) { + FeignClientDecorator decorator = new FeignClientDecorator(new Default(null, null)); + return new RetryableFeignBlockingLoadBalancerClient(decorator, loadBalancerClient, loadBalancedRetryFactory, properties, loadBalancerClientFactory); } + } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignClientDecorator.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignClientDecorator.java new file mode 100644 index 00000000..f59770fb --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignClientDecorator.java @@ -0,0 +1,79 @@ +package com.github.cadecode.uniboot.framework.api.feign; + +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.EscapeUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.servlet.ServletUtil; +import com.github.cadecode.uniboot.common.core.util.JacksonUtil; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.util.RequestUtil; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import feign.Client; +import feign.Request; +import feign.Request.Options; +import feign.RequestTemplate; +import feign.Response; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.Collection; +import java.util.Map; + +/** + * FeignClient 装饰器 + * + * @author Cade Li + * @since 2023/8/1 + */ +public class FeignClientDecorator implements Client { + + private final Client delegate; + + public FeignClientDecorator(Client delegate) { + this.delegate = delegate; + } + + @Override + public Response execute(Request request, Options options) throws IOException { + configRequestTemplate(request.requestTemplate()); + Response response = delegate.execute(request, options); + getResponseHeader(response.headers()); + return response; + } + + protected void configRequestTemplate(RequestTemplate requestTemplate) { + HttpServletRequest servletRequest = RequestUtil.getRequest(); + if (ObjectUtil.isNull(servletRequest)) { + return; + } + // 传递用户 token + String token = SecurityUtil.getTokenFromRequest(servletRequest); + if (StrUtil.isNotEmpty(token)) { + requestTemplate.header(SecurityConst.HEAD_TOKEN, token); + } + // 传递用户详细信息 + String userDetailsJson = ServletUtil.getHeader(servletRequest, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); + if (StrUtil.isEmpty(userDetailsJson)) { + SysUserDetailsDto userDetailsDto = SecurityUtil.getUserDetails(null); + userDetailsJson = JacksonUtil.toJson(userDetailsDto); + } + requestTemplate.header(SecurityConst.HEAD_USER_DETAILS, EscapeUtil.escape(userDetailsJson)); + // 配置客户端 IP + requestTemplate.header("X-Forwarded-For", ServletUtil.getClientIP(servletRequest)); + } + + protected void getResponseHeader(Map> headers) { + HttpServletResponse servletResponse = RequestUtil.getResponse(); + if (ObjectUtil.isNull(servletResponse)) { + return; + } + // 获取 token + if (headers.containsKey(SecurityConst.HEAD_TOKEN)) { + String token = headers.get(SecurityConst.HEAD_TOKEN).stream().findFirst().get(); + servletResponse.addHeader(SecurityConst.HEAD_TOKEN, token); + } + } +} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java new file mode 100644 index 00000000..1485c3bf --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java @@ -0,0 +1,33 @@ +package com.github.cadecode.uniboot.framework.api.util; + +import cn.hutool.core.util.ObjectUtil; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * spring web 工具类 + * + * @author Cade Li + * @since 2023/8/1 + */ +public class RequestUtil { + + public static HttpServletRequest getRequest() { + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (ObjectUtil.isNull(requestAttributes)) { + return null; + } + return requestAttributes.getRequest(); + } + + public static HttpServletResponse getResponse() { + ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); + if (ObjectUtil.isNull(requestAttributes)) { + return null; + } + return requestAttributes.getResponse(); + } +} From a6b78fc4a8b7c2d96f25bf7264f268a6ad65979c Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 1 Aug 2023 10:49:09 +0800 Subject: [PATCH 023/244] =?UTF-8?q?refactor:=20=E5=90=8C=E6=AD=A5=20feign?= =?UTF-8?q?=20=E8=B0=83=E7=94=A8=E5=9B=9E=E5=A1=AB=20token=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E7=94=A8=E5=86=8D=E6=89=8B=E5=8A=A8=E5=9B=9E=E5=A1=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../svc/controller/AuthController.java | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java index dc2b4dde..866e79e6 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java @@ -1,15 +1,10 @@ package com.github.cadecode.uniboot.framework.svc.controller; -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.CharsetUtil; -import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; -import feign.Response; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -20,9 +15,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; - /** * 认证API * @@ -42,14 +34,8 @@ public class AuthController { @ApiLogger(type = LogTypeEnum.AUTH, enableSave = true, description = "用户登录") @ApiOperation("登录") @PostMapping("login") - public ApiResult login(HttpServletResponse sResponse, @RequestParam String username, @RequestParam String password) throws IOException { - // 从 rpc 调用中获取 header token 设置到响应 - Response rResponse = authClient.login(username, password); - String token = rResponse.headers().get(SecurityConst.HEAD_TOKEN).stream().findFirst().get(); - sResponse.addHeader(SecurityConst.HEAD_TOKEN, token); - // 获取 rpc 结果 - String body = IoUtil.read(rResponse.body().asReader(CharsetUtil.CHARSET_UTF_8)); - return JacksonUtil.toBean(body, ApiResult.class); + public ApiResult login(@RequestParam String username, @RequestParam String password) { + return authClient.login(username, password); } @ApiLogger(type = LogTypeEnum.AUTH, enableSave = true, description = "用户注销") @@ -68,7 +54,7 @@ public ApiResult logout() { public interface AuthClient { @PostMapping(FrameSecurityConfig.LOGIN_URL) - Response login(@RequestParam("username") String username, @RequestParam("password") String password); + ApiResult login(@RequestParam("username") String username, @RequestParam("password") String password); @PostMapping(FrameSecurityConfig.LOGOUT_URL) ApiResult logout(); From 4e14fe049c840e47fa81efe1cd63530a3f5e10af Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 1 Aug 2023 11:23:44 +0800 Subject: [PATCH 024/244] =?UTF-8?q?fix:=20FeignClient=20=E8=A3=85=E9=A5=B0?= =?UTF-8?q?=E5=99=A8=E5=A1=AB=E5=85=85=E8=AF=B7=E6=B1=82=E6=97=A0=E6=95=88?= =?UTF-8?q?=EF=BC=8C=E4=BD=BF=E7=94=A8=20feign=20=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/api/config/FeignConfig.java | 41 ++++++++++++++++++- .../api/feign/FeignClientDecorator.java | 38 +++-------------- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java index c42207e2..99bc0b38 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java @@ -1,8 +1,20 @@ package com.github.cadecode.uniboot.framework.api.config; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.EscapeUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.extra.servlet.ServletUtil; +import com.github.cadecode.uniboot.common.core.util.JacksonUtil; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.feign.FeignClientDecorator; +import com.github.cadecode.uniboot.framework.api.util.RequestUtil; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import feign.Client; import feign.Client.Default; +import feign.RequestInterceptor; +import feign.RequestTemplate; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory; import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; @@ -13,6 +25,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import javax.servlet.http.HttpServletRequest; + /** * OpenFeign 配置类 * @@ -22,6 +36,32 @@ @Configuration public class FeignConfig { + @Bean + public RequestInterceptor requestInterceptor() { + return this::configRequestTemplate; + } + + protected void configRequestTemplate(RequestTemplate requestTemplate) { + HttpServletRequest servletRequest = RequestUtil.getRequest(); + if (ObjectUtil.isNull(servletRequest)) { + return; + } + // 传递用户 token + String token = SecurityUtil.getTokenFromRequest(servletRequest); + if (StrUtil.isNotEmpty(token)) { + requestTemplate.header(SecurityConst.HEAD_TOKEN, token); + } + // 传递用户详细信息 + String userDetailsJson = ServletUtil.getHeader(servletRequest, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); + if (StrUtil.isEmpty(userDetailsJson)) { + SysUserDetailsDto userDetailsDto = SecurityUtil.getUserDetails(null); + userDetailsJson = JacksonUtil.toJson(userDetailsDto); + } + requestTemplate.header(SecurityConst.HEAD_USER_DETAILS, EscapeUtil.escape(userDetailsJson)); + // 配置客户端 IP + requestTemplate.header("X-Forwarded-For", ServletUtil.getClientIP(servletRequest)); + } + // 覆盖 feign 配置 // org.springframework.cloud.openfeign.loadbalancer.DefaultFeignLoadBalancerConfiguration @@ -40,5 +80,4 @@ public Client feignRetryClient(LoadBalancerClient loadBalancerClient, LoadBalanc FeignClientDecorator decorator = new FeignClientDecorator(new Default(null, null)); return new RetryableFeignBlockingLoadBalancerClient(decorator, loadBalancerClient, loadBalancedRetryFactory, properties, loadBalancerClientFactory); } - } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignClientDecorator.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignClientDecorator.java index f59770fb..93436fa4 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignClientDecorator.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignClientDecorator.java @@ -1,22 +1,13 @@ package com.github.cadecode.uniboot.framework.api.feign; -import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.EscapeUtil; import cn.hutool.core.util.ObjectUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.extra.servlet.ServletUtil; -import com.github.cadecode.uniboot.common.core.util.JacksonUtil; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.util.RequestUtil; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import feign.Client; import feign.Request; import feign.Request.Options; -import feign.RequestTemplate; import feign.Response; -import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Collection; @@ -38,34 +29,15 @@ public FeignClientDecorator(Client delegate) { @Override public Response execute(Request request, Options options) throws IOException { - configRequestTemplate(request.requestTemplate()); Response response = delegate.execute(request, options); - getResponseHeader(response.headers()); + fillResponseHeader(response.headers()); return response; } - protected void configRequestTemplate(RequestTemplate requestTemplate) { - HttpServletRequest servletRequest = RequestUtil.getRequest(); - if (ObjectUtil.isNull(servletRequest)) { - return; - } - // 传递用户 token - String token = SecurityUtil.getTokenFromRequest(servletRequest); - if (StrUtil.isNotEmpty(token)) { - requestTemplate.header(SecurityConst.HEAD_TOKEN, token); - } - // 传递用户详细信息 - String userDetailsJson = ServletUtil.getHeader(servletRequest, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); - if (StrUtil.isEmpty(userDetailsJson)) { - SysUserDetailsDto userDetailsDto = SecurityUtil.getUserDetails(null); - userDetailsJson = JacksonUtil.toJson(userDetailsDto); - } - requestTemplate.header(SecurityConst.HEAD_USER_DETAILS, EscapeUtil.escape(userDetailsJson)); - // 配置客户端 IP - requestTemplate.header("X-Forwarded-For", ServletUtil.getClientIP(servletRequest)); - } - - protected void getResponseHeader(Map> headers) { + /** + * 回填响应头到请求上下文的 HttpServletResponse 中 + */ + protected void fillResponseHeader(Map> headers) { HttpServletResponse servletResponse = RequestUtil.getResponse(); if (ObjectUtil.isNull(servletResponse)) { return; From 257abacc2a5541cb799c64c0c05ecd334998c7e7 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 1 Aug 2023 14:15:44 +0800 Subject: [PATCH 025/244] =?UTF-8?q?refactor:=20cache=20key=20=E5=88=86?= =?UTF-8?q?=E5=89=B2=E7=AC=A6=E7=BB=9F=E4=B8=80=E4=B8=BA=E5=8D=95=E5=86=92?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/cache/config/CacheConfig.java | 5 ++++- .../uniboot/common/plugin/cache/l2cache/cache/DLCache.java | 4 ++-- .../uniboot/common/plugin/cache/util/KeyGeneUtil.java | 4 +++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/config/CacheConfig.java b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/config/CacheConfig.java index 7aae7fd6..5fffab3f 100644 --- a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/config/CacheConfig.java +++ b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/config/CacheConfig.java @@ -4,6 +4,7 @@ import com.github.cadecode.uniboot.common.plugin.cache.consts.CacheConst; import com.github.cadecode.uniboot.common.plugin.cache.l2cache.DLCacheProperties; import com.github.cadecode.uniboot.common.plugin.cache.l2cache.cache.DLCacheManager; +import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; import lombok.RequiredArgsConstructor; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.cache.annotation.EnableCaching; @@ -17,6 +18,7 @@ import org.springframework.data.redis.serializer.RedisSerializationContext.SerializationPair; import java.time.Duration; +import java.util.Objects; import java.util.concurrent.TimeUnit; /** @@ -71,10 +73,11 @@ public RedisCacheManager redisCacheManager30m(RedisTemplate redi private static RedisCacheManager geneRedisCacheManager(RedisTemplate redisTemplate, long minutes) { RedisCacheConfiguration cacheConfiguration = RedisCacheConfiguration.defaultCacheConfig() + .computePrefixWith(o -> o + KeyGeneUtil.SEPARATOR) .serializeKeysWith(SerializationPair.fromSerializer(redisTemplate.getStringSerializer())) .serializeValuesWith(SerializationPair.fromSerializer(redisTemplate.getValueSerializer())) .entryTtl(Duration.ofMinutes(minutes)); - return RedisCacheManager.builder(redisTemplate.getConnectionFactory()) + return RedisCacheManager.builder(Objects.requireNonNull(redisTemplate.getConnectionFactory())) .cacheDefaults(cacheConfiguration) .transactionAware() .build(); diff --git a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCache.java b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCache.java index db272491..9f888143 100644 --- a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCache.java +++ b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCache.java @@ -6,6 +6,7 @@ import com.github.cadecode.uniboot.common.plugin.cache.l2cache.DLCacheProperties; import com.github.cadecode.uniboot.common.plugin.cache.l2cache.sync.DLCacheRefreshListener; import com.github.cadecode.uniboot.common.plugin.cache.l2cache.sync.DLCacheRefreshMsg; +import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; import lombok.Data; import lombok.Getter; import lombok.extern.slf4j.Slf4j; @@ -223,8 +224,7 @@ protected Object toStoreValue(Object userValue) { * 获取 redis 完整 key */ private String getRedisKey(Object key) { - // 双冒号,与 spring cache 默认一致 - return this.name.concat("::").concat(key.toString()); + return KeyGeneUtil.key(this.name, key.toString()); } /** diff --git a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/util/KeyGeneUtil.java b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/util/KeyGeneUtil.java index 75397cf4..b8f0df88 100644 --- a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/util/KeyGeneUtil.java +++ b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/util/KeyGeneUtil.java @@ -8,6 +8,8 @@ */ public class KeyGeneUtil { + public static final String SEPARATOR = ":"; + /** * 生成 : 分割的 redis key * @@ -18,7 +20,7 @@ public class KeyGeneUtil { public static String key(String prefix, Object... extra) { StringBuilder prefixBuilder = new StringBuilder(prefix); for (Object obj : extra) { - prefixBuilder.append(":").append(obj); + prefixBuilder.append(SEPARATOR).append(obj); } return prefixBuilder.toString(); } From 6b24555aa4bfda6696cd0b916dedb387c5b8eca1 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 1 Aug 2023 14:43:25 +0800 Subject: [PATCH 026/244] =?UTF-8?q?feat:=20feign=20=E6=8B=A6=E6=88=AA?= =?UTF-8?q?=E5=99=A8=E4=BC=A0=E9=80=92=E5=86=85=E9=83=A8=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E6=A0=87=E8=AF=86=E5=A4=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/api/config/FeignConfig.java | 9 ++++++--- .../framework/api/consts/SecurityConst.java | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java index 99bc0b38..dbb48d89 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java @@ -42,24 +42,27 @@ public RequestInterceptor requestInterceptor() { } protected void configRequestTemplate(RequestTemplate requestTemplate) { + // 设置内部请求来源标识 + requestTemplate.header(SecurityConst.HEAD_SOURCE, SecurityConst.HEAD_SOURCE_VALUE); HttpServletRequest servletRequest = RequestUtil.getRequest(); if (ObjectUtil.isNull(servletRequest)) { return; } + // 配置客户端 IP + requestTemplate.header("X-Forwarded-For", ServletUtil.getClientIP(servletRequest)); // 传递用户 token String token = SecurityUtil.getTokenFromRequest(servletRequest); if (StrUtil.isNotEmpty(token)) { requestTemplate.header(SecurityConst.HEAD_TOKEN, token); } - // 传递用户详细信息 + // 传递用户信息 String userDetailsJson = ServletUtil.getHeader(servletRequest, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); + // 不存在则生成 if (StrUtil.isEmpty(userDetailsJson)) { SysUserDetailsDto userDetailsDto = SecurityUtil.getUserDetails(null); userDetailsJson = JacksonUtil.toJson(userDetailsDto); } requestTemplate.header(SecurityConst.HEAD_USER_DETAILS, EscapeUtil.escape(userDetailsJson)); - // 配置客户端 IP - requestTemplate.header("X-Forwarded-For", ServletUtil.getClientIP(servletRequest)); } // 覆盖 feign 配置 diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java index 3c949107..17b468e1 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java @@ -8,7 +8,24 @@ */ public interface SecurityConst { + /** + * token 请求头名称 + */ String HEAD_TOKEN = "token"; + /** + * 请求来源请求头名称 + */ + String HEAD_SOURCE = "from-source"; + + /** + * 请求来源请求头固定值 + */ + String HEAD_SOURCE_VALUE = "inner-rpc"; + + /** + * 用户信息请求头名称 + */ String HEAD_USER_DETAILS = "inner-user-details"; + } From 70e1c5b311df91d6910e49735aff62ca60db9ff7 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 1 Aug 2023 16:59:35 +0800 Subject: [PATCH 027/244] =?UTF-8?q?feat:=20token=20filter=20=E4=B8=AD?= =?UTF-8?q?=E5=85=88=E6=A0=B9=E6=8D=AE=E8=AF=B7=E6=B1=82=E5=A4=B4=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=98=AF=E5=90=A6=E6=98=AF=E5=86=85=E9=83=A8=E8=AF=B7?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filter/TokenAuthFilterService.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java index b6a7a1e6..aff0db1c 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java @@ -63,14 +63,18 @@ protected void writeResponse(HttpServletResponse response, ApiErrorCode errorCod * 由 handler 方法提供处理 */ public void filter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { - // 从请求头中提取来自其他服务调用传递得用户信息 - String escapedUserDetailsJson = ServletUtil.getHeader(request, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); - if (ObjectUtil.isNotEmpty(escapedUserDetailsJson)) { - SysUserDetailsDto userDetailsDto = JacksonUtil.toBean(EscapeUtil.unescape(escapedUserDetailsJson), SysUserDetailsDto.class); - if (ObjectUtil.isNotNull(userDetailsDto)) { - setAuthentication(request, userDetailsDto); - filterChain.doFilter(request, response); - return; + // 根据请求头判断是否是内部请求 + String source = ServletUtil.getHeader(request, SecurityConst.HEAD_SOURCE, CharsetUtil.CHARSET_UTF_8); + if (ObjectUtil.equal(source, SecurityConst.HEAD_SOURCE_VALUE)) { + // 从请求头中提取来自其他服务调用传递得用户信息 + String escapedUserDetailsJson = ServletUtil.getHeader(request, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); + if (ObjectUtil.isNotEmpty(escapedUserDetailsJson)) { + SysUserDetailsDto userDetailsDto = JacksonUtil.toBean(EscapeUtil.unescape(escapedUserDetailsJson), SysUserDetailsDto.class); + if (ObjectUtil.isNotNull(userDetailsDto)) { + setAuthentication(request, userDetailsDto); + filterChain.doFilter(request, response); + return; + } } } handler(request, response, filterChain); From d5ce99e630deff7717a292d4c04a57d8687d11d4 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 1 Aug 2023 17:58:03 +0800 Subject: [PATCH 028/244] =?UTF-8?q?feat:=20log=20feign=20=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BC=A0=E5=8F=82=E6=94=B9=E4=B8=BA=20dto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/api/convert/SysLogConvert.java | 2 ++ .../framework/api/feignclient/SysLogClient.java | 4 ++-- .../uniboot/framework/api/plugin/ApiLogHandler.java | 10 ++++------ .../framework/svc/controller/SysLogController.java | 4 +++- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java index bb233bb6..dfe57d20 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java @@ -21,5 +21,7 @@ public interface SysLogConvert { SysLog dtoToPo(SysLogInfoDto dto); + List dtoToPo(List dto); + List poToVo(List records); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java index c158f5ef..f03c8b1a 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.framework.api.feignclient; -import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogInfoDto; import com.github.cadecode.uniboot.framework.api.consts.SvcName; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -19,6 +19,6 @@ public interface SysLogClient { @PostMapping("system/log/save") - boolean save(@RequestBody @NotEmpty List poList); + boolean save(@RequestBody @NotEmpty List dtoList); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java index 4ab0766a..fe066784 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java @@ -10,8 +10,6 @@ import com.github.cadecode.uniboot.common.plugin.log.aspect.ApiLoggerAspect.BaseLogInfo; import com.github.cadecode.uniboot.common.plugin.log.handler.AbstractApiLogHandler; import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogInfoDto; -import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; -import com.github.cadecode.uniboot.framework.api.convert.SysLogConvert; import com.github.cadecode.uniboot.framework.api.feignclient.SysLogClient; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import io.swagger.annotations.ApiOperation; @@ -89,15 +87,15 @@ public void save(ApiLogger apiLogger, Object o) { if (!apiLogger.enableSave()) { return; } - SysLog po = SysLogConvert.INSTANCE.dtoToPo((SysLogInfoDto) o); + SysLogInfoDto dto = (SysLogInfoDto) o; if (!apiLogger.saveParams()) { - po.setRequestParams(null); + dto.setRequestParams(null); } if (!apiLogger.saveResult()) { - po.setResult(null); + dto.setResult(null); } try { - sysLogClient.save(Collections.singletonList(po)); + sysLogClient.save(Collections.singletonList(dto)); } catch (Exception e) { log.error("API log [{}]: save fail", apiLogger.type().getType(), e); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java index 514786ad..8316fd93 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java @@ -4,6 +4,7 @@ import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogInfoDto; import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; import com.github.cadecode.uniboot.framework.api.bean.vo.SysLogVo.SysLogPageVo; import com.github.cadecode.uniboot.framework.api.convert.SysLogConvert; @@ -69,7 +70,8 @@ public boolean delete(@RequestBody @NotEmpty List idList) { @ApiFormat(false) @ApiOperation("添加") @PostMapping("save") - public boolean save(@RequestBody @NotEmpty List poList) { + public boolean save(@RequestBody @NotEmpty List dtoList) { + List poList = SysLogConvert.INSTANCE.dtoToPo(dtoList); return logService.saveBatch(poList); } } From 1eed2d33f0cb82ac48e998a948d7e742ae742402 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Wed, 2 Aug 2023 10:01:12 +0800 Subject: [PATCH 029/244] =?UTF-8?q?feat:=20=E5=85=AC=E5=BC=80=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=97=A5=E5=BF=97=E5=86=99=E5=85=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/svc/config/FrameSecurityConfig.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java index 6bb962b4..5385c764 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java @@ -110,5 +110,7 @@ public void configure(WebSecurity web) { ignoring.antMatchers("/auth/login"); // 放行接口权限表查询接口 ignoring.antMatchers("/system/api/list_roles_vo"); + // 放行系统日志写入接口 + ignoring.antMatchers("/system/log/save"); } } From 05a5bbb5a60726aef5f02c2732c35f1d3c0c5507 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Wed, 2 Aug 2023 10:02:16 +0800 Subject: [PATCH 030/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20ApiInner?= =?UTF-8?q?=20=E6=B3=A8=E8=A7=A3=E5=8F=8A=E5=88=87=E9=9D=A2=EF=BC=8C?= =?UTF-8?q?=E5=AF=B9=E5=86=85=E9=83=A8=E8=B0=83=E7=94=A8=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E7=AE=A1=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/api/annotation/ApiInner.java | 29 ++++++++++ .../framework/api/aspect/ApiInnerAspect.java | 58 +++++++++++++++++++ .../svc/controller/SysApiController.java | 4 +- .../svc/controller/SysLogController.java | 3 +- 4 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/annotation/ApiInner.java create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/aspect/ApiInnerAspect.java diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/annotation/ApiInner.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/annotation/ApiInner.java new file mode 100644 index 00000000..105f1f05 --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/annotation/ApiInner.java @@ -0,0 +1,29 @@ +package com.github.cadecode.uniboot.framework.api.annotation; + +import java.lang.annotation.*; + +/** + * 标识供内部调用的接口 + * 当有些内部调用不方便传递 token 时(比如异步线程中的 feign 调用,无法直接拿到 token 请求头等) + * 可以将接口配置到 security ignore url 列表中,将不再需要登录 + * + * @author Cade Li + * @since 2023/8/1 + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface ApiInner { + + /** + * 是否仅供内部调用 + * 用于防止接口被来自网关的流量随意访问 + */ + boolean onlyClient() default false; + + /** + * 是否需要用户登录 + * 用于防止接口被未登录访问 + */ + boolean requireUser() default false; +} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/aspect/ApiInnerAspect.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/aspect/ApiInnerAspect.java new file mode 100644 index 00000000..22b8336f --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/aspect/ApiInnerAspect.java @@ -0,0 +1,58 @@ +package com.github.cadecode.uniboot.framework.api.aspect; + +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.extra.servlet.ServletUtil; +import com.github.cadecode.uniboot.common.core.exception.ApiException; +import com.github.cadecode.uniboot.framework.api.annotation.ApiInner; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; +import com.github.cadecode.uniboot.framework.api.util.RequestUtil; +import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import org.aspectj.lang.JoinPoint; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Before; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.stereotype.Component; + +import javax.servlet.http.HttpServletRequest; + +/** + * ApiInner 注解检查切面 + * + * @author Cade Li + * @since 2023/8/2 + */ +@Aspect +@Component +public class ApiInnerAspect { + + @Pointcut("@annotation(com.github.cadecode.uniboot.framework.api.annotation.ApiInner)") + public void pointCut() { + } + + @Before("pointCut()") + public void rateLimit(JoinPoint point) { + // 获取方法上的注解 + MethodSignature methodSignature = (MethodSignature) point.getSignature(); + // 获取注解 + ApiInner apiInner = methodSignature.getMethod().getAnnotation(ApiInner.class); + // 获取 request + HttpServletRequest servletRequest = RequestUtil.getRequest(); + if (ObjectUtil.isNull(servletRequest)) { + return; + } + // 获取请求头 + String source = ServletUtil.getHeader(servletRequest, SecurityConst.HEAD_SOURCE, CharsetUtil.CHARSET_UTF_8); + boolean innerFlag = ObjectUtil.equal(source, SecurityConst.HEAD_SOURCE_VALUE); + // 判断是否仅供内部调用 + if (apiInner.onlyClient() && !innerFlag) { + throw ApiException.of(AuthErrorEnum.TOKEN_NO_AUTHORITY, "ApiInner AOP:该接口仅供内部调用"); + } + // 判断是否需要用户信息 + if (apiInner.requireUser() && !SecurityUtil.isAuthenticated(null)) { + throw ApiException.of(AuthErrorEnum.TOKEN_NOT_EXIST, "ApiInner AOP:该接口要求用户登录"); + } + } +} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java index b6cb6a71..ee7503ce 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java @@ -3,6 +3,7 @@ import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.annotation.ApiInner; import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiSwaggerVo; @@ -121,8 +122,7 @@ public List listSwaggerVo() { .collect(Collectors.toList()); } - - // For feign client + @ApiInner(onlyClient = true) @ApiFormat(false) @ApiOperation("查询API列表-全部") @PostMapping("list_roles_vo") diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java index 8316fd93..1dac364a 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java @@ -4,6 +4,7 @@ import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.annotation.ApiInner; import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogInfoDto; import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; import com.github.cadecode.uniboot.framework.api.bean.vo.SysLogVo.SysLogPageVo; @@ -66,7 +67,7 @@ public boolean delete(@RequestBody @NotEmpty List idList) { return logService.removeBatchByIds(idList); } - // For feign client + @ApiInner(onlyClient = true) @ApiFormat(false) @ApiOperation("添加") @PostMapping("save") From 0a45528e389428a18d9cc0645a6a74ace26fa297 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 3 Aug 2023 17:07:03 +0800 Subject: [PATCH 031/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=87=A0?= =?UTF-8?q?=E4=B8=AA=E6=B5=8B=E8=AF=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/api/feignclient/ExampleClient.java | 5 +++++ .../svc/controller/ExampleController.java | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/ExampleClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/ExampleClient.java index f2b31ecb..01ab5156 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/ExampleClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/ExampleClient.java @@ -17,4 +17,9 @@ public interface ExampleClient { @PostMapping("example/test_str") String testStr(@RequestParam("str") String str); + @PostMapping("example/test_result") + Object testApiResult(); + + @PostMapping("example/test_exception") + Object testException(); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/ExampleController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/ExampleController.java index 959b363f..fcb20a67 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/ExampleController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/ExampleController.java @@ -1,6 +1,9 @@ package com.github.cadecode.uniboot.framework.svc.controller; +import com.github.cadecode.uniboot.common.core.exception.ApiException; +import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.api.enums.FrameErrorEnum; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -24,12 +27,21 @@ @RequestMapping("example") public class ExampleController { - // For feign client - @ApiFormat(false) @ApiOperation("传递字符串") @PostMapping("test_str") public String testStr(@RequestParam String str) { return str; } + @ApiOperation("返回异常结果") + @PostMapping("test_result") + public ApiResult testApiResult() { + return ApiResult.error(FrameErrorEnum.UNKNOWN).moreInfo("测试返回异常结果"); + } + + @ApiOperation("直接抛出异常") + @PostMapping("test_exception") + public Object testException() { + throw ApiException.of("测试直接抛出异常"); + } } From e9b01d32129154396e28435a440ea01c79c4cecb Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 8 Aug 2023 15:27:12 +0800 Subject: [PATCH 032/244] =?UTF-8?q?feat:=20=E5=B0=81=E8=A3=85=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E6=98=AF=E5=90=A6=E5=86=85=E9=83=A8=E8=B0=83=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../filter/TokenAuthFilterService.java | 21 +++------ .../framework/api/util/RequestUtil.java | 44 +++++++++++++++++++ 2 files changed, 51 insertions(+), 14 deletions(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java index aff0db1c..72ff7e2d 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java @@ -1,7 +1,6 @@ package com.github.cadecode.uniboot.framework.api.security.filter; import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.EscapeUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.http.ContentType; @@ -10,7 +9,7 @@ import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.util.RequestUtil; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; @@ -63,18 +62,12 @@ protected void writeResponse(HttpServletResponse response, ApiErrorCode errorCod * 由 handler 方法提供处理 */ public void filter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { - // 根据请求头判断是否是内部请求 - String source = ServletUtil.getHeader(request, SecurityConst.HEAD_SOURCE, CharsetUtil.CHARSET_UTF_8); - if (ObjectUtil.equal(source, SecurityConst.HEAD_SOURCE_VALUE)) { - // 从请求头中提取来自其他服务调用传递得用户信息 - String escapedUserDetailsJson = ServletUtil.getHeader(request, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); - if (ObjectUtil.isNotEmpty(escapedUserDetailsJson)) { - SysUserDetailsDto userDetailsDto = JacksonUtil.toBean(EscapeUtil.unescape(escapedUserDetailsJson), SysUserDetailsDto.class); - if (ObjectUtil.isNotNull(userDetailsDto)) { - setAuthentication(request, userDetailsDto); - filterChain.doFilter(request, response); - return; - } + if (RequestUtil.isInnerRequest(request)) { + SysUserDetailsDto userDetailsDto = RequestUtil.getInnerUserDetails(request); + if (ObjectUtil.isNotNull(userDetailsDto)) { + setAuthentication(request, userDetailsDto); + filterChain.doFilter(request, response); + return; } } handler(request, response, filterChain); diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java index 1485c3bf..12cfe49e 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java @@ -1,6 +1,12 @@ package com.github.cadecode.uniboot.framework.api.util; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.EscapeUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.extra.servlet.ServletUtil; +import com.github.cadecode.uniboot.common.core.util.JacksonUtil; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -30,4 +36,42 @@ public static HttpServletResponse getResponse() { } return requestAttributes.getResponse(); } + + /** + * 根据请求头判断是否是内部请求 + * + * @param request 请求对象,为 null 时自动从上下文获取 + * @return 是否是内部请求 + */ + public static boolean isInnerRequest(HttpServletRequest request) { + if (ObjectUtil.isNull(request)) { + request = getRequest(); + } + if (ObjectUtil.isNull(request)) { + return false; + } + String source = ServletUtil.getHeader(request, SecurityConst.HEAD_SOURCE, CharsetUtil.CHARSET_UTF_8); + return ObjectUtil.equal(source, SecurityConst.HEAD_SOURCE_VALUE); + } + + /** + * 根据请求头获取内部请求携带的用户信息 + * + * @param request 请求对象,为 null 时自动从上下文获取 + * @return 内部请求携带的用户信息 + */ + public static SysUserDetailsDto getInnerUserDetails(HttpServletRequest request) { + if (ObjectUtil.isNull(request)) { + request = getRequest(); + } + if (ObjectUtil.isNull(request)) { + return null; + } + // feign 拦截器填充时做了转义处理 + String escapedUserDetailsJson = ServletUtil.getHeader(request, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); + if (ObjectUtil.isNotEmpty(escapedUserDetailsJson)) { + return JacksonUtil.toBean(EscapeUtil.unescape(escapedUserDetailsJson), SysUserDetailsDto.class); + } + return null; + } } From d9b192abeeeeb678c95daecedb5798fd8ce9da66 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 8 Aug 2023 15:42:05 +0800 Subject: [PATCH 033/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=87=A0?= =?UTF-8?q?=E4=B8=AA=E6=B5=8B=E8=AF=95=E6=8E=A5=E5=8F=A3=E7=9A=84=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/svc/controller/RpcExampleController.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java index f9513e3a..af7c4d84 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java @@ -33,4 +33,16 @@ public String testStr(@RequestParam String str) { return exampleClient.testStr(str); } + @ApiOperation("返回异常结果") + @PostMapping("test_result") + public Object testApiResult() { + return exampleClient.testApiResult(); + } + + @ApiOperation("直接抛出异常") + @PostMapping("test_exception") + public Object testException() { + return exampleClient.testException(); + } + } From 497827cf720f85aabec49b72fcc6b31d3c3da601 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 8 Aug 2023 15:45:44 +0800 Subject: [PATCH 034/244] =?UTF-8?q?feat:=20=E5=86=85=E9=83=A8=E8=B0=83?= =?UTF-8?q?=E7=94=A8=E7=BB=93=E6=9E=9C=E4=B8=8D=E9=9C=80=E8=A6=81=E5=8C=85?= =?UTF-8?q?=E8=A3=85=EF=BC=8C=E5=92=8C=20@ApiFormat=20=E6=97=A0=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/advisor/ApiResultAdvisor.java | 22 ++++++++++++------- .../svc/controller/SysApiController.java | 1 - .../svc/controller/SysLogController.java | 1 - 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiResultAdvisor.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiResultAdvisor.java index 916f07b1..29fd0c3a 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiResultAdvisor.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiResultAdvisor.java @@ -6,6 +6,7 @@ import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.api.enums.FrameErrorEnum; +import com.github.cadecode.uniboot.framework.api.util.RequestUtil; import org.springframework.core.MethodParameter; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -59,15 +60,20 @@ public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType private Object apiResultFormat(MethodParameter returnType, Object body, ServerHttpResponse response) { // 是否需要包装标记 boolean formatFlag; - // 获取方法上的 ApiFormat 注解 - ApiFormat formatM = returnType.getMethodAnnotation(ApiFormat.class); - // 以方法上注解为主 - if (Objects.nonNull(formatM)) { - formatFlag = formatM.value(); + // 如果是内部调用则不需要包装 + if (RequestUtil.isInnerRequest(null)) { + formatFlag = false; } else { - // 获取类上的 ApiFormat 注解 - ApiFormat formatC = returnType.getContainingClass().getAnnotation(ApiFormat.class); - formatFlag = Objects.nonNull(formatC) && formatC.value(); + // 获取方法上的 ApiFormat 注解 + ApiFormat formatM = returnType.getMethodAnnotation(ApiFormat.class); + // 以方法上注解为主 + if (Objects.nonNull(formatM)) { + formatFlag = formatM.value(); + } else { + // 获取类上的 ApiFormat 注解 + ApiFormat formatC = returnType.getContainingClass().getAnnotation(ApiFormat.class); + formatFlag = Objects.nonNull(formatC) && formatC.value(); + } } // 不需要包装,直接返回 if (!formatFlag) { diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java index ee7503ce..9bc125a7 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java @@ -123,7 +123,6 @@ public List listSwaggerVo() { } @ApiInner(onlyClient = true) - @ApiFormat(false) @ApiOperation("查询API列表-全部") @PostMapping("list_roles_vo") public List listRolesVo() { diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java index 1dac364a..4280ce07 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java @@ -68,7 +68,6 @@ public boolean delete(@RequestBody @NotEmpty List idList) { } @ApiInner(onlyClient = true) - @ApiFormat(false) @ApiOperation("添加") @PostMapping("save") public boolean save(@RequestBody @NotEmpty List dtoList) { From dc2dc285ab979a3b41b99b0cfc7dc356a314c510 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 8 Aug 2023 15:58:31 +0800 Subject: [PATCH 035/244] =?UTF-8?q?feat:=20=E7=BD=91=E5=85=B3=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=AF=B7=E6=B1=82=E5=A4=B4=E8=BF=87=E6=BB=A4=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gateway/filter/RequestHeaderFilter.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java new file mode 100644 index 00000000..6a874f0f --- /dev/null +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java @@ -0,0 +1,30 @@ +package com.github.cadecode.uniboot.gateway.filter; + +import org.springframework.cloud.gateway.filter.GatewayFilterChain; +import org.springframework.cloud.gateway.filter.GlobalFilter; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.stereotype.Component; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; + +/** + * 请求头统一过滤 + * + * @author Cade Li + * @since 2023/8/8 + */ +@Component +public class RequestHeaderFilter implements GlobalFilter { + + @Override + public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { + // 去掉内部调用专用的请求头,防止伪造 + ServerHttpRequest request = exchange.getRequest().mutate() + .headers(h -> { + h.remove("from-source"); + h.remove("inner-user-details"); + }) + .build(); + return chain.filter(exchange.mutate().request(request).build()); + } +} From 27da71939d7ae2aebf450017b9f55a899c541601 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 8 Aug 2023 20:06:24 +0800 Subject: [PATCH 036/244] =?UTF-8?q?fix:=20=E5=A4=84=E7=90=86=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=20null=20=E7=9A=84=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=20ErrorCode=20=E7=9A=84=20code=20=E5=80=BC?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E6=AF=94=E8=BE=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/api/advisor/ApiExceptionAdvisor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiExceptionAdvisor.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiExceptionAdvisor.java index b0682833..e8b2592e 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiExceptionAdvisor.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiExceptionAdvisor.java @@ -25,7 +25,7 @@ public class ApiExceptionAdvisor { public ApiResult handleApiException(ApiException e) { log.error("Api Exception =>", e); // 特殊处理接口返回 null 的情况 - if (e.getErrorCode() == FrameErrorEnum.RES_BODY_NULL) { + if (FrameErrorEnum.RES_BODY_NULL.getCode().equals(e.getErrorCode().getCode())) { return ApiResult.ok(null); } return ApiResult.error(e.getErrorCode()).moreInfo(e.getMoreInfo()); From 2e49ea75d856b725049e27ff03de896974e84519 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 8 Aug 2023 22:20:32 +0800 Subject: [PATCH 037/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20RPC=20?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E7=9B=B8=E5=85=B3=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cadecode/uniboot/framework/api/enums/FrameErrorEnum.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/FrameErrorEnum.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/FrameErrorEnum.java index 174b33cb..329bd529 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/FrameErrorEnum.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/FrameErrorEnum.java @@ -58,6 +58,9 @@ public int getStatus() { UPLOAD_FILE_FAIL(2002, "上传文件失败"), FILE_NOT_FOUND(2003, "文件未找到"), + // rpc + RPC_UNKNOWN_ERROR(3001, "RPC UNKNOWN 异常"), + RPC_UNWRAP_FAIL(3002, "RPC UNWRAP 失败"), ; private final String code; From bbb433741b4c37f911d8b3f33cfcf6a8ff7f5f72 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 8 Aug 2023 22:29:48 +0800 Subject: [PATCH 038/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20feign=20?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=20Decoder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/api/config/FeignConfig.java | 8 ++ .../api/feign/FeignErrorDecoder.java | 88 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignErrorDecoder.java diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java index dbb48d89..897c11ab 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java @@ -5,16 +5,19 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.servlet.ServletUtil; +import com.fasterxml.jackson.databind.ObjectMapper; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.feign.FeignClientDecorator; +import com.github.cadecode.uniboot.framework.api.feign.FeignErrorDecoder; import com.github.cadecode.uniboot.framework.api.util.RequestUtil; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import feign.Client; import feign.Client.Default; import feign.RequestInterceptor; import feign.RequestTemplate; +import feign.codec.ErrorDecoder; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory; import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; @@ -83,4 +86,9 @@ public Client feignRetryClient(LoadBalancerClient loadBalancerClient, LoadBalanc FeignClientDecorator decorator = new FeignClientDecorator(new Default(null, null)); return new RetryableFeignBlockingLoadBalancerClient(decorator, loadBalancerClient, loadBalancedRetryFactory, properties, loadBalancerClientFactory); } + + @Bean + public ErrorDecoder errorDecoder(ObjectMapper objectMapper) { + return new FeignErrorDecoder(objectMapper); + } } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignErrorDecoder.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignErrorDecoder.java new file mode 100644 index 00000000..cad8dd99 --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignErrorDecoder.java @@ -0,0 +1,88 @@ +package com.github.cadecode.uniboot.framework.api.feign; + +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; +import com.github.cadecode.uniboot.common.core.exception.ApiException; +import com.github.cadecode.uniboot.common.core.web.response.ApiResult; +import com.github.cadecode.uniboot.common.core.web.response.ApiResult.ErrorMessage; +import com.github.cadecode.uniboot.framework.api.enums.FrameErrorEnum; +import feign.FeignException; +import feign.Response; +import feign.codec.ErrorDecoder; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +import java.io.Reader; + +/** + * Feign 异常内容解码器 + * + * @author Cade Li + * @since 2023/8/2 + */ +@Slf4j +@RequiredArgsConstructor +public class FeignErrorDecoder implements ErrorDecoder { + + private final ObjectMapper objectMapper; + + @Override + public Exception decode(String methodKey, Response response) { + ApiResult result; + try { + Reader reader = response.body().asReader(CharsetUtil.CHARSET_UTF_8); + result = objectMapper.readValue(reader, ApiResult.class); + } catch (Exception e) { + throw ApiException.of(FrameErrorEnum.RPC_UNWRAP_FAIL, e); + } + // 获取 ErrorMessage + ErrorMessage error = result.getError(); + // 返回默认包装的 FeignException + if (ObjectUtil.isNull(error)) { + FeignException feignException = FeignException.errorStatus(methodKey, response); + return ApiException.of(FrameErrorEnum.RPC_UNKNOWN_ERROR, feignException); + } + // 构造 ApiErrorCode + ApiErrorCode errorCode = getErrorCode(result, error); + // 构造 moreInfo + String moreInfo = getMoreInfo(error); + return ApiException.of(errorCode, moreInfo); + } + + /** + * 根据 ErrorMessage 构造 ApiErrorCode 对象 + */ + private ApiErrorCode getErrorCode(ApiResult result, ErrorMessage error) { + return new ApiErrorCode() { + @Override + public String getCode() { + return error.getCode(); + } + + @Override + public String getMessage() { + return error.getMessage(); + } + + @Override + public int getStatus() { + return result.getStatus(); + } + }; + } + + /** + * 根据 ErrorMessage 获取 moreInfo 字符串 + */ + private String getMoreInfo(ErrorMessage error) { + String moreInfo = error.getMoreInfo(); + // 在 moreInfo 前段追加 RPC 标记 + if (!StrUtil.startWith(moreInfo, "[RPC]")) { + moreInfo = StrUtil.concat(true, "[RPC]", moreInfo); + } + return moreInfo; + } +} From 26095b141b276934b9dffa5924adc0703082928e Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 11 Aug 2023 00:00:06 +0800 Subject: [PATCH 039/244] =?UTF-8?q?feat:=20gateway=20=E6=B7=BB=E5=8A=A0=20?= =?UTF-8?q?filter=20=E7=94=9F=E6=88=90=20traceId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gateway/filter/RequestHeaderFilter.java | 10 ++++- .../gateway/filter/TraceInfoFilter.java | 37 +++++++++++++++++++ gateway/src/main/resources/logback-spring.xml | 4 +- 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/TraceInfoFilter.java diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java index 6a874f0f..7e59d8fa 100644 --- a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java @@ -2,6 +2,7 @@ import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; +import org.springframework.core.annotation.Order; import org.springframework.http.server.reactive.ServerHttpRequest; import org.springframework.stereotype.Component; import org.springframework.web.server.ServerWebExchange; @@ -13,16 +14,21 @@ * @author Cade Li * @since 2023/8/8 */ +@Order(1) @Component public class RequestHeaderFilter implements GlobalFilter { + public static final String HEAD_SOURCE = "from-source"; + + public static final String HEAD_USER_DETAILS = "inner-user-details"; + @Override public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { // 去掉内部调用专用的请求头,防止伪造 ServerHttpRequest request = exchange.getRequest().mutate() .headers(h -> { - h.remove("from-source"); - h.remove("inner-user-details"); + h.remove(HEAD_SOURCE); + h.remove(HEAD_USER_DETAILS); }) .build(); return chain.filter(exchange.mutate().request(request).build()); diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/TraceInfoFilter.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/TraceInfoFilter.java new file mode 100644 index 00000000..0a000521 --- /dev/null +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/TraceInfoFilter.java @@ -0,0 +1,37 @@ +package com.github.cadecode.uniboot.gateway.filter; + +import cn.hutool.core.lang.UUID; +import org.slf4j.MDC; +import org.springframework.cloud.gateway.filter.GatewayFilterChain; +import org.springframework.cloud.gateway.filter.GlobalFilter; +import org.springframework.core.annotation.Order; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.stereotype.Component; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; + +/** + * 用于添加 trace id 的过滤器 + * + * @author Cade Li + * @since 2023/8/10 + */ +@Order(0) +@Component +public class TraceInfoFilter implements GlobalFilter { + + public static final String HEAD_TRACE_ID = "trace-id"; + + @Override + public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { + String traceId = UUID.fastUUID().toString(true); + ServerHttpRequest request = exchange.getRequest().mutate() + .headers(h -> { + MDC.put(HEAD_TRACE_ID, traceId); + h.set(HEAD_TRACE_ID, traceId); + }) + .build(); + exchange.getResponse().getHeaders().set(HEAD_TRACE_ID, traceId); + return chain.filter(exchange.mutate().request(request).build()); + } +} diff --git a/gateway/src/main/resources/logback-spring.xml b/gateway/src/main/resources/logback-spring.xml index 9b734e71..050f8c7c 100644 --- a/gateway/src/main/resources/logback-spring.xml +++ b/gateway/src/main/resources/logback-spring.xml @@ -24,9 +24,9 @@ + value="%red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%-15thread]-%X{trace-id}) %highlight(%-5level) %cyan(%-50logger{50}) : %msg%n"/> - + From ce5004d0522975a41958cb13d64588735c3f7b27 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 11 Aug 2023 00:01:18 +0800 Subject: [PATCH 040/244] =?UTF-8?q?feat:=20=E9=85=8D=E7=BD=AE=20trace=20id?= =?UTF-8?q?=20=E8=BF=87=E6=BB=A4=E5=99=A8=EF=BC=8C=E9=85=8D=E7=BD=AE=20fei?= =?UTF-8?q?gn=20=E4=BC=A0=E9=80=92=20trace=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/logback-spring.xml | 4 +-- .../framework/api/config/FeignConfig.java | 7 ++++- .../framework/api/config/SecurityConfig.java | 30 +++++++++++++++++++ .../framework/api/consts/SecurityConst.java | 10 +++++++ .../src/main/resources/logback-spring.xml | 4 +-- 5 files changed, 50 insertions(+), 5 deletions(-) diff --git a/example/example_svc/src/main/resources/logback-spring.xml b/example/example_svc/src/main/resources/logback-spring.xml index 9b734e71..050f8c7c 100644 --- a/example/example_svc/src/main/resources/logback-spring.xml +++ b/example/example_svc/src/main/resources/logback-spring.xml @@ -24,9 +24,9 @@ + value="%red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%-15thread]-%X{trace-id}) %highlight(%-5level) %cyan(%-50logger{50}) : %msg%n"/> - + diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java index 897c11ab..d85e5948 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java @@ -52,7 +52,12 @@ protected void configRequestTemplate(RequestTemplate requestTemplate) { return; } // 配置客户端 IP - requestTemplate.header("X-Forwarded-For", ServletUtil.getClientIP(servletRequest)); + requestTemplate.header(SecurityConst.HEAD_FORWARDED_FOR, ServletUtil.getClientIP(servletRequest)); + // 传递 trace id + String traceId = ServletUtil.getHeader(servletRequest, SecurityConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); + if (ObjectUtil.isNotEmpty(traceId)) { + requestTemplate.header(SecurityConst.HEAD_TRACE_ID, traceId); + } // 传递用户 token String token = SecurityUtil.getTokenFromRequest(servletRequest); if (StrUtil.isNotEmpty(token)) { diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java index 9538707c..f4e0cf96 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java @@ -2,7 +2,11 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.extra.servlet.ServletUtil; import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.api.security.filter.TokenAuthFilter; import com.github.cadecode.uniboot.framework.api.security.handler.NoAuthenticationHandler; @@ -11,6 +15,7 @@ import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.slf4j.MDC; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -26,7 +31,13 @@ import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.web.access.expression.WebExpressionVoter; import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import org.springframework.web.filter.OncePerRequestFilter; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.Arrays; import java.util.List; @@ -89,6 +100,8 @@ protected void configure(HttpSecurity http) throws Exception { Arrays.asList(new WebExpressionVoter(), dataBaseRoleVoter))); // 配置 Token 校验过滤器 http.addFilterBefore(tokenAuthFilter, UsernamePasswordAuthenticationFilter.class); + // 配置 trace id 过滤器 + http.addFilterBefore(new TraceInfoFilter(), TokenAuthFilter.class); log.info("Config Security over,AuthModel:{}", properties.getAuthModel()); } @@ -147,4 +160,21 @@ public static class TokenConfig { */ private String secret; } + + /** + * Filter + * trace id to MDC + */ + public static class TraceInfoFilter extends OncePerRequestFilter { + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain + filterChain) + throws ServletException, IOException { + String traceId = ServletUtil.getHeader(request, SecurityConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); + if (ObjectUtil.isNotEmpty(traceId)) { + MDC.put(SecurityConst.HEAD_TRACE_ID, traceId); + } + filterChain.doFilter(request, response); + } + } } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java index 17b468e1..1db98466 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java @@ -28,4 +28,14 @@ public interface SecurityConst { */ String HEAD_USER_DETAILS = "inner-user-details"; + /** + * X-Forwarded-For + */ + String HEAD_FORWARDED_FOR = "X-Forwarded-For"; + + /** + * trace id + */ + String HEAD_TRACE_ID = "trace-id"; + } diff --git a/framework/framework_svc/src/main/resources/logback-spring.xml b/framework/framework_svc/src/main/resources/logback-spring.xml index 9b734e71..050f8c7c 100644 --- a/framework/framework_svc/src/main/resources/logback-spring.xml +++ b/framework/framework_svc/src/main/resources/logback-spring.xml @@ -24,9 +24,9 @@ + value="%red(%d{yyyy-MM-dd HH:mm:ss.SSS}) %green([%-15thread]-%X{trace-id}) %highlight(%-5level) %cyan(%-50logger{50}) : %msg%n"/> - + From dd448a8047314a6be89565af41d802384a80222e Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 11 Aug 2023 14:04:30 +0800 Subject: [PATCH 041/244] =?UTF-8?q?feat:=20=E5=90=8E=E7=BC=80=20dto=20?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=20vo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/api/bean/dto/SysUserDto.java | 12 ------------ .../uniboot/framework/api/bean/vo/SysUserVo.java | 13 +++++++++++++ .../framework/svc/controller/SysUserController.java | 6 +++--- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java index 927fe838..83a103ee 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java @@ -1,11 +1,7 @@ package com.github.cadecode.uniboot.framework.api.bean.dto; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; -import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Data; -import lombok.NoArgsConstructor; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.authority.SimpleGrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; @@ -83,12 +79,4 @@ public boolean isEnabled() { return true; } } - - @Data - @AllArgsConstructor - @NoArgsConstructor - @Builder - public static class SysUserInfoDto { - private List menuList; - } } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysUserVo.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysUserVo.java index 43cca980..83152588 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysUserVo.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysUserVo.java @@ -1,7 +1,11 @@ package com.github.cadecode.uniboot.framework.api.bean.vo; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.util.Date; import java.util.List; @@ -46,4 +50,13 @@ public static class SysUserRolesVo { private List roles; } + + + @Data + @AllArgsConstructor + @NoArgsConstructor + @Builder + public static class SysUserInfoVo { + private List menuList; + } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java index 19c4ba3c..8f594cc5 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java @@ -5,9 +5,9 @@ import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserInfoDto; import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; +import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserInfoVo; import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; import com.github.cadecode.uniboot.framework.api.convert.SysUserConvert; import com.github.cadecode.uniboot.framework.api.request.SysUserRequest; @@ -58,10 +58,10 @@ public class SysUserController { */ @ApiOperation("获取用户信息") @PostMapping("get_info") - public SysUserInfoDto getInfo() { + public SysUserInfoVo getInfo() { SysUserDetailsDto userDetails = SecurityUtil.getUserDetails(null); List sysMenuTreeVos = sysMenuService.listTreeVoByRoles(userDetails.getRoles()); - return SysUserInfoDto.builder().menuList(sysMenuTreeVos).build(); + return SysUserInfoVo.builder().menuList(sysMenuTreeVos).build(); } @ApiOperation("修改用户信息(用户中心)") From d2e58493828fbabdbd1020ef595674450a1118fd Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 11 Aug 2023 16:43:19 +0800 Subject: [PATCH 042/244] =?UTF-8?q?feat:=20=E5=AE=9E=E4=BD=93=E7=B1=BB?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E8=A7=84=E8=8C=83=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 接口使用 request/vo 2. feign client 使用 dto/response --- .../framework/api/bean/dto/SysLogDto.java | 2 +- .../framework/api/bean/dto/SysUserDto.java | 82 ------------------- .../framework/api/config/FeignConfig.java | 4 +- .../framework/api/convert/SysApiConvert.java | 11 ++- .../framework/api/convert/SysDictConvert.java | 8 ++ .../framework/api/convert/SysLogConvert.java | 8 +- .../framework/api/convert/SysMenuConvert.java | 11 +++ .../framework/api/convert/SysRoleConvert.java | 8 ++ .../framework/api/convert/SysUserConvert.java | 30 +++++-- .../api/feignclient/SysApiClient.java | 4 +- .../api/feignclient/SysLogClient.java | 4 +- .../framework/api/plugin/ApiLogHandler.java | 8 +- .../framework/api/request/SysLogRequest.java | 38 +++++++++ .../api/response/SysApiResponse.java | 33 ++++++++ .../filter/JwtTokenAuthFilterService.java | 8 +- .../filter/RedisTokenAuthFilterService.java | 9 +- .../filter/TokenAuthFilterService.java | 4 +- .../api/security/model/SysUserDetails.java | 76 +++++++++++++++++ .../api/security/voter/DataBaseRoleVoter.java | 20 ++--- .../framework/api/util/RequestUtil.java | 6 +- .../framework/api/util/SecurityUtil.java | 18 ++-- .../svc/controller/SysLogController.java | 6 +- .../svc/controller/SysUserController.java | 8 +- .../JwtLoginSuccessHandleService.java | 11 ++- .../security/LoginSuccessHandleService.java | 4 +- .../svc/security/LoginSuccessHandler.java | 19 ++--- .../RedisLoginSuccessHandleService.java | 11 ++- .../svc/serviceimpl/SysUserServiceImpl.java | 2 +- 28 files changed, 281 insertions(+), 172 deletions(-) delete mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/response/SysApiResponse.java create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/model/SysUserDetails.java diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java index d94675e7..f697e343 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java @@ -21,7 +21,7 @@ public class SysLogDto { @AllArgsConstructor @NoArgsConstructor @Builder - public static class SysLogInfoDto { + public static class SysLogSaveDto { private LogTypeEnum logType; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java deleted file mode 100644 index 83a103ee..00000000 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.github.cadecode.uniboot.framework.api.bean.dto; - -import com.fasterxml.jackson.annotation.JsonIgnore; -import lombok.Data; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; - -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.stream.Collectors; - -/** - * 系统用户 DTO,实现 UserDetails 接口 - * - * @author Cade Li - * @date 2022/5/24 - */ -public class SysUserDto { - - /** - * SpringSecurity UserDetails实现 - */ - @Data - public static class SysUserDetailsDto implements UserDetails { - - private Long id; - - private String username; - - @JsonIgnore - private String password; - - private String nickName; - - private Boolean enableFlag; - - private String sex; - - private String mail; - - private String phone; - - private String loginIp; - - private Date loginDate; - - List roles; - - @JsonIgnore - @Override - public Collection getAuthorities() { - // 重写获取权限的方法,从角色字符串创建 SimpleGrantedAuthority - return roles.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList()); - } - - @JsonIgnore - @Override - public boolean isAccountNonExpired() { - return true; - } - - @JsonIgnore - @Override - public boolean isAccountNonLocked() { - return true; - } - - @JsonIgnore - @Override - public boolean isCredentialsNonExpired() { - return true; - } - - @JsonIgnore - @Override - public boolean isEnabled() { - return true; - } - } -} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java index d85e5948..49975582 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java @@ -7,10 +7,10 @@ import cn.hutool.extra.servlet.ServletUtil; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.feign.FeignClientDecorator; import com.github.cadecode.uniboot.framework.api.feign.FeignErrorDecoder; +import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.api.util.RequestUtil; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import feign.Client; @@ -67,7 +67,7 @@ protected void configRequestTemplate(RequestTemplate requestTemplate) { String userDetailsJson = ServletUtil.getHeader(servletRequest, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); // 不存在则生成 if (StrUtil.isEmpty(userDetailsJson)) { - SysUserDetailsDto userDetailsDto = SecurityUtil.getUserDetails(null); + SysUserDetails userDetailsDto = SecurityUtil.getUserDetails(null); userDetailsJson = JacksonUtil.toJson(userDetailsDto); } requestTemplate.header(SecurityConst.HEAD_USER_DETAILS, EscapeUtil.escape(userDetailsJson)); diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysApiConvert.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysApiConvert.java index cf5db9ea..b3d8c081 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysApiConvert.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysApiConvert.java @@ -1,10 +1,10 @@ package com.github.cadecode.uniboot.framework.api.convert; import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; import com.github.cadecode.uniboot.framework.api.request.SysApiRequest.SysApiAddRequest; import com.github.cadecode.uniboot.framework.api.request.SysApiRequest.SysApiUpdateRequest; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; /** @@ -18,10 +18,15 @@ public interface SysApiConvert { SysApiConvert INSTANCE = Mappers.getMapper(SysApiConvert.class); - SysApiRolesVo poToRolesVo(SysApi po); - + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + @Mapping(target = "createTime", ignore = true) SysApi requestToPo(SysApiUpdateRequest request); + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + @Mapping(target = "id", ignore = true) + @Mapping(target = "createTime", ignore = true) SysApi requestToPo(SysApiAddRequest request); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysDictConvert.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysDictConvert.java index 2a246b3a..f7ecb4e5 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysDictConvert.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysDictConvert.java @@ -7,6 +7,7 @@ import com.github.cadecode.uniboot.framework.api.request.SysDictRequest.SysDictAddRequest; import com.github.cadecode.uniboot.framework.api.request.SysDictRequest.SysDictUpdateRequest; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; import java.util.List; @@ -23,8 +24,15 @@ public interface SysDictConvert { List poToPageVo(List records); + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + @Mapping(target = "id", ignore = true) + @Mapping(target = "createTime", ignore = true) SysDict requestToPo(SysDictAddRequest request); + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + @Mapping(target = "createTime", ignore = true) SysDict requestToPo(SysDictUpdateRequest request); List poToGetByTypeVo(List dictList); diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java index dfe57d20..67a4595d 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java @@ -1,8 +1,8 @@ package com.github.cadecode.uniboot.framework.api.convert; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogInfoDto; import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; import com.github.cadecode.uniboot.framework.api.bean.vo.SysLogVo.SysLogPageVo; +import com.github.cadecode.uniboot.framework.api.request.SysLogRequest.SysLogSaveRequest; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -19,9 +19,7 @@ public interface SysLogConvert { SysLogConvert INSTANCE = Mappers.getMapper(SysLogConvert.class); - SysLog dtoToPo(SysLogInfoDto dto); - - List dtoToPo(List dto); - List poToVo(List records); + + List requestToPo(List requestList); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysMenuConvert.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysMenuConvert.java index d1499d77..42ecca19 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysMenuConvert.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysMenuConvert.java @@ -5,6 +5,7 @@ import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest.SysMenuAddRequest; import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest.SysMenuUpdateRequest; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; /** @@ -18,10 +19,20 @@ public interface SysMenuConvert { SysMenuConvert INSTANCE = Mappers.getMapper(SysMenuConvert.class); + @Mapping(target = "children", ignore = true) SysMenuTreeVo toTreeVo(SysMenu sysMenu); + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + @Mapping(target = "leafFlag", ignore = true) + @Mapping(target = "enableFlag", ignore = true) + @Mapping(target = "createTime", ignore = true) SysMenu requestToPo(SysMenuUpdateRequest request); + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + @Mapping(target = "id", ignore = true) + @Mapping(target = "createTime", ignore = true) SysMenu requestToPo(SysMenuAddRequest request); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysRoleConvert.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysRoleConvert.java index db7e38dd..7f2e6b16 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysRoleConvert.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysRoleConvert.java @@ -5,6 +5,7 @@ import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleAddRequest; import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleUpdateRequest; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; import java.util.List; @@ -24,7 +25,14 @@ public interface SysRoleConvert { List poToListVo(List po); + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + @Mapping(target = "createTime", ignore = true) SysRole requestToPo(SysRoleUpdateRequest request); + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + @Mapping(target = "id", ignore = true) + @Mapping(target = "createTime", ignore = true) SysRole requestToPo(SysRoleAddRequest request); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysUserConvert.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysUserConvert.java index b129b91c..0df8d04a 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysUserConvert.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysUserConvert.java @@ -1,12 +1,13 @@ package com.github.cadecode.uniboot.framework.api.convert; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserAddRequest; import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserModifyInfoRequest; import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserUpdateRequest; +import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; import org.mapstruct.Mapper; +import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; /** @@ -20,15 +21,32 @@ public interface SysUserConvert { SysUserConvert INSTANCE = Mappers.getMapper(SysUserConvert.class); - SysUserRolesVo poToRolesVo(SysUser po); - - SysUserDetailsDto poToDetailsDto(SysUser po); - - SysUserDetailsDto voToDetailsDto(SysUserRolesVo vo); + SysUserDetails voToSysUserDetails(SysUserRolesVo vo); + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + @Mapping(target = "loginIp", ignore = true) + @Mapping(target = "loginDate", ignore = true) + @Mapping(target = "id", ignore = true) + @Mapping(target = "createTime", ignore = true) SysUser requestToPo(SysUserAddRequest request); + @Mapping(target = "username", ignore = true) + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + @Mapping(target = "password", ignore = true) + @Mapping(target = "loginIp", ignore = true) + @Mapping(target = "loginDate", ignore = true) + @Mapping(target = "id", ignore = true) + @Mapping(target = "enableFlag", ignore = true) + @Mapping(target = "createTime", ignore = true) SysUser requestToPo(SysUserModifyInfoRequest request); + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + @Mapping(target = "loginIp", ignore = true) + @Mapping(target = "loginDate", ignore = true) + @Mapping(target = "enableFlag", ignore = true) + @Mapping(target = "createTime", ignore = true) SysUser requestToPo(SysUserUpdateRequest request); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java index 2b9b33d2..7ab19d2f 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java @@ -1,8 +1,8 @@ package com.github.cadecode.uniboot.framework.api.feignclient; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; import com.github.cadecode.uniboot.framework.api.consts.SvcName; +import com.github.cadecode.uniboot.framework.api.response.SysApiResponse.SysApiRolesResponse; import org.springframework.cache.annotation.Cacheable; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -20,6 +20,6 @@ public interface SysApiClient { @Cacheable(cacheNames = KeyPrefix.API_ROLES, key = "'all'") @PostMapping("system/api/list_roles_vo") - List listRolesVo(); + List listRolesVo(); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java index f03c8b1a..58e441f6 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.framework.api.feignclient; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogInfoDto; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogSaveDto; import com.github.cadecode.uniboot.framework.api.consts.SvcName; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -19,6 +19,6 @@ public interface SysLogClient { @PostMapping("system/log/save") - boolean save(@RequestBody @NotEmpty List dtoList); + boolean save(@RequestBody @NotEmpty List dtoList); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java index fe066784..b25887a8 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java @@ -9,7 +9,7 @@ import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.aspect.ApiLoggerAspect.BaseLogInfo; import com.github.cadecode.uniboot.common.plugin.log.handler.AbstractApiLogHandler; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogInfoDto; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogSaveDto; import com.github.cadecode.uniboot.framework.api.feignclient.SysLogClient; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import io.swagger.annotations.ApiOperation; @@ -38,7 +38,7 @@ public class ApiLogHandler extends AbstractApiLogHandler { /** * 构造 LogInfo */ - public SysLogInfoDto generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogInfo) { + public SysLogSaveDto generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogInfo) { ApiLogger apiLogger = baseLogInfo.getApiLogger(); // 解析 user-agent,生成日志信息 String userAgentStr = baseLogInfo.getRequest().getHeader("User-Agent"); @@ -59,7 +59,7 @@ public SysLogInfoDto generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogI description = apiOperation.value(); } } - return SysLogInfoDto.builder() + return SysLogSaveDto.builder() .logType(apiLogger.type()) .classMethod(point.getSignature().getDeclaringTypeName() + '.' + point.getSignature().getName()) .exceptional(baseLogInfo.getExceptional()) @@ -87,7 +87,7 @@ public void save(ApiLogger apiLogger, Object o) { if (!apiLogger.enableSave()) { return; } - SysLogInfoDto dto = (SysLogInfoDto) o; + SysLogSaveDto dto = (SysLogSaveDto) o; if (!apiLogger.saveParams()) { dto.setRequestParams(null); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysLogRequest.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysLogRequest.java index cb005cca..5266f851 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysLogRequest.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysLogRequest.java @@ -3,6 +3,7 @@ import com.github.cadecode.uniboot.common.core.web.response.PageParams; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.Date; import java.util.List; @@ -16,6 +17,7 @@ public class SysLogRequest { @Data + @EqualsAndHashCode(callSuper = true) public static class SysLogPageRequest extends PageParams { private Date startTime; @@ -26,4 +28,40 @@ public static class SysLogPageRequest extends PageParams { private Boolean exceptional; } + + @Data + public static class SysLogSaveRequest { + + private LogTypeEnum logType; + + private String url; + + private Boolean exceptional; + + private String accessUser; + + private String description; + + private String classMethod; + + private String threadId; + + private String threadName; + + private String ip; + + private String httpMethod; + + private String requestParams; + + private String result; + + private Long timeCost; + + private String os; + + private String browser; + + private String userAgent; + } } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/response/SysApiResponse.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/response/SysApiResponse.java new file mode 100644 index 00000000..c8edc4fb --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/response/SysApiResponse.java @@ -0,0 +1,33 @@ +package com.github.cadecode.uniboot.framework.api.response; + +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * SysApi response + * + * @author Cade Li + * @since 2023/8/11 + */ +public class SysApiResponse { + + @Data + public static class SysApiRolesResponse { + + private Long id; + + private String url; + + private String description; + + private Date createTime; + + private Date updateTime; + + private String updateUser; + + private List roles; + } +} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java index b769569b..c154ce1b 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java @@ -4,10 +4,10 @@ import cn.hutool.json.JSONObject; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.core.util.TokenUtil; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; +import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -49,9 +49,9 @@ public void handler(HttpServletRequest request, HttpServletResponse response, Fi } // 获取 jwt 内容 JSONObject payload = TokenUtil.getPayload(jwtToken); - SysUserDetailsDto sysUserDetailsDto = payload.toBean(SysUserDetailsDto.class); + SysUserDetails sysUserDetails = payload.toBean(SysUserDetails.class); // 设置 AuthenticationToken - setAuthentication(request, sysUserDetailsDto); + setAuthentication(request, sysUserDetails); // 判断是否需要刷新 token // 获取过期时间,单位秒 long expiresAt = Long.parseLong(String.valueOf(payload.get("exp"))); @@ -60,7 +60,7 @@ public void handler(HttpServletRequest request, HttpServletResponse response, Fi // 如果当时时间距离过期时间不到配置的 expiration 一半,就下发新的 token if (expiresAt - System.currentTimeMillis() / 1000 < halfExpiration) { // 生成 jwt token - String newJwtToken = TokenUtil.generateToken(sysUserDetailsDto.getId(), sysUserDetailsDto.getUsername(), sysUserDetailsDto.getRoles(), + String newJwtToken = TokenUtil.generateToken(sysUserDetails.getId(), sysUserDetails.getUsername(), sysUserDetails.getRoles(), SecurityUtil.getExpiration(), SecurityUtil.getSecret()); // token 放在请求头 response.addHeader(SecurityConst.HEAD_TOKEN, newJwtToken); diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java index 90bc9ee9..dd520716 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java @@ -4,11 +4,10 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; import com.github.cadecode.uniboot.common.plugin.cache.util.RedisUtil; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; +import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -42,16 +41,16 @@ public void handler(HttpServletRequest request, HttpServletResponse response, Fi } // 查询 redis 中 token String loginUserKey = KeyGeneUtil.key(KeyPrefix.LOGIN_USER, uuidToken); - SysUserDetailsDto sysUserDetailsDto = RedisUtil.get(loginUserKey, SysUserDto.SysUserDetailsDto.class); + SysUserDetails sysUserDetails = RedisUtil.get(loginUserKey, SysUserDetails.class); // redis 中用户不存在 - if (Objects.isNull(sysUserDetailsDto)) { + if (Objects.isNull(sysUserDetails)) { writeResponse(response, AuthErrorEnum.TOKEN_EXPIRED, requestURI); return; } // 用户存在,刷新过期时间 RedisUtil.expire(loginUserKey, SecurityUtil.getExpiration(), TimeUnit.SECONDS); // 设置 AuthenticationToken - setAuthentication(request, sysUserDetailsDto); + setAuthentication(request, sysUserDetails); filterChain.doFilter(request, response); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java index 72ff7e2d..21d79406 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java @@ -8,7 +8,7 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyService; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.api.util.RequestUtil; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.context.SecurityContextHolder; @@ -63,7 +63,7 @@ protected void writeResponse(HttpServletResponse response, ApiErrorCode errorCod */ public void filter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { if (RequestUtil.isInnerRequest(request)) { - SysUserDetailsDto userDetailsDto = RequestUtil.getInnerUserDetails(request); + SysUserDetails userDetailsDto = RequestUtil.getInnerUserDetails(request); if (ObjectUtil.isNotNull(userDetailsDto)) { setAuthentication(request, userDetailsDto); filterChain.doFilter(request, response); diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/model/SysUserDetails.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/model/SysUserDetails.java new file mode 100644 index 00000000..84d7e661 --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/model/SysUserDetails.java @@ -0,0 +1,76 @@ +package com.github.cadecode.uniboot.framework.api.security.model; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import lombok.Data; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.security.core.userdetails.UserDetails; + +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * SpringSecurity UserDetails实现 + * + * @author Cade Li + * @since 2023/8/11 + */ +@Data +public class SysUserDetails implements UserDetails { + + private Long id; + + private String username; + + @JsonIgnore + private String password; + + private String nickName; + + private Boolean enableFlag; + + private String sex; + + private String mail; + + private String phone; + + private String loginIp; + + private Date loginDate; + + List roles; + + @JsonIgnore + @Override + public Collection getAuthorities() { + // 重写获取权限的方法,从角色字符串创建 SimpleGrantedAuthority + return roles.stream().map(SimpleGrantedAuthority::new).collect(Collectors.toList()); + } + + @JsonIgnore + @Override + public boolean isAccountNonExpired() { + return true; + } + + @JsonIgnore + @Override + public boolean isAccountNonLocked() { + return true; + } + + @JsonIgnore + @Override + public boolean isCredentialsNonExpired() { + return true; + } + + @JsonIgnore + @Override + public boolean isEnabled() { + return true; + } +} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java index 88427767..463ae1e8 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java @@ -1,9 +1,9 @@ package com.github.cadecode.uniboot.framework.api.security.voter; import cn.hutool.core.util.ObjectUtil; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; import com.github.cadecode.uniboot.framework.api.feignclient.SysApiClient; +import com.github.cadecode.uniboot.framework.api.response.SysApiResponse.SysApiRolesResponse; +import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import lombok.RequiredArgsConstructor; import org.springframework.security.access.ConfigAttribute; @@ -43,33 +43,33 @@ public int vote(Authentication authentication, Object object, Collection sysApiRolesVos = sysApiClient.listRolesVo(); + List apiRolesResponseList = sysApiClient.listRolesVo(); // 获取用户角色 - SysUserDetailsDto sysUserDetailsDto = SecurityUtil.getUserDetails(authentication); - List roles = sysUserDetailsDto.getRoles(); + SysUserDetails sysUserDetails = SecurityUtil.getUserDetails(authentication); + List roles = sysUserDetails.getRoles(); // 获取与 url 相同的配置,不存在与 url 相同配置则使用 spring mvc ant 风格匹配 - SysApiRolesVo sysApiRolesVo = sysApiRolesVos.stream() + SysApiRolesResponse apiRolesResponse = apiRolesResponseList.stream() .filter(api -> requestUrl.equals(api.getUrl())) .findFirst() .orElseGet(() -> { // 按 spring mvc 路径优先级找到优先级最高的配置 Comparator comparator = antPathMatcher.getPatternComparator(requestUrl); - return sysApiRolesVos.stream() + return apiRolesResponseList.stream() .filter(api -> antPathMatcher.match(api.getUrl(), requestUrl)) .min((o1, o2) -> comparator.compare(o1.getUrl(), o2.getUrl())) .orElse(null); }); // 数据库没有配置就弃权 - if (Objects.isNull(sysApiRolesVo)) { + if (Objects.isNull(apiRolesResponse)) { return ACCESS_ABSTAIN; } // 如果该 api 配置没有关联角色,则通过 // stream().noneMatch 表示没有符合条件的 - if (sysApiRolesVo.getRoles().stream().noneMatch(ObjectUtil::isNotNull)) { + if (apiRolesResponse.getRoles().stream().noneMatch(ObjectUtil::isNotNull)) { return ACCESS_GRANTED; } // 取用户 token 内角色和数据库查询出角色的交集 - roles.retainAll(sysApiRolesVo.getRoles()); + roles.retainAll(apiRolesResponse.getRoles()); return roles.size() > 0 ? ACCESS_GRANTED : ACCESS_DENIED; } } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java index 12cfe49e..2fc2a652 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java @@ -5,8 +5,8 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.extra.servlet.ServletUtil; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -60,7 +60,7 @@ public static boolean isInnerRequest(HttpServletRequest request) { * @param request 请求对象,为 null 时自动从上下文获取 * @return 内部请求携带的用户信息 */ - public static SysUserDetailsDto getInnerUserDetails(HttpServletRequest request) { + public static SysUserDetails getInnerUserDetails(HttpServletRequest request) { if (ObjectUtil.isNull(request)) { request = getRequest(); } @@ -70,7 +70,7 @@ public static SysUserDetailsDto getInnerUserDetails(HttpServletRequest request) // feign 拦截器填充时做了转义处理 String escapedUserDetailsJson = ServletUtil.getHeader(request, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); if (ObjectUtil.isNotEmpty(escapedUserDetailsJson)) { - return JacksonUtil.toBean(EscapeUtil.unescape(escapedUserDetailsJson), SysUserDetailsDto.class); + return JacksonUtil.toBean(EscapeUtil.unescape(escapedUserDetailsJson), SysUserDetails.class); } return null; } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java index 13830d91..ec480a94 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java @@ -2,9 +2,9 @@ import cn.hutool.core.lang.UUID; import cn.hutool.core.util.ObjectUtil; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.InitializingBean; import org.springframework.security.core.Authentication; @@ -79,21 +79,21 @@ public static boolean isAuthenticated(Authentication authentication) { if (ObjectUtil.isNull(authentication)) { authentication = SecurityContextHolder.getContext().getAuthentication(); } - return authentication != null && authentication.getPrincipal() instanceof SysUserDetailsDto; + return authentication != null && authentication.getPrincipal() instanceof SysUserDetails; } /** - * SpringSecurity 相关,取出 UserDetails SysUserDetailsDto + * SpringSecurity 相关,取出 UserDetails SysUserDetails * * @param authentication Security认证信息 - * @return SysUserDetailsDto + * @return SysUserDetails */ - public static SysUserDetailsDto getUserDetails(Authentication authentication) { + public static SysUserDetails getUserDetails(Authentication authentication) { if (ObjectUtil.isNull(authentication)) { authentication = SecurityContextHolder.getContext().getAuthentication(); } - if (authentication != null && authentication.getPrincipal() instanceof SysUserDetailsDto) { - return (SysUserDetailsDto) authentication.getPrincipal(); + if (authentication != null && authentication.getPrincipal() instanceof SysUserDetails) { + return (SysUserDetails) authentication.getPrincipal(); } return null; } @@ -102,9 +102,9 @@ public static SysUserDetailsDto getUserDetails(Authentication authentication) { * SpringSecurity 相关,取出用户名 */ public static String getUsername() { - SysUserDetailsDto userDetails = getUserDetails(null); + SysUserDetails userDetails = getUserDetails(null); return Optional.ofNullable(userDetails) - .map(SysUserDetailsDto::getUsername) + .map(SysUserDetails::getUsername) .map(java.lang.String::valueOf) .orElse(null); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java index 4280ce07..80fa57b1 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java @@ -5,11 +5,11 @@ import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.api.annotation.ApiInner; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogInfoDto; import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; import com.github.cadecode.uniboot.framework.api.bean.vo.SysLogVo.SysLogPageVo; import com.github.cadecode.uniboot.framework.api.convert.SysLogConvert; import com.github.cadecode.uniboot.framework.api.request.SysLogRequest.SysLogPageRequest; +import com.github.cadecode.uniboot.framework.api.request.SysLogRequest.SysLogSaveRequest; import com.github.cadecode.uniboot.framework.svc.service.SysLogService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -70,8 +70,8 @@ public boolean delete(@RequestBody @NotEmpty List idList) { @ApiInner(onlyClient = true) @ApiOperation("添加") @PostMapping("save") - public boolean save(@RequestBody @NotEmpty List dtoList) { - List poList = SysLogConvert.INSTANCE.dtoToPo(dtoList); + public boolean save(@RequestBody @NotEmpty List requestList) { + List poList = SysLogConvert.INSTANCE.requestToPo(requestList); return logService.saveBatch(poList); } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java index 8f594cc5..8fb177b8 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java @@ -4,13 +4,13 @@ import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserInfoVo; import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; import com.github.cadecode.uniboot.framework.api.convert.SysUserConvert; import com.github.cadecode.uniboot.framework.api.request.SysUserRequest; +import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import com.github.cadecode.uniboot.framework.svc.service.SysMenuService; import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; @@ -59,7 +59,7 @@ public class SysUserController { @ApiOperation("获取用户信息") @PostMapping("get_info") public SysUserInfoVo getInfo() { - SysUserDetailsDto userDetails = SecurityUtil.getUserDetails(null); + SysUserDetails userDetails = SecurityUtil.getUserDetails(null); List sysMenuTreeVos = sysMenuService.listTreeVoByRoles(userDetails.getRoles()); return SysUserInfoVo.builder().menuList(sysMenuTreeVos).build(); } @@ -67,7 +67,7 @@ public SysUserInfoVo getInfo() { @ApiOperation("修改用户信息(用户中心)") @PostMapping("modify_info") public boolean modifyInfo(@RequestBody @Valid SysUserRequest.SysUserModifyInfoRequest request) { - SysUserDetailsDto userDetails = SecurityUtil.getUserDetails(null); + SysUserDetails userDetails = SecurityUtil.getUserDetails(null); SysUser po = SysUserConvert.INSTANCE.requestToPo(request); po.setId(userDetails.getId()); return sysUserService.updateById(po); @@ -76,7 +76,7 @@ public boolean modifyInfo(@RequestBody @Valid SysUserRequest.SysUserModifyInfoRe @ApiOperation("修改用户密码(用户中心)") @PostMapping("modify_pass") public boolean modifyPass(@RequestBody @Valid SysUserRequest.SysUserModifyPassRequest request) { - SysUserDetailsDto userDetails = SecurityUtil.getUserDetails(null); + SysUserDetails userDetails = SecurityUtil.getUserDetails(null); SysUser sysUser = sysUserService.lambdaQuery().select(SysUser::getPassword) .eq(SysUser::getId, userDetails.getId()).one(); if (ObjectUtil.notEqual(request.getNewPass(), request.getConfirmedPass())) { diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java index 7529f002..ec1bbeb1 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java @@ -3,10 +3,9 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.core.util.TokenUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; +import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import org.springframework.security.core.Authentication; @@ -25,15 +24,15 @@ public class JwtLoginSuccessHandleService extends LoginSuccessHandleService { @Override - public ApiResult getResult(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { + public ApiResult getResult(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { // 从认证信息中获取用户对象 - SysUserDto.SysUserDetailsDto sysUserDetailsDto = (SysUserDto.SysUserDetailsDto) authentication.getPrincipal(); + SysUserDetails sysUserDetails = (SysUserDetails) authentication.getPrincipal(); // 生成 jwt token - String jwtToken = TokenUtil.generateToken(sysUserDetailsDto.getId(), sysUserDetailsDto.getUsername(), sysUserDetailsDto.getRoles(), + String jwtToken = TokenUtil.generateToken(sysUserDetails.getId(), sysUserDetails.getUsername(), sysUserDetails.getRoles(), SecurityUtil.getExpiration(), SecurityUtil.getSecret()); // token 放在请求头 response.addHeader(SecurityConst.HEAD_TOKEN, jwtToken); - return ApiResult.ok(sysUserDetailsDto).path(FrameSecurityConfig.LOGOUT_URL); + return ApiResult.ok(sysUserDetails).path(FrameSecurityConfig.LOGOUT_URL); } @Override diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandleService.java index 3798c5e7..3a6b390e 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandleService.java @@ -2,7 +2,7 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyService; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; +import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; import org.springframework.security.core.Authentication; import javax.servlet.http.HttpServletRequest; @@ -16,6 +16,6 @@ */ public abstract class LoginSuccessHandleService implements StrategyService { - public abstract ApiResult getResult(HttpServletRequest request, HttpServletResponse response, Authentication authentication); + public abstract ApiResult getResult(HttpServletRequest request, HttpServletResponse response, Authentication authentication); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java index 4be2833d..25754c55 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java @@ -7,10 +7,9 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyExecutor; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.svc.service.SysUserService; import lombok.RequiredArgsConstructor; import org.springframework.security.core.Authentication; @@ -40,22 +39,22 @@ public class LoginSuccessHandler implements AuthenticationSuccessHandler { /** * 更新登录信息 * - * @param sysUserDetailsDto 系统用户 DTO + * @param sysUserDetails 系统用户 DTO */ - public void updateLoginInfo(SysUserDto.SysUserDetailsDto sysUserDetailsDto) { - sysUserDetailsDto.setLoginIp(NetUtil.getLocalhost().getHostAddress()); - sysUserDetailsDto.setLoginDate(new Date()); + public void updateLoginInfo(SysUserDetails sysUserDetails) { + sysUserDetails.setLoginIp(NetUtil.getLocalhost().getHostAddress()); + sysUserDetails.setLoginDate(new Date()); // 同步到用户表 sysUserService.lambdaUpdate() - .eq(SysUser::getId, sysUserDetailsDto.getId()) - .set(SysUser::getLoginIp, sysUserDetailsDto.getLoginIp()) - .set(SysUser::getLoginDate, sysUserDetailsDto.getLoginDate()) + .eq(SysUser::getId, sysUserDetails.getId()) + .set(SysUser::getLoginIp, sysUserDetails.getLoginIp()) + .set(SysUser::getLoginDate, sysUserDetails.getLoginDate()) .update(); } @Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { - ApiResult result = strategyExecutor.execute(LoginSuccessHandleService.class, securityProperties::getAuthModel, s -> { + ApiResult result = strategyExecutor.execute(LoginSuccessHandleService.class, securityProperties::getAuthModel, s -> { return s.getResult(request, response, authentication); }); updateLoginInfo(result.getData()); diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java index d6a1c522..07f717b3 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java @@ -4,11 +4,10 @@ import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; import com.github.cadecode.uniboot.common.plugin.cache.util.RedisUtil; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserDetailsDto; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; +import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import org.springframework.security.core.Authentication; @@ -28,17 +27,17 @@ public class RedisLoginSuccessHandleService extends LoginSuccessHandleService { @Override - public ApiResult getResult(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { + public ApiResult getResult(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { // 从认证信息中获取用户对象 - SysUserDetailsDto sysUserDetailsDto = (SysUserDetailsDto) authentication.getPrincipal(); + SysUserDetails sysUserDetails = (SysUserDetails) authentication.getPrincipal(); // 生成 uuid token String uuidToken = SecurityUtil.generateUUID(); // token 放在请求头 response.addHeader(SecurityConst.HEAD_TOKEN, uuidToken); // 生成存放登录信息的 redis key String loginUserKey = KeyGeneUtil.key(KeyPrefix.LOGIN_USER, uuidToken); - RedisUtil.set(loginUserKey, sysUserDetailsDto, SecurityUtil.getExpiration(), TimeUnit.SECONDS); - return ApiResult.ok(sysUserDetailsDto).path(FrameSecurityConfig.LOGOUT_URL); + RedisUtil.set(loginUserKey, sysUserDetails, SecurityUtil.getExpiration(), TimeUnit.SECONDS); + return ApiResult.ok(sysUserDetails).path(FrameSecurityConfig.LOGOUT_URL); } @Override diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java index 01adf9ea..f3d06df2 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java @@ -44,7 +44,7 @@ public UserDetails loadUserByUsername(String username) { if (!userRolesVo.getEnableFlag()) { throw ApiException.of("账号已被关闭"); } - return SysUserConvert.INSTANCE.voToDetailsDto(userRolesVo); + return SysUserConvert.INSTANCE.voToSysUserDetails(userRolesVo); } @Override From 7faf8f0f6aacf00aa95fb75b96d9cc530f083cb2 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 11 Aug 2023 19:17:59 +0800 Subject: [PATCH 043/244] =?UTF-8?q?feat:=20=E6=8A=BD=E5=8F=96=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E9=80=9A=E7=94=A8=E9=85=8D=E7=BD=AE=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E5=88=B0=20base=20=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/example_api/pom.xml | 5 -- example/example_svc/pom.xml | 4 ++ .../svc/controller/DLCacheController.java | 2 +- .../svc/controller/DynamicDsController.java | 2 +- .../svc/controller/DynamicTpController.java | 2 +- .../svc/controller/RpcExampleController.java | 2 +- .../svc/controller/SpringRetryController.java | 2 +- .../svc/controller/TtlExecutorController.java | 2 +- framework/framework_api/pom.xml | 21 -------- framework/framework_base/pom.xml | 48 +++++++++++++++++++ .../base}/advisor/ApiExceptionAdvisor.java | 2 +- .../base}/advisor/ApiResultAdvisor.java | 6 +-- .../base}/advisor/FrameExceptionAdvisor.java | 2 +- .../framework/base}/annotation/ApiFormat.java | 2 +- .../framework/base}/annotation/ApiInner.java | 2 +- .../base}/aspect/ApiInnerAspect.java | 10 ++-- .../framework/base}/config/FeignConfig.java | 12 ++--- .../framework/base}/config/JacksonConfig.java | 2 +- .../framework/base}/config/PluginConfig.java | 2 +- .../framework/base}/config/RetryConfig.java | 4 +- .../base}/config/SecurityConfig.java | 12 ++--- .../base}/config/ThreadPoolConfig.java | 2 +- .../framework/base}/config/UniBootConfig.java | 2 +- .../framework/base}/config/WebMvcConfig.java | 2 +- .../base}/exception/RetryableException.java | 2 +- .../base}/feign/FeignClientDecorator.java | 4 +- .../base}/feign/FeignErrorDecoder.java | 2 +- .../framework/base}/plugin/ApiLogHandler.java | 4 +- .../base}/plugin/MybatisFillHandler.java | 4 +- .../filter/JwtTokenAuthFilterService.java | 6 +-- .../filter/RedisTokenAuthFilterService.java | 6 +-- .../security/filter/TokenAuthFilter.java | 4 +- .../filter/TokenAuthFilterService.java | 6 +-- .../handler/NoAuthenticationHandler.java | 2 +- .../security/handler/NoAuthorityHandler.java | 2 +- .../base}/security/model/SysUserDetails.java | 2 +- .../security/voter/DataBaseRoleVoter.java | 6 +-- .../framework/base}/util/RequestUtil.java | 4 +- .../framework/base}/util/SecurityUtil.java | 6 +-- framework/framework_svc/pom.xml | 3 +- .../framework/svc}/bean/po/SysApi.java | 2 +- .../framework/svc}/bean/po/SysDict.java | 2 +- .../framework/svc}/bean/po/SysLog.java | 2 +- .../framework/svc}/bean/po/SysMenu.java | 2 +- .../framework/svc}/bean/po/SysRole.java | 2 +- .../framework/svc}/bean/po/SysUser.java | 2 +- .../framework/svc}/bean/vo/SysApiVo.java | 2 +- .../framework/svc}/bean/vo/SysDictVo.java | 2 +- .../framework/svc}/bean/vo/SysLogVo.java | 2 +- .../framework/svc}/bean/vo/SysMenuVo.java | 2 +- .../framework/svc}/bean/vo/SysRoleVo.java | 2 +- .../framework/svc}/bean/vo/SysUserVo.java | 4 +- .../svc/config/FrameSecurityConfig.java | 10 ++-- .../svc/controller/AuthController.java | 2 +- .../svc/controller/CommonController.java | 2 +- .../svc/controller/ExampleController.java | 2 +- .../svc/controller/SysApiController.java | 14 +++--- .../svc/controller/SysDictController.java | 14 +++--- .../svc/controller/SysLogController.java | 14 +++--- .../svc/controller/SysMenuController.java | 10 ++-- .../svc/controller/SysRoleController.java | 14 +++--- .../svc/controller/SysUserController.java | 18 +++---- .../framework/svc}/convert/SysApiConvert.java | 8 ++-- .../svc}/convert/SysDictConvert.java | 16 +++---- .../framework/svc}/convert/SysLogConvert.java | 8 ++-- .../svc}/convert/SysMenuConvert.java | 10 ++-- .../svc}/convert/SysRoleConvert.java | 10 ++-- .../svc}/convert/SysUserConvert.java | 14 +++--- .../framework/svc/mapper/SysApiMapper.java | 6 +-- .../framework/svc/mapper/SysDictMapper.java | 2 +- .../framework/svc/mapper/SysLogMapper.java | 2 +- .../framework/svc/mapper/SysMenuMapper.java | 6 +-- .../framework/svc/mapper/SysRoleMapper.java | 8 ++-- .../framework/svc/mapper/SysUserMapper.java | 6 +-- .../framework/svc}/request/SysApiRequest.java | 2 +- .../svc}/request/SysDictRequest.java | 2 +- .../framework/svc}/request/SysLogRequest.java | 2 +- .../svc}/request/SysMenuRequest.java | 2 +- .../svc}/request/SysRoleRequest.java | 2 +- .../svc}/request/SysUserRequest.java | 2 +- .../JwtLoginSuccessHandleService.java | 4 +- .../security/LoginSuccessHandleService.java | 2 +- .../svc/security/LoginSuccessHandler.java | 6 +-- .../RedisLoginSuccessHandleService.java | 4 +- .../svc/security/SignOutSuccessHandler.java | 2 +- .../framework/svc/service/SysApiService.java | 6 +-- .../framework/svc/service/SysDictService.java | 2 +- .../framework/svc/service/SysLogService.java | 2 +- .../framework/svc/service/SysMenuService.java | 8 ++-- .../framework/svc/service/SysRoleService.java | 8 ++-- .../framework/svc/service/SysUserService.java | 6 +-- .../svc/serviceimpl/SysApiServiceImpl.java | 6 +-- .../svc/serviceimpl/SysDictServiceImpl.java | 2 +- .../svc/serviceimpl/SysLogServiceImpl.java | 2 +- .../svc/serviceimpl/SysMenuServiceImpl.java | 10 ++-- .../svc/serviceimpl/SysRoleServiceImpl.java | 8 ++-- .../svc/serviceimpl/SysUserServiceImpl.java | 8 ++-- .../main/resources/mapper/SysApiMapper.xml | 2 +- .../main/resources/mapper/SysMenuMapper.xml | 4 +- .../main/resources/mapper/SysRoleMapper.xml | 8 ++-- .../main/resources/mapper/SysUserMapper.xml | 2 +- framework/pom.xml | 1 + gateway/pom.xml | 18 +++++++ .../gateway/filter/RequestHeaderFilter.java | 9 ++-- .../gateway/filter/TraceInfoFilter.java | 9 ++-- pom.xml | 5 ++ 106 files changed, 319 insertions(+), 274 deletions(-) create mode 100644 framework/framework_base/pom.xml rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/advisor/ApiExceptionAdvisor.java (95%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/advisor/ApiResultAdvisor.java (94%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/advisor/FrameExceptionAdvisor.java (98%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/annotation/ApiFormat.java (81%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/annotation/ApiInner.java (92%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/aspect/ApiInnerAspect.java (87%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/config/FeignConfig.java (91%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/config/JacksonConfig.java (93%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/config/PluginConfig.java (87%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/config/RetryConfig.java (93%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/config/SecurityConfig.java (92%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/config/ThreadPoolConfig.java (99%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/config/UniBootConfig.java (93%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/config/WebMvcConfig.java (91%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/exception/RetryableException.java (95%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/feign/FeignClientDecorator.java (91%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/feign/FeignErrorDecoder.java (97%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/plugin/ApiLogHandler.java (96%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/plugin/MybatisFillHandler.java (80%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/security/filter/JwtTokenAuthFilterService.java (93%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/security/filter/RedisTokenAuthFilterService.java (91%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/security/filter/TokenAuthFilter.java (87%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/security/filter/TokenAuthFilterService.java (93%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/security/handler/NoAuthenticationHandler.java (94%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/security/handler/NoAuthorityHandler.java (94%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/security/model/SysUserDetails.java (95%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/security/voter/DataBaseRoleVoter.java (93%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/util/RequestUtil.java (95%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base}/util/SecurityUtil.java (93%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/bean/po/SysApi.java (93%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/bean/po/SysDict.java (95%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/bean/po/SysLog.java (96%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/bean/po/SysMenu.java (96%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/bean/po/SysRole.java (94%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/bean/po/SysUser.java (95%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/bean/vo/SysApiVo.java (92%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/bean/vo/SysDictVo.java (94%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/bean/vo/SysLogVo.java (94%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/bean/vo/SysMenuVo.java (94%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/bean/vo/SysRoleVo.java (93%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/bean/vo/SysUserVo.java (89%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/convert/SysApiConvert.java (76%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/convert/SysDictConvert.java (70%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/convert/SysLogConvert.java (64%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/convert/SysMenuConvert.java (76%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/convert/SysRoleConvert.java (75%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/convert/SysUserConvert.java (78%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/request/SysApiRequest.java (92%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/request/SysDictRequest.java (95%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/request/SysLogRequest.java (95%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/request/SysMenuRequest.java (96%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/request/SysRoleRequest.java (94%) rename framework/{framework_api/src/main/java/com/github/cadecode/uniboot/framework/api => framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc}/request/SysUserRequest.java (97%) diff --git a/example/example_api/pom.xml b/example/example_api/pom.xml index 24815132..40d76e8d 100644 --- a/example/example_api/pom.xml +++ b/example/example_api/pom.xml @@ -27,10 +27,5 @@ org.springframework.cloud spring-cloud-starter-loadbalancer - - - com.github.cadecode - uni-boot-framework-api - diff --git a/example/example_svc/pom.xml b/example/example_svc/pom.xml index 85970d24..ae89d0af 100644 --- a/example/example_svc/pom.xml +++ b/example/example_svc/pom.xml @@ -48,6 +48,10 @@ com.github.cadecode uni-boot-common-plugin-actuator + + com.github.cadecode + uni-boot-framework-base + com.github.cadecode uni-boot-example-api diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DLCacheController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DLCacheController.java index 07e21a0e..705acc9f 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DLCacheController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DLCacheController.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.example.svc.controller; import com.github.cadecode.uniboot.common.plugin.cache.consts.CacheConst; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicDsController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicDsController.java index 68966dcd..a484afa9 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicDsController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicDsController.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.example.svc.controller; import com.baomidou.dynamic.datasource.annotation.DS; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicTpController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicTpController.java index 543a50ec..c617e8c3 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicTpController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/DynamicTpController.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.example.svc.controller; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java index af7c4d84..ebaf7feb 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/RpcExampleController.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.example.svc.controller; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.api.feignclient.ExampleClient; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/SpringRetryController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/SpringRetryController.java index f84c2853..e4115c16 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/SpringRetryController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/SpringRetryController.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.example.svc.controller; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/TtlExecutorController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/TtlExecutorController.java index c93e93af..5ce351c3 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/TtlExecutorController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/TtlExecutorController.java @@ -2,7 +2,7 @@ import com.alibaba.ttl.TransmittableThreadLocal; import com.alibaba.ttl.threadpool.TtlExecutors; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/framework/framework_api/pom.xml b/framework/framework_api/pom.xml index 973bf1bf..23b7f71f 100644 --- a/framework/framework_api/pom.xml +++ b/framework/framework_api/pom.xml @@ -26,39 +26,18 @@ org.springframework.cloud spring-cloud-starter-loadbalancer - - - org.springframework.boot - spring-boot-starter-security - com.github.cadecode uni-boot-common-core - - com.github.cadecode - uni-boot-common-plugin-swagger - com.github.cadecode uni-boot-common-plugin-log - - com.github.cadecode - uni-boot-common-plugin-mybatis - - - com.github.cadecode - uni-boot-common-plugin-datasource - com.github.cadecode uni-boot-common-plugin-cache - - com.github.cadecode - uni-boot-common-plugin-concurrent - diff --git a/framework/framework_base/pom.xml b/framework/framework_base/pom.xml new file mode 100644 index 00000000..f2f18f91 --- /dev/null +++ b/framework/framework_base/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + com.github.cadecode + uni-boot-framework + 2023.1.0 + + + uni-boot-framework-base + + + + net.dreamlu + mica-auto + provided + + + + org.springframework.boot + spring-boot-starter-security + + + + com.github.cadecode + uni-boot-framework-api + + + com.github.cadecode + uni-boot-common-plugin-mybatis + + + com.github.cadecode + uni-boot-common-plugin-datasource + + + com.github.cadecode + uni-boot-common-plugin-concurrent + + + com.github.cadecode + uni-boot-common-plugin-swagger + + + + diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiExceptionAdvisor.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiExceptionAdvisor.java similarity index 95% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiExceptionAdvisor.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiExceptionAdvisor.java index e8b2592e..9d68b3b5 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiExceptionAdvisor.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiExceptionAdvisor.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.advisor; +package com.github.cadecode.uniboot.framework.base.advisor; import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; import com.github.cadecode.uniboot.common.core.exception.ApiException; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiResultAdvisor.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiResultAdvisor.java similarity index 94% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiResultAdvisor.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiResultAdvisor.java index 29fd0c3a..bdb96927 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/ApiResultAdvisor.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiResultAdvisor.java @@ -1,12 +1,12 @@ -package com.github.cadecode.uniboot.framework.api.advisor; +package com.github.cadecode.uniboot.framework.base.advisor; import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.api.enums.FrameErrorEnum; -import com.github.cadecode.uniboot.framework.api.util.RequestUtil; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.util.RequestUtil; import org.springframework.core.MethodParameter; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/FrameExceptionAdvisor.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/FrameExceptionAdvisor.java similarity index 98% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/FrameExceptionAdvisor.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/FrameExceptionAdvisor.java index bd637f2d..49063e64 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/advisor/FrameExceptionAdvisor.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/FrameExceptionAdvisor.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.advisor; +package com.github.cadecode.uniboot.framework.base.advisor; import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/annotation/ApiFormat.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/annotation/ApiFormat.java similarity index 81% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/annotation/ApiFormat.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/annotation/ApiFormat.java index a10d1356..fb95a470 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/annotation/ApiFormat.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/annotation/ApiFormat.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.annotation; +package com.github.cadecode.uniboot.framework.base.annotation; import java.lang.annotation.*; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/annotation/ApiInner.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/annotation/ApiInner.java similarity index 92% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/annotation/ApiInner.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/annotation/ApiInner.java index 105f1f05..c58f1e52 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/annotation/ApiInner.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/annotation/ApiInner.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.annotation; +package com.github.cadecode.uniboot.framework.base.annotation; import java.lang.annotation.*; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/aspect/ApiInnerAspect.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/aspect/ApiInnerAspect.java similarity index 87% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/aspect/ApiInnerAspect.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/aspect/ApiInnerAspect.java index 22b8336f..e8d06385 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/aspect/ApiInnerAspect.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/aspect/ApiInnerAspect.java @@ -1,14 +1,14 @@ -package com.github.cadecode.uniboot.framework.api.aspect; +package com.github.cadecode.uniboot.framework.base.aspect; import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.extra.servlet.ServletUtil; import com.github.cadecode.uniboot.common.core.exception.ApiException; -import com.github.cadecode.uniboot.framework.api.annotation.ApiInner; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; -import com.github.cadecode.uniboot.framework.api.util.RequestUtil; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.base.annotation.ApiInner; +import com.github.cadecode.uniboot.framework.base.util.RequestUtil; +import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; @@ -28,7 +28,7 @@ @Component public class ApiInnerAspect { - @Pointcut("@annotation(com.github.cadecode.uniboot.framework.api.annotation.ApiInner)") + @Pointcut("@annotation(com.github.cadecode.uniboot.framework.base.annotation.ApiInner)") public void pointCut() { } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java similarity index 91% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java index 49975582..1b744588 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/FeignConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.config; +package com.github.cadecode.uniboot.framework.base.config; import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.EscapeUtil; @@ -8,11 +8,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; -import com.github.cadecode.uniboot.framework.api.feign.FeignClientDecorator; -import com.github.cadecode.uniboot.framework.api.feign.FeignErrorDecoder; -import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; -import com.github.cadecode.uniboot.framework.api.util.RequestUtil; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.base.feign.FeignClientDecorator; +import com.github.cadecode.uniboot.framework.base.feign.FeignErrorDecoder; +import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.base.util.RequestUtil; +import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import feign.Client; import feign.Client.Default; import feign.RequestInterceptor; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/JacksonConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/JacksonConfig.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/JacksonConfig.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/JacksonConfig.java index 2056c448..e0f03a06 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/JacksonConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/JacksonConfig.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.config; +package com.github.cadecode.uniboot.framework.base.config; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/PluginConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/PluginConfig.java similarity index 87% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/PluginConfig.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/PluginConfig.java index 6dfdb5a1..30eb8bc6 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/PluginConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/PluginConfig.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.config; +package com.github.cadecode.uniboot.framework.base.config; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyService; import org.springframework.context.annotation.Configuration; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/RetryConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/RetryConfig.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/RetryConfig.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/RetryConfig.java index ad3b9553..260e3267 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/RetryConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/RetryConfig.java @@ -1,6 +1,6 @@ -package com.github.cadecode.uniboot.framework.api.config; +package com.github.cadecode.uniboot.framework.base.config; -import com.github.cadecode.uniboot.framework.api.exception.RetryableException; +import com.github.cadecode.uniboot.framework.base.exception.RetryableException; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java similarity index 92% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java index f4e0cf96..97865f93 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/SecurityConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java @@ -1,17 +1,17 @@ -package com.github.cadecode.uniboot.framework.api.config; +package com.github.cadecode.uniboot.framework.base.config; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.extra.servlet.ServletUtil; -import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; -import com.github.cadecode.uniboot.framework.api.security.filter.TokenAuthFilter; -import com.github.cadecode.uniboot.framework.api.security.handler.NoAuthenticationHandler; -import com.github.cadecode.uniboot.framework.api.security.handler.NoAuthorityHandler; -import com.github.cadecode.uniboot.framework.api.security.voter.DataBaseRoleVoter; +import com.github.cadecode.uniboot.framework.base.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.base.security.filter.TokenAuthFilter; +import com.github.cadecode.uniboot.framework.base.security.handler.NoAuthenticationHandler; +import com.github.cadecode.uniboot.framework.base.security.handler.NoAuthorityHandler; +import com.github.cadecode.uniboot.framework.base.security.voter.DataBaseRoleVoter; import lombok.Data; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/ThreadPoolConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/ThreadPoolConfig.java similarity index 99% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/ThreadPoolConfig.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/ThreadPoolConfig.java index 76a62c04..182f1e57 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/ThreadPoolConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/ThreadPoolConfig.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.config; +package com.github.cadecode.uniboot.framework.base.config; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/UniBootConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/UniBootConfig.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/UniBootConfig.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/UniBootConfig.java index 60978c78..d06c710c 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/UniBootConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/UniBootConfig.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.config; +package com.github.cadecode.uniboot.framework.base.config; import lombok.Data; import lombok.RequiredArgsConstructor; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/WebMvcConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/WebMvcConfig.java similarity index 91% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/WebMvcConfig.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/WebMvcConfig.java index 1d521733..eb6c66d0 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/config/WebMvcConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/WebMvcConfig.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.config; +package com.github.cadecode.uniboot.framework.base.config; import com.github.cadecode.uniboot.common.core.web.convertor.ParamEnumConvertorFactory; import org.springframework.context.annotation.Configuration; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/exception/RetryableException.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/exception/RetryableException.java similarity index 95% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/exception/RetryableException.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/exception/RetryableException.java index f1a97dbc..d34096bc 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/exception/RetryableException.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/exception/RetryableException.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.exception; +package com.github.cadecode.uniboot.framework.base.exception; import lombok.Getter; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignClientDecorator.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignClientDecorator.java similarity index 91% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignClientDecorator.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignClientDecorator.java index 93436fa4..7fe5625e 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignClientDecorator.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignClientDecorator.java @@ -1,8 +1,8 @@ -package com.github.cadecode.uniboot.framework.api.feign; +package com.github.cadecode.uniboot.framework.base.feign; import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; -import com.github.cadecode.uniboot.framework.api.util.RequestUtil; +import com.github.cadecode.uniboot.framework.base.util.RequestUtil; import feign.Client; import feign.Request; import feign.Request.Options; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignErrorDecoder.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignErrorDecoder.java similarity index 97% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignErrorDecoder.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignErrorDecoder.java index cad8dd99..9d69d7b8 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feign/FeignErrorDecoder.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignErrorDecoder.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.feign; +package com.github.cadecode.uniboot.framework.base.feign; import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.ObjectUtil; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java similarity index 96% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java index b25887a8..3220bde3 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/ApiLogHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.plugin; +package com.github.cadecode.uniboot.framework.base.plugin; import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.util.ObjectUtil; @@ -11,7 +11,7 @@ import com.github.cadecode.uniboot.common.plugin.log.handler.AbstractApiLogHandler; import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogSaveDto; import com.github.cadecode.uniboot.framework.api.feignclient.SysLogClient; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/MybatisFillHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/MybatisFillHandler.java similarity index 80% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/MybatisFillHandler.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/MybatisFillHandler.java index 6139bff9..a83c9831 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/plugin/MybatisFillHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/MybatisFillHandler.java @@ -1,7 +1,7 @@ -package com.github.cadecode.uniboot.framework.api.plugin; +package com.github.cadecode.uniboot.framework.base.plugin; import com.github.cadecode.uniboot.common.plugin.mybatis.handler.AbstractObjectFillHandler; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import org.apache.ibatis.reflection.MetaObject; import org.springframework.stereotype.Component; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/JwtTokenAuthFilterService.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/JwtTokenAuthFilterService.java index c154ce1b..f489e3a5 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/JwtTokenAuthFilterService.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/JwtTokenAuthFilterService.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.security.filter; +package com.github.cadecode.uniboot.framework.base.security.filter; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; @@ -7,8 +7,8 @@ import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; -import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/RedisTokenAuthFilterService.java similarity index 91% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/RedisTokenAuthFilterService.java index dd520716..52de32e7 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/RedisTokenAuthFilterService.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/RedisTokenAuthFilterService.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.security.filter; +package com.github.cadecode.uniboot.framework.base.security.filter; import cn.hutool.core.util.StrUtil; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; @@ -7,8 +7,8 @@ import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; -import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilter.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilter.java similarity index 87% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilter.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilter.java index 88303292..b09cb953 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilter.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilter.java @@ -1,7 +1,7 @@ -package com.github.cadecode.uniboot.framework.api.security.filter; +package com.github.cadecode.uniboot.framework.base.security.filter; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyExecutor; -import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.base.config.SecurityConfig.SecurityProperties; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilterService.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilterService.java index 21d79406..bca65f6e 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/filter/TokenAuthFilterService.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilterService.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.security.filter; +package com.github.cadecode.uniboot.framework.base.security.filter; import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.ObjectUtil; @@ -8,8 +8,8 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyService; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; -import com.github.cadecode.uniboot.framework.api.util.RequestUtil; +import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.base.util.RequestUtil; import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/NoAuthenticationHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/handler/NoAuthenticationHandler.java similarity index 94% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/NoAuthenticationHandler.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/handler/NoAuthenticationHandler.java index 9b6e9422..9ab65534 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/NoAuthenticationHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/handler/NoAuthenticationHandler.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.security.handler; +package com.github.cadecode.uniboot.framework.base.security.handler; import cn.hutool.core.util.CharsetUtil; import cn.hutool.extra.servlet.ServletUtil; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/NoAuthorityHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/handler/NoAuthorityHandler.java similarity index 94% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/NoAuthorityHandler.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/handler/NoAuthorityHandler.java index 7f0bedae..e5a2c0c7 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/handler/NoAuthorityHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/handler/NoAuthorityHandler.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.security.handler; +package com.github.cadecode.uniboot.framework.base.security.handler; import cn.hutool.core.util.CharsetUtil; import cn.hutool.extra.servlet.ServletUtil; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/model/SysUserDetails.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/model/SysUserDetails.java similarity index 95% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/model/SysUserDetails.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/model/SysUserDetails.java index 84d7e661..01ba1aa7 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/model/SysUserDetails.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/model/SysUserDetails.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.security.model; +package com.github.cadecode.uniboot.framework.base.security.model; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/voter/DataBaseRoleVoter.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/voter/DataBaseRoleVoter.java index 463ae1e8..c80b04c7 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/security/voter/DataBaseRoleVoter.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/voter/DataBaseRoleVoter.java @@ -1,10 +1,10 @@ -package com.github.cadecode.uniboot.framework.api.security.voter; +package com.github.cadecode.uniboot.framework.base.security.voter; import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.framework.api.feignclient.SysApiClient; import com.github.cadecode.uniboot.framework.api.response.SysApiResponse.SysApiRolesResponse; -import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import lombok.RequiredArgsConstructor; import org.springframework.security.access.ConfigAttribute; import org.springframework.security.access.vote.RoleVoter; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/RequestUtil.java similarity index 95% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/RequestUtil.java index 2fc2a652..9b10261c 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/RequestUtil.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/RequestUtil.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.util; +package com.github.cadecode.uniboot.framework.base.util; import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.EscapeUtil; @@ -6,7 +6,7 @@ import cn.hutool.extra.servlet.ServletUtil; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; -import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java index ec480a94..e49a2c22 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/util/SecurityUtil.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java @@ -1,10 +1,10 @@ -package com.github.cadecode.uniboot.framework.api.util; +package com.github.cadecode.uniboot.framework.base.util; import cn.hutool.core.lang.UUID; import cn.hutool.core.util.ObjectUtil; -import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; -import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.base.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.InitializingBean; import org.springframework.security.core.Authentication; diff --git a/framework/framework_svc/pom.xml b/framework/framework_svc/pom.xml index 18173992..2160ff50 100644 --- a/framework/framework_svc/pom.xml +++ b/framework/framework_svc/pom.xml @@ -42,7 +42,6 @@ com.github.ulisesbocchio jasypt-spring-boot-starter - cn.hutool @@ -51,7 +50,7 @@ com.github.cadecode - uni-boot-framework-api + uni-boot-framework-base com.github.cadecode diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysApi.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysApi.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysApi.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysApi.java index df1dd4e0..d84a6d8b 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysApi.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysApi.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.bean.po; +package com.github.cadecode.uniboot.framework.svc.bean.po; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.IdType; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysDict.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysDict.java similarity index 95% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysDict.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysDict.java index ac267b0c..181c5113 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysDict.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysDict.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.bean.po; +package com.github.cadecode.uniboot.framework.svc.bean.po; import com.baomidou.mybatisplus.annotation.*; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysLog.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java similarity index 96% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysLog.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java index f259f5d8..765ce661 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysLog.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.bean.po; +package com.github.cadecode.uniboot.framework.svc.bean.po; import com.baomidou.mybatisplus.annotation.*; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysMenu.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysMenu.java similarity index 96% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysMenu.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysMenu.java index fe343afb..acfc57ec 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysMenu.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysMenu.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.bean.po; +package com.github.cadecode.uniboot.framework.svc.bean.po; import com.baomidou.mybatisplus.annotation.*; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysRole.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysRole.java similarity index 94% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysRole.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysRole.java index 9b6da23f..1803ebda 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysRole.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysRole.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.bean.po; +package com.github.cadecode.uniboot.framework.svc.bean.po; import com.baomidou.mybatisplus.annotation.FieldFill; import com.baomidou.mybatisplus.annotation.IdType; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysUser.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysUser.java similarity index 95% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysUser.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysUser.java index 8f7a9d47..8d852e9c 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/po/SysUser.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysUser.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.bean.po; +package com.github.cadecode.uniboot.framework.svc.bean.po; import com.baomidou.mybatisplus.annotation.*; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysApiVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysApiVo.java similarity index 92% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysApiVo.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysApiVo.java index 96e6b7a3..8619736a 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysApiVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysApiVo.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.bean.vo; +package com.github.cadecode.uniboot.framework.svc.bean.vo; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysDictVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysDictVo.java similarity index 94% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysDictVo.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysDictVo.java index 2c910c09..fdb383a3 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysDictVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysDictVo.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.bean.vo; +package com.github.cadecode.uniboot.framework.svc.bean.vo; import lombok.Data; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysLogVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java similarity index 94% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysLogVo.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java index f362652a..fa5fbe89 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysLogVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.bean.vo; +package com.github.cadecode.uniboot.framework.svc.bean.vo; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; import lombok.Data; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysMenuVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysMenuVo.java similarity index 94% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysMenuVo.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysMenuVo.java index 10050cdd..38d3183c 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysMenuVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysMenuVo.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.bean.vo; +package com.github.cadecode.uniboot.framework.svc.bean.vo; import lombok.Data; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysRoleVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysRoleVo.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysRoleVo.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysRoleVo.java index e867b9a0..7b68dbdd 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysRoleVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysRoleVo.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.bean.vo; +package com.github.cadecode.uniboot.framework.svc.bean.vo; import lombok.Data; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysUserVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysUserVo.java similarity index 89% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysUserVo.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysUserVo.java index 83152588..839ffc03 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/vo/SysUserVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysUserVo.java @@ -1,7 +1,7 @@ -package com.github.cadecode.uniboot.framework.api.bean.vo; +package com.github.cadecode.uniboot.framework.svc.bean.vo; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeVo; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java index 5385c764..adeae8b7 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java @@ -1,10 +1,10 @@ package com.github.cadecode.uniboot.framework.svc.config; -import com.github.cadecode.uniboot.framework.api.config.SecurityConfig; -import com.github.cadecode.uniboot.framework.api.security.filter.TokenAuthFilter; -import com.github.cadecode.uniboot.framework.api.security.handler.NoAuthenticationHandler; -import com.github.cadecode.uniboot.framework.api.security.handler.NoAuthorityHandler; -import com.github.cadecode.uniboot.framework.api.security.voter.DataBaseRoleVoter; +import com.github.cadecode.uniboot.framework.base.config.SecurityConfig; +import com.github.cadecode.uniboot.framework.base.security.filter.TokenAuthFilter; +import com.github.cadecode.uniboot.framework.base.security.handler.NoAuthenticationHandler; +import com.github.cadecode.uniboot.framework.base.security.handler.NoAuthorityHandler; +import com.github.cadecode.uniboot.framework.base.security.voter.DataBaseRoleVoter; import com.github.cadecode.uniboot.framework.svc.security.LoginFailureHandler; import com.github.cadecode.uniboot.framework.svc.security.LoginSuccessHandler; import com.github.cadecode.uniboot.framework.svc.security.SignOutSuccessHandler; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java index 866e79e6..60b0c491 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java @@ -3,7 +3,7 @@ import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/CommonController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/CommonController.java index 161d2f61..7859b1a2 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/CommonController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/CommonController.java @@ -4,8 +4,8 @@ import cn.hutool.extra.servlet.ServletUtil; import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.common.core.util.AssertUtil; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.api.enums.FrameErrorEnum; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.svc.util.FileUploadUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/ExampleController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/ExampleController.java index fcb20a67..4b6b8633 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/ExampleController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/ExampleController.java @@ -2,8 +2,8 @@ import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.api.enums.FrameErrorEnum; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java index 9bc125a7..845ed0a2 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java @@ -2,14 +2,14 @@ import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.api.annotation.ApiInner; -import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiSwaggerVo; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.api.convert.SysApiConvert; -import com.github.cadecode.uniboot.framework.api.request.SysApiRequest; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.annotation.ApiInner; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysApi; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiSwaggerVo; +import com.github.cadecode.uniboot.framework.svc.convert.SysApiConvert; +import com.github.cadecode.uniboot.framework.svc.request.SysApiRequest; import com.github.cadecode.uniboot.framework.svc.service.SysApiService; import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.pagehelper.PageInfo; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java index b871e76a..99eccb55 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java @@ -2,13 +2,13 @@ import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.api.bean.po.SysDict; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysDictVo.SysDictGetByTypeVo; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysDictVo.SysDictPageVo; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysDictVo.SysDictSuggestVo; -import com.github.cadecode.uniboot.framework.api.convert.SysDictConvert; -import com.github.cadecode.uniboot.framework.api.request.SysDictRequest; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysDict; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.SysDictGetByTypeVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.SysDictPageVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.SysDictSuggestVo; +import com.github.cadecode.uniboot.framework.svc.convert.SysDictConvert; +import com.github.cadecode.uniboot.framework.svc.request.SysDictRequest; import com.github.cadecode.uniboot.framework.svc.service.SysDictService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java index 80fa57b1..648a610e 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java @@ -3,13 +3,13 @@ import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.api.annotation.ApiInner; -import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysLogVo.SysLogPageVo; -import com.github.cadecode.uniboot.framework.api.convert.SysLogConvert; -import com.github.cadecode.uniboot.framework.api.request.SysLogRequest.SysLogPageRequest; -import com.github.cadecode.uniboot.framework.api.request.SysLogRequest.SysLogSaveRequest; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.annotation.ApiInner; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysLog; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogPageVo; +import com.github.cadecode.uniboot.framework.svc.convert.SysLogConvert; +import com.github.cadecode.uniboot.framework.svc.request.SysLogRequest.SysLogPageRequest; +import com.github.cadecode.uniboot.framework.svc.request.SysLogRequest.SysLogSaveRequest; import com.github.cadecode.uniboot.framework.svc.service.SysLogService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java index 360075f5..3c979004 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java @@ -1,11 +1,11 @@ package com.github.cadecode.uniboot.framework.svc.controller; import com.github.cadecode.uniboot.common.core.web.response.PageResult; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.api.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuRolesVo; -import com.github.cadecode.uniboot.framework.api.convert.SysMenuConvert; -import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysMenu; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesVo; +import com.github.cadecode.uniboot.framework.svc.convert.SysMenuConvert; +import com.github.cadecode.uniboot.framework.svc.request.SysMenuRequest; import com.github.cadecode.uniboot.framework.svc.service.SysMenuService; import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.pagehelper.PageInfo; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java index bb6a1fa3..d329c65a 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java @@ -1,14 +1,14 @@ package com.github.cadecode.uniboot.framework.svc.controller; import com.github.cadecode.uniboot.common.core.web.response.PageResult; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.api.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysRoleVo.SysRoleListVo; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysRoleVo.SysRoleUnionVo; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.api.convert.SysRoleConvert; -import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest; -import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleMappingRequest; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysRole; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleListVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionVo; +import com.github.cadecode.uniboot.framework.svc.convert.SysRoleConvert; +import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest; +import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleMappingRequest; import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java index 8fb177b8..d7061db0 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java @@ -3,15 +3,15 @@ import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.common.core.web.response.PageResult; -import com.github.cadecode.uniboot.framework.api.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserInfoVo; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; -import com.github.cadecode.uniboot.framework.api.convert.SysUserConvert; -import com.github.cadecode.uniboot.framework.api.request.SysUserRequest; -import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysUser; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserInfoVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesVo; +import com.github.cadecode.uniboot.framework.svc.convert.SysUserConvert; +import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest; import com.github.cadecode.uniboot.framework.svc.service.SysMenuService; import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.cadecode.uniboot.framework.svc.service.SysUserService; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysApiConvert.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysApiConvert.java similarity index 76% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysApiConvert.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysApiConvert.java index b3d8c081..f43ec282 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysApiConvert.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysApiConvert.java @@ -1,8 +1,8 @@ -package com.github.cadecode.uniboot.framework.api.convert; +package com.github.cadecode.uniboot.framework.svc.convert; -import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.api.request.SysApiRequest.SysApiAddRequest; -import com.github.cadecode.uniboot.framework.api.request.SysApiRequest.SysApiUpdateRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysApi; +import com.github.cadecode.uniboot.framework.svc.request.SysApiRequest.SysApiAddRequest; +import com.github.cadecode.uniboot.framework.svc.request.SysApiRequest.SysApiUpdateRequest; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysDictConvert.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysDictConvert.java similarity index 70% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysDictConvert.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysDictConvert.java index f7ecb4e5..120bbde1 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysDictConvert.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysDictConvert.java @@ -1,11 +1,11 @@ -package com.github.cadecode.uniboot.framework.api.convert; - -import com.github.cadecode.uniboot.framework.api.bean.po.SysDict; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysDictVo.SysDictGetByTypeVo; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysDictVo.SysDictPageVo; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysDictVo.SysDictSuggestVo; -import com.github.cadecode.uniboot.framework.api.request.SysDictRequest.SysDictAddRequest; -import com.github.cadecode.uniboot.framework.api.request.SysDictRequest.SysDictUpdateRequest; +package com.github.cadecode.uniboot.framework.svc.convert; + +import com.github.cadecode.uniboot.framework.svc.bean.po.SysDict; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.SysDictGetByTypeVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.SysDictPageVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.SysDictSuggestVo; +import com.github.cadecode.uniboot.framework.svc.request.SysDictRequest.SysDictAddRequest; +import com.github.cadecode.uniboot.framework.svc.request.SysDictRequest.SysDictUpdateRequest; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysLogConvert.java similarity index 64% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysLogConvert.java index 67a4595d..b14794b2 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysLogConvert.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysLogConvert.java @@ -1,8 +1,8 @@ -package com.github.cadecode.uniboot.framework.api.convert; +package com.github.cadecode.uniboot.framework.svc.convert; -import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysLogVo.SysLogPageVo; -import com.github.cadecode.uniboot.framework.api.request.SysLogRequest.SysLogSaveRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysLog; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogPageVo; +import com.github.cadecode.uniboot.framework.svc.request.SysLogRequest.SysLogSaveRequest; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysMenuConvert.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysMenuConvert.java similarity index 76% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysMenuConvert.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysMenuConvert.java index 42ecca19..1517f8ef 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysMenuConvert.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysMenuConvert.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.api.convert; +package com.github.cadecode.uniboot.framework.svc.convert; -import com.github.cadecode.uniboot.framework.api.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; -import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest.SysMenuAddRequest; -import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest.SysMenuUpdateRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysMenu; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeVo; +import com.github.cadecode.uniboot.framework.svc.request.SysMenuRequest.SysMenuAddRequest; +import com.github.cadecode.uniboot.framework.svc.request.SysMenuRequest.SysMenuUpdateRequest; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysRoleConvert.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysRoleConvert.java similarity index 75% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysRoleConvert.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysRoleConvert.java index 7f2e6b16..d0f1a6cd 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysRoleConvert.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysRoleConvert.java @@ -1,9 +1,9 @@ -package com.github.cadecode.uniboot.framework.api.convert; +package com.github.cadecode.uniboot.framework.svc.convert; -import com.github.cadecode.uniboot.framework.api.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysRoleVo.SysRoleListVo; -import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleAddRequest; -import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleUpdateRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysRole; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleListVo; +import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleAddRequest; +import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleUpdateRequest; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysUserConvert.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysUserConvert.java similarity index 78% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysUserConvert.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysUserConvert.java index 0df8d04a..22313c02 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/convert/SysUserConvert.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysUserConvert.java @@ -1,11 +1,11 @@ -package com.github.cadecode.uniboot.framework.api.convert; +package com.github.cadecode.uniboot.framework.svc.convert; -import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; -import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserAddRequest; -import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserModifyInfoRequest; -import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserUpdateRequest; -import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysUser; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesVo; +import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest.SysUserAddRequest; +import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest.SysUserModifyInfoRequest; +import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest.SysUserUpdateRequest; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysApiMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysApiMapper.java index 40242751..34b39ac3 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysApiMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysApiMapper.java @@ -1,9 +1,9 @@ package com.github.cadecode.uniboot.framework.svc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.api.request.SysApiRequest.SysApiRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysApi; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesVo; +import com.github.cadecode.uniboot.framework.svc.request.SysApiRequest.SysApiRolesRequest; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysDictMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysDictMapper.java index 2b25612f..59d7827b 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysDictMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysDictMapper.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.svc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.cadecode.uniboot.framework.api.bean.po.SysDict; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysDict; import org.apache.ibatis.annotations.Mapper; /** diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysLogMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysLogMapper.java index bf5eadec..00807001 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysLogMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysLogMapper.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.svc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysLog; import org.apache.ibatis.annotations.Mapper; /** diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysMenuMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysMenuMapper.java index 67c44c8f..f745866b 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysMenuMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysMenuMapper.java @@ -1,9 +1,9 @@ package com.github.cadecode.uniboot.framework.svc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.cadecode.uniboot.framework.api.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuRolesVo; -import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest.SysMenuRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysMenu; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesVo; +import com.github.cadecode.uniboot.framework.svc.request.SysMenuRequest.SysMenuRolesRequest; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysRoleMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysRoleMapper.java index 272c6954..384fe688 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysRoleMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysRoleMapper.java @@ -1,10 +1,10 @@ package com.github.cadecode.uniboot.framework.svc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.cadecode.uniboot.framework.api.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysRoleVo.SysRoleUnionVo; -import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleMappingRequest; -import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleUnionRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysRole; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionVo; +import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleMappingRequest; +import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleUnionRequest; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysUserMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysUserMapper.java index ca29137d..29581f8d 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysUserMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysUserMapper.java @@ -1,9 +1,9 @@ package com.github.cadecode.uniboot.framework.svc.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; -import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysUser; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesVo; +import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest.SysUserRolesRequest; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysApiRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysApiRequest.java similarity index 92% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysApiRequest.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysApiRequest.java index b1df34b5..5135cf79 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysApiRequest.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysApiRequest.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.request; +package com.github.cadecode.uniboot.framework.svc.request; import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysDictRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysDictRequest.java similarity index 95% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysDictRequest.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysDictRequest.java index 97fd3af0..87be7cc2 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysDictRequest.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysDictRequest.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.request; +package com.github.cadecode.uniboot.framework.svc.request; import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysLogRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java similarity index 95% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysLogRequest.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java index 5266f851..87481a5d 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysLogRequest.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.request; +package com.github.cadecode.uniboot.framework.svc.request; import com.github.cadecode.uniboot.common.core.web.response.PageParams; import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysMenuRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysMenuRequest.java similarity index 96% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysMenuRequest.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysMenuRequest.java index fd264795..21a52348 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysMenuRequest.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysMenuRequest.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.request; +package com.github.cadecode.uniboot.framework.svc.request; import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysRoleRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysRoleRequest.java similarity index 94% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysRoleRequest.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysRoleRequest.java index dc01e59f..011426fd 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysRoleRequest.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysRoleRequest.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.request; +package com.github.cadecode.uniboot.framework.svc.request; import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysUserRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysUserRequest.java similarity index 97% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysUserRequest.java rename to framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysUserRequest.java index fbced1e5..776f6baf 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/request/SysUserRequest.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysUserRequest.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.request; +package com.github.cadecode.uniboot.framework.svc.request; import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java index ec1bbeb1..d7974b24 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java @@ -5,8 +5,8 @@ import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; -import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Component; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandleService.java index 3a6b390e..45df4167 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandleService.java @@ -2,7 +2,7 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyService; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; import org.springframework.security.core.Authentication; import javax.servlet.http.HttpServletRequest; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java index 25754c55..8947c5cd 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java @@ -7,9 +7,9 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyExecutor; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; -import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.base.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysUser; import com.github.cadecode.uniboot.framework.svc.service.SysUserService; import lombok.RequiredArgsConstructor; import org.springframework.security.core.Authentication; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java index 07f717b3..f16ef0ee 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java @@ -7,8 +7,8 @@ import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; -import com.github.cadecode.uniboot.framework.api.security.model.SysUserDetails; -import com.github.cadecode.uniboot.framework.api.util.SecurityUtil; +import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; +import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Component; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java index 4584f4ad..3bd8c913 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java @@ -8,11 +8,11 @@ import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; import com.github.cadecode.uniboot.common.plugin.cache.util.RedisUtil; -import com.github.cadecode.uniboot.framework.api.config.SecurityConfig.SecurityProperties; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; +import com.github.cadecode.uniboot.framework.base.config.SecurityConfig.SecurityProperties; import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import lombok.RequiredArgsConstructor; import org.springframework.security.core.Authentication; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysApiService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysApiService.java index 37535e4b..5e43048c 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysApiService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysApiService.java @@ -1,9 +1,9 @@ package com.github.cadecode.uniboot.framework.svc.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.api.request.SysApiRequest.SysApiRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysApi; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesVo; +import com.github.cadecode.uniboot.framework.svc.request.SysApiRequest.SysApiRolesRequest; import com.github.pagehelper.PageInfo; import java.util.List; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysDictService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysDictService.java index 86bd0573..b07a0613 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysDictService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysDictService.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.svc.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.github.cadecode.uniboot.framework.api.bean.po.SysDict; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysDict; /** * 系统字典服务 diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysLogService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysLogService.java index a1df6d61..09b660e9 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysLogService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysLogService.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.svc.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysLog; /** * 系统日志服务 diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysMenuService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysMenuService.java index a8f94624..820f40ff 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysMenuService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysMenuService.java @@ -1,10 +1,10 @@ package com.github.cadecode.uniboot.framework.svc.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.github.cadecode.uniboot.framework.api.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuRolesVo; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; -import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest.SysMenuRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysMenu; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeVo; +import com.github.cadecode.uniboot.framework.svc.request.SysMenuRequest.SysMenuRolesRequest; import com.github.pagehelper.PageInfo; import java.util.List; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysRoleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysRoleService.java index b13af840..6edadefc 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysRoleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysRoleService.java @@ -1,10 +1,10 @@ package com.github.cadecode.uniboot.framework.svc.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.github.cadecode.uniboot.framework.api.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysRoleVo.SysRoleUnionVo; -import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleMappingRequest; -import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleUnionRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysRole; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionVo; +import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleMappingRequest; +import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleUnionRequest; import com.github.pagehelper.PageInfo; import java.util.List; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysUserService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysUserService.java index 4916d6a3..363335db 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysUserService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysUserService.java @@ -1,9 +1,9 @@ package com.github.cadecode.uniboot.framework.svc.service; import com.baomidou.mybatisplus.extension.service.IService; -import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; -import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysUser; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesVo; +import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest.SysUserRolesRequest; import com.github.pagehelper.PageInfo; import org.springframework.security.core.userdetails.UserDetailsService; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysApiServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysApiServiceImpl.java index 7238eec6..7ca9e1ef 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysApiServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysApiServiceImpl.java @@ -1,10 +1,10 @@ package com.github.cadecode.uniboot.framework.svc.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.cadecode.uniboot.framework.api.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.api.request.SysApiRequest.SysApiRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysApi; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesVo; import com.github.cadecode.uniboot.framework.svc.mapper.SysApiMapper; +import com.github.cadecode.uniboot.framework.svc.request.SysApiRequest.SysApiRolesRequest; import com.github.cadecode.uniboot.framework.svc.service.SysApiService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysDictServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysDictServiceImpl.java index 97a73ce6..a5c8e996 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysDictServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysDictServiceImpl.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.svc.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.cadecode.uniboot.framework.api.bean.po.SysDict; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysDict; import com.github.cadecode.uniboot.framework.svc.mapper.SysDictMapper; import com.github.cadecode.uniboot.framework.svc.service.SysDictService; import org.springframework.stereotype.Service; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysLogServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysLogServiceImpl.java index b4630b7f..817d3a03 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysLogServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysLogServiceImpl.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.svc.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.cadecode.uniboot.framework.api.bean.po.SysLog; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysLog; import com.github.cadecode.uniboot.framework.svc.mapper.SysLogMapper; import com.github.cadecode.uniboot.framework.svc.service.SysLogService; import org.springframework.stereotype.Service; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java index 114f3a7c..3d7e401f 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java @@ -2,12 +2,12 @@ import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.cadecode.uniboot.framework.api.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuRolesVo; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysMenuVo.SysMenuTreeVo; -import com.github.cadecode.uniboot.framework.api.convert.SysMenuConvert; -import com.github.cadecode.uniboot.framework.api.request.SysMenuRequest.SysMenuRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysMenu; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeVo; +import com.github.cadecode.uniboot.framework.svc.convert.SysMenuConvert; import com.github.cadecode.uniboot.framework.svc.mapper.SysMenuMapper; +import com.github.cadecode.uniboot.framework.svc.request.SysMenuRequest.SysMenuRolesRequest; import com.github.cadecode.uniboot.framework.svc.service.SysMenuService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java index 34599127..57649664 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java @@ -1,12 +1,12 @@ package com.github.cadecode.uniboot.framework.svc.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.cadecode.uniboot.framework.api.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysRoleVo.SysRoleUnionVo; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleMappingRequest; -import com.github.cadecode.uniboot.framework.api.request.SysRoleRequest.SysRoleUnionRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysRole; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionVo; import com.github.cadecode.uniboot.framework.svc.mapper.SysRoleMapper; +import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleMappingRequest; +import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleUnionRequest; import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java index f3d06df2..3e56d47f 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java @@ -3,11 +3,11 @@ import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.cadecode.uniboot.common.core.exception.ApiException; -import com.github.cadecode.uniboot.framework.api.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.api.bean.vo.SysUserVo.SysUserRolesVo; -import com.github.cadecode.uniboot.framework.api.convert.SysUserConvert; -import com.github.cadecode.uniboot.framework.api.request.SysUserRequest.SysUserRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.po.SysUser; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesVo; +import com.github.cadecode.uniboot.framework.svc.convert.SysUserConvert; import com.github.cadecode.uniboot.framework.svc.mapper.SysUserMapper; +import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest.SysUserRolesRequest; import com.github.cadecode.uniboot.framework.svc.service.SysUserService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; diff --git a/framework/framework_svc/src/main/resources/mapper/SysApiMapper.xml b/framework/framework_svc/src/main/resources/mapper/SysApiMapper.xml index 7783197b..5a07bbdd 100644 --- a/framework/framework_svc/src/main/resources/mapper/SysApiMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/SysApiMapper.xml @@ -1,7 +1,7 @@ - + diff --git a/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml b/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml index 6e169ab7..0fd8e61b 100644 --- a/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml @@ -1,7 +1,7 @@ - + @@ -17,7 +17,7 @@ - SELECT DISTINCT sm.* FROM sys_menu sm LEFT JOIN sys_role_menu srm ON sm.id = srm.menu_id LEFT JOIN sys_role sr ON srm.role_id = sr.id diff --git a/framework/framework_svc/src/main/resources/mapper/SysRoleMapper.xml b/framework/framework_svc/src/main/resources/mapper/SysRoleMapper.xml index 48bfef8e..b7c79f76 100644 --- a/framework/framework_svc/src/main/resources/mapper/SysRoleMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/SysRoleMapper.xml @@ -1,7 +1,7 @@ - + @@ -12,7 +12,7 @@ - SELECT * FROM sys_role_user ru INNER JOIN sys_role r ON ru.role_id = r.id @@ -24,7 +24,7 @@ ) - SELECT * FROM sys_role_menu rm INNER JOIN sys_role r ON rm.role_id = r.id @@ -36,7 +36,7 @@ ) - SELECT * FROM sys_role_api ra INNER JOIN sys_role r ON ra.role_id = r.id diff --git a/framework/framework_svc/src/main/resources/mapper/SysUserMapper.xml b/framework/framework_svc/src/main/resources/mapper/SysUserMapper.xml index d9a3b93b..888f32ac 100644 --- a/framework/framework_svc/src/main/resources/mapper/SysUserMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/SysUserMapper.xml @@ -1,7 +1,7 @@ - + diff --git a/framework/pom.xml b/framework/pom.xml index 1ca613d5..2ad7b9f3 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -16,6 +16,7 @@ framework_api + framework_base framework_svc diff --git a/gateway/pom.xml b/gateway/pom.xml index c55cd72e..16b919da 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -74,6 +74,24 @@ knife4j-spring-boot-starter + + com.github.cadecode + uni-boot-framework-api + + + com.github.cadecode + uni-boot-common-core + + + com.github.cadecode + uni-boot-common-plugin-cache + + + com.github.cadecode + uni-boot-common-plugin-log + + + com.github.cadecode uni-boot-common-plugin-actuator diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java index 7e59d8fa..99d50444 100644 --- a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java @@ -1,5 +1,6 @@ package com.github.cadecode.uniboot.gateway.filter; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; import org.springframework.core.annotation.Order; @@ -18,17 +19,13 @@ @Component public class RequestHeaderFilter implements GlobalFilter { - public static final String HEAD_SOURCE = "from-source"; - - public static final String HEAD_USER_DETAILS = "inner-user-details"; - @Override public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { // 去掉内部调用专用的请求头,防止伪造 ServerHttpRequest request = exchange.getRequest().mutate() .headers(h -> { - h.remove(HEAD_SOURCE); - h.remove(HEAD_USER_DETAILS); + h.remove(SecurityConst.HEAD_SOURCE); + h.remove(SecurityConst.HEAD_USER_DETAILS); }) .build(); return chain.filter(exchange.mutate().request(request).build()); diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/TraceInfoFilter.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/TraceInfoFilter.java index 0a000521..b3e00ffb 100644 --- a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/TraceInfoFilter.java +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/TraceInfoFilter.java @@ -1,6 +1,7 @@ package com.github.cadecode.uniboot.gateway.filter; import cn.hutool.core.lang.UUID; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import org.slf4j.MDC; import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; @@ -20,18 +21,16 @@ @Component public class TraceInfoFilter implements GlobalFilter { - public static final String HEAD_TRACE_ID = "trace-id"; - @Override public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { String traceId = UUID.fastUUID().toString(true); ServerHttpRequest request = exchange.getRequest().mutate() .headers(h -> { - MDC.put(HEAD_TRACE_ID, traceId); - h.set(HEAD_TRACE_ID, traceId); + MDC.put(SecurityConst.HEAD_TRACE_ID, traceId); + h.set(SecurityConst.HEAD_TRACE_ID, traceId); }) .build(); - exchange.getResponse().getHeaders().set(HEAD_TRACE_ID, traceId); + exchange.getResponse().getHeaders().set(SecurityConst.HEAD_TRACE_ID, traceId); return chain.filter(exchange.mutate().request(request).build()); } } diff --git a/pom.xml b/pom.xml index bc32bc49..bd53511e 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,11 @@ uni-boot-framework-api ${uni.version} + + com.github.cadecode + uni-boot-framework-base + ${uni.version} + com.github.cadecode uni-boot-example-api From f26f50b6a68c716693475f5569b34dadc9957295 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 11 Aug 2023 20:40:19 +0800 Subject: [PATCH 044/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=BD=91?= =?UTF-8?q?=E5=85=B3=E5=85=A8=E5=B1=80=E5=BC=82=E5=B8=B8=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/api/enums/FrameErrorEnum.java | 15 +++- .../base/feign/FeignErrorDecoder.java | 6 +- gateway/pom.xml | 8 +-- .../gateway/UniGatewayApplication.java | 3 + .../handler/GlobalExceptionHandler.java | 70 +++++++++++++++++++ 5 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 gateway/src/main/java/com/github/cadecode/uniboot/gateway/handler/GlobalExceptionHandler.java diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/FrameErrorEnum.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/FrameErrorEnum.java index 329bd529..026ca7e8 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/FrameErrorEnum.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/enums/FrameErrorEnum.java @@ -58,9 +58,18 @@ public int getStatus() { UPLOAD_FILE_FAIL(2002, "上传文件失败"), FILE_NOT_FOUND(2003, "文件未找到"), - // rpc - RPC_UNKNOWN_ERROR(3001, "RPC UNKNOWN 异常"), - RPC_UNWRAP_FAIL(3002, "RPC UNWRAP 失败"), + // cloud + RPC_UNKNOWN_ERROR(3001, "[RPC]UNKNOWN 异常"), + RPC_UNWRAP_FAIL(3002, "[RPC]UNWRAP 失败"), + GW_SVC_NOT_FOUND(3003, "[GW]服务未找到") { + @Override + public int getStatus() { + return ApiStatus.SERVER_UNAVAILABLE; + } + }, + GW_RES_STATUS_ERROR(3004, "[GW]响应状态错误"), + GW_SVC_INTERNAL_ERROR(3005, "[GW]服务内部错误"), + ; private final String code; diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignErrorDecoder.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignErrorDecoder.java index 9d69d7b8..1ac1b5d6 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignErrorDecoder.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignErrorDecoder.java @@ -48,7 +48,7 @@ public Exception decode(String methodKey, Response response) { // 构造 ApiErrorCode ApiErrorCode errorCode = getErrorCode(result, error); // 构造 moreInfo - String moreInfo = getMoreInfo(error); + String moreInfo = markMoreInfo(error); return ApiException.of(errorCode, moreInfo); } @@ -75,9 +75,9 @@ public int getStatus() { } /** - * 根据 ErrorMessage 获取 moreInfo 字符串 + * 获取 moreInfo 字符串,在前面加上 RPC 标记 */ - private String getMoreInfo(ErrorMessage error) { + private String markMoreInfo(ErrorMessage error) { String moreInfo = error.getMoreInfo(); // 在 moreInfo 前段追加 RPC 标记 if (!StrUtil.startWith(moreInfo, "[RPC]")) { diff --git a/gateway/pom.xml b/gateway/pom.xml index 16b919da..8d925ded 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -78,10 +78,6 @@ com.github.cadecode uni-boot-framework-api - - com.github.cadecode - uni-boot-common-core - com.github.cadecode uni-boot-common-plugin-cache @@ -90,6 +86,10 @@ com.github.cadecode uni-boot-common-plugin-log + + org.springframework.boot + spring-boot-starter-web + diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/UniGatewayApplication.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/UniGatewayApplication.java index cc886afc..adbac972 100644 --- a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/UniGatewayApplication.java +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/UniGatewayApplication.java @@ -1,5 +1,6 @@ package com.github.cadecode.uniboot.gateway; +import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyService; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; @@ -7,10 +8,12 @@ import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.plugin.core.config.EnablePluginRegistries; /** * 启动类 */ +@EnablePluginRegistries({StrategyService.class}) @EnableFeignClients("com.github.cadecode") @EnableDiscoveryClient @EnableAspectJAutoProxy(exposeProxy = true) diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/handler/GlobalExceptionHandler.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/handler/GlobalExceptionHandler.java new file mode 100644 index 00000000..b44b16f0 --- /dev/null +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/handler/GlobalExceptionHandler.java @@ -0,0 +1,70 @@ +package com.github.cadecode.uniboot.gateway.handler; + +import cn.hutool.core.util.ObjectUtil; +import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; +import com.github.cadecode.uniboot.common.core.util.JacksonUtil; +import com.github.cadecode.uniboot.common.core.web.response.ApiResult; +import com.github.cadecode.uniboot.framework.api.enums.FrameErrorEnum; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.web.reactive.error.ErrorWebExceptionHandler; +import org.springframework.cloud.gateway.support.NotFoundException; +import org.springframework.core.annotation.Order; +import org.springframework.core.io.buffer.DataBuffer; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.server.reactive.ServerHttpResponse; +import org.springframework.stereotype.Component; +import org.springframework.web.server.ResponseStatusException; +import org.springframework.web.server.ServerWebExchange; +import reactor.core.publisher.Mono; + +/** + * 网关全局异常处理 + * + * @author Cade Li + * @since 2023/8/11 + */ +@Slf4j +@Order(-1) +@Component +public class GlobalExceptionHandler implements ErrorWebExceptionHandler { + + @Override + public Mono handle(ServerWebExchange exchange, Throwable ex) { + ServerHttpResponse response = exchange.getResponse(); + if (exchange.getResponse().isCommitted()) { + return Mono.error(ex); + } + ApiResult result = getApiResultFromEx(exchange, ex); + log.error("[GW]Exception handler=> status:{}, path:{}, msg:{},", result.getStatus(), result.getError().getPath(), result.getError().getMessage(), ex); + response.setStatusCode(HttpStatus.resolve(result.getStatus())); + response.getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE); + DataBuffer dataBuffer = response.bufferFactory().wrap(JacksonUtil.toJson(result).getBytes()); + return response.writeWith(Mono.just(dataBuffer)); + } + + private ApiResult getApiResultFromEx(ServerWebExchange exchange, Throwable ex) { + String moreInfo = ex.getMessage(); + String path = exchange.getRequest().getPath().toString(); + Integer status = null; + ApiErrorCode errorCode; + // 服务未找到 503 + if (ex instanceof NotFoundException) { + errorCode = FrameErrorEnum.GW_SVC_NOT_FOUND; + } else if (ex instanceof ResponseStatusException) { + // 响应状态异常 + errorCode = FrameErrorEnum.GW_RES_STATUS_ERROR; + ResponseStatusException e = (ResponseStatusException) ex; + status = e.getStatus().value(); + } else { + // 其他异常 + errorCode = FrameErrorEnum.GW_SVC_INTERNAL_ERROR; + } + ApiResult result = ApiResult.error(errorCode).moreInfo(moreInfo).path(path); + if (ObjectUtil.isNotNull(status)) { + result.status(status); + } + return result; + } +} From f349a3a85071486b28748cf42b56a0f347d4e7e9 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 11 Aug 2023 21:25:47 +0800 Subject: [PATCH 045/244] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=20REDAME?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=9C=8D=E5=8A=A1=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/config/application-config-example.md | 260 +++++++++++++++++++++ .docs/config/create-service-example.md | 147 ++++++++++++ README.md | 12 +- 3 files changed, 416 insertions(+), 3 deletions(-) create mode 100644 .docs/config/application-config-example.md create mode 100644 .docs/config/create-service-example.md diff --git a/.docs/config/application-config-example.md b/.docs/config/application-config-example.md new file mode 100644 index 00000000..8f6144d4 --- /dev/null +++ b/.docs/config/application-config-example.md @@ -0,0 +1,260 @@ +## 服务参考配置 + +> 服务配置文件推荐由 Nacos 统一管理 + +### 服务共享配置 + +shared-config.yml + +```yaml +server: + shutdown: graceful + +# spring config +spring: + lifecycle: + timeout-per-shutdown-phase: 60s + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + boot: + admin: + client: + url: http://127.0.0.1:1111 + # redis 公共配置 + redis: + lettuce: + pool: + max-active: 8 + min-idle: 0 + max-idle: 8 + max-wait: -1 + # 数据源公共配置 + datasource: + druid: + initialSize: 5 + minIdle: 10 + maxActive: 20 + maxWait: 60000 + timeBetweenEvictionRunsMillis: 60000 + minEvictableIdleTimeMillis: 300000 + maxEvictableIdleTimeMillis: 900000 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + allow: + url-pattern: /druid/* + login-username: dev + login-password: dev123 + filter: + stat: + enabled: true + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: false + wall: + config: + multi-statement-allow: true + dynamic: + tp: + collectorTypes: logging + logPath: ${logging.file.path} + monitorInterval: 10 + executors: + - threadPoolName: asyncExecutor + thread-name-prefix: asyncExecutor- + corePoolSize: 6 + maximumPoolSize: 8 + queueCapacity: 1000 + queueType: VariableLinkedBlockingQueue + rejectedHandlerType: CallerRunsPolicy + keepAliveTime: 50 + waitForTasksToCompleteOnShutdown: true + awaitTerminationSeconds: 300 + notifyEnabled: false + taskWrapperNames: [ "ttl", "mdc" ] + +# pagehelper +pagehelper: + reasonable: true + supportMethodsArguments: true + params: count=countSql + auto-dialect: true + auto-runtime-dialect: true + page-size-zero: true + +# mybatis plus 配置 +mybatis-plus: + mapper-locations: classpath*:mapper/**/*.xml + type-aliases-package: com.github.cadecode.**.bean,com.github.cadecode.**.mybatis.converter + type-enums-package: com.github.cadecode.**.enums + configuration: + map-underscore-to-camel-case: true + +# swagger配置 +knife4j: + enable: true + basic: + enable: true + username: dev + password: dev123 + +# actuator +management: + endpoints: + web: + exposure: + include: '*' + +# uni-boot +uni-boot: + config: + name: ${spring.application.name} + version: 2023.1.0 + swagger-on: true + dynamic-ds-on: false + swagger: + name: Cade Li + url: https://github.com/cadecode/uni-boot-admin + email: cadecode@foxmail.com + version: ${uni-boot.config.version} + module: + default: com.github.cadecode.uniboot + security: + auth-model: redis + token-config: + expiration: 86400 + secret: 12345678123456781234567812345678 + cache: + dl: + allow-null-values: true +``` + +shared-config-dev.yml(DEV 环境) + +```yaml +spring: + cloud: + inetutils: + # 多网卡机器上指定 ip 偏好 + preferred-networks: + - 192.168.0. + - 192.168.238. + - 10. + +# 关闭 swagger 认证 +knife4j: + basic: + enable: false +``` + +### framework 服务配置 + +uni-boot-framework-dev.yml(DEV 环境) + +```yaml +server: + port: 8001 + +spring: + redis: + host: localhost + port: 6379 + password: ENC(jIiKGruIMgDkKx5wj2gJRCROqPutkTvZ) + database: 0 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + dynamic: + primary: master + datasource: + master: + url: jdbc:p6spy:mysql://localhost:3306/demo?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: root + password: ENC(donQ3DazAc4/6B+NFSRdxw==) + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + slave1: + url: jdbc:p6spy:mysql://localhost:3306/demo_cluster?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: root + password: ENC(donQ3DazAc4/6B+NFSRdxw==) + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + +# uni-boot 配置 +uni-boot: + swagger: + title: Framework API Docs + description: Framework 服务在线文档 By Swagger + security: + ignore-urls: /common/download** + framework: + file-base-path: D:/uniboot/file/temp/ +``` + +### example 服务配置 + +uni-boot-example-dev.yml(DEV 环境) + +```yaml +server: + port: 8010 + +spring: + redis: + host: localhost + port: 6379 + password: ENC(jIiKGruIMgDkKx5wj2gJRCROqPutkTvZ) + database: 0 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + dynamic: + primary: master + datasource: + master: + url: jdbc:p6spy:mysql://localhost:3306/demo?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: root + password: ENC(donQ3DazAc4/6B+NFSRdxw==) + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + slave1: + url: jdbc:p6spy:mysql://localhost:3306/demo_cluster?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + username: root + password: ENC(donQ3DazAc4/6B+NFSRdxw==) + driver-class-name: com.p6spy.engine.spy.P6SpyDriver + +# uni-boot 配置 +uni-boot: + swagger: + title: Example API Docs + description: Example 服务在线文档 By Swagger + security: + ignore-urls: +``` + +### gateway 服务配置 + +uni-boot-gateway-dev.yml(DEV 环境) + +```yaml +server: + port: 8000 + +spring: + cloud: + gateway: + routes: + - id: uni-boot-framework + uri: lb://uni-boot-framework + predicates: + - Path=/framework/** + filters: + - StripPrefix=1 + - id: uni-boot-example + uri: lb://uni-boot-example + predicates: + - Path=/example/** + filters: + - StripPrefix=1 +``` diff --git a/.docs/config/create-service-example.md b/.docs/config/create-service-example.md new file mode 100644 index 00000000..b356d8c5 --- /dev/null +++ b/.docs/config/create-service-example.md @@ -0,0 +1,147 @@ +## 服务创建示例 + +### 创建模块 + +创建一个模块 uni-boot-xxx,继承自 uni-boot-dependencies + +```xml + + + uni-boot-dependencies + com.github.cadecode + 2023.1.0 + ../dependencies/pom.xml + +``` + +该模块下创建对应的 api 模块 uni-boot-xxx-api 和 svc 模块 uni-boot-xxx-svc + +api 模块供外部调用、DTO 共享,svc 模块提供基础服务 + +## 添加依赖 + +本项目子模块版本维护在根 pom,第三方模块版本维护在 uni-boot-dependencies + +api 模块基本依赖: +```xml + + + + net.dreamlu + mica-auto + provided + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.cloud + spring-cloud-starter-loadbalancer + + +``` + +svc 模块基本依赖: +```xml + + + + org.springframework.cloud + spring-cloud-starter-bootstrap + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.github.ulisesbocchio + jasypt-spring-boot-starter + + + + com.github.cadecode + uni-boot-common-plugin-actuator + + + + com.github.cadecode + uni-boot-framework-base + + +``` + +## 创建启动类 + +```java + +@MapperScan("com.github.cadecode.**.mapper") +@EnableFeignClients("com.github.cadecode") +@EnableDiscoveryClient +@EnableAspectJAutoProxy(exposeProxy = true) +@SpringBootApplication +public class UniXxxApplication extends SpringBootServletInitializer { + + public static void main(String[] args) { + SpringApplication.run(UniExampleApplication.class, args); + } + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(UniExampleApplication.class); + } +} +``` + +## 配置文件 + +bootstrap.yml +```yaml +logging: + file: + path: /log/uni_boot_admin/xxx + +spring: + application: + name: uni-boot-xxx + cloud: + nacos: + server-addr: localhost:8848 + username: nacos + password: nacos + discovery: + enabled: true + namespace: uni_dev + group: DEFAULT_GROUP + config: + enabled: true + namespace: uni_dev + group: DEFAULT_GROUP + file-extension: yml + shared-configs: + - shared-config.${spring.cloud.nacos.config.file-extension} + - shared-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +``` + +logback-spring.xml +```xml + +``` diff --git a/README.md b/README.md index f195714a..30261929 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,12 @@ # uni-boot-admin -> 基于 SpringBoot 多模块开发的通用后台管理系统骨架,集成 SpringSecurity、Druid、MyBatisPlus、多数据源、二级缓存、DynamicTP 等常用组件 +> 基于 SpringCloud 的通用后台管理系统骨架,引入 Nacos、OpenFeign、Gateway 等微服务核心组件 +> +> 基于 SpringBoot 生态,集成 SpringSecurity、Druid、MyBatisPlus、多数据源、二级缓存、DynamicTP 等常用组件 ## 项目简介 -1. 本项目是一套通用后台管理系统骨架,后端基于 SpringBoot 生态,集成常用组件,方便扩展使用 +1. 本项目是一套通用后台管理系统骨架,后端基于 SpringCloud 生态,集成常用组件,方便扩展使用 2. 本项目采用前后端分离结构,以下是配套前端项目 @@ -14,7 +16,9 @@ JDK 版本:8 - Spring 版本:SpringBoot 2.5.4 + SpringBoot 版本:SpringBoot 2.5.4 + + SpringCloud 版本:SpringCloud 2020.0.5、SpringCloudAlibaba 2021.1 数据库版本:MySQL8 @@ -28,6 +32,8 @@ 较好的编码风格 + 基于 SpringCloud、SpringCloudAlibaba 提供微服务生态支持 + 基于 SpringSecurity 实现认证授权,支持 API 级的角色访问控制,可动态配置 API 权限、菜单权限 权限认证支持本地 JWT 认证和 Redis Token 认证模式 From f13b30487175f0807ba1ec30807bc164fcb8ae9d Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 11 Aug 2023 21:27:28 +0800 Subject: [PATCH 046/244] =?UTF-8?q?build:=20=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=88=B0=202023.1.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/core/pom.xml | 2 +- common/plugin/actuator/pom.xml | 2 +- common/plugin/cache/pom.xml | 2 +- common/plugin/concurrent/pom.xml | 2 +- common/plugin/datasource/pom.xml | 2 +- common/plugin/log/pom.xml | 2 +- common/plugin/mybatis/pom.xml | 2 +- common/plugin/pom.xml | 2 +- common/plugin/swagger/pom.xml | 2 +- common/pom.xml | 2 +- dependencies/pom.xml | 2 +- example/example_api/pom.xml | 2 +- example/example_svc/pom.xml | 2 +- example/pom.xml | 2 +- framework/framework_api/pom.xml | 2 +- framework/framework_base/pom.xml | 2 +- framework/framework_svc/pom.xml | 2 +- framework/pom.xml | 2 +- gateway/pom.xml | 2 +- pom.xml | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/common/core/pom.xml b/common/core/pom.xml index a12421ea..1040393c 100644 --- a/common/core/pom.xml +++ b/common/core/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common - 2023.1.0 + 2023.1.1 4.0.0 diff --git a/common/plugin/actuator/pom.xml b/common/plugin/actuator/pom.xml index 293d0ffd..e75fe736 100644 --- a/common/plugin/actuator/pom.xml +++ b/common/plugin/actuator/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.0 + 2023.1.1 4.0.0 diff --git a/common/plugin/cache/pom.xml b/common/plugin/cache/pom.xml index cdf185c8..1424b09e 100644 --- a/common/plugin/cache/pom.xml +++ b/common/plugin/cache/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.0 + 2023.1.1 4.0.0 diff --git a/common/plugin/concurrent/pom.xml b/common/plugin/concurrent/pom.xml index 8665a655..3310085f 100644 --- a/common/plugin/concurrent/pom.xml +++ b/common/plugin/concurrent/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.0 + 2023.1.1 4.0.0 diff --git a/common/plugin/datasource/pom.xml b/common/plugin/datasource/pom.xml index ba072f46..b0558ce6 100644 --- a/common/plugin/datasource/pom.xml +++ b/common/plugin/datasource/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.0 + 2023.1.1 4.0.0 diff --git a/common/plugin/log/pom.xml b/common/plugin/log/pom.xml index 5ae45493..df2502d6 100644 --- a/common/plugin/log/pom.xml +++ b/common/plugin/log/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.0 + 2023.1.1 4.0.0 diff --git a/common/plugin/mybatis/pom.xml b/common/plugin/mybatis/pom.xml index 92aa18f3..32faf223 100644 --- a/common/plugin/mybatis/pom.xml +++ b/common/plugin/mybatis/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.0 + 2023.1.1 4.0.0 diff --git a/common/plugin/pom.xml b/common/plugin/pom.xml index f43417f1..e1b8bca3 100644 --- a/common/plugin/pom.xml +++ b/common/plugin/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common - 2023.1.0 + 2023.1.1 4.0.0 diff --git a/common/plugin/swagger/pom.xml b/common/plugin/swagger/pom.xml index 7ee7c457..fdc2ca0c 100644 --- a/common/plugin/swagger/pom.xml +++ b/common/plugin/swagger/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.0 + 2023.1.1 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index aab5106a..6df196f7 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ uni-boot-dependencies com.github.cadecode - 2023.1.0 + 2023.1.1 ../dependencies/pom.xml 4.0.0 diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 6c219f84..39a1b4c2 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-parent - 2023.1.0 + 2023.1.1 4.0.0 diff --git a/example/example_api/pom.xml b/example/example_api/pom.xml index 40d76e8d..4319299f 100644 --- a/example/example_api/pom.xml +++ b/example/example_api/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-example - 2023.1.0 + 2023.1.1 4.0.0 diff --git a/example/example_svc/pom.xml b/example/example_svc/pom.xml index ae89d0af..44590bfc 100644 --- a/example/example_svc/pom.xml +++ b/example/example_svc/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-example - 2023.1.0 + 2023.1.1 4.0.0 diff --git a/example/pom.xml b/example/pom.xml index c3a82fed..9ed63171 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -5,7 +5,7 @@ uni-boot-dependencies com.github.cadecode - 2023.1.0 + 2023.1.1 ../dependencies/pom.xml 4.0.0 diff --git a/framework/framework_api/pom.xml b/framework/framework_api/pom.xml index 23b7f71f..c18c6038 100644 --- a/framework/framework_api/pom.xml +++ b/framework/framework_api/pom.xml @@ -6,7 +6,7 @@ com.github.cadecode uni-boot-framework - 2023.1.0 + 2023.1.1 uni-boot-framework-api diff --git a/framework/framework_base/pom.xml b/framework/framework_base/pom.xml index f2f18f91..8717895a 100644 --- a/framework/framework_base/pom.xml +++ b/framework/framework_base/pom.xml @@ -6,7 +6,7 @@ com.github.cadecode uni-boot-framework - 2023.1.0 + 2023.1.1 uni-boot-framework-base diff --git a/framework/framework_svc/pom.xml b/framework/framework_svc/pom.xml index 2160ff50..862ebbfa 100644 --- a/framework/framework_svc/pom.xml +++ b/framework/framework_svc/pom.xml @@ -6,7 +6,7 @@ com.github.cadecode uni-boot-framework - 2023.1.0 + 2023.1.1 uni-boot-framework-svc diff --git a/framework/pom.xml b/framework/pom.xml index 2ad7b9f3..4bbb2ef6 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -5,7 +5,7 @@ uni-boot-dependencies com.github.cadecode - 2023.1.0 + 2023.1.1 ../dependencies/pom.xml 4.0.0 diff --git a/gateway/pom.xml b/gateway/pom.xml index 8d925ded..6e16f938 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -5,7 +5,7 @@ uni-boot-dependencies com.github.cadecode - 2023.1.0 + 2023.1.1 ../dependencies/pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index bd53511e..635a11b2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.cadecode uni-boot-parent - 2023.1.0 + 2023.1.1 pom uni-boot-admin From 9c5f66786fe793c4fa72b5547c1a49c1d4a25fa1 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 12 Aug 2023 10:18:29 +0800 Subject: [PATCH 047/244] =?UTF-8?q?feat:=20Api=20log=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20traceId=20=E5=AD=97=E6=AE=B5=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/api/bean/dto/SysLogDto.java | 2 ++ .../uniboot/framework/api/consts/SecurityConst.java | 5 +++++ .../uniboot/framework/base/plugin/ApiLogHandler.java | 9 +++++++-- .../cadecode/uniboot/framework/svc/bean/po/SysLog.java | 2 ++ .../uniboot/framework/svc/request/SysLogRequest.java | 3 +++ 5 files changed, 19 insertions(+), 2 deletions(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java index f697e343..d8ef62df 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java @@ -54,5 +54,7 @@ public static class SysLogSaveDto { private String browser; private String userAgent; + + private String traceId; } } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java index 1db98466..0c9b0a7a 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java @@ -38,4 +38,9 @@ public interface SecurityConst { */ String HEAD_TRACE_ID = "trace-id"; + /** + * User-Agent + */ + String HEAD_USER_AGENT = "User-Agent"; + } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java index 3220bde3..8340a517 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java @@ -1,6 +1,7 @@ package com.github.cadecode.uniboot.framework.base.plugin; import cn.hutool.core.exceptions.ExceptionUtil; +import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.http.useragent.UserAgent; @@ -10,6 +11,7 @@ import com.github.cadecode.uniboot.common.plugin.log.aspect.ApiLoggerAspect.BaseLogInfo; import com.github.cadecode.uniboot.common.plugin.log.handler.AbstractApiLogHandler; import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogSaveDto; +import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.feignclient.SysLogClient; import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import io.swagger.annotations.ApiOperation; @@ -40,9 +42,11 @@ public class ApiLogHandler extends AbstractApiLogHandler { */ public SysLogSaveDto generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogInfo) { ApiLogger apiLogger = baseLogInfo.getApiLogger(); - // 解析 user-agent,生成日志信息 - String userAgentStr = baseLogInfo.getRequest().getHeader("User-Agent"); + // 解析 user-agent + String userAgentStr = ServletUtil.getHeader(baseLogInfo.getRequest(), SecurityConst.HEAD_USER_AGENT, CharsetUtil.CHARSET_UTF_8); UserAgent userAgent = UserAgentUtil.parse(userAgentStr); + // 获取 trace-id + String traceId = ServletUtil.getHeader(baseLogInfo.getRequest(), SecurityConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); // 解析参数 String paramsJson; try { @@ -76,6 +80,7 @@ public SysLogSaveDto generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogI .userAgent(userAgentStr) .browser(userAgent.getBrowser().getName()) .os(userAgent.getOs().getName()) + .traceId(traceId) .build(); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java index 765ce661..937417bc 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java @@ -89,6 +89,8 @@ public class SysLog { */ private String userAgent; + private String traceId; + @TableField(fill = FieldFill.INSERT) private Date createTime; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java index 87481a5d..6a21ffed 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java @@ -63,5 +63,8 @@ public static class SysLogSaveRequest { private String browser; private String userAgent; + + private String traceId; + } } From 9399d961c60767729a48bf73f68aa0729e33eebb Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 12 Aug 2023 10:19:01 +0800 Subject: [PATCH 048/244] =?UTF-8?q?docs:=20SysLog=20=E8=A1=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20traceId=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/sql/framework/schema.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/.docs/sql/framework/schema.sql b/.docs/sql/framework/schema.sql index 4cb99b90..7c516843 100644 --- a/.docs/sql/framework/schema.sql +++ b/.docs/sql/framework/schema.sql @@ -139,6 +139,7 @@ CREATE TABLE IF NOT EXISTS sys_log os VARCHAR(200) NULL COMMENT '操作系统', browser VARCHAR(200) NULL COMMENT '浏览器', user_agent VARCHAR(500) NULL COMMENT 'user-agent', + trace_id VARCHAR(100) NULL COMMENT 'trace-id', create_time DATETIME DEFAULT CURRENT_TIMESTAMP, update_time DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, From f372c24d509d96151b1ce3e0dd061922bed3b1f5 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 12 Aug 2023 10:20:52 +0800 Subject: [PATCH 049/244] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E7=B1=BB?= =?UTF-8?q?=E5=90=8D=20SecurityConst=20->=20HttpConst?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{SecurityConst.java => HttpConst.java} | 4 ++-- .../framework/base/aspect/ApiInnerAspect.java | 6 +++--- .../framework/base/config/FeignConfig.java | 16 ++++++++-------- .../framework/base/config/SecurityConfig.java | 6 +++--- .../base/feign/FeignClientDecorator.java | 8 ++++---- .../framework/base/plugin/ApiLogHandler.java | 6 +++--- .../filter/JwtTokenAuthFilterService.java | 4 ++-- .../uniboot/framework/base/util/RequestUtil.java | 8 ++++---- .../framework/base/util/SecurityUtil.java | 6 +++--- .../security/JwtLoginSuccessHandleService.java | 4 ++-- .../security/RedisLoginSuccessHandleService.java | 4 ++-- .../svc/security/SignOutSuccessHandler.java | 4 ++-- .../gateway/filter/RequestHeaderFilter.java | 6 +++--- .../uniboot/gateway/filter/TraceInfoFilter.java | 8 ++++---- 14 files changed, 45 insertions(+), 45 deletions(-) rename framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/{SecurityConst.java => HttpConst.java} (93%) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/HttpConst.java similarity index 93% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/HttpConst.java index 0c9b0a7a..ea52d328 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SecurityConst.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/HttpConst.java @@ -1,12 +1,12 @@ package com.github.cadecode.uniboot.framework.api.consts; /** - * Security 常量 + * HTTP 常量 * * @author Cade Li * @since 2023/7/29 */ -public interface SecurityConst { +public interface HttpConst { /** * token 请求头名称 diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/aspect/ApiInnerAspect.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/aspect/ApiInnerAspect.java index e8d06385..58a472c3 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/aspect/ApiInnerAspect.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/aspect/ApiInnerAspect.java @@ -4,7 +4,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.extra.servlet.ServletUtil; import com.github.cadecode.uniboot.common.core.exception.ApiException; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import com.github.cadecode.uniboot.framework.base.annotation.ApiInner; import com.github.cadecode.uniboot.framework.base.util.RequestUtil; @@ -44,8 +44,8 @@ public void rateLimit(JoinPoint point) { return; } // 获取请求头 - String source = ServletUtil.getHeader(servletRequest, SecurityConst.HEAD_SOURCE, CharsetUtil.CHARSET_UTF_8); - boolean innerFlag = ObjectUtil.equal(source, SecurityConst.HEAD_SOURCE_VALUE); + String source = ServletUtil.getHeader(servletRequest, HttpConst.HEAD_SOURCE, CharsetUtil.CHARSET_UTF_8); + boolean innerFlag = ObjectUtil.equal(source, HttpConst.HEAD_SOURCE_VALUE); // 判断是否仅供内部调用 if (apiInner.onlyClient() && !innerFlag) { throw ApiException.of(AuthErrorEnum.TOKEN_NO_AUTHORITY, "ApiInner AOP:该接口仅供内部调用"); diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java index 1b744588..7f574f2e 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java @@ -7,7 +7,7 @@ import cn.hutool.extra.servlet.ServletUtil; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.base.feign.FeignClientDecorator; import com.github.cadecode.uniboot.framework.base.feign.FeignErrorDecoder; import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; @@ -46,31 +46,31 @@ public RequestInterceptor requestInterceptor() { protected void configRequestTemplate(RequestTemplate requestTemplate) { // 设置内部请求来源标识 - requestTemplate.header(SecurityConst.HEAD_SOURCE, SecurityConst.HEAD_SOURCE_VALUE); + requestTemplate.header(HttpConst.HEAD_SOURCE, HttpConst.HEAD_SOURCE_VALUE); HttpServletRequest servletRequest = RequestUtil.getRequest(); if (ObjectUtil.isNull(servletRequest)) { return; } // 配置客户端 IP - requestTemplate.header(SecurityConst.HEAD_FORWARDED_FOR, ServletUtil.getClientIP(servletRequest)); + requestTemplate.header(HttpConst.HEAD_FORWARDED_FOR, ServletUtil.getClientIP(servletRequest)); // 传递 trace id - String traceId = ServletUtil.getHeader(servletRequest, SecurityConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); + String traceId = ServletUtil.getHeader(servletRequest, HttpConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); if (ObjectUtil.isNotEmpty(traceId)) { - requestTemplate.header(SecurityConst.HEAD_TRACE_ID, traceId); + requestTemplate.header(HttpConst.HEAD_TRACE_ID, traceId); } // 传递用户 token String token = SecurityUtil.getTokenFromRequest(servletRequest); if (StrUtil.isNotEmpty(token)) { - requestTemplate.header(SecurityConst.HEAD_TOKEN, token); + requestTemplate.header(HttpConst.HEAD_TOKEN, token); } // 传递用户信息 - String userDetailsJson = ServletUtil.getHeader(servletRequest, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); + String userDetailsJson = ServletUtil.getHeader(servletRequest, HttpConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); // 不存在则生成 if (StrUtil.isEmpty(userDetailsJson)) { SysUserDetails userDetailsDto = SecurityUtil.getUserDetails(null); userDetailsJson = JacksonUtil.toJson(userDetailsDto); } - requestTemplate.header(SecurityConst.HEAD_USER_DETAILS, EscapeUtil.escape(userDetailsJson)); + requestTemplate.header(HttpConst.HEAD_USER_DETAILS, EscapeUtil.escape(userDetailsJson)); } // 覆盖 feign 配置 diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java index 97865f93..5e01e29d 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java @@ -5,7 +5,7 @@ import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.extra.servlet.ServletUtil; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.base.config.SecurityConfig.SecurityProperties; import com.github.cadecode.uniboot.framework.base.security.filter.TokenAuthFilter; @@ -170,9 +170,9 @@ public static class TraceInfoFilter extends OncePerRequestFilter { protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { - String traceId = ServletUtil.getHeader(request, SecurityConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); + String traceId = ServletUtil.getHeader(request, HttpConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); if (ObjectUtil.isNotEmpty(traceId)) { - MDC.put(SecurityConst.HEAD_TRACE_ID, traceId); + MDC.put(HttpConst.HEAD_TRACE_ID, traceId); } filterChain.doFilter(request, response); } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignClientDecorator.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignClientDecorator.java index 7fe5625e..31d5bb2c 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignClientDecorator.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignClientDecorator.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.base.feign; import cn.hutool.core.util.ObjectUtil; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.base.util.RequestUtil; import feign.Client; import feign.Request; @@ -43,9 +43,9 @@ protected void fillResponseHeader(Map> headers) { return; } // 获取 token - if (headers.containsKey(SecurityConst.HEAD_TOKEN)) { - String token = headers.get(SecurityConst.HEAD_TOKEN).stream().findFirst().get(); - servletResponse.addHeader(SecurityConst.HEAD_TOKEN, token); + if (headers.containsKey(HttpConst.HEAD_TOKEN)) { + String token = headers.get(HttpConst.HEAD_TOKEN).stream().findFirst().get(); + servletResponse.addHeader(HttpConst.HEAD_TOKEN, token); } } } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java index 8340a517..da7a68b5 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java @@ -11,7 +11,7 @@ import com.github.cadecode.uniboot.common.plugin.log.aspect.ApiLoggerAspect.BaseLogInfo; import com.github.cadecode.uniboot.common.plugin.log.handler.AbstractApiLogHandler; import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogSaveDto; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.api.feignclient.SysLogClient; import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import io.swagger.annotations.ApiOperation; @@ -43,10 +43,10 @@ public class ApiLogHandler extends AbstractApiLogHandler { public SysLogSaveDto generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogInfo) { ApiLogger apiLogger = baseLogInfo.getApiLogger(); // 解析 user-agent - String userAgentStr = ServletUtil.getHeader(baseLogInfo.getRequest(), SecurityConst.HEAD_USER_AGENT, CharsetUtil.CHARSET_UTF_8); + String userAgentStr = ServletUtil.getHeader(baseLogInfo.getRequest(), HttpConst.HEAD_USER_AGENT, CharsetUtil.CHARSET_UTF_8); UserAgent userAgent = UserAgentUtil.parse(userAgentStr); // 获取 trace-id - String traceId = ServletUtil.getHeader(baseLogInfo.getRequest(), SecurityConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); + String traceId = ServletUtil.getHeader(baseLogInfo.getRequest(), HttpConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); // 解析参数 String paramsJson; try { diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/JwtTokenAuthFilterService.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/JwtTokenAuthFilterService.java index f489e3a5..04ee9241 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/JwtTokenAuthFilterService.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/JwtTokenAuthFilterService.java @@ -4,7 +4,7 @@ import cn.hutool.json.JSONObject; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.core.util.TokenUtil; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; @@ -63,7 +63,7 @@ public void handler(HttpServletRequest request, HttpServletResponse response, Fi String newJwtToken = TokenUtil.generateToken(sysUserDetails.getId(), sysUserDetails.getUsername(), sysUserDetails.getRoles(), SecurityUtil.getExpiration(), SecurityUtil.getSecret()); // token 放在请求头 - response.addHeader(SecurityConst.HEAD_TOKEN, newJwtToken); + response.addHeader(HttpConst.HEAD_TOKEN, newJwtToken); } filterChain.doFilter(request, response); } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/RequestUtil.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/RequestUtil.java index 9b10261c..178c3f6c 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/RequestUtil.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/RequestUtil.java @@ -5,7 +5,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.extra.servlet.ServletUtil; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -50,8 +50,8 @@ public static boolean isInnerRequest(HttpServletRequest request) { if (ObjectUtil.isNull(request)) { return false; } - String source = ServletUtil.getHeader(request, SecurityConst.HEAD_SOURCE, CharsetUtil.CHARSET_UTF_8); - return ObjectUtil.equal(source, SecurityConst.HEAD_SOURCE_VALUE); + String source = ServletUtil.getHeader(request, HttpConst.HEAD_SOURCE, CharsetUtil.CHARSET_UTF_8); + return ObjectUtil.equal(source, HttpConst.HEAD_SOURCE_VALUE); } /** @@ -68,7 +68,7 @@ public static SysUserDetails getInnerUserDetails(HttpServletRequest request) { return null; } // feign 拦截器填充时做了转义处理 - String escapedUserDetailsJson = ServletUtil.getHeader(request, SecurityConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); + String escapedUserDetailsJson = ServletUtil.getHeader(request, HttpConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); if (ObjectUtil.isNotEmpty(escapedUserDetailsJson)) { return JacksonUtil.toBean(EscapeUtil.unescape(escapedUserDetailsJson), SysUserDetails.class); } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java index e49a2c22..6e4f8b60 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java @@ -2,7 +2,7 @@ import cn.hutool.core.lang.UUID; import cn.hutool.core.util.ObjectUtil; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.base.config.SecurityConfig.SecurityProperties; import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; import lombok.RequiredArgsConstructor; @@ -50,13 +50,13 @@ public static String getTokenFromRequest(HttpServletRequest request) { Cookie[] cookies = request.getCookies(); if (ObjectUtil.isNotEmpty(cookies)) { Optional optionalCookie = Arrays.stream(cookies) - .filter(c -> ObjectUtil.equal(c.getName(), SecurityConst.HEAD_TOKEN)) + .filter(c -> ObjectUtil.equal(c.getName(), HttpConst.HEAD_TOKEN)) .findAny(); if (optionalCookie.isPresent()) { return optionalCookie.get().getValue(); } } - return request.getHeader(SecurityConst.HEAD_TOKEN); + return request.getHeader(HttpConst.HEAD_TOKEN); } /** diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java index d7974b24..98f6abdc 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java @@ -3,7 +3,7 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.core.util.TokenUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; @@ -31,7 +31,7 @@ public ApiResult getResult(HttpServletRequest request, HttpServl String jwtToken = TokenUtil.generateToken(sysUserDetails.getId(), sysUserDetails.getUsername(), sysUserDetails.getRoles(), SecurityUtil.getExpiration(), SecurityUtil.getSecret()); // token 放在请求头 - response.addHeader(SecurityConst.HEAD_TOKEN, jwtToken); + response.addHeader(HttpConst.HEAD_TOKEN, jwtToken); return ApiResult.ok(sysUserDetails).path(FrameSecurityConfig.LOGOUT_URL); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java index f16ef0ee..ef933f3f 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java @@ -4,8 +4,8 @@ import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; import com.github.cadecode.uniboot.common.plugin.cache.util.RedisUtil; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; @@ -33,7 +33,7 @@ public ApiResult getResult(HttpServletRequest request, HttpServl // 生成 uuid token String uuidToken = SecurityUtil.generateUUID(); // token 放在请求头 - response.addHeader(SecurityConst.HEAD_TOKEN, uuidToken); + response.addHeader(HttpConst.HEAD_TOKEN, uuidToken); // 生成存放登录信息的 redis key String loginUserKey = KeyGeneUtil.key(KeyPrefix.LOGIN_USER, uuidToken); RedisUtil.set(loginUserKey, sysUserDetails, SecurityUtil.getExpiration(), TimeUnit.SECONDS); diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java index 3bd8c913..6caa0a1d 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java @@ -8,8 +8,8 @@ import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; import com.github.cadecode.uniboot.common.plugin.cache.util.RedisUtil; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.base.config.SecurityConfig.SecurityProperties; @@ -38,7 +38,7 @@ public class SignOutSuccessHandler implements LogoutSuccessHandler { public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { // 删除保存登录信息的 redis key - String uuidToken = request.getHeader(SecurityConst.HEAD_TOKEN); + String uuidToken = request.getHeader(HttpConst.HEAD_TOKEN); if (StrUtil.isNotEmpty(uuidToken) && properties.getAuthModel() == AuthModelEnum.REDIS) { String loginUserKey = KeyGeneUtil.key(KeyPrefix.LOGIN_USER, uuidToken); RedisUtil.del(loginUserKey); diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java index 99d50444..d249eaa0 100644 --- a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/RequestHeaderFilter.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.gateway.filter; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; import org.springframework.core.annotation.Order; @@ -24,8 +24,8 @@ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { // 去掉内部调用专用的请求头,防止伪造 ServerHttpRequest request = exchange.getRequest().mutate() .headers(h -> { - h.remove(SecurityConst.HEAD_SOURCE); - h.remove(SecurityConst.HEAD_USER_DETAILS); + h.remove(HttpConst.HEAD_SOURCE); + h.remove(HttpConst.HEAD_USER_DETAILS); }) .build(); return chain.filter(exchange.mutate().request(request).build()); diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/TraceInfoFilter.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/TraceInfoFilter.java index b3e00ffb..03cf2513 100644 --- a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/TraceInfoFilter.java +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/filter/TraceInfoFilter.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.gateway.filter; import cn.hutool.core.lang.UUID; -import com.github.cadecode.uniboot.framework.api.consts.SecurityConst; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import org.slf4j.MDC; import org.springframework.cloud.gateway.filter.GatewayFilterChain; import org.springframework.cloud.gateway.filter.GlobalFilter; @@ -26,11 +26,11 @@ public Mono filter(ServerWebExchange exchange, GatewayFilterChain chain) { String traceId = UUID.fastUUID().toString(true); ServerHttpRequest request = exchange.getRequest().mutate() .headers(h -> { - MDC.put(SecurityConst.HEAD_TRACE_ID, traceId); - h.set(SecurityConst.HEAD_TRACE_ID, traceId); + MDC.put(HttpConst.HEAD_TRACE_ID, traceId); + h.set(HttpConst.HEAD_TRACE_ID, traceId); }) .build(); - exchange.getResponse().getHeaders().set(SecurityConst.HEAD_TRACE_ID, traceId); + exchange.getResponse().getHeaders().set(HttpConst.HEAD_TRACE_ID, traceId); return chain.filter(exchange.mutate().request(request).build()); } } From c11e506af695cc480516d3a490a982360a852022 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 12 Aug 2023 10:54:41 +0800 Subject: [PATCH 050/244] =?UTF-8?q?fix:=20SysLog=20=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E=20traceId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java index fa5fbe89..83488251 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java @@ -50,10 +50,13 @@ public static class SysLogPageVo { private String userAgent; + private String traceId; + private Date createTime; private Date updateTime; private String updateUser; + } } From 403e96323946e850e3fdc370cd6d7739bb8a1f09 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 12 Aug 2023 10:55:25 +0800 Subject: [PATCH 051/244] =?UTF-8?q?feat:=20=E5=AF=B9=20Api=20log=20?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E7=9A=84=E6=95=8F=E6=84=9F=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=81=9A=E5=BF=BD=E7=95=A5=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/plugin/log/handler/AbstractApiLogHandler.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java index 5317958e..6da01310 100644 --- a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java +++ b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java @@ -1,5 +1,6 @@ package com.github.cadecode.uniboot.common.plugin.log.handler; +import cn.hutool.core.collection.CollUtil; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.aspect.ApiLoggerAspect.BaseLogInfo; import lombok.extern.slf4j.Slf4j; @@ -15,6 +16,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.Set; /** * Api Log 处理器抽象 @@ -25,6 +27,8 @@ @Slf4j public abstract class AbstractApiLogHandler { + private static final Set IGNORE_LOG_FIELD_SET = CollUtil.newHashSet("password"); + public abstract Object generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogInfo); public abstract void save(ApiLogger apiLogger, Object o); @@ -46,6 +50,11 @@ public static Map getRequestParams(JoinPoint joinPoint, ApiLogge } Map map = new HashMap<>(); for (int i = 0; i < names.length; i++) { + // 对敏感字段进行排除 + if (IGNORE_LOG_FIELD_SET.contains(names[i])) { + map.put(names[i], "[IGNORE_LOG_FIELD]"); + continue; + } // 排除请求对象和响应 if (args[i] instanceof HttpServletRequest || args[i] instanceof HttpServletResponse) { continue; From 9c26e8b11f44a02253d0540df0f6091cc7a359c9 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 13 Aug 2023 15:07:40 +0800 Subject: [PATCH 052/244] =?UTF-8?q?feat:=20Api=20log=20=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=B3=A8=E8=A7=A3=20logType=20=E6=94=B9=E4=B8=BA=20String?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/plugin/log/pom.xml | 4 -- .../plugin/log/annotation/ApiLogger.java | 4 +- .../plugin/log/aspect/ApiLoggerAspect.java | 27 +++------- .../common/plugin/log/enums/LogTypeEnum.java | 50 ------------------- .../log/handler/AbstractApiLogHandler.java | 4 +- .../common/plugin/log/model/BaseLogInfo.java | 27 ++++++++++ .../framework/api/bean/dto/SysLogDto.java | 3 +- .../uniboot/framework/api/consts/LogType.java | 32 ++++++++++++ .../framework/base/plugin/ApiLogHandler.java | 6 +-- .../uniboot/framework/svc/bean/po/SysLog.java | 3 +- .../framework/svc/bean/vo/SysLogVo.java | 3 +- .../svc/controller/AuthController.java | 6 +-- .../framework/svc/request/SysLogRequest.java | 5 +- 13 files changed, 80 insertions(+), 94 deletions(-) delete mode 100644 common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/enums/LogTypeEnum.java create mode 100644 common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/model/BaseLogInfo.java create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/LogType.java diff --git a/common/plugin/log/pom.xml b/common/plugin/log/pom.xml index df2502d6..26524fa7 100644 --- a/common/plugin/log/pom.xml +++ b/common/plugin/log/pom.xml @@ -16,9 +16,5 @@ com.github.cadecode uni-boot-common-core - - com.github.cadecode - uni-boot-common-plugin-mybatis - diff --git a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/annotation/ApiLogger.java b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/annotation/ApiLogger.java index 14edff9f..577d80fd 100644 --- a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/annotation/ApiLogger.java +++ b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/annotation/ApiLogger.java @@ -1,8 +1,6 @@ package com.github.cadecode.uniboot.common.plugin.log.annotation; -import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; - import java.lang.annotation.*; /** @@ -17,7 +15,7 @@ public @interface ApiLogger { boolean value() default true; - LogTypeEnum type() default LogTypeEnum.OTHER; + String type() default ""; String description() default ""; diff --git a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java index a2f69052..19664a73 100644 --- a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java +++ b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java @@ -5,7 +5,8 @@ import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.handler.AbstractApiLogHandler; -import lombok.*; +import com.github.cadecode.uniboot.common.plugin.log.model.BaseLogInfo; +import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -16,8 +17,6 @@ import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; -import javax.servlet.http.HttpServletRequest; - /** * 请求响应信息日志 AOP 类 * @@ -91,7 +90,7 @@ public void handleLogger(ProceedingJoinPoint point, ApiLogger apiLogger, Object return; } try { - String resultStr = null; + String resultStr; boolean exceptional = false; if (ObjectUtil.isNotNull(throwable)) { exceptional = true; @@ -101,34 +100,22 @@ public void handleLogger(ProceedingJoinPoint point, ApiLogger apiLogger, Object resultStr = JacksonUtil.toJson(result); } catch (Exception e) { resultStr = ExceptionUtil.stacktraceToString(e); - log.error("API log [{}]: request result to json fail", apiLogger.type().getType(), e); + log.error("API log [{}]: request result to json fail", apiLogger.type(), e); } } BaseLogInfo baseLogInfo = BaseLogInfo.builder().apiLogger(apiLogger).request(attributes.getRequest()) .resultStr(resultStr).timeCost(timeCost).exceptional(exceptional).build(); Object logObj = apiLogHandler.generateLog(point, baseLogInfo); // 打印日志 - log.info("API log [{}]: {}", apiLogger.type().getType(), JacksonUtil.toJson(logObj)); + log.info("API log [{}]: {}", apiLogger.type(), JacksonUtil.toJson(logObj)); // 持久化 try { apiLogHandler.save(apiLogger, logObj); } catch (Exception e) { - log.error("API log [{}]: save async fail", apiLogger.type().getType(), e); + log.error("API log [{}]: save async fail", apiLogger.type(), e); } } catch (Exception e) { - log.error("API log [{}]: handle logger fail", apiLogger.type().getType(), e); + log.error("API log [{}]: handle logger fail", apiLogger.type(), e); } } - - @Data - @AllArgsConstructor - @NoArgsConstructor - @Builder - public static class BaseLogInfo { - private ApiLogger apiLogger; - private Boolean exceptional; - private HttpServletRequest request; - private String resultStr; - private Long timeCost; - } } diff --git a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/enums/LogTypeEnum.java b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/enums/LogTypeEnum.java deleted file mode 100644 index 61cc1c9e..00000000 --- a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/enums/LogTypeEnum.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.github.cadecode.uniboot.common.plugin.log.enums; - -import com.baomidou.mybatisplus.annotation.EnumValue; -import com.fasterxml.jackson.annotation.JsonValue; -import lombok.Getter; - -/** - * Api log 类型 - * - * @author Cade Li - * @since 2023/5/26 - */ -@Getter -public enum LogTypeEnum { - - /** - * curd - */ - QUERY("Query"), - UPDATE("Update"), - REMOVE("Remove"), - ADD("Add"), - /** - * 鉴权 - */ - AUTH("Auth"), - /** - * 导入导出 - */ - IMPORT("Import"), - EXPORT("Export"), - /** - * 上传下载 - */ - UPLOAD("Upload"), - DOWNLOAD("Download"), - /** - * 其他 - */ - OTHER("Other") - ; - - @EnumValue - @JsonValue - private final String type; - - LogTypeEnum(String type) { - this.type = type; - } -} diff --git a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java index 6da01310..202eb11a 100644 --- a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java +++ b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java @@ -2,7 +2,7 @@ import cn.hutool.core.collection.CollUtil; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; -import com.github.cadecode.uniboot.common.plugin.log.aspect.ApiLoggerAspect.BaseLogInfo; +import com.github.cadecode.uniboot.common.plugin.log.model.BaseLogInfo; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; @@ -45,7 +45,7 @@ public static Map getRequestParams(JoinPoint joinPoint, ApiLogge return Collections.emptyMap(); } if (names.length != args.length) { - log.error("API log [{}]: method [{}] param and the pass value do not match", apiLogger.type().getType(), methodSignature.getName()); + log.error("API log [{}]: method [{}] param and the pass value do not match", apiLogger.type(), methodSignature.getName()); return Collections.emptyMap(); } Map map = new HashMap<>(); diff --git a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/model/BaseLogInfo.java b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/model/BaseLogInfo.java new file mode 100644 index 00000000..2b1a0ae7 --- /dev/null +++ b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/model/BaseLogInfo.java @@ -0,0 +1,27 @@ +package com.github.cadecode.uniboot.common.plugin.log.model; + +import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.servlet.http.HttpServletRequest; + +/** + * api log 信息 + * + * @author Cade Li + * @since 2023/8/13 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class BaseLogInfo { + private ApiLogger apiLogger; + private Boolean exceptional; + private HttpServletRequest request; + private String resultStr; + private Long timeCost; +} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java index d8ef62df..468ea704 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java @@ -1,6 +1,5 @@ package com.github.cadecode.uniboot.framework.api.bean.dto; -import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -23,7 +22,7 @@ public class SysLogDto { @Builder public static class SysLogSaveDto { - private LogTypeEnum logType; + private String logType; private String url; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/LogType.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/LogType.java new file mode 100644 index 00000000..fece0ca5 --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/LogType.java @@ -0,0 +1,32 @@ +package com.github.cadecode.uniboot.framework.api.consts; + +/** + * Api log 类型 + * + * @author Cade Li + * @since 2023/8/13 + */ +public interface LogType { + + /** + * curd + */ + String QUERY = "Query"; + String UPDATE = "Update"; + String REMOVE = "Remove"; + String ADD = "Add"; + /** + * 鉴权 + */ + String AUTH = "Auth"; + /** + * 导入导出 + */ + String IMPORT = "Import"; + String EXPORT = "Export"; + /** + * 上传下载 + */ + String UPLOAD = "Upload"; + String DOWNLOAD = "Download"; +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java index da7a68b5..447d36c6 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java @@ -8,8 +8,8 @@ import cn.hutool.http.useragent.UserAgentUtil; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; -import com.github.cadecode.uniboot.common.plugin.log.aspect.ApiLoggerAspect.BaseLogInfo; import com.github.cadecode.uniboot.common.plugin.log.handler.AbstractApiLogHandler; +import com.github.cadecode.uniboot.common.plugin.log.model.BaseLogInfo; import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogSaveDto; import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.api.feignclient.SysLogClient; @@ -53,7 +53,7 @@ public SysLogSaveDto generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogI paramsJson = JacksonUtil.toJson(getRequestParams(point, apiLogger)); } catch (Exception e) { paramsJson = ExceptionUtil.stacktraceToString(e); - log.error("API log [{}]: request params to json fail", apiLogger.type().getType(), e); + log.error("API log [{}]: request params to json fail", apiLogger.type(), e); } // 获取描述 String description = apiLogger.description(); @@ -102,7 +102,7 @@ public void save(ApiLogger apiLogger, Object o) { try { sysLogClient.save(Collections.singletonList(dto)); } catch (Exception e) { - log.error("API log [{}]: save fail", apiLogger.type().getType(), e); + log.error("API log [{}]: save fail", apiLogger.type(), e); } } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java index 937417bc..d2a603ad 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java @@ -1,7 +1,6 @@ package com.github.cadecode.uniboot.framework.svc.bean.po; import com.baomidou.mybatisplus.annotation.*; -import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; import lombok.AllArgsConstructor; import lombok.Builder; @@ -26,7 +25,7 @@ public class SysLog { @TableId(type = IdType.ASSIGN_ID) private Long id; - private LogTypeEnum logType; + private String logType; /** * url */ diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java index 83488251..b14a664b 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java @@ -1,6 +1,5 @@ package com.github.cadecode.uniboot.framework.svc.bean.vo; -import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; import lombok.Data; import java.util.Date; @@ -18,7 +17,7 @@ public static class SysLogPageVo { private Long id; - private LogTypeEnum logType; + private String logType; private String url; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java index 60b0c491..ccfa65a3 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java @@ -2,7 +2,7 @@ import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; -import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; +import com.github.cadecode.uniboot.framework.api.consts.LogType; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import io.swagger.annotations.Api; @@ -31,14 +31,14 @@ public class AuthController { private final AuthClient authClient; - @ApiLogger(type = LogTypeEnum.AUTH, enableSave = true, description = "用户登录") + @ApiLogger(type = LogType.AUTH, enableSave = true, description = "用户登录") @ApiOperation("登录") @PostMapping("login") public ApiResult login(@RequestParam String username, @RequestParam String password) { return authClient.login(username, password); } - @ApiLogger(type = LogTypeEnum.AUTH, enableSave = true, description = "用户注销") + @ApiLogger(type = LogType.AUTH, enableSave = true, description = "用户注销") @ApiOperation("注销") @PostMapping("logout") public ApiResult logout() { diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java index 6a21ffed..0d38f971 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java @@ -1,7 +1,6 @@ package com.github.cadecode.uniboot.framework.svc.request; import com.github.cadecode.uniboot.common.core.web.response.PageParams; -import com.github.cadecode.uniboot.common.plugin.log.enums.LogTypeEnum; import lombok.Data; import lombok.EqualsAndHashCode; @@ -22,7 +21,7 @@ public static class SysLogPageRequest extends PageParams { private Date startTime; private Date endTime; - private List logTypeList; + private List logTypeList; private String url; private String accessUser; private Boolean exceptional; @@ -32,7 +31,7 @@ public static class SysLogPageRequest extends PageParams { @Data public static class SysLogSaveRequest { - private LogTypeEnum logType; + private String logType; private String url; From 1fe567e94e7246d0dcf3e4a22701757b73337f51 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 13 Aug 2023 15:58:57 +0800 Subject: [PATCH 053/244] =?UTF-8?q?refactor:=20=E5=B8=B8=E9=87=8F=E7=B1=BB?= =?UTF-8?q?=E7=B1=BB=E5=90=8D=E8=A7=84=E8=8C=83=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/consts/{KeyPrefix.java => KeyPrefixConst.java} | 2 +- .../api/consts/{LogType.java => LogTypeConst.java} | 2 +- .../api/consts/{SvcName.java => SvcNameConst.java} | 2 +- .../framework/api/feignclient/ExampleClient.java | 4 ++-- .../framework/api/feignclient/SysApiClient.java | 8 ++++---- .../framework/api/feignclient/SysLogClient.java | 4 ++-- .../security/filter/RedisTokenAuthFilterService.java | 4 ++-- .../framework/svc/controller/AuthController.java | 6 +++--- .../framework/svc/controller/SysApiController.java | 6 +++--- .../framework/svc/controller/SysRoleController.java | 6 +++--- .../svc/security/RedisLoginSuccessHandleService.java | 4 ++-- .../framework/svc/security/SignOutSuccessHandler.java | 4 ++-- .../framework/svc/serviceimpl/SysRoleServiceImpl.java | 10 +++++----- 13 files changed, 31 insertions(+), 31 deletions(-) rename framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/{KeyPrefix.java => KeyPrefixConst.java} (90%) rename framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/{LogType.java => LogTypeConst.java} (94%) rename framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/{SvcName.java => SvcNameConst.java} (87%) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/KeyPrefix.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/KeyPrefixConst.java similarity index 90% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/KeyPrefix.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/KeyPrefixConst.java index 0541a9a0..d78b6630 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/KeyPrefix.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/KeyPrefixConst.java @@ -6,7 +6,7 @@ * @author Cade Li * @date 2022/5/29 */ -public interface KeyPrefix { +public interface KeyPrefixConst { /** * 登录用户信息 diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/LogType.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/LogTypeConst.java similarity index 94% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/LogType.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/LogTypeConst.java index fece0ca5..72c328bb 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/LogType.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/LogTypeConst.java @@ -6,7 +6,7 @@ * @author Cade Li * @since 2023/8/13 */ -public interface LogType { +public interface LogTypeConst { /** * curd diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SvcName.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SvcNameConst.java similarity index 87% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SvcName.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SvcNameConst.java index 3f7174b4..a6265127 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SvcName.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/SvcNameConst.java @@ -6,7 +6,7 @@ * @author Cade Li * @since 2023/7/29 */ -public interface SvcName { +public interface SvcNameConst { String FRAMEWORK = "uni-boot-framework"; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/ExampleClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/ExampleClient.java index 01ab5156..8f526d2e 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/ExampleClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/ExampleClient.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.framework.api.feignclient; -import com.github.cadecode.uniboot.framework.api.consts.SvcName; +import com.github.cadecode.uniboot.framework.api.consts.SvcNameConst; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -11,7 +11,7 @@ * @author Cade Li * @since 2023/7/28 */ -@FeignClient(contextId = "ExampleClient", name = SvcName.FRAMEWORK) +@FeignClient(contextId = "ExampleClient", name = SvcNameConst.FRAMEWORK) public interface ExampleClient { @PostMapping("example/test_str") diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java index 7ab19d2f..0cea36e6 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.api.feignclient; -import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; -import com.github.cadecode.uniboot.framework.api.consts.SvcName; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefixConst; +import com.github.cadecode.uniboot.framework.api.consts.SvcNameConst; import com.github.cadecode.uniboot.framework.api.response.SysApiResponse.SysApiRolesResponse; import org.springframework.cache.annotation.Cacheable; import org.springframework.cloud.openfeign.FeignClient; @@ -15,10 +15,10 @@ * @author Cade Li * @since 2023/7/28 */ -@FeignClient(contextId = "SysApiClient", name = SvcName.FRAMEWORK) +@FeignClient(contextId = "SysApiClient", name = SvcNameConst.FRAMEWORK) public interface SysApiClient { - @Cacheable(cacheNames = KeyPrefix.API_ROLES, key = "'all'") + @Cacheable(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @PostMapping("system/api/list_roles_vo") List listRolesVo(); diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java index 58e441f6..88d6de12 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.api.feignclient; import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogSaveDto; -import com.github.cadecode.uniboot.framework.api.consts.SvcName; +import com.github.cadecode.uniboot.framework.api.consts.SvcNameConst; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -15,7 +15,7 @@ * @author Cade Li * @since 2023/7/28 */ -@FeignClient(contextId = "SysLogClient", name = SvcName.FRAMEWORK) +@FeignClient(contextId = "SysLogClient", name = SvcNameConst.FRAMEWORK) public interface SysLogClient { @PostMapping("system/log/save") diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/RedisTokenAuthFilterService.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/RedisTokenAuthFilterService.java index 52de32e7..792f4686 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/RedisTokenAuthFilterService.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/RedisTokenAuthFilterService.java @@ -4,7 +4,7 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; import com.github.cadecode.uniboot.common.plugin.cache.util.RedisUtil; -import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefixConst; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; @@ -40,7 +40,7 @@ public void handler(HttpServletRequest request, HttpServletResponse response, Fi return; } // 查询 redis 中 token - String loginUserKey = KeyGeneUtil.key(KeyPrefix.LOGIN_USER, uuidToken); + String loginUserKey = KeyGeneUtil.key(KeyPrefixConst.LOGIN_USER, uuidToken); SysUserDetails sysUserDetails = RedisUtil.get(loginUserKey, SysUserDetails.class); // redis 中用户不存在 if (Objects.isNull(sysUserDetails)) { diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java index ccfa65a3..5edebb5e 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/AuthController.java @@ -2,7 +2,7 @@ import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; -import com.github.cadecode.uniboot.framework.api.consts.LogType; +import com.github.cadecode.uniboot.framework.api.consts.LogTypeConst; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.svc.config.FrameSecurityConfig; import io.swagger.annotations.Api; @@ -31,14 +31,14 @@ public class AuthController { private final AuthClient authClient; - @ApiLogger(type = LogType.AUTH, enableSave = true, description = "用户登录") + @ApiLogger(type = LogTypeConst.AUTH, enableSave = true, description = "用户登录") @ApiOperation("登录") @PostMapping("login") public ApiResult login(@RequestParam String username, @RequestParam String password) { return authClient.login(username, password); } - @ApiLogger(type = LogType.AUTH, enableSave = true, description = "用户注销") + @ApiLogger(type = LogTypeConst.AUTH, enableSave = true, description = "用户注销") @ApiOperation("注销") @PostMapping("logout") public ApiResult logout() { diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java index 845ed0a2..51581b31 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java @@ -2,7 +2,7 @@ import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; -import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefixConst; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.base.annotation.ApiInner; import com.github.cadecode.uniboot.framework.svc.bean.po.SysApi; @@ -66,7 +66,7 @@ public PageResult pageRolesVo(@RequestBody @Valid SysApiRequest.S return new PageResult<>((int) rolesVoPage.getTotal(), rolesVoPage.getList()); } - @CacheEvict(cacheNames = KeyPrefix.API_ROLES, key = "'all'") + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @ApiOperation("更新API") @PostMapping("update") public boolean update(@RequestBody @Valid SysApiRequest.SysApiUpdateRequest request) { @@ -74,7 +74,7 @@ public boolean update(@RequestBody @Valid SysApiRequest.SysApiUpdateRequest requ return sysApiService.updateById(po); } - @CacheEvict(cacheNames = KeyPrefix.API_ROLES, key = "'all'") + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @ApiOperation("添加API") @PostMapping("add") public boolean add(@RequestBody @Valid SysApiRequest.SysApiAddRequest request) { diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java index d329c65a..0310c51d 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.svc.controller; import com.github.cadecode.uniboot.common.core.web.response.PageResult; -import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefixConst; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.svc.bean.po.SysRole; import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleListVo; @@ -100,7 +100,7 @@ public List listUnionVoByRoleIds(@RequestBody @NotEmpty List getResult(HttpServletRequest request, HttpServl // token 放在请求头 response.addHeader(HttpConst.HEAD_TOKEN, uuidToken); // 生成存放登录信息的 redis key - String loginUserKey = KeyGeneUtil.key(KeyPrefix.LOGIN_USER, uuidToken); + String loginUserKey = KeyGeneUtil.key(KeyPrefixConst.LOGIN_USER, uuidToken); RedisUtil.set(loginUserKey, sysUserDetails, SecurityUtil.getExpiration(), TimeUnit.SECONDS); return ApiResult.ok(sysUserDetails).path(FrameSecurityConfig.LOGOUT_URL); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java index 6caa0a1d..165ece8b 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/SignOutSuccessHandler.java @@ -9,7 +9,7 @@ import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; import com.github.cadecode.uniboot.common.plugin.cache.util.RedisUtil; import com.github.cadecode.uniboot.framework.api.consts.HttpConst; -import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefixConst; import com.github.cadecode.uniboot.framework.api.enums.AuthErrorEnum; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.base.config.SecurityConfig.SecurityProperties; @@ -40,7 +40,7 @@ public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse resp // 删除保存登录信息的 redis key String uuidToken = request.getHeader(HttpConst.HEAD_TOKEN); if (StrUtil.isNotEmpty(uuidToken) && properties.getAuthModel() == AuthModelEnum.REDIS) { - String loginUserKey = KeyGeneUtil.key(KeyPrefix.LOGIN_USER, uuidToken); + String loginUserKey = KeyGeneUtil.key(KeyPrefixConst.LOGIN_USER, uuidToken); RedisUtil.del(loginUserKey); } // 写入响应 diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java index 57649664..ee14bfff 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.svc.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.cadecode.uniboot.framework.api.consts.KeyPrefix; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefixConst; import com.github.cadecode.uniboot.framework.svc.bean.po.SysRole; import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionVo; import com.github.cadecode.uniboot.framework.svc.mapper.SysRoleMapper; @@ -63,13 +63,13 @@ public int removeRoleMenuByRoleIds(List roleIds) { return sysRoleMapper.deleteRoleMenuByRoleIds(roleIds); } - @CacheEvict(cacheNames = KeyPrefix.API_ROLES, key = "'all'") + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @Override public int removeRoleApiByApiIds(List apiIds) { return sysRoleMapper.deleteRoleApiByApiIds(apiIds); } - @CacheEvict(cacheNames = KeyPrefix.API_ROLES, key = "'all'") + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @Override public int removeRoleApiByRoleIds(List roleIds) { return sysRoleMapper.deleteRoleApiByRoleIds(roleIds); @@ -85,7 +85,7 @@ public int removeRoleMenu(List list) { return sysRoleMapper.deleteRoleMenu(list); } - @CacheEvict(cacheNames = KeyPrefix.API_ROLES, key = "'all'") + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @Override public int removeRoleApi(List list) { return sysRoleMapper.deleteRoleApi(list); @@ -101,7 +101,7 @@ public int addRoleMenu(List list) { return sysRoleMapper.insertRoleMenu(list); } - @CacheEvict(cacheNames = KeyPrefix.API_ROLES, key = "'all'") + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @Override public int addRoleApi(List list) { return sysRoleMapper.insertRoleApi(list); From 5ca03f02355c264eb81c51c979790249a418f522 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 13 Aug 2023 17:21:28 +0800 Subject: [PATCH 054/244] =?UTF-8?q?refactor:=20bean=20=E7=B1=BB=E5=90=8D?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/SysApiDto.java} | 8 +- .../framework/api/bean/dto/SysLogDto.java | 2 +- .../api/feignclient/SysApiClient.java | 4 +- .../api/feignclient/SysLogClient.java | 4 +- .../framework/base/plugin/ApiLogHandler.java | 8 +- .../security/voter/DataBaseRoleVoter.java | 6 +- .../framework/svc/bean/vo/SysApiVo.java | 35 ++++++-- .../framework/svc/bean/vo/SysDictVo.java | 51 ++++++++++- .../framework/svc/bean/vo/SysLogVo.java | 58 +++++++++++- .../framework/svc/bean/vo/SysMenuVo.java | 64 ++++++++++++- .../framework/svc/bean/vo/SysRoleVo.java | 42 ++++++++- .../framework/svc/bean/vo/SysUserVo.java | 87 ++++++++++++++++-- .../svc/controller/SysApiController.java | 31 ++++--- .../svc/controller/SysDictController.java | 38 ++++---- .../svc/controller/SysLogController.java | 29 +++--- .../svc/controller/SysMenuController.java | 24 ++--- .../svc/controller/SysRoleController.java | 49 +++++----- .../svc/controller/SysUserController.java | 53 ++++++----- .../framework/svc/convert/SysApiConvert.java | 8 +- .../framework/svc/convert/SysDictConvert.java | 16 ++-- .../framework/svc/convert/SysLogConvert.java | 8 +- .../framework/svc/convert/SysMenuConvert.java | 12 +-- .../framework/svc/convert/SysRoleConvert.java | 14 +-- .../framework/svc/convert/SysUserConvert.java | 16 ++-- .../framework/svc/mapper/SysApiMapper.java | 8 +- .../framework/svc/mapper/SysMenuMapper.java | 8 +- .../framework/svc/mapper/SysRoleMapper.java | 22 ++--- .../framework/svc/mapper/SysUserMapper.java | 10 +-- .../framework/svc/request/SysApiRequest.java | 38 -------- .../framework/svc/request/SysDictRequest.java | 56 ------------ .../framework/svc/request/SysLogRequest.java | 69 -------------- .../framework/svc/request/SysMenuRequest.java | 72 --------------- .../framework/svc/request/SysRoleRequest.java | 49 ---------- .../framework/svc/request/SysUserRequest.java | 89 ------------------- .../framework/svc/service/SysApiService.java | 12 +-- .../framework/svc/service/SysMenuService.java | 14 +-- .../framework/svc/service/SysRoleService.java | 24 ++--- .../framework/svc/service/SysUserService.java | 10 +-- .../svc/serviceimpl/SysApiServiceImpl.java | 18 ++-- .../svc/serviceimpl/SysMenuServiceImpl.java | 30 +++---- .../svc/serviceimpl/SysRoleServiceImpl.java | 32 +++---- .../svc/serviceimpl/SysUserServiceImpl.java | 20 ++--- .../main/resources/mapper/SysApiMapper.xml | 12 +-- .../main/resources/mapper/SysMenuMapper.xml | 24 ++--- .../main/resources/mapper/SysRoleMapper.xml | 16 ++-- .../main/resources/mapper/SysUserMapper.xml | 20 ++--- 46 files changed, 617 insertions(+), 703 deletions(-) rename framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/{response/SysApiResponse.java => bean/dto/SysApiDto.java} (70%) delete mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysApiRequest.java delete mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysDictRequest.java delete mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java delete mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysMenuRequest.java delete mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysRoleRequest.java delete mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysUserRequest.java diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/response/SysApiResponse.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysApiDto.java similarity index 70% rename from framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/response/SysApiResponse.java rename to framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysApiDto.java index c8edc4fb..cab53ed2 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/response/SysApiResponse.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysApiDto.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.api.response; +package com.github.cadecode.uniboot.framework.api.bean.dto; import lombok.Data; @@ -6,15 +6,15 @@ import java.util.List; /** - * SysApi response + * SysApi res dto * * @author Cade Li * @since 2023/8/11 */ -public class SysApiResponse { +public class SysApiDto { @Data - public static class SysApiRolesResponse { + public static class SysApiRolesResDto { private Long id; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java index 468ea704..51bef0e4 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java @@ -20,7 +20,7 @@ public class SysLogDto { @AllArgsConstructor @NoArgsConstructor @Builder - public static class SysLogSaveDto { + public static class SysLogSaveReqDto { private String logType; diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java index 0cea36e6..44128c36 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java @@ -1,8 +1,8 @@ package com.github.cadecode.uniboot.framework.api.feignclient; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysApiDto.SysApiRolesResDto; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefixConst; import com.github.cadecode.uniboot.framework.api.consts.SvcNameConst; -import com.github.cadecode.uniboot.framework.api.response.SysApiResponse.SysApiRolesResponse; import org.springframework.cache.annotation.Cacheable; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -20,6 +20,6 @@ public interface SysApiClient { @Cacheable(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @PostMapping("system/api/list_roles_vo") - List listRolesVo(); + List listRolesResVo(); } diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java index 88d6de12..f4c2954b 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.framework.api.feignclient; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogSaveDto; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogSaveReqDto; import com.github.cadecode.uniboot.framework.api.consts.SvcNameConst; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -19,6 +19,6 @@ public interface SysLogClient { @PostMapping("system/log/save") - boolean save(@RequestBody @NotEmpty List dtoList); + boolean save(@RequestBody @NotEmpty List dtoList); } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java index 447d36c6..73031e2b 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java @@ -10,7 +10,7 @@ import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.handler.AbstractApiLogHandler; import com.github.cadecode.uniboot.common.plugin.log.model.BaseLogInfo; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogSaveDto; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogSaveReqDto; import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.api.feignclient.SysLogClient; import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; @@ -40,7 +40,7 @@ public class ApiLogHandler extends AbstractApiLogHandler { /** * 构造 LogInfo */ - public SysLogSaveDto generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogInfo) { + public SysLogSaveReqDto generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogInfo) { ApiLogger apiLogger = baseLogInfo.getApiLogger(); // 解析 user-agent String userAgentStr = ServletUtil.getHeader(baseLogInfo.getRequest(), HttpConst.HEAD_USER_AGENT, CharsetUtil.CHARSET_UTF_8); @@ -63,7 +63,7 @@ public SysLogSaveDto generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogI description = apiOperation.value(); } } - return SysLogSaveDto.builder() + return SysLogSaveReqDto.builder() .logType(apiLogger.type()) .classMethod(point.getSignature().getDeclaringTypeName() + '.' + point.getSignature().getName()) .exceptional(baseLogInfo.getExceptional()) @@ -92,7 +92,7 @@ public void save(ApiLogger apiLogger, Object o) { if (!apiLogger.enableSave()) { return; } - SysLogSaveDto dto = (SysLogSaveDto) o; + SysLogSaveReqDto dto = (SysLogSaveReqDto) o; if (!apiLogger.saveParams()) { dto.setRequestParams(null); } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/voter/DataBaseRoleVoter.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/voter/DataBaseRoleVoter.java index c80b04c7..449c155e 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/voter/DataBaseRoleVoter.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/voter/DataBaseRoleVoter.java @@ -1,8 +1,8 @@ package com.github.cadecode.uniboot.framework.base.security.voter; import cn.hutool.core.util.ObjectUtil; +import com.github.cadecode.uniboot.framework.api.bean.dto.SysApiDto.SysApiRolesResDto; import com.github.cadecode.uniboot.framework.api.feignclient.SysApiClient; -import com.github.cadecode.uniboot.framework.api.response.SysApiResponse.SysApiRolesResponse; import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import lombok.RequiredArgsConstructor; @@ -43,12 +43,12 @@ public int vote(Authentication authentication, Object object, Collection apiRolesResponseList = sysApiClient.listRolesVo(); + List apiRolesResponseList = sysApiClient.listRolesResVo(); // 获取用户角色 SysUserDetails sysUserDetails = SecurityUtil.getUserDetails(authentication); List roles = sysUserDetails.getRoles(); // 获取与 url 相同的配置,不存在与 url 相同配置则使用 spring mvc ant 风格匹配 - SysApiRolesResponse apiRolesResponse = apiRolesResponseList.stream() + SysApiRolesResDto apiRolesResponse = apiRolesResponseList.stream() .filter(api -> requestUrl.equals(api.getUrl())) .findFirst() .orElseGet(() -> { diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysApiVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysApiVo.java index 8619736a..6199ebb1 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysApiVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysApiVo.java @@ -1,10 +1,10 @@ package com.github.cadecode.uniboot.framework.svc.bean.vo; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import com.github.cadecode.uniboot.common.core.web.response.PageParams; +import lombok.*; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; import java.util.Date; import java.util.List; @@ -17,7 +17,30 @@ public class SysApiVo { @Data - public static class SysApiRolesVo { + @EqualsAndHashCode(callSuper = true) + public static class SysApiRolesReqVo extends PageParams { + private String url; + private String description; + } + + @Data + public static class SysApiUpdateReqVo { + @NotNull + private Long id; + private String url; + private String description; + } + + @Data + public static class SysApiAddReqVo { + @NotEmpty + private String url; + @NotEmpty + private String description; + } + + @Data + public static class SysApiRolesResVo { private Long id; @@ -38,7 +61,7 @@ public static class SysApiRolesVo { @AllArgsConstructor @NoArgsConstructor @Builder - public static class SysApiSwaggerVo { + public static class SysApiSwaggerResVo { private String url; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysDictVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysDictVo.java index fdb383a3..5d055cea 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysDictVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysDictVo.java @@ -1,7 +1,11 @@ package com.github.cadecode.uniboot.framework.svc.bean.vo; +import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; +import lombok.EqualsAndHashCode; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; import java.util.Date; /** @@ -13,7 +17,48 @@ public class SysDictVo { @Data - public static class SysDictPageVo { + @EqualsAndHashCode(callSuper = true) + public static class SysDictPageReqVo extends PageParams { + private String name; + private String type; + } + + @Data + public static class SysDictAddReqVo { + @NotEmpty + private String name; + @NotEmpty + private String type; + private String label; + @NotEmpty + private String value; + @NotNull + private Boolean defaultFlag; + private String description; + @NotNull + private Integer orderNum; + } + + @Data + public static class SysDictUpdateReqVo { + @NotNull + private Long id; + @NotEmpty + private String name; + @NotEmpty + private String type; + private String label; + @NotEmpty + private String value; + @NotNull + private Boolean defaultFlag; + private String description; + @NotNull + private Integer orderNum; + } + + @Data + public static class SysDictPageResVo { private Long id; private String name; private String type; @@ -28,7 +73,7 @@ public static class SysDictPageVo { } @Data - public static class SysDictGetByTypeVo { + public static class SysDictGetByTypeResVo { private Long id; private String name; private String type; @@ -39,7 +84,7 @@ public static class SysDictGetByTypeVo { } @Data - public static class SysDictSuggestVo { + public static class SysDictSuggestResVo { private String name; private String type; } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java index b14a664b..12cf130a 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java @@ -1,8 +1,11 @@ package com.github.cadecode.uniboot.framework.svc.bean.vo; +import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; +import lombok.EqualsAndHashCode; import java.util.Date; +import java.util.List; /** * 系统日志 VO @@ -12,8 +15,61 @@ */ public class SysLogVo { + + @Data + @EqualsAndHashCode(callSuper = true) + public static class SysLogPageReqVo extends PageParams { + + private Date startTime; + private Date endTime; + private List logTypeList; + private String url; + private String accessUser; + private Boolean exceptional; + + } + + @Data + public static class SysLogSaveReqVo { + + private String logType; + + private String url; + + private Boolean exceptional; + + private String accessUser; + + private String description; + + private String classMethod; + + private String threadId; + + private String threadName; + + private String ip; + + private String httpMethod; + + private String requestParams; + + private String result; + + private Long timeCost; + + private String os; + + private String browser; + + private String userAgent; + + private String traceId; + + } + @Data - public static class SysLogPageVo { + public static class SysLogPageResVo { private Long id; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysMenuVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysMenuVo.java index 38d3183c..612bc824 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysMenuVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysMenuVo.java @@ -1,7 +1,11 @@ package com.github.cadecode.uniboot.framework.svc.bean.vo; +import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; +import lombok.EqualsAndHashCode; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -15,7 +19,61 @@ public class SysMenuVo { @Data - public static class SysMenuTreeVo { + @EqualsAndHashCode(callSuper = true) + public static class SysMenuRolesReqVo extends PageParams { + private String routeName; + private String menuName; + private List roleIdList; + private Boolean enableFlag; + private Long parentId; + } + + @Data + public static class SysMenuUpdateEnableReqVo { + @NotNull + private Long id; + @NotNull + private Boolean enableFlag; + } + + @Data + public static class SysMenuUpdateReqVo { + @NotNull + private Long id; + private Long parentId; + @NotEmpty + private String routeName; + @NotEmpty + private String routePath; + private String componentPath; + @NotEmpty + private String menuName; + private String icon; + @NotNull + private Integer orderNum; + } + + @Data + public static class SysMenuAddReqVo { + private Long parentId; + @NotEmpty + private String routeName; + @NotEmpty + private String routePath; + private String componentPath; + @NotEmpty + private String menuName; + @NotNull + private Boolean leafFlag; + private String icon; + @NotNull + private Integer orderNum; + @NotNull + private Boolean enableFlag; + } + + @Data + public static class SysMenuTreeResVo { private Long id; private Long parentId; @@ -32,11 +90,11 @@ public static class SysMenuTreeVo { private String icon; - private List children = new ArrayList<>(); + private List children = new ArrayList<>(); } @Data - public static class SysMenuRolesVo { + public static class SysMenuRolesResVo { private Long id; private Long parentId; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysRoleVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysRoleVo.java index 7b68dbdd..5422b439 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysRoleVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysRoleVo.java @@ -1,7 +1,11 @@ package com.github.cadecode.uniboot.framework.svc.bean.vo; +import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; +import lombok.EqualsAndHashCode; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; import java.util.Date; import java.util.List; @@ -14,7 +18,41 @@ public class SysRoleVo { @Data - public static class SysRoleListVo { + public static class SysRoleMappingReqVo { + @NotNull + private Long id; + @NotNull + private Long roleId; + } + + @Data + @EqualsAndHashCode(callSuper = true) + public static class SysRoleUnionReqVo extends PageParams { + private String code; + private String name; + } + + @Data + public static class SysRoleUpdateReqVo { + @NotNull + private Long id; + private String code; + private String name; + private String description; + } + + @Data + public static class SysRoleAddReqVo { + @NotEmpty + private String code; + @NotEmpty + private String name; + @NotEmpty + private String description; + } + + @Data + public static class SysRoleListResVo { private Long id; @@ -32,7 +70,7 @@ public static class SysRoleListVo { } @Data - public static class SysRoleUnionVo { + public static class SysRoleUnionResVo { private Long id; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysUserVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysUserVo.java index 839ffc03..b6fad4a5 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysUserVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysUserVo.java @@ -1,12 +1,13 @@ package com.github.cadecode.uniboot.framework.svc.bean.vo; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeVo; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; +import com.github.cadecode.uniboot.common.core.web.response.PageParams; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeResVo; +import lombok.*; +import javax.validation.constraints.Email; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; import java.util.Date; import java.util.List; @@ -19,7 +20,77 @@ public class SysUserVo { @Data - public static class SysUserRolesVo { + public static class SysUserModifyInfoReqVo { + @NotEmpty + private String nickName; + private String phone; + @Email + private String mail; + private String sex; + } + + @Data + public static class SysUserModifyPassReqVo { + @NotEmpty + private String oldPass; + @NotEmpty + private String newPass; + @NotEmpty + private String confirmedPass; + } + + @Data + @EqualsAndHashCode(callSuper = true) + public static class SysUserRolesReqVo extends PageParams { + private String username; + private String nickName; + private List roleIdList; + private Boolean enableFlag; + } + + @Data + public static class SysUserUpdateEnableReqVo { + @NotNull + private Long id; + @NotNull + private Boolean enableFlag; + } + + @Data + public static class SysUserUpdateReqVo { + @NotNull + private Long id; + @NotEmpty + private String username; + @NotEmpty + private String nickName; + private String password; + private String phone; + @Email + private String mail; + @NotEmpty + private String sex; + } + + @Data + public static class SysUserAddReqVo { + @NotEmpty + private String username; + @NotEmpty + private String nickName; + @NotEmpty + private String password; + private String phone; + @Email + private String mail; + @NotEmpty + private String sex; + @NotNull + private Boolean enableFlag; + } + + @Data + public static class SysUserRolesResVo { private Long id; @@ -56,7 +127,7 @@ public static class SysUserRolesVo { @AllArgsConstructor @NoArgsConstructor @Builder - public static class SysUserInfoVo { - private List menuList; + public static class SysUserInfoResVo { + private List menuList; } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java index 51581b31..d30b04a4 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java @@ -6,10 +6,10 @@ import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.base.annotation.ApiInner; import com.github.cadecode.uniboot.framework.svc.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiSwaggerVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesResVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiSwaggerResVo; import com.github.cadecode.uniboot.framework.svc.convert.SysApiConvert; -import com.github.cadecode.uniboot.framework.svc.request.SysApiRequest; import com.github.cadecode.uniboot.framework.svc.service.SysApiService; import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.pagehelper.PageInfo; @@ -36,6 +36,9 @@ import java.util.Map; import java.util.stream.Collectors; +import static com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiAddReqVo; +import static com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiUpdateReqVo; + /** * API 管理 * @@ -61,24 +64,24 @@ public class SysApiController { @ApiOperation("查询API列表(带角色)") @PostMapping("page_roles_vo") - public PageResult pageRolesVo(@RequestBody @Valid SysApiRequest.SysApiRolesRequest request) { - PageInfo rolesVoPage = sysApiService.pageRolesVo(request); + public PageResult pageRolesVo(@RequestBody @Valid SysApiRolesReqVo reqVo) { + PageInfo rolesVoPage = sysApiService.pageRolesVo(reqVo); return new PageResult<>((int) rolesVoPage.getTotal(), rolesVoPage.getList()); } @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @ApiOperation("更新API") @PostMapping("update") - public boolean update(@RequestBody @Valid SysApiRequest.SysApiUpdateRequest request) { - SysApi po = SysApiConvert.INSTANCE.requestToPo(request); + public boolean update(@RequestBody @Valid SysApiUpdateReqVo reqVo) { + SysApi po = SysApiConvert.INSTANCE.voToPo(reqVo); return sysApiService.updateById(po); } @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @ApiOperation("添加API") @PostMapping("add") - public boolean add(@RequestBody @Valid SysApiRequest.SysApiAddRequest request) { - SysApi sysApi = SysApiConvert.INSTANCE.requestToPo(request); + public boolean add(@RequestBody @Valid SysApiAddReqVo reqVo) { + SysApi sysApi = SysApiConvert.INSTANCE.voToPo(reqVo); return sysApiService.save(sysApi); } @@ -93,13 +96,13 @@ public boolean delete(@RequestBody @NotEmpty List apiIdList) { @ApiOperation("获取API(带角色)byApiIds") @PostMapping("list_roles_vo_by_api_ids") - public List listRolesVoByApiIds(@RequestBody @NotEmpty List apiIdList) { + public List listRolesVoByApiIds(@RequestBody @NotEmpty List apiIdList) { return sysApiService.listRolesVoByApiIds(apiIdList); } @ApiOperation("获取全部接口及 swagger 注解") @PostMapping("list_swagger_vo") - public List listSwaggerVo() { + public List listSwaggerVo() { Map methodMap = handlerMapping.getHandlerMethods(); return methodMap.entrySet() .stream() @@ -114,18 +117,18 @@ public List listSwaggerVo() { if (ObjectUtil.isNotNull(operation)) { description = operation.value(); } - return SysApiSwaggerVo.builder().url(url).description(description).build(); + return SysApiSwaggerResVo.builder().url(url).description(description).build(); }) .filter(o -> ObjectUtil.isNotEmpty(o.getUrl())) .distinct() - .sorted(Comparator.comparing(SysApiSwaggerVo::getUrl)) + .sorted(Comparator.comparing(SysApiSwaggerResVo::getUrl)) .collect(Collectors.toList()); } @ApiInner(onlyClient = true) @ApiOperation("查询API列表-全部") @PostMapping("list_roles_vo") - public List listRolesVo() { + public List listRolesVo() { return sysApiService.listRolesVo(); } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java index 99eccb55..a5c43b86 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java @@ -4,11 +4,7 @@ import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.svc.bean.po.SysDict; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.SysDictGetByTypeVo; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.SysDictPageVo; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.SysDictSuggestVo; import com.github.cadecode.uniboot.framework.svc.convert.SysDictConvert; -import com.github.cadecode.uniboot.framework.svc.request.SysDictRequest; import com.github.cadecode.uniboot.framework.svc.service.SysDictService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -25,6 +21,8 @@ import java.util.List; import java.util.stream.Collectors; +import static com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.*; + /** * 日志管理 * @@ -44,28 +42,28 @@ public class SysDictController { @ApiOperation("查询列表") @PostMapping("page") - public PageResult page(@RequestBody @Valid SysDictRequest.SysDictPageRequest request) { - PageInfo pageInfo = PageHelper.startPage(request.getPageNumber(), request.getPageSize()) + public PageResult page(@RequestBody @Valid SysDictPageReqVo reqVo) { + PageInfo pageInfo = PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize()) .doSelectPageInfo(() -> sysDictService.lambdaQuery() - .likeRight(ObjectUtil.isNotEmpty(request.getName()), SysDict::getName, request.getName()) - .likeRight(ObjectUtil.isNotEmpty(request.getType()), SysDict::getType, request.getType()) + .likeRight(ObjectUtil.isNotEmpty(reqVo.getName()), SysDict::getName, reqVo.getName()) + .likeRight(ObjectUtil.isNotEmpty(reqVo.getType()), SysDict::getType, reqVo.getType()) .orderByDesc(SysDict::getCreateTime) .list()); - List voList = SysDictConvert.INSTANCE.poToPageVo(pageInfo.getList()); + List voList = SysDictConvert.INSTANCE.poToPageResVo(pageInfo.getList()); return new PageResult<>((int) pageInfo.getTotal(), voList); } @ApiOperation("添加") @PostMapping("add") - public boolean add(@RequestBody @Valid SysDictRequest.SysDictAddRequest request) { - SysDict po = SysDictConvert.INSTANCE.requestToPo(request); + public boolean add(@RequestBody @Valid SysDictAddReqVo reqVo) { + SysDict po = SysDictConvert.INSTANCE.voToPo(reqVo); return sysDictService.save(po); } @ApiOperation("更新") @PostMapping("update") - public boolean update(@RequestBody @Valid SysDictRequest.SysDictUpdateRequest request) { - SysDict po = SysDictConvert.INSTANCE.requestToPo(request); + public boolean update(@RequestBody @Valid SysDictUpdateReqVo reqVo) { + SysDict po = SysDictConvert.INSTANCE.voToPo(reqVo); return sysDictService.updateById(po); } @@ -77,25 +75,25 @@ public boolean delete(@RequestBody @NotEmpty List idList) { @ApiOperation("查询 ByType") @GetMapping("list_by_type") - public List listByType(@RequestParam String type) { + public List listByType(@RequestParam String type) { List dictList = sysDictService.lambdaQuery().eq(SysDict::getType, type).list(); - return SysDictConvert.INSTANCE.poToGetByTypeVo(dictList); + return SysDictConvert.INSTANCE.poToGetByTypeResVo(dictList); } @ApiOperation("查询 ByIds") @PostMapping("list_by_ids") - public List listByIds(@RequestBody @NotEmpty List idList) { + public List listByIds(@RequestBody @NotEmpty List idList) { List dictList = sysDictService.listByIds(idList); - return SysDictConvert.INSTANCE.poToPageVo(dictList); + return SysDictConvert.INSTANCE.poToPageResVo(dictList); } @ApiOperation("查询字典类型种类") @PostMapping("list_type") - public List listType() { + public List listType() { List dictList = sysDictService.lambdaQuery().select(SysDict::getName, SysDict::getType).list(); return dictList.stream() - .map(SysDictConvert.INSTANCE::poToSuggestVo) - .sorted(Comparator.comparing(SysDictSuggestVo::getType)) + .map(SysDictConvert.INSTANCE::poToSuggestResVo) + .sorted(Comparator.comparing(SysDictSuggestResVo::getType)) .distinct() .collect(Collectors.toList()); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java index 648a610e..8660bd4c 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java @@ -6,10 +6,9 @@ import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.base.annotation.ApiInner; import com.github.cadecode.uniboot.framework.svc.bean.po.SysLog; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogPageVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogPageResVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogSaveReqVo; import com.github.cadecode.uniboot.framework.svc.convert.SysLogConvert; -import com.github.cadecode.uniboot.framework.svc.request.SysLogRequest.SysLogPageRequest; -import com.github.cadecode.uniboot.framework.svc.request.SysLogRequest.SysLogSaveRequest; import com.github.cadecode.uniboot.framework.svc.service.SysLogService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -27,6 +26,8 @@ import javax.validation.constraints.NotEmpty; import java.util.List; +import static com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogPageReqVo; + /** * 日志管理 * @@ -46,18 +47,18 @@ public class SysLogController { @ApiOperation("查询列表") @PostMapping("page") - public PageResult page(@RequestBody @Valid SysLogPageRequest request) { - PageInfo pageInfo = PageHelper.startPage(request.getPageNumber(), request.getPageSize()) + public PageResult page(@RequestBody @Valid SysLogPageReqVo reqVo) { + PageInfo pageInfo = PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize()) .doSelectPageInfo(() -> logService.lambdaQuery() - .ge(ObjectUtil.isNotEmpty(request.getStartTime()), SysLog::getCreateTime, request.getStartTime()) - .le(ObjectUtil.isNotEmpty(request.getEndTime()), SysLog::getCreateTime, request.getEndTime()) - .in(ObjectUtil.isNotEmpty(request.getLogTypeList()), SysLog::getLogType, request.getLogTypeList()) - .likeRight(ObjectUtil.isNotEmpty(request.getAccessUser()), SysLog::getAccessUser, request.getAccessUser()) - .like(ObjectUtil.isNotEmpty(request.getUrl()), SysLog::getUrl, request.getUrl()) - .eq(ObjectUtil.isNotNull(request.getExceptional()), SysLog::getExceptional, BoolToIntTypeHandler.mapping(request.getExceptional())) + .ge(ObjectUtil.isNotEmpty(reqVo.getStartTime()), SysLog::getCreateTime, reqVo.getStartTime()) + .le(ObjectUtil.isNotEmpty(reqVo.getEndTime()), SysLog::getCreateTime, reqVo.getEndTime()) + .in(ObjectUtil.isNotEmpty(reqVo.getLogTypeList()), SysLog::getLogType, reqVo.getLogTypeList()) + .likeRight(ObjectUtil.isNotEmpty(reqVo.getAccessUser()), SysLog::getAccessUser, reqVo.getAccessUser()) + .like(ObjectUtil.isNotEmpty(reqVo.getUrl()), SysLog::getUrl, reqVo.getUrl()) + .eq(ObjectUtil.isNotNull(reqVo.getExceptional()), SysLog::getExceptional, BoolToIntTypeHandler.mapping(reqVo.getExceptional())) .orderByDesc(SysLog::getCreateTime) .list()); - List voList = SysLogConvert.INSTANCE.poToVo(pageInfo.getList()); + List voList = SysLogConvert.INSTANCE.poToVo(pageInfo.getList()); return new PageResult<>((int) pageInfo.getTotal(), voList); } @@ -70,8 +71,8 @@ public boolean delete(@RequestBody @NotEmpty List idList) { @ApiInner(onlyClient = true) @ApiOperation("添加") @PostMapping("save") - public boolean save(@RequestBody @NotEmpty List requestList) { - List poList = SysLogConvert.INSTANCE.requestToPo(requestList); + public boolean save(@RequestBody @NotEmpty List requestList) { + List poList = SysLogConvert.INSTANCE.voToPo(requestList); return logService.saveBatch(poList); } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java index 3c979004..ac71ec83 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysMenuController.java @@ -3,9 +3,7 @@ import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.svc.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesVo; import com.github.cadecode.uniboot.framework.svc.convert.SysMenuConvert; -import com.github.cadecode.uniboot.framework.svc.request.SysMenuRequest; import com.github.cadecode.uniboot.framework.svc.service.SysMenuService; import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.pagehelper.PageInfo; @@ -26,6 +24,8 @@ import java.util.List; import java.util.stream.Collectors; +import static com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.*; + /** * 菜单管理API * @@ -46,31 +46,31 @@ public class SysMenuController { @ApiOperation("查询菜单列表(带角色)") @PostMapping("page_roles_vo") - public PageResult pageRolesVo(@RequestBody @Valid SysMenuRequest.SysMenuRolesRequest request) { - PageInfo rolesVoPage = sysMenuService.pageRolesVo(request); + public PageResult pageRolesVo(@RequestBody @Valid SysMenuRolesReqVo reqVo) { + PageInfo rolesVoPage = sysMenuService.pageRolesVo(reqVo); return new PageResult<>((int) rolesVoPage.getTotal(), rolesVoPage.getList()); } @ApiOperation("更新菜单启用状态") @PostMapping("update_enable") - public boolean updateEnable(@RequestBody @Valid SysMenuRequest.SysMenuUpdateEnableRequest request) { + public boolean updateEnable(@RequestBody @Valid SysMenuUpdateEnableReqVo reqVo) { return sysMenuService.updateById(SysMenu.builder() - .id(request.getId()) - .enableFlag(request.getEnableFlag()) + .id(reqVo.getId()) + .enableFlag(reqVo.getEnableFlag()) .build()); } @ApiOperation("更新菜单") @PostMapping("update") - public boolean update(@RequestBody @Valid SysMenuRequest.SysMenuUpdateRequest request) { - SysMenu sysMenu = SysMenuConvert.INSTANCE.requestToPo(request); + public boolean update(@RequestBody @Valid SysMenuUpdateReqVo reqVo) { + SysMenu sysMenu = SysMenuConvert.INSTANCE.voPo(reqVo); return sysMenuService.updateById(sysMenu); } @ApiOperation("添加菜单") @PostMapping("add") - public boolean add(@RequestBody @Valid SysMenuRequest.SysMenuAddRequest request) { - SysMenu sysMenu = SysMenuConvert.INSTANCE.requestToPo(request); + public boolean add(@RequestBody @Valid SysMenuAddReqVo reqVo) { + SysMenu sysMenu = SysMenuConvert.INSTANCE.voPo(reqVo); return sysMenuService.save(sysMenu); } @@ -98,7 +98,7 @@ public boolean delete(@RequestBody @NotEmpty List menuIdList) { @ApiOperation("获取菜单(带角色)byMenuIds") @PostMapping("list_roles_vo_by_menu_ids") - public List listRolesVoByMenuIds(@RequestBody @NotEmpty List menuIdList) { + public List listRolesVoByMenuIds(@RequestBody @NotEmpty List menuIdList) { return sysMenuService.listRolesVoByMenuIds(menuIdList); } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java index 0310c51d..aed753ea 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java @@ -4,11 +4,8 @@ import com.github.cadecode.uniboot.framework.api.consts.KeyPrefixConst; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.svc.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleListVo; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo; import com.github.cadecode.uniboot.framework.svc.convert.SysRoleConvert; -import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest; -import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleMappingRequest; import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; @@ -27,6 +24,8 @@ import javax.validation.constraints.NotEmpty; import java.util.List; +import static com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.*; + /** * 角色管理API * @@ -46,73 +45,73 @@ public class SysRoleController { @ApiOperation("查询角色列表") @PostMapping("list") - public List roleList() { + public List roleList() { List roleList = sysRoleService.list(); - return SysRoleConvert.INSTANCE.poToListVo(roleList); + return SysRoleConvert.INSTANCE.poToListResVo(roleList); } @ApiOperation("添加用户角色绑定") @PostMapping("add_user_mapping") - public boolean addUserMapping(@RequestBody @NotEmpty List request) { - return sysRoleService.addRoleUser(request) > 0; + public boolean addUserMapping(@RequestBody @NotEmpty List reqVoList) { + return sysRoleService.addRoleUser(reqVoList) > 0; } @ApiOperation("删除用户角色绑定") @PostMapping("remove_user_mapping") - public boolean removeUserMapping(@RequestBody @NotEmpty List request) { - return sysRoleService.removeRoleUser(request) > 0; + public boolean removeUserMapping(@RequestBody @NotEmpty List reqVoList) { + return sysRoleService.removeRoleUser(reqVoList) > 0; } @ApiOperation("添加菜单角色绑定") @PostMapping("add_menu_mapping") - public boolean addMenuMapping(@RequestBody @NotEmpty List request) { - return sysRoleService.addRoleMenu(request) > 0; + public boolean addMenuMapping(@RequestBody @NotEmpty List reqVoList) { + return sysRoleService.addRoleMenu(reqVoList) > 0; } @ApiOperation("删除菜单角色绑定") @PostMapping("remove_menu_mapping") - public boolean removeMenuMapping(@RequestBody @NotEmpty List request) { - return sysRoleService.removeRoleMenu(request) > 0; + public boolean removeMenuMapping(@RequestBody @NotEmpty List reqVoList) { + return sysRoleService.removeRoleMenu(reqVoList) > 0; } @ApiOperation("添加API角色绑定") @PostMapping("add_api_mapping") - public boolean addApiMapping(@RequestBody @NotEmpty List request) { - return sysRoleService.addRoleApi(request) > 0; + public boolean addApiMapping(@RequestBody @NotEmpty List reqVoList) { + return sysRoleService.addRoleApi(reqVoList) > 0; } @ApiOperation("删除API角色绑定") @PostMapping("remove_api_mapping") - public boolean removeApiMapping(@RequestBody @NotEmpty List request) { - return sysRoleService.removeRoleApi(request) > 0; + public boolean removeApiMapping(@RequestBody @NotEmpty List reqVoList) { + return sysRoleService.removeRoleApi(reqVoList) > 0; } @ApiOperation("查询角色列表(带菜单、api)") @PostMapping("page_union_vo") - public PageResult pageUnionVo(@RequestBody @Valid SysRoleRequest.SysRoleUnionRequest request) { - PageInfo page = sysRoleService.pageUnionVo(request); + public PageResult pageUnionVo(@RequestBody @Valid SysRoleUnionReqVo reqVo) { + PageInfo page = sysRoleService.pageUnionVo(reqVo); return new PageResult<>((int) page.getTotal(), page.getList()); } @ApiOperation("查询角色列表(带菜单、api)byRoleIds") @PostMapping("list_union_vo_by_role_ids") - public List listUnionVoByRoleIds(@RequestBody @NotEmpty List roleIds) { + public List listUnionVoByRoleIds(@RequestBody @NotEmpty List roleIds) { return sysRoleService.listUnionVoByRoleIds(roleIds); } @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @ApiOperation("更新角色") @PostMapping("update") - public boolean update(@RequestBody @Valid SysRoleRequest.SysRoleUpdateRequest request) { - SysRole po = SysRoleConvert.INSTANCE.requestToPo(request); + public boolean update(@RequestBody @Valid SysRoleVo.SysRoleUpdateReqVo reqVo) { + SysRole po = SysRoleConvert.INSTANCE.voToPo(reqVo); return sysRoleService.updateById(po); } @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @ApiOperation("添加角色") @PostMapping("add") - public boolean add(@RequestBody @Valid SysRoleRequest.SysRoleAddRequest request) { - SysRole sysRole = SysRoleConvert.INSTANCE.requestToPo(request); + public boolean add(@RequestBody @Valid SysRoleAddReqVo reqVo) { + SysRole sysRole = SysRoleConvert.INSTANCE.voToPo(reqVo); return sysRoleService.save(sysRole); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java index d7061db0..0b7c922b 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java @@ -7,11 +7,10 @@ import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import com.github.cadecode.uniboot.framework.svc.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeVo; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserInfoVo; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeResVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.*; import com.github.cadecode.uniboot.framework.svc.convert.SysUserConvert; -import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest; import com.github.cadecode.uniboot.framework.svc.service.SysMenuService; import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.cadecode.uniboot.framework.svc.service.SysUserService; @@ -58,31 +57,31 @@ public class SysUserController { */ @ApiOperation("获取用户信息") @PostMapping("get_info") - public SysUserInfoVo getInfo() { + public SysUserInfoResVo getInfo() { SysUserDetails userDetails = SecurityUtil.getUserDetails(null); - List sysMenuTreeVos = sysMenuService.listTreeVoByRoles(userDetails.getRoles()); - return SysUserInfoVo.builder().menuList(sysMenuTreeVos).build(); + List sysMenuTreeResVos = sysMenuService.listTreeVoByRoles(userDetails.getRoles()); + return SysUserInfoResVo.builder().menuList(sysMenuTreeResVos).build(); } @ApiOperation("修改用户信息(用户中心)") @PostMapping("modify_info") - public boolean modifyInfo(@RequestBody @Valid SysUserRequest.SysUserModifyInfoRequest request) { + public boolean modifyInfo(@RequestBody @Valid SysUserModifyInfoReqVo reqVo) { SysUserDetails userDetails = SecurityUtil.getUserDetails(null); - SysUser po = SysUserConvert.INSTANCE.requestToPo(request); + SysUser po = SysUserConvert.INSTANCE.voToPo(reqVo); po.setId(userDetails.getId()); return sysUserService.updateById(po); } @ApiOperation("修改用户密码(用户中心)") @PostMapping("modify_pass") - public boolean modifyPass(@RequestBody @Valid SysUserRequest.SysUserModifyPassRequest request) { + public boolean modifyPass(@RequestBody @Valid SysUserModifyPassReqVo reqVo) { SysUserDetails userDetails = SecurityUtil.getUserDetails(null); SysUser sysUser = sysUserService.lambdaQuery().select(SysUser::getPassword) .eq(SysUser::getId, userDetails.getId()).one(); - if (ObjectUtil.notEqual(request.getNewPass(), request.getConfirmedPass())) { + if (ObjectUtil.notEqual(reqVo.getNewPass(), reqVo.getConfirmedPass())) { throw ApiException.of("新密码和确认密码不一致"); } - if (!passwordEncoder.matches(request.getOldPass(), sysUser.getPassword())) { + if (!passwordEncoder.matches(reqVo.getOldPass(), sysUser.getPassword())) { throw ApiException.of("原密码错误"); } return sysUserService.lambdaUpdate() @@ -91,45 +90,45 @@ public boolean modifyPass(@RequestBody @Valid SysUserRequest.SysUserModifyPassRe .password(sysUser.getPassword()) .build()) .update(SysUser.builder() - .password(passwordEncoder.encode(request.getNewPass())) + .password(passwordEncoder.encode(reqVo.getNewPass())) .build()); } @ApiOperation("查询用户列表(带角色)") @PostMapping("page_roles_vo") - public PageResult pageRolesVo(@RequestBody @Valid SysUserRequest.SysUserRolesRequest request) { - PageInfo rolesVoPage = sysUserService.pageRolesVo(request); + public PageResult pageRolesVo(@RequestBody @Valid SysUserRolesReqVo reqVo) { + PageInfo rolesVoPage = sysUserService.pageRolesVo(reqVo); return new PageResult<>((int) rolesVoPage.getTotal(), rolesVoPage.getList()); } @ApiOperation("更新用户启用状态") @PostMapping("update_enable") - public boolean updateEnable(@RequestBody @Valid SysUserRequest.SysUserUpdateEnableRequest request) { + public boolean updateEnable(@RequestBody @Valid SysUserUpdateEnableReqVo reqVo) { return sysUserService.updateById(SysUser.builder() - .id(request.getId()) - .enableFlag(request.getEnableFlag()) + .id(reqVo.getId()) + .enableFlag(reqVo.getEnableFlag()) .build()); } @ApiOperation("更新用户") @PostMapping("update") - public boolean update(@RequestBody @Valid SysUserRequest.SysUserUpdateRequest request) { + public boolean update(@RequestBody @Valid SysUserVo.SysUserUpdateReqVo reqVo) { String encodePass = null; - if (ObjectUtil.isNotEmpty(request.getPassword())) { - encodePass = passwordEncoder.encode(request.getPassword()); + if (ObjectUtil.isNotEmpty(reqVo.getPassword())) { + encodePass = passwordEncoder.encode(reqVo.getPassword()); } - SysUser po = SysUserConvert.INSTANCE.requestToPo(request); + SysUser po = SysUserConvert.INSTANCE.voToPo(reqVo); po.setPassword(encodePass); return sysUserService.updateById(po); } @ApiOperation("添加用户") @PostMapping("add") - public boolean add(@RequestBody @Valid SysUserRequest.SysUserAddRequest request) { - if (ObjectUtil.isNotEmpty(request.getPassword())) { - request.setPassword(passwordEncoder.encode(request.getPassword())); + public boolean add(@RequestBody @Valid SysUserAddReqVo reqVo) { + if (ObjectUtil.isNotEmpty(reqVo.getPassword())) { + reqVo.setPassword(passwordEncoder.encode(reqVo.getPassword())); } - SysUser sysUser = SysUserConvert.INSTANCE.requestToPo(request); + SysUser sysUser = SysUserConvert.INSTANCE.voToPo(reqVo); return sysUserService.save(sysUser); } @@ -144,7 +143,7 @@ public boolean delete(@RequestBody @NotEmpty List userIdList) { @ApiOperation("获取用户(带角色)byUserIds") @PostMapping("list_roles_vo_by_user_ids") - public List listRolesVoByUserIds(@RequestBody @NotEmpty List userIdList) { + public List listRolesVoByUserIds(@RequestBody @NotEmpty List userIdList) { return sysUserService.listRolesVoByUserIds(userIdList); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysApiConvert.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysApiConvert.java index f43ec282..2ed17ae7 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysApiConvert.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysApiConvert.java @@ -1,8 +1,8 @@ package com.github.cadecode.uniboot.framework.svc.convert; import com.github.cadecode.uniboot.framework.svc.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.svc.request.SysApiRequest.SysApiAddRequest; -import com.github.cadecode.uniboot.framework.svc.request.SysApiRequest.SysApiUpdateRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiAddReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiUpdateReqVo; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @@ -21,12 +21,12 @@ public interface SysApiConvert { @Mapping(target = "updateUser", ignore = true) @Mapping(target = "updateTime", ignore = true) @Mapping(target = "createTime", ignore = true) - SysApi requestToPo(SysApiUpdateRequest request); + SysApi voToPo(SysApiUpdateReqVo reqVo); @Mapping(target = "updateUser", ignore = true) @Mapping(target = "updateTime", ignore = true) @Mapping(target = "id", ignore = true) @Mapping(target = "createTime", ignore = true) - SysApi requestToPo(SysApiAddRequest request); + SysApi voToPo(SysApiAddReqVo reqVo); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysDictConvert.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysDictConvert.java index 120bbde1..5813fa45 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysDictConvert.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysDictConvert.java @@ -1,11 +1,7 @@ package com.github.cadecode.uniboot.framework.svc.convert; import com.github.cadecode.uniboot.framework.svc.bean.po.SysDict; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.SysDictGetByTypeVo; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.SysDictPageVo; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.SysDictSuggestVo; -import com.github.cadecode.uniboot.framework.svc.request.SysDictRequest.SysDictAddRequest; -import com.github.cadecode.uniboot.framework.svc.request.SysDictRequest.SysDictUpdateRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysDictVo.*; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @@ -22,20 +18,20 @@ public interface SysDictConvert { SysDictConvert INSTANCE = Mappers.getMapper(SysDictConvert.class); - List poToPageVo(List records); + List poToPageResVo(List records); @Mapping(target = "updateUser", ignore = true) @Mapping(target = "updateTime", ignore = true) @Mapping(target = "id", ignore = true) @Mapping(target = "createTime", ignore = true) - SysDict requestToPo(SysDictAddRequest request); + SysDict voToPo(SysDictAddReqVo reqVo); @Mapping(target = "updateUser", ignore = true) @Mapping(target = "updateTime", ignore = true) @Mapping(target = "createTime", ignore = true) - SysDict requestToPo(SysDictUpdateRequest request); + SysDict voToPo(SysDictUpdateReqVo reqVo); - List poToGetByTypeVo(List dictList); + List poToGetByTypeResVo(List dictList); - SysDictSuggestVo poToSuggestVo(SysDict po); + SysDictSuggestResVo poToSuggestResVo(SysDict po); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysLogConvert.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysLogConvert.java index b14794b2..c71a4f3b 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysLogConvert.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysLogConvert.java @@ -1,8 +1,8 @@ package com.github.cadecode.uniboot.framework.svc.convert; import com.github.cadecode.uniboot.framework.svc.bean.po.SysLog; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogPageVo; -import com.github.cadecode.uniboot.framework.svc.request.SysLogRequest.SysLogSaveRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogPageResVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogSaveReqVo; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -19,7 +19,7 @@ public interface SysLogConvert { SysLogConvert INSTANCE = Mappers.getMapper(SysLogConvert.class); - List poToVo(List records); + List poToVo(List records); - List requestToPo(List requestList); + List voToPo(List requestList); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysMenuConvert.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysMenuConvert.java index 1517f8ef..19b7f476 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysMenuConvert.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysMenuConvert.java @@ -1,9 +1,9 @@ package com.github.cadecode.uniboot.framework.svc.convert; import com.github.cadecode.uniboot.framework.svc.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeVo; -import com.github.cadecode.uniboot.framework.svc.request.SysMenuRequest.SysMenuAddRequest; -import com.github.cadecode.uniboot.framework.svc.request.SysMenuRequest.SysMenuUpdateRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuAddReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeResVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuUpdateReqVo; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @@ -20,19 +20,19 @@ public interface SysMenuConvert { SysMenuConvert INSTANCE = Mappers.getMapper(SysMenuConvert.class); @Mapping(target = "children", ignore = true) - SysMenuTreeVo toTreeVo(SysMenu sysMenu); + SysMenuTreeResVo poToTreeResVo(SysMenu sysMenu); @Mapping(target = "updateUser", ignore = true) @Mapping(target = "updateTime", ignore = true) @Mapping(target = "leafFlag", ignore = true) @Mapping(target = "enableFlag", ignore = true) @Mapping(target = "createTime", ignore = true) - SysMenu requestToPo(SysMenuUpdateRequest request); + SysMenu voPo(SysMenuUpdateReqVo reqVo); @Mapping(target = "updateUser", ignore = true) @Mapping(target = "updateTime", ignore = true) @Mapping(target = "id", ignore = true) @Mapping(target = "createTime", ignore = true) - SysMenu requestToPo(SysMenuAddRequest request); + SysMenu voPo(SysMenuAddReqVo reqVo); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysRoleConvert.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysRoleConvert.java index d0f1a6cd..4e221d02 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysRoleConvert.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysRoleConvert.java @@ -1,9 +1,9 @@ package com.github.cadecode.uniboot.framework.svc.convert; import com.github.cadecode.uniboot.framework.svc.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleListVo; -import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleAddRequest; -import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleUpdateRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleAddReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleListResVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUpdateReqVo; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @@ -21,18 +21,18 @@ public interface SysRoleConvert { SysRoleConvert INSTANCE = Mappers.getMapper(SysRoleConvert.class); - SysRoleListVo poToListVo(SysRole po); + SysRoleListResVo poToListResVo(SysRole po); - List poToListVo(List po); + List poToListResVo(List po); @Mapping(target = "updateUser", ignore = true) @Mapping(target = "updateTime", ignore = true) @Mapping(target = "createTime", ignore = true) - SysRole requestToPo(SysRoleUpdateRequest request); + SysRole voToPo(SysRoleUpdateReqVo reqVo); @Mapping(target = "updateUser", ignore = true) @Mapping(target = "updateTime", ignore = true) @Mapping(target = "id", ignore = true) @Mapping(target = "createTime", ignore = true) - SysRole requestToPo(SysRoleAddRequest request); + SysRole voToPo(SysRoleAddReqVo reqVo); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysUserConvert.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysUserConvert.java index 22313c02..3c7d469b 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysUserConvert.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysUserConvert.java @@ -2,10 +2,10 @@ import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.svc.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesVo; -import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest.SysUserAddRequest; -import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest.SysUserModifyInfoRequest; -import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest.SysUserUpdateRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserAddReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserModifyInfoReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesResVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserUpdateReqVo; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; @@ -21,7 +21,7 @@ public interface SysUserConvert { SysUserConvert INSTANCE = Mappers.getMapper(SysUserConvert.class); - SysUserDetails voToSysUserDetails(SysUserRolesVo vo); + SysUserDetails voToSysUserDetails(SysUserRolesResVo vo); @Mapping(target = "updateUser", ignore = true) @Mapping(target = "updateTime", ignore = true) @@ -29,7 +29,7 @@ public interface SysUserConvert { @Mapping(target = "loginDate", ignore = true) @Mapping(target = "id", ignore = true) @Mapping(target = "createTime", ignore = true) - SysUser requestToPo(SysUserAddRequest request); + SysUser voToPo(SysUserAddReqVo reqVo); @Mapping(target = "username", ignore = true) @Mapping(target = "updateUser", ignore = true) @@ -40,7 +40,7 @@ public interface SysUserConvert { @Mapping(target = "id", ignore = true) @Mapping(target = "enableFlag", ignore = true) @Mapping(target = "createTime", ignore = true) - SysUser requestToPo(SysUserModifyInfoRequest request); + SysUser voToPo(SysUserModifyInfoReqVo reqVo); @Mapping(target = "updateUser", ignore = true) @Mapping(target = "updateTime", ignore = true) @@ -48,5 +48,5 @@ public interface SysUserConvert { @Mapping(target = "loginDate", ignore = true) @Mapping(target = "enableFlag", ignore = true) @Mapping(target = "createTime", ignore = true) - SysUser requestToPo(SysUserUpdateRequest request); + SysUser voToPo(SysUserUpdateReqVo reqVo); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysApiMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysApiMapper.java index 34b39ac3..86275611 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysApiMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysApiMapper.java @@ -2,8 +2,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.cadecode.uniboot.framework.svc.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.svc.request.SysApiRequest.SysApiRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesResVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -18,7 +18,7 @@ @Mapper public interface SysApiMapper extends BaseMapper { - List selectRolesVoByApiIds(@Param("apiIds") List apiIds); + List selectRolesVoByApiIds(@Param("apiIds") List apiIds); - List selectRolesVo(@Param("request") SysApiRolesRequest request); + List selectRolesVo(@Param("req") SysApiRolesReqVo reqVo); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysMenuMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysMenuMapper.java index f745866b..99b06a29 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysMenuMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysMenuMapper.java @@ -2,8 +2,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.cadecode.uniboot.framework.svc.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesVo; -import com.github.cadecode.uniboot.framework.svc.request.SysMenuRequest.SysMenuRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesResVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -20,8 +20,8 @@ public interface SysMenuMapper extends BaseMapper { List selectByRoles(@Param("roleCodes") List roleCodes); - List selectRolesVo(@Param("request") SysMenuRolesRequest request); + List selectRolesVo(@Param("req") SysMenuRolesReqVo reqVo); - List selectRolesVoByMenuIds(@Param("menuIds") List menuIds); + List selectRolesVoByMenuIds(@Param("menuIds") List menuIds); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysRoleMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysRoleMapper.java index 384fe688..755d00df 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysRoleMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysRoleMapper.java @@ -2,9 +2,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.cadecode.uniboot.framework.svc.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionVo; -import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleMappingRequest; -import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleUnionRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleMappingReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionResVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -37,20 +37,20 @@ public interface SysRoleMapper extends BaseMapper { int deleteRoleApiByRoleIds(@Param("roleIds") List roleIds); - int deleteRoleUser(List list); + int deleteRoleUser(List list); - int deleteRoleMenu(List list); + int deleteRoleMenu(List list); - int deleteRoleApi(List list); + int deleteRoleApi(List list); - int insertRoleUser(List list); + int insertRoleUser(List list); - int insertRoleMenu(List list); + int insertRoleMenu(List list); - int insertRoleApi(List list); + int insertRoleApi(List list); - List selectRolesVo(@Param("request") SysRoleUnionRequest request); + List selectUnionVo(@Param("req") SysRoleUnionReqVo reqVo); - List selectRolesVoByRoleIds(@Param("roleIds") List roleIds); + List selectUnionVoByRoleIds(@Param("roleIds") List roleIds); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysUserMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysUserMapper.java index 29581f8d..63467278 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysUserMapper.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysUserMapper.java @@ -2,8 +2,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.github.cadecode.uniboot.framework.svc.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesVo; -import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest.SysUserRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesResVo; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -18,10 +18,10 @@ @Mapper public interface SysUserMapper extends BaseMapper { - List selectRolesVoByUserIds(@Param("userIds") List userIds); + List selectRolesVoByUserIds(@Param("userIds") List userIds); - List selectRolesVoByUsername(@Param("username") String username); + List selectRolesVoByUsername(@Param("username") String username); - List selectRolesVo(@Param("request") SysUserRolesRequest request); + List selectRolesVo(@Param("req") SysUserRolesReqVo reqVo); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysApiRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysApiRequest.java deleted file mode 100644 index 5135cf79..00000000 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysApiRequest.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.github.cadecode.uniboot.framework.svc.request; - -import com.github.cadecode.uniboot.common.core.web.response.PageParams; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 系统API请求对象 - * - * @author Cade Li - * @date 2023/5/14 - */ -public class SysApiRequest { - - @Data - public static class SysApiRolesRequest extends PageParams { - private String url; - private String description; - } - - @Data - public static class SysApiUpdateRequest { - @NotNull - private Long id; - private String url; - private String description; - } - - @Data - public static class SysApiAddRequest { - @NotEmpty - private String url; - @NotEmpty - private String description; - } -} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysDictRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysDictRequest.java deleted file mode 100644 index 87be7cc2..00000000 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysDictRequest.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.github.cadecode.uniboot.framework.svc.request; - -import com.github.cadecode.uniboot.common.core.web.response.PageParams; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 系统字典 请求 - * - * @author Cade Li - * @date 2023/6/11 - */ -public class SysDictRequest { - - @Data - public static class SysDictPageRequest extends PageParams { - private String name; - private String type; - } - - @Data - public static class SysDictAddRequest { - @NotEmpty - private String name; - @NotEmpty - private String type; - private String label; - @NotEmpty - private String value; - @NotNull - private Boolean defaultFlag; - private String description; - @NotNull - private Integer orderNum; - } - - @Data - public static class SysDictUpdateRequest { - @NotNull - private Long id; - @NotEmpty - private String name; - @NotEmpty - private String type; - private String label; - @NotEmpty - private String value; - @NotNull - private Boolean defaultFlag; - private String description; - @NotNull - private Integer orderNum; - } -} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java deleted file mode 100644 index 0d38f971..00000000 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysLogRequest.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.github.cadecode.uniboot.framework.svc.request; - -import com.github.cadecode.uniboot.common.core.web.response.PageParams; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.Date; -import java.util.List; - -/** - * 系统日志请求对象 - * - * @author Cade Li - * @since 2023/5/26 - */ -public class SysLogRequest { - - @Data - @EqualsAndHashCode(callSuper = true) - public static class SysLogPageRequest extends PageParams { - - private Date startTime; - private Date endTime; - private List logTypeList; - private String url; - private String accessUser; - private Boolean exceptional; - - } - - @Data - public static class SysLogSaveRequest { - - private String logType; - - private String url; - - private Boolean exceptional; - - private String accessUser; - - private String description; - - private String classMethod; - - private String threadId; - - private String threadName; - - private String ip; - - private String httpMethod; - - private String requestParams; - - private String result; - - private Long timeCost; - - private String os; - - private String browser; - - private String userAgent; - - private String traceId; - - } -} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysMenuRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysMenuRequest.java deleted file mode 100644 index 21a52348..00000000 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysMenuRequest.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.github.cadecode.uniboot.framework.svc.request; - -import com.github.cadecode.uniboot.common.core.web.response.PageParams; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 菜单请求体 - * - * @author Cade Li - * @since 2023/5/5 - */ -public class SysMenuRequest { - - @Data - @EqualsAndHashCode(callSuper = true) - public static class SysMenuRolesRequest extends PageParams { - private String routeName; - private String menuName; - private List roleIdList; - private Boolean enableFlag; - private Long parentId; - } - - @Data - public static class SysMenuUpdateEnableRequest{ - @NotNull - private Long id; - @NotNull - private Boolean enableFlag; - } - - @Data - public static class SysMenuUpdateRequest{ - @NotNull - private Long id; - private Long parentId; - @NotEmpty - private String routeName; - @NotEmpty - private String routePath; - private String componentPath; - @NotEmpty - private String menuName; - private String icon; - @NotNull - private Integer orderNum; - } - - @Data - public static class SysMenuAddRequest{ - private Long parentId; - @NotEmpty - private String routeName; - @NotEmpty - private String routePath; - private String componentPath; - @NotEmpty - private String menuName; - @NotNull - private Boolean leafFlag; - private String icon; - @NotNull - private Integer orderNum; - @NotNull - private Boolean enableFlag; - } -} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysRoleRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysRoleRequest.java deleted file mode 100644 index 011426fd..00000000 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysRoleRequest.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.github.cadecode.uniboot.framework.svc.request; - -import com.github.cadecode.uniboot.common.core.web.response.PageParams; -import lombok.Data; - -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; - -/** - * 角色请求对象 - * - * @author Cade Li - * @since 2023/5/4 - */ -public class SysRoleRequest { - - @Data - public static class SysRoleMappingRequest { - @NotNull - private Long id; - @NotNull - private Long roleId; - } - - @Data - public static class SysRoleUnionRequest extends PageParams { - private String code; - private String name; - } - - @Data - public static class SysRoleUpdateRequest { - @NotNull - private Long id; - private String code; - private String name; - private String description; - } - - @Data - public static class SysRoleAddRequest { - @NotEmpty - private String code; - @NotEmpty - private String name; - @NotEmpty - private String description; - } -} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysUserRequest.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysUserRequest.java deleted file mode 100644 index 776f6baf..00000000 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/request/SysUserRequest.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.github.cadecode.uniboot.framework.svc.request; - -import com.github.cadecode.uniboot.common.core.web.response.PageParams; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import javax.validation.constraints.Email; -import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -import java.util.List; - -/** - * 系统用户请求对象 - * - * @author Cade Li - * @since 2023/4/22 - */ -public class SysUserRequest { - - @Data - public static class SysUserModifyInfoRequest{ - @NotEmpty - private String nickName; - private String phone; - @Email - private String mail; - private String sex; - } - - @Data - public static class SysUserModifyPassRequest{ - @NotEmpty - private String oldPass; - @NotEmpty - private String newPass; - @NotEmpty - private String confirmedPass; - } - - @Data - @EqualsAndHashCode(callSuper = true) - public static class SysUserRolesRequest extends PageParams { - private String username; - private String nickName; - private List roleIdList; - private Boolean enableFlag; - } - - @Data - public static class SysUserUpdateEnableRequest{ - @NotNull - private Long id; - @NotNull - private Boolean enableFlag; - } - - @Data - public static class SysUserUpdateRequest{ - @NotNull - private Long id; - @NotEmpty - private String username; - @NotEmpty - private String nickName; - private String password; - private String phone; - @Email - private String mail; - @NotEmpty - private String sex; - } - - @Data - public static class SysUserAddRequest{ - @NotEmpty - private String username; - @NotEmpty - private String nickName; - @NotEmpty - private String password; - private String phone; - @Email - private String mail; - @NotEmpty - private String sex; - @NotNull - private Boolean enableFlag; - } -} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysApiService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysApiService.java index 5e43048c..608e8c40 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysApiService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysApiService.java @@ -2,8 +2,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.github.cadecode.uniboot.framework.svc.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesVo; -import com.github.cadecode.uniboot.framework.svc.request.SysApiRequest.SysApiRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesResVo; import com.github.pagehelper.PageInfo; import java.util.List; @@ -16,11 +16,11 @@ */ public interface SysApiService extends IService { - List listRolesVo(); + List listRolesVo(); - List listRolesVoByApiIds(List userIds); + List listRolesVoByApiIds(List userIds); - List listRolesVo(SysApiRolesRequest request); + List listRolesVo(SysApiRolesReqVo reqVo); - PageInfo pageRolesVo(SysApiRolesRequest request); + PageInfo pageRolesVo(SysApiRolesReqVo reqVo); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysMenuService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysMenuService.java index 820f40ff..6daabffc 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysMenuService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysMenuService.java @@ -2,9 +2,9 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.github.cadecode.uniboot.framework.svc.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesVo; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeVo; -import com.github.cadecode.uniboot.framework.svc.request.SysMenuRequest.SysMenuRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesResVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeResVo; import com.github.pagehelper.PageInfo; import java.util.List; @@ -19,12 +19,12 @@ public interface SysMenuService extends IService { List listByRoles(List roleCodes); - List listTreeVoByRoles(List roleCodes); + List listTreeVoByRoles(List roleCodes); - List listRolesVo(SysMenuRolesRequest request); + List listRolesVo(SysMenuRolesReqVo reqVo); - PageInfo pageRolesVo(SysMenuRolesRequest request); + PageInfo pageRolesVo(SysMenuRolesReqVo reqVo); - List listRolesVoByMenuIds(List menuIds); + List listRolesVoByMenuIds(List menuIds); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysRoleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysRoleService.java index 6edadefc..7a6e0660 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysRoleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysRoleService.java @@ -2,9 +2,9 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.github.cadecode.uniboot.framework.svc.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionVo; -import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleMappingRequest; -import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleUnionRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleMappingReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionResVo; import com.github.pagehelper.PageInfo; import java.util.List; @@ -35,21 +35,21 @@ public interface SysRoleService extends IService { int removeRoleApiByRoleIds(List roleIds); - int removeRoleUser(List list); + int removeRoleUser(List list); - int removeRoleMenu(List list); + int removeRoleMenu(List list); - int removeRoleApi(List list); + int removeRoleApi(List list); - int addRoleUser(List list); + int addRoleUser(List list); - int addRoleMenu(List list); + int addRoleMenu(List list); - int addRoleApi(List list); + int addRoleApi(List list); - List listUnionVo(SysRoleUnionRequest request); + List listUnionVo(SysRoleUnionReqVo reqVo); - PageInfo pageUnionVo(SysRoleUnionRequest request); + PageInfo pageUnionVo(SysRoleUnionReqVo reqVo); - List listUnionVoByRoleIds(List roleIds); + List listUnionVoByRoleIds(List roleIds); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysUserService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysUserService.java index 363335db..124ea77b 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysUserService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysUserService.java @@ -2,8 +2,8 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.github.cadecode.uniboot.framework.svc.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesVo; -import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest.SysUserRolesRequest; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesResVo; import com.github.pagehelper.PageInfo; import org.springframework.security.core.userdetails.UserDetailsService; @@ -17,9 +17,9 @@ */ public interface SysUserService extends IService, UserDetailsService { - List listRolesVoByUserIds(List userIds); + List listRolesVoByUserIds(List userIds); - List listRolesVo(SysUserRolesRequest request); + List listRolesVo(SysUserRolesReqVo reqVo); - PageInfo pageRolesVo(SysUserRolesRequest request); + PageInfo pageRolesVo(SysUserRolesReqVo reqVo); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysApiServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysApiServiceImpl.java index 7ca9e1ef..72b5f654 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysApiServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysApiServiceImpl.java @@ -2,9 +2,9 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.cadecode.uniboot.framework.svc.bean.po.SysApi; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesResVo; import com.github.cadecode.uniboot.framework.svc.mapper.SysApiMapper; -import com.github.cadecode.uniboot.framework.svc.request.SysApiRequest.SysApiRolesRequest; import com.github.cadecode.uniboot.framework.svc.service.SysApiService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -26,23 +26,23 @@ public class SysApiServiceImpl extends ServiceImpl impleme private final SysApiMapper sysApiMapper; @Override - public List listRolesVo() { + public List listRolesVo() { return sysApiMapper.selectRolesVo(null); } @Override - public List listRolesVoByApiIds(List userIds) { + public List listRolesVoByApiIds(List userIds) { return sysApiMapper.selectRolesVoByApiIds(userIds); } @Override - public List listRolesVo(SysApiRolesRequest request) { - return sysApiMapper.selectRolesVo(request); + public List listRolesVo(SysApiRolesReqVo reqVo) { + return sysApiMapper.selectRolesVo(reqVo); } @Override - public PageInfo pageRolesVo(SysApiRolesRequest request) { - return PageHelper.startPage(request.getPageNumber(), request.getPageSize()) - .doSelectPageInfo(() -> listRolesVo(request)); + public PageInfo pageRolesVo(SysApiRolesReqVo reqVo) { + return PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize()) + .doSelectPageInfo(() -> listRolesVo(reqVo)); } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java index 3d7e401f..60947e90 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java @@ -3,11 +3,11 @@ import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.cadecode.uniboot.framework.svc.bean.po.SysMenu; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesVo; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesResVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuTreeResVo; import com.github.cadecode.uniboot.framework.svc.convert.SysMenuConvert; import com.github.cadecode.uniboot.framework.svc.mapper.SysMenuMapper; -import com.github.cadecode.uniboot.framework.svc.request.SysMenuRequest.SysMenuRolesRequest; import com.github.cadecode.uniboot.framework.svc.service.SysMenuService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -36,33 +36,33 @@ public List listByRoles(List roleCodes) { } @Override - public List listTreeVoByRoles(List roleCodes) { + public List listTreeVoByRoles(List roleCodes) { List sysMenus = listByRoles(roleCodes); - List menuTreeVoList = sysMenus.stream() + List menuTreeVoList = sysMenus.stream() .filter(m -> ObjectUtil.equal(m.getEnableFlag(), true)) - .map(SysMenuConvert.INSTANCE::toTreeVo) + .map(SysMenuConvert.INSTANCE::poToTreeResVo) .collect(Collectors.toList()); return generateMenuTree(menuTreeVoList, null); } @Override - public List listRolesVo(SysMenuRolesRequest request) { - return sysMenuMapper.selectRolesVo(request); + public List listRolesVo(SysMenuRolesReqVo reqVo) { + return sysMenuMapper.selectRolesVo(reqVo); } @Override - public PageInfo pageRolesVo(SysMenuRolesRequest request) { - return PageHelper.startPage(request.getPageNumber(), request.getPageSize()) - .doSelectPageInfo(() -> listRolesVo(request)); + public PageInfo pageRolesVo(SysMenuRolesReqVo reqVo) { + return PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize()) + .doSelectPageInfo(() -> listRolesVo(reqVo)); } @Override - public List listRolesVoByMenuIds(List menuIds) { + public List listRolesVoByMenuIds(List menuIds) { return sysMenuMapper.selectRolesVoByMenuIds(menuIds); } - private List generateMenuTree(List menus, Long rootId) { - List resultList = new ArrayList<>(); + private List generateMenuTree(List menus, Long rootId) { + List resultList = new ArrayList<>(); menus.forEach(menu -> { // 确定下父亲 if (ObjectUtil.notEqual(menu.getParentId(), rootId)) { @@ -74,7 +74,7 @@ private List generateMenuTree(List menus, Long roo return; } // 拿儿子列表 - List children = menu.getChildren(); + List children = menu.getChildren(); // 存儿子 m.setChildren(generateMenuTree(menus, m.getId())); children.add(m); diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java index ee14bfff..95a194a6 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java @@ -3,10 +3,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefixConst; import com.github.cadecode.uniboot.framework.svc.bean.po.SysRole; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleMappingReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionResVo; import com.github.cadecode.uniboot.framework.svc.mapper.SysRoleMapper; -import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleMappingRequest; -import com.github.cadecode.uniboot.framework.svc.request.SysRoleRequest.SysRoleUnionRequest; import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -76,50 +76,50 @@ public int removeRoleApiByRoleIds(List roleIds) { } @Override - public int removeRoleUser(List list) { + public int removeRoleUser(List list) { return sysRoleMapper.deleteRoleUser(list); } @Override - public int removeRoleMenu(List list) { + public int removeRoleMenu(List list) { return sysRoleMapper.deleteRoleMenu(list); } @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @Override - public int removeRoleApi(List list) { + public int removeRoleApi(List list) { return sysRoleMapper.deleteRoleApi(list); } @Override - public int addRoleUser(List list) { + public int addRoleUser(List list) { return sysRoleMapper.insertRoleUser(list); } @Override - public int addRoleMenu(List list) { + public int addRoleMenu(List list) { return sysRoleMapper.insertRoleMenu(list); } @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @Override - public int addRoleApi(List list) { + public int addRoleApi(List list) { return sysRoleMapper.insertRoleApi(list); } @Override - public List listUnionVo(SysRoleUnionRequest request) { - return sysRoleMapper.selectRolesVo(request); + public List listUnionVo(SysRoleUnionReqVo reqVo) { + return sysRoleMapper.selectUnionVo(reqVo); } @Override - public PageInfo pageUnionVo(SysRoleUnionRequest request) { - return PageHelper.startPage(request.getPageNumber(), request.getPageSize()) - .doSelectPageInfo(() -> listUnionVo(request)); + public PageInfo pageUnionVo(SysRoleUnionReqVo reqVo) { + return PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize()) + .doSelectPageInfo(() -> listUnionVo(reqVo)); } @Override - public List listUnionVoByRoleIds(List roleIds) { - return sysRoleMapper.selectRolesVoByRoleIds(roleIds); + public List listUnionVoByRoleIds(List roleIds) { + return sysRoleMapper.selectUnionVoByRoleIds(roleIds); } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java index 3e56d47f..5a1adfbf 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java @@ -4,10 +4,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.framework.svc.bean.po.SysUser; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesReqVo; +import com.github.cadecode.uniboot.framework.svc.bean.vo.SysUserVo.SysUserRolesResVo; import com.github.cadecode.uniboot.framework.svc.convert.SysUserConvert; import com.github.cadecode.uniboot.framework.svc.mapper.SysUserMapper; -import com.github.cadecode.uniboot.framework.svc.request.SysUserRequest.SysUserRolesRequest; import com.github.cadecode.uniboot.framework.svc.service.SysUserService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -34,12 +34,12 @@ public class SysUserServiceImpl extends ServiceImpl impl */ @Override public UserDetails loadUserByUsername(String username) { - List userRolesVoList = sysUserMapper.selectRolesVoByUsername(username); + List userRolesVoList = sysUserMapper.selectRolesVoByUsername(username); // 用户账户不存在 if (ObjectUtil.isEmpty(userRolesVoList)) { throw ApiException.of("该用户不存在"); } - SysUserRolesVo userRolesVo = userRolesVoList.get(0); + SysUserRolesResVo userRolesVo = userRolesVoList.get(0); // 用户账号被关闭 if (!userRolesVo.getEnableFlag()) { throw ApiException.of("账号已被关闭"); @@ -48,18 +48,18 @@ public UserDetails loadUserByUsername(String username) { } @Override - public List listRolesVoByUserIds(List userIds) { + public List listRolesVoByUserIds(List userIds) { return sysUserMapper.selectRolesVoByUserIds(userIds); } @Override - public List listRolesVo(SysUserRolesRequest request) { - return sysUserMapper.selectRolesVo(request); + public List listRolesVo(SysUserRolesReqVo reqVo) { + return sysUserMapper.selectRolesVo(reqVo); } @Override - public PageInfo pageRolesVo(SysUserRolesRequest request) { - return PageHelper.startPage(request.getPageNumber(), request.getPageSize()) - .doSelectPageInfo(() -> listRolesVo(request)); + public PageInfo pageRolesVo(SysUserRolesReqVo reqVo) { + return PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize()) + .doSelectPageInfo(() -> listRolesVo(reqVo)); } } diff --git a/framework/framework_svc/src/main/resources/mapper/SysApiMapper.xml b/framework/framework_svc/src/main/resources/mapper/SysApiMapper.xml index 5a07bbdd..7d8b4d60 100644 --- a/framework/framework_svc/src/main/resources/mapper/SysApiMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/SysApiMapper.xml @@ -1,7 +1,7 @@ - + @@ -30,14 +30,14 @@ FROM sys_api sa LEFT JOIN sys_role_api sra ON sra.api_id = sa.id LEFT JOIN sys_role sr ON sra.role_id = sr.id - + - - + + sa.url like #{bindUrl} - - + + AND sa.description like #{bindDescription} diff --git a/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml b/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml index 0fd8e61b..79771e40 100644 --- a/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml @@ -1,7 +1,7 @@ - + @@ -32,30 +32,30 @@ FROM sys_menu sm LEFT JOIN sys_role_menu srm ON srm.menu_id = sm.id LEFT JOIN sys_role sr ON srm.role_id = sr.id - + - + sm.parent_id is null - sm.parent_id = #{request.parentId} + sm.parent_id = #{req.parentId} - - + + AND sm.route_name like #{bindRouteName} - - + + AND sm.menu_name like #{bindMenuName } - - AND sm.enable_flag = #{request.enableFlag, typeHandler=BoolToIntTypeHandler} + + AND sm.enable_flag = #{req.enableFlag, typeHandler=BoolToIntTypeHandler} - + AND sr.id in ( - + #{id} ) diff --git a/framework/framework_svc/src/main/resources/mapper/SysRoleMapper.xml b/framework/framework_svc/src/main/resources/mapper/SysRoleMapper.xml index b7c79f76..3b82e37b 100644 --- a/framework/framework_svc/src/main/resources/mapper/SysRoleMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/SysRoleMapper.xml @@ -1,7 +1,7 @@ - + @@ -48,21 +48,21 @@ ) - SELECT sr.*, JSON_ARRAYAGG(sm.id) m_id, JSON_ARRAYAGG(sa.id) a_id FROM sys_role sr LEFT JOIN sys_role_menu srm ON srm.role_id = sr.id LEFT JOIN sys_role_api sra ON sra.role_id = sr.id LEFT JOIN sys_menu sm ON srm.menu_id = sm.id LEFT JOIN sys_api sa ON sra.api_id = sa.id - + - - + + sr.code like #{bindCode} - - + + AND sr.name like #{bindName} @@ -70,7 +70,7 @@ GROUP BY sr.id, sr.code ORDER BY sr.code - SELECT sr.*, JSON_ARRAYAGG(sm.id) m_id, JSON_ARRAYAGG(sa.id) a_id FROM sys_role sr LEFT JOIN sys_role_menu srm ON srm.role_id = sr.id diff --git a/framework/framework_svc/src/main/resources/mapper/SysUserMapper.xml b/framework/framework_svc/src/main/resources/mapper/SysUserMapper.xml index 888f32ac..30a71306 100644 --- a/framework/framework_svc/src/main/resources/mapper/SysUserMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/SysUserMapper.xml @@ -1,7 +1,7 @@ - + @@ -45,22 +45,22 @@ FROM sys_user su LEFT JOIN sys_role_user sru ON sru.user_id = su.id LEFT JOIN sys_role sr ON sru.role_id = sr.id - + - - + + su.username like #{bindUsername} - - + + AND su.nick_name like #{binNickName} - - AND su.enable_flag = #{request.enableFlag, typeHandler=BoolToIntTypeHandler} + + AND su.enable_flag = #{req.enableFlag, typeHandler=BoolToIntTypeHandler} - + AND sr.id in ( - + #{id} ) From a20cd6041fe4192380bfff16d848d9dadff1a865 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 13 Aug 2023 17:29:43 +0800 Subject: [PATCH 055/244] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A0=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A7=84=E8=8C=83=E8=AF=B4=E6=98=8E=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application-config-example.md | 0 .../create-service-example.md | 0 .docs/intro/some- code-specification.md | 54 +++++++++++++++++++ 3 files changed, 54 insertions(+) rename .docs/{config => intro}/application-config-example.md (100%) rename .docs/{config => intro}/create-service-example.md (100%) create mode 100644 .docs/intro/some- code-specification.md diff --git a/.docs/config/application-config-example.md b/.docs/intro/application-config-example.md similarity index 100% rename from .docs/config/application-config-example.md rename to .docs/intro/application-config-example.md diff --git a/.docs/config/create-service-example.md b/.docs/intro/create-service-example.md similarity index 100% rename from .docs/config/create-service-example.md rename to .docs/intro/create-service-example.md diff --git a/.docs/intro/some- code-specification.md b/.docs/intro/some- code-specification.md new file mode 100644 index 00000000..316d1902 --- /dev/null +++ b/.docs/intro/some- code-specification.md @@ -0,0 +1,54 @@ +## 一些代码规约 + +### 常见命名规范 + +web 接口,以 Controller 结尾,放于 controller 包 + +service,以 Service 结尾,放于 service 包 + +service 实现,以 ServiceImpl 结尾,放于 serviceimpl 包 + +dao,以 Mapper 结尾,放于 mapper 包 + +manager(复杂业务聚合处理),以 Manager 结尾,放于 manager 包 + +feign 客户端,以 Client 结尾,放于 feignclient 包 + +bean 转换器,以 Convert 结尾,放于 convert 包 + +aop 切面,以 Aspect 结尾,放于 aspect 包 + +常量类,以 Const 结尾,放于 consts 包 + +枚举类,以 Enum 结尾,放于 enums 包 + +### bean 的命名 + +在 bean 包下维护各类简单 bean(贫血模型) + +数据表实体,类名和表名一致,放于 bean.po 或 bean.entity 包 + +web 请求/返回实体,以 ReqVo/ResVo 结尾,放于 bean.vo 包 + +feign 请求/返回实体,以 ReqDto/ResDto 结尾,放于 bean.dto 包 + +mongoDB 实体,以 doc 结尾,放于 bean.doc 包 + +复杂业务实体,以 Bo 结尾,放于 bean.bo 包 + +其他数据实体,以 Do 结尾并冠以前缀,放于 bean.data 包,如 + +- 缓存实体,以 CacheDo 结尾 +- es 实体,以 IdxDo 结尾 +- 消息实体,以 MsgDo 结尾 + +另外,一些独立于业务之外的简单 bean,由于工具类、框架配置等的需要,可放于 model 包下,也可使用内部类方式 + +### 工具类的命名 + +工具类放于 util 包 + +一般使用单数的 Util 结尾,当工具类需要注入使用时,推荐以 Kit 结尾进行区分 + + + From fcbdeb6cf89c3b5f585f77d61c0ec56b5ad2835b Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 14 Aug 2023 00:01:35 +0800 Subject: [PATCH 056/244] =?UTF-8?q?build:=20=E6=B7=BB=E5=8A=A0=20spring=20?= =?UTF-8?q?boot=20maven=20=E6=89=93=E5=8C=85=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/example_svc/pom.xml | 29 +++++++++++++++++++++++++++++ framework/framework_svc/pom.xml | 28 ++++++++++++++++++++++++++++ gateway/pom.xml | 28 ++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+) diff --git a/example/example_svc/pom.xml b/example/example_svc/pom.xml index 44590bfc..28466e65 100644 --- a/example/example_svc/pom.xml +++ b/example/example_svc/pom.xml @@ -9,6 +9,7 @@ 4.0.0 + jar uni-boot-example-svc 微服务样例模块-SERVICE @@ -57,4 +58,32 @@ uni-boot-example-api + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.5.2 + + true + true + + + org.projectlombok + lombok + + + + + + + repackage + + + + + + + diff --git a/framework/framework_svc/pom.xml b/framework/framework_svc/pom.xml index 862ebbfa..0f6023be 100644 --- a/framework/framework_svc/pom.xml +++ b/framework/framework_svc/pom.xml @@ -9,6 +9,7 @@ 2023.1.1 + jar uni-boot-framework-svc @@ -58,4 +59,31 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + 2.5.2 + + true + true + + + org.projectlombok + lombok + + + + + + + repackage + + + + + + + diff --git a/gateway/pom.xml b/gateway/pom.xml index 6e16f938..a3e68dc5 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -10,6 +10,7 @@ 4.0.0 + jar uni-boot-gateway 流量网关 @@ -98,4 +99,31 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + 2.5.2 + + true + true + + + org.projectlombok + lombok + + + + + + + repackage + + + + + + + From cc3a0cf23ead02d6751adb31cba9893c7fc1217c Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 14 Aug 2023 00:01:51 +0800 Subject: [PATCH 057/244] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/intro/create-service-example.md | 112 ++++++++++++++++---------- 1 file changed, 71 insertions(+), 41 deletions(-) diff --git a/.docs/intro/create-service-example.md b/.docs/intro/create-service-example.md index b356d8c5..e99eaffc 100644 --- a/.docs/intro/create-service-example.md +++ b/.docs/intro/create-service-example.md @@ -45,48 +45,78 @@ api 模块基本依赖: svc 模块基本依赖: ```xml - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - org.springframework.boot - spring-boot-starter-tomcat - provided - - - - org.springframework.boot - spring-boot-starter-test - test - - - - com.github.ulisesbocchio - jasypt-spring-boot-starter - - - com.github.cadecode - uni-boot-common-plugin-actuator - - - - com.github.cadecode - uni-boot-framework-base - - + + + + + org.springframework.cloud + spring-cloud-starter-bootstrap + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.github.ulisesbocchio + jasypt-spring-boot-starter + + + + com.github.cadecode + uni-boot-common-plugin-actuator + + + + com.github.cadecode + uni-boot-framework-base + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.5.2 + + true + true + + + org.projectlombok + lombok + + + + + + + repackage + + + + + + + ``` ## 创建启动类 From 631f45818f86356d7713a4c0b05659a56dcc5b95 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 14 Aug 2023 22:13:42 +0800 Subject: [PATCH 058/244] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 30261929..50e9fa31 100644 --- a/README.md +++ b/README.md @@ -63,9 +63,6 @@ 1. 代码结构 ```sh - ├── application - ├── business - │ ├── example ├── common │ ├── core │ ├── plugin @@ -80,6 +77,13 @@ │ └── pom.xml ├── dependencies ├── framework + │ ├── framework_api + │ ├── framework_base + │ ├── framework_svc + ├── example + │ ├── example_api + │ ├── example_svc + ├── gateway ├── LICENSE ├── pom.xml └── README.md @@ -88,9 +92,6 @@ 2. 目录介绍 ```sh - application # 项目启动入口,包含项目配置文件 - business # 业务模块 - business/example # 业务模块示例,包含用于模拟测试的 Controller、Service 等,可丢弃 common # 通用模块 common/core # 通用核心模块,包含公共注解、常量、异常、工具类、抽象模板等 common/plugin # 通用插件模块,用于抽离各种组件、第三方库 @@ -102,7 +103,14 @@ common/plugin/mybatis # mybatis 模块,集成 MybatisPlus、PageHelper common/plugin/swagger # swagger 模块,集成 knife4j,动态配置 swagger 的 module dependencies # 依赖管理模块,作为父模块,管理全局依赖版本 - framework # 系统功能模块,提供相关框架配置、基础功能支持,如用户/菜单/角色/字典等管理功能等 + framework # 框架模块 + framework/framework_api # 框架 feign api + framework/framework_base # 框架通用配置 + framework/framework_svc # 框架服务,提供基础功能支持,如用户/菜单/角色/字典等管理功能等 + example # 示例模块 + example/example_api # 示例 feign api + example/example_svc # 示例服务 + gateway # 网关服务 ``` ## 演示截图 @@ -110,3 +118,4 @@ 参见配套前端项目 [uni-boot-admin-vue](https://github.com/cadecode/uni-boot-admin-vue) + From f60cffb8ec97b8e7b0a10340b2a9d79c74d7f531 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 17 Aug 2023 12:34:01 +0800 Subject: [PATCH 059/244] =?UTF-8?q?refactor:=20=E5=88=A0=E9=99=A4=20UniBoo?= =?UTF-8?q?tConfig=20=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...DSConfig.java => DynamicDSAutoConfig.java} | 4 +- .../config/DynamicDSProperties.java | 2 + .../swagger/config/SwaggerAutoConfig.java | 2 +- .../swagger/config/SwaggerProperties.java | 2 + .../framework/base/config/UniBootConfig.java | 42 ------------------- 5 files changed, 7 insertions(+), 45 deletions(-) rename common/plugin/datasource/src/main/java/com/github/cadecode/uniboot/common/plugin/datasource/config/{DynamicDSConfig.java => DynamicDSAutoConfig.java} (95%) delete mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/UniBootConfig.java diff --git a/common/plugin/datasource/src/main/java/com/github/cadecode/uniboot/common/plugin/datasource/config/DynamicDSConfig.java b/common/plugin/datasource/src/main/java/com/github/cadecode/uniboot/common/plugin/datasource/config/DynamicDSAutoConfig.java similarity index 95% rename from common/plugin/datasource/src/main/java/com/github/cadecode/uniboot/common/plugin/datasource/config/DynamicDSConfig.java rename to common/plugin/datasource/src/main/java/com/github/cadecode/uniboot/common/plugin/datasource/config/DynamicDSAutoConfig.java index f89c9fb5..3b951d69 100644 --- a/common/plugin/datasource/src/main/java/com/github/cadecode/uniboot/common/plugin/datasource/config/DynamicDSConfig.java +++ b/common/plugin/datasource/src/main/java/com/github/cadecode/uniboot/common/plugin/datasource/config/DynamicDSAutoConfig.java @@ -26,8 +26,8 @@ @RequiredArgsConstructor @Configuration @EnableConfigurationProperties(DynamicDSProperties.class) -@ConditionalOnProperty(name = "uni-boot.config.dynamic-ds-on", havingValue = "true") -public class DynamicDSConfig { +@ConditionalOnProperty(name = "uni-boot.dynamic-ds.enable", havingValue = "true") +public class DynamicDSAutoConfig { private final DynamicDSProperties properties; diff --git a/common/plugin/datasource/src/main/java/com/github/cadecode/uniboot/common/plugin/datasource/config/DynamicDSProperties.java b/common/plugin/datasource/src/main/java/com/github/cadecode/uniboot/common/plugin/datasource/config/DynamicDSProperties.java index 0467a06a..4e825c8c 100644 --- a/common/plugin/datasource/src/main/java/com/github/cadecode/uniboot/common/plugin/datasource/config/DynamicDSProperties.java +++ b/common/plugin/datasource/src/main/java/com/github/cadecode/uniboot/common/plugin/datasource/config/DynamicDSProperties.java @@ -16,6 +16,8 @@ @ConfigurationProperties("uni-boot.dynamic-ds") public class DynamicDSProperties { + private boolean enable; + /** * 主数据源 KEY */ diff --git a/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/config/SwaggerAutoConfig.java b/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/config/SwaggerAutoConfig.java index 503cb15b..af1ab9fc 100644 --- a/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/config/SwaggerAutoConfig.java +++ b/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/config/SwaggerAutoConfig.java @@ -22,7 +22,7 @@ @Configuration @Import(SwaggerRegisterKit.class) @EnableConfigurationProperties(SwaggerProperties.class) -@ConditionalOnProperty(name = "uni-boot.config.swagger-on", havingValue = "true") +@ConditionalOnProperty(name = "uni-boot.swagger.enable", havingValue = "true") public class SwaggerAutoConfig implements WebMvcConfigurer, InitializingBean { private final SwaggerProperties swaggerProperties; diff --git a/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/config/SwaggerProperties.java b/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/config/SwaggerProperties.java index e1fd70b1..59a6c988 100644 --- a/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/config/SwaggerProperties.java +++ b/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/config/SwaggerProperties.java @@ -15,6 +15,8 @@ @ConfigurationProperties("uni-boot.swagger") public class SwaggerProperties { + private boolean enable; + /** * 模块和包名 MAP */ diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/UniBootConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/UniBootConfig.java deleted file mode 100644 index d06c710c..00000000 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/UniBootConfig.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.github.cadecode.uniboot.framework.base.config; - -import lombok.Data; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; - -/** - * uni-boot-admin 通用配置类 - * 维护一些功能开关和全局变量 - * - * @author Cade Li - * @date 2022/5/21 - */ -@Slf4j -@Data -@RequiredArgsConstructor -@Configuration -@ConfigurationProperties("uni-boot.config") -public class UniBootConfig { - - /** - * 应用名称 - */ - private String name; - - /** - * 版本号 - */ - private String version; - - /** - * 是否开启 swagger 文档 - */ - private boolean swaggerOn; - - /** - * 是否开启动态数据源配置 - */ - private boolean dynamicDsOn; -} From 6128469781ce533f08ea86874491542ae7c80067 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 17 Aug 2023 12:35:12 +0800 Subject: [PATCH 060/244] =?UTF-8?q?refactor:=20=E5=88=A0=E9=99=A4=20banner?= =?UTF-8?q?=20=E4=B8=AD=20uniboot=20=E7=89=88=E6=9C=AC=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/example_svc/src/main/resources/banner.txt | 1 - framework/framework_svc/src/main/resources/banner.txt | 1 - gateway/src/main/resources/banner.txt | 1 - 3 files changed, 3 deletions(-) diff --git a/example/example_svc/src/main/resources/banner.txt b/example/example_svc/src/main/resources/banner.txt index 0799272a..599fe548 100644 --- a/example/example_svc/src/main/resources/banner.txt +++ b/example/example_svc/src/main/resources/banner.txt @@ -5,4 +5,3 @@ _|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| "`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-' :: Spring Boot :: (${spring-boot.version}) - :: ${uni-boot.config.name} :: (${uni-boot.config.version}) diff --git a/framework/framework_svc/src/main/resources/banner.txt b/framework/framework_svc/src/main/resources/banner.txt index 0799272a..599fe548 100644 --- a/framework/framework_svc/src/main/resources/banner.txt +++ b/framework/framework_svc/src/main/resources/banner.txt @@ -5,4 +5,3 @@ _|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| "`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-' :: Spring Boot :: (${spring-boot.version}) - :: ${uni-boot.config.name} :: (${uni-boot.config.version}) diff --git a/gateway/src/main/resources/banner.txt b/gateway/src/main/resources/banner.txt index 0799272a..599fe548 100644 --- a/gateway/src/main/resources/banner.txt +++ b/gateway/src/main/resources/banner.txt @@ -5,4 +5,3 @@ _|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""| "`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-' :: Spring Boot :: (${spring-boot.version}) - :: ${uni-boot.config.name} :: (${uni-boot.config.version}) From bada7af32f215043f3edab160991b5ac9f7ed1b6 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 17 Aug 2023 12:35:57 +0800 Subject: [PATCH 061/244] =?UTF-8?q?docs:=20=E5=88=A0=E9=99=A4=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E4=B8=AD=20uni-boot.config=20=E7=9A=84=E8=AF=B4?= =?UTF-8?q?=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/intro/application-config-example.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.docs/intro/application-config-example.md b/.docs/intro/application-config-example.md index 8f6144d4..2feb9f70 100644 --- a/.docs/intro/application-config-example.md +++ b/.docs/intro/application-config-example.md @@ -113,16 +113,12 @@ management: # uni-boot uni-boot: - config: - name: ${spring.application.name} - version: 2023.1.0 - swagger-on: true - dynamic-ds-on: false swagger: + enable: true + version: ${uni-boot.config.version} name: Cade Li url: https://github.com/cadecode/uni-boot-admin email: cadecode@foxmail.com - version: ${uni-boot.config.version} module: default: com.github.cadecode.uniboot security: From d40a0b127e6d0c2c05be0495aa1b8a48f6a95c66 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 17 Aug 2023 15:40:10 +0800 Subject: [PATCH 062/244] =?UTF-8?q?build:=20=E5=BC=95=E5=85=A5=20mq=20?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=EF=BC=8CRabbitMQ?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/plugin/mq/pom.xml | 21 +++++++++++++++++++++ pom.xml | 5 +++++ 2 files changed, 26 insertions(+) create mode 100644 common/plugin/mq/pom.xml diff --git a/common/plugin/mq/pom.xml b/common/plugin/mq/pom.xml new file mode 100644 index 00000000..c393229a --- /dev/null +++ b/common/plugin/mq/pom.xml @@ -0,0 +1,21 @@ + + + + com.github.cadecode + uni-boot-common-plugin + 2023.1.1 + + 4.0.0 + + uni-boot-common-plugin-mq + + + + + org.springframework.boot + spring-boot-starter-amqp + + + diff --git a/pom.xml b/pom.xml index 635a11b2..1b02e212 100644 --- a/pom.xml +++ b/pom.xml @@ -67,6 +67,11 @@ uni-boot-common-plugin-concurrent ${uni.version} + + com.github.cadecode + uni-boot-common-plugin-mq + ${uni.version} + com.github.cadecode uni-boot-framework-api From 61e1a66474e018b7e94ab6839461cfc97218a63f Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 17 Aug 2023 16:40:07 +0800 Subject: [PATCH 063/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20RabbitMQ?= =?UTF-8?q?=20=E8=87=AA=E5=8A=A8=E9=85=8D=E7=BD=AE=EF=BC=8C=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=98=9F=E5=88=97=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/mq/config/RabbitAutoConfig.java | 77 ++++++++++ .../plugin/mq/config/RabbitProperties.java | 141 ++++++++++++++++++ 2 files changed, 218 insertions(+) create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java new file mode 100644 index 00000000..7feb94c0 --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java @@ -0,0 +1,77 @@ +package com.github.cadecode.uniboot.common.plugin.mq.config; + +import cn.hutool.core.util.ObjectUtil; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.core.Binding; +import org.springframework.amqp.core.Binding.DestinationType; +import org.springframework.amqp.core.Exchange; +import org.springframework.amqp.core.Queue; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.context.properties.bind.BindResult; +import org.springframework.boot.context.properties.bind.Binder; +import org.springframework.context.EnvironmentAware; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; + +/** + * RabbitMQ 自动配置 + * + * @author Cade Li + * @since 2023/8/17 + */ +@Slf4j +@RequiredArgsConstructor +@EnableConfigurationProperties(RabbitProperties.class) +@ConditionalOnProperty(name = "uni-boot.mq.rabbit.enable", havingValue = "true") +@Configuration +public class RabbitAutoConfig implements BeanFactoryPostProcessor, EnvironmentAware { + + private Environment environment; + + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { + BindResult bindResult = Binder.get(environment).bind(RabbitProperties.ENV_CONF_RABBIT_PREFIX, RabbitProperties.class); + RabbitProperties rabbitProperties = bindResult.orElse(null); + if (ObjectUtil.isNull(rabbitProperties)) { + log.info("Rabbit env config {} not found", RabbitProperties.ENV_CONF_RABBIT_PREFIX); + return; + } + if (ObjectUtil.isNotEmpty(rabbitProperties.getExchanges())) { + rabbitProperties.getExchanges().forEach(o -> { + Exchange exchange = o.toBuilder().build(); + beanFactory.registerSingleton(o.getName(), exchange); + log.info("Rabbit auto register exchange, {}", o.getName()); + }); + } + if (ObjectUtil.isNotEmpty(rabbitProperties.getQueues())) { + rabbitProperties.getQueues().forEach(o -> { + Queue queue = o.toBuilder().build(); + beanFactory.registerSingleton(o.getName(), queue); + log.info("Rabbit auto register queue, {}", o.getName()); + }); + } + if (ObjectUtil.isNotEmpty(rabbitProperties.getBindings())) { + rabbitProperties.getBindings().forEach(o -> { + String bindName = o.getBindName(); + // 对随机后缀的队列,不能直接用 bean name,需要获取 queue 的 bean 再获取队列名称 + if (o.getBindType() == DestinationType.QUEUE) { + Queue queue = beanFactory.getBean(o.getBindName(), Queue.class); + bindName = queue.getName(); + } + Binding binding = new Binding(bindName, o.getBindType(), o.getExchangeName(), o.getRoutingKey(), o.getArguments()); + beanFactory.registerSingleton(o.getBindName() + "-" + o.getExchangeName(), binding); + log.info("Rabbit auto register binding, {} to {}, bindType:{}", o.getBindName(), o.getExchangeName(), o.getBindType()); + }); + } + } + + @Override + public void setEnvironment(Environment environment) { + this.environment = environment; + } +} diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java new file mode 100644 index 00000000..90d83e8e --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java @@ -0,0 +1,141 @@ +package com.github.cadecode.uniboot.common.plugin.mq.config; + +import cn.hutool.core.lang.UUID; +import cn.hutool.core.util.ObjectUtil; +import lombok.Data; +import org.springframework.amqp.core.Binding.DestinationType; +import org.springframework.amqp.core.ExchangeBuilder; +import org.springframework.amqp.core.ExchangeTypes; +import org.springframework.amqp.core.QueueBuilder; +import org.springframework.boot.context.properties.ConfigurationProperties; + +import java.util.List; +import java.util.Map; + +/** + * RabbitMQ 配置项 + * for spring-boot-starter-amqp 2.5.4 + * + * @author Cade Li + * @since 2023/8/17 + */ +@Data +@ConfigurationProperties(RabbitProperties.ENV_CONF_RABBIT_PREFIX) +public class RabbitProperties { + + public static final String ENV_CONF_RABBIT_PREFIX = "uni-boot.mq.rabbit"; + + private boolean enable; + + private List exchanges; + + private List queues; + + private List bindings; + + /** + * 队列声明常用配置项 + * 默认持久化、不独占、不自动删除 + */ + @Data + public static class QueueBuildProperties { + /** + * 队列名称 + */ + private String name; + /** + * 名称是否添加随机后缀 + * 注:随机后缀名适用于发布订阅模式,每个消费者监听各自队列 + * 当需要在 @RabbitListener 注解中指定 queues,可以使用 SpEL 表达式获取完整队列名称 + */ + private boolean randomSuffix; + private boolean durable = true; + private boolean exclusive; + private boolean autoDelete; + private Map arguments; + + public QueueBuilder toBuilder() { + String completedName = name; + if (randomSuffix) { + completedName = completedName + "." + UUID.fastUUID().toString(true); + } + QueueBuilder builder; + if (durable) { + builder = QueueBuilder.durable(completedName); + } else { + builder = QueueBuilder.nonDurable(completedName); + } + if (exclusive) { + builder.exclusive(); + } + if (autoDelete) { + builder.autoDelete(); + } + if (ObjectUtil.isNotEmpty(arguments)) { + arguments.forEach(builder::withArgument); + } + return builder; + } + } + + /** + * 交换机声明配置项 + * 默认持久化、不自动删除 + * 默认类型为 topic + */ + @Data + public static class ExchangeBuildProperties { + private String name; + private String type = ExchangeTypes.TOPIC; + private boolean durable = true; + private boolean autoDelete; + private boolean internal; + private boolean delayed; + private boolean ignoreDeclarationExceptions; + private boolean declare = true; + private Object[] declaringAdmins; + private Map arguments; + + public ExchangeBuilder toBuilder() { + ExchangeBuilder builder = new ExchangeBuilder(name, type); + builder.durable(durable); + if (autoDelete) { + builder.autoDelete(); + } + if (internal) { + builder.internal(); + } + if (delayed) { + builder.delayed(); + } + if (ignoreDeclarationExceptions) { + builder.ignoreDeclarationExceptions(); + } + if (!declare) { + builder.suppressDeclaration(); + } + if (ObjectUtil.isNotEmpty(declaringAdmins)) { + builder.admins(arguments); + } + if (ObjectUtil.isNotEmpty(arguments)) { + arguments.forEach(builder::withArgument); + } + return builder; + } + } + + /** + * 绑定关系声明配置项 + * 可绑定队列到交换机、交换机到交互机 + * 默认绑定类型为队列到交换机 + */ + @Data + public static class BindingBuildProperties { + private String bindName; + private DestinationType bindType = DestinationType.QUEUE; + private String exchangeName; + private String routingKey; + private Map arguments; + } + +} From 63a614b318bf382ca811da287a3bb4657846761e Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 17 Aug 2023 17:06:16 +0800 Subject: [PATCH 064/244] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=20mq=20?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E6=B5=8B=E8=AF=95=E6=8E=A5=E5=8F=A3=E5=92=8C?= =?UTF-8?q?=E6=B6=88=E8=B4=B9=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/plugin/mq/consts/RabbitConst.java | 16 ++++++++ common/plugin/pom.xml | 1 + example/example_svc/pom.xml | 4 ++ .../svc/consumer/RabbitExampleConsumer.java | 36 ++++++++++++++++ .../svc/controller/MqExampleController.java | 41 +++++++++++++++++++ 5 files changed, 98 insertions(+) create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/consts/RabbitConst.java create mode 100644 example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java create mode 100644 example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/consts/RabbitConst.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/consts/RabbitConst.java new file mode 100644 index 00000000..f6ce5665 --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/consts/RabbitConst.java @@ -0,0 +1,16 @@ +package com.github.cadecode.uniboot.common.plugin.mq.consts; + +/** + * RabbitMQ 常量 + * + * @author Cade Li + * @since 2023/8/17 + */ +public interface RabbitConst { + + /** + * delay 交换机类型 + */ + String EXC_TYPE_DELAYED = "x-delayed-message"; + +} diff --git a/common/plugin/pom.xml b/common/plugin/pom.xml index e1b8bca3..41956ffc 100644 --- a/common/plugin/pom.xml +++ b/common/plugin/pom.xml @@ -21,6 +21,7 @@ mybatis swagger concurrent + mq diff --git a/example/example_svc/pom.xml b/example/example_svc/pom.xml index 28466e65..eb3bf2c7 100644 --- a/example/example_svc/pom.xml +++ b/example/example_svc/pom.xml @@ -49,6 +49,10 @@ com.github.cadecode uni-boot-common-plugin-actuator + + com.github.cadecode + uni-boot-common-plugin-mq + com.github.cadecode uni-boot-framework-base diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java new file mode 100644 index 00000000..14505835 --- /dev/null +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java @@ -0,0 +1,36 @@ +package com.github.cadecode.uniboot.example.svc.consumer; + +import cn.hutool.core.util.ObjectUtil; +import com.rabbitmq.client.Channel; +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.stereotype.Component; + +import java.io.IOException; + +/** + * RabbitMQ 测试消费 + * + * @author Cade Li + * @since 2023/8/17 + */ +@Slf4j +@Component +public class RabbitExampleConsumer { + + @RabbitListener(queues = "demo-queue-0", id = "demo-queue-0", ackMode = "AUTO") + public void demoQueue0(String body, Message message, Channel channel) throws IOException { + log.info("Received msg:{}", body); + // 自动模式下,测试重试机制 + if (ObjectUtil.equal(body, "ERROR")) { + throw new RuntimeException("ERROR"); + } + } + + @RabbitListener(queues = "#{@'demo-queue-1'.name}", id = "demo-queue-1") + public void demoQueue1(String body, Message message, Channel channel) throws IOException { + log.info("Received msg:{}", body); + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + } +} diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java new file mode 100644 index 00000000..78fe9a78 --- /dev/null +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java @@ -0,0 +1,41 @@ +package com.github.cadecode.uniboot.example.svc.controller; + +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * MQ 测试接口 + * + * @author Cade Li + * @since 2023/8/16 + */ +@ApiFormat +@Slf4j +@RequiredArgsConstructor +@Api(tags = "MQ 测试") +@RestController +@RequestMapping("demo/mq") +public class MqExampleController { + + private final RabbitTemplate rabbitTemplate; + + @ApiOperation("发送 delay 消息") + @GetMapping("send_delay") + public boolean sendDelay(@RequestParam String exc, @RequestParam String routingKey, + @RequestParam String msg, @RequestParam Integer ms) { + rabbitTemplate.convertAndSend(exc, routingKey, msg, message -> { + message.getMessageProperties().setDelay(ms); + return message; + }); + return true; + } +} + From 19142fbc610d6b4a8edc9885addb763d19a6bbcd Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 18 Aug 2023 13:43:14 +0800 Subject: [PATCH 065/244] =?UTF-8?q?build:=20plugin=20log=20=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/framework_api/pom.xml | 4 ---- framework/framework_base/pom.xml | 4 ++++ gateway/pom.xml | 4 ---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/framework/framework_api/pom.xml b/framework/framework_api/pom.xml index c18c6038..5ef03faa 100644 --- a/framework/framework_api/pom.xml +++ b/framework/framework_api/pom.xml @@ -31,10 +31,6 @@ com.github.cadecode uni-boot-common-core - - com.github.cadecode - uni-boot-common-plugin-log - com.github.cadecode uni-boot-common-plugin-cache diff --git a/framework/framework_base/pom.xml b/framework/framework_base/pom.xml index 8717895a..7242781f 100644 --- a/framework/framework_base/pom.xml +++ b/framework/framework_base/pom.xml @@ -43,6 +43,10 @@ com.github.cadecode uni-boot-common-plugin-swagger + + com.github.cadecode + uni-boot-common-plugin-log + diff --git a/gateway/pom.xml b/gateway/pom.xml index a3e68dc5..93377108 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -83,10 +83,6 @@ com.github.cadecode uni-boot-common-plugin-cache - - com.github.cadecode - uni-boot-common-plugin-log - org.springframework.boot spring-boot-starter-web From 08a5d9b8938d784c8de168695daba267a223def9 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 18 Aug 2023 13:49:13 +0800 Subject: [PATCH 066/244] =?UTF-8?q?refactor:=20=E7=B1=BB=E5=90=8D=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/plugin/{ApiLogHandler.java => LogSaveHandler.java} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/{ApiLogHandler.java => LogSaveHandler.java} (98%) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/LogSaveHandler.java similarity index 98% rename from framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/LogSaveHandler.java index 73031e2b..f27491b8 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/ApiLogHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/LogSaveHandler.java @@ -25,7 +25,7 @@ import java.util.Collections; /** - * Api Log 处理器实现 + * Log 处理器实现-save * * @author Cade Li * @since 2023/6/8 @@ -33,7 +33,7 @@ @Slf4j @RequiredArgsConstructor @Component -public class ApiLogHandler extends AbstractApiLogHandler { +public class LogSaveHandler extends AbstractApiLogHandler { private final SysLogClient sysLogClient; From 2dd1246aed0e676a7e715512c6a982828a32c436 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 18 Aug 2023 14:09:20 +0800 Subject: [PATCH 067/244] =?UTF-8?q?refactor:=20SysLog=20=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=90=84=E6=9C=8D=E5=8A=A1=E5=88=86=E5=88=AB=E7=BB=B4=E6=8A=A4?= =?UTF-8?q?=20PlgLog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/framework_base/pom.xml | 10 ++++- .../base/plugin/bean/po/PlgLog.java} | 4 +- .../base/plugin/bean/vo/PlgLogVo.java} | 11 +++-- .../plugin/controller/PlgLogController.java} | 45 +++++++++---------- .../base/plugin/convert/PlgLogConvert.java | 25 +++++++++++ .../plugin/{ => handler}/LogSaveHandler.java | 2 +- .../{ => handler}/MybatisFillHandler.java | 2 +- .../base/plugin/mapper/PlgLogMapper.java | 15 +++++++ .../base/plugin/service/PlgLogService.java | 13 ++++++ .../plugin/serviceimpl/PlgLogServiceImpl.java | 17 +++++++ .../framework/svc/convert/SysLogConvert.java | 25 ----------- .../framework/svc/mapper/SysLogMapper.java | 15 ------- .../framework/svc/service/SysLogService.java | 13 ------ .../svc/serviceimpl/SysLogServiceImpl.java | 17 ------- 14 files changed, 110 insertions(+), 104 deletions(-) rename framework/{framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgLog.java} (95%) rename framework/{framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgLogVo.java} (88%) rename framework/{framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java => framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java} (61%) create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgLogConvert.java rename framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/{ => handler}/LogSaveHandler.java (98%) rename framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/{ => handler}/MybatisFillHandler.java (89%) create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/mapper/PlgLogMapper.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/service/PlgLogService.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/serviceimpl/PlgLogServiceImpl.java delete mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysLogConvert.java delete mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysLogMapper.java delete mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysLogService.java delete mode 100644 framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysLogServiceImpl.java diff --git a/framework/framework_base/pom.xml b/framework/framework_base/pom.xml index 7242781f..1ac86375 100644 --- a/framework/framework_base/pom.xml +++ b/framework/framework_base/pom.xml @@ -25,7 +25,11 @@ com.github.cadecode - uni-boot-framework-api + uni-boot-common-core + + + com.github.cadecode + uni-boot-common-plugin-cache com.github.cadecode @@ -47,6 +51,10 @@ com.github.cadecode uni-boot-common-plugin-log + + com.github.cadecode + uni-boot-framework-api + diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgLog.java similarity index 95% rename from framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgLog.java index d2a603ad..a02e1308 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysLog.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgLog.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.svc.bean.po; +package com.github.cadecode.uniboot.framework.base.plugin.bean.po; import com.baomidou.mybatisplus.annotation.*; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; @@ -20,7 +20,7 @@ @NoArgsConstructor @Builder @TableName(autoResultMap = true) -public class SysLog { +public class PlgLog { @TableId(type = IdType.ASSIGN_ID) private Long id; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgLogVo.java similarity index 88% rename from framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgLogVo.java index 12cf130a..03634196 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysLogVo.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgLogVo.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.svc.bean.vo; +package com.github.cadecode.uniboot.framework.base.plugin.bean.vo; import com.github.cadecode.uniboot.common.core.web.response.PageParams; import lombok.Data; @@ -13,12 +13,11 @@ * @author Cade Li * @since 2023/5/26 */ -public class SysLogVo { - +public class PlgLogVo { @Data @EqualsAndHashCode(callSuper = true) - public static class SysLogPageReqVo extends PageParams { + public static class PlgLogPageReqVo extends PageParams { private Date startTime; private Date endTime; @@ -30,7 +29,7 @@ public static class SysLogPageReqVo extends PageParams { } @Data - public static class SysLogSaveReqVo { + public static class PlgLogSaveReqVo { private String logType; @@ -69,7 +68,7 @@ public static class SysLogSaveReqVo { } @Data - public static class SysLogPageResVo { + public static class PlgLogPageResVo { private Long id; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java similarity index 61% rename from framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java index 8660bd4c..76b0981d 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysLogController.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java @@ -1,15 +1,16 @@ -package com.github.cadecode.uniboot.framework.svc.controller; +package com.github.cadecode.uniboot.framework.base.plugin.controller; import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.base.annotation.ApiInner; -import com.github.cadecode.uniboot.framework.svc.bean.po.SysLog; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogPageResVo; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogSaveReqVo; -import com.github.cadecode.uniboot.framework.svc.convert.SysLogConvert; -import com.github.cadecode.uniboot.framework.svc.service.SysLogService; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgLog; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo.PlgLogPageResVo; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo.PlgLogSaveReqVo; +import com.github.cadecode.uniboot.framework.base.plugin.convert.PlgLogConvert; +import com.github.cadecode.uniboot.framework.base.plugin.service.PlgLogService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; @@ -26,8 +27,6 @@ import javax.validation.constraints.NotEmpty; import java.util.List; -import static com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogPageReqVo; - /** * 日志管理 * @@ -38,27 +37,27 @@ @Slf4j @RequiredArgsConstructor @Api(tags = "日志管理") -@RequestMapping("system/log") +@RequestMapping("plugin/log") @RestController @Validated -public class SysLogController { +public class PlgLogController { - private final SysLogService logService; + private final PlgLogService logService; @ApiOperation("查询列表") @PostMapping("page") - public PageResult page(@RequestBody @Valid SysLogPageReqVo reqVo) { - PageInfo pageInfo = PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize()) + public PageResult page(@RequestBody @Valid PlgLogVo.PlgLogPageReqVo reqVo) { + PageInfo pageInfo = PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize()) .doSelectPageInfo(() -> logService.lambdaQuery() - .ge(ObjectUtil.isNotEmpty(reqVo.getStartTime()), SysLog::getCreateTime, reqVo.getStartTime()) - .le(ObjectUtil.isNotEmpty(reqVo.getEndTime()), SysLog::getCreateTime, reqVo.getEndTime()) - .in(ObjectUtil.isNotEmpty(reqVo.getLogTypeList()), SysLog::getLogType, reqVo.getLogTypeList()) - .likeRight(ObjectUtil.isNotEmpty(reqVo.getAccessUser()), SysLog::getAccessUser, reqVo.getAccessUser()) - .like(ObjectUtil.isNotEmpty(reqVo.getUrl()), SysLog::getUrl, reqVo.getUrl()) - .eq(ObjectUtil.isNotNull(reqVo.getExceptional()), SysLog::getExceptional, BoolToIntTypeHandler.mapping(reqVo.getExceptional())) - .orderByDesc(SysLog::getCreateTime) + .ge(ObjectUtil.isNotEmpty(reqVo.getStartTime()), PlgLog::getCreateTime, reqVo.getStartTime()) + .le(ObjectUtil.isNotEmpty(reqVo.getEndTime()), PlgLog::getCreateTime, reqVo.getEndTime()) + .in(ObjectUtil.isNotEmpty(reqVo.getLogTypeList()), PlgLog::getLogType, reqVo.getLogTypeList()) + .likeRight(ObjectUtil.isNotEmpty(reqVo.getAccessUser()), PlgLog::getAccessUser, reqVo.getAccessUser()) + .like(ObjectUtil.isNotEmpty(reqVo.getUrl()), PlgLog::getUrl, reqVo.getUrl()) + .eq(ObjectUtil.isNotNull(reqVo.getExceptional()), PlgLog::getExceptional, BoolToIntTypeHandler.mapping(reqVo.getExceptional())) + .orderByDesc(PlgLog::getCreateTime) .list()); - List voList = SysLogConvert.INSTANCE.poToVo(pageInfo.getList()); + List voList = PlgLogConvert.INSTANCE.poToVo(pageInfo.getList()); return new PageResult<>((int) pageInfo.getTotal(), voList); } @@ -71,8 +70,8 @@ public boolean delete(@RequestBody @NotEmpty List idList) { @ApiInner(onlyClient = true) @ApiOperation("添加") @PostMapping("save") - public boolean save(@RequestBody @NotEmpty List requestList) { - List poList = SysLogConvert.INSTANCE.voToPo(requestList); + public boolean save(@RequestBody @NotEmpty List requestList) { + List poList = PlgLogConvert.INSTANCE.voToPo(requestList); return logService.saveBatch(poList); } } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgLogConvert.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgLogConvert.java new file mode 100644 index 00000000..f73c3689 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgLogConvert.java @@ -0,0 +1,25 @@ +package com.github.cadecode.uniboot.framework.base.plugin.convert; + +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgLog; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo.PlgLogPageResVo; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo.PlgLogSaveReqVo; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 系统日志 bean convert + * + * @author Cade Li + * @since 2023/5/26 + */ +@Mapper +public interface PlgLogConvert { + + PlgLogConvert INSTANCE = Mappers.getMapper(PlgLogConvert.class); + + List poToVo(List records); + + List voToPo(List requestList); +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/LogSaveHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/LogSaveHandler.java similarity index 98% rename from framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/LogSaveHandler.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/LogSaveHandler.java index f27491b8..c1ca9b70 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/LogSaveHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/LogSaveHandler.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.base.plugin; +package com.github.cadecode.uniboot.framework.base.plugin.handler; import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.util.CharsetUtil; diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/MybatisFillHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MybatisFillHandler.java similarity index 89% rename from framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/MybatisFillHandler.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MybatisFillHandler.java index a83c9831..66710b22 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/MybatisFillHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MybatisFillHandler.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.base.plugin; +package com.github.cadecode.uniboot.framework.base.plugin.handler; import com.github.cadecode.uniboot.common.plugin.mybatis.handler.AbstractObjectFillHandler; import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/mapper/PlgLogMapper.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/mapper/PlgLogMapper.java new file mode 100644 index 00000000..bd117435 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/mapper/PlgLogMapper.java @@ -0,0 +1,15 @@ +package com.github.cadecode.uniboot.framework.base.plugin.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgLog; +import org.apache.ibatis.annotations.Mapper; + +/** + * 系统日志 DAO + * + * @author Cade Li + * @since 2023/5/26 + */ +@Mapper +public interface PlgLogMapper extends BaseMapper { +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/service/PlgLogService.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/service/PlgLogService.java new file mode 100644 index 00000000..2c514349 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/service/PlgLogService.java @@ -0,0 +1,13 @@ +package com.github.cadecode.uniboot.framework.base.plugin.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgLog; + +/** + * 系统日志服务 + * + * @author Cade Li + * @since 2023/5/26 + */ +public interface PlgLogService extends IService { +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/serviceimpl/PlgLogServiceImpl.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/serviceimpl/PlgLogServiceImpl.java new file mode 100644 index 00000000..29e6ab51 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/serviceimpl/PlgLogServiceImpl.java @@ -0,0 +1,17 @@ +package com.github.cadecode.uniboot.framework.base.plugin.serviceimpl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgLog; +import com.github.cadecode.uniboot.framework.base.plugin.mapper.PlgLogMapper; +import com.github.cadecode.uniboot.framework.base.plugin.service.PlgLogService; +import org.springframework.stereotype.Service; + +/** + * 系统日志服务实现 + * + * @author Cade Li + * @since 2023/5/26 + */ +@Service +public class PlgLogServiceImpl extends ServiceImpl implements PlgLogService { +} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysLogConvert.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysLogConvert.java deleted file mode 100644 index c71a4f3b..00000000 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/convert/SysLogConvert.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.github.cadecode.uniboot.framework.svc.convert; - -import com.github.cadecode.uniboot.framework.svc.bean.po.SysLog; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogPageResVo; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysLogVo.SysLogSaveReqVo; -import org.mapstruct.Mapper; -import org.mapstruct.factory.Mappers; - -import java.util.List; - -/** - * 系统日志 bean convert - * - * @author Cade Li - * @since 2023/5/26 - */ -@Mapper -public interface SysLogConvert { - - SysLogConvert INSTANCE = Mappers.getMapper(SysLogConvert.class); - - List poToVo(List records); - - List voToPo(List requestList); -} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysLogMapper.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysLogMapper.java deleted file mode 100644 index 00807001..00000000 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/mapper/SysLogMapper.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.github.cadecode.uniboot.framework.svc.mapper; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.github.cadecode.uniboot.framework.svc.bean.po.SysLog; -import org.apache.ibatis.annotations.Mapper; - -/** - * 系统日志 DAO - * - * @author Cade Li - * @since 2023/5/26 - */ -@Mapper -public interface SysLogMapper extends BaseMapper { -} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysLogService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysLogService.java deleted file mode 100644 index 09b660e9..00000000 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/service/SysLogService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.github.cadecode.uniboot.framework.svc.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.github.cadecode.uniboot.framework.svc.bean.po.SysLog; - -/** - * 系统日志服务 - * - * @author Cade Li - * @since 2023/5/26 - */ -public interface SysLogService extends IService { -} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysLogServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysLogServiceImpl.java deleted file mode 100644 index 817d3a03..00000000 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysLogServiceImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.github.cadecode.uniboot.framework.svc.serviceimpl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.cadecode.uniboot.framework.svc.bean.po.SysLog; -import com.github.cadecode.uniboot.framework.svc.mapper.SysLogMapper; -import com.github.cadecode.uniboot.framework.svc.service.SysLogService; -import org.springframework.stereotype.Service; - -/** - * 系统日志服务实现 - * - * @author Cade Li - * @since 2023/5/26 - */ -@Service -public class SysLogServiceImpl extends ServiceImpl implements SysLogService { -} From dd79ecc69014cbe66c7f29879eba04e96746ff56 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 18 Aug 2023 14:19:38 +0800 Subject: [PATCH 068/244] =?UTF-8?q?refactor:=20=E5=88=A0=E9=99=A4=E5=8E=9F?= =?UTF-8?q?=20SysLog=20=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE=E3=80=81bean?= =?UTF-8?q?=E3=80=81client=20=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/api/bean/dto/SysLogDto.java | 59 ------------------- .../api/feignclient/SysLogClient.java | 24 -------- .../plugin/controller/PlgLogController.java | 10 ---- .../base/plugin/handler/LogSaveHandler.java | 22 ++++--- .../svc/config/FrameSecurityConfig.java | 2 - 5 files changed, 10 insertions(+), 107 deletions(-) delete mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java delete mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java deleted file mode 100644 index 51bef0e4..00000000 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysLogDto.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.github.cadecode.uniboot.framework.api.bean.dto; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * 系统日志 DTO - * - * @author Cade Li - * @since 2023/5/26 - */ -public class SysLogDto { - - /** - * 请求日志信息类 - */ - @Data - @AllArgsConstructor - @NoArgsConstructor - @Builder - public static class SysLogSaveReqDto { - - private String logType; - - private String url; - - private Boolean exceptional; - - private String accessUser; - - private String description; - - private String classMethod; - - private String threadId; - - private String threadName; - - private String ip; - - private String httpMethod; - - private String requestParams; - - private String result; - - private Long timeCost; - - private String os; - - private String browser; - - private String userAgent; - - private String traceId; - } -} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java deleted file mode 100644 index f4c2954b..00000000 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysLogClient.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.github.cadecode.uniboot.framework.api.feignclient; - -import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogSaveReqDto; -import com.github.cadecode.uniboot.framework.api.consts.SvcNameConst; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -import javax.validation.constraints.NotEmpty; -import java.util.List; - -/** - * SysLog feign client - * - * @author Cade Li - * @since 2023/7/28 - */ -@FeignClient(contextId = "SysLogClient", name = SvcNameConst.FRAMEWORK) -public interface SysLogClient { - - @PostMapping("system/log/save") - boolean save(@RequestBody @NotEmpty List dtoList); - -} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java index 76b0981d..857c18c0 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java @@ -4,11 +4,9 @@ import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; -import com.github.cadecode.uniboot.framework.base.annotation.ApiInner; import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgLog; import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo; import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo.PlgLogPageResVo; -import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo.PlgLogSaveReqVo; import com.github.cadecode.uniboot.framework.base.plugin.convert.PlgLogConvert; import com.github.cadecode.uniboot.framework.base.plugin.service.PlgLogService; import com.github.pagehelper.PageHelper; @@ -66,12 +64,4 @@ public PageResult page(@RequestBody @Valid PlgLogVo.PlgLogPageR public boolean delete(@RequestBody @NotEmpty List idList) { return logService.removeBatchByIds(idList); } - - @ApiInner(onlyClient = true) - @ApiOperation("添加") - @PostMapping("save") - public boolean save(@RequestBody @NotEmpty List requestList) { - List poList = PlgLogConvert.INSTANCE.voToPo(requestList); - return logService.saveBatch(poList); - } } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/LogSaveHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/LogSaveHandler.java index c1ca9b70..6eee75ff 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/LogSaveHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/LogSaveHandler.java @@ -10,9 +10,9 @@ import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.handler.AbstractApiLogHandler; import com.github.cadecode.uniboot.common.plugin.log.model.BaseLogInfo; -import com.github.cadecode.uniboot.framework.api.bean.dto.SysLogDto.SysLogSaveReqDto; import com.github.cadecode.uniboot.framework.api.consts.HttpConst; -import com.github.cadecode.uniboot.framework.api.feignclient.SysLogClient; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgLog; +import com.github.cadecode.uniboot.framework.base.plugin.service.PlgLogService; import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; @@ -22,8 +22,6 @@ import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; -import java.util.Collections; - /** * Log 处理器实现-save * @@ -35,12 +33,12 @@ @Component public class LogSaveHandler extends AbstractApiLogHandler { - private final SysLogClient sysLogClient; + private final PlgLogService logService; /** - * 构造 LogInfo + * 构造 Log 信息对象 */ - public SysLogSaveReqDto generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogInfo) { + public PlgLog generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogInfo) { ApiLogger apiLogger = baseLogInfo.getApiLogger(); // 解析 user-agent String userAgentStr = ServletUtil.getHeader(baseLogInfo.getRequest(), HttpConst.HEAD_USER_AGENT, CharsetUtil.CHARSET_UTF_8); @@ -63,7 +61,7 @@ public SysLogSaveReqDto generateLog(ProceedingJoinPoint point, BaseLogInfo baseL description = apiOperation.value(); } } - return SysLogSaveReqDto.builder() + return PlgLog.builder() .logType(apiLogger.type()) .classMethod(point.getSignature().getDeclaringTypeName() + '.' + point.getSignature().getName()) .exceptional(baseLogInfo.getExceptional()) @@ -92,15 +90,15 @@ public void save(ApiLogger apiLogger, Object o) { if (!apiLogger.enableSave()) { return; } - SysLogSaveReqDto dto = (SysLogSaveReqDto) o; + PlgLog po = (PlgLog) o; if (!apiLogger.saveParams()) { - dto.setRequestParams(null); + po.setRequestParams(null); } if (!apiLogger.saveResult()) { - dto.setResult(null); + po.setResult(null); } try { - sysLogClient.save(Collections.singletonList(dto)); + logService.save(po); } catch (Exception e) { log.error("API log [{}]: save fail", apiLogger.type(), e); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java index adeae8b7..4392e093 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java @@ -110,7 +110,5 @@ public void configure(WebSecurity web) { ignoring.antMatchers("/auth/login"); // 放行接口权限表查询接口 ignoring.antMatchers("/system/api/list_roles_vo"); - // 放行系统日志写入接口 - ignoring.antMatchers("/system/log/save"); } } From 9a2bf95bb17ddba63624ce96696ba83f4cb60d44 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 18 Aug 2023 15:41:33 +0800 Subject: [PATCH 069/244] =?UTF-8?q?fix:=20=E5=AD=97=E5=85=B8=20vo=20?= =?UTF-8?q?=E7=BC=BA=E5=B0=91=20defaultFlag=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../github/cadecode/uniboot/framework/svc/bean/vo/SysDictVo.java | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysDictVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysDictVo.java index 5d055cea..24b1f6e9 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysDictVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysDictVo.java @@ -79,6 +79,7 @@ public static class SysDictGetByTypeResVo { private String type; private String label; private String value; + private Boolean defaultFlag; private String description; private Integer orderNum; } From cdda7d6146a7cc7ed2ecf7e70539f733f0154b4b Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 18 Aug 2023 16:46:47 +0800 Subject: [PATCH 070/244] =?UTF-8?q?refactor:=20=E5=88=A0=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E7=9A=84=20vo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/plugin/bean/vo/PlgLogVo.java | 39 ------------------- .../base/plugin/convert/PlgLogConvert.java | 2 - 2 files changed, 41 deletions(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgLogVo.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgLogVo.java index 03634196..f41ac1e2 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgLogVo.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgLogVo.java @@ -28,45 +28,6 @@ public static class PlgLogPageReqVo extends PageParams { } - @Data - public static class PlgLogSaveReqVo { - - private String logType; - - private String url; - - private Boolean exceptional; - - private String accessUser; - - private String description; - - private String classMethod; - - private String threadId; - - private String threadName; - - private String ip; - - private String httpMethod; - - private String requestParams; - - private String result; - - private Long timeCost; - - private String os; - - private String browser; - - private String userAgent; - - private String traceId; - - } - @Data public static class PlgLogPageResVo { diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgLogConvert.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgLogConvert.java index f73c3689..c8b33f2b 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgLogConvert.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgLogConvert.java @@ -2,7 +2,6 @@ import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgLog; import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo.PlgLogPageResVo; -import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgLogVo.PlgLogSaveReqVo; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; @@ -21,5 +20,4 @@ public interface PlgLogConvert { List poToVo(List records); - List voToPo(List requestList); } From 79553c5389b0d11e202167f39d2c9b92675367aa Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 18 Aug 2023 16:47:10 +0800 Subject: [PATCH 071/244] =?UTF-8?q?docs:=20=E6=97=A5=E5=BF=97=E8=A1=A8?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E7=BB=B4=E6=8A=A4=E5=88=B0=E9=80=9A=E7=94=A8?= =?UTF-8?q?=20SQL=EF=BC=8C=E6=97=A5=E5=BF=97=E7=AE=A1=E7=90=86=20=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E6=94=BE=E5=88=B0=20=E5=BC=80=E5=8F=91=E7=AE=A1?= =?UTF-8?q?=E7=90=86=20=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/sql/all_svc.sql | 35 +++++++++++++ .docs/sql/framework/data.sql | 90 +++++++++++++++++----------------- .docs/sql/framework/schema.sql | 35 ------------- 3 files changed, 79 insertions(+), 81 deletions(-) create mode 100644 .docs/sql/all_svc.sql diff --git a/.docs/sql/all_svc.sql b/.docs/sql/all_svc.sql new file mode 100644 index 00000000..e66efde1 --- /dev/null +++ b/.docs/sql/all_svc.sql @@ -0,0 +1,35 @@ +-- ---------------------------- +-- 通用日志表 +-- ---------------------------- +CREATE TABLE IF NOT EXISTS plg_log +( + id BIGINT UNSIGNED, + log_type VARCHAR(50) NOT NULL COMMENT 'log 类型', + url VARCHAR(500) NULL COMMENT 'URL', + exceptional TINYINT(1) NOT NULL COMMENT '是否异常', + access_user VARCHAR(100) NULL COMMENT '访问者', + description VARCHAR(1000) NULL COMMENT '描述', + class_method VARCHAR(500) NOT NULL COMMENT '方法名', + thread_id VARCHAR(100) NULL COMMENT '线程 ID', + thread_name VARCHAR(500) NULL COMMENT '线程名', + ip VARCHAR(50) NULL COMMENT 'IP', + http_method VARCHAR(50) NULL COMMENT 'HTTP 方法', + request_params TEXT NULL COMMENT '参数', + result TEXT NULL COMMENT '结果', + time_cost BIGINT NULL COMMENT '接口耗时', + os VARCHAR(200) NULL COMMENT '操作系统', + browser VARCHAR(200) NULL COMMENT '浏览器', + user_agent VARCHAR(500) NULL COMMENT 'user-agent', + trace_id VARCHAR(100) NULL COMMENT 'trace-id', + + create_time DATETIME DEFAULT CURRENT_TIMESTAMP, + update_time DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + update_user VARCHAR(100) NULL, + PRIMARY KEY (id), + INDEX idx_create_time (create_time), + INDEX idx_log_type (log_type), + INDEX idx_url (url), + INDEX idx_access_user (access_user) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COMMENT '通用日志表'; diff --git a/.docs/sql/framework/data.sql b/.docs/sql/framework/data.sql index d43be740..c29ecfbb 100644 --- a/.docs/sql/framework/data.sql +++ b/.docs/sql/framework/data.sql @@ -24,49 +24,49 @@ INSERT INTO sys_role (id, code, name, description) -- ---------------------------- INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (1, null, 'Home', '/home/demo_home', '/Home/DemoHome', '首页', 1, 0, 1); + VALUE (1, null, 'Home', '/home/demo_home', '/Home/DemoHome', '首页', 1, 1, 1); INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (2, null, 'System', '/system', null, '系统管理', 0, 1, 1); + VALUE (2, null, 'System', '/system', null, '系统管理', 0, 2, 1); INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (3, 2, 'User', '/system/user', '/System/User', '用户管理', 1, 101, 1); + VALUE (201, 2, 'User', '/system/user', '/System/User', '用户管理', 1, 201, 1); INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (4, 2, 'Role', '/system/role', '/System/Role', '角色管理', 1, 102, 1); + VALUE (202, 2, 'Role', '/system/role', '/System/Role', '角色管理', 1, 202, 1); INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (5, 2, 'Menu', '/system/menu', '/System/Menu', '菜单管理', 1, 103, 1); + VALUE (203, 2, 'Menu', '/system/menu', '/System/Menu', '菜单管理', 1, 203, 1); INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (6, 2, 'Api', '/system/api', '/System/Api', 'API管理', 1, 104, 1); + VALUE (204, 2, 'Api', '/system/api', '/System/Api', 'API管理', 1, 204, 1); INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (7, 2, 'Log', '/system/log', '/System/Log', '日志管理', 1, 105, 1); + VALUE (205, 2, 'Dict', '/system/dict', '/System/Dict', '字典管理', 1, 205, 1); + INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (8, 2, 'Dict', '/system/dict', '/System/Dict', '字典管理', 1, 106, 1); - + VALUE (3, null, 'Develop', '/develop', null, '开发管理', 0, 2, 1); INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (9, null, 'Develop', '/develop', null, '开发管理', 0, 2, 1); + VALUE (301, 3, 'Log', '/develop/log', '/Develop/Log', '日志管理', 1, 301, 1); INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (10, 9, 'Icon', '/develop/icon', '/Develop/Icon', '图标', 1, 201, 1); + VALUE (306, 3, 'Icon', '/develop/icon', '/Develop/Icon', '图标', 1, 306, 1); INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (11, 9, 'Echarts', '/develop/echarts', '/Develop/Echarts', 'Echarts 示例', 1, 202, 1); + VALUE (307, 3, 'Echarts', '/develop/echarts', '/Develop/Echarts', 'Echarts 示例', 1, 307, 1); INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (12, 9, 'Swagger', 'http://localhost:8000/doc.html', null, 'Swagger', 1, 203, 1); + VALUE (308, 3, 'Swagger', 'http://localhost:8000/doc.html', null, 'Swagger', 1, 308, 1); INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (13, 9, 'Druid', 'http://localhost:8000/druid', null, 'Druid', 1, 204, 1); + VALUE (309, 3, 'Druid', 'http://localhost:8000/druid', null, 'Druid', 1, 309, 1); INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, enable_flag) - VALUE (100, null, 'GithubUrl', 'https://github.com/cadecode/uni-boot-admin', null, '源码仓库', 1, 100, 1); + VALUE (1000, null, 'GithubUrl', 'https://github.com/cadecode/uni-boot-admin', null, '源码仓库', 1, 1000, 1); -- ---------------------------- -- 插入 API -- ---------------------------- @@ -89,53 +89,51 @@ VALUES (1, 1); INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 2); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 3); +VALUES (1, 201); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 4); +VALUES (1, 202); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 5); +VALUES (1, 203); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 6); +VALUES (1, 204); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 7); +VALUES (1, 205); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 8); +VALUES (1, 3); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 9); +VALUES (1, 301); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 10); +VALUES (1, 306); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 11); +VALUES (1, 307); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 12); +VALUES (1, 308); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 13); +VALUES (1, 309); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (1, 100); +VALUES (1, 1000); INSERT INTO sys_role_menu (role_id, menu_id) VALUES (2, 1); INSERT INTO sys_role_menu (role_id, menu_id) VALUES (2, 2); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (2, 3); -INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (2, 4); +VALUES (2, 201); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (2, 5); +VALUES (2, 202); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (2, 6); +VALUES (2, 203); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (2, 7); +VALUES (2, 204); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (2, 8); +VALUES (2, 205); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (2, 100); +VALUES (2, 1000); INSERT INTO sys_role_menu (role_id, menu_id) VALUES (3, 1); INSERT INTO sys_role_menu (role_id, menu_id) -VALUES (3, 100); +VALUES (3, 1000); -- ---------------------------- -- 插入角色API关系 -- ---------------------------- @@ -150,41 +148,41 @@ VALUES (3, 1); -- ---------------------------- INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, update_user) -VALUES (1667915699808002049, '日志类型', 'logType', '查询', 'Query', '日志类型-查询', 0, 0, '2023-06-11 23:24:26', +VALUES (1, '日志类型', 'logType', '查询', 'Query', '日志类型-查询', 0, 0, '2023-06-11 23:24:26', '2023-06-12 00:11:57', 'admin'); INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, update_user) -VALUES (1667915811166773250, '日志类型', 'logType', '删除', 'Remove', '日志类型-删除', 1, 0, '2023-06-11 23:24:52', +VALUES (2, '日志类型', 'logType', '删除', 'Remove', '日志类型-删除', 1, 0, '2023-06-11 23:24:52', '2023-06-12 00:12:01', 'admin'); INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, update_user) -VALUES (1667915876962820097, '日志类型', 'logType', '更新', 'Update', '日志类型-更新', 2, 0, '2023-06-11 23:25:08', +VALUES (3, '日志类型', 'logType', '更新', 'Update', '日志类型-更新', 2, 0, '2023-06-11 23:25:08', '2023-06-12 00:12:05', 'admin'); INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, update_user) -VALUES (1667915965307445249, '日志类型', 'logType', '添加', 'Add', '日志类型-添加', 3, 0, '2023-06-11 23:25:29', +VALUES (4, '日志类型', 'logType', '添加', 'Add', '日志类型-添加', 3, 0, '2023-06-11 23:25:29', '2023-06-12 00:12:09', 'admin'); INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, update_user) -VALUES (1667916031808135169, '日志类型', 'logType', '鉴权', 'Auth', '日志类型-鉴权', 4, 0, '2023-06-11 23:25:45', +VALUES (5, '日志类型', 'logType', '鉴权', 'Auth', '日志类型-鉴权', 4, 0, '2023-06-11 23:25:45', '2023-06-12 00:12:15', 'admin'); INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, update_user) -VALUES (1667916084467621889, '日志类型', 'logType', '导入', 'Import', '日志类型-导入', 5, 0, '2023-06-11 23:25:58', +VALUES (6, '日志类型', 'logType', '导入', 'Import', '日志类型-导入', 5, 0, '2023-06-11 23:25:58', '2023-06-12 00:12:19', 'admin'); INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, update_user) -VALUES (1667916134056878081, '日志类型', 'logType', '导出', 'Export', '日志类型-导出', 6, 0, '2023-06-11 23:26:09', +VALUES (7, '日志类型', 'logType', '导出', 'Export', '日志类型-导出', 6, 0, '2023-06-11 23:26:09', '2023-06-12 00:12:30', 'admin'); INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, update_user) -VALUES (1667916204034646018, '日志类型', 'logType', '上传', 'Upload', '日志类型-上传', 7, 0, '2023-06-11 23:26:26', +VALUES (8, '日志类型', 'logType', '上传', 'Upload', '日志类型-上传', 7, 0, '2023-06-11 23:26:26', '2023-06-12 00:12:35', 'admin'); INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, update_user) -VALUES (1667916260599029762, '日志类型', 'logType', '下载', 'Download', '日志类型-下载', 8, 0, '2023-06-11 23:26:40', +VALUES (9, '日志类型', 'logType', '下载', 'Download', '日志类型-下载', 8, 0, '2023-06-11 23:26:40', '2023-06-12 00:12:40', 'admin'); INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, update_user) -VALUES (1667916298465206274, '日志类型', 'logType', '其他', 'Other', '日志类型-其他', 9, 0, '2023-06-11 23:26:49', +VALUES (10, '日志类型', 'logType', '其他', 'Other', '日志类型-其他', 9, 0, '2023-06-11 23:26:49', '2023-06-12 00:52:14', 'admin'); diff --git a/.docs/sql/framework/schema.sql b/.docs/sql/framework/schema.sql index 7c516843..18e28204 100644 --- a/.docs/sql/framework/schema.sql +++ b/.docs/sql/framework/schema.sql @@ -118,41 +118,6 @@ CREATE TABLE IF NOT EXISTS sys_role_menu DEFAULT CHARSET = utf8mb4 COMMENT '角色菜单关系表'; -- ---------------------------- --- 系统日志表 --- ---------------------------- -CREATE TABLE IF NOT EXISTS sys_log -( - id BIGINT UNSIGNED, - log_type VARCHAR(50) NOT NULL COMMENT 'log 类型', - url VARCHAR(500) NULL COMMENT 'URL', - exceptional TINYINT(1) NOT NULL COMMENT '是否异常', - access_user VARCHAR(100) NULL COMMENT '访问者', - description VARCHAR(1000) NULL COMMENT '描述', - class_method VARCHAR(500) NOT NULL COMMENT '方法名', - thread_id VARCHAR(100) NULL COMMENT '线程 ID', - thread_name VARCHAR(500) NULL COMMENT '线程名', - ip VARCHAR(50) NULL COMMENT 'IP', - http_method VARCHAR(50) NULL COMMENT 'HTTP 方法', - request_params TEXT NULL COMMENT '参数', - result TEXT NULL COMMENT '结果', - time_cost BIGINT NULL COMMENT '接口耗时', - os VARCHAR(200) NULL COMMENT '操作系统', - browser VARCHAR(200) NULL COMMENT '浏览器', - user_agent VARCHAR(500) NULL COMMENT 'user-agent', - trace_id VARCHAR(100) NULL COMMENT 'trace-id', - - create_time DATETIME DEFAULT CURRENT_TIMESTAMP, - update_time DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, - update_user VARCHAR(100) NULL, - PRIMARY KEY (id), - INDEX idx_create_time (create_time), - INDEX idx_log_type (log_type), - INDEX idx_url (url), - INDEX idx_access_user (access_user) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 - COMMENT '系统日志表'; --- ---------------------------- -- 系统字典表 -- ---------------------------- CREATE TABLE IF NOT EXISTS sys_dict From 529fdc37a2f32815c56785ac6b2f657adbef9bec Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 18 Aug 2023 16:47:33 +0800 Subject: [PATCH 072/244] =?UTF-8?q?docs:=20=E9=85=8D=E7=BD=AE=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=E6=96=87=E6=A1=A3=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=90=84?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=BD=BF=E7=94=A8=E4=B8=8D=E5=90=8C=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/intro/application-config-example.md | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/.docs/intro/application-config-example.md b/.docs/intro/application-config-example.md index 2feb9f70..cd180d74 100644 --- a/.docs/intro/application-config-example.md +++ b/.docs/intro/application-config-example.md @@ -169,12 +169,7 @@ spring: primary: master datasource: master: - url: jdbc:p6spy:mysql://localhost:3306/demo?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai - username: root - password: ENC(donQ3DazAc4/6B+NFSRdxw==) - driver-class-name: com.p6spy.engine.spy.P6SpyDriver - slave1: - url: jdbc:p6spy:mysql://localhost:3306/demo_cluster?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + url: jdbc:p6spy:mysql://localhost:3306/uni_boot_dev?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai username: root password: ENC(donQ3DazAc4/6B+NFSRdxw==) driver-class-name: com.p6spy.engine.spy.P6SpyDriver @@ -210,12 +205,7 @@ spring: primary: master datasource: master: - url: jdbc:p6spy:mysql://localhost:3306/demo?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai - username: root - password: ENC(donQ3DazAc4/6B+NFSRdxw==) - driver-class-name: com.p6spy.engine.spy.P6SpyDriver - slave1: - url: jdbc:p6spy:mysql://localhost:3306/demo_cluster?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai + url: jdbc:p6spy:mysql://localhost:3306/uni_boot_dev_example?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai username: root password: ENC(donQ3DazAc4/6B+NFSRdxw==) driver-class-name: com.p6spy.engine.spy.P6SpyDriver From cf64b67df1c620ef291c29c81fa09eb4aaaf00ff Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 18 Aug 2023 17:07:47 +0800 Subject: [PATCH 073/244] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=9C=8D=E5=8A=A1=E8=AF=B4=E6=98=8E=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/intro/create-service-example.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.docs/intro/create-service-example.md b/.docs/intro/create-service-example.md index e99eaffc..a9f5e621 100644 --- a/.docs/intro/create-service-example.md +++ b/.docs/intro/create-service-example.md @@ -1,5 +1,11 @@ ## 服务创建示例 +### 创建数据库 + +sql/framework 目录下的 sql 是 framework 服务所需的 + +若新建服务依赖了 uni-boot-framework-base,且使用了其他数据库,则需要执行 all_svc.sql + ### 创建模块 创建一个模块 uni-boot-xxx,继承自 uni-boot-dependencies @@ -23,6 +29,7 @@ api 模块供外部调用、DTO 共享,svc 模块提供基础服务 本项目子模块版本维护在根 pom,第三方模块版本维护在 uni-boot-dependencies api 模块基本依赖: + ```xml @@ -44,6 +51,7 @@ api 模块基本依赖: ``` svc 模块基本依赖: + ```xml @@ -144,6 +152,7 @@ public class UniXxxApplication extends SpringBootServletInitializer { ## 配置文件 bootstrap.yml + ```yaml logging: file: @@ -171,7 +180,6 @@ spring: - shared-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} ``` -logback-spring.xml -```xml - -``` +uni-boot-xxx-dev.yml dev 环境配置,推荐托管到 nacos 配置中心,参考 application-config-example.md + +logback-spring.xml 略 From f3532adb6cae83dec81d119cfabbdef942d86f4e Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 18 Aug 2023 18:15:00 +0800 Subject: [PATCH 074/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=20api=20log=20=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../svc/controller/LogExampleController.java | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/LogExampleController.java diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/LogExampleController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/LogExampleController.java new file mode 100644 index 00000000..2625a27c --- /dev/null +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/LogExampleController.java @@ -0,0 +1,34 @@ +package com.github.cadecode.uniboot.example.svc.controller; + +import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; +import com.github.cadecode.uniboot.framework.api.consts.LogTypeConst; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 日志测试 + * + * @author Cade Li + * @since 2023/8/18 + */ +@ApiFormat +@Slf4j +@RequiredArgsConstructor +@Api(tags = "日志测试") +@RestController +@RequestMapping("demo/log") +public class LogExampleController { + + @ApiLogger(type = LogTypeConst.QUERY, description = "测试查询log",enableSave = true) + @ApiOperation("测试查询log") + @GetMapping("query") + public String query() { + return "OK"; + } +} From c0f749f765dcf2a7a27faa29b105c142430543fd Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 18 Aug 2023 22:26:10 +0800 Subject: [PATCH 075/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20rabbit=20?= =?UTF-8?q?=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/plugin/mq/consts/RabbitConst.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/consts/RabbitConst.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/consts/RabbitConst.java index f6ce5665..ad969ca4 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/consts/RabbitConst.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/consts/RabbitConst.java @@ -8,9 +8,26 @@ */ public interface RabbitConst { + // 交换机类型 + + String EXC_TYPE_TOPIC = "topic"; + + String EXC_TYPE_DIRECT = "direct"; + + String EXC_TYPE_FANOUT = "fanout"; + /** * delay 交换机类型 */ String EXC_TYPE_DELAYED = "x-delayed-message"; + // 交换机类型 --- end + + // 交换机名称 + /** + * 默认交换机 + */ + String EXC_DEFAULT = ""; + + // 交换机名称 --- end } From 4d22b80df68837a4609f6658c11bd98af2a1b7bf Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 18 Aug 2023 22:28:44 +0800 Subject: [PATCH 076/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=80=9A?= =?UTF-8?q?=E7=94=A8=20RabbitMq=20=E6=B6=88=E6=81=AF=E8=BD=AC=E6=8D=A2?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/mq/rabbit/RabbitConverter.java | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitConverter.java diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitConverter.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitConverter.java new file mode 100644 index 00000000..3e4c0a9c --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitConverter.java @@ -0,0 +1,63 @@ +package com.github.cadecode.uniboot.common.plugin.mq.rabbit; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.MessageProperties; +import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; +import org.springframework.amqp.support.converter.MessageConversionException; +import org.springframework.amqp.support.converter.SimpleMessageConverter; +import org.springframework.amqp.support.converter.SmartMessageConverter; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Type; + +/** + * 通用 RabbitMq 消息转换器 + * 支持常见两种形式 text 与 json + * + * @author Cade Li + * @since 2023/8/18 + */ +@Slf4j +@RequiredArgsConstructor +@Component +public class RabbitConverter implements SmartMessageConverter { + + private final SimpleMessageConverter simpleMessageConverter = new SimpleMessageConverter(); + private final Jackson2JsonMessageConverter jackson2JsonMessageConverter = new Jackson2JsonMessageConverter(); + + @Override + public Message toMessage(Object object, MessageProperties messageProperties) throws MessageConversionException { + return toMessage(object, messageProperties, null); + } + + @Override + public Message toMessage(Object object, MessageProperties messageProperties, Type genericType) throws MessageConversionException { + if (object instanceof byte[] || object instanceof String) { + return simpleMessageConverter.toMessage(object, messageProperties, genericType); + } + return jackson2JsonMessageConverter.toMessage(object, messageProperties, genericType); + } + + @Override + public Object fromMessage(Message message) throws MessageConversionException { + return fromMessage(message, null); + } + + @Override + public Object fromMessage(Message message, Object conversionHint) throws MessageConversionException { + MessageProperties properties = message.getMessageProperties(); + if (properties == null) { + return message.getBody(); + } + String contentType = properties.getContentType(); + if (contentType != null && contentType.startsWith("text")) { + return simpleMessageConverter.fromMessage(message); + } + if (contentType != null && contentType.equals(MessageProperties.CONTENT_TYPE_JSON)) { + return jackson2JsonMessageConverter.fromMessage(message, conversionHint); + } + return message.getBody(); + } +} From e0c63497f5c47d49f2cd41152de9fe0c2d220bfe Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 19 Aug 2023 09:09:18 +0800 Subject: [PATCH 077/244] =?UTF-8?q?feat:=20swagger=20=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=94=BE=E5=88=B0=E5=85=AC=E5=85=B1=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/plugin/bean/vo/PlgSwaggerVo.java | 26 +++++++ .../controller/PlgSwaggerController.java | 68 +++++++++++++++++++ .../framework/svc/bean/vo/SysApiVo.java | 14 +--- .../svc/controller/SysApiController.java | 38 ----------- 4 files changed, 96 insertions(+), 50 deletions(-) create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgSwaggerVo.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgSwaggerController.java diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgSwaggerVo.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgSwaggerVo.java new file mode 100644 index 00000000..97479892 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgSwaggerVo.java @@ -0,0 +1,26 @@ +package com.github.cadecode.uniboot.framework.base.plugin.bean.vo; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * plugin swagger vo + * + * @author Cade Li + * @since 2023/8/19 + */ +public class PlgSwaggerVo { + + @Data + @AllArgsConstructor + @NoArgsConstructor + @Builder + public static class PlgSwaggerDescResVo { + + private String url; + + private String description; + } +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgSwaggerController.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgSwaggerController.java new file mode 100644 index 00000000..4d2f2787 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgSwaggerController.java @@ -0,0 +1,68 @@ +package com.github.cadecode.uniboot.framework.base.plugin.controller; + +import cn.hutool.core.util.ObjectUtil; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgSwaggerVo.PlgSwaggerDescResVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.mvc.method.RequestMappingInfo; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * Swagger 插件 API + * + * @author Cade Li + * @since 2023/8/19 + */ +@ApiFormat +@Slf4j +@RequiredArgsConstructor +@Api(tags = "Swagger 插件") +@RequestMapping("plugin/swagger") +@RestController +@Validated +public class PlgSwaggerController { + + /** + * 获取全部接口的处理器 mapping + */ + private final RequestMappingHandlerMapping handlerMapping; + + @ApiOperation("获取全部接口及注解") + @PostMapping("list_desc_vo") + public List listSwaggerVo() { + Map methodMap = handlerMapping.getHandlerMethods(); + return methodMap.entrySet() + .stream() + .map(e -> { + ArrayList urlList = new ArrayList<>(e.getKey().getPatternsCondition().getPatterns()); + String url = null; + if (ObjectUtil.isNotEmpty(urlList)) { + url = urlList.get(0); + } + ApiOperation operation = e.getValue().getMethod().getAnnotation(ApiOperation.class); + String description = null; + if (ObjectUtil.isNotNull(operation)) { + description = operation.value(); + } + return PlgSwaggerDescResVo.builder().url(url).description(description).build(); + }) + .filter(o -> ObjectUtil.isNotEmpty(o.getUrl())) + .distinct() + .sorted(Comparator.comparing(PlgSwaggerDescResVo::getUrl)) + .collect(Collectors.toList()); + } +} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysApiVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysApiVo.java index 6199ebb1..8e04b30e 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysApiVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysApiVo.java @@ -1,7 +1,8 @@ package com.github.cadecode.uniboot.framework.svc.bean.vo; import com.github.cadecode.uniboot.common.core.web.response.PageParams; -import lombok.*; +import lombok.Data; +import lombok.EqualsAndHashCode; import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotNull; @@ -56,15 +57,4 @@ public static class SysApiRolesResVo { private List roles; } - - @Data - @AllArgsConstructor - @NoArgsConstructor - @Builder - public static class SysApiSwaggerResVo { - - private String url; - - private String description; - } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java index d30b04a4..abc9062a 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java @@ -1,6 +1,5 @@ package com.github.cadecode.uniboot.framework.svc.controller; -import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.framework.api.consts.KeyPrefixConst; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; @@ -8,7 +7,6 @@ import com.github.cadecode.uniboot.framework.svc.bean.po.SysApi; import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesReqVo; import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiRolesResVo; -import com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiSwaggerResVo; import com.github.cadecode.uniboot.framework.svc.convert.SysApiConvert; import com.github.cadecode.uniboot.framework.svc.service.SysApiService; import com.github.cadecode.uniboot.framework.svc.service.SysRoleService; @@ -24,17 +22,10 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.method.HandlerMethod; -import org.springframework.web.servlet.mvc.method.RequestMappingInfo; -import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import javax.validation.Valid; import javax.validation.constraints.NotEmpty; -import java.util.ArrayList; -import java.util.Comparator; import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; import static com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiAddReqVo; import static com.github.cadecode.uniboot.framework.svc.bean.vo.SysApiVo.SysApiUpdateReqVo; @@ -57,10 +48,6 @@ public class SysApiController { private final SysApiService sysApiService; private final SysRoleService sysRoleService; - /** - * 获取全部接口的处理器 mapping - */ - private final RequestMappingHandlerMapping handlerMapping; @ApiOperation("查询API列表(带角色)") @PostMapping("page_roles_vo") @@ -100,31 +87,6 @@ public List listRolesVoByApiIds(@RequestBody @NotEmpty List listSwaggerVo() { - Map methodMap = handlerMapping.getHandlerMethods(); - return methodMap.entrySet() - .stream() - .map(e -> { - ArrayList urlList = new ArrayList<>(e.getKey().getPatternsCondition().getPatterns()); - String url = null; - if (ObjectUtil.isNotEmpty(urlList)) { - url = urlList.get(0); - } - ApiOperation operation = e.getValue().getMethod().getAnnotation(ApiOperation.class); - String description = null; - if (ObjectUtil.isNotNull(operation)) { - description = operation.value(); - } - return SysApiSwaggerResVo.builder().url(url).description(description).build(); - }) - .filter(o -> ObjectUtil.isNotEmpty(o.getUrl())) - .distinct() - .sorted(Comparator.comparing(SysApiSwaggerResVo::getUrl)) - .collect(Collectors.toList()); - } - @ApiInner(onlyClient = true) @ApiOperation("查询API列表-全部") @PostMapping("list_roles_vo") From c6c8769e65c10a0d47424327072f207e31840c74 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 19 Aug 2023 10:33:52 +0800 Subject: [PATCH 078/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20RabbitMQ?= =?UTF-8?q?=20=E6=B6=88=E6=81=AF=E7=A1=AE=E8=AE=A4=E5=92=8C=E9=80=80?= =?UTF-8?q?=E5=9B=9E=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/mq/rabbit/RabbitCallback.java | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java new file mode 100644 index 00000000..40ec2633 --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java @@ -0,0 +1,83 @@ +package com.github.cadecode.uniboot.common.plugin.mq.rabbit; + +import cn.hutool.core.util.ObjectUtil; +import com.github.cadecode.uniboot.common.plugin.mq.consts.RabbitConst; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.core.Exchange; +import org.springframework.amqp.core.ReturnedMessage; +import org.springframework.amqp.rabbit.connection.CorrelationData; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.amqp.rabbit.core.RabbitTemplate.ConfirmCallback; +import org.springframework.amqp.rabbit.core.RabbitTemplate.ReturnsCallback; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.stereotype.Component; + +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * RabbitMQ 可靠性回调 + * + * @author Cade Li + * @since 2023/8/18 + */ +@Slf4j +@RequiredArgsConstructor +@Component +public class RabbitCallback implements ConfirmCallback, ReturnsCallback, InitializingBean { + + /** + * 交换机名称映射 + */ + private Map exchangeNameMap; + + private final List exchanges; + + private final RabbitTemplate rabbitTemplate; + + /** + * 消息是否成功到达交换机 + */ + @Override + public void confirm(CorrelationData correlationData, boolean ack, String cause) { + // 获取 correlationData id + String correlationId = ObjectUtil.defaultIfNull(correlationData, CorrelationData::getId, ""); + if (!ack) { + log.error("Rabbit message send fail, correlationId:{}, cause:{}", correlationId, cause); + } + } + + /** + * 消息是否成功投递到队列 + */ + @Override + public void returnedMessage(ReturnedMessage returned) { + // 由于 delay 交换机会默认执行退回回调,不需要处理 + if (isExchangeDelayed(returned.getExchange())) { + return; + } + log.error("Rabbit message is returned, message:{}, replyCode:{}. replyText:{}, exchange:{}, routingKey :{}", + returned.getMessage(), returned.getReplyCode(), returned.getReplyText(), returned.getExchange(), returned.getRoutingKey()); + } + + /** + * 判断是否是 delay 交换机 + */ + private boolean isExchangeDelayed(String exchangeName) { + if (ObjectUtil.isEmpty(exchangeNameMap)) { + exchangeNameMap = exchanges.stream().collect(Collectors.toMap(Exchange::getName, o -> o)); + } + // 若是 delay 交换机 + Exchange exchange = exchangeNameMap.get(exchangeName); + return exchange.isDelayed() || RabbitConst.EXC_TYPE_DELAYED.equals(exchange.getType()); + } + + @Override + public void afterPropertiesSet() { + // 设置回调 + rabbitTemplate.setConfirmCallback(this); + rabbitTemplate.setReturnsCallback(this); + } +} From 66f2eb6d75a8edfc2056b5f233823305a749f6ff Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 19 Aug 2023 10:43:20 +0800 Subject: [PATCH 079/244] =?UTF-8?q?feat:=20=E8=AE=BE=E7=BD=AE=20correlatio?= =?UTF-8?q?nData=20=E5=90=8E=E7=BD=AE=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/mq/rabbit/RabbitCallback.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java index 40ec2633..5484d71c 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java @@ -79,5 +79,13 @@ public void afterPropertiesSet() { // 设置回调 rabbitTemplate.setConfirmCallback(this); rabbitTemplate.setReturnsCallback(this); + // 设置 correlationData 后置处理 + rabbitTemplate.setCorrelationDataPostProcessor((message, correlationData) -> { + // 填充 correlationDataId 到 MessageProperties + if (ObjectUtil.isNotNull(correlationData.getId())) { + message.getMessageProperties().setCorrelationId(correlationData.getId()); + } + return correlationData; + }); } } From a26a4743ac7a6cc2baee1cae9d4b0fe7e86ba937 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 19 Aug 2023 15:22:15 +0800 Subject: [PATCH 080/244] =?UTF-8?q?fix:=20correlationData=20=E7=A9=BA?= =?UTF-8?q?=E6=8C=87=E9=92=88=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/mq/rabbit/RabbitCallback.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java index 5484d71c..4e9f1e7a 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java @@ -82,8 +82,9 @@ public void afterPropertiesSet() { // 设置 correlationData 后置处理 rabbitTemplate.setCorrelationDataPostProcessor((message, correlationData) -> { // 填充 correlationDataId 到 MessageProperties - if (ObjectUtil.isNotNull(correlationData.getId())) { - message.getMessageProperties().setCorrelationId(correlationData.getId()); + if (ObjectUtil.isNotNull(correlationData) && ObjectUtil.isNotNull(correlationData.getId())) { + String correlationId = correlationData.getId(); + message.getMessageProperties().setCorrelationId(correlationId); } return correlationData; }); From 5bc94433c92a353b953c89eb553e524ecb919741 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 19 Aug 2023 19:59:18 +0800 Subject: [PATCH 081/244] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E7=A1=AE=E8=AE=A4=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/mq/rabbit/RabbitCallback.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java index 4e9f1e7a..53b4c47e 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java @@ -44,9 +44,11 @@ public class RabbitCallback implements ConfirmCallback, ReturnsCallback, Initial public void confirm(CorrelationData correlationData, boolean ack, String cause) { // 获取 correlationData id String correlationId = ObjectUtil.defaultIfNull(correlationData, CorrelationData::getId, ""); - if (!ack) { - log.error("Rabbit message send fail, correlationId:{}, cause:{}", correlationId, cause); + if (ack) { + log.debug("Rabbit message send ok, id:{}", correlationId); + return; } + log.error("Rabbit message send fail, correlationId:{}, cause:{}", correlationId, cause); } /** From 1625994561870e3a424f7f8b6f714f432811fd52 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 19 Aug 2023 21:01:06 +0800 Subject: [PATCH 082/244] =?UTF-8?q?feat:=20BaseLogInfo=20=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/log/aspect/ApiLoggerAspect.java | 4 +-- .../common/plugin/log/model/BaseLogInfo.java | 24 +++++++---------- .../common/plugin/log/model/LogInfo.java | 27 +++++++++++++++++++ 3 files changed, 39 insertions(+), 16 deletions(-) create mode 100644 common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/model/LogInfo.java diff --git a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java index 19664a73..48ef282b 100644 --- a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java +++ b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java @@ -5,7 +5,7 @@ import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.handler.AbstractApiLogHandler; -import com.github.cadecode.uniboot.common.plugin.log.model.BaseLogInfo; +import com.github.cadecode.uniboot.common.plugin.log.model.LogInfo; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.aspectj.lang.ProceedingJoinPoint; @@ -103,7 +103,7 @@ public void handleLogger(ProceedingJoinPoint point, ApiLogger apiLogger, Object log.error("API log [{}]: request result to json fail", apiLogger.type(), e); } } - BaseLogInfo baseLogInfo = BaseLogInfo.builder().apiLogger(apiLogger).request(attributes.getRequest()) + LogInfo baseLogInfo = LogInfo.builder().apiLogger(apiLogger).request(attributes.getRequest()) .resultStr(resultStr).timeCost(timeCost).exceptional(exceptional).build(); Object logObj = apiLogHandler.generateLog(point, baseLogInfo); // 打印日志 diff --git a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/model/BaseLogInfo.java b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/model/BaseLogInfo.java index 2b1a0ae7..3a1f2856 100644 --- a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/model/BaseLogInfo.java +++ b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/model/BaseLogInfo.java @@ -1,10 +1,6 @@ package com.github.cadecode.uniboot.common.plugin.log.model; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; import javax.servlet.http.HttpServletRequest; @@ -14,14 +10,14 @@ * @author Cade Li * @since 2023/8/13 */ -@Data -@AllArgsConstructor -@NoArgsConstructor -@Builder -public class BaseLogInfo { - private ApiLogger apiLogger; - private Boolean exceptional; - private HttpServletRequest request; - private String resultStr; - private Long timeCost; +public interface BaseLogInfo { + ApiLogger getApiLogger(); + + Boolean getExceptional(); + + HttpServletRequest getRequest(); + + String getResultStr(); + + Long getTimeCost(); } diff --git a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/model/LogInfo.java b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/model/LogInfo.java new file mode 100644 index 00000000..288393ac --- /dev/null +++ b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/model/LogInfo.java @@ -0,0 +1,27 @@ +package com.github.cadecode.uniboot.common.plugin.log.model; + +import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.servlet.http.HttpServletRequest; + +/** + * api log 信息 + * + * @author Cade Li + * @since 2023/8/19 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class LogInfo implements BaseLogInfo { + private ApiLogger apiLogger; + private Boolean exceptional; + private HttpServletRequest request; + private String resultStr; + private Long timeCost; +} From f46a1633118cd32bee7b7c6566ec67d6faf5ddb8 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 19 Aug 2023 22:31:43 +0800 Subject: [PATCH 083/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20RabbitMQ?= =?UTF-8?q?=20=E6=AD=BB=E4=BF=A1=E4=BA=A4=E6=8D=A2=E6=9C=BA=E7=9A=84?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/mq/config/RabbitAutoConfig.java | 6 +++--- .../uniboot/common/plugin/mq/config/RabbitProperties.java | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java index 7feb94c0..88bd379a 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java @@ -45,14 +45,14 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) rabbitProperties.getExchanges().forEach(o -> { Exchange exchange = o.toBuilder().build(); beanFactory.registerSingleton(o.getName(), exchange); - log.info("Rabbit auto register exchange, {}", o.getName()); + log.info("Rabbit auto register exchange, {}, {}", o.getName(), o); }); } if (ObjectUtil.isNotEmpty(rabbitProperties.getQueues())) { rabbitProperties.getQueues().forEach(o -> { Queue queue = o.toBuilder().build(); beanFactory.registerSingleton(o.getName(), queue); - log.info("Rabbit auto register queue, {}", o.getName()); + log.info("Rabbit auto register queue, {}, {}", o.getName(), o); }); } if (ObjectUtil.isNotEmpty(rabbitProperties.getBindings())) { @@ -65,7 +65,7 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) } Binding binding = new Binding(bindName, o.getBindType(), o.getExchangeName(), o.getRoutingKey(), o.getArguments()); beanFactory.registerSingleton(o.getBindName() + "-" + o.getExchangeName(), binding); - log.info("Rabbit auto register binding, {} to {}, bindType:{}", o.getBindName(), o.getExchangeName(), o.getBindType()); + log.info("Rabbit auto register binding, {} to {}, bindType:{}, {}", o.getBindName(), o.getExchangeName(), o.getBindType(), o); }); } } diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java index 90d83e8e..6854428b 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java @@ -52,6 +52,8 @@ public static class QueueBuildProperties { private boolean durable = true; private boolean exclusive; private boolean autoDelete; + private String dlExchange; + private String dlRoutingKey; private Map arguments; public QueueBuilder toBuilder() { @@ -71,6 +73,10 @@ public QueueBuilder toBuilder() { if (autoDelete) { builder.autoDelete(); } + if (!ObjectUtil.hasNull(dlExchange, dlRoutingKey)) { + builder.deadLetterExchange(dlExchange); + builder.deadLetterRoutingKey(dlRoutingKey); + } if (ObjectUtil.isNotEmpty(arguments)) { arguments.forEach(builder::withArgument); } From 45fce60d92d911160d8fa6c8c2460a5ee7d37786 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 00:10:55 +0800 Subject: [PATCH 084/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20RabbitMQ?= =?UTF-8?q?=20=E5=8F=91=E6=B6=88=E6=81=AF=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/plugin/mq/util/RabbitUtil.java | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/RabbitUtil.java diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/RabbitUtil.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/RabbitUtil.java new file mode 100644 index 00000000..3f6058c3 --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/RabbitUtil.java @@ -0,0 +1,64 @@ +package com.github.cadecode.uniboot.common.plugin.mq.util; + +import cn.hutool.core.util.IdUtil; +import lombok.RequiredArgsConstructor; +import org.springframework.amqp.core.MessagePostProcessor; +import org.springframework.amqp.rabbit.connection.CorrelationData; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.stereotype.Component; + +/** + * RabbitMQ 工具类 + * + * @author Cade Li + * @since 2023/8/18 + */ +@RequiredArgsConstructor +@Component +public class RabbitUtil implements InitializingBean { + + private static RabbitTemplate RABBIT_TEMPLATE; + + private final RabbitTemplate rabbitTemplate; + + public static RabbitTemplate template() { + return RABBIT_TEMPLATE; + } + + public static String send(String exchangeName, String routingKey, Object message) { + return send(exchangeName, routingKey, message, msg -> msg); + } + + public static String send(String exchangeName, String routingKey, Object message, MessagePostProcessor postProcessor) { + CorrelationData correlationData = geneCorrelationData(message); + RABBIT_TEMPLATE.convertAndSend(exchangeName, routingKey, message, postProcessor, correlationData); + return correlationData.getId(); + } + + public static String sendDelay(String exchangeName, String routingKey, Object message, Integer delayTime) { + return sendDelay(exchangeName, routingKey, message, delayTime, msg -> msg); + } + + public static String sendDelay(String exchangeName, String routingKey, Object message, Integer delayTime, MessagePostProcessor postProcessor) { + CorrelationData correlationData = geneCorrelationData(message); + RABBIT_TEMPLATE.convertAndSend(exchangeName, routingKey, message, msg -> { + // 注入 delay 时间 + msg.getMessageProperties().setDelay(delayTime); + postProcessor.postProcessMessage(msg, correlationData); + return msg; + }, correlationData); + return correlationData.getId(); + } + + public static CorrelationData geneCorrelationData(Object message) { + // 有 hutool 雪花算法生成 id + String msgId = String.valueOf(IdUtil.getSnowflakeNextIdStr()); + return new CorrelationData(msgId); + } + + @Override + public void afterPropertiesSet() { + RABBIT_TEMPLATE = rabbitTemplate; + } +} From 5d3a472e946b9f8b2b13afd4d2fa9419e6b7637c Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 01:45:43 +0800 Subject: [PATCH 085/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20RabbitMQ?= =?UTF-8?q?=20=E5=8F=91=E6=B6=88=E6=81=AF=E5=B7=A5=E5=85=B7=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/plugin/mq/util/RabbitUtil.java | 38 ++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/RabbitUtil.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/RabbitUtil.java index 3f6058c3..1aa5317a 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/RabbitUtil.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/RabbitUtil.java @@ -1,6 +1,7 @@ package com.github.cadecode.uniboot.common.plugin.mq.util; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; import lombok.RequiredArgsConstructor; import org.springframework.amqp.core.MessagePostProcessor; import org.springframework.amqp.rabbit.connection.CorrelationData; @@ -27,31 +28,50 @@ public static RabbitTemplate template() { } public static String send(String exchangeName, String routingKey, Object message) { - return send(exchangeName, routingKey, message, msg -> msg); + return send(exchangeName, routingKey, message, msg -> msg, null); } public static String send(String exchangeName, String routingKey, Object message, MessagePostProcessor postProcessor) { - CorrelationData correlationData = geneCorrelationData(message); + return send(exchangeName, routingKey, message, postProcessor, null); + } + + public static String send(String exchangeName, String routingKey, Object message, MessagePostProcessor postProcessor, + CorrelationData correlationData) { + // 不存在消息 id 时构造新的 correlationData + if (ObjectUtil.isNull(correlationData) || ObjectUtil.isNull(correlationData.getId())) { + correlationData = geneCorrelationData(); + } RABBIT_TEMPLATE.convertAndSend(exchangeName, routingKey, message, postProcessor, correlationData); return correlationData.getId(); } public static String sendDelay(String exchangeName, String routingKey, Object message, Integer delayTime) { - return sendDelay(exchangeName, routingKey, message, delayTime, msg -> msg); + return sendDelay(exchangeName, routingKey, message, delayTime, msg -> msg, null); } - public static String sendDelay(String exchangeName, String routingKey, Object message, Integer delayTime, MessagePostProcessor postProcessor) { - CorrelationData correlationData = geneCorrelationData(message); + public static String sendDelay(String exchangeName, String routingKey, Object message, Integer delayTime, + MessagePostProcessor postProcessor) { + return sendDelay(exchangeName, routingKey, message, delayTime, postProcessor, null); + } + + public static String sendDelay(String exchangeName, String routingKey, Object message, Integer delayTime, + MessagePostProcessor postProcessor, CorrelationData correlationData) { + CorrelationData currCorrelationData; + if (ObjectUtil.isNull(correlationData) || ObjectUtil.isNull(correlationData.getId())) { + currCorrelationData = geneCorrelationData(); + } else { + currCorrelationData = correlationData; + } RABBIT_TEMPLATE.convertAndSend(exchangeName, routingKey, message, msg -> { // 注入 delay 时间 msg.getMessageProperties().setDelay(delayTime); - postProcessor.postProcessMessage(msg, correlationData); + postProcessor.postProcessMessage(msg, currCorrelationData); return msg; - }, correlationData); - return correlationData.getId(); + }, currCorrelationData); + return currCorrelationData.getId(); } - public static CorrelationData geneCorrelationData(Object message) { + public static CorrelationData geneCorrelationData() { // 有 hutool 雪花算法生成 id String msgId = String.valueOf(IdUtil.getSnowflakeNextIdStr()); return new CorrelationData(msgId); From 007c569eb52f0a894f218cdb5be762eb8eac5e67 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 10:23:34 +0800 Subject: [PATCH 086/244] =?UTF-8?q?feat:=20example=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=20mq=20=E5=8F=91=E9=80=81=20text=20json=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=B6=88=E6=81=AF=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/svc/bean/data/ExampleMsgDo.java | 23 ++++++++++++++ .../svc/consumer/RabbitExampleConsumer.java | 31 +++++++++++++++---- .../svc/controller/MqExampleController.java | 28 +++++++++++------ 3 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/bean/data/ExampleMsgDo.java diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/bean/data/ExampleMsgDo.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/bean/data/ExampleMsgDo.java new file mode 100644 index 00000000..1cc91ffa --- /dev/null +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/bean/data/ExampleMsgDo.java @@ -0,0 +1,23 @@ +package com.github.cadecode.uniboot.example.svc.bean.data; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 测试消息 DO + * + * @author Cade Li + * @since 2023/8/20 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class ExampleMsgDo { + + private String testKey; + + private String testVal; +} diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java index 14505835..c029187b 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java @@ -1,6 +1,7 @@ package com.github.cadecode.uniboot.example.svc.consumer; import cn.hutool.core.util.ObjectUtil; +import com.github.cadecode.uniboot.example.svc.bean.data.ExampleMsgDo; import com.rabbitmq.client.Channel; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.Message; @@ -19,8 +20,23 @@ @Component public class RabbitExampleConsumer { - @RabbitListener(queues = "demo-queue-0", id = "demo-queue-0", ackMode = "AUTO") - public void demoQueue0(String body, Message message, Channel channel) throws IOException { + @RabbitListener(queues = "example-delay-queue-0", id = "example-delay-queue-0", ackMode = "AUTO") + public void exampleDelayQueue0(String body, Message message, Channel channel) throws IOException { + log.info("Received msg:{}", body); + } + + /** + * 测试 SpEL 获取 queue name + */ + @RabbitListener(queues = "#{@'example-delay-queue-1'.name}", id = "example-delay-queue-1") + public void exampleDelayQueue1(String body, Message message, Channel channel) throws IOException { + log.info("Received msg:{}", body); + channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + } + + + @RabbitListener(queues = "example-biz-queue-0", id = "example-biz-queue-0", ackMode = "AUTO") + public void exampleBizQueue0(String body, Message message, Channel channel) throws IOException { log.info("Received msg:{}", body); // 自动模式下,测试重试机制 if (ObjectUtil.equal(body, "ERROR")) { @@ -28,9 +44,12 @@ public void demoQueue0(String body, Message message, Channel channel) throws IOE } } - @RabbitListener(queues = "#{@'demo-queue-1'.name}", id = "demo-queue-1") - public void demoQueue1(String body, Message message, Channel channel) throws IOException { - log.info("Received msg:{}", body); - channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); + /** + * 测试用对象获取消息 + */ + @RabbitListener(queues = "example-biz-queue-1", id = "example-biz-queue-1", ackMode = "AUTO") + public void exampleBizQueue1(ExampleMsgDo msgDo, Message message, Channel channel) throws IOException { + log.info("Received msg:{}", msgDo); } + } diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java index 78fe9a78..ac232fef 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java @@ -1,11 +1,12 @@ package com.github.cadecode.uniboot.example.svc.controller; +import com.github.cadecode.uniboot.common.plugin.mq.util.RabbitUtil; +import com.github.cadecode.uniboot.example.svc.bean.data.ExampleMsgDo; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -25,16 +26,25 @@ @RequestMapping("demo/mq") public class MqExampleController { - private final RabbitTemplate rabbitTemplate; - @ApiOperation("发送 delay 消息") @GetMapping("send_delay") - public boolean sendDelay(@RequestParam String exc, @RequestParam String routingKey, - @RequestParam String msg, @RequestParam Integer ms) { - rabbitTemplate.convertAndSend(exc, routingKey, msg, message -> { - message.getMessageProperties().setDelay(ms); - return message; - }); + public boolean sendDelay(@RequestParam String exchange, @RequestParam String routingKey, @RequestParam Integer ms) { + RabbitUtil.sendDelay(exchange, routingKey, "Test delay msg", ms); + return true; + } + + @ApiOperation("发送字符串消息") + @GetMapping("send_str") + public boolean sendStr(@RequestParam String exchange, @RequestParam String routingKey) { + RabbitUtil.send(exchange, routingKey, "Test str msg"); + return true; + } + + @ApiOperation("发送对象消息") + @GetMapping("send_obj") + public boolean sendObj(@RequestParam String exchange, @RequestParam String routingKey) { + ExampleMsgDo msgDo = new ExampleMsgDo("Test key", "Test name"); + RabbitUtil.send(exchange, routingKey, msgDo); return true; } } From 440e860169485e40949b9322a8fa56b0bc283b54 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 15:44:07 +0800 Subject: [PATCH 087/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E6=B6=88=E6=81=AF=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/mq/config/TxMsgAutoConfig.java | 20 ++++ .../plugin/mq/config/TxMsgProperties.java | 110 ++++++++++++++++++ .../plugin/mq/exception/TxMsgException.java | 29 +++++ .../mq/handler/AbstractTxMsgHandler.java | 34 ++++++ .../common/plugin/mq/model/BaseTxMsg.java | 23 ++++ .../uniboot/common/plugin/mq/model/TxMsg.java | 37 ++++++ .../common/plugin/mq/task/TxMsgTask.java | 40 +++++++ .../common/plugin/mq/util/TxMsgKit.java | 56 +++++++++ 8 files changed, 349 insertions(+) create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgAutoConfig.java create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgProperties.java create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/exception/TxMsgException.java create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/handler/AbstractTxMsgHandler.java create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/BaseTxMsg.java create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/TxMsg.java create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/task/TxMsgTask.java create mode 100644 common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgAutoConfig.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgAutoConfig.java new file mode 100644 index 00000000..277f9505 --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgAutoConfig.java @@ -0,0 +1,20 @@ +package com.github.cadecode.uniboot.common.plugin.mq.config; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +/** + * 事务消息自动配置 + * + * @author Cade Li + * @since 2023/8/20 + */ +@Slf4j +@RequiredArgsConstructor +@EnableConfigurationProperties(TxMsgProperties.class) +@Configuration +public class TxMsgAutoConfig { + +} diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgProperties.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgProperties.java new file mode 100644 index 00000000..bbf2c97b --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgProperties.java @@ -0,0 +1,110 @@ +package com.github.cadecode.uniboot.common.plugin.mq.config; + +import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.bean.copier.CopyOptions; +import cn.hutool.core.util.ObjectUtil; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * TxMsg 配置 + * + * @author Cade Li + * @since 2023/8/19 + */ +@Data +@ConfigurationProperties(TxMsgProperties.ENV_CONF_TX_MSG_PREFIX) +public class TxMsgProperties implements InitializingBean { + + public static final String ENV_CONF_TX_MSG_PREFIX = "uni-boot.mq.tx-msg"; + + public static final long DEFAULT_RETRY_FIX_DELAY = 30 * 1000; + + public static final long DEFAULT_CLEAR_FIX_DELAY = 2 * 60 * 60 * 1000; + + public static final long DEFAULT_AUTO_CLEAR_INTERVAL = 60 * 60 * 1000; + + // 重试默认属性 + + public static final int DEFAULT_MAX_RETRY_TIMES = 3; + + public static final long DEFAULT_BACKOFF_INIT_INTERVAL = 10 * 1000; + + public static final double DEFAULT_BACKOFF_MULTIPLIER = 2.0; + + public static final long DEFAULT_BACKOFF_MAX_INTERVAL = 30 * 60 * 1000; + + // 重试默认属性 --end + + /** + * 定时重试间隔时间 + */ + private Long retryFixDelay = DEFAULT_RETRY_FIX_DELAY; + + /** + * 定时清理记录间隔时间 + */ + private Long clearFixDelay = DEFAULT_CLEAR_FIX_DELAY; + + /** + * 是否开启自动清理 + */ + private Boolean autoClear = true; + + /** + * 自动清理多久之前的记录 + */ + private Long autoClearInterval = DEFAULT_AUTO_CLEAR_INTERVAL; + + /** + * 事务消息配置 + */ + private MsgOption defaultMsgOption; + + public MsgOption createMsgOption(MsgOption msgOption) { + if (ObjectUtil.isNull(msgOption)) { + msgOption = new MsgOption(); + } + BeanUtil.copyProperties(defaultMsgOption, msgOption, CopyOptions.create().setOverride(false)); + return msgOption; + } + + @Override + public void afterPropertiesSet() { + MsgOption allDefaultOption = MsgOption.builder() + .maxRetryTimes(DEFAULT_MAX_RETRY_TIMES) + .backoffInitInterval(DEFAULT_BACKOFF_INIT_INTERVAL) + .backoffMultiplier(DEFAULT_BACKOFF_MULTIPLIER) + .backoffMaxInterval(DEFAULT_BACKOFF_MAX_INTERVAL) + .build(); + if (ObjectUtil.isNull(defaultMsgOption)) { + defaultMsgOption = allDefaultOption; + } else { + BeanUtil.copyProperties(allDefaultOption, defaultMsgOption, CopyOptions.create().setOverride(false)); + } + } + + @Data + @AllArgsConstructor + @NoArgsConstructor + @Builder + public static class MsgOption { + + // 重试相关属性 + + private Integer maxRetryTimes; + + private Long backoffInitInterval; + + private Double backoffMultiplier; + + private Long backoffMaxInterval; + + // 重试相关属性 -- end + } + +} diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/exception/TxMsgException.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/exception/TxMsgException.java new file mode 100644 index 00000000..d96f8732 --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/exception/TxMsgException.java @@ -0,0 +1,29 @@ +package com.github.cadecode.uniboot.common.plugin.mq.exception; + +/** + * 事务消息异常 + * + * @author Cade Li + * @since 2023/8/20 + */ +public class TxMsgException extends RuntimeException { + public TxMsgException() { + super(); + } + + public TxMsgException(String message) { + super(message); + } + + public TxMsgException(String message, Throwable cause) { + super(message, cause); + } + + public TxMsgException(Throwable cause) { + super(cause); + } + + protected TxMsgException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/handler/AbstractTxMsgHandler.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/handler/AbstractTxMsgHandler.java new file mode 100644 index 00000000..9c18edcd --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/handler/AbstractTxMsgHandler.java @@ -0,0 +1,34 @@ +package com.github.cadecode.uniboot.common.plugin.mq.handler; + +import com.github.cadecode.uniboot.common.plugin.mq.config.TxMsgProperties.MsgOption; +import com.github.cadecode.uniboot.common.plugin.mq.model.BaseTxMsg; +import org.springframework.amqp.core.ReturnedMessage; +import org.springframework.amqp.rabbit.connection.CorrelationData; + +/** + * 事务消息处理器 + * 1. 入库/更新 + * 2. 重试/清理记录 + * + * @author Cade Li + * @since 2023/8/20 + */ +public abstract class AbstractTxMsgHandler { + + public abstract void doRetry(); + + public abstract void doClear(Long autoClearInterval); + + public abstract void sendNoTransaction(BaseTxMsg txMsg, MsgOption msgOption); + + public abstract void sendNotCommit(BaseTxMsg txMsg, MsgOption msgOption); + + public abstract void saveBeforeRegister(BaseTxMsg txMsg, MsgOption msgOption); + + public abstract void sendCommitted(BaseTxMsg txMsg, MsgOption msgOption); + + public abstract void handleConfirm(CorrelationData correlationData, boolean ack, String cause); + + public abstract void handleReturned(ReturnedMessage returned); + +} diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/BaseTxMsg.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/BaseTxMsg.java new file mode 100644 index 00000000..6e9c4162 --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/BaseTxMsg.java @@ -0,0 +1,23 @@ +package com.github.cadecode.uniboot.common.plugin.mq.model; + +/** + * 事务消息基本信息抽象 + * + * @author Cade Li + * @since 2023/8/19 + */ +public interface BaseTxMsg { + + String getId(); + + String getBizType(); + + String getBizKey(); + + String getExchange(); + + String getRoutingKey(); + + String getMessage(); + +} diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/TxMsg.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/TxMsg.java new file mode 100644 index 00000000..a686fcb3 --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/TxMsg.java @@ -0,0 +1,37 @@ +package com.github.cadecode.uniboot.common.plugin.mq.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 事务消息基本信息 + * + * @author Cade Li + * @since 2023/8/18 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class TxMsg implements BaseTxMsg { + + private String id; + + /** + * 业务类型 + */ + private String bizType; + + /** + * 业务键 + */ + private String bizKey; + + private String exchange; + + private String routingKey; + + private String message; +} diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/task/TxMsgTask.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/task/TxMsgTask.java new file mode 100644 index 00000000..bad5035b --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/task/TxMsgTask.java @@ -0,0 +1,40 @@ +package com.github.cadecode.uniboot.common.plugin.mq.task; + +import cn.hutool.core.util.ObjectUtil; +import com.github.cadecode.uniboot.common.plugin.mq.config.TxMsgProperties; +import com.github.cadecode.uniboot.common.plugin.mq.handler.AbstractTxMsgHandler; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.boot.context.event.ApplicationStartedEvent; +import org.springframework.context.event.EventListener; +import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; +import org.springframework.stereotype.Component; + +/** + * 事务消息定时任务 + * + * @author Cade Li + * @since 2023/8/19 + */ +@Slf4j +@RequiredArgsConstructor +@Component +public class TxMsgTask { + + private final ThreadPoolTaskScheduler taskScheduler; + + private final TxMsgProperties txMsgProperties; + + private final AbstractTxMsgHandler txMsgTaskHandler; + + @EventListener(ApplicationStartedEvent.class) + public void onApplicationStartedEvent() { + log.info("TxMsg task do retry started"); + taskScheduler.scheduleWithFixedDelay(txMsgTaskHandler::doRetry, txMsgProperties.getRetryFixDelay()); + log.info("TxMsg task do clear start, {}", txMsgProperties.getAutoClear()); + if (ObjectUtil.equal(txMsgProperties.getAutoClear(), true)) { + taskScheduler.scheduleWithFixedDelay(() -> txMsgTaskHandler.doClear(txMsgProperties.getAutoClearInterval()), + txMsgProperties.getClearFixDelay()); + } + } +} diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java new file mode 100644 index 00000000..27c75427 --- /dev/null +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java @@ -0,0 +1,56 @@ +package com.github.cadecode.uniboot.common.plugin.mq.util; + +import com.github.cadecode.uniboot.common.plugin.mq.config.TxMsgProperties; +import com.github.cadecode.uniboot.common.plugin.mq.config.TxMsgProperties.MsgOption; +import com.github.cadecode.uniboot.common.plugin.mq.handler.AbstractTxMsgHandler; +import com.github.cadecode.uniboot.common.plugin.mq.model.BaseTxMsg; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.transaction.support.TransactionSynchronization; +import org.springframework.transaction.support.TransactionSynchronizationManager; + +/** + * 事务消息工具类 + * + * @author Cade Li + * @since 2023/8/19 + */ +@Slf4j +@RequiredArgsConstructor +@Component +public class TxMsgKit { + + private final TxMsgProperties txMsgProperties; + + private final AbstractTxMsgHandler txMsgTaskHandler; + + public void sendTx(BaseTxMsg txMsg) { + sendTx(txMsg, null); + } + + public void sendTx(BaseTxMsg txMsg, MsgOption msgOption) { + MsgOption currOption = txMsgProperties.createMsgOption(msgOption); + // 若没有事务 + if (!TransactionSynchronizationManager.isActualTransactionActive()) { + log.error("TxMsg send need transaction, txMsg:{}, biz:{}_{}", txMsg.getId(), txMsg.getBizType(), txMsg.getBizKey()); + txMsgTaskHandler.sendNoTransaction(txMsg, currOption); + return; + } + // 持久化 + txMsgTaskHandler.saveBeforeRegister(txMsg, msgOption); + // 注册到事务管理器 + TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { + @Override + public void afterCompletion(int status) { + // 判断状态 + if (status != TransactionSynchronization.STATUS_COMMITTED) { + log.error("TxMsg send not committed, txMsg:{}, biz:{}_{}", txMsg.getId(), txMsg.getBizType(), txMsg.getBizKey()); + txMsgTaskHandler.sendNotCommit(txMsg, currOption); + return; + } + txMsgTaskHandler.sendCommitted(txMsg, currOption); + } + }); + } +} From cfe64b698ee09d70c1939ecf3bebe4439cd91643 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 15:45:16 +0800 Subject: [PATCH 088/244] =?UTF-8?q?feat:=20RabbitMQ=20=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E6=B7=BB=E5=8A=A0=E5=A4=84=E7=90=86=E9=92=A9?= =?UTF-8?q?=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/mq/rabbit/RabbitCallback.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java index 53b4c47e..30877776 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java @@ -2,6 +2,7 @@ import cn.hutool.core.util.ObjectUtil; import com.github.cadecode.uniboot.common.plugin.mq.consts.RabbitConst; +import com.github.cadecode.uniboot.common.plugin.mq.handler.AbstractTxMsgHandler; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.Exchange; @@ -37,6 +38,8 @@ public class RabbitCallback implements ConfirmCallback, ReturnsCallback, Initial private final RabbitTemplate rabbitTemplate; + private final AbstractTxMsgHandler txMsgTaskHandler; + /** * 消息是否成功到达交换机 */ @@ -46,9 +49,11 @@ public void confirm(CorrelationData correlationData, boolean ack, String cause) String correlationId = ObjectUtil.defaultIfNull(correlationData, CorrelationData::getId, ""); if (ack) { log.debug("Rabbit message send ok, id:{}", correlationId); + txMsgTaskHandler.handleConfirm(correlationData, true, cause); return; } log.error("Rabbit message send fail, correlationId:{}, cause:{}", correlationId, cause); + txMsgTaskHandler.handleConfirm(correlationData, false, cause); } /** @@ -62,6 +67,7 @@ public void returnedMessage(ReturnedMessage returned) { } log.error("Rabbit message is returned, message:{}, replyCode:{}. replyText:{}, exchange:{}, routingKey :{}", returned.getMessage(), returned.getReplyCode(), returned.getReplyText(), returned.getExchange(), returned.getRoutingKey()); + txMsgTaskHandler.handleReturned(returned); } /** From 7fd47a8dfb340fc6a0887b6abc522cd0602d113c Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 15:46:00 +0800 Subject: [PATCH 089/244] =?UTF-8?q?build:=20base=20=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E5=BC=95=E5=85=A5=20mq=20=E6=8F=92=E4=BB=B6=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/framework_base/pom.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/framework/framework_base/pom.xml b/framework/framework_base/pom.xml index 1ac86375..6a86c5a7 100644 --- a/framework/framework_base/pom.xml +++ b/framework/framework_base/pom.xml @@ -51,6 +51,10 @@ com.github.cadecode uni-boot-common-plugin-log + + com.github.cadecode + uni-boot-common-plugin-mq + com.github.cadecode uni-boot-framework-api From 7bdf0a8da771e0f3c064cd3f20369a29848e070c Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 15:48:09 +0800 Subject: [PATCH 090/244] =?UTF-8?q?feat:=20=E5=88=9B=E5=BB=BA=20PlgMqMsg?= =?UTF-8?q?=20=E8=A1=A8=E5=AE=9E=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/plugin/bean/po/PlgMqMsg.java | 59 +++++++++++++++++++ .../base/plugin/enums/ConsumeStateEnum.java | 35 +++++++++++ .../base/plugin/enums/SendStateEnum.java | 40 +++++++++++++ .../base/plugin/mapper/PlgMqMsgMapper.java | 15 +++++ .../base/plugin/service/PlgMqMsgService.java | 13 ++++ .../serviceimpl/PlgMqMsgServiceImpl.java | 17 ++++++ 6 files changed, 179 insertions(+) create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/enums/ConsumeStateEnum.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/enums/SendStateEnum.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/mapper/PlgMqMsgMapper.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/service/PlgMqMsgService.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/serviceimpl/PlgMqMsgServiceImpl.java diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java new file mode 100644 index 00000000..3d5265df --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java @@ -0,0 +1,59 @@ +package com.github.cadecode.uniboot.framework.base.plugin.bean.po; + +import com.baomidou.mybatisplus.annotation.*; +import com.github.cadecode.uniboot.framework.base.plugin.enums.ConsumeStateEnum; +import com.github.cadecode.uniboot.framework.base.plugin.enums.SendStateEnum; +import lombok.Data; + +import java.util.Date; + +/** + * MQ 消息实体 + * + * @author Cade Li + * @since 2023/8/19 + */ +@Data +@TableName(autoResultMap = true) +public class PlgMqMsg { + + @TableId(type = IdType.ASSIGN_ID) + private String id; + + private String bizType; + + private String bizKey; + + private String exchange; + + private String routingKey; + + private String message; + + private SendStateEnum sendState; + + private ConsumeStateEnum consumeState; + + private Date nextRetryTime; + + private String cause; + + private Integer currRetryTimes; + + private Integer maxRetryTimes; + + private Long backoffInitInterval; + + private Double backoffMultiplier; + + private Long backoffMaxInterval; + + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @TableField(fill = FieldFill.UPDATE) + private Date updateTime; + + @TableField(fill = FieldFill.INSERT_UPDATE) + private String updateUser; +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/enums/ConsumeStateEnum.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/enums/ConsumeStateEnum.java new file mode 100644 index 00000000..394fac54 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/enums/ConsumeStateEnum.java @@ -0,0 +1,35 @@ +package com.github.cadecode.uniboot.framework.base.plugin.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.Getter; + +/** + * 消费者消息确认状态枚举 + * + * @author Cade Li + * @since 2023/8/19 + */ +@Getter +public enum ConsumeStateEnum { + + /** + * 确认 + */ + ACK("ACK"), + + /** + * 不确认 + */ + NACK("NACK"), + + ; + + @EnumValue + @JsonValue + private final String state; + + ConsumeStateEnum(String state) { + this.state = state; + } +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/enums/SendStateEnum.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/enums/SendStateEnum.java new file mode 100644 index 00000000..1ea80df1 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/enums/SendStateEnum.java @@ -0,0 +1,40 @@ +package com.github.cadecode.uniboot.framework.base.plugin.enums; + +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonValue; +import lombok.Getter; + +/** + * 生产者消息发送状态枚举 + * + * @author Cade Li + * @since 2023/8/19 + */ +@Getter +public enum SendStateEnum { + + /** + * 处理中 + */ + PREPARING("PREPARING"), + + /** + * 完成 + */ + OVER("OVER"), + + /** + * 失败 + */ + FAIL("FAIL"), + + ; + + @EnumValue + @JsonValue + private final String state; + + SendStateEnum(String state) { + this.state = state; + } +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/mapper/PlgMqMsgMapper.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/mapper/PlgMqMsgMapper.java new file mode 100644 index 00000000..08a787e9 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/mapper/PlgMqMsgMapper.java @@ -0,0 +1,15 @@ +package com.github.cadecode.uniboot.framework.base.plugin.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgMqMsg; +import org.apache.ibatis.annotations.Mapper; + +/** + * PlgMqMsg Mapper + * + * @author Cade Li + * @since 2023/8/19 + */ +@Mapper +public interface PlgMqMsgMapper extends BaseMapper { +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/service/PlgMqMsgService.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/service/PlgMqMsgService.java new file mode 100644 index 00000000..b9ce5d2e --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/service/PlgMqMsgService.java @@ -0,0 +1,13 @@ +package com.github.cadecode.uniboot.framework.base.plugin.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgMqMsg; + +/** + * PlgMqMsg Service + * + * @author Cade Li + * @since 2023/5/26 + */ +public interface PlgMqMsgService extends IService { +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/serviceimpl/PlgMqMsgServiceImpl.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/serviceimpl/PlgMqMsgServiceImpl.java new file mode 100644 index 00000000..2ea6e845 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/serviceimpl/PlgMqMsgServiceImpl.java @@ -0,0 +1,17 @@ +package com.github.cadecode.uniboot.framework.base.plugin.serviceimpl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgMqMsg; +import com.github.cadecode.uniboot.framework.base.plugin.mapper.PlgMqMsgMapper; +import com.github.cadecode.uniboot.framework.base.plugin.service.PlgMqMsgService; +import org.springframework.stereotype.Service; + +/** + * PlgMqMsg Service 实现 + * + * @author Cade Li + * @since 2023/5/26 + */ +@Service +public class PlgMqMsgServiceImpl extends ServiceImpl implements PlgMqMsgService { +} From bde17d631739ffa20881cfb0b1372b5913c10705 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 16:06:09 +0800 Subject: [PATCH 091/244] =?UTF-8?q?docs:=20=E7=BB=B4=E6=8A=A4=20SQL=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=8C=E6=B7=BB=E5=8A=A0=20PlgMqMsg=20?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=20SQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/intro/create-service-example.md | 2 +- .docs/sql/all_svc.sql | 35 -------------- .docs/sql/common-plguin.sql | 69 +++++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 36 deletions(-) delete mode 100644 .docs/sql/all_svc.sql create mode 100644 .docs/sql/common-plguin.sql diff --git a/.docs/intro/create-service-example.md b/.docs/intro/create-service-example.md index a9f5e621..f2f07c98 100644 --- a/.docs/intro/create-service-example.md +++ b/.docs/intro/create-service-example.md @@ -4,7 +4,7 @@ sql/framework 目录下的 sql 是 framework 服务所需的 -若新建服务依赖了 uni-boot-framework-base,且使用了其他数据库,则需要执行 all_svc.sql +若新建服务依赖了 uni-boot-framework-base,且使用了其他数据库,则需要执行 common-plguin.sql ### 创建模块 diff --git a/.docs/sql/all_svc.sql b/.docs/sql/all_svc.sql deleted file mode 100644 index e66efde1..00000000 --- a/.docs/sql/all_svc.sql +++ /dev/null @@ -1,35 +0,0 @@ --- ---------------------------- --- 通用日志表 --- ---------------------------- -CREATE TABLE IF NOT EXISTS plg_log -( - id BIGINT UNSIGNED, - log_type VARCHAR(50) NOT NULL COMMENT 'log 类型', - url VARCHAR(500) NULL COMMENT 'URL', - exceptional TINYINT(1) NOT NULL COMMENT '是否异常', - access_user VARCHAR(100) NULL COMMENT '访问者', - description VARCHAR(1000) NULL COMMENT '描述', - class_method VARCHAR(500) NOT NULL COMMENT '方法名', - thread_id VARCHAR(100) NULL COMMENT '线程 ID', - thread_name VARCHAR(500) NULL COMMENT '线程名', - ip VARCHAR(50) NULL COMMENT 'IP', - http_method VARCHAR(50) NULL COMMENT 'HTTP 方法', - request_params TEXT NULL COMMENT '参数', - result TEXT NULL COMMENT '结果', - time_cost BIGINT NULL COMMENT '接口耗时', - os VARCHAR(200) NULL COMMENT '操作系统', - browser VARCHAR(200) NULL COMMENT '浏览器', - user_agent VARCHAR(500) NULL COMMENT 'user-agent', - trace_id VARCHAR(100) NULL COMMENT 'trace-id', - - create_time DATETIME DEFAULT CURRENT_TIMESTAMP, - update_time DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, - update_user VARCHAR(100) NULL, - PRIMARY KEY (id), - INDEX idx_create_time (create_time), - INDEX idx_log_type (log_type), - INDEX idx_url (url), - INDEX idx_access_user (access_user) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 - COMMENT '通用日志表'; diff --git a/.docs/sql/common-plguin.sql b/.docs/sql/common-plguin.sql new file mode 100644 index 00000000..46ff84af --- /dev/null +++ b/.docs/sql/common-plguin.sql @@ -0,0 +1,69 @@ +-- ---------------------------- +-- 通用日志表 +-- ---------------------------- +CREATE TABLE IF NOT EXISTS plg_log +( + id BIGINT UNSIGNED, + log_type VARCHAR(50) NOT NULL COMMENT 'log 类型', + url VARCHAR(500) NULL COMMENT 'URL', + exceptional TINYINT(1) NOT NULL COMMENT '是否异常', + access_user VARCHAR(100) NULL COMMENT '访问者', + description VARCHAR(1000) NULL COMMENT '描述', + class_method VARCHAR(500) NOT NULL COMMENT '方法名', + thread_id VARCHAR(100) NULL COMMENT '线程 ID', + thread_name VARCHAR(500) NULL COMMENT '线程名', + ip VARCHAR(50) NULL COMMENT 'IP', + http_method VARCHAR(50) NULL COMMENT 'HTTP 方法', + request_params TEXT NULL COMMENT '参数', + result TEXT NULL COMMENT '结果', + time_cost BIGINT NULL COMMENT '接口耗时', + os VARCHAR(200) NULL COMMENT '操作系统', + browser VARCHAR(200) NULL COMMENT '浏览器', + user_agent VARCHAR(500) NULL COMMENT 'user-agent', + trace_id VARCHAR(100) NULL COMMENT 'trace-id', + + create_time DATETIME DEFAULT CURRENT_TIMESTAMP, + update_time DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + update_user VARCHAR(100) NULL, + PRIMARY KEY (id), + INDEX idx_create_time (create_time), + INDEX idx_log_type (log_type), + INDEX idx_url (url), + INDEX idx_access_user (access_user) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COMMENT '通用日志表'; + +-- ---------------------------- +-- 消息记录表 +-- ---------------------------- +CREATE TABLE IF NOT EXISTS plg_mq_msg +( + id BIGINT UNSIGNED, + biz_type VARCHAR(200) NOT NULL COMMENT '业务类型', + biz_key VARCHAR(200) NULL COMMENT '业务键', + exchange TINYINT(200) NOT NULL COMMENT '交换机', + routing_key VARCHAR(200) NULL COMMENT '路由 key', + message TEXT NULL COMMENT '消息内容', + send_state VARCHAR(100) NOT NULL COMMENT '发送方状态', + consume_state VARCHAR(100) NULL COMMENT '消费方状态', + next_retry_time DATE NULL COMMENT '下次重试时间', + cause TEXT NULL COMMENT '重试原因', + curr_retry_times INT NULL COMMENT '当前重试次数', + max_retry_times INT NULL COMMENT '最大重试次数', + backoff_init_interval BIGINT UNSIGNED NULL COMMENT '退避-初始时间间隔', + backoff_multiplier DOUBLE NULL COMMENT '退避-乘子', + backoff_max_interval BIGINT UNSIGNED NULL COMMENT '退避-最大时间间隔', + + create_time DATETIME DEFAULT CURRENT_TIMESTAMP, + update_time DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + update_user VARCHAR(100) NULL, + PRIMARY KEY (id), + INDEX idx_create_time (create_time, send_state), + INDEX idx_next_retry_time (next_retry_time, send_state), + INDEX idx_biz_type (biz_type), + INDEX idx_send_state (send_state) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COMMENT '消息记录表'; + From 8ef8baa7accf23f1bb9acd9b87ad778d5049470b Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 20:48:08 +0800 Subject: [PATCH 092/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=8F=91?= =?UTF-8?q?=E9=80=81=20TxMsg=20=E5=89=8D=E6=A0=A1=E9=AA=8C=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/mq/handler/AbstractTxMsgHandler.java | 2 ++ .../github/cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java | 1 + 2 files changed, 3 insertions(+) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/handler/AbstractTxMsgHandler.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/handler/AbstractTxMsgHandler.java index 9c18edcd..93e8a1eb 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/handler/AbstractTxMsgHandler.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/handler/AbstractTxMsgHandler.java @@ -19,6 +19,8 @@ public abstract class AbstractTxMsgHandler { public abstract void doClear(Long autoClearInterval); + public abstract void checkBeforeSend(BaseTxMsg txMsg, MsgOption msgOption); + public abstract void sendNoTransaction(BaseTxMsg txMsg, MsgOption msgOption); public abstract void sendNotCommit(BaseTxMsg txMsg, MsgOption msgOption); diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java index 27c75427..9207dd0d 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java @@ -30,6 +30,7 @@ public void sendTx(BaseTxMsg txMsg) { } public void sendTx(BaseTxMsg txMsg, MsgOption msgOption) { + txMsgTaskHandler.checkBeforeSend(txMsg, msgOption); MsgOption currOption = txMsgProperties.createMsgOption(msgOption); // 若没有事务 if (!TransactionSynchronizationManager.isActualTransactionActive()) { From 94ba2f3222c1005ec947d3a5cd0b09e4505fa143 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 20:48:48 +0800 Subject: [PATCH 093/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E6=B6=88=E6=81=AF=E5=A4=84=E7=90=86=E5=99=A8=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/plugin/convert/PlgMqMsgConvert.java | 36 +++ .../base/plugin/handler/MqTxMsgHandler.java | 250 ++++++++++++++++++ 2 files changed, 286 insertions(+) create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java new file mode 100644 index 00000000..22304424 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java @@ -0,0 +1,36 @@ +package com.github.cadecode.uniboot.framework.base.plugin.convert; + +import com.github.cadecode.uniboot.common.plugin.mq.config.TxMsgProperties.MsgOption; +import com.github.cadecode.uniboot.common.plugin.mq.model.BaseTxMsg; +import com.github.cadecode.uniboot.common.plugin.mq.model.TxMsg; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgMqMsg; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +/** + * PlgMqMsg Bean Convert + * + * @author Cade Li + * @since 2023/8/19 + */ +@Mapper +public interface PlgMqMsgConvert { + + PlgMqMsgConvert INSTANCE = Mappers.getMapper(PlgMqMsgConvert.class); + + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + @Mapping(target = "sendState", ignore = true) + @Mapping(target = "nextRetryTime", ignore = true) + @Mapping(target = "currRetryTimes", ignore = true) + @Mapping(target = "createTime", ignore = true) + @Mapping(target = "consumeState", ignore = true) + @Mapping(target = "cause", ignore = true) + PlgMqMsg baseTxMsgToPo(BaseTxMsg txMsg, MsgOption msgOption); + + TxMsg poToTxMsg(PlgMqMsg po); + + MsgOption poToMsgOption(PlgMqMsg po); + +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java new file mode 100644 index 00000000..0ec69885 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java @@ -0,0 +1,250 @@ +package com.github.cadecode.uniboot.framework.base.plugin.handler; + +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateTime; +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.exceptions.ExceptionUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.github.cadecode.uniboot.common.core.util.AssertUtil; +import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; +import com.github.cadecode.uniboot.common.plugin.cache.util.RedisLockKit; +import com.github.cadecode.uniboot.common.plugin.mq.config.TxMsgProperties.MsgOption; +import com.github.cadecode.uniboot.common.plugin.mq.exception.TxMsgException; +import com.github.cadecode.uniboot.common.plugin.mq.handler.AbstractTxMsgHandler; +import com.github.cadecode.uniboot.common.plugin.mq.model.BaseTxMsg; +import com.github.cadecode.uniboot.common.plugin.mq.model.TxMsg; +import com.github.cadecode.uniboot.common.plugin.mq.util.RabbitUtil; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgMqMsg; +import com.github.cadecode.uniboot.framework.base.plugin.convert.PlgMqMsgConvert; +import com.github.cadecode.uniboot.framework.base.plugin.enums.SendStateEnum; +import com.github.cadecode.uniboot.framework.base.plugin.service.PlgMqMsgService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.core.Message; +import org.springframework.amqp.core.ReturnedMessage; +import org.springframework.amqp.rabbit.connection.CorrelationData; +import org.springframework.stereotype.Component; + +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 事务消息处理器实现 + * + * @author Cade Li + * @since 2023/8/20 + */ +@Slf4j +@RequiredArgsConstructor +@Component +public class MqTxMsgHandler extends AbstractTxMsgHandler { + + // lock key prefix + public static final String LOCK_TX_MSG_DO_RETRY = "txMsg:doRetry"; + public static final String LOCK_TX_MSG_DO_CLEAR = "txMsg:doClear"; + + // rabbit head + + public static final String HEAD_TX_MSG_ID = "TX_MSG_ID"; + public static final String HEAD_TX_MSG_BIZ_TYPE = "TX_MSG_BIZ_TYPE"; + public static final String HEAD_TX_MSG_BIZ_KEY = "TX_MSG_BIZ_KEY"; + + // rabbit head -- end + + private final RedisLockKit redisLockKit; + + private final PlgMqMsgService mqMsgService; + + @Override + public void doRetry() { + String lockKey = KeyGeneUtil.lockKey(LOCK_TX_MSG_DO_RETRY); + try { + redisLockKit.lock(lockKey); + Date currDate = new Date(); + List msgList = mqMsgService.lambdaQuery() + .ge(PlgMqMsg::getNextRetryTime, currDate) + .eq(PlgMqMsg::getSendState, SendStateEnum.FAIL) + .ltSql(PlgMqMsg::getCurrRetryTimes, "max_retry_times") + .list(); + long retryCount = msgList.stream() + .filter(o -> { + int newCurrRetryTimes = o.getCurrRetryTimes() + 1; + Date newNextRetryTime = calcNextRetryTime(new Date(), o.getBackoffInitInterval(), + o.getBackoffMultiplier(), o.getBackoffMaxInterval(), newCurrRetryTimes); + try { + TxMsg txMsg = PlgMqMsgConvert.INSTANCE.poToTxMsg(o); + doSendCommittedOrRetry(txMsg); + boolean updateFlag = updateRetryTime(o.getId(), newCurrRetryTimes, newNextRetryTime); + log.debug("TxMsg sent on retry, updateFlag:{}, txMsg:{}, biz:{}_{}", updateFlag, o.getId(), o.getBizType(), o.getBizKey()); + } catch (Exception e) { + boolean updateFlag = updateRetryTime(o.getId(), newCurrRetryTimes, newNextRetryTime); + log.debug("TxMsg send fail on retry, updateFlag:{}, txMsg:{}, biz:{}_{}", updateFlag, o.getId(), o.getBizType(), o.getBizKey()); + return false; + } + return true; + }) + .count(); + log.debug("TxMsg retry, retryCount:{}, currDate:{}, queryCount:{}", retryCount, currDate, msgList.size()); + } finally { + redisLockKit.unlock(lockKey); + } + } + + private boolean updateRetryTime(String txMsgId, int newCurrRetryTimes, Date newNextRetryTime) { + return mqMsgService.lambdaUpdate() + .eq(PlgMqMsg::getId, txMsgId) + .set(PlgMqMsg::getCurrRetryTimes, newCurrRetryTimes) + .set(PlgMqMsg::getNextRetryTime, newNextRetryTime) + .update(new PlgMqMsg()); + } + + @Override + public void doClear(Long autoClearInterval) { + String lockKey = KeyGeneUtil.lockKey(LOCK_TX_MSG_DO_CLEAR); + try { + redisLockKit.lock(lockKey); + Date currDate = new Date(); + // 查找指定时长之前的记录 + DateTime lastDate = DateUtil.offset(currDate, DateField.MILLISECOND, -autoClearInterval.intValue()); + List msgList = mqMsgService.lambdaQuery() + .select(PlgMqMsg::getId) + .le(PlgMqMsg::getCreateTime, lastDate) + .eq(PlgMqMsg::getSendState, SendStateEnum.OVER) + .list(); + List batchIdList = msgList.stream().map(PlgMqMsg::getId).collect(Collectors.toList()); + boolean removeFlag = mqMsgService.removeBatchByIds(batchIdList); + log.debug("TxMsg clear, {}, currDate:{}, queryCount:{}", removeFlag, currDate, msgList.size()); + } finally { + redisLockKit.unlock(lockKey); + } + } + + @Override + public void checkBeforeSend(BaseTxMsg txMsg, MsgOption msgOption) { + AssertUtil.isNull(txMsg, () -> new TxMsgException("TxMsg null")); + AssertUtil.isNull(txMsg.getExchange(), () -> new TxMsgException("TxMsg exchange null")); + AssertUtil.isNull(txMsg.getRoutingKey(), () -> new TxMsgException("TxMsg routing key null")); + AssertUtil.isNull(txMsg.getMessage(), () -> new TxMsgException("TxMsg message null")); + // 没有设置 id 时生成雪花 id + if (ObjectUtil.isEmpty(txMsg.getId())) { + ((TxMsg) txMsg).setId(String.valueOf(IdWorker.getId(txMsg))); + } + } + + @Override + public void sendNoTransaction(BaseTxMsg txMsg, MsgOption msgOption) { + // 空实现 + } + + @Override + public void sendNotCommit(BaseTxMsg txMsg, MsgOption msgOption) { + // 空实现 + } + + @Override + public void saveBeforeRegister(BaseTxMsg txMsg, MsgOption msgOption) { + // 转换 bean + PlgMqMsg plgMqMsg = PlgMqMsgConvert.INSTANCE.baseTxMsgToPo(txMsg, msgOption); + plgMqMsg.setSendState(SendStateEnum.PREPARING); + // 计算下次重试时间 + plgMqMsg.setCurrRetryTimes(0); + plgMqMsg.setNextRetryTime(calcNextRetryTime(new Date(), plgMqMsg.getBackoffInitInterval(), + plgMqMsg.getBackoffMultiplier(), plgMqMsg.getBackoffMaxInterval(), plgMqMsg.getCurrRetryTimes())); + mqMsgService.save(plgMqMsg); + log.debug("TxMsg save, txMsg:{}, biz:{}_{}", txMsg.getId(), txMsg.getBizType(), txMsg.getBizKey()); + } + + private Date calcNextRetryTime(Date lastDate, long initInterval, double multiplier, + long maxInterval, long currRetryTimes) { + long newInterval = initInterval + Math.round(currRetryTimes * multiplier); + if (newInterval > maxInterval) { + newInterval = maxInterval; + } + return DateUtil.offset(lastDate, DateField.MILLISECOND, (int) newInterval); + } + + @Override + public void sendCommitted(BaseTxMsg txMsg, MsgOption msgOption) { + try { + doSendCommittedOrRetry(txMsg); + log.debug("TxMsg sent on committed, txMsg:{}, biz:{}_{}", txMsg.getId(), txMsg.getBizType(), txMsg.getBizKey()); + } catch (Exception e) { + boolean updateFailFlag = updatePreparingToFail(txMsg.getId(), ExceptionUtil.stacktraceToString(e)); + log.debug("TxMsg send fail on committed, {}, txMsg:{}, biz:{}_{}", updateFailFlag, txMsg.getId(), txMsg.getBizType(), txMsg.getBizKey()); + } + } + + private void doSendCommittedOrRetry(BaseTxMsg txMsg) { + // 放入 txMsg id + CorrelationData correlationData = new CorrelationData(txMsg.getId()); + RabbitUtil.send(txMsg.getExchange(), txMsg.getRoutingKey(), txMsg.getMessage(), msg -> { + // 设置事务消息 head 标记 + msg.getMessageProperties().getHeaders().put(HEAD_TX_MSG_ID, txMsg.getId()); + msg.getMessageProperties().getHeaders().put(HEAD_TX_MSG_BIZ_TYPE, txMsg.getBizType()); + msg.getMessageProperties().getHeaders().put(HEAD_TX_MSG_BIZ_KEY, txMsg.getBizKey()); + // 设置 ReturnedMessage,用于 callback 中获取消息 + correlationData.setReturned(new ReturnedMessage(msg, -9999, null, null, null)); + return msg; + }, correlationData); + } + + @Override + public void handleConfirm(CorrelationData correlationData, boolean ack, String cause) { + if (ObjectUtil.isNull(correlationData) || ObjectUtil.isNull(correlationData.getId()) + || ObjectUtil.isNull(correlationData.getReturned())) { + return; + } + Message message = correlationData.getReturned().getMessage(); + boolean txMsgFlag = message.getMessageProperties().getHeaders().containsKey(HEAD_TX_MSG_ID); + if (!txMsgFlag) { + return; + } + String bizType = String.valueOf(message.getMessageProperties().getHeaders().get(HEAD_TX_MSG_BIZ_TYPE)); + String bizKey = String.valueOf(message.getMessageProperties().getHeaders().get(HEAD_TX_MSG_BIZ_KEY)); + if (!ack) { + boolean updateFailFlag = updatePreparingToFail(correlationData.getId(), cause); + log.debug("TxMsg set to FAIL on confirm, {}, txMsg:{}, biz:{}_{}", updateFailFlag, correlationData.getId(), bizType, bizKey); + return; + } + // ack 为 true 时,状态改为 OVER + boolean updateOverFlag = mqMsgService.lambdaUpdate() + .eq(PlgMqMsg::getId, correlationData.getId()) + .eq(PlgMqMsg::getSendState, SendStateEnum.PREPARING) + .set(PlgMqMsg::getSendState, SendStateEnum.OVER) + .update(new PlgMqMsg()); + log.debug("TxMsg set to OVER on confirm, {}, txMsg:{}, biz:{}_{}", updateOverFlag, correlationData.getId(), bizType, bizKey); + } + + @Override + public void handleReturned(ReturnedMessage returned) { + Message message = returned.getMessage(); + boolean txMsgFlag = message.getMessageProperties().getHeaders().containsKey(HEAD_TX_MSG_ID); + if (!txMsgFlag) { + return; + } + String txMsgId = String.valueOf(message.getMessageProperties().getHeaders().get(HEAD_TX_MSG_ID)); + String bizType = String.valueOf(message.getMessageProperties().getHeaders().get(HEAD_TX_MSG_BIZ_TYPE)); + String bizKey = String.valueOf(message.getMessageProperties().getHeaders().get(HEAD_TX_MSG_BIZ_KEY)); + // 构造 cause + String cause = StrUtil.format("Returned message:{}, replyCode:{}. replyText:{}, exchange:{}, routingKey :{}", + returned.getMessage(), returned.getReplyCode(), returned.getReplyText(), returned.getExchange(), returned.getRoutingKey()); + boolean updateFailFlag = mqMsgService.lambdaUpdate() + .eq(PlgMqMsg::getId, txMsgId) + .set(PlgMqMsg::getSendState, SendStateEnum.FAIL) + .set(PlgMqMsg::getCause, cause) + .update(new PlgMqMsg()); + log.debug("TxMsg set to FAIL on returned, {}, txMsg:{}, biz:{}_{}", updateFailFlag, txMsgId, bizType, bizKey); + } + + private boolean updatePreparingToFail(String txMsgId, String cause) { + return mqMsgService.lambdaUpdate() + .eq(PlgMqMsg::getId, txMsgId) + .eq(PlgMqMsg::getSendState, SendStateEnum.PREPARING) + .set(PlgMqMsg::getSendState, SendStateEnum.FAIL) + .set(PlgMqMsg::getCause, cause) + .update(new PlgMqMsg()); + } +} From 65186d8ef9eaeb6d97f0cc489baf8eb331661ea2 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 21:18:16 +0800 Subject: [PATCH 094/244] =?UTF-8?q?fix:=20=E5=85=A5=E5=8F=82=20msgOption?= =?UTF-8?q?=20=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java index 9207dd0d..b97fa4c2 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/TxMsgKit.java @@ -30,8 +30,8 @@ public void sendTx(BaseTxMsg txMsg) { } public void sendTx(BaseTxMsg txMsg, MsgOption msgOption) { - txMsgTaskHandler.checkBeforeSend(txMsg, msgOption); MsgOption currOption = txMsgProperties.createMsgOption(msgOption); + txMsgTaskHandler.checkBeforeSend(txMsg, currOption); // 若没有事务 if (!TransactionSynchronizationManager.isActualTransactionActive()) { log.error("TxMsg send need transaction, txMsg:{}, biz:{}_{}", txMsg.getId(), txMsg.getBizType(), txMsg.getBizKey()); @@ -39,7 +39,7 @@ public void sendTx(BaseTxMsg txMsg, MsgOption msgOption) { return; } // 持久化 - txMsgTaskHandler.saveBeforeRegister(txMsg, msgOption); + txMsgTaskHandler.saveBeforeRegister(txMsg, currOption); // 注册到事务管理器 TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { @Override From e8967f12d3c5e44344379f71aec7a735ec3b9326 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 21:50:09 +0800 Subject: [PATCH 095/244] =?UTF-8?q?docs:=20=E7=BB=B4=E6=8A=A4=20SQL=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=8C=E4=BF=AE=E6=94=B9=20PlgMqMsg=20?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=20SQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/sql/common-plguin.sql | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.docs/sql/common-plguin.sql b/.docs/sql/common-plguin.sql index 46ff84af..233d213f 100644 --- a/.docs/sql/common-plguin.sql +++ b/.docs/sql/common-plguin.sql @@ -40,14 +40,14 @@ CREATE TABLE IF NOT EXISTS plg_log CREATE TABLE IF NOT EXISTS plg_mq_msg ( id BIGINT UNSIGNED, - biz_type VARCHAR(200) NOT NULL COMMENT '业务类型', + biz_type VARCHAR(200) NULL COMMENT '业务类型', biz_key VARCHAR(200) NULL COMMENT '业务键', - exchange TINYINT(200) NOT NULL COMMENT '交换机', - routing_key VARCHAR(200) NULL COMMENT '路由 key', - message TEXT NULL COMMENT '消息内容', - send_state VARCHAR(100) NOT NULL COMMENT '发送方状态', + exchange VARCHAR(200) NOT NULL COMMENT '交换机', + routing_key VARCHAR(200) NOT NULL COMMENT '路由 key', + message TEXT NOT NULL COMMENT '消息内容', + send_state VARCHAR(100) NULL COMMENT '发送方状态', consume_state VARCHAR(100) NULL COMMENT '消费方状态', - next_retry_time DATE NULL COMMENT '下次重试时间', + next_retry_time DATETIME NULL COMMENT '下次重试时间', cause TEXT NULL COMMENT '重试原因', curr_retry_times INT NULL COMMENT '当前重试次数', max_retry_times INT NULL COMMENT '最大重试次数', From 8972aeeee9af43cfa0c62f4b0728788e0513ad0d Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 22:15:52 +0800 Subject: [PATCH 096/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=98=AF=E5=90=A6=20Returned=20=E7=9A=84=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/plugin/handler/MqTxMsgHandler.java | 57 +++++++++++++------ 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java index 0ec69885..91884421 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java @@ -54,6 +54,11 @@ public class MqTxMsgHandler extends AbstractTxMsgHandler { // rabbit head -- end + /** + * TxMsg CorrelationData ReturnedMessage 默认 replyText + */ + public static final String DEFAULT_TX_MSG_REPLY_TEXT = "DEFAULT_TX_MSG_REPLY"; + private final RedisLockKit redisLockKit; private final PlgMqMsgService mqMsgService; @@ -65,10 +70,13 @@ public void doRetry() { redisLockKit.lock(lockKey); Date currDate = new Date(); List msgList = mqMsgService.lambdaQuery() - .ge(PlgMqMsg::getNextRetryTime, currDate) + .le(PlgMqMsg::getNextRetryTime, currDate) .eq(PlgMqMsg::getSendState, SendStateEnum.FAIL) .ltSql(PlgMqMsg::getCurrRetryTimes, "max_retry_times") .list(); + if (ObjectUtil.isEmpty(msgList)) { + return; + } long retryCount = msgList.stream() .filter(o -> { int newCurrRetryTimes = o.getCurrRetryTimes() + 1; @@ -114,6 +122,9 @@ public void doClear(Long autoClearInterval) { .le(PlgMqMsg::getCreateTime, lastDate) .eq(PlgMqMsg::getSendState, SendStateEnum.OVER) .list(); + if (ObjectUtil.isEmpty(msgList)) { + return; + } List batchIdList = msgList.stream().map(PlgMqMsg::getId).collect(Collectors.toList()); boolean removeFlag = mqMsgService.removeBatchByIds(batchIdList); log.debug("TxMsg clear, {}, currDate:{}, queryCount:{}", removeFlag, currDate, msgList.size()); @@ -136,7 +147,7 @@ public void checkBeforeSend(BaseTxMsg txMsg, MsgOption msgOption) { @Override public void sendNoTransaction(BaseTxMsg txMsg, MsgOption msgOption) { - // 空实现 + throw new TxMsgException("TxMsg no transaction"); } @Override @@ -186,7 +197,8 @@ private void doSendCommittedOrRetry(BaseTxMsg txMsg) { msg.getMessageProperties().getHeaders().put(HEAD_TX_MSG_BIZ_TYPE, txMsg.getBizType()); msg.getMessageProperties().getHeaders().put(HEAD_TX_MSG_BIZ_KEY, txMsg.getBizKey()); // 设置 ReturnedMessage,用于 callback 中获取消息 - correlationData.setReturned(new ReturnedMessage(msg, -9999, null, null, null)); + ReturnedMessage defaultReturnedMessage = new ReturnedMessage(msg, 0, DEFAULT_TX_MSG_REPLY_TEXT, null, null); + correlationData.setReturned(defaultReturnedMessage); return msg; }, correlationData); } @@ -198,31 +210,48 @@ public void handleConfirm(CorrelationData correlationData, boolean ack, String c return; } Message message = correlationData.getReturned().getMessage(); - boolean txMsgFlag = message.getMessageProperties().getHeaders().containsKey(HEAD_TX_MSG_ID); - if (!txMsgFlag) { + if (!isTxMsg(message)) { return; } String bizType = String.valueOf(message.getMessageProperties().getHeaders().get(HEAD_TX_MSG_BIZ_TYPE)); String bizKey = String.valueOf(message.getMessageProperties().getHeaders().get(HEAD_TX_MSG_BIZ_KEY)); + // 若交换机没有 ack if (!ack) { boolean updateFailFlag = updatePreparingToFail(correlationData.getId(), cause); log.debug("TxMsg set to FAIL on confirm, {}, txMsg:{}, biz:{}_{}", updateFailFlag, correlationData.getId(), bizType, bizKey); return; } - // ack 为 true 时,状态改为 OVER + // 若被退回,不修改状态 + if (isTxReturned(correlationData.getReturned())) { + return; + } + // 状态改为 OVER boolean updateOverFlag = mqMsgService.lambdaUpdate() .eq(PlgMqMsg::getId, correlationData.getId()) - .eq(PlgMqMsg::getSendState, SendStateEnum.PREPARING) .set(PlgMqMsg::getSendState, SendStateEnum.OVER) .update(new PlgMqMsg()); log.debug("TxMsg set to OVER on confirm, {}, txMsg:{}, biz:{}_{}", updateOverFlag, correlationData.getId(), bizType, bizKey); } + private boolean updatePreparingToFail(String txMsgId, String cause) { + return mqMsgService.lambdaUpdate() + .eq(PlgMqMsg::getId, txMsgId) + .eq(PlgMqMsg::getSendState, SendStateEnum.PREPARING) + .set(PlgMqMsg::getSendState, SendStateEnum.FAIL) + .set(PlgMqMsg::getCause, cause) + .update(new PlgMqMsg()); + } + + private boolean isTxReturned(ReturnedMessage returned) { + // 当不是默认 replyText,说明被 ReturnsCallback 覆盖 + // RabbitMq 会先回调 ReturnsCallback + return !DEFAULT_TX_MSG_REPLY_TEXT.equals(returned.getReplyText()); + } + @Override public void handleReturned(ReturnedMessage returned) { Message message = returned.getMessage(); - boolean txMsgFlag = message.getMessageProperties().getHeaders().containsKey(HEAD_TX_MSG_ID); - if (!txMsgFlag) { + if (!isTxMsg(message)) { return; } String txMsgId = String.valueOf(message.getMessageProperties().getHeaders().get(HEAD_TX_MSG_ID)); @@ -231,6 +260,7 @@ public void handleReturned(ReturnedMessage returned) { // 构造 cause String cause = StrUtil.format("Returned message:{}, replyCode:{}. replyText:{}, exchange:{}, routingKey :{}", returned.getMessage(), returned.getReplyCode(), returned.getReplyText(), returned.getExchange(), returned.getRoutingKey()); + // 状态改为 FAIL boolean updateFailFlag = mqMsgService.lambdaUpdate() .eq(PlgMqMsg::getId, txMsgId) .set(PlgMqMsg::getSendState, SendStateEnum.FAIL) @@ -239,12 +269,7 @@ public void handleReturned(ReturnedMessage returned) { log.debug("TxMsg set to FAIL on returned, {}, txMsg:{}, biz:{}_{}", updateFailFlag, txMsgId, bizType, bizKey); } - private boolean updatePreparingToFail(String txMsgId, String cause) { - return mqMsgService.lambdaUpdate() - .eq(PlgMqMsg::getId, txMsgId) - .eq(PlgMqMsg::getSendState, SendStateEnum.PREPARING) - .set(PlgMqMsg::getSendState, SendStateEnum.FAIL) - .set(PlgMqMsg::getCause, cause) - .update(new PlgMqMsg()); + private boolean isTxMsg(Message message) { + return message.getMessageProperties().getHeaders().containsKey(HEAD_TX_MSG_ID); } } From 8816d23d6f2c31267216255a9edf227e62a00feb Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 22:40:10 +0800 Subject: [PATCH 097/244] =?UTF-8?q?feat:=20=E5=BD=93=E5=89=8D=E9=87=8D?= =?UTF-8?q?=E8=AF=95=E6=AC=A1=E6=95=B0=E6=94=B9=E4=B8=BA=E5=89=A9=E4=BD=99?= =?UTF-8?q?=E9=87=8D=E8=AF=95=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/plugin/bean/po/PlgMqMsg.java | 2 +- .../base/plugin/handler/MqTxMsgHandler.java | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java index 3d5265df..694e13d6 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java @@ -38,7 +38,7 @@ public class PlgMqMsg { private String cause; - private Integer currRetryTimes; + private Integer leftRetryTimes; private Integer maxRetryTimes; diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java index 91884421..0b14e5c8 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java @@ -72,23 +72,23 @@ public void doRetry() { List msgList = mqMsgService.lambdaQuery() .le(PlgMqMsg::getNextRetryTime, currDate) .eq(PlgMqMsg::getSendState, SendStateEnum.FAIL) - .ltSql(PlgMqMsg::getCurrRetryTimes, "max_retry_times") + .gt(PlgMqMsg::getLeftRetryTimes, 0) .list(); if (ObjectUtil.isEmpty(msgList)) { return; } long retryCount = msgList.stream() .filter(o -> { - int newCurrRetryTimes = o.getCurrRetryTimes() + 1; + int newLeftRetryTimes = o.getLeftRetryTimes() - 1; Date newNextRetryTime = calcNextRetryTime(new Date(), o.getBackoffInitInterval(), - o.getBackoffMultiplier(), o.getBackoffMaxInterval(), newCurrRetryTimes); + o.getBackoffMultiplier(), o.getBackoffMaxInterval(), o.getMaxRetryTimes() - newLeftRetryTimes); try { TxMsg txMsg = PlgMqMsgConvert.INSTANCE.poToTxMsg(o); doSendCommittedOrRetry(txMsg); - boolean updateFlag = updateRetryTime(o.getId(), newCurrRetryTimes, newNextRetryTime); + boolean updateFlag = updateRetryTime(o.getId(), newLeftRetryTimes, newNextRetryTime); log.debug("TxMsg sent on retry, updateFlag:{}, txMsg:{}, biz:{}_{}", updateFlag, o.getId(), o.getBizType(), o.getBizKey()); } catch (Exception e) { - boolean updateFlag = updateRetryTime(o.getId(), newCurrRetryTimes, newNextRetryTime); + boolean updateFlag = updateRetryTime(o.getId(), newLeftRetryTimes, newNextRetryTime); log.debug("TxMsg send fail on retry, updateFlag:{}, txMsg:{}, biz:{}_{}", updateFlag, o.getId(), o.getBizType(), o.getBizKey()); return false; } @@ -101,10 +101,10 @@ public void doRetry() { } } - private boolean updateRetryTime(String txMsgId, int newCurrRetryTimes, Date newNextRetryTime) { + private boolean updateRetryTime(String txMsgId, int newLeftRetryTimes, Date newNextRetryTime) { return mqMsgService.lambdaUpdate() .eq(PlgMqMsg::getId, txMsgId) - .set(PlgMqMsg::getCurrRetryTimes, newCurrRetryTimes) + .set(PlgMqMsg::getLeftRetryTimes, newLeftRetryTimes) .set(PlgMqMsg::getNextRetryTime, newNextRetryTime) .update(new PlgMqMsg()); } @@ -161,9 +161,10 @@ public void saveBeforeRegister(BaseTxMsg txMsg, MsgOption msgOption) { PlgMqMsg plgMqMsg = PlgMqMsgConvert.INSTANCE.baseTxMsgToPo(txMsg, msgOption); plgMqMsg.setSendState(SendStateEnum.PREPARING); // 计算下次重试时间 - plgMqMsg.setCurrRetryTimes(0); + plgMqMsg.setLeftRetryTimes(plgMqMsg.getMaxRetryTimes()); plgMqMsg.setNextRetryTime(calcNextRetryTime(new Date(), plgMqMsg.getBackoffInitInterval(), - plgMqMsg.getBackoffMultiplier(), plgMqMsg.getBackoffMaxInterval(), plgMqMsg.getCurrRetryTimes())); + plgMqMsg.getBackoffMultiplier(), plgMqMsg.getBackoffMaxInterval(), + plgMqMsg.getMaxRetryTimes() - plgMqMsg.getLeftRetryTimes())); mqMsgService.save(plgMqMsg); log.debug("TxMsg save, txMsg:{}, biz:{}_{}", txMsg.getId(), txMsg.getBizType(), txMsg.getBizKey()); } From 0b063b568de8241beea77940747f6e905c9306ba Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 22:40:43 +0800 Subject: [PATCH 098/244] =?UTF-8?q?docs:=20=E7=BB=B4=E6=8A=A4=20SQL=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=8C=E5=BD=93=E5=89=8D=E9=87=8D=E8=AF=95?= =?UTF-8?q?=E6=AC=A1=E6=95=B0=E6=94=B9=E4=B8=BA=E5=89=A9=E4=BD=99=E9=87=8D?= =?UTF-8?q?=E8=AF=95=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/sql/common-plguin.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.docs/sql/common-plguin.sql b/.docs/sql/common-plguin.sql index 233d213f..77c71ffc 100644 --- a/.docs/sql/common-plguin.sql +++ b/.docs/sql/common-plguin.sql @@ -47,9 +47,9 @@ CREATE TABLE IF NOT EXISTS plg_mq_msg message TEXT NOT NULL COMMENT '消息内容', send_state VARCHAR(100) NULL COMMENT '发送方状态', consume_state VARCHAR(100) NULL COMMENT '消费方状态', - next_retry_time DATETIME NULL COMMENT '下次重试时间', + next_retry_time DATETIME NULL COMMENT '下次重试时间', cause TEXT NULL COMMENT '重试原因', - curr_retry_times INT NULL COMMENT '当前重试次数', + left_retry_times INT NULL COMMENT '剩余重试次数', max_retry_times INT NULL COMMENT '最大重试次数', backoff_init_interval BIGINT UNSIGNED NULL COMMENT '退避-初始时间间隔', backoff_multiplier DOUBLE NULL COMMENT '退避-乘子', @@ -60,7 +60,7 @@ CREATE TABLE IF NOT EXISTS plg_mq_msg update_user VARCHAR(100) NULL, PRIMARY KEY (id), INDEX idx_create_time (create_time, send_state), - INDEX idx_next_retry_time (next_retry_time, send_state), + INDEX idx_next_retry_time (next_retry_time, send_state, left_retry_times), INDEX idx_biz_type (biz_type), INDEX idx_send_state (send_state) ) ENGINE = InnoDB From df070e6a667f100ee1157db009b2d1b06d4e5826 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 22:41:39 +0800 Subject: [PATCH 099/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=8F=91?= =?UTF-8?q?=E9=80=81=E4=BA=8B=E5=8A=A1=E6=B6=88=E6=81=AF=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../svc/controller/MqExampleController.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java index ac232fef..d1f1ca9c 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java @@ -1,12 +1,15 @@ package com.github.cadecode.uniboot.example.svc.controller; +import com.github.cadecode.uniboot.common.plugin.mq.model.TxMsg; import com.github.cadecode.uniboot.common.plugin.mq.util.RabbitUtil; +import com.github.cadecode.uniboot.common.plugin.mq.util.TxMsgKit; import com.github.cadecode.uniboot.example.svc.bean.data.ExampleMsgDo; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -26,6 +29,8 @@ @RequestMapping("demo/mq") public class MqExampleController { + private final TxMsgKit txMsgKit; + @ApiOperation("发送 delay 消息") @GetMapping("send_delay") public boolean sendDelay(@RequestParam String exchange, @RequestParam String routingKey, @RequestParam Integer ms) { @@ -47,5 +52,19 @@ public boolean sendObj(@RequestParam String exchange, @RequestParam String routi RabbitUtil.send(exchange, routingKey, msgDo); return true; } + + @Transactional(rollbackFor = Exception.class) + @ApiOperation("发送事务消息") + @GetMapping("send_tx") + public boolean sendTx(@RequestParam String exchange, @RequestParam String routingKey) { + txMsgKit.sendTx(TxMsg.builder() + .bizType("Test biz") + .bizKey("TestBiz001") + .exchange(exchange) + .routingKey(routingKey) + .message("Test TxMsg") + .build()); + return true; + } } From 82f38edc35a5e85eb6ff746393bb48c04a7752a2 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 23:13:08 +0800 Subject: [PATCH 100/244] =?UTF-8?q?feat:=20=E4=BA=8B=E5=8A=A1=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E9=87=8D=E8=AF=95=E6=B7=BB=E5=8A=A0=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E9=9D=9E=20OVER=20=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/base/plugin/handler/MqTxMsgHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java index 0b14e5c8..f5be0c22 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java @@ -71,7 +71,7 @@ public void doRetry() { Date currDate = new Date(); List msgList = mqMsgService.lambdaQuery() .le(PlgMqMsg::getNextRetryTime, currDate) - .eq(PlgMqMsg::getSendState, SendStateEnum.FAIL) + .ne(PlgMqMsg::getSendState, SendStateEnum.OVER) .gt(PlgMqMsg::getLeftRetryTimes, 0) .list(); if (ObjectUtil.isEmpty(msgList)) { From feef47d2343e650b04cf132e6992720d885a3821 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 23:39:15 +0800 Subject: [PATCH 101/244] =?UTF-8?q?refactor:=20hutool=20ObjectUtil=20?= =?UTF-8?q?=E5=B0=86=E5=BC=83=E7=94=A8=EF=BC=8C=E6=94=B9=E4=B8=BA=20ObjUti?= =?UTF-8?q?l?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../strategy/StrategySelectorExecutor.java | 10 +++--- .../uniboot/common/core/util/AssertUtil.java | 34 +++++++++---------- .../uniboot/common/core/util/OfficeUtil.java | 20 +++++------ .../plugin/cache/l2cache/cache/DLCache.java | 24 ++++++------- .../cache/l2cache/cache/DLCacheManager.java | 8 ++--- .../l2cache/sync/DLCacheRefreshListener.java | 4 +-- .../cache/listener/RedisExpiredListener.java | 4 +-- .../plugin/log/aspect/ApiLoggerAspect.java | 6 ++-- .../log/handler/AbstractApiLogHandler.java | 4 +-- .../plugin/mq/config/RabbitAutoConfig.java | 10 +++--- .../plugin/mq/config/RabbitProperties.java | 10 +++--- .../plugin/mq/config/TxMsgProperties.java | 6 ++-- .../plugin/mq/rabbit/RabbitCallback.java | 8 ++--- .../common/plugin/mq/task/TxMsgTask.java | 4 +-- .../common/plugin/mq/util/RabbitUtil.java | 6 ++-- .../converter/BoolToIntTypeHandler.java | 4 +-- .../swagger/util/SwaggerRegisterKit.java | 4 +-- .../svc/consumer/RabbitExampleConsumer.java | 4 +-- .../base/advisor/ApiResultAdvisor.java | 4 +-- .../framework/base/aspect/ApiInnerAspect.java | 6 ++-- .../framework/base/config/FeignConfig.java | 6 ++-- .../framework/base/config/SecurityConfig.java | 4 +-- .../base/feign/FeignClientDecorator.java | 4 +-- .../base/feign/FeignErrorDecoder.java | 4 +-- .../plugin/controller/PlgLogController.java | 14 ++++---- .../controller/PlgSwaggerController.java | 8 ++--- .../base/plugin/handler/LogSaveHandler.java | 6 ++-- .../base/plugin/handler/MqTxMsgHandler.java | 12 +++---- .../filter/TokenAuthFilterService.java | 4 +-- .../security/voter/DataBaseRoleVoter.java | 4 +-- .../framework/base/util/RequestUtil.java | 18 +++++----- .../framework/base/util/SecurityUtil.java | 10 +++--- .../svc/controller/SysDictController.java | 6 ++-- .../svc/controller/SysUserController.java | 8 ++--- .../svc/serviceimpl/SysMenuServiceImpl.java | 8 ++--- .../svc/serviceimpl/SysUserServiceImpl.java | 4 +-- .../handler/GlobalExceptionHandler.java | 4 +-- 37 files changed, 152 insertions(+), 152 deletions(-) diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategySelectorExecutor.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategySelectorExecutor.java index 57575528..0645b9b3 100644 --- a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategySelectorExecutor.java +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategySelectorExecutor.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.common.core.extension.strategy; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.core.exception.ExtException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -36,7 +36,7 @@ public class StrategySelectorExecutor extends AbstractStrategyExecutor { @Override public void execute(Class clazz, StrategyContext context, Consumer consumer) { List services = selectServices(clazz, context); - if (ObjectUtil.isNotEmpty(services)) { + if (ObjUtil.isNotEmpty(services)) { consumer.accept(services.get(0)); return; } @@ -53,7 +53,7 @@ public void execute(Class clazz, StrategyContext @Override public void executeAll(Class clazz, StrategyContext context, Consumer consumer) { List services = selectServices(clazz, context); - if (ObjectUtil.isNotEmpty(services)) { + if (ObjUtil.isNotEmpty(services)) { services.forEach(consumer); return; } @@ -71,7 +71,7 @@ public void executeAll(Class clazz, StrategyConte @Override public R execute(Class clazz, StrategyContext context, Function function) { List services = selectServices(clazz, context); - if (ObjectUtil.isNotEmpty(services)) { + if (ObjUtil.isNotEmpty(services)) { return function.apply(services.get(0)); } throw new ExtException("Strategy service not found"); @@ -88,7 +88,7 @@ public R execute(Class clazz, StrategyContext @Override public List executeAll(Class clazz, StrategyContext context, Function function) { List services = selectServices(clazz, context); - if (ObjectUtil.isNotEmpty(services)) { + if (ObjUtil.isNotEmpty(services)) { return services.stream() .map(function) .collect(Collectors.toList()); diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/util/AssertUtil.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/util/AssertUtil.java index 82cc2bb6..521ab160 100644 --- a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/util/AssertUtil.java +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/util/AssertUtil.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.common.core.util; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; import com.github.cadecode.uniboot.common.core.exception.ApiException; @@ -109,7 +109,7 @@ public static void isFalse(boolean expression, ApiErrorCode errorCode, Throwable * @param exceptionSupplier 运行时异常提供者 */ public static void isNull(Object o, Supplier exceptionSupplier) { - isTrue(ObjectUtil.isNull(o), exceptionSupplier); + isTrue(ObjUtil.isNull(o), exceptionSupplier); } /** @@ -119,7 +119,7 @@ public static void isNull(Object o, Supplier exceptionSupplier * @param moreInfo 异常信息 */ public static void isNull(Object o, String moreInfo) { - isTrue(ObjectUtil.isNull(o), () -> ApiException.of(moreInfo)); + isTrue(ObjUtil.isNull(o), () -> ApiException.of(moreInfo)); } /** @@ -130,7 +130,7 @@ public static void isNull(Object o, String moreInfo) { * @param moreInfo 异常信息 */ public static void isNull(Object o, ApiErrorCode errorCode, String moreInfo) { - isTrue(ObjectUtil.isNull(o), () -> ApiException.of(errorCode, moreInfo)); + isTrue(ObjUtil.isNull(o), () -> ApiException.of(errorCode, moreInfo)); } /** @@ -142,7 +142,7 @@ public static void isNull(Object o, ApiErrorCode errorCode, String moreInfo) { * @param moreInfo 异常信息 */ public static void isNull(Object o, ApiErrorCode errorCode, Throwable throwable, String moreInfo) { - isTrue(ObjectUtil.isNull(o), () -> ApiException.of(errorCode, throwable, moreInfo)); + isTrue(ObjUtil.isNull(o), () -> ApiException.of(errorCode, throwable, moreInfo)); } /** @@ -152,7 +152,7 @@ public static void isNull(Object o, ApiErrorCode errorCode, Throwable throwable, * @param exceptionSupplier 运行时异常提供者 */ public static void isNotNull(Object o, Supplier exceptionSupplier) { - isTrue(ObjectUtil.isNotNull(o), exceptionSupplier); + isTrue(ObjUtil.isNotNull(o), exceptionSupplier); } /** @@ -162,7 +162,7 @@ public static void isNotNull(Object o, Supplier exceptionSuppl * @param moreInfo 异常信息 */ public static void isNotNull(Object o, String moreInfo) { - isTrue(ObjectUtil.isNotNull(o), () -> ApiException.of(moreInfo)); + isTrue(ObjUtil.isNotNull(o), () -> ApiException.of(moreInfo)); } /** @@ -173,7 +173,7 @@ public static void isNotNull(Object o, String moreInfo) { * @param moreInfo 异常信息 */ public static void isNotNull(Object o, ApiErrorCode errorCode, String moreInfo) { - isTrue(ObjectUtil.isNotNull(o), () -> ApiException.of(errorCode, moreInfo)); + isTrue(ObjUtil.isNotNull(o), () -> ApiException.of(errorCode, moreInfo)); } /** @@ -185,7 +185,7 @@ public static void isNotNull(Object o, ApiErrorCode errorCode, String moreInfo) * @param moreInfo 异常信息 */ public static void isNotNull(Object o, ApiErrorCode errorCode, Throwable throwable, String moreInfo) { - isTrue(ObjectUtil.isNotNull(o), () -> ApiException.of(errorCode, throwable, moreInfo)); + isTrue(ObjUtil.isNotNull(o), () -> ApiException.of(errorCode, throwable, moreInfo)); } /** @@ -195,7 +195,7 @@ public static void isNotNull(Object o, ApiErrorCode errorCode, Throwable throwab * @param exceptionSupplier 运行时异常提供者 */ public static void isEmpty(Object o, Supplier exceptionSupplier) { - isTrue(ObjectUtil.isEmpty(o), exceptionSupplier); + isTrue(ObjUtil.isEmpty(o), exceptionSupplier); } /** @@ -205,7 +205,7 @@ public static void isEmpty(Object o, Supplier exceptionSupplie * @param moreInfo 异常信息 */ public static void isEmpty(Object o, String moreInfo) { - isTrue(ObjectUtil.isEmpty(o), () -> ApiException.of(moreInfo)); + isTrue(ObjUtil.isEmpty(o), () -> ApiException.of(moreInfo)); } /** @@ -216,7 +216,7 @@ public static void isEmpty(Object o, String moreInfo) { * @param moreInfo 异常信息 */ public static void isEmpty(Object o, ApiErrorCode errorCode, String moreInfo) { - isTrue(ObjectUtil.isEmpty(o), () -> ApiException.of(errorCode, moreInfo)); + isTrue(ObjUtil.isEmpty(o), () -> ApiException.of(errorCode, moreInfo)); } /** @@ -228,7 +228,7 @@ public static void isEmpty(Object o, ApiErrorCode errorCode, String moreInfo) { * @param moreInfo 异常信息 */ public static void isEmpty(Object o, ApiErrorCode errorCode, Throwable throwable, String moreInfo) { - isTrue(ObjectUtil.isEmpty(o), () -> ApiException.of(errorCode, throwable, moreInfo)); + isTrue(ObjUtil.isEmpty(o), () -> ApiException.of(errorCode, throwable, moreInfo)); } /** @@ -238,7 +238,7 @@ public static void isEmpty(Object o, ApiErrorCode errorCode, Throwable throwable * @param exceptionSupplier 运行时异常提供者 */ public static void isNotEmpty(Object o, Supplier exceptionSupplier) { - isTrue(ObjectUtil.isNotEmpty(o), exceptionSupplier); + isTrue(ObjUtil.isNotEmpty(o), exceptionSupplier); } /** @@ -248,7 +248,7 @@ public static void isNotEmpty(Object o, Supplier exceptionSupp * @param moreInfo 异常信息 */ public static void isNotEmpty(Object o, String moreInfo) { - isTrue(ObjectUtil.isNotEmpty(o), () -> ApiException.of(moreInfo)); + isTrue(ObjUtil.isNotEmpty(o), () -> ApiException.of(moreInfo)); } /** @@ -259,7 +259,7 @@ public static void isNotEmpty(Object o, String moreInfo) { * @param moreInfo 异常信息 */ public static void isNotEmpty(Object o, ApiErrorCode errorCode, String moreInfo) { - isTrue(ObjectUtil.isNotEmpty(o), () -> ApiException.of(errorCode, moreInfo)); + isTrue(ObjUtil.isNotEmpty(o), () -> ApiException.of(errorCode, moreInfo)); } /** @@ -271,7 +271,7 @@ public static void isNotEmpty(Object o, ApiErrorCode errorCode, String moreInfo) * @param moreInfo 异常信息 */ public static void isNotEmpty(Object o, ApiErrorCode errorCode, Throwable throwable, String moreInfo) { - isTrue(ObjectUtil.isNotEmpty(o), () -> ApiException.of(errorCode, throwable, moreInfo)); + isTrue(ObjUtil.isNotEmpty(o), () -> ApiException.of(errorCode, throwable, moreInfo)); } } diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/util/OfficeUtil.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/util/OfficeUtil.java index 47990b1a..f18c7f73 100644 --- a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/util/OfficeUtil.java +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/util/OfficeUtil.java @@ -3,7 +3,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.io.FileUtil; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.poi.excel.ExcelFileUtil; import cn.hutool.poi.excel.sax.ExcelSaxReader; @@ -108,7 +108,7 @@ public void handle(int sheetIndex, long rowIndex, List rowCells) { geneHeadFieldMap(); geneCopyOptions(); // 存在 head 第一行解析完成后 return - if (ObjectUtil.equal(hasHead, true)) { + if (ObjUtil.equal(hasHead, true)) { return; } } @@ -130,28 +130,28 @@ public void doAfterAllAnalysed() { } private void checkAndInitParams() { - if (ObjectUtil.isNull(sheetIndex)) { + if (ObjUtil.isNull(sheetIndex)) { // 默认读取首个 sheet sheetIndex = 0; } - if (ObjectUtil.isNull(hasHead)) { + if (ObjUtil.isNull(hasHead)) { // 默认有表头 hasHead = true; } - if (ObjectUtil.isNull(rowHandler)) { + if (ObjUtil.isNull(rowHandler)) { throw new RuntimeException("Can not read without rowHandler"); } } private boolean initIndexHeadMap(List rowCells) { - if (ObjectUtil.isNotNull(indexHeadMap)) { + if (ObjUtil.isNotNull(indexHeadMap)) { return false; } AtomicInteger tmpIdx = new AtomicInteger(); indexHeadMap = rowCells.stream() .collect(Collectors.toMap(o -> tmpIdx.getAndIncrement(), o -> { // 有表头时使用表头映射 - if (ObjectUtil.equal(hasHead, true)) { + if (ObjUtil.equal(hasHead, true)) { return String.valueOf(o); } // 无表头时使用列序映射 @@ -165,7 +165,7 @@ private void geneHeadFieldMap() { field.setAccessible(true); ExcelField excelField = field.getAnnotation(ExcelField.class); // 若不存在 ExcelField 注解,加入忽略 - if (ObjectUtil.isNull(excelField)) { + if (ObjUtil.isNull(excelField)) { ignoredFields.add(field.getName()); continue; } @@ -175,7 +175,7 @@ private void geneHeadFieldMap() { continue; } // 若存在表头,且 headAlias 不为空 - if (hasHead && ObjectUtil.isNotEmpty(excelField.headAlias())) { + if (hasHead && ObjUtil.isNotEmpty(excelField.headAlias())) { headFieldMap.put(excelField.headAlias(), field.getName()); continue; } @@ -205,7 +205,7 @@ public List readAll() { .sheetIndex(sheetIndex) .hasHead(hasHead); ExcelRowHandler newRowHandler; - if (ObjectUtil.isNull(rowHandler)) { + if (ObjUtil.isNull(rowHandler)) { readHelper.rowHandler((sheetIndex, rowIndex, bean) -> beanList.add(bean)).read(); return beanList; } diff --git a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCache.java b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCache.java index 9f888143..7dbeb650 100644 --- a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCache.java +++ b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCache.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.common.plugin.cache.l2cache.cache; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.benmanes.caffeine.cache.Cache; import com.github.cadecode.uniboot.common.plugin.cache.exception.DLCacheException; import com.github.cadecode.uniboot.common.plugin.cache.l2cache.DLCacheProperties; @@ -63,12 +63,12 @@ protected Object lookup(Object key) { val = caffeineCache.getIfPresent(key); // val 是 toStoreValue 包装过的值,为 null 则 key 不存在 // 因为存储的 null 值被包装成了 DLCacheNullVal.INSTANCE - if (ObjectUtil.isNotNull(val)) { + if (ObjUtil.isNotNull(val)) { log.trace("DLCache local get cache, key:{}, value:{}", key, val); return val; } val = redisTemplate.opsForValue().get(redisKey); - if (ObjectUtil.isNotNull(val)) { + if (ObjUtil.isNotNull(val)) { log.debug("DLCache remote get cache, key:{}, value:{}", key, val); caffeineCache.put(key.toString(), val); return val; @@ -81,13 +81,13 @@ protected Object lookup(Object key) { public T get(Object key, Callable valueLoader) { T val; val = (T) lookup(key); - if (ObjectUtil.isNotNull(val)) { + if (ObjUtil.isNotNull(val)) { return val; } // 双检锁 synchronized (key.toString().intern()) { val = (T) lookup(key); - if (ObjectUtil.isNotNull(val)) { + if (ObjUtil.isNotNull(val)) { return val; } try { @@ -114,7 +114,7 @@ public ValueWrapper putIfAbsent(Object key, Object value) { String redisKey = getRedisKey(key); // 获取旧值 Object oldVal = redisTemplate.opsForValue().get(redisKey); - if (ObjectUtil.isNotNull(oldVal)) { + if (ObjUtil.isNotNull(oldVal)) { return toValueWrapper(oldVal); } Boolean setOkFlag; @@ -123,7 +123,7 @@ public ValueWrapper putIfAbsent(Object key, Object value) { } else { setOkFlag = redisTemplate.opsForValue().setIfAbsent(redisKey, value); } - if (ObjectUtil.equal(setOkFlag, true)) { + if (ObjUtil.equal(setOkFlag, true)) { sendSyncMsg(key); putLocal(key, value); } @@ -169,9 +169,9 @@ private void putRemote(Object key, Object value) { } public void clearRemote(Object key) { - if (ObjectUtil.isNull(key)) { + if (ObjUtil.isNull(key)) { Set keys = redisTemplate.keys(getRedisKey("*")); - if (ObjectUtil.isNotEmpty(keys)) { + if (ObjUtil.isNotEmpty(keys)) { keys.forEach(redisTemplate::delete); } return; @@ -180,7 +180,7 @@ public void clearRemote(Object key) { } public void clearLocal(Object key) { - if (ObjectUtil.isNull(key)) { + if (ObjUtil.isNull(key)) { caffeineCache.invalidateAll(); return; } @@ -194,10 +194,10 @@ public void clearLocal(Object key) { * @return 不为空则 true,为空但允许则 false,否则异常 */ private boolean checkValNotNull(Object value) { - if (ObjectUtil.isNotNull(value)) { + if (ObjUtil.isNotNull(value)) { return true; } - if (isAllowNullValues() && ObjectUtil.isNull(value)) { + if (isAllowNullValues() && ObjUtil.isNull(value)) { return false; } // val 不能为空,但传了空 diff --git a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCacheManager.java b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCacheManager.java index 1bbdb278..29b6a0af 100644 --- a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCacheManager.java +++ b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/cache/DLCacheManager.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.common.plugin.cache.l2cache.cache; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.cadecode.uniboot.common.plugin.cache.l2cache.DLCacheProperties; import com.github.cadecode.uniboot.common.plugin.cache.l2cache.DLCacheProperties.LocalConfig; @@ -46,7 +46,7 @@ private DLCache buildCache(String name) { long expiration = 0; // 获取针对 cache name 设置的过期时间 Map cacheExpirationMap = cacheProperties.getCacheExpirationMap(); - if (ObjectUtil.isNotEmpty(cacheExpirationMap) && cacheExpirationMap.get(name) > 0) { + if (ObjUtil.isNotEmpty(cacheExpirationMap) && cacheExpirationMap.get(name) > 0) { expiration = cacheExpirationMap.get(name); } else if (cacheProperties.getDefaultExpiration() > 0) { expiration = cacheProperties.getDefaultExpiration(); @@ -56,11 +56,11 @@ private DLCache buildCache(String name) { } // 设置参数 LocalConfig localConfig = cacheProperties.getLocal(); - if (ObjectUtil.isNotNull(localConfig.getInitialCapacity()) && localConfig.getInitialCapacity() > 0) { + if (ObjUtil.isNotNull(localConfig.getInitialCapacity()) && localConfig.getInitialCapacity() > 0) { caffeine.initialCapacity(localConfig.getInitialCapacity()); } - if (ObjectUtil.isNotNull(localConfig.getMaximumSize()) && localConfig.getMaximumSize() > 0) { + if (ObjUtil.isNotNull(localConfig.getMaximumSize()) && localConfig.getMaximumSize() > 0) { caffeine.maximumSize(localConfig.getMaximumSize()); } return new DLCache(name, expiration, cacheProperties, caffeine.build(), redisTemplate); diff --git a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/sync/DLCacheRefreshListener.java b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/sync/DLCacheRefreshListener.java index b24c4619..777d2362 100644 --- a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/sync/DLCacheRefreshListener.java +++ b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/l2cache/sync/DLCacheRefreshListener.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.common.plugin.cache.l2cache.sync; import cn.hutool.core.collection.ConcurrentHashSet; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.plugin.cache.l2cache.DLCacheProperties; import com.github.cadecode.uniboot.common.plugin.cache.l2cache.cache.DLCacheManager; import com.github.cadecode.uniboot.common.plugin.cache.listener.RedisMessageListener; @@ -42,7 +42,7 @@ public List topics() { public void onMessage(Message message, byte[] pattern) { // 序列化出刷新消息 DLCacheRefreshMsg refreshMsg = (DLCacheRefreshMsg) RedisUtil.getTemplate().getValueSerializer().deserialize(message.getBody()); - if (ObjectUtil.isNull(refreshMsg)) { + if (ObjUtil.isNull(refreshMsg)) { return; } // 判断是不是自身节点发出 diff --git a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/listener/RedisExpiredListener.java b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/listener/RedisExpiredListener.java index cc58f9ef..a9e46c95 100644 --- a/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/listener/RedisExpiredListener.java +++ b/common/plugin/cache/src/main/java/com/github/cadecode/uniboot/common/plugin/cache/listener/RedisExpiredListener.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.common.plugin.cache.listener; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.core.annotation.Order; @@ -54,7 +54,7 @@ public void onMessage(Message message, byte[] pattern) { .filter(o -> o.checkKey(key)) .sorted(Comparator.comparing(o -> { Order order = o.getClass().getAnnotation(Order.class); - return ObjectUtil.defaultIfNull(order, Order::value, 0); + return ObjUtil.defaultIfNull(order, Order::value, 0); }).reversed()) .findAny(); if (!handlerOpt.isPresent()) { diff --git a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java index 48ef282b..61e0bef3 100644 --- a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java +++ b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/aspect/ApiLoggerAspect.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.common.plugin.log.aspect; import cn.hutool.core.exceptions.ExceptionUtil; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.handler.AbstractApiLogHandler; @@ -86,13 +86,13 @@ private ApiLogger getApiLogger(ProceedingJoinPoint point) { public void handleLogger(ProceedingJoinPoint point, ApiLogger apiLogger, Object result, Throwable throwable, Long timeCost) { // 解析请求对象 ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); - if (ObjectUtil.isNull(attributes)) { + if (ObjUtil.isNull(attributes)) { return; } try { String resultStr; boolean exceptional = false; - if (ObjectUtil.isNotNull(throwable)) { + if (ObjUtil.isNotNull(throwable)) { exceptional = true; resultStr = ExceptionUtil.stacktraceToString(throwable); } else { diff --git a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java index 202eb11a..31873e38 100644 --- a/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java +++ b/common/plugin/log/src/main/java/com/github/cadecode/uniboot/common/plugin/log/handler/AbstractApiLogHandler.java @@ -1,6 +1,7 @@ package com.github.cadecode.uniboot.common.plugin.log.handler; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; import com.github.cadecode.uniboot.common.plugin.log.model.BaseLogInfo; import lombok.extern.slf4j.Slf4j; @@ -8,7 +9,6 @@ import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.Signature; import org.aspectj.lang.reflect.MethodSignature; -import org.springframework.util.ObjectUtils; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; @@ -41,7 +41,7 @@ public static Map getRequestParams(JoinPoint joinPoint, ApiLogge MethodSignature methodSignature = (MethodSignature) signature; String[] names = methodSignature.getParameterNames(); Object[] args = joinPoint.getArgs(); - if (ObjectUtils.isEmpty(names) || ObjectUtils.isEmpty(args)) { + if (ObjUtil.isEmpty(names) || ObjUtil.isEmpty(args)) { return Collections.emptyMap(); } if (names.length != args.length) { diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java index 88bd379a..7c72a3a5 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.common.plugin.mq.config; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.Binding; @@ -37,25 +37,25 @@ public class RabbitAutoConfig implements BeanFactoryPostProcessor, EnvironmentAw public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { BindResult bindResult = Binder.get(environment).bind(RabbitProperties.ENV_CONF_RABBIT_PREFIX, RabbitProperties.class); RabbitProperties rabbitProperties = bindResult.orElse(null); - if (ObjectUtil.isNull(rabbitProperties)) { + if (ObjUtil.isNull(rabbitProperties)) { log.info("Rabbit env config {} not found", RabbitProperties.ENV_CONF_RABBIT_PREFIX); return; } - if (ObjectUtil.isNotEmpty(rabbitProperties.getExchanges())) { + if (ObjUtil.isNotEmpty(rabbitProperties.getExchanges())) { rabbitProperties.getExchanges().forEach(o -> { Exchange exchange = o.toBuilder().build(); beanFactory.registerSingleton(o.getName(), exchange); log.info("Rabbit auto register exchange, {}, {}", o.getName(), o); }); } - if (ObjectUtil.isNotEmpty(rabbitProperties.getQueues())) { + if (ObjUtil.isNotEmpty(rabbitProperties.getQueues())) { rabbitProperties.getQueues().forEach(o -> { Queue queue = o.toBuilder().build(); beanFactory.registerSingleton(o.getName(), queue); log.info("Rabbit auto register queue, {}, {}", o.getName(), o); }); } - if (ObjectUtil.isNotEmpty(rabbitProperties.getBindings())) { + if (ObjUtil.isNotEmpty(rabbitProperties.getBindings())) { rabbitProperties.getBindings().forEach(o -> { String bindName = o.getBindName(); // 对随机后缀的队列,不能直接用 bean name,需要获取 queue 的 bean 再获取队列名称 diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java index 6854428b..5fea3616 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.common.plugin.mq.config; import cn.hutool.core.lang.UUID; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import lombok.Data; import org.springframework.amqp.core.Binding.DestinationType; import org.springframework.amqp.core.ExchangeBuilder; @@ -73,11 +73,11 @@ public QueueBuilder toBuilder() { if (autoDelete) { builder.autoDelete(); } - if (!ObjectUtil.hasNull(dlExchange, dlRoutingKey)) { + if (!ObjUtil.hasNull(dlExchange, dlRoutingKey)) { builder.deadLetterExchange(dlExchange); builder.deadLetterRoutingKey(dlRoutingKey); } - if (ObjectUtil.isNotEmpty(arguments)) { + if (ObjUtil.isNotEmpty(arguments)) { arguments.forEach(builder::withArgument); } return builder; @@ -120,10 +120,10 @@ public ExchangeBuilder toBuilder() { if (!declare) { builder.suppressDeclaration(); } - if (ObjectUtil.isNotEmpty(declaringAdmins)) { + if (ObjUtil.isNotEmpty(declaringAdmins)) { builder.admins(arguments); } - if (ObjectUtil.isNotEmpty(arguments)) { + if (ObjUtil.isNotEmpty(arguments)) { arguments.forEach(builder::withArgument); } return builder; diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgProperties.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgProperties.java index bbf2c97b..7f2b9ff5 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgProperties.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgProperties.java @@ -2,7 +2,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.copier.CopyOptions; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; @@ -66,7 +66,7 @@ public class TxMsgProperties implements InitializingBean { private MsgOption defaultMsgOption; public MsgOption createMsgOption(MsgOption msgOption) { - if (ObjectUtil.isNull(msgOption)) { + if (ObjUtil.isNull(msgOption)) { msgOption = new MsgOption(); } BeanUtil.copyProperties(defaultMsgOption, msgOption, CopyOptions.create().setOverride(false)); @@ -81,7 +81,7 @@ public void afterPropertiesSet() { .backoffMultiplier(DEFAULT_BACKOFF_MULTIPLIER) .backoffMaxInterval(DEFAULT_BACKOFF_MAX_INTERVAL) .build(); - if (ObjectUtil.isNull(defaultMsgOption)) { + if (ObjUtil.isNull(defaultMsgOption)) { defaultMsgOption = allDefaultOption; } else { BeanUtil.copyProperties(allDefaultOption, defaultMsgOption, CopyOptions.create().setOverride(false)); diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java index 30877776..a14baa1b 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.common.plugin.mq.rabbit; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.plugin.mq.consts.RabbitConst; import com.github.cadecode.uniboot.common.plugin.mq.handler.AbstractTxMsgHandler; import lombok.RequiredArgsConstructor; @@ -46,7 +46,7 @@ public class RabbitCallback implements ConfirmCallback, ReturnsCallback, Initial @Override public void confirm(CorrelationData correlationData, boolean ack, String cause) { // 获取 correlationData id - String correlationId = ObjectUtil.defaultIfNull(correlationData, CorrelationData::getId, ""); + String correlationId = ObjUtil.defaultIfNull(correlationData, CorrelationData::getId, ""); if (ack) { log.debug("Rabbit message send ok, id:{}", correlationId); txMsgTaskHandler.handleConfirm(correlationData, true, cause); @@ -74,7 +74,7 @@ public void returnedMessage(ReturnedMessage returned) { * 判断是否是 delay 交换机 */ private boolean isExchangeDelayed(String exchangeName) { - if (ObjectUtil.isEmpty(exchangeNameMap)) { + if (ObjUtil.isEmpty(exchangeNameMap)) { exchangeNameMap = exchanges.stream().collect(Collectors.toMap(Exchange::getName, o -> o)); } // 若是 delay 交换机 @@ -90,7 +90,7 @@ public void afterPropertiesSet() { // 设置 correlationData 后置处理 rabbitTemplate.setCorrelationDataPostProcessor((message, correlationData) -> { // 填充 correlationDataId 到 MessageProperties - if (ObjectUtil.isNotNull(correlationData) && ObjectUtil.isNotNull(correlationData.getId())) { + if (ObjUtil.isNotNull(correlationData) && ObjUtil.isNotNull(correlationData.getId())) { String correlationId = correlationData.getId(); message.getMessageProperties().setCorrelationId(correlationId); } diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/task/TxMsgTask.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/task/TxMsgTask.java index bad5035b..010f7190 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/task/TxMsgTask.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/task/TxMsgTask.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.common.plugin.mq.task; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.plugin.mq.config.TxMsgProperties; import com.github.cadecode.uniboot.common.plugin.mq.handler.AbstractTxMsgHandler; import lombok.RequiredArgsConstructor; @@ -32,7 +32,7 @@ public void onApplicationStartedEvent() { log.info("TxMsg task do retry started"); taskScheduler.scheduleWithFixedDelay(txMsgTaskHandler::doRetry, txMsgProperties.getRetryFixDelay()); log.info("TxMsg task do clear start, {}", txMsgProperties.getAutoClear()); - if (ObjectUtil.equal(txMsgProperties.getAutoClear(), true)) { + if (ObjUtil.equal(txMsgProperties.getAutoClear(), true)) { taskScheduler.scheduleWithFixedDelay(() -> txMsgTaskHandler.doClear(txMsgProperties.getAutoClearInterval()), txMsgProperties.getClearFixDelay()); } diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/RabbitUtil.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/RabbitUtil.java index 1aa5317a..649de398 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/RabbitUtil.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/util/RabbitUtil.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.common.plugin.mq.util; import cn.hutool.core.util.IdUtil; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import lombok.RequiredArgsConstructor; import org.springframework.amqp.core.MessagePostProcessor; import org.springframework.amqp.rabbit.connection.CorrelationData; @@ -38,7 +38,7 @@ public static String send(String exchangeName, String routingKey, Object message public static String send(String exchangeName, String routingKey, Object message, MessagePostProcessor postProcessor, CorrelationData correlationData) { // 不存在消息 id 时构造新的 correlationData - if (ObjectUtil.isNull(correlationData) || ObjectUtil.isNull(correlationData.getId())) { + if (ObjUtil.isNull(correlationData) || ObjUtil.isNull(correlationData.getId())) { correlationData = geneCorrelationData(); } RABBIT_TEMPLATE.convertAndSend(exchangeName, routingKey, message, postProcessor, correlationData); @@ -57,7 +57,7 @@ public static String sendDelay(String exchangeName, String routingKey, Object me public static String sendDelay(String exchangeName, String routingKey, Object message, Integer delayTime, MessagePostProcessor postProcessor, CorrelationData correlationData) { CorrelationData currCorrelationData; - if (ObjectUtil.isNull(correlationData) || ObjectUtil.isNull(correlationData.getId())) { + if (ObjUtil.isNull(correlationData) || ObjUtil.isNull(correlationData.getId())) { currCorrelationData = geneCorrelationData(); } else { currCorrelationData = correlationData; diff --git a/common/plugin/mybatis/src/main/java/com/github/cadecode/uniboot/common/plugin/mybatis/converter/BoolToIntTypeHandler.java b/common/plugin/mybatis/src/main/java/com/github/cadecode/uniboot/common/plugin/mybatis/converter/BoolToIntTypeHandler.java index 401a4732..035efecf 100644 --- a/common/plugin/mybatis/src/main/java/com/github/cadecode/uniboot/common/plugin/mybatis/converter/BoolToIntTypeHandler.java +++ b/common/plugin/mybatis/src/main/java/com/github/cadecode/uniboot/common/plugin/mybatis/converter/BoolToIntTypeHandler.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.common.plugin.mybatis.converter; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import org.apache.ibatis.type.BaseTypeHandler; import org.apache.ibatis.type.JdbcType; import org.apache.ibatis.type.MappedJdbcTypes; @@ -27,7 +27,7 @@ public class BoolToIntTypeHandler extends BaseTypeHandler { public static final String MAPPING = "typeHandler=BoolToIntTypeHandler"; public static Integer mapping(Boolean o) { - return ObjectUtil.isNull(o) ? null : (o ? 1 : 0); + return ObjUtil.isNull(o) ? null : (o ? 1 : 0); } @Override diff --git a/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/util/SwaggerRegisterKit.java b/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/util/SwaggerRegisterKit.java index f4916e53..449fde6b 100644 --- a/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/util/SwaggerRegisterKit.java +++ b/common/plugin/swagger/src/main/java/com/github/cadecode/uniboot/common/plugin/swagger/util/SwaggerRegisterKit.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.common.plugin.swagger.util; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.core.util.SpringUtil; import com.github.cadecode.uniboot.common.plugin.swagger.config.SwaggerProperties; import lombok.RequiredArgsConstructor; @@ -27,7 +27,7 @@ public class SwaggerRegisterKit { */ public void registerModule(SwaggerProperties prop) { log.info("Starting to config swagger dockets"); - if (ObjectUtil.isEmpty(prop.getModule())) { + if (ObjUtil.isEmpty(prop.getModule())) { log.info("Swagger dockets config not found"); return; } diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java index c029187b..60d54d5e 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.example.svc.consumer; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.example.svc.bean.data.ExampleMsgDo; import com.rabbitmq.client.Channel; import lombok.extern.slf4j.Slf4j; @@ -39,7 +39,7 @@ public void exampleDelayQueue1(String body, Message message, Channel channel) th public void exampleBizQueue0(String body, Message message, Channel channel) throws IOException { log.info("Received msg:{}", body); // 自动模式下,测试重试机制 - if (ObjectUtil.equal(body, "ERROR")) { + if (ObjUtil.equal(body, "ERROR")) { throw new RuntimeException("ERROR"); } } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiResultAdvisor.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiResultAdvisor.java index bdb96927..2c4305a5 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiResultAdvisor.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiResultAdvisor.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.framework.base.advisor; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; @@ -87,7 +87,7 @@ private Object apiResultFormat(MethodParameter returnType, Object body, ServerHt return JacksonUtil.toJson(ApiResult.ok(body)); } // 对接口返回 null 特殊处理 - if (ObjectUtil.isNull(body)) { + if (ObjUtil.isNull(body)) { throw ApiException.of(FrameErrorEnum.RES_BODY_NULL, ""); } return ApiResult.ok(body); diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/aspect/ApiInnerAspect.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/aspect/ApiInnerAspect.java index 58a472c3..45fe256d 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/aspect/ApiInnerAspect.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/aspect/ApiInnerAspect.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.base.aspect; import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import cn.hutool.extra.servlet.ServletUtil; import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.framework.api.consts.HttpConst; @@ -40,12 +40,12 @@ public void rateLimit(JoinPoint point) { ApiInner apiInner = methodSignature.getMethod().getAnnotation(ApiInner.class); // 获取 request HttpServletRequest servletRequest = RequestUtil.getRequest(); - if (ObjectUtil.isNull(servletRequest)) { + if (ObjUtil.isNull(servletRequest)) { return; } // 获取请求头 String source = ServletUtil.getHeader(servletRequest, HttpConst.HEAD_SOURCE, CharsetUtil.CHARSET_UTF_8); - boolean innerFlag = ObjectUtil.equal(source, HttpConst.HEAD_SOURCE_VALUE); + boolean innerFlag = ObjUtil.equal(source, HttpConst.HEAD_SOURCE_VALUE); // 判断是否仅供内部调用 if (apiInner.onlyClient() && !innerFlag) { throw ApiException.of(AuthErrorEnum.TOKEN_NO_AUTHORITY, "ApiInner AOP:该接口仅供内部调用"); diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java index 7f574f2e..970f2447 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java @@ -2,7 +2,7 @@ import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.EscapeUtil; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.servlet.ServletUtil; import com.fasterxml.jackson.databind.ObjectMapper; @@ -48,14 +48,14 @@ protected void configRequestTemplate(RequestTemplate requestTemplate) { // 设置内部请求来源标识 requestTemplate.header(HttpConst.HEAD_SOURCE, HttpConst.HEAD_SOURCE_VALUE); HttpServletRequest servletRequest = RequestUtil.getRequest(); - if (ObjectUtil.isNull(servletRequest)) { + if (ObjUtil.isNull(servletRequest)) { return; } // 配置客户端 IP requestTemplate.header(HttpConst.HEAD_FORWARDED_FOR, ServletUtil.getClientIP(servletRequest)); // 传递 trace id String traceId = ServletUtil.getHeader(servletRequest, HttpConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); - if (ObjectUtil.isNotEmpty(traceId)) { + if (ObjUtil.isNotEmpty(traceId)) { requestTemplate.header(HttpConst.HEAD_TRACE_ID, traceId); } // 传递用户 token diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java index 5e01e29d..22ef8c29 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java @@ -3,7 +3,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import cn.hutool.extra.servlet.ServletUtil; import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; @@ -171,7 +171,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse filterChain) throws ServletException, IOException { String traceId = ServletUtil.getHeader(request, HttpConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); - if (ObjectUtil.isNotEmpty(traceId)) { + if (ObjUtil.isNotEmpty(traceId)) { MDC.put(HttpConst.HEAD_TRACE_ID, traceId); } filterChain.doFilter(request, response); diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignClientDecorator.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignClientDecorator.java index 31d5bb2c..5d1aa96c 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignClientDecorator.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignClientDecorator.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.framework.base.feign; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.framework.api.consts.HttpConst; import com.github.cadecode.uniboot.framework.base.util.RequestUtil; import feign.Client; @@ -39,7 +39,7 @@ public Response execute(Request request, Options options) throws IOException { */ protected void fillResponseHeader(Map> headers) { HttpServletResponse servletResponse = RequestUtil.getResponse(); - if (ObjectUtil.isNull(servletResponse)) { + if (ObjUtil.isNull(servletResponse)) { return; } // 获取 token diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignErrorDecoder.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignErrorDecoder.java index 1ac1b5d6..936709e1 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignErrorDecoder.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/feign/FeignErrorDecoder.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.base.feign; import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; import com.fasterxml.jackson.databind.ObjectMapper; import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; @@ -41,7 +41,7 @@ public Exception decode(String methodKey, Response response) { // 获取 ErrorMessage ErrorMessage error = result.getError(); // 返回默认包装的 FeignException - if (ObjectUtil.isNull(error)) { + if (ObjUtil.isNull(error)) { FeignException feignException = FeignException.errorStatus(methodKey, response); return ApiException.of(FrameErrorEnum.RPC_UNKNOWN_ERROR, feignException); } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java index 857c18c0..997ffc20 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.framework.base.plugin.controller; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; @@ -47,12 +47,12 @@ public class PlgLogController { public PageResult page(@RequestBody @Valid PlgLogVo.PlgLogPageReqVo reqVo) { PageInfo pageInfo = PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize()) .doSelectPageInfo(() -> logService.lambdaQuery() - .ge(ObjectUtil.isNotEmpty(reqVo.getStartTime()), PlgLog::getCreateTime, reqVo.getStartTime()) - .le(ObjectUtil.isNotEmpty(reqVo.getEndTime()), PlgLog::getCreateTime, reqVo.getEndTime()) - .in(ObjectUtil.isNotEmpty(reqVo.getLogTypeList()), PlgLog::getLogType, reqVo.getLogTypeList()) - .likeRight(ObjectUtil.isNotEmpty(reqVo.getAccessUser()), PlgLog::getAccessUser, reqVo.getAccessUser()) - .like(ObjectUtil.isNotEmpty(reqVo.getUrl()), PlgLog::getUrl, reqVo.getUrl()) - .eq(ObjectUtil.isNotNull(reqVo.getExceptional()), PlgLog::getExceptional, BoolToIntTypeHandler.mapping(reqVo.getExceptional())) + .ge(ObjUtil.isNotEmpty(reqVo.getStartTime()), PlgLog::getCreateTime, reqVo.getStartTime()) + .le(ObjUtil.isNotEmpty(reqVo.getEndTime()), PlgLog::getCreateTime, reqVo.getEndTime()) + .in(ObjUtil.isNotEmpty(reqVo.getLogTypeList()), PlgLog::getLogType, reqVo.getLogTypeList()) + .likeRight(ObjUtil.isNotEmpty(reqVo.getAccessUser()), PlgLog::getAccessUser, reqVo.getAccessUser()) + .like(ObjUtil.isNotEmpty(reqVo.getUrl()), PlgLog::getUrl, reqVo.getUrl()) + .eq(ObjUtil.isNotNull(reqVo.getExceptional()), PlgLog::getExceptional, BoolToIntTypeHandler.mapping(reqVo.getExceptional())) .orderByDesc(PlgLog::getCreateTime) .list()); List voList = PlgLogConvert.INSTANCE.poToVo(pageInfo.getList()); diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgSwaggerController.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgSwaggerController.java index 4d2f2787..69f2dd32 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgSwaggerController.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgSwaggerController.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.framework.base.plugin.controller; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgSwaggerVo.PlgSwaggerDescResVo; import io.swagger.annotations.Api; @@ -50,17 +50,17 @@ public List listSwaggerVo() { .map(e -> { ArrayList urlList = new ArrayList<>(e.getKey().getPatternsCondition().getPatterns()); String url = null; - if (ObjectUtil.isNotEmpty(urlList)) { + if (ObjUtil.isNotEmpty(urlList)) { url = urlList.get(0); } ApiOperation operation = e.getValue().getMethod().getAnnotation(ApiOperation.class); String description = null; - if (ObjectUtil.isNotNull(operation)) { + if (ObjUtil.isNotNull(operation)) { description = operation.value(); } return PlgSwaggerDescResVo.builder().url(url).description(description).build(); }) - .filter(o -> ObjectUtil.isNotEmpty(o.getUrl())) + .filter(o -> ObjUtil.isNotEmpty(o.getUrl())) .distinct() .sorted(Comparator.comparing(PlgSwaggerDescResVo::getUrl)) .collect(Collectors.toList()); diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/LogSaveHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/LogSaveHandler.java index 6eee75ff..f244bd84 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/LogSaveHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/LogSaveHandler.java @@ -2,7 +2,7 @@ import cn.hutool.core.exceptions.ExceptionUtil; import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.http.useragent.UserAgent; import cn.hutool.http.useragent.UserAgentUtil; @@ -55,9 +55,9 @@ public PlgLog generateLog(ProceedingJoinPoint point, BaseLogInfo baseLogInfo) { } // 获取描述 String description = apiLogger.description(); - if (ObjectUtil.isEmpty(description)) { + if (ObjUtil.isEmpty(description)) { ApiOperation apiOperation = ((MethodSignature) point.getSignature()).getMethod().getAnnotation(ApiOperation.class); - if (ObjectUtil.isNotNull(apiOperation)) { + if (ObjUtil.isNotNull(apiOperation)) { description = apiOperation.value(); } } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java index f5be0c22..72550599 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java @@ -4,7 +4,7 @@ import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import cn.hutool.core.exceptions.ExceptionUtil; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.github.cadecode.uniboot.common.core.util.AssertUtil; @@ -74,7 +74,7 @@ public void doRetry() { .ne(PlgMqMsg::getSendState, SendStateEnum.OVER) .gt(PlgMqMsg::getLeftRetryTimes, 0) .list(); - if (ObjectUtil.isEmpty(msgList)) { + if (ObjUtil.isEmpty(msgList)) { return; } long retryCount = msgList.stream() @@ -122,7 +122,7 @@ public void doClear(Long autoClearInterval) { .le(PlgMqMsg::getCreateTime, lastDate) .eq(PlgMqMsg::getSendState, SendStateEnum.OVER) .list(); - if (ObjectUtil.isEmpty(msgList)) { + if (ObjUtil.isEmpty(msgList)) { return; } List batchIdList = msgList.stream().map(PlgMqMsg::getId).collect(Collectors.toList()); @@ -140,7 +140,7 @@ public void checkBeforeSend(BaseTxMsg txMsg, MsgOption msgOption) { AssertUtil.isNull(txMsg.getRoutingKey(), () -> new TxMsgException("TxMsg routing key null")); AssertUtil.isNull(txMsg.getMessage(), () -> new TxMsgException("TxMsg message null")); // 没有设置 id 时生成雪花 id - if (ObjectUtil.isEmpty(txMsg.getId())) { + if (ObjUtil.isEmpty(txMsg.getId())) { ((TxMsg) txMsg).setId(String.valueOf(IdWorker.getId(txMsg))); } } @@ -206,8 +206,8 @@ private void doSendCommittedOrRetry(BaseTxMsg txMsg) { @Override public void handleConfirm(CorrelationData correlationData, boolean ack, String cause) { - if (ObjectUtil.isNull(correlationData) || ObjectUtil.isNull(correlationData.getId()) - || ObjectUtil.isNull(correlationData.getReturned())) { + if (ObjUtil.isNull(correlationData) || ObjUtil.isNull(correlationData.getId()) + || ObjUtil.isNull(correlationData.getReturned())) { return; } Message message = correlationData.getReturned().getMessage(); diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilterService.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilterService.java index bca65f6e..2fd5e4c8 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilterService.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilterService.java @@ -1,7 +1,7 @@ package com.github.cadecode.uniboot.framework.base.security.filter; import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import cn.hutool.extra.servlet.ServletUtil; import cn.hutool.http.ContentType; import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; @@ -64,7 +64,7 @@ protected void writeResponse(HttpServletResponse response, ApiErrorCode errorCod public void filter(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { if (RequestUtil.isInnerRequest(request)) { SysUserDetails userDetailsDto = RequestUtil.getInnerUserDetails(request); - if (ObjectUtil.isNotNull(userDetailsDto)) { + if (ObjUtil.isNotNull(userDetailsDto)) { setAuthentication(request, userDetailsDto); filterChain.doFilter(request, response); return; diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/voter/DataBaseRoleVoter.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/voter/DataBaseRoleVoter.java index 449c155e..74d36a55 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/voter/DataBaseRoleVoter.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/voter/DataBaseRoleVoter.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.framework.base.security.voter; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.framework.api.bean.dto.SysApiDto.SysApiRolesResDto; import com.github.cadecode.uniboot.framework.api.feignclient.SysApiClient; import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; @@ -65,7 +65,7 @@ public int vote(Authentication authentication, Object object, Collection optionalCookie = Arrays.stream(cookies) - .filter(c -> ObjectUtil.equal(c.getName(), HttpConst.HEAD_TOKEN)) + .filter(c -> ObjUtil.equal(c.getName(), HttpConst.HEAD_TOKEN)) .findAny(); if (optionalCookie.isPresent()) { return optionalCookie.get().getValue(); @@ -76,7 +76,7 @@ public static String generateUUID() { * @return token */ public static boolean isAuthenticated(Authentication authentication) { - if (ObjectUtil.isNull(authentication)) { + if (ObjUtil.isNull(authentication)) { authentication = SecurityContextHolder.getContext().getAuthentication(); } return authentication != null && authentication.getPrincipal() instanceof SysUserDetails; @@ -89,7 +89,7 @@ public static boolean isAuthenticated(Authentication authentication) { * @return SysUserDetails */ public static SysUserDetails getUserDetails(Authentication authentication) { - if (ObjectUtil.isNull(authentication)) { + if (ObjUtil.isNull(authentication)) { authentication = SecurityContextHolder.getContext().getAuthentication(); } if (authentication != null && authentication.getPrincipal() instanceof SysUserDetails) { diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java index a5c43b86..2404a0f6 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.framework.svc.controller; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.svc.bean.po.SysDict; @@ -45,8 +45,8 @@ public class SysDictController { public PageResult page(@RequestBody @Valid SysDictPageReqVo reqVo) { PageInfo pageInfo = PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize()) .doSelectPageInfo(() -> sysDictService.lambdaQuery() - .likeRight(ObjectUtil.isNotEmpty(reqVo.getName()), SysDict::getName, reqVo.getName()) - .likeRight(ObjectUtil.isNotEmpty(reqVo.getType()), SysDict::getType, reqVo.getType()) + .likeRight(ObjUtil.isNotEmpty(reqVo.getName()), SysDict::getName, reqVo.getName()) + .likeRight(ObjUtil.isNotEmpty(reqVo.getType()), SysDict::getType, reqVo.getType()) .orderByDesc(SysDict::getCreateTime) .list()); List voList = SysDictConvert.INSTANCE.poToPageResVo(pageInfo.getList()); diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java index 0b7c922b..ee7479f1 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.framework.svc.controller; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; @@ -78,7 +78,7 @@ public boolean modifyPass(@RequestBody @Valid SysUserModifyPassReqVo reqVo) { SysUserDetails userDetails = SecurityUtil.getUserDetails(null); SysUser sysUser = sysUserService.lambdaQuery().select(SysUser::getPassword) .eq(SysUser::getId, userDetails.getId()).one(); - if (ObjectUtil.notEqual(reqVo.getNewPass(), reqVo.getConfirmedPass())) { + if (ObjUtil.notEqual(reqVo.getNewPass(), reqVo.getConfirmedPass())) { throw ApiException.of("新密码和确认密码不一致"); } if (!passwordEncoder.matches(reqVo.getOldPass(), sysUser.getPassword())) { @@ -114,7 +114,7 @@ public boolean updateEnable(@RequestBody @Valid SysUserUpdateEnableReqVo reqVo) @PostMapping("update") public boolean update(@RequestBody @Valid SysUserVo.SysUserUpdateReqVo reqVo) { String encodePass = null; - if (ObjectUtil.isNotEmpty(reqVo.getPassword())) { + if (ObjUtil.isNotEmpty(reqVo.getPassword())) { encodePass = passwordEncoder.encode(reqVo.getPassword()); } SysUser po = SysUserConvert.INSTANCE.voToPo(reqVo); @@ -125,7 +125,7 @@ public boolean update(@RequestBody @Valid SysUserVo.SysUserUpdateReqVo reqVo) { @ApiOperation("添加用户") @PostMapping("add") public boolean add(@RequestBody @Valid SysUserAddReqVo reqVo) { - if (ObjectUtil.isNotEmpty(reqVo.getPassword())) { + if (ObjUtil.isNotEmpty(reqVo.getPassword())) { reqVo.setPassword(passwordEncoder.encode(reqVo.getPassword())); } SysUser sysUser = SysUserConvert.INSTANCE.voToPo(reqVo); diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java index 60947e90..264d1947 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysMenuServiceImpl.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.framework.svc.serviceimpl; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.cadecode.uniboot.framework.svc.bean.po.SysMenu; import com.github.cadecode.uniboot.framework.svc.bean.vo.SysMenuVo.SysMenuRolesReqVo; @@ -39,7 +39,7 @@ public List listByRoles(List roleCodes) { public List listTreeVoByRoles(List roleCodes) { List sysMenus = listByRoles(roleCodes); List menuTreeVoList = sysMenus.stream() - .filter(m -> ObjectUtil.equal(m.getEnableFlag(), true)) + .filter(m -> ObjUtil.equal(m.getEnableFlag(), true)) .map(SysMenuConvert.INSTANCE::poToTreeResVo) .collect(Collectors.toList()); return generateMenuTree(menuTreeVoList, null); @@ -65,12 +65,12 @@ private List generateMenuTree(List menus, Lo List resultList = new ArrayList<>(); menus.forEach(menu -> { // 确定下父亲 - if (ObjectUtil.notEqual(menu.getParentId(), rootId)) { + if (ObjUtil.notEqual(menu.getParentId(), rootId)) { return; } menus.forEach(m -> { // 比一下是不是儿子 - if (ObjectUtil.notEqual(m.getParentId(), menu.getId())) { + if (ObjUtil.notEqual(m.getParentId(), menu.getId())) { return; } // 拿儿子列表 diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java index 5a1adfbf..bc7ec010 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysUserServiceImpl.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.framework.svc.serviceimpl; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.github.cadecode.uniboot.common.core.exception.ApiException; import com.github.cadecode.uniboot.framework.svc.bean.po.SysUser; @@ -36,7 +36,7 @@ public class SysUserServiceImpl extends ServiceImpl impl public UserDetails loadUserByUsername(String username) { List userRolesVoList = sysUserMapper.selectRolesVoByUsername(username); // 用户账户不存在 - if (ObjectUtil.isEmpty(userRolesVoList)) { + if (ObjUtil.isEmpty(userRolesVoList)) { throw ApiException.of("该用户不存在"); } SysUserRolesResVo userRolesVo = userRolesVoList.get(0); diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/handler/GlobalExceptionHandler.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/handler/GlobalExceptionHandler.java index b44b16f0..ed28c8b7 100644 --- a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/handler/GlobalExceptionHandler.java +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/handler/GlobalExceptionHandler.java @@ -1,6 +1,6 @@ package com.github.cadecode.uniboot.gateway.handler; -import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; @@ -62,7 +62,7 @@ private ApiResult getApiResultFromEx(ServerWebExchange exchange, Throwab errorCode = FrameErrorEnum.GW_SVC_INTERNAL_ERROR; } ApiResult result = ApiResult.error(errorCode).moreInfo(moreInfo).path(path); - if (ObjectUtil.isNotNull(status)) { + if (ObjUtil.isNotNull(status)) { result.status(status); } return result; From 205513366e82e0bb541e582ac5e2da87e7f998ac Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sun, 20 Aug 2023 23:46:59 +0800 Subject: [PATCH 102/244] =?UTF-8?q?fix:=20=E5=AD=97=E6=AE=B5=20currRetryTi?= =?UTF-8?q?mes=20=E5=B7=B2=E6=94=B9=E4=B8=BA=20leftRetryTimes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java index 22304424..74d3c2eb 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java @@ -23,7 +23,7 @@ public interface PlgMqMsgConvert { @Mapping(target = "updateTime", ignore = true) @Mapping(target = "sendState", ignore = true) @Mapping(target = "nextRetryTime", ignore = true) - @Mapping(target = "currRetryTimes", ignore = true) + @Mapping(target = "leftRetryTimes", ignore = true) @Mapping(target = "createTime", ignore = true) @Mapping(target = "consumeState", ignore = true) @Mapping(target = "cause", ignore = true) From 675d157052929b8cd7ef8d5a04960a1d4a36482b Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 21 Aug 2023 22:57:40 +0800 Subject: [PATCH 103/244] =?UTF-8?q?feat:=20po=20to=20vo=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=90=8D=E8=A7=84=E8=8C=83=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/base/plugin/controller/PlgLogController.java | 2 +- .../uniboot/framework/base/plugin/convert/PlgLogConvert.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java index 997ffc20..16b453e1 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgLogController.java @@ -55,7 +55,7 @@ public PageResult page(@RequestBody @Valid PlgLogVo.PlgLogPageR .eq(ObjUtil.isNotNull(reqVo.getExceptional()), PlgLog::getExceptional, BoolToIntTypeHandler.mapping(reqVo.getExceptional())) .orderByDesc(PlgLog::getCreateTime) .list()); - List voList = PlgLogConvert.INSTANCE.poToVo(pageInfo.getList()); + List voList = PlgLogConvert.INSTANCE.poToPageResVo(pageInfo.getList()); return new PageResult<>((int) pageInfo.getTotal(), voList); } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgLogConvert.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgLogConvert.java index c8b33f2b..fc1d1643 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgLogConvert.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgLogConvert.java @@ -18,6 +18,6 @@ public interface PlgLogConvert { PlgLogConvert INSTANCE = Mappers.getMapper(PlgLogConvert.class); - List poToVo(List records); + List poToPageResVo(List records); } From 3e5fb6606bfeef2a70c25af836ec83d4e7f98784 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Wed, 23 Aug 2023 23:18:24 +0800 Subject: [PATCH 104/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20mq=20?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=9F=A5=E8=AF=A2=E6=9B=B4=E6=96=B0=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/plugin/bean/po/PlgMqMsg.java | 6 ++ .../base/plugin/bean/vo/PlgMqMsgVo.java | 59 +++++++++++++++ .../plugin/controller/PlgMqMsgController.java | 73 +++++++++++++++++++ .../base/plugin/convert/PlgMqMsgConvert.java | 24 ++++++ 4 files changed, 162 insertions(+) create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgMqMsgVo.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgMqMsgController.java diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java index 694e13d6..4fce4f18 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java @@ -3,7 +3,10 @@ import com.baomidou.mybatisplus.annotation.*; import com.github.cadecode.uniboot.framework.base.plugin.enums.ConsumeStateEnum; import com.github.cadecode.uniboot.framework.base.plugin.enums.SendStateEnum; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.util.Date; @@ -14,6 +17,9 @@ * @since 2023/8/19 */ @Data +@AllArgsConstructor +@NoArgsConstructor +@Builder @TableName(autoResultMap = true) public class PlgMqMsg { diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgMqMsgVo.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgMqMsgVo.java new file mode 100644 index 00000000..fa02b679 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgMqMsgVo.java @@ -0,0 +1,59 @@ +package com.github.cadecode.uniboot.framework.base.plugin.bean.vo; + +import com.github.cadecode.uniboot.common.core.web.response.PageParams; +import com.github.cadecode.uniboot.framework.base.plugin.enums.ConsumeStateEnum; +import com.github.cadecode.uniboot.framework.base.plugin.enums.SendStateEnum; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.NotNull; +import java.util.Date; +import java.util.List; + +/** + * MQ 消息实体 VO + * + * @author Cade Li + * @since 2023/8/19 + */ +public class PlgMqMsgVo { + + @EqualsAndHashCode(callSuper = true) + @Data + public static class PlgMqMsgPageReqVo extends PageParams { + private Date startCreateTime; + private Date endCreateTime; + private String bizType; + private List sendStateList; + } + + @Data + public static class PlgMqMsgPageResVo { + private String id; + private String bizType; + private String bizKey; + private String exchange; + private String routingKey; + private String message; + private SendStateEnum sendState; + private ConsumeStateEnum consumeState; + private Date nextRetryTime; + private String cause; + private Integer leftRetryTimes; + private Integer maxRetryTimes; + private Long backoffInitInterval; + private Double backoffMultiplier; + private Long backoffMaxInterval; + private Date createTime; + private Date updateTime; + private String updateUser; + } + + @Data + public static class PlgMqMsgUpdateReqVo { + @NotNull + private String id; + private SendStateEnum sendState; + private Integer leftRetryTimes; + } +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgMqMsgController.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgMqMsgController.java new file mode 100644 index 00000000..babff1e0 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgMqMsgController.java @@ -0,0 +1,73 @@ +package com.github.cadecode.uniboot.framework.base.plugin.controller; + +import cn.hutool.core.util.ObjUtil; +import com.github.cadecode.uniboot.common.core.web.response.PageResult; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgMqMsg; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgMqMsgVo.PlgMqMsgPageReqVo; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgMqMsgVo.PlgMqMsgPageResVo; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgMqMsgVo.PlgMqMsgUpdateReqVo; +import com.github.cadecode.uniboot.framework.base.plugin.convert.PlgMqMsgConvert; +import com.github.cadecode.uniboot.framework.base.plugin.service.PlgMqMsgService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; +import java.util.List; + +/** + * MQ 消息管理 + * + * @author Cade Li + * @since 2023/8/19 + */ +@ApiFormat +@Slf4j +@RequiredArgsConstructor +@Api(tags = "MQ 管理") +@RequestMapping("plugin/mq_msg") +@RestController +@Validated +public class PlgMqMsgController { + + private final PlgMqMsgService mqMsgService; + + @ApiOperation("查询列表") + @PostMapping("page") + public PageResult page(@RequestBody @Valid PlgMqMsgPageReqVo reqVo) { + PageInfo pageInfo = PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize()) + .doSelectPageInfo(() -> mqMsgService.lambdaQuery() + .ge(ObjUtil.isNotEmpty(reqVo.getStartCreateTime()), PlgMqMsg::getCreateTime, reqVo.getStartCreateTime()) + .le(ObjUtil.isNotEmpty(reqVo.getEndCreateTime()), PlgMqMsg::getCreateTime, reqVo.getEndCreateTime()) + .eq(ObjUtil.isNotEmpty(reqVo.getBizType()), PlgMqMsg::getBizType, reqVo.getBizType()) + .in(ObjUtil.isNotEmpty(reqVo.getSendStateList()), PlgMqMsg::getSendState, reqVo.getSendStateList()) + .orderByDesc(PlgMqMsg::getCreateTime) + .list()); + List voList = PlgMqMsgConvert.INSTANCE.poToPageResVo(pageInfo.getList()); + return new PageResult<>((int) pageInfo.getTotal(), voList); + } + + @ApiOperation("更新") + @PostMapping("update") + public boolean update(@RequestBody @Valid PlgMqMsgUpdateReqVo reqVo) { + PlgMqMsg po = PlgMqMsgConvert.INSTANCE.voToPo(reqVo); + return mqMsgService.updateById(po); + } + + @ApiOperation("查询-byIdList") + @PostMapping("list_by_id_list") + public List listByIdList(@RequestBody @NotEmpty List idList) { + List poList = mqMsgService.listByIds(idList); + return PlgMqMsgConvert.INSTANCE.poToPageResVo(poList); + } +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java index 74d3c2eb..77ae56f5 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java @@ -4,10 +4,14 @@ import com.github.cadecode.uniboot.common.plugin.mq.model.BaseTxMsg; import com.github.cadecode.uniboot.common.plugin.mq.model.TxMsg; import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgMqMsg; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgMqMsgVo.PlgMqMsgPageResVo; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgMqMsgVo.PlgMqMsgUpdateReqVo; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; +import java.util.List; + /** * PlgMqMsg Bean Convert * @@ -33,4 +37,24 @@ public interface PlgMqMsgConvert { MsgOption poToMsgOption(PlgMqMsg po); + PlgMqMsgPageResVo poToPageResVo(PlgMqMsg po); + + List poToPageResVo(List poList); + + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + @Mapping(target = "routingKey", ignore = true) + @Mapping(target = "nextRetryTime", ignore = true) + @Mapping(target = "message", ignore = true) + @Mapping(target = "maxRetryTimes", ignore = true) + @Mapping(target = "exchange", ignore = true) + @Mapping(target = "createTime", ignore = true) + @Mapping(target = "consumeState", ignore = true) + @Mapping(target = "cause", ignore = true) + @Mapping(target = "bizType", ignore = true) + @Mapping(target = "bizKey", ignore = true) + @Mapping(target = "backoffMultiplier", ignore = true) + @Mapping(target = "backoffMaxInterval", ignore = true) + @Mapping(target = "backoffInitInterval", ignore = true) + PlgMqMsg voToPo(PlgMqMsgUpdateReqVo reqVo); } From af703a1706c03a8cd2bc5f1466a7623e7ba5aa8a Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 24 Aug 2023 09:53:36 +0800 Subject: [PATCH 105/244] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A0=20RabbitMq?= =?UTF-8?q?=20=E7=9A=84=E7=A4=BA=E4=BE=8B=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/intro/application-config-example.md | 63 +++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/.docs/intro/application-config-example.md b/.docs/intro/application-config-example.md index cd180d74..e6166366 100644 --- a/.docs/intro/application-config-example.md +++ b/.docs/intro/application-config-example.md @@ -29,6 +29,22 @@ spring: min-idle: 0 max-idle: 8 max-wait: -1 + # rabbitmq 公共配置 + rabbitmq: + publisher-returns: true + publisher-confirm-type: correlated + listener: + simple: + concurrency: 1 + max-concurrency: 8 + acknowledge-mode: manual + retry: + enabled: true + max-attempts: 5 + max-interval: 10000 + initial-interval: 2000 + multiplier: 2 + prefetch: 5 # 数据源公共配置 datasource: druid: @@ -163,6 +179,12 @@ spring: port: 6379 password: ENC(jIiKGruIMgDkKx5wj2gJRCROqPutkTvZ) database: 0 + rabbitmq: + host: localhost + port: 5672 + username: rabbitmq + password: rabbitmq + virtual-host: /uni_dev datasource: type: com.alibaba.druid.pool.DruidDataSource dynamic: @@ -199,6 +221,12 @@ spring: port: 6379 password: ENC(jIiKGruIMgDkKx5wj2gJRCROqPutkTvZ) database: 0 + rabbitmq: + host: localhost + port: 5672 + username: rabbitmq + password: rabbitmq + virtual-host: /uni_dev datasource: type: com.alibaba.druid.pool.DruidDataSource dynamic: @@ -217,6 +245,41 @@ uni-boot: description: Example 服务在线文档 By Swagger security: ignore-urls: + mq: + rabbit: + enable: true + exchanges: + - name: uni.delay + type: topic + delayed: true + - name: uni.topic + type: topic + queues: + - name: example-delay-queue-0 + - name: example-delay-queue-1 + random-suffix: true + auto-delete: true + - name: example-biz-queue-0 + dl-exchange: uni.topic + dl-routing-key: example-biz-queue-0-dl-rk + - name: example-biz-queue-0-dl + - name: example-biz-queue-1 + bindings: + - bind-name: example-delay-queue-0 + exchange-name: uni.delay + routing-key: example-delay-queue-0-rk + - bind-name: example-delay-queue-1 + exchange-name: uni.delay + routing-key: example-delay-queue-1-rk + - bind-name: example-biz-queue-0 + exchange-name: uni.topic + routing-key: example-biz-queue-0-rk + - bind-name: example-biz-queue-0-dl + exchange-name: uni.topic + routing-key: example-biz-queue-0-dl-rk + - bind-name: example-biz-queue-1 + exchange-name: uni.topic + routing-key: example-biz-queue-1-rk ``` ### gateway 服务配置 From e3c86e9947dcae61137a1b1e674725c0ff7cb676 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 24 Aug 2023 10:02:27 +0800 Subject: [PATCH 106/244] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 50e9fa31..9209b421 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ 集成 knife4j,提供 swagger module 的动态配置支持 + 基础 RabbitMQ,提供通过配置声明交换机和队列功能,以及事务消息、消息重试的支持 + ... ## 功能模块 @@ -73,6 +75,7 @@ │ │ ├── log │ │ ├── mybatis │ │ ├── swagger + │ │ ├── mq │ │ └── pom.xml │ └── pom.xml ├── dependencies @@ -102,6 +105,7 @@ common/plugin/log # 日志模块,集成 API 访问日志 common/plugin/mybatis # mybatis 模块,集成 MybatisPlus、PageHelper common/plugin/swagger # swagger 模块,集成 knife4j,动态配置 swagger 的 module + common/plugin/mq # mq 模块,集成 RabbitMQ,提供事务消息、消息重试的支持 dependencies # 依赖管理模块,作为父模块,管理全局依赖版本 framework # 框架模块 framework/framework_api # 框架 feign api @@ -118,4 +122,3 @@ 参见配套前端项目 [uni-boot-admin-vue](https://github.com/cadecode/uni-boot-admin-vue) - From c8f64b4d3aa946f8c5f2663c6bd6b091de50ab5c Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 24 Aug 2023 12:24:37 +0800 Subject: [PATCH 107/244] =?UTF-8?q?docs:=20=E7=BB=B4=E6=8A=A4=20SQL=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=8C=E7=BB=B4=E6=8A=A4=20menu=20?= =?UTF-8?q?=E8=A1=A8=E3=80=81dict=20=E8=A1=A8=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/sql/framework/data.sql | 187 +++++++++++++++++++---------------- 1 file changed, 103 insertions(+), 84 deletions(-) diff --git a/.docs/sql/framework/data.sql b/.docs/sql/framework/data.sql index c29ecfbb..4d8815f9 100644 --- a/.docs/sql/framework/data.sql +++ b/.docs/sql/framework/data.sql @@ -22,51 +22,56 @@ INSERT INTO sys_role (id, code, name, description) -- ---------------------------- -- 插入菜单 -- ---------------------------- -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (1, null, 'Home', '/home/demo_home', '/Home/DemoHome', '首页', 1, 1, 1); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (1, null, 'Home', '/home/demo_home', '/Home/DemoHome', '首页', 1, 'el-icon-s-home', 1, 1, '2023-08-18 15:03:26', + '2023-08-24 10:28:24', 'admin'); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (2, null, 'System', '/system', '/system', '系统管理', 0, 'el-icon-setting', 2, 1, '2023-08-18 15:03:26', + '2023-08-24 10:28:43', 'admin'); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (3, null, 'Develop', '/develop', '/develop', '开发管理', 0, 'el-icon-s-platform', 2, 1, '2023-08-18 15:03:29', + '2023-08-24 10:28:58', 'admin'); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (201, 2, 'User', '/system/user', '/System/User', '用户管理', 1, null, 201, 1, '2023-08-18 15:03:27', null, null); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (202, 2, 'Role', '/system/role', '/System/Role', '角色管理', 1, null, 202, 1, '2023-08-18 15:03:27', null, null); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (203, 2, 'Menu', '/system/menu', '/System/Menu', '菜单管理', 1, null, 203, 1, '2023-08-18 15:03:28', null, null); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (204, 2, 'Api', '/system/api', '/System/Api', 'API管理', 1, null, 204, 1, '2023-08-18 15:03:28', null, null); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (205, 2, 'Dict', '/system/dict', '/System/Dict', '字典管理', 1, null, 205, 1, '2023-08-18 15:03:29', null, null); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (301, 3, 'Log', '/develop/log', '/Develop/Log', '日志管理', 1, null, 301, 1, '2023-08-18 15:03:30', null, null); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (302, 3, 'MqMsg', '/develop/mq_msg', '/Develop/MqMsg', '消息队列', 1, null, 302, 1, '2023-08-22 23:23:46', + '2023-08-24 10:30:42', 'admin'); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (306, 3, 'Icon', '/develop/icon', '/Develop/Icon', '图标', 1, null, 306, 1, '2023-08-18 15:03:30', null, null); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (307, 3, 'Echarts', '/develop/echarts', '/Develop/Echarts', 'Echarts 示例', 1, null, 307, 1, '2023-08-18 15:03:30', + null, null); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (308, 3, 'Swagger', 'http://localhost:8000/doc.html', null, 'Swagger', 1, null, 308, 1, '2023-08-18 15:03:30', + null, null); +INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) +VALUES (1000, null, 'GithubUrl', 'https://github.com/cadecode/uni-boot-admin', null, '源码仓库', 1, 'el-icon-star-on', 1000, + 1, '2023-08-18 15:03:31', '2023-08-24 10:28:09', 'admin'); -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (2, null, 'System', '/system', null, '系统管理', 0, 2, 1); -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (201, 2, 'User', '/system/user', '/System/User', '用户管理', 1, 201, 1); -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (202, 2, 'Role', '/system/role', '/System/Role', '角色管理', 1, 202, 1); -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (203, 2, 'Menu', '/system/menu', '/System/Menu', '菜单管理', 1, 203, 1); -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (204, 2, 'Api', '/system/api', '/System/Api', 'API管理', 1, 204, 1); -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (205, 2, 'Dict', '/system/dict', '/System/Dict', '字典管理', 1, 205, 1); - -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (3, null, 'Develop', '/develop', null, '开发管理', 0, 2, 1); -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (301, 3, 'Log', '/develop/log', '/Develop/Log', '日志管理', 1, 301, 1); -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (306, 3, 'Icon', '/develop/icon', '/Develop/Icon', '图标', 1, 306, 1); -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (307, 3, 'Echarts', '/develop/echarts', '/Develop/Echarts', 'Echarts 示例', 1, 307, 1); -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (308, 3, 'Swagger', 'http://localhost:8000/doc.html', null, 'Swagger', 1, 308, 1); -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (309, 3, 'Druid', 'http://localhost:8000/druid', null, 'Druid', 1, 309, 1); - -INSERT INTO sys_menu(id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, order_num, - enable_flag) - VALUE (1000, null, 'GithubUrl', 'https://github.com/cadecode/uni-boot-admin', null, '源码仓库', 1, 1000, 1); -- ---------------------------- -- 插入 API -- ---------------------------- @@ -103,6 +108,8 @@ VALUES (1, 3); INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 301); INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 302); +INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 306); INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 307); @@ -146,43 +153,55 @@ VALUES (3, 1); -- ---------------------------- -- 插入字典 -- ---------------------------- -INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, - update_user) -VALUES (1, '日志类型', 'logType', '查询', 'Query', '日志类型-查询', 0, 0, '2023-06-11 23:24:26', - '2023-06-12 00:11:57', 'admin'); -INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, - update_user) -VALUES (2, '日志类型', 'logType', '删除', 'Remove', '日志类型-删除', 1, 0, '2023-06-11 23:24:52', - '2023-06-12 00:12:01', 'admin'); -INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, - update_user) -VALUES (3, '日志类型', 'logType', '更新', 'Update', '日志类型-更新', 2, 0, '2023-06-11 23:25:08', - '2023-06-12 00:12:05', 'admin'); -INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, - update_user) -VALUES (4, '日志类型', 'logType', '添加', 'Add', '日志类型-添加', 3, 0, '2023-06-11 23:25:29', - '2023-06-12 00:12:09', 'admin'); -INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, - update_user) -VALUES (5, '日志类型', 'logType', '鉴权', 'Auth', '日志类型-鉴权', 4, 0, '2023-06-11 23:25:45', - '2023-06-12 00:12:15', 'admin'); -INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, - update_user) -VALUES (6, '日志类型', 'logType', '导入', 'Import', '日志类型-导入', 5, 0, '2023-06-11 23:25:58', - '2023-06-12 00:12:19', 'admin'); -INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, - update_user) -VALUES (7, '日志类型', 'logType', '导出', 'Export', '日志类型-导出', 6, 0, '2023-06-11 23:26:09', - '2023-06-12 00:12:30', 'admin'); -INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, - update_user) -VALUES (8, '日志类型', 'logType', '上传', 'Upload', '日志类型-上传', 7, 0, '2023-06-11 23:26:26', - '2023-06-12 00:12:35', 'admin'); -INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, - update_user) -VALUES (9, '日志类型', 'logType', '下载', 'Download', '日志类型-下载', 8, 0, '2023-06-11 23:26:40', - '2023-06-12 00:12:40', 'admin'); -INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, update_time, - update_user) -VALUES (10, '日志类型', 'logType', '其他', 'Other', '日志类型-其他', 9, 0, '2023-06-11 23:26:49', - '2023-06-12 00:52:14', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (1, '日志类型', 'logType', '查询', 'Query', '日志类型-查询', 0, 0, '2023-06-11 23:24:26', '2023-06-12 00:11:57', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (2, '日志类型', 'logType', '删除', 'Remove', '日志类型-删除', 1, 0, '2023-06-11 23:24:52', '2023-06-12 00:12:01', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (3, '日志类型', 'logType', '更新', 'Update', '日志类型-更新', 2, 0, '2023-06-11 23:25:08', '2023-06-12 00:12:05', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (4, '日志类型', 'logType', '添加', 'Add', '日志类型-添加', 3, 0, '2023-06-11 23:25:29', '2023-06-12 00:12:09', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (5, '日志类型', 'logType', '鉴权', 'Auth', '日志类型-鉴权', 4, 0, '2023-06-11 23:25:45', '2023-06-12 00:12:15', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (6, '日志类型', 'logType', '导入', 'Import', '日志类型-导入', 5, 0, '2023-06-11 23:25:58', '2023-06-12 00:12:19', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (7, '日志类型', 'logType', '导出', 'Export', '日志类型-导出', 6, 0, '2023-06-11 23:26:09', '2023-06-12 00:12:30', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (8, '日志类型', 'logType', '上传', 'Upload', '日志类型-上传', 7, 0, '2023-06-11 23:26:26', '2023-06-12 00:12:35', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (9, '日志类型', 'logType', '下载', 'Download', '日志类型-下载', 8, 0, '2023-06-11 23:26:40', '2023-06-12 00:12:40', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (10, '日志类型', 'logType', '其他', 'Other', '日志类型-其他', 9, 0, '2023-06-11 23:26:49', '2023-06-12 00:52:14', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (11, '服务URL', 'serviceUrl', '框架服务', '/framework', 'framework 服务 url 前缀', 1, 1, '2023-08-18 15:09:16', + '2023-08-24 10:20:50', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (12, '服务URL', 'serviceUrl', '示例服务', '/example', 'example 服务 url 前缀', 2, 0, '2023-08-18 15:09:30', + '2023-08-24 10:20:51', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (13, 'MQ消息发送状态', 'mqMsgSendState', '处理中', 'PREPARING', 'MQ 消息发送中', 1, 1, '2023-08-22 23:25:52', + '2023-08-24 10:20:50', 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (14, 'MQ消息发送状态', 'mqMsgSendState', '失败', 'FAIL', 'MQ 消息发送失败', 2, 1, '2023-08-22 23:26:04', '2023-08-24 10:20:51', + 'admin'); +INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (15, 'MQ消息发送状态', 'mqMsgSendState', '完成', 'OVER', 'MQ 消息发送完成', 3, 0, '2023-08-22 23:26:10', '2023-08-24 10:20:50', + 'admin'); + + From 0f60820377cd6f92fd8cd0eabba806a0bae8f618 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 24 Aug 2023 14:32:27 +0800 Subject: [PATCH 108/244] =?UTF-8?q?build:=20=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=88=B0=202023.1.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/core/pom.xml | 2 +- common/plugin/actuator/pom.xml | 2 +- common/plugin/cache/pom.xml | 2 +- common/plugin/concurrent/pom.xml | 2 +- common/plugin/datasource/pom.xml | 2 +- common/plugin/log/pom.xml | 2 +- common/plugin/mq/pom.xml | 2 +- common/plugin/mybatis/pom.xml | 2 +- common/plugin/pom.xml | 2 +- common/plugin/swagger/pom.xml | 2 +- common/pom.xml | 2 +- dependencies/pom.xml | 2 +- example/example_api/pom.xml | 2 +- example/example_svc/pom.xml | 2 +- example/pom.xml | 2 +- framework/framework_api/pom.xml | 2 +- framework/framework_base/pom.xml | 2 +- framework/framework_svc/pom.xml | 2 +- framework/pom.xml | 2 +- gateway/pom.xml | 2 +- pom.xml | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/common/core/pom.xml b/common/core/pom.xml index 1040393c..e724a1db 100644 --- a/common/core/pom.xml +++ b/common/core/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common - 2023.1.1 + 2023.1.2 4.0.0 diff --git a/common/plugin/actuator/pom.xml b/common/plugin/actuator/pom.xml index e75fe736..15b427e2 100644 --- a/common/plugin/actuator/pom.xml +++ b/common/plugin/actuator/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.1 + 2023.1.2 4.0.0 diff --git a/common/plugin/cache/pom.xml b/common/plugin/cache/pom.xml index 1424b09e..84fb1180 100644 --- a/common/plugin/cache/pom.xml +++ b/common/plugin/cache/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.1 + 2023.1.2 4.0.0 diff --git a/common/plugin/concurrent/pom.xml b/common/plugin/concurrent/pom.xml index 3310085f..713e16df 100644 --- a/common/plugin/concurrent/pom.xml +++ b/common/plugin/concurrent/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.1 + 2023.1.2 4.0.0 diff --git a/common/plugin/datasource/pom.xml b/common/plugin/datasource/pom.xml index b0558ce6..db76ee99 100644 --- a/common/plugin/datasource/pom.xml +++ b/common/plugin/datasource/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.1 + 2023.1.2 4.0.0 diff --git a/common/plugin/log/pom.xml b/common/plugin/log/pom.xml index 26524fa7..7f3ed481 100644 --- a/common/plugin/log/pom.xml +++ b/common/plugin/log/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.1 + 2023.1.2 4.0.0 diff --git a/common/plugin/mq/pom.xml b/common/plugin/mq/pom.xml index c393229a..56c03339 100644 --- a/common/plugin/mq/pom.xml +++ b/common/plugin/mq/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.1 + 2023.1.2 4.0.0 diff --git a/common/plugin/mybatis/pom.xml b/common/plugin/mybatis/pom.xml index 32faf223..438ea17c 100644 --- a/common/plugin/mybatis/pom.xml +++ b/common/plugin/mybatis/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.1 + 2023.1.2 4.0.0 diff --git a/common/plugin/pom.xml b/common/plugin/pom.xml index 41956ffc..d5b6093e 100644 --- a/common/plugin/pom.xml +++ b/common/plugin/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common - 2023.1.1 + 2023.1.2 4.0.0 diff --git a/common/plugin/swagger/pom.xml b/common/plugin/swagger/pom.xml index fdc2ca0c..f501ccd9 100644 --- a/common/plugin/swagger/pom.xml +++ b/common/plugin/swagger/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2023.1.1 + 2023.1.2 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index 6df196f7..b632f72f 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ uni-boot-dependencies com.github.cadecode - 2023.1.1 + 2023.1.2 ../dependencies/pom.xml 4.0.0 diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 39a1b4c2..abb76ff5 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-parent - 2023.1.1 + 2023.1.2 4.0.0 diff --git a/example/example_api/pom.xml b/example/example_api/pom.xml index 4319299f..8d14f3ef 100644 --- a/example/example_api/pom.xml +++ b/example/example_api/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-example - 2023.1.1 + 2023.1.2 4.0.0 diff --git a/example/example_svc/pom.xml b/example/example_svc/pom.xml index eb3bf2c7..59f71dbc 100644 --- a/example/example_svc/pom.xml +++ b/example/example_svc/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-example - 2023.1.1 + 2023.1.2 4.0.0 diff --git a/example/pom.xml b/example/pom.xml index 9ed63171..9fa8df8b 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -5,7 +5,7 @@ uni-boot-dependencies com.github.cadecode - 2023.1.1 + 2023.1.2 ../dependencies/pom.xml 4.0.0 diff --git a/framework/framework_api/pom.xml b/framework/framework_api/pom.xml index 5ef03faa..2cf76b97 100644 --- a/framework/framework_api/pom.xml +++ b/framework/framework_api/pom.xml @@ -6,7 +6,7 @@ com.github.cadecode uni-boot-framework - 2023.1.1 + 2023.1.2 uni-boot-framework-api diff --git a/framework/framework_base/pom.xml b/framework/framework_base/pom.xml index 6a86c5a7..875244a7 100644 --- a/framework/framework_base/pom.xml +++ b/framework/framework_base/pom.xml @@ -6,7 +6,7 @@ com.github.cadecode uni-boot-framework - 2023.1.1 + 2023.1.2 uni-boot-framework-base diff --git a/framework/framework_svc/pom.xml b/framework/framework_svc/pom.xml index 0f6023be..84cdc868 100644 --- a/framework/framework_svc/pom.xml +++ b/framework/framework_svc/pom.xml @@ -6,7 +6,7 @@ com.github.cadecode uni-boot-framework - 2023.1.1 + 2023.1.2 jar diff --git a/framework/pom.xml b/framework/pom.xml index 4bbb2ef6..44245a6d 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -5,7 +5,7 @@ uni-boot-dependencies com.github.cadecode - 2023.1.1 + 2023.1.2 ../dependencies/pom.xml 4.0.0 diff --git a/gateway/pom.xml b/gateway/pom.xml index 93377108..e78efc62 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -5,7 +5,7 @@ uni-boot-dependencies com.github.cadecode - 2023.1.1 + 2023.1.2 ../dependencies/pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index 1b02e212..237c973a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.cadecode uni-boot-parent - 2023.1.1 + 2023.1.2 pom uni-boot-admin From cec0d4bea0933d3788ea8f8ec68af5173db44dfb Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 28 Aug 2023 10:16:28 +0800 Subject: [PATCH 109/244] =?UTF-8?q?docs:=20=E7=BB=B4=E6=8A=A4=20SQL=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=8C=E5=88=A0=E9=99=A4=20schema=20?= =?UTF-8?q?=E5=89=8D=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/sql/framework/data.sql | 116 +++++++++++++++++------------------ 1 file changed, 58 insertions(+), 58 deletions(-) diff --git a/.docs/sql/framework/data.sql b/.docs/sql/framework/data.sql index 4d8815f9..14c940bf 100644 --- a/.docs/sql/framework/data.sql +++ b/.docs/sql/framework/data.sql @@ -22,53 +22,53 @@ INSERT INTO sys_role (id, code, name, description) -- ---------------------------- -- 插入菜单 -- ---------------------------- -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (1, null, 'Home', '/home/demo_home', '/Home/DemoHome', '首页', 1, 'el-icon-s-home', 1, 1, '2023-08-18 15:03:26', '2023-08-24 10:28:24', 'admin'); -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (2, null, 'System', '/system', '/system', '系统管理', 0, 'el-icon-setting', 2, 1, '2023-08-18 15:03:26', '2023-08-24 10:28:43', 'admin'); -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (3, null, 'Develop', '/develop', '/develop', '开发管理', 0, 'el-icon-s-platform', 2, 1, '2023-08-18 15:03:29', '2023-08-24 10:28:58', 'admin'); -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (201, 2, 'User', '/system/user', '/System/User', '用户管理', 1, null, 201, 1, '2023-08-18 15:03:27', null, null); -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (202, 2, 'Role', '/system/role', '/System/Role', '角色管理', 1, null, 202, 1, '2023-08-18 15:03:27', null, null); -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (203, 2, 'Menu', '/system/menu', '/System/Menu', '菜单管理', 1, null, 203, 1, '2023-08-18 15:03:28', null, null); -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (204, 2, 'Api', '/system/api', '/System/Api', 'API管理', 1, null, 204, 1, '2023-08-18 15:03:28', null, null); -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (205, 2, 'Dict', '/system/dict', '/System/Dict', '字典管理', 1, null, 205, 1, '2023-08-18 15:03:29', null, null); -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (301, 3, 'Log', '/develop/log', '/Develop/Log', '日志管理', 1, null, 301, 1, '2023-08-18 15:03:30', null, null); -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (302, 3, 'MqMsg', '/develop/mq_msg', '/Develop/MqMsg', '消息队列', 1, null, 302, 1, '2023-08-22 23:23:46', '2023-08-24 10:30:42', 'admin'); -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (306, 3, 'Icon', '/develop/icon', '/Develop/Icon', '图标', 1, null, 306, 1, '2023-08-18 15:03:30', null, null); -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (307, 3, 'Echarts', '/develop/echarts', '/Develop/Echarts', 'Echarts 示例', 1, null, 307, 1, '2023-08-18 15:03:30', null, null); -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (308, 3, 'Swagger', 'http://localhost:8000/doc.html', null, 'Swagger', 1, null, 308, 1, '2023-08-18 15:03:30', null, null); -INSERT INTO uni_boot_dev.sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, - order_num, enable_flag, create_time, update_time, update_user) +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (1000, null, 'GithubUrl', 'https://github.com/cadecode/uni-boot-admin', null, '源码仓库', 1, 'el-icon-star-on', 1000, 1, '2023-08-18 15:03:31', '2023-08-24 10:28:09', 'admin'); @@ -153,54 +153,54 @@ VALUES (3, 1); -- ---------------------------- -- 插入字典 -- ---------------------------- -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (1, '日志类型', 'logType', '查询', 'Query', '日志类型-查询', 0, 0, '2023-06-11 23:24:26', '2023-06-12 00:11:57', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (2, '日志类型', 'logType', '删除', 'Remove', '日志类型-删除', 1, 0, '2023-06-11 23:24:52', '2023-06-12 00:12:01', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (3, '日志类型', 'logType', '更新', 'Update', '日志类型-更新', 2, 0, '2023-06-11 23:25:08', '2023-06-12 00:12:05', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (4, '日志类型', 'logType', '添加', 'Add', '日志类型-添加', 3, 0, '2023-06-11 23:25:29', '2023-06-12 00:12:09', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (5, '日志类型', 'logType', '鉴权', 'Auth', '日志类型-鉴权', 4, 0, '2023-06-11 23:25:45', '2023-06-12 00:12:15', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (6, '日志类型', 'logType', '导入', 'Import', '日志类型-导入', 5, 0, '2023-06-11 23:25:58', '2023-06-12 00:12:19', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (7, '日志类型', 'logType', '导出', 'Export', '日志类型-导出', 6, 0, '2023-06-11 23:26:09', '2023-06-12 00:12:30', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (8, '日志类型', 'logType', '上传', 'Upload', '日志类型-上传', 7, 0, '2023-06-11 23:26:26', '2023-06-12 00:12:35', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (9, '日志类型', 'logType', '下载', 'Download', '日志类型-下载', 8, 0, '2023-06-11 23:26:40', '2023-06-12 00:12:40', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (10, '日志类型', 'logType', '其他', 'Other', '日志类型-其他', 9, 0, '2023-06-11 23:26:49', '2023-06-12 00:52:14', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (11, '服务URL', 'serviceUrl', '框架服务', '/framework', 'framework 服务 url 前缀', 1, 1, '2023-08-18 15:09:16', '2023-08-24 10:20:50', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (12, '服务URL', 'serviceUrl', '示例服务', '/example', 'example 服务 url 前缀', 2, 0, '2023-08-18 15:09:30', '2023-08-24 10:20:51', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (13, 'MQ消息发送状态', 'mqMsgSendState', '处理中', 'PREPARING', 'MQ 消息发送中', 1, 1, '2023-08-22 23:25:52', '2023-08-24 10:20:50', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (14, 'MQ消息发送状态', 'mqMsgSendState', '失败', 'FAIL', 'MQ 消息发送失败', 2, 1, '2023-08-22 23:26:04', '2023-08-24 10:20:51', 'admin'); -INSERT INTO uni_boot_dev.sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, - update_time, update_user) +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) VALUES (15, 'MQ消息发送状态', 'mqMsgSendState', '完成', 'OVER', 'MQ 消息发送完成', 3, 0, '2023-08-22 23:26:10', '2023-08-24 10:20:50', 'admin'); From 95de5205b4c8aaa5eb08d218e31b9dadca36051f Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 5 Sep 2023 16:03:26 +0800 Subject: [PATCH 110/244] =?UTF-8?q?feat:=20=E7=BC=93=E5=AD=98=E6=B3=A8?= =?UTF-8?q?=E8=A7=A3=E6=89=93=E5=88=B0=20controller=20=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/api/feignclient/SysApiClient.java | 2 +- .../uniboot/framework/svc/controller/SysApiController.java | 5 +++-- .../framework/svc/controller/SysRoleController.java | 7 +++++-- .../framework/svc/serviceimpl/SysRoleServiceImpl.java | 6 ------ 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java index 44128c36..4af664d0 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java @@ -18,7 +18,7 @@ @FeignClient(contextId = "SysApiClient", name = SvcNameConst.FRAMEWORK) public interface SysApiClient { - @Cacheable(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") + @Cacheable(cacheNames = KeyPrefixConst.API_ROLES, key = "'ALL'") @PostMapping("system/api/list_roles_vo") List listRolesResVo(); diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java index abc9062a..16a20310 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java @@ -56,7 +56,7 @@ public PageResult pageRolesVo(@RequestBody @Valid SysApiRolesR return new PageResult<>((int) rolesVoPage.getTotal(), rolesVoPage.getList()); } - @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'ALL'") @ApiOperation("更新API") @PostMapping("update") public boolean update(@RequestBody @Valid SysApiUpdateReqVo reqVo) { @@ -64,7 +64,7 @@ public boolean update(@RequestBody @Valid SysApiUpdateReqVo reqVo) { return sysApiService.updateById(po); } - @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'ALL'") @ApiOperation("添加API") @PostMapping("add") public boolean add(@RequestBody @Valid SysApiAddReqVo reqVo) { @@ -72,6 +72,7 @@ public boolean add(@RequestBody @Valid SysApiAddReqVo reqVo) { return sysApiService.save(sysApi); } + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'ALL'") @ApiOperation("删除API(多选)") @PostMapping("delete") @Transactional(rollbackFor = Exception.class) diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java index aed753ea..e13e7f75 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysRoleController.java @@ -74,12 +74,14 @@ public boolean removeMenuMapping(@RequestBody @NotEmpty List 0; } + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'ALL'") @ApiOperation("添加API角色绑定") @PostMapping("add_api_mapping") public boolean addApiMapping(@RequestBody @NotEmpty List reqVoList) { return sysRoleService.addRoleApi(reqVoList) > 0; } + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'ALL'") @ApiOperation("删除API角色绑定") @PostMapping("remove_api_mapping") public boolean removeApiMapping(@RequestBody @NotEmpty List reqVoList) { @@ -99,7 +101,7 @@ public List listUnionVoByRoleIds(@RequestBody @NotEmpty List< return sysRoleService.listUnionVoByRoleIds(roleIds); } - @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'ALL'") @ApiOperation("更新角色") @PostMapping("update") public boolean update(@RequestBody @Valid SysRoleVo.SysRoleUpdateReqVo reqVo) { @@ -107,7 +109,7 @@ public boolean update(@RequestBody @Valid SysRoleVo.SysRoleUpdateReqVo reqVo) { return sysRoleService.updateById(po); } - @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'ALL'") @ApiOperation("添加角色") @PostMapping("add") public boolean add(@RequestBody @Valid SysRoleAddReqVo reqVo) { @@ -115,6 +117,7 @@ public boolean add(@RequestBody @Valid SysRoleAddReqVo reqVo) { return sysRoleService.save(sysRole); } + @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'ALL'") @ApiOperation("删除角色(多选)") @PostMapping("delete") @Transactional(rollbackFor = Exception.class) diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java index 95a194a6..4d4e7975 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/serviceimpl/SysRoleServiceImpl.java @@ -1,7 +1,6 @@ package com.github.cadecode.uniboot.framework.svc.serviceimpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.github.cadecode.uniboot.framework.api.consts.KeyPrefixConst; import com.github.cadecode.uniboot.framework.svc.bean.po.SysRole; import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleMappingReqVo; import com.github.cadecode.uniboot.framework.svc.bean.vo.SysRoleVo.SysRoleUnionReqVo; @@ -11,7 +10,6 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import lombok.RequiredArgsConstructor; -import org.springframework.cache.annotation.CacheEvict; import org.springframework.stereotype.Service; import java.util.List; @@ -63,13 +61,11 @@ public int removeRoleMenuByRoleIds(List roleIds) { return sysRoleMapper.deleteRoleMenuByRoleIds(roleIds); } - @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @Override public int removeRoleApiByApiIds(List apiIds) { return sysRoleMapper.deleteRoleApiByApiIds(apiIds); } - @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @Override public int removeRoleApiByRoleIds(List roleIds) { return sysRoleMapper.deleteRoleApiByRoleIds(roleIds); @@ -85,7 +81,6 @@ public int removeRoleMenu(List list) { return sysRoleMapper.deleteRoleMenu(list); } - @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @Override public int removeRoleApi(List list) { return sysRoleMapper.deleteRoleApi(list); @@ -101,7 +96,6 @@ public int addRoleMenu(List list) { return sysRoleMapper.insertRoleMenu(list); } - @CacheEvict(cacheNames = KeyPrefixConst.API_ROLES, key = "'all'") @Override public int addRoleApi(List list) { return sysRoleMapper.insertRoleApi(list); From 8e997012ec2bffd0654404b2ec9a8910045e4422 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 5 Sep 2023 16:11:08 +0800 Subject: [PATCH 111/244] =?UTF-8?q?feat:=20=E5=AD=97=E5=85=B8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/api/consts/KeyPrefixConst.java | 5 +++++ .../framework/svc/controller/SysDictController.java | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/KeyPrefixConst.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/KeyPrefixConst.java index d78b6630..d317f450 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/KeyPrefixConst.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/consts/KeyPrefixConst.java @@ -19,4 +19,9 @@ public interface KeyPrefixConst { * Api Roles 映射关系 */ String API_ROLES = "frame:cache:apiRoles"; + + /** + * 字典 + */ + String DICT = "frame:cache:dict"; } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java index 2404a0f6..9bdd7aba 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysDictController.java @@ -2,6 +2,7 @@ import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; +import com.github.cadecode.uniboot.framework.api.consts.KeyPrefixConst; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.svc.bean.po.SysDict; import com.github.cadecode.uniboot.framework.svc.convert.SysDictConvert; @@ -12,6 +13,8 @@ import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -53,6 +56,7 @@ public PageResult page(@RequestBody @Valid SysDictPageReqVo re return new PageResult<>((int) pageInfo.getTotal(), voList); } + @CacheEvict(cacheNames = KeyPrefixConst.DICT, key = "#reqVo.type") @ApiOperation("添加") @PostMapping("add") public boolean add(@RequestBody @Valid SysDictAddReqVo reqVo) { @@ -60,6 +64,7 @@ public boolean add(@RequestBody @Valid SysDictAddReqVo reqVo) { return sysDictService.save(po); } + @CacheEvict(cacheNames = KeyPrefixConst.DICT, key = "#reqVo.type") @ApiOperation("更新") @PostMapping("update") public boolean update(@RequestBody @Valid SysDictUpdateReqVo reqVo) { @@ -67,12 +72,14 @@ public boolean update(@RequestBody @Valid SysDictUpdateReqVo reqVo) { return sysDictService.updateById(po); } + @CacheEvict(cacheNames = KeyPrefixConst.DICT, allEntries = true) @ApiOperation("删除") @PostMapping("delete") public boolean delete(@RequestBody @NotEmpty List idList) { return sysDictService.removeBatchByIds(idList); } + @Cacheable(cacheNames = KeyPrefixConst.DICT, key = "#type") @ApiOperation("查询 ByType") @GetMapping("list_by_type") public List listByType(@RequestParam String type) { From 4d84efc7a9fc6746578ad45f9fd6d1268a212f89 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 7 Sep 2023 09:27:46 +0800 Subject: [PATCH 112/244] =?UTF-8?q?feat:=20feign=20=E9=BB=98=E8=AE=A4=20lo?= =?UTF-8?q?g=20=E5=9F=BA=E6=9C=AC=E6=8C=87=E5=AE=9A=20BASIC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/base/config/FeignConfig.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java index 970f2447..38f0fdd8 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java @@ -15,6 +15,7 @@ import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import feign.Client; import feign.Client.Default; +import feign.Logger.Level; import feign.RequestInterceptor; import feign.RequestTemplate; import feign.codec.ErrorDecoder; @@ -39,6 +40,9 @@ @Configuration public class FeignConfig { + /** + * feign 拦截器 + */ @Bean public RequestInterceptor requestInterceptor() { return this::configRequestTemplate; @@ -92,8 +96,19 @@ public Client feignRetryClient(LoadBalancerClient loadBalancerClient, LoadBalanc return new RetryableFeignBlockingLoadBalancerClient(decorator, loadBalancerClient, loadBalancedRetryFactory, properties, loadBalancerClientFactory); } + /** + * feign 消息 decoder + */ @Bean public ErrorDecoder errorDecoder(ObjectMapper objectMapper) { return new FeignErrorDecoder(objectMapper); } + + /** + * feign 默认日志级别 + */ + @Bean + public Level feignLogLevel() { + return Level.BASIC; + } } From ed85cc00527cb28ac2abba854092c5a528012e89 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 8 Sep 2023 10:43:49 +0800 Subject: [PATCH 113/244] =?UTF-8?q?feat:=20feign=20=E9=9B=86=E6=88=90=20ap?= =?UTF-8?q?ache=20httpclient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/framework_api/pom.xml | 4 + .../framework/base/config/FeignConfig.java | 139 +++++++++++------- 2 files changed, 93 insertions(+), 50 deletions(-) diff --git a/framework/framework_api/pom.xml b/framework/framework_api/pom.xml index 2cf76b97..6ea19ac8 100644 --- a/framework/framework_api/pom.xml +++ b/framework/framework_api/pom.xml @@ -22,6 +22,10 @@ org.springframework.cloud spring-cloud-starter-openfeign + + io.github.openfeign + feign-httpclient + org.springframework.cloud spring-cloud-starter-loadbalancer diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java index 38f0fdd8..5cced597 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/FeignConfig.java @@ -8,6 +8,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.github.cadecode.uniboot.common.core.util.JacksonUtil; import com.github.cadecode.uniboot.framework.api.consts.HttpConst; +import com.github.cadecode.uniboot.framework.base.config.FeignConfig.ApacheHttpFeignConfig; +import com.github.cadecode.uniboot.framework.base.config.FeignConfig.DefaultFeignConfig; import com.github.cadecode.uniboot.framework.base.feign.FeignClientDecorator; import com.github.cadecode.uniboot.framework.base.feign.FeignErrorDecoder; import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; @@ -17,8 +19,10 @@ import feign.Client.Default; import feign.Logger.Level; import feign.RequestInterceptor; -import feign.RequestTemplate; import feign.codec.ErrorDecoder; +import feign.httpclient.ApacheHttpClient; +import lombok.extern.slf4j.Slf4j; +import org.apache.http.client.HttpClient; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.cloud.client.loadbalancer.LoadBalancedRetryFactory; import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; @@ -28,6 +32,7 @@ import org.springframework.cloud.openfeign.loadbalancer.RetryableFeignBlockingLoadBalancerClient; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Import; import javax.servlet.http.HttpServletRequest; @@ -37,7 +42,9 @@ * @author Cade Li * @since 2023/7/29 */ +@Slf4j @Configuration +@Import({ApacheHttpFeignConfig.class, DefaultFeignConfig.class}) public class FeignConfig { /** @@ -45,55 +52,34 @@ public class FeignConfig { */ @Bean public RequestInterceptor requestInterceptor() { - return this::configRequestTemplate; - } - - protected void configRequestTemplate(RequestTemplate requestTemplate) { - // 设置内部请求来源标识 - requestTemplate.header(HttpConst.HEAD_SOURCE, HttpConst.HEAD_SOURCE_VALUE); - HttpServletRequest servletRequest = RequestUtil.getRequest(); - if (ObjUtil.isNull(servletRequest)) { - return; - } - // 配置客户端 IP - requestTemplate.header(HttpConst.HEAD_FORWARDED_FOR, ServletUtil.getClientIP(servletRequest)); - // 传递 trace id - String traceId = ServletUtil.getHeader(servletRequest, HttpConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); - if (ObjUtil.isNotEmpty(traceId)) { - requestTemplate.header(HttpConst.HEAD_TRACE_ID, traceId); - } - // 传递用户 token - String token = SecurityUtil.getTokenFromRequest(servletRequest); - if (StrUtil.isNotEmpty(token)) { - requestTemplate.header(HttpConst.HEAD_TOKEN, token); - } - // 传递用户信息 - String userDetailsJson = ServletUtil.getHeader(servletRequest, HttpConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); - // 不存在则生成 - if (StrUtil.isEmpty(userDetailsJson)) { - SysUserDetails userDetailsDto = SecurityUtil.getUserDetails(null); - userDetailsJson = JacksonUtil.toJson(userDetailsDto); - } - requestTemplate.header(HttpConst.HEAD_USER_DETAILS, EscapeUtil.escape(userDetailsJson)); - } - - // 覆盖 feign 配置 - // org.springframework.cloud.openfeign.loadbalancer.DefaultFeignLoadBalancerConfiguration - - @Bean - @ConditionalOnProperty(value = "spring.cloud.loadbalancer.retry.enabled", havingValue = "false") - public Client feignClient(LoadBalancerClient loadBalancerClient, LoadBalancerProperties properties, - LoadBalancerClientFactory loadBalancerClientFactory) { - FeignClientDecorator decorator = new FeignClientDecorator(new Default(null, null)); - return new FeignBlockingLoadBalancerClient(decorator, loadBalancerClient, properties, loadBalancerClientFactory); - } - - @Bean - @ConditionalOnProperty(value = "spring.cloud.loadbalancer.retry.enabled", havingValue = "true", matchIfMissing = true) - public Client feignRetryClient(LoadBalancerClient loadBalancerClient, LoadBalancedRetryFactory loadBalancedRetryFactory, - LoadBalancerProperties properties, LoadBalancerClientFactory loadBalancerClientFactory) { - FeignClientDecorator decorator = new FeignClientDecorator(new Default(null, null)); - return new RetryableFeignBlockingLoadBalancerClient(decorator, loadBalancerClient, loadBalancedRetryFactory, properties, loadBalancerClientFactory); + return requestTemplate -> { + // 设置内部请求来源标识 + requestTemplate.header(HttpConst.HEAD_SOURCE, HttpConst.HEAD_SOURCE_VALUE); + HttpServletRequest servletRequest = RequestUtil.getRequest(); + if (ObjUtil.isNull(servletRequest)) { + return; + } + // 配置客户端 IP + requestTemplate.header(HttpConst.HEAD_FORWARDED_FOR, ServletUtil.getClientIP(servletRequest)); + // 传递 trace id + String traceId = ServletUtil.getHeader(servletRequest, HttpConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); + if (ObjUtil.isNotEmpty(traceId)) { + requestTemplate.header(HttpConst.HEAD_TRACE_ID, traceId); + } + // 传递用户 token + String token = SecurityUtil.getTokenFromRequest(servletRequest); + if (StrUtil.isNotEmpty(token)) { + requestTemplate.header(HttpConst.HEAD_TOKEN, token); + } + // 传递用户信息 + String userDetailsJson = ServletUtil.getHeader(servletRequest, HttpConst.HEAD_USER_DETAILS, CharsetUtil.CHARSET_UTF_8); + // 不存在则生成 + if (StrUtil.isEmpty(userDetailsJson)) { + SysUserDetails userDetailsDto = SecurityUtil.getUserDetails(null); + userDetailsJson = JacksonUtil.toJson(userDetailsDto); + } + requestTemplate.header(HttpConst.HEAD_USER_DETAILS, EscapeUtil.escape(userDetailsJson)); + }; } /** @@ -111,4 +97,57 @@ public ErrorDecoder errorDecoder(ObjectMapper objectMapper) { public Level feignLogLevel() { return Level.BASIC; } + + /** + * 覆盖 feign 配置, {@link org.springframework.cloud.openfeign.loadbalancer.FeignLoadBalancerAutoConfiguration} + * 参照 DefaultFeignLoadBalancerConfiguration + * 集成 FeignClientDecorator 装饰类 + */ + @ConditionalOnProperty(value = "feign.httpclient.enabled", havingValue = "false") + static class DefaultFeignConfig { + @Bean + @ConditionalOnProperty(value = "spring.cloud.loadbalancer.retry.enabled", havingValue = "false") + public Client feignClient(LoadBalancerClient loadBalancerClient, LoadBalancerProperties properties, + LoadBalancerClientFactory loadBalancerClientFactory) { + log.debug("Feign client use default"); + FeignClientDecorator decorator = new FeignClientDecorator(new Default(null, null)); + return new FeignBlockingLoadBalancerClient(decorator, loadBalancerClient, properties, loadBalancerClientFactory); + } + + @Bean + @ConditionalOnProperty(value = "spring.cloud.loadbalancer.retry.enabled", havingValue = "true", matchIfMissing = true) + public Client feignRetryClient(LoadBalancerClient loadBalancerClient, LoadBalancedRetryFactory loadBalancedRetryFactory, + LoadBalancerProperties properties, LoadBalancerClientFactory loadBalancerClientFactory) { + log.debug("Feign client use default, is retryable"); + FeignClientDecorator decorator = new FeignClientDecorator(new Default(null, null)); + return new RetryableFeignBlockingLoadBalancerClient(decorator, loadBalancerClient, loadBalancedRetryFactory, properties, loadBalancerClientFactory); + } + } + + /** + * 覆盖 feign 配置, {@link org.springframework.cloud.openfeign.loadbalancer.FeignLoadBalancerAutoConfiguration} + * 参照 HttpClientFeignLoadBalancerConfiguration + * 集成 FeignClientDecorator 装饰类,使用 ApacheHttpClient + */ + @ConditionalOnProperty(value = "feign.httpclient.enabled", havingValue = "true", matchIfMissing = true) + static class ApacheHttpFeignConfig { + @Bean + @ConditionalOnProperty(value = "spring.cloud.loadbalancer.retry.enabled", havingValue = "false") + public Client apacheFeignClient(LoadBalancerClient loadBalancerClient, HttpClient httpClient, + LoadBalancerProperties properties, LoadBalancerClientFactory loadBalancerClientFactory) { + log.debug("Feign client use apache httpclient"); + FeignClientDecorator decorator = new FeignClientDecorator(new ApacheHttpClient(httpClient)); + return new FeignBlockingLoadBalancerClient(decorator, loadBalancerClient, properties, loadBalancerClientFactory); + } + + @Bean + @ConditionalOnProperty(value = "spring.cloud.loadbalancer.retry.enabled", havingValue = "true", matchIfMissing = true) + public Client apacheFeignRetryClient(LoadBalancerClient loadBalancerClient, HttpClient httpClient, + LoadBalancedRetryFactory loadBalancedRetryFactory, LoadBalancerProperties properties, + LoadBalancerClientFactory loadBalancerClientFactory) { + log.debug("Feign client use apache httpclient, is retryable"); + FeignClientDecorator decorator = new FeignClientDecorator(new ApacheHttpClient(httpClient)); + return new RetryableFeignBlockingLoadBalancerClient(decorator, loadBalancerClient, loadBalancedRetryFactory, properties, loadBalancerClientFactory); + } + } } From fbfedc034b436eb22ac90e42fe623a0d7217cbce Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 11 Sep 2023 11:26:08 +0800 Subject: [PATCH 114/244] =?UTF-8?q?fix:=20token=20=E6=A0=A1=E9=AA=8C=20fil?= =?UTF-8?q?ter=20=E6=9C=80=E5=A5=BD=E6=94=BE=E5=88=B0=20LogoutFilter=20?= =?UTF-8?q?=E4=B9=8B=E5=89=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/base/config/SecurityConfig.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java index 22ef8c29..5d0202f1 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java @@ -30,7 +30,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.web.access.expression.WebExpressionVoter; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; +import org.springframework.security.web.authentication.logout.LogoutFilter; import org.springframework.web.filter.OncePerRequestFilter; import javax.servlet.FilterChain; @@ -98,8 +98,8 @@ protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .accessDecisionManager(new UnanimousBased( Arrays.asList(new WebExpressionVoter(), dataBaseRoleVoter))); - // 配置 Token 校验过滤器 - http.addFilterBefore(tokenAuthFilter, UsernamePasswordAuthenticationFilter.class); + // 配置 token 校验过滤器 + http.addFilterBefore(tokenAuthFilter, LogoutFilter.class); // 配置 trace id 过滤器 http.addFilterBefore(new TraceInfoFilter(), TokenAuthFilter.class); log.info("Config Security over,AuthModel:{}", properties.getAuthModel()); From 41882d2f538ea1ac8c3e6a277d4191d38016d5ea Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 11 Sep 2023 21:29:09 +0800 Subject: [PATCH 115/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=B7=A8?= =?UTF-8?q?=E5=9F=9F=20filter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../security/filter/CorsAllowAnyFilter.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/CorsAllowAnyFilter.java diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/CorsAllowAnyFilter.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/CorsAllowAnyFilter.java new file mode 100644 index 00000000..7aea3413 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/CorsAllowAnyFilter.java @@ -0,0 +1,29 @@ +package com.github.cadecode.uniboot.framework.base.security.filter; + +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; + +/** + * Filter, cors support + * + * @author Cade Li + * @since 2023/9/11 + */ +public class CorsAllowAnyFilter extends CorsFilter { + + static UrlBasedCorsConfigurationSource urlBasedCorsConfigurationSource = new UrlBasedCorsConfigurationSource(); + + static { + CorsConfiguration corsConfiguration = new CorsConfiguration(); + corsConfiguration.addAllowedHeader("*"); + corsConfiguration.addAllowedMethod("*"); + corsConfiguration.addAllowedOriginPattern("*"); + corsConfiguration.setAllowCredentials(true); + urlBasedCorsConfigurationSource.registerCorsConfiguration("/**", corsConfiguration); + } + + public CorsAllowAnyFilter() { + super(urlBasedCorsConfigurationSource); + } +} From d154113e8f7822592750553b5f957c898edb0876 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 11 Sep 2023 21:56:58 +0800 Subject: [PATCH 116/244] =?UTF-8?q?feat:=20security=20=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=88=86=E4=B8=BA=20permitAll=20=E5=92=8C=20?= =?UTF-8?q?ignoringMatcher=20=E4=B8=A4=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. permitAll 会走 Security 过滤器链 2. ignoringMatcher 不会走 Security 过滤器链,适合静态资源 --- .../framework/base/config/SecurityConfig.java | 103 ++++++++++-------- .../base/security/filter/TokenAuthFilter.java | 9 +- .../base/security/filter/TraceInfoFilter.java | 33 ++++++ .../JwtTokenAuthStrategyImpl.java} | 4 +- .../RedisTokenAuthStrategyImpl.java} | 4 +- .../TokenAuthStrategy.java} | 4 +- .../svc/config/FrameSecurityConfig.java | 34 +++--- 7 files changed, 119 insertions(+), 72 deletions(-) create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TraceInfoFilter.java rename framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/{filter/JwtTokenAuthFilterService.java => strategy/JwtTokenAuthStrategyImpl.java} (95%) rename framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/{filter/RedisTokenAuthFilterService.java => strategy/RedisTokenAuthStrategyImpl.java} (94%) rename framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/{filter/TokenAuthFilterService.java => strategy/TokenAuthStrategy.java} (95%) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java index 5d0202f1..bae7f95e 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java @@ -2,20 +2,20 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.CharsetUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.extra.servlet.ServletUtil; -import com.github.cadecode.uniboot.framework.api.consts.HttpConst; +import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyExecutor; import com.github.cadecode.uniboot.framework.api.enums.AuthModelEnum; import com.github.cadecode.uniboot.framework.base.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.base.security.filter.CorsAllowAnyFilter; import com.github.cadecode.uniboot.framework.base.security.filter.TokenAuthFilter; +import com.github.cadecode.uniboot.framework.base.security.filter.TraceInfoFilter; import com.github.cadecode.uniboot.framework.base.security.handler.NoAuthenticationHandler; import com.github.cadecode.uniboot.framework.base.security.handler.NoAuthorityHandler; import com.github.cadecode.uniboot.framework.base.security.voter.DataBaseRoleVoter; import lombok.Data; +import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.slf4j.MDC; +import org.springframework.beans.factory.InitializingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -31,13 +31,8 @@ import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.web.access.expression.WebExpressionVoter; import org.springframework.security.web.authentication.logout.LogoutFilter; -import org.springframework.web.filter.OncePerRequestFilter; -import javax.servlet.FilterChain; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -54,11 +49,14 @@ @EnableConfigurationProperties(SecurityProperties.class) @ConditionalOnMissingBean(SecurityConfig.class) @Configuration -public class SecurityConfig extends WebSecurityConfigurerAdapter { +public class SecurityConfig extends WebSecurityConfigurerAdapter implements InitializingBean { + + private final StrategyExecutor strategyExecutor; /** * 配置项 */ + @Getter private final SecurityProperties properties; /** @@ -67,11 +65,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter { private final NoAuthenticationHandler noAuthenticationHandler; private final NoAuthorityHandler noAuthorityHandler; - /** - * 注入 Token 过滤器 - */ - private final TokenAuthFilter tokenAuthFilter; - /** * 注入投票器 */ @@ -83,10 +76,22 @@ protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); // 关闭 session 管理 http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); + configAuthorize(http); + registerFilter(http); + log.info("Config Security over,AuthModel:{}", properties.getAuthModel()); + } + + /** + * 配置鉴权规则 + */ + private void configAuthorize(HttpSecurity http) throws Exception { // 配置鉴权规则 + List permitAllList = properties.getPermitAllList(); + log.info("Config Security permit all list:{}", permitAllList); http.authorizeRequests() // 尝试请求直接通过 .antMatchers(HttpMethod.OPTIONS, "/**").permitAll() + .antMatchers(ArrayUtil.toArray(permitAllList, String.class)).permitAll() .anyRequest().authenticated(); // 配置异常处理 http.exceptionHandling() @@ -98,27 +103,40 @@ protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .accessDecisionManager(new UnanimousBased( Arrays.asList(new WebExpressionVoter(), dataBaseRoleVoter))); - // 配置 token 校验过滤器 - http.addFilterBefore(tokenAuthFilter, LogoutFilter.class); + } + + /** + * 配置 filter + */ + private void registerFilter(HttpSecurity http) { + // 配置 Token 校验过滤器 + http.addFilterBefore(new TokenAuthFilter(strategyExecutor, properties), LogoutFilter.class); // 配置 trace id 过滤器 http.addFilterBefore(new TraceInfoFilter(), TokenAuthFilter.class); - log.info("Config Security over,AuthModel:{}", properties.getAuthModel()); + // 配置跨域过滤器 + http.addFilterBefore(new CorsAllowAnyFilter(), TraceInfoFilter.class); } @Override public void configure(WebSecurity web) { // 忽略配置器 IgnoredRequestConfigurer ignoring = web.ignoring(); - // 放行 swagger knife 文档 - ignoring.antMatchers("/doc.html", "/webjars/**", "/swagger-resources/**", "/v2/api-docs/**"); - // 放行其他框架 - ignoring.antMatchers("/error", "/druid/**", "/actuator/**"); // 设置忽略的路径 - List ignoreUrls = properties.getIgnoreUrls(); - if (CollUtil.isNotEmpty(ignoreUrls)) { - log.info("Config Security ignore urls:{}", ignoreUrls); - ignoring.antMatchers(ArrayUtil.toArray(ignoreUrls, String.class)); - } + List ignoringMatcherList = properties.getIgnoringMatcherList(); + log.info("Config Security ignoring matcher list:{}", ignoringMatcherList); + ignoring.antMatchers(ArrayUtil.toArray(ignoringMatcherList, String.class)); + } + + @Override + public void afterPropertiesSet() { + // 对 SecurityProperties 配置项进行修改 + // 加入忽略 url list + this.getProperties().getIgnoringMatcherList().addAll(CollUtil.newArrayList( + // 放行 swagger knife 文档 + "/doc.html", "/webjars/**", "/swagger-resources/**", "/v2/api-docs/**", + // 放行其他框架 + "/error", "/druid/**", "/actuator/**" + )); } /** @@ -134,14 +152,20 @@ public static class SecurityProperties { private AuthModelEnum authModel; /** - * 忽略鉴权的 url + * permitAll url list + */ + private List permitAllList = new ArrayList<>(); + + /** + * 忽略鉴权的 url list */ - private List ignoreUrls; + private List ignoringMatcherList = new ArrayList<>(); /** * JWT Token 配置 */ private TokenConfig tokenConfig; + } /** @@ -160,21 +184,4 @@ public static class TokenConfig { */ private String secret; } - - /** - * Filter - * trace id to MDC - */ - public static class TraceInfoFilter extends OncePerRequestFilter { - @Override - protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain - filterChain) - throws ServletException, IOException { - String traceId = ServletUtil.getHeader(request, HttpConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); - if (ObjUtil.isNotEmpty(traceId)) { - MDC.put(HttpConst.HEAD_TRACE_ID, traceId); - } - filterChain.doFilter(request, response); - } - } } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilter.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilter.java index b09cb953..f13de95b 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilter.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilter.java @@ -2,8 +2,8 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyExecutor; import com.github.cadecode.uniboot.framework.base.config.SecurityConfig.SecurityProperties; +import com.github.cadecode.uniboot.framework.base.security.strategy.TokenAuthStrategy; import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; import javax.servlet.FilterChain; @@ -11,13 +11,12 @@ import javax.servlet.http.HttpServletResponse; /** - * Token 校验过滤器,继承 OncePerRequestFilter + * Filter, token auth * * @author Cade Li - * @date 2022/5/28 + * @since 2023/9/11 */ @RequiredArgsConstructor -@Component public class TokenAuthFilter extends OncePerRequestFilter { private final StrategyExecutor strategyExecutor; @@ -26,7 +25,7 @@ public class TokenAuthFilter extends OncePerRequestFilter { @Override protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) { - strategyExecutor.execute(TokenAuthFilterService.class, securityProperties::getAuthModel, s -> { + strategyExecutor.execute(TokenAuthStrategy.class, securityProperties::getAuthModel, s -> { try { s.filter(request, response, filterChain); } catch (Exception e) { diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TraceInfoFilter.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TraceInfoFilter.java new file mode 100644 index 00000000..b456e2a3 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TraceInfoFilter.java @@ -0,0 +1,33 @@ +package com.github.cadecode.uniboot.framework.base.security.filter; + +import cn.hutool.core.util.CharsetUtil; +import cn.hutool.core.util.ObjUtil; +import cn.hutool.extra.servlet.ServletUtil; +import com.github.cadecode.uniboot.framework.api.consts.HttpConst; +import org.slf4j.MDC; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * Filter, trace id to MDC + * + * @author Cade Li + * @since 2023/9/11 + */ +public class TraceInfoFilter extends OncePerRequestFilter { + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain + filterChain) + throws ServletException, IOException { + String traceId = ServletUtil.getHeader(request, HttpConst.HEAD_TRACE_ID, CharsetUtil.CHARSET_UTF_8); + if (ObjUtil.isNotEmpty(traceId)) { + MDC.put(HttpConst.HEAD_TRACE_ID, traceId); + } + filterChain.doFilter(request, response); + } +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/JwtTokenAuthFilterService.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/JwtTokenAuthStrategyImpl.java similarity index 95% rename from framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/JwtTokenAuthFilterService.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/JwtTokenAuthStrategyImpl.java index 04ee9241..04fd0dc0 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/JwtTokenAuthFilterService.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/JwtTokenAuthStrategyImpl.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.base.security.filter; +package com.github.cadecode.uniboot.framework.base.security.strategy; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONObject; @@ -26,7 +26,7 @@ */ @RequiredArgsConstructor @Component -public class JwtTokenAuthFilterService extends TokenAuthFilterService { +public class JwtTokenAuthStrategyImpl extends TokenAuthStrategy { @Override public void handler(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/RedisTokenAuthFilterService.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/RedisTokenAuthStrategyImpl.java similarity index 94% rename from framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/RedisTokenAuthFilterService.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/RedisTokenAuthStrategyImpl.java index 792f4686..00a88e24 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/RedisTokenAuthFilterService.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/RedisTokenAuthStrategyImpl.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.base.security.filter; +package com.github.cadecode.uniboot.framework.base.security.strategy; import cn.hutool.core.util.StrUtil; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; @@ -28,7 +28,7 @@ */ @RequiredArgsConstructor @Component -public class RedisTokenAuthFilterService extends TokenAuthFilterService { +public class RedisTokenAuthStrategyImpl extends TokenAuthStrategy { @Override public void handler(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilterService.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/TokenAuthStrategy.java similarity index 95% rename from framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilterService.java rename to framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/TokenAuthStrategy.java index 2fd5e4c8..2d98d3fd 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/filter/TokenAuthFilterService.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/TokenAuthStrategy.java @@ -1,4 +1,4 @@ -package com.github.cadecode.uniboot.framework.base.security.filter; +package com.github.cadecode.uniboot.framework.base.security.strategy; import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.ObjUtil; @@ -27,7 +27,7 @@ * @author Cade Li * @since 2023/6/25 */ -public abstract class TokenAuthFilterService implements StrategyService { +public abstract class TokenAuthStrategy implements StrategyService { /** * 设置认证信息 diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java index 4392e093..23a75ce4 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java @@ -1,7 +1,8 @@ package com.github.cadecode.uniboot.framework.svc.config; +import cn.hutool.core.collection.CollUtil; +import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyExecutor; import com.github.cadecode.uniboot.framework.base.config.SecurityConfig; -import com.github.cadecode.uniboot.framework.base.security.filter.TokenAuthFilter; import com.github.cadecode.uniboot.framework.base.security.handler.NoAuthenticationHandler; import com.github.cadecode.uniboot.framework.base.security.handler.NoAuthorityHandler; import com.github.cadecode.uniboot.framework.base.security.voter.DataBaseRoleVoter; @@ -13,8 +14,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity.IgnoredRequestConfigurer; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; @@ -60,12 +59,12 @@ public class FrameSecurityConfig extends SecurityConfig { private static final PasswordEncoder PASSWORD_ENCODER = new BCryptPasswordEncoder(); - public FrameSecurityConfig(SecurityProperties properties, NoAuthenticationHandler noAuthenticationHandler, - NoAuthorityHandler noAuthorityHandler, TokenAuthFilter tokenAuthFilter, + public FrameSecurityConfig(StrategyExecutor strategyExecutor, SecurityProperties properties, + NoAuthenticationHandler noAuthenticationHandler, NoAuthorityHandler noAuthorityHandler, DataBaseRoleVoter dataBaseRoleVoter, LoginSuccessHandler loginSuccessHandler, LoginFailureHandler loginFailureHandler, SignOutSuccessHandler signOutSuccessHandler, UserDetailsService userDetailsService) { - super(properties, noAuthenticationHandler, noAuthorityHandler, tokenAuthFilter, dataBaseRoleVoter); + super(strategyExecutor, properties, noAuthenticationHandler, noAuthorityHandler, dataBaseRoleVoter); this.loginSuccessHandler = loginSuccessHandler; this.loginFailureHandler = loginFailureHandler; this.signOutSuccessHandler = signOutSuccessHandler; @@ -88,6 +87,13 @@ protected void configure(AuthenticationManagerBuilder auth) throws Exception { @Override protected void configure(HttpSecurity http) throws Exception { super.configure(http); + configLoginAndLogout(http); + } + + /** + * 配置登录、注销处理 + */ + private void configLoginAndLogout(HttpSecurity http) throws Exception { // 配置注销处理器 http.logout().permitAll() .logoutUrl(LOGOUT_URL) @@ -103,12 +109,14 @@ protected void configure(HttpSecurity http) throws Exception { } @Override - public void configure(WebSecurity web) { - super.configure(web); - IgnoredRequestConfigurer ignoring = web.ignoring(); - // 放行登录接口 - ignoring.antMatchers("/auth/login"); - // 放行接口权限表查询接口 - ignoring.antMatchers("/system/api/list_roles_vo"); + public void afterPropertiesSet() { + super.afterPropertiesSet(); + // 加入忽略 url list + this.getProperties().getIgnoringMatcherList().addAll(CollUtil.newArrayList( + // 放行登录接口 + "/auth/login", + // 放行接口权限表查询接口 + "/system/api/list_roles_vo" + )); } } From c2895886f9bee8248b3f47d40fb13cee45eb4467 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 11 Sep 2023 22:14:16 +0800 Subject: [PATCH 117/244] =?UTF-8?q?feat:=20TxMsg=20=E9=87=8D=E8=AF=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/mq/config/TxMsgProperties.java | 5 +++++ .../cadecode/uniboot/common/plugin/mq/task/TxMsgTask.java | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgProperties.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgProperties.java index 7f2b9ff5..7de54c17 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgProperties.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/TxMsgProperties.java @@ -40,6 +40,11 @@ public class TxMsgProperties implements InitializingBean { // 重试默认属性 --end + /** + * 是否开启重试 + */ + private Boolean enableRetry = true; + /** * 定时重试间隔时间 */ diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/task/TxMsgTask.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/task/TxMsgTask.java index 010f7190..c90ac320 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/task/TxMsgTask.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/task/TxMsgTask.java @@ -29,9 +29,13 @@ public class TxMsgTask { @EventListener(ApplicationStartedEvent.class) public void onApplicationStartedEvent() { + if (ObjUtil.equals(txMsgProperties.getEnableRetry(), false)) { + log.info("TxMsg task enable retry false"); + return; + } log.info("TxMsg task do retry started"); taskScheduler.scheduleWithFixedDelay(txMsgTaskHandler::doRetry, txMsgProperties.getRetryFixDelay()); - log.info("TxMsg task do clear start, {}", txMsgProperties.getAutoClear()); + log.info("TxMsg task do clear started, {}", txMsgProperties.getAutoClear()); if (ObjUtil.equal(txMsgProperties.getAutoClear(), true)) { taskScheduler.scheduleWithFixedDelay(() -> txMsgTaskHandler.doClear(txMsgProperties.getAutoClearInterval()), txMsgProperties.getClearFixDelay()); From d398a8a74a651a9a6d0d271b8ee2c86510a0c54a Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 12 Sep 2023 14:17:35 +0800 Subject: [PATCH 118/244] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=A4=BA=E4=BE=8B=EF=BC=8Cmq=20=E9=87=8D=E8=AF=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/intro/application-config-example.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.docs/intro/application-config-example.md b/.docs/intro/application-config-example.md index e6166366..4b73926f 100644 --- a/.docs/intro/application-config-example.md +++ b/.docs/intro/application-config-example.md @@ -246,6 +246,8 @@ uni-boot: security: ignore-urls: mq: + tx-msg: + enable-retry: true rabbit: enable: true exchanges: From 0771deb527e2515f650627a295eeb5cbdbc52ea7 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 12 Sep 2023 15:37:14 +0800 Subject: [PATCH 119/244] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=A4=BA=E4=BE=8B=EF=BC=8Csecurity=20=E5=BF=BD?= =?UTF-8?q?=E7=95=A5=E9=85=8D=E7=BD=AE=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/intro/application-config-example.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.docs/intro/application-config-example.md b/.docs/intro/application-config-example.md index 4b73926f..a3f8ded3 100644 --- a/.docs/intro/application-config-example.md +++ b/.docs/intro/application-config-example.md @@ -202,7 +202,7 @@ uni-boot: title: Framework API Docs description: Framework 服务在线文档 By Swagger security: - ignore-urls: /common/download** + permit-all-list: /common/download** framework: file-base-path: D:/uniboot/file/temp/ ``` @@ -244,7 +244,7 @@ uni-boot: title: Example API Docs description: Example 服务在线文档 By Swagger security: - ignore-urls: + permit-all-list: mq: tx-msg: enable-retry: true From dca79e4faba59f02e17d35e87290eab3a27665ff Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 12 Sep 2023 16:03:29 +0800 Subject: [PATCH 120/244] =?UTF-8?q?fix:=20=E5=88=A4=E6=96=AD=E4=BA=A4?= =?UTF-8?q?=E6=8D=A2=E6=9C=BA=20delay=20=E6=96=B9=E6=B3=95=E7=A9=BA?= =?UTF-8?q?=E6=8C=87=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/mq/rabbit/RabbitCallback.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java index a14baa1b..27a093e5 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java @@ -79,7 +79,7 @@ private boolean isExchangeDelayed(String exchangeName) { } // 若是 delay 交换机 Exchange exchange = exchangeNameMap.get(exchangeName); - return exchange.isDelayed() || RabbitConst.EXC_TYPE_DELAYED.equals(exchange.getType()); + return ObjUtil.isNotNull(exchange) && (exchange.isDelayed() || RabbitConst.EXC_TYPE_DELAYED.equals(exchange.getType())); } @Override From 05e7726e21a7991eb50d53c0419aa4e1e34747b5 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Wed, 13 Sep 2023 22:23:07 +0800 Subject: [PATCH 121/244] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=20README?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9209b421..74202e0b 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,9 @@ 集成 knife4j,提供 swagger module 的动态配置支持 - 基础 RabbitMQ,提供通过配置声明交换机和队列功能,以及事务消息、消息重试的支持 + 集成 RabbitMQ,提供通过配置声明交换机和队列功能,以及事务消息、消息重试的支持 + + 集成 OpenFeign,提供统一的消息拦截器、ErrorDecoder、HttpClient 配置等 ... From aa5adf62f9f9f2e0dc16f2537ff222a64f337d20 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 15 Sep 2023 14:39:05 +0800 Subject: [PATCH 122/244] =?UTF-8?q?build:=20=E5=BC=95=E5=85=A5=20spring-mu?= =?UTF-8?q?ltirabbit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/plugin/mq/pom.xml | 10 ++++++++++ dependencies/pom.xml | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/common/plugin/mq/pom.xml b/common/plugin/mq/pom.xml index 56c03339..9c0a6a8f 100644 --- a/common/plugin/mq/pom.xml +++ b/common/plugin/mq/pom.xml @@ -17,5 +17,15 @@ org.springframework.boot spring-boot-starter-amqp + + + com.free-now.multirabbit + spring-multirabbit + + + + com.github.cadecode + uni-boot-common-core + diff --git a/dependencies/pom.xml b/dependencies/pom.xml index abb76ff5..9ed937ee 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -43,6 +43,7 @@ 1.1.3 3.1.1 2.0.0.RELEASE + 2.5.0 @@ -216,6 +217,12 @@ spring-plugin-core ${spring-plugin.version} + + + com.free-now.multirabbit + spring-multirabbit + ${multirabbit.version} + From 67bf54abb1cac41789e9131b80cc1918588de2d7 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 15 Sep 2023 14:40:44 +0800 Subject: [PATCH 123/244] =?UTF-8?q?feat:=20=E9=9B=86=E6=88=90=20RabbitMQ?= =?UTF-8?q?=20=E5=A4=9A=E6=95=B0=E6=8D=AE=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/mq/config/RabbitAutoConfig.java | 177 ++++++++++++++---- .../plugin/mq/config/RabbitProperties.java | 14 +- 2 files changed, 152 insertions(+), 39 deletions(-) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java index 7c72a3a5..fbeb477c 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java @@ -7,16 +7,31 @@ import org.springframework.amqp.core.Binding.DestinationType; import org.springframework.amqp.core.Exchange; import org.springframework.amqp.core.Queue; -import org.springframework.beans.BeansException; +import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; +import org.springframework.amqp.rabbit.connection.ConnectionFactory; +import org.springframework.amqp.rabbit.connection.SimpleRoutingConnectionFactory; +import org.springframework.amqp.rabbit.retry.MessageRecoverer; +import org.springframework.amqp.support.converter.MessageConverter; +import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.BeanPostProcessor; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.boot.autoconfigure.amqp.AbstractRabbitListenerContainerFactoryConfigurer; +import org.springframework.boot.autoconfigure.amqp.MultiRabbitConstants; +import org.springframework.boot.autoconfigure.amqp.MultiRabbitProperties; +import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.context.properties.PropertyMapper; import org.springframework.boot.context.properties.bind.BindResult; import org.springframework.boot.context.properties.bind.Binder; import org.springframework.context.EnvironmentAware; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.DependsOn; import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +import java.util.Map; /** * RabbitMQ 自动配置 @@ -27,51 +42,143 @@ @Slf4j @RequiredArgsConstructor @EnableConfigurationProperties(RabbitProperties.class) -@ConditionalOnProperty(name = "uni-boot.mq.rabbit.enable", havingValue = "true") @Configuration -public class RabbitAutoConfig implements BeanFactoryPostProcessor, EnvironmentAware { +@ConditionalOnProperty(name = "uni-boot.mq.rabbit.enable", havingValue = "true") +public class RabbitAutoConfig implements InitializingBean { - private Environment environment; + private final MessageConverter messageConverter; + private final MultiRabbitProperties multiRabbitProperties; + private final SimpleRoutingConnectionFactory multiRabbitConnectionFactory; + private final Map rabbitListenerContainerFactoryMap; @Override - public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { - BindResult bindResult = Binder.get(environment).bind(RabbitProperties.ENV_CONF_RABBIT_PREFIX, RabbitProperties.class); - RabbitProperties rabbitProperties = bindResult.orElse(null); - if (ObjUtil.isNull(rabbitProperties)) { - log.info("Rabbit env config {} not found", RabbitProperties.ENV_CONF_RABBIT_PREFIX); - return; + public void afterPropertiesSet() { + configureContainerFactory(); + } + + /** + * 配置 SimpleRabbitListenerContainerFactory + * spring-multirabbit {@link org.springframework.boot.autoconfigure.amqp.MultiRabbitAutoConfiguration} + * 自动配置 SimpleRabbitListenerContainerFactory, 部分配置有缺失,此方法用于补偿 + * 参考 {@link SimpleRabbitListenerContainerFactoryConfigurer} + */ + private void configureContainerFactory() { + multiRabbitProperties.getConnections().forEach((connectionName, props) -> { + MultiRabbitContainerFactoryConfigurer configurer = new MultiRabbitContainerFactoryConfigurer(props.getListener().getSimple()); + configurer.setMessageConverter(messageConverter); + SimpleRabbitListenerContainerFactory containerFactory = rabbitListenerContainerFactoryMap.get(connectionName); + ConnectionFactory targetConnectionFactory = multiRabbitConnectionFactory.getTargetConnectionFactory(connectionName); + configurer.configure(containerFactory, targetConnectionFactory); + }); + } + + /** + * MultiRabbit ContainerFactory 配置器 + */ + @RequiredArgsConstructor + private static class MultiRabbitContainerFactoryConfigurer + extends AbstractRabbitListenerContainerFactoryConfigurer { + + private final org.springframework.boot.autoconfigure.amqp.RabbitProperties.SimpleContainer config; + + @Override + public void configure(SimpleRabbitListenerContainerFactory factory, ConnectionFactory connectionFactory) { + PropertyMapper map = PropertyMapper.get(); + configure(factory, connectionFactory, config); + map.from(config::getConcurrency).whenNonNull().to(factory::setConcurrentConsumers); + map.from(config::getMaxConcurrency).whenNonNull().to(factory::setMaxConcurrentConsumers); + map.from(config::getBatchSize).whenNonNull().to(factory::setBatchSize); + map.from(config::isConsumerBatchEnabled).to(factory::setConsumerBatchEnabled); } - if (ObjUtil.isNotEmpty(rabbitProperties.getExchanges())) { - rabbitProperties.getExchanges().forEach(o -> { - Exchange exchange = o.toBuilder().build(); - beanFactory.registerSingleton(o.getName(), exchange); - log.info("Rabbit auto register exchange, {}, {}", o.getName(), o); - }); + + @Override + public void setMessageConverter(MessageConverter messageConverter) { + super.setMessageConverter(messageConverter); } - if (ObjUtil.isNotEmpty(rabbitProperties.getQueues())) { - rabbitProperties.getQueues().forEach(o -> { - Queue queue = o.toBuilder().build(); - beanFactory.registerSingleton(o.getName(), queue); - log.info("Rabbit auto register queue, {}, {}", o.getName(), o); - }); + + @Override + public void setMessageRecoverer(MessageRecoverer messageRecoverer) { + super.setMessageRecoverer(messageRecoverer); } - if (ObjUtil.isNotEmpty(rabbitProperties.getBindings())) { - rabbitProperties.getBindings().forEach(o -> { - String bindName = o.getBindName(); - // 对随机后缀的队列,不能直接用 bean name,需要获取 queue 的 bean 再获取队列名称 - if (o.getBindType() == DestinationType.QUEUE) { - Queue queue = beanFactory.getBean(o.getBindName(), Queue.class); - bindName = queue.getName(); + } + + /** + * RabbitMQ 交换机、队列等配置对象注入容器 + * 注入的 bean 名称格式为 connectionName_declareName + * 使用 {@link org.springframework.amqp.core.Declarable} setAdminsThatShouldDeclare 方法指定 AmqpAdmin bean + */ + @Component + @ConditionalOnProperty(name = "uni-boot.mq.rabbit.enable", havingValue = "true") + public static class MultiRabbitDeclareBeanFactoryPostProcessor implements BeanFactoryPostProcessor, EnvironmentAware { + private Environment environment; + + @Override + public void setEnvironment(Environment environment) { + this.environment = environment; + } + + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { + BindResult bindResult = Binder.get(environment).bind(RabbitProperties.ENV_CONF_RABBIT_PREFIX, RabbitProperties.class); + RabbitProperties rabbitProperties = bindResult.orElse(null); + if (ObjUtil.isNull(rabbitProperties)) { + log.info("Rabbit env config {} not found", RabbitProperties.ENV_CONF_RABBIT_PREFIX); + return; + } + rabbitProperties.getDeclares().forEach((connectionName, declare) -> { + if (ObjUtil.isNotEmpty(declare.getExchanges())) { + declare.getExchanges().forEach(o -> { + Exchange exchange = o.toBuilder().build(); + exchange.setAdminsThatShouldDeclare(getAdminBeanName(connectionName)); + beanFactory.registerSingleton(geneDeclareBeanName(connectionName, o.getName()), exchange); + log.info("Rabbit auto register exchange, connection:{}, queue:{}, {}", connectionName, o.getName(), o); + }); + } + if (ObjUtil.isNotEmpty(declare.getQueues())) { + declare.getQueues().forEach(o -> { + Queue queue = o.toBuilder().build(); + queue.setAdminsThatShouldDeclare(getAdminBeanName(connectionName)); + beanFactory.registerSingleton(geneDeclareBeanName(connectionName, o.getName()), queue); + log.info("Rabbit auto register queue, connection:{}, exchange:{}, {}", connectionName, o.getName(), o); + }); + } + if (ObjUtil.isNotEmpty(declare.getBindings())) { + declare.getBindings().forEach(o -> { + String bindName = o.getBindName(); + // 对随机后缀的队列,不能直接用 bean name,需要获取 queue 的 bean 再获取队列名称 + if (o.getBindType() == DestinationType.QUEUE) { + Queue queue = beanFactory.getBean(geneDeclareBeanName(connectionName, o.getBindName()), Queue.class); + bindName = queue.getName(); + } + Binding binding = new Binding(bindName, o.getBindType(), o.getExchangeName(), o.getRoutingKey(), o.getArguments()); + binding.setAdminsThatShouldDeclare(getAdminBeanName(connectionName)); + String beanName = geneDeclareBeanName(connectionName, o.getBindName() + "-" + o.getExchangeName()); + beanFactory.registerSingleton(beanName, binding); + log.info("Rabbit auto register binding, connection:{}, bind {} to {}, bindType:{}, {}", connectionName, o.getBindName(), + o.getExchangeName(), o.getBindType(), o); + }); } - Binding binding = new Binding(bindName, o.getBindType(), o.getExchangeName(), o.getRoutingKey(), o.getArguments()); - beanFactory.registerSingleton(o.getBindName() + "-" + o.getExchangeName(), binding); - log.info("Rabbit auto register binding, {} to {}, bindType:{}, {}", o.getBindName(), o.getExchangeName(), o.getBindType(), o); }); } + + public String geneDeclareBeanName(String connectionName, String declareName) { + return connectionName + "_" + declareName; + } + + public String getAdminBeanName(String connectionName) { + return connectionName + MultiRabbitConstants.RABBIT_ADMIN_SUFFIX; + } } - @Override - public void setEnvironment(Environment environment) { - this.environment = environment; + /** + * spring-multirabbit + * RabbitListener 注解指定 containerFactory 时,由于 multiRabbitConnectionFactory 未加载 + * 导致 getBean 获取对应 RabbitAdmin 实例失败 + * 此处使用 @DependsOn 使 multiRabbitConnectionFactory 提前加载 + */ + @DependsOn(MultiRabbitConstants.CONNECTION_FACTORY_BEAN_NAME) + @Component + public static class MultiRabbitContainerBeanPostProcessor implements BeanPostProcessor { + } } diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java index 5fea3616..f549087a 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitProperties.java @@ -27,11 +27,17 @@ public class RabbitProperties { private boolean enable; - private List exchanges; + private Map declares; - private List queues; - - private List bindings; + /** + * 针对一个 RabbitMQ 连接配置的交换机、队列、绑定的声明 + */ + @Data + public static class DeclareProperties { + private List exchanges; + private List queues; + private List bindings; + } /** * 队列声明常用配置项 From ae3f45a6c83be6c63393864afb0e4e819f1c400d Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 15 Sep 2023 14:41:31 +0800 Subject: [PATCH 124/244] =?UTF-8?q?feat:=20RabbitExampleConsumer=20@Rabbit?= =?UTF-8?q?Listener=20=E6=8C=87=E5=AE=9A=20containerFactory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../svc/consumer/RabbitExampleConsumer.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java index 60d54d5e..ebdf9fd5 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/consumer/RabbitExampleConsumer.java @@ -20,7 +20,9 @@ @Component public class RabbitExampleConsumer { - @RabbitListener(queues = "example-delay-queue-0", id = "example-delay-queue-0", ackMode = "AUTO") + @RabbitListener(queues = "example-delay-queue-0", + id = "example-delay-queue-0", + ackMode = "AUTO") public void exampleDelayQueue0(String body, Message message, Channel channel) throws IOException { log.info("Received msg:{}", body); } @@ -28,14 +30,19 @@ public void exampleDelayQueue0(String body, Message message, Channel channel) th /** * 测试 SpEL 获取 queue name */ - @RabbitListener(queues = "#{@'example-delay-queue-1'.name}", id = "example-delay-queue-1") + @RabbitListener(containerFactory = "default", + queues = "#{@'default_example-delay-queue-1'.name}", + id = "example-delay-queue-1") public void exampleDelayQueue1(String body, Message message, Channel channel) throws IOException { log.info("Received msg:{}", body); channel.basicAck(message.getMessageProperties().getDeliveryTag(), false); } - @RabbitListener(queues = "example-biz-queue-0", id = "example-biz-queue-0", ackMode = "AUTO") + @RabbitListener(containerFactory = "default", + queues = "example-biz-queue-0", + id = "example-biz-queue-0", + ackMode = "AUTO") public void exampleBizQueue0(String body, Message message, Channel channel) throws IOException { log.info("Received msg:{}", body); // 自动模式下,测试重试机制 @@ -47,9 +54,11 @@ public void exampleBizQueue0(String body, Message message, Channel channel) thro /** * 测试用对象获取消息 */ - @RabbitListener(queues = "example-biz-queue-1", id = "example-biz-queue-1", ackMode = "AUTO") + @RabbitListener(containerFactory = "default", + queues = "example-biz-queue-1", + id = "example-biz2-queue-1", + ackMode = "AUTO") public void exampleBizQueue1(ExampleMsgDo msgDo, Message message, Channel channel) throws IOException { log.info("Received msg:{}", msgDo); } - } From f4c650d31491d45f746a67c90530543290401332 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 16 Sep 2023 08:44:56 +0800 Subject: [PATCH 125/244] =?UTF-8?q?fix:=20multirabbit=20publisher-returns?= =?UTF-8?q?=20=E6=97=A0=E6=95=88=EF=BC=8C=E4=BD=BF=E7=94=A8=20setMandatory?= =?UTF-8?q?=20=E5=BC=80=E5=90=AF=20callback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/mq/rabbit/RabbitCallback.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java index 27a093e5..fce023bd 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java @@ -84,6 +84,8 @@ private boolean isExchangeDelayed(String exchangeName) { @Override public void afterPropertiesSet() { + // 开启 ReturnsCallback + rabbitTemplate.setMandatory(true); // 设置回调 rabbitTemplate.setConfirmCallback(this); rabbitTemplate.setReturnsCallback(this); From b21d09c174aa9057d846fb57eaf9c7a540a7438a Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 16 Sep 2023 08:47:58 +0800 Subject: [PATCH 126/244] =?UTF-8?q?feat:=20TxMsg=20=E9=87=8D=E8=AF=95?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8C=87=E5=AE=9A=20connectionName?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/plugin/mq/model/BaseTxMsg.java | 2 + .../uniboot/common/plugin/mq/model/TxMsg.java | 3 ++ .../base/plugin/bean/po/PlgMqMsg.java | 2 + .../base/plugin/bean/vo/PlgMqMsgVo.java | 1 + .../base/plugin/handler/MqTxMsgHandler.java | 39 +++++++++++++------ 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/BaseTxMsg.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/BaseTxMsg.java index 6e9c4162..a310c06b 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/BaseTxMsg.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/BaseTxMsg.java @@ -20,4 +20,6 @@ public interface BaseTxMsg { String getMessage(); + String getConnectionName(); + } diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/TxMsg.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/TxMsg.java index a686fcb3..76f8a64f 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/TxMsg.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/model/TxMsg.java @@ -34,4 +34,7 @@ public class TxMsg implements BaseTxMsg { private String routingKey; private String message; + + private String connectionName; + } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java index 4fce4f18..56761791 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgMqMsg.java @@ -36,6 +36,8 @@ public class PlgMqMsg { private String message; + private String connectionName; + private SendStateEnum sendState; private ConsumeStateEnum consumeState; diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgMqMsgVo.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgMqMsgVo.java index fa02b679..174d87fb 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgMqMsgVo.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgMqMsgVo.java @@ -34,6 +34,7 @@ public static class PlgMqMsgPageResVo { private String bizKey; private String exchange; private String routingKey; + private String connectionName; private String message; private SendStateEnum sendState; private ConsumeStateEnum consumeState; diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java index 72550599..2f80f3e9 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/MqTxMsgHandler.java @@ -25,6 +25,7 @@ import org.springframework.amqp.core.Message; import org.springframework.amqp.core.ReturnedMessage; import org.springframework.amqp.rabbit.connection.CorrelationData; +import org.springframework.amqp.rabbit.connection.SimpleResourceHolder; import org.springframework.stereotype.Component; import java.util.Date; @@ -143,6 +144,11 @@ public void checkBeforeSend(BaseTxMsg txMsg, MsgOption msgOption) { if (ObjUtil.isEmpty(txMsg.getId())) { ((TxMsg) txMsg).setId(String.valueOf(IdWorker.getId(txMsg))); } + // 填充 connectionName + if (ObjUtil.isEmpty(txMsg.getConnectionName())) { + String connectionName = (String) SimpleResourceHolder.get(RabbitUtil.template().getConnectionFactory()); + ((TxMsg) txMsg).setConnectionName(connectionName); + } } @Override @@ -190,18 +196,27 @@ public void sendCommitted(BaseTxMsg txMsg, MsgOption msgOption) { } private void doSendCommittedOrRetry(BaseTxMsg txMsg) { - // 放入 txMsg id - CorrelationData correlationData = new CorrelationData(txMsg.getId()); - RabbitUtil.send(txMsg.getExchange(), txMsg.getRoutingKey(), txMsg.getMessage(), msg -> { - // 设置事务消息 head 标记 - msg.getMessageProperties().getHeaders().put(HEAD_TX_MSG_ID, txMsg.getId()); - msg.getMessageProperties().getHeaders().put(HEAD_TX_MSG_BIZ_TYPE, txMsg.getBizType()); - msg.getMessageProperties().getHeaders().put(HEAD_TX_MSG_BIZ_KEY, txMsg.getBizKey()); - // 设置 ReturnedMessage,用于 callback 中获取消息 - ReturnedMessage defaultReturnedMessage = new ReturnedMessage(msg, 0, DEFAULT_TX_MSG_REPLY_TEXT, null, null); - correlationData.setReturned(defaultReturnedMessage); - return msg; - }, correlationData); + try { + if (ObjUtil.isNotNull(txMsg.getConnectionName())) { + SimpleResourceHolder.bind(RabbitUtil.template().getConnectionFactory(), txMsg.getConnectionName()); + } + // 放入 txMsg id + CorrelationData correlationData = new CorrelationData(txMsg.getId()); + RabbitUtil.send(txMsg.getExchange(), txMsg.getRoutingKey(), txMsg.getMessage(), msg -> { + // 设置事务消息 head 标记 + msg.getMessageProperties().getHeaders().put(HEAD_TX_MSG_ID, txMsg.getId()); + msg.getMessageProperties().getHeaders().put(HEAD_TX_MSG_BIZ_TYPE, txMsg.getBizType()); + msg.getMessageProperties().getHeaders().put(HEAD_TX_MSG_BIZ_KEY, txMsg.getBizKey()); + // 设置 ReturnedMessage,用于 callback 中获取消息 + ReturnedMessage defaultReturnedMessage = new ReturnedMessage(msg, 0, DEFAULT_TX_MSG_REPLY_TEXT, null, null); + correlationData.setReturned(defaultReturnedMessage); + return msg; + }, correlationData); + } finally { + if (ObjUtil.isNotNull(txMsg.getConnectionName())) { + SimpleResourceHolder.unbindIfPossible(RabbitUtil.template().getConnectionFactory()); + } + } } @Override From 6ea5f0595110f908f57012f68e89333691811817 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 16 Sep 2023 08:49:08 +0800 Subject: [PATCH 127/244] =?UTF-8?q?docs:=20=E7=BB=B4=E6=8A=A4=20PlgMqMsg?= =?UTF-8?q?=20=E8=A1=A8=E5=AD=97=E6=AE=B5=20SQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/sql/common-plguin.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/.docs/sql/common-plguin.sql b/.docs/sql/common-plguin.sql index 77c71ffc..cf62139a 100644 --- a/.docs/sql/common-plguin.sql +++ b/.docs/sql/common-plguin.sql @@ -44,6 +44,7 @@ CREATE TABLE IF NOT EXISTS plg_mq_msg biz_key VARCHAR(200) NULL COMMENT '业务键', exchange VARCHAR(200) NOT NULL COMMENT '交换机', routing_key VARCHAR(200) NOT NULL COMMENT '路由 key', + connection_name VARCHAR(200) NULL COMMENT '连接名称', message TEXT NOT NULL COMMENT '消息内容', send_state VARCHAR(100) NULL COMMENT '发送方状态', consume_state VARCHAR(100) NULL COMMENT '消费方状态', From e3456f3f6a52c8069d22c302d7840ede276997b8 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 16 Sep 2023 08:49:54 +0800 Subject: [PATCH 128/244] =?UTF-8?q?feat:=20=E5=8F=91=E9=80=81=E4=BA=8B?= =?UTF-8?q?=E5=8A=A1=E6=B6=88=E6=81=AF=E7=A4=BA=E4=BE=8B=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=8F=AF=E6=8C=87=E5=AE=9A=20connec?= =?UTF-8?q?tionName?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../svc/controller/MqExampleController.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java index d1f1ca9c..3312e64e 100644 --- a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/MqExampleController.java @@ -1,5 +1,6 @@ package com.github.cadecode.uniboot.example.svc.controller; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.plugin.mq.model.TxMsg; import com.github.cadecode.uniboot.common.plugin.mq.util.RabbitUtil; import com.github.cadecode.uniboot.common.plugin.mq.util.TxMsgKit; @@ -9,6 +10,7 @@ import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.amqp.rabbit.connection.SimpleResourceHolder; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -56,14 +58,24 @@ public boolean sendObj(@RequestParam String exchange, @RequestParam String routi @Transactional(rollbackFor = Exception.class) @ApiOperation("发送事务消息") @GetMapping("send_tx") - public boolean sendTx(@RequestParam String exchange, @RequestParam String routingKey) { - txMsgKit.sendTx(TxMsg.builder() - .bizType("Test biz") - .bizKey("TestBiz001") - .exchange(exchange) - .routingKey(routingKey) - .message("Test TxMsg") - .build()); + public boolean sendTx(@RequestParam String exchange, @RequestParam String routingKey, + @RequestParam(required = false) String connectionName) { + try { + if (ObjUtil.isNotNull(connectionName)) { + SimpleResourceHolder.bind(RabbitUtil.template().getConnectionFactory(), connectionName); + } + txMsgKit.sendTx(TxMsg.builder() + .bizType("Test biz") + .bizKey("TestBiz001") + .exchange(exchange) + .routingKey(routingKey) + .message("Test TxMsg") + .build()); + } finally { + if (ObjUtil.isNotNull(connectionName)) { + SimpleResourceHolder.unbindIfPossible(RabbitUtil.template().getConnectionFactory()); + } + } return true; } } From fb93ba4500591163b8f51a3894090d30e95d25c1 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 16 Sep 2023 09:34:10 +0800 Subject: [PATCH 129/244] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=20README?= =?UTF-8?q?=E3=80=81=E4=BB=8B=E7=BB=8D=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/intro/application-config-example.md | 166 ++++++++++++++-------- README.md | 2 +- 2 files changed, 107 insertions(+), 61 deletions(-) diff --git a/.docs/intro/application-config-example.md b/.docs/intro/application-config-example.md index a3f8ded3..592c8ced 100644 --- a/.docs/intro/application-config-example.md +++ b/.docs/intro/application-config-example.md @@ -29,22 +29,6 @@ spring: min-idle: 0 max-idle: 8 max-wait: -1 - # rabbitmq 公共配置 - rabbitmq: - publisher-returns: true - publisher-confirm-type: correlated - listener: - simple: - concurrency: 1 - max-concurrency: 8 - acknowledge-mode: manual - retry: - enabled: true - max-attempts: 5 - max-interval: 10000 - initial-interval: 2000 - multiplier: 2 - prefetch: 5 # 数据源公共配置 datasource: druid: @@ -158,6 +142,46 @@ spring: - 192.168.0. - 192.168.238. - 10. + # rabbitmq + multirabbitmq: + enabled: true + # 指定默认的连接名称(必要) + default-connection: default + connections: + # 自定义的 connectionName + default: + host: localhost + port: 5672 + username: rabbitmq + password: rabbitmq + virtual-host: uni_dev + publisher-returns: true + publisher-confirm-type: correlated + listener: + simple: + concurrency: 1 + max-concurrency: 8 + acknowledge-mode: manual + retry: + enabled: true + max-attempts: 5 + max-interval: 10000 + initial-interval: 2000 + multiplier: 2 + prefetch: 5 + test: + host: localhost + port: 5672 + username: rabbitmq + password: rabbitmq + virtual-host: uni_dev_test + publisher-returns: true + publisher-confirm-type: correlated + listener: + simple: + concurrency: 1 + max-concurrency: 8 + acknowledge-mode: manual # 关闭 swagger 认证 knife4j: @@ -165,6 +189,15 @@ knife4j: enable: false ``` +> 通过 spring-multirabbit 实现 RabbitMQ 的多数据源,使用 spring.multirabbitmq 配置多个连接 +> +> 在使用 @RabbitListener 监听队列时,指定 containerFactory 为 connectionName +> +> 在注入 RabbitTemplate 发送消息时,发送前使用 SimpleResourceHolder.bind 将 connectionFactory 绑定到 connectName,发送完毕后 +> unbind +> +> 注意:publisher-returns 可能不生效,已在 RabbitCallback 中通过 rabbitTemplate.setMandatory(true) 强制开启 + ### framework 服务配置 uni-boot-framework-dev.yml(DEV 环境) @@ -179,12 +212,6 @@ spring: port: 6379 password: ENC(jIiKGruIMgDkKx5wj2gJRCROqPutkTvZ) database: 0 - rabbitmq: - host: localhost - port: 5672 - username: rabbitmq - password: rabbitmq - virtual-host: /uni_dev datasource: type: com.alibaba.druid.pool.DruidDataSource dynamic: @@ -205,6 +232,10 @@ uni-boot: permit-all-list: /common/download** framework: file-base-path: D:/uniboot/file/temp/ + mq: + tx-msg: + # 关闭重试 + enable-retry: false ``` ### example 服务配置 @@ -221,12 +252,6 @@ spring: port: 6379 password: ENC(jIiKGruIMgDkKx5wj2gJRCROqPutkTvZ) database: 0 - rabbitmq: - host: localhost - port: 5672 - username: rabbitmq - password: rabbitmq - virtual-host: /uni_dev datasource: type: com.alibaba.druid.pool.DruidDataSource dynamic: @@ -247,43 +272,64 @@ uni-boot: permit-all-list: mq: tx-msg: + # 开启重试 enable-retry: true + # rabbitmq 自动创建 rabbit: enable: true - exchanges: - - name: uni.delay - type: topic - delayed: true - - name: uni.topic - type: topic - queues: - - name: example-delay-queue-0 - - name: example-delay-queue-1 - random-suffix: true - auto-delete: true - - name: example-biz-queue-0 - dl-exchange: uni.topic - dl-routing-key: example-biz-queue-0-dl-rk - - name: example-biz-queue-0-dl - - name: example-biz-queue-1 - bindings: - - bind-name: example-delay-queue-0 - exchange-name: uni.delay - routing-key: example-delay-queue-0-rk - - bind-name: example-delay-queue-1 - exchange-name: uni.delay - routing-key: example-delay-queue-1-rk - - bind-name: example-biz-queue-0 - exchange-name: uni.topic - routing-key: example-biz-queue-0-rk - - bind-name: example-biz-queue-0-dl - exchange-name: uni.topic - routing-key: example-biz-queue-0-dl-rk - - bind-name: example-biz-queue-1 - exchange-name: uni.topic - routing-key: example-biz-queue-1-rk + declares: + default: + exchanges: + - name: default.delay + type: topic + delayed: true + - name: default.topic + type: topic + queues: + - name: example-delay-queue-0 + - name: example-delay-queue-1 + random-suffix: true + auto-delete: true + - name: example-biz-queue-0 + dl-exchange: default.topic + dl-routing-key: example-biz-queue-0-dl-rk + - name: example-biz-queue-0-dl + - name: example-biz-queue-1 + bindings: + - bind-name: example-delay-queue-0 + exchange-name: default.delay + routing-key: example-delay-queue-0-rk + - bind-name: example-delay-queue-1 + exchange-name: default.delay + routing-key: example-delay-queue-1-rk + - bind-name: example-biz-queue-0 + exchange-name: default.topic + routing-key: example-biz-queue-0-rk + - bind-name: example-biz-queue-0-dl + exchange-name: default.topic + routing-key: example-biz-queue-0-dl-rk + - bind-name: example-biz-queue-1 + exchange-name: default.topic + routing-key: example-biz-queue-1-rk + test: + exchanges: + - name: test.topic + type: topic + queues: + - name: test-biz-queue-0 + bindings: + - bind-name: test-biz-queue-0 + exchange-name: test.topic + routing-key: test-biz-queue-0-rk ``` +> 通过 uni-boot-mq.rabbit.declares 指定一个 RabbitMQ ConnectionName 需要声明的交换机、队列以及绑定关系, +> 这会自动注入 bean 容器,bean 名称格式是 connectionName_declareName +> +> 注意:当指定 random-suffix 为 true 时,会创建随机的队列名,若要在 @RabbitListener 中指定 queue 名称,可使用 SpringEL 表达式,如 +> queues = "#{@'default_example-delay-queue-1'.name}",其中 default 是 connectionName,example-delay-queue-1 是队列 bean +> name + ### gateway 服务配置 uni-boot-gateway-dev.yml(DEV 环境) diff --git a/README.md b/README.md index 74202e0b..e7e521a7 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ 集成 knife4j,提供 swagger module 的动态配置支持 - 集成 RabbitMQ,提供通过配置声明交换机和队列功能,以及事务消息、消息重试的支持 + 集成 RabbitMQ,提供通过配置声明多数据源、交换机和队列功能,以及事务消息、消息重试的支持 集成 OpenFeign,提供统一的消息拦截器、ErrorDecoder、HttpClient 配置等 From fec45c1b6137de33230f3ffee1d401dbc39f94f6 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Wed, 20 Sep 2023 09:59:30 +0800 Subject: [PATCH 130/244] =?UTF-8?q?fix:=20=E5=B1=9E=E6=80=A7=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E9=94=99=E8=AF=AF=EF=BC=8C=E5=BD=B1=E5=93=8D=E7=BB=A7?= =?UTF-8?q?=E6=89=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/extension/pipeline/AbstractPipelineContext.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/pipeline/AbstractPipelineContext.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/pipeline/AbstractPipelineContext.java index 899e1b37..ead46c04 100644 --- a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/pipeline/AbstractPipelineContext.java +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/pipeline/AbstractPipelineContext.java @@ -13,11 +13,11 @@ @Getter public abstract class AbstractPipelineContext implements PipelineContext { - private final ExtTypeCode extTypeCode; + private final ExtTypeCode pipelineType; private final FilterSelector filterSelector; - public AbstractPipelineContext(ExtTypeCode extTypeCode, FilterSelector filterSelector) { - this.extTypeCode = extTypeCode; + public AbstractPipelineContext(ExtTypeCode pipelineType, FilterSelector filterSelector) { + this.pipelineType = pipelineType; this.filterSelector = filterSelector; } From 7dceebf53300b03bf60f56a1d1eecd55517ce3cb Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 13 Oct 2023 08:49:32 +0800 Subject: [PATCH 131/244] =?UTF-8?q?feat:=20SecurityUtil=20=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=20token=20=E5=85=BC=E5=AE=B9=20url=20=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/base/util/SecurityUtil.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java index e54e5977..fce475ce 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java @@ -47,6 +47,12 @@ public static String getSecret() { * @return token */ public static String getTokenFromRequest(HttpServletRequest request) { + // 从请求头获取 + String token = request.getHeader(HttpConst.HEAD_TOKEN); + if (ObjUtil.isNotEmpty(token)) { + return token; + } + // 从 cookie 中解析 Cookie[] cookies = request.getCookies(); if (ObjUtil.isNotEmpty(cookies)) { Optional optionalCookie = Arrays.stream(cookies) @@ -56,7 +62,8 @@ public static String getTokenFromRequest(HttpServletRequest request) { return optionalCookie.get().getValue(); } } - return request.getHeader(HttpConst.HEAD_TOKEN); + // 从 url 参数中提取 + return request.getParameter(HttpConst.HEAD_TOKEN); } /** From 9a514ca3659da4f6abdff4f28fe1a40ebefab37c Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 13 Oct 2023 13:44:13 +0800 Subject: [PATCH 132/244] =?UTF-8?q?fix:=20gateway=20=E5=8E=BB=E9=99=A4=20t?= =?UTF-8?q?omcat=20=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gateway/pom.xml | 15 +++++++++------ .../uniboot/gateway/UniGatewayApplication.java | 9 +-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/gateway/pom.xml b/gateway/pom.xml index e78efc62..35b7431a 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -14,6 +14,10 @@ uni-boot-gateway 流量网关 + + 2.5 + + @@ -52,12 +56,6 @@ org.springframework.boot spring-boot-configuration-processor - - - org.springframework.boot - spring-boot-starter-tomcat - provided - org.springframework.boot @@ -74,6 +72,11 @@ com.github.xiaoymin knife4j-spring-boot-starter + + javax.servlet + servlet-api + ${servlet-api.version} + com.github.cadecode diff --git a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/UniGatewayApplication.java b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/UniGatewayApplication.java index adbac972..5a8e7383 100644 --- a/gateway/src/main/java/com/github/cadecode/uniboot/gateway/UniGatewayApplication.java +++ b/gateway/src/main/java/com/github/cadecode/uniboot/gateway/UniGatewayApplication.java @@ -3,8 +3,6 @@ import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyService; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.EnableAspectJAutoProxy; @@ -18,14 +16,9 @@ @EnableDiscoveryClient @EnableAspectJAutoProxy(exposeProxy = true) @SpringBootApplication -public class UniGatewayApplication extends SpringBootServletInitializer { +public class UniGatewayApplication { public static void main(String[] args) { SpringApplication.run(UniGatewayApplication.class, args); } - - @Override - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { - return application.sources(UniGatewayApplication.class); - } } From 13f51441a4dd881786409b27aaae8783cbcefc26 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 19 Oct 2023 16:11:35 +0800 Subject: [PATCH 133/244] =?UTF-8?q?feat:=20=E9=80=9A=E7=94=A8=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E6=96=87=E4=BB=B6=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E5=80=BC=E6=94=B9=E4=B8=BA=E4=BF=9D=E5=AD=98=E7=9A=84=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../svc/controller/CommonController.java | 29 +++++++++---------- .../framework/svc/util/FileUploadUtil.java | 8 +++++ 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/CommonController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/CommonController.java index 7859b1a2..720bd468 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/CommonController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/CommonController.java @@ -21,6 +21,9 @@ import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; /** * 通用API @@ -37,12 +40,12 @@ public class CommonController { @ApiOperation("上传文件") @PostMapping("common/upload") - public boolean upload(@RequestPart("file") MultipartFile file) { + public String upload(@RequestPart("file") MultipartFile file) { String originalFilename = file.getOriginalFilename(); boolean checked = FileUploadUtil.checkAllowedExtension(originalFilename); AssertUtil.isFalse(checked, FrameErrorEnum.EXTENSION_NOT_ALLOWED, originalFilename + "不被允许"); String renamedFileName = FileUploadUtil.renameByUUID(originalFilename); - String targetFilePath = FileUploadUtil.uploadPath() + renamedFileName; + String targetFilePath = FileUploadUtil.uploadPath(renamedFileName); try { File targetFile = FileUtil.file(targetFilePath); FileUtil.mkParentDirs(targetFile); @@ -50,27 +53,24 @@ public boolean upload(@RequestPart("file") MultipartFile file) { } catch (IOException e) { throw ApiException.of(FrameErrorEnum.UPLOAD_FILE_FAIL, e, originalFilename + "上传失败"); } - return true; + return renamedFileName; } @ApiOperation("上传多文件") @PostMapping("common/upload_files") - public int uploadFiles(@RequestPart("files") MultipartFile[] files) { - int res = 0; - for (MultipartFile file : files) { - upload(file); - res++; - } - return res; + public List uploadFiles(@RequestPart("files") MultipartFile[] files) { + return Arrays.stream(files) + .map(this::upload) + .collect(Collectors.toList()); } @ApiOperation("下载文件") @GetMapping(FileUploadUtil.DEFAULT_DOWNLOAD_API) - public void download(HttpServletRequest request, HttpServletResponse response, String fileName) throws IOException { + public void download(HttpServletRequest request, HttpServletResponse response, String fileName) { boolean checked = FileUploadUtil.checkAllowedExtension(fileName); AssertUtil.isFalse(checked, FrameErrorEnum.EXTENSION_NOT_ALLOWED, fileName + "不被允许"); // 写文件流 - String targetFilePath = FileUploadUtil.downloadPath() + fileName; + String targetFilePath = FileUploadUtil.downloadPath(fileName); boolean exist = FileUtil.exist(targetFilePath); AssertUtil.isFalse(exist, FrameErrorEnum.FILE_NOT_FOUND, fileName + "不存在"); ServletUtil.write(response, new File(targetFilePath)); @@ -78,10 +78,9 @@ public void download(HttpServletRequest request, HttpServletResponse response, S @ApiOperation("下载临时文件") @GetMapping(FileUploadUtil.DEFAULT_DOWNLOAD_TEMP_API) - public void downloadTemp(HttpServletRequest request, HttpServletResponse response, String fileName) throws IOException { + public void downloadTemp(HttpServletRequest request, HttpServletResponse response, String fileName) { download(request, response, fileName); - String targetFilePath = FileUploadUtil.downloadPath() + fileName; + String targetFilePath = FileUploadUtil.downloadPath(fileName); FileUtil.del(targetFilePath); } - } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/util/FileUploadUtil.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/util/FileUploadUtil.java index f10bff88..53315fca 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/util/FileUploadUtil.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/util/FileUploadUtil.java @@ -51,6 +51,14 @@ public static String downloadPath() { return DOWNLOAD_PATH; } + public static String uploadPath(String fileName) { + return UPLOAD_PATH + fileName; + } + + public static String downloadPath(String fileName) { + return DOWNLOAD_PATH + fileName; + } + public static String downloadUrl(String fileName) { return DEFAULT_DOWNLOAD_API + "?fileName=" + fileName; } From 2be2f0caa6cc2a210f4edda1f396a15e457e6e84 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 26 Oct 2023 14:16:28 +0800 Subject: [PATCH 134/244] =?UTF-8?q?feat:=20=E7=AD=96=E7=95=A5=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=99=A8=20execute=20=E6=96=B9=E6=B3=95=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=20submit=20=E8=A1=A8=E7=A4=BA=E6=9C=89=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/extension/strategy/StrategyExecutor.java | 4 ++-- .../core/extension/strategy/StrategySelectorExecutor.java | 4 ++-- .../uniboot/framework/svc/security/LoginSuccessHandler.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategyExecutor.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategyExecutor.java index 252f6e13..a0f12673 100644 --- a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategyExecutor.java +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategyExecutor.java @@ -16,8 +16,8 @@ public interface StrategyExecutor { void executeAll(Class clazz, StrategyContext context, Consumer consumer); - R execute(Class clazz, StrategyContext context, Function function); + R submit(Class clazz, StrategyContext context, Function function); - List executeAll(Class clazz, StrategyContext context, Function function); + List submitAll(Class clazz, StrategyContext context, Function function); } diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategySelectorExecutor.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategySelectorExecutor.java index 0645b9b3..aeb4a623 100644 --- a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategySelectorExecutor.java +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategySelectorExecutor.java @@ -69,7 +69,7 @@ public void executeAll(Class clazz, StrategyConte * @return 返回值 */ @Override - public R execute(Class clazz, StrategyContext context, Function function) { + public R submit(Class clazz, StrategyContext context, Function function) { List services = selectServices(clazz, context); if (ObjUtil.isNotEmpty(services)) { return function.apply(services.get(0)); @@ -86,7 +86,7 @@ public R execute(Class clazz, StrategyContext * @return 返回值 */ @Override - public List executeAll(Class clazz, StrategyContext context, Function function) { + public List submitAll(Class clazz, StrategyContext context, Function function) { List services = selectServices(clazz, context); if (ObjUtil.isNotEmpty(services)) { return services.stream() diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java index 8947c5cd..ab347b19 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/LoginSuccessHandler.java @@ -54,7 +54,7 @@ public void updateLoginInfo(SysUserDetails sysUserDetails) { @Override public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) { - ApiResult result = strategyExecutor.execute(LoginSuccessHandleService.class, securityProperties::getAuthModel, s -> { + ApiResult result = strategyExecutor.submit(LoginSuccessHandleService.class, securityProperties::getAuthModel, s -> { return s.getResult(request, response, authentication); }); updateLoginInfo(result.getData()); From 3169c8761a9433b8a12079410c6728a7d8f1ead4 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 26 Oct 2023 14:41:13 +0800 Subject: [PATCH 135/244] =?UTF-8?q?build:=20=E5=BC=95=E5=85=A5=20x-file-st?= =?UTF-8?q?orage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/plugin/pom.xml | 1 + common/plugin/storage/pom.xml | 25 +++++++++++++++++++++++++ dependencies/pom.xml | 7 +++++++ example/example_svc/pom.xml | 5 +++++ pom.xml | 5 +++++ 5 files changed, 43 insertions(+) create mode 100644 common/plugin/storage/pom.xml diff --git a/common/plugin/pom.xml b/common/plugin/pom.xml index d5b6093e..6d1ef0e2 100644 --- a/common/plugin/pom.xml +++ b/common/plugin/pom.xml @@ -22,6 +22,7 @@ swagger concurrent mq + storage diff --git a/common/plugin/storage/pom.xml b/common/plugin/storage/pom.xml new file mode 100644 index 00000000..6044ea0f --- /dev/null +++ b/common/plugin/storage/pom.xml @@ -0,0 +1,25 @@ + + + 4.0.0 + + com.github.cadecode + uni-boot-common-plugin + 2023.1.2 + + + uni-boot-common-plugin-storage + + + + com.github.cadecode + uni-boot-common-core + + + + org.dromara.x-file-storage + x-file-storage-spring + + + diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 9ed937ee..6b8bcab9 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -44,6 +44,7 @@ 3.1.1 2.0.0.RELEASE 2.5.0 + 2.0.0 @@ -223,6 +224,12 @@ spring-multirabbit ${multirabbit.version} + + + org.dromara.x-file-storage + x-file-storage-spring + ${x-file-storage.version} + diff --git a/example/example_svc/pom.xml b/example/example_svc/pom.xml index 59f71dbc..bd2dec1b 100644 --- a/example/example_svc/pom.xml +++ b/example/example_svc/pom.xml @@ -61,6 +61,11 @@ com.github.cadecode uni-boot-example-api + + + com.github.cadecode + uni-boot-common-plugin-storage + diff --git a/pom.xml b/pom.xml index 237c973a..7161f37b 100644 --- a/pom.xml +++ b/pom.xml @@ -72,6 +72,11 @@ uni-boot-common-plugin-mq ${uni.version} + + com.github.cadecode + uni-boot-common-plugin-storage + ${uni.version} + com.github.cadecode uni-boot-framework-api From 61495847b9f28a9a557f580a5c5861fe92156261 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 27 Oct 2023 14:27:22 +0800 Subject: [PATCH 136/244] =?UTF-8?q?feat:=20=E9=9B=86=E6=88=90=20x-file-sto?= =?UTF-8?q?rage=20=E6=96=87=E4=BB=B6=E8=AE=B0=E5=BD=95=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E3=80=81=E9=80=9A=E7=94=A8=E4=B8=8A=E6=AC=A1=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/sql/common-plguin.sql | 41 +++++ .../storage/config/XFileStorageConfig.java | 16 ++ .../handler/AbstractStorageHandler.java | 12 ++ framework/framework_base/pom.xml | 4 + .../framework/base/config/PluginConfig.java | 8 + .../base/plugin/bean/po/PlgFile.java | 143 ++++++++++++++++++ .../base/plugin/bean/vo/PlgFileVo.java | 58 +++++++ .../plugin/controller/PlgFileController.java | 135 +++++++++++++++++ .../base/plugin/convert/PlgFileConvert.java | 32 ++++ .../plugin/handler/StorageRecordHandler.java | 50 ++++++ .../base/plugin/mapper/PlgFileMapper.java | 15 ++ .../base/plugin/service/PlgFileService.java | 13 ++ .../serviceimpl/PlgFileServiceImpl.java | 17 +++ 13 files changed, 544 insertions(+) create mode 100644 common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/config/XFileStorageConfig.java create mode 100644 common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/handler/AbstractStorageHandler.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgFile.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgFileVo.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgFileConvert.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/StorageRecordHandler.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/mapper/PlgFileMapper.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/service/PlgFileService.java create mode 100644 framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/serviceimpl/PlgFileServiceImpl.java diff --git a/.docs/sql/common-plguin.sql b/.docs/sql/common-plguin.sql index cf62139a..deedfc11 100644 --- a/.docs/sql/common-plguin.sql +++ b/.docs/sql/common-plguin.sql @@ -68,3 +68,44 @@ CREATE TABLE IF NOT EXISTS plg_mq_msg DEFAULT CHARSET = utf8mb4 COMMENT '消息记录表'; +-- ---------------------------- +-- 文件记录表 +-- ---------------------------- +CREATE TABLE plg_file +( + id BIGINT UNSIGNED, + url varchar(512) NOT NULL COMMENT '文件访问地址', + size bigint(20) NULL COMMENT '文件大小,单位字节', + filename varchar(256) NULL COMMENT '文件名称', + original_filename varchar(256) NULL COMMENT '原始文件名', + base_path varchar(256) NULL COMMENT '基础存储路径', + path varchar(256) NULL COMMENT '存储路径', + ext varchar(32) NULL COMMENT '文件扩展名', + content_type varchar(128) NULL COMMENT 'MIME类型', + platform varchar(32) NULL COMMENT '存储平台', + th_url varchar(512) NULL COMMENT '缩略图访问路径', + th_filename varchar(256) NULL COMMENT '缩略图名称', + th_size bigint(20) NULL COMMENT '缩略图大小,单位字节', + th_content_type varchar(128) NULL COMMENT '缩略图MIME类型', + object_id varchar(32) NULL COMMENT '文件所属对象id', + object_type varchar(32) NULL COMMENT '文件所属对象类型,例如用户头像,评价图片', + metadata text NULL COMMENT '文件元数据', + user_metadata text NULL COMMENT '文件用户元数据', + th_metadata text NULL COMMENT '缩略图元数据', + th_user_metadata text NULL COMMENT '缩略图用户元数据', + attr text NULL COMMENT '附加属性', + file_acl varchar(32) NULL COMMENT '文件ACL', + th_file_acl varchar(32) NULL COMMENT '缩略图文件ACL', + + create_time DATETIME DEFAULT CURRENT_TIMESTAMP, + update_time DATETIME DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP, + update_user VARCHAR(100) NULL, + PRIMARY KEY (id), + INDEX idx_url (url), + INDEX idx_filename (filename), + INDEX idx_platform_url (platform, url), + INDEX idx_object_id (object_id), + INDEX idx_object_type_id (object_type, object_id) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COMMENT '文件记录表'; diff --git a/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/config/XFileStorageConfig.java b/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/config/XFileStorageConfig.java new file mode 100644 index 00000000..3aeb3db3 --- /dev/null +++ b/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/config/XFileStorageConfig.java @@ -0,0 +1,16 @@ +package com.github.cadecode.uniboot.common.plugin.storage.config; + +import org.dromara.x.file.storage.spring.EnableFileStorage; +import org.springframework.context.annotation.Configuration; + +/** + * x-file-storage 配置类 + * + * @author Cade Li + * @since 2023/10/25 + */ +@EnableFileStorage +@Configuration +public class XFileStorageConfig { + +} diff --git a/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/handler/AbstractStorageHandler.java b/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/handler/AbstractStorageHandler.java new file mode 100644 index 00000000..e4c569e3 --- /dev/null +++ b/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/handler/AbstractStorageHandler.java @@ -0,0 +1,12 @@ +package com.github.cadecode.uniboot.common.plugin.storage.handler; + +import org.dromara.x.file.storage.core.recorder.FileRecorder; + +/** + * 文件存储处理器 + * + * @author Cade Li + * @since 2023/10/27 + */ +public abstract class AbstractStorageHandler implements FileRecorder { +} diff --git a/framework/framework_base/pom.xml b/framework/framework_base/pom.xml index 875244a7..7721456f 100644 --- a/framework/framework_base/pom.xml +++ b/framework/framework_base/pom.xml @@ -55,6 +55,10 @@ com.github.cadecode uni-boot-common-plugin-mq + + com.github.cadecode + uni-boot-common-plugin-storage + com.github.cadecode uni-boot-framework-api diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/PluginConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/PluginConfig.java index 30eb8bc6..4456fd05 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/PluginConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/PluginConfig.java @@ -1,6 +1,9 @@ package com.github.cadecode.uniboot.framework.base.config; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyService; +import com.github.cadecode.uniboot.framework.base.plugin.handler.StorageRecordHandler; +import org.dromara.x.file.storage.core.recorder.FileRecorder; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.plugin.core.config.EnablePluginRegistries; @@ -14,4 +17,9 @@ @EnablePluginRegistries({StrategyService.class}) @Configuration public class PluginConfig { + + @Bean + public FileRecorder fileRecorder(StorageRecordHandler storageRecordHandler) { + return storageRecordHandler; + } } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgFile.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgFile.java new file mode 100644 index 00000000..8af0c7d3 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/po/PlgFile.java @@ -0,0 +1,143 @@ +package com.github.cadecode.uniboot.framework.base.plugin.bean.po; + +import cn.hutool.core.lang.Dict; +import com.baomidou.mybatisplus.annotation.*; +import com.github.cadecode.uniboot.common.plugin.mybatis.converter.ObjToStrTypeHandler; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; +import java.util.Map; + +/** + * 文件记录 + * + * @author Cade Li + * @since 2023/10/25 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName(autoResultMap = true) +public class PlgFile { + + @TableId(type = IdType.ASSIGN_ID) + private Long id; + + /** + * 文件访问地址 + */ + private String url; + + /** + * 文件大小,单位字节 + */ + private Long size; + + /** + * 文件名称 + */ + private String filename; + + /** + * 原始文件名 + */ + private String originalFilename; + + /** + * 基础存储路径 + */ + private String basePath; + + /** + * 存储路径 + */ + private String path; + + /** + * 文件扩展名 + */ + private String ext; + + /** + * MIME 类型 + */ + private String contentType; + + /** + * 存储平台 + */ + private String platform; + + /** + * 缩略图访问路径 + */ + private String thUrl; + + /** + * 缩略图名称 + */ + private String thFilename; + + /** + * 缩略图大小,单位字节 + */ + private Long thSize; + + /** + * 缩略图 MIME 类型 + */ + private String thContentType; + + /** + * 文件所属对象id + */ + private String objectId; + + /** + * 文件所属对象类型,例如用户头像,评价图片 + */ + private String objectType; + + /** + * 文件元数据 + */ + @TableField(typeHandler = ObjToStrTypeHandler.class) + private Map metadata; + + /** + * 文件用户元数据 + */ + @TableField(typeHandler = ObjToStrTypeHandler.class) + private Map userMetadata; + + /** + * 缩略图元数据 + */ + @TableField(typeHandler = ObjToStrTypeHandler.class) + private Map thMetadata; + + /** + * 缩略图用户元数据 + */ + @TableField(typeHandler = ObjToStrTypeHandler.class) + private Map thUserMetadata; + + /** + * 附加属性字典 + */ + @TableField(typeHandler = ObjToStrTypeHandler.class) + private Dict attr; + + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @TableField(fill = FieldFill.UPDATE) + private Date updateTime; + + @TableField(fill = FieldFill.INSERT_UPDATE) + private String updateUser; +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgFileVo.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgFileVo.java new file mode 100644 index 00000000..1950ef95 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/bean/vo/PlgFileVo.java @@ -0,0 +1,58 @@ +package com.github.cadecode.uniboot.framework.base.plugin.bean.vo; + +import cn.hutool.core.lang.Dict; +import com.github.cadecode.uniboot.common.core.web.response.PageParams; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; +import java.util.Map; + +/** + * 文件记录 VO + * + * @author Cade Li + * @since 2023/10/25 + */ +public class PlgFileVo { + + @Data + @EqualsAndHashCode(callSuper = true) + public static class PlgFilePageReqVo extends PageParams { + private Date startTime; + private Date endTime; + private String platform; + private String url; + private String filename; + private String objectId; + private String objectType; + } + + @Data + public static class PlgFilePageResVo { + private Long id; + private String url; + private Long size; + private String filename; + private String originalFilename; + private String basePath; + private String path; + private String ext; + private String contentType; + private String platform; + private String thUrl; + private String thFilename; + private Long thSize; + private String thContentType; + private String objectId; + private String objectType; + private Map metadata; + private Map userMetadata; + private Map thMetadata; + private Map thUserMetadata; + private Dict attr; + private Date createTime; + private Date updateTime; + private String updateUser; + } +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java new file mode 100644 index 00000000..99425bad --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java @@ -0,0 +1,135 @@ +package com.github.cadecode.uniboot.framework.base.plugin.controller; + +import cn.hutool.core.util.ObjUtil; +import cn.hutool.extra.servlet.ServletUtil; +import com.github.cadecode.uniboot.common.core.web.response.PageResult; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgFile; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgFileVo.PlgFilePageReqVo; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgFileVo.PlgFilePageResVo; +import com.github.cadecode.uniboot.framework.base.plugin.convert.PlgFileConvert; +import com.github.cadecode.uniboot.framework.base.plugin.service.PlgFileService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.dromara.x.file.storage.core.FileInfo; +import org.dromara.x.file.storage.core.FileStorageService; +import org.dromara.x.file.storage.core.UploadPretreatment; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import javax.validation.constraints.NotEmpty; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * 文件记录管理 + * + * @author Cade Li + * @since 2023/10/26 + */ +@ApiFormat +@Slf4j +@RequiredArgsConstructor +@Api(tags = "文件管理") +@RequestMapping("plugin/file") +@RestController +@Validated +public class PlgFileController { + + private final FileStorageService fileStorageService; + + private final PlgFileService plgFileService; + + @ApiOperation("查询列表") + @PostMapping("record/page") + public PageResult page(@RequestBody @Valid PlgFilePageReqVo reqVo) { + PageInfo pageInfo = PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize()) + .doSelectPageInfo(() -> plgFileService.lambdaQuery() + .ge(ObjUtil.isNotEmpty(reqVo.getStartTime()), PlgFile::getCreateTime, reqVo.getStartTime()) + .le(ObjUtil.isNotEmpty(reqVo.getEndTime()), PlgFile::getCreateTime, reqVo.getEndTime()) + .eq(ObjUtil.isNotEmpty(reqVo.getPlatform()), PlgFile::getPlatform, reqVo.getPlatform()) + .eq(ObjUtil.isNotEmpty(reqVo.getUrl()), PlgFile::getUrl, reqVo.getUrl()) + .eq(ObjUtil.isNotEmpty(reqVo.getFilename()), PlgFile::getFilename, reqVo.getFilename()) + .eq(ObjUtil.isNotEmpty(reqVo.getObjectId()), PlgFile::getObjectId, reqVo.getObjectId()) + .eq(ObjUtil.isNotEmpty(reqVo.getObjectType()), PlgFile::getObjectType, reqVo.getObjectType()) + .orderByDesc(PlgFile::getCreateTime) + .list()); + List voList = PlgFileConvert.INSTANCE.poToPageResVo(pageInfo.getList()); + return new PageResult<>((int) pageInfo.getTotal(), voList); + } + + @ApiOperation("删除-批量") + @PostMapping("record/delete") + public boolean delete(@RequestBody @NotEmpty List idList) { + return plgFileService.removeBatchByIds(idList); + } + + @ApiOperation("通用上传") + @PostMapping("storage/upload") + public FileInfo upload(@RequestPart MultipartFile file) { + return fileStorageService.of(file).upload(); + } + + @ApiOperation("通用上传-批量") + @PostMapping("storage/upload_files") + public List uploadFiles(@RequestPart MultipartFile[] files) { + return Arrays.stream(files) + .map(this::upload) + .collect(Collectors.toList()); + } + + @ApiOperation("通用上传图片") + @PostMapping("storage/upload_image") + public FileInfo uploadImage(@RequestPart MultipartFile file, + @RequestPart(required = false) Integer width, + @RequestPart(required = false) Integer height, + @RequestPart(required = false) Integer thWidth, + @RequestPart(required = false) Integer thHeight) { + UploadPretreatment uploadPretreatment = fileStorageService.of(file); + // 根据传入条件设置宽高和缩略 + if (!ObjUtil.hasNull(width, height)) { + uploadPretreatment.image(img -> img.size(width, height)); + } + if (!ObjUtil.hasNull(thWidth, thHeight)) { + uploadPretreatment.thumbnail(th -> th.size(thWidth, thHeight)); + } + return uploadPretreatment.upload(); + } + + @ApiOperation("通用上传图片-批量") + @PostMapping("storage/upload_images") + public List uploadImages(@RequestPart MultipartFile[] files, + @RequestPart(required = false) Integer width, + @RequestPart(required = false) Integer height, + @RequestPart(required = false) Integer thWidth, + @RequestPart(required = false) Integer thHeight) { + return Arrays.stream(files) + .map(o -> uploadImage(o, width, height, thWidth, thHeight)) + .collect(Collectors.toList()); + } + + @ApiOperation("通用下载") + @GetMapping("storage/download") + public void download(HttpServletResponse response, + @RequestParam String url) { + FileInfo fileInfo = fileStorageService.getFileInfoByUrl(url); + fileStorageService.download(fileInfo).inputStream(in -> ServletUtil.write(response, in)); + } + + @ApiOperation("通用临时下载") + @GetMapping("storage/download_temp") + public void downloadTemp(HttpServletResponse response, + @RequestParam String url) { + FileInfo fileInfo = fileStorageService.getFileInfoByUrl(url); + fileStorageService.download(fileInfo).inputStream(in -> ServletUtil.write(response, in)); + fileStorageService.delete(fileInfo); + } +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgFileConvert.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgFileConvert.java new file mode 100644 index 00000000..a95cfa92 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgFileConvert.java @@ -0,0 +1,32 @@ +package com.github.cadecode.uniboot.framework.base.plugin.convert; + +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgFile; +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgFileVo.PlgFilePageResVo; +import org.dromara.x.file.storage.core.FileInfo; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 文件记录 bean convert + * + * @author Cade Li + * @since 2023/10/25 + */ +@Mapper +public interface PlgFileConvert { + + PlgFileConvert INSTANCE = Mappers.getMapper(PlgFileConvert.class); + + @Mapping(target = "thFileAcl", ignore = true) + @Mapping(target = "fileAcl", ignore = true) + FileInfo poToFileInfo(PlgFile po); + + @Mapping(target = "updateUser", ignore = true) + @Mapping(target = "updateTime", ignore = true) + PlgFile fileInfoToPo(FileInfo fileInfo); + + List poToPageResVo(List poList); +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/StorageRecordHandler.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/StorageRecordHandler.java new file mode 100644 index 00000000..caa6571d --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/handler/StorageRecordHandler.java @@ -0,0 +1,50 @@ +package com.github.cadecode.uniboot.framework.base.plugin.handler; + +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.github.cadecode.uniboot.common.plugin.storage.handler.AbstractStorageHandler; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgFile; +import com.github.cadecode.uniboot.framework.base.plugin.convert.PlgFileConvert; +import com.github.cadecode.uniboot.framework.base.plugin.service.PlgFileService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.dromara.x.file.storage.core.FileInfo; +import org.springframework.stereotype.Component; + +/** + * 文件存储记录处理器 + * + * @author Cade Li + * @since 2023/10/26 + */ +@Slf4j +@RequiredArgsConstructor +@Component +public class StorageRecordHandler extends AbstractStorageHandler { + + private final PlgFileService plgFileService; + + @Override + public boolean save(FileInfo fileInfo) { + PlgFile plgFile = PlgFileConvert.INSTANCE.fileInfoToPo(fileInfo); + boolean saveFlag = plgFileService.save(plgFile); + if (saveFlag) { + // 注入 id + fileInfo.setId(String.valueOf(plgFile.getId())); + } + return saveFlag; + } + + @Override + public FileInfo getByUrl(String url) { + // 按 url 查询 + PlgFile plgFile = plgFileService.lambdaQuery() + .eq(PlgFile::getUrl, url) + .one(); + return PlgFileConvert.INSTANCE.poToFileInfo(plgFile); + } + + @Override + public boolean delete(String url) { + return plgFileService.remove(Wrappers.lambdaQuery().eq(PlgFile::getUrl, url)); + } +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/mapper/PlgFileMapper.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/mapper/PlgFileMapper.java new file mode 100644 index 00000000..17cba584 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/mapper/PlgFileMapper.java @@ -0,0 +1,15 @@ +package com.github.cadecode.uniboot.framework.base.plugin.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgFile; +import org.apache.ibatis.annotations.Mapper; + +/** + * PlgFile Mapper + * + * @author Cade Li + * @since 2023/10/25 + */ +@Mapper +public interface PlgFileMapper extends BaseMapper { +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/service/PlgFileService.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/service/PlgFileService.java new file mode 100644 index 00000000..a7f6faa6 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/service/PlgFileService.java @@ -0,0 +1,13 @@ +package com.github.cadecode.uniboot.framework.base.plugin.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgFile; + +/** + * PlgFile Service + * + * @author Cade Li + * @since 2023/10/25 + */ +public interface PlgFileService extends IService { +} diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/serviceimpl/PlgFileServiceImpl.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/serviceimpl/PlgFileServiceImpl.java new file mode 100644 index 00000000..e902cd86 --- /dev/null +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/serviceimpl/PlgFileServiceImpl.java @@ -0,0 +1,17 @@ +package com.github.cadecode.uniboot.framework.base.plugin.serviceimpl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgFile; +import com.github.cadecode.uniboot.framework.base.plugin.mapper.PlgFileMapper; +import com.github.cadecode.uniboot.framework.base.plugin.service.PlgFileService; +import org.springframework.stereotype.Service; + +/** + * PlgFile ServiceImpl + * + * @author Cade Li + * @since 2023/10/25 + */ +@Service +public class PlgFileServiceImpl extends ServiceImpl implements PlgFileService { +} From f15a0e6080f33b1aa4ac770209853aaddde0fc02 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 27 Oct 2023 14:28:58 +0800 Subject: [PATCH 137/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20x-file-sto?= =?UTF-8?q?rage=20=E4=BD=BF=E7=94=A8=20demo=20controller?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/example_svc/pom.xml | 5 -- .../controller/XFileStorageController.java | 67 +++++++++++++++++++ 2 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/XFileStorageController.java diff --git a/example/example_svc/pom.xml b/example/example_svc/pom.xml index bd2dec1b..59f71dbc 100644 --- a/example/example_svc/pom.xml +++ b/example/example_svc/pom.xml @@ -61,11 +61,6 @@ com.github.cadecode uni-boot-example-api - - - com.github.cadecode - uni-boot-common-plugin-storage - diff --git a/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/XFileStorageController.java b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/XFileStorageController.java new file mode 100644 index 00000000..f1e5c3c3 --- /dev/null +++ b/example/example_svc/src/main/java/com/github/cadecode/uniboot/example/svc/controller/XFileStorageController.java @@ -0,0 +1,67 @@ +package com.github.cadecode.uniboot.example.svc.controller; + +import cn.hutool.extra.servlet.ServletUtil; +import com.github.cadecode.uniboot.common.core.exception.ApiException; +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.dromara.x.file.storage.core.FileInfo; +import org.dromara.x.file.storage.core.FileStorageService; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; + +/** + * X File Storage 测试 API + * + * @author Cade Li + * @since 2023/10/24 + */ +@ApiFormat +@Slf4j +@RequiredArgsConstructor +@Api(tags = " X File Storage 测试") +@RestController +@RequestMapping("demo/x_file_storage") +public class XFileStorageController { + + private final FileStorageService fileStorageService; + + @ApiOperation("上传") + @PostMapping("upload") + public FileInfo localUpload(@RequestPart MultipartFile file, + @RequestPart(required = false) String customFileName) { + return fileStorageService.of(file) + .setSaveFilename(customFileName) + .upload(); + } + + @ApiOperation("上传图片(打开缩略)") + @PostMapping("upload-image") + public FileInfo uploadImage(@RequestPart MultipartFile file, + @RequestPart(required = false) String customFileName) { + return fileStorageService.of(file) + .setSaveFilename(customFileName) + .image(img -> img.size(1000, 1000)) + .thumbnail(th -> th.size(200, 200)) + .upload(); + } + + @ApiOperation("下载") + @GetMapping("download") + public void download(HttpServletResponse response, + @RequestParam String url) { + // 手动构造文件信息,可用于其它操作 + FileInfo fileInfo = fileStorageService.getFileInfoByUrl(url); + // 文件是否存在 + boolean exists = fileStorageService.exists(fileInfo); + if (!exists) { + throw ApiException.of("文件不存在!"); + } + // 下载 + fileStorageService.download(fileInfo).inputStream(in -> ServletUtil.write(response, in)); + } +} From 7e77e3a82a2ec87cbc8f54e680ccae5fa75a5c92 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 30 Oct 2023 15:19:38 +0800 Subject: [PATCH 138/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=88=A0=E9=99=A4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/controller/PlgFileController.java | 18 +++++++++++++++++- .../base/plugin/convert/PlgFileConvert.java | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java index 99425bad..9917b044 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java @@ -66,7 +66,7 @@ public PageResult page(@RequestBody @Valid PlgFilePageReqVo re return new PageResult<>((int) pageInfo.getTotal(), voList); } - @ApiOperation("删除-批量") + @ApiOperation("删除记录-批量") @PostMapping("record/delete") public boolean delete(@RequestBody @NotEmpty List idList) { return plgFileService.removeBatchByIds(idList); @@ -132,4 +132,20 @@ public void downloadTemp(HttpServletResponse response, fileStorageService.download(fileInfo).inputStream(in -> ServletUtil.write(response, in)); fileStorageService.delete(fileInfo); } + + @ApiOperation("通用删除文件-byUrl") + @PostMapping("storage/delete_by_url") + public boolean deleteFile(@RequestParam String url) { + return fileStorageService.delete(url); + } + + @ApiOperation("通用删除文件-byId") + @PostMapping("storage/delete_by_id") + public List deleteFiles(@RequestBody List idList) { + List plgFileList = plgFileService.listByIds(idList); + List fileInfoList = PlgFileConvert.INSTANCE.poToFileInfo(plgFileList); + return fileInfoList.stream() + .filter(fileStorageService::delete) + .collect(Collectors.toList()); + } } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgFileConvert.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgFileConvert.java index a95cfa92..ddac6997 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgFileConvert.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgFileConvert.java @@ -29,4 +29,6 @@ public interface PlgFileConvert { PlgFile fileInfoToPo(FileInfo fileInfo); List poToPageResVo(List poList); + + List poToFileInfo(List plgFileList); } From 21ba8922384945db6603e17b30d9b0fb302d2d7b Mon Sep 17 00:00:00 2001 From: Cade Li Date: Mon, 30 Oct 2023 15:29:11 +0800 Subject: [PATCH 139/244] =?UTF-8?q?feat:=20=E6=96=87=E4=BB=B6=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=8E=A5=E5=8F=A3=E6=B7=BB=E5=8A=A0=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/plugin/controller/PlgFileController.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java index 9917b044..ad3384a0 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java @@ -145,7 +145,14 @@ public List deleteFiles(@RequestBody List idList) { List plgFileList = plgFileService.listByIds(idList); List fileInfoList = PlgFileConvert.INSTANCE.poToFileInfo(plgFileList); return fileInfoList.stream() - .filter(fileStorageService::delete) + .filter(o -> { + try { + return fileStorageService.delete(o); + } catch (Exception e) { + log.error("Delete files by id", e); + return false; + } + }) .collect(Collectors.toList()); } } From 80709bc3abe53e24076f283ffb48e98265d72e33 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 31 Oct 2023 08:42:42 +0800 Subject: [PATCH 140/244] =?UTF-8?q?refactor:=20=E8=B0=83=E6=95=B4=20fileRe?= =?UTF-8?q?corder=20bean=20=E5=A3=B0=E6=98=8E=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/plugin/storage/config/XFileStorageConfig.java | 9 +++++++++ .../uniboot/framework/base/config/PluginConfig.java | 8 -------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/config/XFileStorageConfig.java b/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/config/XFileStorageConfig.java index 3aeb3db3..848b2f99 100644 --- a/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/config/XFileStorageConfig.java +++ b/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/config/XFileStorageConfig.java @@ -1,6 +1,10 @@ package com.github.cadecode.uniboot.common.plugin.storage.config; +import com.github.cadecode.uniboot.common.plugin.storage.handler.AbstractStorageHandler; +import lombok.RequiredArgsConstructor; +import org.dromara.x.file.storage.core.recorder.FileRecorder; import org.dromara.x.file.storage.spring.EnableFileStorage; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** @@ -10,7 +14,12 @@ * @since 2023/10/25 */ @EnableFileStorage +@RequiredArgsConstructor @Configuration public class XFileStorageConfig { + @Bean + public FileRecorder fileRecorder(AbstractStorageHandler storageRecordHandler) { + return storageRecordHandler; + } } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/PluginConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/PluginConfig.java index 4456fd05..30eb8bc6 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/PluginConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/PluginConfig.java @@ -1,9 +1,6 @@ package com.github.cadecode.uniboot.framework.base.config; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyService; -import com.github.cadecode.uniboot.framework.base.plugin.handler.StorageRecordHandler; -import org.dromara.x.file.storage.core.recorder.FileRecorder; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.plugin.core.config.EnablePluginRegistries; @@ -17,9 +14,4 @@ @EnablePluginRegistries({StrategyService.class}) @Configuration public class PluginConfig { - - @Bean - public FileRecorder fileRecorder(StorageRecordHandler storageRecordHandler) { - return storageRecordHandler; - } } From 6187d8e32296573854e78616972e3ecd540ede06 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 31 Oct 2023 09:26:00 +0800 Subject: [PATCH 141/244] =?UTF-8?q?refactor:=20=E6=B7=BB=E5=8A=A0=20mapstr?= =?UTF-8?q?uct=20ignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java | 1 + 1 file changed, 1 insertion(+) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java index 77ae56f5..6d86be36 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/convert/PlgMqMsgConvert.java @@ -41,6 +41,7 @@ public interface PlgMqMsgConvert { List poToPageResVo(List poList); + @Mapping(target = "connectionName", ignore = true) @Mapping(target = "updateUser", ignore = true) @Mapping(target = "updateTime", ignore = true) @Mapping(target = "routingKey", ignore = true) From e57b933712e21925cd62f692409e37b5024030eb Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 31 Oct 2023 09:28:20 +0800 Subject: [PATCH 142/244] =?UTF-8?q?fix:=20=E5=BC=95=E5=85=A5=20common-plug?= =?UTF-8?q?in-mq=EF=BC=8C=E8=A7=A3=E5=86=B3=20fileRecorder=20bean=20?= =?UTF-8?q?=E6=B3=A8=E5=85=A5=E9=A1=BA=E5=BA=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- framework/framework_svc/pom.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/framework/framework_svc/pom.xml b/framework/framework_svc/pom.xml index 84cdc868..600768d3 100644 --- a/framework/framework_svc/pom.xml +++ b/framework/framework_svc/pom.xml @@ -51,11 +51,15 @@ com.github.cadecode - uni-boot-framework-base + uni-boot-common-plugin-actuator com.github.cadecode - uni-boot-common-plugin-actuator + uni-boot-common-plugin-mq + + + com.github.cadecode + uni-boot-framework-base From a00afca123b3238b4fa7710af710062607006f7e Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 31 Oct 2023 15:04:31 +0800 Subject: [PATCH 143/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=20username=20=E6=9F=A5=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=20feign=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/api/bean/dto/SysUserDto.java | 44 +++++++++++++++++++ .../api/feignclient/SysUserClient.java | 20 +++++++++ .../svc/controller/SysUserController.java | 20 +++++++-- 3 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java create mode 100644 framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysUserClient.java diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java new file mode 100644 index 00000000..9584a2ad --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/bean/dto/SysUserDto.java @@ -0,0 +1,44 @@ +package com.github.cadecode.uniboot.framework.api.bean.dto; + +import lombok.Data; + +import java.util.Date; +import java.util.List; + +/** + * SysUser Dto + * + * @author Cade Li + * @since 2023/10/31 + */ +public class SysUserDto { + + @Data + public static class SysUserGetByUsernameResDto { + private Long id; + + private String username; + + private String nickName; + + private Boolean enableFlag; + + private String sex; + + private String mail; + + private String phone; + + private String loginIp; + + private Date loginDate; + + private Date createTime; + + private Date updateTime; + + private String updateUser; + + private List roles; + } +} diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysUserClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysUserClient.java new file mode 100644 index 00000000..6a18937f --- /dev/null +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysUserClient.java @@ -0,0 +1,20 @@ +package com.github.cadecode.uniboot.framework.api.feignclient; + +import com.github.cadecode.uniboot.framework.api.bean.dto.SysUserDto.SysUserGetByUsernameResDto; +import com.github.cadecode.uniboot.framework.api.consts.SvcNameConst; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; + +/** + * SysApi feign client + * + * @author Cade Li + * @since 2023/7/28 + */ +@FeignClient(contextId = "SysUserClient", name = SvcNameConst.FRAMEWORK) +public interface SysUserClient { + + @PostMapping("system/user/client/get_by_username") + SysUserGetByUsernameResDto getByUsername(); + +} diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java index ee7479f1..a4bb1129 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysUserController.java @@ -2,8 +2,10 @@ import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.core.exception.ApiException; +import com.github.cadecode.uniboot.common.core.util.AssertUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; +import com.github.cadecode.uniboot.framework.base.annotation.ApiInner; import com.github.cadecode.uniboot.framework.base.security.model.SysUserDetails; import com.github.cadecode.uniboot.framework.base.util.SecurityUtil; import com.github.cadecode.uniboot.framework.svc.bean.po.SysUser; @@ -22,10 +24,7 @@ import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.validation.Valid; import javax.validation.constraints.NotEmpty; @@ -147,4 +146,17 @@ public List listRolesVoByUserIds(@RequestBody @NotEmpty List< return sysUserService.listRolesVoByUserIds(userIdList); } + // RPC + + @ApiInner(onlyClient = true) + @ApiOperation("RPC-查询用户信息") + @PostMapping("client/get_by_username") + public SysUserRolesResVo clientGetByUsername(@RequestParam String username) { + // 根据用户名查询 + SysUserRolesReqVo reqVo = new SysUserRolesReqVo(); + reqVo.setUsername(username); + List voList = sysUserService.listRolesVo(reqVo); + AssertUtil.isEmpty(voList, "此用户名不存在"); + return voList.get(0); + } } From b79b6a67cf7602f9ff819972d9bc010ae26e2b37 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 31 Oct 2023 15:06:18 +0800 Subject: [PATCH 144/244] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=20api=20=E6=9D=83=E9=99=90=E6=9F=A5=E8=AF=A2=20feign?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/api/feignclient/SysApiClient.java | 2 +- .../uniboot/framework/svc/config/FrameSecurityConfig.java | 2 +- .../uniboot/framework/svc/controller/SysApiController.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java index 4af664d0..ad1e8c81 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysApiClient.java @@ -19,7 +19,7 @@ public interface SysApiClient { @Cacheable(cacheNames = KeyPrefixConst.API_ROLES, key = "'ALL'") - @PostMapping("system/api/list_roles_vo") + @PostMapping("system/api/client_list_roles_vo") List listRolesResVo(); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java index 23a75ce4..eb82f72f 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/config/FrameSecurityConfig.java @@ -116,7 +116,7 @@ public void afterPropertiesSet() { // 放行登录接口 "/auth/login", // 放行接口权限表查询接口 - "/system/api/list_roles_vo" + "/system/api/client_list_roles_vo" )); } } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java index 16a20310..ff2507fc 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/controller/SysApiController.java @@ -90,8 +90,8 @@ public List listRolesVoByApiIds(@RequestBody @NotEmpty List listRolesVo() { + @PostMapping("client_list_roles_vo") + public List clientListRolesVo() { return sysApiService.listRolesVo(); } } From 794c55cd84bda20c297d5cb18fbe8cc27c0ba291 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Wed, 1 Nov 2023 10:05:15 +0800 Subject: [PATCH 145/244] =?UTF-8?q?fix:=20=E6=9F=A5=E8=AF=A2=20SysUser=20f?= =?UTF-8?q?eign=20client=20=E5=8F=82=E6=95=B0=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/api/feignclient/SysUserClient.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysUserClient.java b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysUserClient.java index 6a18937f..7d68e624 100644 --- a/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysUserClient.java +++ b/framework/framework_api/src/main/java/com/github/cadecode/uniboot/framework/api/feignclient/SysUserClient.java @@ -4,6 +4,7 @@ import com.github.cadecode.uniboot.framework.api.consts.SvcNameConst; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; /** * SysApi feign client @@ -15,6 +16,6 @@ public interface SysUserClient { @PostMapping("system/user/client/get_by_username") - SysUserGetByUsernameResDto getByUsername(); + SysUserGetByUsernameResDto getByUsername(@RequestParam("username") String username); } From ab79b07ed36c60c7b389581571b0e6280cfcb571 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 2 Nov 2023 11:11:06 +0800 Subject: [PATCH 146/244] =?UTF-8?q?feat:=20=E5=88=A0=E9=99=A4=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=8E=A5=E5=8F=A3=E5=90=AF=E7=94=A8=20ApiLogger?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/base/plugin/controller/PlgFileController.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java index ad3384a0..432c5b13 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java @@ -3,6 +3,8 @@ import cn.hutool.core.util.ObjUtil; import cn.hutool.extra.servlet.ServletUtil; import com.github.cadecode.uniboot.common.core.web.response.PageResult; +import com.github.cadecode.uniboot.common.plugin.log.annotation.ApiLogger; +import com.github.cadecode.uniboot.framework.api.consts.LogTypeConst; import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgFile; import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgFileVo.PlgFilePageReqVo; @@ -133,12 +135,14 @@ public void downloadTemp(HttpServletResponse response, fileStorageService.delete(fileInfo); } + @ApiLogger(type = LogTypeConst.REMOVE, enableSave = true) @ApiOperation("通用删除文件-byUrl") @PostMapping("storage/delete_by_url") public boolean deleteFile(@RequestParam String url) { return fileStorageService.delete(url); } + @ApiLogger(type = LogTypeConst.REMOVE, enableSave = true) @ApiOperation("通用删除文件-byId") @PostMapping("storage/delete_by_id") public List deleteFiles(@RequestBody List idList) { From 50b2481356b4bf97c4449de80d0f6727c82e3967 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 2 Nov 2023 11:23:10 +0800 Subject: [PATCH 147/244] =?UTF-8?q?docs:=20=E7=BB=B4=E6=8A=A4=20SQL=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20sys=5Fmenu=20=E6=96=87=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/sql/framework/data.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.docs/sql/framework/data.sql b/.docs/sql/framework/data.sql index 14c940bf..184476af 100644 --- a/.docs/sql/framework/data.sql +++ b/.docs/sql/framework/data.sql @@ -58,6 +58,10 @@ VALUES (302, 3, 'MqMsg', '/develop/mq_msg', '/Develop/MqMsg', '消息队列', 1, '2023-08-24 10:30:42', 'admin'); INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, enable_flag, create_time, update_time, update_user) +VALUES (303, 3, 'File', '/develop/file', '/Develop/File', '文件管理', 1, null, 303, 1, '2023-08-22 23:23:46', + '2023-08-24 10:30:42', 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, + order_num, enable_flag, create_time, update_time, update_user) VALUES (306, 3, 'Icon', '/develop/icon', '/Develop/Icon', '图标', 1, null, 306, 1, '2023-08-18 15:03:30', null, null); INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, enable_flag, create_time, update_time, update_user) From 2ccbcae05c04e23a1be69ef3101f06dbc339b345 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 2 Nov 2023 13:43:07 +0800 Subject: [PATCH 148/244] =?UTF-8?q?docs:=20=E7=BB=B4=E6=8A=A4=20SQL=20?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=20sys=5Frole=5Fmenu=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/sql/framework/data.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.docs/sql/framework/data.sql b/.docs/sql/framework/data.sql index 184476af..dd07e97b 100644 --- a/.docs/sql/framework/data.sql +++ b/.docs/sql/framework/data.sql @@ -114,6 +114,8 @@ VALUES (1, 301); INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 302); INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 303); +INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 306); INSERT INTO sys_role_menu (role_id, menu_id) VALUES (1, 307); From 4d278bb930c9eb661edf19bebabd74e12b1475ad Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 2 Nov 2023 15:31:24 +0800 Subject: [PATCH 149/244] =?UTF-8?q?fix:=20=E6=94=B9=E4=B8=BA=20@RequestPar?= =?UTF-8?q?am=20=E6=8E=A5=E6=94=B6=E6=99=AE=E9=80=9A=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/controller/PlgFileController.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java index 432c5b13..4f19805f 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/plugin/controller/PlgFileController.java @@ -91,10 +91,10 @@ public List uploadFiles(@RequestPart MultipartFile[] files) { @ApiOperation("通用上传图片") @PostMapping("storage/upload_image") public FileInfo uploadImage(@RequestPart MultipartFile file, - @RequestPart(required = false) Integer width, - @RequestPart(required = false) Integer height, - @RequestPart(required = false) Integer thWidth, - @RequestPart(required = false) Integer thHeight) { + @RequestParam(required = false) Integer width, + @RequestParam(required = false) Integer height, + @RequestParam(required = false) Integer thWidth, + @RequestParam(required = false) Integer thHeight) { UploadPretreatment uploadPretreatment = fileStorageService.of(file); // 根据传入条件设置宽高和缩略 if (!ObjUtil.hasNull(width, height)) { @@ -109,10 +109,10 @@ public FileInfo uploadImage(@RequestPart MultipartFile file, @ApiOperation("通用上传图片-批量") @PostMapping("storage/upload_images") public List uploadImages(@RequestPart MultipartFile[] files, - @RequestPart(required = false) Integer width, - @RequestPart(required = false) Integer height, - @RequestPart(required = false) Integer thWidth, - @RequestPart(required = false) Integer thHeight) { + @RequestParam(required = false) Integer width, + @RequestParam(required = false) Integer height, + @RequestParam(required = false) Integer thWidth, + @RequestParam(required = false) Integer thHeight) { return Arrays.stream(files) .map(o -> uploadImage(o, width, height, thWidth, thHeight)) .collect(Collectors.toList()); From 63630903d56c8d4bc4f74d6fa0247bcfdc2e3255 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 3 Nov 2023 14:30:00 +0800 Subject: [PATCH 150/244] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=20Rabbit?= =?UTF-8?q?AutoConfig=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/mq/config/RabbitAutoConfig.java | 114 +++++++++++------- 1 file changed, 68 insertions(+), 46 deletions(-) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java index fbeb477c..9a2a824d 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java @@ -26,10 +26,10 @@ import org.springframework.boot.context.properties.bind.BindResult; import org.springframework.boot.context.properties.bind.Binder; import org.springframework.context.EnvironmentAware; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.DependsOn; import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; import java.util.Map; @@ -40,65 +40,91 @@ * @since 2023/8/17 */ @Slf4j -@RequiredArgsConstructor @EnableConfigurationProperties(RabbitProperties.class) @Configuration @ConditionalOnProperty(name = "uni-boot.mq.rabbit.enable", havingValue = "true") -public class RabbitAutoConfig implements InitializingBean { - - private final MessageConverter messageConverter; - private final MultiRabbitProperties multiRabbitProperties; - private final SimpleRoutingConnectionFactory multiRabbitConnectionFactory; - private final Map rabbitListenerContainerFactoryMap; +public class RabbitAutoConfig { + + @Bean + public MultiRabbitContainerFactoryConfig multiRabbitContainerFactoryConfig(MessageConverter messageConverter, + MultiRabbitProperties multiRabbitProperties, + SimpleRoutingConnectionFactory multiRabbitConnectionFactory, + Map rabbitListenerContainerFactoryMap) { + return new MultiRabbitContainerFactoryConfig(messageConverter, multiRabbitProperties, multiRabbitConnectionFactory, rabbitListenerContainerFactoryMap); + } - @Override - public void afterPropertiesSet() { - configureContainerFactory(); + @Bean + public MultiRabbitDeclareBeanFactoryPostProcessor multiRabbitDeclareBeanFactoryPostProcessor() { + return new MultiRabbitDeclareBeanFactoryPostProcessor(); } - /** - * 配置 SimpleRabbitListenerContainerFactory - * spring-multirabbit {@link org.springframework.boot.autoconfigure.amqp.MultiRabbitAutoConfiguration} - * 自动配置 SimpleRabbitListenerContainerFactory, 部分配置有缺失,此方法用于补偿 - * 参考 {@link SimpleRabbitListenerContainerFactoryConfigurer} - */ - private void configureContainerFactory() { - multiRabbitProperties.getConnections().forEach((connectionName, props) -> { - MultiRabbitContainerFactoryConfigurer configurer = new MultiRabbitContainerFactoryConfigurer(props.getListener().getSimple()); - configurer.setMessageConverter(messageConverter); - SimpleRabbitListenerContainerFactory containerFactory = rabbitListenerContainerFactoryMap.get(connectionName); - ConnectionFactory targetConnectionFactory = multiRabbitConnectionFactory.getTargetConnectionFactory(connectionName); - configurer.configure(containerFactory, targetConnectionFactory); - }); + @DependsOn(MultiRabbitConstants.CONNECTION_FACTORY_BEAN_NAME) + @Bean + public MultiRabbitContainerBeanPostProcessor multiRabbitContainerBeanPostProcessor() { + return new MultiRabbitContainerBeanPostProcessor(); } /** - * MultiRabbit ContainerFactory 配置器 + * RabbitMQ ContainerFactory 配置 + * 提供对 MultiRabbit 支持 */ @RequiredArgsConstructor - private static class MultiRabbitContainerFactoryConfigurer - extends AbstractRabbitListenerContainerFactoryConfigurer { + public static class MultiRabbitContainerFactoryConfig implements InitializingBean { - private final org.springframework.boot.autoconfigure.amqp.RabbitProperties.SimpleContainer config; + private final MessageConverter messageConverter; + private final MultiRabbitProperties multiRabbitProperties; + private final SimpleRoutingConnectionFactory multiRabbitConnectionFactory; + private final Map rabbitListenerContainerFactoryMap; @Override - public void configure(SimpleRabbitListenerContainerFactory factory, ConnectionFactory connectionFactory) { - PropertyMapper map = PropertyMapper.get(); - configure(factory, connectionFactory, config); - map.from(config::getConcurrency).whenNonNull().to(factory::setConcurrentConsumers); - map.from(config::getMaxConcurrency).whenNonNull().to(factory::setMaxConcurrentConsumers); - map.from(config::getBatchSize).whenNonNull().to(factory::setBatchSize); - map.from(config::isConsumerBatchEnabled).to(factory::setConsumerBatchEnabled); + public void afterPropertiesSet() { + configureContainerFactory(); } - @Override - public void setMessageConverter(MessageConverter messageConverter) { - super.setMessageConverter(messageConverter); + /** + * 配置 SimpleRabbitListenerContainerFactory + * spring-multirabbit {@link org.springframework.boot.autoconfigure.amqp.MultiRabbitAutoConfiguration} + * 自动配置 SimpleRabbitListenerContainerFactory, 部分配置有缺失,此方法用于补偿 + * 参考 {@link SimpleRabbitListenerContainerFactoryConfigurer} + */ + private void configureContainerFactory() { + multiRabbitProperties.getConnections().forEach((connectionName, props) -> { + MultiRabbitContainerFactoryConfigurer configurer = new MultiRabbitContainerFactoryConfigurer(props.getListener().getSimple()); + configurer.setMessageConverter(messageConverter); + SimpleRabbitListenerContainerFactory containerFactory = rabbitListenerContainerFactoryMap.get(connectionName); + ConnectionFactory targetConnectionFactory = multiRabbitConnectionFactory.getTargetConnectionFactory(connectionName); + configurer.configure(containerFactory, targetConnectionFactory); + }); } - @Override - public void setMessageRecoverer(MessageRecoverer messageRecoverer) { - super.setMessageRecoverer(messageRecoverer); + /** + * MultiRabbit ContainerFactory 配置器 + */ + @RequiredArgsConstructor + private static class MultiRabbitContainerFactoryConfigurer + extends AbstractRabbitListenerContainerFactoryConfigurer { + + private final org.springframework.boot.autoconfigure.amqp.RabbitProperties.SimpleContainer config; + + @Override + public void configure(SimpleRabbitListenerContainerFactory factory, ConnectionFactory connectionFactory) { + PropertyMapper map = PropertyMapper.get(); + configure(factory, connectionFactory, config); + map.from(config::getConcurrency).whenNonNull().to(factory::setConcurrentConsumers); + map.from(config::getMaxConcurrency).whenNonNull().to(factory::setMaxConcurrentConsumers); + map.from(config::getBatchSize).whenNonNull().to(factory::setBatchSize); + map.from(config::isConsumerBatchEnabled).to(factory::setConsumerBatchEnabled); + } + + @Override + public void setMessageConverter(MessageConverter messageConverter) { + super.setMessageConverter(messageConverter); + } + + @Override + public void setMessageRecoverer(MessageRecoverer messageRecoverer) { + super.setMessageRecoverer(messageRecoverer); + } } } @@ -107,8 +133,6 @@ public void setMessageRecoverer(MessageRecoverer messageRecoverer) { * 注入的 bean 名称格式为 connectionName_declareName * 使用 {@link org.springframework.amqp.core.Declarable} setAdminsThatShouldDeclare 方法指定 AmqpAdmin bean */ - @Component - @ConditionalOnProperty(name = "uni-boot.mq.rabbit.enable", havingValue = "true") public static class MultiRabbitDeclareBeanFactoryPostProcessor implements BeanFactoryPostProcessor, EnvironmentAware { private Environment environment; @@ -176,8 +200,6 @@ public String getAdminBeanName(String connectionName) { * 导致 getBean 获取对应 RabbitAdmin 实例失败 * 此处使用 @DependsOn 使 multiRabbitConnectionFactory 提前加载 */ - @DependsOn(MultiRabbitConstants.CONNECTION_FACTORY_BEAN_NAME) - @Component public static class MultiRabbitContainerBeanPostProcessor implements BeanPostProcessor { } From 872f7030c5fc384924a98b780f3b39bf81290d46 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 3 Nov 2023 14:41:11 +0800 Subject: [PATCH 151/244] =?UTF-8?q?refactor:=20Spring=20=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=BA=BF=E7=A8=8B=E6=B1=A0=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E7=AD=89=E5=BE=85=E6=97=B6=E9=97=B4=E8=B0=83=E5=88=B0=2030s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/base/config/ThreadPoolConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/ThreadPoolConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/ThreadPoolConfig.java index 182f1e57..a0fa212e 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/ThreadPoolConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/ThreadPoolConfig.java @@ -55,7 +55,7 @@ public ThreadPoolTaskScheduler taskScheduler() { scheduler.setPoolSize(Runtime.getRuntime().availableProcessors()); scheduler.setThreadNamePrefix("taskScheduler-"); scheduler.setWaitForTasksToCompleteOnShutdown(true); - scheduler.setAwaitTerminationSeconds(300); + scheduler.setAwaitTerminationSeconds(30); scheduler.setErrorHandler(throwable -> { log.error("Scheduled task execute fail,", throwable); }); From 03dc96da1caebff461468aab5d1bbf68fd3d24b4 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 3 Nov 2023 16:16:08 +0800 Subject: [PATCH 152/244] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=20AbstractStorageHandler=20=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E6=9B=BF=E4=BB=A3=E6=A1=86=E6=9E=B6=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=20FileRecorder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../storage/config/XFileStorageConfig.java | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/config/XFileStorageConfig.java b/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/config/XFileStorageConfig.java index 848b2f99..515b8b73 100644 --- a/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/config/XFileStorageConfig.java +++ b/common/plugin/storage/src/main/java/com/github/cadecode/uniboot/common/plugin/storage/config/XFileStorageConfig.java @@ -1,12 +1,21 @@ package com.github.cadecode.uniboot.common.plugin.storage.config; +import cn.hutool.core.util.ObjUtil; import com.github.cadecode.uniboot.common.plugin.storage.handler.AbstractStorageHandler; import lombok.RequiredArgsConstructor; -import org.dromara.x.file.storage.core.recorder.FileRecorder; import org.dromara.x.file.storage.spring.EnableFileStorage; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.config.BeanDefinition; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.beans.factory.support.BeanDefinitionRegistry; +import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor; +import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import java.util.Arrays; +import java.util.Optional; + /** * x-file-storage 配置类 * @@ -18,8 +27,39 @@ @Configuration public class XFileStorageConfig { + public static final String BEAN_NAME_FILE_RECORDER = "fileRecorder"; + @Bean - public FileRecorder fileRecorder(AbstractStorageHandler storageRecordHandler) { - return storageRecordHandler; + public FileRecorderBeanDefinitionRegistryPostProcessor fileRecorderBeanDefinitionRegistryPostProcessor() { + return new FileRecorderBeanDefinitionRegistryPostProcessor(); + } + + /** + * 解决自定义 AbstractStorageHandler 不能替代 x-file-storage 框架默认 FileRecorder + */ + public static class FileRecorderBeanDefinitionRegistryPostProcessor implements BeanDefinitionRegistryPostProcessor { + + @Override + public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException { + + } + + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { + String[] handlerBeanNames = beanFactory.getBeanNamesForType(AbstractStorageHandler.class); + // 查找 primary 的,不存在则取第一个 + if (ObjUtil.isNotEmpty(handlerBeanNames)) { + Optional primaryBF = Arrays.stream(handlerBeanNames) + .map(beanFactory::getBeanDefinition) + .filter(BeanDefinition::isPrimary) + .findFirst(); + BeanDefinition handlerBF; + handlerBF = primaryBF.orElseGet(() -> beanFactory.getBeanDefinition(handlerBeanNames[0])); + if (beanFactory instanceof DefaultListableBeanFactory) { + ((DefaultListableBeanFactory) beanFactory).removeBeanDefinition(BEAN_NAME_FILE_RECORDER); + ((DefaultListableBeanFactory) beanFactory).registerBeanDefinition(BEAN_NAME_FILE_RECORDER, handlerBF); + } + } + } } } From 1527c1b5753a218f858c250fe6c29669b8d4e175 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 3 Nov 2023 16:16:58 +0800 Subject: [PATCH 153/244] =?UTF-8?q?Revert=20"fix:=20=E5=BC=95=E5=85=A5=20c?= =?UTF-8?q?ommon-plugin-mq=EF=BC=8C=E8=A7=A3=E5=86=B3=20fileRecorder=20bea?= =?UTF-8?q?n=20=E6=B3=A8=E5=85=A5=E9=A1=BA=E5=BA=8F=E9=97=AE=E9=A2=98"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit e57b933712e21925cd62f692409e37b5024030eb. --- framework/framework_svc/pom.xml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/framework/framework_svc/pom.xml b/framework/framework_svc/pom.xml index 600768d3..84cdc868 100644 --- a/framework/framework_svc/pom.xml +++ b/framework/framework_svc/pom.xml @@ -51,15 +51,11 @@ com.github.cadecode - uni-boot-common-plugin-actuator - - - com.github.cadecode - uni-boot-common-plugin-mq + uni-boot-framework-base com.github.cadecode - uni-boot-framework-base + uni-boot-common-plugin-actuator From 35588417aed1b33e383cab3556fcded9a0e6fb99 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 3 Nov 2023 16:28:27 +0800 Subject: [PATCH 154/244] =?UTF-8?q?build:=20=E5=88=A0=E9=99=A4=E4=B8=8D?= =?UTF-8?q?=E5=BF=85=E8=A6=81=E7=9A=84=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/example_svc/pom.xml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/example/example_svc/pom.xml b/example/example_svc/pom.xml index 59f71dbc..b4ac1d96 100644 --- a/example/example_svc/pom.xml +++ b/example/example_svc/pom.xml @@ -47,15 +47,11 @@ com.github.cadecode - uni-boot-common-plugin-actuator - - - com.github.cadecode - uni-boot-common-plugin-mq + uni-boot-framework-base com.github.cadecode - uni-boot-framework-base + uni-boot-common-plugin-actuator com.github.cadecode From 58384fe8bc2258318fb22c91b697c8d70cd44aba Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 7 Nov 2023 16:03:19 +0800 Subject: [PATCH 155/244] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=20hiddenFlag=20=E5=AD=97=E6=AE=B5=EF=BC=8C=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E7=AE=A1=E7=90=86=E5=86=85=E9=83=A8=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/svc/bean/po/SysMenu.java | 6 ++++++ .../uniboot/framework/svc/bean/vo/SysMenuVo.java | 9 +++++++-- .../src/main/resources/mapper/SysMenuMapper.xml | 12 +++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysMenu.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysMenu.java index acfc57ec..a7b8fa64 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysMenu.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/po/SysMenu.java @@ -72,6 +72,12 @@ public class SysMenu { @TableField(typeHandler = BoolToIntTypeHandler.class) private Boolean enableFlag; + /** + * 是否隐藏(用于内部路由) + */ + @TableField(typeHandler = BoolToIntTypeHandler.class) + private Boolean hiddenFlag; + @TableField(fill = FieldFill.INSERT) private Date createTime; diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysMenuVo.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysMenuVo.java index 612bc824..d56bd2a6 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysMenuVo.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/bean/vo/SysMenuVo.java @@ -26,6 +26,7 @@ public static class SysMenuRolesReqVo extends PageParams { private List roleIdList; private Boolean enableFlag; private Long parentId; + private Boolean hiddenFlag; } @Data @@ -49,7 +50,6 @@ public static class SysMenuUpdateReqVo { @NotEmpty private String menuName; private String icon; - @NotNull private Integer orderNum; } @@ -66,10 +66,11 @@ public static class SysMenuAddReqVo { @NotNull private Boolean leafFlag; private String icon; - @NotNull private Integer orderNum; @NotNull private Boolean enableFlag; + @NotNull + private Boolean hiddenFlag; } @Data @@ -88,6 +89,8 @@ public static class SysMenuTreeResVo { private Boolean leafFlag; + private Boolean hiddenFlag; + private String icon; private List children = new ArrayList<>(); @@ -115,6 +118,8 @@ public static class SysMenuRolesResVo { private Boolean enableFlag; + private Boolean hiddenFlag; + private List roles; private Date createTime; diff --git a/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml b/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml index 79771e40..3332c428 100644 --- a/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/SysMenuMapper.xml @@ -53,6 +53,9 @@ AND sm.enable_flag = #{req.enableFlag, typeHandler=BoolToIntTypeHandler} + + AND sm.hidden_flag = #{req.hiddenFlag, typeHandler=BoolToIntTypeHandler} + AND sr.id in ( @@ -63,7 +66,14 @@ GROUP BY sm.id, sm.order_num, sm.create_time - ORDER BY sm.order_num + + + ORDER BY sm.create_time DESC + + + ORDER BY sm.order_num + + - SELECT su.*, JSON_ARRAYAGG(sr.code) r_code + SELECT su.*, JSON_ARRAYAGG(sr.code) r_code, sd.dept_name d_dept_name FROM sys_user su LEFT JOIN sys_role_user sru ON sru.user_id = su.id LEFT JOIN sys_role sr ON sru.role_id = sr.id + LEFT JOIN sys_dept sd ON sd.id = su.dept_id WHERE su.id IN ( @@ -33,18 +37,20 @@ ORDER BY su.create_time DESC + SELECT sa.*, JSON_ARRAYAGG(sr.code) r_code + FROM sys_api sa + LEFT JOIN sys_role_api sra ON sra.api_id = sa.id + LEFT JOIN sys_role sr ON sra.role_id = sr.id + + WHERE sa.id IN ( + + #{apiId} + + ) + + GROUP BY sa.id, sa.url, sa.description, sa.create_time, sa.update_time, sa.update_user + ORDER BY sa.url + + + diff --git a/framework/framework_svc/src/main/resources/mapper/oracle/SysMenuMapper.xml b/framework/framework_svc/src/main/resources/mapper/oracle/SysMenuMapper.xml new file mode 100644 index 00000000..47da0919 --- /dev/null +++ b/framework/framework_svc/src/main/resources/mapper/oracle/SysMenuMapper.xml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/framework/framework_svc/src/main/resources/mapper/oracle/SysRoleMapper.xml b/framework/framework_svc/src/main/resources/mapper/oracle/SysRoleMapper.xml new file mode 100644 index 00000000..0c91bd51 --- /dev/null +++ b/framework/framework_svc/src/main/resources/mapper/oracle/SysRoleMapper.xml @@ -0,0 +1,187 @@ + + + + + + + + + + + + + + + + + + + + + DELETE FROM sys_role_user ru + WHERE ru.user_id IN ( + + #{id} + + ) + + + DELETE FROM sys_role_user ru + WHERE ru.role_id IN ( + + #{id} + + ) + + + DELETE FROM sys_role_menu rm + WHERE rm.menu_id IN ( + + #{id} + + ) + + + DELETE FROM sys_role_menu rm + WHERE rm.role_id IN ( + + #{id} + + ) + + + DELETE FROM sys_role_api ra + WHERE ra.api_id IN ( + + #{id} + + ) + + + DELETE FROM sys_role_api ra + WHERE ra.role_id IN ( + + #{id} + + ) + + + DELETE FROM sys_role_user ru + WHERE (ru.user_id, ru.role_id) IN ( + + (#{el.id}, #{el.roleId}) + + ) + + + DELETE FROM sys_role_menu rm + WHERE (rm.menu_id, rm.role_id) IN ( + + (#{el.id}, #{el.roleId}) + + ) + + + DELETE FROM sys_role_api ra + WHERE (ra.api_id, ra.role_id) IN ( + + (#{el.id}, #{el.roleId}) + + ) + + + INSERT INTO sys_role_user (user_id, role_id) + VALUES + + (#{el.id}, #{el.roleId}) + + + + INSERT INTO sys_role_menu (menu_id, role_id) + VALUES + + (#{el.id}, #{el.roleId}) + + + + INSERT INTO sys_role_api (api_id, role_id) + VALUES + + (#{el.id}, #{el.roleId}) + + + + diff --git a/framework/framework_svc/src/main/resources/mapper/oracle/SysUserMapper.xml b/framework/framework_svc/src/main/resources/mapper/oracle/SysUserMapper.xml new file mode 100644 index 00000000..abaee8d4 --- /dev/null +++ b/framework/framework_svc/src/main/resources/mapper/oracle/SysUserMapper.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + From 2846dd7a118fadbac83b269fc679d42d3e86b15e Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 12 Dec 2023 12:14:31 +0800 Subject: [PATCH 198/244] =?UTF-8?q?docs:=20=E7=BB=B4=E6=8A=A4=20oracle=20?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=20SQL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sql/{ => common/mysql}/common-plugin.sql | 0 .../common/oracle/common-plugin.oracle.sql | 174 ++++++++++ .docs/sql/framework/{ => mysql}/data.sql | 0 .docs/sql/framework/{ => mysql}/schema.sql | 0 .docs/sql/framework/oracle/data.oracle.sql | 299 ++++++++++++++++++ .docs/sql/framework/oracle/schema.orace.sql | 228 +++++++++++++ .docs/sql/{ => other}/nacos_v1.4.6.sql | 0 .docs/sql/{ => other}/xxl-job_v2.4.0.sql | 0 8 files changed, 701 insertions(+) rename .docs/sql/{ => common/mysql}/common-plugin.sql (100%) create mode 100644 .docs/sql/common/oracle/common-plugin.oracle.sql rename .docs/sql/framework/{ => mysql}/data.sql (100%) rename .docs/sql/framework/{ => mysql}/schema.sql (100%) create mode 100644 .docs/sql/framework/oracle/data.oracle.sql create mode 100644 .docs/sql/framework/oracle/schema.orace.sql rename .docs/sql/{ => other}/nacos_v1.4.6.sql (100%) rename .docs/sql/{ => other}/xxl-job_v2.4.0.sql (100%) diff --git a/.docs/sql/common-plugin.sql b/.docs/sql/common/mysql/common-plugin.sql similarity index 100% rename from .docs/sql/common-plugin.sql rename to .docs/sql/common/mysql/common-plugin.sql diff --git a/.docs/sql/common/oracle/common-plugin.oracle.sql b/.docs/sql/common/oracle/common-plugin.oracle.sql new file mode 100644 index 00000000..39c3fee0 --- /dev/null +++ b/.docs/sql/common/oracle/common-plugin.oracle.sql @@ -0,0 +1,174 @@ +-- ----------- +-- 通用日志表 +-- ----------- +CREATE TABLE plg_log +( + id NUMBER(19), + log_type VARCHAR2(50) NOT NULL, + url VARCHAR2(500) NULL, + exceptional NUMBER(3) NOT NULL, + access_user VARCHAR2(100) NULL, + description VARCHAR2(1000) NULL, + class_method VARCHAR2(500) NOT NULL, + thread_id VARCHAR2(100) NULL, + thread_name VARCHAR2(500) NULL, + ip VARCHAR2(50) NULL, + http_method VARCHAR2(50) NULL, + request_params CLOB NULL, + result CLOB NULL, + time_cost NUMBER(19) NULL, + os VARCHAR2(200) NULL, + browser VARCHAR2(200) NULL, + user_agent VARCHAR2(500) NULL, + trace_id VARCHAR2(100) NULL, + + create_time TIMESTAMP(0) DEFAULT SYSTIMESTAMP, + update_time TIMESTAMP(0) DEFAULT NULL, + update_user VARCHAR2(100) NULL, + PRIMARY KEY (id) +) +; + +COMMENT ON TABLE plg_log IS '通用日志表'; + +COMMENT ON COLUMN plg_log.log_type IS 'log 类型'; +COMMENT ON COLUMN plg_log.url IS 'URL'; +COMMENT ON COLUMN plg_log.exceptional IS '是否异常'; +COMMENT ON COLUMN plg_log.access_user IS '访问者'; +COMMENT ON COLUMN plg_log.description IS '描述'; +COMMENT ON COLUMN plg_log.class_method IS '方法名'; +COMMENT ON COLUMN plg_log.thread_id IS '线程 ID'; +COMMENT ON COLUMN plg_log.thread_name IS '线程名'; +COMMENT ON COLUMN plg_log.ip IS 'IP'; +COMMENT ON COLUMN plg_log.http_method IS 'HTTP 方法'; +COMMENT ON COLUMN plg_log.request_params IS '参数'; +COMMENT ON COLUMN plg_log.result IS '结果'; +COMMENT ON COLUMN plg_log.time_cost IS '接口耗时'; +COMMENT ON COLUMN plg_log.os IS '操作系统'; +COMMENT ON COLUMN plg_log.browser IS '浏览器'; +COMMENT ON COLUMN plg_log.user_agent IS 'user-agent'; +COMMENT ON COLUMN plg_log.trace_id IS 'trace-id'; + +CREATE INDEX idx_plg_log_create_time ON plg_log (create_time); +CREATE INDEX idx_plg_log_log_type ON plg_log (log_type); +CREATE INDEX idx_plg_log_url ON plg_log (url); +CREATE INDEX idx_plg_log_access_user ON plg_log (access_user); + +-- ----------- +-- 消息记录表 +-- ----------- +CREATE TABLE plg_mq_msg +( + id NUMBER(19), + biz_type VARCHAR2(200) NULL, + biz_key VARCHAR2(200) NULL, + exchange VARCHAR2(200) NOT NULL, + routing_key VARCHAR2(200) NOT NULL, + connection_name VARCHAR2(200) NULL, + message CLOB NOT NULL, + send_state VARCHAR2(100) NULL, + consume_state VARCHAR2(100) NULL, + next_retry_time TIMESTAMP(0) NULL, + cause CLOB NULL, + left_retry_times NUMBER(10) NULL, + max_retry_times NUMBER(10) NULL, + backoff_init_interval NUMBER(19) CHECK (backoff_init_interval > 0) NULL, + backoff_multiplier BINARY_DOUBLE NULL, + backoff_max_interval NUMBER(19) CHECK (backoff_max_interval > 0) NULL, + + create_time TIMESTAMP(0) DEFAULT SYSTIMESTAMP, + update_time TIMESTAMP(0) DEFAULT NULL, + update_user VARCHAR2(100) NULL, + PRIMARY KEY (id) +) +; + +COMMENT ON TABLE plg_mq_msg IS '消息记录表'; + +COMMENT ON COLUMN plg_mq_msg.biz_type IS '业务类型'; +COMMENT ON COLUMN plg_mq_msg.biz_key IS '业务键'; +COMMENT ON COLUMN plg_mq_msg.exchange IS '交换机'; +COMMENT ON COLUMN plg_mq_msg.routing_key IS '路由 key'; +COMMENT ON COLUMN plg_mq_msg.connection_name IS '连接名称'; +COMMENT ON COLUMN plg_mq_msg.message IS '消息内容'; +COMMENT ON COLUMN plg_mq_msg.send_state IS '发送方状态'; +COMMENT ON COLUMN plg_mq_msg.consume_state IS '消费方状态'; +COMMENT ON COLUMN plg_mq_msg.next_retry_time IS '下次重试时间'; +COMMENT ON COLUMN plg_mq_msg.cause IS '重试原因'; +COMMENT ON COLUMN plg_mq_msg.left_retry_times IS '剩余重试次数'; +COMMENT ON COLUMN plg_mq_msg.max_retry_times IS '最大重试次数'; +COMMENT ON COLUMN plg_mq_msg.backoff_init_interval IS '退避-初始时间间隔'; +COMMENT ON COLUMN plg_mq_msg.backoff_multiplier IS '退避-乘子'; +COMMENT ON COLUMN plg_mq_msg.backoff_max_interval IS '退避-最大时间间隔'; + +CREATE INDEX idx_plg_mq_msg_create_time ON plg_mq_msg (create_time, send_state); +CREATE INDEX idx_plg_mq_msg_next_retry_time ON plg_mq_msg (next_retry_time, send_state, left_retry_times); +CREATE INDEX idx_plg_mq_msg_biz_type ON plg_mq_msg (biz_type); +CREATE INDEX idx_plg_mq_msg_send_state ON plg_mq_msg (send_state); + +-- ----------- +-- 文件记录表 +-- ----------- +CREATE TABLE plg_file +( + id NUMBER(19), + url varchar2(512) NOT NULL, + "SIZE" number(19) NULL, + filename varchar2(256) NULL, + original_filename varchar2(256) NULL, + base_path varchar2(256) NULL, + path varchar2(256) NULL, + ext varchar2(32) NULL, + content_type varchar2(128) NULL, + platform varchar2(32) NULL, + th_url varchar2(512) NULL, + th_filename varchar2(256) NULL, + th_size number(19) NULL, + th_content_type varchar2(128) NULL, + object_id varchar2(32) NULL, + object_type varchar2(32) NULL, + metadata clob NULL, + user_metadata clob NULL, + th_metadata clob NULL, + th_user_metadata clob NULL, + attr clob NULL, + file_acl varchar2(32) NULL, + th_file_acl varchar2(32) NULL, + + create_time TIMESTAMP(0) DEFAULT SYSTIMESTAMP, + update_time TIMESTAMP(0) DEFAULT NULL, + update_user VARCHAR2(100) NULL, + PRIMARY KEY (id) +) +; + +COMMENT ON TABLE plg_file IS '文件记录表'; + +COMMENT ON COLUMN plg_file.url IS '文件访问地址'; +COMMENT ON COLUMN plg_file."SIZE" IS '文件大小,单位字节'; +COMMENT ON COLUMN plg_file.filename IS '文件名称'; +COMMENT ON COLUMN plg_file.original_filename IS '原始文件名'; +COMMENT ON COLUMN plg_file.base_path IS '基础存储路径'; +COMMENT ON COLUMN plg_file.path IS '存储路径'; +COMMENT ON COLUMN plg_file.ext IS '文件扩展名'; +COMMENT ON COLUMN plg_file.content_type IS 'MIME类型'; +COMMENT ON COLUMN plg_file.platform IS '存储平台'; +COMMENT ON COLUMN plg_file.th_url IS '缩略图访问路径'; +COMMENT ON COLUMN plg_file.th_filename IS '缩略图名称'; +COMMENT ON COLUMN plg_file.th_size IS '缩略图大小,单位字节'; +COMMENT ON COLUMN plg_file.th_content_type IS '缩略图MIME类型'; +COMMENT ON COLUMN plg_file.object_id IS '文件所属对象id'; +COMMENT ON COLUMN plg_file.object_type IS '文件所属对象类型,例如用户头像,评价图片'; +COMMENT ON COLUMN plg_file.metadata IS '文件元数据'; +COMMENT ON COLUMN plg_file.user_metadata IS '文件用户元数据'; +COMMENT ON COLUMN plg_file.th_metadata IS '缩略图元数据'; +COMMENT ON COLUMN plg_file.th_user_metadata IS '缩略图用户元数据'; +COMMENT ON COLUMN plg_file.attr IS '附加属性'; +COMMENT ON COLUMN plg_file.file_acl IS '文件ACL'; +COMMENT ON COLUMN plg_file.th_file_acl IS '缩略图文件ACL'; + +CREATE INDEX idx_plg_file_url ON plg_file (url); +CREATE INDEX idx_plg_file_filename ON plg_file (filename); +CREATE INDEX idx_plg_file_platform_url ON plg_file (platform, url); +CREATE INDEX idx_plg_file_object_id ON plg_file (object_id); +CREATE INDEX idx_plg_file_object_type_id ON plg_file (object_type, object_id); diff --git a/.docs/sql/framework/data.sql b/.docs/sql/framework/mysql/data.sql similarity index 100% rename from .docs/sql/framework/data.sql rename to .docs/sql/framework/mysql/data.sql diff --git a/.docs/sql/framework/schema.sql b/.docs/sql/framework/mysql/schema.sql similarity index 100% rename from .docs/sql/framework/schema.sql rename to .docs/sql/framework/mysql/schema.sql diff --git a/.docs/sql/framework/oracle/data.oracle.sql b/.docs/sql/framework/oracle/data.oracle.sql new file mode 100644 index 00000000..c181ca26 --- /dev/null +++ b/.docs/sql/framework/oracle/data.oracle.sql @@ -0,0 +1,299 @@ +-- 导入初始数据 + +-- ---------------------------- +-- 插入用户 +-- 密码使用 BCryptPasswordEncoder 生成,此处123456 +-- ---------------------------- +INSERT INTO sys_user (id, username, password, nick_name, dept_id, enable_flag) +VALUES (1, 'admin', '$2a$10$mQJ9z.l0FW.pUSJ0BnrkjeMHrGJs96oGY3mzB1HZGSAvFgHoo2k1O', '管理员', 1, '1'); +INSERT INTO sys_user (id, username, password, nick_name, dept_id, enable_flag) +VALUES (2, 'manager01', '$2a$10$mQJ9z.l0FW.pUSJ0BnrkjeMHrGJs96oGY3mzB1HZGSAvFgHoo2k1O', '高级用户01', 1, '1'); +INSERT INTO sys_user (id, username, password, nick_name, dept_id, enable_flag) +VALUES (3, 'user01', '$2a$10$mQJ9z.l0FW.pUSJ0BnrkjeMHrGJs96oGY3mzB1HZGSAvFgHoo2k1O', '普通用户01', 1, '1'); +-- ---------------------------- +-- 插入角色 +-- ---------------------------- +INSERT INTO sys_role (id, code, name, description) +VALUES (1, 'admin', '管理员用户', '管理员权限'); +INSERT INTO sys_role (id, code, name, description) +VALUES (2, 'manager', '高级用户', '高级用户权限'); +INSERT INTO sys_role (id, code, name, description) +VALUES (3, 'normal', '普通用户', '普通用户权限'); +-- ---------------------------- +-- 插入菜单 +-- ---------------------------- +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (1, null, 'DemoHome', '/home/demo_home', '/Home/DemoHome', '首页', 1, 'el-icon-s-home', 1, 1, 0, 0, + TO_DATE('2023-08-18 15:03:26', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 16:44:14', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (2, null, 'System', '/system', '/system', '系统管理', 0, 'el-icon-setting', 2, 1, 0, 0, + TO_DATE('2023-08-18 15:03:26', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 16:28:48', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (3, null, 'DevelopManagement', '/develop', '/develop', '开发管理', 0, 'el-icon-s-platform', 3, 1, 0, 0, + TO_DATE('2023-08-18 15:03:29', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 16:45:10', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (201, 2, 'UserManagement', '/system/user', '/System/User', '用户管理', 1, null, 201, 1, 0, 0, + TO_DATE('2023-08-18 15:03:27', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 16:44:52', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (202, 2, 'RoleManagement', '/system/role', '/System/Role', '角色管理', 1, null, 202, 1, 0, 0, + TO_DATE('2023-08-18 15:03:27', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 16:44:55', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (203, 2, 'MenuManagement', '/system/menu', '/System/Menu', '菜单管理', 1, null, 203, 1, 0, 0, + TO_DATE('2023-08-18 15:03:28', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 16:44:59', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (204, 2, 'DeptManagement', '/system/dept', '/System/Dept', '部门管理', 1, null, 204, 1, 0, 0, + TO_DATE('2023-11-25 09:46:20', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-26 10:05:19', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (205, 2, 'ApiManagement', '/system/api', '/System/Api', 'API管理', 1, null, 205, 1, 0, 0, + TO_DATE('2023-08-18 15:03:28', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-26 10:05:19', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (206, 2, 'DictManagement', '/system/dict', '/System/Dict', '字典管理', 1, null, 206, 1, 0, 0, + TO_DATE('2023-08-18 15:03:29', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-26 10:05:19', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (301, 3, 'LogManagement', '/develop/log', '/Develop/Log', '日志管理', 1, null, 301, 1, 0, 0, + TO_DATE('2023-08-18 15:03:30', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 16:45:14', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (302, 3, 'MqMsgManagement', '/develop/mq_msg', '/Develop/MqMsg', '消息队列', 1, null, 302, 1, 0, 0, + TO_DATE('2023-08-22 23:23:46', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 16:45:31', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (303, 3, 'FileManagement', '/develop/file', '/Develop/File', '文件管理', 1, null, 303, 1, 0, 0, + TO_DATE('2023-08-22 23:23:46', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 16:45:44', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (306, 3, 'Icon', '/develop/icon', '/Develop/Icon', '图标', 1, null, 306, 1, 0, 0, + TO_DATE('2023-08-18 15:03:30', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 15:57:56', 'yyyy-MM-dd HH24:mi:ss'), null); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (307, 3, 'EchartsDemo', '/develop/echarts', '/Develop/Echarts', 'Echarts 示例', 1, null, 307, 1, 0, 0, + TO_DATE('2023-08-18 15:03:30', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 16:46:04', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (308, 3, 'Swagger', 'http://localhost:8000/doc.html', null, 'Swagger', 1, null, 308, 1, 0, 0, + TO_DATE('2023-08-18 15:03:30', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 15:57:55', 'yyyy-MM-dd HH24:mi:ss'), null); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (1000, null, 'GithubUrl', 'https://github.com/cadecode/uni-boot-admin', null, '源码仓库', 1, 'el-icon-star-on', + 1000, 0, 0, 0, TO_DATE('2023-08-18 15:03:31', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 15:57:55', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_menu (id, parent_id, route_name, route_path, component_path, menu_name, leaf_flag, icon, order_num, + enable_flag, hidden_flag, cache_flag, create_time, update_time, update_user) +VALUES (1001, null, 'UserCenter', '/user_center', '/UserCenter', '个人中心', 1, null, null, 1, 1, 0, + TO_DATE('2023-11-07 15:54:25', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-11-09 17:57:17', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); + +-- ---------------------------- +-- 插入 API +-- ---------------------------- +INSERT INTO sys_api(id, url, description) +VALUES (1, '/**', '默认放通全部接口'); +-- ---------------------------- +-- 插入角色用户关系 +-- ---------------------------- +INSERT INTO sys_role_user (role_id, user_id) +VALUES (1, 1); +INSERT INTO sys_role_user (role_id, user_id) +VALUES (2, 2); +INSERT INTO sys_role_user (role_id, user_id) +VALUES (3, 3); +-- ---------------------------- +-- 插入角色菜单关系 +-- ---------------------------- +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 1); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 2); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 3); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 201); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 202); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 203); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 204); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 205); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 206); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 301); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 302); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 303); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 306); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 307); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 308); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 309); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 1000); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (1, 1001); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (2, 1); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (2, 2); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (2, 201); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (2, 202); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (2, 203); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (2, 204); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (2, 205); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (2, 206); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (2, 1000); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (2, 1001); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (3, 1); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (3, 1000); +INSERT INTO sys_role_menu (role_id, menu_id) +VALUES (3, 1001); + +-- ---------------------------- +-- 插入角色API关系 +-- ---------------------------- +INSERT INTO sys_role_api (role_id, api_id) +VALUES (1, 1); +INSERT INTO sys_role_api (role_id, api_id) +VALUES (2, 1); +INSERT INTO sys_role_api (role_id, api_id) +VALUES (3, 1); +-- ---------------------------- +-- 插入字典 +-- ---------------------------- +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (1, '日志类型', 'logType', '查询', 'Query', '日志类型-查询', 0, 0, + TO_DATE('2023-06-11 23:24:26', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-06-12 00:11:57', 'yyyy-MM-dd HH24:mi:ss'), + 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (2, '日志类型', 'logType', '删除', 'Remove', '日志类型-删除', 1, 0, + TO_DATE('2023-06-11 23:24:52', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-06-12 00:12:01', 'yyyy-MM-dd HH24:mi:ss'), + 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (3, '日志类型', 'logType', '更新', 'Update', '日志类型-更新', 2, 0, + TO_DATE('2023-06-11 23:25:08', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-06-12 00:12:05', 'yyyy-MM-dd HH24:mi:ss'), + 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (4, '日志类型', 'logType', '添加', 'Add', '日志类型-添加', 3, 0, + TO_DATE('2023-06-11 23:25:29', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-06-12 00:12:09', 'yyyy-MM-dd HH24:mi:ss'), + 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (5, '日志类型', 'logType', '鉴权', 'Auth', '日志类型-鉴权', 4, 0, + TO_DATE('2023-06-11 23:25:45', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-06-12 00:12:15', 'yyyy-MM-dd HH24:mi:ss'), + 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (6, '日志类型', 'logType', '导入', 'Import', '日志类型-导入', 5, 0, + TO_DATE('2023-06-11 23:25:58', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-06-12 00:12:19', 'yyyy-MM-dd HH24:mi:ss'), + 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (7, '日志类型', 'logType', '导出', 'Export', '日志类型-导出', 6, 0, + TO_DATE('2023-06-11 23:26:09', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-06-12 00:12:30', 'yyyy-MM-dd HH24:mi:ss'), + 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (8, '日志类型', 'logType', '上传', 'Upload', '日志类型-上传', 7, 0, + TO_DATE('2023-06-11 23:26:26', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-06-12 00:12:35', 'yyyy-MM-dd HH24:mi:ss'), + 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (9, '日志类型', 'logType', '下载', 'Download', '日志类型-下载', 8, 0, + TO_DATE('2023-06-11 23:26:40', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-06-12 00:12:40', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (10, '日志类型', 'logType', '其他', 'Other', '日志类型-其他', 9, 0, + TO_DATE('2023-06-11 23:26:49', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-06-12 00:52:14', 'yyyy-MM-dd HH24:mi:ss'), + 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (11, '服务URL', 'serviceUrl', '框架服务', '/framework', 'framework 服务 url 前缀', 1, 1, + TO_DATE('2023-08-18 15:09:16', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-08-24 10:20:50', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (12, '服务URL', 'serviceUrl', '示例服务', '/example', 'example 服务 url 前缀', 2, 0, + TO_DATE('2023-08-18 15:09:30', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-08-24 10:20:51', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (13, 'MQ消息发送状态', 'mqMsgSendState', '处理中', 'PREPARING', 'MQ 消息发送中', 1, 1, + TO_DATE('2023-08-22 23:25:52', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-08-24 10:20:50', 'yyyy-MM-dd HH24:mi:ss'), 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (14, 'MQ消息发送状态', 'mqMsgSendState', '失败', 'FAIL', 'MQ 消息发送失败', 2, 1, + TO_DATE('2023-08-22 23:26:04', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-08-24 10:20:51', 'yyyy-MM-dd HH24:mi:ss'), + 'admin'); +INSERT INTO sys_dict (id, name, type, label, value, description, order_num, default_flag, create_time, + update_time, update_user) +VALUES (15, 'MQ消息发送状态', 'mqMsgSendState', '完成', 'OVER', 'MQ 消息发送完成', 3, 0, + TO_DATE('2023-08-22 23:26:10', 'yyyy-MM-dd HH24:mi:ss'), + TO_DATE('2023-08-24 10:20:50', 'yyyy-MM-dd HH24:mi:ss'), + 'admin'); +-- ---------------------------- +-- 插入部门 +-- ---------------------------- +INSERT INTO sys_dept (id, dept_name, parent_id, order_num, leader, mail, phone, create_time, update_time, update_user) +VALUES (1, '测试部门1', null, 1, '张三', 'test1@mail.com', '123456', + TO_DATE('2023-11-26 08:34:19', 'yyyy-MM-dd HH24:mi:ss'), null, 'admin'); +INSERT INTO sys_dept (id, dept_name, parent_id, order_num, leader, mail, phone, create_time, update_time, update_user) +VALUES (2, '测试部门2', null, 2, '', null, '', TO_DATE('2023-11-26 08:35:04', 'yyyy-MM-dd HH24:mi:ss'), null, 'admin'); +INSERT INTO sys_dept (id, dept_name, parent_id, order_num, leader, mail, phone, create_time, update_time, update_user) +VALUES (11, '测试科室1-1', 1, 11, '', null, '', TO_DATE('2023-11-26 08:34:53', 'yyyy-MM-dd HH24:mi:ss'), null, 'admin'); + diff --git a/.docs/sql/framework/oracle/schema.orace.sql b/.docs/sql/framework/oracle/schema.orace.sql new file mode 100644 index 00000000..cb00624f --- /dev/null +++ b/.docs/sql/framework/oracle/schema.orace.sql @@ -0,0 +1,228 @@ +-- 基本表结构 + +-- ----------- +-- 系统用户表 +-- ----------- +CREATE TABLE sys_user +( + id NUMBER(19), + username VARCHAR2(50) NOT NULL, + password VARCHAR2(100) NOT NULL, + nick_name VARCHAR2(50) NOT NULL, + dept_id NUMBER(19), + enable_flag NUMBER(3) NOT NULL, + sex CHAR(1) null, + mail VARCHAR2(50) null, + phone VARCHAR2(50) null, + login_ip VARCHAR2(50) null, + login_date TIMESTAMP(0) null, + + create_time TIMESTAMP(0) DEFAULT SYSTIMESTAMP, + update_time TIMESTAMP(0) DEFAULT NULL, + update_user VARCHAR2(100) NULL, + PRIMARY KEY (id), + CONSTRAINT uk_sys_user_username UNIQUE (username) +) +; + +COMMENT ON TABLE sys_user IS '系统用户表'; + +COMMENT ON COLUMN sys_user.username IS '用户名'; +COMMENT ON COLUMN sys_user.password IS '密码'; +COMMENT ON COLUMN sys_user.nick_name IS '昵称'; +COMMENT ON COLUMN sys_user.dept_id IS '部门ID'; +COMMENT ON COLUMN sys_user.enable_flag IS '是否启用'; +comment on column sys_user.sex is '性别'; +comment on column sys_user.mail is '邮箱'; +comment on column sys_user.phone is '电话'; +comment on column sys_user.login_ip is '登录IP'; +comment on column sys_user.login_date is '登录时间'; + +CREATE INDEX idx_sys_user_nick_name ON sys_user (nick_name); +CREATE INDEX idx_sys_user_dept_id ON sys_user (dept_id); +-- ----------- +-- 系统角色表 +-- ----------- +CREATE TABLE sys_role +( + id NUMBER(19), + code VARCHAR2(50) NOT NULL, + name VARCHAR2(50) NOT NULL, + description VARCHAR2(100), + create_time TIMESTAMP(0) DEFAULT SYSTIMESTAMP, + update_time TIMESTAMP(0) DEFAULT NULL, + update_user VARCHAR2(100) NULL, + PRIMARY KEY (id), + CONSTRAINT uk_sys_role_code UNIQUE (code) +) +; + +COMMENT ON TABLE sys_role IS '系统角色表'; + +COMMENT ON COLUMN sys_role.code IS '角色代码'; +COMMENT ON COLUMN sys_role.name IS '角色名称'; +COMMENT ON COLUMN sys_role.description IS '角色描述'; +-- ----------- +-- 系统菜单表 +-- ----------- +CREATE TABLE sys_menu +( + id NUMBER(19), + parent_id NUMBER(19), + route_name VARCHAR2(100) NOT NULL, + route_path CLOB NOT NULL, + component_path CLOB NULL, + menu_name VARCHAR2(100) NOT NULL, + leaf_flag NUMBER(3) NOT NULL, + icon CLOB NULL, + order_num NUMBER(10) NULL, + enable_flag NUMBER(3) NOT NULL, + hidden_flag NUMBER(3) NOT NULL, + cache_flag NUMBER(3) NOT NULL, + + create_time TIMESTAMP(0) DEFAULT SYSTIMESTAMP, + update_time TIMESTAMP(0) DEFAULT NULL, + update_user VARCHAR2(100) NULL, + PRIMARY KEY (id), + CONSTRAINT uk_sys_menu_route_name UNIQUE (route_name) +) +; + +COMMENT ON TABLE sys_menu IS '系统菜单表'; + +COMMENT ON COLUMN sys_menu.route_name IS '路由名称'; +COMMENT ON COLUMN sys_menu.route_path IS '路由路径'; +COMMENT ON COLUMN sys_menu.component_path IS '组件路径'; +COMMENT ON COLUMN sys_menu.menu_name IS '菜单名称'; +COMMENT ON COLUMN sys_menu.leaf_flag IS '是否页面'; +COMMENT ON COLUMN sys_menu.icon IS '图标'; +COMMENT ON COLUMN sys_menu.order_num IS '排序'; +COMMENT ON COLUMN sys_menu.enable_flag IS '是否启用'; +COMMENT ON COLUMN sys_menu.hidden_flag IS '是否隐藏(内部路由)'; +COMMENT ON COLUMN sys_menu.cache_flag IS '是否启用页面缓存'; +-- ----------- +-- 系统权限表 +-- ----------- +CREATE TABLE sys_api +( + id NUMBER(19), + url VARCHAR2(50) NOT NULL, + description VARCHAR2(100), + create_time TIMESTAMP(0) DEFAULT SYSTIMESTAMP, + update_time TIMESTAMP(0) DEFAULT NULL, + update_user VARCHAR2(100) NULL, + PRIMARY KEY (id), + CONSTRAINT uk_sys_api_url UNIQUE (url) +) +; + +COMMENT ON TABLE sys_api IS '系统权限表'; + +COMMENT ON COLUMN sys_api.url IS '接口路径'; +COMMENT ON COLUMN sys_api.description IS '接口描述'; +-- ----------- +-- 角色用户关系表 +-- ----------- +CREATE TABLE sys_role_user +( + role_id NUMBER(19), + user_id NUMBER(19), + PRIMARY KEY (role_id, user_id) +) +; + +COMMENT ON TABLE sys_role_user IS '角色用户关系表'; + +CREATE INDEX idx_sys_role_user_user_id ON sys_role_user (user_id); +-- ----------- +-- 角色权限关系表 +-- ----------- +CREATE TABLE sys_role_api +( + role_id NUMBER(19), + api_id NUMBER(19) NOT NULL, + PRIMARY KEY (role_id, api_id) +) +; + +COMMENT ON TABLE sys_role_api IS '角色权限关系表'; + +CREATE INDEX idx_sys_role_api_api_id ON sys_role_api (api_id); +-- ----------- +-- 角色菜单关系表 +-- ----------- +CREATE TABLE sys_role_menu +( + role_id NUMBER(19), + menu_id NUMBER(19), + PRIMARY KEY (role_id, menu_id) +) +; + +COMMENT ON TABLE sys_role_menu IS '角色菜单关系表'; + +CREATE INDEX idx_sys_role_menu_api_id ON sys_role_menu (menu_id); +-- ----------- +-- 系统字典表 +-- ----------- +CREATE TABLE sys_dict +( + id NUMBER(19), + name VARCHAR2(500) NOT NULL, + type VARCHAR2(500) NOT NULL, + label VARCHAR2(500) NULL, + value CLOB NULL, + description VARCHAR2(1000) NULL, + order_num NUMBER(10) NULL, + default_flag NUMBER(3) NOT NULL, + + create_time TIMESTAMP(0) DEFAULT SYSTIMESTAMP, + update_time TIMESTAMP(0) DEFAULT NULL, + update_user VARCHAR2(100) NULL, + PRIMARY KEY (id) +) +; + +COMMENT ON TABLE sys_dict IS '系统字典表'; + +COMMENT ON COLUMN sys_dict.name IS '字典名称'; +COMMENT ON COLUMN sys_dict.type IS '字典类型'; +COMMENT ON COLUMN sys_dict.label IS '字典标签'; +COMMENT ON COLUMN sys_dict.value IS '字典值'; +COMMENT ON COLUMN sys_dict.description IS '描述'; +COMMENT ON COLUMN sys_dict.order_num IS '排序'; +COMMENT ON COLUMN sys_dict.default_flag IS '是否默认值'; + +CREATE INDEX idx_sys_dict_name ON sys_dict (name); +CREATE INDEX idx_sys_dict_type ON sys_dict (type); +-- ----------- +-- 系统部门表 +-- ----------- +CREATE TABLE sys_dept +( + id NUMBER(19), + dept_name VARCHAR2(50) NOT NULL, + parent_id NUMBER(19) NULL, + order_num NUMBER(10) NULL, + leader VARCHAR2(500) NULL, + mail VARCHAR2(50) null, + phone VARCHAR2(50) null, + + create_time TIMESTAMP(0) DEFAULT SYSTIMESTAMP, + update_time TIMESTAMP(0) DEFAULT NULL, + update_user VARCHAR2(100) NULL, + PRIMARY KEY (id) +) +; + +COMMENT ON TABLE sys_dept IS '系统部门表'; + +COMMENT ON COLUMN sys_dept.dept_name IS '部门名'; +COMMENT ON COLUMN sys_dept.parent_id IS '父级ID'; +COMMENT ON COLUMN sys_dept.order_num IS '排序'; +COMMENT ON COLUMN sys_dept.leader IS '领导名'; +comment on column sys_dept.mail is '邮箱'; +comment on column sys_dept.phone is '电话'; + +CREATE INDEX idx_sys_dept_dept_name ON sys_dept (dept_name); +CREATE INDEX idx_sys_dept_parent_id ON sys_dept (parent_id); diff --git a/.docs/sql/nacos_v1.4.6.sql b/.docs/sql/other/nacos_v1.4.6.sql similarity index 100% rename from .docs/sql/nacos_v1.4.6.sql rename to .docs/sql/other/nacos_v1.4.6.sql diff --git a/.docs/sql/xxl-job_v2.4.0.sql b/.docs/sql/other/xxl-job_v2.4.0.sql similarity index 100% rename from .docs/sql/xxl-job_v2.4.0.sql rename to .docs/sql/other/xxl-job_v2.4.0.sql From 5a165b5573b8f5eb7ec9e260460c7a87d60a484e Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 12 Dec 2023 12:14:50 +0800 Subject: [PATCH 199/244] =?UTF-8?q?docs:=20=E4=BF=AE=E6=94=B9=20intro=20?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/intro/application-config-example.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.docs/intro/application-config-example.md b/.docs/intro/application-config-example.md index 592c8ced..f183f7a8 100644 --- a/.docs/intro/application-config-example.md +++ b/.docs/intro/application-config-example.md @@ -90,7 +90,8 @@ pagehelper: # mybatis plus 配置 mybatis-plus: - mapper-locations: classpath*:mapper/**/*.xml + # 配置使用 mysql mapper文件 路径 + mapper-locations: classpath*:mapper/mysql/**/*.xml type-aliases-package: com.github.cadecode.**.bean,com.github.cadecode.**.mybatis.converter type-enums-package: com.github.cadecode.**.enums configuration: From 2f82bbd35d2630edfa2014504c3490e775a36a43 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 12 Dec 2023 12:41:20 +0800 Subject: [PATCH 200/244] =?UTF-8?q?fix:=20SysMenuMapper=20oracle=20DISTINC?= =?UTF-8?q?T=20=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/oracle/SysMenuMapper.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/framework/framework_svc/src/main/resources/mapper/oracle/SysMenuMapper.xml b/framework/framework_svc/src/main/resources/mapper/oracle/SysMenuMapper.xml index 47da0919..b9ec8c5a 100644 --- a/framework/framework_svc/src/main/resources/mapper/oracle/SysMenuMapper.xml +++ b/framework/framework_svc/src/main/resources/mapper/oracle/SysMenuMapper.xml @@ -19,13 +19,20 @@ - SELECT sa.*, JSON_ARRAYAGG(sr.code) r_code + SELECT sa.*, JSON_ARRAYAGG(CONCAT(sr.type, ':', sr.code)) r_code FROM sys_api sa LEFT JOIN sys_role_api sra ON sra.api_id = sa.id LEFT JOIN sys_role sr ON sra.role_id = sr.id @@ -26,7 +26,7 @@ ORDER BY sa.url - SELECT su.*, JSON_ARRAYAGG(sr.code) r_code, sd.dept_name d_dept_name + SELECT su.*, JSON_ARRAYAGG(CONCAT(sr.type, ':', sr.code)) r_code, sd.dept_name d_dept_name FROM sys_user su LEFT JOIN sys_role_user sru ON sru.user_id = su.id LEFT JOIN sys_role sr ON sru.role_id = sr.id @@ -37,7 +37,7 @@ ORDER BY su.create_time DESC - SELECT sa.*, JSON_ARRAYAGG(sr.code) r_code + SELECT sa.*, JSON_ARRAYAGG(sr.type || ':' || sr.code) r_code FROM sys_api sa LEFT JOIN sys_role_api sra ON sra.api_id = sa.id LEFT JOIN sys_role sr ON sra.role_id = sr.id @@ -26,7 +26,7 @@ ORDER BY sa.url SELECT su.id, su.username, su.password, su.nick_name, su.dept_id, su.enable_flag, su.sex, su.mail, su.phone, - su.login_ip, su.login_date, su.create_time, su.update_time, su.update_user, JSON_ARRAYAGG(sr.code) r_code, + su.login_ip, su.login_date, su.create_time, su.update_time, su.update_user, JSON_ARRAYAGG(sr.type || ':' || + sr.code) r_code, sd.dept_name d_dept_name FROM sys_user su LEFT JOIN sys_role_user sru ON sru.user_id = su.id @@ -55,7 +56,7 @@ su.create_time, su.update_time, su.update_user, - JSON_ARRAYAGG(sr.code) r_code, + JSON_ARRAYAGG(sr.type || ':' || sr.code) r_code, sd.dept_name d_dept_name FROM sys_user su LEFT JOIN sys_role_user sru ON sru.user_id = su.id @@ -67,7 +68,8 @@ From df8bb93ea28e0592dd34fc7ae5dd68a10cac9464 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Wed, 19 Jun 2024 13:10:00 +0800 Subject: [PATCH 234/244] =?UTF-8?q?fix:=20=E7=AD=96=E7=95=A5=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=99=A8=E4=B8=AD=E5=85=88=E5=88=A4=E6=96=AD=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=EF=BC=8C=E5=86=8D=E5=88=A4=E6=96=AD=20supports=20?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 防止在各策略实现中,强转到自己的 context 类报错 --- .../strategy/AbstractStrategyExecutor.java | 3 ++ .../extension/strategy/StrategyExecutor.java | 2 +- .../strategy/StrategySelectorExecutor.java | 28 +++++++++++++------ 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/AbstractStrategyExecutor.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/AbstractStrategyExecutor.java index b3334c08..83eca0db 100644 --- a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/AbstractStrategyExecutor.java +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/AbstractStrategyExecutor.java @@ -1,6 +1,7 @@ package com.github.cadecode.uniboot.common.core.extension.strategy; import java.util.List; +import java.util.Optional; /** * 策略执行器抽象类 @@ -10,5 +11,7 @@ */ public abstract class AbstractStrategyExecutor implements StrategyExecutor { + public abstract Optional selectService(Class clazz, StrategyContext context); + public abstract List selectServices(Class clazz, StrategyContext context); } diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategyExecutor.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategyExecutor.java index a0f12673..ef8488bc 100644 --- a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategyExecutor.java +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategyExecutor.java @@ -18,6 +18,6 @@ public interface StrategyExecutor { R submit(Class clazz, StrategyContext context, Function function); - List submitAll(Class clazz, StrategyContext context, Function function); + List submitAll(Class clazz, StrategyContext context, Function function); } diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategySelectorExecutor.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategySelectorExecutor.java index aeb4a623..61572465 100644 --- a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategySelectorExecutor.java +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/extension/strategy/StrategySelectorExecutor.java @@ -8,6 +8,7 @@ import org.springframework.stereotype.Component; import java.util.List; +import java.util.Optional; import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; @@ -35,9 +36,9 @@ public class StrategySelectorExecutor extends AbstractStrategyExecutor { */ @Override public void execute(Class clazz, StrategyContext context, Consumer consumer) { - List services = selectServices(clazz, context); - if (ObjUtil.isNotEmpty(services)) { - consumer.accept(services.get(0)); + Optional serviceOpt = selectService(clazz, context); + if (serviceOpt.isPresent()) { + consumer.accept(serviceOpt.get()); return; } throw new ExtException("Strategy service not found"); @@ -70,9 +71,9 @@ public void executeAll(Class clazz, StrategyConte */ @Override public R submit(Class clazz, StrategyContext context, Function function) { - List services = selectServices(clazz, context); - if (ObjUtil.isNotEmpty(services)) { - return function.apply(services.get(0)); + Optional serviceOpt = selectService(clazz, context); + if (serviceOpt.isPresent()) { + return function.apply(serviceOpt.get()); } throw new ExtException("Strategy service not found"); } @@ -86,7 +87,7 @@ public R submit(Class clazz, StrategyContext c * @return 返回值 */ @Override - public List submitAll(Class clazz, StrategyContext context, Function function) { + public List submitAll(Class clazz, StrategyContext context, Function function) { List services = selectServices(clazz, context); if (ObjUtil.isNotEmpty(services)) { return services.stream() @@ -96,12 +97,21 @@ public List submitAll(Class clazz, Strate throw new ExtException("Strategy service not found"); } + @SuppressWarnings("unchecked") + @Override + public Optional selectService(Class clazz, StrategyContext context) { + return (Optional) pluginRegistry.getPlugins() + .stream() + .filter(o -> clazz.isAssignableFrom(o.getClass()) && o.supports(context)) + .findFirst(); + } + @SuppressWarnings("unchecked") @Override public List selectServices(Class clazz, StrategyContext context) { - return (List) pluginRegistry.getPluginsFor(context) + return (List) pluginRegistry.getPlugins() .stream() - .filter(o -> clazz.isAssignableFrom(o.getClass())) + .filter(o -> clazz.isAssignableFrom(o.getClass()) && o.supports(context)) .collect(Collectors.toList()); } } From 5d7fef214ffec86882969bf50728a0f26b1a1871 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 20 Jun 2024 09:59:02 +0800 Subject: [PATCH 235/244] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E9=A1=B6?= =?UTF-8?q?=E7=BA=A7=E5=BC=82=E5=B8=B8=EF=BC=8C=E6=94=AF=E6=8C=81=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E4=BF=A1=E6=81=AF=E5=AD=97=E7=AC=A6=E4=B8=B2=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/core/exception/ApiException.java | 60 +++++++++++-------- .../common/core/exception/BaseException.java | 31 ++++++++++ .../common/core/exception/ExtException.java | 15 +++-- .../common/core/exception/UtilException.java | 14 ++--- 4 files changed, 79 insertions(+), 41 deletions(-) create mode 100644 common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/BaseException.java diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/ApiException.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/ApiException.java index cf5dea0a..c6ea26d9 100644 --- a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/ApiException.java +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/ApiException.java @@ -1,5 +1,6 @@ package com.github.cadecode.uniboot.common.core.exception; +import cn.hutool.core.util.StrUtil; import com.github.cadecode.uniboot.common.core.enums.ApiErrorCode; import lombok.Getter; @@ -12,7 +13,7 @@ * @date 2022/5/8 */ @Getter -public class ApiException extends RuntimeException { +public class ApiException extends BaseException { /** * 错误信息码 @@ -24,14 +25,29 @@ public class ApiException extends RuntimeException { */ private final String moreInfo; + /** + * 构造方法 + * + * @param errorCode 错误信息码 + * @param throwable cause + * @param moreInfo 更多异常信息 + * @param params 字符串模板参数 + */ + public ApiException(ApiErrorCode errorCode, Throwable throwable, String moreInfo, Object... params) { + super(geneErrorMessage(errorCode, moreInfo, params), throwable); + this.errorCode = errorCode; + this.moreInfo = StrUtil.format(moreInfo, params); + } + /** * 抛出未知异常 * * @param moreInfo 更多异常信息 + * @param params 字符串模板参数 * @return ApiException */ - public static ApiException of(String moreInfo) { - return of(ApiErrorCode.UNKNOWN, moreInfo); + public static ApiException of(String moreInfo, Object... params) { + return of(ApiErrorCode.UNKNOWN, moreInfo, params); } /** @@ -39,10 +55,11 @@ public static ApiException of(String moreInfo) { * * @param throwable cause * @param moreInfo 更多异常信息 + * @param params 字符串模板参数 * @return ApiException */ - public static ApiException of(Throwable throwable, String moreInfo) { - return of(ApiErrorCode.UNKNOWN, throwable, moreInfo); + public static ApiException of(Throwable throwable, String moreInfo, Object... params) { + return of(ApiErrorCode.UNKNOWN, throwable, moreInfo, params); } /** @@ -50,10 +67,11 @@ public static ApiException of(Throwable throwable, String moreInfo) { * * @param errorCode 错误信息码 * @param moreInfo 更多异常信息 + * @param params 字符串模板参数 * @return ApiException */ - public static ApiException of(ApiErrorCode errorCode, String moreInfo) { - return of(errorCode, null, moreInfo); + public static ApiException of(ApiErrorCode errorCode, String moreInfo, Object... params) { + return of(errorCode, null, moreInfo, params); } /** @@ -73,23 +91,13 @@ public static ApiException of(ApiErrorCode errorCode, Throwable throwable) { * @param errorCode 错误信息码 * @param throwable cause * @param moreInfo 更多异常信息 + * @param params 字符串模板参数 * @return ApiException */ - public static ApiException of(ApiErrorCode errorCode, Throwable throwable, String moreInfo) { - return new ApiException(errorCode, throwable, moreInfo); - } - - /** - * 私有构造 - * - * @param errorCode 错误信息码 - * @param throwable cause - * @param moreInfo 更多异常信息 - */ - private ApiException(ApiErrorCode errorCode, Throwable throwable, String moreInfo) { - super(generateMessage(errorCode, moreInfo), throwable); - this.errorCode = errorCode; - this.moreInfo = moreInfo; + public static ApiException of(ApiErrorCode errorCode, Throwable throwable, String moreInfo, Object... params) { + // 这里直接调用 StrUtil.format 得到 moreInfo + // 避免在构造方法中重复 format 解析字符串模板 + return new ApiException(errorCode, throwable, StrUtil.format(moreInfo, params)); } /** @@ -99,15 +107,15 @@ private ApiException(ApiErrorCode errorCode, Throwable throwable, String moreInf * @param moreInfo 更多异常信息 * @return 完整异常信息 */ - private static String generateMessage(ApiErrorCode errorCode, String moreInfo) { + private static String geneErrorMessage(ApiErrorCode errorCode, String moreInfo, Object... params) { String message = ""; - // 拼接 [错误码-错误信息] + // 拼接 [错误码:错误信息] if (Objects.nonNull(errorCode)) { - message += "[" + errorCode.getCode() + "-" + errorCode.getMessage() + "]"; + message += "[" + errorCode.getCode() + ":" + errorCode.getMessage() + "]"; } // 拼接更多异常信息 if (Objects.nonNull(moreInfo)) { - message += moreInfo; + message += StrUtil.format(moreInfo, params); } return message; } diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/BaseException.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/BaseException.java new file mode 100644 index 00000000..49007695 --- /dev/null +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/BaseException.java @@ -0,0 +1,31 @@ +package com.github.cadecode.uniboot.common.core.exception; + +import cn.hutool.core.util.StrUtil; + +/** + * 基础异常类 + *

message 支持字符串模板,由 hutool {@code StrUtil.format} 提供 + * + * @author Cade Li + * @since 2024/4/23 + */ +public class BaseException extends RuntimeException { + public BaseException() { + } + + public BaseException(String message, Object... params) { + super(StrUtil.format(message, params)); + } + + public BaseException(String message, Throwable cause, Object... params) { + super(StrUtil.format(message, params), cause); + } + + public BaseException(Throwable cause) { + super(cause); + } + + public BaseException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, Object... params) { + super(StrUtil.format(message, params), cause, enableSuppression, writableStackTrace); + } +} diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/ExtException.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/ExtException.java index 605442bb..c43e8512e 100644 --- a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/ExtException.java +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/ExtException.java @@ -6,24 +6,23 @@ * @author Cade Li * @since 2023/6/24 */ -public class ExtException extends RuntimeException { +public class ExtException extends BaseException { public ExtException() { - super(); } - public ExtException(String message) { - super(message); + public ExtException(String message, Object... params) { + super(message, params); } - public ExtException(String message, Throwable cause) { - super(message, cause); + public ExtException(String message, Throwable cause, Object... params) { + super(message, cause, params); } public ExtException(Throwable cause) { super(cause); } - protected ExtException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); + public ExtException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, Object... params) { + super(message, cause, enableSuppression, writableStackTrace, params); } } diff --git a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/UtilException.java b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/UtilException.java index ed66dc88..10410d32 100644 --- a/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/UtilException.java +++ b/common/core/src/main/java/com/github/cadecode/uniboot/common/core/exception/UtilException.java @@ -6,23 +6,23 @@ * @author Cade Li * @date 2023/6/9 */ -public class UtilException extends RuntimeException { +public class UtilException extends BaseException { public UtilException() { } - public UtilException(String message) { - super(message); + public UtilException(String message, Object... params) { + super(message, params); } - public UtilException(String message, Throwable cause) { - super(message, cause); + public UtilException(String message, Throwable cause, Object... params) { + super(message, cause, params); } public UtilException(Throwable cause) { super(cause); } - public UtilException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); + public UtilException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace, Object... params) { + super(message, cause, enableSuppression, writableStackTrace, params); } } From b4a2ed656805b95c54b71429547cc5c90cf98901 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Wed, 10 Jul 2024 10:39:42 +0800 Subject: [PATCH 236/244] =?UTF-8?q?refactor:=20RES=5FBODY=5FNULL=20?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8D=E6=89=93=E5=8D=B0=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/base/advisor/ApiExceptionAdvisor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiExceptionAdvisor.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiExceptionAdvisor.java index 9d68b3b5..2cf2c9d3 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiExceptionAdvisor.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/advisor/ApiExceptionAdvisor.java @@ -23,11 +23,11 @@ public class ApiExceptionAdvisor { */ @ExceptionHandler(ApiException.class) public ApiResult handleApiException(ApiException e) { - log.error("Api Exception =>", e); // 特殊处理接口返回 null 的情况 if (FrameErrorEnum.RES_BODY_NULL.getCode().equals(e.getErrorCode().getCode())) { return ApiResult.ok(null); } + log.error("Api Exception =>", e); return ApiResult.error(e.getErrorCode()).moreInfo(e.getMoreInfo()); } From a7c3dbaf0e920954b379331927c9675cff52c058 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Tue, 23 Jul 2024 13:48:16 +0800 Subject: [PATCH 237/244] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=8D=95=E4=B8=AA=E8=B4=A6=E5=8F=B7=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=20token=20=E6=95=B0=E9=87=8F=EF=BC=88=E9=BB=98=E8=AE=A4=201=20?= =?UTF-8?q?=E5=8D=B3=E4=B8=8D=E6=94=AF=E6=8C=81=E9=87=8D=E5=A4=8D=E7=99=BB?= =?UTF-8?q?=E5=BD=95=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/base/config/SecurityConfig.java | 7 ++++ .../strategy/RedisTokenAuthStrategyImpl.java | 9 +++-- .../framework/base/util/SecurityUtil.java | 8 ++++ .../RedisLoginSuccessHandleService.java | 39 ++++++++++++++++++- 4 files changed, 58 insertions(+), 5 deletions(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java index 5a9475f9..d84e37da 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java @@ -193,5 +193,12 @@ public static class TokenConfig { * 密钥 */ private String secret; + + /** + * 单个账号最多允许几个 token(大于 0) + * 为 1 时即不允许多次登录同时在线 + */ + private Integer maxCount = 1; + } } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/RedisTokenAuthStrategyImpl.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/RedisTokenAuthStrategyImpl.java index d7e1b57d..5a8caba9 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/RedisTokenAuthStrategyImpl.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/RedisTokenAuthStrategyImpl.java @@ -42,15 +42,18 @@ public void handler(HttpServletRequest request, HttpServletResponse response, Fi return; } // 查询 redis 中 token - String loginUserKey = KeyGeneUtil.key(KeyPrefixConst.LOGIN_USER, uuidToken); - SysUserDetails sysUserDetails = RedisUtil.get(loginUserKey, SysUserDetails.class); + String loginUserTokenKey = KeyGeneUtil.key(KeyPrefixConst.LOGIN_USER, uuidToken); + SysUserDetails sysUserDetails = RedisUtil.get(loginUserTokenKey, SysUserDetails.class); // redis 中用户不存在 if (Objects.isNull(sysUserDetails)) { writeResponse(response, AuthErrorEnum.TOKEN_EXPIRED, requestURI); return; } // 用户存在,刷新过期时间 - RedisUtil.expire(loginUserKey, SecurityUtil.getExpiration(), TimeUnit.SECONDS); + RedisUtil.expire(loginUserTokenKey, SecurityUtil.getExpiration(), TimeUnit.SECONDS); + String loginUsernameKey = KeyGeneUtil.key(KeyPrefixConst.LOGIN_USER, sysUserDetails.getUsername()); + RedisUtil.expire(loginUsernameKey, SecurityUtil.getExpiration(), TimeUnit.SECONDS); + ServletUtil.addCookie(response, HttpConst.HEAD_TOKEN, uuidToken, SecurityUtil.getExpiration().intValue()); // 设置 AuthenticationToken setAuthentication(request, sysUserDetails); diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java index fce475ce..01b71a41 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java @@ -32,6 +32,10 @@ public class SecurityUtil implements InitializingBean { // 从 SecurityConfig 获取 token 配置 + public static SecurityProperties properties() { + return PROPERTIES; + } + public static Long getExpiration() { return PROPERTIES.getTokenConfig().getExpiration(); } @@ -40,6 +44,10 @@ public static String getSecret() { return PROPERTIES.getTokenConfig().getSecret(); } + public static Integer getMaxCount() { + return PROPERTIES.getTokenConfig().getMaxCount(); + } + /** * 从request对象解析token,cookie or header * diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java index 6a925b33..cec6620f 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java @@ -1,5 +1,7 @@ package com.github.cadecode.uniboot.framework.svc.security; +import cn.hutool.core.util.ObjUtil; +import com.fasterxml.jackson.core.type.TypeReference; import com.github.cadecode.uniboot.common.core.extension.strategy.StrategyContext; import com.github.cadecode.uniboot.common.core.web.response.ApiResult; import com.github.cadecode.uniboot.common.plugin.cache.util.KeyGeneUtil; @@ -15,7 +17,12 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; /** * 登录成功处理器 @@ -35,11 +42,39 @@ public ApiResult getResult(HttpServletRequest request, HttpServl // token 放在请求头 response.addHeader(HttpConst.HEAD_TOKEN, uuidToken); // 生成存放登录信息的 redis key - String loginUserKey = KeyGeneUtil.key(KeyPrefixConst.LOGIN_USER, uuidToken); - RedisUtil.set(loginUserKey, sysUserDetails, SecurityUtil.getExpiration(), TimeUnit.SECONDS); + String loginUserTokenKey = KeyGeneUtil.key(KeyPrefixConst.LOGIN_USER, uuidToken); + String loginUsernameKey = KeyGeneUtil.key(KeyPrefixConst.LOGIN_USER, sysUserDetails.getUsername()); + // 获取当前账号 token 列表 + List tokenList = getTokenList(loginUsernameKey, loginUserTokenKey); + RedisUtil.set(loginUserTokenKey, sysUserDetails, SecurityUtil.getExpiration(), TimeUnit.SECONDS); + RedisUtil.set(loginUsernameKey, tokenList, SecurityUtil.getExpiration(), TimeUnit.SECONDS); return ApiResult.ok(sysUserDetails).path(FrameSecurityConfig.LOGOUT_URL); } + private List getTokenList(String loginUsernameKey, String loginUserTokenKey) { + List tokenList = RedisUtil.get(loginUsernameKey, new TypeReference>() {}); + if (ObjUtil.isEmpty(tokenList)) { + return new ArrayList<>(Collections.singletonList(loginUserTokenKey)); + } + // 当配置了最大 token 数 + Integer maxTokenCount = SecurityUtil.getMaxCount(); + if (Objects.nonNull(maxTokenCount) && maxTokenCount > 0) { + tokenList.add(loginUserTokenKey); + if (tokenList.size() > maxTokenCount) { + // 清理超过限制的 token + tokenList.stream() + .limit(tokenList.size() - maxTokenCount) + .forEach(RedisUtil::del); + tokenList = tokenList.stream() + .skip(tokenList.size() - maxTokenCount) + .collect(Collectors.toList()); + } + } else { + tokenList = new ArrayList<>(Collections.singletonList(loginUserTokenKey)); + } + return tokenList; + } + @Override public boolean supports(StrategyContext delimiter) { return delimiter.getStrategyType() == AuthModelEnum.REDIS; From d0002da70a573e72dcb6f9eb97009a49cb8ed6a6 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 1 Aug 2024 15:07:54 +0800 Subject: [PATCH 238/244] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E5=90=8C?= =?UTF-8?q?=E5=90=8D=E9=98=9F=E5=88=97=E5=92=8C=E4=BA=A4=E6=8D=A2=E6=9C=BA?= =?UTF-8?q?=E5=A3=B0=E6=98=8E=E5=A4=9A=E4=B8=AA=E7=BB=91=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=20bean=20=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/mq/config/RabbitAutoConfig.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java index a6f10b78..99e76506 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/config/RabbitAutoConfig.java @@ -168,7 +168,8 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) } Binding binding = new Binding(bindName, o.getBindType(), o.getExchangeName(), o.getRoutingKey(), o.getArguments()); binding.setAdminsThatShouldDeclare(getAdminBeanName(connectionName)); - String beanName = geneDeclareBeanName(connectionName, o.getBindName() + "-" + o.getExchangeName()); + String declareName = o.getBindName() + "-" + o.getBindType() + "-" + o.getExchangeName() + "-" + o.getRoutingKey(); + String beanName = geneDeclareBeanName(connectionName, declareName); beanFactory.registerSingleton(beanName, binding); log.info("Rabbit auto register binding, connection:{}, bind {} to {}, bindType:{}, {}", connectionName, o.getBindName(), o.getExchangeName(), o.getBindType(), o); From c09315c24e2162f028b33db467b52b7943c6a59a Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 1 Aug 2024 22:08:26 +0800 Subject: [PATCH 239/244] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20RabbitMQ=20?= =?UTF-8?q?=E5=A4=9A=E6=95=B0=E6=8D=AE=E6=BA=90=E5=A3=B0=E6=98=8E=E5=90=8C?= =?UTF-8?q?=E5=90=8D=E4=BA=A4=E6=8D=A2=E6=9C=BA=E5=88=A4=E6=96=AD=20delay?= =?UTF-8?q?=20=E6=97=B6=20toMap=20=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/common/plugin/mq/rabbit/RabbitCallback.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java index fce023bd..7fc8190d 100644 --- a/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java +++ b/common/plugin/mq/src/main/java/com/github/cadecode/uniboot/common/plugin/mq/rabbit/RabbitCallback.java @@ -32,7 +32,7 @@ public class RabbitCallback implements ConfirmCallback, ReturnsCallback, Initial /** * 交换机名称映射 */ - private Map exchangeNameMap; + private Map> exchangeNameMap; private final List exchanges; @@ -75,11 +75,12 @@ public void returnedMessage(ReturnedMessage returned) { */ private boolean isExchangeDelayed(String exchangeName) { if (ObjUtil.isEmpty(exchangeNameMap)) { - exchangeNameMap = exchanges.stream().collect(Collectors.toMap(Exchange::getName, o -> o)); + exchangeNameMap = exchanges.stream().collect(Collectors.groupingBy(Exchange::getName, Collectors.toList())); } // 若是 delay 交换机 - Exchange exchange = exchangeNameMap.get(exchangeName); - return ObjUtil.isNotNull(exchange) && (exchange.isDelayed() || RabbitConst.EXC_TYPE_DELAYED.equals(exchange.getType())); + List exchangeList = exchangeNameMap.get(exchangeName); + return exchangeList.stream() + .allMatch(exchange -> ObjUtil.isNotNull(exchange) && (exchange.isDelayed() || RabbitConst.EXC_TYPE_DELAYED.equals(exchange.getType()))); } @Override From 1dda3d85c775700d6a2658b497be20a3d0c74184 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 3 Aug 2024 20:48:29 +0800 Subject: [PATCH 240/244] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=90=8D=E6=9B=B4=E5=8A=A0=E5=85=B7=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uniboot/framework/base/config/SecurityConfig.java | 2 ++ .../security/strategy/JwtTokenAuthStrategyImpl.java | 10 +++++----- .../security/strategy/RedisTokenAuthStrategyImpl.java | 6 +++--- .../uniboot/framework/base/util/SecurityUtil.java | 6 +++--- .../svc/security/JwtLoginSuccessHandleService.java | 2 +- .../svc/security/RedisLoginSuccessHandleService.java | 6 +++--- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java index d84e37da..cf5d26d9 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/config/SecurityConfig.java @@ -197,6 +197,8 @@ public static class TokenConfig { /** * 单个账号最多允许几个 token(大于 0) * 为 1 时即不允许多次登录同时在线 + * 为 null 或小于 0 时表示不限制 + * 仅在 Redis 模式下生效 */ private Integer maxCount = 1; diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/JwtTokenAuthStrategyImpl.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/JwtTokenAuthStrategyImpl.java index 667acb12..ee331066 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/JwtTokenAuthStrategyImpl.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/JwtTokenAuthStrategyImpl.java @@ -39,12 +39,12 @@ public void handler(HttpServletRequest request, HttpServletResponse response, Fi return; } // token 不合法 - if (!TokenUtil.verifyToken(jwtToken, SecurityUtil.getSecret())) { + if (!TokenUtil.verifyToken(jwtToken, SecurityUtil.getTokenSecret())) { writeResponse(response, AuthErrorEnum.TOKEN_ERROR, requestURI); return; } // token 已过期 - if (TokenUtil.isExpired(jwtToken, SecurityUtil.getSecret())) { + if (TokenUtil.isExpired(jwtToken, SecurityUtil.getTokenSecret())) { writeResponse(response, AuthErrorEnum.TOKEN_EXPIRED, requestURI); return; } @@ -57,15 +57,15 @@ public void handler(HttpServletRequest request, HttpServletResponse response, Fi // 获取过期时间,单位秒 long expiresAt = Long.parseLong(String.valueOf(payload.get("exp"))); // 过期时间的一半,秒转为毫秒 - long halfExpiration = SecurityUtil.getExpiration() / 2; + long halfExpiration = SecurityUtil.getTokenExpiration() / 2; // 如果当时时间距离过期时间不到配置的 expiration 一半,就下发新的 token if (expiresAt - System.currentTimeMillis() / 1000 < halfExpiration) { // 生成 jwt token String newJwtToken = TokenUtil.generateToken(sysUserDetails.getId(), sysUserDetails.getUsername(), sysUserDetails.getRoles(), - SecurityUtil.getExpiration(), SecurityUtil.getSecret()); + SecurityUtil.getTokenExpiration(), SecurityUtil.getTokenSecret()); // token 放在请求头 response.addHeader(HttpConst.HEAD_TOKEN, newJwtToken); - ServletUtil.addCookie(response, HttpConst.HEAD_TOKEN, newJwtToken, SecurityUtil.getExpiration().intValue()); + ServletUtil.addCookie(response, HttpConst.HEAD_TOKEN, newJwtToken, SecurityUtil.getTokenExpiration().intValue()); } filterChain.doFilter(request, response); } diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/RedisTokenAuthStrategyImpl.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/RedisTokenAuthStrategyImpl.java index 5a8caba9..8a6c9b94 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/RedisTokenAuthStrategyImpl.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/security/strategy/RedisTokenAuthStrategyImpl.java @@ -50,11 +50,11 @@ public void handler(HttpServletRequest request, HttpServletResponse response, Fi return; } // 用户存在,刷新过期时间 - RedisUtil.expire(loginUserTokenKey, SecurityUtil.getExpiration(), TimeUnit.SECONDS); + RedisUtil.expire(loginUserTokenKey, SecurityUtil.getTokenExpiration(), TimeUnit.SECONDS); String loginUsernameKey = KeyGeneUtil.key(KeyPrefixConst.LOGIN_USER, sysUserDetails.getUsername()); - RedisUtil.expire(loginUsernameKey, SecurityUtil.getExpiration(), TimeUnit.SECONDS); + RedisUtil.expire(loginUsernameKey, SecurityUtil.getTokenExpiration(), TimeUnit.SECONDS); - ServletUtil.addCookie(response, HttpConst.HEAD_TOKEN, uuidToken, SecurityUtil.getExpiration().intValue()); + ServletUtil.addCookie(response, HttpConst.HEAD_TOKEN, uuidToken, SecurityUtil.getTokenExpiration().intValue()); // 设置 AuthenticationToken setAuthentication(request, sysUserDetails); filterChain.doFilter(request, response); diff --git a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java index 01b71a41..dd688639 100644 --- a/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java +++ b/framework/framework_base/src/main/java/com/github/cadecode/uniboot/framework/base/util/SecurityUtil.java @@ -36,15 +36,15 @@ public static SecurityProperties properties() { return PROPERTIES; } - public static Long getExpiration() { + public static Long getTokenExpiration() { return PROPERTIES.getTokenConfig().getExpiration(); } - public static String getSecret() { + public static String getTokenSecret() { return PROPERTIES.getTokenConfig().getSecret(); } - public static Integer getMaxCount() { + public static Integer getTokenMaxCount() { return PROPERTIES.getTokenConfig().getMaxCount(); } diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java index 98f6abdc..3d9652a9 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/JwtLoginSuccessHandleService.java @@ -29,7 +29,7 @@ public ApiResult getResult(HttpServletRequest request, HttpServl SysUserDetails sysUserDetails = (SysUserDetails) authentication.getPrincipal(); // 生成 jwt token String jwtToken = TokenUtil.generateToken(sysUserDetails.getId(), sysUserDetails.getUsername(), sysUserDetails.getRoles(), - SecurityUtil.getExpiration(), SecurityUtil.getSecret()); + SecurityUtil.getTokenExpiration(), SecurityUtil.getTokenSecret()); // token 放在请求头 response.addHeader(HttpConst.HEAD_TOKEN, jwtToken); return ApiResult.ok(sysUserDetails).path(FrameSecurityConfig.LOGOUT_URL); diff --git a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java index cec6620f..948d81c2 100644 --- a/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java +++ b/framework/framework_svc/src/main/java/com/github/cadecode/uniboot/framework/svc/security/RedisLoginSuccessHandleService.java @@ -46,8 +46,8 @@ public ApiResult getResult(HttpServletRequest request, HttpServl String loginUsernameKey = KeyGeneUtil.key(KeyPrefixConst.LOGIN_USER, sysUserDetails.getUsername()); // 获取当前账号 token 列表 List tokenList = getTokenList(loginUsernameKey, loginUserTokenKey); - RedisUtil.set(loginUserTokenKey, sysUserDetails, SecurityUtil.getExpiration(), TimeUnit.SECONDS); - RedisUtil.set(loginUsernameKey, tokenList, SecurityUtil.getExpiration(), TimeUnit.SECONDS); + RedisUtil.set(loginUserTokenKey, sysUserDetails, SecurityUtil.getTokenExpiration(), TimeUnit.SECONDS); + RedisUtil.set(loginUsernameKey, tokenList, SecurityUtil.getTokenExpiration(), TimeUnit.SECONDS); return ApiResult.ok(sysUserDetails).path(FrameSecurityConfig.LOGOUT_URL); } @@ -57,7 +57,7 @@ private List getTokenList(String loginUsernameKey, String loginUserToken return new ArrayList<>(Collections.singletonList(loginUserTokenKey)); } // 当配置了最大 token 数 - Integer maxTokenCount = SecurityUtil.getMaxCount(); + Integer maxTokenCount = SecurityUtil.getTokenMaxCount(); if (Objects.nonNull(maxTokenCount) && maxTokenCount > 0) { tokenList.add(loginUserTokenKey); if (tokenList.size() > maxTokenCount) { From 7cbd1e5068ddbf1a4437460a782cd1e3c1605a69 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Sat, 3 Aug 2024 20:58:11 +0800 Subject: [PATCH 241/244] release: update version to 2024.2.0 --- CHANGELOG.md | 24 ++++++++++++++++++++++++ app | 2 +- common/core/pom.xml | 2 +- common/plugin/actuator/pom.xml | 2 +- common/plugin/cache/pom.xml | 2 +- common/plugin/concurrent/pom.xml | 2 +- common/plugin/datasource/pom.xml | 2 +- common/plugin/job/pom.xml | 2 +- common/plugin/log/pom.xml | 2 +- common/plugin/mq/pom.xml | 2 +- common/plugin/mybatis/pom.xml | 2 +- common/plugin/pom.xml | 2 +- common/plugin/storage/pom.xml | 2 +- common/plugin/swagger/pom.xml | 2 +- common/pom.xml | 2 +- dependencies/pom.xml | 2 +- example/example_api/pom.xml | 2 +- example/example_svc/pom.xml | 2 +- example/pom.xml | 2 +- framework/framework_api/pom.xml | 2 +- framework/framework_base/pom.xml | 2 +- framework/framework_svc/pom.xml | 2 +- framework/pom.xml | 2 +- gateway/pom.xml | 2 +- pom.xml | 2 +- 25 files changed, 48 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b22f4f5..49df5055 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,27 @@ +# [2024.2.0](https://github.com/cadecode/uni-boot-cloud/compare/2024.1.0...2024.2.0) (2024-08-03) + +### Bug Fixes + +* 策略执行器中先判断类型,再判断 supports + 方法 ([df8bb93](https://github.com/cadecode/uni-boot-cloud/commit/df8bb93ea28e0592dd34fc7ae5dd68a10cac9464)) +* 解决 mybatis plus 插件和 pageHelper + 插件顺序问题 ([eaf1479](https://github.com/cadecode/uni-boot-cloud/commit/eaf14797a70e634e0c27f7f7f2ed3aa21f79cf61)) +* 解决 RabbitMQ 多数据源声明同名交换机判断 delay 时 toMap + 冲突 ([c09315c](https://github.com/cadecode/uni-boot-cloud/commit/c09315c24e2162f028b33db467b52b7943c6a59a)) +* 解决同名队列和交换机声明多个绑定时 bean + 冲突 ([d0002da](https://github.com/cadecode/uni-boot-cloud/commit/d0002da70a573e72dcb6f9eb97009a49cb8ed6a6)) +* SysRoleMapper Oracle 下 mapper + 字段缺少 ([2017e66](https://github.com/cadecode/uni-boot-cloud/commit/2017e66c007efe5521ef157ff3152fba60b1a49b)) + +### Features + +* 登录和注销时操作客户端 + cookie ([1fc3432](https://github.com/cadecode/uni-boot-cloud/commit/1fc3432ef68d679d15639170ef12693bb34c74dd)) +* +优化顶级异常,支持异常信息字符串模板 ([5d7fef2](https://github.com/cadecode/uni-boot-cloud/commit/5d7fef214ffec86882969bf50728a0f26b1a1871)) +* 支持配置单个账号最大 token 数量(默认 1 + 即不支持重复登录) ([a7c3dba](https://github.com/cadecode/uni-boot-cloud/commit/a7c3dbaf0e920954b379331927c9675cff52c058)) + # [2024.1.0](https://github.com/cadecode/uni-boot-cloud/compare/2023.1.3...2024.1.0) (2024-05-27) ### Bug Fixes diff --git a/app b/app index 778e97f0..7327877f 160000 --- a/app +++ b/app @@ -1 +1 @@ -Subproject commit 778e97f03546237082bcfa353dc563f3c46a9efb +Subproject commit 7327877f4b9933fbe9b60b19180c25f5f30109fe diff --git a/common/core/pom.xml b/common/core/pom.xml index 4561081a..b222021f 100644 --- a/common/core/pom.xml +++ b/common/core/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common - 2024.1.0 + 2024.2.0 4.0.0 diff --git a/common/plugin/actuator/pom.xml b/common/plugin/actuator/pom.xml index da974d44..1b1a40b2 100644 --- a/common/plugin/actuator/pom.xml +++ b/common/plugin/actuator/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2024.1.0 + 2024.2.0 4.0.0 diff --git a/common/plugin/cache/pom.xml b/common/plugin/cache/pom.xml index f136b460..76fe4c76 100644 --- a/common/plugin/cache/pom.xml +++ b/common/plugin/cache/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2024.1.0 + 2024.2.0 4.0.0 diff --git a/common/plugin/concurrent/pom.xml b/common/plugin/concurrent/pom.xml index f6397c7c..9b5f0e8a 100644 --- a/common/plugin/concurrent/pom.xml +++ b/common/plugin/concurrent/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2024.1.0 + 2024.2.0 4.0.0 diff --git a/common/plugin/datasource/pom.xml b/common/plugin/datasource/pom.xml index 4b7afced..2361cdb7 100644 --- a/common/plugin/datasource/pom.xml +++ b/common/plugin/datasource/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2024.1.0 + 2024.2.0 4.0.0 diff --git a/common/plugin/job/pom.xml b/common/plugin/job/pom.xml index 8cfc4f5b..350dce27 100644 --- a/common/plugin/job/pom.xml +++ b/common/plugin/job/pom.xml @@ -6,7 +6,7 @@ com.github.cadecode uni-boot-common-plugin - 2024.1.0 + 2024.2.0 uni-boot-common-plugin-job diff --git a/common/plugin/log/pom.xml b/common/plugin/log/pom.xml index af960c98..88d12978 100644 --- a/common/plugin/log/pom.xml +++ b/common/plugin/log/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2024.1.0 + 2024.2.0 4.0.0 diff --git a/common/plugin/mq/pom.xml b/common/plugin/mq/pom.xml index 0977dfc4..3c8dca3f 100644 --- a/common/plugin/mq/pom.xml +++ b/common/plugin/mq/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2024.1.0 + 2024.2.0 4.0.0 diff --git a/common/plugin/mybatis/pom.xml b/common/plugin/mybatis/pom.xml index 1ec5f4c8..3abdcb8f 100644 --- a/common/plugin/mybatis/pom.xml +++ b/common/plugin/mybatis/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2024.1.0 + 2024.2.0 4.0.0 diff --git a/common/plugin/pom.xml b/common/plugin/pom.xml index e343f8e8..16f5efc6 100644 --- a/common/plugin/pom.xml +++ b/common/plugin/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common - 2024.1.0 + 2024.2.0 4.0.0 diff --git a/common/plugin/storage/pom.xml b/common/plugin/storage/pom.xml index 72805de6..1eab60a2 100644 --- a/common/plugin/storage/pom.xml +++ b/common/plugin/storage/pom.xml @@ -6,7 +6,7 @@ com.github.cadecode uni-boot-common-plugin - 2024.1.0 + 2024.2.0 uni-boot-common-plugin-storage diff --git a/common/plugin/swagger/pom.xml b/common/plugin/swagger/pom.xml index 694ad508..3c55c3db 100644 --- a/common/plugin/swagger/pom.xml +++ b/common/plugin/swagger/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-common-plugin - 2024.1.0 + 2024.2.0 4.0.0 diff --git a/common/pom.xml b/common/pom.xml index 0aec78ee..470878a0 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -5,7 +5,7 @@ uni-boot-dependencies com.github.cadecode - 2024.1.0 + 2024.2.0 ../dependencies/pom.xml 4.0.0 diff --git a/dependencies/pom.xml b/dependencies/pom.xml index a912151a..df597ced 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-parent - 2024.1.0 + 2024.2.0 4.0.0 diff --git a/example/example_api/pom.xml b/example/example_api/pom.xml index b8b8f943..9e9b6015 100644 --- a/example/example_api/pom.xml +++ b/example/example_api/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-example - 2024.1.0 + 2024.2.0 4.0.0 diff --git a/example/example_svc/pom.xml b/example/example_svc/pom.xml index 81a97cc7..a9edcf44 100644 --- a/example/example_svc/pom.xml +++ b/example/example_svc/pom.xml @@ -5,7 +5,7 @@ com.github.cadecode uni-boot-example - 2024.1.0 + 2024.2.0 4.0.0 diff --git a/example/pom.xml b/example/pom.xml index 609b8a04..32ab9ec5 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -5,7 +5,7 @@ uni-boot-dependencies com.github.cadecode - 2024.1.0 + 2024.2.0 ../dependencies/pom.xml 4.0.0 diff --git a/framework/framework_api/pom.xml b/framework/framework_api/pom.xml index bb09a982..723dd731 100644 --- a/framework/framework_api/pom.xml +++ b/framework/framework_api/pom.xml @@ -6,7 +6,7 @@ com.github.cadecode uni-boot-framework - 2024.1.0 + 2024.2.0 uni-boot-framework-api diff --git a/framework/framework_base/pom.xml b/framework/framework_base/pom.xml index b91b97a1..dc8c4e1e 100644 --- a/framework/framework_base/pom.xml +++ b/framework/framework_base/pom.xml @@ -6,7 +6,7 @@ com.github.cadecode uni-boot-framework - 2024.1.0 + 2024.2.0 uni-boot-framework-base diff --git a/framework/framework_svc/pom.xml b/framework/framework_svc/pom.xml index 21974f4d..496d81fe 100644 --- a/framework/framework_svc/pom.xml +++ b/framework/framework_svc/pom.xml @@ -6,7 +6,7 @@ com.github.cadecode uni-boot-framework - 2024.1.0 + 2024.2.0 jar diff --git a/framework/pom.xml b/framework/pom.xml index 92592865..29f32f5c 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -5,7 +5,7 @@ uni-boot-dependencies com.github.cadecode - 2024.1.0 + 2024.2.0 ../dependencies/pom.xml 4.0.0 diff --git a/gateway/pom.xml b/gateway/pom.xml index 9c290d55..db90f2c9 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -5,7 +5,7 @@ uni-boot-dependencies com.github.cadecode - 2024.1.0 + 2024.2.0 ../dependencies/pom.xml 4.0.0 diff --git a/pom.xml b/pom.xml index d62a6bdf..a9fee4c5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.github.cadecode uni-boot-parent - 2024.1.0 + 2024.2.0 pom uni-boot-cloud From 5c989b69e638bc667ebd3a506e0898511fe39f4d Mon Sep 17 00:00:00 2001 From: Cade Date: Mon, 9 Sep 2024 13:54:25 +0800 Subject: [PATCH 242/244] =?UTF-8?q?fix:=20redis=20=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=20Jedis=EF=BC=8C=E8=A7=A3=E5=86=B3=20lettuce?= =?UTF-8?q?=20=E8=BF=9E=E6=8E=A5=E8=B6=85=E6=97=B6=E4=B8=8D=E9=87=8D?= =?UTF-8?q?=E8=BF=9E=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/plugin/cache/pom.xml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/common/plugin/cache/pom.xml b/common/plugin/cache/pom.xml index 76fe4c76..78b97fc5 100644 --- a/common/plugin/cache/pom.xml +++ b/common/plugin/cache/pom.xml @@ -20,12 +20,22 @@ org.springframework.boot spring-boot-starter-cache + + + io.lettuce + lettuce-core + + org.springframework.boot spring-boot-starter-data-redis + + redis.clients + jedis + org.apache.commons From 74e8cd3ae339fd88f93383792047fe5791b7a06e Mon Sep 17 00:00:00 2001 From: Cade Li Date: Thu, 20 Mar 2025 22:04:32 +0800 Subject: [PATCH 243/244] =?UTF-8?q?feat:=20=E5=8D=95=E6=9C=BA=E9=99=90?= =?UTF-8?q?=E6=B5=81=E6=B3=A8=E8=A7=A3=E6=94=AF=E6=8C=81=20guava=20?= =?UTF-8?q?=E9=A2=84=E7=83=AD=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../concurrent/annotation/RateLimit.java | 16 ++++++---- .../concurrent/aspect/RateLimitAspect.java | 31 ++++++++++++------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/common/plugin/concurrent/src/main/java/com/github/cadecode/uniboot/common/plugin/concurrent/annotation/RateLimit.java b/common/plugin/concurrent/src/main/java/com/github/cadecode/uniboot/common/plugin/concurrent/annotation/RateLimit.java index 66bcc27b..f9b43cb2 100644 --- a/common/plugin/concurrent/src/main/java/com/github/cadecode/uniboot/common/plugin/concurrent/annotation/RateLimit.java +++ b/common/plugin/concurrent/src/main/java/com/github/cadecode/uniboot/common/plugin/concurrent/annotation/RateLimit.java @@ -27,17 +27,21 @@ double limitPerSecond() default 1; /** - * 是否阻塞等待 + * 等待超时时间 + * <0 表示时间不限 + * =0 表示不等待,直接返回结果 + * >0 表示超时时间 */ - boolean blockWait() default false; + long waitTimeout() default -1; /** - * 等待时间 + * 等待时间单位 */ - long time() default 0; + TimeUnit waitTimeUnit() default TimeUnit.SECONDS; /** - * 等待时间单位 + * 预热时间,单位毫秒 + * < 0 表示不需要预热 */ - TimeUnit timeUnit() default TimeUnit.SECONDS; + long warmupMillis() default -1; } diff --git a/common/plugin/concurrent/src/main/java/com/github/cadecode/uniboot/common/plugin/concurrent/aspect/RateLimitAspect.java b/common/plugin/concurrent/src/main/java/com/github/cadecode/uniboot/common/plugin/concurrent/aspect/RateLimitAspect.java index 6fc5f741..81f5935f 100644 --- a/common/plugin/concurrent/src/main/java/com/github/cadecode/uniboot/common/plugin/concurrent/aspect/RateLimitAspect.java +++ b/common/plugin/concurrent/src/main/java/com/github/cadecode/uniboot/common/plugin/concurrent/aspect/RateLimitAspect.java @@ -12,6 +12,7 @@ import org.springframework.stereotype.Component; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; /** * 限流器切面 @@ -39,20 +40,26 @@ public void rateLimit(JoinPoint point) { // 获取注解 RateLimit rateLimit = methodSignature.getMethod().getAnnotation(RateLimit.class); // 获取 RateLimiter - RateLimiter rateLimiter = LIMITER_MAP.computeIfAbsent(methodSignature.toLongString(), m -> RateLimiter.create(rateLimit.limitPerSecond())); - // 判断是否需要阻塞等待 - if (!rateLimit.blockWait()) { - boolean acquireOk = false; - if (rateLimit.time() != 0) { - acquireOk = rateLimiter.tryAcquire(rateLimit.time(), rateLimit.timeUnit()); - } else { - acquireOk = rateLimiter.tryAcquire(); - } - if (acquireOk) { - return; + RateLimiter rateLimiter = LIMITER_MAP.computeIfAbsent(methodSignature.toLongString(), m -> { + // 判断是否需要预热 + if (rateLimit.warmupMillis() < 0) { + return RateLimiter.create(rateLimit.limitPerSecond()); } + return RateLimiter.create(rateLimit.limitPerSecond(), rateLimit.warmupMillis(), TimeUnit.MILLISECONDS); + }); + // 判断是否需要阻塞等待 + if (rateLimit.waitTimeout() < 0) { + rateLimiter.acquire(); + return; + } + boolean acquireOk; + if (rateLimit.waitTimeout() > 0) { + acquireOk = rateLimiter.tryAcquire(rateLimit.waitTimeout(), rateLimit.waitTimeUnit()); + } else { + acquireOk = rateLimiter.tryAcquire(); + } + if (!acquireOk) { throw new RateLimitException(); } - rateLimiter.acquire(); } } From 948dc24e56ff773c379e8efc97f9bc480fe83225 Mon Sep 17 00:00:00 2001 From: Cade Li Date: Fri, 21 Mar 2025 23:26:11 +0800 Subject: [PATCH 244/244] =?UTF-8?q?build:=20=E8=B0=83=E6=95=B4=20dependenc?= =?UTF-8?q?ies=20=E6=A8=A1=E5=9D=97=E4=BE=9D=E8=B5=96=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .docs/intro/create-service-example.md | 29 ++--- common/plugin/cache/pom.xml | 2 + common/plugin/concurrent/pom.xml | 2 + common/plugin/datasource/pom.xml | 2 + common/plugin/job/pom.xml | 9 +- common/plugin/log/pom.xml | 1 + common/plugin/mq/pom.xml | 11 +- common/plugin/mybatis/pom.xml | 4 +- common/plugin/storage/pom.xml | 6 ++ common/plugin/swagger/pom.xml | 2 + common/pom.xml | 3 +- dependencies/pom.xml | 121 +++++++++++---------- example/example_svc/pom.xml | 57 ++++------ example/pom.xml | 5 +- framework/framework_api/pom.xml | 20 ++-- framework/framework_base/pom.xml | 34 +++--- framework/framework_svc/pom.xml | 39 ++----- framework/pom.xml | 4 +- gateway/pom.xml | 62 ++++------- pom.xml | 150 ++++++++++++-------------- 20 files changed, 270 insertions(+), 293 deletions(-) diff --git a/.docs/intro/create-service-example.md b/.docs/intro/create-service-example.md index 02e263c6..1c2c74f5 100644 --- a/.docs/intro/create-service-example.md +++ b/.docs/intro/create-service-example.md @@ -8,15 +8,14 @@ sql/framework 目录下的 sql 是 framework 服务所需的 ### 创建模块 -创建一个模块 uni-boot-xxx,继承自 uni-boot-dependencies +创建一个模块 uni-boot-xxx,继承自 uni-boot-parent ```xml - uni-boot-dependencies + uni-boot-parent com.github.cadecode 2023.1.0 - ../dependencies/pom.xml ``` @@ -26,7 +25,7 @@ api 模块供外部调用、DTO 共享,svc 模块提供基础服务 ## 添加依赖 -本项目子模块版本维护在根 pom,第三方模块版本维护在 uni-boot-dependencies +依赖版本维护在 uni-boot-dependencies 统一管理 api 模块基本依赖: @@ -55,6 +54,18 @@ svc 模块基本依赖: ```xml + + com.github.cadecode + uni-boot-common-plugin-actuator + ${uni.version} + + + + com.github.cadecode + uni-boot-framework-base + ${uni.version} + + @@ -86,16 +97,6 @@ svc 模块基本依赖: com.github.ulisesbocchio jasypt-spring-boot-starter - - - com.github.cadecode - uni-boot-common-plugin-actuator - - - - com.github.cadecode - uni-boot-framework-base - diff --git a/common/plugin/cache/pom.xml b/common/plugin/cache/pom.xml index 78b97fc5..7eccbfb0 100644 --- a/common/plugin/cache/pom.xml +++ b/common/plugin/cache/pom.xml @@ -15,7 +15,9 @@ com.github.cadecode uni-boot-common-core + ${uni.version} + org.springframework.boot diff --git a/common/plugin/concurrent/pom.xml b/common/plugin/concurrent/pom.xml index 9b5f0e8a..48cbced1 100644 --- a/common/plugin/concurrent/pom.xml +++ b/common/plugin/concurrent/pom.xml @@ -15,7 +15,9 @@ com.github.cadecode uni-boot-common-core + ${uni.version} + com.alibaba diff --git a/common/plugin/datasource/pom.xml b/common/plugin/datasource/pom.xml index 2361cdb7..49439508 100644 --- a/common/plugin/datasource/pom.xml +++ b/common/plugin/datasource/pom.xml @@ -15,7 +15,9 @@ com.github.cadecode uni-boot-common-core + ${uni.version} + mysql diff --git a/common/plugin/job/pom.xml b/common/plugin/job/pom.xml index 350dce27..7fd73b86 100644 --- a/common/plugin/job/pom.xml +++ b/common/plugin/job/pom.xml @@ -13,13 +13,14 @@ - com.xuxueli - xxl-job-core + com.github.cadecode + uni-boot-common-core + ${uni.version} - com.github.cadecode - uni-boot-common-core + com.xuxueli + xxl-job-core diff --git a/common/plugin/log/pom.xml b/common/plugin/log/pom.xml index 88d12978..c4f27658 100644 --- a/common/plugin/log/pom.xml +++ b/common/plugin/log/pom.xml @@ -15,6 +15,7 @@ com.github.cadecode uni-boot-common-core + ${uni.version} diff --git a/common/plugin/mq/pom.xml b/common/plugin/mq/pom.xml index 3c8dca3f..1b00ae8c 100644 --- a/common/plugin/mq/pom.xml +++ b/common/plugin/mq/pom.xml @@ -12,6 +12,12 @@ uni-boot-common-plugin-mq + + com.github.cadecode + uni-boot-common-core + ${uni.version} + + com.free-now.multirabbit @@ -22,10 +28,5 @@ org.springframework.boot spring-boot-starter-amqp - - - com.github.cadecode - uni-boot-common-core - diff --git a/common/plugin/mybatis/pom.xml b/common/plugin/mybatis/pom.xml index 3abdcb8f..96bbc869 100644 --- a/common/plugin/mybatis/pom.xml +++ b/common/plugin/mybatis/pom.xml @@ -15,13 +15,15 @@ com.github.cadecode uni-boot-common-core + ${uni.version} + org.mybatis.spring.boot mybatis-spring-boot-starter - + com.baomidou mybatis-plus-boot-starter diff --git a/common/plugin/storage/pom.xml b/common/plugin/storage/pom.xml index 1eab60a2..559822f5 100644 --- a/common/plugin/storage/pom.xml +++ b/common/plugin/storage/pom.xml @@ -15,7 +15,9 @@ com.github.cadecode uni-boot-common-core + ${uni.version} + org.dromara.x-file-storage @@ -25,5 +27,9 @@ org.apache.commons commons-pool2 + + cn.hutool + hutool-extra + diff --git a/common/plugin/swagger/pom.xml b/common/plugin/swagger/pom.xml index 3c55c3db..10adc48e 100644 --- a/common/plugin/swagger/pom.xml +++ b/common/plugin/swagger/pom.xml @@ -15,7 +15,9 @@ com.github.cadecode uni-boot-common-core + ${uni.version} + com.github.xiaoymin diff --git a/common/pom.xml b/common/pom.xml index 470878a0..eae12b57 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -3,10 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - uni-boot-dependencies + uni-boot-parent com.github.cadecode 2024.2.0 - ../dependencies/pom.xml 4.0.0 diff --git a/dependencies/pom.xml b/dependencies/pom.xml index df597ced..a811227c 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -2,24 +2,15 @@ - - com.github.cadecode - uni-boot-parent - 2024.2.0 - 4.0.0 + com.github.cadecode + uni-boot-dependencies + 2024.2.0 pom - uni-boot-dependencies + uni-boot-dependencies 全局依赖版本管理 - - ../common - ../framework - ../example - ../gateway - - 2.5.4 2020.0.5 @@ -47,49 +38,13 @@ 2.1.0 2.4.0 5.1.2 - - - - - org.projectlombok - lombok - ${lombok.version} - true - - - - org.mapstruct - mapstruct - ${mapstruct.version} - - - org.mapstruct - mapstruct-processor - ${mapstruct.version} - - - - com.google.guava - guava - ${guava.vsersion} - - - - io.vavr - vavr - ${vavr.vsersion} - - - - cn.hutool - hutool-core - - - cn.hutool - hutool-extra - - + + 3.2.0 + 2.8.1 + 3.5.0 + 2.5.2 + @@ -125,6 +80,35 @@ pom import + + + org.projectlombok + lombok + ${lombok.version} + + + + org.mapstruct + mapstruct + ${mapstruct.version} + + + org.mapstruct + mapstruct-processor + ${mapstruct.version} + + + + com.google.guava + guava + ${guava.vsersion} + + + + io.vavr + vavr + ${vavr.vsersion} + net.dreamlu @@ -246,4 +230,31 @@ + + + + + + org.apache.maven.plugins + maven-resources-plugin + ${maven-resources-plugin.version} + + + org.codehaus.mojo + versions-maven-plugin + ${versions-maven-plugin.version} + + + com.rudikershaw.gitbuildhook + git-build-hook-maven-plugin + ${git-build-hook-maven-plugin.version} + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot-maven-plugin.version} + + + + diff --git a/example/example_svc/pom.xml b/example/example_svc/pom.xml index a9edcf44..0fcc9f20 100644 --- a/example/example_svc/pom.xml +++ b/example/example_svc/pom.xml @@ -9,11 +9,31 @@ 4.0.0 - jar uni-boot-example-svc 微服务样例模块-SERVICE + + com.github.cadecode + uni-boot-framework-base + ${uni.version} + + + com.github.cadecode + uni-boot-common-plugin-actuator + ${uni.version} + + + com.github.cadecode + uni-boot-common-plugin-job + ${uni.version} + + + com.github.cadecode + uni-boot-example-api + ${uni.version} + + org.springframework.cloud @@ -44,23 +64,6 @@ com.github.ulisesbocchio jasypt-spring-boot-starter - - - com.github.cadecode - uni-boot-framework-base - - - com.github.cadecode - uni-boot-common-plugin-actuator - - - com.github.cadecode - uni-boot-common-plugin-job - - - com.github.cadecode - uni-boot-example-api - @@ -69,24 +72,6 @@ org.springframework.boot spring-boot-maven-plugin - 2.5.2 - - true - true - - - org.projectlombok - lombok - - - - - - - repackage - - - diff --git a/example/pom.xml b/example/pom.xml index 32ab9ec5..b32440bc 100644 --- a/example/pom.xml +++ b/example/pom.xml @@ -3,10 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - uni-boot-dependencies + uni-boot-parent com.github.cadecode 2024.2.0 - ../dependencies/pom.xml 4.0.0 @@ -18,5 +17,5 @@ example_api example_svc - + diff --git a/framework/framework_api/pom.xml b/framework/framework_api/pom.xml index 723dd731..95b78be3 100644 --- a/framework/framework_api/pom.xml +++ b/framework/framework_api/pom.xml @@ -12,6 +12,17 @@ uni-boot-framework-api + + com.github.cadecode + uni-boot-common-core + ${uni.version} + + + com.github.cadecode + uni-boot-common-plugin-cache + ${uni.version} + + net.dreamlu mica-auto @@ -30,14 +41,5 @@ org.springframework.cloud spring-cloud-starter-loadbalancer - - - com.github.cadecode - uni-boot-common-core - - - com.github.cadecode - uni-boot-common-plugin-cache - diff --git a/framework/framework_base/pom.xml b/framework/framework_base/pom.xml index dc8c4e1e..d57ff50b 100644 --- a/framework/framework_base/pom.xml +++ b/framework/framework_base/pom.xml @@ -12,61 +12,71 @@ uni-boot-framework-base - - net.dreamlu - mica-auto - provided - - - - org.springframework.boot - spring-boot-starter-security - - com.github.cadecode uni-boot-common-core + ${uni.version} com.github.cadecode uni-boot-common-plugin-cache + ${uni.version} com.github.cadecode uni-boot-common-plugin-mybatis + ${uni.version} com.github.cadecode uni-boot-common-plugin-datasource + ${uni.version} com.github.cadecode uni-boot-common-plugin-concurrent + ${uni.version} com.github.cadecode uni-boot-common-plugin-swagger + ${uni.version} com.github.cadecode uni-boot-common-plugin-log + ${uni.version} com.github.cadecode uni-boot-common-plugin-mq + ${uni.version} com.github.cadecode uni-boot-common-plugin-storage + ${uni.version} com.github.cadecode uni-boot-common-plugin-job + ${uni.version} com.github.cadecode uni-boot-framework-api + ${uni.version} - + + net.dreamlu + mica-auto + provided + + + + org.springframework.boot + spring-boot-starter-security + + diff --git a/framework/framework_svc/pom.xml b/framework/framework_svc/pom.xml index 496d81fe..c8829c35 100644 --- a/framework/framework_svc/pom.xml +++ b/framework/framework_svc/pom.xml @@ -9,10 +9,20 @@ 2024.2.0 - jar uni-boot-framework-svc + + com.github.cadecode + uni-boot-framework-base + ${uni.version} + + + com.github.cadecode + uni-boot-common-plugin-actuator + ${uni.version} + + org.springframework.cloud @@ -48,15 +58,6 @@ cn.hutool hutool-http - - - com.github.cadecode - uni-boot-framework-base - - - com.github.cadecode - uni-boot-common-plugin-actuator - @@ -65,24 +66,6 @@ org.springframework.boot spring-boot-maven-plugin - 2.5.2 - - true - true - - - org.projectlombok - lombok - - - - - - - repackage - - - diff --git a/framework/pom.xml b/framework/pom.xml index 29f32f5c..175df1d0 100644 --- a/framework/pom.xml +++ b/framework/pom.xml @@ -3,10 +3,9 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - uni-boot-dependencies + uni-boot-parent com.github.cadecode 2024.2.0 - ../dependencies/pom.xml 4.0.0 @@ -19,4 +18,5 @@ framework_base framework_svc + diff --git a/gateway/pom.xml b/gateway/pom.xml index db90f2c9..89549706 100644 --- a/gateway/pom.xml +++ b/gateway/pom.xml @@ -3,14 +3,12 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - uni-boot-dependencies + uni-boot-parent com.github.cadecode 2024.2.0 - ../dependencies/pom.xml 4.0.0 - jar uni-boot-gateway 流量网关 @@ -19,6 +17,27 @@ + + com.github.cadecode + uni-boot-framework-api + ${uni.version} + + + com.github.cadecode + uni-boot-common-plugin-cache + + + org.springframework.boot + spring-boot-starter-web + + + + + com.github.cadecode + uni-boot-common-plugin-actuator + ${uni.version} + + org.springframework.cloud @@ -77,25 +96,6 @@ servlet-api ${servlet-api.version} - - - com.github.cadecode - uni-boot-framework-api - - - com.github.cadecode - uni-boot-common-plugin-cache - - - org.springframework.boot - spring-boot-starter-web - - - - - com.github.cadecode - uni-boot-common-plugin-actuator - @@ -104,24 +104,6 @@ org.springframework.boot spring-boot-maven-plugin - 2.5.2 - - true - true - - - org.projectlombok - lombok - - - - - - - repackage - - - diff --git a/pom.xml b/pom.xml index a9fee4c5..8cf94aa0 100644 --- a/pom.xml +++ b/pom.xml @@ -1,17 +1,24 @@ + + com.github.cadecode + uni-boot-dependencies + 2024.2.0 + dependencies + 4.0.0 - com.github.cadecode - uni-boot-parent - 2024.2.0 pom + uni-boot-parent uni-boot-cloud 基于 SpringCloud 的通用后台管理系统1骨架 - dependencies + common + example + framework + gateway @@ -24,81 +31,37 @@ ${project.version} - - - - - com.github.cadecode - uni-boot-common-core - ${uni.version} - - - com.github.cadecode - uni-boot-common-plugin-cache - ${uni.version} - - - com.github.cadecode - uni-boot-common-plugin-actuator - ${uni.version} - - - com.github.cadecode - uni-boot-common-plugin-datasource - ${uni.version} - - - com.github.cadecode - uni-boot-common-plugin-log - ${uni.version} - - - com.github.cadecode - uni-boot-common-plugin-mybatis - ${uni.version} - - - com.github.cadecode - uni-boot-common-plugin-swagger - ${uni.version} - - - com.github.cadecode - uni-boot-common-plugin-concurrent - ${uni.version} - - - com.github.cadecode - uni-boot-common-plugin-mq - ${uni.version} - - - com.github.cadecode - uni-boot-common-plugin-storage - ${uni.version} - - - com.github.cadecode - uni-boot-common-plugin-job - ${uni.version} - - - com.github.cadecode - uni-boot-framework-api - ${uni.version} - - - com.github.cadecode - uni-boot-framework-base - ${uni.version} - - - com.github.cadecode - uni-boot-example-api - ${uni.version} - - - + + + + org.projectlombok + lombok + + + + org.mapstruct + mapstruct + + + org.mapstruct + mapstruct-processor + + + + com.google.guava + guava + + + + io.vavr + vavr + + + + cn.hutool + hutool-core + + @@ -139,12 +102,10 @@ org.apache.maven.plugins maven-resources-plugin - 3.2.0 org.codehaus.mojo versions-maven-plugin - 2.8.1 false @@ -152,7 +113,6 @@ com.rudikershaw.gitbuildhook git-build-hook-maven-plugin - 3.5.0 ci/git-hooks @@ -167,6 +127,32 @@ + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot-maven-plugin.version} + + true + true + + + org.projectlombok + lombok + + + + + + + repackage + + + + + +