feat: 实现关注系统 + 通知侧边栏分类 TAB + 点赞聚合通知
- 新增关注系统:UserFollow 模型、FollowService(toggle/status/列表隐私控制) - User 新增 FollowersCount/FollowingCount/FollowListPublic/NotifyPrefs 字段 - Space 页面增加四态关注按钮(关注/已关注/回关/已互粉)+ 粉丝/关注数链接 - 新增 /space/:uid/followers 和 /space/:uid/following 列表页 - 新增 NotifyFollow/NotifyLikeAggregated 通知类型 - ReactionService 点赞时写入 daily_like_summary,访问时生成聚合通知 - FollowService 关注时触发 NotifyFollow 通知 - 消息中心侧边栏升级为分类 TAB(全部/系统通知/@艾特/点赞/关注) - NotificationService 新增 ListByCategory 按分类分页查询
This commit is contained in:
@ -131,4 +131,18 @@ func setupAPIRoutes(r *gin.Engine, cfg *config.Config, d *dependencies) {
|
||||
reactionAPI.POST("/like", d.reactionCtrl.ToggleLike)
|
||||
reactionAPI.POST("/dislike", d.reactionCtrl.ToggleDislike)
|
||||
}
|
||||
|
||||
// --- 关注 API ---
|
||||
// 公开(未登录返回 false)
|
||||
r.GET("/api/users/:uid/follow-status", d.followCtrl.GetStatus)
|
||||
r.GET("/api/users/:uid/followers", d.followCtrl.Followers)
|
||||
r.GET("/api/users/:uid/following", d.followCtrl.Following)
|
||||
// 需登录:切换关注
|
||||
followAPI := r.Group("/api/users/:uid")
|
||||
followAPI.Use(d.authMdw.Required())
|
||||
followAPI.Use(d.authMdw.BannedWriteGuard())
|
||||
followAPI.Use(middleware.CSRF(cfg))
|
||||
{
|
||||
followAPI.POST("/follow", d.followCtrl.Toggle)
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,8 @@ type dependencies struct {
|
||||
commentService *service.CommentService
|
||||
adminCommentCtrl *adminCtrl.AdminCommentController
|
||||
reactionCtrl *controller.ReactionController
|
||||
followCtrl *controller.FollowController
|
||||
followPageCtrl *controller.FollowPageController
|
||||
}
|
||||
|
||||
func buildDepsCore(db *gorm.DB, cfg *config.Config, siteSettings *config.SiteSettings, redisClient *redis.Client) (
|
||||
|
||||
@ -74,6 +74,13 @@ func buildDeps(db *gorm.DB, cfg *config.Config, siteSettings *config.SiteSetting
|
||||
reactionService := service.NewReactionService(db, reactionRepo)
|
||||
reactionCtrl := controller.NewReactionController(reactionService)
|
||||
|
||||
// 关注系统
|
||||
followRepo := repository.NewFollowRepo(db)
|
||||
followService := service.NewFollowService(db, followRepo)
|
||||
followService.SetNotifier(notificationService) // 关注通知
|
||||
followCtrl := controller.NewFollowController(followService)
|
||||
followPageCtrl := controller.NewFollowPageController(followService)
|
||||
|
||||
// 用户空间
|
||||
spaceService := service.NewSpaceService(userRepo, postRepo)
|
||||
spaceCtrl := controller.NewSpaceController(spaceService)
|
||||
@ -96,5 +103,7 @@ func buildDeps(db *gorm.DB, cfg *config.Config, siteSettings *config.SiteSetting
|
||||
commentService: commentService,
|
||||
adminCommentCtrl: adminCommentCtrl,
|
||||
reactionCtrl: reactionCtrl,
|
||||
followCtrl: followCtrl,
|
||||
followPageCtrl: followPageCtrl,
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,6 +45,10 @@ func setupFrontendRoutes(r *gin.Engine, cfg *config.Config, d *dependencies) {
|
||||
pages.GET("/space", d.spaceCtrl.MySpace)
|
||||
pages.GET("/space/:uid", d.spaceCtrl.ShowSpace)
|
||||
|
||||
// 关注/粉丝列表页
|
||||
pages.GET("/space/:uid/followers", d.followPageCtrl.FollowersPage)
|
||||
pages.GET("/space/:uid/following", d.followPageCtrl.FollowingPage)
|
||||
|
||||
// 帖子页面
|
||||
pages.GET("/posts", d.postCtrl.ListPage)
|
||||
pages.GET("/posts/:id", d.postCtrl.ShowPage)
|
||||
|
||||
Reference in New Issue
Block a user