admin felület fejlesztése garázs, előfizeztési csomagok
This commit is contained in:
@@ -734,4 +734,86 @@ async def bulk_user_action(
|
||||
"total_requested": len(request.user_ids),
|
||||
"missing_ids": missing_ids if missing_ids else None,
|
||||
"message": f"{request.action} művelet végrehajtva {affected_count} felhasználón."
|
||||
}
|
||||
|
||||
|
||||
# ==================== ORGANIZATION SEARCH (EPIC 10: Admin Frontend) ====================
|
||||
|
||||
|
||||
@router.get("/organizations/search", tags=["Organization Management"])
|
||||
async def search_organizations(
|
||||
name: str = Query(..., min_length=2, description="Cégnév vagy garázsnév keresése (ILIKE)"),
|
||||
limit: int = Query(20, ge=1, le=100, description="Maximum találatok száma"),
|
||||
db: AsyncSession = Depends(deps.get_db),
|
||||
current_user: User = Depends(deps.get_current_admin),
|
||||
):
|
||||
"""
|
||||
🔍 Szervezetek / Garázsok keresése név alapján.
|
||||
|
||||
Csak SUPERADMIN, ADMIN és MODERATOR szerepkörű felhasználók számára elérhető.
|
||||
ILIKE keresést használ a full_name, name és display_name mezőkben.
|
||||
|
||||
Args:
|
||||
name: A keresett cégnév vagy garázsnév (minimum 2 karakter).
|
||||
limit: Maximum visszaadott találatok száma (1-100).
|
||||
|
||||
Returns:
|
||||
Lista a megtalált szervezetek alapadataival.
|
||||
"""
|
||||
from app.models.marketplace.organization import Organization
|
||||
|
||||
stmt = (
|
||||
select(
|
||||
Organization.id,
|
||||
Organization.name,
|
||||
Organization.full_name,
|
||||
Organization.display_name,
|
||||
Organization.tax_number,
|
||||
Organization.org_type,
|
||||
Organization.status,
|
||||
Organization.is_verified,
|
||||
Organization.is_active,
|
||||
Organization.is_deleted,
|
||||
Organization.address_city,
|
||||
Organization.region,
|
||||
Organization.segment,
|
||||
Organization.created_at,
|
||||
)
|
||||
.where(
|
||||
or_(
|
||||
Organization.full_name.ilike(f"%{name}%"),
|
||||
Organization.name.ilike(f"%{name}%"),
|
||||
Organization.display_name.ilike(f"%{name}%"),
|
||||
)
|
||||
)
|
||||
.order_by(Organization.full_name.asc())
|
||||
.limit(limit)
|
||||
)
|
||||
|
||||
result = await db.execute(stmt)
|
||||
rows = result.all()
|
||||
|
||||
organizations = []
|
||||
for row in rows:
|
||||
organizations.append({
|
||||
"id": row.id,
|
||||
"name": row.name,
|
||||
"full_name": row.full_name,
|
||||
"display_name": row.display_name,
|
||||
"tax_number": row.tax_number,
|
||||
"org_type": row.org_type.value if hasattr(row.org_type, 'value') else str(row.org_type),
|
||||
"status": row.status,
|
||||
"is_verified": row.is_verified,
|
||||
"is_active": row.is_active,
|
||||
"is_deleted": row.is_deleted,
|
||||
"city": row.address_city,
|
||||
"region": row.region,
|
||||
"segment": row.segment,
|
||||
"created_at": row.created_at.isoformat() if row.created_at else None,
|
||||
})
|
||||
|
||||
return {
|
||||
"total": len(organizations),
|
||||
"query": name,
|
||||
"organizations": organizations,
|
||||
}
|
||||
Reference in New Issue
Block a user