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' });