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; /** * @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 Object getUserBadge(String customerId){ Object userBadge = redisUtils.hGet(BadgeConstant.BADGE_KEY + customerId, BadgeConstant.BADGE); return userBadge; } /** * @Description 存放徽章信息 * @Param userBadge * @Param customerId * @author zxc * @date 2020/11/3 2:51 下午 */ public void setUserBadge(List 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; } }