feat: search profile employee by field name
This commit is contained in:
parent
fa62ebe2f0
commit
a0887d8b74
1 changed files with 4 additions and 10 deletions
|
|
@ -192,7 +192,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
async listProfile(
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword: string = "",
|
||||
@Query() searchField?: "firstName" | "lastName" | "citizenId" | "position",
|
||||
@Query() searchKeyword: string = "",
|
||||
) {
|
||||
const [record, total] = await this.profileRepo.findAndCount({
|
||||
relations: {
|
||||
|
|
@ -202,15 +203,8 @@ export class ProfileEmployeeController extends Controller {
|
|||
relationship: true,
|
||||
bloodGroup: true,
|
||||
},
|
||||
where: [
|
||||
{ citizenId: Like(`%${keyword}%`) },
|
||||
{ position: Like(`%${keyword}%`) },
|
||||
{ prefix: Like(`%${keyword}%`) },
|
||||
{ firstName: Like(`%${keyword}%`) },
|
||||
{ lastName: Like(`%${keyword}%`) },
|
||||
{ email: Like(`%${keyword}%`) },
|
||||
{ telephoneNumber: Like(`%${keyword}%`) },
|
||||
],
|
||||
where:
|
||||
searchField && searchKeyword ? [{ [searchField]: Like(`%${searchKeyword}%`) }] : undefined,
|
||||
order: { createdAt: "ASC" },
|
||||
skip: (page - 1) * pageSize,
|
||||
take: pageSize,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue