feat(validation): 为机房、机柜和设备路由添加Joi验证中间件 feat(hooks): 创建useDesignTokens Hook集中管理主题配置 feat(models): 为耗材模型添加乐观锁version字段和updatedAt索引 feat(3d): 增强3D场景和设备模型视觉效果与交互 refactor: 移除数据备份相关功能并优化代码结构 fix: 修复前端安全日志和密码加密工具 chore: 更新依赖并添加axios和joi库 docs: 更新注释和文档说明 style: 改进代码格式和命名一致性
76 lines
1.4 KiB
JavaScript
76 lines
1.4 KiB
JavaScript
const { DataTypes } = require('sequelize');
|
|
const { sequelize } = require('../db');
|
|
|
|
const Consumable = sequelize.define('Consumable', {
|
|
consumableId: {
|
|
type: DataTypes.STRING,
|
|
primaryKey: true,
|
|
allowNull: false,
|
|
unique: true
|
|
},
|
|
name: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false
|
|
},
|
|
category: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false
|
|
},
|
|
unit: {
|
|
type: DataTypes.STRING,
|
|
allowNull: false,
|
|
defaultValue: '个'
|
|
},
|
|
currentStock: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
defaultValue: 0
|
|
},
|
|
minStock: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
defaultValue: 10
|
|
},
|
|
maxStock: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
defaultValue: 100
|
|
},
|
|
unitPrice: {
|
|
type: DataTypes.DECIMAL(10, 2),
|
|
allowNull: false,
|
|
defaultValue: 0
|
|
},
|
|
supplier: {
|
|
type: DataTypes.STRING
|
|
},
|
|
location: {
|
|
type: DataTypes.STRING,
|
|
comment: '存放位置'
|
|
},
|
|
description: {
|
|
type: DataTypes.TEXT
|
|
},
|
|
status: {
|
|
type: DataTypes.STRING,
|
|
defaultValue: 'active'
|
|
},
|
|
version: {
|
|
type: DataTypes.INTEGER,
|
|
allowNull: false,
|
|
defaultValue: 0,
|
|
comment: '乐观锁版本号'
|
|
}
|
|
}, {
|
|
tableName: 'consumables',
|
|
timestamps: true,
|
|
indexes: [
|
|
{ fields: ['category'] },
|
|
{ fields: ['status'] },
|
|
{ fields: ['category', 'status'] },
|
|
{ fields: ['updatedAt'] }
|
|
]
|
|
});
|
|
|
|
module.exports = Consumable;
|