Browse Source

用户勋章缓存修改.

dev_shibei_match
wangchao 5 years ago
parent
commit
d288d08ed6
  1. 2
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisUtils.java
  2. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRedisKeys.java
  3. 6
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java
  4. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java

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

@ -189,7 +189,7 @@ public class RedisUtils {
T target = clazz.newInstance(); T target = clazz.newInstance();
BeanUtils.copyProperties(o, target); BeanUtils.copyProperties(o, target);
return target; return target;
}catch (Exception e){throw new RenException("convert error");}finally{throw new RenException("convert error");} }catch (Exception e){throw new RenException("convert error");}
}).collect(Collectors.toList()); }).collect(Collectors.toList());
} }

2
epmet-user/epmet-user-server/src/main/java/com/epmet/constant/UserRedisKeys.java

@ -32,5 +32,5 @@ public class UserRedisKeys {
* @date 2020.11.05 13:34 * @date 2020.11.05 13:34
*/ */
public static String getResiUserBadgeKey(String customerId,String userId){ public static String getResiUserBadgeKey(String customerId,String userId){
return rootPrefix.concat("badge:user:").concat(customerId).concat(userId);} return rootPrefix.concat("badge:user:").concat(customerId).concat(":").concat(userId);}
} }

6
epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java

@ -101,9 +101,9 @@ public class UserBadgeRedis {
* @author wangc * @author wangc
* @date 2020.11.05 13:26 * @date 2020.11.05 13:26
*/ */
public List<UserBadgeUnitFormDTO> obtainUserBadge2List(String userId) { public List<UserBadgeUnitFormDTO> obtainUserBadge2List(String userId,String customerId) {
//TODO 补偿 //TODO 补偿
return redisUtils.lrange(UserRedisKeys.getResiUserKey(userId), NumConstant.ZERO, NumConstant.ONE_NEG, UserBadgeUnitFormDTO.class); return redisUtils.lrange(UserRedisKeys.getResiUserBadgeKey(customerId,userId), NumConstant.ZERO, NumConstant.ONE_NEG, UserBadgeUnitFormDTO.class);
} }
/** /**
@ -115,7 +115,7 @@ public class UserBadgeRedis {
* @date 2020.11.05 13:37 * @date 2020.11.05 13:37
*/ */
public long pushOrRemoveUserBadge4List(String userId, String badgeId, String customerId) { public long pushOrRemoveUserBadge4List(String userId, String badgeId, String customerId) {
List<UserBadgeUnitFormDTO> orient = obtainUserBadge2List(userId); List<UserBadgeUnitFormDTO> orient = obtainUserBadge2List(userId,customerId);
UserBadgeUnitFormDTO unit = null; UserBadgeUnitFormDTO unit = null;
if (!CollectionUtils.isEmpty(orient)) { if (!CollectionUtils.isEmpty(orient)) {

2
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java

@ -333,7 +333,7 @@ public class BadgeServiceImpl extends BaseServiceImpl<BadgeDao, BadgeEntity> imp
@Override @Override
public void testCache() { public void testCache() {
badgeRedis.pushOrRemoveUserBadge4List("test-wc","1","45687aa479955f9d06204d415238f7cc"); badgeRedis.pushOrRemoveUserBadge4List("test-wc","1","45687aa479955f9d06204d415238f7cc");
List<UserBadgeUnitFormDTO> cache = badgeRedis.obtainUserBadge2List("test-wc"); List<UserBadgeUnitFormDTO> cache = badgeRedis.obtainUserBadge2List("test-wc","45687aa479955f9d06204d415238f7cc");
System.out.println(cache); System.out.println(cache);
} }

Loading…
Cancel
Save