refactor: 统一代码风格并迁移至 ESLint 新配置
style(backend): 格式化模型文件代码 style(frontend): 调整组件代码格式 chore: 删除旧 ESLint 配置并添加新配置 refactor(backend): 重构模型定义语法 style: 统一箭头函数和对象属性简写
This commit is contained in:
@@ -2,75 +2,75 @@ const { DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('../db');
|
||||
const Consumable = require('./Consumable');
|
||||
|
||||
const ConsumableRecord = sequelize.define('ConsumableRecord', {
|
||||
recordId: {
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
allowNull: false
|
||||
const ConsumableRecord = sequelize.define(
|
||||
'ConsumableRecord',
|
||||
{
|
||||
recordId: {
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
allowNull: false,
|
||||
},
|
||||
consumableId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Consumable,
|
||||
key: 'consumableId',
|
||||
},
|
||||
},
|
||||
type: {
|
||||
type: DataTypes.ENUM('in', 'out'),
|
||||
allowNull: false,
|
||||
},
|
||||
quantity: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
previousStock: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
currentStock: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false,
|
||||
},
|
||||
operator: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
},
|
||||
reason: {
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
recipient: {
|
||||
type: DataTypes.STRING,
|
||||
},
|
||||
notes: {
|
||||
type: DataTypes.TEXT,
|
||||
},
|
||||
snList: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
defaultValue: [],
|
||||
comment: '本次操作的SN序列号列表',
|
||||
},
|
||||
},
|
||||
consumableId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
references: {
|
||||
model: Consumable,
|
||||
key: 'consumableId'
|
||||
}
|
||||
},
|
||||
type: {
|
||||
type: DataTypes.ENUM('in', 'out'),
|
||||
allowNull: false
|
||||
},
|
||||
quantity: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false
|
||||
},
|
||||
previousStock: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false
|
||||
},
|
||||
currentStock: {
|
||||
type: DataTypes.INTEGER,
|
||||
allowNull: false
|
||||
},
|
||||
operator: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false
|
||||
},
|
||||
reason: {
|
||||
type: DataTypes.STRING
|
||||
},
|
||||
recipient: {
|
||||
type: DataTypes.STRING
|
||||
},
|
||||
notes: {
|
||||
type: DataTypes.TEXT
|
||||
},
|
||||
snList: {
|
||||
type: DataTypes.JSON,
|
||||
allowNull: true,
|
||||
defaultValue: [],
|
||||
comment: '本次操作的SN序列号列表'
|
||||
{
|
||||
tableName: 'consumable_records',
|
||||
timestamps: true,
|
||||
indexes: [{ fields: ['consumableId'] }, { fields: ['type'] }, { fields: ['createdAt'] }],
|
||||
}
|
||||
}, {
|
||||
tableName: 'consumable_records',
|
||||
timestamps: true,
|
||||
indexes: [
|
||||
{ fields: ['consumableId'] },
|
||||
{ fields: ['type'] },
|
||||
{ fields: ['createdAt'] }
|
||||
]
|
||||
});
|
||||
);
|
||||
|
||||
ConsumableRecord.belongsTo(Consumable, {
|
||||
ConsumableRecord.belongsTo(Consumable, {
|
||||
foreignKey: 'consumableId',
|
||||
as: 'consumable',
|
||||
onDelete: 'CASCADE'
|
||||
onDelete: 'CASCADE',
|
||||
});
|
||||
Consumable.hasMany(ConsumableRecord, {
|
||||
Consumable.hasMany(ConsumableRecord, {
|
||||
foreignKey: 'consumableId',
|
||||
as: 'records',
|
||||
onDelete: 'CASCADE'
|
||||
onDelete: 'CASCADE',
|
||||
});
|
||||
|
||||
module.exports = ConsumableRecord;
|
||||
|
||||
Reference in New Issue
Block a user