Commit 6522ef48 authored by shiyu's avatar shiyu

登录

parent e8c18c66
......@@ -15,6 +15,9 @@ public class CacheCodeConstants {
*/
public static final String USER_LOGIN_SMS_KEY = "cjxc:wx:user:sms:login:{0}";
public static final String QD_USER_LOGIN_SMS_KEY = "qiandao:wx:user:sms:login:{0}";
/**
* 缓存用户修改密码验证码
* <p>{0}:手机号</p>
......@@ -27,6 +30,9 @@ public class CacheCodeConstants {
*/
public static final String USER_INFO_KEY = "cjxc:wx:user:info:{0}";
public static final String QD_USER_INFO_KEY = "qiandao:wx:user:info:{0}";
/**
* 缓存关注者新发布藏品记录
* <p>{0}被关注者id:粉丝id</p>
......
......@@ -93,7 +93,7 @@ public class QdUserServiceImpl implements QdUserService {
}
String key = "";
if (dto.getSmsType().equals(CacheCodeConstants.SmsTypeEnum.LOGIN.getCode())) {
key = MessageFormat.format(CacheCodeConstants.USER_LOGIN_SMS_KEY, dto.getMobile());
key = MessageFormat.format(CacheCodeConstants.QD_USER_LOGIN_SMS_KEY, dto.getMobile());
} else {
key = MessageFormat.format(CacheCodeConstants.USER_UPDATE_SMS_KEY, dto.getMobile());
}
......@@ -126,7 +126,7 @@ public class QdUserServiceImpl implements QdUserService {
@Override
public Result loginByMobile(QdUserRequestDto dto, HttpServletRequest request) {
try {
String key = MessageFormat.format(CacheCodeConstants.USER_LOGIN_SMS_KEY, dto.getMobile());
String key = MessageFormat.format(CacheCodeConstants.QD_USER_LOGIN_SMS_KEY, dto.getMobile());
Object object = redisUtils.get(key);
if (Objects.isNull(object)) {
return Result.failed("验证码已过期");
......@@ -164,18 +164,6 @@ public class QdUserServiceImpl implements QdUserService {
if (getPhoneResult.getSuccess()) {
mobile = getPhoneResult.getData();
}
/* if (StringUtils.equals("false", mobile)) {
return Result.failed("获取access_token失败");
}
if (StringUtils.equals("sessionFalse", mobile)) {
return Result.failed("获取sessionKey失败");
}
if (StringUtils.equals("phoneFalse", mobile)) {
return Result.failed("获取手机号失败");
}
if (StringUtils.equals("decryptFalse", mobile)) {
return Result.failed(ResultCode.FAILED.getCode(), "用户信息解密失败");
}*/
} catch (Exception e) {
logger.error("获取用户信息异常", e);
return Result.failed("获取用户信息异常");
......@@ -203,7 +191,7 @@ public class QdUserServiceImpl implements QdUserService {
qdUserDao.updateById(user);
// 更新用户缓存
QdUser resultQdUser = qdUserDao.queryById(user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.USER_INFO_KEY, user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.QD_USER_INFO_KEY, user.getId());
redisUtils.set(userKey, resultQdUser, 2 * 60 * 60);
logger.info("【请求结束】用户修改个性签名成功");
return Result.success();
......@@ -224,7 +212,7 @@ public class QdUserServiceImpl implements QdUserService {
qdUserDao.updateById(user);
// 更新用户缓存
QdUser resultQdUser = qdUserDao.queryById(user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.USER_INFO_KEY, user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.QD_USER_INFO_KEY, user.getId());
redisUtils.set(userKey, resultQdUser, 2 * 60 * 60);
logger.info("【请求结束】用户修改背景成功");
return Result.success();
......@@ -277,7 +265,7 @@ public class QdUserServiceImpl implements QdUserService {
qdUserDao.updateById(user);
// 更新用户缓存
QdUser resultQdUser = qdUserDao.queryById(user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.USER_INFO_KEY, user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.QD_USER_INFO_KEY, user.getId());
redisUtils.set(userKey, resultQdUser, 2 * 60 * 60);
logger.info("【请求结束】用户修改昵称成功");
return Result.success();
......@@ -298,7 +286,7 @@ public class QdUserServiceImpl implements QdUserService {
qdUserDao.updateById(user);
// 更新用户缓存
QdUser resultQdUser = qdUserDao.queryById(user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.USER_INFO_KEY, user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.QD_USER_INFO_KEY, user.getId());
redisUtils.set(userKey, resultQdUser, 2 * 60 * 60);
logger.info("【请求结束】用户修改头像成功");
return Result.success();
......@@ -320,7 +308,7 @@ public class QdUserServiceImpl implements QdUserService {
qdUserDao.updateById(user);
// 更新用户缓存
QdUser resultQdUser = qdUserDao.queryById(user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.USER_INFO_KEY, user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.QD_USER_INFO_KEY, user.getId());
redisUtils.set(userKey, resultQdUser, 2 * 60 * 60);
logger.info("【请求结束】用户修改微信二维码成功");
return Result.success();
......@@ -357,7 +345,7 @@ public class QdUserServiceImpl implements QdUserService {
// 更新用户缓存
QdUser resultQdUser = qdUserDao.queryById(user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.USER_INFO_KEY, user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.QD_USER_INFO_KEY, user.getId());
redisUtils.set(userKey, resultQdUser, 2 * 60 * 60);
logger.info("【请求结束】用户修改手机号成功");
// 清除验证码缓存
......@@ -383,7 +371,7 @@ public class QdUserServiceImpl implements QdUserService {
return Result.failed("查询不到当前登录用户信息");
}
QdUser user = null;
String key = MessageFormat.format(CacheCodeConstants.USER_INFO_KEY, userId);
String key = MessageFormat.format(CacheCodeConstants.QD_USER_INFO_KEY, userId);
if (redisUtils.hasKey(key)) {
user = (QdUser) redisUtils.get(key);
} else {
......@@ -522,7 +510,7 @@ public class QdUserServiceImpl implements QdUserService {
result.put("wxOpenid", user.getWxOpenid());
// 缓存用户信息
String userKey = MessageFormat.format(CacheCodeConstants.USER_INFO_KEY, user.getId());
String userKey = MessageFormat.format(CacheCodeConstants.QD_USER_INFO_KEY, user.getId());
redisUtils.set(userKey, user, 2 * 60 * 60);
return result;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment