|
@ -54,7 +54,8 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const { Department, User, UserResource, Resource, Project, Point, PatrolPlan, |
|
|
const { Department, User, UserResource, Resource, Project, Point, PatrolPlan, |
|
|
CheckItems, CheckItemsGroup, PatrolTemplate |
|
|
CheckItems, CheckItemsGroup, |
|
|
|
|
|
PatrolTemplate, PatrolTemplateCheckItems |
|
|
} = dc.models; |
|
|
} = dc.models; |
|
|
|
|
|
|
|
|
UserResource.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' }); |
|
|
UserResource.belongsTo(User, { foreignKey: 'userId', targetKey: 'id' }); |
|
@ -63,6 +64,9 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq |
|
|
PatrolTemplate.belongsTo(User, { foreignKey: 'createUserId', targetKey: 'id' }); |
|
|
PatrolTemplate.belongsTo(User, { foreignKey: 'createUserId', targetKey: 'id' }); |
|
|
User.hasMany(PatrolTemplate, { foreignKey: 'createUserId', sourceKey: 'id' }); |
|
|
User.hasMany(PatrolTemplate, { foreignKey: 'createUserId', sourceKey: 'id' }); |
|
|
|
|
|
|
|
|
|
|
|
CheckItems.belongsToMany(PatrolTemplate, { through: PatrolTemplateCheckItems, foreignKey: 'templateId', otherKey: 'checkItemsId' }); |
|
|
|
|
|
PatrolTemplate.belongsToMany(CheckItems, { through: PatrolTemplateCheckItems, foreignKey: 'templateId', otherKey: 'checkItemsId' }); |
|
|
|
|
|
|
|
|
UserResource.belongsTo(Resource, { foreignKey: 'resourceId', targetKey: 'code' }); |
|
|
UserResource.belongsTo(Resource, { foreignKey: 'resourceId', targetKey: 'code' }); |
|
|
Resource.hasMany(UserResource, { foreignKey: 'resourceId', sourceKey: 'code' }); |
|
|
Resource.hasMany(UserResource, { foreignKey: 'resourceId', sourceKey: 'code' }); |
|
|
Resource.hasMany(Resource, { foreignKey: 'parentResource', sourceKey: 'code' }); |
|
|
Resource.hasMany(Resource, { foreignKey: 'parentResource', sourceKey: 'code' }); |
|
|