revert /api/v1/kpi/period
This commit is contained in:
parent
254d6ae810
commit
1a402f4647
1 changed files with 3 additions and 15 deletions
|
|
@ -302,27 +302,15 @@ export class kpiPeriodController extends Controller {
|
|||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("year") year?: number,
|
||||
@Query("keyword") keyword?: string,
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let query = await AppDataSource.getRepository(KpiPeriod)
|
||||
const [kpiPeriod,total] = await AppDataSource.getRepository(KpiPeriod)
|
||||
.createQueryBuilder("kpiPeriod")
|
||||
.andWhere(
|
||||
year !== 0 && year != null && year != undefined ? "kpiPeriod.year = :year" : "1=1",
|
||||
{ year: year },
|
||||
)
|
||||
|
||||
if (sortBy) {
|
||||
query = query.orderBy(
|
||||
`developmentRequest.${sortBy}`,
|
||||
descending ? "DESC" : "ASC"
|
||||
);
|
||||
}else{
|
||||
query = query.orderBy("kpiPeriod.year", "DESC")
|
||||
.addOrderBy("kpiPeriod.createdAt", "DESC")
|
||||
}
|
||||
|
||||
const [kpiPeriod, total] = await query
|
||||
.orderBy("kpiPeriod.year", "DESC")
|
||||
.addOrderBy("kpiPeriod.createdAt", "DESC")
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue