|
|
@ -140,33 +140,55 @@ async function apiError (ctx) { |
|
|
|
throw '请标明告警类型 type' |
|
|
|
} |
|
|
|
|
|
|
|
let storageData = { |
|
|
|
projectAppId, alarmContent, router, statusCode, type |
|
|
|
} |
|
|
|
const existRes = await models.AppAlarm.findOne({ |
|
|
|
where: { |
|
|
|
projectAppId, alarmContent, router, statusCode, |
|
|
|
confirm: null, type |
|
|
|
} |
|
|
|
}) |
|
|
|
if (existRes) { |
|
|
|
await models.AppAlarm.update({ |
|
|
|
updateTime: now |
|
|
|
}, { |
|
|
|
const isRestore = statusCode == 200 || statusCode == 204 |
|
|
|
if (isRestore) { |
|
|
|
const existRes = await models.AppAlarm.findAll({ |
|
|
|
where: { |
|
|
|
id: existRes.id |
|
|
|
projectAppId, router, |
|
|
|
confirmTime: null, type |
|
|
|
} |
|
|
|
}) |
|
|
|
if (existRes.length) { |
|
|
|
await models.AppAlarm.update({ |
|
|
|
updateTime: now, |
|
|
|
confirmTime: now, |
|
|
|
confirmAuto: true, |
|
|
|
}, { |
|
|
|
where: { |
|
|
|
id: { $in: existRes.map(e => e.id) } |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
const existCount = await models.AppAlarm.count({ |
|
|
|
let storageData = { |
|
|
|
projectAppId, alarmContent, router, statusCode, type |
|
|
|
} |
|
|
|
const existRes = await models.AppAlarm.findOne({ |
|
|
|
where: { |
|
|
|
|
|
|
|
projectAppId, alarmContent, router, statusCode, |
|
|
|
confirmTime: null, type, |
|
|
|
} |
|
|
|
}) |
|
|
|
storageData.serialNumber = 'WEB' + (existCount < 9 ? '0' + (existCount + 1) : existCount) |
|
|
|
storageData.createTime = now |
|
|
|
storageData.screenshot = screenshot |
|
|
|
await models.AppAlarm.create(storageData) |
|
|
|
if (existRes) { |
|
|
|
await models.AppAlarm.update({ |
|
|
|
updateTime: now |
|
|
|
}, { |
|
|
|
where: { |
|
|
|
id: existRes.id |
|
|
|
} |
|
|
|
}) |
|
|
|
} else { |
|
|
|
const existCount = await models.AppAlarm.count({ |
|
|
|
where: { |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
storageData.serialNumber = 'WEB' + (existCount < 9 ? '0' + (existCount + 1) : existCount) |
|
|
|
storageData.createTime = now |
|
|
|
storageData.screenshot = screenshot |
|
|
|
await models.AppAlarm.create(storageData) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ctx.status = 200; |
|
|
@ -248,7 +270,7 @@ async function apiErrorList (ctx) { |
|
|
|
// findOption.where.screenshot = null
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
if(errType){ |
|
|
|
if (errType) { |
|
|
|
findOption.where.type = errType |
|
|
|
} |
|
|
|
if (confirmState) { |
|
|
|