diff --git a/handler/car.py b/handler/car.py index 60f1374..55cc03c 100644 --- a/handler/car.py +++ b/handler/car.py @@ -4,6 +4,7 @@ import logger from fastapi import APIRouter, Depends, Query from db.mysql import database +from model.car.dto.list import ListDto from orm.jiakaobaodian import JiaKaoBaoDian from utils.common import response, strtobool from utils.model import model_list @@ -11,12 +12,10 @@ from utils.model import model_list router = APIRouter(tags=["Car"], prefix="/car") -@router.get("/list") -def get_list(db: Session = Depends(database), - page: int = Query(default=1), - size: int = Query(default=10), - keyword: str = Query(default=""), - order_by_wrong_rate: bool = Query(default=True)): +@router.post("/list") +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 logger.logger.info("page => {}, size => {}, keyword => {}", page, size, keyword) query = db.query(JiaKaoBaoDian) diff --git a/model/__init__.py b/model/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/model/car/__init__.py b/model/car/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/model/car/dto/__init__.py b/model/car/dto/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/model/car/dto/list.py b/model/car/dto/list.py new file mode 100644 index 0000000..45da552 --- /dev/null +++ b/model/car/dto/list.py @@ -0,0 +1,8 @@ +from pydantic import BaseModel + + +class ListDto(BaseModel): + page: int = 1 + size: int = 10 + keyword: str = "" + order_by_wrong_rate: bool = True