Fix 422 error on /admin/banner-cars endpoint
Move /admin/banner-cars route before /admin/{banner_id} to fix route
matching order. FastAPI was matching "banner-cars" as a path parameter
and failing to convert it to an integer.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -124,6 +124,25 @@ def admin_get_banners(
|
||||
return banners
|
||||
|
||||
|
||||
@router.get("/admin/banner-cars")
|
||||
def get_banner_cars(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_admin_user)
|
||||
):
|
||||
"""배너 등록된 차량 목록 조회 (Admin)
|
||||
|
||||
display_order 순으로 정렬된 차량 ID 목록 반환
|
||||
"""
|
||||
banners = db.query(HeroBanner).filter(
|
||||
HeroBanner.car_id.isnot(None)
|
||||
).order_by(HeroBanner.display_order.asc()).all()
|
||||
|
||||
return {
|
||||
"car_ids": [b.car_id for b in banners],
|
||||
"count": len(banners)
|
||||
}
|
||||
|
||||
|
||||
@router.get("/admin/{banner_id}", response_model=HeroBannerResponse)
|
||||
def admin_get_banner(
|
||||
banner_id: int,
|
||||
@@ -341,22 +360,3 @@ def reorder_banners(
|
||||
|
||||
db.commit()
|
||||
return {"message": "Banner order updated", "count": len(request.car_ids)}
|
||||
|
||||
|
||||
@router.get("/admin/banner-cars")
|
||||
def get_banner_cars(
|
||||
db: Session = Depends(get_db),
|
||||
current_user: User = Depends(get_admin_user)
|
||||
):
|
||||
"""배너 등록된 차량 목록 조회 (Admin)
|
||||
|
||||
display_order 순으로 정렬된 차량 ID 목록 반환
|
||||
"""
|
||||
banners = db.query(HeroBanner).filter(
|
||||
HeroBanner.car_id.isnot(None)
|
||||
).order_by(HeroBanner.display_order.asc()).all()
|
||||
|
||||
return {
|
||||
"car_ids": [b.car_id for b in banners],
|
||||
"count": len(banners)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user