- company.notifications 테이블 + NotificationType(SUCCESS/REGENERATED/FAILURE) - 백엔드 알림 조회/읽음 API + close_and_decide 결과 분기마다 알림 생성 - 헤더 알림 벨(안읽음 배지) + 알림 페이지(읽음·딥링크) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
33 lines
1.5 KiB
Python
33 lines
1.5 KiB
Python
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)))
|