search by ancestorDNA

This commit is contained in:
kittapath 2025-01-30 08:53:02 +07:00
parent dd8996336b
commit 3e57b67432
3 changed files with 88 additions and 5 deletions

View file

@ -139,18 +139,23 @@ export class DevelopmentController extends Controller {
.then((x) => {
development.root = x.root;
development.rootId = x.rootId;
development.rootDnaId = x.rootDnaId;
development.rootShortName = x.rootShortName;
development.child1 = x.child1;
development.child1Id = x.child1Id;
development.child1DnaId = x.child1DnaId;
development.child1ShortName = x.child1ShortName;
development.child2 = x.child2;
development.child2Id = x.child2Id;
development.child2DnaId = x.child2DnaId;
development.child2ShortName = x.child2ShortName;
development.child3 = x.child3;
development.child3Id = x.child3Id;
development.child3DnaId = x.child3DnaId;
development.child3ShortName = x.child3ShortName;
development.child4 = x.child4;
development.child4Id = x.child4Id;
development.child4DnaId = x.child4DnaId;
development.child4ShortName = x.child4ShortName;
})
.catch((error) => {
@ -228,18 +233,23 @@ export class DevelopmentController extends Controller {
.then((x) => {
development.root = x.root;
development.rootId = x.rootId;
development.rootDnaId = x.rootDnaId;
development.rootShortName = x.rootShortName;
development.child1 = x.child1;
development.child1Id = x.child1Id;
development.child1DnaId = x.child1DnaId;
development.child1ShortName = x.child1ShortName;
development.child2 = x.child2;
development.child2Id = x.child2Id;
development.child2DnaId = x.child2DnaId;
development.child2ShortName = x.child2ShortName;
development.child3 = x.child3;
development.child3Id = x.child3Id;
development.child3DnaId = x.child3DnaId;
development.child3ShortName = x.child3ShortName;
development.child4 = x.child4;
development.child4Id = x.child4Id;
development.child4DnaId = x.child4DnaId;
development.child4ShortName = x.child4ShortName;
})
.catch((x) => {});
@ -248,42 +258,52 @@ export class DevelopmentController extends Controller {
case 0: {
development.child1 = _null;
development.child1Id = _null;
development.child1DnaId = _null;
development.child1ShortName = _null;
development.child2 = _null;
development.child2Id = _null;
development.child2DnaId = _null;
development.child2ShortName = _null;
development.child3 = _null;
development.child3Id = _null;
development.child3DnaId = _null;
development.child3ShortName = _null;
development.child4 = _null;
development.child4Id = _null;
development.child4DnaId = _null;
development.child4ShortName = _null;
break;
}
case 1: {
development.child2 = _null;
development.child2Id = _null;
development.child2DnaId = _null;
development.child2ShortName = _null;
development.child3 = _null;
development.child3Id = _null;
development.child3DnaId = _null;
development.child3ShortName = _null;
development.child4 = _null;
development.child4Id = _null;
development.child4DnaId = _null;
development.child4ShortName = _null;
break;
}
case 2: {
development.child3 = _null;
development.child3Id = _null;
development.child3DnaId = _null;
development.child3ShortName = _null;
development.child4 = _null;
development.child4Id = _null;
development.child4DnaId = _null;
development.child4ShortName = _null;
break;
}
case 3: {
development.child4 = _null;
development.child4Id = _null;
development.child4DnaId = _null;
development.child4ShortName = _null;
break;
}
@ -1923,14 +1943,14 @@ export class DevelopmentController extends Controller {
.andWhere(
node != undefined && node != null
? node == 4
? "development.child4Id LIKE :nodeId"
? "development.child4DnaId LIKE :nodeId"
: node == 3
? "development.child3Id LIKE :nodeId"
? "development.child3DnaId LIKE :nodeId"
: node == 2
? "development.child2Id LIKE :nodeId"
? "development.child2DnaId LIKE :nodeId"
: node == 1
? "development.child1Id LIKE :nodeId"
: "development.rootId LIKE :nodeId"
? "development.child1DnaId LIKE :nodeId"
: "development.rootDnaId LIKE :nodeId"
: "1=1",
{
nodeId: `${nodeId}`,

View file

@ -27,6 +27,13 @@ export class Development extends EntityBase {
})
rootId: string;
@Column({
nullable: true,
comment: "id Dna หน่วยงาน",
default: null,
})
rootDnaId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน",
@ -48,6 +55,13 @@ export class Development extends EntityBase {
})
child1Id: string;
@Column({
nullable: true,
comment: "id Dna หน่วยงาน child1",
default: null,
})
child1DnaId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน child1",
@ -69,6 +83,13 @@ export class Development extends EntityBase {
})
child2Id: string;
@Column({
nullable: true,
comment: "id Dna หน่วยงาน child2",
default: null,
})
child2DnaId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน child2",
@ -90,6 +111,13 @@ export class Development extends EntityBase {
})
child3Id: string;
@Column({
nullable: true,
comment: "id Dna หน่วยงาน child3",
default: null,
})
child3DnaId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน child3",
@ -111,6 +139,13 @@ export class Development extends EntityBase {
})
child4Id: string;
@Column({
nullable: true,
comment: "id Dna หน่วยงาน child4",
default: null,
})
child4DnaId: string;
@Column({
nullable: true,
comment: "ชื่อหน่วยงาน child4",

View file

@ -0,0 +1,28 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class Updatedevadddna1738201344610 implements MigrationInterface {
name = 'Updatedevadddna1738201344610'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX \`FK_e2721b3f440256b56ce83a04fb2\` ON \`developmentAddress\``);
await queryRunner.query(`DROP INDEX \`FK_47bbbecaea9b7b31d2536054656\` ON \`developmentOther\``);
await queryRunner.query(`DROP INDEX \`FK_bdafbb824b88c3bdb73adf7f220\` ON \`development\``);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`rootDnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child1DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child1'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child2DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child2'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child3DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child3'`);
await queryRunner.query(`ALTER TABLE \`development\` ADD \`child4DnaId\` varchar(255) NULL COMMENT 'id Dna หน่วยงาน child4'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child4DnaId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child3DnaId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child2DnaId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`child1DnaId\``);
await queryRunner.query(`ALTER TABLE \`development\` DROP COLUMN \`rootDnaId\``);
await queryRunner.query(`CREATE INDEX \`FK_bdafbb824b88c3bdb73adf7f220\` ON \`development\` (\`provinceActualId\`)`);
await queryRunner.query(`CREATE INDEX \`FK_47bbbecaea9b7b31d2536054656\` ON \`developmentOther\` (\`provinceActualId\`)`);
await queryRunner.query(`CREATE INDEX \`FK_e2721b3f440256b56ce83a04fb2\` ON \`developmentAddress\` (\`provinceId\`)`);
}
}