From 218886b3f466b0c269edc81e18c57f3909f6b880 Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 30 Aug 2024 18:02:34 +0700 Subject: [PATCH 1/3] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=20=E0=B8=A7?= =?UTF-8?q?=E0=B8=B1=E0=B8=99=E0=B8=97=E0=B8=B5=E0=B9=88=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/AuthRoleAttrController.ts | 4 + src/controllers/AuthRoleController.ts | 12 +- src/controllers/AuthSysController.ts | 4 + src/controllers/BloodGroupController.ts | 3 + src/controllers/ChangePositionController.ts | 21 +- src/controllers/DistrictController.ts | 3 + src/controllers/EducationLevelController.ts | 3 + src/controllers/EmployeePositionController.ts | 25 +- src/controllers/OrganizationController.ts | 14 + .../OrganizationDotnetController.ts | 2 + src/controllers/ProfileAbilityController.ts | 76 +--- .../ProfileAbilityEmployeeController.ts | 117 ++---- .../ProfileAbilityEmployeeTempController.ts | 94 ++--- src/controllers/ProfileAddressController.ts | 81 +--- .../ProfileAddressEmployeeController.ts | 90 +--- .../ProfileAddressEmployeeTempController.ts | 78 +--- .../ProfileAssessmentsController.ts | 104 +---- .../ProfileAssessmentsEmployeeController.ts | 117 ++---- ...rofileAssessmentsEmployeeTempController.ts | 103 ++--- src/controllers/ProfileAvatarController.ts | 22 +- .../ProfileAvatarEmployeeController.ts | 11 +- .../ProfileAvatarEmployeeTempController.ts | 7 +- .../ProfileCertificateController.ts | 97 ++--- .../ProfileCertificateEmployeeController.ts | 106 ++--- ...rofileCertificateEmployeeTempController.ts | 78 +--- .../ProfileChangeNameController.ts | 67 +-- .../ProfileChangeNameEmployeeController.ts | 91 ++--- ...ProfileChangeNameEmployeeTempController.ts | 58 +-- src/controllers/ProfileChildrenController.ts | 16 +- .../ProfileChildrenEmployeeController.ts | 39 +- .../ProfileChildrenEmployeeTempController.ts | 12 +- src/controllers/ProfileController.ts | 30 +- .../ProfileDevelopmentController.ts | 43 +- .../ProfileDevelopmentEmployeeController.ts | 10 +- ...rofileDevelopmentEmployeeTempController.ts | 10 +- .../ProfileDisciplineController.ts | 89 +--- .../ProfileDisciplineEmployeeController.ts | 88 ++-- ...ProfileDisciplineEmployeeTempController.ts | 70 +--- src/controllers/ProfileDutyController.ts | 78 +--- .../ProfileDutyEmployeeController.ts | 57 ++- .../ProfileDutyEmployeeTempController.ts | 39 +- src/controllers/ProfileEditController.ts | 42 +- .../ProfileEditEmployeeController.ts | 4 +- .../ProfileEducationsController.ts | 140 ++----- .../ProfileEducationsEmployeeController.ts | 155 ++----- ...ProfileEducationsEmployeeTempController.ts | 135 +----- src/controllers/ProfileEmployeeController.ts | 54 ++- .../ProfileEmployeeTempController.ts | 1 + .../ProfileFamilyCoupleController.ts | 71 +--- .../ProfileFamilyCoupleEmployeeController.ts | 78 +--- ...ofileFamilyCoupleEmployeeTempController.ts | 76 +--- .../ProfileFamilyFatherController.ts | 67 +-- .../ProfileFamilyFatherEmployeeController.ts | 68 +-- ...ofileFamilyFatherEmployeeTempController.ts | 68 +-- .../ProfileFamilyMotherController.ts | 67 +-- .../ProfileFamilyMotherEmployeeController.ts | 68 +-- ...ofileFamilyMotherEmployeeTempController.ts | 68 +-- .../ProfileGovernmentController.ts | 11 +- .../ProfileGovernmentEmployeeController.ts | 15 +- ...ProfileGovernmentEmployeeTempController.ts | 11 +- src/controllers/ProfileHonorController.ts | 94 ++--- .../ProfileHonorEmployeeController.ts | 102 ++--- .../ProfileHonorEmployeeTempController.ts | 82 +--- src/controllers/ProfileInsigniaController.ts | 117 ++---- .../ProfileInsigniaEmployeeController.ts | 115 ++---- .../ProfileInsigniaEmployeeTempController.ts | 95 +---- src/controllers/ProfileLeaveController.ts | 131 +----- .../ProfileLeaveEmployeeController.ts | 31 +- .../ProfileLeaveEmployeeTempController.ts | 12 +- src/controllers/ProfileNopaidController.ts | 62 +-- .../ProfileNopaidEmployeeController.ts | 29 +- .../ProfileNopaidEmployeeTempController.ts | 10 +- src/controllers/ProfileOtherController.ts | 56 +-- .../ProfileOtherEmployeeController.ts | 29 +- .../ProfileOtherEmployeeTempController.ts | 9 +- src/controllers/ProfileSalaryController.ts | 108 ++--- .../ProfileSalaryEmployeeController.ts | 57 ++- .../ProfileSalaryEmployeeTempController.ts | 15 +- src/controllers/ProfileTrainingController.ts | 107 +---- .../ProfileTrainingEmployeeController.ts | 117 ++---- .../ProfileTrainingEmployeeTempController.ts | 98 +---- src/entities/base/Base.ts | 24 +- .../1725011784785-update_base_date.ts | 386 ++++++++++++++++++ 83 files changed, 1671 insertions(+), 3483 deletions(-) create mode 100644 src/migration/1725011784785-update_base_date.ts diff --git a/src/controllers/AuthRoleAttrController.ts b/src/controllers/AuthRoleAttrController.ts index 72cf6b44..9a564115 100644 --- a/src/controllers/AuthRoleAttrController.ts +++ b/src/controllers/AuthRoleAttrController.ts @@ -68,6 +68,8 @@ export class AuthRoleAttrController 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 }); @@ -101,7 +103,9 @@ export class AuthRoleAttrController extends Controller { body.authSysId = body.authSysId?.toUpperCase(); Object.assign(record, body); + record.lastUpdateUserId = req.user.sub; record.lastUpdateFullName = req.user.name; + record.lastUpdatedAt = new Date(); await Promise.all([this.authRoleAttrRepo.save(record)]); diff --git a/src/controllers/AuthRoleController.ts b/src/controllers/AuthRoleController.ts index 8f31b3af..a413d5af 100644 --- a/src/controllers/AuthRoleController.ts +++ b/src/controllers/AuthRoleController.ts @@ -71,6 +71,8 @@ export class AuthRoleController 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 }); @@ -100,6 +102,7 @@ export class AuthRoleController extends Controller { posMaster.lastUpdateUserId = req.user.sub; posMaster.lastUpdateFullName = req.user.name; + posMaster.lastUpdatedAt = new Date(); posMaster.authRoleId = body.authRoleId; await this.posMasterRepository.save(posMaster); @@ -142,6 +145,7 @@ export class AuthRoleController extends Controller { posMaster.lastUpdateUserId = req.user.sub; posMaster.lastUpdateFullName = req.user.name; + posMaster.lastUpdatedAt = new Date(); posMaster.authRoleId = body.authRoleId; await this.employeePosMasterRepository.save(posMaster); return new HttpSuccess(); @@ -184,6 +188,8 @@ export class AuthRoleController extends Controller { roleName: body.roleName, roleDescription: body.roleDescription, lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), }); } const roleAttrData = await this.authRoleAttrRepo.find({ @@ -207,7 +213,9 @@ export class AuthRoleController extends Controller { // createdUserId: req.user.sub, // createdFullName: req.user.name, // lastUpdateUserId: req.user.sub, - // lastUpdateFullName: req.user.name, + // lastUpdateFullName: req.user.name, + // createdAt: new Date(), + // lastUpdatedAt: new Date(), // }); // return newAttr; // }); @@ -228,6 +236,8 @@ export class AuthRoleController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), }); return newAttr; }); diff --git a/src/controllers/AuthSysController.ts b/src/controllers/AuthSysController.ts index ddfa409e..1aff1526 100644 --- a/src/controllers/AuthSysController.ts +++ b/src/controllers/AuthSysController.ts @@ -71,6 +71,8 @@ export class AuthSysController 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 }); @@ -92,7 +94,9 @@ export class AuthSysController extends Controller { body.id = body.id?.toUpperCase(); Object.assign(record, body); + record.lastUpdateUserId = req.user.sub; record.lastUpdateFullName = req.user.name; + record.lastUpdatedAt = new Date(); await Promise.all([this.authSysRepo.save(record)]); diff --git a/src/controllers/BloodGroupController.ts b/src/controllers/BloodGroupController.ts index 815d7603..02451bc0 100644 --- a/src/controllers/BloodGroupController.ts +++ b/src/controllers/BloodGroupController.ts @@ -53,8 +53,10 @@ export class BloodGroupController extends Controller { const bloodGroup = Object.assign(new BloodGroup(), requestBody); bloodGroup.createdUserId = request.user.sub; bloodGroup.createdFullName = request.user.name; + bloodGroup.createdAt = new Date(); bloodGroup.lastUpdateUserId = request.user.sub; bloodGroup.lastUpdateFullName = request.user.name; + bloodGroup.lastUpdatedAt = new Date(); await this.bloodGroupRepository.save(bloodGroup); return new HttpSuccess(); } @@ -88,6 +90,7 @@ export class BloodGroupController extends Controller { bloodGroup.lastUpdateUserId = request.user.sub; bloodGroup.lastUpdateFullName = request.user.name; + bloodGroup.lastUpdatedAt = new Date(); this.bloodGroupRepository.merge(bloodGroup, requestBody); await this.bloodGroupRepository.save(bloodGroup); return new HttpSuccess(); diff --git a/src/controllers/ChangePositionController.ts b/src/controllers/ChangePositionController.ts index 49b925a1..300d0b69 100644 --- a/src/controllers/ChangePositionController.ts +++ b/src/controllers/ChangePositionController.ts @@ -77,12 +77,14 @@ export class ChangePositionController extends Controller { const changePosition = new ChangePosition(); Object.assign(changePosition, body); - (changePosition.date = new Date()), - (changePosition.status = "WAITTING"), - (changePosition.createdUserId = request.user.sub); + changePosition.date = new Date(); + changePosition.status = "WAITTING"; + changePosition.createdUserId = request.user.sub; changePosition.createdFullName = request.user.name; + changePosition.createdAt = new Date(); changePosition.lastUpdateUserId = request.user.sub; changePosition.lastUpdateFullName = request.user.name; + changePosition.lastUpdatedAt = new Date(); await this.changePositionRepository.save(changePosition); return new HttpSuccess(); } @@ -143,6 +145,7 @@ export class ChangePositionController extends Controller { Object.assign(changePosition, body); changePosition.lastUpdateUserId = request.user.sub; changePosition.lastUpdateFullName = request.user.name; + changePosition.lastUpdatedAt = new Date(); await this.changePositionRepository.save(changePosition); return new HttpSuccess(); } @@ -236,12 +239,14 @@ export class ChangePositionController extends Controller { let positionOld = data.positionOld ? `${data.positionOld}` : ""; let rootOld = data.rootOld ? (data.positionOld ? `/${data.rootOld}` : `${data.rootOld}`) : ""; profiles.changePositionId = changePositionId; - (profiles.organizationPositionOld = `${positionOld}${rootOld}`), - (profiles.status = "WAITTING"), - (profiles.createdUserId = request.user.sub); + profiles.organizationPositionOld = `${positionOld}${rootOld}`; + profiles.status = "WAITTING"; + profiles.createdUserId = request.user.sub; profiles.createdFullName = request.user.name; + profiles.createdAt = new Date(); profiles.lastUpdateUserId = request.user.sub; profiles.lastUpdateFullName = request.user.name; + profiles.lastUpdatedAt = new Date(); profileChangePositions.push(profiles); } await this.profileChangePositionRepository.save(profileChangePositions); @@ -391,6 +396,7 @@ export class ChangePositionController extends Controller { profileChangePos.lastUpdateUserId = request.user.sub; profileChangePos.lastUpdateFullName = request.user.name; + profileChangePos.lastUpdatedAt = new Date(); profileChangePos.educationOld = body.educationOld; profileChangePos.posMasterNoOld = body.posMasterNoOld; profileChangePos.positionTypeOld = body.positionTypeOld; @@ -512,6 +518,7 @@ export class ChangePositionController extends Controller { profileChangePos.lastUpdateUserId = request.user.sub; profileChangePos.lastUpdateFullName = request.user.name; + profileChangePos.lastUpdatedAt = new Date(); profileChangePos.node = body.node; profileChangePos.nodeId = body.nodeId; profileChangePos.orgRevisionId = body.orgRevisionId; @@ -546,11 +553,13 @@ export class ChangePositionController extends Controller { item.status = "REPORT"; item.lastUpdateUserId = request.user.sub; item.lastUpdateFullName = request.user.name; + item.lastUpdatedAt = new Date(); if (item.profileChangePosition) { for (const profile of item.profileChangePosition) { profile.status = "REPORT"; profile.lastUpdateUserId = request.user.sub; profile.lastUpdateFullName = request.user.name; + profile.lastUpdatedAt = new Date(); await this.profileChangePositionRepository.save(profile); } } diff --git a/src/controllers/DistrictController.ts b/src/controllers/DistrictController.ts index b4507dad..d244e53c 100644 --- a/src/controllers/DistrictController.ts +++ b/src/controllers/DistrictController.ts @@ -103,8 +103,10 @@ export class DistrictController extends Controller { _district.createdUserId = request.user.sub; _district.createdFullName = request.user.name; + _district.createdAt = new Date(); _district.lastUpdateUserId = request.user.sub; _district.lastUpdateFullName = request.user.name; + _district.lastUpdatedAt = new Date(); await this.districtRepository.save(_district); return new HttpSuccess(); } @@ -144,6 +146,7 @@ export class DistrictController extends Controller { _district.lastUpdateUserId = request.user.sub; _district.lastUpdateFullName = request.user.name; + _district.lastUpdatedAt = new Date(); this.districtRepository.merge(_district, requestBody); await this.districtRepository.save(_district); return new HttpSuccess(); diff --git a/src/controllers/EducationLevelController.ts b/src/controllers/EducationLevelController.ts index a4e87734..29281e78 100644 --- a/src/controllers/EducationLevelController.ts +++ b/src/controllers/EducationLevelController.ts @@ -53,8 +53,10 @@ export class EducationLevelController extends Controller { const educationLevel = Object.assign(new EducationLevel(), requestBody); educationLevel.createdUserId = request.user.sub; educationLevel.createdFullName = request.user.name; + educationLevel.createdAt = new Date(); educationLevel.lastUpdateUserId = request.user.sub; educationLevel.lastUpdateFullName = request.user.name; + educationLevel.lastUpdatedAt = new Date(); await this.educationLevelRepository.save(educationLevel); return new HttpSuccess(); } @@ -88,6 +90,7 @@ export class EducationLevelController extends Controller { educationLevel.lastUpdateUserId = request.user.sub; educationLevel.lastUpdateFullName = request.user.name; + educationLevel.lastUpdatedAt = new Date(); this.educationLevelRepository.merge(educationLevel, requestBody); await this.educationLevelRepository.save(educationLevel); return new HttpSuccess(); diff --git a/src/controllers/EmployeePositionController.ts b/src/controllers/EmployeePositionController.ts index 61ceabee..b1cc7afb 100644 --- a/src/controllers/EmployeePositionController.ts +++ b/src/controllers/EmployeePositionController.ts @@ -107,8 +107,10 @@ export class EmployeePositionController extends Controller { empPosDict.createdUserId = request.user.sub; empPosDict.createdFullName = request.user.name; + empPosDict.createdAt = new Date(); empPosDict.lastUpdateUserId = request.user.sub; empPosDict.lastUpdateFullName = request.user.name; + empPosDict.lastUpdatedAt = new Date(); await this.employeePosDictRepository.save(empPosDict); return new HttpSuccess(empPosDict.id); } @@ -162,6 +164,7 @@ export class EmployeePositionController extends Controller { empPosDict.lastUpdateUserId = request.user.sub; empPosDict.lastUpdateFullName = request.user.name; + empPosDict.lastUpdatedAt = new Date(); this.employeePosDictRepository.merge(empPosDict, requestBody); await this.employeePosDictRepository.save(empPosDict); return new HttpSuccess(empPosDict.id); @@ -582,8 +585,10 @@ export class EmployeePositionController extends Controller { posMaster.createdUserId = request.user.sub; posMaster.createdFullName = request.user.name; + posMaster.createdAt = new Date(); posMaster.lastUpdateUserId = request.user.sub; posMaster.lastUpdateFullName = request.user.name; + posMaster.lastUpdatedAt = new Date(); await this.employeePosMasterRepository.save(posMaster); await Promise.all( requestBody.positions.map(async (x: any) => { @@ -595,8 +600,10 @@ export class EmployeePositionController extends Controller { position.posMasterId = posMaster.id; position.createdUserId = request.user.sub; position.createdFullName = request.user.name; + position.createdAt = new Date(); position.lastUpdateUserId = request.user.sub; position.lastUpdateFullName = request.user.name; + position.lastUpdatedAt = new Date(); await this.employeePositionRepository.save(position); }), ); @@ -787,8 +794,10 @@ export class EmployeePositionController extends Controller { posMaster.createdUserId = request.user.sub; //สงสัยว่าทำให้ bug แก้ไขไม่ได้ posMaster.createdFullName = request.user.name; + posMaster.createdAt = new Date(); posMaster.lastUpdateUserId = request.user.sub; posMaster.lastUpdateFullName = request.user.name; + posMaster.lastUpdatedAt = new Date(); await this.employeePosMasterRepository.save(posMaster); await this.employeePositionRepository.delete({ posMasterId: posMaster.id }); @@ -802,8 +811,10 @@ export class EmployeePositionController extends Controller { position.posMasterId = posMaster.id; position.createdUserId = request.user.sub; position.createdFullName = request.user.name; + position.createdAt = new Date(); position.lastUpdateUserId = request.user.sub; position.lastUpdateFullName = request.user.name; + position.lastUpdatedAt = new Date(); await this.employeePositionRepository.save(position); }), ); @@ -1186,7 +1197,10 @@ export class EmployeePositionController extends Controller { * */ @Post("sort") - async SortEmp(@Body() requestBody: { id: string; type: number; sortId: string[] }, @Request() request: RequestWithUser) { + async SortEmp( + @Body() requestBody: { id: string; type: number; sortId: string[] }, + @Request() request: RequestWithUser, + ) { await new permission().PermissionUpdate(request, "SYS_ORG_EMP"); switch (requestBody.type) { case 0: { @@ -1614,8 +1628,10 @@ export class EmployeePositionController extends Controller { posMaster.posMasterOrder = maxPosMasterOrder += 1; posMaster.createdUserId = request.user.sub; posMaster.createdFullName = request.user.name; + posMaster.createdAt = new Date(); posMaster.lastUpdateUserId = request.user.sub; posMaster.lastUpdateFullName = request.user.name; + posMaster.lastUpdatedAt = new Date(); await this.employeePosMasterRepository.save(posMaster); } }), @@ -2078,7 +2094,7 @@ export class EmployeePositionController extends Controller { @Post("profile") async createEmpHolder( @Body() requestBody: { posMaster: string; position: string; profileId: string; isSit: boolean }, - @Request() request: RequestWithUser + @Request() request: RequestWithUser, ) { await new permission().PermissionCreate(request, "SYS_ORG_EMP"); const dataMaster = await this.employeePosMasterRepository.findOne({ @@ -2144,7 +2160,10 @@ export class EmployeePositionController extends Controller { * */ @Post("dna") - async dnaEmp(@Body() requestBody: { draftPositionId: string; publishPositionId: string }, @Request() request: RequestWithUser) { + async dnaEmp( + @Body() requestBody: { draftPositionId: string; publishPositionId: string }, + @Request() request: RequestWithUser, + ) { await new permission().PermissionDelete(request, "SYS_ORG_EMP"); const findDraft = await this.orgRevisionRepository.findOne({ where: { diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 453016ea..1628437c 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -3443,6 +3443,20 @@ export class OrganizationController extends Controller { "orgChild1s.orgChild2s.orgChild3s", "orgChild1s.orgChild2s.orgChild3s.orgChild4s", ], + order: { + orgChild1s: { + orgChild1Order: "ASC", + orgChild2s: { + orgChild2Order: "ASC", + orgChild3s: { + orgChild3Order: "ASC", + orgChild4s: { + orgChild4Order: "ASC", + }, + }, + }, + }, + }, }); return new HttpSuccess(data); } diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index 5566b3ba..f89b6ff3 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -874,6 +874,8 @@ export class OrganizationDotnetController 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 }); diff --git a/src/controllers/ProfileAbilityController.ts b/src/controllers/ProfileAbilityController.ts index 7610f058..c8351ef5 100644 --- a/src/controllers/ProfileAbilityController.ts +++ b/src/controllers/ProfileAbilityController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,6 +40,7 @@ export class ProfileAbilityController extends Controller { } const getProfileAbilityId = await this.profileAbilityRepo.find({ where: { profileId: profile.id }, + order: { createdAt: "ASC" }, }); if (!getProfileAbilityId) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -49,31 +49,12 @@ export class ProfileAbilityController extends Controller { } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "ad7d0955-7bcd-4ed0-911c-2edceba12579", - createdAt: "2024-03-12T21:37:35.037Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T21:37:35.037Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "test bar", - lastUpdateFullName: "test bar", - profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม", - detail: "-", - reference: "-", - dateStart: "2024-03-13T04:36:06.000Z", - dateEnd: "2024-03-13T04:36:06.000Z", - field: "ความมั่นคง", - }, - ], - }) public async detailProfileAbility(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); - const getProfileAbilityId = await this.profileAbilityRepo.findBy({ profileId }); + const getProfileAbilityId = await this.profileAbilityRepo.find({ + where: { profileId: profileId }, + order: { createdAt: "ASC" }, + }); if (!getProfileAbilityId) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -81,44 +62,6 @@ export class ProfileAbilityController extends Controller { } @Get("history/{abilityId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "1c92cd8a-e176-48af-ac00-c018fb4c9895", - createdAt: "2024-03-12T21:38:56.342Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T21:38:56.342Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม", - detail: "ด่วน", - reference: "-", - dateStart: "2024-03-13T04:36:06.000Z", - dateEnd: "2024-03-13T04:36:06.000Z", - field: "ความมั่นคง", - profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579", - }, - { - id: "2fb95768-cb62-40a3-9540-5a561d640959", - createdAt: "2024-03-12T21:39:06.094Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T21:39:06.094Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม", - detail: "ด่วนมากสุด", - reference: "-", - dateStart: "2024-03-13T04:36:06.000Z", - dateEnd: "2024-03-13T04:36:06.000Z", - field: "ความมั่นคง", - profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579", - }, - ], - }) public async getProfileAbilityHistory( @Path() abilityId: string, @Request() req: RequestWithUser, @@ -130,8 +73,8 @@ export class ProfileAbilityController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } const record = await this.profileAbilityHistoryRepo.find({ - relations: ["histories"], where: { profileAbilityId: abilityId }, + order: { createdAt: "DESC" }, }); if (!record) { @@ -161,6 +104,8 @@ export class ProfileAbilityController 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 }); @@ -187,15 +132,18 @@ export class ProfileAbilityController extends Controller { const history = new ProfileAbilityHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileAbilityId = abilityId; 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.profileAbilityRepo.save(record), diff --git a/src/controllers/ProfileAbilityEmployeeController.ts b/src/controllers/ProfileAbilityEmployeeController.ts index 9c049869..dba3c1be 100644 --- a/src/controllers/ProfileAbilityEmployeeController.ts +++ b/src/controllers/ProfileAbilityEmployeeController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -13,9 +12,7 @@ import { Tags, } from "tsoa"; import { AppDataSource } from "../database/data-source"; -import { Profile } from "../entities/Profile"; import { - CreateProfileAbility, CreateProfileAbilityEmployee, ProfileAbility, UpdateProfileAbility, @@ -43,6 +40,7 @@ export class ProfileAbilityEmployeeController extends Controller { } const getProfileAbilityId = await this.profileAbilityRepo.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); if (!getProfileAbilityId) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -51,31 +49,15 @@ export class ProfileAbilityEmployeeController extends Controller { } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "ad7d0955-7bcd-4ed0-911c-2edceba12579", - createdAt: "2024-03-12T21:37:35.037Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T21:37:35.037Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "test bar", - lastUpdateFullName: "test bar", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม", - detail: "-", - reference: "-", - dateStart: "2024-03-13T04:36:06.000Z", - dateEnd: "2024-03-13T04:36:06.000Z", - field: "ความมั่นคง", - }, - ], - }) - public async detailProfileAbility(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { + public async detailProfileAbility( + @Path() profileEmployeeId: string, + @Request() req: RequestWithUser, + ) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); - const getProfileAbilityId = await this.profileAbilityRepo.findBy({ profileEmployeeId }); + const getProfileAbilityId = await this.profileAbilityRepo.find({ + where: { profileEmployeeId: profileEmployeeId }, + order: { createdAt: "ASC" }, + }); if (!getProfileAbilityId) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -83,45 +65,10 @@ export class ProfileAbilityEmployeeController extends Controller { } @Get("history/{abilityId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "1c92cd8a-e176-48af-ac00-c018fb4c9895", - createdAt: "2024-03-12T21:38:56.342Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T21:38:56.342Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม", - detail: "ด่วน", - reference: "-", - dateStart: "2024-03-13T04:36:06.000Z", - dateEnd: "2024-03-13T04:36:06.000Z", - field: "ความมั่นคง", - profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579", - }, - { - id: "2fb95768-cb62-40a3-9540-5a561d640959", - createdAt: "2024-03-12T21:39:06.094Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T21:39:06.094Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม", - detail: "ด่วนมากสุด", - reference: "-", - dateStart: "2024-03-13T04:36:06.000Z", - dateEnd: "2024-03-13T04:36:06.000Z", - field: "ความมั่นคง", - profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579", - }, - ], - }) - public async getProfileAbilityHistory(@Path() abilityId: string, @Request() req: RequestWithUser) { + public async getProfileAbilityHistory( + @Path() abilityId: string, + @Request() req: RequestWithUser, + ) { const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); if (_record) { await new permission().PermissionOrgUserGet( @@ -130,8 +77,9 @@ export class ProfileAbilityEmployeeController extends Controller { _record.profileEmployeeId, ); } - const record = await this.profileAbilityHistoryRepo.findBy({ - profileAbilityId: abilityId, + const record = await this.profileAbilityHistoryRepo.find({ + where: { profileAbilityId: abilityId }, + order: { createdAt: "DESC" }, }); if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -147,7 +95,7 @@ export class ProfileAbilityEmployeeController extends Controller { if (!body.profileEmployeeId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); } - + const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -160,6 +108,8 @@ export class ProfileAbilityEmployeeController 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 }); @@ -181,20 +131,27 @@ export class ProfileAbilityEmployeeController extends Controller { ) { const record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId); - + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); + const history = new ProfileAbilityHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileAbilityId = abilityId; 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.profileAbilityRepo.save(record), @@ -206,14 +163,14 @@ export class ProfileAbilityEmployeeController extends Controller { @Delete("{abilityId}") public async deleteProfileAbility(@Path() abilityId: string, @Request() req: RequestWithUser) { - const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); - if (_record) { - await new permission().PermissionOrgUserDelete( - req, - "SYS_REGISTRY_EMP", - _record.profileEmployeeId, - ); - } + const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); + if (_record) { + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); + } await this.profileAbilityHistoryRepo.delete({ profileAbilityId: abilityId, }); diff --git a/src/controllers/ProfileAbilityEmployeeTempController.ts b/src/controllers/ProfileAbilityEmployeeTempController.ts index c79e2247..93fdb67b 100644 --- a/src/controllers/ProfileAbilityEmployeeTempController.ts +++ b/src/controllers/ProfileAbilityEmployeeTempController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -13,9 +12,7 @@ import { Tags, } from "tsoa"; import { AppDataSource } from "../database/data-source"; -import { Profile } from "../entities/Profile"; import { - CreateProfileAbility, CreateProfileAbilityEmployee, ProfileAbility, UpdateProfileAbility, @@ -43,6 +40,7 @@ export class ProfileAbilityEmployeeTempController extends Controller { } const getProfileAbilityId = await this.profileAbilityRepo.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); if (!getProfileAbilityId) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -51,31 +49,15 @@ export class ProfileAbilityEmployeeTempController extends Controller { } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "ad7d0955-7bcd-4ed0-911c-2edceba12579", - createdAt: "2024-03-12T21:37:35.037Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T21:37:35.037Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "test bar", - lastUpdateFullName: "test bar", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม", - detail: "-", - reference: "-", - dateStart: "2024-03-13T04:36:06.000Z", - dateEnd: "2024-03-13T04:36:06.000Z", - field: "ความมั่นคง", - }, - ], - }) - public async detailProfileAbility(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { + public async detailProfileAbility( + @Path() profileEmployeeId: string, + @Request() req: RequestWithUser, + ) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); - const getProfileAbilityId = await this.profileAbilityRepo.findBy({ profileEmployeeId }); + const getProfileAbilityId = await this.profileAbilityRepo.find({ + where: { profileEmployeeId: profileEmployeeId }, + order: { createdAt: "ASC" }, + }); if (!getProfileAbilityId) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -83,52 +65,17 @@ export class ProfileAbilityEmployeeTempController extends Controller { } @Get("history/{abilityId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "1c92cd8a-e176-48af-ac00-c018fb4c9895", - createdAt: "2024-03-12T21:38:56.342Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T21:38:56.342Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม", - detail: "ด่วน", - reference: "-", - dateStart: "2024-03-13T04:36:06.000Z", - dateEnd: "2024-03-13T04:36:06.000Z", - field: "ความมั่นคง", - profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579", - }, - { - id: "2fb95768-cb62-40a3-9540-5a561d640959", - createdAt: "2024-03-12T21:39:06.094Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T21:39:06.094Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - remark: "ต้องส่งให้ทันก่อนวันที่ 15 มีนาคม", - detail: "ด่วนมากสุด", - reference: "-", - dateStart: "2024-03-13T04:36:06.000Z", - dateEnd: "2024-03-13T04:36:06.000Z", - field: "ความมั่นคง", - profileAbilityId: "ad7d0955-7bcd-4ed0-911c-2edceba12579", - }, - ], - }) - public async getProfileAbilityHistory(@Path() abilityId: string, @Request() req: RequestWithUser) { + public async getProfileAbilityHistory( + @Path() abilityId: string, + @Request() req: RequestWithUser, + ) { const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); if (_record) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); } - - const record = await this.profileAbilityHistoryRepo.findBy({ - profileAbilityId: abilityId, + const record = await this.profileAbilityHistoryRepo.find({ + where: { profileAbilityId: abilityId }, + order: { createdAt: "DESC" }, }); if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -157,6 +104,8 @@ export class ProfileAbilityEmployeeTempController 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 }); @@ -178,20 +127,23 @@ export class ProfileAbilityEmployeeTempController extends Controller { ) { const record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP") + await new permission().PermissionUpdate(req, "SYS_REGISTRY_TEMP"); const history = new ProfileAbilityHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileAbilityId = abilityId; 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.profileAbilityRepo.save(record), diff --git a/src/controllers/ProfileAddressController.ts b/src/controllers/ProfileAddressController.ts index 0bb28158..c70253a2 100644 --- a/src/controllers/ProfileAddressController.ts +++ b/src/controllers/ProfileAddressController.ts @@ -1,21 +1,4 @@ -import { - Controller, - Post, - Put, - Delete, - Route, - Security, - Tags, - Body, - Path, - Request, - SuccessResponse, - Response, - Get, - Query, - Patch, - Example, -} from "tsoa"; +import { Controller, Route, Security, Tags, Body, Path, Request, Get, Patch } from "tsoa"; import HttpSuccess from "../interfaces/http-success"; import HttpError from "../interfaces/http-error"; @@ -23,9 +6,6 @@ import HttpStatus from "../interfaces/http-status"; import { RequestWithUser } from "../middlewares/user"; import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile"; import { AppDataSource } from "../database/data-source"; -import { Province } from "../entities/Province"; -import { District } from "../entities/District"; -import { SubDistrict } from "../entities/SubDistrict"; import permission from "../interfaces/permission"; @Route("api/v1/org/profile/address") @Tags("ProfileAddress") @@ -54,7 +34,9 @@ export class ProfileAddressController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", + "createdAt", ], + order: { createdAt: "ASC" }, }); if (!getProfileAddress) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -84,6 +66,7 @@ export class ProfileAddressController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", + "createdAt", ], }); if (!getProfileAddress) { @@ -105,28 +88,7 @@ export class ProfileAddressController extends Controller { } const record = await this.profileAddressHistoryRepo.find({ where: { profileId: profile.id }, - relations: { - registrationProvince: true, - registrationDistrict: true, - registrationSubDistrict: true, - currentProvince: true, - currentDistrict: true, - currentSubDistrict: true, - }, - select: [ - "registrationAddress", - "registrationProvinceId", - "registrationDistrictId", - "registrationSubDistrictId", - "registrationZipCode", - "currentAddress", - "currentProvinceId", - "currentDistrictId", - "currentSubDistrictId", - "currentZipCode", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "DESC" }, }); if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -140,32 +102,14 @@ export class ProfileAddressController extends Controller { * */ @Get("history/{profileId}") - public async getProfileAddressHistory(@Path() profileId: string, @Request() req: RequestWithUser) { + public async getProfileAddressHistory( + @Path() profileId: string, + @Request() req: RequestWithUser, + ) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.profileAddressHistoryRepo.find({ where: { profileId: profileId }, - relations: { - registrationProvince: true, - registrationDistrict: true, - registrationSubDistrict: true, - currentProvince: true, - currentDistrict: true, - currentSubDistrict: true, - }, - select: [ - "registrationAddress", - "registrationProvinceId", - "registrationDistrictId", - "registrationSubDistrictId", - "registrationZipCode", - "currentAddress", - "currentProvinceId", - "currentDistrictId", - "currentSubDistrictId", - "currentZipCode", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "DESC" }, }); if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -191,15 +135,18 @@ export class ProfileAddressController extends Controller { const history = new ProfileAddressHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileId = profileId; 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.profileRepo.save(record), diff --git a/src/controllers/ProfileAddressEmployeeController.ts b/src/controllers/ProfileAddressEmployeeController.ts index 5804c7d3..bb37895c 100644 --- a/src/controllers/ProfileAddressEmployeeController.ts +++ b/src/controllers/ProfileAddressEmployeeController.ts @@ -1,31 +1,11 @@ -import { - Controller, - Post, - Put, - Delete, - Route, - Security, - Tags, - Body, - Path, - Request, - SuccessResponse, - Response, - Get, - Query, - Patch, - Example, -} from "tsoa"; +import { Controller, Route, Security, Tags, Body, Path, Request, Get, Patch } from "tsoa"; import HttpSuccess from "../interfaces/http-success"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; import { RequestWithUser } from "../middlewares/user"; -import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile"; +import { ProfileAddressHistory } from "../entities/Profile"; import { AppDataSource } from "../database/data-source"; -import { Province } from "../entities/Province"; -import { District } from "../entities/District"; -import { SubDistrict } from "../entities/SubDistrict"; import { ProfileEmployee, UpdateProfileAddressEmployee } from "../entities/ProfileEmployee"; import permission from "../interfaces/permission"; @Route("api/v1/org/profile-employee/address") @@ -55,7 +35,9 @@ export class ProfileAddressEmployeeController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", + "createdAt", ], + order: { createdAt: "ASC" }, }); if (!getProfileAddress) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -69,7 +51,10 @@ export class ProfileAddressEmployeeController extends Controller { * */ @Get("{profileEmployeeId}") - public async detailProfileAddress(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { + public async detailProfileAddress( + @Path() profileEmployeeId: string, + @Request() req: RequestWithUser, + ) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const getProfileAddress = await this.profileEmployeeRepo.findOne({ where: { id: profileEmployeeId }, @@ -85,6 +70,7 @@ export class ProfileAddressEmployeeController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", + "createdAt", ], }); if (!getProfileAddress) { @@ -106,28 +92,7 @@ export class ProfileAddressEmployeeController extends Controller { } const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profile.id }, - relations: { - registrationProvince: true, - registrationDistrict: true, - registrationSubDistrict: true, - currentProvince: true, - currentDistrict: true, - currentSubDistrict: true, - }, - select: [ - "registrationAddress", - "registrationProvinceId", - "registrationDistrictId", - "registrationSubDistrictId", - "registrationZipCode", - "currentAddress", - "currentProvinceId", - "currentDistrictId", - "currentSubDistrictId", - "currentZipCode", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "DESC" }, }); if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -141,32 +106,14 @@ export class ProfileAddressEmployeeController extends Controller { * */ @Get("history/{profileId}") - public async getProfileAddressHistory(@Path() profileId: string, @Request() req: RequestWithUser) { + public async getProfileAddressHistory( + @Path() profileId: string, + @Request() req: RequestWithUser, + ) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profileId }, - relations: { - registrationProvince: true, - registrationDistrict: true, - registrationSubDistrict: true, - currentProvince: true, - currentDistrict: true, - currentSubDistrict: true, - }, - select: [ - "registrationAddress", - "registrationProvinceId", - "registrationDistrictId", - "registrationSubDistrictId", - "registrationZipCode", - "currentAddress", - "currentProvinceId", - "currentDistrictId", - "currentSubDistrictId", - "currentZipCode", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "DESC" }, }); if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -188,19 +135,22 @@ export class ProfileAddressEmployeeController extends Controller { const record = await this.profileEmployeeRepo.findOneBy({ id: profileId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.id); - + const history = new ProfileAddressHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileEmployeeId = profileId; 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.profileEmployeeRepo.save(record), diff --git a/src/controllers/ProfileAddressEmployeeTempController.ts b/src/controllers/ProfileAddressEmployeeTempController.ts index fba122fe..18dab2db 100644 --- a/src/controllers/ProfileAddressEmployeeTempController.ts +++ b/src/controllers/ProfileAddressEmployeeTempController.ts @@ -1,31 +1,11 @@ -import { - Controller, - Post, - Put, - Delete, - Route, - Security, - Tags, - Body, - Path, - Request, - SuccessResponse, - Response, - Get, - Query, - Patch, - Example, -} from "tsoa"; +import { Controller, Route, Security, Tags, Body, Path, Request, Get, Patch } from "tsoa"; import HttpSuccess from "../interfaces/http-success"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; import { RequestWithUser } from "../middlewares/user"; -import { Profile, ProfileAddressHistory, UpdateProfileAddress } from "../entities/Profile"; +import { ProfileAddressHistory } from "../entities/Profile"; import { AppDataSource } from "../database/data-source"; -import { Province } from "../entities/Province"; -import { District } from "../entities/District"; -import { SubDistrict } from "../entities/SubDistrict"; import { ProfileEmployee, UpdateProfileAddressEmployee } from "../entities/ProfileEmployee"; import permission from "../interfaces/permission"; @Route("api/v1/org/profile-temp/address") @@ -55,7 +35,9 @@ export class ProfileAddressEmployeeTempController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", + "createdAt", ], + order: { createdAt: "ASC" }, }); if (!getProfileAddress) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -88,6 +70,7 @@ export class ProfileAddressEmployeeTempController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", + "createdAt", ], }); if (!getProfileAddress) { @@ -109,28 +92,7 @@ export class ProfileAddressEmployeeTempController extends Controller { } const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profile.id }, - relations: { - registrationProvince: true, - registrationDistrict: true, - registrationSubDistrict: true, - currentProvince: true, - currentDistrict: true, - currentSubDistrict: true, - }, - select: [ - "registrationAddress", - "registrationProvinceId", - "registrationDistrictId", - "registrationSubDistrictId", - "registrationZipCode", - "currentAddress", - "currentProvinceId", - "currentDistrictId", - "currentSubDistrictId", - "currentZipCode", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "DESC" }, }); if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -151,28 +113,7 @@ export class ProfileAddressEmployeeTempController extends Controller { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profileId }, - relations: { - registrationProvince: true, - registrationDistrict: true, - registrationSubDistrict: true, - currentProvince: true, - currentDistrict: true, - currentSubDistrict: true, - }, - select: [ - "registrationAddress", - "registrationProvinceId", - "registrationDistrictId", - "registrationSubDistrictId", - "registrationZipCode", - "currentAddress", - "currentProvinceId", - "currentDistrictId", - "currentSubDistrictId", - "currentZipCode", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "DESC" }, }); if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -198,15 +139,18 @@ export class ProfileAddressEmployeeTempController extends Controller { const history = new ProfileAddressHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileEmployeeId = profileId; 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.profileEmployeeRepo.save(record), diff --git a/src/controllers/ProfileAssessmentsController.ts b/src/controllers/ProfileAssessmentsController.ts index 316b76eb..ba3d6ed3 100644 --- a/src/controllers/ProfileAssessmentsController.ts +++ b/src/controllers/ProfileAssessmentsController.ts @@ -1,7 +1,6 @@ import { Controller, Post, - Put, Delete, Route, Security, @@ -9,12 +8,8 @@ import { Body, Path, Request, - SuccessResponse, - Response, Get, - Query, Patch, - Example, } from "tsoa"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; @@ -46,6 +41,7 @@ export class ProfileAssessmentsController extends Controller { } const getProfileAssessments = await this.profileAssessmentsRepository.find({ where: { profileId: profile.id }, + order: { createdAt: "ASC" }, }); if (!getProfileAssessments) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -54,36 +50,15 @@ export class ProfileAssessmentsController extends Controller { } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80", - createdAt: "2024-03-12T20:56:45.986Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T20:56:45.986Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "test bar", - lastUpdateFullName: "test bar", - profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - name: "สาวิตรี ศรีสมัย", - date: "2024-03-13T03:55:42.000Z", - point1: 0, - point1Total: 0, - point2: 0, - point2Total: 0, - pointSum: 0, - pointSumTotal: 0, - }, - ], - }) public async detailProfileAssessments( @Path() profileId: string, @Request() req: RequestWithUser, ) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); - const getProfileAssessments = await this.profileAssessmentsRepository.findBy({ profileId }); + const getProfileAssessments = await this.profileAssessmentsRepository.find({ + where: { profileId: profileId }, + order: { createdAt: "ASC" }, + }); if (!getProfileAssessments) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -91,67 +66,25 @@ export class ProfileAssessmentsController extends Controller { } @Get("history/{assessmentId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "47b3e370-be05-4469-a34f-e4a04747f54e", - createdAt: "2024-03-12T20:59:39.774Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T20:59:39.774Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - name: "สาวิตรี ศรีสมัย", - date: "2024-03-13T03:55:42.000Z", - point1: 0, - point1Total: 0, - point2: 100, - point2Total: 100, - pointSum: 100, - pointSumTotal: 100, - profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80", - }, - { - id: "ecff89b1-9bef-49a9-83f5-8be3cecb8ca7", - createdAt: "2024-03-12T20:58:19.450Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T20:58:19.450Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - name: "สาวิตรี ศรีสมัย", - date: "2024-03-13T03:55:42.000Z", - point1: 50, - point1Total: 50, - point2: 100, - point2Total: 100, - pointSum: 150, - pointSumTotal: 150, - profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80", - }, - ], - }) public async getProfileAssessmentsHistory( @Path() assessmentId: string, @Request() req: RequestWithUser, ) { - const record = await this.profileAssessmentsHistoryRepository.findBy({ - profileAssessmentId: assessmentId, + const _record = await this.profileAssessmentsRepository.findOneBy({ + id: assessmentId, + }); + if (_record) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + const record = await this.profileAssessmentsHistoryRepository.find({ + where: { + profileAssessmentId: assessmentId, + }, + order: { createdAt: "DESC" }, }); if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } - const _record = await this.profileAssessmentsRepository.findOne({ - where: { - id: assessmentId, - }, - }); - if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); - } return new HttpSuccess(record); } @@ -176,6 +109,8 @@ export class ProfileAssessmentsController 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 }); const history = new ProfileAssessmentHistory(); @@ -201,15 +136,18 @@ export class ProfileAssessmentsController extends Controller { const history = new ProfileAssessmentHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileAssessmentId = assessmentId; 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.profileAssessmentsRepository.save(record), diff --git a/src/controllers/ProfileAssessmentsEmployeeController.ts b/src/controllers/ProfileAssessmentsEmployeeController.ts index 6b8ba0e9..301e7ae7 100644 --- a/src/controllers/ProfileAssessmentsEmployeeController.ts +++ b/src/controllers/ProfileAssessmentsEmployeeController.ts @@ -1,7 +1,6 @@ import { Controller, Post, - Put, Delete, Route, Security, @@ -9,12 +8,8 @@ import { Body, Path, Request, - SuccessResponse, - Response, Get, - Query, Patch, - Example, } from "tsoa"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; @@ -46,6 +41,7 @@ export class ProfileAssessmentsEmployeeController extends Controller { } const getProfileAssessments = await this.profileAssessmentsRepository.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); if (!getProfileAssessments) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -54,34 +50,16 @@ export class ProfileAssessmentsEmployeeController extends Controller { } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80", - createdAt: "2024-03-12T20:56:45.986Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T20:56:45.986Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "test bar", - lastUpdateFullName: "test bar", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - name: "สาวิตรี ศรีสมัย", - date: "2024-03-13T03:55:42.000Z", - point1: 0, - point1Total: 0, - point2: 0, - point2Total: 0, - pointSum: 0, - pointSumTotal: 0, - }, - ], - }) - public async detailProfileAssessments(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { + public async detailProfileAssessments( + @Path() profileEmployeeId: string, + @Request() req: RequestWithUser, + ) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); - const getProfileAssessments = await this.profileAssessmentsRepository.findBy({ - profileEmployeeId, + const getProfileAssessments = await this.profileAssessmentsRepository.find({ + where: { + profileEmployeeId: profileEmployeeId, + }, + order: { createdAt: "ASC" }, }); if (!getProfileAssessments) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -90,55 +68,19 @@ export class ProfileAssessmentsEmployeeController extends Controller { } @Get("history/{assessmentId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "47b3e370-be05-4469-a34f-e4a04747f54e", - createdAt: "2024-03-12T20:59:39.774Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T20:59:39.774Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - name: "สาวิตรี ศรีสมัย", - date: "2024-03-13T03:55:42.000Z", - point1: 0, - point1Total: 0, - point2: 100, - point2Total: 100, - pointSum: 100, - pointSumTotal: 100, - profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80", - }, - { - id: "ecff89b1-9bef-49a9-83f5-8be3cecb8ca7", - createdAt: "2024-03-12T20:58:19.450Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T20:58:19.450Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - name: "สาวิตรี ศรีสมัย", - date: "2024-03-13T03:55:42.000Z", - point1: 50, - point1Total: 50, - point2: 100, - point2Total: 100, - pointSum: 150, - pointSumTotal: 150, - profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80", - }, - ], - }) - public async getProfileAssessmentsHistory(@Path() assessmentId: string, @Request() req: RequestWithUser) { + public async getProfileAssessmentsHistory( + @Path() assessmentId: string, + @Request() req: RequestWithUser, + ) { const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId }); if (_record) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileId); } - const record = await this.profileAssessmentsHistoryRepository.findBy({ - profileAssessmentId: assessmentId, + const record = await this.profileAssessmentsHistoryRepository.find({ + where: { + profileAssessmentId: assessmentId, + }, + order: { createdAt: "DESC" }, }); if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -155,7 +97,7 @@ export class ProfileAssessmentsEmployeeController extends Controller { if (!body.profileEmployeeId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); } - + const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -168,6 +110,8 @@ export class ProfileAssessmentsEmployeeController 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 }); const history = new ProfileAssessmentHistory(); @@ -188,20 +132,27 @@ export class ProfileAssessmentsEmployeeController extends Controller { ) { const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId); + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); const history = new ProfileAssessmentHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileAssessmentId = assessmentId; 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.profileAssessmentsRepository.save(record), @@ -218,7 +169,11 @@ export class ProfileAssessmentsEmployeeController extends Controller { ) { const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } await this.profileAssessmentsHistoryRepository.delete({ profileAssessmentId: assessmentId, diff --git a/src/controllers/ProfileAssessmentsEmployeeTempController.ts b/src/controllers/ProfileAssessmentsEmployeeTempController.ts index 54e96587..08e843a4 100644 --- a/src/controllers/ProfileAssessmentsEmployeeTempController.ts +++ b/src/controllers/ProfileAssessmentsEmployeeTempController.ts @@ -1,7 +1,6 @@ import { Controller, Post, - Put, Delete, Route, Security, @@ -9,12 +8,8 @@ import { Body, Path, Request, - SuccessResponse, - Response, Get, - Query, Patch, - Example, } from "tsoa"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; @@ -46,6 +41,7 @@ export class ProfileAssessmentsEmployeeTempController extends Controller { } const getProfileAssessments = await this.profileAssessmentsRepository.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); if (!getProfileAssessments) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -54,34 +50,16 @@ export class ProfileAssessmentsEmployeeTempController extends Controller { } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80", - createdAt: "2024-03-12T20:56:45.986Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T20:56:45.986Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "test bar", - lastUpdateFullName: "test bar", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - name: "สาวิตรี ศรีสมัย", - date: "2024-03-13T03:55:42.000Z", - point1: 0, - point1Total: 0, - point2: 0, - point2Total: 0, - pointSum: 0, - pointSumTotal: 0, - }, - ], - }) - public async detailProfileAssessments(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { + public async detailProfileAssessments( + @Path() profileEmployeeId: string, + @Request() req: RequestWithUser, + ) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); - const getProfileAssessments = await this.profileAssessmentsRepository.findBy({ - profileEmployeeId, + const getProfileAssessments = await this.profileAssessmentsRepository.find({ + where: { + profileEmployeeId: profileEmployeeId, + }, + order: { createdAt: "ASC" }, }); if (!getProfileAssessments) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -90,52 +68,16 @@ export class ProfileAssessmentsEmployeeTempController extends Controller { } @Get("history/{assessmentId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "47b3e370-be05-4469-a34f-e4a04747f54e", - createdAt: "2024-03-12T20:59:39.774Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T20:59:39.774Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - name: "สาวิตรี ศรีสมัย", - date: "2024-03-13T03:55:42.000Z", - point1: 0, - point1Total: 0, - point2: 100, - point2Total: 100, - pointSum: 100, - pointSumTotal: 100, - profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80", - }, - { - id: "ecff89b1-9bef-49a9-83f5-8be3cecb8ca7", - createdAt: "2024-03-12T20:58:19.450Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T20:58:19.450Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - name: "สาวิตรี ศรีสมัย", - date: "2024-03-13T03:55:42.000Z", - point1: 50, - point1Total: 50, - point2: 100, - point2Total: 100, - pointSum: 150, - pointSumTotal: 150, - profileAssessmentId: "f723bf42-a61c-4af4-ba8b-0e4ad0a89a80", - }, - ], - }) - public async getProfileAssessmentsHistory(@Path() assessmentId: string, @Request() req: RequestWithUser) { + public async getProfileAssessmentsHistory( + @Path() assessmentId: string, + @Request() req: RequestWithUser, + ) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); - const record = await this.profileAssessmentsHistoryRepository.findBy({ - profileAssessmentId: assessmentId, + const record = await this.profileAssessmentsHistoryRepository.find({ + where: { + profileAssessmentId: assessmentId, + }, + order: { createdAt: "DESC" }, }); if (!record) { @@ -166,6 +108,8 @@ export class ProfileAssessmentsEmployeeTempController 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 }); const history = new ProfileAssessmentHistory(); @@ -191,15 +135,18 @@ export class ProfileAssessmentsEmployeeTempController extends Controller { const history = new ProfileAssessmentHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileAssessmentId = assessmentId; 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.profileAssessmentsRepository.save(record), diff --git a/src/controllers/ProfileAvatarController.ts b/src/controllers/ProfileAvatarController.ts index 8e920d4a..5e466ba9 100644 --- a/src/controllers/ProfileAvatarController.ts +++ b/src/controllers/ProfileAvatarController.ts @@ -19,6 +19,7 @@ export class ProfileAvatarController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.avatarRepository.find({ where: { profileId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -27,7 +28,6 @@ export class ProfileAvatarController extends Controller { async getProfile(@Path() id: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", id); const profile = await this.profileRepository.findOne({ - select: ["id", "avatar", "avatarName"], where: { id }, }); @@ -39,7 +39,6 @@ export class ProfileAvatarController extends Controller { @Get("profileId-admin/{id}") async getProfileAdmin(@Path() id: string) { const profile = await this.profileRepository.findOne({ - select: ["id", "avatar", "avatarName"], where: { id }, }); @@ -49,7 +48,11 @@ export class ProfileAvatarController extends Controller { } @Get("select/{profileId}/{id}") - public async selectAvatar(@Path() profileId: string, @Path() id: string, @Request() req: RequestWithUser) { + public async selectAvatar( + @Path() profileId: string, + @Path() id: string, + @Request() req: RequestWithUser, + ) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const result = await this.avatarRepository.findOneBy({ id: id }); if (!result) { @@ -81,7 +84,7 @@ export class ProfileAvatarController extends Controller { const profile = await this.profileRepository.findOne({ where: { id: body.profileId }, }); - + if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } @@ -94,6 +97,8 @@ export class ProfileAvatarController 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 }); @@ -129,11 +134,14 @@ export class ProfileAvatarController extends Controller { } @Delete("{avatarId}") - public async deleteAvatar(@Path() avatarId: string, @Request() req: RequestWithUser) - { + public async deleteAvatar(@Path() avatarId: string, @Request() req: RequestWithUser) { const _record = await this.avatarRepository.findOneBy({ id: avatarId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_OFFICER", + _record.profileId, + ); } const result = await this.avatarRepository.delete({ id: avatarId }); diff --git a/src/controllers/ProfileAvatarEmployeeController.ts b/src/controllers/ProfileAvatarEmployeeController.ts index e05e1d41..7119fa29 100644 --- a/src/controllers/ProfileAvatarEmployeeController.ts +++ b/src/controllers/ProfileAvatarEmployeeController.ts @@ -22,6 +22,7 @@ export class ProfileAvatarEmployeeController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const lists = await this.avatarRepository.find({ where: { profileEmployeeId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -30,7 +31,6 @@ export class ProfileAvatarEmployeeController extends Controller { async getProfile(@Path() id: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", id); const profile = await this.profileRepository.findOne({ - select: ["id", "avatar", "avatarName"], where: { id }, }); @@ -42,7 +42,6 @@ export class ProfileAvatarEmployeeController extends Controller { @Get("profileEmployeeId-admin/{id}") async getProfileAdmin(@Path() id: string) { const profile = await this.profileRepository.findOne({ - select: ["id", "avatar", "avatarName"], where: { id }, }); @@ -103,6 +102,8 @@ export class ProfileAvatarEmployeeController 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 }); @@ -141,7 +142,11 @@ export class ProfileAvatarEmployeeController extends Controller { public async deleteAvatarEmployee(@Path() avatarId: string, @Request() req: RequestWithUser) { const _record = await this.avatarRepository.findOneBy({ id: avatarId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const result = await this.avatarRepository.delete({ id: avatarId }); diff --git a/src/controllers/ProfileAvatarEmployeeTempController.ts b/src/controllers/ProfileAvatarEmployeeTempController.ts index 076d42df..c86f6144 100644 --- a/src/controllers/ProfileAvatarEmployeeTempController.ts +++ b/src/controllers/ProfileAvatarEmployeeTempController.ts @@ -22,6 +22,7 @@ export class ProfileAvatarEmployeeTempController extends Controller { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.avatarRepository.find({ where: { profileEmployeeId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -30,7 +31,6 @@ export class ProfileAvatarEmployeeTempController extends Controller { async getProfile(@Path() id: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepository.findOne({ - select: ["id", "avatar", "avatarName"], where: { id }, }); @@ -42,7 +42,6 @@ export class ProfileAvatarEmployeeTempController extends Controller { @Get("profileEmployeeId-admin/{id}") async getProfileAdmin(@Path() id: string) { const profile = await this.profileRepository.findOne({ - select: ["id", "avatar", "avatarName"], where: { id }, }); @@ -57,7 +56,7 @@ export class ProfileAvatarEmployeeTempController extends Controller { @Path() id: string, @Request() req: RequestWithUser, ) { - // await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); //ไม่แน่ใจTEMPปิดไว้ก่อน + await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const result = await this.avatarRepository.findOneBy({ id: id }); if (!result) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -104,6 +103,8 @@ export class ProfileAvatarEmployeeTempController 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 }); diff --git a/src/controllers/ProfileCertificateController.ts b/src/controllers/ProfileCertificateController.ts index 76499740..4d73c67a 100644 --- a/src/controllers/ProfileCertificateController.ts +++ b/src/controllers/ProfileCertificateController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,85 +40,34 @@ export class ProfileCertificateController extends Controller { } const record = await this.certificateRepo.find({ where: { profileId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70", - createdAt: "2024-03-12T03:02:27.532Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:02:27.532Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - expireDate: "2024-03-12T10:01:48.000Z", - issueDate: "2024-03-12T10:01:48.000Z", - certificateNo: "string", - certificateType: "string", - issuer: "string", - }, - ], - }) public async getCertificate(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); - const record = await this.certificateRepo.findBy({ profileId }); + const record = await this.certificateRepo.find({ + where: { profileId: profileId }, + order: { createdAt: "ASC" }, + }); return new HttpSuccess(record); } @Get("history/{certificateId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "c0ecf986-b290-44ca-b45e-f4448cdd34dd", - createdAt: "2024-03-12T03:03:30.169Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T03:03:30.169Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - expireDate: "2024-03-12T10:03:05.000Z", - issueDate: "2024-03-12T10:03:05.000Z", - certificateNo: "no", - certificateType: "type", - issuer: "issuer", - profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70", - }, - { - id: "dc4c2800-5fc5-4ec3-b19a-c4a27beac35f", - createdAt: "2024-03-12T03:02:27.583Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:02:27.583Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - expireDate: "2024-03-12T10:01:48.000Z", - issueDate: "2024-03-12T10:01:48.000Z", - certificateNo: "string", - certificateType: "string", - issuer: "string", - profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70", - }, - ], - }) public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) { const _record = await this.certificateRepo.findOneBy({ id: certificateId }); if (_record) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } - const record = await this.certificateHistoryRepo.findBy({ - profileCertificateId: certificateId, + const record = await this.certificateHistoryRepo.find({ + where: { + profileCertificateId: certificateId, + }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); - } @Post() @@ -130,9 +78,9 @@ export class ProfileCertificateController extends Controller { if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } - + const profile = await this.profileRepo.findOneBy({ id: body.profileId }); - + if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } @@ -145,6 +93,8 @@ export class ProfileCertificateController 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 }); @@ -167,19 +117,22 @@ export class ProfileCertificateController extends Controller { const record = await this.certificateRepo.findOneBy({ id: certificateId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId); - + const history = new ProfileCertificateHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileCertificateId = certificateId; 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.certificateRepo.save(record), @@ -191,10 +144,14 @@ export class ProfileCertificateController extends Controller { @Delete("{certificateId}") public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) { - const _record = await this.certificateRepo.findOneBy({ id: certificateId }); - if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); - } + const _record = await this.certificateRepo.findOneBy({ id: certificateId }); + if (_record) { + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_OFFICER", + _record.profileId, + ); + } await this.certificateHistoryRepo.delete({ profileCertificateId: certificateId, }); diff --git a/src/controllers/ProfileCertificateEmployeeController.ts b/src/controllers/ProfileCertificateEmployeeController.ts index 374b11ee..e5f3bd03 100644 --- a/src/controllers/ProfileCertificateEmployeeController.ts +++ b/src/controllers/ProfileCertificateEmployeeController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,82 +40,36 @@ export class ProfileCertificateEmployeeController extends Controller { } const record = await this.certificateRepo.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70", - createdAt: "2024-03-12T03:02:27.532Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:02:27.532Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - expireDate: "2024-03-12T10:01:48.000Z", - issueDate: "2024-03-12T10:01:48.000Z", - certificateNo: "string", - certificateType: "string", - issuer: "string", - }, - ], - }) public async getCertificate(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); - const record = await this.certificateRepo.findBy({ profileEmployeeId }); + const record = await this.certificateRepo.find({ + where: { profileEmployeeId: profileEmployeeId }, + order: { createdAt: "ASC" }, + }); return new HttpSuccess(record); } @Get("history/{certificateId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "c0ecf986-b290-44ca-b45e-f4448cdd34dd", - createdAt: "2024-03-12T03:03:30.169Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T03:03:30.169Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - expireDate: "2024-03-12T10:03:05.000Z", - issueDate: "2024-03-12T10:03:05.000Z", - certificateNo: "no", - certificateType: "type", - issuer: "issuer", - profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70", - }, - { - id: "dc4c2800-5fc5-4ec3-b19a-c4a27beac35f", - createdAt: "2024-03-12T03:02:27.583Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:02:27.583Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - expireDate: "2024-03-12T10:01:48.000Z", - issueDate: "2024-03-12T10:01:48.000Z", - certificateNo: "string", - certificateType: "string", - issuer: "string", - profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70", - }, - ], - }) public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) { - const _record = await this.certificateRepo.findOneBy({ id: certificateId }); - if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); - } - const record = await this.certificateHistoryRepo.findBy({ - profileCertificateId: certificateId, + const _record = await this.certificateRepo.findOneBy({ id: certificateId }); + if (_record) { + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); + } + const record = await this.certificateHistoryRepo.find({ + where: { + profileCertificateId: certificateId, + }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -129,7 +82,7 @@ export class ProfileCertificateEmployeeController extends Controller { if (!body.profileEmployeeId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); } - + const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -143,6 +96,8 @@ export class ProfileCertificateEmployeeController 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 }); @@ -164,20 +119,27 @@ export class ProfileCertificateEmployeeController extends Controller { ) { const record = await this.certificateRepo.findOneBy({ id: certificateId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId); + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); const history = new ProfileCertificateHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileCertificateId = certificateId; 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.certificateRepo.save(record), @@ -191,8 +153,12 @@ export class ProfileCertificateEmployeeController extends Controller { public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) { const _record = await this.certificateRepo.findOneBy({ id: certificateId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); - } + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); + } await this.certificateHistoryRepo.delete({ profileCertificateId: certificateId, }); diff --git a/src/controllers/ProfileCertificateEmployeeTempController.ts b/src/controllers/ProfileCertificateEmployeeTempController.ts index f63cac2c..010948f9 100644 --- a/src/controllers/ProfileCertificateEmployeeTempController.ts +++ b/src/controllers/ProfileCertificateEmployeeTempController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,79 +40,29 @@ export class ProfileCertificateEmployeeTempController extends Controller { } const record = await this.certificateRepo.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70", - createdAt: "2024-03-12T03:02:27.532Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:02:27.532Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - expireDate: "2024-03-12T10:01:48.000Z", - issueDate: "2024-03-12T10:01:48.000Z", - certificateNo: "string", - certificateType: "string", - issuer: "string", - }, - ], - }) public async getCertificate(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); - const record = await this.certificateRepo.findBy({ profileEmployeeId }); + const record = await this.certificateRepo.find({ + where: { profileEmployeeId }, + order: { createdAt: "ASC" }, + }); return new HttpSuccess(record); } @Get("history/{certificateId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "c0ecf986-b290-44ca-b45e-f4448cdd34dd", - createdAt: "2024-03-12T03:03:30.169Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T03:03:30.169Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - expireDate: "2024-03-12T10:03:05.000Z", - issueDate: "2024-03-12T10:03:05.000Z", - certificateNo: "no", - certificateType: "type", - issuer: "issuer", - profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70", - }, - { - id: "dc4c2800-5fc5-4ec3-b19a-c4a27beac35f", - createdAt: "2024-03-12T03:02:27.583Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:02:27.583Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - expireDate: "2024-03-12T10:01:48.000Z", - issueDate: "2024-03-12T10:01:48.000Z", - certificateNo: "string", - certificateType: "string", - issuer: "string", - profileCertificateId: "e1ef9c3d-079a-40d8-8332-664c3e9a5a70", - }, - ], - }) public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); - const record = await this.certificateHistoryRepo.findBy({ - profileCertificateId: certificateId, + const record = await this.certificateHistoryRepo.find({ + where: { + profileCertificateId: certificateId, + }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -141,6 +90,8 @@ export class ProfileCertificateEmployeeTempController 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 }); @@ -168,15 +119,18 @@ export class ProfileCertificateEmployeeTempController extends Controller { const history = new ProfileCertificateHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileCertificateId = certificateId; 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.certificateRepo.save(record), diff --git a/src/controllers/ProfileChangeNameController.ts b/src/controllers/ProfileChangeNameController.ts index 51521570..bf2aa75a 100644 --- a/src/controllers/ProfileChangeNameController.ts +++ b/src/controllers/ProfileChangeNameController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -24,7 +23,6 @@ import { ProfileChangeName, UpdateProfileChangeName, } from "../entities/ProfileChangeName"; -import CallAPI from "../interfaces/call-api"; import { updateName } from "../keycloak"; import permission from "../interfaces/permission"; @Route("api/v1/org/profile/changeName") @@ -43,61 +41,22 @@ export class ProfileChangeNameController extends Controller { } const lists = await this.changeNameRepository.find({ where: { profileId: profile.id }, - select: ["id", "prefix", "firstName", "lastName", "status"], order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - prefix: "string", - firstName: "string", - lastName: "string", - status: "string", - }, - ], - }) public async getChangeName(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.changeNameRepository.find({ where: { profileId: profileId }, - select: ["id", "prefix", "firstName", "lastName", "status"], order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("history/{changeNameId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - prefix: "string", - firstName: "string", - lastName: "string", - status: "string", - createdFullName: "string", - createdAt: "string", - }, - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - prefix: "string", - firstName: "string", - lastName: "string", - status: "string", - createdFullName: "string", - createdAt: "string", - }, - ], - }) public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) { const _record = await this.changeNameRepository.findOneBy({ id: changeNameId }); if (_record) { @@ -105,15 +64,6 @@ export class ProfileChangeNameController extends Controller { } const record = await this.changeNameHistoryRepository.find({ where: { profileChangeNameId: changeNameId }, - select: [ - "id", - "prefix", - "firstName", - "lastName", - "status", - "lastUpdateFullName", - "lastUpdatedAt", - ], order: { createdAt: "DESC" }, }); return new HttpSuccess(record); @@ -127,13 +77,13 @@ export class ProfileChangeNameController extends Controller { if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } - + const profile = await this.profileRepository.findOneBy({ id: body.profileId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profile.id); - + const data = new ProfileChangeName(); const meta = { @@ -141,6 +91,8 @@ export class ProfileChangeNameController 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 }); @@ -179,15 +131,18 @@ export class ProfileChangeNameController extends Controller { const history = new ProfileChangeNameHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileChangeNameId = changeNameId; 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.changeNameRepository.save(record), @@ -228,7 +183,11 @@ export class ProfileChangeNameController extends Controller { public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) { const _record = await this.changeNameRepository.findOneBy({ id: changeNameId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_OFFICER", + _record.profileId, + ); } await this.changeNameHistoryRepository.delete({ profileChangeNameId: changeNameId, diff --git a/src/controllers/ProfileChangeNameEmployeeController.ts b/src/controllers/ProfileChangeNameEmployeeController.ts index 6f7511bb..25c1357c 100644 --- a/src/controllers/ProfileChangeNameEmployeeController.ts +++ b/src/controllers/ProfileChangeNameEmployeeController.ts @@ -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 { ProfileChangeNameHistory } from "../entities/ProfileChangeNameHistory"; import { RequestWithUser } from "../middlewares/user"; -import { Profile } from "../entities/Profile"; import { - CreateProfileChangeName, CreateProfileChangeNameEmployee, ProfileChangeName, UpdateProfileChangeName, @@ -44,78 +41,33 @@ export class ProfileChangeNameEmployeeController extends Controller { } const lists = await this.changeNameRepository.find({ where: { profileEmployeeId: profile.id }, - select: ["id", "prefix", "firstName", "lastName", "status"], order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - prefix: "string", - firstName: "string", - lastName: "string", - status: "string", - }, - ], - }) public async getChangeName(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const lists = await this.changeNameRepository.find({ where: { profileEmployeeId: profileEmployeeId }, - select: ["id", "prefix", "firstName", "lastName", "status"], order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("history/{changeNameId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - prefix: "string", - firstName: "string", - lastName: "string", - status: "string", - createdFullName: "string", - createdAt: "string", - }, - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - prefix: "string", - firstName: "string", - lastName: "string", - status: "string", - createdFullName: "string", - createdAt: "string", - }, - ], - }) public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) { - const _record = await this.changeNameRepository.findOneBy({ id: changeNameId }); - if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId, - ); - } + const _record = await this.changeNameRepository.findOneBy({ id: changeNameId }); + if (_record) { + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); + } const record = await this.changeNameHistoryRepository.find({ where: { profileChangeNameId: changeNameId }, - select: [ - "id", - "prefix", - "firstName", - "lastName", - "status", - "lastUpdateFullName", - "lastUpdatedAt", - ], order: { createdAt: "DESC" }, }); return new HttpSuccess(record); @@ -129,7 +81,7 @@ export class ProfileChangeNameEmployeeController extends Controller { if (!body.profileEmployeeId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); } - + const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -143,6 +95,8 @@ export class ProfileChangeNameEmployeeController 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 }); @@ -176,20 +130,27 @@ export class ProfileChangeNameEmployeeController extends Controller { ) { const record = await this.changeNameRepository.findOneBy({ id: changeNameId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId); + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); const history = new ProfileChangeNameHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileChangeNameId = changeNameId; 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.changeNameRepository.save(record), @@ -220,10 +181,14 @@ export class ProfileChangeNameEmployeeController extends Controller { @Delete("{changeNameId}") public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) { - const _record = await this.changeNameRepository.findOneBy({ id: changeNameId }); - if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); - } + const _record = await this.changeNameRepository.findOneBy({ id: changeNameId }); + if (_record) { + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); + } await this.changeNameHistoryRepository.delete({ profileChangeNameId: changeNameId, }); diff --git a/src/controllers/ProfileChangeNameEmployeeTempController.ts b/src/controllers/ProfileChangeNameEmployeeTempController.ts index a95a46e4..1ea57a8e 100644 --- a/src/controllers/ProfileChangeNameEmployeeTempController.ts +++ b/src/controllers/ProfileChangeNameEmployeeTempController.ts @@ -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 { ProfileChangeNameHistory } from "../entities/ProfileChangeNameHistory"; import { RequestWithUser } from "../middlewares/user"; -import { Profile } from "../entities/Profile"; import { - CreateProfileChangeName, CreateProfileChangeNameEmployee, ProfileChangeName, UpdateProfileChangeName, @@ -44,74 +41,26 @@ export class ProfileChangeNameEmployeeTempController extends Controller { } const lists = await this.changeNameRepository.find({ where: { profileEmployeeId: profile.id }, - select: ["id", "prefix", "firstName", "lastName", "status"], order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - prefix: "string", - firstName: "string", - lastName: "string", - status: "string", - }, - ], - }) public async getChangeName(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.changeNameRepository.find({ where: { profileEmployeeId: profileEmployeeId }, - select: ["id", "prefix", "firstName", "lastName", "status"], order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("history/{changeNameId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - prefix: "string", - firstName: "string", - lastName: "string", - status: "string", - createdFullName: "string", - createdAt: "string", - }, - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - prefix: "string", - firstName: "string", - lastName: "string", - status: "string", - createdFullName: "string", - createdAt: "string", - }, - ], - }) public async changeNameHistory(@Path() changeNameId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.changeNameHistoryRepository.find({ where: { profileChangeNameId: changeNameId }, - select: [ - "id", - "prefix", - "firstName", - "lastName", - "status", - "lastUpdateFullName", - "lastUpdatedAt", - ], order: { createdAt: "DESC" }, }); return new HttpSuccess(record); @@ -140,6 +89,8 @@ export class ProfileChangeNameEmployeeTempController 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 }); @@ -179,15 +130,18 @@ export class ProfileChangeNameEmployeeTempController extends Controller { const history = new ProfileChangeNameHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileChangeNameId = changeNameId; 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.changeNameRepository.save(record), diff --git a/src/controllers/ProfileChildrenController.ts b/src/controllers/ProfileChildrenController.ts index 51bf8689..61cd3cab 100644 --- a/src/controllers/ProfileChildrenController.ts +++ b/src/controllers/ProfileChildrenController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -42,6 +41,7 @@ export class ProfileChildrenController extends Controller { } const lists = await this.childrenRepository.find({ where: { profileId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -51,6 +51,7 @@ export class ProfileChildrenController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.childrenRepository.find({ where: { profileId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -82,6 +83,8 @@ export class ProfileChildrenController 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 }); @@ -109,16 +112,19 @@ export class ProfileChildrenController 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), this.childrenHistoryRepository.save(history), @@ -131,7 +137,11 @@ export class ProfileChildrenController extends Controller { public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) { const _record = await this.childrenRepository.findOneBy({ id: childrenId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_OFFICER", + _record.profileId, + ); } await this.childrenHistoryRepository.delete({ profileChildrenId: childrenId, diff --git a/src/controllers/ProfileChildrenEmployeeController.ts b/src/controllers/ProfileChildrenEmployeeController.ts index 7844fcdd..f0b8acde 100644 --- a/src/controllers/ProfileChildrenEmployeeController.ts +++ b/src/controllers/ProfileChildrenEmployeeController.ts @@ -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 ProfileChildrenEmployeeController extends Controller { } const lists = await this.childrenRepository.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -53,17 +51,21 @@ export class ProfileChildrenEmployeeController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const lists = await this.childrenRepository.find({ where: { profileEmployeeId: profileEmployeeId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("history/{childrenId}") public async childrenHistory(@Path() childrenId: string, @Request() req: RequestWithUser) { - const _record = await this.childrenRepository.findOneBy({ id: childrenId }); - if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId, - ); - } + const _record = await this.childrenRepository.findOneBy({ id: childrenId }); + if (_record) { + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); + } const record = await this.childrenHistoryRepository.find({ where: { profileChildrenId: childrenId }, order: { createdAt: "DESC" }, @@ -89,6 +91,8 @@ export class ProfileChildrenEmployeeController 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,20 +116,27 @@ export class ProfileChildrenEmployeeController extends Controller { ) { const record = await this.childrenRepository.findOneBy({ id: childrenId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId); - + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); + 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), @@ -139,7 +150,11 @@ export class ProfileChildrenEmployeeController extends Controller { public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) { const _record = await this.childrenRepository.findOneBy({ id: childrenId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } await this.childrenHistoryRepository.delete({ profileChildrenId: childrenId, diff --git a/src/controllers/ProfileChildrenEmployeeTempController.ts b/src/controllers/ProfileChildrenEmployeeTempController.ts index deea1fbe..e0e63daa 100644 --- a/src/controllers/ProfileChildrenEmployeeTempController.ts +++ b/src/controllers/ProfileChildrenEmployeeTempController.ts @@ -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), diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 4d6a97dd..91d3712c 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -1419,6 +1419,8 @@ export class ProfileController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), }); await Promise.all([this.salaryRepository.save(profileSalary)]); } @@ -1498,6 +1500,8 @@ export class ProfileController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), }); await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); @@ -1576,6 +1580,8 @@ export class ProfileController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), }); await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); @@ -1654,6 +1660,8 @@ export class ProfileController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), }); // //เพิ่มวินัย // const profileDiscipline: ProfileDiscipline = Object.assign(new ProfileDiscipline(), { @@ -1663,7 +1671,9 @@ export class ProfileController extends Controller { // createdUserId: req.user.sub, // createdFullName: req.user.name, // lastUpdateUserId: req.user.sub, - // lastUpdateFullName: req.user.name, + // lastUpdateFullName: req.user.name, + // createdAt: new Date(), + // lastUpdatedAt: new Date(), // }); await Promise.all([ this.profileRepo.save(_profile), @@ -1746,6 +1756,8 @@ export class ProfileController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), }); await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); @@ -1824,6 +1836,8 @@ export class ProfileController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), }); await Promise.all([this.profileRepo.save(_profile), this.salaryRepository.save(profileSalary)]); @@ -1895,6 +1909,8 @@ export class ProfileController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), }); await Promise.all([this.salaryRepository.save(profileSalary)]); @@ -1966,6 +1982,8 @@ export class ProfileController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), }); await Promise.all([this.salaryRepository.save(profileSalary)]); @@ -2037,6 +2055,8 @@ export class ProfileController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), }); await Promise.all([this.salaryRepository.save(profileSalary)]); @@ -2108,6 +2128,8 @@ export class ProfileController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), }); await Promise.all([this.salaryRepository.save(profileSalary)]); @@ -2179,6 +2201,8 @@ export class ProfileController extends Controller { createdFullName: req.user.name, lastUpdateUserId: req.user.sub, lastUpdateFullName: req.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), }); await Promise.all([this.salaryRepository.save(profileSalary)]); @@ -2250,7 +2274,9 @@ export class ProfileController extends Controller { // createdUserId: req.user.sub, // createdFullName: req.user.name, // lastUpdateUserId: req.user.sub, - // lastUpdateFullName: req.user.name, + // lastUpdateFullName: req.user.name, + // createdAt: new Date(), + // lastUpdatedAt: new Date(), // }); await Promise.all([this.profileRepo.save(profile)]); diff --git a/src/controllers/ProfileDevelopmentController.ts b/src/controllers/ProfileDevelopmentController.ts index 1624b7d5..11deb174 100644 --- a/src/controllers/ProfileDevelopmentController.ts +++ b/src/controllers/ProfileDevelopmentController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,53 +40,22 @@ export class ProfileDevelopmentController extends Controller { } const lists = await this.developmentRepository.find({ where: { profileId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - isActive: true, - date: "2024-03-12T10:09:47.000Z", - reference: "string", - detail: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - ], - }) public async getDevelopment(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.developmentRepository.find({ where: { profileId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("history/{developmentId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - isActive: true, - date: "2024-03-12T10:09:47.000Z", - detail: "string", - }, - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - isActive: true, - date: "2024-03-12T10:09:47.000Z", - detail: "string", - }, - ], - }) public async developmentHistory(@Path() developmentId: string, @Request() req: RequestWithUser) { const _record = await this.developmentRepository.findOneBy({ id: developmentId }); if (_record) { @@ -122,6 +90,8 @@ export class ProfileDevelopmentController 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 }); @@ -150,15 +120,18 @@ export class ProfileDevelopmentController extends Controller { const history = new ProfileDevelopmentHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileDevelopmentId = developmentId; 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.developmentRepository.save(record), diff --git a/src/controllers/ProfileDevelopmentEmployeeController.ts b/src/controllers/ProfileDevelopmentEmployeeController.ts index dc6e3c8e..4089b8a4 100644 --- a/src/controllers/ProfileDevelopmentEmployeeController.ts +++ b/src/controllers/ProfileDevelopmentEmployeeController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,6 +40,7 @@ export class ProfileDevelopmentEmployeeController extends Controller { } const lists = await this.developmentRepository.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -50,6 +50,7 @@ export class ProfileDevelopmentEmployeeController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const lists = await this.developmentRepository.find({ where: { profileEmployeeId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -93,6 +94,8 @@ export class ProfileDevelopmentEmployeeController 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 }); @@ -125,15 +128,18 @@ export class ProfileDevelopmentEmployeeController extends Controller { const history = new ProfileDevelopmentHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileDevelopmentId = developmentId; 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.developmentRepository.save(record), diff --git a/src/controllers/ProfileDevelopmentEmployeeTempController.ts b/src/controllers/ProfileDevelopmentEmployeeTempController.ts index 5d6193c4..425232a4 100644 --- a/src/controllers/ProfileDevelopmentEmployeeTempController.ts +++ b/src/controllers/ProfileDevelopmentEmployeeTempController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,6 +40,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller { } const lists = await this.developmentRepository.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -50,6 +50,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.developmentRepository.find({ where: { profileEmployeeId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -87,6 +88,8 @@ export class ProfileDevelopmentEmployeeTempController 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 }); @@ -116,15 +119,18 @@ export class ProfileDevelopmentEmployeeTempController extends Controller { const history = new ProfileDevelopmentHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileDevelopmentId = developmentId; 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.developmentRepository.save(record), diff --git a/src/controllers/ProfileDisciplineController.ts b/src/controllers/ProfileDisciplineController.ts index c1fa0de4..d9acf0e4 100644 --- a/src/controllers/ProfileDisciplineController.ts +++ b/src/controllers/ProfileDisciplineController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,17 +40,7 @@ export class ProfileDisciplineController extends Controller { } const lists = await this.disciplineRepository.find({ where: { profileId: profile.id }, - select: [ - "id", - "date", - "level", - "detail", - "unStigma", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -61,17 +50,7 @@ export class ProfileDisciplineController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.disciplineRepository.find({ where: { profileId: profileId }, - select: [ - "id", - "date", - "level", - "detail", - "unStigma", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -81,46 +60,12 @@ export class ProfileDisciplineController extends Controller { await new permission().PermissionGet(req, "SYS_SALARY_OFFICER"); const lists = await this.disciplineRepository.find({ where: { profileId: profileId }, - select: [ - "id", - "date", - "level", - "detail", - "unStigma", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("history/{disciplineId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - date: "2024-03-12T10:09:47.000Z", - level: "string", - detail: "string", - unStigma: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - { - id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f", - date: "2024-03-12T10:09:47.000Z", - level: "string", - detail: "string", - unStigma: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - ], - }) public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) { const _record = await this.disciplineRepository.findOneBy({ id: disciplineId }); if (_record) { @@ -128,17 +73,6 @@ export class ProfileDisciplineController extends Controller { } const record = await this.disciplineHistoryRepository.find({ where: { profileDisciplineId: disciplineId }, - select: [ - "id", - "date", - "level", - "detail", - "unStigma", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], order: { createdAt: "DESC" }, }); return new HttpSuccess(record); @@ -152,9 +86,9 @@ export class ProfileDisciplineController extends Controller { if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } - + const profile = await this.profileRepository.findOneBy({ id: body.profileId }); - + if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } @@ -167,6 +101,8 @@ export class ProfileDisciplineController 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 }); @@ -193,15 +129,18 @@ export class ProfileDisciplineController extends Controller { const history = new ProfileDisciplineHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileDisciplineId = disciplineId; 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.disciplineRepository.save(record), @@ -215,7 +154,11 @@ export class ProfileDisciplineController extends Controller { public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) { const _record = await this.disciplineRepository.findOneBy({ id: disciplineId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_OFFICER", + _record.profileId, + ); } await this.disciplineHistoryRepository.delete({ profileDisciplineId: disciplineId, diff --git a/src/controllers/ProfileDisciplineEmployeeController.ts b/src/controllers/ProfileDisciplineEmployeeController.ts index f09ca2b9..3beb847b 100644 --- a/src/controllers/ProfileDisciplineEmployeeController.ts +++ b/src/controllers/ProfileDisciplineEmployeeController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,52 +40,17 @@ export class ProfileDisciplineEmployeeController extends Controller { } const lists = await this.disciplineRepository.find({ where: { profileEmployeeId: profile.id }, - select: [ - "id", - "date", - "level", - "detail", - "unStigma", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - date: "2024-03-12T10:09:47.000Z", - level: "string", - detail: "string", - unStigma: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - ], - }) public async getDiscipline(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const lists = await this.disciplineRepository.find({ where: { profileEmployeeId: profileId }, - select: [ - "id", - "date", - "level", - "detail", - "unStigma", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -96,17 +60,7 @@ export class ProfileDisciplineEmployeeController extends Controller { await new permission().PermissionGet(req, "SYS_WAGE"); const lists = await this.disciplineRepository.find({ where: { profileEmployeeId: profileId }, - select: [ - "id", - "date", - "level", - "detail", - "unStigma", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -115,21 +69,14 @@ export class ProfileDisciplineEmployeeController extends Controller { public async disciplineHistory(@Path() disciplineId: string, @Request() req: RequestWithUser) { const _record = await this.disciplineRepository.findOneBy({ id: disciplineId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.disciplineHistoryRepository.find({ where: { profileDisciplineId: disciplineId }, - select: [ - "id", - "date", - "level", - "detail", - "unStigma", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], order: { createdAt: "DESC" }, }); return new HttpSuccess(record); @@ -157,6 +104,8 @@ export class ProfileDisciplineEmployeeController 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 }); @@ -178,20 +127,27 @@ export class ProfileDisciplineEmployeeController extends Controller { ) { const record = await this.disciplineRepository.findOneBy({ id: disciplineId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); const history = new ProfileDisciplineHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileDisciplineId = disciplineId; 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.disciplineRepository.save(record), @@ -205,7 +161,11 @@ export class ProfileDisciplineEmployeeController extends Controller { public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) { const _record = await this.disciplineRepository.findOneBy({ id: disciplineId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } await this.disciplineHistoryRepository.delete({ profileDisciplineId: disciplineId, diff --git a/src/controllers/ProfileDisciplineEmployeeTempController.ts b/src/controllers/ProfileDisciplineEmployeeTempController.ts index 4ada9c77..c459ed03 100644 --- a/src/controllers/ProfileDisciplineEmployeeTempController.ts +++ b/src/controllers/ProfileDisciplineEmployeeTempController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,52 +40,17 @@ export class ProfileDisciplineEmployeeTempController extends Controller { } const lists = await this.disciplineRepository.find({ where: { profileEmployeeId: profile.id }, - select: [ - "id", - "date", - "level", - "detail", - "unStigma", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - date: "2024-03-12T10:09:47.000Z", - level: "string", - detail: "string", - unStigma: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - ], - }) public async getDiscipline(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.disciplineRepository.find({ where: { profileEmployeeId: profileId }, - select: [ - "id", - "date", - "level", - "detail", - "unStigma", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -96,17 +60,7 @@ export class ProfileDisciplineEmployeeTempController extends Controller { await new permission().PermissionGet(req, "SYS_WAGE"); const lists = await this.disciplineRepository.find({ where: { profileEmployeeId: profileId }, - select: [ - "id", - "date", - "level", - "detail", - "unStigma", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -116,17 +70,6 @@ export class ProfileDisciplineEmployeeTempController extends Controller { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.disciplineHistoryRepository.find({ where: { profileDisciplineId: disciplineId }, - select: [ - "id", - "date", - "level", - "detail", - "unStigma", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], order: { createdAt: "DESC" }, }); return new HttpSuccess(record); @@ -155,6 +98,8 @@ export class ProfileDisciplineEmployeeTempController 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 }); @@ -182,15 +127,18 @@ export class ProfileDisciplineEmployeeTempController extends Controller { const history = new ProfileDisciplineHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileDisciplineId = disciplineId; 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.disciplineRepository.save(record), diff --git a/src/controllers/ProfileDutyController.ts b/src/controllers/ProfileDutyController.ts index 08d9d406..f97c7e5d 100644 --- a/src/controllers/ProfileDutyController.ts +++ b/src/controllers/ProfileDutyController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -37,77 +36,22 @@ export class ProfileDutyController extends Controller { } const lists = await this.dutyRepository.find({ where: { profileId: profile.id }, - select: [ - "id", - "dateStart", - "dateEnd", - "reference", - "detail", - "refCommandNo", - "refCommandDate", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - dateStart: "2024-03-12T10:09:47.000Z", - dateEnd: "string", - reference: "string", - detail: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - ], - }) public async getDuty(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.dutyRepository.find({ where: { profileId: profileId }, - select: [ - "id", - "dateStart", - "dateEnd", - "reference", - "detail", - "refCommandNo", - "refCommandDate", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("history/{dutyId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - dateStart: "2024-03-12T10:09:47.000Z", - dateEnd: "string", - reference: "string", - detail: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - dateStart: "2024-03-12T10:09:47.000Z", - dateEnd: "string", - reference: "string", - detail: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - ], - }) public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) { const _record = await this.dutyRepository.findOneBy({ id: dutyId }); if (_record) { @@ -115,17 +59,6 @@ export class ProfileDutyController extends Controller { } const record = await this.dutyHistoryRepository.find({ where: { profileDutyId: dutyId }, - select: [ - "id", - "dateStart", - "dateEnd", - "reference", - "detail", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], order: { createdAt: "DESC" }, }); return new HttpSuccess(record); @@ -150,6 +83,8 @@ export class ProfileDutyController 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 }); @@ -176,15 +111,18 @@ export class ProfileDutyController extends Controller { const history = new ProfileDutyHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileDutyId = dutyId; 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.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]); diff --git a/src/controllers/ProfileDutyEmployeeController.ts b/src/controllers/ProfileDutyEmployeeController.ts index 4381969f..72f2a65e 100644 --- a/src/controllers/ProfileDutyEmployeeController.ts +++ b/src/controllers/ProfileDutyEmployeeController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -37,15 +36,7 @@ export class ProfileDutyEmployeeController extends Controller { } const lists = await this.dutyRepository.find({ where: { profileEmployeeId: profile.id }, - select: [ - "id", - "dateStart", - "dateEnd", - "reference", - "detail", - "refCommandNo", - "refCommandDate", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -55,15 +46,7 @@ export class ProfileDutyEmployeeController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const lists = await this.dutyRepository.find({ where: { profileEmployeeId: profileId }, - select: [ - "id", - "dateStart", - "dateEnd", - "reference", - "detail", - "refCommandNo", - "refCommandDate", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -72,21 +55,14 @@ export class ProfileDutyEmployeeController extends Controller { public async dutyHistory(@Path() dutyId: string, @Request() req: RequestWithUser) { const _record = await this.dutyRepository.findOneBy({ id: dutyId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.dutyHistoryRepository.find({ where: { profileDutyId: dutyId }, - select: [ - "id", - "dateStart", - "dateEnd", - "reference", - "detail", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], order: { createdAt: "DESC" }, }); return new HttpSuccess(record); @@ -111,6 +87,8 @@ export class ProfileDutyEmployeeController 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 }); @@ -132,20 +110,27 @@ export class ProfileDutyEmployeeController extends Controller { ) { const record = await this.dutyRepository.findOneBy({ id: dutyId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); const history = new ProfileDutyHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileDutyId = dutyId; 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.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]); @@ -156,7 +141,11 @@ export class ProfileDutyEmployeeController extends Controller { public async deleteDuty(@Path() dutyId: string, @Request() req: RequestWithUser) { const _record = await this.dutyRepository.findOneBy({ id: dutyId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } await this.dutyHistoryRepository.delete({ profileDutyId: dutyId, diff --git a/src/controllers/ProfileDutyEmployeeTempController.ts b/src/controllers/ProfileDutyEmployeeTempController.ts index 18a9749e..3c65f345 100644 --- a/src/controllers/ProfileDutyEmployeeTempController.ts +++ b/src/controllers/ProfileDutyEmployeeTempController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -37,15 +36,7 @@ export class ProfileDutyEmployeeTempController extends Controller { } const lists = await this.dutyRepository.find({ where: { profileEmployeeId: profile.id }, - select: [ - "id", - "dateStart", - "dateEnd", - "reference", - "detail", - "refCommandNo", - "refCommandDate", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -55,15 +46,7 @@ export class ProfileDutyEmployeeTempController extends Controller { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.dutyRepository.find({ where: { profileEmployeeId: profileId }, - select: [ - "id", - "dateStart", - "dateEnd", - "reference", - "detail", - "refCommandNo", - "refCommandDate", - ], + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -73,17 +56,6 @@ export class ProfileDutyEmployeeTempController extends Controller { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.dutyHistoryRepository.find({ where: { profileDutyId: dutyId }, - select: [ - "id", - "dateStart", - "dateEnd", - "reference", - "detail", - "refCommandNo", - "refCommandDate", - "lastUpdateFullName", - "lastUpdatedAt", - ], order: { createdAt: "DESC" }, }); return new HttpSuccess(record); @@ -109,6 +81,8 @@ export class ProfileDutyEmployeeTempController 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 }); @@ -136,15 +110,18 @@ export class ProfileDutyEmployeeTempController extends Controller { const history = new ProfileDutyHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileDutyId = dutyId; 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.dutyRepository.save(record), this.dutyHistoryRepository.save(history)]); diff --git a/src/controllers/ProfileEditController.ts b/src/controllers/ProfileEditController.ts index 450d8bd5..083f588f 100644 --- a/src/controllers/ProfileEditController.ts +++ b/src/controllers/ProfileEditController.ts @@ -19,7 +19,7 @@ import { AppDataSource } from "../database/data-source"; import { Profile } from "../entities/Profile"; import { CreateProfileEdit, EditProfileEdit, ProfileEdit } from "../entities/ProfileEdit"; import { RequestWithUser } from "../middlewares/user"; -import { IsNull, Not, Brackets } from "typeorm"; +import { Brackets } from "typeorm"; @Route("api/v1/org/profile/edit") @Tags("ProfileEdit") @@ -52,22 +52,14 @@ export class ProfileEditController extends Controller { }) .andWhere( new Brackets((qb) => { - qb.where( - keyword != "" && keyword != null - ? "ProfileEdit.topic LIKE :keyword" - : "1=1", + qb.where(keyword != "" && keyword != null ? "ProfileEdit.topic LIKE :keyword" : "1=1", { + keyword: `%${keyword}%`, + }).orWhere( + keyword != "" && keyword != null ? "ProfileEdit.detail LIKE :keyword" : "1=1", { keyword: `%${keyword}%`, }, - ) - .orWhere( - keyword != "" && keyword != null - ? "ProfileEdit.detail LIKE :keyword" - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) + ); }), ) .orderBy("ProfileEdit.createdAt", "ASC") @@ -114,22 +106,14 @@ export class ProfileEditController extends Controller { }) .andWhere( new Brackets((qb) => { - qb.where( - keyword != "" && keyword != null - ? "ProfileEdit.topic LIKE :keyword" - : "1=1", + qb.where(keyword != "" && keyword != null ? "ProfileEdit.topic LIKE :keyword" : "1=1", { + keyword: `%${keyword}%`, + }).orWhere( + keyword != "" && keyword != null ? "ProfileEdit.detail LIKE :keyword" : "1=1", { keyword: `%${keyword}%`, }, - ) - .orWhere( - keyword != "" && keyword != null - ? "ProfileEdit.detail LIKE :keyword" - : "1=1", - { - keyword: `%${keyword}%`, - }, - ) + ); }), ) .orderBy("ProfileEdit.createdAt", "ASC") @@ -209,6 +193,8 @@ export class ProfileEditController 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 }); @@ -226,7 +212,7 @@ export class ProfileEditController extends Controller { ) { // const record = await this.profileEditRepo.findOneBy({ id: editId }); const record = await this.profileEditRepo.findOne({ - where: { id: editId } + where: { id: editId }, }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); diff --git a/src/controllers/ProfileEditEmployeeController.ts b/src/controllers/ProfileEditEmployeeController.ts index 40901a9a..5405742f 100644 --- a/src/controllers/ProfileEditEmployeeController.ts +++ b/src/controllers/ProfileEditEmployeeController.ts @@ -23,7 +23,7 @@ import { } from "../entities/ProfileEdit"; import { ProfileEmployee } from "../entities/ProfileEmployee"; import { RequestWithUser } from "../middlewares/user"; -import { IsNull, Not, Brackets } from "typeorm"; +import { Brackets } from "typeorm"; @Route("api/v1/org/profile-employee/edit") @Tags("ProfileEmployeeEdit") @@ -203,6 +203,8 @@ export class ProfileEditEmployeeController 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 }); data.status = "PENDING"; diff --git a/src/controllers/ProfileEducationsController.ts b/src/controllers/ProfileEducationsController.ts index bf81e0fd..0e8bc208 100644 --- a/src/controllers/ProfileEducationsController.ts +++ b/src/controllers/ProfileEducationsController.ts @@ -1,7 +1,6 @@ import { Controller, Post, - Put, Delete, Route, Security, @@ -9,12 +8,8 @@ import { Body, Path, Request, - SuccessResponse, - Response, Get, - Query, Patch, - Example, } from "tsoa"; import HttpSuccess from "../interfaces/http-success"; @@ -47,6 +42,7 @@ export class ProfileEducationsController extends Controller { } const getProfileEducation = await this.profileEducationRepo.find({ where: { profileId: profile.id }, + order: { createdAt: "ASC" }, }); if (!getProfileEducation) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -55,45 +51,12 @@ export class ProfileEducationsController extends Controller { } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6", - createdAt: "2024-03-12T20:26:42.621Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T20:33:09.000Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "test bar", - lastUpdateFullName: "test bar", - profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - isActive: true, - country: "string", - degree: "ปวส", - duration: "-", - durationYear: 0, - field: "ชางเทคนิค ชั้นสูง", - finishDate: "2024-03-13T03:23:31.000Z", - fundName: "-", - gpa: "3.64", - institute: "เทคโนเชียงใหม่", - other: "string", - startDate: "2024-03-13T03:23:31.000Z", - endDate: "2024-03-13T03:23:31.000Z", - educationLevel: "ปวส", - educationLevelId: "string", - positionPath: "string", - positionPathId: "string", - note: "string", - isDate: true, - isEducation: true, - }, - ], - }) public async detailProfileEducation(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); - const getProfileEducation = await this.profileEducationRepo.findBy({ profileId }); + const getProfileEducation = await this.profileEducationRepo.find({ + where: { profileId: profileId }, + order: { createdAt: "ASC" }, + }); if (!getProfileEducation) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -101,79 +64,19 @@ export class ProfileEducationsController extends Controller { } @Get("history/{educationId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "294aa117-6ce7-4c23-b5bd-fe1f12932c4a", - createdAt: "2024-03-12T20:29:45.251Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T20:29:45.251Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - isActive: true, - country: "string", - degree: "ปวส", - duration: "-", - durationYear: 0, - field: "ชางเทคนิค", - finishDate: "2024-03-13T03:23:31.000Z", - fundName: "-", - gpa: "3.64", - institute: "เทคโนเชียงใหม่", - other: "string", - startDate: "2024-03-13T03:23:31.000Z", - endDate: "2024-03-13T03:23:31.000Z", - educationLevel: "ปวส", - educationLevelId: "string", - positionPath: "string", - positionPathId: "string", - note: "string", - isDate: true, - isEducation: true, - profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6", + public async getProfileEducationHistory( + @Path() educationId: string, + @Request() req: RequestWithUser, + ) { + const _record = await this.profileEducationRepo.findOneBy({ id: educationId }); + if (_record) { + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + } + const record = await this.profileEducationHistoryRepo.find({ + where: { + profileEducationId: educationId, }, - { - id: "2f00bd59-be3e-46d8-92a2-c4700baabf12", - createdAt: "2024-03-12T20:33:09.128Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T20:33:09.128Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - isActive: true, - country: "string", - degree: "ปวส", - duration: "-", - durationYear: 0, - field: "ชางเทคนิค ชั้นสูง", - finishDate: "2024-03-13T03:23:31.000Z", - fundName: "-", - gpa: "3.64", - institute: "เทคโนเชียงใหม่", - other: "string", - startDate: "2024-03-13T03:23:31.000Z", - endDate: "2024-03-13T03:23:31.000Z", - educationLevel: "ปวส", - educationLevelId: "string", - positionPath: "string", - positionPathId: "string", - note: "string", - isDate: true, - isEducation: true, - profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6", - }, - ], - }) - public async getProfileEducationHistory(@Path() educationId: string, @Request() req: RequestWithUser) { - const _record = await this.profileEducationRepo.findOneBy({ id: educationId }); - if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); - } - const record = await this.profileEducationHistoryRepo.findBy({ - profileEducationId: educationId, + order: { createdAt: "DESC" }, }); if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -189,7 +92,7 @@ export class ProfileEducationsController extends Controller { if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } - + const profile = await this.profileRepo.findOneBy({ id: body.profileId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -202,6 +105,8 @@ export class ProfileEducationsController 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 }); @@ -228,15 +133,18 @@ export class ProfileEducationsController extends Controller { const history = new ProfileEducationHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileEducationId = educationId; 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.profileEducationRepo.save(record), diff --git a/src/controllers/ProfileEducationsEmployeeController.ts b/src/controllers/ProfileEducationsEmployeeController.ts index 0a5cc824..06789f3c 100644 --- a/src/controllers/ProfileEducationsEmployeeController.ts +++ b/src/controllers/ProfileEducationsEmployeeController.ts @@ -1,7 +1,6 @@ import { Controller, Post, - Put, Delete, Route, Security, @@ -9,24 +8,18 @@ import { Body, Path, Request, - SuccessResponse, - Response, Get, - Query, Patch, - Example, } from "tsoa"; import HttpSuccess from "../interfaces/http-success"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; import { ProfileEducation, - CreateProfileEducation, UpdateProfileEducation, CreateProfileEducationEmployee, } from "../entities/ProfileEducation"; import { RequestWithUser } from "../middlewares/user"; -import { Profile } from "../entities/Profile"; import { ProfileEducationHistory } from "../entities/ProfileEducationHistory"; import { AppDataSource } from "../database/data-source"; import { ProfileEmployee } from "../entities/ProfileEmployee"; @@ -47,6 +40,7 @@ export class ProfileEducationsEmployeeController extends Controller { } const getProfileEducation = await this.profileEducationRepo.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); if (!getProfileEducation) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -55,46 +49,14 @@ export class ProfileEducationsEmployeeController extends Controller { } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6", - createdAt: "2024-03-12T20:26:42.621Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T20:33:09.000Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "test bar", - lastUpdateFullName: "test bar", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - isActive: true, - country: "string", - degree: "ปวส", - duration: "-", - durationYear: 0, - field: "ชางเทคนิค ชั้นสูง", - finishDate: "2024-03-13T03:23:31.000Z", - fundName: "-", - gpa: "3.64", - institute: "เทคโนเชียงใหม่", - other: "string", - startDate: "2024-03-13T03:23:31.000Z", - endDate: "2024-03-13T03:23:31.000Z", - educationLevel: "ปวส", - educationLevelId: "string", - positionPath: "string", - positionPathId: "string", - note: "string", - isDate: true, - isEducation: true, - }, - ], - }) - public async detailProfileEducation(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { + public async detailProfileEducation( + @Path() profileEmployeeId: string, + @Request() req: RequestWithUser, + ) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const getProfileEducation = await this.profileEducationRepo.find({ where: { profileEmployeeId: profileEmployeeId }, + order: { createdAt: "ASC" }, }); if (!getProfileEducation) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -103,80 +65,24 @@ export class ProfileEducationsEmployeeController extends Controller { } @Get("history/{educationId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "294aa117-6ce7-4c23-b5bd-fe1f12932c4a", - createdAt: "2024-03-12T20:29:45.251Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T20:29:45.251Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - isActive: true, - country: "string", - degree: "ปวส", - duration: "-", - durationYear: 0, - field: "ชางเทคนิค", - finishDate: "2024-03-13T03:23:31.000Z", - fundName: "-", - gpa: "3.64", - institute: "เทคโนเชียงใหม่", - other: "string", - startDate: "2024-03-13T03:23:31.000Z", - endDate: "2024-03-13T03:23:31.000Z", - educationLevel: "ปวส", - educationLevelId: "string", - positionPath: "string", - positionPathId: "string", - note: "string", - isDate: true, - isEducation: true, - profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6", - }, - { - id: "2f00bd59-be3e-46d8-92a2-c4700baabf12", - createdAt: "2024-03-12T20:33:09.128Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T20:33:09.128Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - isActive: true, - country: "string", - degree: "ปวส", - duration: "-", - durationYear: 0, - field: "ชางเทคนิค ชั้นสูง", - finishDate: "2024-03-13T03:23:31.000Z", - fundName: "-", - gpa: "3.64", - institute: "เทคโนเชียงใหม่", - other: "string", - startDate: "2024-03-13T03:23:31.000Z", - endDate: "2024-03-13T03:23:31.000Z", - educationLevel: "ปวส", - educationLevelId: "string", - positionPath: "string", - positionPathId: "string", - note: "string", - isDate: true, - isEducation: true, - profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6", - }, - ], - }) - public async getProfileEducationHistory(@Path() educationId: string, @Request() req: RequestWithUser) { + public async getProfileEducationHistory( + @Path() educationId: string, + @Request() req: RequestWithUser, + ) { const _record = await this.profileEducationRepo.findOneBy({ id: educationId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } - const record = await this.profileEducationHistoryRepo.findBy({ - profileEducationId: educationId, + const record = await this.profileEducationHistoryRepo.find({ + where: { + profileEducationId: educationId, + }, + order: { createdAt: "DESC" }, }); if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -192,7 +98,7 @@ export class ProfileEducationsEmployeeController extends Controller { if (!body.profileEmployeeId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); } - + const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -205,6 +111,8 @@ export class ProfileEducationsEmployeeController 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 }); @@ -226,20 +134,27 @@ export class ProfileEducationsEmployeeController extends Controller { ) { const record = await this.profileEducationRepo.findOneBy({ id: educationId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId); + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); const history = new ProfileEducationHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileEducationId = educationId; 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.profileEducationRepo.save(record), @@ -256,7 +171,11 @@ export class ProfileEducationsEmployeeController extends Controller { ) { const _record = await this.profileEducationRepo.findOneBy({ id: educationId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } await this.profileEducationHistoryRepo.delete({ diff --git a/src/controllers/ProfileEducationsEmployeeTempController.ts b/src/controllers/ProfileEducationsEmployeeTempController.ts index 4318a5d0..a24c6dda 100644 --- a/src/controllers/ProfileEducationsEmployeeTempController.ts +++ b/src/controllers/ProfileEducationsEmployeeTempController.ts @@ -1,7 +1,6 @@ import { Controller, Post, - Put, Delete, Route, Security, @@ -9,24 +8,18 @@ import { Body, Path, Request, - SuccessResponse, - Response, Get, - Query, Patch, - Example, } from "tsoa"; import HttpSuccess from "../interfaces/http-success"; import HttpError from "../interfaces/http-error"; import HttpStatus from "../interfaces/http-status"; import { ProfileEducation, - CreateProfileEducation, UpdateProfileEducation, CreateProfileEducationEmployee, } from "../entities/ProfileEducation"; import { RequestWithUser } from "../middlewares/user"; -import { Profile } from "../entities/Profile"; import { ProfileEducationHistory } from "../entities/ProfileEducationHistory"; import { AppDataSource } from "../database/data-source"; import { ProfileEmployee } from "../entities/ProfileEmployee"; @@ -47,6 +40,7 @@ export class ProfileEducationsEmployeeTempController extends Controller { } const getProfileEducation = await this.profileEducationRepo.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); if (!getProfileEducation) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -55,46 +49,14 @@ export class ProfileEducationsEmployeeTempController extends Controller { } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6", - createdAt: "2024-03-12T20:26:42.621Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T20:33:09.000Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "test bar", - lastUpdateFullName: "test bar", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - isActive: true, - country: "string", - degree: "ปวส", - duration: "-", - durationYear: 0, - field: "ชางเทคนิค ชั้นสูง", - finishDate: "2024-03-13T03:23:31.000Z", - fundName: "-", - gpa: "3.64", - institute: "เทคโนเชียงใหม่", - other: "string", - startDate: "2024-03-13T03:23:31.000Z", - endDate: "2024-03-13T03:23:31.000Z", - educationLevel: "ปวส", - educationLevelId: "string", - positionPath: "string", - positionPathId: "string", - note: "string", - isDate: true, - isEducation: true, - }, - ], - }) - public async detailProfileEducation(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { + public async detailProfileEducation( + @Path() profileEmployeeId: string, + @Request() req: RequestWithUser, + ) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const getProfileEducation = await this.profileEducationRepo.find({ where: { profileEmployeeId: profileEmployeeId }, + order: { createdAt: "ASC" }, }); if (!getProfileEducation) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -103,76 +65,16 @@ export class ProfileEducationsEmployeeTempController extends Controller { } @Get("history/{educationId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "294aa117-6ce7-4c23-b5bd-fe1f12932c4a", - createdAt: "2024-03-12T20:29:45.251Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T20:29:45.251Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - isActive: true, - country: "string", - degree: "ปวส", - duration: "-", - durationYear: 0, - field: "ชางเทคนิค", - finishDate: "2024-03-13T03:23:31.000Z", - fundName: "-", - gpa: "3.64", - institute: "เทคโนเชียงใหม่", - other: "string", - startDate: "2024-03-13T03:23:31.000Z", - endDate: "2024-03-13T03:23:31.000Z", - educationLevel: "ปวส", - educationLevelId: "string", - positionPath: "string", - positionPathId: "string", - note: "string", - isDate: true, - isEducation: true, - profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6", - }, - { - id: "2f00bd59-be3e-46d8-92a2-c4700baabf12", - createdAt: "2024-03-12T20:33:09.128Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T20:33:09.128Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "test bar", - isActive: true, - country: "string", - degree: "ปวส", - duration: "-", - durationYear: 0, - field: "ชางเทคนิค ชั้นสูง", - finishDate: "2024-03-13T03:23:31.000Z", - fundName: "-", - gpa: "3.64", - institute: "เทคโนเชียงใหม่", - other: "string", - startDate: "2024-03-13T03:23:31.000Z", - endDate: "2024-03-13T03:23:31.000Z", - educationLevel: "ปวส", - educationLevelId: "string", - positionPath: "string", - positionPathId: "string", - note: "string", - isDate: true, - isEducation: true, - profileEducationId: "f6c693b4-1a9b-4fbe-95c5-ed4da50d35b6", - }, - ], - }) - public async getProfileEducationHistory(@Path() educationId: string, @Request() req: RequestWithUser) { + public async getProfileEducationHistory( + @Path() educationId: string, + @Request() req: RequestWithUser, + ) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); - const record = await this.profileEducationHistoryRepo.findBy({ - profileEducationId: educationId, + const record = await this.profileEducationHistoryRepo.find({ + where: { + profileEducationId: educationId, + }, + order: { createdAt: "DESC" }, }); if (!record) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -201,6 +103,8 @@ export class ProfileEducationsEmployeeTempController 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 }); @@ -227,15 +131,18 @@ export class ProfileEducationsEmployeeTempController extends Controller { const history = new ProfileEducationHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileEducationId = educationId; 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.profileEducationRepo.save(record), diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 2c40bc14..419e1281 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -666,6 +666,9 @@ export class ProfileEmployeeController extends Controller { await this.profileHistoryRepo.save( Object.assign(new ProfileEmployeeHistory(), { ...record, + lastUpdateUserId: request.user.sub, + lastUpdateFullName: request.user.name, + lastUpdatedAt: new Date(), profileEmployeeId: id, id: undefined, }), @@ -2923,11 +2926,15 @@ export class ProfileEmployeeController extends Controller { if (!profileEmp) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้"); const history = new ProfileEmployeeInformationHistory(); - Object.assign(history, { ...profileEmp, id: undefined }); Object.assign(profileEmp, body); + Object.assign(history, { ...profileEmp, id: undefined }); history.profileEmployeeId = profileEmployeeId; history.lastUpdateFullName = request.user.name; history.lastUpdateUserId = request.user.sub; + history.lastUpdatedAt = new Date(); + history.createdUserId = request.user.sub; + history.createdFullName = request.user.name; + history.createdAt = new Date(); profileEmp.lastUpdateUserId = request.user.sub; profileEmp.lastUpdateFullName = request.user.name; @@ -3103,24 +3110,26 @@ export class ProfileEmployeeController extends Controller { if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); await new permission().PermissionOrgUserUpdate(request, "SYS_REGISTRY_EMP", profile.id); - const employment = new ProfileEmployeeEmployment(); - // const history = new ProfileEmployeeEmploymentHistory(); - Object.assign(employment, body); - employment.profileEmployeeId = profileEmployeeId; - employment.createdUserId = request.user.sub; - employment.createdFullName = request.user.name; - employment.lastUpdateUserId = request.user.sub; - employment.lastUpdateFullName = request.user.name; - await this.employmentRepository.save(employment); - // if (employment) { - // Object.assign(history, { ...employment, id: undefined }); - // history.profileEmployeeEmploymentId = employment.id; - // history.createdUserId = request.user.sub; - // history.createdFullName = request.user.name; - // history.lastUpdateFullName = request.user.name; - // history.lastUpdateUserId = request.user.sub; - // await this.employmentHistoryRepository.save(history); - // } + const data = new ProfileEmployeeEmployment(); + + const meta = { + createdUserId: request.user.sub, + createdFullName: request.user.name, + lastUpdateUserId: request.user.sub, + lastUpdateFullName: request.user.name, + createdAt: new Date(), + lastUpdatedAt: new Date(), + profileEmployeeId: profileEmployeeId, + }; + + Object.assign(data, { ...body, ...meta }); + const history = new ProfileEmployeeEmploymentHistory(); + Object.assign(history, { ...data, id: undefined }); + + await this.employmentRepository.save(data); + history.profileEmployeeEmploymentId = data.id; + await this.employmentHistoryRepository.save(history); + return new HttpSuccess(); } @@ -3176,14 +3185,16 @@ export class ProfileEmployeeController extends Controller { ); const history = new ProfileEmployeeEmploymentHistory(); - Object.assign(history, { ...employment, id: undefined }); Object.assign(employment, body); + Object.assign(history, { ...employment, id: undefined }); employment.lastUpdateUserId = request.user.sub; employment.lastUpdateFullName = request.user.name; history.profileEmployeeEmploymentId = id; - history.lastUpdateFullName = request.user.name; history.lastUpdateUserId = request.user.sub; + history.lastUpdateFullName = request.user.name; + history.createdUserId = request.user.sub; + history.createdFullName = request.user.name; await Promise.all([ this.employmentRepository.save(employment), @@ -3210,6 +3221,7 @@ export class ProfileEmployeeController extends Controller { statusTemp: "REPORT", lastUpdateUserId: request.user.sub, lastUpdateFullName: request.user.name, + lastUpdatedAt: new Date(), }; }), ); diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 1c7061c1..35911acc 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -3171,6 +3171,7 @@ export class ProfileEmployeeTempController extends Controller { statusTemp: "REPORT", lastUpdateUserId: request.user.sub, lastUpdateFullName: request.user.name, + lastUpdatedAt: new Date(), }; }), ); diff --git a/src/controllers/ProfileFamilyCoupleController.ts b/src/controllers/ProfileFamilyCoupleController.ts index 7458feed..5b7a82cf 100644 --- a/src/controllers/ProfileFamilyCoupleController.ts +++ b/src/controllers/ProfileFamilyCoupleController.ts @@ -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), diff --git a/src/controllers/ProfileFamilyCoupleEmployeeController.ts b/src/controllers/ProfileFamilyCoupleEmployeeController.ts index 0549c7ca..425d6534 100644 --- a/src/controllers/ProfileFamilyCoupleEmployeeController.ts +++ b/src/controllers/ProfileFamilyCoupleEmployeeController.ts @@ -1,7 +1,6 @@ import { Body, Controller, - Delete, Example, Get, Patch, @@ -41,18 +40,6 @@ export class ProfileFamilyCoupleEmployeeController 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 ProfileFamilyCoupleEmployeeController 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) { const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, @@ -87,18 +58,6 @@ export class ProfileFamilyCoupleEmployeeController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profile.id); const familyCouple = await this.ProfileFamilyCouple.findOne({ - select: [ - "id", - "couplePrefix", - "coupleFirstName", - "coupleLastName", - "coupleLastNameOld", - "coupleCareer", - "coupleCitizenId", - "coupleLive", - "relationship", - "profileEmployeeId", - ], where: { profileEmployeeId }, order: { lastUpdatedAt: "DESC" }, }); @@ -152,32 +111,10 @@ export class ProfileFamilyCoupleEmployeeController 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, + ) { const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, }); @@ -237,6 +174,8 @@ export class ProfileFamilyCoupleEmployeeController 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(); @@ -256,7 +195,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller { @Body() body: UpdateProfileFamilyCouple, @Path() profileEmployeeId: string, ) { - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId) + await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId); const familyCouple = await this.ProfileFamilyCouple.findOneBy({ profileEmployeeId: profileEmployeeId, }); @@ -270,10 +209,13 @@ export class ProfileFamilyCoupleEmployeeController 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), diff --git a/src/controllers/ProfileFamilyCoupleEmployeeTempController.ts b/src/controllers/ProfileFamilyCoupleEmployeeTempController.ts index 2156e628..142fea29 100644 --- a/src/controllers/ProfileFamilyCoupleEmployeeTempController.ts +++ b/src/controllers/ProfileFamilyCoupleEmployeeTempController.ts @@ -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), diff --git a/src/controllers/ProfileFamilyFatherController.ts b/src/controllers/ProfileFamilyFatherController.ts index 8797c9e9..b9d1b65e 100644 --- a/src/controllers/ProfileFamilyFatherController.ts +++ b/src/controllers/ProfileFamilyFatherController.ts @@ -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), diff --git a/src/controllers/ProfileFamilyFatherEmployeeController.ts b/src/controllers/ProfileFamilyFatherEmployeeController.ts index 1260f95f..fc42cdf7 100644 --- a/src/controllers/ProfileFamilyFatherEmployeeController.ts +++ b/src/controllers/ProfileFamilyFatherEmployeeController.ts @@ -1,7 +1,6 @@ import { Body, Controller, - Delete, Example, Get, Patch, @@ -41,16 +40,6 @@ export class ProfileFamilyFatherEmployeeController 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: { profileEmployeeId: profile.id }, order: { lastUpdatedAt: "DESC" }, }); @@ -59,20 +48,6 @@ export class ProfileFamilyFatherEmployeeController extends Controller { } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: { - id: "6207ae29-05ef-4abb-9a37-a887265d671e", - fatherPrefix: "string", - fatherFirstName: "string", - fatherLastName: "string", - fatherCareer: "string", - fatherCitizenId: "string", - fatherLive: true, - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - }, - }) public async getFamilyFather(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const profile = await this.profileRepo.findOne({ @@ -82,16 +57,6 @@ export class ProfileFamilyFatherEmployeeController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const familyFather = await this.ProfileFamilyFather.findOne({ - select: [ - "id", - "fatherPrefix", - "fatherFirstName", - "fatherLastName", - "fatherCareer", - "fatherCitizenId", - "fatherLive", - "profileEmployeeId", - ], where: { profileEmployeeId }, order: { lastUpdatedAt: "DESC" }, }); @@ -141,30 +106,10 @@ export class ProfileFamilyFatherEmployeeController 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: "สาวิตรี ศรีสมัย", - fatherPrefix: "string", - fatherFirstName: "string", - fatherLastName: "string", - fatherCareer: "string", - fatherCitizenId: "string", - fatherLive: true, - profileFamilyFatherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - }, - ], - }) - public async familyFatherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { + public async familyFatherHistory( + @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 ProfileFamilyFatherEmployeeController extends Controller { 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 }); @@ -252,10 +199,13 @@ export class ProfileFamilyFatherEmployeeController extends Controller { history.profileFamilyFatherId = familyFather.id; 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), diff --git a/src/controllers/ProfileFamilyFatherEmployeeTempController.ts b/src/controllers/ProfileFamilyFatherEmployeeTempController.ts index dfb73e31..ed19610b 100644 --- a/src/controllers/ProfileFamilyFatherEmployeeTempController.ts +++ b/src/controllers/ProfileFamilyFatherEmployeeTempController.ts @@ -1,7 +1,6 @@ import { Body, Controller, - Delete, Example, Get, Patch, @@ -41,16 +40,6 @@ export class ProfileFamilyFatherEmployeeTempController 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: { profileEmployeeId: profile.id }, order: { lastUpdatedAt: "DESC" }, }); @@ -59,20 +48,6 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller { } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: { - id: "6207ae29-05ef-4abb-9a37-a887265d671e", - fatherPrefix: "string", - fatherFirstName: "string", - fatherLastName: "string", - fatherCareer: "string", - fatherCitizenId: "string", - fatherLive: true, - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - }, - }) public async getFamilyFather(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepo.findOne({ @@ -83,16 +58,6 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } const familyFather = await this.ProfileFamilyFather.findOne({ - select: [ - "id", - "fatherPrefix", - "fatherFirstName", - "fatherLastName", - "fatherCareer", - "fatherCitizenId", - "fatherLive", - "profileEmployeeId", - ], where: { profileEmployeeId }, order: { lastUpdatedAt: "DESC" }, }); @@ -142,30 +107,10 @@ export class ProfileFamilyFatherEmployeeTempController 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: "สาวิตรี ศรีสมัย", - fatherPrefix: "string", - fatherFirstName: "string", - fatherLastName: "string", - fatherCareer: "string", - fatherCitizenId: "string", - fatherLive: true, - profileFamilyFatherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - }, - ], - }) - public async familyFatherHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { + public async familyFatherHistory( + @Path() profileEmployeeId: string, + @Request() req: RequestWithUser, + ) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, @@ -222,6 +167,8 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller { 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 }); @@ -253,10 +200,13 @@ export class ProfileFamilyFatherEmployeeTempController extends Controller { history.profileFamilyFatherId = familyFather.id; 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), diff --git a/src/controllers/ProfileFamilyMotherController.ts b/src/controllers/ProfileFamilyMotherController.ts index 47878028..dc9ac3a1 100644 --- a/src/controllers/ProfileFamilyMotherController.ts +++ b/src/controllers/ProfileFamilyMotherController.ts @@ -1,7 +1,6 @@ import { Body, Controller, - Delete, Example, Get, Patch, @@ -41,16 +40,6 @@ export class ProfileFamilyMotherController 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: { profileId: profile.id }, order: { lastUpdatedAt: "DESC" }, }); @@ -59,20 +48,6 @@ export class ProfileFamilyMotherController extends Controller { } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: { - id: "6207ae29-05ef-4abb-9a37-a887265d671e", - motherPrefix: "string", - motherFirstName: "string", - motherLastName: "string", - motherCareer: "string", - motherCitizenId: "string", - motherLive: true, - profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - }, - }) public async getFamilyMother(@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 ProfileFamilyMotherController 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: { profileId }, order: { lastUpdatedAt: "DESC" }, }); @@ -142,29 +107,6 @@ export class ProfileFamilyMotherController 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: "สาวิตรี ศรีสมัย", - motherPrefix: "string", - motherFirstName: "string", - motherLastName: "string", - motherCareer: "string", - motherCitizenId: "string", - motherLive: true, - profileFamilyMotherId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - }, - ], - }) public async familyMotherHistory(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const profile = await this.profileRepo.findOne({ @@ -215,12 +157,14 @@ export class ProfileFamilyMotherController 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); familyMother.motherCitizenId = Extension.CheckCitizen(String(body.motherCitizenId)); familyMother.createdUserId = req.user.sub; 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 }); @@ -238,7 +182,7 @@ export class ProfileFamilyMotherController extends Controller { @Body() body: UpdateProfileFamilyMother, @Path() profileId: string, ) { - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId); + await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", profileId); const familyMother = await this.ProfileFamilyMother.findOneBy({ profileId: profileId }); if (!familyMother) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); @@ -250,10 +194,13 @@ export class ProfileFamilyMotherController 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), diff --git a/src/controllers/ProfileFamilyMotherEmployeeController.ts b/src/controllers/ProfileFamilyMotherEmployeeController.ts index dfb98517..90961151 100644 --- a/src/controllers/ProfileFamilyMotherEmployeeController.ts +++ b/src/controllers/ProfileFamilyMotherEmployeeController.ts @@ -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), diff --git a/src/controllers/ProfileFamilyMotherEmployeeTempController.ts b/src/controllers/ProfileFamilyMotherEmployeeTempController.ts index 12a2973a..401443bc 100644 --- a/src/controllers/ProfileFamilyMotherEmployeeTempController.ts +++ b/src/controllers/ProfileFamilyMotherEmployeeTempController.ts @@ -1,7 +1,6 @@ import { Body, Controller, - Delete, Example, Get, Patch, @@ -41,16 +40,6 @@ export class ProfileFamilyMotherEmployeeTempController 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 ProfileFamilyMotherEmployeeTempController 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().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepo.findOne({ @@ -83,16 +58,6 @@ export class ProfileFamilyMotherEmployeeTempController 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 ProfileFamilyMotherEmployeeTempController 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().PermissionGet(req, "SYS_REGISTRY_TEMP"); const profile = await this.profileRepo.findOne({ where: { id: profileEmployeeId }, @@ -222,6 +167,8 @@ export class ProfileFamilyMotherEmployeeTempController 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 }); @@ -253,10 +200,13 @@ export class ProfileFamilyMotherEmployeeTempController 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), diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index 7652215f..6ca9bec5 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -29,7 +29,7 @@ export class ProfileGovernmentHistoryController extends Controller { public async getGovHistoryUser(@Request() request: { user: Record }) { const orgRevision = await this.orgRevisionRepository.findOne({ select: ["id"], - where: { + where: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true, }, @@ -141,7 +141,7 @@ export class ProfileGovernmentHistoryController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const orgRevision = await this.orgRevisionRepository.findOne({ select: ["id"], - where: { + where: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true, }, @@ -242,7 +242,7 @@ export class ProfileGovernmentHistoryController extends Controller { public async getGovHistoryAdmin(@Path() profileId: string) { const orgRevision = await this.orgRevisionRepository.findOne({ select: ["id"], - where: { + where: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true, }, @@ -389,15 +389,18 @@ export class ProfileGovernmentHistoryController extends Controller { const history = new ProfileGovernment(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileId = profileId; 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.profileRepo.save(record), this.govRepo.save(history)]); diff --git a/src/controllers/ProfileGovernmentEmployeeController.ts b/src/controllers/ProfileGovernmentEmployeeController.ts index a43e2401..5b6256ba 100644 --- a/src/controllers/ProfileGovernmentEmployeeController.ts +++ b/src/controllers/ProfileGovernmentEmployeeController.ts @@ -46,7 +46,7 @@ export class ProfileGovernmentEmployeeController extends Controller { public async getGovHistoryUser(@Request() request: { user: Record }) { const orgRevision = await this.orgRevisionRepository.findOne({ select: ["id"], - where: { + where: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true, }, @@ -147,7 +147,7 @@ export class ProfileGovernmentEmployeeController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const orgRevision = await this.orgRevisionRepository.findOne({ select: ["id"], - where: { + where: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true, }, @@ -238,7 +238,7 @@ export class ProfileGovernmentEmployeeController extends Controller { public async getGovHistoryAdmin(@Path() profileEmployeeId: string) { const orgRevision = await this.orgRevisionRepository.findOne({ select: ["id"], - where: { + where: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true, }, @@ -343,7 +343,7 @@ export class ProfileGovernmentEmployeeController extends Controller { @Get("history/{profileEmployeeId}") @Example({}) public async govHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId) + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const record = await this.govRepo.find({ order: { lastUpdatedAt: "DESC" }, where: { profileEmployeeId: profileEmployeeId }, @@ -362,7 +362,7 @@ export class ProfileGovernmentEmployeeController extends Controller { @Body() body: UpdateProfileGovernment, @Path() profileEmployeeId: string, ) { - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId) + await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profileEmployeeId); const record = await this.profileEmployeeRepo.findOne({ where: { id: profileEmployeeId }, }); @@ -371,15 +371,18 @@ export class ProfileGovernmentEmployeeController extends Controller { const history = new ProfileGovernment(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileEmployeeId = profileEmployeeId; 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.profileEmployeeRepo.save(record), this.govRepo.save(history)]); return new HttpSuccess(); diff --git a/src/controllers/ProfileGovernmentEmployeeTempController.ts b/src/controllers/ProfileGovernmentEmployeeTempController.ts index 10da980a..ee9b7c27 100644 --- a/src/controllers/ProfileGovernmentEmployeeTempController.ts +++ b/src/controllers/ProfileGovernmentEmployeeTempController.ts @@ -46,7 +46,7 @@ export class ProfileGovernmentEmployeeTempController extends Controller { public async getGovHistoryUser(@Request() request: { user: Record }) { const orgRevision = await this.orgRevisionRepository.findOne({ select: ["id"], - where: { + where: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true, }, @@ -147,7 +147,7 @@ export class ProfileGovernmentEmployeeTempController extends Controller { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const orgRevision = await this.orgRevisionRepository.findOne({ select: ["id"], - where: { + where: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true, }, @@ -239,7 +239,7 @@ export class ProfileGovernmentEmployeeTempController extends Controller { public async getGovHistoryAdmin(@Path() profileEmployeeId: string) { const orgRevision = await this.orgRevisionRepository.findOne({ select: ["id"], - where: { + where: { orgRevisionIsDraft: false, orgRevisionIsCurrent: true, }, @@ -372,15 +372,18 @@ export class ProfileGovernmentEmployeeTempController extends Controller { const history = new ProfileGovernment(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileEmployeeId = profileEmployeeId; 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.profileEmployeeRepo.save(record), this.govRepo.save(history)]); return new HttpSuccess(); diff --git a/src/controllers/ProfileHonorController.ts b/src/controllers/ProfileHonorController.ts index b11ae01c..17711b4e 100644 --- a/src/controllers/ProfileHonorController.ts +++ b/src/controllers/ProfileHonorController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -37,36 +36,18 @@ export class ProfileHonorController extends Controller { } const record = await this.honorRepo.find({ where: { profileId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - createdAt: "2024-03-12T03:10:05.594Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:10:05.594Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - detail: "string", - issueDate: "2024-03-12T10:09:47.000Z", - issuer: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - refCommandNo: "string", - isDate: true, - }, - ], - }) public async getHonor(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); - const record = await this.honorRepo.findBy({ profileId }); + const record = await this.honorRepo.find({ + where: { profileId: profileId }, + order: { createdAt: "ASC" }, + }); return new HttpSuccess(record); } @@ -87,56 +68,22 @@ export class ProfileHonorController extends Controller { profileId: profile.id, }, }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @Get("history/{honorId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "3bedb365-4a41-4df5-8f47-b6e143221d2c", - createdAt: "2024-03-12T03:11:01.395Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T03:11:01.395Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - detail: "detail", - issueDate: "2024-03-12T10:10:31.000Z", - issuer: "issuer", - refCommandDate: "2024-03-12T10:10:31.000Z", - refCommandNo: "refCommandNo", - isDate: true, - profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - }, - { - id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f", - createdAt: "2024-03-12T03:10:05.657Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:10:05.657Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - detail: "string", - issueDate: "2024-03-12T10:09:47.000Z", - issuer: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - refCommandNo: "string", - isDate: true, - profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - }, - ], - }) public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) { - const _record = await this.honorRepo.findOneBy({ id: honorId }); - if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); - } - const record = await this.honorHistoryRepo.findBy({ - profileHonorId: honorId, + const _record = await this.honorRepo.findOneBy({ id: honorId }); + if (_record) { + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + } + const record = await this.honorHistoryRepo.find({ + where: { + profileHonorId: honorId, + }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -146,9 +93,9 @@ export class ProfileHonorController extends Controller { if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } - + const profile = await this.profileRepo.findOneBy({ id: body.profileId }); - + if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } @@ -161,6 +108,8 @@ export class ProfileHonorController 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 }); @@ -187,15 +136,18 @@ export class ProfileHonorController extends Controller { const history = new ProfileHonorHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileHonorId = honorId; 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.honorRepo.save(record), this.honorHistoryRepo.save(history)]); diff --git a/src/controllers/ProfileHonorEmployeeController.ts b/src/controllers/ProfileHonorEmployeeController.ts index 426e3152..e038665f 100644 --- a/src/controllers/ProfileHonorEmployeeController.ts +++ b/src/controllers/ProfileHonorEmployeeController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,36 +40,18 @@ export class ProfileHonorEmployeeController extends Controller { } const record = await this.honorRepo.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - createdAt: "2024-03-12T03:10:05.594Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:10:05.594Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - detail: "string", - issueDate: "2024-03-12T10:09:47.000Z", - issuer: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - refCommandNo: "string", - isDate: true, - }, - ], - }) public async getHonor(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); - const record = await this.honorRepo.findBy({ profileEmployeeId }); + const record = await this.honorRepo.find({ + where: { profileEmployeeId: profileEmployeeId }, + order: { createdAt: "ASC" }, + }); return new HttpSuccess(record); } @@ -91,57 +72,27 @@ export class ProfileHonorEmployeeController extends Controller { profileEmployeeId: profile.id, }, }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @Get("history/{honorId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "3bedb365-4a41-4df5-8f47-b6e143221d2c", - createdAt: "2024-03-12T03:11:01.395Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T03:11:01.395Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - detail: "detail", - issueDate: "2024-03-12T10:10:31.000Z", - issuer: "issuer", - refCommandDate: "2024-03-12T10:10:31.000Z", - refCommandNo: "refCommandNo", - isDate: true, - profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - }, - { - id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f", - createdAt: "2024-03-12T03:10:05.657Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:10:05.657Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - detail: "string", - issueDate: "2024-03-12T10:09:47.000Z", - issuer: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - refCommandNo: "string", - isDate: true, - profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - }, - ], - }) public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) { const _record = await this.honorRepo.findOneBy({ id: honorId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } - const record = await this.honorHistoryRepo.findBy({ - profileHonorId: honorId, + const record = await this.honorHistoryRepo.find({ + where: { + profileHonorId: honorId, + }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -165,6 +116,8 @@ export class ProfileHonorEmployeeController 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 }); @@ -186,20 +139,27 @@ export class ProfileHonorEmployeeController extends Controller { ) { const record = await this.honorRepo.findOneBy({ id: honorId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) - + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); + const history = new ProfileHonorHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileHonorId = honorId; 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.honorRepo.save(record), this.honorHistoryRepo.save(history)]); @@ -210,7 +170,11 @@ export class ProfileHonorEmployeeController extends Controller { public async deleteTraning(@Path() honorId: string, @Request() req: RequestWithUser) { const _record = await this.honorRepo.findOneBy({ id: honorId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } await this.honorHistoryRepo.delete({ diff --git a/src/controllers/ProfileHonorEmployeeTempController.ts b/src/controllers/ProfileHonorEmployeeTempController.ts index 44422f49..c59c662a 100644 --- a/src/controllers/ProfileHonorEmployeeTempController.ts +++ b/src/controllers/ProfileHonorEmployeeTempController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,36 +40,18 @@ export class ProfileHonorEmployeeTempController extends Controller { } const record = await this.honorRepo.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - createdAt: "2024-03-12T03:10:05.594Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:10:05.594Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - detail: "string", - issueDate: "2024-03-12T10:09:47.000Z", - issuer: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - refCommandNo: "string", - isDate: true, - }, - ], - }) public async getHonor(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); - const record = await this.honorRepo.findBy({ profileEmployeeId }); + const record = await this.honorRepo.find({ + where: { profileEmployeeId: profileEmployeeId }, + order: { createdAt: "ASC" }, + }); return new HttpSuccess(record); } @@ -91,53 +72,19 @@ export class ProfileHonorEmployeeTempController extends Controller { profileEmployeeId: profile.id, }, }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @Get("history/{honorId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "3bedb365-4a41-4df5-8f47-b6e143221d2c", - createdAt: "2024-03-12T03:11:01.395Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T03:11:01.395Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - detail: "detail", - issueDate: "2024-03-12T10:10:31.000Z", - issuer: "issuer", - refCommandDate: "2024-03-12T10:10:31.000Z", - refCommandNo: "refCommandNo", - isDate: true, - profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - }, - { - id: "ba0e2f82-014e-46c6-8b82-a7c28eb5325f", - createdAt: "2024-03-12T03:10:05.657Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:10:05.657Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - detail: "string", - issueDate: "2024-03-12T10:09:47.000Z", - issuer: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - refCommandNo: "string", - isDate: true, - profileHonorId: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - }, - ], - }) public async honorHistory(@Path() honorId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); - const record = await this.honorHistoryRepo.findBy({ - profileHonorId: honorId, + const record = await this.honorHistoryRepo.find({ + where: { + profileHonorId: honorId, + }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -162,6 +109,8 @@ export class ProfileHonorEmployeeTempController 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 }); @@ -189,15 +138,18 @@ export class ProfileHonorEmployeeTempController extends Controller { const history = new ProfileHonorHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileHonorId = honorId; 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.honorRepo.save(record), this.honorHistoryRepo.save(history)]); diff --git a/src/controllers/ProfileInsigniaController.ts b/src/controllers/ProfileInsigniaController.ts index e4d3dbd3..048e0230 100644 --- a/src/controllers/ProfileInsigniaController.ts +++ b/src/controllers/ProfileInsigniaController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -48,41 +47,12 @@ export class ProfileInsigniaController extends Controller { }, }, where: { profileId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb", - createdAt: "2024-03-12T03:05:09.393Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:05:09.393Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - year: 0, - no: "string", - volume: "string", - section: "string", - page: "string", - receiveDate: "2024-03-12T10:05:02.000Z", - insigniaId: "string", - insigniaType: "string", - dateAnnounce: "2024-03-12T10:05:02.000Z", - issue: "string", - volumeNo: "string", - refCommandDate: "2024-03-12T10:05:02.000Z", - refCommandNo: "string", - note: "string", - }, - ], - }) public async getInsignia(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.insigniaRepo.find({ @@ -92,70 +62,17 @@ export class ProfileInsigniaController extends Controller { }, }, where: { profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("history/{InsigniaId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "c363d13c-88bd-4954-adf5-70d3f5ca9c30", - createdAt: "2024-03-12T03:06:31.062Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T03:06:31.062Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - year: 0, - no: "no", - volume: "volume", - section: "section", - page: "page", - receiveDate: "2024-03-12T10:05:44.000Z", - insigniaId: "insigniaId", - insigniaType: "insigniaType", - dateAnnounce: "2024-03-12T10:05:44.000Z", - issue: "string", - volumeNo: "volumeNo", - refCommandDate: "2024-03-12T10:05:44.000Z", - refCommandNo: "refCommandNo", - note: "string", - profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb", - }, - { - id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb", - createdAt: "2024-03-12T03:05:09.393Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:09:04.905Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - year: 0, - no: "string", - volume: "string", - section: "string", - page: "string", - receiveDate: "2024-03-12T10:05:02.000Z", - insigniaId: "string", - insigniaType: "string", - dateAnnounce: "2024-03-12T10:05:02.000Z", - issue: "string", - volumeNo: "string", - refCommandDate: "2024-03-12T10:05:02.000Z", - refCommandNo: "string", - note: "string", - profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb", - }, - ], - }) public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) { - const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId }); - if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); - } + const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId }); + if (_record) { + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + } const record = await this.insigniaHistoryRepo.find({ relations: { insignia: { @@ -165,6 +82,7 @@ export class ProfileInsigniaController extends Controller { where: { profileInsigniaId: InsigniaId, }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -174,7 +92,7 @@ export class ProfileInsigniaController extends Controller { if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } - + const profile = await this.profileRepo.findOneBy({ id: body.profileId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -195,6 +113,8 @@ export class ProfileInsigniaController 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 }); @@ -228,15 +148,18 @@ export class ProfileInsigniaController extends Controller { const history = new ProfileInsigniaHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileInsigniaId = insigniaId; 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.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]); @@ -247,14 +170,18 @@ export class ProfileInsigniaController extends Controller { public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) { const _record = await this.insigniaRepo.findOneBy({ id: insigniaId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_OFFICER", + _record.profileId, + ); } await this.insigniaHistoryRepo.delete({ profileInsigniaId: insigniaId, }); - + const result = await this.insigniaRepo.delete({ id: insigniaId }); - + if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); } @@ -291,6 +218,8 @@ export class ProfileInsigniaController 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 }); diff --git a/src/controllers/ProfileInsigniaEmployeeController.ts b/src/controllers/ProfileInsigniaEmployeeController.ts index f30c7361..e00202a9 100644 --- a/src/controllers/ProfileInsigniaEmployeeController.ts +++ b/src/controllers/ProfileInsigniaEmployeeController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -48,41 +47,12 @@ export class ProfileInsigniaEmployeeController extends Controller { }, }, where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb", - createdAt: "2024-03-12T03:05:09.393Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:05:09.393Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - year: 0, - no: "string", - volume: "string", - section: "string", - page: "string", - receiveDate: "2024-03-12T10:05:02.000Z", - insigniaId: "string", - insigniaType: "string", - dateAnnounce: "2024-03-12T10:05:02.000Z", - issue: "string", - volumeNo: "string", - refCommandDate: "2024-03-12T10:05:02.000Z", - refCommandNo: "string", - note: "string", - }, - ], - }) public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); const record = await this.insigniaRepo.find({ @@ -92,69 +62,20 @@ export class ProfileInsigniaEmployeeController extends Controller { }, }, where: { profileEmployeeId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("history/{InsigniaId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "c363d13c-88bd-4954-adf5-70d3f5ca9c30", - createdAt: "2024-03-12T03:06:31.062Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T03:06:31.062Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - year: 0, - no: "no", - volume: "volume", - section: "section", - page: "page", - receiveDate: "2024-03-12T10:05:44.000Z", - insigniaId: "insigniaId", - insigniaType: "insigniaType", - dateAnnounce: "2024-03-12T10:05:44.000Z", - issue: "string", - volumeNo: "volumeNo", - refCommandDate: "2024-03-12T10:05:44.000Z", - refCommandNo: "refCommandNo", - note: "string", - profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb", - }, - { - id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb", - createdAt: "2024-03-12T03:05:09.393Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:09:04.905Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - year: 0, - no: "string", - volume: "string", - section: "string", - page: "string", - receiveDate: "2024-03-12T10:05:02.000Z", - insigniaId: "string", - insigniaType: "string", - dateAnnounce: "2024-03-12T10:05:02.000Z", - issue: "string", - volumeNo: "string", - refCommandDate: "2024-03-12T10:05:02.000Z", - refCommandNo: "string", - note: "string", - profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb", - }, - ], - }) public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) { const _record = await this.insigniaRepo.findOneBy({ id: InsigniaId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.insigniaHistoryRepo.find({ relations: { @@ -165,6 +86,7 @@ export class ProfileInsigniaEmployeeController extends Controller { where: { profileInsigniaId: InsigniaId, }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -182,7 +104,7 @@ export class ProfileInsigniaEmployeeController extends Controller { if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); } - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id) + await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id); const insignia = await this.insigniaMetaRepo.findOne({ where: { id: body.insigniaId }, @@ -198,6 +120,8 @@ export class ProfileInsigniaEmployeeController 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 }); @@ -219,7 +143,11 @@ export class ProfileInsigniaEmployeeController extends Controller { ) { const record = await this.insigniaRepo.findOneBy({ id: insigniaId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); const insignia = await this.insigniaMetaRepo.findOne({ where: { id: body.insigniaId }, @@ -231,15 +159,18 @@ export class ProfileInsigniaEmployeeController extends Controller { const history = new ProfileInsigniaHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileInsigniaId = insigniaId; 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.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]); @@ -250,7 +181,11 @@ export class ProfileInsigniaEmployeeController extends Controller { public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) { const _record = await this.insigniaRepo.findOneBy({ id: insigniaId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } await this.insigniaHistoryRepo.delete({ diff --git a/src/controllers/ProfileInsigniaEmployeeTempController.ts b/src/controllers/ProfileInsigniaEmployeeTempController.ts index f644fad5..298bdf5b 100644 --- a/src/controllers/ProfileInsigniaEmployeeTempController.ts +++ b/src/controllers/ProfileInsigniaEmployeeTempController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -48,41 +47,12 @@ export class ProfileInsigniaEmployeeTempController extends Controller { }, }, where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb", - createdAt: "2024-03-12T03:05:09.393Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:05:09.393Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - year: 0, - no: "string", - volume: "string", - section: "string", - page: "string", - receiveDate: "2024-03-12T10:05:02.000Z", - insigniaId: "string", - insigniaType: "string", - dateAnnounce: "2024-03-12T10:05:02.000Z", - issue: "string", - volumeNo: "string", - refCommandDate: "2024-03-12T10:05:02.000Z", - refCommandNo: "string", - note: "string", - }, - ], - }) public async getInsignia(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.insigniaRepo.find({ @@ -92,65 +62,12 @@ export class ProfileInsigniaEmployeeTempController extends Controller { }, }, where: { profileEmployeeId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("history/{InsigniaId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "c363d13c-88bd-4954-adf5-70d3f5ca9c30", - createdAt: "2024-03-12T03:06:31.062Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T03:06:31.062Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - year: 0, - no: "no", - volume: "volume", - section: "section", - page: "page", - receiveDate: "2024-03-12T10:05:44.000Z", - insigniaId: "insigniaId", - insigniaType: "insigniaType", - dateAnnounce: "2024-03-12T10:05:44.000Z", - issue: "string", - volumeNo: "volumeNo", - refCommandDate: "2024-03-12T10:05:44.000Z", - refCommandNo: "refCommandNo", - note: "string", - profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb", - }, - { - id: "c9d4dd52-25f5-491a-852d-28bfe00d66cb", - createdAt: "2024-03-12T03:05:09.393Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T03:09:04.905Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - year: 0, - no: "string", - volume: "string", - section: "string", - page: "string", - receiveDate: "2024-03-12T10:05:02.000Z", - insigniaId: "string", - insigniaType: "string", - dateAnnounce: "2024-03-12T10:05:02.000Z", - issue: "string", - volumeNo: "string", - refCommandDate: "2024-03-12T10:05:02.000Z", - refCommandNo: "string", - note: "string", - profileInsigniaId: "c9d4dd52-25f5-491a-852d-28bfe00d66cb", - }, - ], - }) public async getInsigniaHistory(@Path() InsigniaId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.insigniaHistoryRepo.find({ @@ -162,6 +79,7 @@ export class ProfileInsigniaEmployeeTempController extends Controller { where: { profileInsigniaId: InsigniaId, }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -196,6 +114,8 @@ export class ProfileInsigniaEmployeeTempController 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 }); @@ -230,15 +150,18 @@ export class ProfileInsigniaEmployeeTempController extends Controller { const history = new ProfileInsigniaHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileInsigniaId = insigniaId; 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.insigniaRepo.save(record), this.insigniaHistoryRepo.save(history)]); diff --git a/src/controllers/ProfileLeaveController.ts b/src/controllers/ProfileLeaveController.ts index b54c23c3..d7ff9617 100644 --- a/src/controllers/ProfileLeaveController.ts +++ b/src/controllers/ProfileLeaveController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -25,7 +24,6 @@ import HttpError from "../interfaces/http-error"; import { RequestWithUser } from "../middlewares/user"; import { Profile } from "../entities/Profile"; import { LeaveType } from "../entities/LeaveType"; -import { Brackets } from "typeorm"; import permission from "../interfaces/permission"; @Route("api/v1/org/profile/leave") @Tags("ProfileLeave") @@ -121,50 +119,18 @@ export class ProfileLeaveController extends Controller { const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: { - id: "adbb08a6-d2f4-41b0-a9c1-49e883ca96bc", - createdAt: "2024-03-20T23:35:45.230Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-20T23:40:06.000Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - leaveTypeId: "8dc5e672-b416-4323-b086-06dde8c4353c", - dateLeaveStart: "2024-03-21T06:39:46.000Z", - dateLeaveEnd: "2024-03-21T06:39:46.000Z", - leaveDays: 0, - leaveCount: null, - totalLeave: 0, - status: "string", - reason: "string", - leaveType: { - id: "8dc5e672-b416-4323-b086-06dde8c4353c", - createdAt: "2024-02-04T21:28:40.536Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-02-04T21:28:40.536Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - name: "ลาป่วย", - code: "CM-002", - limit: 1, - }, - }, - }) public async getLeave(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @@ -175,87 +141,21 @@ export class ProfileLeaveController extends Controller { const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("history/{leaveId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "7eed2e72-d71c-4b3b-a90b-e1b7abdaa838", - createdAt: "2024-03-20T23:35:45.230Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-20T23:40:06.000Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - leaveTypeId: "8dc5e672-b416-4323-b086-06dde8c4353c", - dateLeaveStart: "2024-03-21T06:39:46.000Z", - dateLeaveEnd: "2024-03-21T06:39:46.000Z", - leaveDays: 0, - leaveCount: null, - totalLeave: 0, - status: "string", - reason: "string", - leaveType: { - id: "8dc5e672-b416-4323-b086-06dde8c4353c", - createdAt: "2024-02-04T21:28:40.536Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-02-04T21:28:40.536Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - name: "ลาป่วย", - code: "CM-002", - limit: 1, - }, - profileLeaveId: "adbb08a6-d2f4-41b0-a9c1-49e883ca96bc", - }, - { - id: "b1b9c291-9c96-4cbb-9309-6ff5a2a6e0e8", - createdAt: "2024-03-20T23:35:45.230Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-20T23:35:45.230Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - leaveTypeId: "7dc4e314-b456-4323-b086-06dde8c4353c", - dateLeaveStart: "2024-03-21T06:34:49.000Z", - dateLeaveEnd: "2024-03-21T06:34:49.000Z", - leaveDays: 2, - leaveCount: null, - totalLeave: 200, - status: "ไม่ผ่าน", - reason: "ติดงานสำคัญ", - leaveType: { - id: "7dc4e314-b456-4323-b086-06dde8c4353c", - createdAt: "2024-02-04T21:28:40.536Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-02-04T21:28:40.536Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - name: "ลาพักร้อน", - code: "CM-001", - limit: 356, - }, - profileLeaveId: "adbb08a6-d2f4-41b0-a9c1-49e883ca96bc", - }, - ], - }) public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) { - const _record = await this.leaveRepo.findOneBy({ id: leaveId }); - if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); - } + const _record = await this.leaveRepo.findOneBy({ id: leaveId }); + if (_record) { + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + } const record = await this.leaveHistoryRepo.find({ relations: { leaveType: true }, where: { profileLeaveId: leaveId }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -286,6 +186,8 @@ export class ProfileLeaveController 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 }); @@ -319,15 +221,18 @@ export class ProfileLeaveController extends Controller { const history = new ProfileLeaveHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileLeaveId = leaveId; 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.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]); @@ -338,7 +243,11 @@ export class ProfileLeaveController extends Controller { public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) { const _record = await this.leaveRepo.findOneBy({ id: leaveId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_OFFICER", + _record.profileId, + ); } await this.leaveHistoryRepo.delete({ profileLeaveId: leaveId, @@ -378,6 +287,8 @@ export class ProfileLeaveController 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 }); diff --git a/src/controllers/ProfileLeaveEmployeeController.ts b/src/controllers/ProfileLeaveEmployeeController.ts index 0a464062..e25395c5 100644 --- a/src/controllers/ProfileLeaveEmployeeController.ts +++ b/src/controllers/ProfileLeaveEmployeeController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -44,6 +43,7 @@ export class ProfileLeaveEmployeeController extends Controller { const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @@ -54,6 +54,7 @@ export class ProfileLeaveEmployeeController extends Controller { const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileEmployeeId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @@ -64,6 +65,7 @@ export class ProfileLeaveEmployeeController extends Controller { const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileEmployeeId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @@ -72,18 +74,22 @@ export class ProfileLeaveEmployeeController extends Controller { public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) { const _record = await this.leaveRepo.findOneBy({ id: leaveId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.leaveHistoryRepo.find({ relations: { leaveType: true }, where: { profileLeaveId: leaveId }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @Post() public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeLeave) { - if (!body.profileEmployeeId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -108,6 +114,8 @@ export class ProfileLeaveEmployeeController 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 }); @@ -129,7 +137,11 @@ export class ProfileLeaveEmployeeController extends Controller { ) { const record = await this.leaveRepo.findOneBy({ id: leaveId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); const leaveType = await this.leaveTypeRepository.findOne({ where: { id: body.leaveTypeId }, @@ -141,15 +153,18 @@ export class ProfileLeaveEmployeeController extends Controller { const history = new ProfileLeaveHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileLeaveId = leaveId; 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.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]); @@ -160,7 +175,11 @@ export class ProfileLeaveEmployeeController extends Controller { public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) { const _record = await this.leaveRepo.findOneBy({ id: leaveId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } await this.leaveHistoryRepo.delete({ diff --git a/src/controllers/ProfileLeaveEmployeeTempController.ts b/src/controllers/ProfileLeaveEmployeeTempController.ts index 237e508b..2ea9c4d4 100644 --- a/src/controllers/ProfileLeaveEmployeeTempController.ts +++ b/src/controllers/ProfileLeaveEmployeeTempController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -44,6 +43,7 @@ export class ProfileLeaveEmployeeTempController extends Controller { const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @@ -54,6 +54,7 @@ export class ProfileLeaveEmployeeTempController extends Controller { const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileEmployeeId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @@ -64,6 +65,7 @@ export class ProfileLeaveEmployeeTempController extends Controller { const record = await this.leaveRepo.find({ relations: { leaveType: true }, where: { profileEmployeeId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @@ -74,6 +76,7 @@ export class ProfileLeaveEmployeeTempController extends Controller { const record = await this.leaveHistoryRepo.find({ relations: { leaveType: true }, where: { profileLeaveId: leaveId }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -104,6 +107,8 @@ export class ProfileLeaveEmployeeTempController 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 }); @@ -138,15 +143,18 @@ export class ProfileLeaveEmployeeTempController extends Controller { const history = new ProfileLeaveHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileLeaveId = leaveId; 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.leaveRepo.save(record), this.leaveHistoryRepo.save(history)]); diff --git a/src/controllers/ProfileNopaidController.ts b/src/controllers/ProfileNopaidController.ts index 3146386f..27167e49 100644 --- a/src/controllers/ProfileNopaidController.ts +++ b/src/controllers/ProfileNopaidController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -37,61 +36,27 @@ export class ProfileNopaidController extends Controller { } const lists = await this.nopaidRepository.find({ where: { profileId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - date: "2024-03-12T10:09:47.000Z", - reference: "string", - detail: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - ], - }) public async getNopaid(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.nopaidRepository.find({ where: { profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("history/{nopaidId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - date: "2024-03-12T10:09:47.000Z", - reference: "string", - detail: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - date: "2024-03-12T10:09:47.000Z", - reference: "string", - detail: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - ], - }) public async nopaidHistory(@Path() nopaidId: string, @Request() req: RequestWithUser) { - const _record = await this.nopaidRepository.findOneBy({ id: nopaidId }); - if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); - }; + const _record = await this.nopaidRepository.findOneBy({ id: nopaidId }); + if (_record) { + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); + } const record = await this.nopaidHistoryRepository.find({ where: { profileNopaidId: nopaidId }, order: { createdAt: "DESC" }, @@ -104,7 +69,7 @@ export class ProfileNopaidController extends Controller { if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } - + const profile = await this.profileRepository.findOneBy({ id: body.profileId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -118,6 +83,8 @@ export class ProfileNopaidController 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 }); @@ -144,15 +111,18 @@ export class ProfileNopaidController extends Controller { const history = new ProfileNopaidHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileNopaidId = nopaidId; 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.nopaidRepository.save(record), @@ -166,7 +136,11 @@ export class ProfileNopaidController extends Controller { public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) { const _record = await this.nopaidRepository.findOneBy({ id: nopaidId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_OFFICER", + _record.profileId, + ); } await this.nopaidHistoryRepository.delete({ profileNopaidId: nopaidId, diff --git a/src/controllers/ProfileNopaidEmployeeController.ts b/src/controllers/ProfileNopaidEmployeeController.ts index 03be8ed3..08dd320e 100644 --- a/src/controllers/ProfileNopaidEmployeeController.ts +++ b/src/controllers/ProfileNopaidEmployeeController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,20 +40,24 @@ export class ProfileNopaidEmployeeController extends Controller { } const lists = await this.nopaidRepository.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("{profileId}") - public async getNopaid(@Path() profileId: string) { + public async getNopaid(@Path() profileId: string, @Request() req: RequestWithUser) { + await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.nopaidRepository.find({ where: { profileEmployeeId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("history/{nopaidId}") - public async nopaidHistory(@Path() nopaidId: string) { + public async nopaidHistory(@Path() nopaidId: string, @Request() req: RequestWithUser) { + await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.nopaidHistoryRepository.find({ where: { profileNopaidId: nopaidId }, order: { createdAt: "DESC" }, @@ -67,7 +70,6 @@ export class ProfileNopaidEmployeeController extends Controller { @Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeNopaid, ) { - if (!body.profileEmployeeId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } @@ -85,6 +87,8 @@ export class ProfileNopaidEmployeeController 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 }); @@ -106,20 +110,27 @@ export class ProfileNopaidEmployeeController extends Controller { ) { const record = await this.nopaidRepository.findOneBy({ id: nopaidId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); const history = new ProfileNopaidHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileNopaidId = nopaidId; 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.nopaidRepository.save(record), @@ -133,7 +144,11 @@ export class ProfileNopaidEmployeeController extends Controller { public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) { const _record = await this.nopaidRepository.findOneBy({ id: nopaidId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } await this.nopaidHistoryRepository.delete({ diff --git a/src/controllers/ProfileNopaidEmployeeTempController.ts b/src/controllers/ProfileNopaidEmployeeTempController.ts index 42576e68..6e7d4396 100644 --- a/src/controllers/ProfileNopaidEmployeeTempController.ts +++ b/src/controllers/ProfileNopaidEmployeeTempController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,6 +40,7 @@ export class ProfileNopaidEmployeeTempController extends Controller { } const lists = await this.nopaidRepository.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -50,6 +50,7 @@ export class ProfileNopaidEmployeeTempController extends Controller { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.nopaidRepository.find({ where: { profileEmployeeId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -87,6 +88,8 @@ export class ProfileNopaidEmployeeTempController 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 }); @@ -114,15 +117,18 @@ export class ProfileNopaidEmployeeTempController extends Controller { const history = new ProfileNopaidHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileNopaidId = nopaidId; 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.nopaidRepository.save(record), diff --git a/src/controllers/ProfileOtherController.ts b/src/controllers/ProfileOtherController.ts index a457f029..95ddd931 100644 --- a/src/controllers/ProfileOtherController.ts +++ b/src/controllers/ProfileOtherController.ts @@ -37,53 +37,22 @@ export class ProfileOtherController extends Controller { } const lists = await this.otherRepository.find({ where: { profileId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - isActive: true, - date: "2024-03-12T10:09:47.000Z", - reference: "string", - detail: "string", - refCommandNo: "string", - refCommandDate: "2024-03-12T10:09:47.000Z", - }, - ], - }) public async getOther(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const lists = await this.otherRepository.find({ where: { profileId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @Get("history/{otherId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - isActive: true, - date: "2024-03-12T10:09:47.000Z", - detail: "string", - }, - { - id: "debfa8a7-83fb-4801-a940-8ae74e7638d3", - isActive: true, - date: "2024-03-12T10:09:47.000Z", - detail: "string", - }, - ], - }) public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) { const _record = await this.otherRepository.findOneBy({ id: otherId }); if (_record) { @@ -101,7 +70,7 @@ export class ProfileOtherController extends Controller { if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } - + const profile = await this.profileRepository.findOneBy({ id: body.profileId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -115,6 +84,8 @@ export class ProfileOtherController 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 }); @@ -141,15 +112,18 @@ export class ProfileOtherController extends Controller { const history = new ProfileOtherHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileOtherId = otherId; 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.otherRepository.save(record), @@ -161,10 +135,14 @@ export class ProfileOtherController extends Controller { @Delete("{otherId}") public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) { - const _record = await this.otherRepository.findOneBy({ id: otherId }); - if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); - } + const _record = await this.otherRepository.findOneBy({ id: otherId }); + if (_record) { + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_OFFICER", + _record.profileId, + ); + } await this.otherHistoryRepository.delete({ profileOtherId: otherId, }); diff --git a/src/controllers/ProfileOtherEmployeeController.ts b/src/controllers/ProfileOtherEmployeeController.ts index 47f81440..12c5d446 100644 --- a/src/controllers/ProfileOtherEmployeeController.ts +++ b/src/controllers/ProfileOtherEmployeeController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,6 +40,7 @@ export class ProfileOtherEmployeeController extends Controller { } const lists = await this.otherRepository.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -50,6 +50,7 @@ export class ProfileOtherEmployeeController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const lists = await this.otherRepository.find({ where: { profileEmployeeId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -58,7 +59,11 @@ export class ProfileOtherEmployeeController extends Controller { public async otherHistory(@Path() otherId: string, @Request() req: RequestWithUser) { const _record = await this.otherRepository.findOneBy({ id: otherId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const record = await this.otherHistoryRepository.find({ where: { profileOtherId: otherId }, @@ -86,6 +91,8 @@ export class ProfileOtherEmployeeController 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 }); @@ -105,23 +112,29 @@ export class ProfileOtherEmployeeController extends Controller { @Body() body: UpdateProfileOther, @Path() otherId: string, ) { - const record = await this.otherRepository.findOneBy({ id: otherId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); const history = new ProfileOtherHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileOtherId = otherId; 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.otherRepository.save(record), @@ -135,7 +148,11 @@ export class ProfileOtherEmployeeController extends Controller { public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) { const _record = await this.otherRepository.findOneBy({ id: otherId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } await this.otherHistoryRepository.delete({ diff --git a/src/controllers/ProfileOtherEmployeeTempController.ts b/src/controllers/ProfileOtherEmployeeTempController.ts index 7218b7d7..d8aa8e12 100644 --- a/src/controllers/ProfileOtherEmployeeTempController.ts +++ b/src/controllers/ProfileOtherEmployeeTempController.ts @@ -41,6 +41,7 @@ export class ProfileOtherEmployeeTempController extends Controller { } const lists = await this.otherRepository.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -50,6 +51,7 @@ export class ProfileOtherEmployeeTempController extends Controller { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const lists = await this.otherRepository.find({ where: { profileEmployeeId: profileId }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(lists); } @@ -84,6 +86,8 @@ export class ProfileOtherEmployeeTempController 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 }); @@ -111,15 +115,18 @@ export class ProfileOtherEmployeeTempController extends Controller { const history = new ProfileOtherHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileOtherId = otherId; 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.otherRepository.save(record), diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index 48bbdac3..6e82bb70 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -44,34 +44,6 @@ export class ProfileSalaryController extends Controller { } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "3cf02fb7-2f0c-471b-b641-51d557375c0a", - createdAt: "2024-03-12T02:55:56.915Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T02:55:56.915Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - isActive: true, - startDate: "2024-03-12T09:55:23.000Z", - endDate: "2024-03-12T09:55:23.000Z", - numberOrder: "string", - topic: "string", - place: "string", - dateOrder: "2024-03-12T09:55:23.000Z", - department: "string", - duration: "string", - name: "string", - yearly: 0, - isDate: true, - }, - ], - }) public async getSalary(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.salaryRepo.find({ @@ -92,63 +64,16 @@ export class ProfileSalaryController extends Controller { } @Get("history/{salaryId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d", - createdAt: "2024-03-12T02:55:56.971Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T02:55:56.971Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - isActive: true, - startDate: "2024-03-12T09:55:23.000Z", - endDate: "2024-03-12T09:55:23.000Z", - numberOrder: "string", - topic: "string", - place: "string", - dateOrder: "2024-03-12T09:55:23.000Z", - department: "string", - duration: "string", - name: "string", - yearly: 0, - isDate: true, - profileSalaryId: "3cf02fb7-2f0c-471b-b641-51d557375c0a", - }, - { - id: "a251c176-3dac-4d09-9813-38c8db1127e3", - createdAt: "2024-03-12T02:58:17.917Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T02:58:17.917Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - isActive: true, - startDate: "2024-03-12T09:57:44.000Z", - endDate: "2024-03-12T09:57:44.000Z", - numberOrder: "string", - topic: "topic", - place: "place", - dateOrder: "2024-03-12T09:57:44.000Z", - department: "department", - duration: "string", - name: "name", - yearly: 0, - isDate: true, - profileSalaryId: "3cf02fb7-2f0c-471b-b641-51d557375c0a", - }, - ], - }) public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) { const _record = await this.salaryRepo.findOneBy({ id: salaryId }); if (_record) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } - const record = await this.salaryHistoryRepo.findBy({ - profileSalaryId: salaryId, + const record = await this.salaryHistoryRepo.find({ + where: { + profileSalaryId: salaryId, + }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -158,7 +83,7 @@ export class ProfileSalaryController extends Controller { if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } - + const profile = await this.profileRepo.findOneBy({ id: body.profileId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -178,6 +103,8 @@ export class ProfileSalaryController 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 }); @@ -200,19 +127,22 @@ export class ProfileSalaryController extends Controller { const record = await this.salaryRepo.findOneBy({ id: salaryId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId); - + const history = new ProfileSalaryHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileSalaryId = salaryId; 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.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]); @@ -223,7 +153,11 @@ export class ProfileSalaryController extends Controller { public async deleteSalary(@Path() salaryId: string, @Request() req: RequestWithUser) { const _record = await this.salaryRepo.findOneBy({ id: salaryId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_OFFICER", + _record.profileId, + ); } await this.salaryHistoryRepo.delete({ profileSalaryId: salaryId, @@ -239,7 +173,11 @@ export class ProfileSalaryController extends Controller { } @Get("swap/{direction}/{salaryId}") - public async swapSalary(@Path() direction: string, salaryId: string, @Request() req: RequestWithUser) { + public async swapSalary( + @Path() direction: string, + salaryId: string, + @Request() req: RequestWithUser, + ) { const source_item = await this.salaryRepo.findOne({ where: { id: salaryId } }); // if (source_item) { // await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", source_item.profileId);//ไม่แน่ใจOFFปิดไว้ก่อน diff --git a/src/controllers/ProfileSalaryEmployeeController.ts b/src/controllers/ProfileSalaryEmployeeController.ts index 4ecbf5df..e143324a 100644 --- a/src/controllers/ProfileSalaryEmployeeController.ts +++ b/src/controllers/ProfileSalaryEmployeeController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -49,10 +48,7 @@ export class ProfileSalaryEmployeeController extends Controller { @Get("{profileId}") public async getSalaryEmployee(@Path() profileId: string, @Request() req: RequestWithUser) { - // const _record = await this.salaryRepo.findOneBy({ id: profileId }); - // if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); - // } + await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const record = await this.salaryRepo.find({ where: { profileEmployeeId: profileId }, order: { order: "ASC" }, @@ -63,10 +59,6 @@ export class ProfileSalaryEmployeeController extends Controller { @Get("admin/{profileId}") public async getSalaryEmployeeAdmin(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_WAGE"); - // const _record = await this.salaryRepo.findOneBy({ id: profileId }); - // if (_record) { - // await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); - // } const record = await this.salaryRepo.find({ where: { profileEmployeeId: profileId }, order: { order: "ASC" }, @@ -78,10 +70,17 @@ export class ProfileSalaryEmployeeController extends Controller { public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) { const _record = await this.salaryRepo.findOneBy({ id: salaryId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } - const record = await this.salaryHistoryRepo.findBy({ - profileSalaryId: salaryId, + const record = await this.salaryHistoryRepo.find({ + where: { + profileSalaryId: salaryId, + }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -114,6 +113,8 @@ export class ProfileSalaryEmployeeController 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 }); @@ -133,23 +134,29 @@ export class ProfileSalaryEmployeeController extends Controller { @Body() body: UpdateProfileSalaryEmployee, @Path() salaryId: string, ) { - const record = await this.salaryRepo.findOneBy({ id: salaryId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); const history = new ProfileSalaryHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileSalaryId = salaryId; 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.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]); @@ -160,7 +167,11 @@ export class ProfileSalaryEmployeeController extends Controller { public async deleteSalaryEmployee(@Path() salaryId: string, @Request() req: RequestWithUser) { const _record = await this.salaryRepo.findOneBy({ id: salaryId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } await this.salaryHistoryRepo.delete({ @@ -177,10 +188,18 @@ export class ProfileSalaryEmployeeController extends Controller { } @Get("swap/{direction}/{salaryId}") - public async swapSalaryEmployee(@Path() direction: string, salaryId: string, @Request() req: RequestWithUser) { - const _record = await this.salaryRepo.findOneBy({ id: salaryId }); + public async swapSalaryEmployee( + @Path() direction: string, + salaryId: string, + @Request() req: RequestWithUser, + ) { + const _record = await this.salaryRepo.findOneBy({ id: salaryId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } const source_item = await this.salaryRepo.findOne({ where: { id: salaryId } }); if (source_item == null) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); diff --git a/src/controllers/ProfileSalaryEmployeeTempController.ts b/src/controllers/ProfileSalaryEmployeeTempController.ts index 1fcf844c..1461d588 100644 --- a/src/controllers/ProfileSalaryEmployeeTempController.ts +++ b/src/controllers/ProfileSalaryEmployeeTempController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -70,8 +69,11 @@ export class ProfileSalaryEmployeeTempController extends Controller { @Get("history/{salaryId}") public async salaryHistory(@Path() salaryId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); - const record = await this.salaryHistoryRepo.findBy({ - profileSalaryId: salaryId, + const record = await this.salaryHistoryRepo.find({ + where: { + profileSalaryId: salaryId, + }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -105,6 +107,8 @@ export class ProfileSalaryEmployeeTempController 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 }); @@ -132,15 +136,18 @@ export class ProfileSalaryEmployeeTempController extends Controller { const history = new ProfileSalaryHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileSalaryId = salaryId; 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.salaryRepo.save(record), this.salaryHistoryRepo.save(history)]); diff --git a/src/controllers/ProfileTrainingController.ts b/src/controllers/ProfileTrainingController.ts index d460377b..ae64e294 100644 --- a/src/controllers/ProfileTrainingController.ts +++ b/src/controllers/ProfileTrainingController.ts @@ -2,7 +2,6 @@ import { Body, Controller, Delete, - Example, Get, Patch, Path, @@ -41,103 +40,32 @@ export class ProfileTrainingController extends Controller { } const record = await this.trainingRepo.find({ where: { profileId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("{profileId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "3cf02fb7-2f0c-471b-b641-51d557375c0a", - createdAt: "2024-03-12T02:55:56.915Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T02:55:56.915Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - isActive: true, - startDate: "2024-03-12T09:55:23.000Z", - endDate: "2024-03-12T09:55:23.000Z", - numberOrder: "string", - topic: "string", - place: "string", - dateOrder: "2024-03-12T09:55:23.000Z", - department: "string", - duration: "string", - name: "string", - yearly: 0, - isDate: true, - }, - ], - }) public async getTraining(@Path() profileId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); - const record = await this.trainingRepo.findBy({ profileId }); + const record = await this.trainingRepo.find({ + where: { profileId }, + order: { createdAt: "ASC" }, + }); return new HttpSuccess(record); } @Get("history/{trainingId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d", - createdAt: "2024-03-12T02:55:56.971Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T02:55:56.971Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - isActive: true, - startDate: "2024-03-12T09:55:23.000Z", - endDate: "2024-03-12T09:55:23.000Z", - numberOrder: "string", - topic: "string", - place: "string", - dateOrder: "2024-03-12T09:55:23.000Z", - department: "string", - duration: "string", - name: "string", - yearly: 0, - isDate: true, - profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a", - }, - { - id: "a251c176-3dac-4d09-9813-38c8db1127e3", - createdAt: "2024-03-12T02:58:17.917Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T02:58:17.917Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - isActive: true, - startDate: "2024-03-12T09:57:44.000Z", - endDate: "2024-03-12T09:57:44.000Z", - numberOrder: "string", - topic: "topic", - place: "place", - dateOrder: "2024-03-12T09:57:44.000Z", - department: "department", - duration: "string", - name: "name", - yearly: 0, - isDate: true, - profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a", - }, - ], - }) public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) { const _record = await this.trainingRepo.findOneBy({ id: trainingId }); if (_record) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", _record.profileId); } - const record = await this.trainingHistoryRepo.findBy({ - profileTrainingId: trainingId, + const record = await this.trainingHistoryRepo.find({ + where: { + profileTrainingId: trainingId, + }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -147,7 +75,7 @@ export class ProfileTrainingController extends Controller { if (!body.profileId) { throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); } - + const profile = await this.profileRepo.findOneBy({ id: body.profileId }); if (!profile) { throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว"); @@ -161,6 +89,8 @@ export class ProfileTrainingController 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 }); @@ -187,15 +117,18 @@ export class ProfileTrainingController extends Controller { const history = new ProfileTrainingHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileTrainingId = trainingId; 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.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]); @@ -206,7 +139,11 @@ export class ProfileTrainingController extends Controller { public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) { const _record = await this.trainingRepo.findOneBy({ id: trainingId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_OFFICER", + _record.profileId, + ); } await this.trainingHistoryRepo.delete({ profileTrainingId: trainingId, diff --git a/src/controllers/ProfileTrainingEmployeeController.ts b/src/controllers/ProfileTrainingEmployeeController.ts index 19f22cb8..da4ba019 100644 --- a/src/controllers/ProfileTrainingEmployeeController.ts +++ b/src/controllers/ProfileTrainingEmployeeController.ts @@ -41,104 +41,37 @@ export class ProfileTrainingEmployeeController extends Controller { } const record = await this.trainingRepo.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "3cf02fb7-2f0c-471b-b641-51d557375c0a", - createdAt: "2024-03-12T02:55:56.915Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T02:55:56.915Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - isActive: true, - startDate: "2024-03-12T09:55:23.000Z", - endDate: "2024-03-12T09:55:23.000Z", - numberOrder: "string", - topic: "string", - place: "string", - dateOrder: "2024-03-12T09:55:23.000Z", - department: "string", - duration: "string", - name: "string", - yearly: 0, - isDate: true, - }, - ], - }) public async getTraining(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId); - const record = await this.trainingRepo.findBy({ profileEmployeeId }); + const record = await this.trainingRepo.find({ + where: { profileEmployeeId }, + order: { createdAt: "ASC" }, + }); return new HttpSuccess(record); } @Get("history/{trainingId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d", - createdAt: "2024-03-12T02:55:56.971Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T02:55:56.971Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - isActive: true, - startDate: "2024-03-12T09:55:23.000Z", - endDate: "2024-03-12T09:55:23.000Z", - numberOrder: "string", - topic: "string", - place: "string", - dateOrder: "2024-03-12T09:55:23.000Z", - department: "string", - duration: "string", - name: "string", - yearly: 0, - isDate: true, - profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a", - }, - { - id: "a251c176-3dac-4d09-9813-38c8db1127e3", - createdAt: "2024-03-12T02:58:17.917Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T02:58:17.917Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - isActive: true, - startDate: "2024-03-12T09:57:44.000Z", - endDate: "2024-03-12T09:57:44.000Z", - numberOrder: "string", - topic: "topic", - place: "place", - dateOrder: "2024-03-12T09:57:44.000Z", - department: "department", - duration: "string", - name: "name", - yearly: 0, - isDate: true, - profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a", - }, - ], - }) public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) { const _record = await this.trainingRepo.findOneBy({ id: trainingId }); if (_record) { - await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserGet( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } - const record = await this.trainingHistoryRepo.findBy({ - profileTrainingId: trainingId, + const record = await this.trainingHistoryRepo.find({ + where: { + profileTrainingId: trainingId, + }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -158,7 +91,6 @@ export class ProfileTrainingEmployeeController extends Controller { } await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", profile.id); - const data = new ProfileTraining(); const meta = { @@ -166,6 +98,8 @@ export class ProfileTrainingEmployeeController 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 }); @@ -187,20 +121,27 @@ export class ProfileTrainingEmployeeController extends Controller { ) { const record = await this.trainingRepo.findOneBy({ id: trainingId }); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId) + await new permission().PermissionOrgUserUpdate( + req, + "SYS_REGISTRY_EMP", + record.profileEmployeeId, + ); const history = new ProfileTrainingHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileTrainingId = trainingId; 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.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]); @@ -211,7 +152,11 @@ export class ProfileTrainingEmployeeController extends Controller { public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) { const _record = await this.trainingRepo.findOneBy({ id: trainingId }); if (_record) { - await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId); + await new permission().PermissionOrgUserDelete( + req, + "SYS_REGISTRY_EMP", + _record.profileEmployeeId, + ); } await this.trainingHistoryRepo.delete({ diff --git a/src/controllers/ProfileTrainingEmployeeTempController.ts b/src/controllers/ProfileTrainingEmployeeTempController.ts index a5dd241a..b1836ab4 100644 --- a/src/controllers/ProfileTrainingEmployeeTempController.ts +++ b/src/controllers/ProfileTrainingEmployeeTempController.ts @@ -41,100 +41,29 @@ export class ProfileTrainingEmployeeTempController extends Controller { } const record = await this.trainingRepo.find({ where: { profileEmployeeId: profile.id }, + order: { createdAt: "ASC" }, }); return new HttpSuccess(record); } @Get("{profileEmployeeId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "3cf02fb7-2f0c-471b-b641-51d557375c0a", - createdAt: "2024-03-12T02:55:56.915Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T02:55:56.915Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - profileEmployeeId: "1526d9d3-d8b1-43ab-81b5-a84dfbe99201", - isActive: true, - startDate: "2024-03-12T09:55:23.000Z", - endDate: "2024-03-12T09:55:23.000Z", - numberOrder: "string", - topic: "string", - place: "string", - dateOrder: "2024-03-12T09:55:23.000Z", - department: "string", - duration: "string", - name: "string", - yearly: 0, - isDate: true, - }, - ], - }) public async getTraining(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); - const record = await this.trainingRepo.findBy({ profileEmployeeId }); + const record = await this.trainingRepo.find({ + where: { profileEmployeeId }, + order: { createdAt: "ASC" }, + }); return new HttpSuccess(record); } @Get("history/{trainingId}") - @Example({ - status: 200, - message: "สำเร็จ", - result: [ - { - id: "6d4e9dbe-8697-4546-9651-0a1c3ea0a82d", - createdAt: "2024-03-12T02:55:56.971Z", - createdUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - lastUpdatedAt: "2024-03-12T02:55:56.971Z", - lastUpdateUserId: "59134ef9-9e62-41d0-aac5-339be727f2b0", - createdFullName: "สาวิตรี ศรีสมัย", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - isActive: true, - startDate: "2024-03-12T09:55:23.000Z", - endDate: "2024-03-12T09:55:23.000Z", - numberOrder: "string", - topic: "string", - place: "string", - dateOrder: "2024-03-12T09:55:23.000Z", - department: "string", - duration: "string", - name: "string", - yearly: 0, - isDate: true, - profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a", - }, - { - id: "a251c176-3dac-4d09-9813-38c8db1127e3", - createdAt: "2024-03-12T02:58:17.917Z", - createdUserId: "00000000-0000-0000-0000-000000000000", - lastUpdatedAt: "2024-03-12T02:58:17.917Z", - lastUpdateUserId: "00000000-0000-0000-0000-000000000000", - createdFullName: "string", - lastUpdateFullName: "สาวิตรี ศรีสมัย", - isActive: true, - startDate: "2024-03-12T09:57:44.000Z", - endDate: "2024-03-12T09:57:44.000Z", - numberOrder: "string", - topic: "topic", - place: "place", - dateOrder: "2024-03-12T09:57:44.000Z", - department: "department", - duration: "string", - name: "name", - yearly: 0, - isDate: true, - profileTrainingId: "3cf02fb7-2f0c-471b-b641-51d557375c0a", - }, - ], - }) public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); - const record = await this.trainingHistoryRepo.findBy({ - profileTrainingId: trainingId, + const record = await this.trainingHistoryRepo.find({ + where: { + profileTrainingId: trainingId, + }, + order: { createdAt: "DESC" }, }); return new HttpSuccess(record); } @@ -162,6 +91,8 @@ export class ProfileTrainingEmployeeTempController 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 }); @@ -189,15 +120,18 @@ export class ProfileTrainingEmployeeTempController extends Controller { const history = new ProfileTrainingHistory(); Object.assign(record, body); - Object.assign(history, body); + Object.assign(history, { ...body, id: undefined }); history.profileTrainingId = trainingId; 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.trainingRepo.save(record), this.trainingHistoryRepo.save(history)]); diff --git a/src/entities/base/Base.ts b/src/entities/base/Base.ts index b404feb0..175d4e63 100644 --- a/src/entities/base/Base.ts +++ b/src/entities/base/Base.ts @@ -1,14 +1,14 @@ import { - Entity, - PrimaryGeneratedColumn, - Column, - CreateDateColumn, - UpdateDateColumn, - } from "typeorm"; - - @Entity() - export class EntityBase { - @PrimaryGeneratedColumn("uuid") + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, +} from "typeorm"; + +@Entity() +export class EntityBase { + @PrimaryGeneratedColumn("uuid") id!: string; @CreateDateColumn({ comment: "สร้างข้อมูลเมื่อ" }) @@ -36,6 +36,4 @@ import { @Column({ comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด", length: 200, default: "string" }) lastUpdateFullName!: String; - - } - \ No newline at end of file +} diff --git a/src/migration/1725011784785-update_base_date.ts b/src/migration/1725011784785-update_base_date.ts new file mode 100644 index 00000000..0cbdc5ab --- /dev/null +++ b/src/migration/1725011784785-update_base_date.ts @@ -0,0 +1,386 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateBaseDate1725011784785 implements MigrationInterface { + name = 'UpdateBaseDate1725011784785' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`DROP INDEX \`FK_4913ef1466f9f35c1429e213d4b\` ON \`developmentProject\``); + await queryRunner.query(`DROP INDEX \`FK_8e3f2e86427befeff4283ae80f0\` ON \`developmentProject\``); + await queryRunner.query(`CREATE TABLE \`subDistrictImport\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`PROVINCE_CODE\` varchar(255) NULL, \`AMPHUR_CODE\` varchar(255) NULL, \`DISTRICT_CODE\` varchar(255) NULL, \`DISTRICT_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`provinceImport\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`PROVINCE_CODE\` varchar(255) NULL, \`PROVINCE_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`HR_POSITION_OFFICER\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`MP_POS_DATE\` text NULL, \`SALARY\` text NULL, \`MP_COMMAND_NUM\` text NULL, \`POS_NUM_NAME\` text NULL, \`POS_NUM_CODE\` text NULL, \`FLAG_TO_NAME\` text NULL, \`WORK_LINE_NAME\` text NULL, \`SPECIALIST_NAME\` text NULL, \`ADMIN_NAME\` text NULL, \`REMARK\` text NULL, \`ORDER_MOVE_POSITION\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_OFFICER_FAMILY\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`FATHER_RANK_NAME\` text NULL, \`FATHER_FNAME\` text NULL, \`FATHER_LNAME\` text NULL, \`MOTHER_RANK_NAME\` text NULL, \`MOTHER_FNAME\` text NULL, \`MOTHER_LNAME\` text NULL, \`SPOUSE_RANK_NAME\` text NULL, \`SPOUSE_FNAME\` text NULL, \`SPOUSE_LNAME\` text NULL, \`SPOUSE_ID\` text NULL, \`MARRIAGE_STATE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_EMP_ADDRESS\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`PROVINCE_CODE\` text NULL, \`AMPHUR_CODE\` text NULL, \`DISTRICT_CODE\` text NULL, \`CONTACT_PROVINCE_CODE\` text NULL, \`CONTACT_AMPHUR_CODE\` text NULL, \`CONTACT_DISTRICT_CODE\` text NULL, \`H_NUMBER\` text NULL, \`ZIPCODE\` text NULL, \`CONTACT_H_NUMBER\` text NULL, \`CONTACT_ZIPCODE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_OFFICER_ADDRESS\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`PROVINCE_CODE\` text NULL, \`AMPHUR_CODE\` text NULL, \`DISTRICT_CODE\` text NULL, \`CONTACT_PROVINCE_CODE\` text NULL, \`CONTACT_AMPHUR_CODE\` text NULL, \`CONTACT_DISTRICT_CODE\` text NULL, \`H_NUMBER\` text NULL, \`ZIPCODE\` text NULL, \`CONTACT_H_NUMBER\` text NULL, \`CONTACT_ZIPCODE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`HR_PERSONAL_EMP_FAMILY\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`FATHER_RANK_NAME\` text NULL, \`FATHER_FNAME\` text NULL, \`FATHER_LNAME\` text NULL, \`MOTHER_RANK_NAME\` text NULL, \`MOTHER_FNAME\` text NULL, \`MOTHER_LNAME\` text NULL, \`SPOUSE_RANK_NAME\` text NULL, \`SPOUSE_FNAME\` text NULL, \`SPOUSE_LNAME\` text NULL, \`SPOUSE_ID\` text NULL, \`MARRIAGE_STATE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`HR_EDUCATION_EMP\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`EDUCATION_CODE\` text NULL, \`START_EDUCATION_YEAR\` text NULL, \`EDUCATION_YEAR\` text NULL, \`INSTITUE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`HR_EDUCATION\` (\`CIT\` text NULL, \`id\` int NOT NULL AUTO_INCREMENT, \`EDUCATION_CODE\` text NULL, \`START_EDUCATION_YEAR\` text NULL, \`EDUCATION_YEAR\` text NULL, \`INSTITUE\` text NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`educationMis\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`EDUCATION_CODE\` varchar(255) NULL, \`EDUCATION_NAME\` varchar(255) NULL, \`EDUCATION_ABB_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`CREATE TABLE \`amphurImport\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`PROVINCE_CODE\` varchar(255) NULL, \`AMPHUR_CODE\` varchar(255) NULL, \`AMPHUR_NAME\` varchar(255) NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); + await queryRunner.query(`ALTER TABLE \`entity_base\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`entity_base\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`province\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`province\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`district\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`district\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`subDistrict\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`subDistrict\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`relationship\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`relationship\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`rank\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`rank\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`religion\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`religion\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileSalary\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileSalary\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileCertificateHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileCertificateHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileCertificate\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileCertificate\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`insigniaType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`insigniaType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`insignia\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`insignia\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileInsigniaHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileInsigniaHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileInsignia\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileInsignia\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileHonorHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileHonorHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileHonor\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileHonor\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAssessmentHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileAssessmentHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAssessment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileAssessment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`leaveType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`leaveType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileLeave\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileLeave\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileLeaveHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileLeaveHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDutyHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileDutyHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDuty\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileDuty\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileNopaidHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileNopaidHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileNopaid\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileNopaid\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDisciplineHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileDisciplineHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChangeNameHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileChangeNameHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChangeName\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileChangeName\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEducationHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileEducationHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEducation\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileEducation\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAbilityHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileAbilityHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAbility\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileAbility\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileOtherHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileOtherHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileOther\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileOther\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAvatar\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileAvatar\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileGovernment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileGovernment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyFatherHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyFatherHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyFather\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyFather\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyMotherHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyMotherHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyCouple\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyCouple\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChildren\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileChildren\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeInformationHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeInformationHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeEmploymentHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeEmploymentHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeEmployment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeEmployment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEdit\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileEdit\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDevelopmentHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileDevelopmentHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDevelopment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileDevelopment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployee\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileEmployee\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosLevel\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`employeePosLevel\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosDict\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`employeePosDict\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`employeePosType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosition\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`employeePosition\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`authRoleAttr\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`authRoleAttr\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`authRole\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`authRole\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosMaster\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`employeePosMaster\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posExecutive\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`posExecutive\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`posType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posLevel\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`posLevel\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posMasterAct\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`posMasterAct\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profile\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profile\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAddressHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileAddressHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileTraining\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileTraining\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileTrainingHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileTrainingHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`changePosition\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`changePosition\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChangePosition\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`profileChangePosition\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`prefixe\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`prefixe\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`gender\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`gender\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`educationLevel\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`educationLevel\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`developmentProject\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`developmentProject\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`bloodGroup\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time)`); + await queryRunner.query(`ALTER TABLE \`bloodGroup\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT Fri Aug 30 2024 16:56:46 GMT+0700 (Indochina Time) ON UPDATE CURRENT_TIMESTAMP(6)`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`bloodGroup\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`bloodGroup\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`developmentProject\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`developmentProject\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`educationLevel\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`educationLevel\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`gender\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`gender\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`prefixe\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`prefixe\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChangePosition\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChangePosition\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`changePosition\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`changePosition\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileTrainingHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileTrainingHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileTraining\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileTraining\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAddressHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAddressHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profile\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profile\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posMaster\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posMasterAct\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posMasterAct\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`position\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posLevel\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posLevel\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posDict\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posExecutive\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`posExecutive\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgRevision\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosMaster\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosMaster\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`authRole\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`authRole\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`authRoleAttr\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`authRoleAttr\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosition\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosition\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosDict\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosDict\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosLevel\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`employeePosLevel\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployee\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployee\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDevelopment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDevelopment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDevelopmentHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDevelopmentHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEdit\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEdit\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeEmployment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeEmployment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeEmploymentHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeEmploymentHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeInformationHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEmployeeInformationHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChildren\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChildren\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChildrenHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyCouple\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyCouple\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyCoupleHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyMother\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyMotherHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyMotherHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyFather\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyFather\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyFatherHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyFatherHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileGovernment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileGovernment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAvatar\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAvatar\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileOther\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileOther\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileOtherHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileOtherHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAbility\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAbility\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAbilityHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAbilityHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEducation\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEducation\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEducationHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileEducationHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileFamilyHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChangeName\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChangeName\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChangeNameHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileChangeNameHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDiscipline\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDisciplineHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDisciplineHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileNopaid\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileNopaid\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileNopaidHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileNopaidHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDuty\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDuty\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDutyHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileDutyHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileLeaveHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileLeaveHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileLeave\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileLeave\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`leaveType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`leaveType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAssessment\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAssessment\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAssessmentHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileAssessmentHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileHonor\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileHonor\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileHonorHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileHonorHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileInsignia\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileInsignia\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileInsigniaHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileInsigniaHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`insignia\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`insignia\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`insigniaType\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`insigniaType\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileCertificate\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileCertificate\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileCertificateHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileCertificateHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileSalary\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileSalary\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`profileSalaryHistory\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgRoot\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgChild1\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgChild2\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgChild3\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`orgChild4\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`religion\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`religion\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`rank\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`rank\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`relationship\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`relationship\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`subDistrict\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`subDistrict\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`district\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`district\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`province\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`province\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`entity_base\` CHANGE \`lastUpdatedAt\` \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`ALTER TABLE \`entity_base\` CHANGE \`createdAt\` \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6)`); + await queryRunner.query(`DROP TABLE \`amphurImport\``); + await queryRunner.query(`DROP TABLE \`educationMis\``); + await queryRunner.query(`DROP TABLE \`HR_EDUCATION\``); + await queryRunner.query(`DROP TABLE \`HR_EDUCATION_EMP\``); + await queryRunner.query(`DROP TABLE \`HR_PERSONAL_EMP_FAMILY\``); + await queryRunner.query(`DROP TABLE \`HR_PERSONAL_OFFICER_ADDRESS\``); + await queryRunner.query(`DROP TABLE \`HR_PERSONAL_EMP_ADDRESS\``); + await queryRunner.query(`DROP TABLE \`HR_PERSONAL_OFFICER_FAMILY\``); + await queryRunner.query(`DROP TABLE \`HR_POSITION_OFFICER\``); + await queryRunner.query(`DROP TABLE \`provinceImport\``); + await queryRunner.query(`DROP TABLE \`subDistrictImport\``); + await queryRunner.query(`CREATE INDEX \`FK_8e3f2e86427befeff4283ae80f0\` ON \`developmentProject\` (\`profileDevelopmentHistoryId\`)`); + await queryRunner.query(`CREATE INDEX \`FK_4913ef1466f9f35c1429e213d4b\` ON \`developmentProject\` (\`profileDevelopmentId\`)`); + } + +} From ad4efc2b4749b138760047f387218aa1465ae24e Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 30 Aug 2024 21:02:14 +0700 Subject: [PATCH 2/3] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88?= =?UTF-8?q?=E0=B8=A1=E0=B8=A7=E0=B8=B1=E0=B8=99=E0=B8=97=E0=B8=B5=E0=B9=88?= =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/AuthRoleController.ts | 2 +- src/controllers/EmployeePosLevelController.ts | 10 +++- src/controllers/EmployeePosTypeController.ts | 10 +++- src/controllers/GenderController.ts | 3 + src/controllers/ImportDataController.ts | 36 ++++++++++++ src/controllers/InsigniaController.ts | 3 + src/controllers/InsigniaTypeController.ts | 33 ++++++----- src/controllers/OrgChild1Controller.ts | 2 + src/controllers/OrgChild2Controller.ts | 2 + src/controllers/OrgChild3Controller.ts | 2 + src/controllers/OrgChild4Controller.ts | 4 +- src/controllers/OrgRootController.ts | 2 + src/controllers/OrganizationController.ts | 2 + .../OrganizationDotnetController.ts | 1 + src/controllers/PosExecutiveController.ts | 3 + src/controllers/PosLevelController.ts | 10 +++- src/controllers/PosMasterActController.ts | 2 + src/controllers/PosTypeController.ts | 10 +++- src/controllers/PositionController.ts | 57 +++++++++++++------ src/controllers/PrefixController.ts | 3 + src/controllers/ProfileController.ts | 15 +++++ src/controllers/ProfileEmployeeController.ts | 8 +++ .../ProfileEmployeeTempController.ts | 10 ++++ src/controllers/ProvinceController.ts | 3 + src/controllers/RankController.ts | 3 + src/controllers/RelationshipController.ts | 3 + src/controllers/ReligionController.ts | 3 + src/controllers/SubDistrictController.ts | 3 + 28 files changed, 205 insertions(+), 40 deletions(-) diff --git a/src/controllers/AuthRoleController.ts b/src/controllers/AuthRoleController.ts index a413d5af..4d78ae93 100644 --- a/src/controllers/AuthRoleController.ts +++ b/src/controllers/AuthRoleController.ts @@ -188,7 +188,7 @@ export class AuthRoleController extends Controller { roleName: body.roleName, roleDescription: body.roleDescription, lastUpdateFullName: req.user.name, - createdAt: new Date(), + lastUpdateUserId: req.user.sub, lastUpdatedAt: new Date(), }); } diff --git a/src/controllers/EmployeePosLevelController.ts b/src/controllers/EmployeePosLevelController.ts index d3539d3b..79d50615 100644 --- a/src/controllers/EmployeePosLevelController.ts +++ b/src/controllers/EmployeePosLevelController.ts @@ -80,6 +80,8 @@ export class EmployeePosLevelController extends Controller { EmpPosLevel.createdFullName = request.user.name; EmpPosLevel.lastUpdateUserId = request.user.sub; EmpPosLevel.lastUpdateFullName = request.user.name; + EmpPosLevel.createdAt = new Date(); + EmpPosLevel.lastUpdatedAt = new Date(); await this.employeePosLevelRepository.save(EmpPosLevel); return new HttpSuccess(EmpPosLevel.id); } @@ -125,6 +127,7 @@ export class EmployeePosLevelController extends Controller { } EmpPosLevel.lastUpdateUserId = request.user.sub; EmpPosLevel.lastUpdateFullName = request.user.name; + EmpPosLevel.lastUpdatedAt = new Date(); this.employeePosLevelRepository.merge(EmpPosLevel, requestBody); await this.employeePosLevelRepository.save(EmpPosLevel); return new HttpSuccess(EmpPosLevel.id); @@ -139,11 +142,14 @@ export class EmployeePosLevelController extends Controller { */ @Delete("{id}") async deleteType(@Path() id: string) { - let result :any + let result: any; try { result = await this.employeePosLevelRepository.delete({ id: id }); } catch { - throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับชั้นงานนี้อยู่"); + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับชั้นงานนี้อยู่", + ); } if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); diff --git a/src/controllers/EmployeePosTypeController.ts b/src/controllers/EmployeePosTypeController.ts index aeefffac..24261118 100644 --- a/src/controllers/EmployeePosTypeController.ts +++ b/src/controllers/EmployeePosTypeController.ts @@ -76,6 +76,8 @@ export class EmployeePosTypeController extends Controller { EmpPosType.createdFullName = request.user.name; EmpPosType.lastUpdateUserId = request.user.sub; EmpPosType.lastUpdateFullName = request.user.name; + EmpPosType.createdAt = new Date(); + EmpPosType.lastUpdatedAt = new Date(); await this.employeePosTypeRepository.save(EmpPosType); return new HttpSuccess(EmpPosType.id); } @@ -120,6 +122,7 @@ export class EmployeePosTypeController extends Controller { } EmpPosType.lastUpdateUserId = request.user.sub; EmpPosType.lastUpdateFullName = request.user.name; + EmpPosType.lastUpdatedAt = new Date(); this.employeePosTypeRepository.merge(EmpPosType, requestBody); await this.employeePosTypeRepository.save(EmpPosType); return new HttpSuccess(EmpPosType.id); @@ -134,11 +137,14 @@ export class EmployeePosTypeController extends Controller { */ @Delete("{id}") async deleteType(@Path() id: string) { - let result :any + let result: any; try { result = await this.employeePosTypeRepository.delete({ id: id }); } catch { - throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับกลุ่มงานนี้อยู่"); + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับกลุ่มงานนี้อยู่", + ); } if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); diff --git a/src/controllers/GenderController.ts b/src/controllers/GenderController.ts index a1b38dc2..5e373d83 100644 --- a/src/controllers/GenderController.ts +++ b/src/controllers/GenderController.ts @@ -98,6 +98,8 @@ export class GenderController extends Controller { _gender.createdFullName = request.user.name; _gender.lastUpdateUserId = request.user.sub; _gender.lastUpdateFullName = request.user.name; + _gender.createdAt = new Date(); + _gender.lastUpdatedAt = new Date(); await this.genderRepository.save(_gender); return new HttpSuccess(); } @@ -129,6 +131,7 @@ export class GenderController extends Controller { _gender.lastUpdateUserId = request.user.sub; _gender.lastUpdateFullName = request.user.name; + _gender.lastUpdatedAt = new Date(); this.genderRepository.merge(_gender, requestBody); await this.genderRepository.save(_gender); return new HttpSuccess(); diff --git a/src/controllers/ImportDataController.ts b/src/controllers/ImportDataController.ts index 986e0c2d..15b406f6 100644 --- a/src/controllers/ImportDataController.ts +++ b/src/controllers/ImportDataController.ts @@ -175,6 +175,8 @@ export class ImportDataController extends Controller { profile.createdFullName = request.user.name; profile.lastUpdateUserId = request.user.sub; profile.lastUpdateFullName = request.user.name; + profile.createdAt = new Date(); + profile.lastUpdatedAt = new Date(); profiles.push(profile); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); @@ -248,6 +250,8 @@ export class ImportDataController extends Controller { profileEmp.createdFullName = request.user.name; profileEmp.lastUpdateUserId = request.user.sub; profileEmp.lastUpdateFullName = request.user.name; + profileEmp.createdAt = new Date(); + profileEmp.lastUpdatedAt = new Date(); profiles.push(profileEmp); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); @@ -336,6 +340,8 @@ export class ImportDataController extends Controller { profileSalary.createdFullName = request.user.name; profileSalary.lastUpdateUserId = request.user.sub; profileSalary.lastUpdateFullName = request.user.name; + profileSalary.createdAt = new Date(); + profileSalary.lastUpdatedAt = new Date(); // profileSalarys.push(profileSalary); // await this.salaryRepository.save(profileSalary); // if (profileSalarys.length === BATCH_SIZE) { @@ -428,6 +434,8 @@ export class ImportDataController extends Controller { profileSalary.createdFullName = request.user.name; profileSalary.lastUpdateUserId = request.user.sub; profileSalary.lastUpdateFullName = request.user.name; + profileSalary.createdAt = new Date(); + profileSalary.lastUpdatedAt = new Date(); // profileSalarys.push(profileSalary); // await this.salaryRepository.save(profileSalary); // if (profileSalarys.length === BATCH_SIZE) { @@ -509,6 +517,8 @@ export class ImportDataController extends Controller { profileFather.createdFullName = request.user.name; profileFather.lastUpdateUserId = request.user.sub; profileFather.lastUpdateFullName = request.user.name; + profileFather.createdAt = new Date(); + profileFather.lastUpdatedAt = new Date(); profileMother.profileId = _item.id; profileMother.motherPrefix = existingProfile.MOTHER_RANK_NAME; @@ -518,6 +528,8 @@ export class ImportDataController extends Controller { profileMother.createdFullName = request.user.name; profileMother.lastUpdateUserId = request.user.sub; profileMother.lastUpdateFullName = request.user.name; + profileMother.createdAt = new Date(); + profileMother.lastUpdatedAt = new Date(); profileCouple.profileId = _item.id; profileCouple.couplePrefix = existingProfile.SPOUSE_RANK_NAME; @@ -539,6 +551,8 @@ export class ImportDataController extends Controller { profileCouple.createdFullName = request.user.name; profileCouple.lastUpdateUserId = request.user.sub; profileCouple.lastUpdateFullName = request.user.name; + profileCouple.createdAt = new Date(); + profileCouple.lastUpdatedAt = new Date(); // fathers.push(profileFather); // mothers.push(profileMother); @@ -633,6 +647,8 @@ export class ImportDataController extends Controller { profileFather.createdFullName = request.user.name; profileFather.lastUpdateUserId = request.user.sub; profileFather.lastUpdateFullName = request.user.name; + profileFather.createdAt = new Date(); + profileFather.lastUpdatedAt = new Date(); profileMother.profileEmployeeId = _item.id; profileMother.motherPrefix = existingProfile.MOTHER_RANK_NAME; @@ -642,6 +658,8 @@ export class ImportDataController extends Controller { profileMother.createdFullName = request.user.name; profileMother.lastUpdateUserId = request.user.sub; profileMother.lastUpdateFullName = request.user.name; + profileMother.createdAt = new Date(); + profileMother.lastUpdatedAt = new Date(); profileCouple.profileEmployeeId = _item.id; profileCouple.couplePrefix = existingProfile.SPOUSE_RANK_NAME; @@ -663,6 +681,8 @@ export class ImportDataController extends Controller { profileCouple.createdFullName = request.user.name; profileCouple.lastUpdateUserId = request.user.sub; profileCouple.lastUpdateFullName = request.user.name; + profileCouple.createdAt = new Date(); + profileCouple.lastUpdatedAt = new Date(); // fathers.push(profileFather); // mothers.push(profileMother); @@ -720,6 +740,8 @@ export class ImportDataController extends Controller { educationMis.createdFullName = request.user.name; educationMis.lastUpdateUserId = request.user.sub; educationMis.lastUpdateFullName = request.user.name; + educationMis.createdAt = new Date(); + educationMis.lastUpdatedAt = new Date(); educationMis_.push(educationMis); }), ); @@ -786,6 +808,8 @@ export class ImportDataController extends Controller { education.createdFullName = request.user.name; education.lastUpdateUserId = request.user.sub; education.lastUpdateFullName = request.user.name; + education.createdAt = new Date(); + education.lastUpdatedAt = new Date(); // await educations.push(await education); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); await this.educationRepository.save(await education); @@ -860,6 +884,8 @@ export class ImportDataController extends Controller { education.createdFullName = request.user.name; education.lastUpdateUserId = request.user.sub; education.lastUpdateFullName = request.user.name; + education.createdAt = new Date(); + education.lastUpdatedAt = new Date(); // educations.push(education); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); await this.educationRepository.save(education); @@ -898,6 +924,8 @@ export class ImportDataController extends Controller { prov.createdFullName = request.user.name; prov.lastUpdateUserId = request.user.sub; prov.lastUpdateFullName = request.user.name; + prov.createdAt = new Date(); + prov.lastUpdatedAt = new Date(); provinces_.push(prov); }), ); @@ -930,6 +958,8 @@ export class ImportDataController extends Controller { amh.createdFullName = request.user.name; amh.lastUpdateUserId = request.user.sub; amh.lastUpdateFullName = request.user.name; + amh.createdAt = new Date(); + amh.lastUpdatedAt = new Date(); amphur_.push(amh); }), ); @@ -963,6 +993,8 @@ export class ImportDataController extends Controller { subD.createdFullName = request.user.name; subD.lastUpdateUserId = request.user.sub; subD.lastUpdateFullName = request.user.name; + subD.createdAt = new Date(); + subD.lastUpdatedAt = new Date(); subDistrict_.push(subD); }), ); @@ -1112,6 +1144,8 @@ export class ImportDataController extends Controller { _item.createdFullName = request.user.name; _item.lastUpdateUserId = request.user.sub; _item.lastUpdateFullName = request.user.name; + _item.createdAt = new Date(); + _item.lastUpdatedAt = new Date(); // profileDatas.push(_item); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); await this.profileRepo.save(_item); @@ -1265,6 +1299,8 @@ export class ImportDataController extends Controller { _item.createdFullName = request.user.name; _item.lastUpdateUserId = request.user.sub; _item.lastUpdateFullName = request.user.name; + _item.createdAt = new Date(); + _item.lastUpdatedAt = new Date(); // profileDatas.push(_item); console.log(">>>>>>>>>>>>>>>>>>>" + rowCount); await this.profileEmpRepo.save(_item); diff --git a/src/controllers/InsigniaController.ts b/src/controllers/InsigniaController.ts index 44d20d7a..6085fccf 100644 --- a/src/controllers/InsigniaController.ts +++ b/src/controllers/InsigniaController.ts @@ -71,6 +71,8 @@ export class InsigniaController extends Controller { insignia.createdFullName = request.user.name; insignia.lastUpdateUserId = request.user.sub; insignia.lastUpdateFullName = request.user.name; + insignia.createdAt = new Date(); + insignia.lastUpdatedAt = new Date(); await this.insigniaRepository.save(insignia); return new HttpSuccess(insignia.id); } @@ -113,6 +115,7 @@ export class InsigniaController extends Controller { insignia.lastUpdateUserId = request.user.sub; insignia.lastUpdateFullName = request.user.name; + insignia.lastUpdatedAt = new Date(); this.insigniaRepository.merge(insignia, requestBody); await this.insigniaRepository.save(insignia); return new HttpSuccess(insignia.id); diff --git a/src/controllers/InsigniaTypeController.ts b/src/controllers/InsigniaTypeController.ts index 164aaf93..3c69398a 100644 --- a/src/controllers/InsigniaTypeController.ts +++ b/src/controllers/InsigniaTypeController.ts @@ -21,8 +21,8 @@ import HttpSuccess from "../interfaces/http-success"; import HttpStatusCode from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; import { Equal, ILike, In, IsNull, Like, Not, Brackets, Between } from "typeorm"; -import { InsigniaType, CreateInsigniaType, UpdateInsigniaType } from "../entities/InsigniaType"; -import { Insignia, } from "../entities/Insignia"; +import { InsigniaType, CreateInsigniaType, UpdateInsigniaType } from "../entities/InsigniaType"; +import { Insignia } from "../entities/Insignia"; @Route("api/v1/org/insignia/insignia-type") @Tags("InsigniaType") @@ -33,10 +33,9 @@ import { Insignia, } from "../entities/Insignia"; ) @SuccessResponse(HttpStatusCode.OK, "สำเร็จ") export class InsigniaTypeController extends Controller { - private insigniaTypeRepository = AppDataSource.getRepository(InsigniaType); private insigniaRepository = AppDataSource.getRepository(Insignia); - + /** * API เพิ่มข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์ * @@ -48,7 +47,6 @@ export class InsigniaTypeController extends Controller { @Body() requestBody: CreateInsigniaType, @Request() request: { user: Record }, ) { - const insigniaType = Object.assign(new InsigniaType(), requestBody); if (!insigniaType) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); @@ -68,6 +66,8 @@ export class InsigniaTypeController extends Controller { insigniaType.createdFullName = request.user.name; insigniaType.lastUpdateUserId = request.user.sub; insigniaType.lastUpdateFullName = request.user.name; + insigniaType.createdAt = new Date(); + insigniaType.lastUpdatedAt = new Date(); await this.insigniaTypeRepository.save(insigniaType); return new HttpSuccess(insigniaType.id); } @@ -77,7 +77,7 @@ export class InsigniaTypeController extends Controller { * * @summary แก้ไขลำดับชั้นเครื่องราชอิสริยาภรณ์ (ADMIN) * - * @param {string} id Id ลำดับชั้นเครื่องราชอิสริยาภรณ์ + * @param {string} id Id ลำดับชั้นเครื่องราชอิสริยาภรณ์ */ @Put("{id}") async UpdateInsigniaType( @@ -104,6 +104,7 @@ export class InsigniaTypeController extends Controller { insigniaType.lastUpdateUserId = request.user.sub; insigniaType.lastUpdateFullName = request.user.name; + insigniaType.lastUpdatedAt = new Date(); this.insigniaTypeRepository.merge(insigniaType, requestBody); await this.insigniaTypeRepository.save(insigniaType); return new HttpSuccess(insigniaType.id); @@ -122,11 +123,14 @@ export class InsigniaTypeController extends Controller { if (!delInsigniaType) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์นี้"); } - const Insignia = await this.insigniaRepository.find({ - where: { insigniaTypeId: id } + const Insignia = await this.insigniaRepository.find({ + where: { insigniaTypeId: id }, }); if (Insignia.length > 0) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้ เนื่องจากพบข้อมูลที่ตารางเครื่องราชอิสริยาภรณ์"); + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่สามารถลบได้ เนื่องจากพบข้อมูลที่ตารางเครื่องราชอิสริยาภรณ์", + ); } await this.insigniaTypeRepository.remove(delInsigniaType); return new HttpSuccess(); @@ -143,7 +147,7 @@ export class InsigniaTypeController extends Controller { const insigniaType_Active = await this.insigniaTypeRepository.find({ select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"], where: { isActive: true }, - order: { "name": "ASC" } + order: { name: "ASC" }, }); return new HttpSuccess(insigniaType_Active); } @@ -153,7 +157,7 @@ export class InsigniaTypeController extends Controller { * * @summary ORG_037 - รายละเอียดข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์ (ADMIN) # * - * @param {string} id Id ลำดับชั้นเครื่องราชอิสริยาภรณ์ + * @param {string} id Id ลำดับชั้นเครื่องราชอิสริยาภรณ์ */ @Get("{id}") async GetInsigniaTypeById(@Path() id: string) { @@ -163,7 +167,10 @@ export class InsigniaTypeController extends Controller { where: { id: id }, }); if (!insigniaType) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์ นี้"); + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่พบข้อมูลลำดับชั้นเครื่องราชอิสริยาภรณ์ นี้", + ); } return new HttpSuccess(insigniaType); } @@ -178,7 +185,7 @@ export class InsigniaTypeController extends Controller { async GetInsigniaType() { const insigniaTypeAll = await this.insigniaTypeRepository.find({ select: ["id", "name", "createdAt", "lastUpdatedAt", "lastUpdateFullName", "isActive"], - order: { "name": "ASC" } + order: { name: "ASC" }, }); return new HttpSuccess(insigniaTypeAll); } diff --git a/src/controllers/OrgChild1Controller.ts b/src/controllers/OrgChild1Controller.ts index 72d93883..b82d65e9 100644 --- a/src/controllers/OrgChild1Controller.ts +++ b/src/controllers/OrgChild1Controller.ts @@ -167,6 +167,8 @@ export class OrgChild1Controller { child1.createdFullName = request.user.name; child1.lastUpdateUserId = request.user.sub; child1.lastUpdateFullName = request.user.name; + child1.createdAt = new Date(); + child1.lastUpdatedAt = new Date(); child1.orgRevisionId = String(rootIdExits?.orgRevisionId); child1.orgRootId = String(rootIdExits?.id); child1.orgChild1Order = diff --git a/src/controllers/OrgChild2Controller.ts b/src/controllers/OrgChild2Controller.ts index 4d35f197..38a07fa9 100644 --- a/src/controllers/OrgChild2Controller.ts +++ b/src/controllers/OrgChild2Controller.ts @@ -152,6 +152,8 @@ export class OrgChild2Controller extends Controller { child2.createdFullName = request.user.name; child2.lastUpdateUserId = request.user.sub; child2.lastUpdateFullName = request.user.name; + child2.createdAt = new Date(); + child2.lastUpdatedAt = new Date(); child2.orgRootId = String(child1?.orgRootId); child2.orgRevisionId = String(child1?.orgRevisionId); child2.orgChild1Id = String(child1?.id); diff --git a/src/controllers/OrgChild3Controller.ts b/src/controllers/OrgChild3Controller.ts index 596fec4a..2cfe6aba 100644 --- a/src/controllers/OrgChild3Controller.ts +++ b/src/controllers/OrgChild3Controller.ts @@ -131,6 +131,8 @@ export class OrgChild3Controller { child3.createdFullName = request.user.name; child3.lastUpdateUserId = request.user.sub; child3.lastUpdateFullName = request.user.name; + child3.createdAt = new Date(); + child3.lastUpdatedAt = new Date(); child3.orgRootId = String(child2?.orgRootId); child3.orgChild1Id = String(child2?.orgChild1Id); child3.orgRevisionId = String(child2?.orgRevisionId); diff --git a/src/controllers/OrgChild4Controller.ts b/src/controllers/OrgChild4Controller.ts index 859607f2..51ff95b8 100644 --- a/src/controllers/OrgChild4Controller.ts +++ b/src/controllers/OrgChild4Controller.ts @@ -150,6 +150,8 @@ export class OrgChild4Controller extends Controller { child4.createdFullName = request.user.name; child4.lastUpdateUserId = request.user.sub; child4.lastUpdateFullName = request.user.name; + child4.createdAt = new Date(); + child4.lastUpdatedAt = new Date(); child4.orgRootId = String(child3?.orgRootId); child4.orgChild1Id = String(child3?.orgChild1Id); child4.orgChild2Id = String(child3?.orgChild2Id); @@ -189,7 +191,7 @@ export class OrgChild4Controller extends Controller { requestBody: UpdateOrgChild4, @Request() request: RequestWithUser, ) { - await new permission().PermissionUpdate(request, "SYS_ORG"); + await new permission().PermissionUpdate(request, "SYS_ORG"); const child3IdExits = await this.child3Repository.findOne({ where: { id: requestBody.orgChild3Id }, }); diff --git a/src/controllers/OrgRootController.ts b/src/controllers/OrgRootController.ts index 39a09ea4..f52bac96 100644 --- a/src/controllers/OrgRootController.ts +++ b/src/controllers/OrgRootController.ts @@ -152,6 +152,8 @@ export class OrgRootController extends Controller { orgRoot.createdFullName = request.user.name; orgRoot.lastUpdateUserId = request.user.sub; orgRoot.lastUpdateFullName = request.user.name; + orgRoot.createdAt = new Date(); + orgRoot.lastUpdatedAt = new Date(); orgRoot.orgRootOrder = order == null || order.orgRootOrder == null ? 1 : order.orgRootOrder + 1; await this.orgRootRepository.save(orgRoot); diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 1628437c..d3f43d1d 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -128,6 +128,8 @@ export class OrganizationController extends Controller { revision.createdFullName = request.user.name; revision.lastUpdateUserId = request.user.sub; revision.lastUpdateFullName = request.user.name; + revision.createdAt = new Date(); + revision.lastUpdatedAt = new Date(); await this.orgRevisionRepository.save(revision); if ( diff --git a/src/controllers/OrganizationDotnetController.ts b/src/controllers/OrganizationDotnetController.ts index f89b6ff3..5d0fb211 100644 --- a/src/controllers/OrganizationDotnetController.ts +++ b/src/controllers/OrganizationDotnetController.ts @@ -828,6 +828,7 @@ export class OrganizationDotnetController extends Controller { profile.dutyTimeEffectiveDate = body.effectiveDate; profile.lastUpdateUserId = req.user.sub; profile.lastUpdateFullName = req.user.name; + profile.lastUpdatedAt = new Date(); await this.profileRepo.save(profile); return new HttpSuccess(); } diff --git a/src/controllers/PosExecutiveController.ts b/src/controllers/PosExecutiveController.ts index dcab6724..bee1c224 100644 --- a/src/controllers/PosExecutiveController.ts +++ b/src/controllers/PosExecutiveController.ts @@ -79,6 +79,8 @@ export class PosExecutiveController extends Controller { posExecutive.createdFullName = request.user.name; posExecutive.lastUpdateUserId = request.user.sub; posExecutive.lastUpdateFullName = request.user.name; + posExecutive.createdAt = new Date(); + posExecutive.lastUpdatedAt = new Date(); await this.posExecutiveRepository.save(posExecutive); return new HttpSuccess(posExecutive.id); } @@ -138,6 +140,7 @@ export class PosExecutiveController extends Controller { posExecutive.posExecutiveName = requestBody.posExecutiveName; posExecutive.lastUpdateUserId = request.user.sub; posExecutive.lastUpdateFullName = request.user.name; + posExecutive.lastUpdatedAt = new Date(); // this.posExecutiveRepository.merge(posExecutive, requestBody); await this.posExecutiveRepository.save(posExecutive); return new HttpSuccess(); diff --git a/src/controllers/PosLevelController.ts b/src/controllers/PosLevelController.ts index eea43181..8563bc46 100644 --- a/src/controllers/PosLevelController.ts +++ b/src/controllers/PosLevelController.ts @@ -89,6 +89,8 @@ export class PosLevelController extends Controller { posLevel.createdFullName = request.user.name; posLevel.lastUpdateUserId = request.user.sub; posLevel.lastUpdateFullName = request.user.name; + posLevel.createdAt = new Date(); + posLevel.lastUpdatedAt = new Date(); await this.posLevelRepository.save(posLevel); return new HttpSuccess(posLevel); } @@ -144,6 +146,7 @@ export class PosLevelController extends Controller { posLevel.lastUpdateUserId = request.user.sub; posLevel.lastUpdateFullName = request.user.name; + posLevel.lastUpdatedAt = new Date(); this.posLevelRepository.merge(posLevel, requestBody); await this.posLevelRepository.save(posLevel); return new HttpSuccess(posLevel.id); @@ -158,11 +161,14 @@ export class PosLevelController extends Controller { */ @Delete("{id}") async deleteLevel(@Path() id: string) { - let result :any + let result: any; try { result = await this.posLevelRepository.delete({ id: id }); } catch { - throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับตำแหน่งนี้อยู่"); + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่สามารถลบได้เนื่องจากมีการใช้งานระดับตำแหน่งนี้อยู่", + ); } if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); diff --git a/src/controllers/PosMasterActController.ts b/src/controllers/PosMasterActController.ts index 4ca0766b..9575e0df 100644 --- a/src/controllers/PosMasterActController.ts +++ b/src/controllers/PosMasterActController.ts @@ -84,6 +84,8 @@ export class PosMasterActController extends Controller { posMasterAct.createdFullName = request.user.name; posMasterAct.lastUpdateUserId = request.user.sub; posMasterAct.lastUpdateFullName = request.user.name; + posMasterAct.createdAt = new Date(); + posMasterAct.lastUpdatedAt = new Date(); await this.posMasterActRepository.save(posMasterAct); return new HttpSuccess(posMasterAct); } diff --git a/src/controllers/PosTypeController.ts b/src/controllers/PosTypeController.ts index 8cd28488..b3228a1e 100644 --- a/src/controllers/PosTypeController.ts +++ b/src/controllers/PosTypeController.ts @@ -68,6 +68,8 @@ export class PosTypeController extends Controller { posType.createdFullName = request.user.name; posType.lastUpdateUserId = request.user.sub; posType.lastUpdateFullName = request.user.name; + posType.createdAt = new Date(); + posType.lastUpdatedAt = new Date(); await this.posTypeRepository.save(posType); return new HttpSuccess(posType); } @@ -104,6 +106,7 @@ export class PosTypeController extends Controller { } posType.lastUpdateUserId = request.user.sub; posType.lastUpdateFullName = request.user.name; + posType.lastUpdatedAt = new Date(); this.posTypeRepository.merge(posType, requestBody); await this.posTypeRepository.save(posType); return new HttpSuccess(posType.id); @@ -118,11 +121,14 @@ export class PosTypeController extends Controller { */ @Delete("{id}") async deleteType(@Path() id: string) { - let result :any + let result: any; try { result = await this.posTypeRepository.delete({ id: id }); } catch { - throw new HttpError( HttpStatusCode.NOT_FOUND, "ไม่สามารถลบได้เนื่องจากมีการใช้งานประเภทตำแหน่งนี้อยู่"); + throw new HttpError( + HttpStatusCode.NOT_FOUND, + "ไม่สามารถลบได้เนื่องจากมีการใช้งานประเภทตำแหน่งนี้อยู่", + ); } if (result.affected == undefined || result.affected <= 0) { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 8064a5f1..09dcca57 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -143,6 +143,8 @@ export class PositionController extends Controller { posDict.createdFullName = request.user.name; posDict.lastUpdateUserId = request.user.sub; posDict.lastUpdateFullName = request.user.name; + posDict.createdAt = new Date(); + posDict.lastUpdatedAt = new Date(); await this.posDictRepository.save(posDict); return new HttpSuccess(posDict.id); } @@ -222,6 +224,8 @@ export class PositionController extends Controller { posExecutive.createdFullName = request.user.name; posExecutive.lastUpdateUserId = request.user.sub; posExecutive.lastUpdateFullName = request.user.name; + posExecutive.createdAt = new Date(); + posExecutive.lastUpdatedAt = new Date(); await this.posExecutiveRepository.save(posExecutive); } @@ -246,6 +250,8 @@ export class PositionController extends Controller { posDict.createdFullName = request.user.name; posDict.lastUpdateUserId = request.user.sub; posDict.lastUpdateFullName = request.user.name; + posDict.createdAt = new Date(); + posDict.lastUpdatedAt = new Date(); await this.posDictRepository.save(posDict); return new HttpSuccess(posDict.id); } @@ -331,18 +337,19 @@ export class PositionController extends Controller { Object.assign(posDict, requestBody); posDict.lastUpdateUserId = request.user.sub; posDict.lastUpdateFullName = request.user.name; - (posDict.posDictName = requestBody.posDictName), - (posDict.posDictField = requestBody.posDictField), - (posDict.posTypeId = requestBody.posTypeId), - (posDict.posLevelId = requestBody.posLevelId), - (posDict.posExecutiveId = requestBody.posExecutiveId ? requestBody.posExecutiveId : null), - (posDict.posDictExecutiveField = requestBody.posDictExecutiveField - ? requestBody.posDictExecutiveField - : ""), - (posDict.posDictArea = requestBody.posDictArea ? requestBody.posDictArea : ""), - (posDict.isSpecial = requestBody.isSpecial), - // this.posDictRepository.merge(posDict, requestBody); - await this.posDictRepository.save(posDict); + posDict.lastUpdatedAt = new Date(); + posDict.posDictName = requestBody.posDictName; + posDict.posDictField = requestBody.posDictField; + posDict.posTypeId = requestBody.posTypeId; + posDict.posLevelId = requestBody.posLevelId; + posDict.posExecutiveId = requestBody.posExecutiveId ? requestBody.posExecutiveId : null; + posDict.posDictExecutiveField = requestBody.posDictExecutiveField + ? requestBody.posDictExecutiveField + : ""; + posDict.posDictArea = requestBody.posDictArea ? requestBody.posDictArea : ""; + posDict.isSpecial = requestBody.isSpecial; + // this.posDictRepository.merge(posDict, requestBody); + await this.posDictRepository.save(posDict); return new HttpSuccess(); } @@ -743,6 +750,8 @@ export class PositionController extends Controller { posMaster.createdFullName = request.user.name; posMaster.lastUpdateUserId = request.user.sub; posMaster.lastUpdateFullName = request.user.name; + posMaster.createdAt = new Date(); + posMaster.lastUpdatedAt = new Date(); await this.posMasterRepository.save(posMaster); await Promise.all( requestBody.positions.map(async (x: any) => { @@ -761,6 +770,8 @@ export class PositionController extends Controller { position.createdFullName = request.user.name; position.lastUpdateUserId = request.user.sub; position.lastUpdateFullName = request.user.name; + position.createdAt = new Date(); + position.lastUpdatedAt = new Date(); await this.positionRepository.save(position); }), ); @@ -948,6 +959,8 @@ export class PositionController extends Controller { posMaster.createdFullName = request.user.name; posMaster.lastUpdateUserId = request.user.sub; posMaster.lastUpdateFullName = request.user.name; + posMaster.createdAt = new Date(); + posMaster.lastUpdatedAt = new Date(); await this.posMasterRepository.save(posMaster); await this.positionRepository.delete({ posMasterId: posMaster.id }); @@ -970,6 +983,8 @@ export class PositionController extends Controller { position.createdFullName = request.user.name; position.lastUpdateUserId = request.user.sub; position.lastUpdateFullName = request.user.name; + position.createdAt = new Date(); + position.lastUpdatedAt = new Date(); await this.positionRepository.save(position); }), ); @@ -1407,7 +1422,10 @@ export class PositionController extends Controller { * */ @Post("sort") - async Sort(@Body() requestBody: { id: string; type: number; sortId: string[] }, @Request() request: RequestWithUser) { + async Sort( + @Body() requestBody: { id: string; type: number; sortId: string[] }, + @Request() request: RequestWithUser, + ) { await new permission().PermissionUpdate(request, "SYS_ORG"); switch (requestBody.type) { case 0: { @@ -2014,6 +2032,8 @@ export class PositionController extends Controller { posMaster.createdFullName = request.user.name; posMaster.lastUpdateUserId = request.user.sub; posMaster.lastUpdateFullName = request.user.name; + posMaster.createdAt = new Date(); + posMaster.lastUpdatedAt = new Date(); await this.posMasterRepository.save(posMaster); } }), @@ -2476,7 +2496,7 @@ export class PositionController extends Controller { @Post("profile") async createHolder( @Body() requestBody: { posMaster: string; position: string; profileId: string; isSit: boolean }, - @Request() request: RequestWithUser + @Request() request: RequestWithUser, ) { await new permission().PermissionUpdate(request, "SYS_ORG"); const dataMaster = await this.posMasterRepository.findOne({ @@ -2511,7 +2531,7 @@ export class PositionController extends Controller { */ @Post("profile/delete/{id}") async deleteHolder(@Path() id: string, @Request() request: RequestWithUser) { - await new permission().PermissionDelete(request, "SYS_ORG"); + await new permission().PermissionDelete(request, "SYS_ORG"); const dataMaster = await this.posMasterRepository.findOne({ where: { id: id }, relations: ["positions"], @@ -2540,8 +2560,11 @@ export class PositionController extends Controller { * */ @Post("dna") - async dna(@Body() requestBody: { draftPositionId: string; publishPositionId: string }, @Request() request: RequestWithUser) { - await new permission().PermissionUpdate(request, "SYS_ORG"); + async dna( + @Body() requestBody: { draftPositionId: string; publishPositionId: string }, + @Request() request: RequestWithUser, + ) { + await new permission().PermissionUpdate(request, "SYS_ORG"); const findDraft = await this.orgRevisionRepository.findOne({ where: { orgRevisionIsDraft: true, diff --git a/src/controllers/PrefixController.ts b/src/controllers/PrefixController.ts index 4f0cbedd..d85d6437 100644 --- a/src/controllers/PrefixController.ts +++ b/src/controllers/PrefixController.ts @@ -97,6 +97,8 @@ export class PrefixController extends Controller { _prefix.createdFullName = request.user.name; _prefix.lastUpdateUserId = request.user.sub; _prefix.lastUpdateFullName = request.user.name; + _prefix.createdAt = new Date(); + _prefix.lastUpdatedAt = new Date(); await this.prefixRepository.save(_prefix); return new HttpSuccess(); } @@ -128,6 +130,7 @@ export class PrefixController extends Controller { _prefix.lastUpdateUserId = request.user.sub; _prefix.lastUpdateFullName = request.user.name; + _prefix.lastUpdatedAt = new Date(); this.prefixRepository.merge(_prefix, requestBody); await this.prefixRepository.save(_prefix); return new HttpSuccess(); diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 91d3712c..a2126488 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -1268,6 +1268,8 @@ export class ProfileController extends Controller { profile.createdFullName = request.user.name; profile.lastUpdateUserId = request.user.sub; profile.lastUpdateFullName = request.user.name; + profile.createdAt = new Date(); + profile.lastUpdatedAt = new Date(); profile.dateRetire = calculateRetireDate(profile.birthDate); profile.dateRetireLaw = calculateRetireLaw(profile.birthDate); await this.profileRepo.save(profile); @@ -1310,6 +1312,8 @@ export class ProfileController extends Controller { profile.createdFullName = request.user.name; profile.lastUpdateUserId = request.user.sub; profile.lastUpdateFullName = request.user.name; + profile.createdAt = new Date(); + profile.lastUpdatedAt = new Date(); await this.profileRepo.save(profile); return new HttpSuccess(profile.id); } @@ -1346,6 +1350,8 @@ export class ProfileController extends Controller { profile.createdFullName = request.user.name; profile.lastUpdateUserId = request.user.sub; profile.lastUpdateFullName = request.user.name; + profile.createdAt = new Date(); + profile.lastUpdatedAt = new Date(); await this.profileRepo.save(profile); return new HttpSuccess(profile.id); } @@ -1386,6 +1392,7 @@ export class ProfileController extends Controller { profile.isProbation = false; profile.lastUpdateUserId = req.user.sub; profile.lastUpdateFullName = req.user.name; + profile.lastUpdatedAt = new Date(); const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, @@ -1470,6 +1477,7 @@ export class ProfileController extends Controller { _profile.dateLeave = dateLeave_; _profile.lastUpdateUserId = req.user.sub; _profile.lastUpdateFullName = req.user.name; + _profile.lastUpdatedAt = new Date(); const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, @@ -1550,6 +1558,7 @@ export class ProfileController extends Controller { _profile.dateLeave = dateLeave_; _profile.lastUpdateUserId = req.user.sub; _profile.lastUpdateFullName = req.user.name; + _profile.lastUpdatedAt = new Date(); const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, @@ -1630,6 +1639,7 @@ export class ProfileController extends Controller { _profile.dateLeave = dateLeave_; _profile.lastUpdateUserId = req.user.sub; _profile.lastUpdateFullName = req.user.name; + _profile.lastUpdatedAt = new Date(); const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, @@ -1726,6 +1736,7 @@ export class ProfileController extends Controller { _profile.dateLeave = dateLeave_; _profile.lastUpdateUserId = req.user.sub; _profile.lastUpdateFullName = req.user.name; + _profile.lastUpdatedAt = new Date(); const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { profileId: body.profileId, date: body.date, @@ -2245,6 +2256,7 @@ export class ProfileController extends Controller { profile.dateLeave = null_; profile.lastUpdateUserId = req.user.sub; profile.lastUpdateFullName = req.user.name; + profile.lastUpdatedAt = new Date(); // const profileSalary: ProfileSalary = Object.assign(new ProfileSalary(), { // profileId: body.profileId, // date: body.date, @@ -2387,6 +2399,7 @@ export class ProfileController extends Controller { Object.assign(record, body); record.lastUpdateUserId = request.user.sub; record.lastUpdateFullName = request.user.name; + record.lastUpdatedAt = new Date(); record.dateRetire = calculateRetireDate(record.birthDate); record.dateRetireLaw = calculateRetireLaw(record.birthDate); await this.profileRepo.save(record); @@ -5487,6 +5500,8 @@ export class ProfileController extends Controller { profile.createdFullName = request.user.name; profile.lastUpdateUserId = request.user.sub; profile.lastUpdateFullName = request.user.name; + profile.createdAt = new Date(); + profile.lastUpdatedAt = new Date(); // return new HttpSuccess(profile); await this.profileRepo.save(profile); return new HttpSuccess(profile.id); diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 419e1281..059e9206 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -612,6 +612,8 @@ export class ProfileEmployeeController extends Controller { profile.createdFullName = request.user.name; profile.lastUpdateUserId = request.user.sub; profile.lastUpdateFullName = request.user.name; + profile.createdAt = new Date(); + profile.lastUpdatedAt = new Date(); profile.dateRetire = calculateRetireDate(profile.birthDate); profile.dateRetireLaw = calculateRetireLaw(profile.birthDate); profile.citizenId = Extension.CheckCitizen(profile.citizenId); @@ -684,6 +686,7 @@ export class ProfileEmployeeController extends Controller { Object.assign(record, body); record.lastUpdateUserId = request.user.sub; record.lastUpdateFullName = request.user.name; + record.lastUpdatedAt = new Date(); record.dateRetire = calculateRetireDate(record.birthDate); record.dateRetireLaw = calculateRetireLaw(record.birthDate); record.citizenId = Extension.CheckCitizen(record.citizenId); @@ -2208,6 +2211,7 @@ export class ProfileEmployeeController extends Controller { profileEmp.lastUpdateUserId = request.user.sub; profileEmp.lastUpdateFullName = request.user.name; + profileEmp.lastUpdatedAt = new Date(); profileEmp.nodeTemp = String(body.node); profileEmp.nodeIdTemp = body.nodeId; profileEmp.orgRevisionIdTemp = body.orgRevisionId; @@ -2937,6 +2941,7 @@ export class ProfileEmployeeController extends Controller { history.createdAt = new Date(); profileEmp.lastUpdateUserId = request.user.sub; profileEmp.lastUpdateFullName = request.user.name; + profileEmp.lastUpdatedAt = new Date(); await Promise.all([ this.profileRepo.save(profileEmp), @@ -3190,11 +3195,14 @@ export class ProfileEmployeeController extends Controller { employment.lastUpdateUserId = request.user.sub; employment.lastUpdateFullName = request.user.name; + employment.lastUpdatedAt = new Date(); history.profileEmployeeEmploymentId = id; history.lastUpdateUserId = request.user.sub; history.lastUpdateFullName = request.user.name; history.createdUserId = request.user.sub; history.createdFullName = request.user.name; + history.createdAt = new Date(); + history.lastUpdatedAt = new Date(); await Promise.all([ this.employmentRepository.save(employment), diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 35911acc..3488ebb6 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -609,6 +609,8 @@ export class ProfileEmployeeTempController extends Controller { profile.createdFullName = request.user.name; profile.lastUpdateUserId = request.user.sub; profile.lastUpdateFullName = request.user.name; + profile.createdAt = new Date(); + profile.lastUpdatedAt = new Date(); profile.dateRetire = calculateRetireDate(profile.birthDate); profile.dateRetireLaw = calculateRetireLaw(profile.birthDate); profile.citizenId = Extension.CheckCitizen(profile.citizenId); @@ -678,6 +680,7 @@ export class ProfileEmployeeTempController extends Controller { Object.assign(record, body); record.lastUpdateUserId = request.user.sub; record.lastUpdateFullName = request.user.name; + record.lastUpdatedAt = new Date(); record.dateRetire = calculateRetireDate(record.birthDate); record.dateRetireLaw = calculateRetireLaw(record.birthDate); record.citizenId = Extension.CheckCitizen(record.citizenId); @@ -2192,6 +2195,7 @@ export class ProfileEmployeeTempController extends Controller { profileEmp.lastUpdateUserId = request.user.sub; profileEmp.lastUpdateFullName = request.user.name; + profileEmp.lastUpdatedAt = new Date(); profileEmp.nodeTemp = String(body.node); profileEmp.nodeIdTemp = body.nodeId; profileEmp.orgRevisionIdTemp = body.orgRevisionId; @@ -2916,8 +2920,10 @@ export class ProfileEmployeeTempController extends Controller { history.profileEmployeeId = profileEmployeeId; history.lastUpdateFullName = request.user.name; history.lastUpdateUserId = request.user.sub; + history.lastUpdatedAt = new Date(); profileEmp.lastUpdateUserId = request.user.sub; profileEmp.lastUpdateFullName = request.user.name; + profileEmp.lastUpdatedAt = new Date(); await Promise.all([ this.profileRepo.save(profileEmp), @@ -3084,6 +3090,8 @@ export class ProfileEmployeeTempController extends Controller { employment.createdFullName = request.user.name; employment.lastUpdateUserId = request.user.sub; employment.lastUpdateFullName = request.user.name; + employment.createdAt = new Date(); + employment.lastUpdatedAt = new Date(); await this.employmentRepository.save(employment); // if (employment) { // Object.assign(history, { ...employment, id: undefined }); @@ -3141,9 +3149,11 @@ export class ProfileEmployeeTempController extends Controller { employment.lastUpdateUserId = request.user.sub; employment.lastUpdateFullName = request.user.name; + employment.lastUpdatedAt = new Date(); history.profileEmployeeEmploymentId = id; history.lastUpdateFullName = request.user.name; history.lastUpdateUserId = request.user.sub; + history.lastUpdatedAt = new Date(); await Promise.all([ this.employmentRepository.save(employment), diff --git a/src/controllers/ProvinceController.ts b/src/controllers/ProvinceController.ts index 95b704fc..b53b9e65 100644 --- a/src/controllers/ProvinceController.ts +++ b/src/controllers/ProvinceController.ts @@ -96,6 +96,8 @@ export class ProvinceController extends Controller { _province.createdFullName = request.user.name; _province.lastUpdateUserId = request.user.sub; _province.lastUpdateFullName = request.user.name; + _province.createdAt = new Date(); + _province.lastUpdatedAt = new Date(); await this.provinceRepository.save(_province); return new HttpSuccess(); } @@ -127,6 +129,7 @@ export class ProvinceController extends Controller { _province.lastUpdateUserId = request.user.sub; _province.lastUpdateFullName = request.user.name; + _province.lastUpdatedAt = new Date(); this.provinceRepository.merge(_province, requestBody); await this.provinceRepository.save(_province); return new HttpSuccess(); diff --git a/src/controllers/RankController.ts b/src/controllers/RankController.ts index 32c002ba..fb8529c4 100644 --- a/src/controllers/RankController.ts +++ b/src/controllers/RankController.ts @@ -55,6 +55,8 @@ export class RankController extends Controller { rank.createdFullName = request.user.name; rank.lastUpdateUserId = request.user.sub; rank.lastUpdateFullName = request.user.name; + rank.createdAt = new Date(); + rank.lastUpdatedAt = new Date(); await this.rankRepository.save(rank); return new HttpSuccess(); } @@ -88,6 +90,7 @@ export class RankController extends Controller { rank.lastUpdateUserId = request.user.sub; rank.lastUpdateFullName = request.user.name; + rank.lastUpdatedAt = new Date(); this.rankRepository.merge(rank, requestBody); await this.rankRepository.save(rank); return new HttpSuccess(); diff --git a/src/controllers/RelationshipController.ts b/src/controllers/RelationshipController.ts index b43b5e3e..8a46e818 100644 --- a/src/controllers/RelationshipController.ts +++ b/src/controllers/RelationshipController.ts @@ -55,6 +55,8 @@ export class RelationshipController extends Controller { relationship.createdFullName = request.user.name; relationship.lastUpdateUserId = request.user.sub; relationship.lastUpdateFullName = request.user.name; + relationship.createdAt = new Date(); + relationship.lastUpdatedAt = new Date(); await this.relationshipRepository.save(relationship); return new HttpSuccess(); } @@ -88,6 +90,7 @@ export class RelationshipController extends Controller { relationship.lastUpdateUserId = request.user.sub; relationship.lastUpdateFullName = request.user.name; + relationship.lastUpdatedAt = new Date(); this.relationshipRepository.merge(relationship, requestBody); await this.relationshipRepository.save(relationship); return new HttpSuccess(); diff --git a/src/controllers/ReligionController.ts b/src/controllers/ReligionController.ts index b3fdbed7..c883b851 100644 --- a/src/controllers/ReligionController.ts +++ b/src/controllers/ReligionController.ts @@ -55,6 +55,8 @@ export class ReligionController extends Controller { religion.createdFullName = request.user.name; religion.lastUpdateUserId = request.user.sub; religion.lastUpdateFullName = request.user.name; + religion.createdAt = new Date(); + religion.lastUpdatedAt = new Date(); await this.religionRepository.save(religion); return new HttpSuccess(); } @@ -88,6 +90,7 @@ export class ReligionController extends Controller { religion.lastUpdateUserId = request.user.sub; religion.lastUpdateFullName = request.user.name; + religion.lastUpdatedAt = new Date(); this.religionRepository.merge(religion, requestBody); await this.religionRepository.save(religion); return new HttpSuccess(); diff --git a/src/controllers/SubDistrictController.ts b/src/controllers/SubDistrictController.ts index 68313eb2..7d355f23 100644 --- a/src/controllers/SubDistrictController.ts +++ b/src/controllers/SubDistrictController.ts @@ -107,6 +107,8 @@ export class SubDistrictController extends Controller { _subDistrict.createdFullName = request.user.name; _subDistrict.lastUpdateUserId = request.user.sub; _subDistrict.lastUpdateFullName = request.user.name; + _subDistrict.createdAt = new Date(); + _subDistrict.lastUpdatedAt = new Date(); await this.subDistrictRepository.save(_subDistrict); return new HttpSuccess(); } @@ -150,6 +152,7 @@ export class SubDistrictController extends Controller { _subDistrict.lastUpdateUserId = request.user.sub; _subDistrict.lastUpdateFullName = request.user.name; + _subDistrict.lastUpdatedAt = new Date(); this.subDistrictRepository.merge(_subDistrict, requestBody); await this.subDistrictRepository.save(_subDistrict); return new HttpSuccess(); From a2292d6048cea3b7825677f86a0cb3b124ca6ffb Mon Sep 17 00:00:00 2001 From: kittapath Date: Sun, 1 Sep 2024 22:44:23 +0700 Subject: [PATCH 3/3] add update time --- src/controllers/ProfileAbilityController.ts | 2 +- .../ProfileAbilityEmployeeController.ts | 2 +- .../ProfileAbilityEmployeeTempController.ts | 2 +- src/controllers/ProfileAddressController.ts | 64 +++++++++++++++---- .../ProfileAddressEmployeeController.ts | 64 +++++++++++++++---- .../ProfileAddressEmployeeTempController.ts | 64 +++++++++++++++---- .../ProfileAssessmentsController.ts | 2 +- .../ProfileAssessmentsEmployeeController.ts | 2 +- ...rofileAssessmentsEmployeeTempController.ts | 2 +- .../ProfileCertificateController.ts | 2 +- .../ProfileCertificateEmployeeController.ts | 2 +- ...rofileCertificateEmployeeTempController.ts | 2 +- .../ProfileChangeNameController.ts | 2 +- .../ProfileChangeNameEmployeeController.ts | 2 +- ...ProfileChangeNameEmployeeTempController.ts | 2 +- src/controllers/ProfileChildrenController.ts | 2 +- .../ProfileChildrenEmployeeController.ts | 2 +- .../ProfileChildrenEmployeeTempController.ts | 2 +- src/controllers/ProfileController.ts | 13 ++-- .../ProfileDevelopmentController.ts | 2 +- .../ProfileDevelopmentEmployeeController.ts | 2 +- ...rofileDevelopmentEmployeeTempController.ts | 2 +- .../ProfileDisciplineController.ts | 2 +- .../ProfileDisciplineEmployeeController.ts | 2 +- ...ProfileDisciplineEmployeeTempController.ts | 2 +- src/controllers/ProfileDutyController.ts | 2 +- .../ProfileDutyEmployeeController.ts | 2 +- .../ProfileDutyEmployeeTempController.ts | 2 +- .../ProfileEducationsController.ts | 2 +- .../ProfileEducationsEmployeeController.ts | 2 +- ...ProfileEducationsEmployeeTempController.ts | 2 +- src/controllers/ProfileEmployeeController.ts | 46 +++++++++++++ .../ProfileEmployeeTempController.ts | 2 +- .../ProfileGovernmentController.ts | 2 +- .../ProfileGovernmentEmployeeController.ts | 2 +- ...ProfileGovernmentEmployeeTempController.ts | 2 +- src/controllers/ProfileHonorController.ts | 2 +- .../ProfileHonorEmployeeController.ts | 2 +- .../ProfileHonorEmployeeTempController.ts | 2 +- src/controllers/ProfileInsigniaController.ts | 2 +- .../ProfileInsigniaEmployeeController.ts | 2 +- .../ProfileInsigniaEmployeeTempController.ts | 2 +- src/controllers/ProfileLeaveController.ts | 2 +- .../ProfileLeaveEmployeeController.ts | 2 +- .../ProfileLeaveEmployeeTempController.ts | 2 +- src/controllers/ProfileNopaidController.ts | 2 +- .../ProfileNopaidEmployeeController.ts | 2 +- .../ProfileNopaidEmployeeTempController.ts | 2 +- src/controllers/ProfileOtherController.ts | 2 +- .../ProfileOtherEmployeeController.ts | 2 +- .../ProfileOtherEmployeeTempController.ts | 2 +- src/controllers/ProfileSalaryController.ts | 2 +- .../ProfileSalaryEmployeeController.ts | 2 +- .../ProfileSalaryEmployeeTempController.ts | 2 +- src/controllers/ProfileTrainingController.ts | 2 +- .../ProfileTrainingEmployeeController.ts | 2 +- .../ProfileTrainingEmployeeTempController.ts | 2 +- 57 files changed, 257 insertions(+), 98 deletions(-) diff --git a/src/controllers/ProfileAbilityController.ts b/src/controllers/ProfileAbilityController.ts index c8351ef5..d92c96aa 100644 --- a/src/controllers/ProfileAbilityController.ts +++ b/src/controllers/ProfileAbilityController.ts @@ -132,7 +132,7 @@ export class ProfileAbilityController extends Controller { const history = new ProfileAbilityHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileAbilityId = abilityId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAbilityEmployeeController.ts b/src/controllers/ProfileAbilityEmployeeController.ts index dba3c1be..8963c260 100644 --- a/src/controllers/ProfileAbilityEmployeeController.ts +++ b/src/controllers/ProfileAbilityEmployeeController.ts @@ -140,7 +140,7 @@ export class ProfileAbilityEmployeeController extends Controller { const history = new ProfileAbilityHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileAbilityId = abilityId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAbilityEmployeeTempController.ts b/src/controllers/ProfileAbilityEmployeeTempController.ts index 93fdb67b..949eaf90 100644 --- a/src/controllers/ProfileAbilityEmployeeTempController.ts +++ b/src/controllers/ProfileAbilityEmployeeTempController.ts @@ -132,7 +132,7 @@ export class ProfileAbilityEmployeeTempController extends Controller { const history = new ProfileAbilityHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileAbilityId = abilityId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAddressController.ts b/src/controllers/ProfileAddressController.ts index c70253a2..44f1c447 100644 --- a/src/controllers/ProfileAddressController.ts +++ b/src/controllers/ProfileAddressController.ts @@ -34,7 +34,6 @@ export class ProfileAddressController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", - "createdAt", ], order: { createdAt: "ASC" }, }); @@ -66,7 +65,6 @@ export class ProfileAddressController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", - "createdAt", ], }); if (!getProfileAddress) { @@ -88,12 +86,32 @@ export class ProfileAddressController extends Controller { } const record = await this.profileAddressHistoryRepo.find({ where: { profileId: profile.id }, - order: { createdAt: "DESC" }, + relations: [ + "registrationProvince", + "registrationDistrict", + "registrationSubDistrict", + "currentProvince", + "currentDistrict", + "currentSubDistrict", + ], + order: { createdAt: "ASC" }, }); - if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - return new HttpSuccess(record); + const _record = record.map((item) => ({ + id: item.id, + currentAddress: item.currentAddress, + registrationAddress: item.registrationAddress, + currentZipCode: item.currentZipCode, + registrationZipCode: item.registrationZipCode, + currentProvince: item.currentProvince?.name ?? null, + registrationProvince: item.registrationProvince?.name ?? null, + currentDistrict: item.currentDistrict?.name ?? null, + registrationDistrict: item.registrationDistrict?.name ?? null, + currentSubDistrict: item.currentSubDistrict?.name ?? null, + registrationSubDistrict: item.registrationSubDistrict?.name ?? null, + lastUpdatedAt: item.lastUpdatedAt, + lastUpdateFullName: item.lastUpdateFullName, + })); + return new HttpSuccess(_record); } /** @@ -109,12 +127,32 @@ export class ProfileAddressController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId); const record = await this.profileAddressHistoryRepo.find({ where: { profileId: profileId }, - order: { createdAt: "DESC" }, + relations: [ + "registrationProvince", + "registrationDistrict", + "registrationSubDistrict", + "currentProvince", + "currentDistrict", + "currentSubDistrict", + ], + order: { createdAt: "ASC" }, }); - if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - return new HttpSuccess(record); + const _record = record.map((item) => ({ + id: item.id, + currentAddress: item.currentAddress, + registrationAddress: item.registrationAddress, + currentZipCode: item.currentZipCode, + registrationZipCode: item.registrationZipCode, + currentProvince: item.currentProvince?.name ?? null, + registrationProvince: item.registrationProvince?.name ?? null, + currentDistrict: item.currentDistrict?.name ?? null, + registrationDistrict: item.registrationDistrict?.name ?? null, + currentSubDistrict: item.currentSubDistrict?.name ?? null, + registrationSubDistrict: item.registrationSubDistrict?.name ?? null, + lastUpdatedAt: item.lastUpdatedAt, + lastUpdateFullName: item.lastUpdateFullName, + })); + return new HttpSuccess(_record); } /** @@ -135,7 +173,7 @@ export class ProfileAddressController extends Controller { const history = new ProfileAddressHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileId = profileId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAddressEmployeeController.ts b/src/controllers/ProfileAddressEmployeeController.ts index bb37895c..3e6bce14 100644 --- a/src/controllers/ProfileAddressEmployeeController.ts +++ b/src/controllers/ProfileAddressEmployeeController.ts @@ -35,7 +35,6 @@ export class ProfileAddressEmployeeController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", - "createdAt", ], order: { createdAt: "ASC" }, }); @@ -70,7 +69,6 @@ export class ProfileAddressEmployeeController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", - "createdAt", ], }); if (!getProfileAddress) { @@ -92,12 +90,32 @@ export class ProfileAddressEmployeeController extends Controller { } const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profile.id }, - order: { createdAt: "DESC" }, + relations: [ + "registrationProvince", + "registrationDistrict", + "registrationSubDistrict", + "currentProvince", + "currentDistrict", + "currentSubDistrict", + ], + order: { createdAt: "ASC" }, }); - if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - return new HttpSuccess(record); + const _record = record.map((item) => ({ + id: item.id, + currentAddress: item.currentAddress, + registrationAddress: item.registrationAddress, + currentZipCode: item.currentZipCode, + registrationZipCode: item.registrationZipCode, + currentProvince: item.currentProvince?.name ?? null, + registrationProvince: item.registrationProvince?.name ?? null, + currentDistrict: item.currentDistrict?.name ?? null, + registrationDistrict: item.registrationDistrict?.name ?? null, + currentSubDistrict: item.currentSubDistrict?.name ?? null, + registrationSubDistrict: item.registrationSubDistrict?.name ?? null, + lastUpdatedAt: item.lastUpdatedAt, + lastUpdateFullName: item.lastUpdateFullName, + })); + return new HttpSuccess(_record); } /** @@ -113,12 +131,32 @@ export class ProfileAddressEmployeeController extends Controller { await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId); const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profileId }, - order: { createdAt: "DESC" }, + relations: [ + "registrationProvince", + "registrationDistrict", + "registrationSubDistrict", + "currentProvince", + "currentDistrict", + "currentSubDistrict", + ], + order: { createdAt: "ASC" }, }); - if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - return new HttpSuccess(record); + const _record = record.map((item) => ({ + id: item.id, + currentAddress: item.currentAddress, + registrationAddress: item.registrationAddress, + currentZipCode: item.currentZipCode, + registrationZipCode: item.registrationZipCode, + currentProvince: item.currentProvince?.name ?? null, + registrationProvince: item.registrationProvince?.name ?? null, + currentDistrict: item.currentDistrict?.name ?? null, + registrationDistrict: item.registrationDistrict?.name ?? null, + currentSubDistrict: item.currentSubDistrict?.name ?? null, + registrationSubDistrict: item.registrationSubDistrict?.name ?? null, + lastUpdatedAt: item.lastUpdatedAt, + lastUpdateFullName: item.lastUpdateFullName, + })); + return new HttpSuccess(_record); } /** @@ -139,7 +177,7 @@ export class ProfileAddressEmployeeController extends Controller { const history = new ProfileAddressHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEmployeeId = profileId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAddressEmployeeTempController.ts b/src/controllers/ProfileAddressEmployeeTempController.ts index 18dab2db..1aaca55f 100644 --- a/src/controllers/ProfileAddressEmployeeTempController.ts +++ b/src/controllers/ProfileAddressEmployeeTempController.ts @@ -35,7 +35,6 @@ export class ProfileAddressEmployeeTempController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", - "createdAt", ], order: { createdAt: "ASC" }, }); @@ -70,7 +69,6 @@ export class ProfileAddressEmployeeTempController extends Controller { "currentDistrictId", "currentSubDistrictId", "currentZipCode", - "createdAt", ], }); if (!getProfileAddress) { @@ -92,12 +90,32 @@ export class ProfileAddressEmployeeTempController extends Controller { } const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profile.id }, - order: { createdAt: "DESC" }, + relations: [ + "registrationProvince", + "registrationDistrict", + "registrationSubDistrict", + "currentProvince", + "currentDistrict", + "currentSubDistrict", + ], + order: { createdAt: "ASC" }, }); - if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - return new HttpSuccess(record); + const _record = record.map((item) => ({ + id: item.id, + currentAddress: item.currentAddress, + registrationAddress: item.registrationAddress, + currentZipCode: item.currentZipCode, + registrationZipCode: item.registrationZipCode, + currentProvince: item.currentProvince?.name ?? null, + registrationProvince: item.registrationProvince?.name ?? null, + currentDistrict: item.currentDistrict?.name ?? null, + registrationDistrict: item.registrationDistrict?.name ?? null, + currentSubDistrict: item.currentSubDistrict?.name ?? null, + registrationSubDistrict: item.registrationSubDistrict?.name ?? null, + lastUpdatedAt: item.lastUpdatedAt, + lastUpdateFullName: item.lastUpdateFullName, + })); + return new HttpSuccess(_record); } /** @@ -113,12 +131,32 @@ export class ProfileAddressEmployeeTempController extends Controller { await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP"); const record = await this.profileAddressHistoryRepo.find({ where: { profileEmployeeId: profileId }, - order: { createdAt: "DESC" }, + relations: [ + "registrationProvince", + "registrationDistrict", + "registrationSubDistrict", + "currentProvince", + "currentDistrict", + "currentSubDistrict", + ], + order: { createdAt: "ASC" }, }); - if (!record) { - throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); - } - return new HttpSuccess(record); + const _record = record.map((item) => ({ + id: item.id, + currentAddress: item.currentAddress, + registrationAddress: item.registrationAddress, + currentZipCode: item.currentZipCode, + registrationZipCode: item.registrationZipCode, + currentProvince: item.currentProvince?.name ?? null, + registrationProvince: item.registrationProvince?.name ?? null, + currentDistrict: item.currentDistrict?.name ?? null, + registrationDistrict: item.registrationDistrict?.name ?? null, + currentSubDistrict: item.currentSubDistrict?.name ?? null, + registrationSubDistrict: item.registrationSubDistrict?.name ?? null, + lastUpdatedAt: item.lastUpdatedAt, + lastUpdateFullName: item.lastUpdateFullName, + })); + return new HttpSuccess(_record); } /** @@ -139,7 +177,7 @@ export class ProfileAddressEmployeeTempController extends Controller { const history = new ProfileAddressHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEmployeeId = profileId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAssessmentsController.ts b/src/controllers/ProfileAssessmentsController.ts index ba3d6ed3..681de617 100644 --- a/src/controllers/ProfileAssessmentsController.ts +++ b/src/controllers/ProfileAssessmentsController.ts @@ -136,7 +136,7 @@ export class ProfileAssessmentsController extends Controller { const history = new ProfileAssessmentHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileAssessmentId = assessmentId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAssessmentsEmployeeController.ts b/src/controllers/ProfileAssessmentsEmployeeController.ts index 301e7ae7..dd7b7b41 100644 --- a/src/controllers/ProfileAssessmentsEmployeeController.ts +++ b/src/controllers/ProfileAssessmentsEmployeeController.ts @@ -141,7 +141,7 @@ export class ProfileAssessmentsEmployeeController extends Controller { const history = new ProfileAssessmentHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileAssessmentId = assessmentId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileAssessmentsEmployeeTempController.ts b/src/controllers/ProfileAssessmentsEmployeeTempController.ts index 08e843a4..ae7a834f 100644 --- a/src/controllers/ProfileAssessmentsEmployeeTempController.ts +++ b/src/controllers/ProfileAssessmentsEmployeeTempController.ts @@ -135,7 +135,7 @@ export class ProfileAssessmentsEmployeeTempController extends Controller { const history = new ProfileAssessmentHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileAssessmentId = assessmentId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileCertificateController.ts b/src/controllers/ProfileCertificateController.ts index 4d73c67a..18a8aba0 100644 --- a/src/controllers/ProfileCertificateController.ts +++ b/src/controllers/ProfileCertificateController.ts @@ -121,7 +121,7 @@ export class ProfileCertificateController extends Controller { const history = new ProfileCertificateHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileCertificateId = certificateId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileCertificateEmployeeController.ts b/src/controllers/ProfileCertificateEmployeeController.ts index e5f3bd03..3c4a2aeb 100644 --- a/src/controllers/ProfileCertificateEmployeeController.ts +++ b/src/controllers/ProfileCertificateEmployeeController.ts @@ -128,7 +128,7 @@ export class ProfileCertificateEmployeeController extends Controller { const history = new ProfileCertificateHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileCertificateId = certificateId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileCertificateEmployeeTempController.ts b/src/controllers/ProfileCertificateEmployeeTempController.ts index 010948f9..ae494b85 100644 --- a/src/controllers/ProfileCertificateEmployeeTempController.ts +++ b/src/controllers/ProfileCertificateEmployeeTempController.ts @@ -119,7 +119,7 @@ export class ProfileCertificateEmployeeTempController extends Controller { const history = new ProfileCertificateHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileCertificateId = certificateId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileChangeNameController.ts b/src/controllers/ProfileChangeNameController.ts index bf2aa75a..85100d84 100644 --- a/src/controllers/ProfileChangeNameController.ts +++ b/src/controllers/ProfileChangeNameController.ts @@ -131,7 +131,7 @@ export class ProfileChangeNameController extends Controller { const history = new ProfileChangeNameHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileChangeNameId = changeNameId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileChangeNameEmployeeController.ts b/src/controllers/ProfileChangeNameEmployeeController.ts index 25c1357c..8accbad2 100644 --- a/src/controllers/ProfileChangeNameEmployeeController.ts +++ b/src/controllers/ProfileChangeNameEmployeeController.ts @@ -139,7 +139,7 @@ export class ProfileChangeNameEmployeeController extends Controller { const history = new ProfileChangeNameHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileChangeNameId = changeNameId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileChangeNameEmployeeTempController.ts b/src/controllers/ProfileChangeNameEmployeeTempController.ts index 1ea57a8e..69e27fd7 100644 --- a/src/controllers/ProfileChangeNameEmployeeTempController.ts +++ b/src/controllers/ProfileChangeNameEmployeeTempController.ts @@ -130,7 +130,7 @@ export class ProfileChangeNameEmployeeTempController extends Controller { const history = new ProfileChangeNameHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileChangeNameId = changeNameId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileChildrenController.ts b/src/controllers/ProfileChildrenController.ts index 61cd3cab..b9b010bd 100644 --- a/src/controllers/ProfileChildrenController.ts +++ b/src/controllers/ProfileChildrenController.ts @@ -112,7 +112,7 @@ export class ProfileChildrenController extends Controller { const history = new ProfileChildrenHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId)); history.profileChildrenId = record.id; diff --git a/src/controllers/ProfileChildrenEmployeeController.ts b/src/controllers/ProfileChildrenEmployeeController.ts index f0b8acde..5c2510fc 100644 --- a/src/controllers/ProfileChildrenEmployeeController.ts +++ b/src/controllers/ProfileChildrenEmployeeController.ts @@ -124,7 +124,7 @@ export class ProfileChildrenEmployeeController extends Controller { const history = new ProfileChildrenHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId)); history.profileChildrenId = record.id; diff --git a/src/controllers/ProfileChildrenEmployeeTempController.ts b/src/controllers/ProfileChildrenEmployeeTempController.ts index e0e63daa..9a6ce934 100644 --- a/src/controllers/ProfileChildrenEmployeeTempController.ts +++ b/src/controllers/ProfileChildrenEmployeeTempController.ts @@ -113,7 +113,7 @@ export class ProfileChildrenEmployeeTempController extends Controller { const history = new ProfileChildrenHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); record.childrenCitizenId = Extension.CheckCitizen(String(record.childrenCitizenId)); history.profileChildrenId = record.id; diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index a2126488..08142f0d 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -2388,6 +2388,12 @@ export class ProfileController extends Controller { if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้"); + Object.assign(record, body); + record.lastUpdateUserId = request.user.sub; + record.lastUpdateFullName = request.user.name; + record.lastUpdatedAt = new Date(); + record.dateRetire = calculateRetireDate(record.birthDate); + record.dateRetireLaw = calculateRetireLaw(record.birthDate); await this.profileHistoryRepo.save( Object.assign(new ProfileHistory(), { ...record, @@ -2395,13 +2401,6 @@ export class ProfileController extends Controller { id: undefined, }), ); - - Object.assign(record, body); - record.lastUpdateUserId = request.user.sub; - record.lastUpdateFullName = request.user.name; - record.lastUpdatedAt = new Date(); - record.dateRetire = calculateRetireDate(record.birthDate); - record.dateRetireLaw = calculateRetireLaw(record.birthDate); await this.profileRepo.save(record); if (record != null && record.keycloak != null) { diff --git a/src/controllers/ProfileDevelopmentController.ts b/src/controllers/ProfileDevelopmentController.ts index 11deb174..46d16d6d 100644 --- a/src/controllers/ProfileDevelopmentController.ts +++ b/src/controllers/ProfileDevelopmentController.ts @@ -120,7 +120,7 @@ export class ProfileDevelopmentController extends Controller { const history = new ProfileDevelopmentHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDevelopmentId = developmentId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDevelopmentEmployeeController.ts b/src/controllers/ProfileDevelopmentEmployeeController.ts index 4089b8a4..b93a5608 100644 --- a/src/controllers/ProfileDevelopmentEmployeeController.ts +++ b/src/controllers/ProfileDevelopmentEmployeeController.ts @@ -128,7 +128,7 @@ export class ProfileDevelopmentEmployeeController extends Controller { const history = new ProfileDevelopmentHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDevelopmentId = developmentId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDevelopmentEmployeeTempController.ts b/src/controllers/ProfileDevelopmentEmployeeTempController.ts index 425232a4..b92c1149 100644 --- a/src/controllers/ProfileDevelopmentEmployeeTempController.ts +++ b/src/controllers/ProfileDevelopmentEmployeeTempController.ts @@ -119,7 +119,7 @@ export class ProfileDevelopmentEmployeeTempController extends Controller { const history = new ProfileDevelopmentHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDevelopmentId = developmentId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDisciplineController.ts b/src/controllers/ProfileDisciplineController.ts index d9acf0e4..510b8a69 100644 --- a/src/controllers/ProfileDisciplineController.ts +++ b/src/controllers/ProfileDisciplineController.ts @@ -129,7 +129,7 @@ export class ProfileDisciplineController extends Controller { const history = new ProfileDisciplineHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDisciplineId = disciplineId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDisciplineEmployeeController.ts b/src/controllers/ProfileDisciplineEmployeeController.ts index 3beb847b..9463641e 100644 --- a/src/controllers/ProfileDisciplineEmployeeController.ts +++ b/src/controllers/ProfileDisciplineEmployeeController.ts @@ -136,7 +136,7 @@ export class ProfileDisciplineEmployeeController extends Controller { const history = new ProfileDisciplineHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDisciplineId = disciplineId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDisciplineEmployeeTempController.ts b/src/controllers/ProfileDisciplineEmployeeTempController.ts index c459ed03..18213655 100644 --- a/src/controllers/ProfileDisciplineEmployeeTempController.ts +++ b/src/controllers/ProfileDisciplineEmployeeTempController.ts @@ -127,7 +127,7 @@ export class ProfileDisciplineEmployeeTempController extends Controller { const history = new ProfileDisciplineHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDisciplineId = disciplineId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDutyController.ts b/src/controllers/ProfileDutyController.ts index f97c7e5d..6c909495 100644 --- a/src/controllers/ProfileDutyController.ts +++ b/src/controllers/ProfileDutyController.ts @@ -111,7 +111,7 @@ export class ProfileDutyController extends Controller { const history = new ProfileDutyHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDutyId = dutyId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDutyEmployeeController.ts b/src/controllers/ProfileDutyEmployeeController.ts index 72f2a65e..f34b6631 100644 --- a/src/controllers/ProfileDutyEmployeeController.ts +++ b/src/controllers/ProfileDutyEmployeeController.ts @@ -119,7 +119,7 @@ export class ProfileDutyEmployeeController extends Controller { const history = new ProfileDutyHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDutyId = dutyId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileDutyEmployeeTempController.ts b/src/controllers/ProfileDutyEmployeeTempController.ts index 3c65f345..f39bd693 100644 --- a/src/controllers/ProfileDutyEmployeeTempController.ts +++ b/src/controllers/ProfileDutyEmployeeTempController.ts @@ -110,7 +110,7 @@ export class ProfileDutyEmployeeTempController extends Controller { const history = new ProfileDutyHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileDutyId = dutyId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileEducationsController.ts b/src/controllers/ProfileEducationsController.ts index 0e8bc208..d7131240 100644 --- a/src/controllers/ProfileEducationsController.ts +++ b/src/controllers/ProfileEducationsController.ts @@ -133,7 +133,7 @@ export class ProfileEducationsController extends Controller { const history = new ProfileEducationHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEducationId = educationId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileEducationsEmployeeController.ts b/src/controllers/ProfileEducationsEmployeeController.ts index 06789f3c..179be788 100644 --- a/src/controllers/ProfileEducationsEmployeeController.ts +++ b/src/controllers/ProfileEducationsEmployeeController.ts @@ -143,7 +143,7 @@ export class ProfileEducationsEmployeeController extends Controller { const history = new ProfileEducationHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEducationId = educationId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileEducationsEmployeeTempController.ts b/src/controllers/ProfileEducationsEmployeeTempController.ts index a24c6dda..103e6e92 100644 --- a/src/controllers/ProfileEducationsEmployeeTempController.ts +++ b/src/controllers/ProfileEducationsEmployeeTempController.ts @@ -131,7 +131,7 @@ export class ProfileEducationsEmployeeTempController extends Controller { const history = new ProfileEducationHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEducationId = educationId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 059e9206..9069ccc9 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -1234,6 +1234,12 @@ export class ProfileEmployeeController extends Controller { .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount(); + const findRevision = await this.orgRevisionRepo.findOne({ + where: { orgRevisionIsCurrent: true }, + }); + if (!findRevision) { + throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision"); + } const data = await Promise.all( record.map((_data) => { const shortName = @@ -1256,6 +1262,45 @@ export class ProfileEmployeeController extends Controller { : _data.profileEmployeeEmployment.reduce((latest, current) => { return latest.date > current.date ? latest : current; }).date; + const root = + _data.current_holders.length == 0 || + (_data.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null && + _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null) + ? null + : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot; + + const child1 = + _data.current_holders == null || + _data.current_holders.length == 0 || + _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1; + + const child2 = + _data.current_holders == null || + _data.current_holders.length == 0 || + _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2; + + const child3 = + _data.current_holders == null || + _data.current_holders.length == 0 || + _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3; + + const child4 = + _data.current_holders == null || + _data.current_holders.length == 0 || + _data.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null + ? null + : _data.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4; + + let _child1 = child1 == null ? "" : `${child1.orgChild1Name}/`; + let _child2 = child2 == null ? "" : `${child2.orgChild2Name}/`; + let _child3 = child3 == null ? "" : `${child3.orgChild3Name}/`; + let _child4 = child4 == null ? "" : `${child4.orgChild4Name}/`; return { id: _data.id, prefix: _data.prefix, @@ -1335,6 +1380,7 @@ export class ProfileEmployeeController extends Controller { child4: _data.child4Temp ? _data.child4Temp : null, child4Id: _data.child4IdTemp ? _data.child4IdTemp : null, child4ShortName: _data.child4ShortNameTemp ? _data.child4ShortNameTemp : null, + org: `${_child4}${_child3}${_child2}${_child1}${root?.orgRootName ?? ""}`, }; }), ); diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 3488ebb6..6dcfc92f 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -3144,8 +3144,8 @@ export class ProfileEmployeeTempController extends Controller { if (!employment) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); const history = new ProfileEmployeeEmploymentHistory(); - Object.assign(history, { ...employment, id: undefined }); Object.assign(employment, body); + Object.assign(history, { ...employment, id: undefined }); employment.lastUpdateUserId = request.user.sub; employment.lastUpdateFullName = request.user.name; diff --git a/src/controllers/ProfileGovernmentController.ts b/src/controllers/ProfileGovernmentController.ts index 6ca9bec5..2a4645a5 100644 --- a/src/controllers/ProfileGovernmentController.ts +++ b/src/controllers/ProfileGovernmentController.ts @@ -389,7 +389,7 @@ export class ProfileGovernmentHistoryController extends Controller { const history = new ProfileGovernment(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileId = profileId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileGovernmentEmployeeController.ts b/src/controllers/ProfileGovernmentEmployeeController.ts index 5b6256ba..7aac86c9 100644 --- a/src/controllers/ProfileGovernmentEmployeeController.ts +++ b/src/controllers/ProfileGovernmentEmployeeController.ts @@ -371,7 +371,7 @@ export class ProfileGovernmentEmployeeController extends Controller { const history = new ProfileGovernment(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEmployeeId = profileEmployeeId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileGovernmentEmployeeTempController.ts b/src/controllers/ProfileGovernmentEmployeeTempController.ts index ee9b7c27..57c223a0 100644 --- a/src/controllers/ProfileGovernmentEmployeeTempController.ts +++ b/src/controllers/ProfileGovernmentEmployeeTempController.ts @@ -372,7 +372,7 @@ export class ProfileGovernmentEmployeeTempController extends Controller { const history = new ProfileGovernment(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileEmployeeId = profileEmployeeId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileHonorController.ts b/src/controllers/ProfileHonorController.ts index 17711b4e..ac93bc40 100644 --- a/src/controllers/ProfileHonorController.ts +++ b/src/controllers/ProfileHonorController.ts @@ -136,7 +136,7 @@ export class ProfileHonorController extends Controller { const history = new ProfileHonorHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileHonorId = honorId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileHonorEmployeeController.ts b/src/controllers/ProfileHonorEmployeeController.ts index e038665f..f992d526 100644 --- a/src/controllers/ProfileHonorEmployeeController.ts +++ b/src/controllers/ProfileHonorEmployeeController.ts @@ -148,7 +148,7 @@ export class ProfileHonorEmployeeController extends Controller { const history = new ProfileHonorHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileHonorId = honorId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileHonorEmployeeTempController.ts b/src/controllers/ProfileHonorEmployeeTempController.ts index c59c662a..075e31ee 100644 --- a/src/controllers/ProfileHonorEmployeeTempController.ts +++ b/src/controllers/ProfileHonorEmployeeTempController.ts @@ -138,7 +138,7 @@ export class ProfileHonorEmployeeTempController extends Controller { const history = new ProfileHonorHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileHonorId = honorId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileInsigniaController.ts b/src/controllers/ProfileInsigniaController.ts index 048e0230..8d2d34a0 100644 --- a/src/controllers/ProfileInsigniaController.ts +++ b/src/controllers/ProfileInsigniaController.ts @@ -148,7 +148,7 @@ export class ProfileInsigniaController extends Controller { const history = new ProfileInsigniaHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileInsigniaId = insigniaId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileInsigniaEmployeeController.ts b/src/controllers/ProfileInsigniaEmployeeController.ts index e00202a9..b2d4a613 100644 --- a/src/controllers/ProfileInsigniaEmployeeController.ts +++ b/src/controllers/ProfileInsigniaEmployeeController.ts @@ -159,7 +159,7 @@ export class ProfileInsigniaEmployeeController extends Controller { const history = new ProfileInsigniaHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileInsigniaId = insigniaId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileInsigniaEmployeeTempController.ts b/src/controllers/ProfileInsigniaEmployeeTempController.ts index 298bdf5b..fc22ca48 100644 --- a/src/controllers/ProfileInsigniaEmployeeTempController.ts +++ b/src/controllers/ProfileInsigniaEmployeeTempController.ts @@ -150,7 +150,7 @@ export class ProfileInsigniaEmployeeTempController extends Controller { const history = new ProfileInsigniaHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileInsigniaId = insigniaId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileLeaveController.ts b/src/controllers/ProfileLeaveController.ts index d7ff9617..843cc39b 100644 --- a/src/controllers/ProfileLeaveController.ts +++ b/src/controllers/ProfileLeaveController.ts @@ -221,7 +221,7 @@ export class ProfileLeaveController extends Controller { const history = new ProfileLeaveHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileLeaveId = leaveId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileLeaveEmployeeController.ts b/src/controllers/ProfileLeaveEmployeeController.ts index e25395c5..f4858bb2 100644 --- a/src/controllers/ProfileLeaveEmployeeController.ts +++ b/src/controllers/ProfileLeaveEmployeeController.ts @@ -153,7 +153,7 @@ export class ProfileLeaveEmployeeController extends Controller { const history = new ProfileLeaveHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileLeaveId = leaveId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileLeaveEmployeeTempController.ts b/src/controllers/ProfileLeaveEmployeeTempController.ts index 2ea9c4d4..831480a8 100644 --- a/src/controllers/ProfileLeaveEmployeeTempController.ts +++ b/src/controllers/ProfileLeaveEmployeeTempController.ts @@ -143,7 +143,7 @@ export class ProfileLeaveEmployeeTempController extends Controller { const history = new ProfileLeaveHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileLeaveId = leaveId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileNopaidController.ts b/src/controllers/ProfileNopaidController.ts index 27167e49..e934bda9 100644 --- a/src/controllers/ProfileNopaidController.ts +++ b/src/controllers/ProfileNopaidController.ts @@ -111,7 +111,7 @@ export class ProfileNopaidController extends Controller { const history = new ProfileNopaidHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileNopaidId = nopaidId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileNopaidEmployeeController.ts b/src/controllers/ProfileNopaidEmployeeController.ts index 08dd320e..a337ca7a 100644 --- a/src/controllers/ProfileNopaidEmployeeController.ts +++ b/src/controllers/ProfileNopaidEmployeeController.ts @@ -119,7 +119,7 @@ export class ProfileNopaidEmployeeController extends Controller { const history = new ProfileNopaidHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileNopaidId = nopaidId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileNopaidEmployeeTempController.ts b/src/controllers/ProfileNopaidEmployeeTempController.ts index 6e7d4396..aad9f443 100644 --- a/src/controllers/ProfileNopaidEmployeeTempController.ts +++ b/src/controllers/ProfileNopaidEmployeeTempController.ts @@ -117,7 +117,7 @@ export class ProfileNopaidEmployeeTempController extends Controller { const history = new ProfileNopaidHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileNopaidId = nopaidId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileOtherController.ts b/src/controllers/ProfileOtherController.ts index 95ddd931..14e3e3a4 100644 --- a/src/controllers/ProfileOtherController.ts +++ b/src/controllers/ProfileOtherController.ts @@ -112,7 +112,7 @@ export class ProfileOtherController extends Controller { const history = new ProfileOtherHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileOtherId = otherId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileOtherEmployeeController.ts b/src/controllers/ProfileOtherEmployeeController.ts index 12c5d446..4b4c7033 100644 --- a/src/controllers/ProfileOtherEmployeeController.ts +++ b/src/controllers/ProfileOtherEmployeeController.ts @@ -123,7 +123,7 @@ export class ProfileOtherEmployeeController extends Controller { const history = new ProfileOtherHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileOtherId = otherId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileOtherEmployeeTempController.ts b/src/controllers/ProfileOtherEmployeeTempController.ts index d8aa8e12..647e01cf 100644 --- a/src/controllers/ProfileOtherEmployeeTempController.ts +++ b/src/controllers/ProfileOtherEmployeeTempController.ts @@ -115,7 +115,7 @@ export class ProfileOtherEmployeeTempController extends Controller { const history = new ProfileOtherHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileOtherId = otherId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileSalaryController.ts b/src/controllers/ProfileSalaryController.ts index 6e82bb70..94c2e633 100644 --- a/src/controllers/ProfileSalaryController.ts +++ b/src/controllers/ProfileSalaryController.ts @@ -131,7 +131,7 @@ export class ProfileSalaryController extends Controller { const history = new ProfileSalaryHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileSalaryId = salaryId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileSalaryEmployeeController.ts b/src/controllers/ProfileSalaryEmployeeController.ts index e143324a..6c39900d 100644 --- a/src/controllers/ProfileSalaryEmployeeController.ts +++ b/src/controllers/ProfileSalaryEmployeeController.ts @@ -145,7 +145,7 @@ export class ProfileSalaryEmployeeController extends Controller { const history = new ProfileSalaryHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileSalaryId = salaryId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileSalaryEmployeeTempController.ts b/src/controllers/ProfileSalaryEmployeeTempController.ts index 1461d588..b23c4bf9 100644 --- a/src/controllers/ProfileSalaryEmployeeTempController.ts +++ b/src/controllers/ProfileSalaryEmployeeTempController.ts @@ -136,7 +136,7 @@ export class ProfileSalaryEmployeeTempController extends Controller { const history = new ProfileSalaryHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileSalaryId = salaryId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileTrainingController.ts b/src/controllers/ProfileTrainingController.ts index ae64e294..414c2e56 100644 --- a/src/controllers/ProfileTrainingController.ts +++ b/src/controllers/ProfileTrainingController.ts @@ -117,7 +117,7 @@ export class ProfileTrainingController extends Controller { const history = new ProfileTrainingHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileTrainingId = trainingId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileTrainingEmployeeController.ts b/src/controllers/ProfileTrainingEmployeeController.ts index da4ba019..0f576ffb 100644 --- a/src/controllers/ProfileTrainingEmployeeController.ts +++ b/src/controllers/ProfileTrainingEmployeeController.ts @@ -130,7 +130,7 @@ export class ProfileTrainingEmployeeController extends Controller { const history = new ProfileTrainingHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileTrainingId = trainingId; record.lastUpdateUserId = req.user.sub; diff --git a/src/controllers/ProfileTrainingEmployeeTempController.ts b/src/controllers/ProfileTrainingEmployeeTempController.ts index b1836ab4..942abac4 100644 --- a/src/controllers/ProfileTrainingEmployeeTempController.ts +++ b/src/controllers/ProfileTrainingEmployeeTempController.ts @@ -120,7 +120,7 @@ export class ProfileTrainingEmployeeTempController extends Controller { const history = new ProfileTrainingHistory(); Object.assign(record, body); - Object.assign(history, { ...body, id: undefined }); + Object.assign(history, { ...record, id: undefined }); history.profileTrainingId = trainingId; record.lastUpdateUserId = req.user.sub;