修改注销逻辑

parent 2b4d3b48
...@@ -62,6 +62,8 @@ public interface Constants { ...@@ -62,6 +62,8 @@ public interface Constants {
String USER_SESSION_ID_CACHE = "userid-sessionvalue:cache:"; String USER_SESSION_ID_CACHE = "userid-sessionvalue:cache:";
String USER_SESSION_KEY_SET = "userid-keys:set:"; String USER_SESSION_KEY_SET = "userid-keys:set:";
Long ONE_DAY = 24 * 60 * 60L; Long ONE_DAY = 24 * 60 * 60L;
String USER_CATCH_KEY="usercache:xyqbuser";
String USER_CATCH_INFO_KEY="userextinfocache:extinfo";
} }
interface WeChat { interface WeChat {
......
...@@ -9,6 +9,8 @@ import cn.quantgroup.xyqb.model.session.SessionStruct; ...@@ -9,6 +9,8 @@ import cn.quantgroup.xyqb.model.session.SessionStruct;
import cn.quantgroup.xyqb.model.session.SessionValue; import cn.quantgroup.xyqb.model.session.SessionValue;
import cn.quantgroup.xyqb.service.session.ISessionService; import cn.quantgroup.xyqb.service.session.ISessionService;
import cn.quantgroup.xyqb.service.session.aspect.UserBtRegisterFill; import cn.quantgroup.xyqb.service.session.aspect.UserBtRegisterFill;
import cn.quantgroup.xyqb.service.user.IUserService;
import cn.quantgroup.xyqb.service.user.impl.UserServiceImpl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Joiner; import com.google.common.base.Joiner;
...@@ -37,6 +39,8 @@ public class SessionServiceImpl implements ISessionService { ...@@ -37,6 +39,8 @@ public class SessionServiceImpl implements ISessionService {
@Autowired @Autowired
@Qualifier("stringRedisTemplate") @Qualifier("stringRedisTemplate")
private RedisTemplate<String, String> stringRedisTemplate; private RedisTemplate<String, String> stringRedisTemplate;
@Autowired
private IUserService userService;
@Override @Override
public AuthBean createSession(Long channelId, Long createdFrom, String appChannel, User user, Merchant merchant) { public AuthBean createSession(Long channelId, Long createdFrom, String appChannel, User user, Merchant merchant) {
...@@ -181,14 +185,25 @@ public class SessionServiceImpl implements ISessionService { ...@@ -181,14 +185,25 @@ public class SessionServiceImpl implements ISessionService {
@Override @Override
public void deleteByUserId(long userId) { public void deleteByUserId(long userId) {
//1.删除session关联
Set useIdKeys = stringRedisTemplate.opsForSet().members(Constants.Session.USER_SESSION_KEY_SET + userId); Set useIdKeys = stringRedisTemplate.opsForSet().members(Constants.Session.USER_SESSION_KEY_SET + userId);
if (!CollectionUtils.isEmpty(useIdKeys)) { if (!CollectionUtils.isEmpty(useIdKeys)) {
useIdKeys.forEach(key -> { useIdKeys.forEach(key -> {
log.info("删除用户userId={}的缓存信息", userId); log.info("删除用户userId={}的缓存信息", userId);
stringRedisTemplate.delete(String.valueOf(key)); stringRedisTemplate.delete(String.valueOf(key));
}); });
//2.删除session缓存健
stringRedisTemplate.delete(Constants.Session.USER_SESSION_KEY_SET + userId);
//3.删除用户查询缓存
stringRedisTemplate.delete(Constants.Session.USER_SESSION_KEY_SET + userId); stringRedisTemplate.delete(Constants.Session.USER_SESSION_KEY_SET + userId);
stringRedisTemplate.delete(Constants.Session.USER_CATCH_KEY + userId);
stringRedisTemplate.delete(Constants.Session.USER_CATCH_INFO_KEY + userId);
User user = userService.findById(userId);
if (null != user) {
stringRedisTemplate.delete(Constants.Session.USER_CATCH_KEY + user.getPhoneNo());
stringRedisTemplate.delete(Constants.Session.USER_CATCH_KEY + user.getUuid());
}
} }
......
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