sort org command
This commit is contained in:
parent
77b455ea8f
commit
58e44de196
1 changed files with 27 additions and 5 deletions
|
|
@ -2585,6 +2585,8 @@ export class ProfileController extends Controller {
|
|||
keyword: string;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
sortBy?: string;
|
||||
descending?: boolean;
|
||||
},
|
||||
) {
|
||||
let posMaster = await this.posMasterRepo.findOne({
|
||||
|
|
@ -2672,7 +2674,7 @@ export class ProfileController extends Controller {
|
|||
// condition.isDirector = true;
|
||||
// // conditionNow.isDirector = true;
|
||||
// }
|
||||
const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
|
||||
let query = await AppDataSource.getRepository(viewDirectorActing)
|
||||
.createQueryBuilder("viewDirectorActing")
|
||||
// .andWhere(condition)
|
||||
.andWhere(
|
||||
|
|
@ -2724,9 +2726,19 @@ export class ProfileController extends Controller {
|
|||
);
|
||||
}),
|
||||
)
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
if (body.sortBy) {
|
||||
query = query.orderBy(
|
||||
`viewDirectorActing.${body.sortBy}`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
const [lists, total] = await query
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
return new HttpSuccess({ data: lists, total });
|
||||
} else {
|
||||
// const posMaster = await this.posMasterRepo.findOne({
|
||||
|
|
@ -2764,7 +2776,7 @@ export class ProfileController extends Controller {
|
|||
// condition.isDirector = true;
|
||||
// // conditionNow.isDirector = true;
|
||||
// }
|
||||
const [lists, total] = await AppDataSource.getRepository(viewDirector)
|
||||
let query = await AppDataSource.getRepository(viewDirector)
|
||||
.createQueryBuilder("viewDirector")
|
||||
// .andWhere(condition)
|
||||
.andWhere(
|
||||
|
|
@ -2816,9 +2828,19 @@ export class ProfileController extends Controller {
|
|||
);
|
||||
}),
|
||||
)
|
||||
|
||||
if (body.sortBy) {
|
||||
query = query.orderBy(
|
||||
`viewDirector.${body.sortBy}`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
const [lists, total] = await query
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
return new HttpSuccess({ data: lists, total });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue