diff --git a/src/controllers/CommandSalaryController.ts b/src/controllers/CommandSalaryController.ts index bf426436..131a5a70 100644 --- a/src/controllers/CommandSalaryController.ts +++ b/src/controllers/CommandSalaryController.ts @@ -19,6 +19,7 @@ import HttpStatusCode from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; import { CommandSalary, CreateCommandSalary, UpdateCommandSalary } from "../entities/CommandSalary"; import { CommandSys } from "../entities/CommandSys"; +import { Brackets } from "typeorm"; @Route("api/v1/org/commandSalary") @Tags("CommandSalary") @@ -67,6 +68,7 @@ export class CommandSalaryController extends Controller { @Query("pageSize") pageSize: number = 10, @Query() commandSysId?: string | null, @Query() isActive?: boolean | null, + @Query() searchKeyword?: string | null, ) { const [commandSalarys, total] = await this.commandSalaryRepository .createQueryBuilder("commandSalary") @@ -88,6 +90,18 @@ export class CommandSalaryController extends Controller { : `${commandSysId}`, }, ) + .andWhere( + new Brackets((qb) => { + qb.where( + searchKeyword != undefined && searchKeyword != null && searchKeyword != "" + ? "name LIKE :keyword" + : "1=1", + { + keyword: `%${searchKeyword}%`, + }, + ) + }), + ) .orderBy("commandSalary.createdAt", "ASC") .skip((page - 1) * pageSize) .take(pageSize)