1
This commit is contained in:
158
api/model/account_config.js
Normal file
158
api/model/account_config.js
Normal file
@@ -0,0 +1,158 @@
|
||||
const Sequelize = require('sequelize');
|
||||
|
||||
/**
|
||||
* 账号配置表模型
|
||||
* 配置不同平台的账号设置
|
||||
*/
|
||||
module.exports = (db) => {
|
||||
const account_config = db.define("account_config", {
|
||||
account_id: {
|
||||
comment: '账号ID(关联 pla_account.id)',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: false,
|
||||
primaryKey: true
|
||||
},
|
||||
platform_type: {
|
||||
comment: '平台类型(boss- Boss直聘, liepin- 猎聘)',
|
||||
type: Sequelize.STRING(50),
|
||||
allowNull: false,
|
||||
defaultValue: 'boss'
|
||||
},
|
||||
// 平台相关配置(JSON格式)
|
||||
platform_config: {
|
||||
comment: '平台相关配置(JSON对象)',
|
||||
type: Sequelize.JSON(),
|
||||
allowNull: true,
|
||||
get: function () {
|
||||
const value = this.getDataValue('platform_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('platform_config', null);
|
||||
} else if (typeof value === 'string') {
|
||||
this.setDataValue('platform_config', value);
|
||||
} else {
|
||||
this.setDataValue('platform_config', JSON.stringify(value));
|
||||
}
|
||||
},
|
||||
defaultValue: null
|
||||
},
|
||||
// 自动投递配置
|
||||
auto_deliver_config: {
|
||||
comment: '自动投递配置(JSON对象)',
|
||||
type: Sequelize.JSON(),
|
||||
allowNull: true,
|
||||
get: function () {
|
||||
const value = this.getDataValue('auto_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('auto_deliver_config', null);
|
||||
} else if (typeof value === 'string') {
|
||||
this.setDataValue('auto_deliver_config', value);
|
||||
} else {
|
||||
this.setDataValue('auto_deliver_config', JSON.stringify(value));
|
||||
}
|
||||
},
|
||||
defaultValue: null
|
||||
},
|
||||
// 自动沟通配置
|
||||
auto_chat_config: {
|
||||
comment: '自动沟通配置(JSON对象)',
|
||||
type: Sequelize.JSON(),
|
||||
allowNull: true,
|
||||
get: function () {
|
||||
const value = this.getDataValue('auto_chat_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('auto_chat_config', null);
|
||||
} else if (typeof value === 'string') {
|
||||
this.setDataValue('auto_chat_config', value);
|
||||
} else {
|
||||
this.setDataValue('auto_chat_config', JSON.stringify(value));
|
||||
}
|
||||
},
|
||||
defaultValue: null
|
||||
},
|
||||
// 自动活跃配置
|
||||
auto_active_config: {
|
||||
comment: '自动活跃配置(JSON对象)',
|
||||
type: Sequelize.JSON(),
|
||||
allowNull: true,
|
||||
get: function () {
|
||||
const value = this.getDataValue('auto_active_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('auto_active_config', null);
|
||||
} else if (typeof value === 'string') {
|
||||
this.setDataValue('auto_active_config', value);
|
||||
} else {
|
||||
this.setDataValue('auto_active_config', JSON.stringify(value));
|
||||
}
|
||||
},
|
||||
defaultValue: null
|
||||
},
|
||||
// 备注
|
||||
notes: {
|
||||
comment: '备注',
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
}
|
||||
}, {
|
||||
timestamps: true,
|
||||
createdAt: 'created_time',
|
||||
updatedAt: 'last_update_time',
|
||||
indexes: [
|
||||
{
|
||||
unique: false,
|
||||
fields: ['account_id']
|
||||
},
|
||||
{
|
||||
unique: false,
|
||||
fields: ['platform_type']
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
return account_config;
|
||||
};
|
||||
|
||||
@@ -1,309 +0,0 @@
|
||||
const Sequelize = require('sequelize');
|
||||
|
||||
/**
|
||||
* 设备状态表模型
|
||||
* 记录pydp客户端设备的实时状态和运行信息
|
||||
*/
|
||||
module.exports = (db) => {
|
||||
const device_status= db.define("device_status", {
|
||||
// 设备基本信息
|
||||
sn_code: {
|
||||
comment: '设备SN码(唯一标识)',
|
||||
type: Sequelize.STRING(50),
|
||||
allowNull: false,
|
||||
primaryKey: true
|
||||
},
|
||||
device_id:{
|
||||
comment: '设备ID',
|
||||
type: Sequelize.STRING(200),
|
||||
allowNull: false,
|
||||
primaryKey: true
|
||||
},
|
||||
|
||||
deviceName: {
|
||||
comment: '设备名称',
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
deviceType: {
|
||||
comment: '设备类型',
|
||||
type: Sequelize.STRING(50),
|
||||
allowNull: true,
|
||||
defaultValue: 'pydp'
|
||||
},
|
||||
|
||||
// 在线状态
|
||||
isOnline: {
|
||||
comment: '是否在线',
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false
|
||||
},
|
||||
isRunning: {
|
||||
comment: '是否运行中',
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: false,
|
||||
defaultValue: false
|
||||
},
|
||||
lastOnlineTime: {
|
||||
comment: '最后在线时间',
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true
|
||||
},
|
||||
lastOfflineTime: {
|
||||
comment: '最后离线时间',
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true
|
||||
},
|
||||
onlineDuration: {
|
||||
comment: '在线时长(分钟)',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
|
||||
// 运行状态
|
||||
currentTask: {
|
||||
comment: '当前执行任务',
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
currentTaskId: {
|
||||
comment: '当前任务ID',
|
||||
type: Sequelize.STRING(50),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
taskStatus: {
|
||||
comment: '任务状态',
|
||||
type: Sequelize.STRING(20),
|
||||
allowNull: true,
|
||||
defaultValue: 'idle'
|
||||
},
|
||||
lastTaskTime: {
|
||||
comment: '最后任务时间',
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true
|
||||
},
|
||||
|
||||
// 平台信息
|
||||
platform: {
|
||||
comment: '当前使用平台: boss-Boss直聘, liepin-猎聘',
|
||||
type: Sequelize.STRING(20),
|
||||
allowNull: true,
|
||||
defaultValue: 'boss'
|
||||
},
|
||||
isLoggedIn: {
|
||||
comment: '是否已登录平台',
|
||||
type: Sequelize.BOOLEAN,
|
||||
allowNull: true,
|
||||
defaultValue: false
|
||||
},
|
||||
loginTime: {
|
||||
comment: '登录时间',
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true
|
||||
},
|
||||
accountName: {
|
||||
comment: '账号名称',
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
|
||||
// 性能信息
|
||||
cpuUsage: {
|
||||
comment: 'CPU使用率(%)',
|
||||
type: Sequelize.FLOAT,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
memoryUsage: {
|
||||
comment: '内存使用率(%)',
|
||||
type: Sequelize.FLOAT,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
diskUsage: {
|
||||
comment: '磁盘使用率(%)',
|
||||
type: Sequelize.FLOAT,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
|
||||
// 网络信息
|
||||
ipAddress: {
|
||||
comment: 'IP地址',
|
||||
type: Sequelize.STRING(50),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
macAddress: {
|
||||
comment: 'MAC地址',
|
||||
type: Sequelize.STRING(50),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
networkStatus: {
|
||||
comment: '网络状态: good-良好, slow-缓慢, offline-离线',
|
||||
type: Sequelize.STRING(20),
|
||||
allowNull: true,
|
||||
defaultValue: 'good'
|
||||
},
|
||||
|
||||
// 心跳信息
|
||||
lastHeartbeatTime: {
|
||||
comment: '最后心跳时间',
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true
|
||||
},
|
||||
heartbeatInterval: {
|
||||
comment: '心跳间隔(秒)',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 30
|
||||
},
|
||||
missedHeartbeats: {
|
||||
comment: '丢失的心跳次数',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
|
||||
// 版本信息
|
||||
clientVersion: {
|
||||
comment: '客户端版本',
|
||||
type: Sequelize.STRING(20),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
pythonVersion: {
|
||||
comment: 'Python版本',
|
||||
type: Sequelize.STRING(20),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
osVersion: {
|
||||
comment: '操作系统版本',
|
||||
type: Sequelize.STRING(100),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
|
||||
// 统计信息
|
||||
totalTasksCompleted: {
|
||||
comment: '完成任务总数',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
totalTasksFailed: {
|
||||
comment: '失败任务总数',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
totalJobsSearched: {
|
||||
comment: '搜索岗位总数',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
totalApplies: {
|
||||
comment: '投递简历总数',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
totalChats: {
|
||||
comment: '聊天总数',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
|
||||
// 错误信息
|
||||
lastError: {
|
||||
comment: '最后错误信息',
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
lastErrorTime: {
|
||||
comment: '最后错误时间',
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true
|
||||
},
|
||||
errorCount: {
|
||||
comment: '错误次数',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
|
||||
// 健康状态
|
||||
healthStatus: {
|
||||
comment: '健康状态: healthy-健康, warning-警告, error-错误, unknown-未知',
|
||||
type: Sequelize.STRING(20),
|
||||
allowNull: true,
|
||||
defaultValue: 'unknown'
|
||||
},
|
||||
healthScore: {
|
||||
comment: '健康评分(0-100)',
|
||||
type: Sequelize.INTEGER,
|
||||
allowNull: true,
|
||||
defaultValue: 0
|
||||
},
|
||||
|
||||
// 配置信息
|
||||
config: {
|
||||
comment: '设备配置(JSON)',
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
|
||||
// 其他信息
|
||||
notes: {
|
||||
comment: '备注',
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
|
||||
}, {
|
||||
timestamps: false,
|
||||
indexes: [
|
||||
{
|
||||
unique: false,
|
||||
fields: ['isOnline']
|
||||
},
|
||||
{
|
||||
unique: false,
|
||||
fields: ['isRunning']
|
||||
},
|
||||
{
|
||||
unique: false,
|
||||
fields: ['healthStatus']
|
||||
},
|
||||
{
|
||||
unique: false,
|
||||
fields: ['platform']
|
||||
},
|
||||
{
|
||||
unique: false,
|
||||
fields: ['lastHeartbeatTime']
|
||||
},
|
||||
|
||||
]
|
||||
});
|
||||
|
||||
// device_status.sync({ force: true });
|
||||
|
||||
return device_status
|
||||
|
||||
// device_status.sync({ force: true
|
||||
};
|
||||
|
||||
@@ -15,6 +15,12 @@ module.exports = (db) => {
|
||||
allowNull: false,
|
||||
defaultValue: ''
|
||||
},
|
||||
device_id: {
|
||||
comment: '设备ID',
|
||||
type: Sequelize.STRING(200),
|
||||
allowNull: true,
|
||||
defaultValue: ''
|
||||
},
|
||||
platform_type: {
|
||||
comment: '平台',
|
||||
type: Sequelize.STRING(50),
|
||||
|
||||
Reference in New Issue
Block a user