diff --git a/api/.vscode/launch.json b/api/.vscode/launch.json index d6fafe8..d593d41 100644 --- a/api/.vscode/launch.json +++ b/api/.vscode/launch.json @@ -34,6 +34,8 @@ "--clickHouseUrl http://10.8.30.161", // "--clickHouseUrl https://clickhouse01.anxinyun.cn/play", "--clickHousePort 30123", + "--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 e21b6aa..c071b5e 100644 --- a/api/app/lib/controllers/alarm/app.js +++ b/api/app/lib/controllers/alarm/app.js @@ -210,8 +210,9 @@ async function apiErrorList (ctx) { }] }] } + let projectRes = [] if (keyword) { - const projectRes = await clickHouse.projectManage.query(` + projectRes = await clickHouse.projectManage.query(` ${pepProjectSql} WHERE project_name LIKE '%${keyword}%'` ).toPromise() @@ -221,7 +222,7 @@ async function apiErrorList (ctx) { '$projectApp.projectCorrelation.pep_project_id$': { $in: projectRes.map(p => p.id) }, - '$projectApp.name$':{$like:`%${keyword}%`} + '$projectApp.name$': { $like: `%${keyword}%` } } ) } @@ -264,6 +265,10 @@ async function apiErrorList (ctx) { const listRes = await models.AppAlarm.findAndCountAll(findOption) if (!keyword) { // 没有关键字筛选 查询关联的项目信息 + let pepProjectIds = new Set() + for(let lr of listRes){ + + } } ctx.status = 200; diff --git a/api/app/lib/service/clickHouseClient.js b/api/app/lib/service/clickHouseClient.js index 7534465..c0a0418 100644 --- a/api/app/lib/service/clickHouseClient.js +++ b/api/app/lib/service/clickHouseClient.js @@ -5,7 +5,7 @@ function factory (app, opts) { if (opts.clickHouse) { try { app.fs.clickHouse = {} - const { url, port, db = [] } = opts.clickHouse + const { url, port, user, password, db = [] } = opts.clickHouse for (let d of db) { if (d.name && d.db) { app.fs.clickHouse[d.name] = new ClickHouse({ @@ -13,6 +13,10 @@ function factory (app, opts) { port: port, debug: opts.dev, format: "json", + basicAuth: user && password ? { + username: user, + password: password, + } : null, config: { database: d.db, }, diff --git a/api/config.js b/api/config.js index 56c86eb..e0ffff4 100644 --- a/api/config.js +++ b/api/config.js @@ -69,6 +69,8 @@ const QINIU_SK = process.env.ANXINCLOUD_QINIU_SECRETKEY || flags.qnsk; // clickHouse const CLICKHOUST_URL = process.env.CLICKHOUST_URL || flags.clickHouseUrl const CLICKHOUST_PORT = process.env.CLICKHOUST_PORT || flags.clickHousePort +const CLICKHOUST_USER = process.env.CLICKHOUST_USER || flags.clickHouseUser +const CLICKHOUST_PASSWORD = process.env.CLICKHOUST_PASSWORD || flags.clickHousePassword const CLICKHOUST_ANXINCLOUD = process.env.CLICKHOUST_ANXINCLOUD || flags.clickHouseAnxincloud const CLICKHOUST_PEP_EMIS = process.env.CLICKHOUST_PEP_EMIS || flags.clickHousePepEmis const CLICKHOUST_PROJECT_MANAGE = process.env.CLICKHOUST_PROJECT_MANAGE || flags.clickHouseProjectManage @@ -155,6 +157,8 @@ const product = { clickHouse: { url: CLICKHOUST_URL, port: CLICKHOUST_PORT, + user: CLICKHOUST_USER, + password: CLICKHOUST_PASSWORD, db: [{ name: 'anxinyun', db: CLICKHOUST_ANXINCLOUD