hrms-api-org/src/entities/Profile.ts
2024-02-07 12:43:49 +07:00

112 lines
3 KiB
TypeScript

import { Entity, Column, OneToMany, OneToOne, JoinColumn, ManyToMany, ManyToOne } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosMaster } from "./PosMaster";
import { PosLevel } from "./PosLevel";
import { PosType } from "./PosType";
@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,
length: 13,
})
citizenId: string;
@Column({
nullable: true,
comment: "ตำแหน่ง",
default: null,
length: 255,
})
position: string;
@Column({
nullable: true,
length: 40,
comment: "ไอดีระดับตำแหน่ง",
})
posLevelId: string;
@Column({
nullable: true,
length: 40,
comment: "ไอดีประเภทตำแหน่",
})
posTypeId: string;
// @Column({
// nullable: true,
// length: 40,
// comment:
// "คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้",
// default: null,
// unique: false,
// })
// current_holderId: string;
// @Column({
// nullable: true,
// length: 40,
// comment:
// "คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย",
// default: null,
// unique: false,
// })
// next_holderId: string;
@OneToMany(() => PosMaster, (posMaster) => posMaster.current_holder)
current_holders: PosMaster[];
@OneToMany(() => PosMaster, (posMaster) => posMaster.next_holder)
next_holders: PosMaster[];
@ManyToOne(() => PosLevel, (posLevel) => posLevel.posLevels)
@JoinColumn({ name: "posLevelId" })
posLevel: PosLevel;
@ManyToOne(() => PosType, (posType) => posType.posTypes)
@JoinColumn({ name: "posTypeId" })
posType: PosType;
}
export class CreateProfile {
@Column()
prefix: string;
@Column()
firstName: string;
@Column()
lastName: string;
@Column()
citizenId: string;
}
export type UpdateProfile = Partial<CreateProfile>;