controller
This commit is contained in:
parent
9f2a08ccc9
commit
2609ecc1bf
17 changed files with 320 additions and 95 deletions
|
@ -21,8 +21,7 @@ export async function getAllEquipments(req: Request, res: Response): Promise<any
|
|||
let noLimit = req.query.noLimit === "true";
|
||||
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
|
||||
|
||||
//{ offset, count, search, noLimit, ids }
|
||||
let [equipments, total] = await EquipmentService.getAll();
|
||||
let [equipments, total] = await EquipmentService.getAll({ offset, count, search, noLimit, ids });
|
||||
|
||||
res.json({
|
||||
equipments: equipments,
|
||||
|
@ -45,6 +44,25 @@ export async function getEquipmentById(req: Request, res: Response): Promise<any
|
|||
res.json(EquipmentFactory.mapToSingle(equipment));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description get equipment by Ids
|
||||
* @param req {Request} Express req object
|
||||
* @param res {Response} Express res object
|
||||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getEquipmentsByIds(req: Request, res: Response): Promise<any> {
|
||||
let ids = req.body.ids as Array<string>;
|
||||
|
||||
let [equipments, total] = await EquipmentService.getAll({ noLimit: true, ids });
|
||||
|
||||
res.json({
|
||||
equipments: EquipmentFactory.mapToBase(equipments),
|
||||
total: total,
|
||||
offset: 0,
|
||||
count: total,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @description create equipment
|
||||
* @param req {Request} Express req object
|
||||
|
|
|
@ -21,8 +21,7 @@ export async function getAllEquipmentTypes(req: Request, res: Response): Promise
|
|||
let noLimit = req.query.noLimit === "true";
|
||||
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
|
||||
|
||||
//{ offset, count, search, noLimit, ids }
|
||||
let [equipmentTypes, total] = await EquipmentTypeService.getAll();
|
||||
let [equipmentTypes, total] = await EquipmentTypeService.getAll({ offset, count, search, noLimit, ids });
|
||||
|
||||
res.json({
|
||||
equipmentTypes: equipmentTypes,
|
||||
|
|
|
@ -19,12 +19,10 @@ export async function getAllInspectionsForRelated(req: Request, res: Response):
|
|||
let relationId = req.params.relatedId as string;
|
||||
let offset = parseInt((req.query.offset as string) ?? "0");
|
||||
let count = parseInt((req.query.count as string) ?? "25");
|
||||
let search = (req.query.search as string) ?? "";
|
||||
let noLimit = req.query.noLimit === "true";
|
||||
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
|
||||
|
||||
//{ offset, count, search, noLimit, ids }
|
||||
let [inspections, total] = await InspectionService.getAllForRelated({ equipmentId: relationId });
|
||||
let where = relation === "equipment" ? { equipmentId: relationId } : { vehicleId: relationId };
|
||||
let [inspections, total] = await InspectionService.getAllForRelated(where, { offset, count, noLimit });
|
||||
|
||||
res.json({
|
||||
inspections: inspections,
|
||||
|
|
|
@ -23,8 +23,14 @@ export async function getAllInspectionPlansForRelated(req: Request, res: Respons
|
|||
let noLimit = req.query.noLimit === "true";
|
||||
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
|
||||
|
||||
//{ offset, count, search, noLimit, ids }
|
||||
let [inspectionPlans, total] = await InspectionPlanService.getAllForRelated({ equipmentId: relationId });
|
||||
let where = relation === "equipment" ? { equipmentId: relationId } : { vehicleId: relationId };
|
||||
let [inspectionPlans, total] = await InspectionPlanService.getAllForRelated(where, {
|
||||
offset,
|
||||
count,
|
||||
search,
|
||||
noLimit,
|
||||
ids,
|
||||
});
|
||||
|
||||
res.json({
|
||||
inspectionPlans: inspectionPlans,
|
||||
|
|
|
@ -21,8 +21,7 @@ export async function getAllVehicles(req: Request, res: Response): Promise<any>
|
|||
let noLimit = req.query.noLimit === "true";
|
||||
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
|
||||
|
||||
//{ offset, count, search, noLimit, ids }
|
||||
let [vehicles, total] = await VehicleService.getAll();
|
||||
let [vehicles, total] = await VehicleService.getAll({ offset, count, search, noLimit, ids });
|
||||
|
||||
res.json({
|
||||
vehicles: vehicles,
|
||||
|
|
|
@ -21,8 +21,7 @@ export async function getAllVehicleTypes(req: Request, res: Response): Promise<a
|
|||
let noLimit = req.query.noLimit === "true";
|
||||
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
|
||||
|
||||
//{ offset, count, search, noLimit, ids }
|
||||
let [vehicleTypes, total] = await VehicleTypeService.getAll();
|
||||
let [vehicleTypes, total] = await VehicleTypeService.getAll({ offset, count, search, noLimit, ids });
|
||||
|
||||
res.json({
|
||||
vehicleTypes: vehicleTypes,
|
||||
|
|
|
@ -21,8 +21,7 @@ export async function getAllWearables(req: Request, res: Response): Promise<any>
|
|||
let noLimit = req.query.noLimit === "true";
|
||||
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
|
||||
|
||||
//{ offset, count, search, noLimit, ids }
|
||||
let [wearables, total] = await WearableService.getAll();
|
||||
let [wearables, total] = await WearableService.getAll({ offset, count, search, noLimit, ids });
|
||||
|
||||
res.json({
|
||||
wearables: wearables,
|
||||
|
|
|
@ -21,8 +21,7 @@ export async function getAllWearableTypes(req: Request, res: Response): Promise<
|
|||
let noLimit = req.query.noLimit === "true";
|
||||
let ids = ((req.query.ids ?? "") as string).split(",").filter((i) => i);
|
||||
|
||||
//{ offset, count, search, noLimit, ids }
|
||||
let [wearableTypes, total] = await WearableTypeService.getAll();
|
||||
let [wearableTypes, total] = await WearableTypeService.getAll({ offset, count, search, noLimit, ids });
|
||||
|
||||
res.json({
|
||||
wearableTypes: wearableTypes,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue