11from typing import Annotated
22
3- from fastapi import APIRouter , Depends , HTTPException , Path , status
3+ from fastapi import APIRouter , Path , status
44from fastapi_pagination import Page
5- from sqlalchemy .ext .asyncio .session import AsyncSession
65
76from futuramaapi .repositories import INT32
8- from futuramaapi .repositories .session import get_async_session
9- from futuramaapi .routers .exceptions import ModelNotFoundError , NotFoundResponse
10-
11- from .schemas import Season
7+ from futuramaapi .routers .exceptions import NotFoundResponse
8+ from futuramaapi .routers .services .seasons .get_season import (
9+ GetSeasonResponse ,
10+ GetSeasonService ,
11+ )
12+ from futuramaapi .routers .services .seasons .list_seasons import (
13+ ListSeasonResponse ,
14+ ListSeasonsService ,
15+ )
1216
1317router = APIRouter (
1418 prefix = "/seasons" ,
2428 "model" : NotFoundResponse ,
2529 },
2630 },
27- response_model = Season ,
31+ response_model = GetSeasonResponse ,
2832 name = "season" ,
2933)
3034async def get_season (
@@ -34,30 +38,25 @@ async def get_season(
3438 le = INT32 ,
3539 ),
3640 ],
37- session : AsyncSession = Depends (get_async_session ), # noqa: B008
38- ) -> Season :
41+ ) -> GetSeasonResponse :
3942 """Retrieve specific season.
4043
4144 Utilize this endpoint to retrieve detailed information about a specific Futurama season by providing its unique ID.
4245 The response includes details such as the list of seasons, season ID, and more.
4346
4447 Can be used to gain in-depth insights into a particular season of Futurama.
4548 """
46- try :
47- return await Season .get (session , season_id )
48- except ModelNotFoundError :
49- raise HTTPException (status_code = status .HTTP_404_NOT_FOUND ) from None
49+ service : GetSeasonService = GetSeasonService (pk = season_id )
50+ return await service ()
5051
5152
5253@router .get (
5354 "" ,
5455 status_code = status .HTTP_200_OK ,
55- response_model = Page [Season ],
56+ response_model = Page [ListSeasonResponse ],
5657 name = "seasons" ,
5758)
58- async def get_seasons (
59- session : AsyncSession = Depends (get_async_session ), # noqa: B008
60- ) -> Page [Season ]:
59+ async def get_seasons () -> Page [ListSeasonResponse ]:
6160 """Retrieve specific seasons.
6261
6362 Access a comprehensive list of all Futurama seasons using this endpoint,
@@ -67,4 +66,5 @@ async def get_seasons(
6766 This endpoint is valuable for those interested in exploring the entirety of Futurama's seasons or implementing
6867 features like season browsing on your site.
6968 """
70- return await Season .paginate (session )
69+ service : ListSeasonsService = ListSeasonsService ()
70+ return await service ()
0 commit comments