refactor(notification): 通知实体抽成独立包

`video` 与 `worker` 各有一份 `notifications` 表的实体。
两份定义会漂移,所以合并到 `internal/notification`。
新增 `entity.go` 保存唯一一份列标签。

`worker`、`ssehub`、`comment_repo`、`db` 与两个集成测试改为引用新包。
`db` 包不再 import `worker`。
去重键仍是 `*string`,因此 NULL 才能共存。

验证:go test -count=1 ./... 全绿;集成测试三包全绿。
This commit is contained in:
2026-10-30 23:48:43 +08:00
parent 07f3166ab7
commit 151faf25fa
9 changed files with 87 additions and 83 deletions

View File

@@ -9,6 +9,8 @@ import (
"sync"
"testing"
"feedsystem_video_go/internal/notification"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"
@@ -49,10 +51,10 @@ func newTestDB(t *testing.T) *gorm.DB {
if err != nil {
t.Fatalf("connect mysql: %v", err)
}
if err := db.Migrator().DropTable(&Comment{}, &Video{}, &NotificationRow{}, &testAccount{}); err != nil {
if err := db.Migrator().DropTable(&Comment{}, &Video{}, &notification.Notification{}, &testAccount{}); err != nil {
t.Fatalf("drop tables: %v", err)
}
if err := db.AutoMigrate(&testAccount{}, &Video{}, &Comment{}, &NotificationRow{}); err != nil {
if err := db.AutoMigrate(&testAccount{}, &Video{}, &Comment{}, &notification.Notification{}); err != nil {
t.Fatalf("migrate: %v", err)
}
return db
@@ -208,7 +210,7 @@ func TestP0_4_MentionNotificationDedupe(t *testing.T) {
}
}
var rows []NotificationRow
var rows []notification.Notification
if err := db.Find(&rows).Error; err != nil {
t.Fatalf("查询 notifications: %v", err)
}