feat: 添加数据库迁移脚本并更新Dockerfile配置 - 在Dockerfile中添加alembic配置文件和目录的复制指令 - 更新alembic/env.py注册新的模块模型:events、workflows、writebacks - 生成完整的初始数据库schema迁移脚本,包含以下表: - approval_requests, attendance_records, audit_logs, domain_events - expenses, feishu_event_receipts, fund_accounts, legacy_sync_runs - official_writeback_runs, performance_metrics, policies, procurements - projects, report_push_runs, risk_event_actions, risk_events - standards, suppliers, work_reports, work_tasks, workflow_actions - workflow_instances等21个数据表结构定义 - 在API路由器中添加新模块的路由:events、workflows、writebacks、observability ```
43 lines
1.2 KiB
Python
43 lines
1.2 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.api.router import api_router
|
|
from app.core.config import get_settings
|
|
from app.core.middleware import request_id_middleware
|
|
from app.core.scheduler import attach_scheduler
|
|
|
|
|
|
def _allow_cors_credentials(cors_origins: list[str]) -> bool:
|
|
return "*" not in cors_origins
|
|
|
|
|
|
def create_app() -> FastAPI:
|
|
"""Create and configure the FastAPI application."""
|
|
|
|
settings = get_settings()
|
|
app = FastAPI(
|
|
title=settings.app_name,
|
|
debug=settings.debug,
|
|
version="0.1.0",
|
|
description=(
|
|
"AI integration layer for company lifecycle management, existing MySQL "
|
|
"project systems, Feishu, OpenClaw, Hermes, and model providers."
|
|
),
|
|
)
|
|
|
|
app.middleware("http")(request_id_middleware)
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origins,
|
|
allow_credentials=_allow_cors_credentials(settings.cors_origins),
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(api_router, prefix=settings.api_prefix)
|
|
attach_scheduler(app)
|
|
return app
|
|
|
|
|
|
app = create_app()
|