3737import org .springframework .stereotype .Service ;
3838import org .springframework .transaction .annotation .Transactional ;
3939import org .springframework .web .multipart .MultipartFile ;
40-
4140import javax .servlet .http .HttpServletResponse ;
4241import javax .validation .constraints .NotBlank ;
4342import java .io .File ;
@@ -120,10 +119,6 @@ public void update(User resources) {
120119 redisUtils .del (CacheKey .MENU_USER + resources .getId ());
121120 redisUtils .del (CacheKey .ROLE_AUTH + resources .getId ());
122121 }
123- // 如果用户名称修改
124- if (!resources .getUsername ().equals (user .getUsername ())){
125- redisUtils .del ("user::username:" + user .getUsername ());
126- }
127122 // 如果用户被禁用,则清除用户登录信息
128123 if (!resources .getEnabled ()){
129124 onlineUserService .kickOutForUsername (resources .getUsername ());
@@ -170,7 +165,6 @@ public void delete(Set<Long> ids) {
170165 }
171166
172167 @ Override
173- @ Cacheable (key = "'username:' + #p0" )
174168 public UserDto findByName (String userName ) {
175169 User user = userRepository .findByUsername (userName );
176170 if (user == null ) {
@@ -184,7 +178,6 @@ public UserDto findByName(String userName) {
184178 @ Transactional (rollbackFor = Exception .class )
185179 public void updatePass (String username , String pass ) {
186180 userRepository .updatePass (username , pass , new Date ());
187- redisUtils .del ("user::username:" + username );
188181 flushCache (username );
189182 }
190183
@@ -201,7 +194,6 @@ public Map<String, String> updateAvatar(MultipartFile multipartFile) {
201194 FileUtil .del (oldPath );
202195 }
203196 @ NotBlank String username = user .getUsername ();
204- redisUtils .del (CacheKey .USER_NAME + username );
205197 flushCache (username );
206198 return new HashMap <String , String >(1 ) {{
207199 put ("avatar" , file .getName ());
@@ -212,7 +204,6 @@ public Map<String, String> updateAvatar(MultipartFile multipartFile) {
212204 @ Transactional (rollbackFor = Exception .class )
213205 public void updateEmail (String username , String email ) {
214206 userRepository .updateEmail (username , email );
215- redisUtils .del (CacheKey .USER_NAME + username );
216207 flushCache (username );
217208 }
218209
@@ -243,7 +234,6 @@ public void download(List<UserDto> queryAll, HttpServletResponse response) throw
243234 */
244235 public void delCaches (Long id , String username ) {
245236 redisUtils .del (CacheKey .USER_ID + id );
246- redisUtils .del (CacheKey .USER_NAME + username );
247237 flushCache (username );
248238 }
249239
0 commit comments