แก้ วันที่ 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,16 +40,6 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyMother = await this.ProfileFamilyMother.findOne({
select: [
"id",
"motherPrefix",
"motherFirstName",
"motherLastName",
"motherCareer",
"motherCitizenId",
"motherLive",
"profileId",
],
where: { profileEmployeeId: profile.id },
order: { lastUpdatedAt: "DESC" },
});
@ -59,20 +48,6 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
}
@Get("{profileEmployeeId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
motherPrefix: "string",
motherFirstName: "string",
motherLastName: "string",
motherCareer: "string",
motherCitizenId: "string",
motherLive: true,
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyMother(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const profile = await this.profileRepo.findOne({
@ -83,16 +58,6 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyMother = await this.ProfileFamilyMother.findOne({
select: [
"id",
"motherPrefix",
"motherFirstName",
"motherLastName",
"motherCareer",
"motherCitizenId",
"motherLive",
"profileEmployeeId",
],
where: { profileEmployeeId },
order: { lastUpdatedAt: "DESC" },
});
@ -142,30 +107,10 @@ export class ProfileFamilyMotherEmployeeController 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: "สาวิตรี ศรีสมัย",
motherPrefix: "string",
motherFirstName: "string",
motherLastName: "string",
motherCareer: "string",
motherCitizenId: "string",
motherLive: true,
profileFamilyMotherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
],
})
public async familyMotherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
public async familyMotherHistory(
@Path() profileEmployeeId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const profile = await this.profileRepo.findOne({
where: { id: profileEmployeeId },
@ -221,6 +166,8 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
familyMother.createdFullName = req.user.name;
familyMother.lastUpdateUserId = req.user.sub;
familyMother.lastUpdateFullName = req.user.name;
familyMother.createdAt = new Date();
familyMother.lastUpdatedAt = new Date();
const history = new ProfileFamilyMotherHistory();
Object.assign(history, { ...familyMother, id: undefined });
@ -252,10 +199,13 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
history.profileFamilyMotherId = familyMother.id;
familyMother.lastUpdateUserId = req.user.sub;
familyMother.lastUpdateFullName = req.user.name;
familyMother.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.ProfileFamilyMother.save(familyMother),