57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
from fastapi import APIRouter, HTTPException
|
||
from app.models.request import AuditRequest
|
||
from app.models.response import AuditResponse
|
||
from app.services.audit_service import AuditService
|
||
import logging
|
||
|
||
# 配置日志
|
||
logging.basicConfig(level=logging.INFO)
|
||
logger = logging.getLogger(__name__)
|
||
|
||
router = APIRouter(prefix="/api/v1", tags=["audit"])
|
||
|
||
# 创建审核服务实例
|
||
audit_service = AuditService()
|
||
|
||
@router.post("/audit", response_model=AuditResponse)
|
||
async def audit_order(request: AuditRequest):
|
||
"""
|
||
AI审核订单接口
|
||
|
||
接收订单信息,执行AI智能审核,返回审核结果
|
||
"""
|
||
try:
|
||
logger.info(f"开始审核订单: {request.order_id}")
|
||
|
||
# 执行审核
|
||
result = await audit_service.audit_order(request)
|
||
|
||
logger.info(f"订单审核完成: {request.order_id}, 结果: {result.result}")
|
||
|
||
return result
|
||
|
||
except Exception as e:
|
||
logger.error(f"订单审核失败: {request.order_id}, 错误: {str(e)}")
|
||
|
||
raise HTTPException(
|
||
status_code=500,
|
||
detail={
|
||
"error": "AI审核服务异常",
|
||
"order_id": request.order_id,
|
||
"message": str(e)
|
||
}
|
||
)
|
||
|
||
@router.get("/health")
|
||
async def health_check():
|
||
"""健康检查接口"""
|
||
return {"status": "healthy", "service": "ai_review_service"}
|
||
|
||
@router.get("/version")
|
||
async def get_version():
|
||
"""版本信息接口"""
|
||
return {
|
||
"service": "TYCM AI Review Service",
|
||
"version": "1.0.0",
|
||
"description": "AI智能审核服务 - 最小实现版本"
|
||
} |