feat: detect self reference
This commit is contained in:
parent
ae42cb2f76
commit
c59e0f537a
1 changed files with 7 additions and 0 deletions
|
|
@ -238,6 +238,13 @@ export class BranchController extends Controller {
|
|||
@Body() body: BranchUpdate,
|
||||
@Path() branchId: string,
|
||||
) {
|
||||
if (body.headOfficeId === branchId)
|
||||
throw new HttpError(
|
||||
HttpStatus.BAD_REQUEST,
|
||||
"Cannot make this as head office and branch at the same time.",
|
||||
"missing_or_invalid_parameter",
|
||||
);
|
||||
|
||||
if (body.subDistrictId || body.districtId || body.provinceId || body.headOfficeId) {
|
||||
const [province, district, subDistrict, branch] = await prisma.$transaction([
|
||||
prisma.province.findFirst({ where: { id: body.provinceId || undefined } }),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue