Merge branch 'develop' into develop-Bright
This commit is contained in:
commit
322c2f3665
2 changed files with 41 additions and 13 deletions
|
|
@ -535,6 +535,7 @@ export class ProfileController extends Controller {
|
|||
const certs = await this.certificateRepository.find({
|
||||
where: { profileId: id },
|
||||
select: ["certificateType", "issuer", "certificateNo", "issueDate"],
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const Cert =
|
||||
certs.length > 0
|
||||
|
|
@ -555,6 +556,7 @@ export class ProfileController extends Controller {
|
|||
const trainings = await this.trainingRepository.find({
|
||||
select: ["startDate", "endDate", "place", "department", "name"],
|
||||
where: { profileId: id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const Training =
|
||||
trainings.length > 0
|
||||
|
|
@ -591,6 +593,7 @@ export class ProfileController extends Controller {
|
|||
const disciplines = await this.disciplineRepository.find({
|
||||
select: ["refCommandDate", "refCommandNo", "detail"],
|
||||
where: { profileId: id },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const Discipline =
|
||||
disciplines.length > 0
|
||||
|
|
@ -612,7 +615,8 @@ export class ProfileController extends Controller {
|
|||
const educations = await this.educationRepository.find({
|
||||
select: ["startDate", "endDate", "educationLevel", "degree", "field", "institute"],
|
||||
where: { profileId: id },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
// order: { lastUpdatedAt: "DESC" },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
const Education =
|
||||
educations.length > 0
|
||||
|
|
@ -765,6 +769,10 @@ export class ProfileController extends Controller {
|
|||
},
|
||||
];
|
||||
|
||||
// const data = {
|
||||
// FullName: ,
|
||||
// };
|
||||
|
||||
return new HttpSuccess({
|
||||
Profile: [Profile],
|
||||
Cert,
|
||||
|
|
@ -775,6 +783,11 @@ export class ProfileController extends Controller {
|
|||
Insignia,
|
||||
Leave,
|
||||
});
|
||||
// return new HttpSuccess({
|
||||
// template: "kk1",
|
||||
// reportName: "docx-report",
|
||||
// data: data,
|
||||
// });
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
|
@ -2747,18 +2760,22 @@ export class ProfileController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
||||
const lastestData = await this.profileFamilyFatherRepository.findOne({
|
||||
let lastestData:any = await this.profileFamilyFatherRepository.findOne({
|
||||
where:{ profileId:id },
|
||||
order:{ createdAt: "DESC" }
|
||||
});
|
||||
if (!lastestData) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบข้อมูลดังกล่าว");
|
||||
}
|
||||
|
||||
Object.keys(body).forEach((key) => {
|
||||
const typedKey = key as keyof UpdateProfileFather; // บอก TypeScript ว่า key เป็นฟิลด์ของ UpdateProfileFather
|
||||
if (body[typedKey] === null || body[typedKey] === "") delete body[typedKey];
|
||||
});
|
||||
|
||||
if (!lastestData) {
|
||||
lastestData = new ProfileFamilyFather();
|
||||
Object.assign(lastestData, body);
|
||||
lastestData.profileId = id;
|
||||
}
|
||||
|
||||
Object.assign(lastestData, body);
|
||||
lastestData.createdUserId = req.user.sub;
|
||||
lastestData.createdFullName = req.user.name;
|
||||
|
|
@ -2795,18 +2812,22 @@ export class ProfileController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
||||
const lastestData = await this.profileFamilyMotherRepository.findOne({
|
||||
let lastestData = await this.profileFamilyMotherRepository.findOne({
|
||||
where:{ profileId:id },
|
||||
order:{ createdAt: "DESC" }
|
||||
});
|
||||
if (!lastestData) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบข้อมูลดังกล่าว");
|
||||
}
|
||||
|
||||
Object.keys(body).forEach((key) => {
|
||||
const typedKey = key as keyof UpdateProfileMother; // บอก TypeScript ว่า key เป็นฟิลด์ของ UpdateProfileMother
|
||||
if (body[typedKey] === null || body[typedKey] === "") delete body[typedKey];
|
||||
});
|
||||
|
||||
if (!lastestData) {
|
||||
lastestData = new ProfileFamilyMother();
|
||||
Object.assign(lastestData, body);
|
||||
lastestData.profileId = id;
|
||||
}
|
||||
|
||||
Object.assign(lastestData, body);
|
||||
lastestData.createdUserId = req.user.sub;
|
||||
lastestData.createdFullName = req.user.name;
|
||||
|
|
@ -2843,18 +2864,22 @@ export class ProfileController extends Controller {
|
|||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
||||
const lastestData = await this.profileFamilyCoupleRepository.findOne({
|
||||
let lastestData = await this.profileFamilyCoupleRepository.findOne({
|
||||
where:{ profileId:id },
|
||||
order:{ createdAt: "DESC" }
|
||||
});
|
||||
if (!lastestData) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบข้อมูลดังกล่าว");
|
||||
}
|
||||
|
||||
Object.keys(body).forEach((key) => {
|
||||
const typedKey = key as keyof UpdateProfileCouple; // บอก TypeScript ว่า key เป็นฟิลด์ของ UpdateProfileCouple
|
||||
if (body[typedKey] === null || body[typedKey] === "") delete body[typedKey];
|
||||
});
|
||||
|
||||
if (!lastestData) {
|
||||
lastestData = new ProfileFamilyCouple();
|
||||
Object.assign(lastestData, body);
|
||||
lastestData.profileId = id;
|
||||
}
|
||||
|
||||
Object.assign(lastestData, body);
|
||||
lastestData.createdUserId = req.user.sub;
|
||||
lastestData.createdFullName = req.user.name;
|
||||
|
|
|
|||
|
|
@ -773,6 +773,7 @@ export type UpdateProfileFather = {
|
|||
fatherLastName?: string | null;
|
||||
fatherCareer?: string | null;
|
||||
fatherLive?: boolean | null;
|
||||
fatherCitizenId?: string | null;
|
||||
};
|
||||
|
||||
export type UpdateProfileMother = {
|
||||
|
|
@ -781,6 +782,7 @@ export type UpdateProfileMother = {
|
|||
motherLastName?: string | null;
|
||||
motherCareer?: string | null;
|
||||
motherLive?: boolean | null;
|
||||
motherCitizenId?: string | null;
|
||||
};
|
||||
|
||||
export type UpdateProfileCouple = {
|
||||
|
|
@ -791,6 +793,7 @@ export type UpdateProfileCouple = {
|
|||
coupleCareer?: string | null;
|
||||
coupleLive?: boolean | null;
|
||||
relationship?: string | null;
|
||||
coupleCitizenId?: string | null;
|
||||
};
|
||||
|
||||
export type UpdateProfileAddress = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue