forked from dyf/fys-Multi-tenant
设备分享3
This commit is contained in:
@ -8,4 +8,5 @@ import java.lang.annotation.Target;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface FunctionAccessAnnotation {
|
||||
String value() default "";
|
||||
long timeOut() default 30;
|
||||
}
|
||||
|
@ -8,4 +8,6 @@ import java.lang.annotation.Target;
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface FunctionAccessBatcAnnotation {
|
||||
String value() default "";
|
||||
long timeOut() default 30;
|
||||
long batchMaxTimeOut() default 40;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ public class FunctionAccessAspect {
|
||||
// 获取方法参数,查找设备ID
|
||||
Object[] args = joinPoint.getArgs();
|
||||
deviceImei = extractDeviceImei(args);
|
||||
long timeout = functionAccessAnnotation.timeOut();
|
||||
|
||||
if (StringUtils.isNotBlank(deviceImei)) {
|
||||
// 生成全局Redis key
|
||||
@ -37,7 +38,7 @@ public class FunctionAccessAspect {
|
||||
throw new ServiceException("设备已存在访问限制,请稍后再试", 500);
|
||||
}
|
||||
//
|
||||
RedisUtils.setCacheObject(redisKey, "ACTIVE", Duration.ofSeconds(30));
|
||||
RedisUtils.setCacheObject(redisKey, "ACTIVE", Duration.ofSeconds(timeout));
|
||||
}
|
||||
|
||||
// 执行原方法
|
||||
|
@ -41,10 +41,10 @@ public class FunctionAccessBatchAspect {
|
||||
throw new ServiceException("设备已存在访问限制,请稍后再试", 500);
|
||||
}
|
||||
deviceImeiList.forEach(item->{
|
||||
RedisUtils.setCacheObject(FUNCTION_ACCESS_KEY + item, "ACTIVE", Duration.ofSeconds(30));
|
||||
RedisUtils.setCacheObject(FUNCTION_ACCESS_KEY + item, "ACTIVE", Duration.ofSeconds(functionAccessBatchAspect.timeOut()));
|
||||
});
|
||||
String deviceImeiListStr = JSONUtil.toJsonStr(deviceImeiList);
|
||||
RedisUtils.setCacheObject(redisKey, deviceImeiListStr , Duration.ofSeconds(40));
|
||||
RedisUtils.setCacheObject(redisKey, deviceImeiListStr , Duration.ofSeconds(functionAccessBatchAspect.batchMaxTimeOut()));
|
||||
}
|
||||
|
||||
// 执行原方法
|
||||
|
Reference in New Issue
Block a user