!12 使用内存缓存

* 后台管理员登录失败次数设置为10次
* 优化代码
* 后台缓存接口新增权限控制
* 移除redis关键字
* Merge branch 'dev' into dev-cache
* 优化静态资源访问不存在抛出异常
* 删除redis相关内容
* 移除compose.yml中redis和minio的配置
* changelog
* 后台 s3配置
* 后台 s3配置
* 云存储:移除minio;新增阿里云oss,腾讯云cos
* 内存缓存替换redis缓存
This commit is contained in:
白书科技
2025-05-10 02:13:24 +00:00
parent 05bad03d69
commit b9f600d3bc
281 changed files with 886 additions and 3397 deletions

View File

@@ -22,7 +22,6 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import xyz.playedu.common.config.UniqueNameGeneratorConfig;
@SpringBootApplication

View File

@@ -15,13 +15,12 @@
*/
package xyz.playedu.api.bus;
import java.util.HashMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import xyz.playedu.api.event.UserLoginEvent;
import xyz.playedu.common.bus.LDAPBus;
import xyz.playedu.common.domain.User;
@@ -31,8 +30,6 @@ import xyz.playedu.common.util.IpUtil;
import xyz.playedu.common.util.RequestUtil;
import xyz.playedu.common.util.ldap.LdapTransformUser;
import java.util.HashMap;
@Component
@Slf4j
public class LoginBus {

View File

@@ -15,11 +15,9 @@
*/
package xyz.playedu.api.bus;
import org.springframework.stereotype.Component;
import xyz.playedu.common.constant.ConfigConstant;
import java.util.Map;
import org.springframework.stereotype.Component;
import xyz.playedu.common.constant.ConfigConstant;
@Component
public class UserBus {

View File

@@ -17,11 +17,10 @@ package xyz.playedu.api.cache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import xyz.playedu.common.config.PlayEduConfig;
import xyz.playedu.common.exception.ServiceException;
import xyz.playedu.common.service.RateLimiterService;
import xyz.playedu.common.util.RedisUtil;
import xyz.playedu.common.util.MemoryCacheUtil;
@Component
public class LoginLimitCache {
@@ -34,14 +33,14 @@ public class LoginLimitCache {
String limitKey = cacheKey(email);
Long reqCount = rateLimiterService.current(limitKey, 600L);
if (reqCount >= 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) {

View File

@@ -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) {

View File

@@ -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);
}
}

View File

@@ -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")

View File

@@ -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<Integer> permissionIds = roleService.getPermissionIdsByRoleId(role.getId());
List<Integer> permAction = new ArrayList<>();
List<Integer> permData = new ArrayList<>();
if (permissionIds != null && permissionIds.size() > 0) {
if (permissionIds != null && !permissionIds.isEmpty()) {
List<AdminPermission> permissions = permissionService.chunks(permissionIds);
Map<String, List<AdminPermission>> permissionsGroup =
permissions.stream().collect(Collectors.groupingBy(AdminPermission::getType));

View File

@@ -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<AdminUser> result = adminUserService.paginate(page, size, filter);
Map<Integer, List<Integer>> 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("请输入密码");
}

View File

@@ -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 {

View File

@@ -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<String, Object> 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<String, Object> 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<String> keys = memoryCacheUtil.getAllKeys();
for (String key : keys) {
MemoryCacheUtil.del(key);
}
return JsonResponse.success();
}
}

View File

@@ -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("参数为空");
}

View File

@@ -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")

View File

@@ -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;

View File

@@ -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")

View File

@@ -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("参数为空");
}

View File

@@ -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<Integer> 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<UserCourseRecord> records =

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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")

View File

@@ -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("当前管理员已禁止登录");

View File

@@ -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<String, List<Resource>> resources =
resourceService
.chunks(

View File

@@ -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 {

View File

@@ -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

View File

@@ -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<String, Object> 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());
// 视频信息

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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 {

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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();

View File

@@ -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

View File

@@ -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 {

View File

@@ -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,

View File

@@ -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 {

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -17,7 +17,6 @@ package xyz.playedu.api.event;
import lombok.Getter;
import lombok.Setter;
import org.springframework.context.ApplicationEvent;
/**

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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 杭州白书科技有限公司
*

View File

@@ -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)

View File

@@ -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;

View File

@@ -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)

View File

@@ -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

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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;

View File

@@ -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 杭州白书科技有限公司

View File

@@ -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 杭州白书科技有限公司

View File

@@ -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 杭州白书科技有限公司

View File

@@ -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 {

View File

@@ -17,7 +17,6 @@ package xyz.playedu.api.request.backend;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@Data

View File

@@ -15,9 +15,8 @@
*/
package xyz.playedu.api.request.backend;
import lombok.Data;
import java.util.List;
import lombok.Data;
@Data
public class CourseAttachmentSortRequest {

View File

@@ -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 杭州白书科技有限公司

View File

@@ -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;
/**

View File

@@ -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 杭州白书科技有限公司

View File

@@ -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 杭州白书科技有限公司

View File

@@ -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;
/**

View File

@@ -15,9 +15,8 @@
*/
package xyz.playedu.api.request.backend;
import lombok.Data;
import java.util.List;
import lombok.Data;
/**
* @Author 杭州白书科技有限公司

View File

@@ -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 杭州白书科技有限公司

View File

@@ -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 杭州白书科技有限公司

View File

@@ -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 杭州白书科技有限公司

View File

@@ -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 杭州白书科技有限公司

View File

@@ -15,9 +15,8 @@
*/
package xyz.playedu.api.request.backend;
import lombok.Data;
import java.util.List;
import lombok.Data;
/**
* @Author 杭州白书科技有限公司

View File

@@ -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 {

View File

@@ -16,9 +16,7 @@
package xyz.playedu.api.request.backend;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
/**

View File

@@ -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 {

View File

@@ -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 杭州白书科技有限公司

View File

@@ -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;
/**

View File

@@ -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 杭州白书科技有限公司

View File

@@ -15,9 +15,8 @@
*/
package xyz.playedu.api.request.backend;
import lombok.Data;
import java.util.List;
import lombok.Data;
@Data
public class ResourceDestroyMultiRequest {

View File

@@ -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;
/**

View File

@@ -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

View File

@@ -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;
/**

View File

@@ -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 杭州白书科技有限公司

View File

@@ -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;
/**

View File

@@ -16,9 +16,7 @@
package xyz.playedu.api.request.frontend;
import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
/**

View File

@@ -16,7 +16,6 @@
package xyz.playedu.api.request.frontend;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
/**

View File

@@ -16,7 +16,6 @@
package xyz.playedu.api.request.frontend;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
@Data

View File

@@ -16,7 +16,6 @@
package xyz.playedu.api.request.frontend;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
@Data

View File

@@ -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

View File

@@ -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: