356 lines
12 KiB
JavaScript
356 lines
12 KiB
JavaScript
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(200),
|
||
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_search: {
|
||
comment: '自动搜索开关',
|
||
type: Sequelize.TINYINT(1),
|
||
allowNull: false,
|
||
defaultValue: 0
|
||
},
|
||
// 自动搜索配置(JSON格式,包含:search_interval-搜索间隔分钟数, page_count-滚动获取职位列表次数, city-城市, time_range-搜索时间段)
|
||
search_config: {
|
||
comment: '自动搜索配置(JSON对象)',
|
||
type: Sequelize.JSON(),
|
||
allowNull: true,
|
||
get: function () {
|
||
const value = this.getDataValue('search_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('search_config', null);
|
||
} else if (typeof value === 'string') {
|
||
// 如果已经是字符串,直接使用
|
||
this.setDataValue('search_config', value);
|
||
} else {
|
||
// 如果是对象,序列化为字符串
|
||
this.setDataValue('search_config', JSON.stringify(value));
|
||
}
|
||
},
|
||
// 默认值说明:
|
||
// city: '' - 城市,默认空字符串
|
||
// cityName: '' - 城市名称,默认空字符串
|
||
// salary: '' - 薪资,默认空字符串
|
||
// experience: '' - 经验,默认空字符串
|
||
// education: '' - 学历,默认空字符串
|
||
|
||
defaultValue: JSON.stringify({
|
||
search_interval: 30,
|
||
city: '',
|
||
cityName: '',
|
||
salary: '',
|
||
experience: '',
|
||
education: ''
|
||
})
|
||
},
|
||
// 自动沟通相关配置
|
||
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
|
||
|
||
|
||
}; |