sort admin
This commit is contained in:
parent
d999241536
commit
8b40eb0ad5
3 changed files with 66 additions and 9 deletions
|
|
@ -56,11 +56,14 @@ export class ProfileDevelopmentEmployeeController 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_EMP");
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileId);
|
||||
const [profileDevelopment, total] = await AppDataSource.getRepository(ProfileDevelopment)
|
||||
|
||||
let query = await AppDataSource.getRepository(ProfileDevelopment)
|
||||
.createQueryBuilder("profileDevelopment")
|
||||
.where({ profileEmployeeId: profileId })
|
||||
.andWhere(
|
||||
|
|
@ -100,9 +103,19 @@ export class ProfileDevelopmentEmployeeController 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