[feat] negodata: 알림함 — 견적 마감 결과(낙찰/재생성/결렬) 자동 통지
- company.notifications 테이블 + NotificationType(SUCCESS/REGENERATED/FAILURE) - 백엔드 알림 조회/읽음 API + close_and_decide 결과 분기마다 알림 생성 - 헤더 알림 벨(안읽음 배지) + 알림 페이지(읽음·딥링크) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
b42cc41b5e
commit
1d111a031e
30 files changed
+995
-3
No files matched your search
@@ -0,0 +1,32 @@
|
||||
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)))
|
||||
@@ -0,0 +1,33 @@
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
from typing import Any, Optional
|
||||
|
||||
from pydantic import ConfigDict
|
||||
|
||||
from common.enums import NotificationType
|
||||
from common.models.gmodel import Res_PageProtocol, Res_WebPacketProtocol, WebPacketProtocol
|
||||
|
||||
|
||||
class NotificationProtocol(WebPacketProtocol):
|
||||
pass
|
||||
|
||||
|
||||
class NotificationData(WebPacketProtocol):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
notification_id: uuid.UUID
|
||||
type: NotificationType
|
||||
ref_qt_id: Optional[uuid.UUID] = None
|
||||
ref_session_id: Optional[uuid.UUID] = None
|
||||
data: Optional[Any] = None # 렌더 스냅샷(유형별 필드)
|
||||
read_at: Optional[datetime] = None
|
||||
created_at: Optional[datetime] = None
|
||||
|
||||
|
||||
class Res_NotificationList(Res_PageProtocol):
|
||||
notifications: list[NotificationData] = []
|
||||
unread: int = 0 # 안읽음 총수(헤더 빨콩이)
|
||||
|
||||
|
||||
class Res_NotificationRead(Res_WebPacketProtocol):
|
||||
pass
|
||||
Reference in new issue
Block a user