using Asp.Versioning; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using SCM.Application.Planejamento; using SCM.Application.Planejamento.Dtos; using SCM.Shared.Api; using SCM.Shared.Constants; namespace SCM.Api.Controllers; /// Itens programados (PA/PP) de uma Folha de Tarefa. [ApiController] [ApiVersion("1.0")] [Route("api/v{version:apiVersion}/folhas-tarefa/{folhaTarefaId:guid}/itens")] [Authorize] [Produces("application/json")] public sealed class FolhaTarefaItensController : ControllerBase { private readonly IFolhaTarefaItemService _service; public FolhaTarefaItensController(IFolhaTarefaItemService service) => _service = service; /// Lista os itens programados da FT. [HttpGet] [ProducesResponseType(typeof(IReadOnlyList), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status404NotFound)] public async Task>> Get(Guid folhaTarefaId, CancellationToken ct = default) => Ok(await _service.GetByFolhaTarefaAsync(folhaTarefaId, ct)); /// Programa (reconstrói) os itens da FT — só em FT EM_PROGRAMACAO. [HttpPut] [Authorize(Roles = Roles.Administrador + "," + Roles.Gestor + "," + Roles.Engenheiro)] [ProducesResponseType(typeof(IReadOnlyList), StatusCodes.Status200OK)] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status400BadRequest)] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status404NotFound)] [ProducesResponseType(typeof(ApiResponse), StatusCodes.Status409Conflict)] public async Task>> Programar( Guid folhaTarefaId, [FromBody] ProgramarItensFtRequest request, CancellationToken ct = default) => Ok(await _service.ProgramarAsync(folhaTarefaId, request, ct)); }