search-personal (current revision)

This commit is contained in:
AdisakKanthawilang 2024-12-02 15:46:57 +07:00
parent 296f33b190
commit 0b9818955c

View file

@ -4249,20 +4249,22 @@ export class ProfileController extends Controller {
: `profile.dateLeave IS NOT NULL`
: "1=1",
)
.andWhere(
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
? queryLike
: "1=1",
{
keyword: `%${searchKeyword}%`,
},
)
.andWhere(nodeCondition, {
nodeId: nodeId,
nodeId: nodeId,
})
// .andWhere(`current_holders.orgRevisionId LIKE :orgRevisionId`, {
// orgRevisionId: findRevision.id,
// })
.andWhere(
new Brackets((qb) => {
qb.orWhere(
searchKeyword != undefined && searchKeyword != null && searchKeyword != ""
? queryLike
: "1=1",
{
keyword: `%${searchKeyword}%`,
},
)
})
)
.orderBy("current_holders.posMasterNo", "ASC")
.skip((page - 1) * pageSize)
.take(pageSize)
@ -6039,7 +6041,12 @@ export class ProfileController extends Controller {
switch (body.fieldName) {
case "citizenId":
[findProfile, total] = await this.profileRepo.findAndCount({
where: { citizenId: Like(`%${body.keyword}%`) },
where: {
citizenId: Like(`%${body.keyword}%`),
current_holders:{
orgRevisionId:revision?.id
}
},
relations: [
"posType",
"posLevel",
@ -6066,7 +6073,8 @@ export class ProfileController extends Controller {
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
.where("CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", { keyword: `%${body.keyword}%` })
.where("current_holders.orgRevision = :revisionId", { revisionId: revision?.id })
.andWhere("CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword", { keyword: `%${body.keyword}%` })
.skip(skip)
.take(take)
.getManyAndCount();
@ -6074,7 +6082,12 @@ export class ProfileController extends Controller {
case "position":
[findProfile, total] = await this.profileRepo.findAndCount({
where: { position: Like(`%${body.keyword}%`) },
where: {
position: Like(`%${body.keyword}%`),
current_holders:{
orgRevisionId:revision?.id
}
},
relations: [
"posType",
"posLevel",
@ -6122,6 +6135,9 @@ export class ProfileController extends Controller {
where: {
posType: {
posTypeName:Like(`%${body.keyword}%`)
},
current_holders:{
orgRevisionId:revision?.id
}
},
relations: [
@ -6145,6 +6161,9 @@ export class ProfileController extends Controller {
where: {
posLevel: {
posLevelName:Like(`%${body.keyword}%`)
},
current_holders:{
orgRevisionId:revision?.id
}
},
relations: [
@ -6167,6 +6186,7 @@ export class ProfileController extends Controller {
[findProfile, total] = await this.profileRepo.findAndCount({
where: {
current_holders:{
orgRevisionId:revision?.id,
orgRoot:{
orgRootName:Like(`%${body.keyword}%`)
}
@ -6189,6 +6209,11 @@ export class ProfileController extends Controller {
default:
[findProfile, total] = await this.profileRepo.findAndCount({
where:{
current_holders:{
orgRevisionId:revision?.id
}
},
relations: [
"posType",
"posLevel",