68 lines
2.2 KiB
C#
68 lines
2.2 KiB
C#
using AdsManagerService.API.Application.Commands;
|
|
using MediatR;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace AdsManagerService.API.Controllers;
|
|
|
|
/// <summary>
|
|
/// EN: API Controller for managing individual ads.
|
|
/// VI: API Controller quản lý quảng cáo.
|
|
/// </summary>
|
|
[ApiController]
|
|
[Route("api/v1/ads-manager/ads")]
|
|
[Produces("application/json")]
|
|
public class AdsController : ControllerBase
|
|
{
|
|
private readonly IMediator _mediator;
|
|
private readonly ILogger<AdsController> _logger;
|
|
|
|
public AdsController(IMediator mediator, ILogger<AdsController> logger)
|
|
{
|
|
_mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));
|
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
|
}
|
|
|
|
/// <summary>
|
|
/// EN: Create a new ad.
|
|
/// VI: Tạo quảng cáo mới.
|
|
/// </summary>
|
|
[HttpPost]
|
|
[ProducesResponseType(StatusCodes.Status201Created)]
|
|
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
|
public async Task<ActionResult<Guid>> CreateAd([FromBody] CreateAdCommand command)
|
|
{
|
|
_logger.LogInformation("Creating ad for ad set {AdSetId}", command.AdSetId);
|
|
|
|
var adId = await _mediator.Send(command);
|
|
|
|
return CreatedAtAction(nameof(GetAdById), new { id = adId }, adId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// EN: Get ad by ID (placeholder).
|
|
/// VI: Lấy quảng cáo theo ID (placeholder).
|
|
/// </summary>
|
|
[HttpGet("{id}")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
public async Task<IActionResult> GetAdById(Guid id)
|
|
{
|
|
// TODO: Implement GetAdByIdQuery
|
|
return Ok(new { id, message = "Ad details" });
|
|
}
|
|
|
|
/// <summary>
|
|
/// EN: Submit ad for review.
|
|
/// VI: Gửi quảng cáo để duyệt.
|
|
/// </summary>
|
|
[HttpPost("{id}/submit")]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
|
public async Task<IActionResult> SubmitAdForReview(Guid id)
|
|
{
|
|
_logger.LogInformation("Submitting ad {AdId} for review", id);
|
|
// TODO: Implement SubmitAdForReviewCommand
|
|
return NoContent();
|
|
}
|
|
}
|