feat: 实现新闻批量接收和法律风险分析API
- 添加 /api/news/batch 端点用于接收和查询新闻数据
- 添加 /api/legal-risk/analyze 端点用于企业风险评估
- 使用内存存储(后续将迁移至PostgreSQL)
- 包含测试脚本和使用示例
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
37cd6d3ab5
commit
b02f3bab5b
4 changed files with 614 additions and 0 deletions
79
API_DELIVERY_SUMMARY.md
Normal file
79
API_DELIVERY_SUMMARY.md
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
# API Extension Delivery Summary
|
||||
|
||||
## Completed Tasks ✅
|
||||
|
||||
### 1. News Batch API (`/api/news/batch`)
|
||||
- **Location**: `src/app/api/news/batch/route.ts`
|
||||
- **Features**:
|
||||
- POST: Receive batch news data from crawlers
|
||||
- GET: Retrieve latest news (default 10, max 100)
|
||||
- In-memory storage (up to 1000 articles)
|
||||
- Filtering by source and category
|
||||
|
||||
### 2. Legal Risk Analysis API (`/api/legal-risk/analyze`)
|
||||
- **Location**: `src/app/api/legal-risk/analyze/route.ts`
|
||||
- **Features**:
|
||||
- POST: Analyze enterprise risk levels
|
||||
- GET: Retrieve analysis history
|
||||
- Risk scoring algorithm (0-100)
|
||||
- Risk categorization (regulatory, financial, reputational, operational, compliance)
|
||||
- Automated recommendations based on risk level
|
||||
- In-memory storage (up to 100 analyses)
|
||||
|
||||
## Test Commands
|
||||
|
||||
### News API Test
|
||||
```bash
|
||||
# POST news articles
|
||||
curl -X POST http://localhost:3000/api/news/batch \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"source": "test_crawler",
|
||||
"articles": [
|
||||
{
|
||||
"title": "Test Article",
|
||||
"content": "Article content here...",
|
||||
"url": "https://example.com/news/1",
|
||||
"category": "Technology"
|
||||
}
|
||||
]
|
||||
}'
|
||||
|
||||
# GET latest news
|
||||
curl http://localhost:3000/api/news/batch
|
||||
```
|
||||
|
||||
### Legal Risk API Test
|
||||
```bash
|
||||
# POST risk analysis
|
||||
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,
|
||||
"publiclyTraded": false
|
||||
}
|
||||
}'
|
||||
|
||||
# GET analysis history
|
||||
curl http://localhost:3000/api/legal-risk/analyze
|
||||
```
|
||||
|
||||
## Files Created
|
||||
1. `src/app/api/news/batch/route.ts` - News batch API endpoint
|
||||
2. `src/app/api/legal-risk/analyze/route.ts` - Legal risk analysis API endpoint
|
||||
3. `test-apis.js` - Test script with usage examples
|
||||
4. `API_DELIVERY_SUMMARY.md` - This documentation
|
||||
|
||||
## Notes
|
||||
- Both APIs use in-memory storage temporarily (PostgreSQL integration pending)
|
||||
- Server must be running on port 3000 (`npm run dev`)
|
||||
- APIs follow Next.js App Router conventions
|
||||
- TypeScript with proper type definitions
|
||||
- Error handling and validation included
|
||||
|
||||
## Delivery Time
|
||||
Completed before 18:00 deadline ✅
|
||||
Loading…
Add table
Add a link
Reference in a new issue