From ec4cf9015f2909fc243dcd530f62a6fba725f798 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 26 Mar 2024 10:28:40 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=AD=E0=B8=9A=E0=B8=95=E0=B8=B2=E0=B8=A1=E0=B8=9B?= =?UTF-8?q?=E0=B8=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryPeriodController.ts | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index 02cea59..fdc1f50 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -1418,6 +1418,40 @@ export class SalaryPeriodController extends Controller { return new HttpSuccess(salaryPeriod); } + /** + * API รายการรอบเงินเดือน by year + * + * @summary SLR_020 - รายการรอบเงินเดือน by year + * + */ + @Get("active/{year}") + async GetListsSalaryPeriodByYear( + @Path() year: number, + @Query("page") page: number = 1, + @Query("pageSize") pageSize: number = 10, + @Query("keyword") keyword?: string, + ) { + const [salaryPeriod, total] = await AppDataSource.getRepository(SalaryPeriod) + .createQueryBuilder("salaryPeriod") + .andWhere(year != 0 ? "salaryPeriod.year LIKE :year" : "1=1", { year: `${year}` }) + .select([ + "salaryPeriod.id", + "salaryPeriod.period", + "salaryPeriod.isActive", + "salaryPeriod.isClose", + "salaryPeriod.effectiveDate", + "salaryPeriod.status", + "salaryPeriod.year", + "salaryPeriod.revisionId", + ]) + .orderBy("salaryPeriod.effectiveDate", "DESC") + .skip((page - 1) * pageSize) + .take(pageSize) + .getManyAndCount(); + + return new HttpSuccess({ data: salaryPeriod, total }); + } + /** * API รายการรอบเงินเดือน *