【fix】修复根据用户ID添加角色权限会添加相同角色的问题
This commit is contained in:
parent
9dcbdad7f1
commit
5fff0d28c0
|
@ -116,6 +116,14 @@ public class UserController {
|
|||
@ApiOperation("根据用户ID添加角色权限")
|
||||
@PostMapping("/add/role")
|
||||
public Result<String> addRoleUser(@RequestBody RoleOrgParam roleOrgParam) {
|
||||
//查询已有权限
|
||||
List<RoleUser> exist=roleUserRepository.findByUserId(roleOrgParam.getUserId());
|
||||
List<Long> 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()
|
||||
|
|
Loading…
Reference in New Issue