From 7de982d1509e7aa66b0630f29ec3899a05cce167 Mon Sep 17 00:00:00 2001
From: root <13910913995@163.com>
Date: Fri, 7 Nov 2025 22:30:59 +0800
Subject: [PATCH] refactor: replace @Value(file-space.system) with
@ConfigurationProperties
feat: add Actuator/Micrometer Prometheus and Springdoc defaults
build(app): fix MyBatis dependency convergence; relax enforcer for Maven 3.6.3
chore: add quartz.properties example and Dockerfile; remove duplicate websocket dep
---
.vscode/launch.json | 21 +
app/.gitignore | 34 +
app/Dockerfile | 21 +
app/pom.xml | 374 ++++++++++
.../com/yfd/platform/PlatformApplication.java | 45 ++
.../com/yfd/platform/ServletInitializer.java | 13 +
.../platform/annotation/AnonymousAccess.java | 30 +
.../java/com/yfd/platform/annotation/Log.java | 20 +
.../annotation/rest/AnonymousGetMapping.java | 86 +++
.../com/yfd/platform/aspect/LogAspect.java | 93 +++
.../component/ServerSendEventServer.java | 147 ++++
.../platform/component/WebSocketServer.java | 106 +++
.../yfd/platform/config/FileProperties.java | 59 ++
.../platform/config/FileSpaceProperties.java | 17 +
.../config/GlobalExceptionHandler.java | 24 +
.../com/yfd/platform/config/JobRunner.java | 56 ++
.../config/JwtAuthenticationTokenFilter.java | 83 +++
.../yfd/platform/config/MessageConfig.java | 50 ++
.../yfd/platform/config/MybitsPlusConfig.java | 24 +
.../com/yfd/platform/config/QuartzConfig.java | 77 ++
.../yfd/platform/config/ResponseResult.java | 57 ++
.../yfd/platform/config/SecurityConfig.java | 91 +++
.../yfd/platform/config/SwaggerConfig.java | 50 ++
.../com/yfd/platform/config/WebConfig.java | 58 ++
.../yfd/platform/config/WebSocketConfig.java | 16 +
.../yfd/platform/config/bean/LoginCode.java | 61 ++
.../platform/config/bean/LoginCodeEnum.java | 43 ++
.../platform/config/bean/LoginProperties.java | 110 +++
.../config/thread/AsyncTaskExecutePool.java | 70 ++
.../config/thread/AsyncTaskProperties.java | 39 +
.../config/thread/TheadFactoryName.java | 62 ++
.../config/thread/ThreadPoolExecutorUtil.java | 44 ++
.../com/yfd/platform/constant/Constant.java | 42 ++
.../yfd/platform/datasource/DataSource.java | 17 +
.../platform/datasource/DataSourceAspect.java | 55 ++
.../datasource/DynamicDataSource.java | 40 ++
.../datasource/DynamicDataSourceConfig.java | 38 +
.../exception/AccessDeniedHandExcetion.java | 27 +
.../exception/AuthenticationException.java | 32 +
.../exception/BadConfigurationException.java | 98 +++
.../exception/BadRequestException.java | 41 ++
.../exception/ChildrenExistException.java | 20 +
.../exception/EntityExistException.java | 34 +
.../exception/EntityNotFoundException.java | 34 +
.../controller/DataSourceController.java | 42 ++
.../system/controller/LoginController.java | 238 +++++++
.../system/controller/MessageController.java | 150 ++++
.../controller/QuartzJobController.java | 183 +++++
.../system/controller/SSEController.java | 59 ++
.../controller/SysConfigController.java | 68 ++
.../controller/SysDictionaryController.java | 142 ++++
.../SysDictionaryItemsController.java | 201 ++++++
.../system/controller/SysLogController.java | 74 ++
.../system/controller/SysMenuController.java | 308 ++++++++
.../controller/SysOrganizationController.java | 210 ++++++
.../system/controller/SysRoleController.java | 324 +++++++++
.../system/controller/UserController.java | 188 +++++
.../platform/system/domain/Dictionary.java | 78 ++
.../yfd/platform/system/domain/LoginUser.java | 76 ++
.../yfd/platform/system/domain/Message.java | 117 +++
.../yfd/platform/system/domain/QuartzJob.java | 118 +++
.../yfd/platform/system/domain/SysConfig.java | 78 ++
.../platform/system/domain/SysDictionary.java | 71 ++
.../system/domain/SysDictionaryItems.java | 77 ++
.../yfd/platform/system/domain/SysLog.java | 92 +++
.../yfd/platform/system/domain/SysMenu.java | 114 +++
.../system/domain/SysOrganization.java | 93 +++
.../yfd/platform/system/domain/SysRole.java | 98 +++
.../yfd/platform/system/domain/SysUser.java | 116 +++
.../platform/system/mapper/MessageMapper.java | 16 +
.../system/mapper/QuartzJobMapper.java | 16 +
.../system/mapper/SysConfigMapper.java | 17 +
.../mapper/SysDictionaryItemsMapper.java | 17 +
.../system/mapper/SysDictionaryMapper.java | 22 +
.../platform/system/mapper/SysLogMapper.java | 16 +
.../platform/system/mapper/SysMenuMapper.java | 59 ++
.../system/mapper/SysOrganizationMapper.java | 33 +
.../platform/system/mapper/SysRoleMapper.java | 89 +++
.../platform/system/mapper/SysUserMapper.java | 96 +++
.../system/service/IMessageService.java | 16 +
.../system/service/IQuartzJobService.java | 43 ++
.../system/service/ISysConfigService.java | 22 +
.../service/ISysDictionaryItemsService.java | 47 ++
.../system/service/ISysDictionaryService.java | 45 ++
.../system/service/ISysLogService.java | 52 ++
.../system/service/ISysMenuService.java | 101 +++
.../service/ISysOrganizationService.java | 60 ++
.../system/service/ISysRoleService.java | 66 ++
.../platform/system/service/IUserService.java | 143 ++++
.../service/impl/MessageServiceImpl.java | 20 +
.../service/impl/QuartzJobServiceImpl.java | 114 +++
.../service/impl/SysConfigServiceImpl.java | 34 +
.../impl/SysDictionaryItemsServiceImpl.java | 123 ++++
.../impl/SysDictionaryServiceImpl.java | 114 +++
.../service/impl/SysLogServiceImpl.java | 219 ++++++
.../service/impl/SysMenuServiceImpl.java | 674 ++++++++++++++++++
.../impl/SysOrganizationServiceImpl.java | 338 +++++++++
.../service/impl/SysRoleServiceImpl.java | 163 +++++
.../service/impl/UserDetailsServiceImpl.java | 52 ++
.../system/service/impl/UserServiceImpl.java | 550 ++++++++++++++
.../com/yfd/platform/task/TaskMessage.java | 57 ++
.../java/com/yfd/platform/utils/CallBack.java | 43 ++
.../com/yfd/platform/utils/CodeGenerator.java | 75 ++
.../yfd/platform/utils/EncryptConfigUtil.java | 28 +
.../com/yfd/platform/utils/EncryptUtils.java | 100 +++
.../com/yfd/platform/utils/ExecutionJob.java | 103 +++
.../java/com/yfd/platform/utils/FileUtil.java | 398 +++++++++++
.../com/yfd/platform/utils/MpGenerator.java | 79 ++
.../yfd/platform/utils/PropertiesUtils.java | 29 +
.../com/yfd/platform/utils/QuartzManage.java | 187 +++++
.../yfd/platform/utils/QuartzRunnable.java | 58 ++
.../com/yfd/platform/utils/RequestHolder.java | 34 +
.../java/com/yfd/platform/utils/RsaUtils.java | 181 +++++
.../com/yfd/platform/utils/SecurityUtils.java | 84 +++
.../platform/utils/SpringContextHolder.java | 145 ++++
.../com/yfd/platform/utils/StringUtils.java | 305 ++++++++
app/src/main/resources/all-application.yml | 168 +++++
app/src/main/resources/application-dev.yml | 84 +++
app/src/main/resources/application-server.yml | 43 ++
app/src/main/resources/application.yml | 36 +
app/src/main/resources/banner.txt | 8 +
app/src/main/resources/ip2region/ip2region.db | 0
.../main/resources/log4jdbc.log4j2.properties | 4 +
app/src/main/resources/logback-spring.xml | 38 +
app/src/main/resources/logback.xml | 45 ++
.../mapper/system/DictionaryMapper.xml | 5 +
.../resources/mapper/system/MessageMapper.xml | 5 +
.../resources/mapper/system/Model3dMapper.xml | 5 +
.../mapper/system/QuartzJobMapper.xml | 5 +
.../mapper/system/SysConfigMapper.xml | 5 +
.../system/SysDictionaryItemsMapper.xml | 5 +
.../mapper/system/SysDictionaryMapper.xml | 15 +
.../resources/mapper/system/SysLogMapper.xml | 5 +
.../resources/mapper/system/SysMenuMapper.xml | 103 +++
.../mapper/system/SysMessageMapper.xml | 5 +
.../mapper/system/SysOrganizationMapper.xml | 14 +
.../mapper/system/SysQuartzJobMapper.xml | 5 +
.../resources/mapper/system/SysRoleMapper.xml | 116 +++
.../resources/mapper/system/SysUserMapper.xml | 114 +++
app/src/main/resources/quartz.properties | 21 +
.../icon/0312cfde741a47ad9dfd2b6379c24229.png | Bin 0 -> 630 bytes
.../icon/1376916838a345799b96ac1eacc8608f.png | Bin 0 -> 520 bytes
.../icon/1449347c56414681a321dc3c84302b00.png | Bin 0 -> 630 bytes
.../icon/56b7117b688a40699246aa378119c005.png | Bin 0 -> 520 bytes
.../icon/78e0a2de1f8e4354ad4bc46101ff7b1d.png | Bin 0 -> 570 bytes
.../icon/88d05ff3ffa74bcd9f80584c9edf300d.png | Bin 0 -> 630 bytes
.../icon/91a883092f2a40ee84b135aea9640fd1.png | Bin 0 -> 431 bytes
.../icon/aff16e96f9164e5196942b3738c55c10.png | Bin 0 -> 630 bytes
.../icon/beaea0bdfd514f61b451d400e93f81b4.png | Bin 0 -> 498 bytes
.../icon/c6cdc92296c24d168c8c08aa2009d7ca.png | Bin 0 -> 527 bytes
.../icon/cc9abc741e7d444e9d8736056d76cb49.png | Bin 0 -> 414 bytes
.../icon/cf3e2b0ace7a42a7b627cdd4929b21d1.png | Bin 0 -> 640 bytes
.../platform/PlatformApplicationTests.java | 49 ++
.../test/java/com/yfd/platform/TestGuaVA.java | 73 ++
docs/TECHNICAL_PLAN.md | 143 ++++
155 files changed, 12276 insertions(+)
create mode 100644 .vscode/launch.json
create mode 100644 app/.gitignore
create mode 100644 app/Dockerfile
create mode 100644 app/pom.xml
create mode 100644 app/src/main/java/com/yfd/platform/PlatformApplication.java
create mode 100644 app/src/main/java/com/yfd/platform/ServletInitializer.java
create mode 100644 app/src/main/java/com/yfd/platform/annotation/AnonymousAccess.java
create mode 100644 app/src/main/java/com/yfd/platform/annotation/Log.java
create mode 100644 app/src/main/java/com/yfd/platform/annotation/rest/AnonymousGetMapping.java
create mode 100644 app/src/main/java/com/yfd/platform/aspect/LogAspect.java
create mode 100644 app/src/main/java/com/yfd/platform/component/ServerSendEventServer.java
create mode 100644 app/src/main/java/com/yfd/platform/component/WebSocketServer.java
create mode 100644 app/src/main/java/com/yfd/platform/config/FileProperties.java
create mode 100644 app/src/main/java/com/yfd/platform/config/FileSpaceProperties.java
create mode 100644 app/src/main/java/com/yfd/platform/config/GlobalExceptionHandler.java
create mode 100644 app/src/main/java/com/yfd/platform/config/JobRunner.java
create mode 100644 app/src/main/java/com/yfd/platform/config/JwtAuthenticationTokenFilter.java
create mode 100644 app/src/main/java/com/yfd/platform/config/MessageConfig.java
create mode 100644 app/src/main/java/com/yfd/platform/config/MybitsPlusConfig.java
create mode 100644 app/src/main/java/com/yfd/platform/config/QuartzConfig.java
create mode 100644 app/src/main/java/com/yfd/platform/config/ResponseResult.java
create mode 100644 app/src/main/java/com/yfd/platform/config/SecurityConfig.java
create mode 100644 app/src/main/java/com/yfd/platform/config/SwaggerConfig.java
create mode 100644 app/src/main/java/com/yfd/platform/config/WebConfig.java
create mode 100644 app/src/main/java/com/yfd/platform/config/WebSocketConfig.java
create mode 100644 app/src/main/java/com/yfd/platform/config/bean/LoginCode.java
create mode 100644 app/src/main/java/com/yfd/platform/config/bean/LoginCodeEnum.java
create mode 100644 app/src/main/java/com/yfd/platform/config/bean/LoginProperties.java
create mode 100644 app/src/main/java/com/yfd/platform/config/thread/AsyncTaskExecutePool.java
create mode 100644 app/src/main/java/com/yfd/platform/config/thread/AsyncTaskProperties.java
create mode 100644 app/src/main/java/com/yfd/platform/config/thread/TheadFactoryName.java
create mode 100644 app/src/main/java/com/yfd/platform/config/thread/ThreadPoolExecutorUtil.java
create mode 100644 app/src/main/java/com/yfd/platform/constant/Constant.java
create mode 100644 app/src/main/java/com/yfd/platform/datasource/DataSource.java
create mode 100644 app/src/main/java/com/yfd/platform/datasource/DataSourceAspect.java
create mode 100644 app/src/main/java/com/yfd/platform/datasource/DynamicDataSource.java
create mode 100644 app/src/main/java/com/yfd/platform/datasource/DynamicDataSourceConfig.java
create mode 100644 app/src/main/java/com/yfd/platform/exception/AccessDeniedHandExcetion.java
create mode 100644 app/src/main/java/com/yfd/platform/exception/AuthenticationException.java
create mode 100644 app/src/main/java/com/yfd/platform/exception/BadConfigurationException.java
create mode 100644 app/src/main/java/com/yfd/platform/exception/BadRequestException.java
create mode 100644 app/src/main/java/com/yfd/platform/exception/ChildrenExistException.java
create mode 100644 app/src/main/java/com/yfd/platform/exception/EntityExistException.java
create mode 100644 app/src/main/java/com/yfd/platform/exception/EntityNotFoundException.java
create mode 100644 app/src/main/java/com/yfd/platform/system/controller/DataSourceController.java
create mode 100644 app/src/main/java/com/yfd/platform/system/controller/LoginController.java
create mode 100644 app/src/main/java/com/yfd/platform/system/controller/MessageController.java
create mode 100644 app/src/main/java/com/yfd/platform/system/controller/QuartzJobController.java
create mode 100644 app/src/main/java/com/yfd/platform/system/controller/SSEController.java
create mode 100644 app/src/main/java/com/yfd/platform/system/controller/SysConfigController.java
create mode 100644 app/src/main/java/com/yfd/platform/system/controller/SysDictionaryController.java
create mode 100644 app/src/main/java/com/yfd/platform/system/controller/SysDictionaryItemsController.java
create mode 100644 app/src/main/java/com/yfd/platform/system/controller/SysLogController.java
create mode 100644 app/src/main/java/com/yfd/platform/system/controller/SysMenuController.java
create mode 100644 app/src/main/java/com/yfd/platform/system/controller/SysOrganizationController.java
create mode 100644 app/src/main/java/com/yfd/platform/system/controller/SysRoleController.java
create mode 100644 app/src/main/java/com/yfd/platform/system/controller/UserController.java
create mode 100644 app/src/main/java/com/yfd/platform/system/domain/Dictionary.java
create mode 100644 app/src/main/java/com/yfd/platform/system/domain/LoginUser.java
create mode 100644 app/src/main/java/com/yfd/platform/system/domain/Message.java
create mode 100644 app/src/main/java/com/yfd/platform/system/domain/QuartzJob.java
create mode 100644 app/src/main/java/com/yfd/platform/system/domain/SysConfig.java
create mode 100644 app/src/main/java/com/yfd/platform/system/domain/SysDictionary.java
create mode 100644 app/src/main/java/com/yfd/platform/system/domain/SysDictionaryItems.java
create mode 100644 app/src/main/java/com/yfd/platform/system/domain/SysLog.java
create mode 100644 app/src/main/java/com/yfd/platform/system/domain/SysMenu.java
create mode 100644 app/src/main/java/com/yfd/platform/system/domain/SysOrganization.java
create mode 100644 app/src/main/java/com/yfd/platform/system/domain/SysRole.java
create mode 100644 app/src/main/java/com/yfd/platform/system/domain/SysUser.java
create mode 100644 app/src/main/java/com/yfd/platform/system/mapper/MessageMapper.java
create mode 100644 app/src/main/java/com/yfd/platform/system/mapper/QuartzJobMapper.java
create mode 100644 app/src/main/java/com/yfd/platform/system/mapper/SysConfigMapper.java
create mode 100644 app/src/main/java/com/yfd/platform/system/mapper/SysDictionaryItemsMapper.java
create mode 100644 app/src/main/java/com/yfd/platform/system/mapper/SysDictionaryMapper.java
create mode 100644 app/src/main/java/com/yfd/platform/system/mapper/SysLogMapper.java
create mode 100644 app/src/main/java/com/yfd/platform/system/mapper/SysMenuMapper.java
create mode 100644 app/src/main/java/com/yfd/platform/system/mapper/SysOrganizationMapper.java
create mode 100644 app/src/main/java/com/yfd/platform/system/mapper/SysRoleMapper.java
create mode 100644 app/src/main/java/com/yfd/platform/system/mapper/SysUserMapper.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/IMessageService.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/IQuartzJobService.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/ISysConfigService.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/ISysDictionaryItemsService.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/ISysDictionaryService.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/ISysLogService.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/ISysMenuService.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/ISysOrganizationService.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/ISysRoleService.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/IUserService.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/impl/MessageServiceImpl.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/impl/QuartzJobServiceImpl.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/impl/SysConfigServiceImpl.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/impl/SysDictionaryItemsServiceImpl.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/impl/SysDictionaryServiceImpl.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/impl/SysLogServiceImpl.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/impl/SysMenuServiceImpl.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/impl/SysOrganizationServiceImpl.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/impl/SysRoleServiceImpl.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/impl/UserDetailsServiceImpl.java
create mode 100644 app/src/main/java/com/yfd/platform/system/service/impl/UserServiceImpl.java
create mode 100644 app/src/main/java/com/yfd/platform/task/TaskMessage.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/CallBack.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/CodeGenerator.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/EncryptConfigUtil.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/EncryptUtils.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/ExecutionJob.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/FileUtil.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/MpGenerator.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/PropertiesUtils.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/QuartzManage.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/QuartzRunnable.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/RequestHolder.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/RsaUtils.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/SecurityUtils.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/SpringContextHolder.java
create mode 100644 app/src/main/java/com/yfd/platform/utils/StringUtils.java
create mode 100644 app/src/main/resources/all-application.yml
create mode 100644 app/src/main/resources/application-dev.yml
create mode 100644 app/src/main/resources/application-server.yml
create mode 100644 app/src/main/resources/application.yml
create mode 100644 app/src/main/resources/banner.txt
create mode 100644 app/src/main/resources/ip2region/ip2region.db
create mode 100644 app/src/main/resources/log4jdbc.log4j2.properties
create mode 100644 app/src/main/resources/logback-spring.xml
create mode 100644 app/src/main/resources/logback.xml
create mode 100644 app/src/main/resources/mapper/system/DictionaryMapper.xml
create mode 100644 app/src/main/resources/mapper/system/MessageMapper.xml
create mode 100644 app/src/main/resources/mapper/system/Model3dMapper.xml
create mode 100644 app/src/main/resources/mapper/system/QuartzJobMapper.xml
create mode 100644 app/src/main/resources/mapper/system/SysConfigMapper.xml
create mode 100644 app/src/main/resources/mapper/system/SysDictionaryItemsMapper.xml
create mode 100644 app/src/main/resources/mapper/system/SysDictionaryMapper.xml
create mode 100644 app/src/main/resources/mapper/system/SysLogMapper.xml
create mode 100644 app/src/main/resources/mapper/system/SysMenuMapper.xml
create mode 100644 app/src/main/resources/mapper/system/SysMessageMapper.xml
create mode 100644 app/src/main/resources/mapper/system/SysOrganizationMapper.xml
create mode 100644 app/src/main/resources/mapper/system/SysQuartzJobMapper.xml
create mode 100644 app/src/main/resources/mapper/system/SysRoleMapper.xml
create mode 100644 app/src/main/resources/mapper/system/SysUserMapper.xml
create mode 100644 app/src/main/resources/quartz.properties
create mode 100644 app/src/main/resources/static/icon/0312cfde741a47ad9dfd2b6379c24229.png
create mode 100644 app/src/main/resources/static/icon/1376916838a345799b96ac1eacc8608f.png
create mode 100644 app/src/main/resources/static/icon/1449347c56414681a321dc3c84302b00.png
create mode 100644 app/src/main/resources/static/icon/56b7117b688a40699246aa378119c005.png
create mode 100644 app/src/main/resources/static/icon/78e0a2de1f8e4354ad4bc46101ff7b1d.png
create mode 100644 app/src/main/resources/static/icon/88d05ff3ffa74bcd9f80584c9edf300d.png
create mode 100644 app/src/main/resources/static/icon/91a883092f2a40ee84b135aea9640fd1.png
create mode 100644 app/src/main/resources/static/icon/aff16e96f9164e5196942b3738c55c10.png
create mode 100644 app/src/main/resources/static/icon/beaea0bdfd514f61b451d400e93f81b4.png
create mode 100644 app/src/main/resources/static/icon/c6cdc92296c24d168c8c08aa2009d7ca.png
create mode 100644 app/src/main/resources/static/icon/cc9abc741e7d444e9d8736056d76cb49.png
create mode 100644 app/src/main/resources/static/icon/cf3e2b0ace7a42a7b627cdd4929b21d1.png
create mode 100644 app/src/test/java/com/yfd/platform/PlatformApplicationTests.java
create mode 100644 app/src/test/java/com/yfd/platform/TestGuaVA.java
create mode 100644 docs/TECHNICAL_PLAN.md
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..02d942d
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,21 @@
+{
+ // 使用 IntelliSense 了解相关属性。
+ // 悬停以查看现有属性的描述。
+ // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "type": "java",
+ "name": "PlatformApplication",
+ "request": "launch",
+ "mainClass": "com.yfd.platform.PlatformApplication",
+ "projectName": ""
+ },
+ {
+ "type": "java",
+ "name": "Current File",
+ "request": "launch",
+ "mainClass": "${file}"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/app/.gitignore b/app/.gitignore
new file mode 100644
index 0000000..b4bd40c
--- /dev/null
+++ b/app/.gitignore
@@ -0,0 +1,34 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+/logs/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
diff --git a/app/Dockerfile b/app/Dockerfile
new file mode 100644
index 0000000..ca2a05f
--- /dev/null
+++ b/app/Dockerfile
@@ -0,0 +1,21 @@
+# syntax=docker/dockerfile:1
+FROM eclipse-temurin:17-jre-alpine
+
+LABEL maintainer="platform-team"
+
+ENV TZ=Asia/Shanghai \
+ LANG=zh_CN.UTF-8 \
+ JAVA_OPTS="-Dfile.encoding=UTF-8" \
+ SPRING_PROFILES_ACTIVE=dev
+
+RUN apk add --no-cache tzdata && \
+ ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
+
+WORKDIR /app
+
+# 注意:在构建镜像前先执行 `mvn -DskipTests package` 生成 WAR
+COPY target/platform-1.0.war /app/app.war
+
+EXPOSE 8093
+
+ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app/app.war --spring.profiles.active=$SPRING_PROFILES_ACTIVE"]
\ No newline at end of file
diff --git a/app/pom.xml b/app/pom.xml
new file mode 100644
index 0000000..4f357a2
--- /dev/null
+++ b/app/pom.xml
@@ -0,0 +1,374 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 3.3.0
+
+
+ com.yfd
+ platform
+ 1.0
+ war
+ platform
+ springboot 项目基础框架3.0
+
+ 17
+ UTF-8
+ 2023.0.1.0
+ 2023.0.1
+ 3.3.0
+ 17
+ 17
+ 17
+ 3.5.16
+ 3.5.6
+
+ 30.0-jre
+ 3.0.3
+ 1.2.20
+ 1.2.20
+ 3.32.3.2
+ 5.8.8
+ 4.1.2
+ 4.1.2
+ 1.2.70
+ 2.5.0
+ 2.3.28
+ 1.11.3
+ 1.16
+ 1.7.2
+ 1.6.2
+ 1.21
+
+
+
+
+
+
+
+ org.mybatis
+ mybatis
+ ${mybatis.version}
+
+
+ org.mybatis
+ mybatis-spring
+ 3.0.3
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-websocket
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-cache
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+ com.google.guava
+ guava
+ ${guava.version}
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-tomcat
+ provided
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-quartz
+
+
+
+
+
+
+
+
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ ${mybatis.spring.boot.starter.version}
+
+
+
+
+ org.mybatis
+ mybatis
+ ${mybatis.version}
+
+
+
+
+ com.alibaba
+ druid
+ ${druid.version}
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+
+
+
+
+ com.alibaba
+ druid-spring-boot-starter
+ ${druid.starter.version}
+
+
+
+
+ com.mysql
+ mysql-connector-j
+ runtime
+
+
+
+
+ org.xerial
+ sqlite-jdbc
+ ${sqlite-jdbc.version}
+
+
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ ${mybatis-plus.version}
+
+
+
+ com.baomidou
+ mybatis-plus-generator
+ ${mybatis-plus.version}
+
+
+
+
+ org.apache.commons
+ commons-lang3
+
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
+
+
+
+ cn.hutool
+ hutool-all
+ ${hutool.version}
+
+
+
+
+ org.apache.poi
+ poi
+ ${poi.version}
+
+
+ org.apache.poi
+ poi-ooxml
+ ${poi.ooxml.version}
+
+
+
+
+ com.alibaba
+ fastjson
+ ${fastjson.version}
+
+
+
+
+ org.springdoc
+ springdoc-openapi-starter-webmvc-ui
+ ${springdoc.version}
+
+
+
+ io.micrometer
+ micrometer-registry-prometheus
+
+
+
+ org.freemarker
+ freemarker
+ ${freemarker.version}
+ compile
+
+
+ org.jsoup
+ jsoup
+ ${jsoup.version}
+
+
+
+
+ com.github.ulisesbocchio
+ jasypt-spring-boot-starter
+ ${jasypt.version}
+
+
+
+ org.lionsoul
+ ip2region
+ ${ip2region.version}
+
+
+
+
+ com.github.whvcse
+ easy-captcha
+ ${easy.captcha.version}
+
+
+
+
+ eu.bitwalker
+ UserAgentUtils
+ ${useragentutils.version}
+
+
+
+
+
+
+ src/main/resources
+
+ **/*.*
+
+ false
+
+
+ src/main/java
+
+ **/*.*
+
+
+ **/*.java
+
+ false
+
+
+
+
+
+
+ org.asciidoctor
+ asciidoctor-maven-plugin
+ 1.5.8
+
+
+ generate-docs
+ prepare-package
+
+ process-asciidoc
+
+
+ html
+ book
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ 3.4.1
+
+
+ enforce-rules
+
+ enforce
+
+
+
+
+
+ [3.6.3,)
+
+
+ [17,)
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/com/yfd/platform/PlatformApplication.java b/app/src/main/java/com/yfd/platform/PlatformApplication.java
new file mode 100644
index 0000000..a98fea6
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/PlatformApplication.java
@@ -0,0 +1,45 @@
+package com.yfd.platform;
+
+import com.yfd.platform.annotation.rest.AnonymousGetMapping;
+import com.yfd.platform.datasource.DynamicDataSourceConfig;
+import com.yfd.platform.utils.SpringContextHolder;
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.web.servlet.ServletComponentScan;
+import org.springframework.cache.annotation.EnableCaching;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Import;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.springframework.web.bind.annotation.RestController;
+
+//@SpringBootApplication
+@RestController
+@EnableTransactionManagement
+@ServletComponentScan("com.yfd.platform.config")
+@MapperScan(basePackages = "com.yfd.platform.modules.*.mapper,com.yfd.platform.*.mapper")
+@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
+@Import({DynamicDataSourceConfig.class})
+@EnableCaching
+public class PlatformApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(PlatformApplication.class, args);
+ }
+
+ @Bean
+ public SpringContextHolder springContextHolder() {
+ return new SpringContextHolder();
+ }
+
+ /**
+ * 访问首页提示
+ *
+ * @return /
+ */
+ @AnonymousGetMapping("/")
+ public String index() {
+ return "Backend service started successfully";
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/ServletInitializer.java b/app/src/main/java/com/yfd/platform/ServletInitializer.java
new file mode 100644
index 0000000..0234b48
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/ServletInitializer.java
@@ -0,0 +1,13 @@
+package com.yfd.platform;
+
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+
+public class ServletInitializer extends SpringBootServletInitializer {
+
+ @Override
+ protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+ return application.sources(PlatformApplication.class);
+ }
+
+}
diff --git a/app/src/main/java/com/yfd/platform/annotation/AnonymousAccess.java b/app/src/main/java/com/yfd/platform/annotation/AnonymousAccess.java
new file mode 100644
index 0000000..2fbd4c0
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/annotation/AnonymousAccess.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yfd.platform.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * @author jacky
+ * 用于标记匿名访问方法
+ */
+@Inherited
+@Documented
+@Target({ElementType.METHOD,ElementType.ANNOTATION_TYPE})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface AnonymousAccess {
+
+}
diff --git a/app/src/main/java/com/yfd/platform/annotation/Log.java b/app/src/main/java/com/yfd/platform/annotation/Log.java
new file mode 100644
index 0000000..6739494
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/annotation/Log.java
@@ -0,0 +1,20 @@
+package com.yfd.platform.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author TangWei
+ * @date 2018-11-24
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Log {
+
+ String value() default "";
+
+ String module() default "";
+}
+
diff --git a/app/src/main/java/com/yfd/platform/annotation/rest/AnonymousGetMapping.java b/app/src/main/java/com/yfd/platform/annotation/rest/AnonymousGetMapping.java
new file mode 100644
index 0000000..01fcc32
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/annotation/rest/AnonymousGetMapping.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2002-2016 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.yfd.platform.annotation.rest;
+
+import com.yfd.platform.annotation.AnonymousAccess;
+import org.springframework.core.annotation.AliasFor;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import java.lang.annotation.*;
+
+/**
+ * Annotation for mapping HTTP {@code GET} requests onto specific handler
+ * methods.
+ *
+ * 支持匿名访问 GetMapping
+ *
+ * @author liaojinlong
+ * @see RequestMapping
+ */
+@AnonymousAccess
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+@RequestMapping(method = RequestMethod.GET)
+public @interface AnonymousGetMapping {
+
+ /**
+ * Alias for {@link RequestMapping#name}.
+ */
+ @AliasFor(annotation = RequestMapping.class)
+ String name() default "";
+
+ /**
+ * Alias for {@link RequestMapping#value}.
+ */
+ @AliasFor(annotation = RequestMapping.class)
+ String[] value() default {};
+
+ /**
+ * Alias for {@link RequestMapping#path}.
+ */
+ @AliasFor(annotation = RequestMapping.class)
+ String[] path() default {};
+
+ /**
+ * Alias for {@link RequestMapping#params}.
+ */
+ @AliasFor(annotation = RequestMapping.class)
+ String[] params() default {};
+
+ /**
+ * Alias for {@link RequestMapping#headers}.
+ */
+ @AliasFor(annotation = RequestMapping.class)
+ String[] headers() default {};
+
+ /**
+ * Alias for {@link RequestMapping#consumes}.
+ *
+ * @since 4.3.5
+ */
+ @AliasFor(annotation = RequestMapping.class)
+ String[] consumes() default {};
+
+ /**
+ * Alias for {@link RequestMapping#produces}.
+ */
+ @AliasFor(annotation = RequestMapping.class)
+ String[] produces() default {};
+
+}
diff --git a/app/src/main/java/com/yfd/platform/aspect/LogAspect.java b/app/src/main/java/com/yfd/platform/aspect/LogAspect.java
new file mode 100644
index 0000000..0c52a21
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/aspect/LogAspect.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yfd.platform.aspect;
+
+import com.yfd.platform.system.domain.SysLog;
+import com.yfd.platform.system.mapper.SysUserMapper;
+import com.yfd.platform.system.service.ISysLogService;
+import com.yfd.platform.system.service.IUserService;
+import com.yfd.platform.utils.RequestHolder;
+import com.yfd.platform.utils.SecurityUtils;
+import com.yfd.platform.utils.StringUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.springframework.stereotype.Component;
+
+import jakarta.annotation.Resource;
+import jakarta.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+/**
+ * @author
+ * @date 2018-11-24
+ */
+@Component
+@Aspect
+@Slf4j
+public class LogAspect {
+
+ @Resource
+ private final ISysLogService sysLogService;
+
+ @Resource
+ private IUserService userService;
+
+ ThreadLocal currentTime = new ThreadLocal<>();
+
+ public LogAspect(ISysLogService sysLogService) {
+ this.sysLogService = sysLogService;
+ }
+
+ /**
+ * 配置切入点
+ */
+ @Pointcut("@annotation(com.yfd.platform.annotation.Log)")
+ public void logPointcut() {
+ // 该方法无方法体,主要为了让同类中其他方法使用此切入点
+ }
+
+ /**
+ * 配置环绕通知,使用在方法logPointcut()上注册的切入点
+ *
+ * @param joinPoint join point for advice
+ */
+ @Around("logPointcut()")
+ public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
+ Object result;
+ currentTime.set(System.currentTimeMillis());
+ result = joinPoint.proceed();
+ SysLog log = new SysLog("INFO");
+ currentTime.remove();
+ HttpServletRequest request = RequestHolder.getHttpServletRequest();
+ Map nameInfo = userService.getNameInfo();
+ String nickname = nameInfo.get("nickname");
+ String username = nameInfo.get("username");
+ sysLogService.save(nickname, username, StringUtils.getBrowser(request),
+ StringUtils.getIp(request), joinPoint, log);
+ return result;
+ }
+
+ public String getUsername() {
+ try {
+ return SecurityUtils.getCurrentUsername();
+ } catch (Exception e) {
+ return "";
+ }
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/component/ServerSendEventServer.java b/app/src/main/java/com/yfd/platform/component/ServerSendEventServer.java
new file mode 100644
index 0000000..ca1b1fe
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/component/ServerSendEventServer.java
@@ -0,0 +1,147 @@
+package com.yfd.platform.component;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.MediaType;
+import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.function.Consumer;
+
+/**
+ * @author Huhailong
+ * SSE Server send Event 服务器推送服务
+ */
+@Slf4j
+public class ServerSendEventServer {
+
+ /**
+ * 当前连接数
+ */
+ private static AtomicInteger count = new AtomicInteger(0);
+
+ private static Map sseEmitterMap =
+ new ConcurrentHashMap<>();
+
+ public static SseEmitter connect(String userId) {
+ //设置超时时间,0表示不过期,默认是30秒,超过时间未完成会抛出异常
+ SseEmitter sseEmitter = new SseEmitter(0L);
+ //SseEmitter sseEmitter = new SseEmitter();
+ //注册回调
+ sseEmitter.onCompletion(completionCallBack(userId));
+ sseEmitter.onError(errorCallBack(userId));
+ sseEmitter.onTimeout(timeOutCallBack(userId));
+ sseEmitterMap.put(userId, sseEmitter);
+ //数量+1
+ count.getAndIncrement();
+ log.info("create new sse connect ,current user:{}", userId);
+ return sseEmitter;
+ }
+
+ /**
+ * 给指定用户发消息
+ */
+ public static void sendMessage(String userId, String message) {
+ if (sseEmitterMap.containsKey(userId)) {
+ try {
+ sseEmitterMap.get(userId).send(message);
+ } catch (IOException e) {
+ log.error("user id:{}, send message error:{}", userId,
+ e.getMessage());
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 给所有用户发消息
+ */
+ public static void sendMessage(String message) {
+ if (sseEmitterMap != null && !sseEmitterMap.isEmpty()) {
+ sseEmitterMap.forEach((k, v) -> {
+ // 发送消息
+ sendMessage(k, message);
+
+ });
+ }
+ }
+
+ /**
+ * 想多人发送消息,组播
+ */
+ public static void groupSendMessage(String groupId, String message) {
+ if (sseEmitterMap != null && !sseEmitterMap.isEmpty()) {
+ sseEmitterMap.forEach((k, v) -> {
+ try {
+ if (k.startsWith(groupId)) {
+ v.send(message, MediaType.APPLICATION_JSON);
+ }
+ } catch (IOException e) {
+ log.error("user id:{}, send message error:{}", groupId,
+ message);
+ removeUser(k);
+ }
+ });
+ }
+ }
+
+ public static void batchSendMessage(String message) {
+ sseEmitterMap.forEach((k, v) -> {
+ try {
+ v.send(message, MediaType.APPLICATION_JSON);
+ } catch (IOException e) {
+ log.error("user id:{}, send message error:{}", k,
+ e.getMessage());
+ removeUser(k);
+ }
+ });
+ }
+
+ /**
+ * 群发消息
+ */
+ public static void batchSendMessage(String message, Set userIds) {
+ userIds.forEach(userId -> sendMessage(userId, message));
+ }
+
+ public static void removeUser(String userId) {
+ sseEmitterMap.remove(userId);
+ //数量-1
+ count.getAndDecrement();
+ log.info("remove user id:{}", userId);
+ }
+
+ public static List getIds() {
+ return new ArrayList<>(sseEmitterMap.keySet());
+ }
+
+ public static int getUserCount() {
+ return count.intValue();
+ }
+
+ private static Runnable completionCallBack(String userId) {
+ return () -> {
+ log.info("结束连接,{}", userId);
+ removeUser(userId);
+ };
+ }
+
+ private static Runnable timeOutCallBack(String userId) {
+ return () -> {
+ log.info("连接超时,{}", userId);
+ removeUser(userId);
+ };
+ }
+
+ private static Consumer errorCallBack(String userId) {
+ return throwable -> {
+ log.error("连接异常,{}", userId);
+ removeUser(userId);
+ };
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/component/WebSocketServer.java b/app/src/main/java/com/yfd/platform/component/WebSocketServer.java
new file mode 100644
index 0000000..1d0b913
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/component/WebSocketServer.java
@@ -0,0 +1,106 @@
+package com.yfd.platform.component;
+
+import org.springframework.stereotype.Component;
+
+import jakarta.websocket.*;
+import jakarta.websocket.server.PathParam;
+import jakarta.websocket.server.ServerEndpoint;
+import java.io.IOException;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+@ServerEndpoint("/websocket/{token}")
+@Component
+public class WebSocketServer {
+ private static int onlineCount=0;//在线人数
+ private static CopyOnWriteArrayList webSocketSet=new CopyOnWriteArrayList();//在线用户集合
+ private Session session;//与某个客户端的连接会话
+ private String currentUser;
+
+ @OnOpen
+ public void onOpen(@PathParam("token") String token, Session session){
+ this.currentUser = token;
+ this.session=session;
+ webSocketSet.add(this);//加入set中
+ addOnlineCount();
+ System.out.println("有新连接加入!当前在线人数为"+getOnlineCount());
+ allCurrentOnline();
+ }
+
+ @OnClose
+ public void onClose(){
+ webSocketSet.remove(this);
+ subOnlineCount();
+ System.out.println("有一连接关闭!当前在线人数为" + getOnlineCount());
+ allCurrentOnline();
+ }
+
+ @OnMessage
+ public void onMessage(String message, Session session){
+ System.out.println("来自客户端的消息:"+message);
+ for (WebSocketServer item:webSocketSet){
+ try {
+ item.sendMessage(message);
+ } catch (IOException e) {
+ e.printStackTrace();
+ continue;
+ }
+ }
+ }
+
+ @OnError
+ public void onError(Session session, Throwable throwable){
+ System.out.println("发生错误!");
+ throwable.printStackTrace();
+ }
+
+ public void sendMessage(String message) throws IOException {
+ this.session.getBasicRemote().sendText(message);
+ }
+
+ /**
+ * 获取当前所有在线用户名
+ */
+ public static void allCurrentOnline(){
+ for (WebSocketServer item : webSocketSet) {
+ System.out.println(item.currentUser);
+ }
+ }
+
+ /**
+ * 发送给指定用户
+ */
+ public static void sendMessageTo(String message,String token) throws IOException {
+ for (WebSocketServer item : webSocketSet) {
+ if(item.currentUser.equals(token)){
+ item.session.getBasicRemote().sendText(message);
+ }
+ }
+ }
+
+ /**
+ * 群发自定义消息
+ */
+ public static void sendInfo(String message) throws IOException {
+ System.out.println(message);
+ for (WebSocketServer item : webSocketSet) {
+ try {
+ item.sendMessage(message);
+ } catch (IOException e) {
+ continue;
+ }
+ }
+ }
+
+ public static synchronized int getOnlineCount(){
+ return onlineCount;
+ }
+ public static synchronized void addOnlineCount(){
+ WebSocketServer.onlineCount++;
+ }
+ public static synchronized void subOnlineCount(){
+ WebSocketServer.onlineCount--;
+ }
+
+}
+
+
diff --git a/app/src/main/java/com/yfd/platform/config/FileProperties.java b/app/src/main/java/com/yfd/platform/config/FileProperties.java
new file mode 100644
index 0000000..c179499
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/FileProperties.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yfd.platform.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author
+ */
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "file")
+public class FileProperties {
+
+ /** 文件大小限制 */
+ private Long maxSize;
+
+ /** 头像大小限制 */
+ private Long avatarMaxSize;
+
+ private ElPath mac;
+
+ private ElPath linux;
+
+ private ElPath windows;
+
+ public ElPath getPath(){
+ String os = System.getProperty("os.name");
+ if(os.toLowerCase().startsWith("win")) {
+ return windows;
+ } else if(os.toLowerCase().startsWith("mac")){
+ return mac;
+ }
+ return linux;
+ }
+
+ @Data
+ public static class ElPath{
+
+ private String path;
+
+ private String avatar;
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/config/FileSpaceProperties.java b/app/src/main/java/com/yfd/platform/config/FileSpaceProperties.java
new file mode 100644
index 0000000..74aab7d
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/FileSpaceProperties.java
@@ -0,0 +1,17 @@
+package com.yfd.platform.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * 文件空间相关配置,替换 @Value("${file-space.system}") 用法
+ */
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "file-space")
+public class FileSpaceProperties {
+
+ /** 基础目录,例如 D:/data/platform/ */
+ private String system;
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/yfd/platform/config/GlobalExceptionHandler.java b/app/src/main/java/com/yfd/platform/config/GlobalExceptionHandler.java
new file mode 100644
index 0000000..d9c7d7a
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/GlobalExceptionHandler.java
@@ -0,0 +1,24 @@
+package com.yfd.platform.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * @author TangWei
+ * @Date: 2023/3/27 18:07
+ * @Description:
+ */
+@Slf4j
+@ControllerAdvice
+public class GlobalExceptionHandler {
+
+ @ResponseBody
+ @ExceptionHandler(value = Throwable.class)
+ public ResponseResult handleException(Throwable e) {
+ log.error("message:{}", e.getMessage());
+ return ResponseResult.error(e.getMessage());
+ }
+
+}
diff --git a/app/src/main/java/com/yfd/platform/config/JobRunner.java b/app/src/main/java/com/yfd/platform/config/JobRunner.java
new file mode 100644
index 0000000..c0d451e
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/JobRunner.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yfd.platform.config;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.yfd.platform.system.domain.QuartzJob;
+import com.yfd.platform.system.mapper.QuartzJobMapper;
+import com.yfd.platform.utils.QuartzManage;
+import lombok.RequiredArgsConstructor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.ApplicationArguments;
+import org.springframework.boot.ApplicationRunner;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * @author
+ * @date 2019-01-07
+ */
+@Component
+@RequiredArgsConstructor
+public class JobRunner implements ApplicationRunner {
+
+ private static final Logger log = LoggerFactory.getLogger(JobRunner.class);
+ private final QuartzJobMapper quartzJobMapper;
+ private final QuartzManage quartzManage;
+
+ /**
+ * 项目启动时重新激活启用的定时任务
+ *
+ * @param applicationArguments /
+ */
+ @Override
+ public void run(ApplicationArguments applicationArguments) {
+ log.info("--------------------注入定时任务---------------------");
+ List quartzJobs =
+ quartzJobMapper.selectList(new LambdaQueryWrapper().eq(QuartzJob::getStatus, "1"));
+ quartzJobs.forEach(quartzManage::addJob);
+ log.info("--------------------定时任务注入完成---------------------");
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/config/JwtAuthenticationTokenFilter.java b/app/src/main/java/com/yfd/platform/config/JwtAuthenticationTokenFilter.java
new file mode 100644
index 0000000..bcb79c0
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/JwtAuthenticationTokenFilter.java
@@ -0,0 +1,83 @@
+package com.yfd.platform.config;
+
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.jwt.JWT;
+import cn.hutool.jwt.JWTUtil;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.yfd.platform.component.ServerSendEventServer;
+import com.yfd.platform.constant.Constant;
+import com.yfd.platform.system.domain.LoginUser;
+import com.yfd.platform.system.domain.Message;
+import com.yfd.platform.system.service.IMessageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Component;
+import org.springframework.web.filter.OncePerRequestFilter;
+
+import jakarta.annotation.Resource;
+import jakarta.servlet.FilterChain;
+import jakarta.servlet.ServletException;
+import jakarta.servlet.http.HttpServletRequest;
+import jakarta.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+@Component
+public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
+
+ @Autowired
+ private WebConfig webConfig;
+
+ @Override
+ protected void doFilterInternal(HttpServletRequest httpServletRequest,
+ HttpServletResponse httpServletResponse,
+ FilterChain filterChain) throws ServletException, IOException {
+ //获取token
+ String uri = httpServletRequest.getRequestURI();
+ String token = httpServletRequest.getHeader("token");
+ if (StrUtil.isEmpty(token) || "/user/login".equals(uri)) {
+ filterChain.doFilter(httpServletRequest, httpServletResponse);
+ return;
+ }
+ //解析token
+ boolean isok = JWTUtil.verify(token, "12345678".getBytes());
+ String userid = "";
+ if (isok) {
+ final JWT jwt = JWTUtil.parseToken(token);
+ userid = jwt.getPayload("userid").toString();
+ //从cachekey中获取用户信息失效时间
+ String cachekey = "expire_time:" + userid;
+ if(StrUtil.isNotEmpty(webConfig.loginuserCache().get(cachekey))){
+ long expire_time =Long.parseLong(webConfig.loginuserCache().get(cachekey));
+ if (System.currentTimeMillis() > expire_time) {
+ httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN, "Token超过期限!");
+ return;
+ }
+ }
+ }
+
+ //从cachekey中获取用户信息
+ String cachekey = "login:" + userid;
+ String jsonstr = webConfig.loginuserCache().get(cachekey);
+ LoginUser loginUser = JSON.parseObject(jsonstr, LoginUser.class);
+ if (ObjectUtil.isEmpty(loginUser)) {
+ httpServletResponse.sendError(HttpServletResponse.SC_FORBIDDEN,
+ "登录用户已失效!");
+ return;
+ }
+ //存入SecurityContextHolder
+ UsernamePasswordAuthenticationToken authenticationToken =
+ new UsernamePasswordAuthenticationToken(loginUser, null,
+ loginUser.getAuthorities());
+ SecurityContextHolder.getContext().setAuthentication(authenticationToken);
+ webConfig.loginuserCache().put(Constant.TOKEN + userid, token);
+ //更新了超期时间
+ long expireTime =System.currentTimeMillis() + ( 30L * 60L * 1000L);
+ webConfig.loginuserCache().put("expire_time:" + userid, String.valueOf(expireTime));
+ //放行过滤器
+ filterChain.doFilter(httpServletRequest, httpServletResponse);
+ }
+
+}
diff --git a/app/src/main/java/com/yfd/platform/config/MessageConfig.java b/app/src/main/java/com/yfd/platform/config/MessageConfig.java
new file mode 100644
index 0000000..e079d02
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/MessageConfig.java
@@ -0,0 +1,50 @@
+package com.yfd.platform.config;
+
+import cn.hutool.cache.Cache;
+import cn.hutool.cache.impl.CacheObj;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.yfd.platform.component.ServerSendEventServer;
+import com.yfd.platform.constant.Constant;
+import com.yfd.platform.system.domain.Message;
+import com.yfd.platform.system.domain.SysUser;
+import com.yfd.platform.system.service.IMessageService;
+import com.yfd.platform.system.service.IUserService;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.stereotype.Component;
+
+import jakarta.annotation.Resource;
+import java.util.Iterator;
+
+/**
+ * @author TangWei
+ * @Date: 2023/3/24 15:56
+ * @Description:
+ */
+@Component
+public class MessageConfig {
+
+ @Resource
+ private IMessageService messageService;
+
+ @Resource
+ private IUserService userService;
+
+ @Resource
+ private WebConfig webConfig;
+
+ public void sendMessage() {
+ long count =
+ messageService.count(new LambdaQueryWrapper().eq(Message::getStatus, "1"));
+ String userId = userService.getUserInfo().getId();
+ String token = webConfig.loginuserCache().get(Constant.TOKEN + userId);
+ ServerSendEventServer.sendMessage(token, count + "");
+ }
+
+ public void addMessage(Message message) {
+ messageService.save(message);
+ long count =
+ messageService.count(new LambdaQueryWrapper().eq(Message::getStatus, "1"));
+ ServerSendEventServer.sendMessage(count + "");
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/config/MybitsPlusConfig.java b/app/src/main/java/com/yfd/platform/config/MybitsPlusConfig.java
new file mode 100644
index 0000000..de009d7
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/MybitsPlusConfig.java
@@ -0,0 +1,24 @@
+package com.yfd.platform.config;
+
+import com.baomidou.mybatisplus.annotation.DbType;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/******************************
+ * 用途说明:
+ * 作者姓名: pcj
+ * 创建时间: 2022/10/24 10:50
+ ******************************/
+@Configuration
+public class MybitsPlusConfig {
+
+ @Bean
+ public MybatisPlusInterceptor mybatisPlusInterceptor() {
+ MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
+ mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
+ return mybatisPlusInterceptor;
+ }
+
+}
diff --git a/app/src/main/java/com/yfd/platform/config/QuartzConfig.java b/app/src/main/java/com/yfd/platform/config/QuartzConfig.java
new file mode 100644
index 0000000..41a36db
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/QuartzConfig.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yfd.platform.config;
+
+import org.quartz.Scheduler;
+import org.quartz.spi.TriggerFiredBundle;
+import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.quartz.AdaptableJobFactory;
+import org.springframework.scheduling.quartz.SchedulerFactoryBean;
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDateTime;
+
+/**
+ * 定时任务配置
+ *
+ * @author /
+ * @date 2019-01-07
+ */
+@Configuration
+public class QuartzConfig {
+
+ /**
+ * 解决Job中注入Spring Bean为null的问题
+ */
+ @Component("quartzJobFactory")
+ public static class QuartzJobFactory extends AdaptableJobFactory {
+
+ private final AutowireCapableBeanFactory capableBeanFactory;
+
+ public QuartzJobFactory(AutowireCapableBeanFactory capableBeanFactory) {
+ this.capableBeanFactory = capableBeanFactory;
+ }
+
+ @Override
+ protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
+
+ //调用父类的方法
+ Object jobInstance = super.createJobInstance(bundle);
+ capableBeanFactory.autowireBean(jobInstance);
+ return jobInstance;
+ }
+ }
+
+ /**
+ * 注入scheduler到spring
+ *
+ * @param quartzJobFactory /
+ * @return Scheduler
+ * @throws Exception /
+ */
+ @Bean(name = "scheduler")
+ public Scheduler scheduler(QuartzJobFactory quartzJobFactory) throws Exception {
+ SchedulerFactoryBean factoryBean = new SchedulerFactoryBean();
+ factoryBean.setJobFactory(quartzJobFactory);
+ factoryBean.afterPropertiesSet();
+ Scheduler scheduler = factoryBean.getScheduler();
+ scheduler.start();
+ return scheduler;
+ }
+
+}
diff --git a/app/src/main/java/com/yfd/platform/config/ResponseResult.java b/app/src/main/java/com/yfd/platform/config/ResponseResult.java
new file mode 100644
index 0000000..9638fcf
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/ResponseResult.java
@@ -0,0 +1,57 @@
+package com.yfd.platform.config;
+
+import java.util.HashMap;
+
+public class ResponseResult extends HashMap {
+ private static final long serialVersionUID = 1L;
+
+ public ResponseResult() {
+ }
+
+ public static ResponseResult unlogin() {
+ return message("401", "未登录");
+ }
+
+ public static ResponseResult error() {
+ return error("操作失败");
+ }
+
+ public static ResponseResult success() {
+ return success("操作成功");
+ }
+
+ public static ResponseResult error(String msg) {
+ ResponseResult json = new ResponseResult();
+ json.put((String)"code", "1");//错误
+ json.put((String)"msg", msg);
+ return json;
+ }
+
+ public static ResponseResult message(String code, String msg) {
+ ResponseResult json = new ResponseResult();
+ json.put((String)"code", code);
+ json.put((String)"msg", msg);
+ return json;
+ }
+
+ public static ResponseResult success(String msg) {
+ ResponseResult json = new ResponseResult();
+ json.put((String)"code", "0");//正常
+ json.put((String)"msg", msg);
+ return json;
+ }
+
+ public static ResponseResult successData(Object obj) {
+ ResponseResult json = new ResponseResult();
+ json.put((String)"code", "0");//正常
+ json.put((String)"msg", "操作成功");
+ json.put("data", obj);
+ return json;
+ }
+
+
+ public ResponseResult put(String key, Object value) {
+ super.put(key, value);
+ return this;
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/config/SecurityConfig.java b/app/src/main/java/com/yfd/platform/config/SecurityConfig.java
new file mode 100644
index 0000000..f1e1cfa
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/SecurityConfig.java
@@ -0,0 +1,91 @@
+package com.yfd.platform.config;
+
+import com.yfd.platform.config.bean.LoginProperties;
+import com.yfd.platform.exception.AccessDeniedHandExcetion;
+import com.yfd.platform.exception.AuthenticationException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.http.HttpMethod;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.http.SessionCreationPolicy;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+import org.springframework.security.crypto.password.PasswordEncoder;
+import org.springframework.security.web.SecurityFilterChain;
+import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
+
+@Configuration
+public class SecurityConfig {
+
+ @Bean
+ public PasswordEncoder passwordEncoder() {
+ return new BCryptPasswordEncoder();
+ }
+
+ @Bean
+ @ConfigurationProperties(prefix = "login", ignoreUnknownFields = true)
+ public LoginProperties loginProperties() {
+ return new LoginProperties();
+ }
+
+ @Bean
+ public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception {
+ return authenticationConfiguration.getAuthenticationManager();
+ }
+
+ @Autowired
+ private JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter;
+
+ @Autowired
+ private AuthenticationException authenticationException;
+
+ @Autowired
+ private AccessDeniedHandExcetion accessDeniedHandExcetion;
+
+ @Bean
+ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
+ http
+ .csrf(csrf -> csrf.disable())
+ .sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
+ .authorizeHttpRequests(auth -> auth
+ .requestMatchers("/user/login").anonymous()
+ .requestMatchers("/user/code").permitAll()
+ .requestMatchers(HttpMethod.GET,
+ "/*.html",
+ "/**/*.html",
+ "/**/*.css",
+ "/**/*.js",
+ "/webSocket/**").permitAll()
+ .requestMatchers(
+ "/swagger-ui.html",
+ "/swagger-ui/**",
+ "/v3/api-docs/**",
+ "/v3/api-docs.yaml",
+ "/swagger-resources/**",
+ "/webjars/**",
+ "/*/api-docs").permitAll()
+ .requestMatchers(
+ "/report/**",
+ "/images/**",
+ "/pageimage/**",
+ "/avatar/**",
+ "/systemurl/**",
+ "/api/imageserver/upload").permitAll()
+ .requestMatchers("/**/**").permitAll()
+ .anyRequest().authenticated()
+ )
+ .cors(cors -> {});
+
+ http.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
+
+ http.exceptionHandling(ex -> ex
+ .authenticationEntryPoint(authenticationException)
+ .accessDeniedHandler(accessDeniedHandExcetion)
+ );
+
+ return http.build();
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/config/SwaggerConfig.java b/app/src/main/java/com/yfd/platform/config/SwaggerConfig.java
new file mode 100644
index 0000000..b92f09b
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/SwaggerConfig.java
@@ -0,0 +1,50 @@
+package com.yfd.platform.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springdoc.core.models.GroupedOpenApi;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Info;
+import io.swagger.v3.oas.models.info.Contact;
+
+/**
+ * Springdoc OpenAPI 配置
+ */
+@Configuration
+public class SwaggerConfig {
+
+ @Bean
+ public OpenAPI projectOpenAPI() {
+ return new OpenAPI()
+ .info(new Info()
+ .title("项目API 接口文档")
+ .version("3.0")
+ .description("")
+ .contact(new Contact().name("郑顺利").email("13910913995@163.com"))
+ );
+ }
+
+ @Bean
+ public GroupedOpenApi groupWebsiteApi() {
+ return GroupedOpenApi.builder()
+ .group("1. 深北莫网站")
+ .packagesToScan("com.yfd.platform.modules.sbmwebsitedb.controller")
+ .build();
+ }
+
+ @Bean
+ public GroupedOpenApi groupQuartzApi() {
+ return GroupedOpenApi.builder()
+ .group("2. 定时任务")
+ .packagesToScan("com.yfd.platform.modules.quartz.controller")
+ .build();
+ }
+
+ @Bean
+ public GroupedOpenApi groupSystemApi() {
+ return GroupedOpenApi.builder()
+ .group("3. 系统管理")
+ .packagesToScan("com.yfd.platform.system.controller")
+ .build();
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/config/WebConfig.java b/app/src/main/java/com/yfd/platform/config/WebConfig.java
new file mode 100644
index 0000000..c242a34
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/WebConfig.java
@@ -0,0 +1,58 @@
+package com.yfd.platform.config;
+
+import cn.hutool.cache.Cache;
+import cn.hutool.cache.CacheUtil;
+import lombok.SneakyThrows;
+import jakarta.annotation.Resource;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.cors.CorsConfiguration;
+import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
+import org.springframework.web.filter.CorsFilter;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
+
+@Configuration
+public class WebConfig implements WebMvcConfigurer {
+ @Resource
+ private FileSpaceProperties fileSpaceProperties;
+
+
+
+ @Bean
+ public Cache loginuserCache() {
+ return CacheUtil.newLRUCache(200);//用户登录缓存数 缺省200
+ }
+
+ @Bean
+ public CorsFilter corsFilter() {
+ UrlBasedCorsConfigurationSource source =
+ new UrlBasedCorsConfigurationSource();
+ CorsConfiguration config = new CorsConfiguration();
+ config.setAllowCredentials(true);
+ config.addAllowedOriginPattern("*");
+ config.addAllowedHeader("*");
+ config.addAllowedMethod("*");
+ config.setMaxAge(3600L);
+ source.registerCorsConfiguration("/**", config);
+ return new CorsFilter(source);
+ }
+
+ @SneakyThrows
+ @Override
+ public void addResourceHandlers(ResourceHandlerRegistry registry) {
+ // 菜单图标访问路径
+ String iconUrl = "file:" + System.getProperty("user.dir") + "\\src" +
+ "\\main\\resources\\static\\icon\\";
+ registry.addResourceHandler("/menu/**").addResourceLocations(iconUrl).setCachePeriod(0);
+
+ registry.addResourceHandler("swagger-ui.html").addResourceLocations(
+ "classpath:/META-INF/resources/");
+
+ String systemUrl = "file:" + fileSpaceProperties.getSystem().replace("\\", "/")+"user\\";
+ registry.addResourceHandler("/avatar/**").addResourceLocations(systemUrl).setCachePeriod(0);
+
+
+ }
+
+}
diff --git a/app/src/main/java/com/yfd/platform/config/WebSocketConfig.java b/app/src/main/java/com/yfd/platform/config/WebSocketConfig.java
new file mode 100644
index 0000000..349ead0
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/WebSocketConfig.java
@@ -0,0 +1,16 @@
+package com.yfd.platform.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.socket.server.standard.ServerEndpointExporter;
+
+@Configuration
+public class WebSocketConfig {
+
+ @Bean
+ public ServerEndpointExporter serverEndpointExporter() {
+
+ return new ServerEndpointExporter();
+ }
+}
+
diff --git a/app/src/main/java/com/yfd/platform/config/bean/LoginCode.java b/app/src/main/java/com/yfd/platform/config/bean/LoginCode.java
new file mode 100644
index 0000000..2a7586b
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/bean/LoginCode.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2019-2020 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yfd.platform.config.bean;
+
+import lombok.Data;
+
+/**
+ * 登录验证码配置信息
+ *
+ * @author: liaojinlong
+ * @date: 2020/6/10 18:53
+ */
+@Data
+public class LoginCode {
+
+ /**
+ * 验证码配置
+ */
+ private LoginCodeEnum codeType;
+ /**
+ * 验证码有效期 分钟
+ */
+ private Long expiration = 2L;
+ /**
+ * 验证码内容长度
+ */
+ private int length = 2;
+ /**
+ * 验证码宽度
+ */
+ private int width = 111;
+ /**
+ * 验证码高度
+ */
+ private int height = 36;
+ /**
+ * 验证码字体
+ */
+ private String fontName;
+ /**
+ * 字体大小
+ */
+ private int fontSize = 25;
+
+ public LoginCodeEnum getCodeType() {
+ return codeType;
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/config/bean/LoginCodeEnum.java b/app/src/main/java/com/yfd/platform/config/bean/LoginCodeEnum.java
new file mode 100644
index 0000000..d9ade21
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/bean/LoginCodeEnum.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2019-2020 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yfd.platform.config.bean;
+
+/**
+ * 验证码配置枚举
+ *
+ * @author: liaojinlong
+ * @date: 2020/6/10 17:40
+ */
+
+public enum LoginCodeEnum {
+ /**
+ * 算数
+ */
+ arithmetic,
+ /**
+ * 中文
+ */
+ chinese,
+ /**
+ * 中文闪图
+ */
+ chinese_gif,
+ /**
+ * 闪图
+ */
+ gif,
+ spec
+}
diff --git a/app/src/main/java/com/yfd/platform/config/bean/LoginProperties.java b/app/src/main/java/com/yfd/platform/config/bean/LoginProperties.java
new file mode 100644
index 0000000..b16644d
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/bean/LoginProperties.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2019-2020 the original author or authors.
+ *
+ * Licensed under the Apache License, Version loginCode.length.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-loginCode.length.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yfd.platform.config.bean;
+
+import cn.hutool.core.util.StrUtil;
+import com.wf.captcha.*;
+import com.wf.captcha.base.Captcha;
+import com.yfd.platform.exception.BadConfigurationException;
+import lombok.Data;
+import java.awt.*;
+import java.util.Objects;
+
+/**
+ * 配置文件读取
+ *
+ * @author liaojinlong
+ * @date loginCode.length0loginCode.length0/6/10 17:loginCode.length6
+ */
+@Data
+public class LoginProperties {
+
+ /**
+ * 账号单用户 登录
+ */
+ private boolean singleLogin = false;
+
+ private LoginCode loginCode;
+ /**
+ * 用户登录信息缓存
+ */
+ private boolean cacheEnable;
+
+ public boolean isSingleLogin() {
+ return singleLogin;
+ }
+
+ public boolean isCacheEnable() {
+ return cacheEnable;
+ }
+
+ /**
+ * 获取验证码生产类
+ *
+ * @return /
+ */
+ public Captcha getCaptcha() {
+ if (Objects.isNull(loginCode)) {
+ loginCode = new LoginCode();
+ if (Objects.isNull(loginCode.getCodeType())) {
+ loginCode.setCodeType(LoginCodeEnum.arithmetic);
+ }
+ }
+ return switchCaptcha(loginCode);
+ }
+
+ /**
+ * 依据配置信息生产验证码
+ *
+ * @param loginCode 验证码配置信息
+ * @return /
+ */
+ private Captcha switchCaptcha(LoginCode loginCode) {
+ Captcha captcha;
+ synchronized (this) {
+ switch (loginCode.getCodeType()) {
+ case arithmetic:
+ // 算术类型 https://gitee.com/whvse/EasyCaptcha
+ captcha = new ArithmeticCaptcha(loginCode.getWidth(), loginCode.getHeight());
+ // 几位数运算,默认是两位
+ captcha.setLen(loginCode.getLength());
+ break;
+ case chinese:
+ captcha = new ChineseCaptcha(loginCode.getWidth(), loginCode.getHeight());
+ captcha.setLen(loginCode.getLength());
+ break;
+ case chinese_gif:
+ captcha = new ChineseGifCaptcha(loginCode.getWidth(), loginCode.getHeight());
+ captcha.setLen(loginCode.getLength());
+ break;
+ case gif:
+ captcha = new GifCaptcha(loginCode.getWidth(), loginCode.getHeight());
+ captcha.setLen(loginCode.getLength());
+ break;
+ case spec:
+ captcha = new SpecCaptcha(loginCode.getWidth(), loginCode.getHeight());
+ captcha.setLen(loginCode.getLength());
+ break;
+ default:
+ throw new BadConfigurationException("验证码配置信息错误!正确配置查看 LoginCodeEnum ");
+ }
+ }
+ if(StrUtil.isNotBlank(loginCode.getFontName())){
+ captcha.setFont(new Font(loginCode.getFontName(), Font.PLAIN, loginCode.getFontSize()));
+ }
+ return captcha;
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/config/thread/AsyncTaskExecutePool.java b/app/src/main/java/com/yfd/platform/config/thread/AsyncTaskExecutePool.java
new file mode 100644
index 0000000..ff10654
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/thread/AsyncTaskExecutePool.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yfd.platform.config.thread;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.scheduling.annotation.AsyncConfigurer;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+import java.util.concurrent.ThreadPoolExecutor;
+
+/**
+ * 异步任务线程池装配类
+ * @author https://juejin.im/entry/5abb8f6951882555677e9da2
+ * @date 2019年10月31日15:06:18
+ */
+@Slf4j
+@Configuration
+public class AsyncTaskExecutePool implements AsyncConfigurer {
+
+ /** 注入配置类 */
+ private final AsyncTaskProperties config;
+
+ public AsyncTaskExecutePool(AsyncTaskProperties config) {
+ this.config = config;
+ }
+
+ @Override
+ public Executor getAsyncExecutor() {
+ ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
+ //核心线程池大小
+ executor.setCorePoolSize(config.getCorePoolSize());
+ //最大线程数
+ executor.setMaxPoolSize(config.getMaxPoolSize());
+ //队列容量
+ executor.setQueueCapacity(config.getQueueCapacity());
+ //活跃时间
+ executor.setKeepAliveSeconds(config.getKeepAliveSeconds());
+ //线程名字前缀
+ executor.setThreadNamePrefix("el-async-");
+ // setRejectedExecutionHandler:当pool已经达到max size的时候,如何处理新任务
+ // CallerRunsPolicy:不在新线程中执行任务,而是由调用者所在的线程来执行
+ executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+ executor.initialize();
+ return executor;
+ }
+
+ @Override
+ public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
+ return (throwable, method, objects) -> {
+ log.error("===="+throwable.getMessage()+"====", throwable);
+ log.error("exception method:"+method.getName());
+ };
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/config/thread/AsyncTaskProperties.java b/app/src/main/java/com/yfd/platform/config/thread/AsyncTaskProperties.java
new file mode 100644
index 0000000..a5bc7d2
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/thread/AsyncTaskProperties.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yfd.platform.config.thread;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * 线程池配置属性类
+ * @author https://juejin.im/entry/5abb8f6951882555677e9da2
+ * @date 2019年10月31日14:58:18
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "task.pool")
+public class AsyncTaskProperties {
+
+ private int corePoolSize;
+
+ private int maxPoolSize;
+
+ private int keepAliveSeconds;
+
+ private int queueCapacity;
+}
diff --git a/app/src/main/java/com/yfd/platform/config/thread/TheadFactoryName.java b/app/src/main/java/com/yfd/platform/config/thread/TheadFactoryName.java
new file mode 100644
index 0000000..118faba
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/thread/TheadFactoryName.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yfd.platform.config.thread;
+
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.ThreadFactory;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * 自定义线程名称
+ * @author
+ * @date 2019年10月31日17:49:55
+ */
+@Component
+public class TheadFactoryName implements ThreadFactory {
+
+ private static final AtomicInteger POOL_NUMBER = new AtomicInteger(1);
+ private final ThreadGroup group;
+ private final AtomicInteger threadNumber = new AtomicInteger(1);
+ private final String namePrefix;
+
+ public TheadFactoryName() {
+ this("el-pool");
+ }
+
+ private TheadFactoryName(String name){
+ // 使用当前线程的线程组,避免依赖已弃用的 SecurityManager
+ group = Thread.currentThread().getThreadGroup();
+ //此时namePrefix就是 name + 第几个用这个工厂创建线程池的
+ this.namePrefix = name +
+ POOL_NUMBER.getAndIncrement();
+ }
+
+ @Override
+ public Thread newThread(Runnable r) {
+ //此时线程的名字 就是 namePrefix + -thread- + 这个线程池中第几个执行的线程
+ Thread t = new Thread(group, r,
+ namePrefix + "-thread-"+threadNumber.getAndIncrement(),
+ 0);
+ if (t.isDaemon()) {
+ t.setDaemon(false);
+ }
+ if (t.getPriority() != Thread.NORM_PRIORITY) {
+ t.setPriority(Thread.NORM_PRIORITY);
+ }
+ return t;
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/config/thread/ThreadPoolExecutorUtil.java b/app/src/main/java/com/yfd/platform/config/thread/ThreadPoolExecutorUtil.java
new file mode 100644
index 0000000..cb84cc4
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/config/thread/ThreadPoolExecutorUtil.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.yfd.platform.config.thread;
+
+
+
+import com.yfd.platform.utils.SpringContextHolder;
+
+import java.util.concurrent.ArrayBlockingQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 用于获取自定义线程池
+ * @author
+ * @date 2019年10月31日18:16:47
+ */
+public class ThreadPoolExecutorUtil {
+
+ public static ThreadPoolExecutor getPoll(){
+ AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);
+ return new ThreadPoolExecutor(
+ properties.getCorePoolSize(),
+ properties.getMaxPoolSize(),
+ properties.getKeepAliveSeconds(),
+ TimeUnit.SECONDS,
+ new ArrayBlockingQueue<>(properties.getQueueCapacity()),
+ new TheadFactoryName()
+ );
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/constant/Constant.java b/app/src/main/java/com/yfd/platform/constant/Constant.java
new file mode 100644
index 0000000..c460999
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/constant/Constant.java
@@ -0,0 +1,42 @@
+package com.yfd.platform.constant;
+
+/**
+ * @author TangWei
+ * @Date: 2023/3/3 17:40
+ * @Description: 常量类
+ */
+public class Constant {
+
+ public static final String LOGIN = "login:";
+ public static final String TOKEN = "token:";
+ public static final String USER_ID = "userid";
+ public static final String DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
+
+ public static final String CODE_KEY = "code-key-";
+ public static final long CODE_EXPIRATION_TIME = 1000 * 60;
+ /**
+ * 用于IP定位转换
+ */
+ public static final String REGION = "内网IP|内网IP";
+ /**
+ * win 系统
+ */
+ public static final String WIN = "win";
+
+ /**
+ * mac 系统
+ */
+ public static final String MAC = "mac";
+
+ /**
+ * 常用接口
+ */
+ public static class Url {
+
+ // IP归属地查询
+ // public static final String IP_URL = "http://whois.pconline.com
+ // .cn/ipJson.jsp?ip=%s&json=true";
+ public static final String IP_URL = "http://whois.pconline.com" +
+ ".cn/ipJson.jsp?ip=%s&json=true";
+ }
+}
diff --git a/app/src/main/java/com/yfd/platform/datasource/DataSource.java b/app/src/main/java/com/yfd/platform/datasource/DataSource.java
new file mode 100644
index 0000000..7c6d795
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/datasource/DataSource.java
@@ -0,0 +1,17 @@
+package com.yfd.platform.datasource;
+
+import java.lang.annotation.*;
+
+/******************************
+ * 用途说明:
+ * 作者姓名: wxy
+ * 创建时间: 2022/9/23 17:48
+ ******************************/
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface DataSource {
+
+ String name() default "";
+
+}
diff --git a/app/src/main/java/com/yfd/platform/datasource/DataSourceAspect.java b/app/src/main/java/com/yfd/platform/datasource/DataSourceAspect.java
new file mode 100644
index 0000000..f20c0f8
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/datasource/DataSourceAspect.java
@@ -0,0 +1,55 @@
+package com.yfd.platform.datasource;
+
+import cn.hutool.core.util.StrUtil;
+import org.aspectj.lang.ProceedingJoinPoint;
+import org.aspectj.lang.annotation.Around;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Pointcut;
+import org.aspectj.lang.reflect.MethodSignature;
+import org.springframework.stereotype.Component;
+
+import java.lang.reflect.Method;
+
+/******************************
+ * 用途说明:
+ * 作者姓名: wxy
+ * 创建时间: 2022/9/23 17:50
+ ******************************/
+@Aspect
+@Component
+public class DataSourceAspect {
+
+ @Pointcut("@annotation(com.yfd.platform.datasource.DataSource)")
+ public void dataSourcePointCut() {
+
+ }
+
+ private String DataBaseName;
+
+ @Around("dataSourcePointCut()")
+ public Object around(ProceedingJoinPoint point) throws Throwable {
+ MethodSignature signature = (MethodSignature) point.getSignature();
+ Method method = signature.getMethod();
+ if (StrUtil.isNotBlank(DataBaseName)){
+ DynamicDataSource.setDataSource(DataBaseName);
+ }else {
+ DynamicDataSource.setDataSource("master");
+ }
+
+ try {
+ return point.proceed();
+ } finally {
+ DynamicDataSource.clearDataSource();
+ }
+ }
+
+ public String getDataBase(Integer type){
+ if (type == 1){
+ DataBaseName="master";
+ }else {
+ DataBaseName="slave";
+ }
+ return DataBaseName;
+ }
+
+}
diff --git a/app/src/main/java/com/yfd/platform/datasource/DynamicDataSource.java b/app/src/main/java/com/yfd/platform/datasource/DynamicDataSource.java
new file mode 100644
index 0000000..8b52521
--- /dev/null
+++ b/app/src/main/java/com/yfd/platform/datasource/DynamicDataSource.java
@@ -0,0 +1,40 @@
+package com.yfd.platform.datasource;
+
+import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
+
+import javax.sql.DataSource;
+import java.util.Map;
+
+/******************************
+ * 用途说明:
+ * 作者姓名: wxy
+ * 创建时间: 2022/9/23 17:47
+ ******************************/
+public class DynamicDataSource extends AbstractRoutingDataSource {
+ private static final ThreadLocal contextHolder = new ThreadLocal<>();
+
+ public DynamicDataSource(DataSource defaultTargetDataSource, Map