Feat: Cambios Varios 2
This commit is contained in:
41
src/SIGCM.API/Controllers/DashboardController.cs
Normal file
41
src/SIGCM.API/Controllers/DashboardController.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SIGCM.Domain.Interfaces;
|
||||
|
||||
namespace SIGCM.API.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
public class DashboardController : ControllerBase
|
||||
{
|
||||
private readonly IListingRepository _repository;
|
||||
|
||||
public DashboardController(IListingRepository repository)
|
||||
{
|
||||
_repository = repository;
|
||||
}
|
||||
|
||||
// Obtiene estadísticas básicas para el dashboard principal
|
||||
[HttpGet("stats")]
|
||||
public async Task<IActionResult> GetStats([FromQuery] DateTime? start, [FromQuery] DateTime? end)
|
||||
{
|
||||
var startDate = start ?? DateTime.UtcNow.AddDays(-7);
|
||||
var endDate = end ?? DateTime.UtcNow;
|
||||
|
||||
var stats = await _repository.GetDashboardStatsAsync(startDate, endDate);
|
||||
return Ok(stats);
|
||||
}
|
||||
|
||||
// Obtiene analítica avanzada para reportes gerenciales detallados
|
||||
[HttpGet("analytics")]
|
||||
[Authorize(Roles = "Admin,Gerente")]
|
||||
public async Task<IActionResult> GetAdvancedAnalytics([FromQuery] DateTime? start, [FromQuery] DateTime? end)
|
||||
{
|
||||
var startDate = start ?? DateTime.UtcNow.AddMonths(-1);
|
||||
var endDate = end ?? DateTime.UtcNow;
|
||||
|
||||
var analytics = await _repository.GetAdvancedAnalyticsAsync(startDate, endDate);
|
||||
return Ok(analytics);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user