แก้ defult value

This commit is contained in:
Kittapath 2024-02-01 11:02:35 +07:00
parent 9ac7517518
commit c89126a8a2
16 changed files with 381 additions and 110 deletions

View file

@ -22,7 +22,7 @@ import HttpSuccess from "../interfaces/http-success";
import { CreateOrgChild1, OrgChild1 } from "../entities/OrgChild1";
import HttpError from "../interfaces/http-error";
import HttpStatusCode from "../interfaces/http-status";
import { In, Not } from "typeorm";
import { In, IsNull, Not } from "typeorm";
import { OrgRoot } from "../entities/OrgRoot";
import { OrgChild2 } from "../entities/OrgChild2";
import { OrgChild3 } from "../entities/OrgChild3";
@ -608,7 +608,7 @@ export class OrganizationController extends Controller {
"orgRoot.orgRevisionId",
"orgRoot.orgRootRank",
])
.orderBy("orgRoot.createdAt", "ASC")
.orderBy("orgRoot.orgRootOrder", "ASC")
.getMany();
const orgRootIds = orgRootData.map((orgRoot) => orgRoot.id) || null;
@ -629,7 +629,7 @@ export class OrganizationController extends Controller {
"orgChild1.orgRootId",
"orgChild1.orgChild1Rank",
])
.orderBy("orgChild1.createdAt", "ASC")
.orderBy("orgChild1.orgChild1Order", "ASC")
.getMany()
: [];
@ -650,10 +650,9 @@ export class OrganizationController extends Controller {
"orgChild2.orgChild2Fax",
"orgChild2.orgRootId",
"orgChild2.orgChild2Rank",
"orgChild2.orgChild1Id",
])
.orderBy("orgChild2.createdAt", "ASC")
.orderBy("orgChild2.orgChild2Order", "ASC")
.getMany()
: [];
@ -674,10 +673,9 @@ export class OrganizationController extends Controller {
"orgChild3.orgChild3Fax",
"orgChild3.orgRootId",
"orgChild3.orgChild3Rank",
"orgChild3.orgChild2Id",
])
.orderBy("orgChild3.createdAt", "ASC")
.orderBy("orgChild3.orgChild3Order", "ASC")
.getMany()
: [];
@ -698,10 +696,9 @@ export class OrganizationController extends Controller {
"orgChild4.orgChild4Fax",
"orgChild4.orgRootId",
"orgChild4.orgChild4Rank",
"orgChild4.orgChild3Id",
])
.orderBy("orgChild4.createdAt", "ASC")
.orderBy("orgChild4.orgChild4Order", "ASC")
.getMany()
: [];
@ -869,7 +866,11 @@ export class OrganizationController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Child1");
}
const datas = await this.child1Repository.find({
where: { isAncestorDNA: orgChild1.isAncestorDNA },
where: [
{ isAncestorDNA: orgChild1.isAncestorDNA },
{ isAncestorDNA: Not("00000000-0000-0000-0000-000000000000") },
{ isAncestorDNA: Not(IsNull()) },
],
relations: ["orgRevision"],
order: { lastUpdatedAt: "DESC" },
});
@ -888,7 +889,11 @@ export class OrganizationController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Child2");
}
const datas = await this.child2Repository.find({
where: { isAncestorDNA: orgChild2.isAncestorDNA },
where: [
{ isAncestorDNA: orgChild2.isAncestorDNA },
{ isAncestorDNA: Not("00000000-0000-0000-0000-000000000000") },
{ isAncestorDNA: Not(IsNull()) },
],
relations: ["orgRevision"],
order: { lastUpdatedAt: "DESC" },
});
@ -907,7 +912,11 @@ export class OrganizationController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Child3");
}
const datas = await this.child3Repository.find({
where: { isAncestorDNA: orgChild3.isAncestorDNA },
where: [
{ isAncestorDNA: orgChild3.isAncestorDNA },
{ isAncestorDNA: Not("00000000-0000-0000-0000-000000000000") },
{ isAncestorDNA: Not(IsNull()) },
],
relations: ["orgRevision"],
order: { lastUpdatedAt: "DESC" },
});
@ -926,7 +935,11 @@ export class OrganizationController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Child4");
}
const datas = await this.child4Repository.find({
where: { isAncestorDNA: orgChild4.isAncestorDNA },
where: [
{ isAncestorDNA: orgChild4.isAncestorDNA },
{ isAncestorDNA: Not("00000000-0000-0000-0000-000000000000") },
{ isAncestorDNA: Not(IsNull()) },
],
relations: ["orgRevision"],
order: { lastUpdatedAt: "DESC" },
});
@ -945,7 +958,11 @@ export class OrganizationController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Root");
}
const datas = await this.orgRootRepository.find({
where: { isAncestorDNA: orgRoot.isAncestorDNA },
where: [
{ isAncestorDNA: orgRoot.isAncestorDNA },
{ isAncestorDNA: Not("00000000-0000-0000-0000-000000000000") },
{ isAncestorDNA: Not(IsNull()) },
],
relations: ["orgRevision"],
order: { lastUpdatedAt: "DESC" },
});