From 654d1e24700746915d7a8a62d80699728f2179b5 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Wed, 4 Sep 2024 17:42:31 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=AA=E0=B8=B4=E0=B8=97=E0=B8=98=E0=B8=B4?= =?UTF-8?q?=E0=B9=8C=E0=B9=80=E0=B8=A1=E0=B8=99=E0=B8=B9=20=E0=B9=80?= =?UTF-8?q?=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94=E0=B8=B7=E0=B8=AD?= =?UTF-8?q?=E0=B8=99=20setup(1-3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/SalaryController.ts | 10 +++++----- src/controllers/SalaryEmployeeController.ts | 5 ++++- src/controllers/SalaryPeriodController.ts | 5 ++++- src/controllers/SalaryRankController.ts | 4 ++++ src/controllers/SalaryRankEmployeeController.ts | 4 ++++ 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/controllers/SalaryController.ts b/src/controllers/SalaryController.ts index 4c36e71..27b36dd 100644 --- a/src/controllers/SalaryController.ts +++ b/src/controllers/SalaryController.ts @@ -247,7 +247,8 @@ export class SalaryController extends Controller { endDate: "datetime", //วันที่สิ้นสุดบังคับใช้ detail: "string", //คำอธิบาย }) - async GetSalaryById(@Path() id: string) { + async GetSalaryById(@Path() id: string, @Request() req: RequestWithUser) { + await new permission().PermissionGet(req, "SYS_SALARY_CHART_OFFICER"); const salary = await this.salaryRepository.findOne({ relations: ["posType_", "posLevel_"], where: { id: id }, @@ -280,10 +281,12 @@ export class SalaryController extends Controller { */ @Get() async listSalary( + @Request() req: RequestWithUser, @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Query("keyword") keyword?: string, ) { + await new permission().PermissionList(req, "SYS_SALARY_CHART_OFFICER"); const [salary, total] = await AppDataSource.getRepository(Salarys) .createQueryBuilder("salary") .leftJoinAndSelect("salary.posType_", "posType_") @@ -327,10 +330,7 @@ export class SalaryController extends Controller { * */ @Post("copy") - async copySalary( - @Body() body: { id: string }, - @Request() request: RequestWithUser, - ) { + async copySalary(@Body() body: { id: string }, @Request() request: RequestWithUser) { await new permission().PermissionCreate(request, "SYS_SALARY_CHART_OFFICER"); const salary = await this.salaryRepository.findOne({ relations: ["posLevel_", "posType_", "salaryRanks_"], diff --git a/src/controllers/SalaryEmployeeController.ts b/src/controllers/SalaryEmployeeController.ts index 361e4f4..72abd11 100644 --- a/src/controllers/SalaryEmployeeController.ts +++ b/src/controllers/SalaryEmployeeController.ts @@ -213,7 +213,8 @@ export class SalaryEmployeeController extends Controller { endDate: "datetime", //วันที่สิ้นสุดบังคับใช้ detail: "string", //คำอธิบาย }) - async GetSalaryById(@Path() id: string) { + async GetSalaryById(@Path() id: string, @Request() request: RequestWithUser) { + await new permission().PermissionGet(request, "SYS_WAGE_CHART_EMP"); const salary = await this.salaryEmployeeRepository.findOne({ where: { id: id }, select: ["name", "group", "isActive", "date", "startDate", "endDate", "details"], @@ -231,10 +232,12 @@ export class SalaryEmployeeController extends Controller { */ @Get() async listSalary( + @Request() request: RequestWithUser, @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Query("keyword") keyword?: string, ) { + await new permission().PermissionList(request, "SYS_WAGE_CHART_EMP"); const [salaryEmployee, total] = await AppDataSource.getRepository(SalaryEmployee) .createQueryBuilder("salaryEmployee") .andWhere( diff --git a/src/controllers/SalaryPeriodController.ts b/src/controllers/SalaryPeriodController.ts index c94b965..c1a5da9 100644 --- a/src/controllers/SalaryPeriodController.ts +++ b/src/controllers/SalaryPeriodController.ts @@ -1546,7 +1546,8 @@ export class SalaryPeriodController extends Controller { * @param {string} id Guid, *Id รอบเงินเดือน */ @Get("close/{id}") - async closeSalaryPeriod_ById(@Path() id: string) { + async closeSalaryPeriod_ById(@Path() id: string, @Request() request: RequestWithUser) { + await new permission().PermissionUpdate(request, "SYS_SALARY_ROUND"); const salaryPeriod = await this.salaryPeriodRepository.findOne({ where: { id: id }, }); @@ -1915,11 +1916,13 @@ export class SalaryPeriodController extends Controller { */ @Get() async GetListsSalaryPeriod( + @Request() request: RequestWithUser, @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Query("keyword") keyword?: string, @Query("year") year: number = 2024, ) { + await new permission().PermissionList(request, "SYS_SALARY_ROUND"); const [salaryPeriod, total] = await AppDataSource.getRepository(SalaryPeriod) .createQueryBuilder("salaryPeriod") .andWhere(year != 0 ? "salaryPeriod.year LIKE :year" : "1=1", { year: `${year}` }) diff --git a/src/controllers/SalaryRankController.ts b/src/controllers/SalaryRankController.ts index 5ae8769..006833b 100644 --- a/src/controllers/SalaryRankController.ts +++ b/src/controllers/SalaryRankController.ts @@ -21,6 +21,8 @@ import HttpStatusCode from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; import { CreateSalaryRank, SalaryRanks, UpdateSalaryRank } from "../entities/SalaryRanks"; import { Salarys } from "../entities/Salarys"; +import { RequestWithUser } from "../middlewares/user"; +import permission from "../interfaces/permission"; @Route("api/v1/salary/rate") @Tags("SalaryRank") @Security("bearerAuth") @@ -118,10 +120,12 @@ export class SalaryRanksController extends Controller { @Get("{id}") async listSalaryRanks( @Path() id: string, + @Request() req: RequestWithUser, @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Query("keyword") keyword?: string, ) { + await new permission().PermissionGet(req, "SYS_SALARY_CHART_OFFICER"); const [salaryRank, total] = await AppDataSource.getRepository(SalaryRanks) .createQueryBuilder("salaryRank") .andWhere( diff --git a/src/controllers/SalaryRankEmployeeController.ts b/src/controllers/SalaryRankEmployeeController.ts index 1b0324e..7118746 100644 --- a/src/controllers/SalaryRankEmployeeController.ts +++ b/src/controllers/SalaryRankEmployeeController.ts @@ -25,6 +25,8 @@ import { UpdateSalaryRankEmployee, } from "../entities/SalaryRankEmployee"; import { SalaryEmployee } from "../entities/SalaryEmployee"; +import permission from "../interfaces/permission"; +import { RequestWithUser } from "../middlewares/user"; @Route("api/v1/salary/rate/employee") @Tags("SalaryRankEmployee") @Security("bearerAuth") @@ -138,11 +140,13 @@ export class SalaryRankEmployeeController extends Controller { */ @Get("{id}") async listSalaryRankEmployees( + @Request() request: RequestWithUser, @Path() id: string, @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Query("keyword") keyword?: string, ) { + await new permission().PermissionGet(request, "SYS_WAGE_CHART_EMP"); const [salaryRankEmployee, total] = await AppDataSource.getRepository(SalaryRankEmployee) .createQueryBuilder("salaryRankEmployee") .andWhere(