Implementación AnomalIA - Fix de dropdowns y permisos.
All checks were successful
Optimized Build and Deploy / remote-build-and-deploy (push) Successful in 5m17s
All checks were successful
Optimized Build and Deploy / remote-build-and-deploy (push) Successful in 5m17s
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using GestionIntegral.Api.Dtos.Anomalia;
|
||||
using GestionIntegral.Api.Services.Anomalia;
|
||||
|
||||
namespace GestionIntegral.Api.Controllers.Anomalia
|
||||
{
|
||||
[Route("api/alertas")]
|
||||
[ApiController]
|
||||
[Authorize]
|
||||
public class AlertasController : ControllerBase
|
||||
{
|
||||
private readonly IAlertaService _alertaService;
|
||||
|
||||
public AlertasController(IAlertaService alertaService)
|
||||
{
|
||||
_alertaService = alertaService;
|
||||
}
|
||||
|
||||
// GET: api/alertas
|
||||
[HttpGet]
|
||||
[ProducesResponseType(typeof(IEnumerable<AlertaGenericaDto>), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetAlertasNoLeidas()
|
||||
{
|
||||
var alertas = await _alertaService.ObtenerAlertasNoLeidasAsync();
|
||||
return Ok(alertas);
|
||||
}
|
||||
|
||||
// POST: api/alertas/{idAlerta}/marcar-leida
|
||||
[HttpPost("{idAlerta:int}/marcar-leida")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<IActionResult> MarcarComoLeida(int idAlerta)
|
||||
{
|
||||
var (exito, error) = await _alertaService.MarcarComoLeidaAsync(idAlerta);
|
||||
if (!exito)
|
||||
{
|
||||
return NotFound(new { message = error });
|
||||
}
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
// POST: api/alertas/marcar-grupo-leido
|
||||
[HttpPost("marcar-grupo-leido")]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> MarcarGrupoLeido([FromBody] MarcarGrupoLeidoRequestDto request)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
var (exito, error) = await _alertaService.MarcarGrupoComoLeidoAsync(request.TipoAlerta, request.IdEntidad);
|
||||
if (!exito)
|
||||
{
|
||||
return BadRequest(new { message = error });
|
||||
}
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
|
||||
// DTO para el cuerpo del request de marcar grupo
|
||||
public class MarcarGrupoLeidoRequestDto
|
||||
{
|
||||
[System.ComponentModel.DataAnnotations.Required]
|
||||
public string TipoAlerta { get; set; } = string.Empty;
|
||||
|
||||
[System.ComponentModel.DataAnnotations.Required]
|
||||
public int IdEntidad { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -50,10 +50,19 @@ namespace GestionIntegral.Api.Controllers.Distribucion
|
||||
public async Task<IActionResult> GetAllCanillas([FromQuery] string? nomApe, [FromQuery] int? legajo, [FromQuery] bool? esAccionista, [FromQuery] bool? soloActivos = true)
|
||||
{
|
||||
if (!TienePermiso(PermisoVer)) return Forbid();
|
||||
var canillitas = await _canillaService.ObtenerTodosAsync(nomApe, legajo, soloActivos, esAccionista); // <<-- Pasa el parámetro
|
||||
var canillitas = await _canillaService.ObtenerTodosAsync(nomApe, legajo, soloActivos, esAccionista);
|
||||
return Ok(canillitas);
|
||||
}
|
||||
|
||||
[HttpGet("dropdown")]
|
||||
[ProducesResponseType(typeof(IEnumerable<CanillaDropdownDto>), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetAllDropdownCanillas([FromQuery] bool? esAccionista, [FromQuery] bool? soloActivos = true)
|
||||
{
|
||||
var canillitas = await _canillaService.ObtenerTodosDropdownAsync(esAccionista, soloActivos);
|
||||
return Ok(canillitas);
|
||||
}
|
||||
|
||||
|
||||
// GET: api/canillas/{id}
|
||||
[HttpGet("{id:int}", Name = "GetCanillaById")]
|
||||
[ProducesResponseType(typeof(CanillaDto), StatusCodes.Status200OK)]
|
||||
|
||||
@@ -64,6 +64,23 @@ namespace GestionIntegral.Api.Controllers.Distribucion
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("dropdown")]
|
||||
[ProducesResponseType(typeof(IEnumerable<OtroDestinoDropdownDto>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> GetAllOtrosDestinosDropdown()
|
||||
{
|
||||
try
|
||||
{
|
||||
var destinos = await _otroDestinoService.ObtenerTodosDropdownAsync();
|
||||
return Ok(destinos);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error al obtener Otros Destinos para dropdown.");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "Error interno al obtener la lista de destinos.");
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/otrosdestinos/{id}
|
||||
[HttpGet("{id:int}", Name = "GetOtroDestinoById")]
|
||||
[ProducesResponseType(typeof(OtroDestinoDto), StatusCodes.Status200OK)]
|
||||
|
||||
@@ -67,6 +67,23 @@ namespace GestionIntegral.Api.Controllers.Impresion
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/estadosbobina/dropdown
|
||||
[HttpGet("dropdown")]
|
||||
[ProducesResponseType(typeof(IEnumerable<EstadoBobinaDto>), StatusCodes.Status200OK)]
|
||||
public async Task<IActionResult> GetAllDropdownEstadosBobina()
|
||||
{
|
||||
try
|
||||
{
|
||||
var estados = await _estadoBobinaService.ObtenerTodosDropdownAsync();
|
||||
return Ok(estados);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error al obtener todos los Estados de Bobina.");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "Error interno al obtener los estados de bobina.");
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/estadosbobina/{id}
|
||||
[HttpGet("{id:int}", Name = "GetEstadoBobinaById")]
|
||||
[ProducesResponseType(typeof(EstadoBobinaDto), StatusCodes.Status200OK)]
|
||||
|
||||
@@ -62,6 +62,25 @@ namespace GestionIntegral.Api.Controllers.Impresion
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/tiposbobina/dropdown
|
||||
[HttpGet("dropdown")]
|
||||
[ProducesResponseType(typeof(IEnumerable<TipoBobinaDto>), StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status403Forbidden)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> GetAllTiposBobina()
|
||||
{
|
||||
try
|
||||
{
|
||||
var tiposBobina = await _tipoBobinaService.ObtenerTodosDropdownAsync();
|
||||
return Ok(tiposBobina);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error al obtener todos los Tipos de Bobina.");
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "Error interno al obtener los tipos de bobina.");
|
||||
}
|
||||
}
|
||||
|
||||
// GET: api/tiposbobina/{id}
|
||||
// Permiso: IB006 (Ver Tipos Bobinas)
|
||||
[HttpGet("{id:int}", Name = "GetTipoBobinaById")]
|
||||
|
||||
Reference in New Issue
Block a user