fix find fullName

This commit is contained in:
AdisakKanthawilang 2024-08-16 12:06:37 +07:00
parent ee9d492e27
commit 81c9db66e5

View file

@ -4191,7 +4191,8 @@ export class ProfileController extends Controller {
keyword?: string;
},
) {
const [firstName, lastName] = body.keyword ? body.keyword.split(" ") : ["", ""];
let conditionFullName =
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
const [findProfile, total] = await AppDataSource.getRepository(Profile)
.createQueryBuilder("profile")
.leftJoinAndSelect("profile.posLevel", "posLevel")
@ -4223,16 +4224,9 @@ export class ProfileController extends Controller {
.orWhere(`posType.posTypeName LIKE :keyword`, {
keyword: `%${body.keyword}%`,
})
.orWhere(
new Brackets((qb) => {
if (body.keyword) {
qb.where(`profile.firstName LIKE :firstName`, { firstName: `%${firstName}%` }).orWhere(
`profile.lastName LIKE :lastName`,
{ lastName: `%${lastName}%` },
);
}
}),
)
.orWhere(conditionFullName, {
keyword: `%${body.keyword}%`,
})
.orderBy("profile.citizenId", "ASC")
.skip((body.page - 1) * body.pageSize)
.take(body.pageSize)