- 在recruiters与jobs表中新增账号权益和统计字段,添加对应索引和外键约束 - 扩展Recruiter和Job领域模型,支持权益、同步状态及职位统计信息 - 实现账号同步定时任务,定期检查账号状态、同步权益及职位数据 - 实现简历处理定时任务,遍历活跃账号职位,抓取候选人简历并统一入库 - 引入Job调度器,集中管理账号同步和简历处理任务的调度、启停及状态监控 - 添加.gitignore规则忽略.idea目录配置文件
数据库配置指南
1. 数据库设计文档
核心表结构
| 表名 | 说明 | 主要字段 |
|---|---|---|
candidates |
候选人主表 | 基本信息、职业信息、联系方式、状态 |
resumes |
简历内容表 | 原始内容、解析内容、附件、版本 |
jobs |
职位信息表 | 职位名称、部门、薪资、要求 |
evaluation_schemas |
评价方案表 | 维度配置、权重、提示词模板 |
evaluations |
评价记录表 | 评分结果、AI分析、推荐意见 |
notifications |
通知记录表 | 通知渠道、状态、发送时间 |
ER 关系图
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ candidates │────<│ resumes │ │ jobs │
│ (候选人) │ │ (简历) │ │ (职位) │
└──────┬──────┘ └─────────────┘ └──────┬──────┘
│ │
│ ┌─────────────┐ │
└────────>│ evaluations │<─────────────┘
│ (评价记录) │
└──────┬──────┘
│
┌──────┴──────┐
│ notifications│
│ (通知记录) │
└─────────────┘
2. 数据库配置方法
方法一:SQLite (开发测试)
无需额外配置,默认使用 SQLite:
# 在项目根目录创建 .env 文件
echo "DB_URL=sqlite:///./hr_agent.db" > .env
方法二:MySQL (生产环境)
2.1 创建数据库
CREATE DATABASE hr_agent CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'hr_agent'@'%' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON hr_agent.* TO 'hr_agent'@'%';
FLUSH PRIVILEGES;
2.2 配置连接
# .env 文件
echo "DB_URL=mysql+pymysql://hr_agent:your_password@localhost:3306/hr_agent" > .env
2.3 安装依赖
uv add pymysql cryptography
方法三:PostgreSQL
3.1 创建数据库
CREATE DATABASE hr_agent ENCODING 'UTF8';
CREATE USER hr_agent WITH PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE hr_agent TO hr_agent;
3.2 配置连接
# .env 文件
echo "DB_URL=postgresql+asyncpg://hr_agent:your_password@localhost:5432/hr_agent" > .env
3.3 安装依赖
uv add asyncpg
3. 初始化数据库
3.1 执行 SQL 脚本
# MySQL
mysql -u hr_agent -p hr_agent < migrations/001_init_schema.sql
# SQLite
sqlite3 hr_agent.db < migrations/001_init_schema.sql
# PostgreSQL
psql -U hr_agent -d hr_agent -f migrations/001_init_schema.sql
3.2 验证初始化
-- 查看表结构
SHOW TABLES;
-- 查看默认评价方案
SELECT * FROM evaluation_schemas;
4. 环境变量配置
在项目根目录创建 .env 文件:
# 数据库配置
DB_URL=sqlite:///./hr_agent.db
DB_ECHO=false
# LLM 配置
LLM_PROVIDER=mock
LLM_API_KEY=
LLM_MODEL=gpt-4
# 爬虫配置
CRAWLER_BOSS_WT_TOKEN=your_boss_token
# 通知配置 (可选)
NOTIFY_WECHAT_WORK_WEBHOOK=
NOTIFY_DINGTALK_WEBHOOK=
5. 常用查询示例
查询候选人列表
SELECT
c.id,
c.name,
c.source,
c.current_company,
c.current_position,
c.status,
e.overall_score,
e.recommendation
FROM candidates c
LEFT JOIN evaluations e ON c.id = e.candidate_id
WHERE c.status = 'NEW'
ORDER BY c.created_at DESC;
查询高分候选人
SELECT
c.name,
c.current_company,
e.overall_score,
e.summary
FROM candidates c
JOIN evaluations e ON c.id = e.candidate_id
WHERE e.overall_score >= 80
AND e.recommendation IN ('strong_recommend', 'recommend')
ORDER BY e.overall_score DESC;
统计各渠道候选人数量
SELECT
source,
COUNT(*) as total,
SUM(CASE WHEN status = 'ANALYZED' THEN 1 ELSE 0 END) as analyzed
FROM candidates
GROUP BY source;