新增获取角色列表接口
This commit is contained in:
commit
dfee6cbc66
@ -1,5 +1,6 @@
|
|||||||
using Apimanager_backend.Dtos;
|
using Apimanager_backend.Dtos;
|
||||||
using Apimanager_backend.Exceptions;
|
using Apimanager_backend.Exceptions;
|
||||||
|
using Apimanager_backend.Models;
|
||||||
using Apimanager_backend.Services;
|
using Apimanager_backend.Services;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
@ -145,5 +146,15 @@ namespace Apimanager_backend.Controllers
|
|||||||
return Ok(res);
|
return Ok(res);
|
||||||
}
|
}
|
||||||
#endregion
|
#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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,5 +114,11 @@ namespace Apimanager_backend.Services
|
|||||||
return await context.Users.CountAsync();
|
return await context.Users.CountAsync();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
#region 获取角色列表
|
||||||
|
public async Task<List<UserRole>> GetRolesAsync()
|
||||||
|
{
|
||||||
|
return await context.UserRoles.Where(x => true).Take(10).ToListAsync();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Apimanager_backend.Dtos;
|
using Apimanager_backend.Dtos;
|
||||||
|
using Apimanager_backend.Models;
|
||||||
|
|
||||||
namespace Apimanager_backend.Services
|
namespace Apimanager_backend.Services
|
||||||
{
|
{
|
||||||
@ -46,5 +47,10 @@ namespace Apimanager_backend.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<int> UserCountAsync();
|
Task<int> UserCountAsync();
|
||||||
|
/// <summary>
|
||||||
|
/// 获取角色列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<UserRole>> GetRolesAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user