hrms-api-org/src/entities/Insignia.ts
2024-03-18 18:03:01 +07:00

82 lines
2 KiB
TypeScript

import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { InsigniaType } from "./InsigniaType";
import { ProfileInsignia } from "./ProfileInsignia";
import { ProfileInsigniaHistory } from "./ProfileInsigniaHistory";
@Entity("insignia")
export class Insignia extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อเครื่องราช",
length: 255,
default: null,
})
name: string;
@Column({
nullable: true,
comment: "ชื่อย่อเครื่องราช",
length: 255,
default: null,
})
shortName: string;
@Column({
nullable: true,
comment:
"ลำดับชั้นของเครื่องราช เอาไว้ตรวจสอบเวลาขอว่าต้องได้ชั้นที่สูงกว่าที่เคยได้รับแล้วเท่านั้น",
default: null,
})
level: number;
@Column({
comment: "สถานะการใช้งาน",
default: false,
})
isActive: boolean;
@Column({
nullable: true,
comment: "หมายเหตุ",
default: null,
})
note: string;
@Column({
length: 40,
comment: "id ประเภทเครื่องราช",
})
insigniaTypeId: string;
@ManyToOne(() => InsigniaType, (insigniaType) => insigniaType.insignias)
@JoinColumn({ name: "insigniaTypeId" })
insigniaType: InsigniaType;
@OneToMany(() => ProfileInsignia, (v) => v.insignia)
@JoinColumn({ name: "insigniaId" })
profileInsignias: ProfileInsignia;
@OneToMany(() => ProfileInsigniaHistory, (v) => v.insignia)
@JoinColumn({ name: "insigniaHistoryId" })
profileInsigniaHistories: ProfileInsigniaHistory;
}
export class CreateInsignias {
@Column()
name: string;
@Column()
shortName: string;
@Column()
isActive: boolean;
@Column()
note: string;
@Column("uuid")
insigniaTypeId: string;
}
export type UpdateInsignias = Partial<CreateInsignias>;