2024-10-03 13:31:05 +02:00
|
|
|
import { Request, Response } from "express";
|
|
|
|
import ProtocolService from "../../service/protocolService";
|
|
|
|
import ProtocolFactory from "../../factory/admin/protocol";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @description get all protocols
|
|
|
|
* @param req {Request} Express req object
|
|
|
|
* @param res {Response} Express res object
|
|
|
|
* @returns {Promise<*>}
|
|
|
|
*/
|
|
|
|
export async function getAllProtocols(req: Request, res: Response): Promise<any> {
|
|
|
|
let offset = parseInt((req.query.offset as string) ?? "0");
|
|
|
|
let count = parseInt((req.query.count as string) ?? "25");
|
|
|
|
let [protocols, total] = await ProtocolService.getAll(offset, count);
|
|
|
|
|
|
|
|
res.json({
|
|
|
|
protocols: ProtocolFactory.mapToBase(protocols),
|
|
|
|
total: total,
|
|
|
|
offset: offset,
|
|
|
|
count: count,
|
|
|
|
});
|
|
|
|
}
|
2024-10-04 12:47:13 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @description get protocol by id
|
|
|
|
* @param req {Request} Express req object
|
|
|
|
* @param res {Response} Express res object
|
|
|
|
* @returns {Promise<*>}
|
|
|
|
*/
|
|
|
|
export async function getProtocolById(req: Request, res: Response): Promise<any> {
|
|
|
|
let id = parseInt(req.params.id);
|
|
|
|
let protocol = await ProtocolService.getById(id);
|
|
|
|
|
|
|
|
res.json(ProtocolFactory.mapToSingle(protocol));
|
|
|
|
}
|