relation posMaster to Root and Child1-4

This commit is contained in:
AdisakKanthawilang 2024-01-31 15:31:20 +07:00
parent afc97292d3
commit 8cb8b449b4
6 changed files with 47 additions and 2 deletions

View file

@ -5,6 +5,7 @@ import { OrgChild2 } from "./OrgChild2";
import { OrgRevision } from "./OrgRevision";
import { OrgChild3 } from "./OrgChild3";
import { OrgChild4 } from "./OrgChild4";
import { PosMaster } from "./PosMaster";
enum OrgChild1Rank {
DEPARTMENT = "DEPARTMENT",
@ -108,6 +109,9 @@ export class OrgChild1 extends EntityBase {
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild1)
orgChild4s: OrgChild4[];
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgChild1)
posMasters: PosMaster[];
}
export class CreateOrgChild1 {

View file

@ -5,6 +5,7 @@ import { OrgChild1 } from "./OrgChild1";
import { OrgChild3 } from "./OrgChild3";
import { OrgChild4 } from "./OrgChild4";
import { OrgRevision } from "./OrgRevision";
import { PosMaster } from "./PosMaster";
// ENUM orgChild2Rank
enum OrgChild2Rank {
@ -123,6 +124,9 @@ export class OrgChild2 extends EntityBase {
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild2)
orgChild4s: OrgChild4[];
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgChild2)
posMasters: PosMaster[];
}
export class CreateOrgChild2 {

View file

@ -5,6 +5,7 @@ import { OrgChild4 } from "./OrgChild4";
import { OrgRevision } from "./OrgRevision";
import { OrgChild1 } from "./OrgChild1";
import { OrgRoot } from "./OrgRoot";
import { PosMaster } from "./PosMaster";
enum OrgChild3Rank {
DEPARTMENT = "DEPARTMENT",
@ -122,6 +123,9 @@ export class OrgChild3 extends EntityBase {
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild3)
orgChild4s: OrgChild4[];
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgChild3)
posMasters: PosMaster[];
}
export class CreateOrgChild3 {

View file

@ -1,10 +1,11 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne } from "typeorm";
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { OrgRoot } from "./OrgRoot";
import { OrgChild1 } from "./OrgChild1";
import { OrgChild2 } from "./OrgChild2";
import { OrgChild3 } from "./OrgChild3";
import { OrgRevision } from "./OrgRevision";
import { PosMaster } from "./PosMaster";
// ENUM orgChild4Rank
enum OrgChild4Rank {
DEPARTMENT = "DEPARTMENT",
@ -136,6 +137,9 @@ export class OrgChild4 extends EntityBase {
@ManyToOne(() => OrgChild3, (orgChild3) => orgChild3.orgChild4s)
@JoinColumn({ name: "orgChild3Id" })
orgChild3: OrgChild3;
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgChild4)
posMasters: PosMaster[]
}
export class CreateOrgChild4 {

View file

@ -5,6 +5,7 @@ import { OrgRevision } from "./OrgRevision";
import { OrgChild2 } from "./OrgChild2";
import { OrgChild3 } from "./OrgChild3";
import { OrgChild4 } from "./OrgChild4";
import { PosMaster } from "./PosMaster";
// ENUM orgRootRank
enum OrgRootRank {
@ -92,6 +93,9 @@ export class OrgRoot extends EntityBase {
@JoinColumn({ name: "orgRevisionId" })
orgRevision: OrgRevision;
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgRoot)
posMasters: PosMaster[];
@OneToMany(() => OrgChild1, (orgChild1) => orgChild1.orgRoot)
orgChild1s: OrgChild1[];

View file

@ -3,6 +3,11 @@ import { EntityBase } from "./base/Base";
import { CreatePosDict } from "./PosDict";
import { OrgRevision } from "./OrgRevision";
import { Position } from "./Position";
import { OrgRoot } from "./OrgRoot";
import { OrgChild1 } from "./OrgChild1";
import { OrgChild2 } from "./OrgChild2";
import { OrgChild3 } from "./OrgChild3";
import { OrgChild4 } from "./OrgChild4";
enum PosMasterLine {
MAIN = "MAIN",
@ -130,10 +135,30 @@ export class PosMaster extends EntityBase {
})
orgRevisionId: string; //fk
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgRoots)
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.posMasters)
@JoinColumn({ name: "orgRevisionId" })
orgRevision: OrgRevision;
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.posMasters)
@JoinColumn({ name: "orgRootId" })
orgRoot: OrgRoot;
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.posMasters)
@JoinColumn({ name: "orgChild1Id" })
orgChild1: OrgChild1;
@ManyToOne(() => OrgChild2, (orgChild2) => orgChild2.posMasters)
@JoinColumn({ name: "orgChild2" })
orgChild2: OrgChild2;
@ManyToOne(() => OrgChild3, (orgChild3) => orgChild3.posMasters)
@JoinColumn({ name: "orgChild3OrgChild3Id" })
orgChild3: OrgChild3;
@ManyToOne(() => OrgChild4, (orgChild4) => orgChild4.posMasters)
@JoinColumn({ name: "orgChild4" })
orgChild4: OrgChild4;
@OneToMany(() => Position, (position) => position.posMaster)
positions: Position[];
}