增加周播放量
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.sqx.common.utils;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -114,8 +115,13 @@ public class ApiAccessLimitUtil {
|
||||
String redisKey = generateRedisKey(key, id);
|
||||
Object countObj = redisUtils.get(redisKey);
|
||||
if (countObj == null) {
|
||||
// 根据不同时间周期设置过期时间并初始化访问次数为1
|
||||
long expireAt = calculateExpireAt(timeFormat);
|
||||
long expireAt;
|
||||
if (StrUtil.isBlank(timeFormat)) {
|
||||
expireAt = count;
|
||||
}else {
|
||||
// 根据不同时间周期设置过期时间并初始化访问次数为1
|
||||
expireAt = calculateExpireAt(timeFormat);
|
||||
}
|
||||
redisUtils.set(redisKey, 1, expireAt);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user