fix: 删除用户同时删除用户历史密码

This commit is contained in:
2024-06-24 21:17:50 +08:00
parent eb65cff4c7
commit f53d6b6504
4 changed files with 16 additions and 1 deletions

View File

@@ -16,6 +16,8 @@
package top.continew.admin.system.service;
import java.util.List;
/**
* 用户历史密码业务接口
*
@@ -33,6 +35,13 @@ public interface UserPasswordHistoryService {
*/
void add(Long userId, String password, int count);
/**
* 根据用户 ID 删除
*
* @param userIds 用户 ID 列表
*/
void deleteByUserIds(List<Long> userIds);
/**
* 密码是否为重复使用
*

View File

@@ -52,6 +52,11 @@ public class UserPasswordHistoryServiceImpl implements UserPasswordHistoryServic
baseMapper.deleteExpired(userId, count);
}
@Override
public void deleteByUserIds(List<Long> userIds) {
baseMapper.lambdaUpdate().in(UserPasswordHistoryDO::getUserId, userIds).remove();
}
@Override
public boolean isPasswordReused(Long userId, String password, int count) {
// 查询近 N 个历史密码

View File

@@ -63,7 +63,6 @@ public class UserRoleServiceImpl implements UserRoleService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteByUserIds(List<Long> userIds) {
baseMapper.lambdaUpdate().in(UserRoleDO::getUserId, userIds).remove();
}

View File

@@ -345,6 +345,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, UserDO, UserRes
.getNickname());
// 删除用户和角色关联
userRoleService.deleteByUserIds(ids);
// 删除历史密码
userPasswordHistoryService.deleteByUserIds(ids);
// 删除用户
super.delete(ids);
}