เพิ่มlink relation

This commit is contained in:
Kittapath 2024-01-31 14:29:39 +07:00
parent a41e33c0d4
commit d74c3140fa
16 changed files with 416 additions and 139 deletions

View file

@ -2,6 +2,9 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToMany, PrimaryGeneratedColum
import { EntityBase } from "./base/Base";
import { OrgRoot } from "./OrgRoot";
import { OrgChild2 } from "./OrgChild2";
import { OrgRevision } from "./OrgRevision";
import { OrgChild3 } from "./OrgChild3";
import { OrgChild4 } from "./OrgChild4";
enum OrgChild1Rank {
DEPARTMENT = "DEPARTMENT",
@ -89,12 +92,22 @@ export class OrgChild1 extends EntityBase {
})
isAncestorDNA: string;
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild1s)
@JoinColumn({ name: "orgRevisionId" })
orgRevision: OrgRevision;
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild1s)
@JoinColumn({ name: "orgRootId" })
orgRoot: OrgRoot;
@OneToMany(() => OrgChild2, (orgChild2) => orgChild2.orgChild1)
orgChild2s: OrgChild2[];
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild1)
orgChild3s: OrgChild3[];
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild1)
orgChild4s: OrgChild4[];
}
export class CreateOrgChild1 {

View file

@ -4,6 +4,7 @@ import { OrgRoot } from "./OrgRoot";
import { OrgChild1 } from "./OrgChild1";
import { OrgChild3 } from "./OrgChild3";
import { OrgChild4 } from "./OrgChild4";
import { OrgRevision } from "./OrgRevision";
// ENUM orgChild2Rank
enum OrgChild2Rank {
@ -105,12 +106,23 @@ export class OrgChild2 extends EntityBase {
})
isAncestorDNA: string;
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild2s)
@JoinColumn({ name: "orgRevisionId" })
orgRevision: OrgRevision;
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild2s)
@JoinColumn({ name: "orgRootId" })
orgRoot: OrgRoot;
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.orgChild2s)
@JoinColumn({ name: "orgChild1Id" })
orgChild1: OrgChild1;
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild2)
orgChild3s: OrgChild3[];
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild2)
orgChild4s: OrgChild4[];
}
export class CreateOrgChild2 {

View file

@ -2,6 +2,9 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { OrgChild2 } from "./OrgChild2";
import { OrgChild4 } from "./OrgChild4";
import { OrgRevision } from "./OrgRevision";
import { OrgChild1 } from "./OrgChild1";
import { OrgRoot } from "./OrgRoot";
enum OrgChild3Rank {
DEPARTMENT = "DEPARTMENT",
@ -101,6 +104,18 @@ export class OrgChild3 extends EntityBase {
})
isAncestorDNA: string;
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild3s)
@JoinColumn({ name: "orgRevisionId" })
orgRevision: OrgRevision;
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild3s)
@JoinColumn({ name: "orgRootId" })
orgRoot: OrgRoot;
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.orgChild3s)
@JoinColumn({ name: "orgChild1Id" })
orgChild1: OrgChild1;
@ManyToOne(() => OrgChild2, (orgChild2) => orgChild2.orgChild3s)
@JoinColumn({ name: "orgChild2Id" })
orgChild2: OrgChild2;

View file

@ -4,6 +4,7 @@ import { OrgRoot } from "./OrgRoot";
import { OrgChild1 } from "./OrgChild1";
import { OrgChild2 } from "./OrgChild2";
import { OrgChild3 } from "./OrgChild3";
import { OrgRevision } from "./OrgRevision";
// ENUM orgChild4Rank
enum OrgChild4Rank {
DEPARTMENT = "DEPARTMENT",
@ -116,6 +117,22 @@ export class OrgChild4 extends EntityBase {
})
isAncestorDNA: string;
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild4s)
@JoinColumn({ name: "orgRevisionId" })
orgRevision: OrgRevision;
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild4s)
@JoinColumn({ name: "orgRootId" })
orgRoot: OrgRoot;
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.orgChild4s)
@JoinColumn({ name: "orgChild1Id" })
orgChild1: OrgChild1;
@ManyToOne(() => OrgChild2, (orgChild2) => orgChild2.orgChild4s)
@JoinColumn({ name: "orgChild2Id" })
orgChild2: OrgChild2;
@ManyToOne(() => OrgChild3, (orgChild3) => orgChild3.orgChild4s)
@JoinColumn({ name: "orgChild3Id" })
orgChild3: OrgChild3;

View file

@ -1,6 +1,11 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { OrgRoot } from "./OrgRoot";
import { PosMaster } from "./PosMaster";
import { OrgChild1 } from "./OrgChild1";
import { OrgChild2 } from "./OrgChild2";
import { OrgChild3 } from "./OrgChild3";
import { OrgChild4 } from "./OrgChild4";
@Entity("orgRevision")
export class OrgRevision extends EntityBase {
@ -46,8 +51,23 @@ export class OrgRevision extends EntityBase {
})
orgRevisionIsDraft: boolean;
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgRevision)
posMasters: PosMaster[];
@OneToMany(() => OrgRoot, (orgRoot) => orgRoot.orgRevision)
orgRoots: OrgRoot[];
@OneToMany(() => OrgChild1, (orgChild1) => orgChild1.orgRevision)
orgChild1s: OrgChild1[];
@OneToMany(() => OrgChild2, (orgChild2) => orgChild2.orgRevision)
orgChild2s: OrgChild2[];
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgRevision)
orgChild3s: OrgChild3[];
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgRevision)
orgChild4s: OrgChild4[];
}
export class CreateOrgRevision {

View file

@ -2,6 +2,9 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "type
import { EntityBase } from "./base/Base";
import { OrgChild1 } from "./OrgChild1";
import { OrgRevision } from "./OrgRevision";
import { OrgChild2 } from "./OrgChild2";
import { OrgChild3 } from "./OrgChild3";
import { OrgChild4 } from "./OrgChild4";
// ENUM orgRootRank
enum OrgRootRank {
@ -91,6 +94,15 @@ export class OrgRoot extends EntityBase {
@OneToMany(() => OrgChild1, (orgChild1) => orgChild1.orgRoot)
orgChild1s: OrgChild1[];
@OneToMany(() => OrgChild2, (orgChild2) => orgChild2.orgChild1)
orgChild2s: OrgChild2[];
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild1)
orgChild3s: OrgChild3[];
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild1)
orgChild4s: OrgChild4[];
}
export class CreateOrgRoot {

View file

@ -1,5 +1,8 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosExecutive } from "./PosExecutive";
import { PosType } from "./PosType";
import { PosLevel } from "./PosLevel";
@Entity("posDict")
export class PosDict extends EntityBase {
@ -24,7 +27,6 @@ export class PosDict extends EntityBase {
comment: "ตำแหน่งประเภท",
default: "00000000-0000-0000-0000-000000000000",
})
posTypeId: string;
@Column({
@ -58,6 +60,17 @@ export class PosDict extends EntityBase {
})
posDictArea: string;
@ManyToOne(() => PosExecutive, (posExecutive) => posExecutive)
@JoinColumn({ name: "posExecutiveId" })
posExecutive: PosExecutive;
@ManyToOne(() => PosType, (posType) => posType)
@JoinColumn({ name: "posTypeId" })
posType: PosType;
@ManyToOne(() => PosLevel, (posLevel) => posLevel)
@JoinColumn({ name: "posLevelId" })
posLevel: PosLevel;
}
export class CreatePosDict {
@ -84,4 +97,3 @@ export class CreatePosDict {
}
export type UpdatePosDict = Partial<CreatePosDict>;

View file

@ -1,19 +1,27 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Position } from "./Position";
import { PosDict } from "./PosDict";
@Entity("posExecutive")
export class PosExecutive extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อตำแหน่งทางการบริหาร",
length: 255,
default: "string",
})
posExecutiveName: string;
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
})
posExecutivePriority: number;
@Column({
nullable: true,
comment: "ชื่อตำแหน่งทางการบริหาร",
length: 255,
default: "string",
})
posExecutiveName: string;
@Column({
nullable: true,
comment: "ลำดับความสำคัญ",
})
posExecutivePriority: number;
@OneToMany(() => Position, (position) => position.posExecutive)
positions: Position[];
@OneToMany(() => PosDict, (posDict) => posDict.posExecutive)
posDicts: PosDict[];
}

View file

@ -1,6 +1,8 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosType } from "./PosType";
import { Position } from "./Position";
import { PosDict } from "./PosDict";
// ENUM PosLevelAuthority
enum PosLevelAuthority {
HEAD = "HEAD",
@ -43,4 +45,9 @@ export class PosLevel extends EntityBase {
@JoinColumn({ name: "posTypeId" })
posType: PosType;
@OneToMany(() => Position, (position) => position.posLevel)
positions: Position[];
@OneToMany(() => PosDict, (posDict) => posDict.posLevel)
posDicts: PosDict[];
}

View file

@ -1,6 +1,8 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { CreatePosDict } from "./PosDict";
import { OrgRevision } from "./OrgRevision";
import { Position } from "./Position";
enum PosMasterLine {
MAIN = "MAIN",
@ -127,6 +129,13 @@ export class PosMaster extends EntityBase {
default: "00000000-0000-0000-0000-000000000000",
})
orgRevisionId: string; //fk
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgRoots)
@JoinColumn({ name: "orgRevisionId" })
orgRevision: OrgRevision;
@OneToMany(() => Position, (position) => position.posMaster)
positions: Position[];
}
export class CreatePosMaster {

View file

@ -1,24 +1,32 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosLevel } from "./PosLevel";
import { Position } from "./Position";
import { PosDict } from "./PosDict";
@Entity("posType")
export class PosType extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)",
length: 255,
default: "string",
})
posTypeName: string;
@Column({
nullable: true,
comment: "ระดับของประเภทตำแหน่ง ไว้ใช้ระบุว่าประเภทตำแหน่งนี้อยู่ระดับสูงหรือต่ำกว่ากัน โดย 1 = ต่ำกว่า , มากกว่า 1 = สูงกว่า ทั่วไป = 1 วิชาการ = 2 อำนวยการ = 3 บริหาร = 4",
})
posTypeRank: number;
@Column({
nullable: true,
comment: "ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)",
length: 255,
default: "string",
})
posTypeName: string;
@OneToMany(() => PosLevel, (posLevel) => posLevel.posType)
posLevels: PosLevel[];
@Column({
nullable: true,
comment:
"ระดับของประเภทตำแหน่ง ไว้ใช้ระบุว่าประเภทตำแหน่งนี้อยู่ระดับสูงหรือต่ำกว่ากัน โดย 1 = ต่ำกว่า , มากกว่า 1 = สูงกว่า ทั่วไป = 1 วิชาการ = 2 อำนวยการ = 3 บริหาร = 4",
})
posTypeRank: number;
@OneToMany(() => PosLevel, (posLevel) => posLevel.posType)
posLevels: PosLevel[];
@OneToMany(() => Position, (position) => position.posType)
positions: Position[];
@OneToMany(() => PosDict, (posDict) => posDict.posType)
posDicts: PosDict[];
}

View file

@ -1,5 +1,9 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosMaster } from "./PosMaster";
import { PosLevel } from "./PosLevel";
import { PosType } from "./PosType";
import { PosExecutive } from "./PosExecutive";
@Entity("position")
export class Position extends EntityBase {
@ -69,6 +73,22 @@ export class Position extends EntityBase {
default: "00000000-0000-0000-0000-000000000000",
})
posMasterId: string;
@ManyToOne(() => PosMaster, (posMaster) => posMaster)
@JoinColumn({ name: "posMasterId" })
posMaster: PosMaster;
@ManyToOne(() => PosExecutive, (posExecutive) => posExecutive)
@JoinColumn({ name: "posExecutiveId" })
posExecutive: PosExecutive;
@ManyToOne(() => PosType, (posType) => posType)
@JoinColumn({ name: "posTypeId" })
posType: PosType;
@ManyToOne(() => PosLevel, (posLevel) => posLevel)
@JoinColumn({ name: "posLevelId" })
posLevel: PosLevel;
}
export class CreatePosition {
@Column()
@ -93,4 +113,4 @@ export class CreatePosition {
positionArea: string;
}
export type UpdatePosition = Partial<CreatePosition>;
export type UpdatePosition = Partial<CreatePosition>;