Fixing order by di user list
This commit is contained in:
@ -84,20 +84,39 @@ export class UserController {
|
|||||||
.where(whereAttr, whereVal);
|
.where(whereAttr, whereVal);
|
||||||
|
|
||||||
const subquery = userRepository
|
const subquery = userRepository
|
||||||
.createQueryBuilder()
|
.createQueryBuilder("User")
|
||||||
.select("User.id")
|
.select("User.id", "id")
|
||||||
.where(whereAttr, whereVal)
|
.where(whereAttr, whereVal)
|
||||||
.orderBy(param.order_field, param.order_direction)
|
.orderBy("User." + param.order_field, param.order_direction)
|
||||||
.offset(offset)
|
.offset(offset)
|
||||||
.limit(param.limit);
|
.limit(param.limit);
|
||||||
console.log('subquery :', subquery.getQuery());
|
|
||||||
|
|
||||||
const res_list = userRepository
|
const res_list = userRepository
|
||||||
.createQueryBuilder()
|
.createQueryBuilder("User")
|
||||||
.where(`User.id IN (${subquery.getQuery()})`)
|
.innerJoin(
|
||||||
|
"(" + subquery.getQuery() + ")",
|
||||||
|
"sub",
|
||||||
|
"User.id = sub.id"
|
||||||
|
)
|
||||||
.setParameters(subquery.getParameters())
|
.setParameters(subquery.getParameters())
|
||||||
.leftJoinAndSelect("User.roles", "roles")
|
.leftJoinAndSelect("User.roles", "roles")
|
||||||
.leftJoinAndSelect("roles.application", "application");
|
.leftJoinAndSelect("roles.application", "application")
|
||||||
|
.orderBy("User." + param.order_field, param.order_direction);
|
||||||
|
|
||||||
|
// const subquery = userRepository
|
||||||
|
// .createQueryBuilder()
|
||||||
|
// .select("User.id")
|
||||||
|
// .where(whereAttr, whereVal)
|
||||||
|
// .orderBy("User." + param.order_field, param.order_direction)
|
||||||
|
// .offset(offset)
|
||||||
|
// .limit(param.limit);
|
||||||
|
|
||||||
|
// const res_list = userRepository
|
||||||
|
// .createQueryBuilder()
|
||||||
|
// .where(`User.id IN (${subquery.getQuery()})`)
|
||||||
|
// .setParameters(subquery.getParameters())
|
||||||
|
// .leftJoinAndSelect("User.roles", "roles")
|
||||||
|
// .leftJoinAndSelect("roles.application", "application");
|
||||||
|
|
||||||
// const res_list = userRepository.createQueryBuilder()
|
// const res_list = userRepository.createQueryBuilder()
|
||||||
// .where(whereAttr, whereVal)
|
// .where(whereAttr, whereVal)
|
||||||
@ -107,6 +126,8 @@ export class UserController {
|
|||||||
// .offset(offset)
|
// .offset(offset)
|
||||||
// .limit(param.limit);
|
// .limit(param.limit);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (param.with_deleted) {
|
if (param.with_deleted) {
|
||||||
res_count.withDeleted();
|
res_count.withDeleted();
|
||||||
res_list.withDeleted();
|
res_list.withDeleted();
|
||||||
|
|||||||
Reference in New Issue
Block a user