mirror of
https://github.com/PlayEdu/PlayEdu
synced 2025-12-26 04:39:26 +08:00
学员真实学习时长记录
This commit is contained in:
@@ -25,12 +25,13 @@ public class UserCanSeeCourseCache {
|
||||
public boolean check(User user, Course course, boolean isThrow) throws ServiceException {
|
||||
boolean result;
|
||||
if (RedisUtil.exists(key(user, course))) {
|
||||
result = "1".equals(RedisUtil.get(key(user, course)));
|
||||
String cacheResult = (String) RedisUtil.get(key(user, course));
|
||||
result = "1".equals(cacheResult);
|
||||
} else {
|
||||
result = userBus.canSeeCourse(user, course);
|
||||
put(user, course, result);
|
||||
}
|
||||
if (isThrow) {
|
||||
if (!result && isThrow) {
|
||||
throw new ServiceException("无权限观看");
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
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 final static int expire = 9500;//9.5s
|
||||
|
||||
public Long get(Integer userId) {
|
||||
return (Long) RedisUtil.hGet(groupName, userId + "");
|
||||
}
|
||||
|
||||
public void put(Integer userId, Long timestamp) {
|
||||
RedisUtil.hSet(groupName, userId + "", timestamp);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user