From 061be20d3bb7460a9c60d73ca197289537b2bb02 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 22 Feb 2024 14:08:43 +0700 Subject: [PATCH] SalaryPeriod Entity --- src/entities/SalarysPeriod.ts | 63 +++++++++++++++++++ ...1708585607075-create_salaryPeriod_table.ts | 18 ++++++ 2 files changed, 81 insertions(+) create mode 100644 src/entities/SalarysPeriod.ts create mode 100644 src/migration/1708585607075-create_salaryPeriod_table.ts diff --git a/src/entities/SalarysPeriod.ts b/src/entities/SalarysPeriod.ts new file mode 100644 index 0000000..8bb9348 --- /dev/null +++ b/src/entities/SalarysPeriod.ts @@ -0,0 +1,63 @@ +import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm"; +import { EntityBase } from "./base/Base"; + +@Entity("salaryPeriod") +export class SalaryPeriod extends EntityBase { + @Column({ + comment: "ประเภทผัง (SPECIAL->รอบพิเศษ,APR->รอบเมษายน,OCT->รอบตุลาคม)", + length: 255, + }) + period: string; + + @Column({ + comment: "สถานะการใช้งาน", + default: false, + }) + isActive: boolean; + + @Column({ + nullable: true, + type: "datetime", + comment: "วันที่มีผลบังคับใช้", + }) + effectiveDate: Date; + + @Column({ + comment: "สถานะ", + length: 255, + default: "PENDING", + }) + status?: string; + +} + +export class CreateSalaryPeriod { + + @Column() + period: string; + + @Column() + isActive: boolean; + + @Column() + effectiveDate: Date; + + @Column() + status?: string; +} + +export class UpdateSalaryPeriod { + + @Column() + period: string; + + @Column() + isActive: boolean; + + @Column() + effectiveDate: Date; + + @Column() + status?: string; + +} \ No newline at end of file diff --git a/src/migration/1708585607075-create_salaryPeriod_table.ts b/src/migration/1708585607075-create_salaryPeriod_table.ts new file mode 100644 index 0000000..e9a61cb --- /dev/null +++ b/src/migration/1708585607075-create_salaryPeriod_table.ts @@ -0,0 +1,18 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class CreateSalaryPeriodTable1708585607075 implements MigrationInterface { + name = 'CreateSalaryPeriodTable1708585607075' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`CREATE TABLE \`salaryPeriod\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`period\` varchar(255) NOT NULL COMMENT 'ประเภทผัง (SPECIAL->รอบพิเศษ,APR->รอบเมษายน,OCT->รอบตุลาคม)', \`isActive\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 0, \`effectiveDate\` datetime NULL COMMENT 'วันที่มีผลบังคับใช้', \`status\` varchar(255) NOT NULL COMMENT 'สถานะ' DEFAULT 'PENDING', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`salarys\` ADD CONSTRAINT \`FK_fa211557e2cbee0bb3bbef363f2\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE \`salarys\` ADD CONSTRAINT \`FK_683719e5363cc977da591556731\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`salarys\` DROP FOREIGN KEY \`FK_683719e5363cc977da591556731\``); + await queryRunner.query(`ALTER TABLE \`salarys\` DROP FOREIGN KEY \`FK_fa211557e2cbee0bb3bbef363f2\``); + await queryRunner.query(`DROP TABLE \`salaryPeriod\``); + } + +}