From b9f600d3bc4aed58e4643035f116c6211bbc8dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E4=B9=A6=E7=A7=91=E6=8A=80?= <412656+myteng@user.noreply.gitee.com> Date: Sat, 10 May 2025 02:13:24 +0000 Subject: [PATCH] =?UTF-8?q?!12=20=E4=BD=BF=E7=94=A8=E5=86=85=E5=AD=98?= =?UTF-8?q?=E7=BC=93=E5=AD=98=20*=20=E5=90=8E=E5=8F=B0=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E7=99=BB=E5=BD=95=E5=A4=B1=E8=B4=A5=E6=AC=A1=E6=95=B0?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=B8=BA10=E6=AC=A1=20*=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=20*=20=E5=90=8E=E5=8F=B0=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=96=B0=E5=A2=9E=E6=9D=83=E9=99=90=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=20*=20=E7=A7=BB=E9=99=A4redis=E5=85=B3=E9=94=AE?= =?UTF-8?q?=E5=AD=97=20*=20Merge=20branch=20'dev'=20into=20dev-cache=20*?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E9=9D=99=E6=80=81=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E4=B8=8D=E5=AD=98=E5=9C=A8=E6=8A=9B=E5=87=BA?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=20*=20=E5=88=A0=E9=99=A4redis=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E5=86=85=E5=AE=B9=20*=20=E7=A7=BB=E9=99=A4compose.yml?= =?UTF-8?q?=E4=B8=ADredis=E5=92=8Cminio=E7=9A=84=E9=85=8D=E7=BD=AE=20*=20c?= =?UTF-8?q?hangelog=20*=20=E5=90=8E=E5=8F=B0=20s3=E9=85=8D=E7=BD=AE=20*=20?= =?UTF-8?q?=E5=90=8E=E5=8F=B0=20s3=E9=85=8D=E7=BD=AE=20*=20=E4=BA=91?= =?UTF-8?q?=E5=AD=98=E5=82=A8=EF=BC=9A=E7=A7=BB=E9=99=A4minio;=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E9=98=BF=E9=87=8C=E4=BA=91oss,=E8=85=BE=E8=AE=AF?= =?UTF-8?q?=E4=BA=91cos=20*=20=E5=86=85=E5=AD=98=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=9B=BF=E6=8D=A2redis=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 11 +- CHANGELOG.md | 9 +- Dockerfile | 2 +- compose.yml | 44 +- docker/nginx/conf/nginx.conf | 27 +- docker/redis/Dockerfile | 3 - docker/redis/redis.conf | 1377 ----------------- playedu-admin/src/index.less | 4 + .../src/pages/system/config/index.tsx | 72 +- .../playedu/api/PlayeduApiApplication.java | 1 - .../java/xyz/playedu/api/bus/LoginBus.java | 5 +- .../java/xyz/playedu/api/bus/UserBus.java | 6 +- .../playedu/api/cache/LoginLimitCache.java | 7 +- .../xyz/playedu/api/cache/LoginLockCache.java | 12 +- .../api/controller/ExceptionController.java | 18 +- .../backend/AdminLogController.java | 5 +- .../backend/AdminRoleController.java | 15 +- .../backend/AdminUserController.java | 15 +- .../backend/AppConfigController.java | 8 +- .../controller/backend/CacheController.java | 65 + .../backend/CourseAttachmentController.java | 12 +- ...CourseAttachmentDownloadLogController.java | 5 +- .../backend/CourseChapterController.java | 1 - .../controller/backend/CourseController.java | 11 +- .../backend/CourseHourController.java | 7 +- .../backend/CourseUserController.java | 15 +- .../backend/DashboardController.java | 12 +- .../backend/DepartmentController.java | 7 +- .../controller/backend/LoginController.java | 12 +- .../backend/ResourceCategoryController.java | 10 +- .../backend/ResourceController.java | 7 +- .../controller/backend/SystemController.java | 11 +- .../controller/backend/UploadController.java | 21 +- .../controller/backend/UserController.java | 8 +- .../frontend/CategoryController.java | 8 +- .../controller/frontend/CourseController.java | 15 +- .../frontend/DepartmentController.java | 4 +- .../controller/frontend/HourController.java | 21 +- .../controller/frontend/LoginController.java | 5 +- .../controller/frontend/SystemController.java | 6 +- .../controller/frontend/UserController.java | 11 +- .../api/event/AdminUserLoginEvent.java | 4 +- .../api/event/CourseCategoryDestroyEvent.java | 4 +- .../api/event/CourseChapterDestroyEvent.java | 4 +- .../playedu/api/event/CourseDestroyEvent.java | 4 +- .../api/event/CourseHourCreatedEvent.java | 4 +- .../api/event/CourseHourDestroyEvent.java | 4 +- .../api/event/DepartmentDestroyEvent.java | 4 +- .../event/ResourceCategoryDestroyEvent.java | 4 +- .../event/UserCourseHourFinishedEvent.java | 4 +- .../UserCourseHourRecordDestroyEvent.java | 4 +- .../event/UserCourseRecordDestroyEvent.java | 4 +- .../playedu/api/event/UserDestroyEvent.java | 4 +- .../api/event/UserLearnCourseUpdateEvent.java | 1 - .../xyz/playedu/api/event/UserLoginEvent.java | 5 +- .../playedu/api/event/UserLogoutEvent.java | 4 +- .../api/interceptor/AdminInterceptor.java | 8 +- .../api/interceptor/ApiInterceptor.java | 3 - .../api/interceptor/FrontInterceptor.java | 6 +- .../playedu/api/interceptor/WebMvcConfig.java | 3 +- .../api/listener/AdminUserLoginListener.java | 2 - .../CourseCategoryDestroyListener.java | 1 - .../CourseChapterDestroyListener.java | 1 - .../api/listener/CourseDestroyListener.java | 1 - .../listener/CourseHourCreatedListener.java | 1 - .../listener/CourseHourDestroyListener.java | 1 - .../listener/DepartmentDestroyListener.java | 1 - .../UserCourseHourFinishedListener.java | 1 - .../UserCourseHourRecordDestroyListener.java | 2 - .../UserCourseRecordDestroyListener.java | 1 - .../api/listener/UserDestroyListener.java | 2 - .../UserLearnCourseUpdateListener.java | 2 - .../api/listener/UserLoginListener.java | 5 +- .../api/listener/UserLogoutListener.java | 2 - .../api/request/backend/AdminRoleRequest.java | 8 +- .../api/request/backend/AdminUserRequest.java | 8 +- .../api/request/backend/AppConfigRequest.java | 4 +- .../backend/CourseAttachmentMultiRequest.java | 4 +- .../backend/CourseAttachmentRequest.java | 1 - .../backend/CourseAttachmentSortRequest.java | 3 +- .../backend/CourseCategoryRequest.java | 8 +- .../request/backend/CourseChapterRequest.java | 2 - .../backend/CourseChapterSortRequest.java | 4 +- .../backend/CourseHourMultiRequest.java | 5 +- .../request/backend/CourseHourRequest.java | 2 - .../backend/CourseHourSortRequest.java | 3 +- .../api/request/backend/CourseRequest.java | 5 +- .../backend/CourseUserDestroyRequest.java | 4 +- .../backend/DepartmentParentRequest.java | 5 +- .../request/backend/DepartmentRequest.java | 8 +- .../backend/DepartmentSortRequest.java | 3 +- .../api/request/backend/LoginRequest.java | 4 +- .../backend/PasswordChangeRequest.java | 2 - .../ResourceCategoryChangeRequest.java | 5 +- .../ResourceCategoryParentRequest.java | 5 +- .../backend/ResourceCategoryRequest.java | 3 - .../backend/ResourceCategorySortRequest.java | 4 +- .../backend/ResourceDestroyMultiRequest.java | 3 +- .../api/request/backend/ResourceRequest.java | 3 - .../backend/ResourceUpdateRequest.java | 3 - .../backend/UploadFileMergeRequest.java | 2 - .../request/backend/UserImportRequest.java | 5 +- .../api/request/backend/UserRequest.java | 3 - .../frontend/ChangePasswordRequest.java | 2 - .../frontend/CourseHourRecordRequest.java | 1 - .../request/frontend/LoginLdapRequest.java | 1 - .../frontend/LoginPasswordRequest.java | 1 - .../playedu/api/schedule/LDAPSchedule.java | 2 - .../src/main/resources/application.yml | 14 - .../xyz/playedu/common/annotation/Log.java | 3 +- .../xyz/playedu/common/bus/BackendBus.java | 6 +- .../java/xyz/playedu/common/bus/LDAPBus.java | 16 +- .../xyz/playedu/common/config/AuthConfig.java | 1 - .../common/config/MybatisPlusConfig.java | 1 - .../playedu/common/config/PlayEduConfig.java | 1 - .../playedu/common/config/RedisConfig.java | 59 - .../playedu/common/config/SaTokenConfig.java | 1 - .../common/constant/BPermissionConstant.java | 10 +- .../common/constant/ConfigConstant.java | 12 +- .../common/constant/SystemConstant.java | 2 +- .../java/xyz/playedu/common/context/BCtx.java | 3 +- .../java/xyz/playedu/common/context/FCtx.java | 3 +- .../xyz/playedu/common/domain/AdminLog.java | 4 +- .../common/domain/AdminPermission.java | 4 +- .../xyz/playedu/common/domain/AdminRole.java | 4 +- .../common/domain/AdminRolePermission.java | 4 +- .../xyz/playedu/common/domain/AdminUser.java | 7 +- .../playedu/common/domain/AdminUserRole.java | 4 +- .../xyz/playedu/common/domain/AppConfig.java | 4 +- .../xyz/playedu/common/domain/Category.java | 4 +- .../xyz/playedu/common/domain/Department.java | 4 +- .../playedu/common/domain/LdapDepartment.java | 1 - .../xyz/playedu/common/domain/LdapUser.java | 1 - .../java/xyz/playedu/common/domain/User.java | 7 +- .../playedu/common/domain/UserDepartment.java | 4 +- .../common/domain/UserLoginRecord.java | 4 +- .../common/domain/UserUploadImageLog.java | 4 +- .../playedu/common/mapper/AdminLogMapper.java | 5 +- .../common/mapper/AdminPermissionMapper.java | 2 - .../common/mapper/AdminRoleMapper.java | 2 - .../mapper/AdminRolePermissionMapper.java | 2 - .../common/mapper/AdminUserMapper.java | 2 - .../common/mapper/AdminUserRoleMapper.java | 2 - .../common/mapper/AppConfigMapper.java | 2 - .../playedu/common/mapper/CategoryMapper.java | 2 - .../common/mapper/DepartmentMapper.java | 5 +- .../common/mapper/LdapDepartmentMapper.java | 1 - .../playedu/common/mapper/LdapUserMapper.java | 1 - .../common/mapper/UserDepartmentMapper.java | 2 - .../common/mapper/UserLoginRecordMapper.java | 2 - .../xyz/playedu/common/mapper/UserMapper.java | 5 +- .../mapper/UserUploadImageLogMapper.java | 2 - .../common/service/AdminLogService.java | 1 - .../service/AdminPermissionService.java | 4 +- .../service/AdminRolePermissionService.java | 1 - .../common/service/AdminRoleService.java | 4 +- .../common/service/AdminUserRoleService.java | 4 +- .../common/service/AdminUserService.java | 6 +- .../common/service/AppConfigService.java | 8 +- .../common/service/CategoryService.java | 6 +- .../common/service/DepartmentService.java | 6 +- .../common/service/LdapDepartmentService.java | 4 +- .../common/service/LdapUserService.java | 1 - .../common/service/UserDepartmentService.java | 4 +- .../service/UserLoginRecordService.java | 1 - .../playedu/common/service/UserService.java | 6 +- .../service/UserUploadImageLogService.java | 1 - .../service/impl/AdminLogServiceImpl.java | 2 - .../impl/AdminPermissionServiceImpl.java | 11 +- .../impl/AdminRolePermissionServiceImpl.java | 2 - .../service/impl/AdminRoleServiceImpl.java | 9 +- .../impl/AdminUserRoleServiceImpl.java | 5 +- .../service/impl/AdminUserServiceImpl.java | 7 +- .../service/impl/AppConfigServiceImpl.java | 60 +- .../common/service/impl/AuthServiceImpl.java | 6 +- .../service/impl/BackendAuthServiceImpl.java | 4 +- .../service/impl/CategoryServiceImpl.java | 15 +- .../service/impl/DepartmentServiceImpl.java | 8 +- .../service/impl/FrontendAuthServiceImpl.java | 4 +- .../impl/LdapDepartmentServiceImpl.java | 7 +- .../service/impl/LdapUserServiceImpl.java | 5 +- .../impl/MemoryRateLimiterServiceImpl.java | 43 + .../service/impl/RateLimiterServiceImpl.java | 42 - .../impl/UserDepartmentServiceImpl.java | 7 +- .../impl/UserLoginRecordServiceImpl.java | 2 - .../common/service/impl/UserServiceImpl.java | 10 +- .../impl/UserUploadImageLogServiceImpl.java | 2 - ...UserCourseHourRecordCourseCountMapper.java | 1 - .../UserCourseHourRecordUserCountMapper.java | 1 - ...rseHourRecordUserFirstCreatedAtMapper.java | 4 +- .../types/paginate/CoursePaginateFiler.java | 3 +- .../paginate/ResourcePaginateFilter.java | 3 +- .../types/paginate/UserPaginateFilter.java | 3 +- .../xyz/playedu/common/util/HelperUtil.java | 4 +- .../java/xyz/playedu/common/util/IpUtil.java | 5 +- .../playedu/common/util/MemoryCacheUtil.java | 198 +++ .../common/util/MemoryDistributedLock.java | 64 + .../common/util/RedisDistributedLock.java | 68 - .../xyz/playedu/common/util/RedisUtil.java | 683 -------- .../xyz/playedu/common/util/RequestUtil.java | 7 +- .../java/xyz/playedu/common/util/S3Util.java | 29 +- .../xyz/playedu/common/util/StringUtil.java | 4 +- .../common/util/ldap/LdapTransformUser.java | 3 +- .../playedu/common/util/ldap/LdapUtil.java | 11 +- .../main/resources/lua/RateLimiterScript.lua | 6 - .../java/xyz/playedu/course/bus/UserBus.java | 8 +- .../playedu/course/caches/CourseCache.java | 57 - .../course/caches/UserCanSeeCourseCache.java | 22 +- .../course/caches/UserLastLearnTimeCache.java | 7 +- .../xyz/playedu/course/domain/Course.java | 4 +- .../course/domain/CourseAttachment.java | 4 +- .../domain/CourseAttachmentDownloadLog.java | 4 +- .../playedu/course/domain/CourseCategory.java | 4 +- .../playedu/course/domain/CourseChapter.java | 4 +- .../course/domain/CourseDepartment.java | 4 +- .../xyz/playedu/course/domain/CourseHour.java | 4 +- .../course/domain/UserCourseHourRecord.java | 4 +- .../course/domain/UserCourseRecord.java | 4 +- .../course/domain/UserLatestLearn.java | 1 - .../domain/UserLearnDurationRecord.java | 4 +- .../course/domain/UserLearnDurationStats.java | 4 +- .../CourseAttachmentDownloadLogMapper.java | 5 +- .../course/mapper/CourseAttachmentMapper.java | 2 - .../course/mapper/CourseCategoryMapper.java | 2 - .../course/mapper/CourseChapterMapper.java | 2 - .../course/mapper/CourseDepartmentMapper.java | 2 - .../course/mapper/CourseHourMapper.java | 2 - .../playedu/course/mapper/CourseMapper.java | 5 +- .../mapper/UserCourseHourRecordMapper.java | 5 +- .../course/mapper/UserCourseRecordMapper.java | 5 +- .../mapper/UserLearnDurationRecordMapper.java | 2 - .../mapper/UserLearnDurationStatsMapper.java | 2 - .../CourseAttachmentDownloadLogService.java | 2 - .../service/CourseAttachmentService.java | 4 +- .../course/service/CourseCategoryService.java | 4 +- .../course/service/CourseChapterService.java | 4 +- .../service/CourseDepartmentService.java | 4 +- .../course/service/CourseHourService.java | 4 +- .../playedu/course/service/CourseService.java | 8 +- .../service/UserCourseHourRecordService.java | 4 +- .../service/UserCourseRecordService.java | 4 +- .../UserLearnDurationRecordService.java | 1 - .../UserLearnDurationStatsService.java | 4 +- ...ourseAttachmentDownloadLogServiceImpl.java | 2 - .../impl/CourseAttachmentServiceImpl.java | 9 +- .../impl/CourseCategoryServiceImpl.java | 5 +- .../impl/CourseChapterServiceImpl.java | 9 +- .../impl/CourseDepartmentServiceImpl.java | 5 +- .../service/impl/CourseHourServiceImpl.java | 9 +- .../service/impl/CourseServiceImpl.java | 8 +- .../impl/UserCourseHourRecordServiceImpl.java | 9 +- .../impl/UserCourseRecordServiceImpl.java | 9 +- .../UserLearnDurationRecordServiceImpl.java | 8 +- .../UserLearnDurationStatsServiceImpl.java | 15 +- .../xyz/playedu/resource/domain/Resource.java | 4 +- .../resource/domain/ResourceCategory.java | 4 +- .../resource/domain/ResourceVideo.java | 4 +- .../mapper/ResourceCategoryMapper.java | 2 - .../resource/mapper/ResourceMapper.java | 5 +- .../resource/mapper/ResourceVideoMapper.java | 2 - .../service/ResourceCategoryService.java | 4 +- .../resource/service/ResourceService.java | 4 +- .../service/ResourceVideoService.java | 4 +- .../resource/service/UploadService.java | 8 +- .../impl/ResourceCategoryServiceImpl.java | 7 +- .../service/impl/ResourceServiceImpl.java | 5 +- .../impl/ResourceVideoServiceImpl.java | 11 +- .../service/impl/UploadServiceImpl.java | 19 +- .../system/aspectj/AdminLogAspect.java | 11 +- .../aspectj/BackendPermissionAspect.java | 5 +- .../playedu/system/aspectj/LockAspect.java | 27 +- .../system/checks/AdminPermissionCheck.java | 4 +- .../playedu/system/checks/AppConfigCheck.java | 36 +- .../playedu/system/checks/MigrationCheck.java | 11 +- .../system/checks/SystemDataCheck.java | 2 - .../playedu/system/checks/UpgradeCheck.java | 4 +- .../xyz/playedu/system/domain/Migration.java | 1 - .../system/mapper/MigrationMapper.java | 1 - .../system/service/MigrationService.java | 4 +- .../service/impl/MigrationServiceImpl.java | 5 +- playedu-api/pom.xml | 9 - 281 files changed, 886 insertions(+), 3397 deletions(-) delete mode 100644 docker/redis/Dockerfile delete mode 100644 docker/redis/redis.conf create mode 100644 playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CacheController.java delete mode 100644 playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/RedisConfig.java create mode 100644 playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/MemoryRateLimiterServiceImpl.java delete mode 100644 playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/RateLimiterServiceImpl.java create mode 100644 playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/MemoryCacheUtil.java create mode 100644 playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/MemoryDistributedLock.java delete mode 100644 playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/RedisDistributedLock.java delete mode 100644 playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/RedisUtil.java delete mode 100644 playedu-api/playedu-common/src/main/resources/lua/RateLimiterScript.lua delete mode 100644 playedu-api/playedu-course/src/main/java/xyz/playedu/course/caches/CourseCache.java diff --git a/.env.example b/.env.example index 3cb81cc..dd91c86 100644 --- a/.env.example +++ b/.env.example @@ -6,13 +6,4 @@ PLAYEDU_ADMIN_PORT=9900 PLAYEDU_JWT_KEY=playeduxyz ################# MySQL ################### -MYSQL_PORT=3306 - -################# Redis ################### -REDIS_PORT=6379 - -################# MINIO ################### -MINIO_ROOT_USERNAME=username -MINIO_ROOT_PASSWORD=password -MINIO_PORT=9002 -MINIO_CONSOLE_PORT=50002 +MYSQL_PORT=3306 \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 2550f57..6a1c8c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,16 @@ -## 1.8 版本更新 +## 1.9 + +- 优化:移除`Redis`运行依赖改为使用内存缓存 +- 优化:移除本地存储方案`MinIO`的支持改为支持阿里云OSS和腾讯云COS + +## 1.8 - 优化:[API]日志输出 - 优化:[API]LDAP的部门同步逻辑 - 优化:[API]LDAP的用户同步逻辑 - 优化:[其它]`docker`镜像更换为阿里云加速 -## 1.7 版本更新 +## 1.7 - 新增:[API]MinIO配置信息增加环境变量的读取 - 新增:[API]学员学习权限优化 diff --git a/Dockerfile b/Dockerfile index c8d1410..04bf6ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,4 +31,4 @@ COPY --from=node-builder /app/h5/dist /app/h5 COPY docker/nginx/conf/nginx.conf /etc/nginx/sites-enabled/default -CMD nginx; echo "Waiting for MySQL/Redis/MinIO to start..."; sleep 15; java -jar /app/api/app.jar --spring.profiles.active=prod --spring.datasource.url="jdbc:mysql://${DB_HOST}:${DB_PORT:-3306}/${DB_NAME}?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true" --spring.datasource.username=${DB_USER} --spring.datasource.password=${DB_PASS} --spring.data.redis.host=${REDIS_HOST} --spring.data.redis.port=${REDIS_PORT:-6379} --spring.data.redis.password=${REDIS_PASS} --spring.data.redis.database=${REDIS_DB:-0} --sa-token.is-concurrent=${SA_TOKEN_IS_CONCURRENT:-false} --sa-token.jwt-secret-key=${SA_TOKEN_JWT_SECRET_KEY} \ No newline at end of file +CMD nginx; echo "Waiting for MySQL to start..."; sleep 15; java -jar /app/api/app.jar --spring.profiles.active=prod --spring.datasource.url="jdbc:mysql://${DB_HOST}:${DB_PORT:-3306}/${DB_NAME}?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true" --spring.datasource.username=${DB_USER} --spring.datasource.password=${DB_PASS} --sa-token.is-concurrent=${SA_TOKEN_IS_CONCURRENT:-false} --sa-token.jwt-secret-key=${SA_TOKEN_JWT_SECRET_KEY} \ No newline at end of file diff --git a/compose.yml b/compose.yml index a84d7fe..b23dbb2 100644 --- a/compose.yml +++ b/compose.yml @@ -6,21 +6,14 @@ x-logging: &default-logging networks: playedu: - driver: bridge - ipam: - driver: default - config: - - subnet: 172.10.10.0/24 + driver: host volumes: mysql-data: - redis-data: - minio-data: services: playedu: - # build: . - image: registry.cn-hangzhou.aliyuncs.com/playedu/light:1.8 + image: registry.cn-hangzhou.aliyuncs.com/playedu/light:1.9 restart: always environment: - DB_HOST=mysql @@ -28,10 +21,6 @@ services: - DB_NAME=playedu - DB_USER=root - DB_PASS=playeduxyz - - REDIS_HOST=redis - - REDIS_PASS=playeduxyz - - REDIS_PORT=6379 - - REDIS_DB=2 - SA_TOKEN_IS_CONCURRENT=false - SA_TOKEN_JWT_SECRET_KEY=${PLAYEDU_JWT_KEY:-playeduxyz} ports: @@ -45,19 +34,6 @@ services: - playedu depends_on: - mysql - - redis - - minio - logging: *default-logging - - redis: - build: ./docker/redis - restart: always - volumes: - - redis-data:/data - # ports: - # - "${REDIS_PORT:-6379}:6379" - networks: - - playedu logging: *default-logging mysql: @@ -71,22 +47,6 @@ services: - mysql-data:/var/lib/mysql # ports: # - "${MYSQL_PORT:-3306}:3306" - networks: - - playedu - logging: *default-logging - - minio: - image: registry.cn-hangzhou.aliyuncs.com/hzbs/bitnami-minio:2024.6.6 - restart: always - environment: - - MINIO_ROOT_USER=${MINIO_ROOT_USERNAME:-username} - - MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD:-password} - - MINIO_DEFAULT_BUCKETS=playedu:public - volumes: - - minio-data:/bitnami/minio/data - ports: - - "${MINIO_PORT:-9002}:9000" - - "${MINIO_CONSOLE_PORT:-50002}:9001" networks: - playedu logging: *default-logging \ No newline at end of file diff --git a/docker/nginx/conf/nginx.conf b/docker/nginx/conf/nginx.conf index 97322d9..da6c764 100644 --- a/docker/nginx/conf/nginx.conf +++ b/docker/nginx/conf/nginx.conf @@ -1,5 +1,18 @@ client_max_body_size 50m; +server { + listen 9700; + server_name _; + root /app/pc; + index index.html; + + location / { + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://127.0.0.1:9898/; + } +} + server { listen 9800; server_name _; @@ -73,18 +86,4 @@ server { location ~* ^/(?![api].*) { try_files $uri /index.html; } -} - - -server { - listen 9700; - server_name _; - root /app/pc; - index index.html; - - location / { - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_pass http://127.0.0.1:9898/; - } } \ No newline at end of file diff --git a/docker/redis/Dockerfile b/docker/redis/Dockerfile deleted file mode 100644 index 4891291..0000000 --- a/docker/redis/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM registry.cn-hangzhou.aliyuncs.com/hzbs/redis:7.0.12 - -COPY redis.conf /usr/local/etc/redis/redis.conf \ No newline at end of file diff --git a/docker/redis/redis.conf b/docker/redis/redis.conf deleted file mode 100644 index 1b2352a..0000000 --- a/docker/redis/redis.conf +++ /dev/null @@ -1,1377 +0,0 @@ -# Redis configuration file example. -# -# Note that in order to read the configuration file, Redis must be -# started with the file path as first argument: -# -# ./redis-server /path/to/redis.conf - -# Note on units: when memory size is needed, it is possible to specify -# it in the usual form of 1k 5GB 4M and so forth: -# -# 1k => 1000 bytes -# 1kb => 1024 bytes -# 1m => 1000000 bytes -# 1mb => 1024*1024 bytes -# 1g => 1000000000 bytes -# 1gb => 1024*1024*1024 bytes -# -# units are case insensitive so 1GB 1Gb 1gB are all the same. - -################################## INCLUDES ################################### - -# Include one or more other config files here. This is useful if you -# have a standard template that goes to all Redis servers but also need -# to customize a few per-server settings. Include files can include -# other files, so use this wisely. -# -# Notice option "include" won't be rewritten by command "CONFIG REWRITE" -# from admin or Redis Sentinel. Since Redis always uses the last processed -# line as value of a configuration directive, you'd better put includes -# at the beginning of this file to avoid overwriting config change at runtime. -# -# If instead you are interested in using includes to override configuration -# options, it is better to use include as the last line. -# -# include /path/to/local.conf -# include /path/to/other.conf - -################################## MODULES ##################################### - -# Load modules at startup. If the server is not able to load modules -# it will abort. It is possible to use multiple loadmodule directives. -# -# loadmodule /path/to/my_module.so -# loadmodule /path/to/other_module.so - -################################## NETWORK ##################################### - -# By default, if no "bind" configuration directive is specified, Redis listens -# for connections from all the network interfaces available on the server. -# It is possible to listen to just one or multiple selected interfaces using -# the "bind" configuration directive, followed by one or more IP addresses. -# -# Examples: -# -# bind 192.168.1.100 10.0.0.1 -# bind 127.0.0.1 ::1 -# -# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the -# internet, binding to all the interfaces is dangerous and will expose the -# instance to everybody on the internet. So by default we uncomment the -# following bind directive, that will force Redis to listen only into -# the IPv4 loopback interface address (this means Redis will be able to -# accept connections only from clients running into the same computer it -# is running). -# -# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES -# JUST COMMENT THE FOLLOWING LINE. -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -bind 0.0.0.0 - -# Protected mode is a layer of security protection, in order to avoid that -# Redis instances left open on the internet are accessed and exploited. -# -# When protected mode is on and if: -# -# 1) The server is not binding explicitly to a set of addresses using the -# "bind" directive. -# 2) No password is configured. -# -# The server only accepts connections from clients connecting from the -# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain -# sockets. -# -# By default protected mode is enabled. You should disable it only if -# you are sure you want clients from other hosts to connect to Redis -# even if no authentication is configured, nor a specific set of interfaces -# are explicitly listed using the "bind" directive. -protected-mode yes - -# Accept connections on the specified port, default is 6379 (IANA #815344). -# If port 0 is specified Redis will not listen on a TCP socket. -port 6379 - -# TCP listen() backlog. -# -# In high requests-per-second environments you need an high backlog in order -# to avoid slow clients connections issues. Note that the Linux kernel -# will silently truncate it to the value of /proc/sys/net/core/somaxconn so -# make sure to raise both the value of somaxconn and tcp_max_syn_backlog -# in order to get the desired effect. -tcp-backlog 511 - -# Unix socket. -# -# Specify the path for the Unix socket that will be used to listen for -# incoming connections. There is no default, so Redis will not listen -# on a unix socket when not specified. -# -# unixsocket /tmp/redis.sock -# unixsocketperm 700 - -# Close the connection after a client is idle for N seconds (0 to disable) -timeout 0 - -# TCP keepalive. -# -# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence -# of communication. This is useful for two reasons: -# -# 1) Detect dead peers. -# 2) Take the connection alive from the point of view of network -# equipment in the middle. -# -# On Linux, the specified value (in seconds) is the period used to send ACKs. -# Note that to close the connection the double of the time is needed. -# On other kernels the period depends on the kernel configuration. -# -# A reasonable value for this option is 300 seconds, which is the new -# Redis default starting with Redis 3.2.1. -tcp-keepalive 300 - -################################# GENERAL ##################################### - -# By default Redis does not run as a daemon. Use 'yes' if you need it. -# Note that Redis will write a pid file in /var/run/redis.pid when daemonized. -daemonize no - -# If you run Redis from upstart or systemd, Redis can interact with your -# supervision tree. Options: -# supervised no - no supervision interaction -# supervised upstart - signal upstart by putting Redis into SIGSTOP mode -# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET -# supervised auto - detect upstart or systemd method based on -# UPSTART_JOB or NOTIFY_SOCKET environment variables -# Note: these supervision methods only signal "process is ready." -# They do not enable continuous liveness pings back to your supervisor. -supervised no - -# If a pid file is specified, Redis writes it where specified at startup -# and removes it at exit. -# -# When the server runs non daemonized, no pid file is created if none is -# specified in the configuration. When the server is daemonized, the pid file -# is used even if not specified, defaulting to "/var/run/redis.pid". -# -# Creating a pid file is best effort: if Redis is not able to create it -# nothing bad happens, the server will start and run normally. -pidfile /var/run/redis_6379.pid - -# Specify the server verbosity level. -# This can be one of: -# debug (a lot of information, useful for development/testing) -# verbose (many rarely useful info, but not a mess like the debug level) -# notice (moderately verbose, what you want in production probably) -# warning (only very important / critical messages are logged) -loglevel notice - -# Specify the log file name. Also the empty string can be used to force -# Redis to log on the standard output. Note that if you use standard -# output for logging but daemonize, logs will be sent to /dev/null -logfile "" - -# To enable logging to the system logger, just set 'syslog-enabled' to yes, -# and optionally update the other syslog parameters to suit your needs. -# syslog-enabled no - -# Specify the syslog identity. -# syslog-ident redis - -# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7. -# syslog-facility local0 - -# Set the number of databases. The default database is DB 0, you can select -# a different one on a per-connection basis using SELECT where -# dbid is a number between 0 and 'databases'-1 -databases 16 - -# By default Redis shows an ASCII art logo only when started to log to the -# standard output and if the standard output is a TTY. Basically this means -# that normally a logo is displayed only in interactive sessions. -# -# However it is possible to force the pre-4.0 behavior and always show a -# ASCII art logo in startup logs by setting the following option to yes. -always-show-logo yes - -################################ SNAPSHOTTING ################################ -# -# Save the DB on disk: -# -# save -# -# Will save the DB if both the given number of seconds and the given -# number of write operations against the DB occurred. -# -# In the example below the behaviour will be to save: -# after 900 sec (15 min) if at least 1 key changed -# after 300 sec (5 min) if at least 10 keys changed -# after 60 sec if at least 10000 keys changed -# -# Note: you can disable saving completely by commenting out all "save" lines. -# -# It is also possible to remove all the previously configured save -# points by adding a save directive with a single empty string argument -# like in the following example: -# -# save "" - -save 900 1 -save 300 10 -save 60 10000 - -# By default Redis will stop accepting writes if RDB snapshots are enabled -# (at least one save point) and the latest background save failed. -# This will make the user aware (in a hard way) that data is not persisting -# on disk properly, otherwise chances are that no one will notice and some -# disaster will happen. -# -# If the background saving process will start working again Redis will -# automatically allow writes again. -# -# However if you have setup your proper monitoring of the Redis server -# and persistence, you may want to disable this feature so that Redis will -# continue to work as usual even if there are problems with disk, -# permissions, and so forth. -stop-writes-on-bgsave-error yes - -# Compress string objects using LZF when dump .rdb databases? -# For default that's set to 'yes' as it's almost always a win. -# If you want to save some CPU in the saving child set it to 'no' but -# the dataset will likely be bigger if you have compressible values or keys. -rdbcompression yes - -# Since version 5 of RDB a CRC64 checksum is placed at the end of the file. -# This makes the format more resistant to corruption but there is a performance -# hit to pay (around 10%) when saving and loading RDB files, so you can disable it -# for maximum performances. -# -# RDB files created with checksum disabled have a checksum of zero that will -# tell the loading code to skip the check. -rdbchecksum yes - -# The filename where to dump the DB -dbfilename dump.rdb - -# The working directory. -# -# The DB will be written inside this directory, with the filename specified -# above using the 'dbfilename' configuration directive. -# -# The Append Only File will also be created inside this directory. -# -# Note that you must specify a directory here, not a file name. -dir ./ - -################################# REPLICATION ################################# - -# Master-Replica replication. Use replicaof to make a Redis instance a copy of -# another Redis server. A few things to understand ASAP about Redis replication. -# -# +------------------+ +---------------+ -# | Master | ---> | Replica | -# | (receive writes) | | (exact copy) | -# +------------------+ +---------------+ -# -# 1) Redis replication is asynchronous, but you can configure a master to -# stop accepting writes if it appears to be not connected with at least -# a given number of replicas. -# 2) Redis replicas are able to perform a partial resynchronization with the -# master if the replication link is lost for a relatively small amount of -# time. You may want to configure the replication backlog size (see the next -# sections of this file) with a sensible value depending on your needs. -# 3) Replication is automatic and does not need user intervention. After a -# network partition replicas automatically try to reconnect to masters -# and resynchronize with them. -# -# replicaof - -# If the master is password protected (using the "requirepass" configuration -# directive below) it is possible to tell the replica to authenticate before -# starting the replication synchronization process, otherwise the master will -# refuse the replica request. -# -# masterauth - -# When a replica loses its connection with the master, or when the replication -# is still in progress, the replica can act in two different ways: -# -# 1) if replica-serve-stale-data is set to 'yes' (the default) the replica will -# still reply to client requests, possibly with out of date data, or the -# data set may just be empty if this is the first synchronization. -# -# 2) if replica-serve-stale-data is set to 'no' the replica will reply with -# an error "SYNC with master in progress" to all the kind of commands -# but to INFO, replicaOF, AUTH, PING, SHUTDOWN, REPLCONF, ROLE, CONFIG, -# SUBSCRIBE, UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBLISH, PUBSUB, -# COMMAND, POST, HOST: and LATENCY. -# -replica-serve-stale-data yes - -# You can configure a replica instance to accept writes or not. Writing against -# a replica instance may be useful to store some ephemeral data (because data -# written on a replica will be easily deleted after resync with the master) but -# may also cause problems if clients are writing to it because of a -# misconfiguration. -# -# Since Redis 2.6 by default replicas are read-only. -# -# Note: read only replicas are not designed to be exposed to untrusted clients -# on the internet. It's just a protection layer against misuse of the instance. -# Still a read only replica exports by default all the administrative commands -# such as CONFIG, DEBUG, and so forth. To a limited extent you can improve -# security of read only replicas using 'rename-command' to shadow all the -# administrative / dangerous commands. -replica-read-only yes - -# Replication SYNC strategy: disk or socket. -# -# ------------------------------------------------------- -# WARNING: DISKLESS REPLICATION IS EXPERIMENTAL CURRENTLY -# ------------------------------------------------------- -# -# New replicas and reconnecting replicas that are not able to continue the replication -# process just receiving differences, need to do what is called a "full -# synchronization". An RDB file is transmitted from the master to the replicas. -# The transmission can happen in two different ways: -# -# 1) Disk-backed: The Redis master creates a new process that writes the RDB -# file on disk. Later the file is transferred by the parent -# process to the replicas incrementally. -# 2) Diskless: The Redis master creates a new process that directly writes the -# RDB file to replica sockets, without touching the disk at all. -# -# With disk-backed replication, while the RDB file is generated, more replicas -# can be queued and served with the RDB file as soon as the current child producing -# the RDB file finishes its work. With diskless replication instead once -# the transfer starts, new replicas arriving will be queued and a new transfer -# will start when the current one terminates. -# -# When diskless replication is used, the master waits a configurable amount of -# time (in seconds) before starting the transfer in the hope that multiple replicas -# will arrive and the transfer can be parallelized. -# -# With slow disks and fast (large bandwidth) networks, diskless replication -# works better. -repl-diskless-sync no - -# When diskless replication is enabled, it is possible to configure the delay -# the server waits in order to spawn the child that transfers the RDB via socket -# to the replicas. -# -# This is important since once the transfer starts, it is not possible to serve -# new replicas arriving, that will be queued for the next RDB transfer, so the server -# waits a delay in order to let more replicas arrive. -# -# The delay is specified in seconds, and by default is 5 seconds. To disable -# it entirely just set it to 0 seconds and the transfer will start ASAP. -repl-diskless-sync-delay 5 - -# Replicas send PINGs to server in a predefined interval. It's possible to change -# this interval with the repl_ping_replica_period option. The default value is 10 -# seconds. -# -# repl-ping-replica-period 10 - -# The following option sets the replication timeout for: -# -# 1) Bulk transfer I/O during SYNC, from the point of view of replica. -# 2) Master timeout from the point of view of replicas (data, pings). -# 3) Replica timeout from the point of view of masters (REPLCONF ACK pings). -# -# It is important to make sure that this value is greater than the value -# specified for repl-ping-replica-period otherwise a timeout will be detected -# every time there is low traffic between the master and the replica. -# -# repl-timeout 60 - -# Disable TCP_NODELAY on the replica socket after SYNC? -# -# If you select "yes" Redis will use a smaller number of TCP packets and -# less bandwidth to send data to replicas. But this can add a delay for -# the data to appear on the replica side, up to 40 milliseconds with -# Linux kernels using a default configuration. -# -# If you select "no" the delay for data to appear on the replica side will -# be reduced but more bandwidth will be used for replication. -# -# By default we optimize for low latency, but in very high traffic conditions -# or when the master and replicas are many hops away, turning this to "yes" may -# be a good idea. -repl-disable-tcp-nodelay no - -# Set the replication backlog size. The backlog is a buffer that accumulates -# replica data when replicas are disconnected for some time, so that when a replica -# wants to reconnect again, often a full resync is not needed, but a partial -# resync is enough, just passing the portion of data the replica missed while -# disconnected. -# -# The bigger the replication backlog, the longer the time the replica can be -# disconnected and later be able to perform a partial resynchronization. -# -# The backlog is only allocated once there is at least a replica connected. -# -# repl-backlog-size 1mb - -# After a master has no longer connected replicas for some time, the backlog -# will be freed. The following option configures the amount of seconds that -# need to elapse, starting from the time the last replica disconnected, for -# the backlog buffer to be freed. -# -# Note that replicas never free the backlog for timeout, since they may be -# promoted to masters later, and should be able to correctly "partially -# resynchronize" with the replicas: hence they should always accumulate backlog. -# -# A value of 0 means to never release the backlog. -# -# repl-backlog-ttl 3600 - -# The replica priority is an integer number published by Redis in the INFO output. -# It is used by Redis Sentinel in order to select a replica to promote into a -# master if the master is no longer working correctly. -# -# A replica with a low priority number is considered better for promotion, so -# for instance if there are three replicas with priority 10, 100, 25 Sentinel will -# pick the one with priority 10, that is the lowest. -# -# However a special priority of 0 marks the replica as not able to perform the -# role of master, so a replica with priority of 0 will never be selected by -# Redis Sentinel for promotion. -# -# By default the priority is 100. -replica-priority 100 - -# It is possible for a master to stop accepting writes if there are less than -# N replicas connected, having a lag less or equal than M seconds. -# -# The N replicas need to be in "online" state. -# -# The lag in seconds, that must be <= the specified value, is calculated from -# the last ping received from the replica, that is usually sent every second. -# -# This option does not GUARANTEE that N replicas will accept the write, but -# will limit the window of exposure for lost writes in case not enough replicas -# are available, to the specified number of seconds. -# -# For example to require at least 3 replicas with a lag <= 10 seconds use: -# -# min-replicas-to-write 3 -# min-replicas-max-lag 10 -# -# Setting one or the other to 0 disables the feature. -# -# By default min-replicas-to-write is set to 0 (feature disabled) and -# min-replicas-max-lag is set to 10. - -# A Redis master is able to list the address and port of the attached -# replicas in different ways. For example the "INFO replication" section -# offers this information, which is used, among other tools, by -# Redis Sentinel in order to discover replica instances. -# Another place where this info is available is in the output of the -# "ROLE" command of a master. -# -# The listed IP and address normally reported by a replica is obtained -# in the following way: -# -# IP: The address is auto detected by checking the peer address -# of the socket used by the replica to connect with the master. -# -# Port: The port is communicated by the replica during the replication -# handshake, and is normally the port that the replica is using to -# listen for connections. -# -# However when port forwarding or Network Address Translation (NAT) is -# used, the replica may be actually reachable via different IP and port -# pairs. The following two options can be used by a replica in order to -# report to its master a specific set of IP and port, so that both INFO -# and ROLE will report those values. -# -# There is no need to use both the options if you need to override just -# the port or the IP address. -# -# replica-announce-ip 5.5.5.5 -# replica-announce-port 1234 - -################################## SECURITY ################################### - -# Require clients to issue AUTH before processing any other -# commands. This might be useful in environments in which you do not trust -# others with access to the host running redis-server. -# -# This should stay commented out for backward compatibility and because most -# people do not need auth (e.g. they run their own servers). -# -# Warning: since Redis is pretty fast an outside user can try up to -# 150k passwords per second against a good box. This means that you should -# use a very strong password otherwise it will be very easy to break. -# -requirepass playeduxyz - -# Command renaming. -# -# It is possible to change the name of dangerous commands in a shared -# environment. For instance the CONFIG command may be renamed into something -# hard to guess so that it will still be available for internal-use tools -# but not available for general clients. -# -# Example: -# -# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 -# -# It is also possible to completely kill a command by renaming it into -# an empty string: -# -# rename-command CONFIG "" -# -# Please note that changing the name of commands that are logged into the -# AOF file or transmitted to replicas may cause problems. - -################################### CLIENTS #################################### - -# Set the max number of connected clients at the same time. By default -# this limit is set to 10000 clients, however if the Redis server is not -# able to configure the process file limit to allow for the specified limit -# the max number of allowed clients is set to the current file limit -# minus 32 (as Redis reserves a few file descriptors for internal uses). -# -# Once the limit is reached Redis will close all the new connections sending -# an error 'max number of clients reached'. -# -# maxclients 10000 - -############################## MEMORY MANAGEMENT ################################ - -# Set a memory usage limit to the specified amount of bytes. -# When the memory limit is reached Redis will try to remove keys -# according to the eviction policy selected (see maxmemory-policy). -# -# If Redis can't remove keys according to the policy, or if the policy is -# set to 'noeviction', Redis will start to reply with errors to commands -# that would use more memory, like SET, LPUSH, and so on, and will continue -# to reply to read-only commands like GET. -# -# This option is usually useful when using Redis as an LRU or LFU cache, or to -# set a hard memory limit for an instance (using the 'noeviction' policy). -# -# WARNING: If you have replicas attached to an instance with maxmemory on, -# the size of the output buffers needed to feed the replicas are subtracted -# from the used memory count, so that network problems / resyncs will -# not trigger a loop where keys are evicted, and in turn the output -# buffer of replicas is full with DELs of keys evicted triggering the deletion -# of more keys, and so forth until the database is completely emptied. -# -# In short... if you have replicas attached it is suggested that you set a lower -# limit for maxmemory so that there is some free RAM on the system for replica -# output buffers (but this is not needed if the policy is 'noeviction'). -# -# maxmemory - -# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory -# is reached. You can select among five behaviors: -# -# volatile-lru -> Evict using approximated LRU among the keys with an expire set. -# allkeys-lru -> Evict any key using approximated LRU. -# volatile-lfu -> Evict using approximated LFU among the keys with an expire set. -# allkeys-lfu -> Evict any key using approximated LFU. -# volatile-random -> Remove a random key among the ones with an expire set. -# allkeys-random -> Remove a random key, any key. -# volatile-ttl -> Remove the key with the nearest expire time (minor TTL) -# noeviction -> Don't evict anything, just return an error on write operations. -# -# LRU means Least Recently Used -# LFU means Least Frequently Used -# -# Both LRU, LFU and volatile-ttl are implemented using approximated -# randomized algorithms. -# -# Note: with any of the above policies, Redis will return an error on write -# operations, when there are no suitable keys for eviction. -# -# At the date of writing these commands are: set setnx setex append -# incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd -# sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby -# zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby -# getset mset msetnx exec sort -# -# The default is: -# -# maxmemory-policy noeviction - -# LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated -# algorithms (in order to save memory), so you can tune it for speed or -# accuracy. For default Redis will check five keys and pick the one that was -# used less recently, you can change the sample size using the following -# configuration directive. -# -# The default of 5 produces good enough results. 10 Approximates very closely -# true LRU but costs more CPU. 3 is faster but not very accurate. -# -# maxmemory-samples 5 - -# Starting from Redis 5, by default a replica will ignore its maxmemory setting -# (unless it is promoted to master after a failover or manually). It means -# that the eviction of keys will be just handled by the master, sending the -# DEL commands to the replica as keys evict in the master side. -# -# This behavior ensures that masters and replicas stay consistent, and is usually -# what you want, however if your replica is writable, or you want the replica to have -# a different memory setting, and you are sure all the writes performed to the -# replica are idempotent, then you may change this default (but be sure to understand -# what you are doing). -# -# Note that since the replica by default does not evict, it may end using more -# memory than the one set via maxmemory (there are certain buffers that may -# be larger on the replica, or data structures may sometimes take more memory and so -# forth). So make sure you monitor your replicas and make sure they have enough -# memory to never hit a real out-of-memory condition before the master hits -# the configured maxmemory setting. -# -# replica-ignore-maxmemory yes - -############################# LAZY FREEING #################################### - -# Redis has two primitives to delete keys. One is called DEL and is a blocking -# deletion of the object. It means that the server stops processing new commands -# in order to reclaim all the memory associated with an object in a synchronous -# way. If the key deleted is associated with a small object, the time needed -# in order to execute the DEL command is very small and comparable to most other -# O(1) or O(log_N) commands in Redis. However if the key is associated with an -# aggregated value containing millions of elements, the server can block for -# a long time (even seconds) in order to complete the operation. -# -# For the above reasons Redis also offers non blocking deletion primitives -# such as UNLINK (non blocking DEL) and the ASYNC option of FLUSHALL and -# FLUSHDB commands, in order to reclaim memory in background. Those commands -# are executed in constant time. Another thread will incrementally free the -# object in the background as fast as possible. -# -# DEL, UNLINK and ASYNC option of FLUSHALL and FLUSHDB are user-controlled. -# It's up to the design of the application to understand when it is a good -# idea to use one or the other. However the Redis server sometimes has to -# delete keys or flush the whole database as a side effect of other operations. -# Specifically Redis deletes objects independently of a user call in the -# following scenarios: -# -# 1) On eviction, because of the maxmemory and maxmemory policy configurations, -# in order to make room for new data, without going over the specified -# memory limit. -# 2) Because of expire: when a key with an associated time to live (see the -# EXPIRE command) must be deleted from memory. -# 3) Because of a side effect of a command that stores data on a key that may -# already exist. For example the RENAME command may delete the old key -# content when it is replaced with another one. Similarly SUNIONSTORE -# or SORT with STORE option may delete existing keys. The SET command -# itself removes any old content of the specified key in order to replace -# it with the specified string. -# 4) During replication, when a replica performs a full resynchronization with -# its master, the content of the whole database is removed in order to -# load the RDB file just transferred. -# -# In all the above cases the default is to delete objects in a blocking way, -# like if DEL was called. However you can configure each case specifically -# in order to instead release memory in a non-blocking way like if UNLINK -# was called, using the following configuration directives: - -lazyfree-lazy-eviction no -lazyfree-lazy-expire no -lazyfree-lazy-server-del no -replica-lazy-flush no - -############################## APPEND ONLY MODE ############################### - -# By default Redis asynchronously dumps the dataset on disk. This mode is -# good enough in many applications, but an issue with the Redis process or -# a power outage may result into a few minutes of writes lost (depending on -# the configured save points). -# -# The Append Only File is an alternative persistence mode that provides -# much better durability. For instance using the default data fsync policy -# (see later in the config file) Redis can lose just one second of writes in a -# dramatic event like a server power outage, or a single write if something -# wrong with the Redis process itself happens, but the operating system is -# still running correctly. -# -# AOF and RDB persistence can be enabled at the same time without problems. -# If the AOF is enabled on startup Redis will load the AOF, that is the file -# with the better durability guarantees. -# -# Please check http://redis.io/topics/persistence for more information. - -appendonly no - -# The name of the append only file (default: "appendonly.aof") - -appendfilename "appendonly.aof" - -# The fsync() call tells the Operating System to actually write data on disk -# instead of waiting for more data in the output buffer. Some OS will really flush -# data on disk, some other OS will just try to do it ASAP. -# -# Redis supports three different modes: -# -# no: don't fsync, just let the OS flush the data when it wants. Faster. -# always: fsync after every write to the append only log. Slow, Safest. -# everysec: fsync only one time every second. Compromise. -# -# The default is "everysec", as that's usually the right compromise between -# speed and data safety. It's up to you to understand if you can relax this to -# "no" that will let the operating system flush the output buffer when -# it wants, for better performances (but if you can live with the idea of -# some data loss consider the default persistence mode that's snapshotting), -# or on the contrary, use "always" that's very slow but a bit safer than -# everysec. -# -# More details please check the following article: -# http://antirez.com/post/redis-persistence-demystified.html -# -# If unsure, use "everysec". - -# appendfsync always -appendfsync everysec -# appendfsync no - -# When the AOF fsync policy is set to always or everysec, and a background -# saving process (a background save or AOF log background rewriting) is -# performing a lot of I/O against the disk, in some Linux configurations -# Redis may block too long on the fsync() call. Note that there is no fix for -# this currently, as even performing fsync in a different thread will block -# our synchronous write(2) call. -# -# In order to mitigate this problem it's possible to use the following option -# that will prevent fsync() from being called in the main process while a -# BGSAVE or BGREWRITEAOF is in progress. -# -# This means that while another child is saving, the durability of Redis is -# the same as "appendfsync none". In practical terms, this means that it is -# possible to lose up to 30 seconds of log in the worst scenario (with the -# default Linux settings). -# -# If you have latency problems turn this to "yes". Otherwise leave it as -# "no" that is the safest pick from the point of view of durability. - -no-appendfsync-on-rewrite no - -# Automatic rewrite of the append only file. -# Redis is able to automatically rewrite the log file implicitly calling -# BGREWRITEAOF when the AOF log size grows by the specified percentage. -# -# This is how it works: Redis remembers the size of the AOF file after the -# latest rewrite (if no rewrite has happened since the restart, the size of -# the AOF at startup is used). -# -# This base size is compared to the current size. If the current size is -# bigger than the specified percentage, the rewrite is triggered. Also -# you need to specify a minimal size for the AOF file to be rewritten, this -# is useful to avoid rewriting the AOF file even if the percentage increase -# is reached but it is still pretty small. -# -# Specify a percentage of zero in order to disable the automatic AOF -# rewrite feature. - -auto-aof-rewrite-percentage 100 -auto-aof-rewrite-min-size 64mb - -# An AOF file may be found to be truncated at the end during the Redis -# startup process, when the AOF data gets loaded back into memory. -# This may happen when the system where Redis is running -# crashes, especially when an ext4 filesystem is mounted without the -# data=ordered option (however this can't happen when Redis itself -# crashes or aborts but the operating system still works correctly). -# -# Redis can either exit with an error when this happens, or load as much -# data as possible (the default now) and start if the AOF file is found -# to be truncated at the end. The following option controls this behavior. -# -# If aof-load-truncated is set to yes, a truncated AOF file is loaded and -# the Redis server starts emitting a log to inform the user of the event. -# Otherwise if the option is set to no, the server aborts with an error -# and refuses to start. When the option is set to no, the user requires -# to fix the AOF file using the "redis-check-aof" utility before to restart -# the server. -# -# Note that if the AOF file will be found to be corrupted in the middle -# the server will still exit with an error. This option only applies when -# Redis will try to read more data from the AOF file but not enough bytes -# will be found. -aof-load-truncated yes - -# When rewriting the AOF file, Redis is able to use an RDB preamble in the -# AOF file for faster rewrites and recoveries. When this option is turned -# on the rewritten AOF file is composed of two different stanzas: -# -# [RDB file][AOF tail] -# -# When loading Redis recognizes that the AOF file starts with the "REDIS" -# string and loads the prefixed RDB file, and continues loading the AOF -# tail. -aof-use-rdb-preamble yes - -################################ LUA SCRIPTING ############################### - -# Max execution time of a Lua script in milliseconds. -# -# If the maximum execution time is reached Redis will log that a script is -# still in execution after the maximum allowed time and will start to -# reply to queries with an error. -# -# When a long running script exceeds the maximum execution time only the -# SCRIPT KILL and SHUTDOWN NOSAVE commands are available. The first can be -# used to stop a script that did not yet called write commands. The second -# is the only way to shut down the server in the case a write command was -# already issued by the script but the user doesn't want to wait for the natural -# termination of the script. -# -# Set it to 0 or a negative value for unlimited execution without warnings. -lua-time-limit 5000 - -################################ REDIS CLUSTER ############################### -# -# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# WARNING EXPERIMENTAL: Redis Cluster is considered to be stable code, however -# in order to mark it as "mature" we need to wait for a non trivial percentage -# of users to deploy it in production. -# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# -# Normal Redis instances can't be part of a Redis Cluster; only nodes that are -# started as cluster nodes can. In order to start a Redis instance as a -# cluster node enable the cluster support uncommenting the following: -# -# cluster-enabled yes - -# Every cluster node has a cluster configuration file. This file is not -# intended to be edited by hand. It is created and updated by Redis nodes. -# Every Redis Cluster node requires a different cluster configuration file. -# Make sure that instances running in the same system do not have -# overlapping cluster configuration file names. -# -# cluster-config-file nodes-6379.conf - -# Cluster node timeout is the amount of milliseconds a node must be unreachable -# for it to be considered in failure state. -# Most other internal time limits are multiple of the node timeout. -# -# cluster-node-timeout 15000 - -# A replica of a failing master will avoid to start a failover if its data -# looks too old. -# -# There is no simple way for a replica to actually have an exact measure of -# its "data age", so the following two checks are performed: -# -# 1) If there are multiple replicas able to failover, they exchange messages -# in order to try to give an advantage to the replica with the best -# replication offset (more data from the master processed). -# Replicas will try to get their rank by offset, and apply to the start -# of the failover a delay proportional to their rank. -# -# 2) Every single replica computes the time of the last interaction with -# its master. This can be the last ping or command received (if the master -# is still in the "connected" state), or the time that elapsed since the -# disconnection with the master (if the replication link is currently down). -# If the last interaction is too old, the replica will not try to failover -# at all. -# -# The point "2" can be tuned by user. Specifically a replica will not perform -# the failover if, since the last interaction with the master, the time -# elapsed is greater than: -# -# (node-timeout * replica-validity-factor) + repl-ping-replica-period -# -# So for example if node-timeout is 30 seconds, and the replica-validity-factor -# is 10, and assuming a default repl-ping-replica-period of 10 seconds, the -# replica will not try to failover if it was not able to talk with the master -# for longer than 310 seconds. -# -# A large replica-validity-factor may allow replicas with too old data to failover -# a master, while a too small value may prevent the cluster from being able to -# elect a replica at all. -# -# For maximum availability, it is possible to set the replica-validity-factor -# to a value of 0, which means, that replicas will always try to failover the -# master regardless of the last time they interacted with the master. -# (However they'll always try to apply a delay proportional to their -# offset rank). -# -# Zero is the only value able to guarantee that when all the partitions heal -# the cluster will always be able to continue. -# -# cluster-replica-validity-factor 10 - -# Cluster replicas are able to migrate to orphaned masters, that are masters -# that are left without working replicas. This improves the cluster ability -# to resist to failures as otherwise an orphaned master can't be failed over -# in case of failure if it has no working replicas. -# -# Replicas migrate to orphaned masters only if there are still at least a -# given number of other working replicas for their old master. This number -# is the "migration barrier". A migration barrier of 1 means that a replica -# will migrate only if there is at least 1 other working replica for its master -# and so forth. It usually reflects the number of replicas you want for every -# master in your cluster. -# -# Default is 1 (replicas migrate only if their masters remain with at least -# one replica). To disable migration just set it to a very large value. -# A value of 0 can be set but is useful only for debugging and dangerous -# in production. -# -# cluster-migration-barrier 1 - -# By default Redis Cluster nodes stop accepting queries if they detect there -# is at least an hash slot uncovered (no available node is serving it). -# This way if the cluster is partially down (for example a range of hash slots -# are no longer covered) all the cluster becomes, eventually, unavailable. -# It automatically returns available as soon as all the slots are covered again. -# -# However sometimes you want the subset of the cluster which is working, -# to continue to accept queries for the part of the key space that is still -# covered. In order to do so, just set the cluster-require-full-coverage -# option to no. -# -# cluster-require-full-coverage yes - -# This option, when set to yes, prevents replicas from trying to failover its -# master during master failures. However the master can still perform a -# manual failover, if forced to do so. -# -# This is useful in different scenarios, especially in the case of multiple -# data center operations, where we want one side to never be promoted if not -# in the case of a total DC failure. -# -# cluster-replica-no-failover no - -# In order to setup your cluster make sure to read the documentation -# available at http://redis.io web site. - -########################## CLUSTER DOCKER/NAT support ######################## - -# In certain deployments, Redis Cluster nodes address discovery fails, because -# addresses are NAT-ted or because ports are forwarded (the typical case is -# Docker and other containers). -# -# In order to make Redis Cluster working in such environments, a static -# configuration where each node knows its public address is needed. The -# following two options are used for this scope, and are: -# -# * cluster-announce-ip -# * cluster-announce-port -# * cluster-announce-bus-port -# -# Each instruct the node about its address, client port, and cluster message -# bus port. The information is then published in the header of the bus packets -# so that other nodes will be able to correctly map the address of the node -# publishing the information. -# -# If the above options are not used, the normal Redis Cluster auto-detection -# will be used instead. -# -# Note that when remapped, the bus port may not be at the fixed offset of -# clients port + 10000, so you can specify any port and bus-port depending -# on how they get remapped. If the bus-port is not set, a fixed offset of -# 10000 will be used as usually. -# -# Example: -# -# cluster-announce-ip 10.1.1.5 -# cluster-announce-port 6379 -# cluster-announce-bus-port 6380 - -################################## SLOW LOG ################################### - -# The Redis Slow Log is a system to log queries that exceeded a specified -# execution time. The execution time does not include the I/O operations -# like talking with the client, sending the reply and so forth, -# but just the time needed to actually execute the command (this is the only -# stage of command execution where the thread is blocked and can not serve -# other requests in the meantime). -# -# You can configure the slow log with two parameters: one tells Redis -# what is the execution time, in microseconds, to exceed in order for the -# command to get logged, and the other parameter is the length of the -# slow log. When a new command is logged the oldest one is removed from the -# queue of logged commands. - -# The following time is expressed in microseconds, so 1000000 is equivalent -# to one second. Note that a negative number disables the slow log, while -# a value of zero forces the logging of every command. -slowlog-log-slower-than 10000 - -# There is no limit to this length. Just be aware that it will consume memory. -# You can reclaim memory used by the slow log with SLOWLOG RESET. -slowlog-max-len 128 - -################################ LATENCY MONITOR ############################## - -# The Redis latency monitoring subsystem samples different operations -# at runtime in order to collect data related to possible sources of -# latency of a Redis instance. -# -# Via the LATENCY command this information is available to the user that can -# print graphs and obtain reports. -# -# The system only logs operations that were performed in a time equal or -# greater than the amount of milliseconds specified via the -# latency-monitor-threshold configuration directive. When its value is set -# to zero, the latency monitor is turned off. -# -# By default latency monitoring is disabled since it is mostly not needed -# if you don't have latency issues, and collecting data has a performance -# impact, that while very small, can be measured under big load. Latency -# monitoring can easily be enabled at runtime using the command -# "CONFIG SET latency-monitor-threshold " if needed. -latency-monitor-threshold 0 - -############################# EVENT NOTIFICATION ############################## - -# Redis can notify Pub/Sub clients about events happening in the key space. -# This feature is documented at http://redis.io/topics/notifications -# -# For instance if keyspace events notification is enabled, and a client -# performs a DEL operation on key "foo" stored in the Database 0, two -# messages will be published via Pub/Sub: -# -# PUBLISH __keyspace@0__:foo del -# PUBLISH __keyevent@0__:del foo -# -# It is possible to select the events that Redis will notify among a set -# of classes. Every class is identified by a single character: -# -# K Keyspace events, published with __keyspace@__ prefix. -# E Keyevent events, published with __keyevent@__ prefix. -# g Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ... -# $ String commands -# l List commands -# s Set commands -# h Hash commands -# z Sorted set commands -# x Expired events (events generated every time a key expires) -# e Evicted events (events generated when a key is evicted for maxmemory) -# A Alias for g$lshzxe, so that the "AKE" string means all the events. -# -# The "notify-keyspace-events" takes as argument a string that is composed -# of zero or multiple characters. The empty string means that notifications -# are disabled. -# -# Example: to enable list and generic events, from the point of view of the -# event name, use: -# -# notify-keyspace-events Elg -# -# Example 2: to get the stream of the expired keys subscribing to channel -# name __keyevent@0__:expired use: -# -# notify-keyspace-events Ex -# -# By default all notifications are disabled because most users don't need -# this feature and the feature has some overhead. Note that if you don't -# specify at least one of K or E, no events will be delivered. -notify-keyspace-events "" - -############################### ADVANCED CONFIG ############################### - -# Hashes are encoded using a memory efficient data structure when they have a -# small number of entries, and the biggest entry does not exceed a given -# threshold. These thresholds can be configured using the following directives. -hash-max-ziplist-entries 512 -hash-max-ziplist-value 64 - -# Lists are also encoded in a special way to save a lot of space. -# The number of entries allowed per internal list node can be specified -# as a fixed maximum size or a maximum number of elements. -# For a fixed maximum size, use -5 through -1, meaning: -# -5: max size: 64 Kb <-- not recommended for normal workloads -# -4: max size: 32 Kb <-- not recommended -# -3: max size: 16 Kb <-- probably not recommended -# -2: max size: 8 Kb <-- good -# -1: max size: 4 Kb <-- good -# Positive numbers mean store up to _exactly_ that number of elements -# per list node. -# The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size), -# but if your use case is unique, adjust the settings as necessary. -list-max-ziplist-size -2 - -# Lists may also be compressed. -# Compress depth is the number of quicklist ziplist nodes from *each* side of -# the list to *exclude* from compression. The head and tail of the list -# are always uncompressed for fast push/pop operations. Settings are: -# 0: disable all list compression -# 1: depth 1 means "don't start compressing until after 1 node into the list, -# going from either the head or tail" -# So: [head]->node->node->...->node->[tail] -# [head], [tail] will always be uncompressed; inner nodes will compress. -# 2: [head]->[next]->node->node->...->node->[prev]->[tail] -# 2 here means: don't compress head or head->next or tail->prev or tail, -# but compress all nodes between them. -# 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail] -# etc. -list-compress-depth 0 - -# Sets have a special encoding in just one case: when a set is composed -# of just strings that happen to be integers in radix 10 in the range -# of 64 bit signed integers. -# The following configuration setting sets the limit in the size of the -# set in order to use this special memory saving encoding. -set-max-intset-entries 512 - -# Similarly to hashes and lists, sorted sets are also specially encoded in -# order to save a lot of space. This encoding is only used when the length and -# elements of a sorted set are below the following limits: -zset-max-ziplist-entries 128 -zset-max-ziplist-value 64 - -# HyperLogLog sparse representation bytes limit. The limit includes the -# 16 bytes header. When an HyperLogLog using the sparse representation crosses -# this limit, it is converted into the dense representation. -# -# A value greater than 16000 is totally useless, since at that point the -# dense representation is more memory efficient. -# -# The suggested value is ~ 3000 in order to have the benefits of -# the space efficient encoding without slowing down too much PFADD, -# which is O(N) with the sparse encoding. The value can be raised to -# ~ 10000 when CPU is not a concern, but space is, and the data set is -# composed of many HyperLogLogs with cardinality in the 0 - 15000 range. -hll-sparse-max-bytes 3000 - -# Streams macro node max size / items. The stream data structure is a radix -# tree of big nodes that encode multiple items inside. Using this configuration -# it is possible to configure how big a single node can be in bytes, and the -# maximum number of items it may contain before switching to a new node when -# appending new stream entries. If any of the following settings are set to -# zero, the limit is ignored, so for instance it is possible to set just a -# max entires limit by setting max-bytes to 0 and max-entries to the desired -# value. -stream-node-max-bytes 4096 -stream-node-max-entries 100 - -# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in -# order to help rehashing the main Redis hash table (the one mapping top-level -# keys to values). The hash table implementation Redis uses (see dict.c) -# performs a lazy rehashing: the more operation you run into a hash table -# that is rehashing, the more rehashing "steps" are performed, so if the -# server is idle the rehashing is never complete and some more memory is used -# by the hash table. -# -# The default is to use this millisecond 10 times every second in order to -# actively rehash the main dictionaries, freeing memory when possible. -# -# If unsure: -# use "activerehashing no" if you have hard latency requirements and it is -# not a good thing in your environment that Redis can reply from time to time -# to queries with 2 milliseconds delay. -# -# use "activerehashing yes" if you don't have such hard requirements but -# want to free memory asap when possible. -activerehashing yes - -# The client output buffer limits can be used to force disconnection of clients -# that are not reading data from the server fast enough for some reason (a -# common reason is that a Pub/Sub client can't consume messages as fast as the -# publisher can produce them). -# -# The limit can be set differently for the three different classes of clients: -# -# normal -> normal clients including MONITOR clients -# replica -> replica clients -# pubsub -> clients subscribed to at least one pubsub channel or pattern -# -# The syntax of every client-output-buffer-limit directive is the following: -# -# client-output-buffer-limit -# -# A client is immediately disconnected once the hard limit is reached, or if -# the soft limit is reached and remains reached for the specified number of -# seconds (continuously). -# So for instance if the hard limit is 32 megabytes and the soft limit is -# 16 megabytes / 10 seconds, the client will get disconnected immediately -# if the size of the output buffers reach 32 megabytes, but will also get -# disconnected if the client reaches 16 megabytes and continuously overcomes -# the limit for 10 seconds. -# -# By default normal clients are not limited because they don't receive data -# without asking (in a push way), but just after a request, so only -# asynchronous clients may create a scenario where data is requested faster -# than it can read. -# -# Instead there is a default limit for pubsub and replica clients, since -# subscribers and replicas receive data in a push fashion. -# -# Both the hard or the soft limit can be disabled by setting them to zero. -client-output-buffer-limit normal 0 0 0 -client-output-buffer-limit replica 256mb 64mb 60 -client-output-buffer-limit pubsub 32mb 8mb 60 - -# Client query buffers accumulate new commands. They are limited to a fixed -# amount by default in order to avoid that a protocol desynchronization (for -# instance due to a bug in the client) will lead to unbound memory usage in -# the query buffer. However you can configure it here if you have very special -# needs, such us huge multi/exec requests or alike. -# -# client-query-buffer-limit 1gb - -# In the Redis protocol, bulk requests, that are, elements representing single -# strings, are normally limited ot 512 mb. However you can change this limit -# here. -# -# proto-max-bulk-len 512mb - -# Redis calls an internal function to perform many background tasks, like -# closing connections of clients in timeout, purging expired keys that are -# never requested, and so forth. -# -# Not all tasks are performed with the same frequency, but Redis checks for -# tasks to perform according to the specified "hz" value. -# -# By default "hz" is set to 10. Raising the value will use more CPU when -# Redis is idle, but at the same time will make Redis more responsive when -# there are many keys expiring at the same time, and timeouts may be -# handled with more precision. -# -# The range is between 1 and 500, however a value over 100 is usually not -# a good idea. Most users should use the default of 10 and raise this up to -# 100 only in environments where very low latency is required. -hz 10 - -# Normally it is useful to have an HZ value which is proportional to the -# number of clients connected. This is useful in order, for instance, to -# avoid too many clients are processed for each background task invocation -# in order to avoid latency spikes. -# -# Since the default HZ value by default is conservatively set to 10, Redis -# offers, and enables by default, the ability to use an adaptive HZ value -# which will temporary raise when there are many connected clients. -# -# When dynamic HZ is enabled, the actual configured HZ will be used as -# as a baseline, but multiples of the configured HZ value will be actually -# used as needed once more clients are connected. In this way an idle -# instance will use very little CPU time while a busy instance will be -# more responsive. -dynamic-hz yes - -# When a child rewrites the AOF file, if the following option is enabled -# the file will be fsync-ed every 32 MB of data generated. This is useful -# in order to commit the file to the disk more incrementally and avoid -# big latency spikes. -aof-rewrite-incremental-fsync yes - -# When redis saves RDB file, if the following option is enabled -# the file will be fsync-ed every 32 MB of data generated. This is useful -# in order to commit the file to the disk more incrementally and avoid -# big latency spikes. -rdb-save-incremental-fsync yes - -# Redis LFU eviction (see maxmemory setting) can be tuned. However it is a good -# idea to start with the default settings and only change them after investigating -# how to improve the performances and how the keys LFU change over time, which -# is possible to inspect via the OBJECT FREQ command. -# -# There are two tunable parameters in the Redis LFU implementation: the -# counter logarithm factor and the counter decay time. It is important to -# understand what the two parameters mean before changing them. -# -# The LFU counter is just 8 bits per key, it's maximum value is 255, so Redis -# uses a probabilistic increment with logarithmic behavior. Given the value -# of the old counter, when a key is accessed, the counter is incremented in -# this way: -# -# 1. A random number R between 0 and 1 is extracted. -# 2. A probability P is calculated as 1/(old_value*lfu_log_factor+1). -# 3. The counter is incremented only if R < P. -# -# The default lfu-log-factor is 10. This is a table of how the frequency -# counter changes with a different number of accesses with different -# logarithmic factors: -# -# +--------+------------+------------+------------+------------+------------+ -# | factor | 100 hits | 1000 hits | 100K hits | 1M hits | 10M hits | -# +--------+------------+------------+------------+------------+------------+ -# | 0 | 104 | 255 | 255 | 255 | 255 | -# +--------+------------+------------+------------+------------+------------+ -# | 1 | 18 | 49 | 255 | 255 | 255 | -# +--------+------------+------------+------------+------------+------------+ -# | 10 | 10 | 18 | 142 | 255 | 255 | -# +--------+------------+------------+------------+------------+------------+ -# | 100 | 8 | 11 | 49 | 143 | 255 | -# +--------+------------+------------+------------+------------+------------+ -# -# NOTE: The above table was obtained by running the following commands: -# -# redis-benchmark -n 1000000 incr foo -# redis-cli object freq foo -# -# NOTE 2: The counter initial value is 5 in order to give new objects a chance -# to accumulate hits. -# -# The counter decay time is the time, in minutes, that must elapse in order -# for the key counter to be divided by two (or decremented if it has a value -# less <= 10). -# -# The default value for the lfu-decay-time is 1. A Special value of 0 means to -# decay the counter every time it happens to be scanned. -# -# lfu-log-factor 10 -# lfu-decay-time 1 - -########################### ACTIVE DEFRAGMENTATION ####################### -# -# WARNING THIS FEATURE IS EXPERIMENTAL. However it was stress tested -# even in production and manually tested by multiple engineers for some -# time. -# -# What is active defragmentation? -# ------------------------------- -# -# Active (online) defragmentation allows a Redis server to compact the -# spaces left between small allocations and deallocations of data in memory, -# thus allowing to reclaim back memory. -# -# Fragmentation is a natural process that happens with every allocator (but -# less so with Jemalloc, fortunately) and certain workloads. Normally a server -# restart is needed in order to lower the fragmentation, or at least to flush -# away all the data and create it again. However thanks to this feature -# implemented by Oran Agra for Redis 4.0 this process can happen at runtime -# in an "hot" way, while the server is running. -# -# Basically when the fragmentation is over a certain level (see the -# configuration options below) Redis will start to create new copies of the -# values in contiguous memory regions by exploiting certain specific Jemalloc -# features (in order to understand if an allocation is causing fragmentation -# and to allocate it in a better place), and at the same time, will release the -# old copies of the data. This process, repeated incrementally for all the keys -# will cause the fragmentation to drop back to normal values. -# -# Important things to understand: -# -# 1. This feature is disabled by default, and only works if you compiled Redis -# to use the copy of Jemalloc we ship with the source code of Redis. -# This is the default with Linux builds. -# -# 2. You never need to enable this feature if you don't have fragmentation -# issues. -# -# 3. Once you experience fragmentation, you can enable this feature when -# needed with the command "CONFIG SET activedefrag yes". -# -# The configuration parameters are able to fine tune the behavior of the -# defragmentation process. If you are not sure about what they mean it is -# a good idea to leave the defaults untouched. - -# Enabled active defragmentation -# activedefrag yes - -# Minimum amount of fragmentation waste to start active defrag -# active-defrag-ignore-bytes 100mb - -# Minimum percentage of fragmentation to start active defrag -# active-defrag-threshold-lower 10 - -# Maximum percentage of fragmentation at which we use maximum effort -# active-defrag-threshold-upper 100 - -# Minimal effort for defrag in CPU percentage -# active-defrag-cycle-min 5 - -# Maximal effort for defrag in CPU percentage -# active-defrag-cycle-max 75 - -# Maximum number of set/hash/zset/list fields that will be processed from -# the main dictionary scan -# active-defrag-max-scan-fields 1000 \ No newline at end of file diff --git a/playedu-admin/src/index.less b/playedu-admin/src/index.less index f614571..bad5b83 100644 --- a/playedu-admin/src/index.less +++ b/playedu-admin/src/index.less @@ -551,6 +551,10 @@ textarea.ant-input { } } +.ant-btn-variant-link { + color: @primaryColor !important; +} + .b-link { padding: 0 !important; &:hover { diff --git a/playedu-admin/src/pages/system/config/index.tsx b/playedu-admin/src/pages/system/config/index.tsx index b5bd571..c5c4bee 100644 --- a/playedu-admin/src/pages/system/config/index.tsx +++ b/playedu-admin/src/pages/system/config/index.tsx @@ -11,6 +11,7 @@ import { Checkbox, Slider, Space, + Select, } from "antd"; import { appConfig, system } from "../../../api/index"; import { UploadImageButton } from "../../../compenents"; @@ -31,6 +32,7 @@ const SystemConfigPage = () => { const [thumb, setThumb] = useState(""); const [avatar, setAvatar] = useState(""); const [tabKey, setTabKey] = useState(1); + const [s3Service, setS3Service] = useState(""); const [nameChecked, setNameChecked] = useState(false); const [emailChecked, setEmailChecked] = useState(false); const [idCardchecked, setIdCardChecked] = useState(false); @@ -136,25 +138,34 @@ const SystemConfigPage = () => { form.setFieldsValue({ "member.default_avatar": configData[i].key_value, }); - } else if (configData[i].key_name === "minio.access_key") { + } else if (configData[i].key_name === "s3.service") { form.setFieldsValue({ - "minio.access_key": configData[i].key_value, + "s3.service": configData[i].key_value, }); - } else if (configData[i].key_name === "minio.secret_key") { + setS3Service(configData[i].key_value); + } else if (configData[i].key_name === "s3.access_key") { form.setFieldsValue({ - "minio.secret_key": configData[i].key_value, + "s3.access_key": configData[i].key_value, }); - } else if (configData[i].key_name === "minio.bucket") { + } else if (configData[i].key_name === "s3.secret_key") { form.setFieldsValue({ - "minio.bucket": configData[i].key_value, + "s3.secret_key": configData[i].key_value, }); - } else if (configData[i].key_name === "minio.endpoint") { + } else if (configData[i].key_name === "s3.bucket") { form.setFieldsValue({ - "minio.endpoint": configData[i].key_value, + "s3.bucket": configData[i].key_value, }); - } else if (configData[i].key_name === "minio.domain") { + } else if (configData[i].key_name === "s3.region") { form.setFieldsValue({ - "minio.domain": configData[i].key_value, + "s3.region": configData[i].key_value, + }); + } else if (configData[i].key_name === "s3.endpoint") { + form.setFieldsValue({ + "s3.endpoint": configData[i].key_value, + }); + } else if (configData[i].key_name === "s3.domain") { + form.setFieldsValue({ + "s3.domain": configData[i].key_value, }); } else if (configData[i].key_name === "ldap.enabled") { let value = 0; @@ -620,7 +631,7 @@ const SystemConfigPage = () => { }, { key: "4", - label: `MinIO存储`, + label: `S3存储`, children: (
{ onFinishFailed={onFinishFailed} autoComplete="off" > + + { { { placeholder="请填写Bucket" /> + + + { = 10 && !playEduConfig.getTesting()) { - Long exp = RedisUtil.ttlWithoutPrefix(limitKey); + Long exp = MemoryCacheUtil.ttlWithoutPrefix(limitKey); String msg = String.format("您的账号已被锁定,请%s后重试", exp > 60 ? exp / 60 + "分钟" : exp + "秒"); throw new ServiceException(msg); } } public void destroy(String email) { - RedisUtil.del(cacheKey(email)); + MemoryCacheUtil.del(cacheKey(email)); } private String cacheKey(String email) { diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/cache/LoginLockCache.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/cache/LoginLockCache.java index efc4074..08735f4 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/cache/LoginLockCache.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/cache/LoginLockCache.java @@ -15,25 +15,23 @@ */ package xyz.playedu.api.cache; +import java.util.concurrent.TimeUnit; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - -import xyz.playedu.common.util.RedisDistributedLock; - -import java.util.concurrent.TimeUnit; +import xyz.playedu.common.util.MemoryDistributedLock; @Component public class LoginLockCache { - @Autowired private RedisDistributedLock redisDistributedLock; + @Autowired private MemoryDistributedLock distributedLock; public boolean apply(String username) { String key = cacheKey(username); - return redisDistributedLock.tryLock(key, 10L, TimeUnit.SECONDS); + return distributedLock.tryLock(key, 10L, TimeUnit.SECONDS); } public void release(String username) { - redisDistributedLock.releaseLock(cacheKey(username)); + distributedLock.releaseLock(cacheKey(username)); } private String cacheKey(String username) { diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/ExceptionController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/ExceptionController.java index e08c0b6..29e3d1f 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/ExceptionController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/ExceptionController.java @@ -16,10 +16,8 @@ package xyz.playedu.api.controller; import com.amazonaws.services.s3.model.AmazonS3Exception; - +import java.util.List; import lombok.extern.slf4j.Slf4j; - -import org.springframework.data.redis.RedisConnectionFailureException; import org.springframework.http.converter.HttpMessageNotReadableException; import org.springframework.validation.ObjectError; import org.springframework.web.HttpRequestMethodNotSupportedException; @@ -28,14 +26,12 @@ import org.springframework.web.bind.MissingServletRequestParameterException; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; - +import org.springframework.web.servlet.resource.NoResourceFoundException; import xyz.playedu.common.exception.LimitException; import xyz.playedu.common.exception.NotFoundException; import xyz.playedu.common.exception.ServiceException; import xyz.playedu.common.types.JsonResponse; -import java.util.List; - @RestControllerAdvice @Slf4j public class ExceptionController { @@ -51,11 +47,6 @@ public class ExceptionController { return JsonResponse.error(e.getMessage(), 1); } - @ExceptionHandler(RedisConnectionFailureException.class) - public JsonResponse serviceExceptionHandler(RedisConnectionFailureException e) { - return JsonResponse.error("redis服务连接失败", 500); - } - @ExceptionHandler(HttpMessageNotReadableException.class) public JsonResponse serviceExceptionHandler(HttpMessageNotReadableException e) { log.error("error", e); @@ -103,4 +94,9 @@ public class ExceptionController { log.error("s3错误={}", e.getMessage()); return JsonResponse.error("存储配置有问题或存储无法无法正常访问", 500); } + + @ExceptionHandler(NoResourceFoundException.class) + public JsonResponse serviceExceptionHandler(NoResourceFoundException e) { + return JsonResponse.error("资源不存在", 404); + } } diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AdminLogController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AdminLogController.java index 2f4cbed..55f11d9 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AdminLogController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AdminLogController.java @@ -15,12 +15,11 @@ */ package xyz.playedu.api.controller.backend; +import java.util.HashMap; import lombok.extern.slf4j.Slf4j; - import org.apache.commons.collections4.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; - import xyz.playedu.common.annotation.BackendPermission; import xyz.playedu.common.annotation.Log; import xyz.playedu.common.bus.BackendBus; @@ -34,8 +33,6 @@ import xyz.playedu.common.types.JsonResponse; import xyz.playedu.common.types.paginate.AdminLogPaginateFiler; import xyz.playedu.common.types.paginate.PaginationResult; -import java.util.HashMap; - @RestController @Slf4j @RequestMapping("/backend/v1/admin/log") diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AdminRoleController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AdminRoleController.java index 2f29488..d407dc8 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AdminRoleController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AdminRoleController.java @@ -15,12 +15,15 @@ */ package xyz.playedu.api.controller.backend; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.request.backend.AdminRoleRequest; import xyz.playedu.common.annotation.BackendPermission; import xyz.playedu.common.annotation.Log; @@ -34,12 +37,6 @@ import xyz.playedu.common.service.AdminPermissionService; import xyz.playedu.common.service.AdminRoleService; import xyz.playedu.common.types.JsonResponse; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - @RestController @RequestMapping("/backend/v1/admin-role") @Slf4j @@ -88,7 +85,7 @@ public class AdminRoleController { List permissionIds = roleService.getPermissionIdsByRoleId(role.getId()); List permAction = new ArrayList<>(); List permData = new ArrayList<>(); - if (permissionIds != null && permissionIds.size() > 0) { + if (permissionIds != null && !permissionIds.isEmpty()) { List permissions = permissionService.chunks(permissionIds); Map> permissionsGroup = permissions.stream().collect(Collectors.groupingBy(AdminPermission::getType)); diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AdminUserController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AdminUserController.java index 6353ad4..75e8119 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AdminUserController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AdminUserController.java @@ -15,13 +15,15 @@ */ package xyz.playedu.api.controller.backend; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import lombok.extern.slf4j.Slf4j; - import org.apache.commons.collections4.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.request.backend.AdminUserRequest; import xyz.playedu.common.annotation.BackendPermission; import xyz.playedu.common.annotation.Log; @@ -37,11 +39,6 @@ import xyz.playedu.common.types.JsonResponse; import xyz.playedu.common.types.paginate.AdminUserPaginateFilter; import xyz.playedu.common.types.paginate.PaginationResult; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - @RestController @Slf4j @RequestMapping("/backend/v1/admin-user") @@ -67,7 +64,7 @@ public class AdminUserController { PaginationResult result = adminUserService.paginate(page, size, filter); Map> userRoleIds = new HashMap<>(); - if (result.getData() != null && result.getData().size() > 0) { + if (result.getData() != null && !result.getData().isEmpty()) { userRoleIds = adminUserService.getAdminUserRoleIds( result.getData().stream().map(AdminUser::getId).toList()); @@ -101,7 +98,7 @@ public class AdminUserController { @Log(title = "管理员-新建", businessType = BusinessTypeConstant.INSERT) public JsonResponse store(@RequestBody @Validated AdminUserRequest req) throws ServiceException { - if (req.getPassword().length() == 0) { + if (req.getPassword().isEmpty()) { return JsonResponse.error("请输入密码"); } diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AppConfigController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AppConfigController.java index 18fa455..a4b5b1d 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AppConfigController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/AppConfigController.java @@ -15,9 +15,11 @@ */ package xyz.playedu.api.controller.backend; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.request.backend.AppConfigRequest; import xyz.playedu.common.annotation.BackendPermission; import xyz.playedu.common.annotation.Log; @@ -30,10 +32,6 @@ import xyz.playedu.common.service.AppConfigService; import xyz.playedu.common.types.JsonResponse; import xyz.playedu.common.util.StringUtil; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - @RestController @RequestMapping("/backend/v1/app-config") public class AppConfigController { diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CacheController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CacheController.java new file mode 100644 index 0000000..c4a44cc --- /dev/null +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CacheController.java @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2023 杭州白书科技有限公司 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package xyz.playedu.api.controller.backend; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.MapUtils; +import org.springframework.web.bind.annotation.*; +import xyz.playedu.common.annotation.BackendPermission; +import xyz.playedu.common.annotation.Log; +import xyz.playedu.common.constant.BPermissionConstant; +import xyz.playedu.common.constant.BusinessTypeConstant; +import xyz.playedu.common.types.JsonResponse; +import xyz.playedu.common.util.MemoryCacheUtil; + +@RestController +@Slf4j +@RequestMapping("/backend/v1/cache") +public class CacheController { + + @BackendPermission(slug = BPermissionConstant.CACHE_MANAGE) + @GetMapping("/list") + @Log(title = "缓存列表", businessType = BusinessTypeConstant.GET) + public JsonResponse list(MemoryCacheUtil memoryCacheUtil) { + Map data = new HashMap<>(); + data.put("keys", memoryCacheUtil.getAllKeys()); + data.put("cache", memoryCacheUtil.getAllCache()); + return JsonResponse.data(data); + } + + @BackendPermission(slug = BPermissionConstant.CACHE_MANAGE) + @DeleteMapping("/clear") + @Log(title = "缓存删除key", businessType = BusinessTypeConstant.DELETE) + public JsonResponse clear(@RequestParam HashMap params) { + String cache_key = MapUtils.getString(params, "cache_key"); + MemoryCacheUtil.del(cache_key); + return JsonResponse.success(); + } + + @BackendPermission(slug = BPermissionConstant.CACHE_MANAGE) + @DeleteMapping("/clear/all") + @Log(title = "缓存清空", businessType = BusinessTypeConstant.DELETE) + public JsonResponse clearAll(MemoryCacheUtil memoryCacheUtil) { + List keys = memoryCacheUtil.getAllKeys(); + for (String key : keys) { + MemoryCacheUtil.del(key); + } + return JsonResponse.success(); + } +} diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseAttachmentController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseAttachmentController.java index 87471f6..d34ccad 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseAttachmentController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseAttachmentController.java @@ -15,13 +15,12 @@ */ package xyz.playedu.api.controller.backend; +import java.util.*; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.request.backend.CourseAttachmentMultiRequest; import xyz.playedu.api.request.backend.CourseAttachmentRequest; import xyz.playedu.api.request.backend.CourseAttachmentSortRequest; @@ -35,8 +34,6 @@ import xyz.playedu.common.types.JsonResponse; import xyz.playedu.course.domain.CourseAttachment; import xyz.playedu.course.service.CourseAttachmentService; -import java.util.*; - @RestController @Slf4j @RequestMapping("/backend/v1/course/{courseId}/attachment") @@ -65,9 +62,8 @@ public class CourseAttachmentController { } } - CourseAttachment courseAttachment = - attachmentService.create( - courseId, req.getSort(), req.getTitle(), type, req.getRid()); + attachmentService.create(courseId, req.getSort(), req.getTitle(), type, req.getRid()); + return JsonResponse.success(); } @@ -78,7 +74,7 @@ public class CourseAttachmentController { public JsonResponse storeMulti( @PathVariable(name = "courseId") Integer courseId, @RequestBody @Validated CourseAttachmentMultiRequest req) { - if (req.getAttachments().size() == 0) { + if (req.getAttachments().isEmpty()) { return JsonResponse.error("参数为空"); } diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseAttachmentDownloadLogController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseAttachmentDownloadLogController.java index 1012f24..2045ec1 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseAttachmentDownloadLogController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseAttachmentDownloadLogController.java @@ -15,12 +15,11 @@ */ package xyz.playedu.api.controller.backend; +import java.util.*; import lombok.extern.slf4j.Slf4j; - import org.apache.commons.collections4.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; - import xyz.playedu.common.annotation.Log; import xyz.playedu.common.constant.BusinessTypeConstant; import xyz.playedu.common.types.JsonResponse; @@ -29,8 +28,6 @@ import xyz.playedu.common.types.paginate.PaginationResult; import xyz.playedu.course.domain.CourseAttachmentDownloadLog; import xyz.playedu.course.service.CourseAttachmentDownloadLogService; -import java.util.*; - @RestController @Slf4j @RequestMapping("/backend/v1/course/attachment/download/log") diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseChapterController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseChapterController.java index 3a4fad3..8b0273d 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseChapterController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseChapterController.java @@ -19,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.event.CourseChapterDestroyEvent; import xyz.playedu.api.request.backend.CourseChapterRequest; import xyz.playedu.api.request.backend.CourseChapterSortRequest; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseController.java index 50052f9..137c835 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseController.java @@ -15,16 +15,18 @@ */ package xyz.playedu.api.controller.backend; +import java.text.ParseException; +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; - import org.apache.commons.collections4.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.event.CourseDestroyEvent; import xyz.playedu.api.request.backend.CourseRequest; import xyz.playedu.common.annotation.BackendPermission; @@ -53,11 +55,6 @@ import xyz.playedu.course.service.CourseService; import xyz.playedu.resource.domain.Resource; import xyz.playedu.resource.service.ResourceService; -import java.text.ParseException; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; - @RestController @Slf4j @RequestMapping("/backend/v1/course") diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseHourController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseHourController.java index faacf04..63bbe14 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseHourController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseHourController.java @@ -15,14 +15,13 @@ */ package xyz.playedu.api.controller.backend; +import java.util.*; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.event.CourseHourCreatedEvent; import xyz.playedu.api.event.CourseHourDestroyEvent; import xyz.playedu.api.request.backend.CourseHourMultiRequest; @@ -42,8 +41,6 @@ import xyz.playedu.course.domain.CourseHour; import xyz.playedu.course.service.CourseChapterService; import xyz.playedu.course.service.CourseHourService; -import java.util.*; - /** * @Author 杭州白书科技有限公司 * @@ -135,7 +132,7 @@ public class CourseHourController { public JsonResponse storeMulti( @PathVariable(name = "courseId") Integer courseId, @RequestBody @Validated CourseHourMultiRequest req) { - if (req.getHours().size() == 0) { + if (req.getHours().isEmpty()) { return JsonResponse.error("参数为空"); } diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseUserController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseUserController.java index c1c6fc8..9f95422 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseUserController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/CourseUserController.java @@ -15,15 +15,17 @@ */ package xyz.playedu.api.controller.backend; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; - import org.apache.commons.collections4.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.event.UserCourseRecordDestroyEvent; import xyz.playedu.api.request.backend.CourseUserDestroyRequest; import xyz.playedu.common.annotation.BackendPermission; @@ -42,11 +44,6 @@ import xyz.playedu.course.service.CourseService; import xyz.playedu.course.service.UserCourseHourRecordService; import xyz.playedu.course.service.UserCourseRecordService; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.stream.Collectors; - /** * @Author 杭州白书科技有限公司 * @@ -102,7 +99,7 @@ public class CourseUserController { }); } else { // 默认读取课程关联的全部部门 List depIds = courseService.getDepIdsByCourseId(courseId); - if (depIds != null && depIds.size() > 0) { + if (depIds != null && !depIds.isEmpty()) { filter.setDepIds(depIds); } } @@ -159,7 +156,7 @@ public class CourseUserController { public JsonResponse destroy( @PathVariable(name = "courseId") Integer courseId, @RequestBody @Validated CourseUserDestroyRequest req) { - if (req.getIds().size() == 0) { + if (req.getIds().isEmpty()) { return JsonResponse.error("请选择需要删除的数据"); } List records = diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/DashboardController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/DashboardController.java index 05f0fb1..b7f959a 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/DashboardController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/DashboardController.java @@ -15,11 +15,15 @@ */ package xyz.playedu.api.controller.backend; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - import xyz.playedu.common.annotation.Log; import xyz.playedu.common.constant.BackendConstant; import xyz.playedu.common.constant.BusinessTypeConstant; @@ -32,12 +36,6 @@ import xyz.playedu.course.service.CourseService; import xyz.playedu.course.service.UserLearnDurationStatsService; import xyz.playedu.resource.service.ResourceService; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/DepartmentController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/DepartmentController.java index 317055b..518ca35 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/DepartmentController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/DepartmentController.java @@ -15,15 +15,15 @@ */ package xyz.playedu.api.controller.backend; +import java.util.*; +import java.util.stream.Collectors; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; - import org.apache.commons.collections4.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.event.DepartmentDestroyEvent; import xyz.playedu.api.request.backend.DepartmentParentRequest; import xyz.playedu.api.request.backend.DepartmentRequest; @@ -50,9 +50,6 @@ import xyz.playedu.course.service.CourseDepartmentService; import xyz.playedu.course.service.CourseService; import xyz.playedu.course.service.UserCourseRecordService; -import java.util.*; -import java.util.stream.Collectors; - @RestController @Slf4j @RequestMapping("/backend/v1/department") diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/LoginController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/LoginController.java index e9a33ba..8305700 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/LoginController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/LoginController.java @@ -15,11 +15,11 @@ */ package xyz.playedu.api.controller.backend; +import java.util.HashMap; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.event.AdminUserLoginEvent; import xyz.playedu.api.request.backend.LoginRequest; import xyz.playedu.api.request.backend.PasswordChangeRequest; @@ -37,11 +37,9 @@ import xyz.playedu.common.service.RateLimiterService; import xyz.playedu.common.types.JsonResponse; import xyz.playedu.common.util.HelperUtil; import xyz.playedu.common.util.IpUtil; -import xyz.playedu.common.util.RedisUtil; +import xyz.playedu.common.util.MemoryCacheUtil; import xyz.playedu.common.util.RequestUtil; -import java.util.HashMap; - @RestController @RequestMapping("/backend/v1/auth") public class LoginController { @@ -68,8 +66,8 @@ public class LoginController { String limitKey = "admin-login-limit:" + loginRequest.getEmail(); Long reqCount = rateLimiterService.current(limitKey, 3600L); - if (reqCount > 5 && !playEduConfig.getTesting()) { - Long exp = RedisUtil.ttlWithoutPrefix(limitKey); + if (reqCount > 10 && !playEduConfig.getTesting()) { + Long exp = MemoryCacheUtil.ttlWithoutPrefix(limitKey); return JsonResponse.error( String.format("您的账号已被锁定,请%s后重试", exp > 60 ? exp / 60 + "分钟" : exp + "秒")); } @@ -80,7 +78,7 @@ public class LoginController { return JsonResponse.error("邮箱或密码错误"); } - RedisUtil.del(limitKey); + MemoryCacheUtil.del(limitKey); if (adminUser.getIsBanLogin().equals(1)) { return JsonResponse.error("当前管理员已禁止登录"); diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/ResourceCategoryController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/ResourceCategoryController.java index d3f7392..764b352 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/ResourceCategoryController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/ResourceCategoryController.java @@ -15,11 +15,12 @@ */ package xyz.playedu.api.controller.backend; +import java.util.*; +import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.event.ResourceCategoryDestroyEvent; import xyz.playedu.api.request.backend.ResourceCategoryParentRequest; import xyz.playedu.api.request.backend.ResourceCategoryRequest; @@ -40,9 +41,6 @@ import xyz.playedu.resource.domain.Resource; import xyz.playedu.resource.service.ResourceCategoryService; import xyz.playedu.resource.service.ResourceService; -import java.util.*; -import java.util.stream.Collectors; - /** * @Author 杭州白书科技有限公司 * @@ -128,7 +126,7 @@ public class ResourceCategoryController { data.put("videos", new ArrayList<>()); data.put("images", new ArrayList<>()); - if (courseIds != null && courseIds.size() > 0) { + if (courseIds != null && !courseIds.isEmpty()) { data.put( "courses", courseService.chunks( @@ -141,7 +139,7 @@ public class ResourceCategoryController { })); } - if (rids != null && rids.size() > 0) { + if (rids != null && !rids.isEmpty()) { Map> resources = resourceService .chunks( diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/ResourceController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/ResourceController.java index a3c600c..fb07a90 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/ResourceController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/ResourceController.java @@ -15,14 +15,14 @@ */ package xyz.playedu.api.controller.backend; +import java.util.*; +import java.util.stream.Collectors; import lombok.SneakyThrows; - import org.apache.commons.collections4.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.request.backend.ResourceDestroyMultiRequest; import xyz.playedu.api.request.backend.ResourceUpdateRequest; import xyz.playedu.common.annotation.Log; @@ -47,9 +47,6 @@ import xyz.playedu.resource.domain.ResourceVideo; import xyz.playedu.resource.service.ResourceService; import xyz.playedu.resource.service.ResourceVideoService; -import java.util.*; -import java.util.stream.Collectors; - @RestController @RequestMapping("/backend/v1/resource") public class ResourceController { diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/SystemController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/SystemController.java index 9a18f4d..c0b618c 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/SystemController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/SystemController.java @@ -15,13 +15,15 @@ */ package xyz.playedu.api.controller.backend; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - import xyz.playedu.api.bus.UserBus; import xyz.playedu.common.annotation.Log; import xyz.playedu.common.constant.BusinessTypeConstant; @@ -32,11 +34,6 @@ import xyz.playedu.common.service.DepartmentService; import xyz.playedu.common.types.JsonResponse; import xyz.playedu.common.util.RequestUtil; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - @RestController @RequestMapping("/backend/v1/system") @Slf4j diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/UploadController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/UploadController.java index df589f0..80da796 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/UploadController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/UploadController.java @@ -15,14 +15,13 @@ */ package xyz.playedu.api.controller.backend; +import java.util.HashMap; import lombok.extern.slf4j.Slf4j; - import org.apache.commons.collections4.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; - import xyz.playedu.api.request.backend.UploadFileMergeRequest; import xyz.playedu.common.annotation.BackendPermission; import xyz.playedu.common.annotation.Log; @@ -33,14 +32,13 @@ import xyz.playedu.common.context.BCtx; import xyz.playedu.common.exception.ServiceException; import xyz.playedu.common.service.AppConfigService; import xyz.playedu.common.types.JsonResponse; +import xyz.playedu.common.types.config.S3Config; import xyz.playedu.common.util.HelperUtil; import xyz.playedu.common.util.S3Util; import xyz.playedu.resource.domain.Resource; import xyz.playedu.resource.service.ResourceService; import xyz.playedu.resource.service.UploadService; -import java.util.HashMap; - @RestController @Slf4j @RequestMapping("/backend/v1/upload") @@ -59,7 +57,12 @@ public class UploadController { @RequestParam HashMap params, MultipartFile file) throws ServiceException { String categoryIds = MapUtils.getString(params, "category_ids"); - Resource res = uploadService.storeMinio(BCtx.getId(), file, categoryIds); + Resource res = + uploadService.storeMinio( + appConfigService.getS3Config().getService(), + BCtx.getId(), + file, + categoryIds); return JsonResponse.data(res); } @@ -121,7 +124,8 @@ public class UploadController { String originalFilename = req.getOriginalFilename().replaceAll("(?i)." + extension, ""); // 合并资源文件 - S3Util s3Util = new S3Util(appConfigService.getS3Config()); + S3Config s3Config = appConfigService.getS3Config(); + S3Util s3Util = new S3Util(s3Config); String url = s3Util.merge(req.getFilename(), req.getUploadId()); // 资源素材保存 @@ -133,7 +137,7 @@ public class UploadController { originalFilename, extension, req.getSize(), - BackendConstant.STORAGE_DRIVER_MINIO, + s3Config.getService(), "", req.getFilename(), url); @@ -142,7 +146,8 @@ public class UploadController { if (BackendConstant.RESOURCE_TYPE_VIDEO.equals(type)) { // 视频封面素材保存 Resource posterResource = - uploadService.storeBase64Image(BCtx.getId(), req.getPoster(), null); + uploadService.storeBase64Image( + s3Config.getService(), BCtx.getId(), req.getPoster(), null); // 视频的封面素材改为[隐藏 && 属于视频的子素材] resourceService.changeParentId(posterResource.getId(), videoResource.getId()); // 视频信息 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/UserController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/UserController.java index 8b4e906..e2c3e35 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/UserController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/backend/UserController.java @@ -16,18 +16,17 @@ package xyz.playedu.api.controller.backend; import cn.hutool.core.date.DateTime; - +import java.util.*; +import java.util.stream.Collectors; import lombok.Data; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; - import org.apache.commons.collections4.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.bus.UserBus; import xyz.playedu.api.event.UserCourseHourRecordDestroyEvent; import xyz.playedu.api.event.UserCourseRecordDestroyEvent; @@ -55,9 +54,6 @@ import xyz.playedu.common.util.StringUtil; import xyz.playedu.course.domain.*; import xyz.playedu.course.service.*; -import java.util.*; -import java.util.stream.Collectors; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/CategoryController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/CategoryController.java index f3da055..73ad925 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/CategoryController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/CategoryController.java @@ -15,19 +15,17 @@ */ package xyz.playedu.api.controller.frontend; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - import xyz.playedu.common.domain.Category; import xyz.playedu.common.service.CategoryService; import xyz.playedu.common.types.JsonResponse; -import java.util.HashMap; -import java.util.List; -import java.util.stream.Collectors; - @RestController @RequestMapping("/api/v1/category") public class CategoryController { diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/CourseController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/CourseController.java index b32ded2..00c677b 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/CourseController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/CourseController.java @@ -15,11 +15,15 @@ */ package xyz.playedu.api.controller.frontend; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; import lombok.SneakyThrows; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; - import xyz.playedu.common.context.FCtx; import xyz.playedu.common.types.JsonResponse; import xyz.playedu.common.util.IpUtil; @@ -28,13 +32,6 @@ import xyz.playedu.course.service.*; import xyz.playedu.resource.domain.Resource; import xyz.playedu.resource.service.ResourceService; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/DepartmentController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/DepartmentController.java index 5874ce2..3d014f7 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/DepartmentController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/DepartmentController.java @@ -15,15 +15,13 @@ */ package xyz.playedu.api.controller.frontend; +import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; - import xyz.playedu.common.domain.Department; import xyz.playedu.common.service.DepartmentService; import xyz.playedu.common.types.JsonResponse; -import java.util.stream.Collectors; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/HourController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/HourController.java index c52ebdb..3ec3772 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/HourController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/HourController.java @@ -15,20 +15,19 @@ */ package xyz.playedu.api.controller.frontend; +import java.util.HashMap; +import java.util.concurrent.TimeUnit; import lombok.SneakyThrows; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; - import xyz.playedu.api.event.UserCourseHourFinishedEvent; import xyz.playedu.api.event.UserLearnCourseUpdateEvent; import xyz.playedu.api.request.frontend.CourseHourRecordRequest; import xyz.playedu.common.context.FCtx; import xyz.playedu.common.types.JsonResponse; -import xyz.playedu.common.util.RedisDistributedLock; -import xyz.playedu.course.caches.CourseCache; +import xyz.playedu.common.util.MemoryDistributedLock; import xyz.playedu.course.caches.UserCanSeeCourseCache; import xyz.playedu.course.caches.UserLastLearnTimeCache; import xyz.playedu.course.domain.Course; @@ -40,9 +39,6 @@ import xyz.playedu.course.service.UserCourseHourRecordService; import xyz.playedu.resource.domain.Resource; import xyz.playedu.resource.service.ResourceService; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; - /** * @Author 杭州白书科技有限公司 * @@ -62,9 +58,8 @@ public class HourController { // ------- CACHE ---------- @Autowired private UserCanSeeCourseCache userCanSeeCourseCache; - @Autowired private CourseCache courseCache; - @Autowired private RedisDistributedLock redisDistributedLock; + @Autowired private MemoryDistributedLock distributedLock; @Autowired private UserLastLearnTimeCache userLastLearnTimeCache; @@ -125,7 +120,7 @@ public class HourController { // 获取锁 String lockKey = String.format("record:%d", FCtx.getId()); - boolean tryLock = redisDistributedLock.tryLock(lockKey, 5, TimeUnit.SECONDS); + boolean tryLock = distributedLock.tryLock(lockKey, 5, TimeUnit.SECONDS); if (!tryLock) { return JsonResponse.success(); } @@ -141,7 +136,7 @@ public class HourController { } } finally { // 此处未考虑上面代码执行失败释放锁 - redisDistributedLock.releaseLock(lockKey); + distributedLock.releaseLock(lockKey); } return JsonResponse.success(); @@ -156,7 +151,7 @@ public class HourController { // 获取锁 String lockKey = String.format("ping:%d", FCtx.getId()); - boolean tryLock = redisDistributedLock.tryLock(lockKey, 5, TimeUnit.SECONDS); + boolean tryLock = distributedLock.tryLock(lockKey, 5, TimeUnit.SECONDS); if (!tryLock) { return JsonResponse.success(); } @@ -178,7 +173,7 @@ public class HourController { this, FCtx.getId(), courseId, id, lastTime, curTime)); } finally { // 此处未考虑上面代码执行失败释放锁 - redisDistributedLock.releaseLock(lockKey); + distributedLock.releaseLock(lockKey); } return JsonResponse.success(); diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/LoginController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/LoginController.java index 8eb25a5..623d1cf 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/LoginController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/LoginController.java @@ -15,9 +15,9 @@ */ package xyz.playedu.api.controller.frontend; +import java.util.HashMap; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; import org.springframework.validation.annotation.Validated; @@ -25,7 +25,6 @@ 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 xyz.playedu.api.bus.LoginBus; import xyz.playedu.api.cache.LoginLimitCache; import xyz.playedu.api.cache.LoginLockCache; @@ -43,8 +42,6 @@ import xyz.playedu.common.util.*; import xyz.playedu.common.util.ldap.LdapTransformUser; import xyz.playedu.common.util.ldap.LdapUtil; -import java.util.HashMap; - @RestController @RequestMapping("/api/v1/auth/login") @Slf4j diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/SystemController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/SystemController.java index a63999e..6944b4c 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/SystemController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/SystemController.java @@ -15,18 +15,16 @@ */ package xyz.playedu.api.controller.frontend; +import java.util.HashMap; +import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - import xyz.playedu.common.constant.ConfigConstant; import xyz.playedu.common.service.AppConfigService; import xyz.playedu.common.types.JsonResponse; -import java.util.HashMap; -import java.util.Map; - @RestController @RequestMapping("/api/v1/system") public class SystemController { diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/UserController.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/UserController.java index 449bc45..1591bcb 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/UserController.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/controller/frontend/UserController.java @@ -15,15 +15,15 @@ */ package xyz.playedu.api.controller.frontend; +import java.util.*; +import java.util.stream.Collectors; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; - import org.apache.commons.collections4.MapUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; - import xyz.playedu.api.request.frontend.ChangePasswordRequest; import xyz.playedu.common.constant.FrontendConstant; import xyz.playedu.common.context.FCtx; @@ -32,6 +32,7 @@ import xyz.playedu.common.domain.Department; import xyz.playedu.common.domain.User; import xyz.playedu.common.domain.UserUploadImageLog; import xyz.playedu.common.exception.ServiceException; +import xyz.playedu.common.service.AppConfigService; import xyz.playedu.common.service.CategoryService; import xyz.playedu.common.service.DepartmentService; import xyz.playedu.common.service.UserService; @@ -43,9 +44,6 @@ import xyz.playedu.course.domain.*; import xyz.playedu.course.service.*; import xyz.playedu.resource.service.UploadService; -import java.util.*; -import java.util.stream.Collectors; - @RestController @RequestMapping("/api/v1/user") @Slf4j @@ -69,6 +67,8 @@ public class UserController { @Autowired private CategoryService categoryService; + @Autowired private AppConfigService appConfigService; + @GetMapping("/detail") public JsonResponse detail() { User user = FCtx.getUser(); @@ -91,6 +91,7 @@ public class UserController { public JsonResponse changeAvatar(MultipartFile file) { UserUploadImageLog log = uploadService.userAvatar( + appConfigService.getS3Config().getService(), FCtx.getId(), file, FrontendConstant.USER_UPLOAD_IMAGE_TYPE_AVATAR, diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/AdminUserLoginEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/AdminUserLoginEvent.java index f58228a..9cdbc27 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/AdminUserLoginEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/AdminUserLoginEvent.java @@ -15,13 +15,11 @@ */ package xyz.playedu.api.event; +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - @Getter @Setter public class AdminUserLoginEvent extends ApplicationEvent { diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseCategoryDestroyEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseCategoryDestroyEvent.java index 9fc431e..a2eb09c 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseCategoryDestroyEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseCategoryDestroyEvent.java @@ -15,13 +15,11 @@ */ package xyz.playedu.api.event; +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseChapterDestroyEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseChapterDestroyEvent.java index 8dd6ad3..eee4c18 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseChapterDestroyEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseChapterDestroyEvent.java @@ -15,13 +15,11 @@ */ package xyz.playedu.api.event; +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseDestroyEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseDestroyEvent.java index 1d55871..4ac4543 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseDestroyEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseDestroyEvent.java @@ -15,13 +15,11 @@ */ package xyz.playedu.api.event; +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseHourCreatedEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseHourCreatedEvent.java index 4a733dc..ffcf6a5 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseHourCreatedEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseHourCreatedEvent.java @@ -15,13 +15,11 @@ */ package xyz.playedu.api.event; +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseHourDestroyEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseHourDestroyEvent.java index f402b02..b974400 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseHourDestroyEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/CourseHourDestroyEvent.java @@ -15,13 +15,11 @@ */ package xyz.playedu.api.event; +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/DepartmentDestroyEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/DepartmentDestroyEvent.java index de9db84..83d3277 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/DepartmentDestroyEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/DepartmentDestroyEvent.java @@ -15,13 +15,11 @@ */ package xyz.playedu.api.event; +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/ResourceCategoryDestroyEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/ResourceCategoryDestroyEvent.java index f746430..0b8de61 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/ResourceCategoryDestroyEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/ResourceCategoryDestroyEvent.java @@ -15,13 +15,11 @@ */ package xyz.playedu.api.event; +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserCourseHourFinishedEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserCourseHourFinishedEvent.java index b3e0c44..82c301c 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserCourseHourFinishedEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserCourseHourFinishedEvent.java @@ -15,13 +15,11 @@ */ package xyz.playedu.api.event; +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserCourseHourRecordDestroyEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserCourseHourRecordDestroyEvent.java index 1fceeaa..cc91f0c 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserCourseHourRecordDestroyEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserCourseHourRecordDestroyEvent.java @@ -15,13 +15,11 @@ */ package xyz.playedu.api.event; +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserCourseRecordDestroyEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserCourseRecordDestroyEvent.java index 8fbe5ec..f3c69b6 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserCourseRecordDestroyEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserCourseRecordDestroyEvent.java @@ -15,13 +15,11 @@ */ package xyz.playedu.api.event; +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserDestroyEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserDestroyEvent.java index 988f648..e835b04 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserDestroyEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserDestroyEvent.java @@ -15,13 +15,11 @@ */ package xyz.playedu.api.event; +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserLearnCourseUpdateEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserLearnCourseUpdateEvent.java index 3c023b7..7ef51a1 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserLearnCourseUpdateEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserLearnCourseUpdateEvent.java @@ -17,7 +17,6 @@ package xyz.playedu.api.event; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; /** diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserLoginEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserLoginEvent.java index 011586a..0145cd6 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserLoginEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserLoginEvent.java @@ -16,14 +16,11 @@ package xyz.playedu.api.event; import cn.hutool.http.useragent.UserAgent; - +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserLogoutEvent.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserLogoutEvent.java index a4ee518..c63f1dd 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserLogoutEvent.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/event/UserLogoutEvent.java @@ -15,13 +15,11 @@ */ package xyz.playedu.api.event; +import java.util.Date; import lombok.Getter; import lombok.Setter; - import org.springframework.context.ApplicationEvent; -import java.util.Date; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/AdminInterceptor.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/AdminInterceptor.java index ebb66c0..3ee450c 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/AdminInterceptor.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/AdminInterceptor.java @@ -17,14 +17,13 @@ package xyz.playedu.api.interceptor; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; - +import java.io.IOException; +import java.util.Map; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; import org.springframework.web.servlet.HandlerInterceptor; - import xyz.playedu.common.bus.BackendBus; import xyz.playedu.common.context.BCtx; import xyz.playedu.common.domain.AdminUser; @@ -34,9 +33,6 @@ import xyz.playedu.common.service.BackendAuthService; import xyz.playedu.common.types.JsonResponse; import xyz.playedu.common.util.HelperUtil; -import java.io.IOException; -import java.util.Map; - @Component @Slf4j @Order(20) diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/ApiInterceptor.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/ApiInterceptor.java index 94f1a9d..3cbe7b5 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/ApiInterceptor.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/ApiInterceptor.java @@ -17,14 +17,11 @@ package xyz.playedu.api.interceptor; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; - import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; import org.springframework.web.servlet.HandlerInterceptor; - import xyz.playedu.common.config.PlayEduConfig; import xyz.playedu.common.constant.BackendConstant; import xyz.playedu.common.service.RateLimiterService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/FrontInterceptor.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/FrontInterceptor.java index f779b58..c98d551 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/FrontInterceptor.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/FrontInterceptor.java @@ -17,14 +17,12 @@ package xyz.playedu.api.interceptor; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; - +import java.io.IOException; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; import org.springframework.web.servlet.HandlerInterceptor; - import xyz.playedu.common.constant.FrontendConstant; import xyz.playedu.common.context.FCtx; import xyz.playedu.common.domain.User; @@ -33,8 +31,6 @@ import xyz.playedu.common.service.UserService; import xyz.playedu.common.types.JsonResponse; import xyz.playedu.common.util.HelperUtil; -import java.io.IOException; - @Component @Slf4j @Order(20) diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/WebMvcConfig.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/WebMvcConfig.java index 0be226c..7550aa6 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/WebMvcConfig.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/interceptor/WebMvcConfig.java @@ -16,12 +16,11 @@ package xyz.playedu.api.interceptor; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.config.annotation.CorsRegistry; @Configuration @Slf4j diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/AdminUserLoginListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/AdminUserLoginListener.java index 028e055..0c1548f 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/AdminUserLoginListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/AdminUserLoginListener.java @@ -16,11 +16,9 @@ package xyz.playedu.api.listener; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.AdminUserLoginEvent; import xyz.playedu.common.domain.AdminUser; import xyz.playedu.common.service.AdminUserService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseCategoryDestroyListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseCategoryDestroyListener.java index a3e5ce2..e290634 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseCategoryDestroyListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseCategoryDestroyListener.java @@ -18,7 +18,6 @@ package xyz.playedu.api.listener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.CourseCategoryDestroyEvent; import xyz.playedu.course.service.CourseService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseChapterDestroyListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseChapterDestroyListener.java index 0b61720..a9af1f0 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseChapterDestroyListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseChapterDestroyListener.java @@ -18,7 +18,6 @@ package xyz.playedu.api.listener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.CourseChapterDestroyEvent; import xyz.playedu.course.service.CourseHourService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseDestroyListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseDestroyListener.java index 9f869a2..d16ad3f 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseDestroyListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseDestroyListener.java @@ -18,7 +18,6 @@ package xyz.playedu.api.listener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.CourseDestroyEvent; import xyz.playedu.course.service.CourseAttachmentService; import xyz.playedu.course.service.CourseCategoryService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseHourCreatedListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseHourCreatedListener.java index af0ebb0..09783a0 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseHourCreatedListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseHourCreatedListener.java @@ -18,7 +18,6 @@ package xyz.playedu.api.listener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.CourseHourCreatedEvent; import xyz.playedu.course.service.CourseHourService; import xyz.playedu.course.service.CourseService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseHourDestroyListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseHourDestroyListener.java index 37dfd0b..3febe0d 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseHourDestroyListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/CourseHourDestroyListener.java @@ -18,7 +18,6 @@ package xyz.playedu.api.listener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.CourseHourDestroyEvent; import xyz.playedu.course.service.CourseHourService; import xyz.playedu.course.service.CourseService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/DepartmentDestroyListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/DepartmentDestroyListener.java index 1eae3f6..3addb0c 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/DepartmentDestroyListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/DepartmentDestroyListener.java @@ -18,7 +18,6 @@ package xyz.playedu.api.listener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.DepartmentDestroyEvent; import xyz.playedu.common.service.DepartmentService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserCourseHourFinishedListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserCourseHourFinishedListener.java index e0d6088..fbc6da4 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserCourseHourFinishedListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserCourseHourFinishedListener.java @@ -18,7 +18,6 @@ package xyz.playedu.api.listener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.UserCourseHourFinishedEvent; import xyz.playedu.course.service.CourseHourService; import xyz.playedu.course.service.UserCourseHourRecordService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserCourseHourRecordDestroyListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserCourseHourRecordDestroyListener.java index c9e4625..0cd6138 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserCourseHourRecordDestroyListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserCourseHourRecordDestroyListener.java @@ -16,11 +16,9 @@ package xyz.playedu.api.listener; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.UserCourseHourRecordDestroyEvent; import xyz.playedu.course.service.UserCourseRecordService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserCourseRecordDestroyListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserCourseRecordDestroyListener.java index b2c7c7d..caa77eb 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserCourseRecordDestroyListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserCourseRecordDestroyListener.java @@ -18,7 +18,6 @@ package xyz.playedu.api.listener; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.UserCourseRecordDestroyEvent; import xyz.playedu.course.service.UserCourseHourRecordService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserDestroyListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserDestroyListener.java index dd8a95c..0a4bf59 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserDestroyListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserDestroyListener.java @@ -16,11 +16,9 @@ package xyz.playedu.api.listener; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.UserDestroyEvent; import xyz.playedu.common.service.UserLoginRecordService; import xyz.playedu.common.service.UserService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserLearnCourseUpdateListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserLearnCourseUpdateListener.java index b43c02a..2e46f0d 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserLearnCourseUpdateListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserLearnCourseUpdateListener.java @@ -16,11 +16,9 @@ package xyz.playedu.api.listener; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.UserLearnCourseUpdateEvent; import xyz.playedu.course.service.UserLearnDurationRecordService; import xyz.playedu.course.service.UserLearnDurationStatsService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserLoginListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserLoginListener.java index 89c2479..2d01b3f 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserLoginListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserLoginListener.java @@ -15,20 +15,17 @@ */ package xyz.playedu.api.listener; +import java.util.HashMap; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.UserLoginEvent; import xyz.playedu.common.service.FrontendAuthService; import xyz.playedu.common.service.UserLoginRecordService; import xyz.playedu.common.util.IpUtil; -import java.util.HashMap; - @Component @Slf4j public class UserLoginListener { diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserLogoutListener.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserLogoutListener.java index e2b9e4a..eba26f7 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserLogoutListener.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/listener/UserLogoutListener.java @@ -16,12 +16,10 @@ package xyz.playedu.api.listener; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Component; - import xyz.playedu.api.event.UserLogoutEvent; import xyz.playedu.common.service.UserLoginRecordService; diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/AdminRoleRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/AdminRoleRequest.java index 81282c4..a232e93 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/AdminRoleRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/AdminRoleRequest.java @@ -16,16 +16,12 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; - -import lombok.Data; - -import org.hibernate.validator.constraints.Length; - import java.io.Serial; import java.io.Serializable; +import lombok.Data; +import org.hibernate.validator.constraints.Length; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/AdminUserRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/AdminUserRequest.java index 4714813..3824dc4 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/AdminUserRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/AdminUserRequest.java @@ -16,17 +16,13 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; - -import lombok.Data; - -import org.hibernate.validator.constraints.Length; - import java.io.Serial; import java.io.Serializable; +import lombok.Data; +import org.hibernate.validator.constraints.Length; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/AppConfigRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/AppConfigRequest.java index 7b3c7ab..467e35e 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/AppConfigRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/AppConfigRequest.java @@ -16,10 +16,8 @@ package xyz.playedu.api.request.backend; import jakarta.validation.constraints.NotNull; - -import lombok.Data; - import java.util.HashMap; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseAttachmentMultiRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseAttachmentMultiRequest.java index ce27437..76cf434 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseAttachmentMultiRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseAttachmentMultiRequest.java @@ -16,10 +16,8 @@ package xyz.playedu.api.request.backend; import jakarta.validation.constraints.NotNull; - -import lombok.Data; - import java.util.List; +import lombok.Data; @Data public class CourseAttachmentMultiRequest { diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseAttachmentRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseAttachmentRequest.java index c2afeb5..c6cd80c 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseAttachmentRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseAttachmentRequest.java @@ -17,7 +17,6 @@ package xyz.playedu.api.request.backend; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; - import lombok.Data; @Data diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseAttachmentSortRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseAttachmentSortRequest.java index 83e36ac..15805bf 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseAttachmentSortRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseAttachmentSortRequest.java @@ -15,9 +15,8 @@ */ package xyz.playedu.api.request.backend; -import lombok.Data; - import java.util.List; +import lombok.Data; @Data public class CourseAttachmentSortRequest { diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseCategoryRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseCategoryRequest.java index 8a8c301..a0faa66 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseCategoryRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseCategoryRequest.java @@ -16,16 +16,12 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; - -import lombok.Data; - -import org.hibernate.validator.constraints.Length; - import java.io.Serial; import java.io.Serializable; +import lombok.Data; +import org.hibernate.validator.constraints.Length; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseChapterRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseChapterRequest.java index 3c44b7a..d54dd96 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseChapterRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseChapterRequest.java @@ -17,9 +17,7 @@ package xyz.playedu.api.request.backend; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; - import lombok.Data; - import org.hibernate.validator.constraints.Length; /** diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseChapterSortRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseChapterSortRequest.java index 6d14029..2eac919 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseChapterSortRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseChapterSortRequest.java @@ -16,10 +16,8 @@ package xyz.playedu.api.request.backend; import jakarta.validation.constraints.NotNull; - -import lombok.Data; - import java.util.List; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseHourMultiRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseHourMultiRequest.java index 7b67cef..6c5e44c 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseHourMultiRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseHourMultiRequest.java @@ -16,12 +16,9 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotNull; - -import lombok.Data; - import java.util.List; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseHourRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseHourRequest.java index 0175c1f..2d17fe9 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseHourRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseHourRequest.java @@ -16,10 +16,8 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; - import lombok.Data; /** diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseHourSortRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseHourSortRequest.java index 6a49daf..ea5f960 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseHourSortRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseHourSortRequest.java @@ -15,9 +15,8 @@ */ package xyz.playedu.api.request.backend; -import lombok.Data; - import java.util.List; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseRequest.java index d94d981..fb59705 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseRequest.java @@ -16,14 +16,11 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; - -import lombok.Data; - import java.util.Date; import java.util.List; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseUserDestroyRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseUserDestroyRequest.java index e79df42..0741786 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseUserDestroyRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/CourseUserDestroyRequest.java @@ -16,10 +16,8 @@ package xyz.playedu.api.request.backend; import jakarta.validation.constraints.NotNull; - -import lombok.Data; - import java.util.List; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/DepartmentParentRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/DepartmentParentRequest.java index 47c78f8..f448712 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/DepartmentParentRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/DepartmentParentRequest.java @@ -16,12 +16,9 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotNull; - -import lombok.Data; - import java.util.List; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/DepartmentRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/DepartmentRequest.java index 9e09fce..7564732 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/DepartmentRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/DepartmentRequest.java @@ -16,16 +16,12 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; - -import lombok.Data; - -import org.hibernate.validator.constraints.Length; - import java.io.Serial; import java.io.Serializable; +import lombok.Data; +import org.hibernate.validator.constraints.Length; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/DepartmentSortRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/DepartmentSortRequest.java index abf939d..0db9a17 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/DepartmentSortRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/DepartmentSortRequest.java @@ -15,9 +15,8 @@ */ package xyz.playedu.api.request.backend; -import lombok.Data; - import java.util.List; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/LoginRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/LoginRequest.java index 05799bd..ef57297 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/LoginRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/LoginRequest.java @@ -16,11 +16,9 @@ package xyz.playedu.api.request.backend; import jakarta.validation.constraints.NotNull; - -import lombok.Data; - import java.io.Serial; import java.io.Serializable; +import lombok.Data; @Data public class LoginRequest implements Serializable { diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/PasswordChangeRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/PasswordChangeRequest.java index 312023e..4a366b6 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/PasswordChangeRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/PasswordChangeRequest.java @@ -16,9 +16,7 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotBlank; - import lombok.Data; /** diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategoryChangeRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategoryChangeRequest.java index f9a15f9..d66daeb 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategoryChangeRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategoryChangeRequest.java @@ -16,12 +16,9 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotNull; - -import lombok.Data; - import java.util.List; +import lombok.Data; @Data public class ResourceCategoryChangeRequest { diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategoryParentRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategoryParentRequest.java index 91aed7f..7419e25 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategoryParentRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategoryParentRequest.java @@ -16,12 +16,9 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotNull; - -import lombok.Data; - import java.util.List; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategoryRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategoryRequest.java index d609b80..ba1e625 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategoryRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategoryRequest.java @@ -16,12 +16,9 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; - import lombok.Data; - import org.hibernate.validator.constraints.Length; /** diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategorySortRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategorySortRequest.java index 51542d6..0393673 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategorySortRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceCategorySortRequest.java @@ -16,10 +16,8 @@ package xyz.playedu.api.request.backend; import jakarta.validation.constraints.NotNull; - -import lombok.Data; - import java.util.List; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceDestroyMultiRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceDestroyMultiRequest.java index d488a30..b091928 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceDestroyMultiRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceDestroyMultiRequest.java @@ -15,9 +15,8 @@ */ package xyz.playedu.api.request.backend; -import lombok.Data; - import java.util.List; +import lombok.Data; @Data public class ResourceDestroyMultiRequest { diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceRequest.java index 178ba2a..90e8f05 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceRequest.java @@ -16,12 +16,9 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; - import lombok.Data; - import org.hibernate.validator.constraints.Length; /** diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceUpdateRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceUpdateRequest.java index 88125e3..1ef5fe4 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceUpdateRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/ResourceUpdateRequest.java @@ -16,12 +16,9 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; - import lombok.Data; - import org.hibernate.validator.constraints.Length; @Data diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/UploadFileMergeRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/UploadFileMergeRequest.java index 4ac9fc6..2c84c52 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/UploadFileMergeRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/UploadFileMergeRequest.java @@ -16,10 +16,8 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; - import lombok.Data; /** diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/UserImportRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/UserImportRequest.java index 34a7d2f..887794e 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/UserImportRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/UserImportRequest.java @@ -16,12 +16,9 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotNull; - -import lombok.Data; - import java.util.List; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/UserRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/UserRequest.java index 2ecac01..570b532 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/UserRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/backend/UserRequest.java @@ -16,13 +16,10 @@ package xyz.playedu.api.request.backend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.Email; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; - import lombok.Data; - import org.hibernate.validator.constraints.Length; /** diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/ChangePasswordRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/ChangePasswordRequest.java index cca0072..af2890d 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/ChangePasswordRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/ChangePasswordRequest.java @@ -16,9 +16,7 @@ package xyz.playedu.api.request.frontend; import com.fasterxml.jackson.annotation.JsonProperty; - import jakarta.validation.constraints.NotBlank; - import lombok.Data; /** diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/CourseHourRecordRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/CourseHourRecordRequest.java index 3ace8d9..1cb4b5e 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/CourseHourRecordRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/CourseHourRecordRequest.java @@ -16,7 +16,6 @@ package xyz.playedu.api.request.frontend; import jakarta.validation.constraints.NotNull; - import lombok.Data; /** diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/LoginLdapRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/LoginLdapRequest.java index 0f27fc0..28f089f 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/LoginLdapRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/LoginLdapRequest.java @@ -16,7 +16,6 @@ package xyz.playedu.api.request.frontend; import jakarta.validation.constraints.NotBlank; - import lombok.Data; @Data diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/LoginPasswordRequest.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/LoginPasswordRequest.java index 9a31af1..5265a3e 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/LoginPasswordRequest.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/request/frontend/LoginPasswordRequest.java @@ -16,7 +16,6 @@ package xyz.playedu.api.request.frontend; import jakarta.validation.constraints.NotBlank; - import lombok.Data; @Data diff --git a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/schedule/LDAPSchedule.java b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/schedule/LDAPSchedule.java index 8ee1d04..23d76cd 100644 --- a/playedu-api/playedu-api/src/main/java/xyz/playedu/api/schedule/LDAPSchedule.java +++ b/playedu-api/playedu-api/src/main/java/xyz/playedu/api/schedule/LDAPSchedule.java @@ -16,11 +16,9 @@ package xyz.playedu.api.schedule; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; - import xyz.playedu.common.bus.LDAPBus; @Component diff --git a/playedu-api/playedu-api/src/main/resources/application.yml b/playedu-api/playedu-api/src/main/resources/application.yml index 04ac178..54f2ba6 100644 --- a/playedu-api/playedu-api/src/main/resources/application.yml +++ b/playedu-api/playedu-api/src/main/resources/application.yml @@ -21,20 +21,6 @@ spring: minimum-idle: 1 # 最小连接数 maximum-pool-size: 10 # 最大连接数 auto-commit: true # 自动提交 - # Redis配置 - data: - redis: - host: "127.0.0.1" - port: 6379 - password: - database: 0 - timeout: 5000 - lettuce: - pool: - max-wait: 30000 # 连接池最大阻塞等待时间(使用负数表示没有限制,默认-1) - max-active: 100 # 连接池最大连接数(使用负数表示没有限制,默认8) - max-idle: 20 # 连接池中的最大空闲连接(默认8) - min-idle: 1 # 连接池中的最小空闲连接(默认0) # 线程池配置 task: execution: diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/annotation/Log.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/annotation/Log.java index 78821aa..d28b6c7 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/annotation/Log.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/annotation/Log.java @@ -15,9 +15,8 @@ */ package xyz.playedu.common.annotation; -import xyz.playedu.common.constant.BusinessTypeConstant; - import java.lang.annotation.*; +import xyz.playedu.common.constant.BusinessTypeConstant; @Target({ElementType.PARAMETER, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/bus/BackendBus.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/bus/BackendBus.java index 47d3ef8..4bece52 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/bus/BackendBus.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/bus/BackendBus.java @@ -15,9 +15,10 @@ */ package xyz.playedu.common.bus; +import java.util.HashMap; +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import xyz.playedu.common.constant.BackendConstant; import xyz.playedu.common.context.BCtx; import xyz.playedu.common.domain.AdminRole; @@ -26,9 +27,6 @@ import xyz.playedu.common.service.AdminRoleService; import xyz.playedu.common.service.AdminUserService; import xyz.playedu.common.util.PrivacyUtil; -import java.util.HashMap; -import java.util.List; - @Component public class BackendBus { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/bus/LDAPBus.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/bus/LDAPBus.java index e277d88..b7943a5 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/bus/LDAPBus.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/bus/LDAPBus.java @@ -15,11 +15,15 @@ */ package xyz.playedu.common.bus; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import javax.naming.NamingException; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import xyz.playedu.common.domain.Department; import xyz.playedu.common.domain.LdapDepartment; import xyz.playedu.common.domain.LdapUser; @@ -32,14 +36,6 @@ import xyz.playedu.common.util.ldap.LdapTransformDepartment; import xyz.playedu.common.util.ldap.LdapTransformUser; import xyz.playedu.common.util.ldap.LdapUtil; -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import javax.naming.NamingException; - @Component @Slf4j public class LDAPBus { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/AuthConfig.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/AuthConfig.java index b6c8b7b..57a320d 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/AuthConfig.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/AuthConfig.java @@ -16,7 +16,6 @@ package xyz.playedu.common.config; import lombok.Data; - import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/MybatisPlusConfig.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/MybatisPlusConfig.java index 8b5063e..251ab05 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/MybatisPlusConfig.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/MybatisPlusConfig.java @@ -18,7 +18,6 @@ package xyz.playedu.common.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; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/PlayEduConfig.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/PlayEduConfig.java index 43dfb65..fedea41 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/PlayEduConfig.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/PlayEduConfig.java @@ -16,7 +16,6 @@ package xyz.playedu.common.config; import lombok.Data; - import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/RedisConfig.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/RedisConfig.java deleted file mode 100644 index 35e8a58..0000000 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/RedisConfig.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (C) 2023 杭州白书科技有限公司 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package xyz.playedu.common.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.ClassPathResource; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.script.DefaultRedisScript; -import org.springframework.data.redis.core.script.RedisScript; -import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; -import org.springframework.data.redis.serializer.StringRedisSerializer; -import org.springframework.scripting.support.ResourceScriptSource; - -@Configuration -public class RedisConfig { - - @Bean(name = "redisTemplate") - public RedisTemplate redisTemplate( - RedisConnectionFactory redisConnectionFactory) { - RedisTemplate redisTemplate = new RedisTemplate<>(); - redisTemplate.setConnectionFactory(redisConnectionFactory); - - // key值采用StringRedisSerializer序列化 - StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); - redisTemplate.setKeySerializer(stringRedisSerializer); - redisTemplate.setHashKeySerializer(stringRedisSerializer); - - GenericJackson2JsonRedisSerializer jsonRedisSerializer = - new GenericJackson2JsonRedisSerializer(); - redisTemplate.setValueSerializer(jsonRedisSerializer); - redisTemplate.setHashValueSerializer(jsonRedisSerializer); - - return redisTemplate; - } - - @Bean(name = "rateLimiterScript") - public RedisScript rateLimiterScript() { - DefaultRedisScript script = new DefaultRedisScript<>(); - script.setScriptSource( - new ResourceScriptSource(new ClassPathResource("lua/RateLimiterScript.lua"))); - script.setResultType(Long.class); - return script; - } -} diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/SaTokenConfig.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/SaTokenConfig.java index ef53c9e..6444e04 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/SaTokenConfig.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/config/SaTokenConfig.java @@ -17,7 +17,6 @@ package xyz.playedu.common.config; import cn.dev33.satoken.jwt.StpLogicJwtForSimple; import cn.dev33.satoken.stp.StpLogic; - import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/constant/BPermissionConstant.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/constant/BPermissionConstant.java index cfa9b94..fadc544 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/constant/BPermissionConstant.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/constant/BPermissionConstant.java @@ -21,36 +21,28 @@ public class BPermissionConstant { public static final String TYPE_DATA = "data"; public static final String PASSWORD_CHANGE = "password-change"; - public static final String ADMIN_USER_INDEX = "admin-user-index"; public static final String ADMIN_USER_CUD = "admin-user-cud"; - public static final String ADMIN_ROLE = "admin-role"; - public static final String ADMIN_LOG = "admin-log"; - public static final String DEPARTMENT_CUD = "department-cud"; public static final String DEPARTMENT_USER_LEARN = "department-user-learn"; - public static final String USER_INDEX = "user-index"; public static final String USER_STORE = "user-store"; public static final String USER_UPDATE = "user-update"; public static final String USER_DESTROY = "user-destroy"; public static final String USER_LEARN = "user-learn"; public static final String USER_LEARN_DESTROY = "user-learn-destroy"; - public static final String COURSE = "course"; public static final String COURSE_CUD = "course-cud"; public static final String COURSE_USER = "course-user"; public static final String COURSE_USER_DESTROY = "course-user-destroy"; - public static final String RESOURCE_CATEGORY = "resource-category"; public static final String RESOURCE_CATEGORY_MENU = "resource-category-menu"; public static final String RESOURCE_MENU = "resource-menu"; - public static final String SYSTEM_CONFIG = "system-config"; - public static final String UPLOAD = "upload"; + public static final String CACHE_MANAGE = "cache-manage"; // ##### 友情分割线 ################################################## diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/constant/ConfigConstant.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/constant/ConfigConstant.java index beaaef9..92df84f 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/constant/ConfigConstant.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/constant/ConfigConstant.java @@ -30,11 +30,13 @@ public class ConfigConstant { public static final String MEMBER_DEFAULT_AVATAR = "member.default_avatar"; - public static final String MINIO_ACCESS_KEY = "minio.access_key"; - public static final String MINIO_SECRET_KEY = "minio.secret_key"; - public static final String MINIO_BUCKET = "minio.bucket"; - public static final String MINIO_ENDPOINT = "minio.endpoint"; - public static final String MINIO_DOMAIN = "minio.domain"; + public static final String S3_SERVICE = "s3.service"; + public static final String S3_ACCESS_KEY = "s3.access_key"; + public static final String S3_SECRET_KEY = "s3.secret_key"; + public static final String S3_BUCKET = "s3.bucket"; + public static final String S3_REGION = "s3.region"; + public static final String S3_ENDPOINT = "s3.endpoint"; + public static final String S3_DOMAIN = "s3.domain"; public static final String LDAP_ENABLED = "ldap.enabled"; public static final String LDAP_URL = "ldap.url"; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/constant/SystemConstant.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/constant/SystemConstant.java index 765e5c7..4f5acf2 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/constant/SystemConstant.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/constant/SystemConstant.java @@ -21,7 +21,7 @@ public class SystemConstant { public static final String ENV_PROD = "prod"; - public static final String REDIS_PREFIX = "playedu:"; + public static final String CACHE_NAME_PREFIX = "playedu:"; public static final String JWT_PRV_ADMIN_USER = "dc14511e97e7eb725fb2976bc939b375"; // AdminUser的md5加密 diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/context/BCtx.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/context/BCtx.java index e826238..951b684 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/context/BCtx.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/context/BCtx.java @@ -15,11 +15,10 @@ */ package xyz.playedu.common.context; -import xyz.playedu.common.domain.AdminUser; - import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; +import xyz.playedu.common.domain.AdminUser; public class BCtx { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/context/FCtx.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/context/FCtx.java index 28aca14..1756bf9 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/context/FCtx.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/context/FCtx.java @@ -15,9 +15,8 @@ */ package xyz.playedu.common.context; -import xyz.playedu.common.domain.User; - import java.util.LinkedHashMap; +import xyz.playedu.common.domain.User; public class FCtx { private static final ThreadLocal> THREAD_LOCAL = diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminLog.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminLog.java index 51e31cc..b695abe 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminLog.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminLog.java @@ -20,11 +20,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName admin_logs diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminPermission.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminPermission.java index 4321435..a21aa9b 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminPermission.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminPermission.java @@ -20,11 +20,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName admin_permissions diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminRole.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminRole.java index 7ee85a8..2688cbe 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminRole.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminRole.java @@ -20,11 +20,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName admin_roles diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminRolePermission.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminRolePermission.java index fda75c4..e51575d 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminRolePermission.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminRolePermission.java @@ -20,10 +20,8 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; +import lombok.Data; /** * @TableName admin_role_permission diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminUser.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminUser.java index cd481c0..638083d 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminUser.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminUser.java @@ -22,17 +22,14 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; - +import java.io.Serializable; +import java.util.Date; import lombok.Data; import lombok.extern.slf4j.Slf4j; - import xyz.playedu.common.bus.BackendBus; import xyz.playedu.common.constant.BPermissionConstant; import xyz.playedu.common.constant.BackendConstant; -import java.io.Serializable; -import java.util.Date; - /** * @TableName admin_users */ diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminUserRole.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminUserRole.java index 864fb3c..c199c6d 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminUserRole.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AdminUserRole.java @@ -20,10 +20,8 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; +import lombok.Data; /** * @TableName admin_user_role diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AppConfig.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AppConfig.java index 32e6066..a41155c 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AppConfig.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/AppConfig.java @@ -22,11 +22,9 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName app_config diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/Category.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/Category.java index 684ec35..47f9de2 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/Category.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/Category.java @@ -21,11 +21,9 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName resource_categories diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/Department.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/Department.java index 791335d..7248d75 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/Department.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/Department.java @@ -20,11 +20,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName departments diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/LdapDepartment.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/LdapDepartment.java index c4e40f3..18b6659 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/LdapDepartment.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/LdapDepartment.java @@ -20,7 +20,6 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - import java.io.Serializable; import java.util.Date; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/LdapUser.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/LdapUser.java index 49b505d..12618b0 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/LdapUser.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/LdapUser.java @@ -19,7 +19,6 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; - import java.io.Serializable; import java.util.Date; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/User.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/User.java index 9f075f9..ed2cd58 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/User.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/User.java @@ -22,16 +22,13 @@ import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonGetter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; - +import java.io.Serializable; +import java.util.Date; import lombok.Data; - import xyz.playedu.common.bus.BackendBus; import xyz.playedu.common.constant.BPermissionConstant; import xyz.playedu.common.constant.BackendConstant; -import java.io.Serializable; -import java.util.Date; - /** * @TableName users */ diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/UserDepartment.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/UserDepartment.java index 131b458..3bf0918 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/UserDepartment.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/UserDepartment.java @@ -20,10 +20,8 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; +import lombok.Data; /** * @TableName user_department diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/UserLoginRecord.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/UserLoginRecord.java index de27066..80cfe94 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/UserLoginRecord.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/UserLoginRecord.java @@ -19,11 +19,9 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName user_login_records diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/UserUploadImageLog.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/UserUploadImageLog.java index ad11122..9331e02 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/UserUploadImageLog.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/domain/UserUploadImageLog.java @@ -20,11 +20,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName user_upload_image_logs diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminLogMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminLogMapper.java index ff9e907..9ba2d5d 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminLogMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminLogMapper.java @@ -16,14 +16,11 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - +import java.util.List; import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.domain.AdminLog; import xyz.playedu.common.types.paginate.AdminLogPaginateFiler; -import java.util.List; - /** * @author tengteng * @description 针对表【admin_logs】的数据库操作Mapper diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminPermissionMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminPermissionMapper.java index f9399b2..0a46c85 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminPermissionMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminPermissionMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.domain.AdminPermission; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminRoleMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminRoleMapper.java index 162757c..bfea2ae 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminRoleMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminRoleMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.domain.AdminRole; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminRolePermissionMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminRolePermissionMapper.java index 4ce7795..5ddbd01 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminRolePermissionMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminRolePermissionMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.domain.AdminRolePermission; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminUserMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminUserMapper.java index a5569e2..210d7a2 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminUserMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminUserMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.domain.AdminUser; @Mapper diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminUserRoleMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminUserRoleMapper.java index 43adf66..7b0ddc5 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminUserRoleMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AdminUserRoleMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.domain.AdminUserRole; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AppConfigMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AppConfigMapper.java index bbf5bd9..ca98de4 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AppConfigMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/AppConfigMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.domain.AppConfig; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/CategoryMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/CategoryMapper.java index fa534c4..891dea8 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/CategoryMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/CategoryMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.domain.Category; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/DepartmentMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/DepartmentMapper.java index a9f06bd..be9c19e 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/DepartmentMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/DepartmentMapper.java @@ -16,14 +16,11 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - +import java.util.List; import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.domain.Department; import xyz.playedu.common.types.mapper.DepartmentsUserCountMapRes; -import java.util.List; - /** * @author tengteng * @description 针对表【departments】的数据库操作Mapper diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/LdapDepartmentMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/LdapDepartmentMapper.java index 6cacf70..15833f8 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/LdapDepartmentMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/LdapDepartmentMapper.java @@ -16,7 +16,6 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import xyz.playedu.common.domain.LdapDepartment; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/LdapUserMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/LdapUserMapper.java index 104adb7..4ef26a0 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/LdapUserMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/LdapUserMapper.java @@ -16,7 +16,6 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import xyz.playedu.common.domain.LdapUser; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserDepartmentMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserDepartmentMapper.java index da20975..ec63d16 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserDepartmentMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserDepartmentMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.domain.UserDepartment; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserLoginRecordMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserLoginRecordMapper.java index b4ea1d1..d08ae17 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserLoginRecordMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserLoginRecordMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.domain.UserLoginRecord; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserMapper.java index 3f14e13..b4b342f 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserMapper.java @@ -16,14 +16,11 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - +import java.util.List; import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.domain.User; import xyz.playedu.common.types.paginate.UserPaginateFilter; -import java.util.List; - /** * @author tengteng * @description 针对表【users】的数据库操作Mapper diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserUploadImageLogMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserUploadImageLogMapper.java index 6cd7dc8..3a61771 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserUploadImageLogMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/mapper/UserUploadImageLogMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.common.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.domain.UserUploadImageLog; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminLogService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminLogService.java index be28b7f..7bd96f0 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminLogService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminLogService.java @@ -16,7 +16,6 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - import xyz.playedu.common.domain.AdminLog; import xyz.playedu.common.types.paginate.AdminLogPaginateFiler; import xyz.playedu.common.types.paginate.PaginationResult; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminPermissionService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminPermissionService.java index c491644..b4281db 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminPermissionService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminPermissionService.java @@ -16,11 +16,9 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - -import xyz.playedu.common.domain.AdminPermission; - import java.util.HashMap; import java.util.List; +import xyz.playedu.common.domain.AdminPermission; /** * @author tengteng diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminRolePermissionService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminRolePermissionService.java index a4639e3..684d3df 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminRolePermissionService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminRolePermissionService.java @@ -16,7 +16,6 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - import xyz.playedu.common.domain.AdminRolePermission; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminRoleService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminRoleService.java index 15b2fd3..ca03603 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminRoleService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminRoleService.java @@ -16,12 +16,10 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - +import java.util.List; import xyz.playedu.common.domain.AdminRole; import xyz.playedu.common.exception.NotFoundException; -import java.util.List; - /** * @author tengteng * @description 针对表【admin_roles】的数据库操作Service diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminUserRoleService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminUserRoleService.java index 22ca247..dc0a28e 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminUserRoleService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminUserRoleService.java @@ -16,10 +16,8 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - -import xyz.playedu.common.domain.AdminUserRole; - import java.util.List; +import xyz.playedu.common.domain.AdminUserRole; /** * @author tengteng diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminUserService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminUserService.java index 17bae01..8bf9097 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminUserService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AdminUserService.java @@ -16,16 +16,14 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - +import java.util.List; +import java.util.Map; import xyz.playedu.common.domain.AdminUser; import xyz.playedu.common.exception.NotFoundException; import xyz.playedu.common.exception.ServiceException; import xyz.playedu.common.types.paginate.AdminUserPaginateFilter; import xyz.playedu.common.types.paginate.PaginationResult; -import java.util.List; -import java.util.Map; - /** * @author tengteng * @description 针对表【admin_users】的数据库操作Service diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AppConfigService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AppConfigService.java index 753dfe3..030b67f 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AppConfigService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/AppConfigService.java @@ -16,14 +16,12 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - -import xyz.playedu.common.domain.AppConfig; -import xyz.playedu.common.types.LdapConfig; -import xyz.playedu.common.types.config.S3Config; - import java.util.HashMap; import java.util.List; import java.util.Map; +import xyz.playedu.common.domain.AppConfig; +import xyz.playedu.common.types.LdapConfig; +import xyz.playedu.common.types.config.S3Config; public interface AppConfigService extends IService { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/CategoryService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/CategoryService.java index e2fb660..7b1a095 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/CategoryService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/CategoryService.java @@ -16,12 +16,10 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - -import xyz.playedu.common.domain.Category; -import xyz.playedu.common.exception.NotFoundException; - import java.util.List; import java.util.Map; +import xyz.playedu.common.domain.Category; +import xyz.playedu.common.exception.NotFoundException; /** * @author tengteng diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/DepartmentService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/DepartmentService.java index 989aefd..5774f7a 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/DepartmentService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/DepartmentService.java @@ -16,12 +16,10 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - -import xyz.playedu.common.domain.Department; -import xyz.playedu.common.exception.NotFoundException; - import java.util.List; import java.util.Map; +import xyz.playedu.common.domain.Department; +import xyz.playedu.common.exception.NotFoundException; /** * @author tengteng diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/LdapDepartmentService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/LdapDepartmentService.java index 368a99f..1efe631 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/LdapDepartmentService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/LdapDepartmentService.java @@ -16,10 +16,8 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - -import xyz.playedu.common.domain.LdapDepartment; - import java.util.List; +import xyz.playedu.common.domain.LdapDepartment; public interface LdapDepartmentService extends IService { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/LdapUserService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/LdapUserService.java index e3f1905..bddd13a 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/LdapUserService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/LdapUserService.java @@ -16,7 +16,6 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - import xyz.playedu.common.domain.LdapUser; import xyz.playedu.common.util.ldap.LdapTransformUser; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserDepartmentService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserDepartmentService.java index b624c34..e20ce51 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserDepartmentService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserDepartmentService.java @@ -16,10 +16,8 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - -import xyz.playedu.common.domain.UserDepartment; - import java.util.List; +import xyz.playedu.common.domain.UserDepartment; /** * @author tengteng diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserLoginRecordService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserLoginRecordService.java index 149242f..baf40e3 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserLoginRecordService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserLoginRecordService.java @@ -16,7 +16,6 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - import xyz.playedu.common.domain.UserLoginRecord; public interface UserLoginRecordService extends IService { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserService.java index 82b4c82..b654392 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserService.java @@ -16,16 +16,14 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - +import java.util.List; +import java.util.Map; import xyz.playedu.common.domain.User; import xyz.playedu.common.exception.NotFoundException; import xyz.playedu.common.exception.ServiceException; import xyz.playedu.common.types.paginate.PaginationResult; import xyz.playedu.common.types.paginate.UserPaginateFilter; -import java.util.List; -import java.util.Map; - /** * @author tengteng * @description 针对表【users】的数据库操作Service diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserUploadImageLogService.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserUploadImageLogService.java index 860d918..9a3fa49 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserUploadImageLogService.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/UserUploadImageLogService.java @@ -16,7 +16,6 @@ package xyz.playedu.common.service; import com.baomidou.mybatisplus.extension.service.IService; - import xyz.playedu.common.domain.UserUploadImageLog; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminLogServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminLogServiceImpl.java index f39f79b..41e3ba6 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminLogServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminLogServiceImpl.java @@ -16,9 +16,7 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - import org.springframework.stereotype.Service; - import xyz.playedu.common.domain.AdminLog; import xyz.playedu.common.mapper.AdminLogMapper; import xyz.playedu.common.service.AdminLogService; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminPermissionServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminPermissionServiceImpl.java index d5fd4f1..92f29d5 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminPermissionServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminPermissionServiceImpl.java @@ -16,16 +16,13 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - -import org.springframework.stereotype.Service; - -import xyz.playedu.common.domain.AdminPermission; -import xyz.playedu.common.mapper.AdminPermissionMapper; -import xyz.playedu.common.service.AdminPermissionService; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import org.springframework.stereotype.Service; +import xyz.playedu.common.domain.AdminPermission; +import xyz.playedu.common.mapper.AdminPermissionMapper; +import xyz.playedu.common.service.AdminPermissionService; /** * @author tengteng diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminRolePermissionServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminRolePermissionServiceImpl.java index 490d37e..a1aa91a 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminRolePermissionServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminRolePermissionServiceImpl.java @@ -16,9 +16,7 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - import org.springframework.stereotype.Service; - import xyz.playedu.common.domain.AdminRolePermission; import xyz.playedu.common.mapper.AdminRolePermissionMapper; import xyz.playedu.common.service.AdminRolePermissionService; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminRoleServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminRoleServiceImpl.java index bb058a9..927fe4a 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminRoleServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminRoleServiceImpl.java @@ -17,11 +17,12 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - import xyz.playedu.common.constant.BackendConstant; import xyz.playedu.common.domain.AdminRole; import xyz.playedu.common.domain.AdminRolePermission; @@ -32,10 +33,6 @@ import xyz.playedu.common.service.AdminRoleService; import xyz.playedu.common.service.AdminUserRoleService; import xyz.playedu.common.util.HelperUtil; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - /** * @author tengteng * @description 针对表【admin_roles】的数据库操作Service实现 diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminUserRoleServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminUserRoleServiceImpl.java index d58d020..c12c8e6 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminUserRoleServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminUserRoleServiceImpl.java @@ -16,15 +16,12 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.List; import org.springframework.stereotype.Service; - import xyz.playedu.common.domain.AdminUserRole; import xyz.playedu.common.mapper.AdminUserRoleMapper; import xyz.playedu.common.service.AdminUserRoleService; -import java.util.List; - /** * @author tengteng * @description 针对表【admin_user_role】的数据库操作Service实现 diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminUserServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminUserServiceImpl.java index 34c834a..5b1fe50 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminUserServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AdminUserServiceImpl.java @@ -19,11 +19,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.*; +import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - import xyz.playedu.common.domain.AdminUser; import xyz.playedu.common.domain.AdminUserRole; import xyz.playedu.common.exception.NotFoundException; @@ -35,9 +35,6 @@ import xyz.playedu.common.types.paginate.AdminUserPaginateFilter; import xyz.playedu.common.types.paginate.PaginationResult; import xyz.playedu.common.util.HelperUtil; -import java.util.*; -import java.util.stream.Collectors; - @Service public class AdminUserServiceImpl extends ServiceImpl implements AdminUserService { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AppConfigServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AppConfigServiceImpl.java index 6a29c13..447fc31 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AppConfigServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AppConfigServiceImpl.java @@ -16,12 +16,14 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; import lombok.extern.log4j.Log4j2; - import org.springframework.core.env.Environment; import org.springframework.stereotype.Service; - import xyz.playedu.common.constant.ConfigConstant; import xyz.playedu.common.domain.AppConfig; import xyz.playedu.common.exception.ServiceException; @@ -31,12 +33,6 @@ import xyz.playedu.common.types.LdapConfig; import xyz.playedu.common.types.config.S3Config; import xyz.playedu.common.util.StringUtil; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - @Service @Log4j2 public class AppConfigServiceImpl extends ServiceImpl @@ -102,40 +98,32 @@ public class AppConfigServiceImpl extends ServiceImpl config = keyValues(); S3Config s3Config = new S3Config(); - s3Config.setAccessKey(config.get(ConfigConstant.MINIO_ACCESS_KEY)); - s3Config.setSecretKey(config.get(ConfigConstant.MINIO_SECRET_KEY)); - s3Config.setBucket(config.get(ConfigConstant.MINIO_BUCKET)); - s3Config.setEndpoint(config.get(ConfigConstant.MINIO_ENDPOINT)); - s3Config.setDomain(config.get(ConfigConstant.MINIO_DOMAIN)); - s3Config.setRegion(null); - s3Config.setService("minio"); + s3Config.setAccessKey(config.get(ConfigConstant.S3_ACCESS_KEY)); + s3Config.setSecretKey(config.get(ConfigConstant.S3_SECRET_KEY)); + s3Config.setBucket(config.get(ConfigConstant.S3_BUCKET)); + s3Config.setEndpoint(config.get(ConfigConstant.S3_ENDPOINT)); + s3Config.setDomain(config.get(ConfigConstant.S3_DOMAIN)); + s3Config.setService(ConfigConstant.S3_SERVICE); - if (StringUtil.isEmpty(s3Config.getAccessKey())) { - s3Config.setAccessKey(environment.getProperty("MINIO_USERNAME")); - } - if (StringUtil.isEmpty(s3Config.getSecretKey())) { - s3Config.setSecretKey(environment.getProperty("MINIO_PASSWORD")); - } - if (StringUtil.isEmpty(s3Config.getBucket())) { - s3Config.setBucket(environment.getProperty("MINIO_BUCKET")); - } - if (StringUtil.isEmpty(s3Config.getEndpoint())) { - s3Config.setEndpoint(environment.getProperty("MINIO_ENDPOINT")); - } - if (StringUtil.isEmpty(s3Config.getDomain())) { - s3Config.setDomain(environment.getProperty("MINIO_DOMAIN")); - } + // region解析 + String region = config.get(ConfigConstant.S3_REGION); + s3Config.setRegion(StringUtil.isEmpty(region) ? null : region); - if (s3Config.getService().equals("minio") && StringUtil.isNotEmpty(s3Config.getDomain())) { + if (StringUtil.isNotEmpty(s3Config.getService()) + && StringUtil.isNotEmpty(s3Config.getDomain())) { String _domain = s3Config.getDomain(); + // 拼接https://前缀 + if (_domain.length() < 7 + || (!"http://".equalsIgnoreCase(_domain.substring(0, 7)) + && !"https://".equalsIgnoreCase(_domain.substring(0, 8)))) { + _domain = "https://" + _domain; + } + // 移除 / 后缀 if (StringUtil.endsWith(_domain, "/")) { _domain = _domain.substring(0, _domain.length() - 1); } - // 判断是否携带了bucket - if (!StringUtil.endsWith(_domain, s3Config.getBucket())) { - _domain += "/" + s3Config.getBucket(); - } + s3Config.setDomain(_domain); } diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AuthServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AuthServiceImpl.java index 7d37aac..8221093 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AuthServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/AuthServiceImpl.java @@ -17,17 +17,13 @@ package xyz.playedu.common.service.impl; import cn.dev33.satoken.stp.SaLoginConfig; import cn.dev33.satoken.stp.StpUtil; - +import java.util.HashMap; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import xyz.playedu.common.config.AuthConfig; import xyz.playedu.common.service.AuthService; -import java.util.HashMap; - @Service @Slf4j public class AuthServiceImpl implements AuthService { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/BackendAuthServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/BackendAuthServiceImpl.java index e92c88e..9a776df 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/BackendAuthServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/BackendAuthServiceImpl.java @@ -15,15 +15,13 @@ */ package xyz.playedu.common.service.impl; +import java.util.HashMap; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import xyz.playedu.common.constant.SystemConstant; import xyz.playedu.common.service.AuthService; import xyz.playedu.common.service.BackendAuthService; -import java.util.HashMap; - @Service public class BackendAuthServiceImpl implements BackendAuthService { @Autowired private AuthService authService; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/CategoryServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/CategoryServiceImpl.java index a12b0b8..98c8ed6 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/CategoryServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/CategoryServiceImpl.java @@ -16,20 +16,17 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import xyz.playedu.common.domain.Category; -import xyz.playedu.common.exception.NotFoundException; -import xyz.playedu.common.mapper.CategoryMapper; -import xyz.playedu.common.service.CategoryService; - import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import xyz.playedu.common.domain.Category; +import xyz.playedu.common.exception.NotFoundException; +import xyz.playedu.common.mapper.CategoryMapper; +import xyz.playedu.common.service.CategoryService; /** * @author tengteng diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/DepartmentServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/DepartmentServiceImpl.java index b96cc91..695c3c2 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/DepartmentServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/DepartmentServiceImpl.java @@ -17,14 +17,13 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.*; +import java.util.stream.Collectors; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - import xyz.playedu.common.domain.Department; import xyz.playedu.common.domain.UserDepartment; import xyz.playedu.common.exception.NotFoundException; @@ -34,9 +33,6 @@ import xyz.playedu.common.service.UserDepartmentService; import xyz.playedu.common.types.mapper.DepartmentsUserCountMapRes; import xyz.playedu.common.util.StringUtil; -import java.util.*; -import java.util.stream.Collectors; - /** * @author tengteng * @description 针对表【departments】的数据库操作Service实现 diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/FrontendAuthServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/FrontendAuthServiceImpl.java index 1351d80..443364e 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/FrontendAuthServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/FrontendAuthServiceImpl.java @@ -15,15 +15,13 @@ */ package xyz.playedu.common.service.impl; +import java.util.HashMap; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; - import xyz.playedu.common.constant.SystemConstant; import xyz.playedu.common.service.AuthService; import xyz.playedu.common.service.FrontendAuthService; -import java.util.HashMap; - @Service public class FrontendAuthServiceImpl implements FrontendAuthService { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/LdapDepartmentServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/LdapDepartmentServiceImpl.java index 234c0fa..f51d09e 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/LdapDepartmentServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/LdapDepartmentServiceImpl.java @@ -16,16 +16,13 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.Date; +import java.util.List; import org.springframework.stereotype.Service; - import xyz.playedu.common.domain.LdapDepartment; import xyz.playedu.common.mapper.LdapDepartmentMapper; import xyz.playedu.common.service.LdapDepartmentService; -import java.util.Date; -import java.util.List; - @Service public class LdapDepartmentServiceImpl extends ServiceImpl implements LdapDepartmentService { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/LdapUserServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/LdapUserServiceImpl.java index b61b67e..db7542d 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/LdapUserServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/LdapUserServiceImpl.java @@ -16,17 +16,14 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.Date; import org.springframework.stereotype.Service; - import xyz.playedu.common.domain.LdapUser; import xyz.playedu.common.mapper.LdapUserMapper; import xyz.playedu.common.service.LdapUserService; import xyz.playedu.common.util.StringUtil; import xyz.playedu.common.util.ldap.LdapTransformUser; -import java.util.Date; - /** * @author tengyongzhi * @description 针对表【ldap_user】的数据库操作Service实现 diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/MemoryRateLimiterServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/MemoryRateLimiterServiceImpl.java new file mode 100644 index 0000000..97141cc --- /dev/null +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/MemoryRateLimiterServiceImpl.java @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2023 杭州白书科技有限公司 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package xyz.playedu.common.service.impl; + +import java.util.concurrent.locks.ReentrantLock; +import org.springframework.stereotype.Service; +import xyz.playedu.common.service.RateLimiterService; +import xyz.playedu.common.util.MemoryCacheUtil; + +@Service +public class MemoryRateLimiterServiceImpl implements RateLimiterService { + private static final ReentrantLock lock = new ReentrantLock(); + + @Override + public Long current(String key, Long duration) { + lock.lock(); + try { + Long count = (Long) MemoryCacheUtil.get(key); + if (count == null) { + // 第一次访问,设置初始值和过期时间 + MemoryCacheUtil.set(key, 1L, duration); + return 1L; + } + // 已存在计数器,直接自增 + return MemoryCacheUtil.increment(key, 1L); + } finally { + lock.unlock(); + } + } +} diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/RateLimiterServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/RateLimiterServiceImpl.java deleted file mode 100644 index d4cf765..0000000 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/RateLimiterServiceImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2023 杭州白书科技有限公司 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package xyz.playedu.common.service.impl; - -import lombok.extern.slf4j.Slf4j; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.data.redis.core.script.RedisScript; -import org.springframework.stereotype.Component; - -import xyz.playedu.common.service.RateLimiterService; -import xyz.playedu.common.util.RedisUtil; - -import java.util.Arrays; - -@Component -@Slf4j -public class RateLimiterServiceImpl implements RateLimiterService { - - @Autowired - @Qualifier("rateLimiterScript") - private RedisScript redisScript; - - @Override - public Long current(String key, Long seconds) { - return RedisUtil.handler().execute(redisScript, Arrays.asList(key, seconds + "")); - } -} diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserDepartmentServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserDepartmentServiceImpl.java index c50676f..e6cb418 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserDepartmentServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserDepartmentServiceImpl.java @@ -16,16 +16,13 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.ArrayList; +import java.util.List; import org.springframework.stereotype.Service; - import xyz.playedu.common.domain.UserDepartment; import xyz.playedu.common.mapper.UserDepartmentMapper; import xyz.playedu.common.service.UserDepartmentService; -import java.util.ArrayList; -import java.util.List; - /** * @author tengteng * @description 针对表【user_department】的数据库操作Service实现 diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserLoginRecordServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserLoginRecordServiceImpl.java index ceef6aa..93eafa5 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserLoginRecordServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserLoginRecordServiceImpl.java @@ -16,9 +16,7 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - import org.springframework.stereotype.Service; - import xyz.playedu.common.domain.UserLoginRecord; import xyz.playedu.common.mapper.UserLoginRecordMapper; import xyz.playedu.common.service.UserLoginRecordService; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserServiceImpl.java index 52b6b1f..953a924 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserServiceImpl.java @@ -16,13 +16,13 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; import lombok.SneakyThrows; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - import xyz.playedu.common.constant.SystemConstant; import xyz.playedu.common.domain.User; import xyz.playedu.common.domain.UserDepartment; @@ -35,10 +35,6 @@ import xyz.playedu.common.types.paginate.PaginationResult; import xyz.playedu.common.types.paginate.UserPaginateFilter; import xyz.playedu.common.util.HelperUtil; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.stream.Collectors; - /** * @author tengteng * @description 针对表【users】的数据库操作Service实现 diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserUploadImageLogServiceImpl.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserUploadImageLogServiceImpl.java index 881421c..a3bd252 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserUploadImageLogServiceImpl.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/service/impl/UserUploadImageLogServiceImpl.java @@ -16,9 +16,7 @@ package xyz.playedu.common.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - import org.springframework.stereotype.Service; - import xyz.playedu.common.domain.UserUploadImageLog; import xyz.playedu.common.mapper.UserUploadImageLogMapper; import xyz.playedu.common.service.UserUploadImageLogService; diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/mapper/UserCourseHourRecordCourseCountMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/mapper/UserCourseHourRecordCourseCountMapper.java index 9190b64..e2f2292 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/mapper/UserCourseHourRecordCourseCountMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/mapper/UserCourseHourRecordCourseCountMapper.java @@ -16,7 +16,6 @@ package xyz.playedu.common.types.mapper; import com.fasterxml.jackson.annotation.JsonProperty; - import lombok.Data; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/mapper/UserCourseHourRecordUserCountMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/mapper/UserCourseHourRecordUserCountMapper.java index 4c4f5ba..6882375 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/mapper/UserCourseHourRecordUserCountMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/mapper/UserCourseHourRecordUserCountMapper.java @@ -16,7 +16,6 @@ package xyz.playedu.common.types.mapper; import com.fasterxml.jackson.annotation.JsonProperty; - import lombok.Data; /** diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/mapper/UserCourseHourRecordUserFirstCreatedAtMapper.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/mapper/UserCourseHourRecordUserFirstCreatedAtMapper.java index a4a35da..e46e591 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/mapper/UserCourseHourRecordUserFirstCreatedAtMapper.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/mapper/UserCourseHourRecordUserFirstCreatedAtMapper.java @@ -16,10 +16,8 @@ package xyz.playedu.common.types.mapper; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.util.Date; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/paginate/CoursePaginateFiler.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/paginate/CoursePaginateFiler.java index 552c5c0..b5606c0 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/paginate/CoursePaginateFiler.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/paginate/CoursePaginateFiler.java @@ -15,9 +15,8 @@ */ package xyz.playedu.common.types.paginate; -import lombok.Data; - import java.util.List; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/paginate/ResourcePaginateFilter.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/paginate/ResourcePaginateFilter.java index 586e642..ba38a48 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/paginate/ResourcePaginateFilter.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/paginate/ResourcePaginateFilter.java @@ -15,9 +15,8 @@ */ package xyz.playedu.common.types.paginate; -import lombok.Data; - import java.util.List; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/paginate/UserPaginateFilter.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/paginate/UserPaginateFilter.java index 95dc92e..154c2a3 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/paginate/UserPaginateFilter.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/types/paginate/UserPaginateFilter.java @@ -15,9 +15,8 @@ */ package xyz.playedu.common.types.paginate; -import lombok.Data; - import java.util.List; +import lombok.Data; /** * @Author 杭州白书科技有限公司 diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/HelperUtil.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/HelperUtil.java index aa98643..e092a0c 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/HelperUtil.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/HelperUtil.java @@ -17,14 +17,12 @@ package xyz.playedu.common.util; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; - -import org.springframework.util.DigestUtils; - import java.io.*; import java.net.URL; import java.net.URLConnection; import java.nio.charset.StandardCharsets; import java.util.*; +import org.springframework.util.DigestUtils; public class HelperUtil { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/IpUtil.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/IpUtil.java index f50156f..c27e437 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/IpUtil.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/IpUtil.java @@ -18,14 +18,11 @@ package xyz.playedu.common.util; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; - import jakarta.servlet.http.HttpServletRequest; - -import lombok.extern.slf4j.Slf4j; - import java.net.InetAddress; import java.net.UnknownHostException; import java.util.HashMap; +import lombok.extern.slf4j.Slf4j; @Slf4j public class IpUtil { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/MemoryCacheUtil.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/MemoryCacheUtil.java new file mode 100644 index 0000000..9f4cfb7 --- /dev/null +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/MemoryCacheUtil.java @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2023 杭州白书科技有限公司 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package xyz.playedu.common.util; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; +import org.springframework.stereotype.Component; +import xyz.playedu.common.constant.SystemConstant; + +@Component +public class MemoryCacheUtil { + private static final Map cache = new ConcurrentHashMap<>(); + private static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); + private static final String cacheNamePrefix = SystemConstant.CACHE_NAME_PREFIX; + + static { + // 启动定时清理过期缓存的线程 + scheduler.scheduleAtFixedRate( + () -> { + cache.entrySet().removeIf(entry -> entry.getValue().isExpired()); + }, + 1, + 1, + TimeUnit.MINUTES); + } + + // 基本操作 + public static void set(String key, Object value) { + key = cacheNamePrefix + key; + cache.put(key, new CacheObject(value, Long.MAX_VALUE)); + } + + public static void set(String key, Object value, long expireSeconds) { + key = cacheNamePrefix + key; + cache.put(key, new CacheObject(value, System.currentTimeMillis() + expireSeconds * 1000)); + } + + public static void set(String key, Object value, long expire, TimeUnit timeUnit) { + key = cacheNamePrefix + key; + cache.put( + key, + new CacheObject(value, System.currentTimeMillis() + timeUnit.toMillis(expire))); + } + + public static Object get(String key) { + key = cacheNamePrefix + key; + CacheObject cacheObject = cache.get(key); + if (cacheObject != null && !cacheObject.isExpired()) { + return cacheObject.getValue(); + } + cache.remove(key); + return null; + } + + public static Long ttlWithoutPrefix(String key) { + return getExpire(cacheNamePrefix + key); + } + + /** + * 获取所有缓存键值对 + * + * @return 所有缓存键值对的Map,包含值和失效时间 + */ + public Map> getAllCache() { + Map> result = new HashMap<>(); + for (Map.Entry entry : cache.entrySet()) { + Map cacheInfo = new HashMap<>(); + cacheInfo.put("value", entry.getValue().getValue()); + cacheInfo.put("expireTime", entry.getValue().getExpireTime()); + cacheInfo.put("ttl", getExpire(entry.getKey())); + result.put(entry.getKey(), cacheInfo); + } + return result; + } + + /** + * 获取所有缓存键 + * + * @return 所有缓存键的列表 + */ + public List getAllKeys() { + return new ArrayList<>(cache.keySet()); + } + + // 键操作 + public static Boolean exists(String key) { + key = cacheNamePrefix + key; + CacheObject cacheObject = cache.get(key); + return cacheObject != null && !cacheObject.isExpired(); + } + + public static void del(String... key) { + if (key == null || key.length == 0) { + return; + } + if (key.length == 1) { + key[0] = cacheNamePrefix + key[0]; + cache.remove(key[0]); + } else { + for (String k : key) { + cache.remove(cacheNamePrefix + k); + } + } + } + + // Hash操作 + public static Object hGet(String key, String field) { + key = cacheNamePrefix + key; + CacheObject cacheObject = cache.get(key); + if (cacheObject != null && !cacheObject.isExpired()) { + Map map = (Map) cacheObject.getValue(); + return map.get(field); + } + return null; + } + + public static void hSet(String key, String item, Object value) { + key = cacheNamePrefix + key; + CacheObject cacheObject = cache.get(key); + if (cacheObject != null && !cacheObject.isExpired()) { + Map map = (Map) cacheObject.getValue(); + map.put(item, value); + } else { + Map map = new HashMap<>(); + map.put(item, value); + cache.put(key, new CacheObject(map, Long.MAX_VALUE)); + } + } + + // 内部方法 + public static Long increment(String key, long delta) { + CacheObject cacheObject = cache.get(key); + if (cacheObject == null || cacheObject.isExpired()) { + cache.put(key, new CacheObject(new AtomicLong(delta), Long.MAX_VALUE)); + return delta; + } + AtomicLong counter = (AtomicLong) cacheObject.getValue(); + return counter.addAndGet(delta); + } + + private static Long getExpire(String key) { + CacheObject cacheObject = cache.get(key); + if (cacheObject == null) { + return -2L; + } + if (cacheObject.getExpireTime() == Long.MAX_VALUE) { + return -1L; + } + return (cacheObject.getExpireTime() - System.currentTimeMillis()) / 1000; + } + + private static class CacheObject { + private Object value; + private long expireTime; + + public CacheObject(Object value, long expireTime) { + this.value = value; + this.expireTime = expireTime; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public long getExpireTime() { + return expireTime; + } + + public void setExpireTime(long expireTime) { + this.expireTime = expireTime; + } + + public boolean isExpired() { + return System.currentTimeMillis() > expireTime; + } + } +} diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/MemoryDistributedLock.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/MemoryDistributedLock.java new file mode 100644 index 0000000..47c2864 --- /dev/null +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/MemoryDistributedLock.java @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2023 杭州白书科技有限公司 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package xyz.playedu.common.util; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; +import org.springframework.stereotype.Component; + +@Component +public class MemoryDistributedLock { + private static final Map locks = new ConcurrentHashMap<>(); + + public boolean tryLock(String key, long expire, TimeUnit timeUnit) { + LockInfo lockInfo = locks.get(key); + if (lockInfo == null || lockInfo.isExpired()) { + locks.put( + key, + new LockInfo( + Thread.currentThread().getId(), + System.currentTimeMillis() + timeUnit.toMillis(expire))); + return true; + } + return false; + } + + public void releaseLock(String key) { + LockInfo lockInfo = locks.get(key); + if (lockInfo != null && lockInfo.getThreadId() == Thread.currentThread().getId()) { + locks.remove(key); + } + } + + private static class LockInfo { + private final long threadId; + private final long expireTime; + + public LockInfo(long threadId, long expireTime) { + this.threadId = threadId; + this.expireTime = expireTime; + } + + public long getThreadId() { + return threadId; + } + + public boolean isExpired() { + return System.currentTimeMillis() > expireTime; + } + } +} diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/RedisDistributedLock.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/RedisDistributedLock.java deleted file mode 100644 index da0ad98..0000000 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/RedisDistributedLock.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2023 杭州白书科技有限公司 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package xyz.playedu.common.util; - -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.data.redis.core.script.DefaultRedisScript; -import org.springframework.stereotype.Component; - -import java.util.Collections; -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -/** - * @Author 杭州白书科技有限公司 - * - * @create 2023/3/12 10:43 - */ -@Component -public class RedisDistributedLock { - - private final StringRedisTemplate redisTemplate; - private final ThreadLocal lockValue = new ThreadLocal<>(); - - public RedisDistributedLock(StringRedisTemplate redisTemplate) { - this.redisTemplate = redisTemplate; - } - - public boolean tryLock(String key, long expire, TimeUnit timeUnit) { - String value = UUID.randomUUID().toString(); - Boolean success = redisTemplate.opsForValue().setIfAbsent(key, value, expire, timeUnit); - if (Boolean.TRUE.equals(success)) { - lockValue.set(value); - return true; - } - return false; - } - - public boolean releaseLock(String key) { - String value = lockValue.get(); - if (value == null) { - return false; - } - DefaultRedisScript script = - new DefaultRedisScript<>( - "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del'," - + " KEYS[1]) else return 0 end", - Boolean.class); - Boolean success = redisTemplate.execute(script, Collections.singletonList(key), value); - if (Boolean.TRUE.equals(success)) { - lockValue.remove(); - return true; - } - return false; - } -} diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/RedisUtil.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/RedisUtil.java deleted file mode 100644 index a7864aa..0000000 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/RedisUtil.java +++ /dev/null @@ -1,683 +0,0 @@ -/* - * Copyright (C) 2023 杭州白书科技有限公司 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package xyz.playedu.common.util; - -import jakarta.annotation.Resource; - -import org.springframework.data.redis.connection.RedisConnection; -import org.springframework.data.redis.core.Cursor; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.ScanOptions; -import org.springframework.data.redis.serializer.RedisSerializer; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import xyz.playedu.common.constant.SystemConstant; - -import java.util.*; -import java.util.concurrent.TimeUnit; - -@Component -public class RedisUtil { - - private static RedisTemplate redisTemplate; - private static final String redisPrefix = SystemConstant.REDIS_PREFIX; - - /** - * 注入Redis - * - * @param redisTemplate Redis对象 - * @author fzr - */ - @Resource - public void setRedisTemplate(RedisTemplate redisTemplate) { - RedisUtil.redisTemplate = redisTemplate; - } - - /** - * 对象句柄 - * - * @return RedisTemplate - * @author fzr - */ - public static RedisTemplate handler() { - return redisTemplate; - } - - /** - * 指定缓存失效时间 - * - * @param key 键 - * @param second 时间(秒) - * @author fzr - */ - public static void expire(String key, Long second) { - key = redisPrefix + key; - redisTemplate.expire(key, second, TimeUnit.SECONDS); - } - - /** - * 指定缓存失效时间 - * - * @param key 键 - * @param millisecond 时间(毫秒) - * @author fzr - */ - public static void pExpire(String key, Long millisecond) { - key = redisPrefix + key; - redisTemplate.expire(key, millisecond, TimeUnit.MILLISECONDS); - } - - /** - * 指定缓存永久有效 - * - * @param key 键 - * @author fzr - */ - public static void persist(String key) { - key = redisPrefix + key; - redisTemplate.persist(key); - } - - /** - * 根据key获取过期时间 - * - * @param key 键不能为null - * @return 返回0代表为永久有效(秒) - * @author fzr - */ - public static Long ttl(String key) { - key = redisPrefix + key; - return redisTemplate.getExpire(key, TimeUnit.SECONDS); - } - - public static Long ttlWithoutPrefix(String key) { - return redisTemplate.getExpire(key, TimeUnit.SECONDS); - } - - /** - * 根据key获取过期时间 - * - * @param key 键不能为null - * @return 返回0代表为永久有效(毫秒) - * @author fzr - */ - public static Long pTtl(String key) { - key = redisPrefix + key; - return redisTemplate.getExpire(key, TimeUnit.MILLISECONDS); - } - - /** - * 判断key是否存在 - * - * @param key 键 - * @return true=存在,false=不存在 - * @author fzr - */ - public static Boolean exists(String key) { - key = redisPrefix + key; - return redisTemplate.hasKey(key); - } - - /** - * 删除1个或多个键 - * - * @param key 键(一个或多个) - * @author fzr - */ - @SuppressWarnings("unchecked") - public static void del(String... key) { - if (key.length == 1) { - key[0] = redisPrefix + key[0]; - redisTemplate.delete(key[0]); - } else { - for (int i = 0; key.length > i; i++) { - key[i] = redisPrefix + key[i]; - } - redisTemplate.delete((Collection) CollectionUtils.arrayToList(key)); - } - } - - /** - * 给key赋值一个新的key名 - * - * @param oldKey 旧的key - * @param newKey 新的key - * @author fzr - */ - public static void rename(String oldKey, String newKey) { - oldKey = redisPrefix + oldKey; - newKey = redisPrefix + newKey; - redisTemplate.rename(oldKey, newKey); - } - - /** - * 将当前数据库的key移动到给定的数据库db当中 - * - * @param key 键 - * @param db 库 - * @return Boolean - * @author fzr - */ - public static Boolean move(String key, int db) { - key = redisPrefix + key; - return redisTemplate.move(key, db); - } - - /** - * 获取匹配的key值 - * - * @param pattern 通配符(*, ?, []) - * @return Set - * @author fzr - * @author fzr - */ - public static Set keys(String pattern) { - return redisTemplate.keys(pattern); - } - - /** - * 随机返回一个key - * - * @return String - * @author fzr - * @author fzr - */ - public static String randomKey() { - return redisTemplate.randomKey(); - } - - /* ***************** common end *************** */ - - /** - * 按匹配获取或有KEY - * - * @param pattern 规则 - * @return Set - * @author fzr - */ - public static Set matchSet(String pattern) { - Set keys = new LinkedHashSet<>(); - RedisUtil.handler() - .execute( - (RedisConnection connection) -> { - try (Cursor cursor = - connection.scan( - ScanOptions.scanOptions() - .count(Long.MAX_VALUE) - .match(pattern) - .build())) { - cursor.forEachRemaining( - item -> { - keys.add(RedisSerializer.string().deserialize(item)); - }); - return null; - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - - return keys; - } - - /** - * 获取key的值 - * - * @param key 键 - * @return Object - * @author fzr - */ - public static Object get(String key) { - key = redisPrefix + key; - return redisTemplate.opsForValue().get(key); - } - - /** - * 获取旧值并设置新值 - * - * @param key 键 - * @param newVal 新值 - * @return Object - * @author fzr - */ - public static Object getSet(String key, Object newVal) { - key = redisPrefix + key; - return redisTemplate.opsForValue().getAndSet(key, newVal); - } - - /** - * 设置键值对 - * - * @param key 键 - * @param value 值 - * @author fzr - */ - public static void set(String key, Object value) { - key = redisPrefix + key; - redisTemplate.opsForValue().set(key, value); - } - - /** - * 设置键值对并设置时间 - * - * @param key 键 - * @param value 值 - * @param time time要大于0 如果time小于等于0 将设置无限期 - * @author fzr - */ - public static void set(String key, Object value, long time) { - key = redisPrefix + key; - if (time > 0) { - redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); - } else { - set(key, value); - } - } - - /** - * 递增 - * - * @param key 键 - * @param delta 要增加几(大于0) - * @return Long - * @author fzr - */ - public static Long incr(String key, long delta) { - if (delta < 0) { - throw new RuntimeException("递增因子必须大于0"); - } - key = redisPrefix + key; - return redisTemplate.opsForValue().increment(key, delta); - } - - /** - * 递减 - * - * @param key 键 - * @param delta 要减少几(小于0) - * @return Long - * @author fzr - */ - public static Long decr(String key, long delta) { - if (delta < 0) { - throw new RuntimeException("递减因子必须大于0"); - } - key = redisPrefix + key; - return redisTemplate.opsForValue().increment(key, -delta); - } - - /* ***************** String end *************** */ - - /** - * 获取key中field域的值 - * - * @param key 键 不能为null - * @param field 项 不能为null - * @return 值 - * @author fzr - */ - public static Object hGet(String key, String field) { - key = redisPrefix + key; - return redisTemplate.opsForHash().get(key, field); - } - - /** - * 判断key中有没有field域名 - * - * @param key 键 - * @param field 字段 - * @return Boolean - * @author fzr - */ - public static Boolean hExists(String key, Object field) { - key = redisPrefix + key; - return redisTemplate.opsForHash().hasKey(key, field); - } - - /** - * 获取hashKey对应的所有键值 - * - * @param key 键 - * @return 对应的多个键值 - * @author fzr - */ - public Map hmGet(String key) { - key = redisPrefix + key; - return redisTemplate.opsForHash().entries(key); - } - - /** - * 设置field1->N个域,对应的值是value1->N - * - * @param key 键 - * @param map 对应多个键值 - * @author fzr - */ - public static void hmSet(String key, Map map) { - key = redisPrefix + key; - redisTemplate.opsForHash().putAll(key, map); - } - - /** - * HashSet 并设置时间 - * - * @param key 键 - * @param map 对应多个键值 - * @param time 时间(秒) - * @author fzr - */ - public static void hmSet(String key, Map map, long time) { - key = redisPrefix + key; - redisTemplate.opsForHash().putAll(key, map); - if (time > 0) { - expire(key, time); - } - } - - /** - * 向一张hash表中放入数据,如果不存在将创建 - * - * @param key 键 - * @param item 项 - * @param value 值 - * @author fzr - */ - public static void hSet(String key, String item, Object value) { - key = redisPrefix + key; - redisTemplate.opsForHash().put(key, item, value); - } - - /** - * 向一张hash表中放入数据,如果不存在将创建 - * - * @param key 键 - * @param item 项 - * @param value 值 - * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 - * @return true 成功 false失败 - * @author fzr - */ - public static boolean hSet(String key, String item, Object value, long time) { - key = redisPrefix + key; - redisTemplate.opsForHash().put(key, item, value); - if (time > 0) { - expire(key, time); - } - return true; - } - - /** - * 删除hash表中的值 - * - * @param key 键 不能为null - * @param item 项 可以使多个 不能为null - * @author fzr - */ - public static void hDel(String key, Object... item) { - key = redisPrefix + key; - redisTemplate.opsForHash().delete(key, item); - } - - /** - * 判断hash表中是否有该项的值 - * - * @param key 键 不能为null - * @param item 项 不能为null - * @return true 存在 false不存在 - * @author fzr - */ - public static boolean hHasKey(String key, String item) { - key = redisPrefix + key; - return redisTemplate.opsForHash().hasKey(key, item); - } - - /** - * hash递增 如果不存在,就会创建一个并把新增后的值返回 - * - * @param key 键 - * @param item 项 - * @param by 要增加几(大于0) - * @return double - * @author fzr - */ - public static double hIncr(String key, String item, long by) { - key = redisPrefix + key; - return redisTemplate.opsForHash().increment(key, item, by); - } - - /** - * hash递减 - * - * @param key 键 - * @param item 项 - * @param by 要减少记(小于0) - * @return double - * @author fzr - */ - public static double hDecr(String key, String item, long by) { - key = redisPrefix + key; - return redisTemplate.opsForHash().increment(key, item, -by); - } - - /* ***************** Map end *************** */ - - /** - * 根据key获取Set中的所有值 - * - * @param key 键 - * @return Set - * @author fzr - */ - public static Set sGet(String key) { - key = redisPrefix + key; - return redisTemplate.opsForSet().members(key); - } - - /** - * 根据value从一个set中查询,是否存在 - * - * @param key 键 - * @param value 值 - * @return true 存在 false不存在 - * @author fzr - */ - public Boolean sHasKey(String key, Object value) { - key = redisPrefix + key; - return redisTemplate.opsForSet().isMember(key, value); - } - - /** - * 将数据放入set缓存 - * - * @param key 键 - * @param values 值 可以是多个 - * @return 成功个数 - * @author fzr - */ - public static Long sSet(String key, Object... values) { - key = redisPrefix + key; - return redisTemplate.opsForSet().add(key, values); - } - - /** - * 将set数据放入缓存 - * - * @param key 键 - * @param time 时间(秒) - * @param values 值 可以是多个 - * @return 成功个数 - * @author fzr - */ - public Long sSetAndTime(String key, long time, Object... values) { - key = redisPrefix + key; - return redisTemplate.opsForSet().add(key, values); - } - - /** - * 获取set缓存的长度 - * - * @param key 键 - * @return Long - * @author fzr - */ - public Long sGetSetSize(String key) { - key = redisPrefix + key; - return redisTemplate.opsForSet().size(key); - } - - /** - * 移除值为value的 - * - * @param key 键 - * @param values 值 可以是多个 - * @return 移除的个数 - * @author fzr - */ - public Long setRemove(String key, Object... values) { - key = redisPrefix + key; - return redisTemplate.opsForSet().remove(key, values); - } - - /* ***************** Set end *************** */ - - /** - * 获取list缓存的内容 - * - * @param key 键 - * @param start 开始 - * @param end 结束 0 到 -1代表所有值 - * @return List - * @author fzr - */ - public List lGet(String key, long start, long end) { - key = redisPrefix + key; - return redisTemplate.opsForList().range(key, start, end); - } - - /** - * 获取list缓存的长度 - * - * @param key 键 - * @return Long - * @author fzr - */ - public Long lGetListSize(String key) { - key = redisPrefix + key; - return redisTemplate.opsForList().size(key); - } - - /** - * 通过索引获取list中的值 - * - * @param key 键 - * @param index 索引 index>=0时,0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 - * @return Object - * @author fzr - */ - public Object lGetIndex(String key, long index) { - key = redisPrefix + key; - return redisTemplate.opsForList().index(key, index); - } - - /** - * 将list放入缓存 - * - * @param key 键 - * @param value 值 - * @return boolean - * @author fzr - */ - public boolean lSet(String key, Object value) { - key = redisPrefix + key; - redisTemplate.opsForList().rightPush(key, value); - return true; - } - - /** - * 将list放入缓存 - * - * @param key 键 - * @param value 值 - * @param second 时间(秒) - * @return boolean - * @author fzr - */ - public boolean lSet(String key, Object value, long second) { - key = redisPrefix + key; - redisTemplate.opsForList().rightPush(key, value); - if (second > 0) expire(key, second); - return true; - } - - /** - * 将list放入缓存 - * - * @param key 键 - * @param value 值 - * @return boolean - * @author fzr - */ - public boolean lSet(String key, List value) { - key = redisPrefix + key; - redisTemplate.opsForList().rightPushAll(key, value); - return true; - } - - /** - * 将list放入缓存 - * - * @param key 键 - * @param value 值 - * @param time 时间(秒) - * @return boolean - * @author fzr - */ - public boolean lSet(String key, List value, Long time) { - key = redisPrefix + key; - redisTemplate.opsForList().rightPushAll(key, value); - if (time > 0) expire(key, time); - return true; - } - - /** - * 根据索引修改list中的某条数据 - * - * @param key 键 - * @param index 索引 - * @param value 值 - * @return boolean - * @author fzr - */ - public boolean lUpdateIndex(String key, Long index, Object value) { - key = redisPrefix + key; - redisTemplate.opsForList().set(key, index, value); - return true; - } - - /** - * 移除N个值为value - * - * @param key 键 - * @param count 移除多少个 - * @param value 值 - * @return 移除的个数 - * @author fzr - */ - public Long lRemove(String key, Long count, Object value) { - key = redisPrefix + key; - return redisTemplate.opsForList().remove(key, count, value); - } -} diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/RequestUtil.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/RequestUtil.java index 3f4bcc9..6251939 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/RequestUtil.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/RequestUtil.java @@ -17,14 +17,11 @@ package xyz.playedu.common.util; import cn.hutool.http.useragent.UserAgent; import cn.hutool.http.useragent.UserAgentUtil; - import jakarta.servlet.http.HttpServletRequest; - -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; - import java.util.Arrays; import java.util.List; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; public class RequestUtil { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/S3Util.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/S3Util.java index 84bbbaf..0fc2d9b 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/S3Util.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/S3Util.java @@ -23,21 +23,17 @@ import com.amazonaws.client.builder.AwsClientBuilder; import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3ClientBuilder; import com.amazonaws.services.s3.model.*; - -import lombok.SneakyThrows; -import lombok.extern.slf4j.Slf4j; - -import org.springframework.web.multipart.MultipartFile; - -import xyz.playedu.common.exception.ServiceException; -import xyz.playedu.common.types.config.S3Config; - import java.io.ByteArrayInputStream; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Date; import java.util.List; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.multipart.MultipartFile; +import xyz.playedu.common.exception.ServiceException; +import xyz.playedu.common.types.config.S3Config; @Slf4j public class S3Util { @@ -57,14 +53,6 @@ public class S3Util { return this; } - public boolean configIsEmpty() { - return defaultConfig == null - || StringUtil.isEmpty(defaultConfig.getDomain()) - || StringUtil.isEmpty(defaultConfig.getEndpoint()) - || StringUtil.isEmpty(defaultConfig.getAccessKey()) - || StringUtil.isEmpty(defaultConfig.getSecretKey()); - } - @SneakyThrows private AmazonS3 getClient() { if (defaultConfig == null) { @@ -78,8 +66,6 @@ public class S3Util { defaultConfig.getEndpoint(), defaultConfig.getRegion()); AmazonS3ClientBuilder builder = AmazonS3ClientBuilder.standard(); - // 开启路径访问 - builder.setPathStyleAccessEnabled(true); return builder.withCredentials(new AWSStaticCredentialsProvider(credentials)) .withEndpointConfiguration(endpointConfiguration) @@ -170,9 +156,6 @@ public class S3Util { } public String generateEndpointPreSignUrl(String path) { - if (defaultConfig.getService().equals("minio")) { - return defaultConfig.getDomain() + "/" + path; - } - return ""; + return defaultConfig.getDomain() + "/" + path; } } diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/StringUtil.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/StringUtil.java index 12f152c..5f9542b 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/StringUtil.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/StringUtil.java @@ -16,10 +16,8 @@ package xyz.playedu.common.util; import cn.hutool.json.JSONUtil; - -import org.springframework.util.AntPathMatcher; - import java.util.*; +import org.springframework.util.AntPathMatcher; /** 字符串工具类 */ public class StringUtil extends org.apache.commons.lang3.StringUtils { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/ldap/LdapTransformUser.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/ldap/LdapTransformUser.java index c8d1a0e..30ab406 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/ldap/LdapTransformUser.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/ldap/LdapTransformUser.java @@ -15,9 +15,8 @@ */ package xyz.playedu.common.util.ldap; -import lombok.Data; - import java.util.List; +import lombok.Data; @Data public class LdapTransformUser { diff --git a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/ldap/LdapUtil.java b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/ldap/LdapUtil.java index 3ec7d21..e830f0c 100644 --- a/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/ldap/LdapUtil.java +++ b/playedu-api/playedu-common/src/main/java/xyz/playedu/common/util/ldap/LdapUtil.java @@ -15,15 +15,8 @@ */ package xyz.playedu.common.util.ldap; -import lombok.extern.slf4j.Slf4j; - -import xyz.playedu.common.exception.ServiceException; -import xyz.playedu.common.types.LdapConfig; -import xyz.playedu.common.util.StringUtil; - import java.io.IOException; import java.util.*; - import javax.naming.Context; import javax.naming.NamingEnumeration; import javax.naming.NamingException; @@ -32,6 +25,10 @@ import javax.naming.directory.Attributes; import javax.naming.directory.SearchControls; import javax.naming.directory.SearchResult; import javax.naming.ldap.*; +import lombok.extern.slf4j.Slf4j; +import xyz.playedu.common.exception.ServiceException; +import xyz.playedu.common.types.LdapConfig; +import xyz.playedu.common.util.StringUtil; @Slf4j public class LdapUtil { diff --git a/playedu-api/playedu-common/src/main/resources/lua/RateLimiterScript.lua b/playedu-api/playedu-common/src/main/resources/lua/RateLimiterScript.lua deleted file mode 100644 index 8c8ba50..0000000 --- a/playedu-api/playedu-common/src/main/resources/lua/RateLimiterScript.lua +++ /dev/null @@ -1,6 +0,0 @@ -local current -current = redis.call("incr", KEYS[1]) -if tonumber(current) == 1 then - redis.call("expire", KEYS[1], KEYS[2]) -end -return current \ No newline at end of file diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/bus/UserBus.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/bus/UserBus.java index bf5c1b5..0e0ead4 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/bus/UserBus.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/bus/UserBus.java @@ -15,20 +15,18 @@ */ package xyz.playedu.course.bus; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import xyz.playedu.common.domain.Department; import xyz.playedu.common.service.DepartmentService; import xyz.playedu.common.service.UserService; import xyz.playedu.common.util.StringUtil; import xyz.playedu.course.service.CourseService; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - /** * @Author 杭州白书科技有限公司 * diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/caches/CourseCache.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/caches/CourseCache.java deleted file mode 100644 index 4896121..0000000 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/caches/CourseCache.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2023 杭州白书科技有限公司 - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package xyz.playedu.course.caches; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import xyz.playedu.common.exception.NotFoundException; -import xyz.playedu.common.util.RedisUtil; -import xyz.playedu.course.domain.Course; -import xyz.playedu.course.service.CourseService; - -/** - * @Author 杭州白书科技有限公司 - * - * @create 2023/3/20 17:57 - */ -@Component -public class CourseCache { - - @Autowired private CourseService courseService; - - private static final String keyTemplate = "course:%d"; - - private static final int expire = 3600; // s - - public Course findOrFail(Integer id) throws NotFoundException { - String keyName = key(id); - if (RedisUtil.exists(keyName)) { - return (Course) RedisUtil.get(keyName); - } - Course course = courseService.findOrFail(id); - put(course); - return course; - } - - public void put(Course course) { - RedisUtil.set(key(course.getId()), course, expire); - } - - private String key(Integer courseId) { - return String.format(keyTemplate, courseId); - } -} diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/caches/UserCanSeeCourseCache.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/caches/UserCanSeeCourseCache.java index 25a81db..125b779 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/caches/UserCanSeeCourseCache.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/caches/UserCanSeeCourseCache.java @@ -15,16 +15,14 @@ */ package xyz.playedu.course.caches; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import xyz.playedu.common.exception.ServiceException; -import xyz.playedu.common.util.RedisUtil; -import xyz.playedu.common.util.StringUtil; -import xyz.playedu.course.bus.UserBus; - import java.util.ArrayList; import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import xyz.playedu.common.exception.ServiceException; +import xyz.playedu.common.util.MemoryCacheUtil; +import xyz.playedu.common.util.StringUtil; +import xyz.playedu.course.bus.UserBus; /** * @Author 杭州白书科技有限公司 @@ -43,8 +41,8 @@ public class UserCanSeeCourseCache { public boolean check(Integer userId, Integer courseId, boolean isThrow) throws ServiceException { boolean result; - if (RedisUtil.exists(key(userId, courseId))) { - String cacheResult = (String) RedisUtil.get(key(userId, courseId)); + if (MemoryCacheUtil.exists(key(userId, courseId))) { + String cacheResult = (String) MemoryCacheUtil.get(key(userId, courseId)); result = "1".equals(cacheResult); } else { result = userBus.canSeeCourse(userId, courseId); @@ -57,7 +55,7 @@ public class UserCanSeeCourseCache { } public void put(Integer userId, Integer courseId, boolean result) { - RedisUtil.set(key(userId, courseId), result ? "1" : "0", expire); + MemoryCacheUtil.set(key(userId, courseId), result ? "1" : "0", expire); } public void destroy(List userIds, Integer courseId) { @@ -66,7 +64,7 @@ public class UserCanSeeCourseCache { for (Integer userId : userIds) { keyList.add(key(userId, courseId)); } - RedisUtil.del(keyList.toArray(new String[keyList.size()])); + MemoryCacheUtil.del(keyList.toArray(new String[keyList.size()])); } } diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/caches/UserLastLearnTimeCache.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/caches/UserLastLearnTimeCache.java index 6394a65..933d11c 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/caches/UserLastLearnTimeCache.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/caches/UserLastLearnTimeCache.java @@ -16,8 +16,7 @@ package xyz.playedu.course.caches; import org.springframework.stereotype.Component; - -import xyz.playedu.common.util.RedisUtil; +import xyz.playedu.common.util.MemoryCacheUtil; /** * @Author 杭州白书科技有限公司 @@ -32,10 +31,10 @@ public class UserLastLearnTimeCache { private static final int expire = 9500; // 9.5s public Long get(Integer userId) { - return (Long) RedisUtil.hGet(groupName, userId + ""); + return (Long) MemoryCacheUtil.hGet(groupName, userId + ""); } public void put(Integer userId, Long timestamp) { - RedisUtil.hSet(groupName, userId + "", timestamp); + MemoryCacheUtil.hSet(groupName, userId + "", timestamp); } } diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/Course.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/Course.java index b37bfc3..0cb0053 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/Course.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/Course.java @@ -21,12 +21,10 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serial; import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName courses diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseAttachment.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseAttachment.java index 6aeeefa..6946a64 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseAttachment.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseAttachment.java @@ -21,11 +21,9 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName course_attachment diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseAttachmentDownloadLog.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseAttachmentDownloadLog.java index a3afc5d..d9ccff2 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseAttachmentDownloadLog.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseAttachmentDownloadLog.java @@ -20,11 +20,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName course_attachment_download_log diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseCategory.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseCategory.java index 955802d..1b15715 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseCategory.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseCategory.java @@ -20,10 +20,8 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; +import lombok.Data; /** * @TableName resource_course_category diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseChapter.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseChapter.java index eaa5699..5bc0e26 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseChapter.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseChapter.java @@ -20,11 +20,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName course_chapters diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseDepartment.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseDepartment.java index 65cbc1a..7c40666 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseDepartment.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseDepartment.java @@ -20,10 +20,8 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; +import lombok.Data; /** * @TableName course_department diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseHour.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseHour.java index 443b392..faea00e 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseHour.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/CourseHour.java @@ -21,11 +21,9 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName course_hour diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserCourseHourRecord.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserCourseHourRecord.java index 01607d9..5c7bad4 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserCourseHourRecord.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserCourseHourRecord.java @@ -20,11 +20,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName user_course_hour_records diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserCourseRecord.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserCourseRecord.java index 924643e..8348d50 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserCourseRecord.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserCourseRecord.java @@ -20,11 +20,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName user_course_records diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserLatestLearn.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserLatestLearn.java index 9a30c33..84eb79e 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserLatestLearn.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserLatestLearn.java @@ -16,7 +16,6 @@ package xyz.playedu.course.domain; import com.fasterxml.jackson.annotation.JsonProperty; - import lombok.Data; /** diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserLearnDurationRecord.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserLearnDurationRecord.java index ccca068..f43e3ce 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserLearnDurationRecord.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserLearnDurationRecord.java @@ -20,11 +20,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName user_learn_duration_records diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserLearnDurationStats.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserLearnDurationStats.java index 662f5d9..1e6f564 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserLearnDurationStats.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/domain/UserLearnDurationStats.java @@ -20,11 +20,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName user_learn_duration_stats diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseAttachmentDownloadLogMapper.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseAttachmentDownloadLogMapper.java index 915c703..d0fbdcf 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseAttachmentDownloadLogMapper.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseAttachmentDownloadLogMapper.java @@ -16,14 +16,11 @@ package xyz.playedu.course.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - +import java.util.List; import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.types.paginate.CourseAttachmentDownloadLogPaginateFiler; import xyz.playedu.course.domain.CourseAttachmentDownloadLog; -import java.util.List; - /** * @author tengteng * @description 针对表【course_attachment_download_log】的数据库操作Mapper diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseAttachmentMapper.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseAttachmentMapper.java index af22afc..7537257 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseAttachmentMapper.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseAttachmentMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.course.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.course.domain.CourseAttachment; /** diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseCategoryMapper.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseCategoryMapper.java index 20298c6..456bfd3 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseCategoryMapper.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseCategoryMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.course.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.course.domain.CourseCategory; /** diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseChapterMapper.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseChapterMapper.java index d4c7eb7..7bd0c46 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseChapterMapper.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseChapterMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.course.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.course.domain.CourseChapter; /** diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseDepartmentMapper.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseDepartmentMapper.java index 0487c8b..580c0ec 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseDepartmentMapper.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseDepartmentMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.course.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.course.domain.CourseDepartment; /** diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseHourMapper.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseHourMapper.java index dd28885..22384b7 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseHourMapper.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseHourMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.course.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.course.domain.CourseHour; /** diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseMapper.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseMapper.java index 5fd0d42..58d8f64 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseMapper.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/CourseMapper.java @@ -16,14 +16,11 @@ package xyz.playedu.course.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - +import java.util.List; import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.types.paginate.CoursePaginateFiler; import xyz.playedu.course.domain.Course; -import java.util.List; - /** * @author tengteng * @description 针对表【courses】的数据库操作Mapper diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserCourseHourRecordMapper.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserCourseHourRecordMapper.java index 1d72413..bed0f3d 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserCourseHourRecordMapper.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserCourseHourRecordMapper.java @@ -16,17 +16,14 @@ package xyz.playedu.course.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - +import java.util.List; import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.types.mapper.UserCourseHourRecordCourseCountMapper; import xyz.playedu.common.types.mapper.UserCourseHourRecordUserCountMapper; import xyz.playedu.common.types.mapper.UserCourseHourRecordUserFirstCreatedAtMapper; import xyz.playedu.common.types.paginate.UserCourseHourRecordPaginateFilter; import xyz.playedu.course.domain.UserCourseHourRecord; -import java.util.List; - /** * @author tengteng * @description 针对表【user_course_hour_records】的数据库操作Mapper diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserCourseRecordMapper.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserCourseRecordMapper.java index 5d2511a..fd51317 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserCourseRecordMapper.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserCourseRecordMapper.java @@ -16,14 +16,11 @@ package xyz.playedu.course.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - +import java.util.List; import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.types.paginate.UserCourseRecordPaginateFilter; import xyz.playedu.course.domain.UserCourseRecord; -import java.util.List; - /** * @author tengteng * @description 针对表【user_course_records】的数据库操作Mapper diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserLearnDurationRecordMapper.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserLearnDurationRecordMapper.java index cf683d2..fea3747 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserLearnDurationRecordMapper.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserLearnDurationRecordMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.course.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.course.domain.UserLearnDurationRecord; /** diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserLearnDurationStatsMapper.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserLearnDurationStatsMapper.java index 836bb60..24ef5b6 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserLearnDurationStatsMapper.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/mapper/UserLearnDurationStatsMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.course.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.course.domain.UserLearnDurationStats; /** diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseAttachmentDownloadLogService.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseAttachmentDownloadLogService.java index daac355..5482854 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseAttachmentDownloadLogService.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseAttachmentDownloadLogService.java @@ -16,9 +16,7 @@ package xyz.playedu.course.service; import com.baomidou.mybatisplus.extension.service.IService; - import org.springframework.stereotype.Service; - import xyz.playedu.common.types.paginate.CourseAttachmentDownloadLogPaginateFiler; import xyz.playedu.common.types.paginate.PaginationResult; import xyz.playedu.course.domain.CourseAttachmentDownloadLog; diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseAttachmentService.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseAttachmentService.java index ddf3124..23cc8bd 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseAttachmentService.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseAttachmentService.java @@ -16,12 +16,10 @@ package xyz.playedu.course.service; import com.baomidou.mybatisplus.extension.service.IService; - +import java.util.List; import xyz.playedu.common.exception.NotFoundException; import xyz.playedu.course.domain.CourseAttachment; -import java.util.List; - public interface CourseAttachmentService extends IService { CourseAttachment findOrFail(Integer id, Integer courseId) throws NotFoundException; diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseCategoryService.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseCategoryService.java index d26b6f5..8aaca35 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseCategoryService.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseCategoryService.java @@ -16,10 +16,8 @@ package xyz.playedu.course.service; import com.baomidou.mybatisplus.extension.service.IService; - -import xyz.playedu.course.domain.CourseCategory; - import java.util.List; +import xyz.playedu.course.domain.CourseCategory; /** * @author tengteng diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseChapterService.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseChapterService.java index 26eade8..3766f69 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseChapterService.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseChapterService.java @@ -16,12 +16,10 @@ package xyz.playedu.course.service; import com.baomidou.mybatisplus.extension.service.IService; - +import java.util.List; import xyz.playedu.common.exception.NotFoundException; import xyz.playedu.course.domain.CourseChapter; -import java.util.List; - /** * @author tengteng * @description 针对表【course_chapters】的数据库操作Service diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseDepartmentService.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseDepartmentService.java index 064334a..db81714 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseDepartmentService.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseDepartmentService.java @@ -16,10 +16,8 @@ package xyz.playedu.course.service; import com.baomidou.mybatisplus.extension.service.IService; - -import xyz.playedu.course.domain.CourseDepartment; - import java.util.List; +import xyz.playedu.course.domain.CourseDepartment; /** * @author tengteng diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseHourService.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseHourService.java index 6ab930c..0550f01 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseHourService.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseHourService.java @@ -16,12 +16,10 @@ package xyz.playedu.course.service; import com.baomidou.mybatisplus.extension.service.IService; - +import java.util.List; import xyz.playedu.common.exception.NotFoundException; import xyz.playedu.course.domain.CourseHour; -import java.util.List; - /** * @author tengteng * @description 针对表【course_hour】的数据库操作Service diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseService.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseService.java index 02827cc..fa4f176 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseService.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/CourseService.java @@ -16,16 +16,14 @@ package xyz.playedu.course.service; import com.baomidou.mybatisplus.extension.service.IService; - +import java.util.Date; +import java.util.List; +import java.util.Map; import xyz.playedu.common.exception.NotFoundException; import xyz.playedu.common.types.paginate.CoursePaginateFiler; import xyz.playedu.common.types.paginate.PaginationResult; import xyz.playedu.course.domain.Course; -import java.util.Date; -import java.util.List; -import java.util.Map; - /** * @author tengteng * @description 针对表【courses】的数据库操作Service diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserCourseHourRecordService.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserCourseHourRecordService.java index 839ca15..cd0b299 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserCourseHourRecordService.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserCourseHourRecordService.java @@ -16,7 +16,7 @@ package xyz.playedu.course.service; import com.baomidou.mybatisplus.extension.service.IService; - +import java.util.List; import xyz.playedu.common.types.mapper.UserCourseHourRecordCourseCountMapper; import xyz.playedu.common.types.mapper.UserCourseHourRecordUserCountMapper; import xyz.playedu.common.types.mapper.UserCourseHourRecordUserFirstCreatedAtMapper; @@ -24,8 +24,6 @@ import xyz.playedu.common.types.paginate.PaginationResult; import xyz.playedu.common.types.paginate.UserCourseHourRecordPaginateFilter; import xyz.playedu.course.domain.UserCourseHourRecord; -import java.util.List; - /** * @author tengteng * @description 针对表【user_course_hour_records】的数据库操作Service diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserCourseRecordService.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserCourseRecordService.java index e437f09..4532e4e 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserCourseRecordService.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserCourseRecordService.java @@ -16,13 +16,11 @@ package xyz.playedu.course.service; import com.baomidou.mybatisplus.extension.service.IService; - +import java.util.List; import xyz.playedu.common.types.paginate.PaginationResult; import xyz.playedu.common.types.paginate.UserCourseRecordPaginateFilter; import xyz.playedu.course.domain.UserCourseRecord; -import java.util.List; - /** * @author tengteng * @description 针对表【user_course_records】的数据库操作Service diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserLearnDurationRecordService.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserLearnDurationRecordService.java index 4f3d847..6a83063 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserLearnDurationRecordService.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserLearnDurationRecordService.java @@ -16,7 +16,6 @@ package xyz.playedu.course.service; import com.baomidou.mybatisplus.extension.service.IService; - import xyz.playedu.course.domain.UserLearnDurationRecord; /** diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserLearnDurationStatsService.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserLearnDurationStatsService.java index 54a2b21..8769220 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserLearnDurationStatsService.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/UserLearnDurationStatsService.java @@ -16,10 +16,8 @@ package xyz.playedu.course.service; import com.baomidou.mybatisplus.extension.service.IService; - -import xyz.playedu.course.domain.UserLearnDurationStats; - import java.util.List; +import xyz.playedu.course.domain.UserLearnDurationStats; /** * @author tengteng diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseAttachmentDownloadLogServiceImpl.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseAttachmentDownloadLogServiceImpl.java index f1148c7..d663ca2 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseAttachmentDownloadLogServiceImpl.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseAttachmentDownloadLogServiceImpl.java @@ -16,9 +16,7 @@ package xyz.playedu.course.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - import org.springframework.stereotype.Service; - import xyz.playedu.common.types.paginate.CourseAttachmentDownloadLogPaginateFiler; import xyz.playedu.common.types.paginate.PaginationResult; import xyz.playedu.course.domain.CourseAttachmentDownloadLog; diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseAttachmentServiceImpl.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseAttachmentServiceImpl.java index d07dbb5..d661092 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseAttachmentServiceImpl.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseAttachmentServiceImpl.java @@ -16,18 +16,15 @@ package xyz.playedu.course.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import org.springframework.stereotype.Service; - import xyz.playedu.common.exception.NotFoundException; import xyz.playedu.course.domain.CourseAttachment; import xyz.playedu.course.mapper.CourseAttachmentMapper; import xyz.playedu.course.service.CourseAttachmentService; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - @Service public class CourseAttachmentServiceImpl extends ServiceImpl diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseCategoryServiceImpl.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseCategoryServiceImpl.java index 629171e..1833a66 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseCategoryServiceImpl.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseCategoryServiceImpl.java @@ -16,15 +16,12 @@ package xyz.playedu.course.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.List; import org.springframework.stereotype.Service; - import xyz.playedu.course.domain.CourseCategory; import xyz.playedu.course.mapper.CourseCategoryMapper; import xyz.playedu.course.service.CourseCategoryService; -import java.util.List; - /** * @author tengteng * @description 针对表【resource_course_category】的数据库操作Service实现 diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseChapterServiceImpl.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseChapterServiceImpl.java index 78d50e4..e2ef11b 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseChapterServiceImpl.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseChapterServiceImpl.java @@ -16,18 +16,15 @@ package xyz.playedu.course.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import org.springframework.stereotype.Service; - import xyz.playedu.common.exception.NotFoundException; import xyz.playedu.course.domain.CourseChapter; import xyz.playedu.course.mapper.CourseChapterMapper; import xyz.playedu.course.service.CourseChapterService; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - /** * @author tengteng * @description 针对表【course_chapters】的数据库操作Service实现 diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseDepartmentServiceImpl.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseDepartmentServiceImpl.java index 34190ff..c02a771 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseDepartmentServiceImpl.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseDepartmentServiceImpl.java @@ -16,15 +16,12 @@ package xyz.playedu.course.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.List; import org.springframework.stereotype.Service; - import xyz.playedu.course.domain.CourseDepartment; import xyz.playedu.course.mapper.CourseDepartmentMapper; import xyz.playedu.course.service.CourseDepartmentService; -import java.util.List; - /** * @author tengteng * @description 针对表【course_department】的数据库操作Service实现 diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseHourServiceImpl.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseHourServiceImpl.java index c0c3b97..e24bb6c 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseHourServiceImpl.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseHourServiceImpl.java @@ -16,18 +16,15 @@ package xyz.playedu.course.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import org.springframework.stereotype.Service; - import xyz.playedu.common.exception.NotFoundException; import xyz.playedu.course.domain.CourseHour; import xyz.playedu.course.mapper.CourseHourMapper; import xyz.playedu.course.service.CourseHourService; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - /** * @author tengteng * @description 针对表【course_hour】的数据库操作Service实现 diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseServiceImpl.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseServiceImpl.java index 18bac02..827fc46 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseServiceImpl.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/CourseServiceImpl.java @@ -16,13 +16,12 @@ package xyz.playedu.course.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.*; +import java.util.stream.Collectors; import lombok.SneakyThrows; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - import xyz.playedu.common.exception.NotFoundException; import xyz.playedu.common.types.paginate.CoursePaginateFiler; import xyz.playedu.common.types.paginate.PaginationResult; @@ -35,9 +34,6 @@ import xyz.playedu.course.service.CourseCategoryService; import xyz.playedu.course.service.CourseDepartmentService; import xyz.playedu.course.service.CourseService; -import java.util.*; -import java.util.stream.Collectors; - /** * @author tengteng * @description 针对表【courses】的数据库操作Service实现 diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserCourseHourRecordServiceImpl.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserCourseHourRecordServiceImpl.java index 65bb1f7..9158837 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserCourseHourRecordServiceImpl.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserCourseHourRecordServiceImpl.java @@ -16,9 +16,10 @@ package xyz.playedu.course.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import org.springframework.stereotype.Service; - import xyz.playedu.common.types.mapper.UserCourseHourRecordCourseCountMapper; import xyz.playedu.common.types.mapper.UserCourseHourRecordUserCountMapper; import xyz.playedu.common.types.mapper.UserCourseHourRecordUserFirstCreatedAtMapper; @@ -28,10 +29,6 @@ import xyz.playedu.course.domain.UserCourseHourRecord; import xyz.playedu.course.mapper.UserCourseHourRecordMapper; import xyz.playedu.course.service.UserCourseHourRecordService; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - /** * @author tengteng * @description 针对表【user_course_hour_records】的数据库操作Service实现 diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserCourseRecordServiceImpl.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserCourseRecordServiceImpl.java index 8805d28..47ca28b 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserCourseRecordServiceImpl.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserCourseRecordServiceImpl.java @@ -16,20 +16,17 @@ package xyz.playedu.course.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.ArrayList; +import java.util.Date; +import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - import xyz.playedu.common.types.paginate.PaginationResult; import xyz.playedu.common.types.paginate.UserCourseRecordPaginateFilter; import xyz.playedu.course.domain.UserCourseRecord; import xyz.playedu.course.mapper.UserCourseRecordMapper; import xyz.playedu.course.service.UserCourseRecordService; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - /** * @author tengteng * @description 针对表【user_course_records】的数据库操作Service实现 diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserLearnDurationRecordServiceImpl.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserLearnDurationRecordServiceImpl.java index c357f8b..3f0b877 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserLearnDurationRecordServiceImpl.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserLearnDurationRecordServiceImpl.java @@ -16,18 +16,14 @@ package xyz.playedu.course.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.text.SimpleDateFormat; +import java.util.Date; import lombok.SneakyThrows; - import org.springframework.stereotype.Service; - import xyz.playedu.course.domain.UserLearnDurationRecord; import xyz.playedu.course.mapper.UserLearnDurationRecordMapper; import xyz.playedu.course.service.UserLearnDurationRecordService; -import java.text.SimpleDateFormat; -import java.util.Date; - /** * @author tengteng * @description 针对表【user_learn_duration_records】的数据库操作Service实现 diff --git a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserLearnDurationStatsServiceImpl.java b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserLearnDurationStatsServiceImpl.java index f32f39e..65b19ed 100644 --- a/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserLearnDurationStatsServiceImpl.java +++ b/playedu-api/playedu-course/src/main/java/xyz/playedu/course/service/impl/UserLearnDurationStatsServiceImpl.java @@ -16,20 +16,15 @@ package xyz.playedu.course.service.impl; import cn.hutool.core.date.DateTime; - import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - -import lombok.SneakyThrows; - -import org.springframework.stereotype.Service; - -import xyz.playedu.course.domain.UserLearnDurationStats; -import xyz.playedu.course.mapper.UserLearnDurationStatsMapper; -import xyz.playedu.course.service.UserLearnDurationStatsService; - import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; +import lombok.SneakyThrows; +import org.springframework.stereotype.Service; +import xyz.playedu.course.domain.UserLearnDurationStats; +import xyz.playedu.course.mapper.UserLearnDurationStatsMapper; +import xyz.playedu.course.service.UserLearnDurationStatsService; /** * @author tengteng diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/domain/Resource.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/domain/Resource.java index 080feac..4db1570 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/domain/Resource.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/domain/Resource.java @@ -21,11 +21,9 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName resources diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/domain/ResourceCategory.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/domain/ResourceCategory.java index 8e49e25..bdae2a5 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/domain/ResourceCategory.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/domain/ResourceCategory.java @@ -19,10 +19,8 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; - -import lombok.Data; - import java.io.Serializable; +import lombok.Data; /** * @TableName resource_category diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/domain/ResourceVideo.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/domain/ResourceVideo.java index 1f4d830..f3c84d8 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/domain/ResourceVideo.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/domain/ResourceVideo.java @@ -20,11 +20,9 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonIgnore; - -import lombok.Data; - import java.io.Serializable; import java.util.Date; +import lombok.Data; /** * @TableName resource_videos diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/mapper/ResourceCategoryMapper.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/mapper/ResourceCategoryMapper.java index 1034520..50f8be5 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/mapper/ResourceCategoryMapper.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/mapper/ResourceCategoryMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.resource.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.resource.domain.ResourceCategory; /** diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/mapper/ResourceMapper.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/mapper/ResourceMapper.java index 4a53d50..fba7013 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/mapper/ResourceMapper.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/mapper/ResourceMapper.java @@ -16,14 +16,11 @@ package xyz.playedu.resource.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - +import java.util.List; import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.common.types.paginate.ResourcePaginateFilter; import xyz.playedu.resource.domain.Resource; -import java.util.List; - /** * @author tengteng * @description 针对表【resources】的数据库操作Mapper diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/mapper/ResourceVideoMapper.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/mapper/ResourceVideoMapper.java index 7c8357f..1907765 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/mapper/ResourceVideoMapper.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/mapper/ResourceVideoMapper.java @@ -16,9 +16,7 @@ package xyz.playedu.resource.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import org.apache.ibatis.annotations.Mapper; - import xyz.playedu.resource.domain.ResourceVideo; /** diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/ResourceCategoryService.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/ResourceCategoryService.java index 9bea696..1ce8620 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/ResourceCategoryService.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/ResourceCategoryService.java @@ -16,10 +16,8 @@ package xyz.playedu.resource.service; import com.baomidou.mybatisplus.extension.service.IService; - -import xyz.playedu.resource.domain.ResourceCategory; - import java.util.List; +import xyz.playedu.resource.domain.ResourceCategory; public interface ResourceCategoryService extends IService { void rebuild(Integer resourceId, List categoryIds); diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/ResourceService.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/ResourceService.java index d59ca5a..a8ed7d9 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/ResourceService.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/ResourceService.java @@ -16,14 +16,12 @@ package xyz.playedu.resource.service; import com.baomidou.mybatisplus.extension.service.IService; - +import java.util.List; import xyz.playedu.common.exception.NotFoundException; import xyz.playedu.common.types.paginate.PaginationResult; import xyz.playedu.common.types.paginate.ResourcePaginateFilter; import xyz.playedu.resource.domain.Resource; -import java.util.List; - public interface ResourceService extends IService { PaginationResult paginate(int page, int size, ResourcePaginateFilter filter); diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/ResourceVideoService.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/ResourceVideoService.java index dd128b0..31a9afa 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/ResourceVideoService.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/ResourceVideoService.java @@ -16,10 +16,8 @@ package xyz.playedu.resource.service; import com.baomidou.mybatisplus.extension.service.IService; - -import xyz.playedu.resource.domain.ResourceVideo; - import java.util.List; +import xyz.playedu.resource.domain.ResourceVideo; /** * @author tengteng diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/UploadService.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/UploadService.java index f3d84e0..8e0a62d 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/UploadService.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/UploadService.java @@ -16,7 +16,6 @@ package xyz.playedu.resource.service; import org.springframework.web.multipart.MultipartFile; - import xyz.playedu.common.domain.UserUploadImageLog; import xyz.playedu.common.exception.ServiceException; import xyz.playedu.common.types.UploadFileInfo; @@ -31,11 +30,12 @@ public interface UploadService { UploadFileInfo upload(MultipartFile file, String dir) throws ServiceException; - Resource storeMinio(Integer adminId, MultipartFile file, String categoryIds) + Resource storeMinio(String disk, Integer adminId, MultipartFile file, String categoryIds) throws ServiceException; - Resource storeBase64Image(Integer adminId, String content, String categoryIds) + Resource storeBase64Image(String disk, Integer adminId, String content, String categoryIds) throws ServiceException; - UserUploadImageLog userAvatar(Integer userId, MultipartFile file, String typed, String scene); + UserUploadImageLog userAvatar( + String disk, Integer userId, MultipartFile file, String typed, String scene); } diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/ResourceCategoryServiceImpl.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/ResourceCategoryServiceImpl.java index 0dc7273..2ffb03f 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/ResourceCategoryServiceImpl.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/ResourceCategoryServiceImpl.java @@ -16,16 +16,13 @@ package xyz.playedu.resource.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.ArrayList; +import java.util.List; import org.springframework.stereotype.Service; - import xyz.playedu.resource.domain.ResourceCategory; import xyz.playedu.resource.mapper.ResourceCategoryMapper; import xyz.playedu.resource.service.ResourceCategoryService; -import java.util.ArrayList; -import java.util.List; - @Service public class ResourceCategoryServiceImpl extends ServiceImpl diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/ResourceServiceImpl.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/ResourceServiceImpl.java index 47942e9..64a7034 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/ResourceServiceImpl.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/ResourceServiceImpl.java @@ -16,11 +16,10 @@ package xyz.playedu.resource.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; - import xyz.playedu.common.exception.NotFoundException; import xyz.playedu.common.types.paginate.PaginationResult; import xyz.playedu.common.types.paginate.ResourcePaginateFilter; @@ -32,8 +31,6 @@ import xyz.playedu.resource.service.ResourceCategoryService; import xyz.playedu.resource.service.ResourceService; import xyz.playedu.resource.service.ResourceVideoService; -import java.util.*; - /** * @author tengteng * @description 针对表【resources】的数据库操作Service实现 diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/ResourceVideoServiceImpl.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/ResourceVideoServiceImpl.java index f1c0c65..2681974 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/ResourceVideoServiceImpl.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/ResourceVideoServiceImpl.java @@ -16,16 +16,13 @@ package xyz.playedu.resource.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - -import org.springframework.stereotype.Service; - -import xyz.playedu.resource.domain.ResourceVideo; -import xyz.playedu.resource.mapper.ResourceVideoMapper; -import xyz.playedu.resource.service.ResourceVideoService; - import java.util.ArrayList; import java.util.Date; import java.util.List; +import org.springframework.stereotype.Service; +import xyz.playedu.resource.domain.ResourceVideo; +import xyz.playedu.resource.mapper.ResourceVideoMapper; +import xyz.playedu.resource.service.ResourceVideoService; /** * @author tengteng diff --git a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/UploadServiceImpl.java b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/UploadServiceImpl.java index 0f45269..cfbf047 100644 --- a/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/UploadServiceImpl.java +++ b/playedu-api/playedu-resource/src/main/java/xyz/playedu/resource/service/impl/UploadServiceImpl.java @@ -15,13 +15,12 @@ */ package xyz.playedu.resource.service.impl; +import java.util.Date; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; - import xyz.playedu.common.constant.BackendConstant; import xyz.playedu.common.constant.FrontendConstant; import xyz.playedu.common.domain.UserUploadImageLog; @@ -36,8 +35,6 @@ import xyz.playedu.resource.domain.Resource; import xyz.playedu.resource.service.ResourceService; import xyz.playedu.resource.service.UploadService; -import java.util.Date; - @Service @Slf4j public class UploadServiceImpl implements UploadService { @@ -93,7 +90,8 @@ public class UploadServiceImpl implements UploadService { @Override @SneakyThrows - public Resource storeMinio(Integer adminId, MultipartFile file, String categoryIds) { + public Resource storeMinio( + String disk, Integer adminId, MultipartFile file, String categoryIds) { UploadFileInfo info = upload(file, null); return resourceService.create( @@ -103,7 +101,7 @@ public class UploadServiceImpl implements UploadService { info.getOriginalName(), info.getExtension(), file.getSize(), - BackendConstant.STORAGE_DRIVER_MINIO, + disk, "", info.getSavePath(), info.getUrl()); @@ -111,7 +109,8 @@ public class UploadServiceImpl implements UploadService { @Override @SneakyThrows - public Resource storeBase64Image(Integer adminId, String content, String categoryIds) { + public Resource storeBase64Image( + String disk, Integer adminId, String content, String categoryIds) { // data:image/jpeg;base64, String[] base64Rows = content.split(","); // 解析出content-type @@ -143,7 +142,7 @@ public class UploadServiceImpl implements UploadService { filename, ext, (long) binary.length, - BackendConstant.STORAGE_DRIVER_MINIO, + disk, "", savePath, url); @@ -152,14 +151,14 @@ public class UploadServiceImpl implements UploadService { @Override @SneakyThrows public UserUploadImageLog userAvatar( - Integer userId, MultipartFile file, String typed, String scene) { + String disk, Integer userId, MultipartFile file, String typed, String scene) { UploadFileInfo info = upload(file, FrontendConstant.DIR_AVATAR); UserUploadImageLog log = new UserUploadImageLog(); log.setUserId(userId); log.setTyped(typed); log.setScene(scene); log.setSize(info.getSize()); - log.setDriver(BackendConstant.STORAGE_DRIVER_MINIO); + log.setDriver(disk); log.setPath(info.getSavePath()); log.setUrl(info.getUrl()); log.setName(info.getOriginalName()); diff --git a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/aspectj/AdminLogAspect.java b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/aspectj/AdminLogAspect.java index c1e93e1..2b34e74 100644 --- a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/aspectj/AdminLogAspect.java +++ b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/aspectj/AdminLogAspect.java @@ -17,11 +17,11 @@ package xyz.playedu.system.aspectj; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; - import jakarta.servlet.http.HttpServletRequest; - +import java.lang.reflect.Method; +import java.util.Date; +import java.util.Map; import lombok.extern.slf4j.Slf4j; - import org.aspectj.lang.JoinPoint; import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.AfterThrowing; @@ -30,7 +30,6 @@ import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import xyz.playedu.common.annotation.Log; import xyz.playedu.common.constant.SystemConstant; import xyz.playedu.common.domain.AdminLog; @@ -42,10 +41,6 @@ import xyz.playedu.common.util.IpUtil; import xyz.playedu.common.util.RequestUtil; import xyz.playedu.common.util.StringUtil; -import java.lang.reflect.Method; -import java.util.Date; -import java.util.Map; - @Aspect @Component @Slf4j diff --git a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/aspectj/BackendPermissionAspect.java b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/aspectj/BackendPermissionAspect.java index 5547caa..78a933b 100644 --- a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/aspectj/BackendPermissionAspect.java +++ b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/aspectj/BackendPermissionAspect.java @@ -15,8 +15,8 @@ */ package xyz.playedu.system.aspectj; +import java.util.HashMap; import lombok.extern.slf4j.Slf4j; - import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; @@ -24,14 +24,11 @@ import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import xyz.playedu.common.annotation.BackendPermission; import xyz.playedu.common.bus.BackendBus; import xyz.playedu.common.context.BCtx; import xyz.playedu.common.types.JsonResponse; -import java.util.HashMap; - @Aspect @Component @Slf4j diff --git a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/aspectj/LockAspect.java b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/aspectj/LockAspect.java index 20608c5..63f3178 100644 --- a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/aspectj/LockAspect.java +++ b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/aspectj/LockAspect.java @@ -15,44 +15,43 @@ */ package xyz.playedu.system.aspectj; +import java.lang.reflect.Method; +import java.util.concurrent.TimeUnit; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.reflect.MethodSignature; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; - import xyz.playedu.common.annotation.Lock; import xyz.playedu.common.exception.LimitException; -import xyz.playedu.common.util.RedisDistributedLock; - -import java.lang.reflect.Method; -import java.util.concurrent.TimeUnit; +import xyz.playedu.common.util.MemoryDistributedLock; @Aspect @Component public class LockAspect { - private final RedisDistributedLock redisDistributedLock; + @Autowired private MemoryDistributedLock distributedLock; - public LockAspect(RedisDistributedLock redisDistributedLock) { - this.redisDistributedLock = redisDistributedLock; + public LockAspect(MemoryDistributedLock distributedLock) { + this.distributedLock = distributedLock; } @Around("@annotation(xyz.playedu.common.annotation.Lock)") public Object around(ProceedingJoinPoint joinPoint) throws Throwable { MethodSignature signature = (MethodSignature) joinPoint.getSignature(); Method method = signature.getMethod(); - Lock distributedLock = method.getAnnotation(Lock.class); - String key = distributedLock.key(); - long expire = distributedLock.expire(); - TimeUnit timeUnit = distributedLock.timeUnit(); - boolean success = redisDistributedLock.tryLock(key, expire, timeUnit); + Lock lock = method.getAnnotation(Lock.class); + String key = lock.key(); + long expire = lock.expire(); + TimeUnit timeUnit = lock.timeUnit(); + boolean success = distributedLock.tryLock(key, expire, timeUnit); if (!success) { throw new LimitException("请稍后再试"); } try { return joinPoint.proceed(); } finally { - redisDistributedLock.releaseLock(key); + distributedLock.releaseLock(key); } } } diff --git a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/AdminPermissionCheck.java b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/AdminPermissionCheck.java index 49673e0..ae2fd48 100644 --- a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/AdminPermissionCheck.java +++ b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/AdminPermissionCheck.java @@ -15,17 +15,15 @@ */ package xyz.playedu.system.checks; +import java.util.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; - import xyz.playedu.common.constant.BPermissionConstant; import xyz.playedu.common.domain.AdminPermission; import xyz.playedu.common.service.AdminPermissionService; -import java.util.*; - @Order(1020) @Component public class AdminPermissionCheck implements CommandLineRunner { diff --git a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/AppConfigCheck.java b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/AppConfigCheck.java index c864bfb..3740906 100644 --- a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/AppConfigCheck.java +++ b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/AppConfigCheck.java @@ -15,18 +15,16 @@ */ package xyz.playedu.system.checks; +import java.util.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; - import xyz.playedu.common.constant.BackendConstant; import xyz.playedu.common.constant.ConfigConstant; import xyz.playedu.common.domain.AppConfig; import xyz.playedu.common.service.AppConfigService; -import java.util.*; - @Component @Order(100) public class AppConfigCheck implements CommandLineRunner { @@ -174,14 +172,25 @@ public class AppConfigCheck implements CommandLineRunner { }, }); put( - "MinIO", + "S3存储", new AppConfig[] { + new AppConfig() { + { + setName("服务商"); + setSort(1); + setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_SELECT); + setKeyName(ConfigConstant.S3_SERVICE); + setKeyValue(""); + setOptionValue( + "[{\"name\":\"阿里云OSS\",\"value\":\"oss\"},{\"name\":\"腾讯云COS\",\"value\":\"cos\"}]"); + } + }, new AppConfig() { { setName("AccessKey"); setSort(10); setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_TEXT); - setKeyName(ConfigConstant.MINIO_ACCESS_KEY); + setKeyName(ConfigConstant.S3_ACCESS_KEY); setKeyValue(""); } }, @@ -190,7 +199,7 @@ public class AppConfigCheck implements CommandLineRunner { setName("SecretKey"); setSort(20); setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_TEXT); - setKeyName(ConfigConstant.MINIO_SECRET_KEY); + setKeyName(ConfigConstant.S3_SECRET_KEY); setKeyValue(""); setIsPrivate(1); } @@ -200,7 +209,16 @@ public class AppConfigCheck implements CommandLineRunner { setName("Bucket"); setSort(30); setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_TEXT); - setKeyName(ConfigConstant.MINIO_BUCKET); + setKeyName(ConfigConstant.S3_BUCKET); + setKeyValue(""); + } + }, + new AppConfig() { + { + setName("Region"); + setSort(35); + setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_TEXT); + setKeyName(ConfigConstant.S3_REGION); setKeyValue(""); } }, @@ -209,7 +227,7 @@ public class AppConfigCheck implements CommandLineRunner { setName("Endpoint"); setSort(40); setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_TEXT); - setKeyName(ConfigConstant.MINIO_ENDPOINT); + setKeyName(ConfigConstant.S3_ENDPOINT); setKeyValue(""); } }, @@ -218,7 +236,7 @@ public class AppConfigCheck implements CommandLineRunner { setName("Domain"); setSort(50); setFieldType(BackendConstant.APP_CONFIG_FIELD_TYPE_TEXT); - setKeyName(ConfigConstant.MINIO_DOMAIN); + setKeyName(ConfigConstant.S3_DOMAIN); setKeyValue(""); } }, diff --git a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/MigrationCheck.java b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/MigrationCheck.java index b1f166a..90691bf 100644 --- a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/MigrationCheck.java +++ b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/MigrationCheck.java @@ -15,21 +15,18 @@ */ package xyz.playedu.system.checks; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; - import xyz.playedu.system.service.MigrationService; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - @Order(10) @Component @Slf4j diff --git a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/SystemDataCheck.java b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/SystemDataCheck.java index 8102722..7ff46d1 100644 --- a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/SystemDataCheck.java +++ b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/SystemDataCheck.java @@ -16,12 +16,10 @@ package xyz.playedu.system.checks; import lombok.extern.slf4j.Slf4j; - import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; - import xyz.playedu.common.constant.BackendConstant; import xyz.playedu.common.domain.AdminRole; import xyz.playedu.common.service.AdminRoleService; diff --git a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/UpgradeCheck.java b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/UpgradeCheck.java index 2d305f8..7ce4e06 100644 --- a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/UpgradeCheck.java +++ b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/checks/UpgradeCheck.java @@ -15,17 +15,15 @@ */ package xyz.playedu.system.checks; +import java.util.ArrayList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; - import xyz.playedu.common.domain.AppConfig; import xyz.playedu.common.service.AdminPermissionService; import xyz.playedu.common.service.AppConfigService; -import java.util.ArrayList; - @Order(10000) @Component public class UpgradeCheck implements CommandLineRunner { diff --git a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/domain/Migration.java b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/domain/Migration.java index eb14238..f7a057b 100644 --- a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/domain/Migration.java +++ b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/domain/Migration.java @@ -19,7 +19,6 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; - import java.io.Serializable; /** diff --git a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/mapper/MigrationMapper.java b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/mapper/MigrationMapper.java index d9966d6..543a743 100644 --- a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/mapper/MigrationMapper.java +++ b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/mapper/MigrationMapper.java @@ -16,7 +16,6 @@ package xyz.playedu.system.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; - import xyz.playedu.system.domain.Migration; /** diff --git a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/service/MigrationService.java b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/service/MigrationService.java index dbc4e7c..b83793b 100644 --- a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/service/MigrationService.java +++ b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/service/MigrationService.java @@ -16,10 +16,8 @@ package xyz.playedu.system.service; import com.baomidou.mybatisplus.extension.service.IService; - -import xyz.playedu.system.domain.Migration; - import java.util.List; +import xyz.playedu.system.domain.Migration; /** * @author tengyongzhi diff --git a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/service/impl/MigrationServiceImpl.java b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/service/impl/MigrationServiceImpl.java index ec34fcb..e436948 100644 --- a/playedu-api/playedu-system/src/main/java/xyz/playedu/system/service/impl/MigrationServiceImpl.java +++ b/playedu-api/playedu-system/src/main/java/xyz/playedu/system/service/impl/MigrationServiceImpl.java @@ -16,15 +16,12 @@ package xyz.playedu.system.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; - +import java.util.List; import org.springframework.stereotype.Service; - import xyz.playedu.system.domain.Migration; import xyz.playedu.system.mapper.MigrationMapper; import xyz.playedu.system.service.MigrationService; -import java.util.List; - /** * @author tengyongzhi * @description 针对表【migrations】的数据库操作Service实现 diff --git a/playedu-api/pom.xml b/playedu-api/pom.xml index 2355c73..b9c9837 100644 --- a/playedu-api/pom.xml +++ b/playedu-api/pom.xml @@ -41,10 +41,6 @@ org.springframework.boot spring-boot-starter-websocket - - org.springframework.boot - spring-boot-starter-data-redis - org.springframework.boot spring-boot-starter-validation @@ -118,11 +114,6 @@ sa-token-spring-boot3-starter 1.39.0 - - cn.dev33 - sa-token-redis-jackson - 1.39.0 - cn.dev33 sa-token-jwt