feat: 实现统一日志系统和维护模式功能
This commit is contained in:
@@ -118,7 +118,7 @@ const Device = sequelize.define(
|
||||
}
|
||||
);
|
||||
|
||||
Device.belongsTo(Rack, { foreignKey: 'rackId' });
|
||||
Device.belongsTo(Warehouse, { foreignKey: 'warehouseId' });
|
||||
Device.belongsTo(Rack, { foreignKey: 'rackId', onDelete: 'SET NULL' });
|
||||
Device.belongsTo(Warehouse, { foreignKey: 'warehouseId', onDelete: 'SET NULL' });
|
||||
|
||||
module.exports = Device;
|
||||
|
||||
@@ -57,7 +57,7 @@ const Rack = sequelize.define(
|
||||
);
|
||||
|
||||
// 关联关系
|
||||
Rack.belongsTo(Room, { foreignKey: 'roomId' });
|
||||
Room.hasMany(Rack, { foreignKey: 'roomId' });
|
||||
Rack.belongsTo(Room, { foreignKey: 'roomId', onDelete: 'CASCADE' });
|
||||
Room.hasMany(Rack, { foreignKey: 'roomId', onDelete: 'CASCADE' });
|
||||
|
||||
module.exports = Rack;
|
||||
|
||||
@@ -65,7 +65,7 @@ const Ticket = sequelize.define(
|
||||
},
|
||||
reporterId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
allowNull: true,
|
||||
comment: '报修人ID',
|
||||
},
|
||||
reporterName: {
|
||||
@@ -139,8 +139,8 @@ const Ticket = sequelize.define(
|
||||
}
|
||||
);
|
||||
|
||||
Ticket.belongsTo(User, { foreignKey: 'reporterId', as: 'reporter', constraints: false });
|
||||
Ticket.belongsTo(User, { foreignKey: 'assigneeId', as: 'assignee', constraints: false });
|
||||
Ticket.belongsTo(Device, { foreignKey: 'deviceId', constraints: false });
|
||||
Ticket.belongsTo(User, { foreignKey: 'reporterId', as: 'reporter', onDelete: 'SET NULL' });
|
||||
Ticket.belongsTo(User, { foreignKey: 'assigneeId', as: 'assignee', onDelete: 'SET NULL' });
|
||||
Ticket.belongsTo(Device, { foreignKey: 'deviceId', onDelete: 'SET NULL' });
|
||||
|
||||
module.exports = Ticket;
|
||||
|
||||
Reference in New Issue
Block a user