event&eventaction
This commit is contained in:
@@ -184,3 +184,32 @@ async def domain_delete(
|
|||||||
):
|
):
|
||||||
|
|
||||||
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
|
||||||
@@ -225,3 +225,15 @@ def get_domain(db: Session, userid: str):
|
|||||||
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
|
||||||
@@ -59,3 +59,18 @@ class UserDomain(Base):
|
|||||||
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"))
|
||||||
@@ -124,3 +124,14 @@ class Domain(Base):
|
|||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
orm_mode = True
|
orm_mode = True
|
||||||
|
|
||||||
|
class Event(Base):
|
||||||
|
id: int
|
||||||
|
category: str
|
||||||
|
type: str
|
||||||
|
eventid: str
|
||||||
|
function: str
|
||||||
|
mobile: bool
|
||||||
|
|
||||||
|
class Config:
|
||||||
|
orm_mode = True
|
||||||
Reference in New Issue
Block a user