全局控制

This commit is contained in:
2025-08-13 10:40:10 +08:00
parent 546433b3bc
commit a8efbb2768
8 changed files with 48 additions and 52 deletions

View File

@ -36,7 +36,7 @@ public class FunctionAccessAspect {
throw new ServiceException("设备已存在访问限制,请稍后再试", 500);
}
// 存储到Redis中设置过期时间
RedisUtils.setCacheObject(redisKey, "ACTIVE", Duration.ofMinutes(30));
RedisUtils.setCacheObject(redisKey, "ACTIVE", Duration.ofSeconds(30));
log.info("设备Redis key已添加: {}", redisKey);
}

View File

@ -3,6 +3,7 @@ import cn.hutool.json.JSON;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.fuyuanshen.common.core.exception.ServiceException;
import com.fuyuanshen.common.core.utils.ObjectUtils;
import com.fuyuanshen.common.core.utils.StringUtils;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessAnnotation;
import com.fuyuanshen.common.ratelimiter.annotation.FunctionAccessBatcAnnotation;
@ -14,9 +15,7 @@ import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import static com.fuyuanshen.common.core.constant.GlobalConstants.FUNCTION_ACCESS_KEY;
@ -43,8 +42,15 @@ public class FunctionAccessBatchAspect {
if(StringUtils.isNotBlank(cacheKey) && "ACTIVE".equals(cacheKey)){
throw new ServiceException("设备已存在访问限制,请稍后再试", 500);
}
Map<String, String> deviceImeiMap = new HashMap<>();
if(ObjectUtils.length(deviceImeiList)>0){
deviceImeiList.forEach(item->{
deviceImeiMap.put(item, "ACTIVE");
});
}
// 存储到Redis中设置过期时间
RedisUtils.setCacheObject(redisKey, JSONUtil.toJsonStr(deviceImeiList), Duration.ofMinutes(30));
RedisUtils.setCacheObject(redisKey, JSONUtil.toJsonStr(deviceImeiMap), Duration.ofSeconds(15));
log.info("设备Redis key已添加: {}", redisKey);
}