import { Request, Response } from "express"; import CalendarFactory from "../factory/admin/calendar"; import CalendarService from "../service/calendarService"; import CalendarTypeService from "../service/calendarTypeService"; import { calendar } from "../entity/calendar"; /** * @description get all calendar items by types or nscdr * @param req {Request} Express req object * @param res {Response} Express res object * @returns {Promise<*>} */ export async function getCalendarItemsByTypes(req: Request, res: Response): Promise { let types = Array.isArray(req.query.types) ? req.query.types : [req.query.types]; let items: Array = []; if (types.length == 0) { let typeIds = await CalendarTypeService.getByTypes(types as Array); items = await CalendarService.getByTypes(typeIds.map((t) => t.id)); } else { items = await CalendarService.getByTypeNSCDR(); } res.json(CalendarFactory.mapToBase(items)); }