fix: insignia relations
This commit is contained in:
parent
8339c55472
commit
b0292f3921
4 changed files with 74 additions and 186 deletions
|
|
@ -66,7 +66,14 @@ export class ProfileInsigniaController extends Controller {
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
public async getInsignia(@Path() profileId: string) {
|
public async getInsignia(@Path() profileId: string) {
|
||||||
const record = await this.insigniaRepo.findBy({ profileId });
|
const record = await this.insigniaRepo.find({
|
||||||
|
relations: {
|
||||||
|
insignia: {
|
||||||
|
insigniaType: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
where: { profileId },
|
||||||
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -128,8 +135,15 @@ export class ProfileInsigniaController extends Controller {
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
public async getInsigniaHistory(@Path() InsigniaId: string) {
|
public async getInsigniaHistory(@Path() InsigniaId: string) {
|
||||||
const record = await this.insigniaHistoryRepo.findBy({
|
const record = await this.insigniaHistoryRepo.find({
|
||||||
profileInsigniaId: InsigniaId,
|
relations: {
|
||||||
|
insignia: {
|
||||||
|
insigniaType: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
profileInsigniaId: InsigniaId,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { InsigniaType } from "./InsigniaType";
|
import { InsigniaType } from "./InsigniaType";
|
||||||
|
import { ProfileInsignia } from "./ProfileInsignia";
|
||||||
|
import { ProfileInsigniaHistory } from "./ProfileInsigniaHistory";
|
||||||
|
|
||||||
@Entity("insignia")
|
@Entity("insignia")
|
||||||
export class Insignia extends EntityBase {
|
export class Insignia extends EntityBase {
|
||||||
|
|
@ -50,6 +52,14 @@ export class Insignia extends EntityBase {
|
||||||
@ManyToOne(() => InsigniaType, (insigniaType) => insigniaType.insignias)
|
@ManyToOne(() => InsigniaType, (insigniaType) => insigniaType.insignias)
|
||||||
@JoinColumn({ name: "insigniaTypeId" })
|
@JoinColumn({ name: "insigniaTypeId" })
|
||||||
insigniaType: InsigniaType;
|
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 {
|
export class CreateInsignias {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { Profile } from "./Profile";
|
import { Profile } from "./Profile";
|
||||||
import { ProfileInsigniaHistory } from "./ProfileInsigniaHistory";
|
import { ProfileInsigniaHistory } from "./ProfileInsigniaHistory";
|
||||||
|
import { Insignia } from "./Insignia";
|
||||||
|
|
||||||
@Entity("profileInsignia")
|
@Entity("profileInsignia")
|
||||||
export class ProfileInsignia extends EntityBase {
|
export class ProfileInsignia extends EntityBase {
|
||||||
|
|
@ -64,22 +65,6 @@ export class ProfileInsignia extends EntityBase {
|
||||||
})
|
})
|
||||||
receiveDate: Date;
|
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({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
type: "datetime",
|
type: "datetime",
|
||||||
|
|
@ -127,6 +112,17 @@ export class ProfileInsignia extends EntityBase {
|
||||||
})
|
})
|
||||||
note: string;
|
note: string;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง Insignia",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
insigniaId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => Insignia, (v) => v.profileInsignias)
|
||||||
|
insignia: Insignia;
|
||||||
|
|
||||||
@OneToMany(
|
@OneToMany(
|
||||||
() => ProfileInsigniaHistory,
|
() => ProfileInsigniaHistory,
|
||||||
(profileInsigniaHistory) => profileInsigniaHistory.histories,
|
(profileInsigniaHistory) => profileInsigniaHistory.histories,
|
||||||
|
|
@ -139,53 +135,39 @@ export class ProfileInsignia extends EntityBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateProfileInsignia {
|
export class CreateProfileInsignia {
|
||||||
@Column("uuid")
|
|
||||||
profileId: string | null;
|
profileId: string | null;
|
||||||
|
|
||||||
@Column()
|
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
|
|
||||||
@Column()
|
|
||||||
year: number;
|
year: number;
|
||||||
|
|
||||||
@Column()
|
|
||||||
no: string | null;
|
no: string | null;
|
||||||
|
|
||||||
@Column()
|
|
||||||
volume: string | null;
|
volume: string | null;
|
||||||
|
|
||||||
@Column()
|
|
||||||
section: string | null;
|
section: string | null;
|
||||||
|
|
||||||
@Column()
|
|
||||||
page: string | null;
|
page: string | null;
|
||||||
|
|
||||||
@Column()
|
|
||||||
receiveDate: Date | null;
|
receiveDate: Date | null;
|
||||||
|
|
||||||
@Column("uuid")
|
|
||||||
insigniaId: string | null;
|
insigniaId: string | null;
|
||||||
|
|
||||||
@Column()
|
|
||||||
insigniaType: string | null;
|
insigniaType: string | null;
|
||||||
|
|
||||||
@Column()
|
|
||||||
dateAnnounce: Date | null;
|
dateAnnounce: Date | null;
|
||||||
|
|
||||||
@Column()
|
|
||||||
issue: string | null;
|
issue: string | null;
|
||||||
|
|
||||||
@Column()
|
|
||||||
volumeNo: string | null;
|
volumeNo: string | null;
|
||||||
|
|
||||||
@Column()
|
|
||||||
refCommandDate: Date | null;
|
refCommandDate: Date | null;
|
||||||
|
|
||||||
@Column()
|
|
||||||
refCommandNo: string | null;
|
refCommandNo: string | null;
|
||||||
|
|
||||||
@Column()
|
|
||||||
note: string | null;
|
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;
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { Profile } from "./Profile";
|
|
||||||
import { ProfileInsignia } from "./ProfileInsignia";
|
import { ProfileInsignia } from "./ProfileInsignia";
|
||||||
|
import { Insignia } from "./Insignia";
|
||||||
|
|
||||||
@Entity("profileInsigniaHistory")
|
@Entity("profileInsigniaHistory")
|
||||||
export class ProfileInsigniaHistory extends EntityBase {
|
export class ProfileInsigniaHistory extends EntityBase {
|
||||||
|
|
@ -11,112 +11,46 @@ export class ProfileInsigniaHistory extends EntityBase {
|
||||||
})
|
})
|
||||||
isActive: boolean;
|
isActive: boolean;
|
||||||
|
|
||||||
@Column({
|
@Column({ comment: "ปีที่ยื่นขอ" })
|
||||||
comment: "ปีที่ยื่นขอ",
|
|
||||||
})
|
|
||||||
year: number;
|
year: number;
|
||||||
|
|
||||||
@Column({
|
@Column({ nullable: true, length: 20, comment: "ลำดับที่", default: null })
|
||||||
nullable: true,
|
|
||||||
length: 20,
|
|
||||||
comment: "ลำดับที่",
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
no: string;
|
no: string;
|
||||||
|
|
||||||
@Column({
|
@Column({ nullable: true, length: 30, comment: "เล่ม", default: null })
|
||||||
nullable: true,
|
|
||||||
length: 30,
|
|
||||||
comment: "เล่ม",
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
volume: string;
|
volume: string;
|
||||||
|
|
||||||
@Column({
|
@Column({ nullable: true, length: 30, comment: "ตอน", default: null })
|
||||||
nullable: true,
|
|
||||||
length: 30,
|
|
||||||
comment: "ตอน",
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
section: string;
|
section: string;
|
||||||
|
|
||||||
@Column({
|
@Column({ nullable: true, length: 30, comment: "หน้า", default: null })
|
||||||
nullable: true,
|
|
||||||
length: 30,
|
|
||||||
comment: "หน้า",
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
page: string;
|
page: string;
|
||||||
|
|
||||||
@Column({
|
@Column({ nullable: true, type: "datetime", comment: "ลงวันที่", default: null })
|
||||||
nullable: true,
|
|
||||||
type: "datetime",
|
|
||||||
comment: "ลงวันที่",
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
receiveDate: Date;
|
receiveDate: Date;
|
||||||
|
|
||||||
@Column({
|
@Column({ nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง Insignia", default: null })
|
||||||
nullable: true,
|
|
||||||
length: 40,
|
|
||||||
comment: "คีย์นอก(FK)ของตาราง Insignia",
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
insigniaId: string;
|
insigniaId: string;
|
||||||
|
|
||||||
@Column({
|
@ManyToOne(() => Insignia, (v) => v.profileInsigniaHistories)
|
||||||
nullable: true,
|
insignia: Insignia;
|
||||||
comment: "ประเภท",
|
|
||||||
type: "text",
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
insigniaType: string;
|
|
||||||
|
|
||||||
@Column({
|
@Column({ nullable: true, type: "datetime", comment: "วันที่ประกาศในราชกิจจาฯ", default: null })
|
||||||
nullable: true,
|
|
||||||
type: "datetime",
|
|
||||||
comment: "วันที่ประกาศในราชกิจจาฯ",
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
dateAnnounce: Date;
|
dateAnnounce: Date;
|
||||||
|
|
||||||
@Column({
|
@Column({ nullable: true, length: 300, comment: "ราชกิจจาฯ ฉบับที่", default: null })
|
||||||
nullable: true,
|
|
||||||
length: 300,
|
|
||||||
comment: "ราชกิจจาฯ ฉบับที่",
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
issue: string;
|
issue: string;
|
||||||
|
|
||||||
@Column({
|
@Column({ nullable: true, length: 30, comment: "เล่มที่", default: null })
|
||||||
nullable: true,
|
|
||||||
length: 30,
|
|
||||||
comment: "เล่มที่",
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
volumeNo: string;
|
volumeNo: string;
|
||||||
|
|
||||||
@Column({
|
@Column({ nullable: true, type: "datetime", comment: "เอกสารอ้างอิง (ลงวันที่)", default: null })
|
||||||
nullable: true,
|
|
||||||
type: "datetime",
|
|
||||||
comment: "เอกสารอ้างอิง (ลงวันที่)",
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
refCommandDate: Date;
|
refCommandDate: Date;
|
||||||
|
|
||||||
@Column({
|
@Column({ nullable: true, comment: "เอกสารอ้างอิง (เลขที่คำสั่ง)", type: "text", default: null })
|
||||||
nullable: true,
|
|
||||||
comment: "เอกสารอ้างอิง (เลขที่คำสั่ง)",
|
|
||||||
type: "text",
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
refCommandNo: string;
|
refCommandNo: string;
|
||||||
|
|
||||||
@Column({
|
@Column({ nullable: true, comment: "หมายเหตุ", default: null })
|
||||||
nullable: true,
|
|
||||||
comment: "หมายเหตุ",
|
|
||||||
default: null,
|
|
||||||
})
|
|
||||||
note: string;
|
note: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
|
|
@ -131,55 +65,3 @@ export class ProfileInsigniaHistory extends EntityBase {
|
||||||
@JoinColumn({ name: "profileInsigniaId" })
|
@JoinColumn({ name: "profileInsigniaId" })
|
||||||
histories: ProfileInsignia;
|
histories: ProfileInsignia;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateProfileInsigniaHistory {
|
|
||||||
@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;
|
|
||||||
|
|
||||||
@Column("uuid")
|
|
||||||
profileInsigniaId: string | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type UpdateProfileInsigniaHistory = Partial<CreateProfileInsigniaHistory>;
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue