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