From 2860dfb5ef5997f21c5bd02ea1c428e0124f08de Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Wed, 31 May 2023 14:02:01 +0800 Subject: [PATCH] =?UTF-8?q?/car/list=20=E8=B0=83=E6=95=B4=E4=B8=BA=20post?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/car.py | 2 +- model/car/dto/list.py | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/handler/car.py b/handler/car.py index 55cc03c..e3361fb 100644 --- a/handler/car.py +++ b/handler/car.py @@ -12,7 +12,7 @@ from utils.model import model_list router = APIRouter(tags=["Car"], prefix="/car") -@router.post("/list") +@router.post("/list", summary="题目列表") def get_list(dto: ListDto, db: Session = Depends(database)): (page, size, keyword) = (dto.page, dto.size, dto.keyword) order_by_wrong_rate = dto.order_by_wrong_rate diff --git a/model/car/dto/list.py b/model/car/dto/list.py index 45da552..68548fb 100644 --- a/model/car/dto/list.py +++ b/model/car/dto/list.py @@ -1,8 +1,9 @@ +from fastapi import Body from pydantic import BaseModel class ListDto(BaseModel): - page: int = 1 - size: int = 10 - keyword: str = "" - order_by_wrong_rate: bool = True + page: int = Body(description="页数", default=1) + size: int = Body(description="页面大小", default=10) + keyword: str = Body(description="查询关键字", default="") + order_by_wrong_rate: bool = Body(alias="orderByWrongRate", description="按错误率排序", default=True)