แก้ วันที่ 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 ProfileFamilyCoupleEmployeeTempController 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: { profileEmployeeId: profile.id },
order: { lastUpdatedAt: "DESC" },
});
@ -61,22 +48,6 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
}
@Get("{profileEmployeeId}")
@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",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyCouple(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const profile = await this.profileRepo.findOne({
@ -87,18 +58,6 @@ export class ProfileFamilyCoupleEmployeeTempController 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",
"profileEmployeeId",
],
where: { profileEmployeeId },
order: { lastUpdatedAt: "DESC" },
});
@ -153,32 +112,10 @@ export class ProfileFamilyCoupleEmployeeTempController extends Controller {
}
@Get("history/{profileEmployeeId}")
@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",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
],
})
public async familyCoupleHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
public async familyCoupleHistory(
@Path() profileEmployeeId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId },
@ -237,6 +174,8 @@ export class ProfileFamilyCoupleEmployeeTempController 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();
await this.ProfileFamilyCouple.save(familyCouple);
profile.relationship = familyCouple.relationship; //update profileEmployee.relationship
@ -271,10 +210,13 @@ export class ProfileFamilyCoupleEmployeeTempController 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),