repair: get detail sparepart
This commit is contained in:
@@ -20,15 +20,21 @@ class SparepartService {
|
||||
throw new ErrorHandler(error.statusCode || 500, error.message);
|
||||
}
|
||||
}
|
||||
static async getSparepartById(id) {
|
||||
try {
|
||||
const Sparepart = await getSparepartByIdDb(id);
|
||||
if (!Sparepart) throw new ErrorHandler(404, "Sparepart not found");
|
||||
return Sparepart;
|
||||
} catch (error) {
|
||||
throw new ErrorHandler(error.statusCode || 500, error.message);
|
||||
|
||||
static async getSparepartById(id) {
|
||||
try {
|
||||
const sparepart = await getSparepartByIdDb(id);
|
||||
|
||||
if (!sparepart || sparepart.length === 0) {
|
||||
throw new ErrorHandler(404, "Sparepart not found");
|
||||
}
|
||||
|
||||
return sparepart[0];
|
||||
} catch (error) {
|
||||
throw new ErrorHandler(error.statusCode || 500, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static async createSparepart(data) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user