feat: 添加通知微服务,支持站内通知已读状态

This commit is contained in:
zetaloop
2026-04-24 12:44:59 +08:00
parent 95f2f10f9f
commit b557bfcc2e
52 changed files with 7035 additions and 30 deletions
+24
View File
@@ -0,0 +1,24 @@
CREATE TABLE notifications
(
id BIGINT PRIMARY KEY,
user_id BIGINT NOT NULL,
type VARCHAR(20) NOT NULL,
title VARCHAR(200) NOT NULL,
content TEXT NOT NULL,
read BOOLEAN NOT NULL DEFAULT FALSE,
link VARCHAR(500),
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT chk_notification_type CHECK (type IN ('order', 'community', 'system'))
);
CREATE INDEX idx_notifications_user_created ON notifications (user_id, created_at DESC);
CREATE INDEX idx_notifications_user_read_created ON notifications (user_id, read, created_at DESC);
CREATE INDEX idx_notifications_user_type_created ON notifications (user_id, type, created_at DESC);
CREATE TRIGGER trigger_notifications_updated_at
BEFORE UPDATE
ON notifications
FOR EACH ROW
EXECUTE FUNCTION update_updated_at_column();