Merge branch 'develop' into dev
This commit is contained in:
commit
ef35f9dcc6
1 changed files with 31 additions and 2 deletions
|
|
@ -78,6 +78,8 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
results?: string | null;
|
results?: string | null;
|
||||||
reqedit?: string | null;
|
reqedit?: string | null;
|
||||||
evaluating?: boolean | null;
|
evaluating?: boolean | null;
|
||||||
|
sortBy?: string | null;
|
||||||
|
descending?: boolean | null;
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
// await new permission().PermissionList(request, "SYS_KPI_ROUND");
|
// await new permission().PermissionList(request, "SYS_KPI_ROUND");
|
||||||
|
|
@ -97,7 +99,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
// } else if (profileId == item.commanderHighId) {
|
// } else if (profileId == item.commanderHighId) {
|
||||||
// role = "COMMANDERHIGH";
|
// role = "COMMANDERHIGH";
|
||||||
// }
|
// }
|
||||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
let query = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||||
.createQueryBuilder("kpiUserEvaluation")
|
.createQueryBuilder("kpiUserEvaluation")
|
||||||
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||||
.andWhere(
|
.andWhere(
|
||||||
|
|
@ -185,6 +187,15 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.orderBy("kpiUserEvaluation.createdAt", "DESC")
|
.orderBy("kpiUserEvaluation.createdAt", "DESC")
|
||||||
|
|
||||||
|
if (requestBody.sortBy) {
|
||||||
|
query = query.orderBy(
|
||||||
|
`kpiUserEvaluation.${requestBody.sortBy}`,
|
||||||
|
requestBody.descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const [kpiUserEvaluation, total] = await query
|
||||||
.skip((requestBody.page - 1) * requestBody.pageSize)
|
.skip((requestBody.page - 1) * requestBody.pageSize)
|
||||||
.take(requestBody.pageSize)
|
.take(requestBody.pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
@ -1445,6 +1456,8 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
@Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
@Query("status") status?: string,
|
@Query("status") status?: string,
|
||||||
@Query("results") results?: string,
|
@Query("results") results?: string,
|
||||||
|
@Query("sortBy") sortBy?: string,
|
||||||
|
@Query("descending") descending?: boolean,
|
||||||
) {
|
) {
|
||||||
let profileId: any = null;
|
let profileId: any = null;
|
||||||
await new CallAPI()
|
await new CallAPI()
|
||||||
|
|
@ -1456,7 +1469,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
|
||||||
});
|
});
|
||||||
|
|
||||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
let query = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||||
.createQueryBuilder("kpiUserEvaluation")
|
.createQueryBuilder("kpiUserEvaluation")
|
||||||
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||||
.andWhere(
|
.andWhere(
|
||||||
|
|
@ -1486,6 +1499,22 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.orderBy("kpiUserEvaluation.createdAt", "DESC")
|
.orderBy("kpiUserEvaluation.createdAt", "DESC")
|
||||||
|
|
||||||
|
if (sortBy) {
|
||||||
|
if (["year", "durationKPI"].includes(sortBy)) {
|
||||||
|
query = query.orderBy(
|
||||||
|
`kpiPeriod.${sortBy}`,
|
||||||
|
descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
query = query.orderBy(
|
||||||
|
`kpiUserEvaluation.${sortBy}`,
|
||||||
|
descending ? "DESC" : "ASC"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const [kpiUserEvaluation, total] = await query
|
||||||
.skip((page - 1) * pageSize)
|
.skip((page - 1) * pageSize)
|
||||||
.take(pageSize)
|
.take(pageSize)
|
||||||
.getManyAndCount();
|
.getManyAndCount();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue