fix: insignia relations

This commit is contained in:
Methapon2001 2024-03-18 18:03:01 +07:00
parent 8339c55472
commit b0292f3921
4 changed files with 74 additions and 186 deletions

View file

@ -2,6 +2,7 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Profile } from "./Profile";
import { ProfileInsigniaHistory } from "./ProfileInsigniaHistory";
import { Insignia } from "./Insignia";
@Entity("profileInsignia")
export class ProfileInsignia extends EntityBase {
@ -64,22 +65,6 @@ export class ProfileInsignia extends EntityBase {
})
receiveDate: Date;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง Insignia",
default: null,
})
insigniaId: string;
@Column({
nullable: true,
comment: "ประเภท",
type: "text",
default: null,
})
insigniaType: string;
@Column({
nullable: true,
type: "datetime",
@ -127,6 +112,17 @@ export class ProfileInsignia extends EntityBase {
})
note: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง Insignia",
default: null,
})
insigniaId: string;
@ManyToOne(() => Insignia, (v) => v.profileInsignias)
insignia: Insignia;
@OneToMany(
() => ProfileInsigniaHistory,
(profileInsigniaHistory) => profileInsigniaHistory.histories,
@ -139,53 +135,39 @@ export class ProfileInsignia extends EntityBase {
}
export class CreateProfileInsignia {
@Column("uuid")
profileId: string | null;
@Column()
isActive: boolean;
@Column()
year: number;
@Column()
no: string | null;
@Column()
volume: string | null;
@Column()
section: string | null;
@Column()
page: string | null;
@Column()
receiveDate: Date | null;
@Column("uuid")
insigniaId: string | null;
@Column()
insigniaType: string | null;
@Column()
dateAnnounce: Date | null;
@Column()
issue: string | null;
@Column()
volumeNo: string | null;
@Column()
refCommandDate: Date | null;
@Column()
refCommandNo: string | null;
@Column()
note: string | null;
}
export type UpdateProfileInsignia = Partial<CreateProfileInsignia>;
export type UpdateProfileInsignia = {
profileId?: string | null;
isActive?: boolean;
year?: number;
no?: string | null;
volume?: string | null;
section?: string | null;
page?: string | null;
receiveDate?: Date | null;
insigniaId?: string | null;
insigniaType?: string | null;
dateAnnounce?: Date | null;
issue?: string | null;
volumeNo?: string | null;
refCommandDate?: Date | null;
refCommandNo?: string | null;
note?: string | null;
};