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

@@ -183,4 +183,33 @@ async def domain_delete(
db=Depends(get_db), db=Depends(get_db),
): ):
return delete_domain(db, userid,id) 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

@@ -224,4 +224,16 @@ def get_domain(db: Session, userid: str):
domains = db.query(models.UserDomain).filter(models.UserDomain.userid == userid).all() domains = db.query(models.UserDomain).filter(models.UserDomain.userid == userid).all()
if not domains: if not domains:
raise HTTPException(status_code=404, detail="Data not found") raise HTTPException(status_code=404, detail="Data not found")
return domains 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

@@ -58,4 +58,19 @@ class UserDomain(Base):
url = Column(String(200), nullable=False) url = Column(String(200), nullable=False)
kintoneuser = Column(String(100), nullable=False) kintoneuser = Column(String(100), nullable=False)
kintonepwd = Column(String(100), nullable=False) kintonepwd = Column(String(100), nullable=False)
active = Column(Boolean, default=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

@@ -122,5 +122,16 @@ class Domain(Base):
kintonepwd: str kintonepwd: str
active:bool active:bool
class Config:
orm_mode = True
class Event(Base):
id: int
category: str
type: str
eventid: str
function: str
mobile: bool
class Config: class Config:
orm_mode = True orm_mode = True