แก้ api เก็บประวัติแก้ทะเบียน

This commit is contained in:
kittapath 2024-08-13 17:43:30 +07:00
parent 576f6bcc0d
commit fd3f1fa515
62 changed files with 855 additions and 1471 deletions

View file

@ -164,15 +164,21 @@ export class ProfileAssessmentsController extends Controller {
lastUpdateFullName: req.user.name,
};
Object.assign(data, { ...body, ...meta });
const history = new ProfileAssessmentHistory();
history.profileAssessmentId = data.id;
await this.profileAssessmentsRepository.save(data);
await Promise.all([
this.profileAssessmentsRepository.save(data),
(history.profileAssessmentId = data.id),
this.profileAssessmentsHistoryRepository.save(history),
]);
return new HttpSuccess();
}
@Patch("{assessmentId}")
public async editProfileAssessment(
@Body() requestBody: UpdateProfileAssessment,
@Body() body: UpdateProfileAssessment,
@Request() req: RequestWithUser,
@Path() assessmentId: string,
) {
@ -182,17 +188,22 @@ export class ProfileAssessmentsController extends Controller {
const history = new ProfileAssessmentHistory();
Object.assign(history, { ...record, id: undefined });
Object.assign(record, requestBody);
Object.assign(record, body);
Object.assign(history, body);
history.profileAssessmentId = assessmentId;
history.lastUpdateFullName = req.user.name;
record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name;
history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;
history.createdFullName = req.user.name;
await Promise.all([
this.profileAssessmentsRepository.save(record),
this.profileAssessmentsHistoryRepository.save(history),
]);
return new HttpSuccess();
}