refactor: 统一代码风格并迁移至 ESLint 新配置
style(backend): 格式化模型文件代码 style(frontend): 调整组件代码格式 chore: 删除旧 ESLint 配置并添加新配置 refactor(backend): 重构模型定义语法 style: 统一箭头函数和对象属性简写
This commit is contained in:
@@ -5,85 +5,90 @@ const generateRecordId = () => {
|
||||
return `OPLOG_${Date.now().toString(36)}_${Math.random().toString(36).substr(2, 9)}`;
|
||||
};
|
||||
|
||||
const OperationLog = sequelize.define('OperationLog', {
|
||||
recordId: {
|
||||
type: DataTypes.STRING,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
unique: true
|
||||
const OperationLog = sequelize.define(
|
||||
'OperationLog',
|
||||
{
|
||||
recordId: {
|
||||
type: DataTypes.STRING,
|
||||
primaryKey: true,
|
||||
allowNull: false,
|
||||
unique: true,
|
||||
},
|
||||
module: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '模块:device/user/role/consumable/rack/room',
|
||||
},
|
||||
operationType: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment:
|
||||
'操作类型: create/update/delete/batch_delete/batch_update/status_change/move/permission_change',
|
||||
},
|
||||
operationDescription: {
|
||||
type: DataTypes.TEXT,
|
||||
comment: '操作描述',
|
||||
},
|
||||
targetId: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '目标对象ID',
|
||||
},
|
||||
targetName: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '目标对象名称(冗余便于展示)',
|
||||
},
|
||||
operatorId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '操作人ID',
|
||||
},
|
||||
operatorName: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '操作人姓名',
|
||||
},
|
||||
operatorRole: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '操作人角色',
|
||||
},
|
||||
beforeState: {
|
||||
type: DataTypes.JSON,
|
||||
comment: '操作前状态',
|
||||
},
|
||||
afterState: {
|
||||
type: DataTypes.JSON,
|
||||
comment: '操作后状态',
|
||||
},
|
||||
result: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: 'success',
|
||||
comment: '操作结果: success/failed',
|
||||
},
|
||||
ipAddress: {
|
||||
type: DataTypes.STRING,
|
||||
comment: 'IP地址',
|
||||
},
|
||||
userAgent: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '用户代理',
|
||||
},
|
||||
metadata: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: {},
|
||||
comment: '扩展字段',
|
||||
},
|
||||
},
|
||||
module: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '模块:device/user/role/consumable/rack/room'
|
||||
},
|
||||
operationType: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '操作类型: create/update/delete/batch_delete/batch_update/status_change/move/permission_change'
|
||||
},
|
||||
operationDescription: {
|
||||
type: DataTypes.TEXT,
|
||||
comment: '操作描述'
|
||||
},
|
||||
targetId: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '目标对象ID'
|
||||
},
|
||||
targetName: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '目标对象名称(冗余便于展示)'
|
||||
},
|
||||
operatorId: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '操作人ID'
|
||||
},
|
||||
operatorName: {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: false,
|
||||
comment: '操作人姓名'
|
||||
},
|
||||
operatorRole: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '操作人角色'
|
||||
},
|
||||
beforeState: {
|
||||
type: DataTypes.JSON,
|
||||
comment: '操作前状态'
|
||||
},
|
||||
afterState: {
|
||||
type: DataTypes.JSON,
|
||||
comment: '操作后状态'
|
||||
},
|
||||
result: {
|
||||
type: DataTypes.STRING,
|
||||
defaultValue: 'success',
|
||||
comment: '操作结果: success/failed'
|
||||
},
|
||||
ipAddress: {
|
||||
type: DataTypes.STRING,
|
||||
comment: 'IP地址'
|
||||
},
|
||||
userAgent: {
|
||||
type: DataTypes.STRING,
|
||||
comment: '用户代理'
|
||||
},
|
||||
metadata: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: {},
|
||||
comment: '扩展字段'
|
||||
{
|
||||
tableName: 'operation_logs',
|
||||
timestamps: true,
|
||||
indexes: [
|
||||
{ fields: ['module'] },
|
||||
{ fields: ['operationType'] },
|
||||
{ fields: ['targetId'] },
|
||||
{ fields: ['operatorId'] },
|
||||
{ fields: ['createdAt'] },
|
||||
],
|
||||
}
|
||||
}, {
|
||||
tableName: 'operation_logs',
|
||||
timestamps: true,
|
||||
indexes: [
|
||||
{ fields: ['module'] },
|
||||
{ fields: ['operationType'] },
|
||||
{ fields: ['targetId'] },
|
||||
{ fields: ['operatorId'] },
|
||||
{ fields: ['createdAt'] }
|
||||
]
|
||||
});
|
||||
);
|
||||
|
||||
module.exports = OperationLog;
|
||||
|
||||
Reference in New Issue
Block a user