From 5c1e691424978961462bd8ea84de2794125f0ea4 Mon Sep 17 00:00:00 2001 From: Moss <> Date: Mon, 16 Jun 2025 22:11:33 +0700 Subject: [PATCH] search dna --- .../KpiUserDevelopmentController.ts | 29 ++++--- .../KpiUserEvaluationController.ts | 84 ++++++++++++++++--- 2 files changed, 91 insertions(+), 22 deletions(-) diff --git a/src/controllers/KpiUserDevelopmentController.ts b/src/controllers/KpiUserDevelopmentController.ts index 0e80e5b..8b71573 100644 --- a/src/controllers/KpiUserDevelopmentController.ts +++ b/src/controllers/KpiUserDevelopmentController.ts @@ -30,6 +30,7 @@ import { DevelopmentProject } from "../entities/developmentProject"; import { RequestWithUser } from "../middlewares/user"; import permission from "../interfaces/permission"; import { setLogDataDiff } from "../interfaces/utils"; +import CallAPI from "../interfaces/call-api"; @Route("api/v1/kpi/user/achievement/development") @Tags("KpiUserDevelopment") @@ -361,7 +362,13 @@ export class KpiUserDevelopmentController extends Controller { // await new permission().PermissionList(request, "SYS_RESULT"); let conditionFullName = "CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword"; - let _data = await new permission().PermissionOrgList(request,"SYS_RESULT"); + let _data = await new permission().PermissionOrgList(request, "SYS_RESULT"); + await new CallAPI() + .PostData(request, "/org/finddna", _data) + .then((x) => { + _data = x; + }) + .catch((x) => {}); const [kpiUserDevelopment, total] = await AppDataSource.getRepository(KpiUserDevelopment) .createQueryBuilder("kpiUserDevelopment") .leftJoinAndSelect("kpiUserDevelopment.kpiUserEvaluation", "kpiUserEvaluation") @@ -370,8 +377,8 @@ export class KpiUserDevelopmentController extends Controller { .andWhere( _data.root != undefined && _data.root != null ? _data.root[0] != null - ? `kpiUserEvaluation.orgId IN (:...root)` - : `kpiUserEvaluation.orgId is null` + ? `kpiUserEvaluation.rootDnaId IN (:...root)` + : `kpiUserEvaluation.rootDnaId is null` : "1=1", { root: _data.root, @@ -380,8 +387,8 @@ export class KpiUserDevelopmentController extends Controller { .andWhere( _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null - ? `kpiUserEvaluation.child1Id IN (:...child1)` - : `kpiUserEvaluation.child1Id is null` + ? `kpiUserEvaluation.child1DnaId IN (:...child1)` + : `kpiUserEvaluation.child1DnaId is null` : "1=1", { child1: _data.child1, @@ -390,8 +397,8 @@ export class KpiUserDevelopmentController extends Controller { .andWhere( _data.child2 != undefined && _data.child2 != null ? _data.child2[0] != null - ? `kpiUserEvaluation.child2Id IN (:...child2)` - : `kpiUserEvaluation.child2Id is null` + ? `kpiUserEvaluation.child2DnaId IN (:...child2)` + : `kpiUserEvaluation.child2DnaId is null` : "1=1", { child2: _data.child2, @@ -400,8 +407,8 @@ export class KpiUserDevelopmentController extends Controller { .andWhere( _data.child3 != undefined && _data.child3 != null ? _data.child3[0] != null - ? `kpiUserEvaluation.child3Id IN (:...child3)` - : `kpiUserEvaluation.child3Id is null` + ? `kpiUserEvaluation.child3DnaId IN (:...child3)` + : `kpiUserEvaluation.child3DnaId is null` : "1=1", { child3: _data.child3, @@ -410,8 +417,8 @@ export class KpiUserDevelopmentController extends Controller { .andWhere( _data.child4 != undefined && _data.child4 != null ? _data.child4[0] != null - ? `kpiUserEvaluation.child4Id IN (:...child4)` - : `kpiUserEvaluation.child4Id is null` + ? `kpiUserEvaluation.child4DnaId IN (:...child4)` + : `kpiUserEvaluation.child4DnaId is null` : "1=1", { child4: _data.child4, diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index b78feda..e97caa6 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -232,13 +232,19 @@ export class KpiUserEvaluationController extends Controller { let conditionFullName = "CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword"; let _data = await new permission().PermissionOrgList(request, "SYS_RESULT"); + await new CallAPI() + .PostData(request, "/org/finddna", _data) + .then((x) => { + _data = x; + }) + .catch((x) => {}); const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation) .createQueryBuilder("kpiUserEvaluation") .andWhere( _data.root != undefined && _data.root != null ? _data.root[0] != null - ? `kpiUserEvaluation.orgId IN (:...root)` - : `kpiUserEvaluation.orgId is null` + ? `kpiUserEvaluation.orgDnaId IN (:...root)` + : `kpiUserEvaluation.orgDnaId is null` : "1=1", { root: _data.root, @@ -247,8 +253,8 @@ export class KpiUserEvaluationController extends Controller { .andWhere( _data.child1 != undefined && _data.child1 != null ? _data.child1[0] != null - ? `kpiUserEvaluation.child1Id IN (:...child1)` - : `kpiUserEvaluation.child1Id is null` + ? `kpiUserEvaluation.child1DnaId IN (:...child1)` + : `kpiUserEvaluation.child1DnaId is null` : "1=1", { child1: _data.child1, @@ -257,8 +263,8 @@ export class KpiUserEvaluationController extends Controller { .andWhere( _data.child2 != undefined && _data.child2 != null ? _data.child2[0] != null - ? `kpiUserEvaluation.child2Id IN (:...child2)` - : `kpiUserEvaluation.child2Id is null` + ? `kpiUserEvaluation.child2DnaId IN (:...child2)` + : `kpiUserEvaluation.child2DnaId is null` : "1=1", { child2: _data.child2, @@ -267,8 +273,8 @@ export class KpiUserEvaluationController extends Controller { .andWhere( _data.child3 != undefined && _data.child3 != null ? _data.child3[0] != null - ? `kpiUserEvaluation.child3Id IN (:...child3)` - : `kpiUserEvaluation.child3Id is null` + ? `kpiUserEvaluation.child3DnaId IN (:...child3)` + : `kpiUserEvaluation.child3DnaId is null` : "1=1", { child3: _data.child3, @@ -277,8 +283,8 @@ export class KpiUserEvaluationController extends Controller { .andWhere( _data.child4 != undefined && _data.child4 != null ? _data.child4[0] != null - ? `kpiUserEvaluation.child4Id IN (:...child4)` - : `kpiUserEvaluation.child4Id is null` + ? `kpiUserEvaluation.child4DnaId IN (:...child4)` + : `kpiUserEvaluation.child4DnaId is null` : "1=1", { child4: _data.child4, @@ -397,7 +403,13 @@ export class KpiUserEvaluationController extends Controller { results?: string | null; }, ) { - await new permission().PermissionList(request, "SYS_KPI_LIST"); + let _data = await new permission().PermissionOrgList(request, "SYS_KPI_LIST"); + await new CallAPI() + .PostData(request, "/org/finddna", _data) + .then((x) => { + _data = x; + }) + .catch((x) => {}); let conditionFullName = "CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword"; const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation) @@ -459,6 +471,56 @@ export class KpiUserEvaluationController extends Controller { }); }), ) + .andWhere( + _data.root != undefined && _data.root != null + ? _data.root[0] != null + ? `kpiUserEvaluation.orgDnaId IN (:...root)` + : `kpiUserEvaluation.orgDnaId is null` + : "1=1", + { + root: _data.root, + }, + ) + .andWhere( + _data.child1 != undefined && _data.child1 != null + ? _data.child1[0] != null + ? `kpiUserEvaluation.child1DnaId IN (:...child1)` + : `kpiUserEvaluation.child1DnaId is null` + : "1=1", + { + child1: _data.child1, + }, + ) + .andWhere( + _data.child2 != undefined && _data.child2 != null + ? _data.child2[0] != null + ? `kpiUserEvaluation.child2DnaId IN (:...child2)` + : `kpiUserEvaluation.child2DnaId is null` + : "1=1", + { + child2: _data.child2, + }, + ) + .andWhere( + _data.child3 != undefined && _data.child3 != null + ? _data.child3[0] != null + ? `kpiUserEvaluation.child3DnaId IN (:...child3)` + : `kpiUserEvaluation.child3DnaId is null` + : "1=1", + { + child3: _data.child3, + }, + ) + .andWhere( + _data.child4 != undefined && _data.child4 != null + ? _data.child4[0] != null + ? `kpiUserEvaluation.child4DnaId IN (:...child4)` + : `kpiUserEvaluation.child4DnaId is null` + : "1=1", + { + child4: _data.child4, + }, + ) .orderBy("kpiPeriod.year", "DESC") .addOrderBy("kpiUserEvaluation.createdAt", "DESC") .skip((requestBody.page - 1) * requestBody.pageSize)