using Dlhis.Sys.Identity.Request; using Dlhis.Sys.Identity.Response; using Dlhis.User.Identity.Services; using Kurisu.Core.DataAccess.Dto; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Dlhis.Sys.Identity.Controllers; /// /// 角色 /// [Authorize] [Route("api/[controller]")] [ApiController] public class RolesController : ControllerBase { private readonly IRoleService _roleService; public RolesController(IRoleService roleService) { _roleService = roleService; } /// /// 获取角色分页 /// /// /// [Authorize(Roles = "admin")] [HttpGet("page")] public async Task> GetPageAsync([FromQuery] RolePageRequest request) { return await _roleService.GetPageAsync(request); } /// /// 角色列表 /// /// [Authorize(Roles = "admin")] [HttpGet("list")] public async Task> GetListAsync() { return await _roleService.GetListAsync(); } /// /// 分配角色 /// /// /// [Authorize(Roles = "admin")] [HttpPost("assign")] public async Task AssignRole(AssignRoleRequest request) { await _roleService.AssignRoleAsync(request); } /// /// 保存角色 /// /// [Authorize(Roles = "admin")] [HttpPost("save")] public async Task SaveRole(RoleSaveRequest request) { await _roleService.SaveRoleAsync(request); } /// /// 移除角色 /// /// /// [Authorize(Roles = "admin")] [HttpPost("delete")] public async Task RemoveRole(RoleRemoveRequest request) { await _roleService.RemoveRoleAsync(request); } /// /// 我的角色 /// /// [HttpGet("my")] public async Task GetMyRoleAsync(int? userId) { return await _roleService.GetMyRoleAsync(userId); } }