Browse Source

用户勋章缓存修改

dev_shibei_match
wangchao 5 years ago
parent
commit
cca7e6eb30
  1. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java
  2. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/redis/UserBadgeRedis.java
  3. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/BadgeService.java
  4. 12
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/BadgeServiceImpl.java

5
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/BadgeController.java

@ -100,5 +100,10 @@ public class BadgeController {
return new Result(); return new Result();
} }
@PostMapping("test-cache")
public Result testCache(){
badgeService.testCache();
return new Result();
}
} }

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

@ -127,8 +127,11 @@ public class UserBadgeRedis {
} }
//徽章池 //徽章池
Object badgeObj = getCustomerBadge(customerId);
List<UserBadgeListResultDTO> badgePool = List<UserBadgeListResultDTO> badgePool =
Optional.ofNullable(JSON.parseArray(getCustomerBadge(customerId).toString(), UserBadgeListResultDTO.class)) null == badgeObj ? null :
Optional.ofNullable(JSON.parseArray(badgeObj.toString(), UserBadgeListResultDTO.class))
.orElse(badgeDao.selectCustomerBadgePool(customerId)); .orElse(badgeDao.selectCustomerBadgePool(customerId));
if (CollectionUtils.isEmpty(badgePool)) { if (CollectionUtils.isEmpty(badgePool)) {
log.error("com.epmet.redis.UserBadgeRedis.pushOrRemoveUserBadge4List,缓存中客户{}下的徽章池为空", customerId); log.error("com.epmet.redis.UserBadgeRedis.pushOrRemoveUserBadge4List,缓存中客户{}下的徽章池为空", customerId);

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

@ -147,4 +147,6 @@ public interface BadgeService extends BaseService<BadgeEntity> {
* @return void * @return void
*/ */
void deleteBadge(TokenDto tokenDto, BadgeFormDTO formDTO); void deleteBadge(TokenDto tokenDto, BadgeFormDTO formDTO);
void testCache();
} }

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

@ -33,12 +33,15 @@ import com.epmet.dto.BadgeDTO;
import com.epmet.dto.form.AddBadgeFormDTO; import com.epmet.dto.form.AddBadgeFormDTO;
import com.epmet.dto.form.BadgeFormDTO; import com.epmet.dto.form.BadgeFormDTO;
import com.epmet.dto.form.EditBadgeFormDTO; import com.epmet.dto.form.EditBadgeFormDTO;
import com.epmet.dto.form.UserBadgeUnitFormDTO;
import com.epmet.dto.result.BadgeDetailResultDTO; import com.epmet.dto.result.BadgeDetailResultDTO;
import com.epmet.dto.result.BadgeListResultDTO; import com.epmet.dto.result.BadgeListResultDTO;
import com.epmet.entity.BadgeCertificationConfigEntity; import com.epmet.entity.BadgeCertificationConfigEntity;
import com.epmet.entity.BadgeEntity; import com.epmet.entity.BadgeEntity;
import com.epmet.redis.UserBadgeRedis;
import com.epmet.service.BadgeCertificationConfigService; import com.epmet.service.BadgeCertificationConfigService;
import com.epmet.service.BadgeService; import com.epmet.service.BadgeService;
import com.epmet.service.UserBadgeService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -61,6 +64,8 @@ public class BadgeServiceImpl extends BaseServiceImpl<BadgeDao, BadgeEntity> imp
@Autowired @Autowired
private BadgeCertificationConfigService badgeCertificationConfigService; private BadgeCertificationConfigService badgeCertificationConfigService;
@Autowired
private UserBadgeRedis badgeRedis;
@Override @Override
@ -245,4 +250,11 @@ public class BadgeServiceImpl extends BaseServiceImpl<BadgeDao, BadgeEntity> imp
badgeCertificationConfigService.deleteConfig(tokenDto.getCustomerId(), formDTO.getBadgeId()); badgeCertificationConfigService.deleteConfig(tokenDto.getCustomerId(), formDTO.getBadgeId());
} }
@Override
public void testCache() {
badgeRedis.pushOrRemoveUserBadge4List("test-wc","1","45687aa479955f9d06204d415238f7cc");
List<UserBadgeUnitFormDTO> cache = badgeRedis.obtainUserBadge2List("test-wc");
System.out.println(cache);
}
} }
Loading…
Cancel
Save