ปรับ family
This commit is contained in:
parent
0524653f4b
commit
3e62126570
6 changed files with 19 additions and 5 deletions
|
|
@ -33,7 +33,7 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
@Example({
|
||||
status: 200,
|
||||
message: "สำเร็จ",
|
||||
result: [{
|
||||
result: {
|
||||
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
|
||||
couple: true,
|
||||
couplePrefix: "string",
|
||||
|
|
@ -45,7 +45,7 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
coupleLive: true,
|
||||
relationship: "string",
|
||||
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
|
||||
}],
|
||||
},
|
||||
})
|
||||
public async getFamilyCouple(@Path() profileId: string) {
|
||||
const profile = await this.profileRepo.findOne({
|
||||
|
|
@ -55,12 +55,13 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const familyCouple = await this.ProfileFamilyCouple.find({
|
||||
const familyCouple = await this.ProfileFamilyCouple.findOne({
|
||||
select: [
|
||||
"id", "couple", "couplePrefix", "coupleFirstName", "coupleLastName", "coupleLastNameOld",
|
||||
"coupleCareer", "coupleCitizenId", "coupleLive", "relationship", "profileId",
|
||||
],
|
||||
where: { profileId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
||||
return new HttpSuccess(familyCouple);
|
||||
|
|
@ -150,6 +151,7 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
await this.ProfileFamilyCouple.save(familyCouple);
|
||||
|
||||
if (familyCouple) {
|
||||
profile.relationship = familyCouple.relationship //update profile.relationship
|
||||
const history: ProfileFamilyCoupleHistory = Object.assign(new ProfileFamilyCoupleHistory(), {
|
||||
profileFamilyCoupleId: familyCouple.id,
|
||||
couple: familyCouple.couple,
|
||||
|
|
@ -165,7 +167,10 @@ export class ProfileFamilyCoupleController extends Controller {
|
|||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
});
|
||||
await this.ProfileFamilyCoupleHistory.save(history);
|
||||
await Promise.all([
|
||||
this.profileRepo.save(profile),
|
||||
this.ProfileFamilyCoupleHistory.save(history)
|
||||
]);
|
||||
}
|
||||
return new HttpSuccess(familyCouple.id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
|||
"coupleCareer", "coupleCitizenId", "coupleLive", "relationship", "profileEmployeeId",
|
||||
],
|
||||
where: { profileEmployeeId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
||||
return new HttpSuccess(familyCouple);
|
||||
|
|
@ -150,6 +151,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
|||
await this.ProfileFamilyCouple.save(familyCouple);
|
||||
|
||||
if (familyCouple) {
|
||||
profile.relationship = familyCouple.relationship //update profileEmployee.relationship
|
||||
const history: ProfileFamilyCoupleHistory = Object.assign(new ProfileFamilyCoupleHistory(), {
|
||||
profileFamilyCoupleId: familyCouple.id,
|
||||
couple: familyCouple.couple,
|
||||
|
|
@ -165,7 +167,10 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
|
|||
lastUpdateUserId: req.user.sub,
|
||||
lastUpdateFullName: req.user.name,
|
||||
});
|
||||
await this.ProfileFamilyCoupleHistory.save(history);
|
||||
await Promise.all([
|
||||
this.profileRepo.save(profile),
|
||||
this.ProfileFamilyCoupleHistory.save(history)
|
||||
]);
|
||||
}
|
||||
return new HttpSuccess(familyCouple.id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ export class ProfileFamilyFatherController extends Controller {
|
|||
"fatherCareer", "fatherCitizenId", "fatherLive", "profileId",
|
||||
],
|
||||
where: { profileId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
||||
return new HttpSuccess(familyFather);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
|
|||
"fatherCareer", "fatherCitizenId", "fatherLive", "profileEmployeeId",
|
||||
],
|
||||
where: { profileEmployeeId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
||||
return new HttpSuccess(familyFather);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ export class ProfileFamilyMotherController extends Controller {
|
|||
"motherCareer", "motherCitizenId", "motherLive", "profileId",
|
||||
],
|
||||
where: { profileId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
||||
return new HttpSuccess(familyMother);
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
|
|||
"motherCareer", "motherCitizenId", "motherLive", "profileEmployeeId",
|
||||
],
|
||||
where: { profileEmployeeId },
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
|
||||
return new HttpSuccess(familyMother);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue