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;
|
||||
reqedit?: string | null;
|
||||
evaluating?: boolean | null;
|
||||
sortBy?: string | null;
|
||||
descending?: boolean | null;
|
||||
},
|
||||
) {
|
||||
// await new permission().PermissionList(request, "SYS_KPI_ROUND");
|
||||
|
|
@ -97,7 +99,7 @@ export class KpiUserEvaluationController extends Controller {
|
|||
// } else if (profileId == item.commanderHighId) {
|
||||
// role = "COMMANDERHIGH";
|
||||
// }
|
||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
let query = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
.createQueryBuilder("kpiUserEvaluation")
|
||||
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||
.andWhere(
|
||||
|
|
@ -185,6 +187,15 @@ export class KpiUserEvaluationController extends Controller {
|
|||
}),
|
||||
)
|
||||
.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)
|
||||
.take(requestBody.pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
@ -1445,6 +1456,8 @@ export class KpiUserEvaluationController extends Controller {
|
|||
@Query("keyword") keyword?: string,
|
||||
@Query("status") status?: string,
|
||||
@Query("results") results?: string,
|
||||
@Query("sortBy") sortBy?: string,
|
||||
@Query("descending") descending?: boolean,
|
||||
) {
|
||||
let profileId: any = null;
|
||||
await new CallAPI()
|
||||
|
|
@ -1456,7 +1469,7 @@ export class KpiUserEvaluationController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ");
|
||||
});
|
||||
|
||||
const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
let query = await AppDataSource.getRepository(KpiUserEvaluation)
|
||||
.createQueryBuilder("kpiUserEvaluation")
|
||||
.leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod")
|
||||
.andWhere(
|
||||
|
|
@ -1486,6 +1499,22 @@ export class KpiUserEvaluationController extends Controller {
|
|||
},
|
||||
)
|
||||
.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)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue