39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using BrokerApiCore;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
|
|
namespace BrokerApiServer.Controllers;
|
|
|
|
[Route("api/v1/planet")]
|
|
[ApiController, SwaggerTag("플래닛의 인증 처리")]
|
|
// 플래닛 인증 컨트롤러
|
|
public class PlanetController : ControllerBase
|
|
{
|
|
private readonly PlanetService m_planet_service;
|
|
|
|
public PlanetController(PlanetService planetService)
|
|
{
|
|
m_planet_service = planetService;
|
|
}
|
|
|
|
[HttpPost("auth")]
|
|
[Produces("application/json")]
|
|
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(PlanetAuthResponse))]
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest, Type = typeof(ApiErrorResponse))]
|
|
[SwaggerOperation(Summary = "플래닛 서비스 인증")]
|
|
public async Task<IActionResult> auth(
|
|
[FromBody, SwaggerRequestBody(nameof(PlanetAuthRequest))]
|
|
PlanetAuthRequest request)
|
|
{
|
|
Guard.Against.isNull(request, ServerErrorCode.InvalidRequest, ()=>"invalid request");
|
|
Guard.Against.isNullOrEmptyOrWhiteSpace(request.PlanetId, ServerErrorCode.InvalidRequest,
|
|
()=>"planet id is required");
|
|
Guard.Against.isNullOrEmptyOrWhiteSpace(request.PlanetSecretKey, ServerErrorCode.InvalidRequest,
|
|
()=>"planet access key is required");
|
|
|
|
var access_token = await m_planet_service.auth(request.PlanetId, request.PlanetSecretKey);
|
|
Guard.Against.isNull(access_token, ServerErrorCode.InternalServerError, ()=>"access_token create failed");
|
|
return Ok(new PlanetAuthResponse { AccessToken = access_token });
|
|
}
|
|
}
|