sort probation
This commit is contained in:
parent
5be3635198
commit
8af006bae3
1 changed files with 31 additions and 2 deletions
|
|
@ -9103,6 +9103,8 @@ export class ProfileController extends Controller {
|
|||
page: number;
|
||||
pageSize: number;
|
||||
keyword?: string;
|
||||
sortBy?: string;
|
||||
descending?: boolean;
|
||||
},
|
||||
) {
|
||||
let _data: any = {
|
||||
|
|
@ -9116,7 +9118,7 @@ export class ProfileController extends Controller {
|
|||
if (!request.user.role.includes("SUPER_ADMIN")) {
|
||||
_data = await new permission().PermissionOrgCreate(request, "SYS_PROBATION");
|
||||
}
|
||||
const [findProfile, total] = await AppDataSource.getRepository(Profile)
|
||||
let query = await AppDataSource.getRepository(Profile)
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.profileSalary", "profileSalary")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
|
|
@ -9230,7 +9232,34 @@ export class ProfileController extends Controller {
|
|||
);
|
||||
}),
|
||||
)
|
||||
.orderBy("profile.citizenId", "ASC")
|
||||
|
||||
if (body.sortBy) {
|
||||
if(body.sortBy === "posLevelName"){
|
||||
query = query.orderBy(
|
||||
`posLevel.posLevelName`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(body.sortBy === "posTypeName"){
|
||||
query = query.orderBy(
|
||||
`posType.posTypeName`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else if(body.sortBy === "commandNo"){
|
||||
query = query.orderBy(
|
||||
`profileSalary.commandNo`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy(
|
||||
`profile.${body.sortBy}`,
|
||||
body.descending ? "DESC" : "ASC"
|
||||
);
|
||||
}
|
||||
}else{
|
||||
query = query.orderBy("profile.citizenId", "ASC")
|
||||
}
|
||||
|
||||
const [findProfile, total] = await query
|
||||
.skip((body.page - 1) * body.pageSize)
|
||||
.take(body.pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue