sort พัฒนาบุคลากร
This commit is contained in:
parent
6725e9f4d9
commit
57114edac3
3 changed files with 91 additions and 9 deletions
|
|
@ -2022,6 +2022,8 @@ export class DevelopmentController extends Controller {
|
|||
@Query("nodeId") nodeId?: string | null,
|
||||
@Query("node") node?: number | null,
|
||||
@Query("keyword") keyword?: string,
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_DEV_PROJECT");
|
||||
await new CallAPI()
|
||||
|
|
@ -2030,7 +2032,7 @@ export class DevelopmentController extends Controller {
|
|||
_data = x;
|
||||
})
|
||||
.catch((x) => {});
|
||||
const [development, total] = await AppDataSource.getRepository(Development)
|
||||
let query = await AppDataSource.getRepository(Development)
|
||||
.createQueryBuilder("development")
|
||||
.andWhere(year > 0 ? "development.year LIKE :year" : "1=1", {
|
||||
year: `${year.toString()}`,
|
||||
|
|
@ -2129,8 +2131,18 @@ export class DevelopmentController extends Controller {
|
|||
"development.child3",
|
||||
"development.child4",
|
||||
])
|
||||
.orderBy("development.year", "DESC")
|
||||
.addOrderBy("development.createdAt", "DESC")
|
||||
|
||||
if (sortBy) {
|
||||
query = query.orderBy(
|
||||
`development.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy("development.year", "DESC")
|
||||
.addOrderBy("development.createdAt", "DESC")
|
||||
}
|
||||
|
||||
const [development, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue