edit repair

This commit is contained in:
Julian Krauser 2025-07-22 13:10:13 +02:00
parent 85fa912024
commit f812298cb2
6 changed files with 166 additions and 13 deletions

View file

@ -1,10 +1,16 @@
import { Request, Response } from "express";
import RepairService from "../../../service/unit/repairService";
import RepairFactory from "../../../factory/admin/unit/repair";
import { CreateRepairCommand, UpdateRepairCommand } from "../../../command/unit/repairCommand";
import {
CreateRepairCommand,
UpdateRepairCommand,
UpdateRepairStatusCommand,
} from "../../../command/unit/repairCommand";
import RepairCommandHandler from "../../../command/unit/repairCommandHandler";
import BadRequestException from "../../../exceptions/badRequestException";
import { FileSystemHelper } from "../../../helpers/fileSystemHelper";
import { UpdateDamageReportRelatedRepairCommand } from "../../../command/unit/damageReportCommand";
import DamageReportCommandHandler from "../../../command/unit/damageReportCommandHandler";
/**
* @description get all repairs by status
@ -110,21 +116,53 @@ export async function createRepair(req: Request, res: Response): Promise<any> {
*/
export async function updateRepairById(req: Request, res: Response): Promise<any> {
const repairId = req.params.id;
const status = req.body.status;
const title = req.body.title;
const description = req.body.description;
const responsible = req.body.responsible;
const reports = req.body.reports;
let updateRepair: UpdateRepairCommand = {
id: repairId,
status,
title,
description,
responsible,
reports,
};
await RepairCommandHandler.update(updateRepair);
res.sendStatus(204);
}
/**
* @description update repair by id
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function updateRepairReportsById(req: Request, res: Response): Promise<any> {
const repairId = req.params.id;
const reports = req.body.reports as Array<string>;
await DamageReportCommandHandler.updateRelatedMaintenanceMulti(repairId, reports);
res.sendStatus(204);
}
/**
* @description update repair by id
* @param req {Request} Express req object
* @param res {Response} Express res object
* @returns {Promise<*>}
*/
export async function updateRepairStatusById(req: Request, res: Response): Promise<any> {
const repairId = req.params.id;
const status = req.body.status;
const done = req.body.done;
let updateRepair: UpdateRepairStatusCommand = {
id: repairId,
status,
done,
};
await RepairCommandHandler.updateStatus(updateRepair);
res.sendStatus(204);
}