เพิ่้มและลบ api history/user
This commit is contained in:
parent
abc4aee8a4
commit
8d1de6365a
22 changed files with 512 additions and 466 deletions
|
|
@ -98,6 +98,47 @@ export class ProfileFamilyMotherController extends Controller {
|
|||
return new HttpSuccess(familyMother);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary ประวัติแก้ไขครอบครัว by keycloak
|
||||
*
|
||||
*/
|
||||
@Get("history/user")
|
||||
public async familyMotherHistoryUser(@Request() request: RequestWithUser) {
|
||||
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
|
||||
const familyMother = await this.ProfileFamilyMother.find({
|
||||
relations: ["histories"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
where: { profileId: profile.id },
|
||||
});
|
||||
|
||||
const mapData = familyMother
|
||||
.flatMap((x) => x.histories)
|
||||
.map((y) => ({
|
||||
id: y.id,
|
||||
createdAt: y.createdAt,
|
||||
createdUserId: y.createdUserId,
|
||||
lastUpdatedAt: y.lastUpdatedAt,
|
||||
lastUpdateUserId: y.lastUpdateUserId,
|
||||
createdFullName: y.createdFullName,
|
||||
lastUpdateFullName: y.lastUpdateFullName,
|
||||
motherPrefix: y.motherPrefix,
|
||||
motherFirstName: y.motherFirstName,
|
||||
motherLastName: y.motherLastName,
|
||||
motherCareer: y.motherCareer,
|
||||
motherCitizenId: y.motherCitizenId,
|
||||
motherLive: y.motherLive,
|
||||
profileFamilyMotherId: y.profileFamilyMotherId,
|
||||
profileId: profile.id,
|
||||
}));
|
||||
|
||||
return new HttpSuccess(mapData);
|
||||
}
|
||||
|
||||
@Get("history/{profileId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue