From d902f920b3bfad6845c22d69710e7376e90dd863 Mon Sep 17 00:00:00 2001 From: AutonetSellCar Deploy Date: Wed, 31 Dec 2025 16:45:47 +0900 Subject: [PATCH] Fix 422 error on /admin/banner-cars endpoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- backend/app/api/hero_banners.py | 38 ++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/backend/app/api/hero_banners.py b/backend/app/api/hero_banners.py index d2d4e91..a28fc52 100644 --- a/backend/app/api/hero_banners.py +++ b/backend/app/api/hero_banners.py @@ -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) - }