新增批量

This commit is contained in:
杨志
2026-01-06 11:23:52 +08:00
parent e41dd33d23
commit cb7ad9a4b7
15 changed files with 1371 additions and 75 deletions

View File

@@ -0,0 +1,161 @@
# 批量匹配查询接口说明
## 接口地址
```
POST /match/batch
```
## 接口说明
该接口基于数据库实现快速批量匹配查询传入用户ID自动从数据库读取用户简历信息和所有岗位进行匹配计算并按匹配度排序返回。
## 请求参数
### 请求方式
- **方法**: POST
- **Content-Type**: application/json 或 application/x-www-form-urlencoded
### 请求参数说明
| 参数名 | 类型 | 必填 | 说明 |
|--------|------|------|------|
| user_id | int | 是 | 用户ID |
| page | int | 否 | 页码从1开始默认1 |
| page_size | int | 否 | 每页数量默认20最大100 |
| filter_zero | bool | 否 | 是否过滤0分岗位默认false |
### 请求示例
#### JSON格式请求
```json
{
"user_id": 527,
"page": 1,
"page_size": 20,
"filter_zero": false
}
```
#### 表单格式请求
```
user_id=527&page=1&page_size=20&filter_zero=false
```
## 响应参数
### 成功响应
```json
{
"code": 200,
"msg": "查询成功",
"data": {
"list": [
{
"position_id": 2,
"match_score": 95,
"position": {
"id": 2,
"positon_name": "人工智能与大数据侦察职位二",
"education_require": "本科及以上",
"degree_require": "学士及以上",
...
}
},
{
"position_id": 1,
"match_score": 80,
"position": { ... }
}
],
"pagination": {
"page": 1,
"page_size": 20,
"total": 150,
"total_pages": 8,
"has_more": true
}
}
}
```
### 错误响应
```json
{
"code": 400,
"msg": "参数错误user_id不能为空且必须为数字",
"data": null
}
```
## 功能说明
### 1. 自动读取用户简历
接口会自动从数据库读取:
- 用户基本信息(`t_user`表)
- 教育经历(自动查找教育经历表)
### 2. 数据库快速过滤
使用SQL WHERE条件快速过滤岗位
- 学历要求过滤
- 性别要求过滤
- 排除已删除的岗位
### 3. 匹配度计算
对通过初步筛选的岗位进行详细匹配计算:
- 硬性条件检查(一票否决)
- 软性条件评分100分制
### 4. 排序和分页
- 按匹配度降序排序
- 支持分页返回
- 可选过滤0分岗位
## 性能说明
- **数据库过滤**利用SQL索引快速筛选从1万个岗位可能筛选到几百个
- **计算时间**:只计算通过初步筛选的岗位,大幅减少计算量
- **响应时间**通常在1-3秒内返回结果
## 注意事项
1. **教育经历表**:系统会自动查找以下表名:
- `t_user_education`
- `user_education`
- `t_education`
- `education`
如果您的教育经历表名不同,需要修改 `getUserResumeFromDb` 方法中的表名列表。
2. **年龄过滤**:由于年龄要求是文本格式(如"18周岁以上、35周岁以下"难以用SQL精确匹配会在详细匹配时检查。如需优化性能建议在数据库中添加 `age_min``age_max` 字段。
3. **专业要求**:专业要求存储在 `position_other_require` 的JSON字段中会在匹配时解析。
## 使用示例
```bash
# 查询用户ID为527的匹配岗位第1页每页20条
curl -X POST http://your-domain.com/match/batch \
-H "Content-Type: application/json" \
-d '{
"user_id": 527,
"page": 1,
"page_size": 20
}'
```
## 后续优化建议
1. **添加年龄字段**:在 `no_notice_position` 表中添加 `age_min``age_max` 字段,提升过滤效率
2. **建立索引**:对 `education_require``sex_require` 等字段建立索引
3. **缓存机制**:如果简历不变,可以缓存匹配结果
4. **专业分类表**:建立专业分类映射表,优化专业匹配