Merge branch 'develop' into dev
All checks were successful
Build & Deploy on Dev / build (push) Successful in 49s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 49s
* develop: sort eva
This commit is contained in:
commit
e546dfeaff
1 changed files with 14 additions and 2 deletions
|
|
@ -145,6 +145,8 @@ export class EvaluationController {
|
||||||
pageSize: number;
|
pageSize: number;
|
||||||
keyword?: string;
|
keyword?: string;
|
||||||
status?: string[];
|
status?: string[];
|
||||||
|
sortBy?: string;
|
||||||
|
descending?: boolean;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -156,7 +158,7 @@ export class EvaluationController {
|
||||||
_data = x;
|
_data = x;
|
||||||
})
|
})
|
||||||
.catch((x) => {});
|
.catch((x) => {});
|
||||||
const [evaluation, total] = await AppDataSource.getRepository(Evaluation)
|
let query = await AppDataSource.getRepository(Evaluation)
|
||||||
.createQueryBuilder("evaluation")
|
.createQueryBuilder("evaluation")
|
||||||
.andWhere(
|
.andWhere(
|
||||||
_data.root != undefined && _data.root != null
|
_data.root != undefined && _data.root != null
|
||||||
|
|
@ -233,7 +235,17 @@ export class EvaluationController {
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orderBy("evaluation.lastUpdatedAt", "DESC")
|
|
||||||
|
if (body.sortBy) {
|
||||||
|
query = query.orderBy(
|
||||||
|
`evaluation.${body.sortBy}`,
|
||||||
|
body.descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
query = query.orderBy("evaluation.lastUpdatedAt", "DESC")
|
||||||
|
}
|
||||||
|
|
||||||
|
const [evaluation, total] = await query
|
||||||
.skip((body.page - 1) * body.pageSize)
|
.skip((body.page - 1) * body.pageSize)
|
||||||
.take(body.pageSize)
|
.take(body.pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue