初始化项目

This commit is contained in:
李如威 2025-08-21 23:32:47 +08:00
commit d99b278d24
6 changed files with 124 additions and 0 deletions

38
.gitignore vendored Normal file
View File

@ -0,0 +1,38 @@
# ---- 通用 ----
.DS_Store
*.log
*.tmp
*.swp
__pycache__/
*.py[cod]
.env
venv/
.idea/
.vscode/
# ---- Python (backend) ----
backend/__pycache__/
backend/.mypy_cache/
backend/.pytest_cache/
backend/.ruff_cache/
*.sqlite3
# 虚拟环境
backend/venv/
.env/
# ---- Node.js / React (frontend) ----
frontend/node_modules/
frontend/dist/
frontend/.vite/
frontend/.eslintcache
# 打包产物
*.tgz
# ---- Docker ----
*.pid
*.seed
*.pid.lock
docker-compose.override.yml

1
backend/.python-version Normal file
View File

@ -0,0 +1 @@
3.13.0

View File

@ -0,0 +1,11 @@
{
"is_init": false,
"db_type": "sqlite",
"mysql": {
"host": "",
"port": "",
"user": "",
"password": "",
"db_name": ""
}
}

52
backend/app/main.py Normal file
View File

@ -0,0 +1,52 @@
import uvicorn
import os
import json
from fastapi import FastAPI
from pathlib import Path
from models.schemas.system import InitStatusResponse, InitConfigRequest
# 响应类型
def load_init_config():
"""读取配置文件"""
config_path = Path(__file__).parent / "config" / "init.json"
with open(config_path, "r", encoding="utf-8") as f:
return json.load(f)
def create_app():
app = FastAPI(title="Workflow API", version="1.0.0")
@app.get("/")
async def root():
return {"message": "hello"}
@app.get(
"/check_init",
tags=["System"],
description="系统是否初始化",
response_model=InitStatusResponse,
)
async def check_init():
init_config = load_init_config()
is_init = init_config.get("is_init")
return InitStatusResponse(data=is_init)
@app.post(
"/init_system",
tags=["System"],
description="系统初始化",
response_model=InitStatusResponse,
)
async def init_system(request: InitConfigRequest):
return InitStatusResponse()
return app
app = create_app()
if __name__ == "__main__":
uvicorn.run("main:app", host="0.0.0.0", port=8080, reload=True)

View File

@ -0,0 +1,20 @@
from pydantic import BaseModel
class BaseResponse(BaseModel):
success: bool = True
message: str | None = None
class InitConfigRequest(BaseModel):
db_type: str
db_host: str | None
db_port: str | None
db_user: str | None
db_password: str | None
db_name: str | None
admin_password: str
class InitStatusResponse(BaseResponse):
data: bool = False

2
backend/requirements.txt Normal file
View File

@ -0,0 +1,2 @@
fastapi==0.116.1
uvicorn==0.35,0