Browse Source
Merge pull request #2985 from abpframework/maliming/allrole
Create an endpoint to query all roles.
pull/3156/head
Halil İbrahim Kalkan
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with
32 additions and
5 deletions
-
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IIdentityRoleAppService.cs
-
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityRoleAppService.cs
-
modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs
-
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/CreateModal.cshtml.cs
-
modules/identity/src/Volo.Abp.Identity.Web/Pages/Identity/Users/EditModal.cshtml.cs
-
modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs
|
|
@ -8,6 +8,8 @@ namespace Volo.Abp.Identity |
|
|
{ |
|
|
{ |
|
|
public interface IIdentityRoleAppService : IApplicationService |
|
|
public interface IIdentityRoleAppService : IApplicationService |
|
|
{ |
|
|
{ |
|
|
|
|
|
Task<ListResultDto<IdentityRoleDto>> GetAllListAsync(); |
|
|
|
|
|
|
|
|
Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input); |
|
|
Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input); |
|
|
|
|
|
|
|
|
Task<IdentityRoleDto> CreateAsync(IdentityRoleCreateDto input); |
|
|
Task<IdentityRoleDto> CreateAsync(IdentityRoleCreateDto input); |
|
|
|
|
|
@ -27,6 +27,13 @@ namespace Volo.Abp.Identity |
|
|
await _roleManager.GetByIdAsync(id)); |
|
|
await _roleManager.GetByIdAsync(id)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public virtual async Task<ListResultDto<IdentityRoleDto>> GetAllListAsync() |
|
|
|
|
|
{ |
|
|
|
|
|
var list = await _roleRepository.GetListAsync(); |
|
|
|
|
|
return new ListResultDto<IdentityRoleDto>( |
|
|
|
|
|
ObjectMapper.Map<List<IdentityRole>, List<IdentityRoleDto>>(list)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public virtual async Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input) |
|
|
public virtual async Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input) |
|
|
{ |
|
|
{ |
|
|
var list = await _roleRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount); |
|
|
var list = await _roleRepository.GetListAsync(input.Sorting, input.MaxResultCount, input.SkipCount); |
|
|
|
|
|
@ -1,4 +1,5 @@ |
|
|
using System; |
|
|
using System; |
|
|
|
|
|
using System.Collections.Generic; |
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
@ -19,6 +20,13 @@ namespace Volo.Abp.Identity |
|
|
_roleAppService = roleAppService; |
|
|
_roleAppService = roleAppService; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
|
|
|
[Route("all")] |
|
|
|
|
|
public virtual Task<ListResultDto<IdentityRoleDto>> GetAllListAsync() |
|
|
|
|
|
{ |
|
|
|
|
|
return _roleAppService.GetAllListAsync(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[HttpGet] |
|
|
[HttpGet] |
|
|
public virtual Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input) |
|
|
public virtual Task<PagedResultDto<IdentityRoleDto>> GetListAsync(PagedAndSortedResultRequestDto input) |
|
|
{ |
|
|
{ |
|
|
|
|
|
@ -29,9 +29,9 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users |
|
|
{ |
|
|
{ |
|
|
UserInfo = new UserInfoViewModel(); |
|
|
UserInfo = new UserInfoViewModel(); |
|
|
|
|
|
|
|
|
var roleDtoList = await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto()); |
|
|
var roleDtoList = (await _identityRoleAppService.GetAllListAsync()).Items; |
|
|
|
|
|
|
|
|
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>(roleDtoList.Items); |
|
|
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>(roleDtoList); |
|
|
|
|
|
|
|
|
foreach (var role in Roles) |
|
|
foreach (var role in Roles) |
|
|
{ |
|
|
{ |
|
|
|
|
|
@ -31,9 +31,7 @@ namespace Volo.Abp.Identity.Web.Pages.Identity.Users |
|
|
{ |
|
|
{ |
|
|
UserInfo = ObjectMapper.Map<IdentityUserDto, UserInfoViewModel>(await _identityUserAppService.GetAsync(id)); |
|
|
UserInfo = ObjectMapper.Map<IdentityUserDto, UserInfoViewModel>(await _identityUserAppService.GetAsync(id)); |
|
|
|
|
|
|
|
|
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>( |
|
|
Roles = ObjectMapper.Map<IReadOnlyList<IdentityRoleDto>, AssignedRoleViewModel[]>((await _identityRoleAppService.GetAllListAsync()).Items); |
|
|
(await _identityRoleAppService.GetListAsync(new PagedAndSortedResultRequestDto())).Items |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
var userRoleNames = (await _identityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList(); |
|
|
var userRoleNames = (await _identityUserAppService.GetRolesAsync(UserInfo.Id)).Items.Select(r => r.Name).ToList(); |
|
|
foreach (var role in Roles) |
|
|
foreach (var role in Roles) |
|
|
|
|
|
@ -34,6 +34,18 @@ namespace Volo.Abp.Identity |
|
|
result.Id.ShouldBe(moderator.Id); |
|
|
result.Id.ShouldBe(moderator.Id); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public async Task GetAllListAsync() |
|
|
|
|
|
{ |
|
|
|
|
|
//Act
|
|
|
|
|
|
|
|
|
|
|
|
var result = await _roleAppService.GetAllListAsync(); |
|
|
|
|
|
|
|
|
|
|
|
//Assert
|
|
|
|
|
|
|
|
|
|
|
|
result.Items.Count.ShouldBeGreaterThan(0); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
[Fact] |
|
|
[Fact] |
|
|
public async Task GetListAsync() |
|
|
public async Task GetListAsync() |
|
|
{ |
|
|
{ |
|
|
|