|
-
- //
-
-
-
-
-
-
-
-
- namespace SafeCampus.Web.Core;
-
- /// <summary>
- /// 角色管理控制器
- /// </summary>
- [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;
- }
-
- /// <summary>
- /// 角色分页查询
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpGet("page")]
- public async Task<dynamic> Page([FromQuery] RolePageInput input)
- {
- return await _sysRoleService.Page(input);
- }
-
- /// <summary>
- /// 添加角色
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost("add")]
- [DisplayName("添加角色")]
- public async Task Add([FromBody] RoleAddInput input)
- {
- await _sysRoleService.Add(input);
- }
-
- /// <summary>
- /// 修改角色
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost("edit")]
- [DisplayName("修改角色")]
- public async Task Edit([FromBody] RoleEditInput input)
- {
- await _sysRoleService.Edit(input);
- }
-
- /// <summary>
- /// 删除角色
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost("delete")]
- [DisplayName("删除角色")]
- public async Task Delete([FromBody] BaseIdListInput input)
- {
- await _sysRoleService.Delete(input);
- }
-
- /// <summary>
- /// 获取角色授权资源树
- /// </summary>
- /// <returns></returns>
- [HttpGet("resourceTreeSelector")]
- public async Task<dynamic> ResourceTreeSelector()
- {
- return await _resourceService.ResourceTreeSelector();
- }
-
- /// <summary>
- /// 获取角色拥有资源
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpGet("ownResource")]
- public async Task<dynamic> OwnResource([FromQuery] BaseIdInput input)
- {
- return await _sysRoleService.OwnResource(input, CateGoryConst.RELATION_SYS_ROLE_HAS_RESOURCE);
- }
-
- /// <summary>
- /// 给角色授权资源
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost("grantResource")]
- [DisplayName("角色授权资源")]
- public async Task GrantResource([FromBody] GrantResourceInput input)
- {
- await _sysRoleService.GrantResource(input);
- }
-
- /// <summary>
- /// 获取权限授权树
- /// </summary>
- /// <returns></returns>
- [HttpGet("permissionTreeSelector")]
- public async Task<dynamic> PermissionTreeSelector([FromQuery] BaseIdInput input)
- {
- return await _sysRoleService.RolePermissionTreeSelector(input);
- }
-
- /// <summary>
- /// 获取角色拥有权限
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpGet("ownPermission")]
- public async Task<dynamic> OwnPermission([FromQuery] BaseIdInput input)
- {
- return await _sysRoleService.OwnPermission(input);
- }
-
- /// <summary>
- /// 给角色授权权限
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost("grantPermission")]
- [DisplayName("角色授权权限")]
- public async Task GrantPermission([FromBody] GrantPermissionInput input)
- {
- await _sysRoleService.GrantPermission(input);
- }
-
-
- /// <summary>
- /// 获取角色下的用户
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpGet("ownUser")]
- public async Task<dynamic> OwnUser([FromQuery] BaseIdInput input)
- {
- return await _sysRoleService.OwnUser(input);
- }
-
- /// <summary>
- /// 给角色授权用户
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost("grantUser")]
- [DisplayName("角色授权")]
- public async Task GrantUser([FromBody] GrantUserInput input)
- {
- await _sysRoleService.GrantUser(input);
- }
-
- /// <summary>
- /// 获取角色树
- /// </summary>
- /// <returns></returns>
- [HttpGet("tree")]
- [DisplayName("获取角色树")]
- public async Task<dynamic> Tree([FromQuery] RoleTreeInput input)
- {
- return await _sysRoleService.Tree(input);
- }
-
-
- /// <summary>
- /// 获取角色详情
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpGet("detail")]
- public async Task<dynamic> Detail([FromQuery] BaseIdInput input)
- {
- return await _sysRoleService.Detail(input);
- }
-
- /// <summary>
- /// 获取角色选择器
- /// </summary>
- /// <returns></returns>
- [HttpGet("roleSelector")]
- public async Task<dynamic> RoleSelector([FromQuery] RoleSelectorInput input)
- {
- return await _sysRoleService.RoleSelector(input);
- }
- }
|