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:
@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"metazone.cc/metalab/internal/common"
|
||||
"metazone.cc/metalab/internal/model"
|
||||
@ -75,9 +76,29 @@ func (s *ReactionService) ToggleLike(userID, postID uint) (bool, error) {
|
||||
return nil
|
||||
})
|
||||
|
||||
if err == nil && isLiked {
|
||||
// 新赞 → 记录到每日点赞汇总(非关键路径)
|
||||
s.recordLikeForAggregation(postID, userID)
|
||||
}
|
||||
|
||||
return isLiked, err
|
||||
}
|
||||
|
||||
// recordLikeForAggregation 记录点赞到每日汇总(非关键路径,失败不阻塞)
|
||||
func (s *ReactionService) recordLikeForAggregation(postID uint, likerID uint) {
|
||||
authorID, err := s.repo.GetPostAuthorID(postID)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
// 不记录自己赞自己
|
||||
if authorID == likerID {
|
||||
return
|
||||
}
|
||||
date := time.Now().Format("2006-01-02")
|
||||
likerUID := fmt.Sprintf("%d", likerID)
|
||||
_ = s.repo.UpsertDailyLikeSummary(authorID, date, likerUID)
|
||||
}
|
||||
|
||||
// ToggleDislike 切换踩(含赞互斥逻辑)
|
||||
// 返回:当前是否已踩
|
||||
func (s *ReactionService) ToggleDislike(userID, postID uint) (bool, error) {
|
||||
|
||||
Reference in New Issue
Block a user