Perplexica/PR_TEMPLATE.md
钟山 5bc1f1299e feat: 接入PostgreSQL数据库实现数据持久化
- 将news/batch API从内存存储改为PostgreSQL
- 添加企业实体识别功能(Lagos-inspired)
- 创建三个数据表:news_articles, risk_analyses, entity_mentions
- 实现分页和过滤功能
- 支持在新闻中搜索企业实体
- 添加完整的测试脚本和文档

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-07 23:12:16 +08:00

82 lines
No EOL
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PR创建信息
## 分支已推送成功 ✅
- 分支名:`feature/khartoum-api-extension`
- PR链接https://github.com/Zhongshan9810/Perplexica/pull/new/feature/khartoum-api-extension
## PR标题
```
[Khartoum] 实现新闻批量接收和法律风险分析API
```
## PR描述复制以下内容
```markdown
## 完成内容
- [x] 创建 /api/news/batch 端点用于接收爬虫批量数据
- [x] 实现 GET 方法返回最新10条新闻支持筛选和分页
- [x] 创建 /api/legal-risk/analyze 端点用于企业风险分析
- [x] 实现风险评分算法0-100分和风险等级分类
- [x] 自动生成风险因素分析和建议
- [x] 使用内存存储实现数据暂存后续迁移至PostgreSQL
- [x] 编写测试脚本和使用示例
## 测试结果
### News API测试命令
```bash
# POST 批量新闻数据
curl -X POST http://localhost:3000/api/news/batch \
-H "Content-Type: application/json" \
-d '{
"source": "test_crawler",
"articles": [
{
"title": "Breaking: Tech Company Update",
"content": "Content here...",
"category": "Technology"
}
]
}'
# GET 最新新闻
curl http://localhost:3000/api/news/batch
```
### Legal Risk API测试命令
```bash
# POST 风险分析
curl -X POST http://localhost:3000/api/legal-risk/analyze \
-H "Content-Type: application/json" \
-d '{
"companyName": "TestCorp Inc.",
"industry": "Financial Services",
"dataPoints": {
"employees": 25,
"yearFounded": 2022
}
}'
```
### 预期响应:
- News API: 返回处理成功消息和存储的文章列表
- Risk API: 返回风险评分(0-100)、风险等级、分类评估和建议
## 运行方法
```bash
# 1. 安装依赖
npm install
# 2. 启动开发服务器
npm run dev
# 3. 执行测试脚本查看示例
node test-apis.js
# 4. 使用curl命令测试API服务器需在3000端口运行
```
## 文件变更
- `src/app/api/news/batch/route.ts` - 新闻批量API
- `src/app/api/legal-risk/analyze/route.ts` - 法律风险分析API
- `test-apis.js` - 测试脚本
- `API_DELIVERY_SUMMARY.md` - 交付文档
```