feat: 新增用户批量删除接口
This commit is contained in:
parent
287b2eab6f
commit
18fcc8fbc5
|
@ -71,6 +71,15 @@ public class UserController {
|
|||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-list")
|
||||
@Parameter(name = "ids", description = "编号列表", required = true)
|
||||
@Operation(summary = "批量删除用户")
|
||||
@PreAuthorize("@ss.hasPermission('system:user:delete')")
|
||||
public CommonResult<Boolean> deleteUserList(@RequestParam("ids") List<Long> ids) {
|
||||
userService.deleteUserList(ids);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/update-password")
|
||||
@Operation(summary = "重置用户密码")
|
||||
@PreAuthorize("@ss.hasPermission('system:user:update-password')")
|
||||
|
|
|
@ -95,6 +95,13 @@ public interface AdminUserService {
|
|||
*/
|
||||
void deleteUser(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除用户
|
||||
*
|
||||
* @param ids 用户编号数组
|
||||
*/
|
||||
void deleteUserList(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
|
|
|
@ -248,6 +248,28 @@ public class AdminUserServiceImpl implements AdminUserService {
|
|||
LogRecordContext.putVariable("user", user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteUserList(List<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return;
|
||||
}
|
||||
// 1. 校验用户存在
|
||||
List<AdminUserDO> users = userMapper.selectByIds(ids);
|
||||
if (CollUtil.isEmpty(users)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 批量删除用户
|
||||
userMapper.deleteByIds(ids);
|
||||
|
||||
// 3. 批量删除用户关联数据
|
||||
ids.forEach(id -> {
|
||||
permissionService.processUserDeleted(id);
|
||||
userPostMapper.deleteByUserId(id);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdminUserDO getUserByUsername(String username) {
|
||||
return userMapper.selectByUsername(username);
|
||||
|
|
Loading…
Reference in New Issue