//
namespace SafeCampus.Web.Core;
///
/// 角色管理控制器
///
[ApiDescriptionSettings(Tag = "角色管理")]
[Route("sys/limit/[controller]")]
[SuperAdmin]
public class RoleController : BaseController
{
private readonly ISysRoleService _sysRoleService;
private readonly IResourceService _resourceService;
public RoleController(ISysRoleService sysRoleService, IResourceService resourceService)
{
_sysRoleService = sysRoleService;
_resourceService = resourceService;
}
///
/// 角色分页查询
///
///
///
[HttpGet("page")]
public async Task Page([FromQuery] RolePageInput input)
{
return await _sysRoleService.Page(input);
}
///
/// 添加角色
///
///
///
[HttpPost("add")]
[DisplayName("添加角色")]
public async Task Add([FromBody] RoleAddInput input)
{
await _sysRoleService.Add(input);
}
///
/// 修改角色
///
///
///
[HttpPost("edit")]
[DisplayName("修改角色")]
public async Task Edit([FromBody] RoleEditInput input)
{
await _sysRoleService.Edit(input);
}
///
/// 删除角色
///
///
///
[HttpPost("delete")]
[DisplayName("删除角色")]
public async Task Delete([FromBody] BaseIdListInput input)
{
await _sysRoleService.Delete(input);
}
///
/// 获取角色授权资源树
///
///
[HttpGet("resourceTreeSelector")]
public async Task ResourceTreeSelector()
{
return await _resourceService.ResourceTreeSelector();
}
///
/// 获取角色拥有资源
///
///
///
[HttpGet("ownResource")]
public async Task OwnResource([FromQuery] BaseIdInput input)
{
return await _sysRoleService.OwnResource(input, CateGoryConst.RELATION_SYS_ROLE_HAS_RESOURCE);
}
///
/// 给角色授权资源
///
///
///
[HttpPost("grantResource")]
[DisplayName("角色授权资源")]
public async Task GrantResource([FromBody] GrantResourceInput input)
{
await _sysRoleService.GrantResource(input);
}
///
/// 获取权限授权树
///
///
[HttpGet("permissionTreeSelector")]
public async Task PermissionTreeSelector([FromQuery] BaseIdInput input)
{
return await _sysRoleService.RolePermissionTreeSelector(input);
}
///
/// 获取角色拥有权限
///
///
///
[HttpGet("ownPermission")]
public async Task OwnPermission([FromQuery] BaseIdInput input)
{
return await _sysRoleService.OwnPermission(input);
}
///
/// 给角色授权权限
///
///
///
[HttpPost("grantPermission")]
[DisplayName("角色授权权限")]
public async Task GrantPermission([FromBody] GrantPermissionInput input)
{
await _sysRoleService.GrantPermission(input);
}
///
/// 获取角色下的用户
///
///
///
[HttpGet("ownUser")]
public async Task OwnUser([FromQuery] BaseIdInput input)
{
return await _sysRoleService.OwnUser(input);
}
///
/// 给角色授权用户
///
///
///
[HttpPost("grantUser")]
[DisplayName("角色授权")]
public async Task GrantUser([FromBody] GrantUserInput input)
{
await _sysRoleService.GrantUser(input);
}
///
/// 获取角色树
///
///
[HttpGet("tree")]
[DisplayName("获取角色树")]
public async Task Tree([FromQuery] RoleTreeInput input)
{
return await _sysRoleService.Tree(input);
}
///
/// 获取角色详情
///
///
///
[HttpGet("detail")]
public async Task Detail([FromQuery] BaseIdInput input)
{
return await _sysRoleService.Detail(input);
}
///
/// 获取角色选择器
///
///
[HttpGet("roleSelector")]
public async Task RoleSelector([FromQuery] RoleSelectorInput input)
{
return await _sysRoleService.RoleSelector(input);
}
}