fix find fullName
This commit is contained in:
parent
ee9d492e27
commit
81c9db66e5
1 changed files with 5 additions and 11 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue