SPMS_API/SPMS.API/Controllers/NoticeController.cs

45 lines
1.8 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using SPMS.Application.DTOs.Notice;
using SPMS.Application.Interfaces;
using SPMS.Domain.Common;
namespace SPMS.API.Controllers;
[ApiController]
[Route("v1/in/public/notice")]
[ApiExplorerSettings(GroupName = "public")]
public class NoticeController : ControllerBase
{
private readonly INoticeService _noticeService;
public NoticeController(INoticeService noticeService)
{
_noticeService = noticeService;
}
[HttpPost("list")]
[SwaggerOperation(Summary = "공지사항 목록", Description = "활성화된 공지사항 목록을 페이징으로 조회합니다. 상단 고정 우선 정렬.")]
public async Task<IActionResult> GetListAsync([FromBody] NoticeListRequestDto request)
{
var serviceCode = Request.Headers["X-Service-Code"].FirstOrDefault();
if (string.IsNullOrWhiteSpace(serviceCode))
return BadRequest(ApiResponse.Fail(ErrorCodes.BadRequest, "X-Service-Code 헤더가 필요합니다."));
var result = await _noticeService.GetListAsync(serviceCode, request);
return Ok(ApiResponse<NoticeListResponseDto>.Success(result));
}
[HttpPost("info")]
[SwaggerOperation(Summary = "공지사항 상세", Description = "공지사항 ID로 상세 정보를 조회합니다.")]
public async Task<IActionResult> GetInfoAsync([FromBody] NoticeInfoRequestDto request)
{
var serviceCode = Request.Headers["X-Service-Code"].FirstOrDefault();
if (string.IsNullOrWhiteSpace(serviceCode))
return BadRequest(ApiResponse.Fail(ErrorCodes.BadRequest, "X-Service-Code 헤더가 필요합니다."));
var result = await _noticeService.GetInfoAsync(serviceCode, request);
return Ok(ApiResponse<NoticeInfoResponseDto>.Success(result));
}
}