...
|
...
|
@@ -6,6 +6,8 @@ import com.yohoufo.common.concurrent.RedisLimitor; |
|
|
import com.yohoufo.msg.constants.RuleKeyType;
|
|
|
import com.yohoufo.msg.model.NoticeRuleNode;
|
|
|
import lombok.Builder;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
...
|
...
|
@@ -18,11 +20,12 @@ import java.util.function.Supplier; |
|
|
|
|
|
@Service
|
|
|
public class RedisLimitStrategy {
|
|
|
private final Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
|
@Autowired
|
|
|
private RedisConcurrentFactory redisConcurrentFactory;
|
|
|
|
|
|
public boolean checkLimit(Integer uid, Integer storageId,
|
|
|
public boolean limit(Integer uid, Integer storageId,
|
|
|
RedisKeyBuilder rkb,
|
|
|
Map<Integer, NoticeRuleNode> noticeRuleNodeMap,
|
|
|
Supplier<Integer> pushSupplier){
|
...
|
...
|
@@ -50,6 +53,8 @@ public class RedisLimitStrategy { |
|
|
}
|
|
|
|
|
|
}
|
|
|
logger.info("RedisLimitStrategy.limit check by all config ,uid {} sku {} result {}",
|
|
|
uid, storageId, result);
|
|
|
//所有条件都满足后,聚合处理自增
|
|
|
if (result){
|
|
|
pushSupplier.get();
|
...
|
...
|
@@ -59,7 +64,7 @@ public class RedisLimitStrategy { |
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public CheckResultNode checkLimitBySingleRule(RedisKeyBuilder rkb, NoticeRuleNode ruleNode){
|
|
|
private CheckResultNode checkLimitBySingleRule(RedisKeyBuilder rkb, NoticeRuleNode ruleNode){
|
|
|
|
|
|
Integer uid = ruleNode.getUid();
|
|
|
TimeUnit timeUnit = ruleNode.getTimeUnit();
|
...
|
...
|
|