Entity profileSalary
This commit is contained in:
parent
d5e318f8dc
commit
e147412ea4
3 changed files with 102 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ import { EntityBase } from "./base/Base";
|
|||
import { PosMaster } from "./PosMaster";
|
||||
import { PosLevel } from "./PosLevel";
|
||||
import { PosType } from "./PosType";
|
||||
import { ProfileSalary } from "./ProfileSalary";
|
||||
|
||||
@Entity("profile")
|
||||
export class Profile extends EntityBase {
|
||||
|
|
@ -113,6 +114,9 @@ export class Profile extends EntityBase {
|
|||
@OneToMany(() => PosMaster, (posMaster) => posMaster.next_holder)
|
||||
next_holders: PosMaster[];
|
||||
|
||||
@OneToMany(() => ProfileSalary, (profileSalary) => profileSalary.profile)
|
||||
profileSalary: ProfileSalary[];
|
||||
|
||||
@ManyToOne(() => PosLevel, (posLevel) => posLevel.posLevels)
|
||||
@JoinColumn({ name: "posLevelId" })
|
||||
posLevel: PosLevel;
|
||||
|
|
|
|||
82
src/entities/ProfileSalary.ts
Normal file
82
src/entities/ProfileSalary.ts
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
import { Entity, Column, OneToMany, OneToOne, JoinColumn, ManyToMany, ManyToOne, Double } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { Profile } from "./Profile" ;
|
||||
|
||||
@Entity("profileSalary")
|
||||
export class ProfileSalary extends EntityBase {
|
||||
@Column({
|
||||
comment: "วันที่",
|
||||
type: "datetime",
|
||||
nullable: true,
|
||||
})
|
||||
date: Date;
|
||||
|
||||
@Column({
|
||||
comment: "เงินเดือนฐาน",
|
||||
default: 0,
|
||||
nullable: true,
|
||||
type: "double"
|
||||
})
|
||||
amount: Double;
|
||||
|
||||
@Column({
|
||||
comment: "เงินประจำตำแหน่ง",
|
||||
default: 0,
|
||||
nullable: true,
|
||||
type: "double"
|
||||
})
|
||||
positionSalaryAmount: Double;
|
||||
|
||||
@Column({
|
||||
comment: "เงินค่าตอบแทนรายเดือน",
|
||||
default: 0,
|
||||
nullable: true,
|
||||
type: "double"
|
||||
})
|
||||
mouthSalaryAmount: Double;
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
comment: "ไอดีโปรไฟล์",
|
||||
})
|
||||
profileId: string;
|
||||
|
||||
@ManyToOne(() => Profile, (profile) => profile.profileSalary)
|
||||
@JoinColumn({ name: "profileId" })
|
||||
profile: Profile;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// export class CreateProfileSalary {
|
||||
|
||||
// @Column()
|
||||
// date: Date;
|
||||
|
||||
// @Column()
|
||||
// amount: Double;
|
||||
|
||||
// @Column()
|
||||
// positionSalaryAmount: Double;
|
||||
|
||||
// @Column()
|
||||
// mouthSalaryAmount: Double;
|
||||
|
||||
// }
|
||||
|
||||
// export class UpdateProfileSalary {
|
||||
|
||||
// @Column()
|
||||
// date: Date;
|
||||
|
||||
// @Column()
|
||||
// amount: Double;
|
||||
|
||||
// @Column()
|
||||
// positionSalaryAmount: Double;
|
||||
|
||||
// @Column()
|
||||
// mouthSalaryAmount: Double;
|
||||
|
||||
// }
|
||||
|
||||
16
src/migration/1708672520446-create_profileSalary_table.ts
Normal file
16
src/migration/1708672520446-create_profileSalary_table.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class CreateProfileSalaryTable1708672520446 implements MigrationInterface {
|
||||
name = 'CreateProfileSalaryTable1708672520446'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`CREATE TABLE \`profileSalary\` (\`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', \`date\` datetime NULL COMMENT 'วันที่', \`amount\` double NULL COMMENT 'เงินเดือนฐาน' DEFAULT '0', \`positionSalaryAmount\` double NULL COMMENT 'เงินประจำตำแหน่ง' DEFAULT '0', \`mouthSalaryAmount\` double NULL COMMENT 'เงินค่าตอบแทนรายเดือน' DEFAULT '0', \`profileId\` varchar(40) NOT NULL COMMENT 'ไอดีโปรไฟล์', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||
await queryRunner.query(`ALTER TABLE \`profileSalary\` ADD CONSTRAINT \`FK_7534d36579c78107ba08a96be6f\` 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 \`profileSalary\` DROP FOREIGN KEY \`FK_7534d36579c78107ba08a96be6f\``);
|
||||
await queryRunner.query(`DROP TABLE \`profileSalary\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue