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();