From 5fff0d28c008772f8ff328a0ede29da5208f88bf Mon Sep 17 00:00:00 2001 From: nixj Date: Tue, 18 Jun 2024 10:05:57 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90fix=E3=80=91=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=94=A8=E6=88=B7ID=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E6=9D=83=E9=99=90=E4=BC=9A=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E8=A7=92=E8=89=B2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/chint/application/system/UserController.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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()