sort
This commit is contained in:
parent
2a9f69f736
commit
77918a4b6b
2 changed files with 68 additions and 4 deletions
|
|
@ -9781,6 +9781,8 @@ export class ProfileController extends Controller {
|
||||||
rootId?: string;
|
rootId?: string;
|
||||||
year: number;
|
year: number;
|
||||||
period: string;
|
period: string;
|
||||||
|
sortBy?: string;
|
||||||
|
descending?: boolean;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const findRevision = await this.orgRevisionRepo.findOne({
|
const findRevision = await this.orgRevisionRepo.findOne({
|
||||||
|
|
@ -9790,7 +9792,7 @@ export class ProfileController extends Controller {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
}
|
}
|
||||||
|
|
||||||
const [findPosMaster, total] = await AppDataSource.getRepository(PosMaster)
|
let query = await AppDataSource.getRepository(PosMaster)
|
||||||
.createQueryBuilder("posMaster")
|
.createQueryBuilder("posMaster")
|
||||||
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
|
.leftJoinAndSelect("posMaster.current_holder", "current_holder")
|
||||||
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
||||||
|
|
@ -9923,7 +9925,37 @@ export class ProfileController extends Controller {
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orderBy("current_holder.citizenId", "ASC")
|
|
||||||
|
if (body.sortBy) {
|
||||||
|
if(body.sortBy === "posType"){
|
||||||
|
query = query.orderBy(
|
||||||
|
`posType.posTypeName`,
|
||||||
|
body.descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}else if(body.sortBy === "posLevel"){
|
||||||
|
query = query.orderBy(
|
||||||
|
`posLevel.posLevelName`,
|
||||||
|
body.descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}else if(body.sortBy === "orgShortName" || body.sortBy === "posMasterNo"){
|
||||||
|
query = query
|
||||||
|
.orderBy(`orgRoot.orgRootShortName`,body.descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`orgChild1.orgChild1ShortName`,body.descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`orgChild2.orgChild2ShortName`,body.descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`orgChild3.orgChild3ShortName`,body.descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`orgChild4.orgChild4ShortName`,body.descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`posMaster.posMasterNo`,body.descending ? "DESC" : "ASC")
|
||||||
|
}else{
|
||||||
|
query = query.orderBy(
|
||||||
|
`current_holder.${body.sortBy}`,
|
||||||
|
body.descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
query = query.orderBy("current_holder.citizenId", "ASC")
|
||||||
|
}
|
||||||
|
|
||||||
|
const [findPosMaster, total] = await query
|
||||||
.skip((body.page - 1) * body.pageSize)
|
.skip((body.page - 1) * body.pageSize)
|
||||||
.take(body.pageSize)
|
.take(body.pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
|
||||||
|
|
@ -4981,6 +4981,8 @@ export class ProfileEmployeeController extends Controller {
|
||||||
rootId?: string;
|
rootId?: string;
|
||||||
year: number;
|
year: number;
|
||||||
period: string;
|
period: string;
|
||||||
|
sortBy?: string;
|
||||||
|
descending?: boolean;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const findRevision = await this.orgRevisionRepo.findOne({
|
const findRevision = await this.orgRevisionRepo.findOne({
|
||||||
|
|
@ -4990,7 +4992,7 @@ export class ProfileEmployeeController extends Controller {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||||
}
|
}
|
||||||
|
|
||||||
const [findPosMaster, total] = await AppDataSource.getRepository(EmployeePosMaster)
|
let query = await AppDataSource.getRepository(EmployeePosMaster)
|
||||||
.createQueryBuilder("employeePosMaster")
|
.createQueryBuilder("employeePosMaster")
|
||||||
.leftJoinAndSelect("employeePosMaster.current_holder", "current_holder")
|
.leftJoinAndSelect("employeePosMaster.current_holder", "current_holder")
|
||||||
.leftJoinAndSelect("employeePosMaster.orgRoot", "orgRoot")
|
.leftJoinAndSelect("employeePosMaster.orgRoot", "orgRoot")
|
||||||
|
|
@ -5122,10 +5124,40 @@ export class ProfileEmployeeController extends Controller {
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orderBy("current_holder.citizenId", "ASC")
|
|
||||||
|
if (body.sortBy) {
|
||||||
|
if(body.sortBy === "posType"){
|
||||||
|
query = query.orderBy(
|
||||||
|
`posType.posTypeName`,
|
||||||
|
body.descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}else if(body.sortBy === "posLevel"){
|
||||||
|
query = query
|
||||||
|
.orderBy(`posType.posTypeShortName`,body.descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`posLevel.posLevelName`,body.descending ? "DESC" : "ASC");
|
||||||
|
}else if(body.sortBy === "orgShortName" || body.sortBy === "posMasterNo"){
|
||||||
|
query = query
|
||||||
|
.orderBy(`orgRoot.orgRootShortName`,body.descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`orgChild1.orgChild1ShortName`,body.descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`orgChild2.orgChild2ShortName`,body.descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`orgChild3.orgChild3ShortName`,body.descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`orgChild4.orgChild4ShortName`,body.descending ? "DESC" : "ASC")
|
||||||
|
.addOrderBy(`employeePosMaster.posMasterNo`,body.descending ? "DESC" : "ASC")
|
||||||
|
}else{
|
||||||
|
query = query.orderBy(
|
||||||
|
`current_holder.${body.sortBy}`,
|
||||||
|
body.descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
query = query.orderBy("current_holder.citizenId", "ASC")
|
||||||
|
}
|
||||||
|
|
||||||
|
const [findPosMaster, total] = await query
|
||||||
.skip((body.page - 1) * body.pageSize)
|
.skip((body.page - 1) * body.pageSize)
|
||||||
.take(body.pageSize)
|
.take(body.pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
||||||
if (!findPosMaster) {
|
if (!findPosMaster) {
|
||||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. PosMaster");
|
throw new HttpError(HttpStatus.NOT_FOUND, "not found. PosMaster");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue