You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
3.7 KiB
124 lines
3.7 KiB
using Microsoft.AspNetCore.Mvc; |
|
using Sanhe.Abp.Identity.Dto; |
|
using System; |
|
using System.Threading.Tasks; |
|
using Volo.Abp; |
|
using Volo.Abp.Application.Dtos; |
|
using Volo.Abp.AspNetCore.Mvc; |
|
using Volo.Abp.Identity; |
|
|
|
namespace Sanhe.Abp.Identity |
|
{ |
|
/// <summary> |
|
/// 角色 |
|
/// </summary> |
|
[RemoteService(true, Name = IdentityRemoteServiceConsts.RemoteServiceName)] |
|
[Area("identity")] |
|
[ControllerName("Role")] |
|
[Route("api/identity/roles")] |
|
public class IdentityRoleController : AbpController, IIdentityRoleAppService |
|
{ |
|
protected IIdentityRoleAppService RoleAppService { get; } |
|
|
|
public IdentityRoleController(IIdentityRoleAppService roleAppService) |
|
{ |
|
RoleAppService = roleAppService; |
|
} |
|
|
|
#region OrganizationUnit |
|
|
|
/// <summary> |
|
/// 获取角色组织单元 |
|
/// </summary> |
|
/// <param name="id"></param> |
|
/// <returns></returns> |
|
[HttpGet] |
|
[Route("{id}/organization-units")] |
|
public async virtual Task<ListResultDto<OrganizationUnitDto>> GetOrganizationUnitsAsync(Guid id) |
|
{ |
|
return await RoleAppService.GetOrganizationUnitsAsync(id); |
|
} |
|
|
|
/// <summary> |
|
/// 修改角色组织单元 |
|
/// </summary> |
|
/// <param name="id"></param> |
|
/// <param name="input"></param> |
|
/// <returns></returns> |
|
[HttpPut] |
|
[Route("{id}/organization-units")] |
|
public async virtual Task SetOrganizationUnitsAsync(Guid id, IdentityRoleAddOrRemoveOrganizationUnitDto input) |
|
{ |
|
await RoleAppService.SetOrganizationUnitsAsync(id, input); |
|
} |
|
|
|
/// <summary> |
|
/// 删除角色组织单元 |
|
/// </summary> |
|
/// <param name="id"></param> |
|
/// <param name="ouId"></param> |
|
/// <returns></returns> |
|
[HttpDelete] |
|
[Route("{id}/organization-units/{ouId}")] |
|
public async virtual Task RemoveOrganizationUnitsAsync(Guid id, Guid ouId) |
|
{ |
|
await RoleAppService.RemoveOrganizationUnitsAsync(id, ouId); |
|
} |
|
|
|
#endregion |
|
|
|
#region Claim |
|
|
|
/// <summary> |
|
/// 获取角色身份声明 |
|
/// </summary> |
|
/// <param name="id"></param> |
|
/// <returns></returns> |
|
[HttpGet] |
|
[Route("{id}/claims")] |
|
public async virtual Task<ListResultDto<IdentityClaimDto>> GetClaimsAsync(Guid id) |
|
{ |
|
return await RoleAppService.GetClaimsAsync(id); |
|
} |
|
|
|
/// <summary> |
|
/// 创建角色身份声明 |
|
/// </summary> |
|
/// <param name="id"></param> |
|
/// <param name="input"></param> |
|
/// <returns></returns> |
|
[HttpPost] |
|
[Route("{id}/claims")] |
|
public async virtual Task AddClaimAsync(Guid id, IdentityRoleClaimCreateDto input) |
|
{ |
|
await RoleAppService.AddClaimAsync(id, input); |
|
} |
|
|
|
/// <summary> |
|
/// 修改角色身份声明 |
|
/// </summary> |
|
/// <param name="id"></param> |
|
/// <param name="input"></param> |
|
/// <returns></returns> |
|
[HttpPut] |
|
[Route("{id}/claims")] |
|
public async virtual Task UpdateClaimAsync(Guid id, IdentityRoleClaimUpdateDto input) |
|
{ |
|
await RoleAppService.UpdateClaimAsync(id, input); |
|
} |
|
|
|
/// <summary> |
|
/// 删除角色身份声明 |
|
/// </summary> |
|
/// <param name="id"></param> |
|
/// <param name="input"></param> |
|
/// <returns></returns> |
|
[HttpDelete] |
|
[Route("{id}/claims")] |
|
public async virtual Task DeleteClaimAsync(Guid id, IdentityRoleClaimDeleteDto input) |
|
{ |
|
await RoleAppService.DeleteClaimAsync(id, input); |
|
} |
|
#endregion |
|
} |
|
}
|
|
|