From 44d5c2ac816f258a5be2fae83b8ca2294978e212 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Wed, 31 May 2023 13:50:18 +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 | 11 +++++------ model/__init__.py | 0 model/car/__init__.py | 0 model/car/dto/__init__.py | 0 model/car/dto/list.py | 8 ++++++++ 5 files changed, 13 insertions(+), 6 deletions(-) create mode 100644 model/__init__.py create mode 100644 model/car/__init__.py create mode 100644 model/car/dto/__init__.py create mode 100644 model/car/dto/list.py 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