extend wearable and enable maintenance
This commit is contained in:
parent
aeb1ccbc42
commit
b8b2186c58
20 changed files with 457 additions and 93 deletions
|
@ -16,13 +16,20 @@ import BadRequestException from "../../../exceptions/badRequestException";
|
|||
* @returns {Promise<*>}
|
||||
*/
|
||||
export async function getAllInspectionsForRelated(req: Request, res: Response): Promise<any> {
|
||||
let relation = req.params.related as "vehicle" | "equipment";
|
||||
let relation = req.params.related as "vehicle" | "equipment" | "wearable";
|
||||
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 noLimit = req.query.noLimit === "true";
|
||||
|
||||
let where = relation === "equipment" ? { equipmentId: relationId } : { vehicleId: relationId };
|
||||
let where;
|
||||
if (relation == "equipment") {
|
||||
where = { equipmentId: relationId };
|
||||
} else if (relation == "vehicle") {
|
||||
where = { vehicleId: relationId };
|
||||
} else {
|
||||
where = { wearableId: relationId };
|
||||
}
|
||||
let [inspections, total] = await InspectionService.getAllForRelated(where, { offset, count, noLimit });
|
||||
|
||||
res.json({
|
||||
|
@ -59,8 +66,8 @@ export async function createInspection(req: Request, res: Response): Promise<any
|
|||
const assigned = req.body.assigned;
|
||||
const nextInspection = req.body.nextInspection || null;
|
||||
|
||||
if (assigned != "equipment" && assigned != "vehicle")
|
||||
throw new BadRequestException("set assigned to equipment or vehicle");
|
||||
if (assigned != "equipment" && assigned != "vehicle" && assigned != "wearable")
|
||||
throw new BadRequestException("set assigned to equipment or vehicle or wearable");
|
||||
|
||||
let createInspection: CreateInspectionCommand = {
|
||||
context,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue