SPMS_API/SPMS.API/Controllers/MessageController.cs
SEAN ce7b8b3d35 feat: 메시지 유효성 검사 서비스 구현 (#118)
- MessageValidationService: title/body/image_url/link_url/link_type/data 검증
- POST /v1/in/message/validate 엔드포인트 추가
- MessageController 기반 구성

Closes #118
2026-02-10 17:15:57 +09:00

37 lines
1.2 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using SPMS.Application.DTOs.Message;
using SPMS.Application.Interfaces;
using SPMS.Domain.Common;
namespace SPMS.API.Controllers;
[ApiController]
[Route("v1/in/message")]
[ApiExplorerSettings(GroupName = "message")]
public class MessageController : ControllerBase
{
private readonly IMessageValidationService _validationService;
public MessageController(IMessageValidationService validationService)
{
_validationService = validationService;
}
[HttpPost("validate")]
[SwaggerOperation(Summary = "메시지 유효성 검사", Description = "메시지 내용의 유효성을 검사합니다.")]
public IActionResult ValidateAsync([FromBody] MessageValidateRequestDto request)
{
var result = _validationService.Validate(request);
return Ok(ApiResponse<MessageValidationResultDto>.Success(result));
}
private long GetServiceId()
{
if (HttpContext.Items.TryGetValue("ServiceId", out var serviceIdObj) && serviceIdObj is long serviceId)
return serviceId;
throw new Domain.Exceptions.SpmsException(ErrorCodes.BadRequest, "서비스 식별 정보가 없습니다.", 400);
}
}