event&eventaction

This commit is contained in:
2023-10-29 17:16:50 +09:00
parent ead6658455
commit 9cd4c8a5ab
4 changed files with 70 additions and 3 deletions

View File

@@ -184,3 +184,32 @@ async def domain_delete(
):
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

View File

@@ -225,3 +225,15 @@ def get_domain(db: Session, userid: str):
if not domains:
raise HTTPException(status_code=404, detail="Data not found")
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

View File

@@ -59,3 +59,18 @@ class UserDomain(Base):
kintoneuser = Column(String(100), nullable=False)
kintonepwd = Column(String(100), nullable=False)
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"))

View File

@@ -124,3 +124,14 @@ class Domain(Base):
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