From d4ae890a9fcc46d530f35502b554b80ab6d8f153 Mon Sep 17 00:00:00 2001 From: "gao.zhiyuan" Date: Tue, 20 Sep 2022 16:29:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=BA=94=E7=94=A8=E5=B7=A1?= =?UTF-8?q?=E6=A3=80=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/alarm/app.js | 2 +- api/app/lib/index.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/app/lib/controllers/alarm/app.js b/api/app/lib/controllers/alarm/app.js index 6ad6898..cd0950e 100644 --- a/api/app/lib/controllers/alarm/app.js +++ b/api/app/lib/controllers/alarm/app.js @@ -42,7 +42,7 @@ async function inspectionList (ctx) { }, order: [['id', 'DESC']], include: [{ - model: models.ProjectApp, + model: models.App, required: true, where: appId ? { id: appId diff --git a/api/app/lib/index.js b/api/app/lib/index.js index ece53c4..21063b4 100644 --- a/api/app/lib/index.js +++ b/api/app/lib/index.js @@ -69,6 +69,8 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq ProjectCorrelation.belongsToMany(App, { through: ProjectApp, foreignKey: 'projectId', otherKey: 'appId' }); + App.belongsToMany(ProjectCorrelation, { through: ProjectApp, foreignKey: 'appId', otherKey: 'projectId' }); + AppAlarm.belongsTo(App, { foreignKey: 'projectAppId', targetKey: 'id' }); App.hasMany(AppAlarm, { foreignKey: 'projectAppId', sourceKey: 'id' }); };