删除用户缓存

master
bynt 2 years ago
parent c9b273eccf
commit 57c0ca1332

@ -10,7 +10,7 @@ spring:
username: root username: root
redis: redis:
#数据库索引 #数据库索引
database: 9 database: 2
host: 8.130.96.163 host: 8.130.96.163
port: 6379 port: 6379
#连接超时时间 #连接超时时间

@ -11,7 +11,7 @@ spring:
username: root username: root
redis: redis:
#数据库索引 #数据库索引
database: 9 database: 2
host: 127.0.0.1 host: 127.0.0.1
port: 6379 port: 6379
#连接超时时间 #连接超时时间

@ -15,7 +15,6 @@ import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager; import org.springframework.cache.CacheManager;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.AuthorityUtils; import org.springframework.security.core.authority.AuthorityUtils;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.security.core.userdetails.UsernameNotFoundException;
@ -25,7 +24,6 @@ import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
/** /**
* *

@ -24,6 +24,7 @@ import cn.hutool.core.text.StrPool;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.baiye.component.LoginUser;
import com.baiye.config.BusinessConfig; import com.baiye.config.BusinessConfig;
import com.baiye.config.properties.FileProperties; import com.baiye.config.properties.FileProperties;
import com.baiye.constant.DefaultNumberConstants; import com.baiye.constant.DefaultNumberConstants;
@ -57,6 +58,8 @@ import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.cache.Cache;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheConfig; import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
@ -87,6 +90,8 @@ public class UserServiceImpl implements UserService {
private final UserMapper userMapper; private final UserMapper userMapper;
private final RedisUtils redisUtils; private final RedisUtils redisUtils;
private final CacheManager cacheManager;
private final RoleRepository repository; private final RoleRepository repository;
private final FileProperties properties; private final FileProperties properties;
private final BusinessConfig businessConfig; private final BusinessConfig businessConfig;
@ -518,6 +523,7 @@ public class UserServiceImpl implements UserService {
user.setGender(resources.getGender()); user.setGender(resources.getGender());
user.setTurnCrmNum(resources.getTurnCrmNum()); user.setTurnCrmNum(resources.getTurnCrmNum());
userRepository.save(user); userRepository.save(user);
this.redisUtils.del(CacheKey.USER_DETAILS + "::" + resources.getUsername());
// 清除缓存 // 清除缓存
delCaches(user.getId(), user.getUsername()); delCaches(user.getId(), user.getUsername());
} }

Loading…
Cancel
Save