from uuid import UUID from fastapi import APIRouter, Depends from common.models.gmodel import PageParams, UserInfo from router.v1.validator.dependencies import IsValidAccessToken, RemoveNoneResponse from services.notification import NotificationService from .protocol import Res_NotificationList, Res_NotificationRead # 알림(인박스) 라우터. 항상 로그인 유저(user_info.user_id) 기준으로 조회/처리한다. router = APIRouter(prefix="/v1/notification", tags=["Notification"], responses={404: {"description": "Not found"}}) @router.get(path="/list", response_model=Res_NotificationList, summary="알림 목록(+안읽음 수)") async def list_notifications( service: NotificationService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken), pg: PageParams = Depends(), ): return RemoveNoneResponse(await service.list_notifications(user_info.user_id, pg)) @router.post(path="/read-all", response_model=Res_NotificationRead, summary="전체 읽음 처리") async def read_all(service: NotificationService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken)): return RemoveNoneResponse(await service.mark_all_read(user_info.user_id)) @router.post(path="/{notification_id}/read", response_model=Res_NotificationRead, summary="알림 읽음 처리") async def read_one( notification_id: UUID, service: NotificationService = Depends(), user_info: UserInfo = Depends(IsValidAccessToken) ): return RemoveNoneResponse(await service.mark_read(user_info.user_id, str(notification_id)))