From 9dcbdad7f1ed5a55e6c5a33c39077d96404c3f73 Mon Sep 17 00:00:00 2001 From: nixj Date: Tue, 18 Jun 2024 09:50:29 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90add=E3=80=91=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E8=A7=92=E8=89=B2=E5=88=86=E9=A1=B5=E6=8E=A5=E5=8F=A3=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dtos/system/RolePageDto.java | 7 +++---- .../application/dtos/system/RoleUserDto.java | 11 +++++++++++ .../domain/service/UserDomainService.java | 19 +++++++++++++------ 3 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/chint/application/dtos/system/RoleUserDto.java diff --git a/src/main/java/com/chint/application/dtos/system/RolePageDto.java b/src/main/java/com/chint/application/dtos/system/RolePageDto.java index 48edd241..86a600e8 100644 --- a/src/main/java/com/chint/application/dtos/system/RolePageDto.java +++ b/src/main/java/com/chint/application/dtos/system/RolePageDto.java @@ -2,13 +2,12 @@ package com.chint.application.dtos.system; import lombok.Data; +import java.util.List; + @Data public class RolePageDto { private String name; private String employeeNo; - private String roleName; private Long userId; - private Long roleId; - private Long roleUserId; - private String roleDesc; + List roleUserDtos; } diff --git a/src/main/java/com/chint/application/dtos/system/RoleUserDto.java b/src/main/java/com/chint/application/dtos/system/RoleUserDto.java new file mode 100644 index 00000000..dd54e987 --- /dev/null +++ b/src/main/java/com/chint/application/dtos/system/RoleUserDto.java @@ -0,0 +1,11 @@ +package com.chint.application.dtos.system; + +import lombok.Data; + +@Data +public class RoleUserDto { + private String roleName; + private Long roleId; + private Long roleUserId; + private String roleDesc; +} diff --git a/src/main/java/com/chint/domain/service/UserDomainService.java b/src/main/java/com/chint/domain/service/UserDomainService.java index 489380c3..52bfd504 100644 --- a/src/main/java/com/chint/domain/service/UserDomainService.java +++ b/src/main/java/com/chint/domain/service/UserDomainService.java @@ -2,6 +2,7 @@ package com.chint.domain.service; import com.chint.application.dtos.system.RolePageDto; import com.chint.application.dtos.system.RolePageQuery; +import com.chint.application.dtos.system.RoleUserDto; import com.chint.domain.aggregates.user.Role; import com.chint.domain.aggregates.user.RoleUser; import com.chint.domain.aggregates.user.User; @@ -54,13 +55,19 @@ public class UserDomainService { .filter(s -> s.getUserId().equals(temp.getUserId())) .toList(); if(!roleUser.isEmpty()){ - obj.setRoleId(roleUser.get(0).getRoleId()); - obj.setRoleUserId(roleUser.get(0).getId()); - List roleList=roles.stream().filter(s->s.getId().equals(obj.getRoleId())).toList(); - if(!roleList.isEmpty()){ - obj.setRoleName(roleList.get(0).getRoleName()); - obj.setRoleDesc(roleList.get(0).getRoleDesc()); + List roleUserDtos=new ArrayList<>(); + for(RoleUser roleUserObj : roleUser){ + RoleUserDto roleUserDto=new RoleUserDto(); + roleUserDto.setRoleId(roleUserObj.getRoleId()); + roleUserDto.setRoleUserId(roleUserObj.getId()); + List roleList=roles.stream().filter(s->s.getId().equals(roleUserDto.getRoleId())).toList(); + if(!roleList.isEmpty()){ + roleUserDto.setRoleName(roleList.get(0).getRoleName()); + roleUserDto.setRoleDesc(roleList.get(0).getRoleDesc()); + } + roleUserDtos.add(roleUserDto); } + obj.setRoleUserDtos(roleUserDtos); } return obj; }).toList();