แก้ วันที่ update

This commit is contained in:
kittapath 2024-08-30 18:02:34 +07:00
parent 6d36c9b05f
commit 218886b3f4
83 changed files with 1671 additions and 3483 deletions

View file

@ -2,7 +2,6 @@ import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
Path,
@ -18,9 +17,7 @@ import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { ProfileChildrenHistory } from "../entities/ProfileChildrenHistory";
import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import {
CreateProfileChildren,
CreateProfileChildrenEmployee,
ProfileChildren,
UpdateProfileChildren,
@ -44,6 +41,7 @@ export class ProfileChildrenEmployeeTempController extends Controller {
}
const lists = await this.childrenRepository.find({
where: { profileEmployeeId: profile.id },
order: { createdAt: "ASC" },
});
return new HttpSuccess(lists);
}
@ -53,6 +51,7 @@ export class ProfileChildrenEmployeeTempController extends Controller {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const lists = await this.childrenRepository.find({
where: { profileEmployeeId: profileEmployeeId },
order: { createdAt: "ASC" },
});
return new HttpSuccess(lists);
}
@ -86,6 +85,8 @@ export class ProfileChildrenEmployeeTempController extends Controller {
createdFullName: req.user.name,
lastUpdateUserId: req.user.sub,
lastUpdateFullName: req.user.name,
createdAt: new Date(),
lastUpdatedAt: new Date(),
};
Object.assign(data, { ...body, ...meta });
@ -112,16 +113,19 @@ export class ProfileChildrenEmployeeTempController extends Controller {
const history = new ProfileChildrenHistory();
Object.assign(record, body);
Object.assign(history, body);
Object.assign(history, { ...body, id: undefined });
record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId));
history.profileChildrenId = record.id;
record.lastUpdateUserId = req.user.sub;
record.lastUpdateFullName = req.user.name;
record.lastUpdatedAt = new Date();
history.lastUpdateUserId = req.user.sub;
history.lastUpdateFullName = req.user.name;
history.createdUserId = req.user.sub;
history.createdFullName = req.user.name;
history.createdAt = new Date();
history.lastUpdatedAt = new Date();
await Promise.all([
this.childrenRepository.save(record),