Files
autoAiWorkSys/api/model/chat_message.js
张成 5ec4e7f440 1
2026-02-28 16:28:28 +08:00

63 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const Sequelize = require('sequelize');
/**
* 聊天消息表
* 每句话一条记录;会话形态(仅 data+job用 mid=0 存一条
*/
module.exports = (db) => {
const chat_message = db.define('chat_message', {
sn_code: {
comment: '设备SN码',
type: Sequelize.STRING(50),
allowNull: false,
defaultValue: ''
},
platform: {
comment: '平台: boss / liepin',
type: Sequelize.STRING(20),
allowNull: false,
defaultValue: 'boss'
},
friendId: {
comment: '好友/会话ID',
type: Sequelize.BIGINT,
allowNull: false
},
encryptFriendId: {
comment: '好友加密ID',
type: Sequelize.STRING(100),
allowNull: true,
defaultValue: ''
},
mid: {
comment: '消息ID接口返回',
type: Sequelize.BIGINT,
allowNull: false
},
message_data: {
comment: '单条消息原始数据 JSON',
type: Sequelize.JSON,
allowNull: true,
defaultValue: null
},
fetch_time: {
comment: '拉取时间',
type: Sequelize.DATE,
allowNull: true,
defaultValue: Sequelize.NOW
}
}, {
timestamps: false,
indexes: [
{ unique: true, fields: ['sn_code', 'platform', 'friendId', 'mid'] },
{ unique: false, fields: ['sn_code', 'platform', 'friendId'] },
{ unique: false, fields: ['fetch_time'] }
]
});
// chat_message.sync({ force: true });
return chat_message;
};