Что POST запрос сразу возращал answer

This commit is contained in:
maksim 2024-06-03 20:05:19 +04:00
parent 82e6075f3f
commit 0b619038ba
3 changed files with 4 additions and 4 deletions

View File

@ -38,7 +38,7 @@ class QuestionRepository:
await session.flush()
await session.commit()
return question.id
return question.id, question.answer
@classmethod
async def find_all(cls) -> list[SQuestion]:

View File

@ -17,8 +17,8 @@ async def add_question(
type_mood: TypeMood, # Добавлен параметр type_mood
type_model: TypeModel, # Добавлен параметр type_model
) -> SQuestionId:
question_id = await QuestionRepository.add_one(question, type_mood, type_model) # Передача параметров type_mood и type_model
return {"ok": True, "question_id": question_id}
question_id, answer = await QuestionRepository.add_one(question, type_mood, type_model) # Передача параметров type_mood и type_model
return {"question_id": question_id, "answer": answer}
@router.get("")
async def get_questions() -> list[SQuestion]:

View File

@ -17,8 +17,8 @@ class SQuestion(SQuestionAdd):
model_config = ConfigDict(from_attributes=True)
class SQuestionId(BaseModel):
ok: bool = True
question_id: int
answer: str
class Flight(BaseModel):
id: int