Browse Source

标签使用次数缓存修改方法添加

dev_shibei_match
zxc 5 years ago
parent
commit
95fc91a910
  1. 18
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java
  2. 27
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueProjectTagDictRedis.java

18
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java

@ -10,12 +10,13 @@ package com.epmet.commons.tools.redis;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.ConvertUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.*;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.data.redis.support.atomic.RedisAtomicLong;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
@ -363,6 +364,17 @@ public class RedisUtils {
return redisTemplate.opsForZSet().incrementScore(key, value, delta);
}
/**
* @Description 获取某个Zset的score
* @Param key
* @Param o
* @author zxc
* @date 2020/12/9 下午3:07
*/
public Double getScore(String key, Object o){
return redisTemplate.opsForZSet().score(key,o);
}
/**
* @Description 判断key是否存在
* @param key

27
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/redis/IssueProjectTagDictRedis.java

@ -17,10 +17,12 @@
package com.epmet.redis;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.constant.GovIssueRedisKeys;
import com.epmet.dto.result.IssueCategoryTagResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -71,4 +73,27 @@ public class IssueProjectTagDictRedis {
return null;
}
/**
* @Description 标签使用次数修改
* @Param customerId 客户ID
* @Param categoryId 标签ID 自定义标签的categoryId统一为[customize]
* @Param formDTO
* @Param status 标签次数更新状态 0+11-1
* @author zxc
* @date 2020/12/9 下午2:54
*/
public void editTagUseCount(String customerId,String categoryId, Object formDTO,String status){
String key = GovIssueRedisKeys.getGovernmentTagKey(customerId, categoryId);
if (status.equals(NumConstant.ZERO_STR)){
// 标签使用次数+1
redisUtils.zIncrementScore(key, formDTO,NumConstant.ONE);
}
if (status.equals(NumConstant.ONE_STR)){
//标签使用次数-1
if (redisUtils.getScore(key,formDTO)>NumConstant.ZERO){
redisUtils.zIncrementScore(key, formDTO,NumConstant.ONE_NEG);
}
}
}
}
Loading…
Cancel
Save