sort admin
This commit is contained in:
parent
d999241536
commit
8b40eb0ad5
3 changed files with 66 additions and 9 deletions
|
|
@ -110,6 +110,8 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword: string = "",
|
||||
@Query("status") status: string = "",
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let data = await new permission().PermissionOrgList(request, "SYS_REGISTRY_EMP");
|
||||
const orgRevisionPublish = await this.orgRevisionRepository
|
||||
|
|
@ -117,7 +119,8 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
.where("orgRevision.orgRevisionIsDraft = false")
|
||||
.andWhere("orgRevision.orgRevisionIsCurrent = true")
|
||||
.getOne();
|
||||
let [getProfileEdit, total] = await AppDataSource.getRepository(ProfileEdit)
|
||||
|
||||
let query = await AppDataSource.getRepository(ProfileEdit)
|
||||
.createQueryBuilder("ProfileEdit")
|
||||
.leftJoinAndSelect("ProfileEdit.profileEmployee", "profileEmployee")
|
||||
.leftJoinAndSelect("profileEmployee.current_holders", "current_holders")
|
||||
|
|
@ -209,9 +212,25 @@ export class ProfileEditEmployeeController extends Controller {
|
|||
}),
|
||||
)
|
||||
.orderBy("ProfileEdit.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
if (sortBy) {
|
||||
if(sortBy == "fullname"){
|
||||
query = query.orderBy(
|
||||
`profileEmployee.firstName`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`ProfileEdit.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let [getProfileEdit, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const _data = getProfileEdit.map((item) => ({
|
||||
id: item.id,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue