add api.log&errorlog->db
This commit is contained in:
@@ -282,4 +282,12 @@ 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
|
||||
return eveactions
|
||||
|
||||
|
||||
def create_log(db: Session, error:schemas.ErrorCreate):
|
||||
db_log = models.ErrorLog(location=error.location,title=error.title,content=error.content)
|
||||
db.add(db_log)
|
||||
db.commit()
|
||||
db.refresh(db_log)
|
||||
return db_log
|
||||
@@ -90,4 +90,12 @@ class EventAction(Base):
|
||||
__tablename__ = "eventaction"
|
||||
|
||||
eventid = Column(Integer,ForeignKey("event.id"))
|
||||
actionid = Column(Integer,ForeignKey("action.id"))
|
||||
actionid = Column(Integer,ForeignKey("action.id"))
|
||||
|
||||
|
||||
class ErrorLog(Base):
|
||||
__tablename__ = "errorlog"
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
location = Column(String(200))
|
||||
title = Column(String(50))
|
||||
content = Column(String(5000))
|
||||
@@ -139,4 +139,9 @@ class Event(Base):
|
||||
mobile: bool
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
orm_mode = True
|
||||
|
||||
class ErrorCreate(BaseModel):
|
||||
location:str
|
||||
title:str
|
||||
content:str
|
||||
Reference in New Issue
Block a user