Refactor backend APIs to RESTful route patterns.

Align group and conversation handlers/services with path-based endpoints, and unify response/service error handling for related modules.

Made-with: Cursor
This commit is contained in:
2026-03-10 20:52:50 +08:00
parent 86ef150fec
commit 21293644b8
10 changed files with 217 additions and 189 deletions

View File

@@ -411,6 +411,31 @@ func (s *PostService) IsFavorited(ctx context.Context, postID, userID string) bo
return s.postRepo.IsFavorited(postID, userID)
}
// GetPostInteractionStatus 批量获取帖子的交互状态(点赞、收藏)
func (s *PostService) GetPostInteractionStatus(ctx context.Context, postIDs []string, userID string) (map[string]bool, map[string]bool, error) {
isLikedMap := make(map[string]bool)
isFavoritedMap := make(map[string]bool)
if userID == "" || len(postIDs) == 0 {
return isLikedMap, isFavoritedMap, nil
}
for _, postID := range postIDs {
isLikedMap[postID] = s.postRepo.IsLiked(postID, userID)
isFavoritedMap[postID] = s.postRepo.IsFavorited(postID, userID)
}
return isLikedMap, isFavoritedMap, nil
}
// GetPostInteractionStatusSingle 获取单个帖子的交互状态
func (s *PostService) GetPostInteractionStatusSingle(ctx context.Context, postID, userID string) (isLiked, isFavorited bool) {
if userID == "" {
return false, false
}
return s.postRepo.IsLiked(postID, userID), s.postRepo.IsFavorited(postID, userID)
}
// IncrementViews 增加帖子观看量并同步到Gorse
func (s *PostService) IncrementViews(ctx context.Context, postID, userID string) error {
if err := s.postRepo.IncrementViews(postID); err != nil {