[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
@@ -333,11 +333,30 @@ CREATE TABLE IF NOT EXISTS negotiation.results (
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE -- 소프트 삭제 여부
|
||||
);
|
||||
|
||||
-- ============================================================
|
||||
-- company : 알림(인박스) — 협상 이벤트를 견적 작성자(유저)에게 통지
|
||||
-- ============================================================
|
||||
CREATE TABLE IF NOT EXISTS company.notifications (
|
||||
notification_id uuid PRIMARY KEY DEFAULT gen_random_uuid(), -- 알림 식별자(PK)
|
||||
user_id uuid NOT NULL, -- 수신자(company.users.user_id) = 견적 작성자
|
||||
type SMALLINT NOT NULL, -- 알림 유형(NotificationType): 1=success(낙찰), 2=regenerated(재생성), 3=failure(결렬), 4=created(견적생성)
|
||||
ref_qt_id uuid NULL, -- 관련 견적(quotation.quotations.qt_id), 클릭 시 이동
|
||||
ref_session_id uuid NULL, -- 관련 세션(negotiation.sessions.session_id), 공급사 알림만
|
||||
data JSONB NULL, -- 렌더 스냅샷(qt_name/qt_number + 유형별 필드). 발생 시점 값 보관(텍스트 불변).
|
||||
read_at TIMESTAMPTZ NULL, -- 읽은 시각(NULL=안읽음). 행동 필요(검토) 판정 겸용
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(), -- 생성 시각(UTC)
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(), -- 수정 시각(UTC, 앱에서 갱신)
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE -- 소프트 삭제 여부
|
||||
);
|
||||
|
||||
-- ============================================================
|
||||
-- 인덱스 (FK 를 걸지 않으므로 조인 컬럼 인덱스를 명시적으로 생성)
|
||||
-- ============================================================
|
||||
CREATE INDEX IF NOT EXISTS idx_users_company_id ON company.users (company_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_user_tokens_user_id ON company.user_tokens (user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_notifications_user_id ON company.notifications (user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_notifications_user_unread ON company.notifications (user_id, created_at) WHERE deleted = FALSE AND read_at IS NULL;
|
||||
CREATE INDEX IF NOT EXISTS idx_notifications_ref_qt_id ON company.notifications (ref_qt_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_supplier_users_supplier_id ON supplier.supplier_users (supplier_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_sut_su_id ON supplier.supplier_user_tokens (su_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_suppliers_company_id ON partner.suppliers (company_id);
|
||||
|
||||
@@ -32,3 +32,22 @@ ALTER TABLE card.wild_cards
|
||||
-- ───────────────────────────────────────────────────────────
|
||||
ALTER TABLE negotiation.sessions
|
||||
ADD COLUMN IF NOT EXISTS email_sent_at TIMESTAMPTZ;
|
||||
|
||||
-- ───────────────────────────────────────────────────────────
|
||||
-- [2026-06-30] 알림(인박스): 협상 이벤트를 견적 작성자에게 통지
|
||||
-- ───────────────────────────────────────────────────────────
|
||||
CREATE TABLE IF NOT EXISTS company.notifications (
|
||||
notification_id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
user_id uuid NOT NULL, -- 수신자(company.users.user_id) = 견적 작성자
|
||||
type SMALLINT NOT NULL, -- 알림 유형(NotificationType): 1=success(낙찰), 2=regenerated(재생성), 3=failure(결렬)
|
||||
ref_qt_id uuid NULL, -- 관련 견적(quotation.quotations.qt_id)
|
||||
ref_session_id uuid NULL, -- 관련 세션(negotiation.sessions.session_id)
|
||||
data JSONB NULL, -- 렌더 스냅샷(유형별)
|
||||
read_at TIMESTAMPTZ NULL, -- 읽은 시각(NULL=안읽음)
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
deleted BOOLEAN NOT NULL DEFAULT FALSE
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_notifications_user_id ON company.notifications (user_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_notifications_user_unread ON company.notifications (user_id, created_at) WHERE deleted = FALSE AND read_at IS NULL;
|
||||
CREATE INDEX IF NOT EXISTS idx_notifications_ref_qt_id ON company.notifications (ref_qt_id);
|
||||
Reference in new issue
Block a user