【add】用户角色分页接口返回格式修改

This commit is contained in:
nixj 2024-06-18 09:50:29 +08:00
parent bb280237d9
commit 9dcbdad7f1
3 changed files with 27 additions and 10 deletions

View File

@ -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<RoleUserDto> roleUserDtos;
}

View File

@ -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;
}

View File

@ -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<Role> roleList=roles.stream().filter(s->s.getId().equals(obj.getRoleId())).toList();
List<RoleUserDto> roleUserDtos=new ArrayList<>();
for(RoleUser roleUserObj : roleUser){
RoleUserDto roleUserDto=new RoleUserDto();
roleUserDto.setRoleId(roleUserObj.getRoleId());
roleUserDto.setRoleUserId(roleUserObj.getId());
List<Role> roleList=roles.stream().filter(s->s.getId().equals(roleUserDto.getRoleId())).toList();
if(!roleList.isEmpty()){
obj.setRoleName(roleList.get(0).getRoleName());
obj.setRoleDesc(roleList.get(0).getRoleDesc());
roleUserDto.setRoleName(roleList.get(0).getRoleName());
roleUserDto.setRoleDesc(roleList.get(0).getRoleDesc());
}
roleUserDtos.add(roleUserDto);
}
obj.setRoleUserDtos(roleUserDtos);
}
return obj;
}).toList();