forked from luyan/epmet-cloud-lingshan
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
5 years ago
|
package com.epmet.redis;
|
||
|
|
||
|
import com.alibaba.fastjson.JSON;
|
||
|
import com.epmet.commons.tools.redis.RedisUtils;
|
||
|
import com.epmet.commons.tools.utils.ConvertUtils;
|
||
|
import com.epmet.constant.BadgeConstant;
|
||
|
import com.epmet.dto.result.UserBadgeListResultDTO;
|
||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
import org.springframework.stereotype.Component;
|
||
|
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
|
||
|
/**
|
||
|
* @Author zxc
|
||
|
* @DateTime 2020/11/3 2:21 下午
|
||
|
*/
|
||
|
@Component
|
||
|
public class UserBadgeRedis {
|
||
|
|
||
|
@Autowired
|
||
|
private RedisUtils redisUtils;
|
||
|
|
||
|
/**
|
||
|
* @Description 获取徽章信息
|
||
|
* @Param customerId
|
||
|
* @author zxc
|
||
|
* @date 2020/11/3 2:50 下午
|
||
|
*/
|
||
|
public List<UserBadgeListResultDTO> getUserBadge(String customerId){
|
||
|
Object userBadge = redisUtils.hGet(BadgeConstant.BADGE_KEY + customerId, BadgeConstant.BADGE);
|
||
|
if (null == userBadge){
|
||
|
return new ArrayList<>();
|
||
|
}
|
||
|
return JSON.parseArray(userBadge.toString(), UserBadgeListResultDTO.class);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @Description 存放徽章信息
|
||
|
* @Param userBadge
|
||
|
* @Param customerId
|
||
|
* @author zxc
|
||
|
* @date 2020/11/3 2:51 下午
|
||
|
*/
|
||
|
public void setUserBadge(List<UserBadgeListResultDTO> userBadge,String customerId){
|
||
|
redisUtils.hSet(BadgeConstant.BADGE_KEY+customerId,BadgeConstant.BADGE, JSON.toJSON(userBadge).toString(),-1);
|
||
|
}
|
||
|
|
||
|
}
|