feat: delete customer
This commit is contained in:
parent
239582b472
commit
6e07e0658e
1 changed files with 15 additions and 0 deletions
|
|
@ -115,4 +115,19 @@ export class CustomerController extends Controller {
|
|||
),
|
||||
});
|
||||
}
|
||||
|
||||
@Delete("{customerId}")
|
||||
async deleteById(@Path() customerId: string) {
|
||||
const record = await prisma.customer.findFirst({ where: { id: customerId } });
|
||||
|
||||
if (!record) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "Customer cannot be found.", "data_not_found");
|
||||
}
|
||||
|
||||
if (record.status !== Status.CREATED) {
|
||||
throw new HttpError(HttpStatus.FORBIDDEN, "Customer is in used.", "data_in_used");
|
||||
}
|
||||
|
||||
return await prisma.customer.delete({ where: { id: customerId } });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue