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 getCustomerBadge(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 setCustomerBadge(List userBadge, String customerId){ redisUtils.hSet(BadgeConstant.BADGE_KEY+customerId,BadgeConstant.BADGE, JSON.toJSON(userBadge).toString(),-1); } /** * @Description 删除客户徽章信息 * @Param customerId * @author zxc * @date 2020/11/5 3:06 下午 */ public void delCustomerBadge(String customerId){ redisUtils.hDel(BadgeConstant.BADGE_KEY+customerId,BadgeConstant.BADGE); } /** * @Description 存放徽章审核 手机验证码 * @Param mobile * @author zxc * @date 2020/11/5 10:30 上午 */ public void saveBadgeSmsCode(String mobile, String smsCode) { String smsCodeKey = BadgeConstant.SMS_CODE_KEY + mobile; redisUtils.set(smsCodeKey, smsCode, MINUTE_THIRTY_EXPIRE); } /** * @Description 获取徽章审核 手机验证码 * @Param mobile * @author zxc * @date 2020/11/5 10:30 上午 */ public String getBadgeSmsCode(String mobile) { String smsCodeKey = BadgeConstant.SMS_CODE_KEY + mobile; String smsCode = (String) redisUtils.get(smsCodeKey); return smsCode; } }