diff --git a/src/main/java/com/chint/application/system/UserController.java b/src/main/java/com/chint/application/system/UserController.java index 97698a4c..e405e7fa 100644 --- a/src/main/java/com/chint/application/system/UserController.java +++ b/src/main/java/com/chint/application/system/UserController.java @@ -116,6 +116,14 @@ public class UserController { @ApiOperation("根据用户ID添加角色权限") @PostMapping("/add/role") public Result addRoleUser(@RequestBody RoleOrgParam roleOrgParam) { + //查询已有权限 + List exist=roleUserRepository.findByUserId(roleOrgParam.getUserId()); + List roleIdList=roleOrgParam.getRoleIdList(); + roleIdList.removeAll(exist.stream().map(RoleUser::getRoleId).toList()); + if (roleIdList.isEmpty()) { + return Result.Success(); + } + roleOrgParam.setRoleIdList(roleIdList); roleOrgParam.getRoleIdList().stream() .map(it -> RoleUser.of(roleOrgParam.getUserId(), it)) .toList()