/car/list 调整为 post

This commit is contained in:
shikong 2023-05-31 13:50:18 +08:00
parent 9544b7773a
commit 44d5c2ac81
5 changed files with 13 additions and 6 deletions

View File

@ -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)

0
model/__init__.py Normal file
View File

0
model/car/__init__.py Normal file
View File

View File

8
model/car/dto/list.py Normal file
View File

@ -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