11from fastapi import APIRouter , BackgroundTasks , Depends , Query
2- from sqlalchemy .ext .asyncio import AsyncSession
32
43from app .api .v1 .deps import require_login
5- from app .db . session import get_db
6- from app .schemas . application import (
4+ from app .application . dependencies import get_application_service
5+ from app .application . schemas import (
76 ApplicationCreateReq ,
87 ApplicationListResp ,
98 ReviewSubmissionReq ,
109)
11- from app .services import application as application_service
10+ from app .application . service import ApplicationService
1211
1312router = APIRouter (tags = ["Application" ])
1413
1716async def create_application (
1817 body : ApplicationCreateReq ,
1918 background_tasks : BackgroundTasks ,
20- db : AsyncSession = Depends (get_db ),
2119 reviewer_id : str = Depends (require_login ),
20+ service : ApplicationService = Depends (get_application_service ),
2221) -> None :
23- await application_service .create_application (
24- db , reviewer_id , body , background_tasks
25- )
22+ await service .create_application (reviewer_id , body , background_tasks )
2623
2724
2825@router .get ("/application" , response_model = ApplicationListResp )
2926async def get_my_applications (
3027 page : int = Query (default = 0 , ge = 0 ),
3128 size : int = Query (default = 20 , ge = 1 ),
32- db : AsyncSession = Depends (get_db ),
3329 reviewer_id : str = Depends (require_login ),
30+ service : ApplicationService = Depends (get_application_service ),
3431) -> ApplicationListResp :
35- applications , total = await application_service .list_my_applications (
36- db , reviewer_id , page , size
37- )
32+ applications , total = await service .list_my_applications (reviewer_id , page , size )
3833 total_pages = max (1 , (total + size - 1 ) // size )
3934 return ApplicationListResp (
4035 applications = applications ,
@@ -48,17 +43,17 @@ async def get_my_applications(
4843@router .delete ("/application/{applicationId}" , response_model = None )
4944async def cancel_application (
5045 applicationId : str ,
51- db : AsyncSession = Depends (get_db ),
5246 user_id : str = Depends (require_login ),
47+ service : ApplicationService = Depends (get_application_service ),
5348) -> None :
54- await application_service .cancel_application (db , applicationId , user_id )
49+ await service .cancel_application (applicationId , user_id )
5550
5651
5752@router .post ("/application/{applicationId}/submission" , response_model = None )
5853async def submit_review (
5954 applicationId : str ,
6055 body : ReviewSubmissionReq ,
61- db : AsyncSession = Depends (get_db ),
6256 user_id : str = Depends (require_login ),
57+ service : ApplicationService = Depends (get_application_service ),
6358) -> None :
64- await application_service .submit_review (db , applicationId , user_id , body )
59+ await service .submit_review (applicationId , user_id , body )
0 commit comments