This repository has been archived on 2026-03-25. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
JiaoTianBo eedaac69b0 feat(notification): 新增通知渠道及绑定管理功能
- 新增数据库表 notification_channels, recruiter_channel_bindings 支持多渠道通知绑定
- 在 notifications 表中新增 channel_id 关联通知渠道
- 增加默认通知渠道示例数据插入脚本(企业微信、钉钉、飞书)
- 实现 NotificationChannel 和 RecruiterChannelBinding 两个ORM模型及关联关系
- 增加通知渠道管理API,支持增删改查及启用停用操作
- 实现通知渠道类型枚举及配置验证
- 新增招聘者与通知渠道绑定管理路由,支持绑定关系创建、更新和删除
- 在招聘者模块中集成通知渠道绑定管理相关接口
- 增加对应的请求参数、响应模型及数据校验模型
- 更新数据库配置和依赖注入,支持通知渠道服务
- 完善接口响应的错误处理和成功提示信息
- 保证所有新增代码符合项目代码风格和结构规范
2026-03-25 10:39:33 +08:00
..

数据库配置指南

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;