From 4056a2aa7fc09a33584499f8f062c6c95cf418c4 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 4 Sep 2024 21:20:50 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B9=84=E0=B8=82?= =?UTF-8?q?=E0=B9=80=E0=B8=81=E0=B9=87=E0=B8=9A=E0=B8=9B=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B8=A7=E0=B8=B1=E0=B8=95=E0=B8=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileAddressController.ts | 4 +-- .../ProfileAddressEmployeeController.ts | 4 +-- .../ProfileAddressEmployeeTempController.ts | 4 +-- src/controllers/ProfileController.ts | 5 +-- src/controllers/ProfileEmployeeController.ts | 31 +++---------------- .../ProfileEmployeeTempController.ts | 29 +++-------------- 6 files changed, 19 insertions(+), 58 deletions(-) diff --git a/src/controllers/ProfileAddressController.ts b/src/controllers/ProfileAddressController.ts index 44f1c447..7226bbbd 100644 --- a/src/controllers/ProfileAddressController.ts +++ b/src/controllers/ProfileAddressController.ts @@ -94,7 +94,7 @@ export class ProfileAddressController extends Controller { "currentDistrict", "currentSubDistrict", ], - order: { createdAt: "ASC" }, + order: { createdAt: "DESC" }, }); const _record = record.map((item) => ({ id: item.id, @@ -135,7 +135,7 @@ export class ProfileAddressController extends Controller { "currentDistrict", "currentSubDistrict", ], - order: { createdAt: "ASC" }, + order: { createdAt: "DESC" }, }); const _record = record.map((item) => ({ id: item.id, diff --git a/src/controllers/ProfileAddressEmployeeController.ts b/src/controllers/ProfileAddressEmployeeController.ts index 3e6bce14..3728b3f9 100644 --- a/src/controllers/ProfileAddressEmployeeController.ts +++ b/src/controllers/ProfileAddressEmployeeController.ts @@ -98,7 +98,7 @@ export class ProfileAddressEmployeeController extends Controller { "currentDistrict", "currentSubDistrict", ], - order: { createdAt: "ASC" }, + order: { createdAt: "DESC" }, }); const _record = record.map((item) => ({ id: item.id, @@ -139,7 +139,7 @@ export class ProfileAddressEmployeeController extends Controller { "currentDistrict", "currentSubDistrict", ], - order: { createdAt: "ASC" }, + order: { createdAt: "DESC" }, }); const _record = record.map((item) => ({ id: item.id, diff --git a/src/controllers/ProfileAddressEmployeeTempController.ts b/src/controllers/ProfileAddressEmployeeTempController.ts index 1aaca55f..07359243 100644 --- a/src/controllers/ProfileAddressEmployeeTempController.ts +++ b/src/controllers/ProfileAddressEmployeeTempController.ts @@ -98,7 +98,7 @@ export class ProfileAddressEmployeeTempController extends Controller { "currentDistrict", "currentSubDistrict", ], - order: { createdAt: "ASC" }, + order: { createdAt: "DESC" }, }); const _record = record.map((item) => ({ id: item.id, @@ -139,7 +139,7 @@ export class ProfileAddressEmployeeTempController extends Controller { "currentDistrict", "currentSubDistrict", ], - order: { createdAt: "ASC" }, + order: { createdAt: "DESC" }, }); const _record = record.map((item) => ({ id: item.id, diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index b7451545..c012435d 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -2389,11 +2389,12 @@ export class ProfileController extends Controller { if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้"); Object.assign(record, body); + record.createdUserId = request.user.sub; + record.createdFullName = request.user.name; + record.createdAt = new Date(); 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, diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index d95dfee4..85e02cf5 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -62,11 +62,9 @@ import { } from "../entities/ProfileEmployeeEmployment"; import { ProfileEmployeeEmploymentHistory } from "../entities/ProfileEmployeeEmploymentHistory"; import CallAPI from "../interfaces/call-api"; -import { EmployeePosition } from "../entities/EmployeePosition"; import { ProfileInsignia } from "../entities/ProfileInsignia"; import { ProfileLeave } from "../entities/ProfileLeave"; import permission from "../interfaces/permission"; -import { request } from "axios"; @Route("api/v1/org/profile-employee") @Tags("ProfileEmployee") @Security("bearerAuth") @@ -82,7 +80,6 @@ export class ProfileEmployeeController extends Controller { private profileHistoryRepo = AppDataSource.getRepository(ProfileEmployeeHistory); private posLevelRepo = AppDataSource.getRepository(EmployeePosLevel); private posTypeRepo = AppDataSource.getRepository(EmployeePosType); - private positionRepository = AppDataSource.getRepository(EmployeePosition); private provinceRepository = AppDataSource.getRepository(Province); private districtRepository = AppDataSource.getRepository(District); private subDistrict = AppDataSource.getRepository(SubDistrict); @@ -673,13 +670,12 @@ export class ProfileEmployeeController extends Controller { } Object.assign(record, body); + record.createdUserId = request.user.sub; + record.createdFullName = request.user.name; + record.createdAt = new Date(); 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); - record.employeeClass = record.employeeClass.toLocaleUpperCase(); await this.profileHistoryRepo.save( Object.assign(new ProfileEmployeeHistory(), { ...record, @@ -2798,18 +2794,6 @@ export class ProfileEmployeeController extends Controller { item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision.id); - const position = - posMaster == null || - item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.positions == null || - item.current_holders?.find((x) => x.orgRevisionId == findRevision.id)?.positions.length == - 0 || - item.current_holders - .find((x) => x.orgRevisionId == findRevision.id) - ?.positions?.find((position) => position.positionIsSelected == true) == null - ? null - : item.current_holders - .find((x) => x.orgRevisionId == findRevision.id) - ?.positions?.find((position) => position.positionIsSelected == true); // const posExecutive = // position == null || // item.current_holders @@ -2978,11 +2962,6 @@ export class ProfileEmployeeController extends Controller { } await this.profileRepo.save(profile); - const profileSalary = await this.salaryRepository.findOne({ - where: { profileEmployeeId: id }, - order: { createdAt: "DESC" }, - }); - return new HttpSuccess(); } @@ -3333,7 +3312,7 @@ export class ProfileEmployeeController extends Controller { refCommandNo: v.refCommandNo, templateDoc: v.templateDoc, }) - .then(async (x) => { + .then(async () => { profile.statusTemp = "DONE"; profile.employeeClass = "PERM"; const _null: any = null; @@ -3346,7 +3325,7 @@ export class ProfileEmployeeController extends Controller { positionId: profile.positionIdTemp, profileId: profile.id, }) - .then(async (x) => {}); + .then(async () => {}); } }), ); diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 1e1c6b70..c3200eeb 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -81,7 +81,6 @@ export class ProfileEmployeeTempController extends Controller { private profileHistoryRepo = AppDataSource.getRepository(ProfileEmployeeHistory); private posLevelRepo = AppDataSource.getRepository(EmployeePosLevel); private posTypeRepo = AppDataSource.getRepository(EmployeePosType); - private positionRepository = AppDataSource.getRepository(EmployeePosition); private provinceRepository = AppDataSource.getRepository(Province); private districtRepository = AppDataSource.getRepository(District); private subDistrict = AppDataSource.getRepository(SubDistrict); @@ -670,13 +669,12 @@ export class ProfileEmployeeTempController extends Controller { } Object.assign(record, body); + record.createdUserId = request.user.sub; + record.createdFullName = request.user.name; + record.createdAt = new Date(); 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); - record.employeeClass = record.employeeClass.toLocaleUpperCase(); await this.profileHistoryRepo.save( Object.assign(new ProfileEmployeeHistory(), { ...record, @@ -2703,18 +2701,6 @@ export class ProfileEmployeeTempController extends Controller { item.current_holders.find((x) => x.orgRevisionId == findRevision.id) == null ? null : item.current_holders.find((x) => x.orgRevisionId == findRevision.id); - const position = - posMaster == null || - item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.positions == null || - item.current_holders?.find((x) => x.orgRevisionId == findRevision.id)?.positions.length == - 0 || - item.current_holders - .find((x) => x.orgRevisionId == findRevision.id) - ?.positions?.find((position) => position.positionIsSelected == true) == null - ? null - : item.current_holders - .find((x) => x.orgRevisionId == findRevision.id) - ?.positions?.find((position) => position.positionIsSelected == true); // const posExecutive = // position == null || // item.current_holders @@ -2883,11 +2869,6 @@ export class ProfileEmployeeTempController extends Controller { } await this.profileRepo.save(profile); - const profileSalary = await this.salaryRepository.findOne({ - where: { profileEmployeeId: id }, - order: { createdAt: "DESC" }, - }); - return new HttpSuccess(); } @@ -3206,7 +3187,7 @@ export class ProfileEmployeeTempController extends Controller { refCommandNo: v.refCommandNo, templateDoc: v.templateDoc, }) - .then(async (x) => { + .then(async () => { profile.statusTemp = "DONE"; profile.employeeClass = "PERM"; const _null: any = null; @@ -3219,7 +3200,7 @@ export class ProfileEmployeeTempController extends Controller { positionId: profile.positionIdTemp, profileId: profile.id, }) - .then(async (x) => {}); + .then(async () => {}); } }), );