1
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
const Sequelize = require('sequelize');
|
||||
|
||||
/**
|
||||
* 聊天记录表模型
|
||||
* 记录与HR的聊天内容和效果
|
||||
* 聊天会话列表表模型
|
||||
* 按 Boss 「好友/会话」列表维度存储,会话摘要信息
|
||||
*/
|
||||
module.exports = (db) => {
|
||||
const chat_records = db.define("chat_records", {
|
||||
// 聊天基本信息
|
||||
const chat_records = db.define('chat_records', {
|
||||
// 设备与平台
|
||||
sn_code: {
|
||||
comment: '设备SN码',
|
||||
type: Sequelize.STRING(50),
|
||||
@@ -19,270 +19,91 @@ module.exports = (db) => {
|
||||
allowNull: false,
|
||||
defaultValue: 'boss'
|
||||
},
|
||||
|
||||
// 岗位关联
|
||||
jobId: {
|
||||
comment: '岗位ID',
|
||||
|
||||
// Boss 会话列表字段(与接口 friend 对象对应)
|
||||
friendId: {
|
||||
comment: '好友ID',
|
||||
type: Sequelize.BIGINT,
|
||||
allowNull: false
|
||||
},
|
||||
friendSource: {
|
||||
comment: '好友来源',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
encryptFriendId: {
|
||||
comment: '好友加密ID',
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: true,
|
||||
allowNull: false,
|
||||
defaultValue: ''
|
||||
},
|
||||
encryptBossId: {
|
||||
comment: 'Boss加密ID',
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
jobTitle: {
|
||||
comment: '岗位名称',
|
||||
type: Sequelize.STRING(200),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
companyName: {
|
||||
comment: '公司名称',
|
||||
type: Sequelize.STRING(200),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
|
||||
// HR信息
|
||||
hrName: {
|
||||
name: {
|
||||
comment: 'HR姓名',
|
||||
type: Sequelize.STRING(50),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
hrTitle: {
|
||||
comment: 'HR职位',
|
||||
type: Sequelize.STRING(50),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
hrId: {
|
||||
comment: 'HR ID',
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
|
||||
// 聊天内容
|
||||
chatType: {
|
||||
comment: '聊天类型: greeting-打招呼, follow_up-跟进, interview-面试邀约, reply-回复',
|
||||
type: Sequelize.STRING(20),
|
||||
allowNull: false,
|
||||
defaultValue: 'greeting'
|
||||
},
|
||||
direction: {
|
||||
comment: '消息方向: sent-发送, received-接收',
|
||||
type: Sequelize.STRING(20),
|
||||
allowNull: false,
|
||||
defaultValue: 'sent'
|
||||
},
|
||||
content: {
|
||||
comment: '聊天内容',
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: false,
|
||||
defaultValue: ''
|
||||
},
|
||||
contentType: {
|
||||
comment: '内容类型: text-文本, image-图片, file-文件',
|
||||
type: Sequelize.STRING(20),
|
||||
allowNull: true,
|
||||
defaultValue: 'text'
|
||||
},
|
||||
|
||||
// AI生成信息
|
||||
isAiGenerated: {
|
||||
comment: '是否AI生成',
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: true,
|
||||
defaultValue: false
|
||||
},
|
||||
aiPrompt: {
|
||||
comment: 'AI生成的提示词',
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
aiModel: {
|
||||
comment: 'AI模型名称',
|
||||
type: Sequelize.STRING(50),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
|
||||
// 发送状态
|
||||
sendStatus: {
|
||||
comment: '发送状态: pending-待发送, sending-发送中, sent-已发送, failed-发送失败',
|
||||
type: Sequelize.STRING(20),
|
||||
allowNull: true,
|
||||
defaultValue: 'pending'
|
||||
},
|
||||
sendTime: {
|
||||
comment: '发送时间',
|
||||
type: Sequelize.DATE,
|
||||
updateTime: {
|
||||
comment: '最后更新时间(毫秒时间戳)',
|
||||
type: Sequelize.BIGINT,
|
||||
allowNull: true
|
||||
},
|
||||
receiveTime: {
|
||||
comment: '接收时间',
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true
|
||||
},
|
||||
|
||||
// 回复信息
|
||||
hasReply: {
|
||||
comment: '是否有回复',
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: true,
|
||||
defaultValue: false
|
||||
},
|
||||
replyTime: {
|
||||
comment: '回复时间',
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true
|
||||
},
|
||||
replyContent: {
|
||||
comment: '回复内容',
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
replyDuration: {
|
||||
comment: '回复时长(分钟)',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
|
||||
// 面试邀约信息
|
||||
isInterviewInvitation: {
|
||||
comment: '是否包含面试邀约',
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: true,
|
||||
defaultValue: false
|
||||
},
|
||||
interviewTime: {
|
||||
comment: '面试时间',
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true
|
||||
},
|
||||
interviewLocation: {
|
||||
comment: '面试地点',
|
||||
brandName: {
|
||||
comment: '公司名称',
|
||||
type: Sequelize.STRING(200),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
interviewType: {
|
||||
comment: '面试类型: online-线上, offline-线下',
|
||||
type: Sequelize.STRING(20),
|
||||
jobName: {
|
||||
comment: '职位名称',
|
||||
type: Sequelize.STRING(200),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
interviewStatus: {
|
||||
comment: '面试状态: pending-待确认, confirmed-已确认, completed-已完成, cancelled-已取消',
|
||||
type: Sequelize.STRING(20),
|
||||
jobTypeDesc: {
|
||||
comment: '职位类型描述',
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
|
||||
// 效果评估
|
||||
effectScore: {
|
||||
comment: '效果评分(0-100)',
|
||||
jobCity: {
|
||||
comment: '职位城市',
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
positionName: {
|
||||
comment: '岗位名称/方向',
|
||||
type: Sequelize.STRING(200),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
bossTitle: {
|
||||
comment: 'Boss/HR 职位头衔',
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
waterLevel: {
|
||||
comment: '水位(Boss 优先级标记)',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
sentiment: {
|
||||
comment: '情感倾向: positive-正面, neutral-中性, negative-负面',
|
||||
type: Sequelize.STRING(20),
|
||||
allowNull: true,
|
||||
defaultValue: 'neutral'
|
||||
},
|
||||
|
||||
// 会话信息
|
||||
conversationId: {
|
||||
comment: '会话ID(同一个岗位的聊天属于一个会话)',
|
||||
type: Sequelize.STRING(50),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
messageIndex: {
|
||||
comment: '消息序号(会话内的消息顺序)',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
|
||||
// 关联信息
|
||||
taskId: {
|
||||
comment: '关联任务ID',
|
||||
type: Sequelize.STRING(50),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
|
||||
// 其他信息
|
||||
originalData: {
|
||||
comment: '原始数据(JSON)',
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
errorMessage: {
|
||||
comment: '错误信息',
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
notes: {
|
||||
comment: '备注',
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
|
||||
}, {
|
||||
timestamps: false,
|
||||
indexes: [
|
||||
{
|
||||
unique: false,
|
||||
fields: ['sn_code']
|
||||
},
|
||||
{
|
||||
unique: false,
|
||||
fields: ['jobId']
|
||||
},
|
||||
{
|
||||
unique: false,
|
||||
fields: ['encryptBossId']
|
||||
},
|
||||
{
|
||||
unique: false,
|
||||
fields: ['conversationId']
|
||||
},
|
||||
{
|
||||
unique: false,
|
||||
fields: ['chatType']
|
||||
},
|
||||
{
|
||||
unique: false,
|
||||
fields: ['sendStatus']
|
||||
},
|
||||
{
|
||||
unique: false,
|
||||
fields: ['hasReply']
|
||||
},
|
||||
|
||||
{ unique: false, fields: ['sn_code'] },
|
||||
{ unique: false, fields: ['platform'] },
|
||||
{ unique: false, fields: ['friendId'] },
|
||||
{ unique: false, fields: ['encryptFriendId'] }
|
||||
]
|
||||
});
|
||||
|
||||
//chat_records.sync({ force: true });
|
||||
// chat_records.sync({ force: true });
|
||||
|
||||
return chat_records
|
||||
|
||||
|
||||
|
||||
return chat_records;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user