289 lines
6.3 KiB
JavaScript
289 lines
6.3 KiB
JavaScript
const Sequelize = require('sequelize');
|
|
|
|
/**
|
|
* 聊天记录表模型
|
|
* 记录与HR的聊天内容和效果
|
|
*/
|
|
module.exports = (db) => {
|
|
const chat_records = db.define("chat_records", {
|
|
// 聊天基本信息
|
|
sn_code: {
|
|
comment: '设备SN码',
|
|
type: Sequelize.STRING(50),
|
|
allowNull: false,
|
|
defaultValue: ''
|
|
},
|
|
platform: {
|
|
comment: '平台: boss-Boss直聘, liepin-猎聘',
|
|
type: Sequelize.STRING(20),
|
|
allowNull: false,
|
|
defaultValue: 'boss'
|
|
},
|
|
|
|
// 岗位关联
|
|
jobId: {
|
|
comment: '岗位ID',
|
|
type: Sequelize.STRING(100),
|
|
allowNull: true,
|
|
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: {
|
|
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,
|
|
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: '面试地点',
|
|
type: Sequelize.STRING(200),
|
|
allowNull: true,
|
|
defaultValue: ''
|
|
},
|
|
interviewType: {
|
|
comment: '面试类型: online-线上, offline-线下',
|
|
type: Sequelize.STRING(20),
|
|
allowNull: true,
|
|
defaultValue: ''
|
|
},
|
|
interviewStatus: {
|
|
comment: '面试状态: pending-待确认, confirmed-已确认, completed-已完成, cancelled-已取消',
|
|
type: Sequelize.STRING(20),
|
|
allowNull: true,
|
|
defaultValue: ''
|
|
},
|
|
|
|
// 效果评估
|
|
effectScore: {
|
|
comment: '效果评分(0-100)',
|
|
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']
|
|
},
|
|
|
|
]
|
|
});
|
|
|
|
//chat_records.sync({ force: true });
|
|
|
|
return chat_records
|
|
|
|
|
|
|
|
};
|
|
|