diff --git a/src/controllers/SubDistrictController.ts b/src/controllers/SubDistrictController.ts index 2d93445c..3ea667c8 100644 --- a/src/controllers/SubDistrictController.ts +++ b/src/controllers/SubDistrictController.ts @@ -93,7 +93,10 @@ export class SubDistrictController extends Controller { } const checkName = await this.subDistrictRepository.findOne({ - where: { name: requestBody.name }, + where: { + name: requestBody.name, + districtId: requestBody.districtId + }, }); if (checkName) { @@ -135,7 +138,11 @@ export class SubDistrictController extends Controller { } const checkName = await this.subDistrictRepository.findOne({ - where: { id: Not(id), name: requestBody.name }, + where: { + id: Not(id), + name: requestBody.name, + districtId: requestBody.districtId + }, }); if (checkName) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ชื่อนี้มีอยู่ในระบบแล้ว");