diff --git a/src/controllers/KpiEvaluationController.ts b/src/controllers/KpiEvaluationController.ts index 9f6dcc6..6dd5406 100644 --- a/src/controllers/KpiEvaluationController.ts +++ b/src/controllers/KpiEvaluationController.ts @@ -64,15 +64,12 @@ export class kpiEvaluationController extends Controller { /** * API list เกณฑ์การประเมิน - * @param page - * @param pageSize */ @Get() async listKpiEvaluation( @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Query("keyword") keyword?: string, - @Query("status") status?: string, ) { let whereClause: any = {}; @@ -85,9 +82,6 @@ export class kpiEvaluationController extends Controller { const [kpiEvaluation, total] = await this.kpiEvaluationRepository.findAndCount({ ...whereClause, - ...(status == null || status == undefined - ? {} - : { evaluationStatus: status.trim().toUpperCase() }), ...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }), order: { level: "DESC", diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 0c8e8fd..8ea7619 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -241,7 +241,7 @@ export class KpiUserEvaluationController extends Controller { async listKpiUserCommanderEvaluation(@Path() id: string, @Path() type: string) { const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRepository.find({ where: { kpiUserEvaluationId: id, type: type.trim().toUpperCase() }, - order: { createdAt: "ASC" } + order: { createdAt: "ASC" }, }); return new HttpSuccess(kpiUserEvaluationReason); } @@ -333,16 +333,25 @@ export class KpiUserEvaluationController extends Controller { */ @Get() async listKpiUserEvaluation( + @Request() request: { user: Record }, @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Query("kpiPeriodId") kpiPeriodId?: string, - // @Query("keyword") keyword?: string, + @Query("keyword") keyword?: string, + @Query("status") status?: string, ) { const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation) .createQueryBuilder("kpiUserEvaluation") .andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", { kpiPeriodId: kpiPeriodId, }) + .andWhere({ createdUserId: request.user.sub }) + .andWhere( + status == null || status == undefined ? "1=1" : "evaluationStatus LIKE :evaluationStatus", + { + evaluationStatus: status == undefined ? "" : status.trim().toUpperCase(), + }, + ) .orderBy("kpiUserEvaluation.createdAt", "ASC") .skip((page - 1) * pageSize) .take(pageSize)