This commit is contained in:
fro1991
2025-01-24 16:56:46 +07:00
parent 3f61577a06
commit 0db6d8adad

View File

@ -83,14 +83,29 @@ export class UserController {
const res_count = userRepository.createQueryBuilder() const res_count = userRepository.createQueryBuilder()
.where(whereAttr, whereVal); .where(whereAttr, whereVal);
const res_list = userRepository.createQueryBuilder()
const subquery = userRepository
.createQueryBuilder()
.select("User.id")
.where(whereAttr, whereVal) .where(whereAttr, whereVal)
.leftJoinAndSelect("User.roles", "roles")
.leftJoinAndSelect("roles.application", "application")
.orderBy(param.order_field, param.order_direction) .orderBy(param.order_field, param.order_direction)
.offset(offset) .offset(offset)
.limit(param.limit); .limit(param.limit);
const res_list = userRepository
.createQueryBuilder()
.where(`User.id IN (${subquery.getQuery()})`)
.leftJoinAndSelect("User.roles", "roles")
.leftJoinAndSelect("roles.application", "application");
// const res_list = userRepository.createQueryBuilder()
// .where(whereAttr, whereVal)
// .leftJoinAndSelect("User.roles", "roles")
// .leftJoinAndSelect("roles.application", "application")
// .orderBy(param.order_field, param.order_direction)
// .offset(offset)
// .limit(param.limit);
if (param.with_deleted) { if (param.with_deleted) {
res_count.withDeleted(); res_count.withDeleted();
res_list.withDeleted(); res_list.withDeleted();