From c1e50736e87deddc8f75aa4c759f81d1dfb6ada4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=20=E6=9F=8F?= Date: Sat, 16 Sep 2023 01:52:15 +0000 Subject: [PATCH] action table add --- backend/app/api/api_v1/routers/platform.py | 16 ++++++++++++++-- backend/app/db/crud.py | 8 +++++++- backend/app/db/models.py | 10 +++++++++- backend/app/db/schemas.py | 10 ++++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/backend/app/api/api_v1/routers/platform.py b/backend/app/api/api_v1/routers/platform.py index 358aaab..e87f9c6 100644 --- a/backend/app/api/api_v1/routers/platform.py +++ b/backend/app/api/api_v1/routers/platform.py @@ -2,7 +2,7 @@ from fastapi import Request,Depends, APIRouter, UploadFile,HTTPException,File from app.db import Base,engine from app.db.session import get_db from app.db.crud import * -from app.db.schemas import AppBase, AppEdit, App,Kintone +from app.db.schemas import AppBase, AppEdit, App,Kintone,Action platform_router = r = APIRouter() @@ -64,4 +64,16 @@ async def kintone_data( db=Depends(get_db), ): kintone = get_kintones(db, type) - return kintone \ No newline at end of file + return kintone + +@r.get( + "/actions", + response_model=t.List[Action], + response_model_exclude={"id"}, +) +async def action_data( + request: Request, + db=Depends(get_db), +): + actions = get_actions(db) + return actions \ No newline at end of file diff --git a/backend/app/db/crud.py b/backend/app/db/crud.py index 08614f4..d7a6fa1 100644 --- a/backend/app/db/crud.py +++ b/backend/app/db/crud.py @@ -115,4 +115,10 @@ def get_kintones(db: Session, type: int): kintones = db.query(models.Kintone).filter(models.Kintone.type == type).all() if not kintones: raise HTTPException(status_code=404, detail="Data not found") - return kintones \ No newline at end of file + return kintones + +def get_actions(db: Session): + actions = db.query(models.Action).all() + if not actions: + raise HTTPException(status_code=404, detail="Data not found") + return actions \ No newline at end of file diff --git a/backend/app/db/models.py b/backend/app/db/models.py index 0e6812b..0216735 100644 --- a/backend/app/db/models.py +++ b/backend/app/db/models.py @@ -28,4 +28,12 @@ class Kintone(Base): type = Column(Integer, index=True, nullable=False) name = Column(String(100), nullable=False) desc = Column(String) - content = Column(String) \ No newline at end of file + content = Column(String) + +class Action(Base): + __tablename__ = "action" + id = Column(Integer, primary_key=True, index=True) + name = Column(String(100), index=True, nullable=False) + title = Column(String(200)) + inputpoint = Column(String(100)) + property = Column(String) \ No newline at end of file diff --git a/backend/app/db/schemas.py b/backend/app/db/schemas.py index 5d106c7..91d7256 100644 --- a/backend/app/db/schemas.py +++ b/backend/app/db/schemas.py @@ -67,5 +67,15 @@ class Kintone(BaseModel): desc: str = None content: str = None + class Config: + orm_mode = True + +class Action(BaseModel): + id: int + name: str = None + title: str = None + inputpoint: str = None + property: str = None + class Config: orm_mode = True \ No newline at end of file