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:
52
apps/api/src/controllers/calendario.controller.ts
Normal file
52
apps/api/src/controllers/calendario.controller.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user