Browse Source

缓存中没有客户勋章则去数据库查询

master
wangchao 5 years ago
parent
commit
5f0eab13c9
  1. 8
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java

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

@ -1,7 +1,7 @@
package com.epmet.redis;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.redis.RedisUtils;
@ -10,7 +10,6 @@ import com.epmet.constant.BadgeConstant;
import com.epmet.constant.UserRedisKeys;
import com.epmet.dao.BadgeDao;
import com.epmet.dto.form.UserBadgeUnitFormDTO;
import com.epmet.dto.result.BadgeListResultDTO;
import com.epmet.dto.result.UserBadgeListResultDTO;
import com.epmet.service.UserBadgeService;
import lombok.extern.slf4j.Slf4j;
@ -130,9 +129,8 @@ public class UserBadgeRedis {
Object badgeObj = getCustomerBadge(customerId);
List<UserBadgeListResultDTO> badgePool =
null == badgeObj ? null :
Optional.ofNullable(JSON.parseArray(badgeObj.toString(), UserBadgeListResultDTO.class))
.orElse(badgeDao.selectCustomerBadgePool(customerId));
null == badgeObj ? badgeDao.selectCustomerBadgePool(customerId) : JSON.parseArray(badgeObj.toString(), UserBadgeListResultDTO.class);
if (CollectionUtils.isEmpty(badgePool)) {
log.error("com.epmet.redis.UserBadgeRedis.pushOrRemoveUserBadge4List,缓存中客户{}下的徽章池为空", customerId);
return NumConstant.ZERO;

Loading…
Cancel
Save