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;
|
keyword: string;
|
||||||
page: number;
|
page: number;
|
||||||
pageSize: number;
|
pageSize: number;
|
||||||
|
sortBy?: string;
|
||||||
|
descending?: boolean;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
let posMaster = await this.posMasterRepo.findOne({
|
let posMaster = await this.posMasterRepo.findOne({
|
||||||
|
|
@ -2672,7 +2674,7 @@ export class ProfileController extends Controller {
|
||||||
// condition.isDirector = true;
|
// condition.isDirector = true;
|
||||||
// // conditionNow.isDirector = true;
|
// // conditionNow.isDirector = true;
|
||||||
// }
|
// }
|
||||||
const [lists, total] = await AppDataSource.getRepository(viewDirectorActing)
|
let query = await AppDataSource.getRepository(viewDirectorActing)
|
||||||
.createQueryBuilder("viewDirectorActing")
|
.createQueryBuilder("viewDirectorActing")
|
||||||
// .andWhere(condition)
|
// .andWhere(condition)
|
||||||
.andWhere(
|
.andWhere(
|
||||||
|
|
@ -2724,9 +2726,19 @@ export class ProfileController extends Controller {
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.skip((body.page - 1) * body.pageSize)
|
|
||||||
.take(body.pageSize)
|
if (body.sortBy) {
|
||||||
.getManyAndCount();
|
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 });
|
return new HttpSuccess({ data: lists, total });
|
||||||
} else {
|
} else {
|
||||||
// const posMaster = await this.posMasterRepo.findOne({
|
// const posMaster = await this.posMasterRepo.findOne({
|
||||||
|
|
@ -2764,7 +2776,7 @@ export class ProfileController extends Controller {
|
||||||
// condition.isDirector = true;
|
// condition.isDirector = true;
|
||||||
// // conditionNow.isDirector = true;
|
// // conditionNow.isDirector = true;
|
||||||
// }
|
// }
|
||||||
const [lists, total] = await AppDataSource.getRepository(viewDirector)
|
let query = await AppDataSource.getRepository(viewDirector)
|
||||||
.createQueryBuilder("viewDirector")
|
.createQueryBuilder("viewDirector")
|
||||||
// .andWhere(condition)
|
// .andWhere(condition)
|
||||||
.andWhere(
|
.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)
|
.skip((body.page - 1) * body.pageSize)
|
||||||
.take(body.pageSize)
|
.take(body.pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
return new HttpSuccess({ data: lists, total });
|
return new HttpSuccess({ data: lists, total });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue