namespace Fengling.Console.Controllers;
///
/// OAuth客户端管理控制器
///
[ApiController]
[Route("api/console/[controller]")]
[Authorize(AuthenticationSchemes = OpenIddictValidationAspNetCoreDefaults.AuthenticationScheme)]
public class OAuthClientsController : ControllerBase
{
private readonly IOAuthClientService _service;
private readonly ILogger _logger;
public OAuthClientsController(
IOAuthClientService service,
ILogger logger)
{
_service = service;
_logger = logger;
}
///
/// 获取OAuth客户端列表
///
/// 分页查询参数,支持按显示名称、客户端ID和状态筛选
/// 分页的OAuth客户端列表,包含总数量、分页信息和客户端详情
/// 成功返回OAuth客户端分页列表
/// 服务器内部错误
[HttpGet]
[Produces("application/json")]
[ProducesResponseType(typeof(OAuthClientListDto), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(object), StatusCodes.Status500InternalServerError)]
public async Task> GetClients([FromQuery] OAuthClientQueryDto query)
{
try
{
var (items, totalCount) = await _service.GetClientsAsync(query.Page, query.PageSize, query.DisplayName, query.ClientId, query.Status);
var result = new OAuthClientListDto
{
Items = items.ToList(),
TotalCount = totalCount,
Page = query.Page,
PageSize = query.PageSize
};
return Ok(result);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error getting clients");
return StatusCode(500, new { message = ex.Message });
}
}
///
/// 获取OAuth客户端选项
///
/// 包含客户端类型、授权类型、授权范围等可选值的配置选项
/// 成功返回客户端配置选项
[HttpGet("options")]
[Produces("application/json")]
[ProducesResponseType(typeof(object), StatusCodes.Status200OK)]
public ActionResult