增加周播放量
This commit is contained in:
@@ -21,4 +21,6 @@ public interface RedisService {
|
||||
boolean isRecordUserOnLineTime(long userId);
|
||||
|
||||
boolean isSetUserState(long userId);
|
||||
|
||||
int getCourseWeekViewCount(long courseId);
|
||||
}
|
||||
|
||||
@@ -291,4 +291,23 @@ public class RedisServiceImpl implements RedisService {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCourseWeekViewCount(long courseId) {
|
||||
String key = "course:viewCount:" + courseId;
|
||||
String info = redisUtils.get(key);
|
||||
if (StrUtil.isBlank(info)) {
|
||||
// 获取当前时间
|
||||
DateTime now = DateUtil.date();
|
||||
// 获取下周一的日期
|
||||
DateTime nextMonday = DateUtil.nextWeek();
|
||||
// 计算距离下周一还有多少秒
|
||||
long seconds = nextMonday.getTime() - now.getTime();
|
||||
redisUtils.set(key, 1, seconds);
|
||||
return 1;
|
||||
}
|
||||
int i = Integer.parseInt(info) + 1;
|
||||
redisUtils.set(key, i, -1);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user