mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-11-04 10:57:10 +08:00 
			
		
		
		
	fix(system/user): 修复删除用户时未及时清除第三方账号信息的错误 (PR by Gitee@hagyao520)
This commit is contained in:
		@@ -68,4 +68,11 @@ public interface UserSocialService {
 | 
				
			|||||||
     * @param userId 用户 ID
 | 
					     * @param userId 用户 ID
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    void deleteBySourceAndUserId(String source, Long userId);
 | 
					    void deleteBySourceAndUserId(String source, Long userId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * 根据用户 ID 删除
 | 
				
			||||||
 | 
					     *
 | 
				
			||||||
 | 
					     * @param userIds 用户 ID 列表
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    void deleteByUserIds(List<Long> userIds);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -110,10 +110,11 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    private final PasswordEncoder passwordEncoder;
 | 
					    private final PasswordEncoder passwordEncoder;
 | 
				
			||||||
    private final UserPasswordHistoryService userPasswordHistoryService;
 | 
					    private final UserPasswordHistoryService userPasswordHistoryService;
 | 
				
			||||||
    private final OnlineUserService onlineUserService;
 | 
					    private final UserSocialService userSocialService;
 | 
				
			||||||
    private final OptionService optionService;
 | 
					 | 
				
			||||||
    private final UserRoleService userRoleService;
 | 
					    private final UserRoleService userRoleService;
 | 
				
			||||||
 | 
					    private final OptionService optionService;
 | 
				
			||||||
    private final RoleService roleService;
 | 
					    private final RoleService roleService;
 | 
				
			||||||
 | 
					    private final OnlineUserService onlineUserService;
 | 
				
			||||||
    private final FileService fileService;
 | 
					    private final FileService fileService;
 | 
				
			||||||
    private final FileStorageService fileStorageService;
 | 
					    private final FileStorageService fileStorageService;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -209,6 +210,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
 | 
				
			|||||||
        userRoleService.deleteByUserIds(ids);
 | 
					        userRoleService.deleteByUserIds(ids);
 | 
				
			||||||
        // 删除历史密码
 | 
					        // 删除历史密码
 | 
				
			||||||
        userPasswordHistoryService.deleteByUserIds(ids);
 | 
					        userPasswordHistoryService.deleteByUserIds(ids);
 | 
				
			||||||
 | 
					        // 删除用户绑定的第三方账号信息
 | 
				
			||||||
 | 
					        userSocialService.deleteByUserIds(ids);
 | 
				
			||||||
        // 删除用户
 | 
					        // 删除用户
 | 
				
			||||||
        super.delete(ids);
 | 
					        super.delete(ids);
 | 
				
			||||||
        // 踢出在线用户
 | 
					        // 踢出在线用户
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,6 +16,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
package top.continew.admin.system.service.impl;
 | 
					package top.continew.admin.system.service.impl;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import cn.hutool.core.collection.CollUtil;
 | 
				
			||||||
import cn.hutool.json.JSONUtil;
 | 
					import cn.hutool.json.JSONUtil;
 | 
				
			||||||
import lombok.RequiredArgsConstructor;
 | 
					import lombok.RequiredArgsConstructor;
 | 
				
			||||||
import me.zhyd.oauth.model.AuthUser;
 | 
					import me.zhyd.oauth.model.AuthUser;
 | 
				
			||||||
@@ -90,4 +91,12 @@ public class UserSocialServiceImpl implements UserSocialService {
 | 
				
			|||||||
    public void deleteBySourceAndUserId(String source, Long userId) {
 | 
					    public void deleteBySourceAndUserId(String source, Long userId) {
 | 
				
			||||||
        baseMapper.lambdaUpdate().eq(UserSocialDO::getSource, source).eq(UserSocialDO::getUserId, userId).remove();
 | 
					        baseMapper.lambdaUpdate().eq(UserSocialDO::getSource, source).eq(UserSocialDO::getUserId, userId).remove();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void deleteByUserIds(List<Long> userIds) {
 | 
				
			||||||
 | 
					        if (CollUtil.isEmpty(userIds)) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        baseMapper.lambdaUpdate().in(UserSocialDO::getUserId, userIds).remove();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user