Что POST запрос сразу возращал answer
This commit is contained in:
parent
82e6075f3f
commit
0b619038ba
@ -38,7 +38,7 @@ class QuestionRepository:
|
|||||||
|
|
||||||
await session.flush()
|
await session.flush()
|
||||||
await session.commit()
|
await session.commit()
|
||||||
return question.id
|
return question.id, question.answer
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def find_all(cls) -> list[SQuestion]:
|
async def find_all(cls) -> list[SQuestion]:
|
||||||
|
@ -17,8 +17,8 @@ async def add_question(
|
|||||||
type_mood: TypeMood, # Добавлен параметр type_mood
|
type_mood: TypeMood, # Добавлен параметр type_mood
|
||||||
type_model: TypeModel, # Добавлен параметр type_model
|
type_model: TypeModel, # Добавлен параметр type_model
|
||||||
) -> SQuestionId:
|
) -> SQuestionId:
|
||||||
question_id = await QuestionRepository.add_one(question, type_mood, type_model) # Передача параметров type_mood и type_model
|
question_id, answer = await QuestionRepository.add_one(question, type_mood, type_model) # Передача параметров type_mood и type_model
|
||||||
return {"ok": True, "question_id": question_id}
|
return {"question_id": question_id, "answer": answer}
|
||||||
|
|
||||||
@router.get("")
|
@router.get("")
|
||||||
async def get_questions() -> list[SQuestion]:
|
async def get_questions() -> list[SQuestion]:
|
||||||
|
@ -17,8 +17,8 @@ class SQuestion(SQuestionAdd):
|
|||||||
model_config = ConfigDict(from_attributes=True)
|
model_config = ConfigDict(from_attributes=True)
|
||||||
|
|
||||||
class SQuestionId(BaseModel):
|
class SQuestionId(BaseModel):
|
||||||
ok: bool = True
|
|
||||||
question_id: int
|
question_id: int
|
||||||
|
answer: str
|
||||||
|
|
||||||
class Flight(BaseModel):
|
class Flight(BaseModel):
|
||||||
id: int
|
id: int
|
||||||
|
Loading…
Reference in New Issue
Block a user