sort org/workflow/commander/operate
This commit is contained in:
parent
d6a5cc9cf5
commit
a61cd6f060
1 changed files with 10 additions and 1 deletions
|
|
@ -809,6 +809,8 @@ export class WorkflowController extends Controller {
|
|||
pageSize: number;
|
||||
keycloakId?: string | null;
|
||||
type?: string | null;
|
||||
sortBy?: string | null,
|
||||
descending?: boolean,
|
||||
},
|
||||
) {
|
||||
const userKeycloak = body.keycloakId ?? request.user.sub;
|
||||
|
|
@ -946,7 +948,7 @@ export class WorkflowController extends Controller {
|
|||
? AppDataSource.getRepository(viewDirectorActing)
|
||||
: AppDataSource.getRepository(viewDirector);
|
||||
|
||||
const queryBuilder = repository.createQueryBuilder("entity");
|
||||
let queryBuilder = repository.createQueryBuilder("entity");
|
||||
|
||||
// 5. แยก WHERE conditions ให้เร็วขึ้น
|
||||
queryBuilder.where(
|
||||
|
|
@ -985,6 +987,13 @@ export class WorkflowController extends Controller {
|
|||
);
|
||||
}
|
||||
|
||||
if (body.sortBy) {
|
||||
queryBuilder = queryBuilder.orderBy(
|
||||
`entity.${body.sortBy}`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
// 7. Execute พร้อมกัน - ใช้ Promise.all
|
||||
const [data, total] = await Promise.all([
|
||||
queryBuilder
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue