fix: when no keyword, list cannot be found

This commit is contained in:
Methapon2001 2024-03-21 10:40:25 +07:00
parent 8a1400d840
commit ed7b15ebbe

View file

@ -186,7 +186,7 @@ export class ProfileController extends Controller {
async listProfile(
@Query("page") page: number = 1,
@Query("pageSize") pageSize: number = 10,
@Query("keyword") keyword?: string,
@Query("keyword") keyword: string = "",
) {
const [record, total] = await this.profileRepo.findAndCount({
relations: {
@ -196,13 +196,15 @@ export class ProfileController extends Controller {
relationship: true,
bloodGroup: true,
},
where: {
citizenId: Like(`%${keyword}%`),
position: Like(`%${keyword}%`),
prefix: Like(`%${keyword}%`),
firstName: Like(`%${keyword}%`),
lastName: Like(`%${keyword}%`),
},
where: [
{ citizenId: Like(`%${keyword}%`) },
{ position: Like(`%${keyword}%`) },
{ prefix: Like(`%${keyword}%`) },
{ firstName: Like(`%${keyword}%`) },
{ lastName: Like(`%${keyword}%`) },
{ email: Like(`%${keyword}%`) },
{ telephoneNumber: Like(`%${keyword}%`) },
],
order: { createdAt: "ASC" },
skip: (page - 1) * pageSize,
take: pageSize,