2025-10-13
群组查询修改
This commit is contained in:
@@ -100,6 +100,14 @@ export class ProgramGroupService {
|
||||
"program",
|
||||
"group.program_id = program.id"
|
||||
)
|
||||
|
||||
queryBuilder.leftJoinAndMapOne(
|
||||
"group.chargeUser",
|
||||
UsersEntity,
|
||||
"chargeUser",
|
||||
"group.charge_id = chargeUser.id"
|
||||
)
|
||||
|
||||
queryBuilder.leftJoinAndMapOne(
|
||||
"group.user",
|
||||
UsersEntity,
|
||||
@@ -123,11 +131,23 @@ export class ProgramGroupService {
|
||||
queryBuilder.orWhere("group.charge_id = :charge_id", {charge_id: programGroup.userId})
|
||||
}
|
||||
|
||||
if (programGroup.keyword != null){
|
||||
queryBuilder.andWhere(
|
||||
"(program.name LIKE :nameKeyword OR program.company LIKE :companyKeyword)",
|
||||
{
|
||||
nameKeyword: '%' + programGroup.keyword + '%',
|
||||
companyKeyword: '%' + programGroup.keyword + '%'
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
queryBuilder
|
||||
.orderBy("latest_message_time", 'DESC')
|
||||
.take(programGroup.size || 10)
|
||||
.skip(offset || 0);
|
||||
|
||||
// console.log(queryBuilder.getSql())
|
||||
|
||||
let [items, total] = await queryBuilder.getManyAndCount();
|
||||
|
||||
// 将未读数据(redis)塞入数据(list)中
|
||||
@@ -167,8 +187,10 @@ export class ProgramGroupService {
|
||||
let item = list[i];
|
||||
let userUnreadValue = await this.redisService.getValue(`${item.groupId}_${item.userId}`)
|
||||
let chargeUnreadValue = await this.redisService.getValue(`${item.groupId}_${item.chargeId}`)
|
||||
let customerUnreadValue = await this.redisService.getValue(`${item.groupId}_${item.customerId}`)
|
||||
item.userUnread = userUnreadValue == null ? [] : JSON.parse(userUnreadValue)
|
||||
item.chargeUnread = chargeUnreadValue == null ? [] : JSON.parse(chargeUnreadValue)
|
||||
item.customerUnread = customerUnreadValue == null ? [] : JSON.parse(customerUnreadValue)
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user