Initial commit - Migrated to Dev environment
This commit is contained in:
23
backend/app/api/v1/endpoints/vehicle_search.py
Executable file
23
backend/app/api/v1/endpoints/vehicle_search.py
Executable file
@@ -0,0 +1,23 @@
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from sqlalchemy.orm import Session
|
||||
from app.db.session import get_db
|
||||
from app.models.vehicle import VehicleBrand # Feltételezve, hogy létezik a modell
|
||||
from typing import List
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.get("/search/brands")
|
||||
def search_brands(q: str = Query(..., min_length=2), db: Session = Depends(get_db)):
|
||||
# 1. KERESÉS A SAJÁT ADATBÁZISBAN
|
||||
results = db.query(VehicleBrand).filter(
|
||||
VehicleBrand.name.ilike(f"%{q}%"),
|
||||
VehicleBrand.is_active == True
|
||||
).limit(10).all()
|
||||
|
||||
# 2. HA NINCS TALÁLAT, INDÍTHATJUK A BOT-OT (Logikai váz)
|
||||
if not results:
|
||||
# Itt hívnánk meg a Discovery Bot-ot async módon
|
||||
# discovery_bot.find_brand_remotely(q)
|
||||
return {"status": "not_found", "message": "Nincs találat, a Bot elindult keresni...", "data": []}
|
||||
|
||||
return {"status": "success", "data": results}
|
||||
Reference in New Issue
Block a user