diff --git a/backend/app/api/api_v1/routers/platform.py b/backend/app/api/api_v1/routers/platform.py index 07ae5f7..3bc409d 100644 --- a/backend/app/api/api_v1/routers/platform.py +++ b/backend/app/api/api_v1/routers/platform.py @@ -183,4 +183,33 @@ async def domain_delete( db=Depends(get_db), ): - return delete_domain(db, userid,id) \ No newline at end of file + return delete_domain(db, userid,id) + + +@r.get( + "/events", + response_model=t.List[Event], + response_model_exclude={"id"}, + response_model_exclude_none=True, +) +async def event_data( + request: Request, + db=Depends(get_db), +): + events = get_events(db) + return events + + +@r.get( + "/eventactions/{eventid}", + response_model=t.List[Action], + response_model_exclude={"id"}, + response_model_exclude_none=True, +) +async def eventactions_data( + request: Request, + eventid: str, + db=Depends(get_db), +): + actions = get_eventactions(db,eventid) + return actions \ No newline at end of file diff --git a/backend/app/db/crud.py b/backend/app/db/crud.py index 4b5fcdc..2b983a9 100644 --- a/backend/app/db/crud.py +++ b/backend/app/db/crud.py @@ -224,4 +224,16 @@ def get_domain(db: Session, userid: str): domains = db.query(models.UserDomain).filter(models.UserDomain.userid == userid).all() if not domains: raise HTTPException(status_code=404, detail="Data not found") - return domains \ No newline at end of file + return domains + +def get_events(db: Session): + events = db.query(models.Event).all() + if not events: + raise HTTPException(status_code=404, detail="Data not found") + return events + +def get_eventactions(db: Session,eventid: str): + eveactions = db.query(models.Action).join(models.EventAction,models.EventAction.actionid == models.Action.id ).join(models.Event,models.Event.id == models.EventAction.eventid).filter(models.Event.eventid == eventid).all() + if not eveactions: + raise HTTPException(status_code=404, detail="Data not found") + return eveactions \ No newline at end of file diff --git a/backend/app/db/models.py b/backend/app/db/models.py index b22033a..49a8994 100644 --- a/backend/app/db/models.py +++ b/backend/app/db/models.py @@ -58,4 +58,19 @@ class UserDomain(Base): url = Column(String(200), nullable=False) kintoneuser = Column(String(100), nullable=False) kintonepwd = Column(String(100), nullable=False) - active = Column(Boolean, default=False) \ No newline at end of file + active = Column(Boolean, default=False) + +class Event(Base): + __tablename__ = "event" + + category = Column(String(100), nullable=False) + type = Column(String(100), nullable=False) + eventid= Column(String(100), nullable=False) + function = Column(String(500), nullable=False) + mobile = Column(Boolean, default=False) + +class EventAction(Base): + __tablename__ = "eventaction" + + eventid = Column(Integer,ForeignKey("event.id")) + actionid = Column(Integer,ForeignKey("action.id")) \ No newline at end of file diff --git a/backend/app/db/schemas.py b/backend/app/db/schemas.py index ef75fe1..5d36ee3 100644 --- a/backend/app/db/schemas.py +++ b/backend/app/db/schemas.py @@ -122,5 +122,16 @@ class Domain(Base): kintonepwd: str active:bool + class Config: + orm_mode = True + +class Event(Base): + id: int + category: str + type: str + eventid: str + function: str + mobile: bool + class Config: orm_mode = True \ No newline at end of file