补充修改

This commit is contained in:
2025-10-11 08:53:47 +08:00
parent 1a1abf4c26
commit 9b8d177e34
34 changed files with 391 additions and 1882 deletions

View File

@@ -1,5 +1,25 @@
const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');
const { DataTypes, Sequelize } = require('sequelize');
const config = require('../config/index.js');
// 创建专门的Sequelize实例不使用underscored
const sequelize = new Sequelize(
config.DB_CONFIG.database,
config.DB_CONFIG.user,
config.DB_CONFIG.password,
{
host: config.DB_CONFIG.host,
port: config.DB_CONFIG.port,
dialect: config.DB_CONFIG.dialect,
logging: console.log,
define: {
timestamps: true,
paranoid: false,
underscored: false, // 明确设置为false
freezeTableName: true
},
timezone: '+08:00'
}
);
const DeviceWarning = sequelize.define('DeviceWarning', {
id: {
@@ -67,34 +87,42 @@ const DeviceWarning = sequelize.define('DeviceWarning', {
description: {
type: DataTypes.TEXT,
comment: '预警描述',
field: 'description'
},
location: {
type: DataTypes.STRING,
comment: '设备位置',
field: 'location'
},
batteryLevel: {
type: DataTypes.INTEGER,
comment: '电池电量百分比',
field: 'batteryLevel'
},
signalStrength: {
type: DataTypes.INTEGER,
comment: '信号强度',
field: 'signalStrength'
},
temperature: {
type: DataTypes.FLOAT,
comment: '温度值',
field: 'temperature'
},
resolvedBy: {
type: DataTypes.STRING,
comment: '解决人',
field: 'resolvedBy'
},
resolvedAt: {
type: DataTypes.DATE,
comment: '解决时间',
field: 'resolvedAt'
},
remarks: {
type: DataTypes.TEXT,
comment: '备注',
field: 'remarks'
},
}, {
tableName: 'device_warnings',
@@ -102,6 +130,7 @@ const DeviceWarning = sequelize.define('DeviceWarning', {
createdAt: 'createdAt',
updatedAt: 'updatedAt',
paranoid: false,
underscored: false, // 覆盖全局配置,不使用下划线命名
});
module.exports = DeviceWarning;