Example #1
0
 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
Example #2
0
 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)
     }
Example #3
0
    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)
Example #4
0
    def remove_topic( self, db: Session, *, id: str = id ):                
        removed_topic = TopicsRepository.remove(db, id=id)

        return response_topic(removed_topic)
Example #5
0
    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        
Example #6
0
 def create_topic( self, db: Session, *, object: TopicBaseSchema ):
     topic = TopicsRepository.create(db, req_object=object)
     
     return response_topic(topic)