def create_topics_list( self, db: Session ): # skip, limit = dict(config).values() # Desestruturando (Unpacking) os valores do Request Body config topics = TopicsRepository.get_all(db) response_topics = [response_topic(topic) for topic in topics] return response_topics
def validate_id( self, db: Session, *, id: str = id ) -> TopicsModel: topic = TopicsRepository.get_by_id( db, id=id ) if not topic: raise HTTPException( status_code=400, detail="Aula não encontrado." ) return { "db_object": topic, "response": response_topic(topic) }
def update_topic( self, db: Session, *, db_object: TopicsModel, infos_object: Union[TopicBaseSchema, Dict[str, Union[str, StatusOptions]]] ): # Reforçando que o id que chega no Params seja o mesmo que o Request Body # infos_object['id'] = id updated_topic = TopicsRepository.update(db, db_object=db_object, req_object=infos_object) return response_topic(updated_topic)
def remove_topic( self, db: Session, *, id: str = id ): removed_topic = TopicsRepository.remove(db, id=id) return response_topic(removed_topic)
def create_topics_list_by_class(self, db: Session, *, id: str = id): topics = TopicsRepository.get_by_class(db, id=id) response_topics = [response_topic(topic) for topic in topics] return response_topics
def create_topic( self, db: Session, *, object: TopicBaseSchema ): topic = TopicsRepository.create(db, req_object=object) return response_topic(topic)