sort admin
This commit is contained in:
parent
57c9a84c40
commit
d999241536
3 changed files with 54 additions and 10 deletions
|
|
@ -58,11 +58,13 @@ export class ProfileDevelopmentController extends Controller {
|
|||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query() searchKeyword: string = "",
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let _workflow = await new permission().Workflow(req, profileId, "SYS_REGISTRY_OFFICER");
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const [profileDevelopment, total] = await AppDataSource.getRepository(ProfileDevelopment)
|
||||
let query = await AppDataSource.getRepository(ProfileDevelopment)
|
||||
.createQueryBuilder("profileDevelopment")
|
||||
.where({ profileId: profileId })
|
||||
.andWhere(
|
||||
|
|
@ -102,9 +104,19 @@ export class ProfileDevelopmentController extends Controller {
|
|||
}),
|
||||
)
|
||||
.orderBy("profileDevelopment.createdAt", "ASC")
|
||||
|
||||
if (sortBy) {
|
||||
query = query.orderBy(
|
||||
`profileDevelopment.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
|
||||
const [profileDevelopment, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
return new HttpSuccess({ data: profileDevelopment, total });
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue