Browse Source

查询应用接口/元素错误信息

dev
巴林闲侠 2 years ago
parent
commit
f58a6561cc
  1. 9
      api/.vscode/launch.json
  2. 32
      api/app/lib/controllers/alarm/app.js
  3. 5
      api/app/lib/controllers/project/bind.js

9
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",

32
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
}
}
}

5
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} 缺少必要参数`
}

Loading…
Cancel
Save