diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index d593d41..524c11d 100644 --- a/api/.vscode/launch.json +++ b/api/.vscode/launch.json @@ -7,7 +7,7 @@ { "type": "node", "request": "launch", - "name": "启动API", + "name": "启动 API", "program": "${workspaceRoot}/server.js", "env": { "NODE_ENV": "development" @@ -34,8 +34,11 @@ "--clickHouseUrl http://10.8.30.161", // "--clickHouseUrl https://clickhouse01.anxinyun.cn/play", "--clickHousePort 30123", - "--clickHouseUser ", - "--clickHousePassword ", + + // 似乎不能传空 先注释 * 2 + // "--clickHouseUser ", + // "--clickHousePassword ", + "--clickHouseAnxincloud Anxinyun8", "--clickHousePepEmis pepca8", "--clickHouseProjectManage peppm8", diff --git a/api/app/lib/controllers/alarm/app.js b/api/app/lib/controllers/alarm/app.js index c071b5e..6ad6898 100644 --- a/api/app/lib/controllers/alarm/app.js +++ b/api/app/lib/controllers/alarm/app.js @@ -201,12 +201,18 @@ async function apiErrorList (ctx) { model: models.ProjectApp, where: { + }, + attributes: { + exclude: ['projectId'] }, include: [{ model: models.ProjectCorrelation, where: { - } + }, + attributes: { + exclude: ['createTime', 'createUser', 'anxinProjectId',] + }, }] }] } @@ -262,12 +268,32 @@ async function apiErrorList (ctx) { if (page && limit) { findOption.offset = page * limit } + if (!findOption.where.$or.length) { + delete findOption.where.$or + } const listRes = await models.AppAlarm.findAndCountAll(findOption) if (!keyword) { // 没有关键字筛选 查询关联的项目信息 let pepProjectIds = new Set() - for(let lr of listRes){ - + for (let lr of listRes.rows) { + if (lr.projectApp && lr.projectApp.projectCorrelation) { + pepProjectIds.add(lr.projectApp.projectCorrelation.pepProjectId) + } + } + if (pepProjectIds.size) { + projectRes = await clickHouse.projectManage.query(` + ${pepProjectSql} + WHERE id IN (${[...pepProjectIds].join(',')})` + ).toPromise() + } + } + + for (let lr of listRes.rows) { + if (lr.projectApp && lr.projectApp.projectCorrelation) { + let corPepProject = projectRes.find(p => p.id == lr.projectApp.projectCorrelation.pepProjectId) + if (corPepProject) { + lr.projectApp.projectCorrelation.dataValues.pepProject = corPepProject + } } } diff --git a/api/app/lib/controllers/project/bind.js b/api/app/lib/controllers/project/bind.js index 7359a00..2ea45be 100644 --- a/api/app/lib/controllers/project/bind.js +++ b/api/app/lib/controllers/project/bind.js @@ -39,7 +39,7 @@ async function bindAnxin2pep (ctx) { throw '尚无已绑定的项企项目' } if (name) { - + } await models.ProjectCorrelation.update(storageData, { where: { @@ -76,6 +76,9 @@ async function bindAnxin2pep (ctx) { } app.forEach((a, i, arr) => { + if (!a.name && !a.url) { + return + } if (!a.name || !a.url) { throw `${a.name} ${a.url} 缺少必要参数` }