From 38aa24b5e30f17509020fa799a4f438115521699 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Thu, 29 Sep 2022 09:19:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=91=8A=E8=AD=A6=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=90=8D=E7=A7=B0=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/utils/dataRange.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/api/app/lib/utils/dataRange.js b/api/app/lib/utils/dataRange.js index ec055cf..650ab16 100644 --- a/api/app/lib/utils/dataRange.js +++ b/api/app/lib/utils/dataRange.js @@ -34,6 +34,18 @@ module.exports = function (app, opts) { findOption.where.id = { $in: correlationProject } } + let pepProjectWhereOptions = [] + if (keywordTarget == 'pepProject' && keyword) { + pepProjectWhereOptions.push(`t_pim_project.project_name LIKE '%${keyword}%'`) + findOption.where.name = { + $or: [{ + $eq: null + }, { + $like: `%${keyword}%` + }] + } + } + // TODO 这儿也许需要判断传进来的 pepProjectId 在不在当前用户的关注范围内 // 根据 poms 的项目绑定关系查相关联的项企项目、安心云项目id信息 const bindRes = await models.ProjectCorrelation.findAll(findOption) @@ -46,10 +58,7 @@ module.exports = function (app, opts) { } } // 查询项企项目的信息 - let pepProjectWhereOptions = [] - if (keywordTarget == 'pepProject' && keyword) { - pepProjectWhereOptions.push(`t_pim_project.project_name LIKE '%${keyword}%'`) - } + const pepProjectRes = pepProjectIds.length ? await clickHouse.projectManage.query( ` @@ -77,8 +86,9 @@ module.exports = function (app, opts) { // 获取不重复的 安心云项目 id const anxinProjectIds = [ ...( - // bindRes.filter(b => pepProjectRes.some(pp => pp.id == b.pepProjectId)) - bindRes + keywordTarget == 'pepProject' && keyword ? + bindRes.filter(b => b.name || pepProjectRes.some(pp => pp.id == b.pepProjectId)) : + bindRes ).reduce( (arr, b) => { for (let sid of b.anxinProjectId) {