feat: delete branch endpoint
This commit is contained in:
parent
59a79a3374
commit
9938dba0e1
1 changed files with 15 additions and 0 deletions
|
|
@ -65,4 +65,19 @@ export class BranchController extends Controller {
|
||||||
where: { id: branchId },
|
where: { id: branchId },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Delete("{branchId}")
|
||||||
|
async deleteBranch(@Path() branchId: string) {
|
||||||
|
const record = await prisma.branch.findFirst({ where: { id: branchId } });
|
||||||
|
|
||||||
|
if (!record) {
|
||||||
|
throw new HttpError(HttpStatus.NOT_FOUND, "Branch cannot be found.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (record.status === Status.USED) {
|
||||||
|
throw new HttpError(HttpStatus.FORBIDDEN, "Branch is in used.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return await prisma.branch.delete({ where: { id: branchId } });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue