Commit 186f9b15 authored by 技术部-任文超's avatar 技术部-任文超

代码重构

parent 025c1465
......@@ -87,14 +87,6 @@ public interface Constants {
String AVATAR_DEFAULT = "https://avatar.xyqb.com/default_avatar.png";
}
interface Sms {
String VERIFICATION_CODE = "尊敬的用户,您本次的验证码为:%s,有效期10分钟。"; // 随机验证码
String BINDCARD_SMS = "用户您好,您已绑卡成功,将会在1-5个工作日内收到借款,请耐心等待。如有疑问,请致电400-002-0061,感谢您对我们的支持";//绑卡成功后的短信文案
String REPAY_SMS = "用户您好,您在信用钱包的本期账单已还款成功,保持良好的信用可升级为VIP用户,享更多特权,感谢您对信用钱包的支持";
}
String AES_KEY = "ScnmRBhuQpo9kBdn";
}
......@@ -21,6 +21,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import javax.xml.crypto.dsig.keyinfo.PGPData;
import java.util.Objects;
/**
* IP白名单检验
......@@ -44,9 +45,9 @@ public class IpValidateAdvisor {
private void whiteIpMatch() {
}
@Before("whiteIpMatch()")
@Around("whiteIpMatch()")
private Object doWhiteIpMatch(ProceedingJoinPoint pjp) throws Throwable {
if(isDebug != 0){
if(Objects.equals(isDebug, 0)){
return pjp.proceed();
}
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
......@@ -69,8 +70,7 @@ public class IpValidateAdvisor {
private void needIpValidate() {
}
@Around("needIpValidate()")
private Object doCapchaValidate(ProceedingJoinPoint pjp) throws Throwable {
return pjp.proceed();
@Before("needIpValidate()")
private void doCapchaValidate() throws Throwable {
}
}
......@@ -153,9 +153,10 @@ public class SessionServiceImpl implements ISessionService {
*/
private void setUserIdTokenKeys(long userId, String key) {
if (0L != userId) {
String setKey = getUserSessionSetKey(userId);
try {
stringRedisTemplate.opsForSet().add(Constants.Session.USER_SESSION_KEY_SET + userId, key);
stringRedisTemplate.expire(Constants.Session.USER_SESSION_KEY_SET + userId, Constants.Session.ONE_DAY, TimeUnit.SECONDS);
stringRedisTemplate.opsForSet().add(setKey, key);
stringRedisTemplate.expire(setKey, Constants.Session.ONE_DAY, TimeUnit.SECONDS);
} catch (Exception e) {
log.error("存储用户注销件失败,userId:{},Exception:{}", userId, e);
}
......@@ -189,21 +190,16 @@ public class SessionServiceImpl implements ISessionService {
@CacheEvict(value = "userextinfocache", key = "'extinfo' + #userId", cacheManager = "cacheManager")
public void deleteByUserId(long userId) {
//1.删除session关联
Set useIdKeys = stringRedisTemplate.opsForSet().members(Constants.Session.USER_SESSION_KEY_SET + userId);
String setKey = getUserSessionSetKey(userId);
Set useIdKeys = stringRedisTemplate.opsForSet().members(setKey);
if (!CollectionUtils.isEmpty(useIdKeys)) {
useIdKeys.forEach(key -> {
log.info("删除用户userId={}的缓存信息", userId);
stringRedisTemplate.delete(String.valueOf(key));
});
//2.删除session缓存健
stringRedisTemplate.delete(Constants.Session.USER_SESSION_KEY_SET + userId);
stringRedisTemplate.delete(setKey);
}
}
/**
......@@ -221,4 +217,13 @@ public class SessionServiceImpl implements ISessionService {
public void deleteUserCatch(User user) {
}
/**
* 获取用户的会话缓存Set的Redis-Key
* @param userId - 用户主键
* @return
*/
private String getUserSessionSetKey(long userId) {
return Constants.Session.USER_SESSION_KEY_SET + userId;
}
}
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