Browse Source

应用告警查询接口

dev
巴林闲侠 2 years ago
parent
commit
4b2ce5d77a
  1. 22
      api/app/lib/controllers/alarm/app.js

22
api/app/lib/controllers/alarm/app.js

@ -198,7 +198,7 @@ async function apiErrorList (ctx) {
$or: []
},
include: [{
model: models.ProjectApp,
model: models.App,
where: {
},
@ -225,10 +225,10 @@ async function apiErrorList (ctx) {
if (projectRes.length) {
findOption.where.$or.push(
{
'$projectApp.projectCorrelation.pep_project_id$': {
'$app->projectCorrelations.pep_project_id$': {
$in: projectRes.map(p => p.id)
},
'$projectApp.name$': { $like: `%${keyword}%` }
'$app.name$': { $like: `%${keyword}%` }
}
)
}
@ -276,8 +276,10 @@ async function apiErrorList (ctx) {
// 没有关键字筛选 查询关联的项目信息
let pepProjectIds = new Set()
for (let lr of listRes.rows) {
if (lr.projectApp && lr.projectApp.projectCorrelation) {
pepProjectIds.add(lr.projectApp.projectCorrelation.pepProjectId)
if (lr.app && lr.app.projectCorrelations) {
for (let p of lr.app.projectCorrelations) {
pepProjectIds.add(p.pepProjectId)
}
}
}
if (pepProjectIds.size) {
@ -289,10 +291,12 @@ async function apiErrorList (ctx) {
}
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
if (lr.app && lr.app.projectCorrelations) {
for (let p of lr.app.projectCorrelations) {
let corPepProject = projectRes.find(pr => pr.id == p.pepProjectId)
if (corPepProject) {
p.dataValues.pepProject = corPepProject
}
}
}
}

Loading…
Cancel
Save