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