用户认证: - User 模型(支持邮箱/手机号登录) - 双 Token JWT 认证(accessToken + refreshToken) - 注册/登录/刷新 Token API 组织模型: - Brand(品牌方)、Agency(代理商)、Creator(达人) - 多对多关系:品牌方↔代理商、代理商↔达人 项目与任务: - Project 模型(品牌方发布) - Task 模型(完整审核流程追踪) - Brief 模型(解析后的结构化内容) 文件上传: - 阿里云 OSS 直传签名服务 - 支持分片上传,最大 500MB 数据库迁移: - 003_user_org_project_task.py Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
"""FastAPI 应用入口"""
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from app.config import settings
|
|
from app.api import health, auth, upload, scripts, videos, tasks, rules, ai_config, risk_exceptions, metrics
|
|
|
|
# 创建应用
|
|
app = FastAPI(
|
|
title=settings.APP_NAME,
|
|
version=settings.APP_VERSION,
|
|
description="AI 营销内容合规审核平台 API",
|
|
docs_url="/docs" if settings.DEBUG else None,
|
|
redoc_url="/redoc" if settings.DEBUG else None,
|
|
)
|
|
|
|
# CORS 配置
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"] if settings.DEBUG else ["https://miaosi.ai"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# 注册路由
|
|
app.include_router(health.router, prefix="/api/v1")
|
|
app.include_router(auth.router, prefix="/api/v1")
|
|
app.include_router(upload.router, prefix="/api/v1")
|
|
app.include_router(scripts.router, prefix="/api/v1")
|
|
app.include_router(videos.router, prefix="/api/v1")
|
|
app.include_router(tasks.router, prefix="/api/v1")
|
|
app.include_router(rules.router, prefix="/api/v1")
|
|
app.include_router(ai_config.router, prefix="/api/v1")
|
|
app.include_router(risk_exceptions.router, prefix="/api/v1")
|
|
app.include_router(metrics.router, prefix="/api/v1")
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
"""根路径"""
|
|
return {
|
|
"message": f"Welcome to {settings.APP_NAME}",
|
|
"version": settings.APP_VERSION,
|
|
"docs": "/docs" if settings.DEBUG else "disabled",
|
|
}
|