refactor: 统一代码风格并迁移至 ESLint 新配置
style(backend): 格式化模型文件代码 style(frontend): 调整组件代码格式 chore: 删除旧 ESLint 配置并添加新配置 refactor(backend): 重构模型定义语法 style: 统一箭头函数和对象属性简写
This commit is contained in:
+44
-44
@@ -2,54 +2,54 @@ const { DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('../db');
|
||||
const Room = require('./Room');
|
||||
|
||||
const Rack = sequelize.define('Rack', {
|
||||
rackId: {
|
||||
type: DataTypes.STRING,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
unique: true
|
||||
const Rack = sequelize.define(
|
||||
'Rack',
|
||||
{
|
||||
rackId: {
|
||||
type: DataTypes.STRING,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
height: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 45, // 标准机柜高度(U数)
|
||||
},
|
||||
maxPower: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false,
|
||||
},
|
||||
currentPower: {
|
||||
type: DataTypes.FLOAT,
|
||||
defaultValue: 0,
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: 'active',
|
||||
},
|
||||
roomId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Room,
|
||||
key: 'roomId',
|
||||
},
|
||||
},
|
||||
},
|
||||
name: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
height: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
defaultValue: 45 // 标准机柜高度(U数)
|
||||
},
|
||||
maxPower: {
|
||||
type: DataTypes.FLOAT,
|
||||
allowNull: false
|
||||
},
|
||||
currentPower: {
|
||||
type: DataTypes.FLOAT,
|
||||
defaultValue: 0
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: 'active'
|
||||
},
|
||||
roomId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Room,
|
||||
key: 'roomId'
|
||||
}
|
||||
{
|
||||
tableName: 'racks',
|
||||
timestamps: true,
|
||||
indexes: [{ fields: ['roomId'] }, { fields: ['status'] }, { fields: ['roomId', 'status'] }],
|
||||
}
|
||||
}, {
|
||||
tableName: 'racks',
|
||||
timestamps: true,
|
||||
indexes: [
|
||||
{ fields: ['roomId'] },
|
||||
{ fields: ['status'] },
|
||||
{ fields: ['roomId', 'status'] }
|
||||
]
|
||||
});
|
||||
);
|
||||
|
||||
// 关联关系
|
||||
Rack.belongsTo(Room, { foreignKey: 'roomId' });
|
||||
Room.hasMany(Rack, { foreignKey: 'roomId' });
|
||||
|
||||
module.exports = Rack;
|
||||
module.exports = Rack;
|
||||
|
||||
Reference in New Issue
Block a user