DB連動実装

This commit is contained in:
2023-09-27 14:35:24 +09:00
parent 418f45f997
commit 4c6b2ea844
16 changed files with 688 additions and 24 deletions

View File

@@ -3,6 +3,7 @@ from app.db import Base,engine
from app.db.session import get_db
from app.db.crud import *
from app.db.schemas import *
from typing import List
platform_router = r = APIRouter()
@@ -91,7 +92,21 @@ async def flow_details(
):
app = get_flow(db, flowid)
return app
@r.get(
"/flows/{appid}",
response_model=List[Flow],
response_model_exclude_none=True,
)
async def flow_list(
request: Request,
appid: str,
db=Depends(get_db),
):
flows = get_flows_by_app(db, appid)
return flows
@r.post("/flow", response_model=Flow, response_model_exclude_none=True)
async def flow_create(

View File

@@ -173,4 +173,10 @@ def get_flow(db: Session, flowid: str):
flow = db.query(models.Flow).filter(models.Flow.flowid == flowid).first()
if not flow:
raise HTTPException(status_code=404, detail="Data not found")
return flow
return flow
def get_flows_by_app(db: Session, appid: str):
flows = db.query(models.Flow).filter(models.Flow.appid == appid).all()
if not flows:
raise HTTPException(status_code=404, detail="Data not found")
return flows