- 添加 /api/news/batch 端点用于接收和查询新闻数据
- 添加 /api/legal-risk/analyze 端点用于企业风险评估
- 使用内存存储(后续将迁移至PostgreSQL)
- 包含测试脚本和使用示例
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
2.2 KiB
2.2 KiB
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
# 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
# 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
src/app/api/news/batch/route.ts- News batch API endpointsrc/app/api/legal-risk/analyze/route.ts- Legal risk analysis API endpointtest-apis.js- Test script with usage examplesAPI_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 ✅