新增获取角色列表接口

This commit is contained in:
南浔
2024-12-09 09:58:28 +08:00
3 changed files with 23 additions and 0 deletions
@@ -1,5 +1,6 @@
using Apimanager_backend.Dtos;
using Apimanager_backend.Exceptions;
using Apimanager_backend.Models;
using Apimanager_backend.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
@@ -145,5 +146,15 @@ namespace Apimanager_backend.Controllers
return Ok(res);
}
#endregion
#region
[HttpGet]
[Authorize(Roles = "Admin")]
public async Task<ActionResult<ResponseBase<List<UserRole>>>> GetRoles()
{
var userRoles = await adminService.GetRolesAsync();
var res = new ResponseBase<List<UserRole>>(userRoles);
return Ok(res);
}
#endregion
}
}