diff --git a/src/controllers/DevelopmentEmployeeHistoryController.ts b/src/controllers/DevelopmentEmployeeHistoryController.ts index 6d6dadc..9534b7f 100644 --- a/src/controllers/DevelopmentEmployeeHistoryController.ts +++ b/src/controllers/DevelopmentEmployeeHistoryController.ts @@ -239,7 +239,7 @@ export class DevelopmentEmployeeHistoryController extends Controller { { year: body.year }, ) .andWhere( - body.root != null && body.root != undefined ? "developmentHistory.rootId = :root" : "1=1", + body.root != null && body.root != undefined ? "developmentHistory.root = :root" : "1=1", { root: body.root, }, diff --git a/src/controllers/DevelopmentHistoryController.ts b/src/controllers/DevelopmentHistoryController.ts index cee2aee..8ba2d90 100644 --- a/src/controllers/DevelopmentHistoryController.ts +++ b/src/controllers/DevelopmentHistoryController.ts @@ -230,12 +230,9 @@ export class DevelopmentOfficerHistoryController extends Controller { : "1=1", { year: body.year }, ) - .andWhere( - body.root != null && body.root != undefined ? "development.rootId = :root" : "1=1", - { - root: body.root, - }, - ) + .andWhere(body.root != null && body.root != undefined ? "development.root = :root" : "1=1", { + root: body.root, + }) .andWhere(body.root != null ? "developmentHistory.root = :root" : "1=1", { root: body.root }) .andWhere("developmentHistory.type = :type", { type: type }) .andWhere( diff --git a/src/controllers/DevelopmentScholarshipController.ts b/src/controllers/DevelopmentScholarshipController.ts index c85f7a4..9af4a2e 100644 --- a/src/controllers/DevelopmentScholarshipController.ts +++ b/src/controllers/DevelopmentScholarshipController.ts @@ -238,7 +238,11 @@ export class DevelopmentScholarshipController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทุนการศึกษา/ฝึกอบรมนี้"); } const formattedData = { + rootId: getDevelopment.rootId ? getDevelopment.rootId : null, + root: getDevelopment.root ? getDevelopment.root : null, org: getDevelopment.org ? getDevelopment.org : null, + orgRootShortName: getDevelopment.orgRootShortName ? getDevelopment.orgRootShortName : null, + orgRevisionId: getDevelopment.orgRevisionId ? getDevelopment.orgRevisionId : null, rank: getDevelopment.rank ? getDevelopment.rank : null, prefix: getDevelopment.prefix ? getDevelopment.prefix : null, firstName: getDevelopment.firstName ? getDevelopment.firstName : null, @@ -252,6 +256,15 @@ export class DevelopmentScholarshipController extends Controller { : null, posTypeId: getDevelopment.posTypeId ? getDevelopment.posTypeId : null, posTypeName: getDevelopment.posType?.posTypeName ? getDevelopment.posType?.posTypeName : null, + guarantorRootId: getDevelopment.guarantorRootId ? getDevelopment.guarantorRootId : null, + guarantorRoot: getDevelopment.guarantorRoot ? getDevelopment.guarantorRoot : null, + guarantorOrg: getDevelopment.guarantorOrg ? getDevelopment.guarantorOrg : null, + guarantorOrgRootShortName: getDevelopment.guarantorOrgRootShortName + ? getDevelopment.guarantorOrgRootShortName + : null, + guarantorOrgRevisionId: getDevelopment.guarantorOrgRevisionId + ? getDevelopment.guarantorOrgRevisionId + : null, guarantorRank: getDevelopment.guarantorRank ? getDevelopment.guarantorRank : null, guarantorPrefix: getDevelopment.guarantorPrefix ? getDevelopment.guarantorPrefix : null, guarantorFirstName: getDevelopment.guarantorFirstName diff --git a/src/entities/DevelopmentScholarship.ts b/src/entities/DevelopmentScholarship.ts index 99b3d23..efa05ba 100644 --- a/src/entities/DevelopmentScholarship.ts +++ b/src/entities/DevelopmentScholarship.ts @@ -137,6 +137,41 @@ export class DevelopmentScholarship extends EntityBase { @JoinColumn({ name: "posTypeId" }) posType: PosType; + @Column({ + nullable: true, + comment: "id หน่วยงาน", + default: null, + }) + guarantorRootId: string; + + @Column({ + nullable: true, + comment: "ชื่อหน่วยงาน", + default: null, + }) + guarantorRoot: string; + + @Column({ + nullable: true, + comment: "ชื่อหน่วยงานที่สังกัด", + default: null, + }) + guarantorOrg: string; + + @Column({ + nullable: true, + comment: "ชื่อย่อหน่วยงาน", + default: null, + }) + guarantorOrgRootShortName: string; + + @Column({ + nullable: true, + comment: "id revision", + default: null, + }) + guarantorOrgRevisionId: string; + @Column({ nullable: true, comment: "ยศ(ผู้ค้ำ)", @@ -549,6 +584,11 @@ export class CreateDevelopmentScholarship { posExecutive: string | null; posLevelId: string | null; posTypeId: string | null; + guarantorRootId: string | null; + guarantorRoot: string | null; + guarantorOrg: string | null; + guarantorOrgRootShortName: string | null; + guarantorOrgRevisionId: string | null; guarantorRank?: string | null; guarantorPrefix: string | null; guarantorFirstName: string | null; @@ -609,6 +649,11 @@ export class UpdateDevelopmentScholarship { posExecutive: string | null; posLevelId: string | null; posTypeId: string | null; + guarantorRootId?: string | null; + guarantorRoot?: string | null; + guarantorOrg?: string | null; + guarantorOrgRootShortName?: string | null; + guarantorOrgRevisionId?: string | null; guarantorRank?: string | null; guarantorPrefix: string | null; guarantorFirstName: string | null; diff --git a/src/migration/1713431125506-update_table_devscholar_add_guarantorOrg.ts b/src/migration/1713431125506-update_table_devscholar_add_guarantorOrg.ts new file mode 100644 index 0000000..7d2ff87 --- /dev/null +++ b/src/migration/1713431125506-update_table_devscholar_add_guarantorOrg.ts @@ -0,0 +1,22 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTableDevscholarAddGuarantorOrg1713431125506 implements MigrationInterface { + name = 'UpdateTableDevscholarAddGuarantorOrg1713431125506' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorRootId\` varchar(255) NULL COMMENT 'id หน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorRoot\` varchar(255) NULL COMMENT 'ชื่อหน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorOrg\` varchar(255) NULL COMMENT 'ชื่อหน่วยงานที่สังกัด'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorOrgRootShortName\` varchar(255) NULL COMMENT 'ชื่อย่อหน่วยงาน'`); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` ADD \`guarantorOrgRevisionId\` varchar(255) NULL COMMENT 'id revision'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorOrgRevisionId\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorOrgRootShortName\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorOrg\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorRoot\``); + await queryRunner.query(`ALTER TABLE \`developmentScholarship\` DROP COLUMN \`guarantorRootId\``); + } + +}