fix Orgcontroller
This commit is contained in:
parent
aca680f4f4
commit
22324853db
4 changed files with 7 additions and 12 deletions
|
|
@ -25,6 +25,7 @@ import HttpStatusCode from "../interfaces/http-status";
|
|||
@Security("bearerAuth")
|
||||
export class OrgRootController extends Controller {
|
||||
private orgRootRepository = AppDataSource.getRepository(OrgRoot);
|
||||
private orgChild1Repository = AppDataSource.getRepository(OrgChild1);
|
||||
|
||||
/**
|
||||
* สร้างโครงสร้างระดับ Root
|
||||
|
|
@ -118,7 +119,7 @@ export class OrgRootController extends Controller {
|
|||
const chkCode = await this.orgRootRepository.findOne({
|
||||
where: { orgRootCode: requestBody.orgRootCode },
|
||||
});
|
||||
if (chkCode != null) {
|
||||
if (chkCode?.id != id && chkCode != null ) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "รหัสหน่วยงานนี้มีอยู่ในระบบแล้ว");
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +152,7 @@ export class OrgRootController extends Controller {
|
|||
async delete(@Path() id: string) {
|
||||
try {
|
||||
const orgRoot = await this.orgRootRepository.findOne({ where: { id } });
|
||||
const orgChild1 = await this.orgRootRepository.findOne({ where: { id: id } });
|
||||
const orgChild1 = await this.orgChild1Repository.findOne({ where: { orgRootId: id } });
|
||||
|
||||
if (!orgRoot) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue