Files
o2o-weather/backend/router/v1/shorts/shorts.py

17 lines
726 B
Python

from fastapi import APIRouter, Depends
from common.enums import ErrorType
from common.models.errors import error_info
from router.v1.shorts.protocol import Res_ShortList, ShortItem
from services.shorts_service import ShortsService
router = APIRouter(prefix="/v1/shorts", tags=["shorts"])
@router.get("", response_model=Res_ShortList, response_model_exclude_none=True, summary="오늘 화면 쇼츠 줄: 날씨각 유튜브 채널의 쇼츠, 최신순")
async def list_shorts(service: ShortsService = Depends()) -> Res_ShortList:
err, items = await service.items()
if err is not ErrorType.SUCCESS:
return Res_ShortList(result=error_info(err))
return Res_ShortList(items=[ShortItem(**i) for i in items])