feat(alertas): add alerts CRUD with stats and management UI

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Consultoria AS
2026-01-22 03:00:14 +00:00
parent 6d59c8d842
commit 9b8aaea7eb
31 changed files with 4892 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
import { Request, Response, NextFunction } from 'express';
import * as calendarioService from '../services/calendario.service.js';
export async function getEventos(req: Request, res: Response, next: NextFunction) {
try {
const { año, mes } = req.query;
const añoNum = parseInt(año as string) || new Date().getFullYear();
const mesNum = mes ? parseInt(mes as string) : undefined;
const eventos = await calendarioService.getEventos(req.tenantSchema!, añoNum, mesNum);
res.json(eventos);
} catch (error) {
next(error);
}
}
export async function getProximos(req: Request, res: Response, next: NextFunction) {
try {
const dias = parseInt(req.query.dias as string) || 30;
const eventos = await calendarioService.getProximosEventos(req.tenantSchema!, dias);
res.json(eventos);
} catch (error) {
next(error);
}
}
export async function createEvento(req: Request, res: Response, next: NextFunction) {
try {
const evento = await calendarioService.createEvento(req.tenantSchema!, req.body);
res.status(201).json(evento);
} catch (error) {
next(error);
}
}
export async function updateEvento(req: Request, res: Response, next: NextFunction) {
try {
const evento = await calendarioService.updateEvento(req.tenantSchema!, parseInt(req.params.id), req.body);
res.json(evento);
} catch (error) {
next(error);
}
}
export async function deleteEvento(req: Request, res: Response, next: NextFunction) {
try {
await calendarioService.deleteEvento(req.tenantSchema!, parseInt(req.params.id));
res.status(204).send();
} catch (error) {
next(error);
}
}