table sign
This commit is contained in:
parent
322c2f3665
commit
0b2650e17c
4 changed files with 107 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ import { CommandSalary } from "./CommandSalary";
|
|||
import { CommandRecive } from "./CommandRecive";
|
||||
import { ProfileSalary } from "./ProfileSalary";
|
||||
import { ProfileSalaryHistory } from "./ProfileSalaryHistory";
|
||||
import { CommandSign } from "./CommandSign";
|
||||
|
||||
@Entity("command")
|
||||
export class Command extends EntityBase {
|
||||
|
|
@ -151,6 +152,9 @@ export class Command extends EntityBase {
|
|||
@OneToMany(() => CommandSend, (commandSend) => commandSend.command)
|
||||
commandSends: CommandSend[];
|
||||
|
||||
@OneToMany(() => CommandSign, (commandSign) => commandSign.command)
|
||||
commandSigns: CommandSign[];
|
||||
|
||||
@OneToMany(() => CommandRecive, (commandRecive) => commandRecive.command)
|
||||
commandRecives: CommandRecive[];
|
||||
|
||||
|
|
|
|||
80
src/entities/CommandSign.ts
Normal file
80
src/entities/CommandSign.ts
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
import { Entity, Column, JoinColumn, ManyToOne, OneToMany } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { Command } from "./Command";
|
||||
import { Profile } from "./Profile";
|
||||
|
||||
@Entity("commandSign")
|
||||
export class CommandSign extends EntityBase {
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "คำนำหน้า",
|
||||
length: 255,
|
||||
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: "ตำแหน่ง",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
position: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ความเห็น",
|
||||
length: 255,
|
||||
default: null,
|
||||
})
|
||||
comment: string;
|
||||
|
||||
@Column({
|
||||
comment: "เป็นผู้มีอำนาจลงนาม",
|
||||
default: false,
|
||||
})
|
||||
isActive: boolean;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง command",
|
||||
})
|
||||
commandId: string;
|
||||
|
||||
@ManyToOne(() => Command, (command) => command.commandSigns)
|
||||
@JoinColumn({ name: "commandId" })
|
||||
command: Command;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง profile",
|
||||
})
|
||||
profileId: string;
|
||||
|
||||
@ManyToOne(() => Profile, (profile) => profile.commandSigns)
|
||||
@JoinColumn({ name: "profileId" })
|
||||
profile: Profile;
|
||||
}
|
||||
|
||||
export class CreateCommandSign {
|
||||
@Column()
|
||||
name: string;
|
||||
}
|
||||
|
||||
// export type UpdateCommandSign = Partial<CreateCommandSign>;
|
||||
|
|
@ -34,6 +34,7 @@ import { CommandSend } from "./CommandSend";
|
|||
import { DevelopmentRequest } from "./DevelopmentRequest";
|
||||
import { StateOperatorUser } from "./StateOperatorUser";
|
||||
import { StateUserComment } from "./StateUserComment";
|
||||
import { CommandSign } from "./CommandSign";
|
||||
|
||||
@Entity("profile")
|
||||
export class Profile extends EntityBase {
|
||||
|
|
@ -122,7 +123,7 @@ export class Profile extends EntityBase {
|
|||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "สถานะอีเมล",//VERIFIED = ยืนยัน, NOT_VERIFIED = ไม่ได้ยืนยัน
|
||||
comment: "สถานะอีเมล", //VERIFIED = ยืนยัน, NOT_VERIFIED = ไม่ได้ยืนยัน
|
||||
default: null,
|
||||
})
|
||||
statusEmail: string;
|
||||
|
|
@ -387,6 +388,9 @@ export class Profile extends EntityBase {
|
|||
@OneToMany(() => CommandSend, (v) => v.profile)
|
||||
commandSends: CommandSend[];
|
||||
|
||||
@OneToMany(() => CommandSign, (v) => v.profile)
|
||||
commandSigns: CommandSign[];
|
||||
|
||||
@OneToMany(() => StateOperatorUser, (v) => v.profile)
|
||||
stateOperatorUsers: StateOperatorUser[];
|
||||
|
||||
|
|
|
|||
18
src/migration/1730456393834-add_table_commandSign.ts
Normal file
18
src/migration/1730456393834-add_table_commandSign.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddTableCommandSign1730456393834 implements MigrationInterface {
|
||||
name = 'AddTableCommandSign1730456393834'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TABLE \`commandSign\` (\`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', \`prefix\` varchar(255) NULL COMMENT 'คำนำหน้า', \`firstName\` varchar(255) NULL COMMENT 'ชื่อ', \`lastName\` varchar(255) NULL COMMENT 'สกุล', \`position\` varchar(255) NULL COMMENT 'ตำแหน่ง', \`comment\` varchar(255) NULL COMMENT 'ความเห็น', \`isActive\` tinyint NOT NULL COMMENT 'เป็นผู้มีอำนาจลงนาม' DEFAULT 0, \`commandId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง command', \`profileId\` varchar(40) NOT NULL COMMENT 'คีย์นอก(FK)ของตาราง profile', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`ALTER TABLE \`commandSign\` ADD CONSTRAINT \`FK_143488a80d2317daa9333e1a726\` FOREIGN KEY (\`commandId\`) REFERENCES \`command\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
await queryRunner.query(`ALTER TABLE \`commandSign\` ADD CONSTRAINT \`FK_748a443f8f9d4fa32dfddad0b2e\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`commandSign\` DROP FOREIGN KEY \`FK_748a443f8f9d4fa32dfddad0b2e\``);
|
||||
await queryRunner.query(`ALTER TABLE \`commandSign\` DROP FOREIGN KEY \`FK_143488a80d2317daa9333e1a726\``);
|
||||
await queryRunner.query(`DROP TABLE \`commandSign\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue