แก้ วันที่ 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

@ -1,7 +1,6 @@
import {
Body,
Controller,
Delete,
Example,
Get,
Patch,
@ -41,18 +40,6 @@ export class ProfileFamilyCoupleController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyCouple = await this.ProfileFamilyCouple.findOne({
select: [
"id",
"couplePrefix",
"coupleFirstName",
"coupleLastName",
"coupleLastNameOld",
"coupleCareer",
"coupleCitizenId",
"coupleLive",
"relationship",
"profileId",
],
where: { profileId: profile.id },
order: { lastUpdatedAt: "DESC" },
});
@ -61,22 +48,6 @@ export class ProfileFamilyCoupleController extends Controller {
}
@Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
couplePrefix: "string",
coupleFirstName: "string",
coupleLastName: "string",
coupleLastNameOld: "string",
coupleCareer: "string",
coupleCitizenId: "string",
coupleLive: true,
relationship: "string",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyCouple(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const profile = await this.profileRepo.findOne({
@ -87,18 +58,6 @@ export class ProfileFamilyCoupleController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyCouple = await this.ProfileFamilyCouple.findOne({
select: [
"id",
"couplePrefix",
"coupleFirstName",
"coupleLastName",
"coupleLastNameOld",
"coupleCareer",
"coupleCitizenId",
"coupleLive",
"relationship",
"profileId",
],
where: { profileId },
order: { lastUpdatedAt: "DESC" },
});
@ -152,31 +111,6 @@ export class ProfileFamilyCoupleController extends Controller {
}
@Get("history/{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: [
{
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
createdAt: "2024-03-19T11:00:29.769Z",
createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
lastUpdatedAt: "2024-03-19T11:00:29.769Z",
lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0",
createdFullName: "สาวิตรี ศรีสมัย",
lastUpdateFullName: "สาวิตรี ศรีสมัย",
couplePrefix: "string",
coupleFirstName: "string",
coupleLastName: "string",
coupleLastNameOld: "string",
coupleCareer: "string",
coupleCitizenId: "string",
coupleLive: true,
relationship: "string",
profileFamilyCoupleId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
],
})
public async familyCoupleHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const profile = await this.profileRepo.findOne({
@ -236,6 +170,8 @@ export class ProfileFamilyCoupleController extends Controller {
familyCouple.createdFullName = req.user.name;
familyCouple.lastUpdateUserId = req.user.sub;
familyCouple.lastUpdateFullName = req.user.name;
familyCouple.createdAt = new Date();
familyCouple.lastUpdatedAt = new Date();
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
const history = new ProfileFamilyCoupleHistory();
@ -267,10 +203,13 @@ export class ProfileFamilyCoupleController extends Controller {
history.profileFamilyCoupleId = familyCouple.id;
familyCouple.lastUpdateUserId = req.user.sub;
familyCouple.lastUpdateFullName = req.user.name;
familyCouple.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.ProfileFamilyCouple.save(familyCouple),