refactor: 统一代码风格并迁移至 ESLint 新配置
style(backend): 格式化模型文件代码 style(frontend): 调整组件代码格式 chore: 删除旧 ESLint 配置并添加新配置 refactor(backend): 重构模型定义语法 style: 统一箭头函数和对象属性简写
This commit is contained in:
@@ -1,68 +1,72 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('../db');
|
||||
|
||||
const DevicePort = sequelize.define('DevicePort', {
|
||||
portId: {
|
||||
type: DataTypes.STRING,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
unique: true
|
||||
},
|
||||
deviceId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: 'devices',
|
||||
key: 'deviceId'
|
||||
}
|
||||
},
|
||||
nicId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
references: {
|
||||
model: 'network_cards',
|
||||
key: 'nicId'
|
||||
const DevicePort = sequelize.define(
|
||||
'DevicePort',
|
||||
{
|
||||
portId: {
|
||||
type: DataTypes.STRING,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
deviceId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: 'devices',
|
||||
key: 'deviceId',
|
||||
},
|
||||
},
|
||||
nicId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true,
|
||||
references: {
|
||||
model: 'network_cards',
|
||||
key: 'nicId',
|
||||
},
|
||||
comment: '所属网卡ID,可为空(向后兼容)',
|
||||
},
|
||||
portName: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
portType: {
|
||||
type: DataTypes.ENUM('RJ45', 'SFP', 'SFP+', 'SFP28', 'QSFP', 'QSFP28'),
|
||||
defaultValue: 'RJ45',
|
||||
allowNull: false,
|
||||
},
|
||||
portSpeed: {
|
||||
type: DataTypes.ENUM('100M', '1G', '10G', '25G', '40G', '100G'),
|
||||
defaultValue: '1G',
|
||||
allowNull: false,
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.ENUM('free', 'occupied', 'fault'),
|
||||
defaultValue: 'free',
|
||||
allowNull: false,
|
||||
},
|
||||
vlanId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true,
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true,
|
||||
},
|
||||
comment: '所属网卡ID,可为空(向后兼容)'
|
||||
},
|
||||
portName: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
portType: {
|
||||
type: DataTypes.ENUM('RJ45', 'SFP', 'SFP+', 'SFP28', 'QSFP', 'QSFP28'),
|
||||
defaultValue: 'RJ45',
|
||||
allowNull: false
|
||||
},
|
||||
portSpeed: {
|
||||
type: DataTypes.ENUM('100M', '1G', '10G', '25G', '40G', '100G'),
|
||||
defaultValue: '1G',
|
||||
allowNull: false
|
||||
},
|
||||
status: {
|
||||
type: DataTypes.ENUM('free', 'occupied', 'fault'),
|
||||
defaultValue: 'free',
|
||||
allowNull: false
|
||||
},
|
||||
vlanId: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: true
|
||||
},
|
||||
description: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: true
|
||||
{
|
||||
tableName: 'device_ports',
|
||||
timestamps: true,
|
||||
indexes: [
|
||||
{ fields: ['deviceId'] },
|
||||
{ fields: ['nicId'] },
|
||||
{ fields: ['status'] },
|
||||
{ fields: ['portType'] },
|
||||
{ fields: ['portSpeed'] },
|
||||
{ unique: true, fields: ['deviceId', 'portName'] },
|
||||
],
|
||||
}
|
||||
}, {
|
||||
tableName: 'device_ports',
|
||||
timestamps: true,
|
||||
indexes: [
|
||||
{ fields: ['deviceId'] },
|
||||
{ fields: ['nicId'] },
|
||||
{ fields: ['status'] },
|
||||
{ fields: ['portType'] },
|
||||
{ fields: ['portSpeed'] },
|
||||
{ unique: true, fields: ['deviceId', 'portName'] }
|
||||
]
|
||||
});
|
||||
);
|
||||
|
||||
module.exports = DevicePort;
|
||||
|
||||
Reference in New Issue
Block a user