Files
autoAiWorkSys/api/model/pla_account.js
张成 10aff2f266 1
2025-12-19 22:24:23 +08:00

305 lines
9.9 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 dayjs = require("dayjs");
const Sequelize = require('sequelize');
module.exports = (db) => {
const pla_account = db.define("pla_account", {
name: {
comment: '账户名',
type: Sequelize.STRING(50),
allowNull: false,
defaultValue: ''
},
sn_code: {
comment: '唯一标识码',
type: Sequelize.STRING(50),
allowNull: false,
defaultValue: ''
},
device_id: {
comment: '设备ID',
type: Sequelize.STRING(200),
allowNull: true,
defaultValue: ''
},
platform_type: {
comment: '平台',
type: Sequelize.STRING(50),
allowNull: false,
defaultValue: ''
},
login_name: {
comment: '登录名',
type: Sequelize.STRING(50),
allowNull: false,
defaultValue: ''
},
pwd: {
comment: '密码',
type: Sequelize.STRING(50),
allowNull: false,
defaultValue: ''
},
keyword: {
comment: '关键词',
type: Sequelize.STRING(50),
allowNull: false,
defaultValue: ''
},
is_enabled: {
comment: '账号启用状态1=启用0=禁用)',
type: Sequelize.TINYINT(1),
allowNull: false,
defaultValue: 1
},
is_online: {
comment: '设备在线状态1=在线0=离线)',
type: Sequelize.TINYINT(1),
allowNull: false,
defaultValue: 0
},
is_logged_in: {
comment: '平台登录状态1=已登录0=未登录)',
type: Sequelize.TINYINT(1),
allowNull: false,
defaultValue: 0
},
job_type_id: {
comment: '职位类型ID关联 job_types 表)',
type: Sequelize.INTEGER,
allowNull: true,
defaultValue: null
},
//优先 排序 ,距离,薪资,工作年限 ,学历
is_salary_priority: {
comment: '排序优先级',
type: Sequelize.JSON(),
allowNull: false,
get: function () {
const value = this.getDataValue('is_salary_priority');
if (!value) {
return [{ "key": "distance", "weight": 50 }, { "key": "salary", "weight": 20 }, { "key": "work_years", "weight": 10 }, { "key": "education", "weight": 20}];
}
if (typeof value === 'string') {
try {
return JSON.parse(value);
} catch (e) {
return [{ "key": "distance", "weight": 50 }, { "key": "salary", "weight": 20 }, { "key": "work_years", "weight": 10 }, { "key": "education", "weight": 20}];
}
}
return value;
},
set: function (value) {
if (value === null || value === undefined) {
this.setDataValue('is_salary_priority', JSON.stringify([{ "key": "distance", "weight": 50 }, { "key": "salary", "weight": 20 }, { "key": "work_years", "weight": 10 }, { "key": "education", "weight": 20}]));
} else if (typeof value === 'string') {
// 如果已经是字符串,直接使用
this.setDataValue('is_salary_priority', value);
} else {
// 如果是对象/数组,序列化为字符串
this.setDataValue('is_salary_priority', JSON.stringify(value));
}
},
defaultValue: JSON.stringify([{ "key": "distance", "weight": 50 }, { "key": "salary", "weight": 20 }, { "key": "work_years", "weight": 10 }, { "key": "education", "weight": 20}])
},
// 用户地址
user_address: {
comment: '用户地址',
type: Sequelize.STRING(200),
allowNull: false,
defaultValue: ''
},
// 用户经度
user_longitude: {
comment: '用户经度',
type: Sequelize.STRING(50),
allowNull: false,
defaultValue: ''
},
// 用户纬度
user_latitude: {
comment: '用户纬度',
type: Sequelize.STRING(50),
allowNull: false,
defaultValue: ''
},
// 自动投递相关配置
auto_deliver: {
comment: '自动投递开关',
type: Sequelize.TINYINT(1),
allowNull: false,
defaultValue: 0
},
// 自动投递配置JSON格式包含deliver_interval-投递间隔分钟数, min_salary-最低薪资, max_salary-最高薪资, page_count-滚动获取职位列表次数, max_deliver-每次最多投递数量, filter_keywords-过滤关键词, exclude_keywords-排除关键词)
deliver_config: {
comment: '自动投递配置JSON对象',
type: Sequelize.JSON(),
allowNull: true,
get: function () {
const value = this.getDataValue('deliver_config');
if (!value) return null;
if (typeof value === 'string') {
try {
return JSON.parse(value);
} catch (e) {
return null;
}
}
return value;
},
set: function (value) {
if (value === null || value === undefined) {
this.setDataValue('deliver_config', null);
} else if (typeof value === 'string') {
// 如果已经是字符串,直接使用
this.setDataValue('deliver_config', value);
} else {
// 如果是对象,序列化为字符串
this.setDataValue('deliver_config', JSON.stringify(value));
}
},
// 默认值说明:
// deliver_interval: 30 - 投递间隔时间单位分钟默认30分钟执行一次自动投递
// min_salary: 0 - 最低薪资单位0表示不限制
// max_salary: 0 - 最高薪资单位0表示不限制
// page_count: 3 - 滚动获取职位列表次数默认3次
// max_deliver: 10 - 每次最多投递数量默认10个
// filter_keywords: [] - 过滤关键词数组,包含这些关键词的职位会被优先考虑
// exclude_keywords: [] - 排除关键词数组,包含这些关键词的职位会被排除
defaultValue: JSON.stringify({
deliver_interval: 30,
min_salary: 0,
max_salary: 0,
page_count: 3,
max_deliver: 10,
time_range: {
start_time: '09:00',
end_time: '18:00',
workdays_only: 1
},
filter_keywords: [],
exclude_keywords: []
})
},
// 自动沟通相关配置
auto_chat: {
comment: '自动沟通开关',
type: Sequelize.TINYINT(1),
allowNull: false,
defaultValue: 0
},
// 自动沟通配置JSON格式包含chat_interval-沟通间隔分钟数, is_chat_outsourcing-是否沟通外包岗位, time_range-沟通时间段)
chat_strategy: {
comment: '自动沟通策略配置JSON对象',
type: Sequelize.JSON(),
allowNull: true,
get: function () {
const value = this.getDataValue('chat_strategy');
if (!value) return null;
if (typeof value === 'string') {
try {
return JSON.parse(value);
} catch (e) {
return null;
}
}
return value;
},
set: function (value) {
if (value === null || value === undefined) {
this.setDataValue('chat_strategy', null);
} else if (typeof value === 'string') {
// 如果已经是字符串,直接使用
this.setDataValue('chat_strategy', value);
} else {
// 如果是对象,序列化为字符串
this.setDataValue('chat_strategy', JSON.stringify(value));
}
},
// 默认值说明:
// chat_interval: 30 - 沟通间隔时间单位分钟默认30分钟执行一次自动沟通
// is_chat_outsourcing: 0 - 是否沟通外包岗位0=不沟通外包岗位1=沟通外包岗位
// time_range: 沟通时间段配置
// - start_time: 开始时间格式HH:mm默认 "09:00"
// - end_time: 结束时间格式HH:mm默认 "18:00"
// - workdays_only: 是否仅工作日0=包含周末1=仅工作日默认1
defaultValue: JSON.stringify({
chat_interval: 30,
is_chat_outsourcing: 0,
time_range: {
start_time: '09:00',
end_time: '18:00',
workdays_only: 1
}
})
},
// 自动活跃相关配置
auto_active: {
comment: '自动活跃开关',
type: Sequelize.TINYINT(1),
allowNull: false,
defaultValue: 0
},
// 自动活跃配置JSON格式包含active_interval-活跃间隔分钟数, actions-活跃动作列表)
active_actions: {
comment: '自动活跃动作配置JSON对象',
type: Sequelize.JSON(),
allowNull: true,
get: function () {
const value = this.getDataValue('active_actions');
if (!value) return null;
if (typeof value === 'string') {
try {
return JSON.parse(value);
} catch (e) {
return null;
}
}
return value;
},
set: function (value) {
if (value === null || value === undefined) {
this.setDataValue('active_actions', null);
} else if (typeof value === 'string') {
// 如果已经是字符串,直接使用
this.setDataValue('active_actions', value);
} else {
// 如果是对象,序列化为字符串
this.setDataValue('active_actions', JSON.stringify(value));
}
},
// 默认值说明:
// active_interval: 60 - 活跃间隔时间单位分钟默认60分钟执行一次活跃动作
// actions: [] - 活跃动作列表,数组格式,可包含多个活跃动作配置对象
defaultValue: JSON.stringify({
active_interval: 60,
actions: []
})
},
// 授权相关字段
authorization_date: {
comment: '授权日期(授权开始时间)',
type: Sequelize.DATE,
allowNull: true,
defaultValue: null
},
authorization_days: {
comment: '授权天数',
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0
}
});
// pla_account.sync({ force: true });
return pla_account
};