Merge pull request 'wisdom' (#45) from wisdom into main

Reviewed-on: #45
This commit is contained in:
2026-04-27 06:31:20 +00:00
4 changed files with 35 additions and 2 deletions

View File

@@ -28,6 +28,8 @@ class SparepartService {
throw new ErrorHandler(404, "Sparepart not found");
}
sparepart[0].sparepart_yearly = JSON.parse(sparepart[0].sparepart_yearly);
return sparepart[0];
} catch (error) {
throw new ErrorHandler(error.statusCode || 500, error.message);
@@ -42,6 +44,11 @@ class SparepartService {
if (exists)
throw new ErrorHandler(400, "Sparepart name already exists");
}
if (data.sparepart_yearly) {
data.sparepart_yearly = JSON.stringify(data.sparepart_yearly);
}
const created = await createSparepartDb(data);
if (!created) throw new ErrorHandler(500, "Failed to create Sparepart");
return created;
@@ -65,6 +72,11 @@ class SparepartService {
if (exists)
throw new ErrorHandler(400, "Sparepart name already exists");
}
if (data.sparepart_yearly) {
data.sparepart_yearly = JSON.stringify(data.sparepart_yearly);
}
const updated = await updateSparepartDb(id, data);
if (!updated) throw new ErrorHandler(500, "Failed to update Sparepart");
return await this.getSparepartById(id);