แก้ วันที่ 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 ProfileFamilyFatherController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyFather = await this.ProfileFamilyFather.findOne({
select: [
"id",
"fatherPrefix",
"fatherFirstName",
"fatherLastName",
"fatherCareer",
"fatherCitizenId",
"fatherLive",
"profileId",
],
where: { profileId: profile.id },
order: { lastUpdatedAt: "DESC" },
});
@ -59,20 +48,6 @@ export class ProfileFamilyFatherController extends Controller {
}
@Get("{profileId}")
@Example({
status: 200,
message: "สำเร็จ",
result: {
id: "6207ae29-05ef-4abb-9a37-a887265d671e",
fatherPrefix: "string",
fatherFirstName: "string",
fatherLastName: "string",
fatherCareer: "string",
fatherCitizenId: "string",
fatherLive: true,
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
})
public async getFamilyFather(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const profile = await this.profileRepo.findOne({
@ -83,16 +58,6 @@ export class ProfileFamilyFatherController extends Controller {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
const familyFather = await this.ProfileFamilyFather.findOne({
select: [
"id",
"fatherPrefix",
"fatherFirstName",
"fatherLastName",
"fatherCareer",
"fatherCitizenId",
"fatherLive",
"profileId",
],
where: { profileId },
order: { lastUpdatedAt: "DESC" },
});
@ -142,29 +107,6 @@ export class ProfileFamilyFatherController 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: "สาวิตรี ศรีสมัย",
fatherPrefix: "string",
fatherFirstName: "string",
fatherLastName: "string",
fatherCareer: "string",
fatherCitizenId: "string",
fatherLive: true,
profileFamilyFatherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201",
},
],
})
public async familyFatherHistory(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const profile = await this.profileRepo.findOne({
@ -216,12 +158,14 @@ export class ProfileFamilyFatherController extends Controller {
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id);
familyFather.fatherCitizenId = Extension.CheckCitizen(String(body.fatherCitizenId));
familyFather.createdUserId = req.user.sub;
familyFather.createdFullName = req.user.name;
familyFather.lastUpdateUserId = req.user.sub;
familyFather.lastUpdateFullName = req.user.name;
familyFather.createdAt = new Date();
familyFather.lastUpdatedAt = new Date();
const history = new ProfileFamilyFatherHistory();
Object.assign(history, { ...familyFather, id: undefined });
@ -239,7 +183,7 @@ export class ProfileFamilyFatherController extends Controller {
@Body() body: UpdateProfileFamilyFather,
@Path() profileId: string,
) {
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId);
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId);
const familyFather = await this.ProfileFamilyFather.findOneBy({ profileId: profileId });
if (!familyFather) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -251,10 +195,13 @@ export class ProfileFamilyFatherController extends Controller {
history.profileFamilyFatherId = familyFather.id; //profileFamilyFatherId
familyFather.lastUpdateUserId = req.user.sub;
familyFather.lastUpdateFullName = req.user.name;
familyFather.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.ProfileFamilyFather.save(familyFather),