def post(self): try: data = Post_Video_parser.parse_args(strict=True) id_ = Video.insert(**data) if not id_: return succeed_resp(message="已存在") return succeed_resp(id_=id_) except Exception as e: traceback.print_exc() return failed_resp(message=str(e))
def get(self, id_=None): args = Get_Episode_parser.parse_args(strict=True) if id_ is None: data = Episode.query_list(**args) result = { "data": [i.to_dict() for i in data.items], "total": data.total, "page": data.page, "per_page": data.per_page } return succeed_resp(result=result) else: result = Episode.query_id(id_) return succeed_resp(result=result)
def post(self): try: data = Episode_parser.parse_args(strict=True) id_ = Episode.insert(**data) return succeed_resp(id_=id_) except Exception as e: return failed_resp(message=str(e))
def patch(self, id_): data = Update_Episode_parser.parse_args() if Episode.update_query(id_, **data): return succeed_resp(message="ok") else: return failed_resp(message="failed")
def delete(self, id_): if Episode.delete(id_): return succeed_resp(message="ok") else: return failed_resp(message="failed")
def get(self): args = Get_Video_parser.parse_args(strict=True) data = Video.query_by_episode_id(**args) return succeed_resp(result=data)