Skip to content

Commit

Permalink
fix: 删除用户同时删除用户历史密码
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Jun 24, 2024
1 parent eb65cff commit f53d6b6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package top.continew.admin.system.service;

import java.util.List;

/**
* 用户历史密码业务接口
*
Expand All @@ -33,6 +35,13 @@ public interface UserPasswordHistoryService {
*/
void add(Long userId, String password, int count);

/**
* 根据用户 ID 删除
*
* @param userIds 用户 ID 列表
*/
void deleteByUserIds(List<Long> userIds);

/**
* 密码是否为重复使用
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public void add(Long userId, String password, int count) {
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 个历史密码
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public boolean add(List<Long> roleIds, Long userId) {
}

@Override
@Transactional(rollbackFor = Exception.class)
public void deleteByUserIds(List<Long> userIds) {
baseMapper.lambdaUpdate().in(UserRoleDO::getUserId, userIds).remove();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ public void delete(List<Long> ids) {
.getNickname());
// 删除用户和角色关联
userRoleService.deleteByUserIds(ids);
// 删除历史密码
userPasswordHistoryService.deleteByUserIds(ids);
// 删除用户
super.delete(ids);
}
Expand Down

0 comments on commit f53d6b6

Please sign in to comment.