代码格式化

This commit is contained in:
none
2023-04-07 10:03:45 +08:00
parent fc8ff14a24
commit f437b3ad4d
252 changed files with 7467 additions and 5770 deletions

View File

@@ -1,7 +1,12 @@
/**
* This file is part of the PlayEdu.
* (c) 杭州白书科技有限公司
*/
package xyz.playedu.api.caches;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import xyz.playedu.api.domain.Course;
import xyz.playedu.api.exception.NotFoundException;
import xyz.playedu.api.service.CourseService;
@@ -9,17 +14,17 @@ import xyz.playedu.api.util.RedisUtil;
/**
* @Author 杭州白书科技有限公司
*
* @create 2023/3/20 17:57
*/
@Component
public class CourseCache {
@Autowired
private CourseService courseService;
@Autowired private CourseService courseService;
private final static String keyTemplate = "course:%d";
private static final String keyTemplate = "course:%d";
private final static int expire = 3600;//s
private static final int expire = 3600; // s
public Course findOrFail(Integer id) throws NotFoundException {
String keyName = key(id);
@@ -38,5 +43,4 @@ public class CourseCache {
private String key(Integer courseId) {
return String.format(keyTemplate, courseId);
}
}

View File

@@ -1,7 +1,12 @@
/**
* This file is part of the PlayEdu.
* (c) 杭州白书科技有限公司
*/
package xyz.playedu.api.caches;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import xyz.playedu.api.bus.UserBus;
import xyz.playedu.api.domain.Course;
import xyz.playedu.api.domain.User;
@@ -10,17 +15,17 @@ import xyz.playedu.api.util.RedisUtil;
/**
* @Author 杭州白书科技有限公司
*
* @create 2023/3/20 15:20
*/
@Component
public class UserCanSeeCourseCache {
@Autowired
private UserBus userBus;
@Autowired private UserBus userBus;
private final static String keyTemplate = "c:%d-u:%d";
private static final String keyTemplate = "c:%d-u:%d";
private final static int expire = 3600;//s
private static final int expire = 3600; // s
public boolean check(User user, Course course, boolean isThrow) throws ServiceException {
boolean result;
@@ -44,5 +49,4 @@ public class UserCanSeeCourseCache {
private String key(User user, Course course) {
return String.format(keyTemplate, course.getId(), user.getId());
}
}

View File

@@ -1,18 +1,24 @@
/**
* This file is part of the PlayEdu.
* (c) 杭州白书科技有限公司
*/
package xyz.playedu.api.caches;
import org.springframework.stereotype.Component;
import xyz.playedu.api.util.RedisUtil;
/**
* @Author 杭州白书科技有限公司
*
* @create 2023/3/22 13:57
*/
@Component
public class UserLastLearnTimeCache {
private final static String groupName = "user-learn-last-timestamp";
private static final String groupName = "user-learn-last-timestamp";
private final static int expire = 9500;//9.5s
private static final int expire = 9500; // 9.5s
public Long get(Integer userId) {
return (Long) RedisUtil.hGet(groupName, userId + "");