- POST /v1/in/push/send (단건 발송) - POST /v1/in/push/send/tag (태그 발송) - PushService: 메시지 조회 → 변수 치환 → RabbitMQ 큐 발행 - MessageNotFound(151) 에러 코드 추가 Closes #114
47 lines
1.7 KiB
C#
47 lines
1.7 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Swashbuckle.AspNetCore.Annotations;
|
|
using SPMS.Application.DTOs.Push;
|
|
using SPMS.Application.Interfaces;
|
|
using SPMS.Domain.Common;
|
|
|
|
namespace SPMS.API.Controllers;
|
|
|
|
[ApiController]
|
|
[Route("v1/in/push")]
|
|
[ApiExplorerSettings(GroupName = "push")]
|
|
public class PushController : ControllerBase
|
|
{
|
|
private readonly IPushService _pushService;
|
|
|
|
public PushController(IPushService pushService)
|
|
{
|
|
_pushService = pushService;
|
|
}
|
|
|
|
[HttpPost("send")]
|
|
[SwaggerOperation(Summary = "단건 발송", Description = "특정 디바이스에 푸시 메시지를 즉시 발송합니다.")]
|
|
public async Task<IActionResult> SendAsync([FromBody] PushSendRequestDto request)
|
|
{
|
|
var serviceId = GetServiceId();
|
|
var result = await _pushService.SendAsync(serviceId, request);
|
|
return Ok(ApiResponse<PushSendResponseDto>.Success(result));
|
|
}
|
|
|
|
[HttpPost("send/tag")]
|
|
[SwaggerOperation(Summary = "태그 발송", Description = "태그 조건에 해당하는 디바이스에 푸시 메시지를 발송합니다.")]
|
|
public async Task<IActionResult> SendByTagAsync([FromBody] PushSendTagRequestDto request)
|
|
{
|
|
var serviceId = GetServiceId();
|
|
var result = await _pushService.SendByTagAsync(serviceId, request);
|
|
return Ok(ApiResponse<PushSendResponseDto>.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);
|
|
}
|
|
}
|