素材列表展示
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
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_id,material_id,upload_id,resource_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,
|
||||
}
|
||||
Reference in New Issue
Block a user