Merge branch 'develop' into adiDev

This commit is contained in:
AdisakKanthawilang 2024-03-12 14:53:49 +07:00
commit 67f903dda2
5 changed files with 190 additions and 0 deletions

View file

@ -0,0 +1,57 @@
import { Entity, Column, ManyToOne, JoinColumn, } from "typeorm";
import { EntityBase } from "./base/Base";
import { EmployeePosType } from "./EmployeePosType";
import { EmployeePosLevel } from "./EmployeePosLevel";
@Entity("employeePosDict")
export class EmployeePosDict extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อตำแหน่ง",
length: 255,
default: null,
})
posDictName: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง employeePosType",
})
employeePosTypeId: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง employeePosLevel",
})
employeePosLevelId: string;
@ManyToOne(() => EmployeePosType, (employeePosType) => employeePosType)
@JoinColumn({ name: "employeePosTypeId" })
employeePosType: EmployeePosType;
@ManyToOne(() => EmployeePosLevel, (employeePosLevel) => employeePosLevel)
@JoinColumn({ name: "employeePosLevelId" })
employeePosLevel: EmployeePosLevel;
}
export class CreateEmployeePosDict {
@Column()
posDictName: string | null;
@Column("uuid")
employeePosTypeId: string | null;
@Column("uuid")
employeePosLevelId: string | null;
}
export class UpdateEmployeePosDict {
@Column()
posDictName: string;
@Column("uuid")
employeePosTypeId: string;
@Column("uuid")
employeePosLevelId: string;
}

View file

@ -0,0 +1,44 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { EmployeePosDict } from "./EmployeePosDict";
import { EmployeePosType } from "./EmployeePosType";
@Entity("employeePosLevel")
export class EmployeePosLevel extends EntityBase {
@Column({
comment: "ชื่อระดับชั้นงาน",
type: "int",
})
posLevelName: number;
@Column({
comment: "ระดับของระดับชั้นงาน",
type: "int",
})
posLevelRank: number;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง employeePosType",
})
employeePosTypeId: string;
@ManyToOne(() => EmployeePosType, (employeePosType) => employeePosType.employeePosLevels)
@JoinColumn({ name: "employeePosTypeId" })
employeePosType: EmployeePosType;
@OneToMany(() => EmployeePosDict, (employeePosDict) => employeePosDict.employeePosLevel)
employeePosDicts: EmployeePosDict[];
}
export class CreateEmployeePosLevel {
@Column()
posLevelName: number;
@Column()
posLevelRank: number;
}
export type UpdateEmployeePosLevel= Partial<CreateEmployeePosLevel>;

View file

@ -0,0 +1,49 @@
import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { EmployeePosDict } from "./EmployeePosDict";
import { EmployeePosLevel } from "./EmployeePosLevel";
@Entity("employeePosType")
export class EmployeePosType extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อกลุ่มงาน",
length: 255,
default: null,
})
posTypeName: string;
@Column({
comment: "ระดับของกลุ่มงาน",
})
posTypeRank: number;
@Column({
nullable: true,
comment: "ชื่อย่อกลุ่มงาน",
length: 255,
default: null,
})
posTypeShortName: string;
@OneToMany(() => EmployeePosLevel, (employeePosLevel) => employeePosLevel.employeePosType)
employeePosLevels: EmployeePosLevel[];
@OneToMany(() => EmployeePosDict, (employeePosDict) => employeePosDict.employeePosType)
employeePosDicts: EmployeePosDict[];
}
export class CreateEmployeePosType {
@Column()
posTypeName: string;
@Column()
posTypeRank: number;
@Column()
posTypeShortName: string;
}
export type UpdateEmployeePosType = Partial<CreateEmployeePosType>;

View file

@ -0,0 +1,24 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class AddTableEmployees1710220097101 implements MigrationInterface {
name = 'AddTableEmployees1710220097101'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE TABLE \`employeePosType\` (\`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', \`posTypeName\` varchar(255) NULL COMMENT 'ชื่อกลุ่มงาน', \`posTypeRank\` int NOT NULL COMMENT 'ระดับของกลุ่มงาน', \`posTypeShortName\` varchar(255) NULL COMMENT 'ชื่อย่อกลุ่มงาน', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`employeePosDict\` (\`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', \`posDictName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่ง', \`employeePosTypeId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง employeePosType', \`employeePosLevelId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง employeePosLevel', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`CREATE TABLE \`employeePosLevel\` (\`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', \`posLevelName\` varchar(255) NULL COMMENT 'ชื่อระดับชั้นงาน', \`posLevelRank\` int NOT NULL COMMENT 'ระดับของระดับชั้นงาน', \`employeePosTypeId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง employeePosType', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
await queryRunner.query(`ALTER TABLE \`employeePosDict\` ADD CONSTRAINT \`FK_73ad56ef383399f567d58b213e2\` FOREIGN KEY (\`employeePosTypeId\`) REFERENCES \`employeePosType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`employeePosDict\` ADD CONSTRAINT \`FK_28d45cec912604b7d6f3dfac39a\` FOREIGN KEY (\`employeePosLevelId\`) REFERENCES \`employeePosLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` ADD CONSTRAINT \`FK_a822851af7b58288be65debfdd5\` FOREIGN KEY (\`employeePosTypeId\`) REFERENCES \`employeePosType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` DROP FOREIGN KEY \`FK_a822851af7b58288be65debfdd5\``);
await queryRunner.query(`ALTER TABLE \`employeePosDict\` DROP FOREIGN KEY \`FK_28d45cec912604b7d6f3dfac39a\``);
await queryRunner.query(`ALTER TABLE \`employeePosDict\` DROP FOREIGN KEY \`FK_73ad56ef383399f567d58b213e2\``);
await queryRunner.query(`DROP TABLE \`employeePosLevel\``);
await queryRunner.query(`DROP TABLE \`employeePosDict\``);
await queryRunner.query(`DROP TABLE \`employeePosType\``);
}
}

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class EditTypeEmpPosLevel1710220658926 implements MigrationInterface {
name = 'EditTypeEmpPosLevel1710220658926'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` DROP COLUMN \`posLevelName\``);
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` ADD \`posLevelName\` int NOT NULL COMMENT 'ชื่อระดับชั้นงาน'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` DROP COLUMN \`posLevelName\``);
await queryRunner.query(`ALTER TABLE \`employeePosLevel\` ADD \`posLevelName\` varchar(255) NULL COMMENT 'ชื่อระดับชั้นงาน'`);
}
}