From 416250cf4b78af380d857caaa2634ec01c229775 Mon Sep 17 00:00:00 2001 From: mamoss <> Date: Wed, 21 May 2025 15:13:13 +0700 Subject: [PATCH] sort salaryhis --- .../ProfileSalaryTempController.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/controllers/ProfileSalaryTempController.ts b/src/controllers/ProfileSalaryTempController.ts index f7c7f2ad..5eb7f126 100644 --- a/src/controllers/ProfileSalaryTempController.ts +++ b/src/controllers/ProfileSalaryTempController.ts @@ -1462,6 +1462,37 @@ export class ProfileSalaryTempController extends Controller { } } + /** + * API แก้้ไขลำดับรายคน + * + * @summary API แก้้ไขลำดับรายคน + * + */ + @Get("change/sort/all") + public async changeSortEditGenAll() { + try { + const profiles = await this.profileRepo.find(); + let num = 1; + for await (const item of profiles) { + let salaryOld = await this.salaryRepo.find({ + where: { profileId: item.id }, + order: { commandDateAffect: "ASC", order: "ASC" }, + }); + + salaryOld.forEach((item: any, i) => { + item.order = i + 1; + }); + num = num + 1; + console.log(num); + await this.salaryRepo.save(salaryOld); + } + + return new HttpSuccess(); + } catch { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถดําเนินการได้"); + } + } + /** * API แก้้ไขลำดับรายคน *