1. 新增操作日志记录功能,记录关键操作 2. 实现危险操作确认对话框,防止误删 3. 添加业务和库房管理模块 4. 支持设备标记为空闲状态 5. 完善API文档和健康检查 6. 优化前端删除操作的确认流程 7. 添加Swagger API文档支持 8. 实现设备与业务的关联功能 9. 改进设备模型,添加空闲相关字段 10. 优化用户、角色管理操作日志
58 lines
1.2 KiB
JavaScript
58 lines
1.2 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const { sequelize } = require('../db');
|
|
const Device = require('./Device');
|
|
const Business = require('./Business');
|
|
|
|
const DeviceBusiness = sequelize.define('DeviceBusiness', {
|
|
id: {
|
|
type: DataTypes.INTEGER,
|
|
primaryKey: true,
|
|
autoIncrement: true
|
|
},
|
|
deviceId: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
references: {
|
|
model: Device,
|
|
key: 'deviceId'
|
|
}
|
|
},
|
|
businessId: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
references: {
|
|
model: Business,
|
|
key: 'businessId'
|
|
}
|
|
},
|
|
isPrimary: {
|
|
type: DataTypes.BOOLEAN,
|
|
defaultValue: false
|
|
}
|
|
}, {
|
|
tableName: 'device_business',
|
|
timestamps: true,
|
|
indexes: [
|
|
{ fields: ['deviceId'] },
|
|
{ fields: ['businessId'] },
|
|
{ unique: true, fields: ['deviceId', 'businessId'] }
|
|
]
|
|
});
|
|
|
|
Device.belongsToMany(Business, {
|
|
through: DeviceBusiness,
|
|
foreignKey: 'deviceId',
|
|
otherKey: 'businessId'
|
|
});
|
|
|
|
Business.belongsToMany(Device, {
|
|
through: DeviceBusiness,
|
|
foreignKey: 'businessId',
|
|
otherKey: 'deviceId'
|
|
});
|
|
|
|
DeviceBusiness.belongsTo(Business, { foreignKey: 'businessId' });
|
|
DeviceBusiness.belongsTo(Device, { foreignKey: 'deviceId' });
|
|
|
|
module.exports = DeviceBusiness;
|