เพิ่้มและลบ api history/user
This commit is contained in:
parent
abc4aee8a4
commit
8d1de6365a
22 changed files with 512 additions and 466 deletions
|
|
@ -134,6 +134,38 @@ export class ProfileFamilyHistoryController extends Controller {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary ประวัติแก้ไขครอบครัว by keycloak
|
||||
*
|
||||
*/
|
||||
@Get("history/user")
|
||||
public async familyHistoryUser(@Request() request: RequestWithUser) {
|
||||
const profile = await this.profileRepo.findOneBy({ keycloak: request.user.sub });
|
||||
if (!profile) {
|
||||
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
|
||||
}
|
||||
const family = await this.familyHistoryRepo.find({
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
where: {
|
||||
profileId: profile.id
|
||||
},
|
||||
});
|
||||
|
||||
family.shift();
|
||||
|
||||
const record = await Promise.all(
|
||||
family.map(async (v) => ({
|
||||
...v,
|
||||
children: await this.childrenHistoryRepo.find({
|
||||
order: { createdAt: "ASC" },
|
||||
}),
|
||||
})),
|
||||
);
|
||||
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
||||
@Get("history/{profileId}")
|
||||
@Example({
|
||||
status: 200,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue