|
|
|
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(Name = IdentityRemoteServiceConsts.RemoteServiceName)]
|
|
|
|
[Area("identity")]
|
|
|
|
[ControllerName("organization-units")]
|
|
|
|
[Route("api/identity/organization-units")]
|
|
|
|
public class OrganizationUnitController : AbpController, IOrganizationUnitAppService
|
|
|
|
{
|
|
|
|
protected IOrganizationUnitAppService OrganizationUnitAppService { get; }
|
|
|
|
|
|
|
|
public OrganizationUnitController(IOrganizationUnitAppService organizationUnitAppService)
|
|
|
|
{
|
|
|
|
OrganizationUnitAppService = organizationUnitAppService;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建组织单位
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost]
|
|
|
|
public async virtual Task<OrganizationUnitDto> CreateAsync(OrganizationUnitCreateDto input)
|
|
|
|
{
|
|
|
|
return await OrganizationUnitAppService.CreateAsync(input);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 删除组织单位
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id">Id</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpDelete]
|
|
|
|
[Route("{id}")]
|
|
|
|
public async virtual Task DeleteAsync(Guid id)
|
|
|
|
{
|
|
|
|
await OrganizationUnitAppService.DeleteAsync(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 查找子单位
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
|
|
[Route("find-children")]
|
|
|
|
public async virtual Task<ListResultDto<OrganizationUnitDto>> FindChildrenAsync(OrganizationUnitGetChildrenDto input)
|
|
|
|
{
|
|
|
|
return await OrganizationUnitAppService.FindChildrenAsync(input);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取组织单位信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id">Id</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
|
|
[Route("{id}")]
|
|
|
|
public async virtual Task<OrganizationUnitDto> GetAsync(Guid id)
|
|
|
|
{
|
|
|
|
return await OrganizationUnitAppService.GetAsync(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取根组织单位
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
|
|
[Route("root-node")]
|
|
|
|
public async virtual Task<ListResultDto<OrganizationUnitDto>> GetRootAsync()
|
|
|
|
{
|
|
|
|
return await OrganizationUnitAppService.GetRootAsync();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 最后一个组织节点
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="parentId">父Id</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
|
|
[Route("last-children")]
|
|
|
|
public async virtual Task<OrganizationUnitDto> GetLastChildOrNullAsync(Guid? parentId)
|
|
|
|
{
|
|
|
|
return await OrganizationUnitAppService.GetLastChildOrNullAsync(parentId);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取所有组织单位
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
|
|
[Route("all")]
|
|
|
|
public async virtual Task<ListResultDto<OrganizationUnitDto>> GetAllListAsync()
|
|
|
|
{
|
|
|
|
return await OrganizationUnitAppService.GetAllListAsync();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 分页获取
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
|
|
public async virtual Task<PagedResultDto<OrganizationUnitDto>> GetListAsync(OrganizationUnitGetByPagedDto input)
|
|
|
|
{
|
|
|
|
return await OrganizationUnitAppService.GetListAsync(input);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取该组织单位所有角色名称
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id">Id</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
|
|
[Route("{id}/role-names")]
|
|
|
|
public async virtual Task<ListResultDto<string>> GetRoleNamesAsync(Guid id)
|
|
|
|
{
|
|
|
|
return await OrganizationUnitAppService.GetRoleNamesAsync(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 分页获取未添加的角色
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
|
|
[Route("{id}/unadded-roles")]
|
|
|
|
public async virtual Task<PagedResultDto<IdentityRoleDto>> GetUnaddedRolesAsync(Guid id, OrganizationUnitGetUnaddedRoleByPagedDto input)
|
|
|
|
{
|
|
|
|
return await OrganizationUnitAppService.GetUnaddedRolesAsync(id, input);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 分页获取组织单位角色
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
|
|
[Route("{id}/roles")]
|
|
|
|
public async virtual Task<PagedResultDto<IdentityRoleDto>> GetRolesAsync(Guid id, PagedAndSortedResultRequestDto input)
|
|
|
|
{
|
|
|
|
return await OrganizationUnitAppService.GetRolesAsync(id, input);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 分页获取未添加的用户
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
|
|
[Route("{id}/unadded-users")]
|
|
|
|
public async virtual Task<PagedResultDto<IdentityUserDto>> GetUnaddedUsersAsync(Guid id, OrganizationUnitGetUnaddedUserByPagedDto input)
|
|
|
|
{
|
|
|
|
return await OrganizationUnitAppService.GetUnaddedUsersAsync(id, input);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 分页获取组织单位下用户
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id">Id</param>
|
|
|
|
/// <param name="input">分页参数</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet]
|
|
|
|
[Route("{id}/users")]
|
|
|
|
public async virtual Task<PagedResultDto<IdentityUserDto>> GetUsersAsync(Guid id, GetIdentityUsersInput input)
|
|
|
|
{
|
|
|
|
return await OrganizationUnitAppService.GetUsersAsync(id, input);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 指定组织单位下添加用户
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost]
|
|
|
|
[Route("{id}/users")]
|
|
|
|
public async virtual Task AddUsersAsync(Guid id, OrganizationUnitAddUserDto input)
|
|
|
|
{
|
|
|
|
await OrganizationUnitAppService.AddUsersAsync(id, input);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 指定组织单位下添加角色
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost]
|
|
|
|
[Route("{id}/roles")]
|
|
|
|
public async virtual Task AddRolesAsync(Guid id, OrganizationUnitAddRoleDto input)
|
|
|
|
{
|
|
|
|
await OrganizationUnitAppService.AddRolesAsync(id, input);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 移动
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id"></param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPut]
|
|
|
|
[Route("{id}/move")]
|
|
|
|
public async virtual Task MoveAsync(Guid id, OrganizationUnitMoveDto input)
|
|
|
|
{
|
|
|
|
await OrganizationUnitAppService.MoveAsync(id, input);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 修改组织单位信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id">Id</param>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPut]
|
|
|
|
[Route("{id}")]
|
|
|
|
public async virtual Task<OrganizationUnitDto> UpdateAsync(Guid id, OrganizationUnitUpdateDto input)
|
|
|
|
{
|
|
|
|
return await OrganizationUnitAppService.UpdateAsync(id, input);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|