From ba0419d1f1a5cf4c479ec90e2889e44ac523c90c Mon Sep 17 00:00:00 2001 From: wuqun Date: Thu, 27 Oct 2022 14:32:05 +0800 Subject: [PATCH] =?UTF-8?q?(*)=E6=8E=A7=E5=88=B6=E5=8F=B0-=E6=9C=80?= =?UTF-8?q?=E6=96=B0=E5=8A=A8=E6=80=81=E6=9F=A5=E8=AF=A2=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/control/data.js | 16 +++++++++++----- api/app/lib/index.js | 5 ++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/api/app/lib/controllers/control/data.js b/api/app/lib/controllers/control/data.js index 6d97f7c..f66e691 100644 --- a/api/app/lib/controllers/control/data.js +++ b/api/app/lib/controllers/control/data.js @@ -203,7 +203,11 @@ async function getLatestDynamic(ctx) { }, { model: models.AlarmAppearRecord }, { - model: models.EmailSendLog + model: models.EmailSendLog, + include: [{ + model: models.AlarmPushConfig, + attributes: ['id', 'name'], + }] }, { model: models.AlarmConfirmLog }], @@ -219,7 +223,9 @@ async function getLatestDynamic(ctx) { pepPojectIds.add(p.projectCorrelation.pepProjectId); if (p.emailSendLog) { - notedUserIds.add(p.emailSendLog.toPepUserId);//通知 接收人 + p.emailSendLog.toPepUserIds.map(u => { + notedUserIds.add(u);//通知 接收人 + }) } if (p.alarmConfirmLog && p.alarmConfirmLog.pepUserId) { notedUserIds.add(p.alarmConfirmLog.pepUserId);//确认 操作者 @@ -240,14 +246,14 @@ async function getLatestDynamic(ctx) { if (d.alarmAppearId) { appear.push({ projectName, - ...d.alarmAppearRecord + ...d.alarmAppearRecord.dataValues }); } if (d.emailSendId) { notice.push({ - userName: userPepRes.find(u => u.id == d.emailSendLog.toPepUserId).name, + userName: userPepRes.find(u => d.emailSendLog.toPepUserIds.indexOf(u.id) != -1), projectName, - ...d.emailSendLog + ...d.emailSendLog.dataValues }); } if (d.alarmConfirmId) { diff --git a/api/app/lib/index.js b/api/app/lib/index.js index 10a1b33..d33bbb7 100644 --- a/api/app/lib/index.js +++ b/api/app/lib/index.js @@ -58,7 +58,7 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq }); const { - AppInspection, ProjectApp, ProjectCorrelation, AppAlarm, App, AlarmAppearRecord, AlarmConfirmLog, EmailSendLog, LatestDynamicList + AppInspection, ProjectApp, ProjectCorrelation, AppAlarm, App, AlarmAppearRecord, AlarmConfirmLog, EmailSendLog, LatestDynamicList, AlarmPushConfig } = dc.models; AppInspection.belongsTo(App, { foreignKey: 'projectAppId', targetKey: 'id' }); @@ -88,6 +88,9 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq EmailSendLog.belongsTo(ProjectCorrelation, { foreignKey: 'projectCorrelationId', targetKey: 'id' }); ProjectCorrelation.hasMany(EmailSendLog, { foreignKey: 'projectCorrelationId', sourceKey: 'id' }); + EmailSendLog.belongsTo(AlarmPushConfig, { foreignKey: 'pushConfigId', targetKey: 'id' }); + AlarmPushConfig.hasMany(EmailSendLog, { foreignKey: 'pushConfigId', sourceKey: 'id' }); + LatestDynamicList.belongsTo(AlarmAppearRecord, { foreignKey: 'alarmAppearId', targetKey: 'id' }); AlarmAppearRecord.hasMany(LatestDynamicList, { foreignKey: 'alarmAppearId', sourceKey: 'id' });