เพิ่ม where search #776
This commit is contained in:
parent
da9e89147c
commit
4608ff14de
1 changed files with 14 additions and 0 deletions
|
|
@ -19,6 +19,7 @@ import HttpStatusCode from "../interfaces/http-status";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { CommandSalary, CreateCommandSalary, UpdateCommandSalary } from "../entities/CommandSalary";
|
import { CommandSalary, CreateCommandSalary, UpdateCommandSalary } from "../entities/CommandSalary";
|
||||||
import { CommandSys } from "../entities/CommandSys";
|
import { CommandSys } from "../entities/CommandSys";
|
||||||
|
import { Brackets } from "typeorm";
|
||||||
|
|
||||||
@Route("api/v1/org/commandSalary")
|
@Route("api/v1/org/commandSalary")
|
||||||
@Tags("CommandSalary")
|
@Tags("CommandSalary")
|
||||||
|
|
@ -67,6 +68,7 @@ export class CommandSalaryController extends Controller {
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
@Query() commandSysId?: string | null,
|
@Query() commandSysId?: string | null,
|
||||||
@Query() isActive?: boolean | null,
|
@Query() isActive?: boolean | null,
|
||||||
|
@Query() searchKeyword?: string | null,
|
||||||
) {
|
) {
|
||||||
const [commandSalarys, total] = await this.commandSalaryRepository
|
const [commandSalarys, total] = await this.commandSalaryRepository
|
||||||
.createQueryBuilder("commandSalary")
|
.createQueryBuilder("commandSalary")
|
||||||
|
|
@ -88,6 +90,18 @@ export class CommandSalaryController extends Controller {
|
||||||
: `${commandSysId}`,
|
: `${commandSysId}`,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
.andWhere(
|
||||||
|
new Brackets((qb) => {
|
||||||
|
qb.where(
|
||||||
|
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
|
||||||
|
? "name LIKE :keyword"
|
||||||
|
: "1=1",
|
||||||
|
{
|
||||||
|
keyword: `%${searchKeyword}%`,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
}),
|
||||||
|
)
|
||||||
.orderBy("commandSalary.createdAt", "ASC")
|
.orderBy("commandSalary.createdAt", "ASC")
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue