Files
zhang1106 63f0cb570e refactor: 统一代码风格并迁移至 ESLint 新配置
style(backend): 格式化模型文件代码
style(frontend): 调整组件代码格式
chore: 删除旧 ESLint 配置并添加新配置
refactor(backend): 重构模型定义语法
style: 统一箭头函数和对象属性简写
2026-03-27 19:12:16 +08:00

66 lines
1.5 KiB
JavaScript

const { DataTypes } = require('sequelize');
const { sequelize } = require('../db');
const FaultCategory = sequelize.define(
'FaultCategory',
{
categoryId: {
type: DataTypes.STRING,
primaryKey: true,
allowNull: false,
unique: true,
},
name: {
type: DataTypes.STRING,
allowNull: false,
unique: true,
comment: '分类名称',
},
description: {
type: DataTypes.TEXT,
comment: '分类说明 - 说明此类故障代表什么问题',
},
priority: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: '排序优先级',
},
defaultPriority: {
type: DataTypes.STRING,
defaultValue: 'medium',
comment: '默认优先级: critical/high/medium/low',
},
expectedDuration: {
type: DataTypes.INTEGER,
comment: '预计处理时长(小时)',
},
solutions: {
type: DataTypes.JSON,
defaultValue: [],
comment: '常见解决方案',
},
isSystem: {
type: DataTypes.BOOLEAN,
defaultValue: false,
comment: '是否系统内置分类',
},
isActive: {
type: DataTypes.BOOLEAN,
defaultValue: true,
comment: '是否启用',
},
metadata: {
type: DataTypes.JSON,
defaultValue: {},
comment: '扩展字段',
},
},
{
tableName: 'fault_categories',
timestamps: true,
indexes: [{ fields: ['name'] }, { fields: ['isActive'] }, { fields: ['priority'] }],
}
);
module.exports = FaultCategory;