Files
video-gen/video-gen-api/app/api/v1/resources_material.py
T
2026-06-24 18:47:36 +08:00

45 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from typing import Any, Optional
from fastapi import APIRouter, Depends, Query
from sqlalchemy.ext.asyncio import AsyncSession
from app.dependencies import get_db
from app.schemas.resources_material import ResourcesMaterialListResponse
from app.services.resources_material_service import get_resources_material_list
router = APIRouter(prefix="/resources-material", tags=["resources-material"])
@router.get(
"/list",
summary="查询素材列表",
description="通过advertiser_idmaterial_idupload_idresource_type查询素材列表,同时返回关联的资源信息",
response_model=ResourcesMaterialListResponse,
)
async def get_resources_material_list_api(
advertiser_id: Optional[str] = Query(None, description="广告主id"),
material_id: Optional[str] = Query(None, description="素材id"),
upload_id: Optional[str] = Query(None, description="上传资源平台id"),
file_name: Optional[str] = Query(None, description="文件名"),
resource_type: Optional[str] = Query(None, description="资源类型,image或者video"),
page: int = Query(1, description="页码"),
page_size: int = Query(20, description="每页数量"),
db: AsyncSession = Depends(get_db),
) -> Any | dict:
items, total = await get_resources_material_list(
db=db,
advertiser_id=advertiser_id,
material_id=material_id,
upload_id=upload_id,
file_name=file_name,
resource_type=resource_type,
page=page,
page_size=page_size,
)
return {
"code": 0,
"message": "查询成功",
"data": items,
"total": total,
}