refactor:优化角色授权查询
This commit is contained in:
@@ -132,9 +132,21 @@ namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
[Route("/api/role/auth-user/{roleId}/{isAllocated}")]
|
||||
public async Task<PagedResultDto<UserGetListOutputDto>> GetAuthUserByRoleIdAsync([FromRoute] long roleId, [FromRoute] bool isAllocated, [FromQuery] RoleAuthUserGetListInput input)
|
||||
{
|
||||
|
||||
PagedResultDto<UserGetListOutputDto> output;
|
||||
//角色下已授权用户
|
||||
if (isAllocated == true)
|
||||
{
|
||||
output = await GetAllocatedAuthUserByRoleIdAsync(roleId, input);
|
||||
}
|
||||
//角色下未授权用户
|
||||
else
|
||||
{
|
||||
output = await GetNotAllocatedAuthUserByRoleIdAsync(roleId, input);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
private async Task<PagedResultDto<UserGetListOutputDto>> GetAllocatedAuthUserByRoleIdAsync(long roleId, RoleAuthUserGetListInput input)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
var output = await _userRoleRepository._DbQueryable
|
||||
@@ -146,8 +158,8 @@ namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
.ToPageListAsync(input.PageNum, input.PageSize, total);
|
||||
return new PagedResultDto<UserGetListOutputDto>(total, output);
|
||||
}
|
||||
//角色下未授权用户
|
||||
else
|
||||
|
||||
private async Task<PagedResultDto<UserGetListOutputDto>> GetNotAllocatedAuthUserByRoleIdAsync(long roleId, RoleAuthUserGetListInput input)
|
||||
{
|
||||
RefAsync<int> total = 0;
|
||||
var entities = await _userRoleRepository._Db.Queryable<UserEntity>()
|
||||
@@ -158,9 +170,6 @@ namespace Yi.Furion.Application.Rbac.Services.Impl
|
||||
var output = entities.Adapt<List<UserGetListOutputDto>>();
|
||||
return new PagedResultDto<UserGetListOutputDto>(total, output);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user