|
@@ -174,7 +174,13 @@ async def admin_delete_photo(photo_id: int, admin: dict = Depends(require_admin)
|
|
|
# --- 3D Scan Portfolio Endpoints ---
|
|
# --- 3D Scan Portfolio Endpoints ---
|
|
|
|
|
|
|
|
@router.get("/scans")
|
|
@router.get("/scans")
|
|
|
-async def get_public_scans():
|
|
|
|
|
|
|
+async def get_public_scans(page: int = 1, size: int = 10):
|
|
|
|
|
+ offset = (page - 1) * size
|
|
|
|
|
+
|
|
|
|
|
+ # Get total count
|
|
|
|
|
+ count_res = db.execute_query("SELECT COUNT(*) as total FROM portfolio_scans WHERE is_public = TRUE")
|
|
|
|
|
+ total = count_res[0]['total'] if count_res else 0
|
|
|
|
|
+
|
|
|
query = """
|
|
query = """
|
|
|
SELECT id, title_en, title_ru, title_me, title_ua,
|
|
SELECT id, title_en, title_ru, title_me, title_ua,
|
|
|
description_en, description_ru, description_me, description_ua,
|
|
description_en, description_ru, description_me, description_ua,
|
|
@@ -182,29 +188,37 @@ async def get_public_scans():
|
|
|
FROM portfolio_scans
|
|
FROM portfolio_scans
|
|
|
WHERE is_public = TRUE
|
|
WHERE is_public = TRUE
|
|
|
ORDER BY created_at DESC
|
|
ORDER BY created_at DESC
|
|
|
|
|
+ LIMIT %s OFFSET %s
|
|
|
"""
|
|
"""
|
|
|
- scans = db.execute_query(query)
|
|
|
|
|
|
|
+ scans = db.execute_query(query, (size, offset))
|
|
|
scans_dir = os.path.join(config.UPLOAD_DIR, "scans")
|
|
scans_dir = os.path.join(config.UPLOAD_DIR, "scans")
|
|
|
for scan in scans:
|
|
for scan in scans:
|
|
|
photo_path = os.path.join(scans_dir, scan["folder_name"], "photo.webp")
|
|
photo_path = os.path.join(scans_dir, scan["folder_name"], "photo.webp")
|
|
|
scan["has_photo"] = os.path.exists(photo_path)
|
|
scan["has_photo"] = os.path.exists(photo_path)
|
|
|
- return scans
|
|
|
|
|
|
|
+ return {"scans": scans, "total": total}
|
|
|
|
|
|
|
|
@router.get("/admin/scans")
|
|
@router.get("/admin/scans")
|
|
|
-async def admin_get_all_scans(admin: dict = Depends(require_admin)):
|
|
|
|
|
|
|
+async def admin_get_all_scans(page: int = 1, size: int = 10, admin: dict = Depends(require_admin)):
|
|
|
|
|
+ offset = (page - 1) * size
|
|
|
|
|
+
|
|
|
|
|
+ # Get total count
|
|
|
|
|
+ count_res = db.execute_query("SELECT COUNT(*) as total FROM portfolio_scans")
|
|
|
|
|
+ total = count_res[0]['total'] if count_res else 0
|
|
|
|
|
+
|
|
|
query = """
|
|
query = """
|
|
|
SELECT id, title_en, title_ru, title_me, title_ua,
|
|
SELECT id, title_en, title_ru, title_me, title_ua,
|
|
|
description_en, description_ru, description_me, description_ua,
|
|
description_en, description_ru, description_me, description_ua,
|
|
|
folder_name, frames_count, is_public, created_at
|
|
folder_name, frames_count, is_public, created_at
|
|
|
FROM portfolio_scans
|
|
FROM portfolio_scans
|
|
|
ORDER BY created_at DESC
|
|
ORDER BY created_at DESC
|
|
|
|
|
+ LIMIT %s OFFSET %s
|
|
|
"""
|
|
"""
|
|
|
- scans = db.execute_query(query)
|
|
|
|
|
|
|
+ scans = db.execute_query(query, (size, offset))
|
|
|
scans_dir = os.path.join(config.UPLOAD_DIR, "scans")
|
|
scans_dir = os.path.join(config.UPLOAD_DIR, "scans")
|
|
|
for scan in scans:
|
|
for scan in scans:
|
|
|
photo_path = os.path.join(scans_dir, scan["folder_name"], "photo.webp")
|
|
photo_path = os.path.join(scans_dir, scan["folder_name"], "photo.webp")
|
|
|
scan["has_photo"] = os.path.exists(photo_path)
|
|
scan["has_photo"] = os.path.exists(photo_path)
|
|
|
- return scans
|
|
|
|
|
|
|
+ return {"scans": scans, "total": total}
|
|
|
|
|
|
|
|
@router.post("/admin/scans/upload-bundle")
|
|
@router.post("/admin/scans/upload-bundle")
|
|
|
async def admin_upload_scan_bundle(
|
|
async def admin_upload_scan_bundle(
|