48 lines
1.5 KiB
C#
48 lines
1.5 KiB
C#
using Bitget_Server.Application.Services;
|
|
using Bitget_Server.Domain.Models;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Bitget_Server.Api.Controllers;
|
|
|
|
/// <summary>
|
|
/// 기존 WinForms 코인 선택 그리드 데이터를 REST 화.
|
|
/// </summary>
|
|
[ApiController]
|
|
[Route("api/coins")]
|
|
[Produces("application/json")]
|
|
public class CoinsController : ControllerBase
|
|
{
|
|
private readonly SettingsService _settings;
|
|
private readonly ILogger<CoinsController> _logger;
|
|
|
|
public CoinsController(SettingsService settings, ILogger<CoinsController> logger)
|
|
{
|
|
_settings = settings;
|
|
_logger = logger;
|
|
}
|
|
|
|
/// <summary>
|
|
/// USDT 기준 Bitget 선물 마켓 정보 목록을 반환한다.
|
|
/// 내부적으로 BitgetClient 캐시(_state.marketInfoList)를 우선 사용하고 비어 있으면 호출.
|
|
/// </summary>
|
|
[HttpGet]
|
|
[ProducesResponseType(typeof(IEnumerable<MarketInfo>), StatusCodes.Status200OK)]
|
|
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status502BadGateway)]
|
|
public async Task<ActionResult<IEnumerable<MarketInfo>>> GetCoins(CancellationToken ct)
|
|
{
|
|
try
|
|
{
|
|
var coins = await _settings.GetCoinsAsync(ct);
|
|
return Ok(coins);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "코인 조회 실패");
|
|
return Problem(
|
|
detail: ex.Message,
|
|
statusCode: StatusCodes.Status502BadGateway,
|
|
title: "Failed to fetch coins from Bitget");
|
|
}
|
|
}
|
|
}
|