เพิ่ม table Profile ทำ relation 2 field
This commit is contained in:
parent
f9bafbb4f1
commit
6804332f40
2 changed files with 73 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ import { OrgChild1 } from "./OrgChild1";
|
|||
import { OrgChild2 } from "./OrgChild2";
|
||||
import { OrgChild3 } from "./OrgChild3";
|
||||
import { OrgChild4 } from "./OrgChild4";
|
||||
import { Profile } from "./Profile";
|
||||
|
||||
enum PosMasterLine {
|
||||
MAIN = "MAIN",
|
||||
|
|
@ -136,13 +137,15 @@ export class PosMaster extends EntityBase {
|
|||
default: null,
|
||||
})
|
||||
profileIdNextHolder: string;
|
||||
|
||||
|
||||
@Column({
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง orgRevision",
|
||||
})
|
||||
orgRevisionId: string; //fk
|
||||
|
||||
|
||||
|
||||
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.posMasters)
|
||||
@JoinColumn({ name: "orgRevisionId" })
|
||||
orgRevision: OrgRevision;
|
||||
|
|
@ -167,6 +170,14 @@ export class PosMaster extends EntityBase {
|
|||
@JoinColumn({ name: "orgChild4Id" })
|
||||
orgChild4: OrgChild4;
|
||||
|
||||
@ManyToOne(() => Profile, (profile) => profile.posMasters)
|
||||
@JoinColumn({ name: "profileIdCurrentHolder" })
|
||||
profile: Profile;
|
||||
|
||||
@ManyToOne(() => Profile, (profile) => profile.next_holder_posMasters)
|
||||
@JoinColumn({ name: "profileIdNextHolder" })
|
||||
next_holder: Profile;
|
||||
|
||||
@OneToMany(() => Position, (position) => position.posMaster)
|
||||
positions: Position[];
|
||||
}
|
||||
|
|
|
|||
61
src/entities/Profile.ts
Normal file
61
src/entities/Profile.ts
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
import { Entity, Column, OneToMany} from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { PosMaster } from "./PosMaster";
|
||||
|
||||
@Entity("profile")
|
||||
export class Profile extends EntityBase {
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "คำนำหน้าชื่อ",
|
||||
length: 40,
|
||||
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: "เลขประจำตัวประชาชน",
|
||||
default: null,
|
||||
})
|
||||
citizenId: number;
|
||||
|
||||
@OneToMany(() => PosMaster, (posMaster) => posMaster.profile)
|
||||
posMasters: PosMaster[];
|
||||
|
||||
@OneToMany(() => PosMaster, (posMaster) => posMaster.next_holder)
|
||||
next_holder_posMasters: PosMaster[];
|
||||
}
|
||||
|
||||
export class CreateProfile {
|
||||
@Column()
|
||||
prefix: string;
|
||||
|
||||
@Column()
|
||||
firstName: string;
|
||||
|
||||
@Column()
|
||||
lastName: string;
|
||||
|
||||
@Column()
|
||||
citizenId: number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export type UpdateProfile = Partial<CreateProfile>;
|
||||
Loading…
Add table
Add a link
Reference in a new issue