style(backend): 格式化模型文件代码 style(frontend): 调整组件代码格式 chore: 删除旧 ESLint 配置并添加新配置 refactor(backend): 重构模型定义语法 style: 统一箭头函数和对象属性简写
82 lines
1.8 KiB
JavaScript
82 lines
1.8 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
||
const { sequelize } = require('../db');
|
||
|
||
const InventoryTask = sequelize.define(
|
||
'InventoryTask',
|
||
{
|
||
taskId: {
|
||
type: DataTypes.STRING,
|
||
primaryKey: true,
|
||
allowNull: false,
|
||
unique: true,
|
||
},
|
||
planId: {
|
||
type: DataTypes.STRING,
|
||
allowNull: false,
|
||
},
|
||
targetType: {
|
||
type: DataTypes.STRING,
|
||
allowNull: false,
|
||
comment: 'room:机房, rack:机柜, device:设备',
|
||
},
|
||
targetId: {
|
||
type: DataTypes.STRING,
|
||
allowNull: false,
|
||
comment: '目标ID(机房ID/机柜ID/设备ID)',
|
||
},
|
||
targetName: {
|
||
type: DataTypes.STRING,
|
||
allowNull: true,
|
||
comment: '目标名称',
|
||
},
|
||
status: {
|
||
type: DataTypes.STRING,
|
||
defaultValue: 'pending',
|
||
comment: 'pending:待执行, in_progress:进行中, completed:已完成, skipped:已跳过',
|
||
},
|
||
totalDevices: {
|
||
type: DataTypes.INTEGER,
|
||
defaultValue: 0,
|
||
comment: '设备总数',
|
||
},
|
||
checkedDevices: {
|
||
type: DataTypes.INTEGER,
|
||
defaultValue: 0,
|
||
comment: '已盘点设备数',
|
||
},
|
||
normalDevices: {
|
||
type: DataTypes.INTEGER,
|
||
defaultValue: 0,
|
||
comment: '正常设备数',
|
||
},
|
||
abnormalDevices: {
|
||
type: DataTypes.INTEGER,
|
||
defaultValue: 0,
|
||
comment: '异常设备数',
|
||
},
|
||
assignedTo: {
|
||
type: DataTypes.STRING,
|
||
allowNull: true,
|
||
},
|
||
assignedAt: {
|
||
type: DataTypes.DATE,
|
||
allowNull: true,
|
||
},
|
||
completedAt: {
|
||
type: DataTypes.DATE,
|
||
allowNull: true,
|
||
},
|
||
remark: {
|
||
type: DataTypes.TEXT,
|
||
allowNull: true,
|
||
},
|
||
},
|
||
{
|
||
tableName: 'inventory_tasks',
|
||
timestamps: true,
|
||
indexes: [{ fields: ['planId'] }, { fields: ['status'] }, { fields: ['assignedTo'] }],
|
||
}
|
||
);
|
||
|
||
module.exports = InventoryTask;
|