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.

58 lines
1.6 KiB

5 years ago
package com.epmet.redis;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.redis.RedisUtils;
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.List;
import static com.epmet.commons.tools.redis.RedisUtils.MINUTE_THIRTY_EXPIRE;
5 years ago
/**
* @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 下午
*/
5 years ago
public Object getUserBadge(String customerId){
5 years ago
Object userBadge = redisUtils.hGet(BadgeConstant.BADGE_KEY + customerId, BadgeConstant.BADGE);
5 years ago
return userBadge;
5 years ago
}
/**
* @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);
}
public void saveBadgeSmsCode(String mobile, String smsCode) {
String smsCodeKey = "epmet:smsCode:badge:" + mobile;
redisUtils.set(smsCodeKey, smsCode, MINUTE_THIRTY_EXPIRE);
}
public String getBadgeSmsCode(String mobile) {
String smsCodeKey = "epmet:smsCode:badge:" + mobile;
String smsCode = (String) redisUtils.get(smsCodeKey);
return smsCode;
}
5 years ago
}