add fields appointDirector

This commit is contained in:
Bright 2024-12-26 16:38:33 +07:00
parent e9c62d190a
commit c4fbfc72e1
4 changed files with 76 additions and 1 deletions

View file

@ -52,7 +52,7 @@ export class AppointController extends Controller {
}
const appoint = await this.appointRepository.find({
relations: ["personal"],
relations: ["personal", "directors"],
where: { personal: conditions },
})

View file

@ -59,6 +59,11 @@ export type Person = {
role: string | null
posNo?: string | null
actFullName?: string | null
prefix?: string | null
fullName?: string | null
lastName?: string | null
citizenId?: string | null
rootId?: string | null
}
export class UpdateAppoint {

View file

@ -64,6 +64,46 @@ export class AppointDirector extends EntityBase {
})
actFullName: string
@Column({
nullable: true,
comment: "คำนำหน้าชื่อ",
length: 40,
default: null,
})
prefix: string;
@Column({
nullable: true,
comment: "ชื่อ",
length: 255,
default: null,
})
firstName: string;
@Column({
nullable: true,
comment: "นามสกุล",
length: 255,
default: null,
})
lastName: string;
@Column({
nullable: true,
comment: "เลขประจำตัวประชาชน",
default: null,
length: 13,
})
citizenId: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง orgRoot",
default: null,
})
rootId: string;
@ManyToOne(() => Appoint, (appoint: Appoint) => appoint.directors)
@JoinColumn({ name: "appointId" })
appoint: Appoint

View file

@ -0,0 +1,30 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddColumnsAppointDirector1735205130127 implements MigrationInterface {
name = 'AddColumnsAppointDirector1735205130127'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`appointDirector\` ADD \`prefix\` varchar(40) NULL COMMENT 'คำนำหน้าชื่อ'`);
await queryRunner.query(`ALTER TABLE \`appointDirector\` ADD \`firstName\` varchar(255) NULL COMMENT 'ชื่อ'`);
await queryRunner.query(`ALTER TABLE \`appointDirector\` ADD \`lastName\` varchar(255) NULL COMMENT 'นามสกุล'`);
await queryRunner.query(`ALTER TABLE \`appointDirector\` ADD \`citizenId\` varchar(13) NULL COMMENT 'เลขประจำตัวประชาชน'`);
await queryRunner.query(`ALTER TABLE \`appointDirector\` ADD \`rootId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง orgRoot'`);
await queryRunner.query(`ALTER TABLE \`appoint\` ADD UNIQUE INDEX \`IDX_46c617b30fd9def96938f43b6e\` (\`profileId\`)`);
await queryRunner.query(`CREATE UNIQUE INDEX \`REL_46c617b30fd9def96938f43b6e\` ON \`appoint\` (\`profileId\`)`);
await queryRunner.query(`ALTER TABLE \`appoint\` ADD CONSTRAINT \`FK_46c617b30fd9def96938f43b6ee\` FOREIGN KEY (\`profileId\`) REFERENCES \`personal\`(\`personal_id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`personal\` ADD CONSTRAINT \`FK_5abc77b4bd19c4295cabe6a3bf5\` FOREIGN KEY (\`personal_id\`) REFERENCES \`appoint\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`personal\` DROP FOREIGN KEY \`FK_5abc77b4bd19c4295cabe6a3bf5\``);
await queryRunner.query(`ALTER TABLE \`appoint\` DROP FOREIGN KEY \`FK_46c617b30fd9def96938f43b6ee\``);
await queryRunner.query(`DROP INDEX \`REL_46c617b30fd9def96938f43b6e\` ON \`appoint\``);
await queryRunner.query(`ALTER TABLE \`appoint\` DROP INDEX \`IDX_46c617b30fd9def96938f43b6e\``);
await queryRunner.query(`ALTER TABLE \`appointDirector\` DROP COLUMN \`rootId\``);
await queryRunner.query(`ALTER TABLE \`appointDirector\` DROP COLUMN \`citizenId\``);
await queryRunner.query(`ALTER TABLE \`appointDirector\` DROP COLUMN \`lastName\``);
await queryRunner.query(`ALTER TABLE \`appointDirector\` DROP COLUMN \`firstName\``);
await queryRunner.query(`ALTER TABLE \`appointDirector\` DROP COLUMN \`prefix\``);
}
}