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.

80 lines
2.2 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 获取客户徽章信息
5 years ago
* @Param customerId
* @author zxc
* @date 2020/11/3 2:50 下午
*/
5 years ago
public Object getCustomerBadge(String customerId){
5 years ago
Object userBadge = redisUtils.hGet(BadgeConstant.BADGE_KEY + customerId, BadgeConstant.BADGE);
5 years ago
return userBadge;
5 years ago
}
/**
* @Description 存放客户徽章信息
5 years ago
* @Param userBadge
* @Param customerId
* @author zxc
* @date 2020/11/3 2:51 下午
*/
5 years ago
public void setCustomerBadge(List<UserBadgeListResultDTO> userBadge, String customerId){
5 years ago
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);
}
5 years ago
/**
* @Description 存放徽章审核 手机验证码
* @Param mobile
* @author zxc
* @date 2020/11/5 10:30 上午
*/
public void saveBadgeSmsCode(String mobile, String smsCode) {
5 years ago
String smsCodeKey = BadgeConstant.SMS_CODE_KEY + mobile;
redisUtils.set(smsCodeKey, smsCode, MINUTE_THIRTY_EXPIRE);
}
5 years ago
/**
* @Description 获取徽章审核 手机验证码
* @Param mobile
* @author zxc
* @date 2020/11/5 10:30 上午
*/
public String getBadgeSmsCode(String mobile) {
5 years ago
String smsCodeKey = BadgeConstant.SMS_CODE_KEY + mobile;
String smsCode = (String) redisUtils.get(smsCodeKey);
return smsCode;
}
5 years ago
}