Files
neo-blog/internal/service/like.go
Snowykami dd7641bf6e
All checks were successful
Push to Helm Chart Repository / build (push) Successful in 13s
feat: implement advanced comment features including reply and like functionality
- Added support for nested comments with reply functionality.
- Implemented like/unlike feature for comments and posts.
- Enhanced comment DTO to include reply count, like count, and like status.
- Updated comment and like services to handle new functionalities.
- Created new API endpoints for toggling likes and listing comments.
- Improved UI components for comments to support replies and likes with animations.
- Added localization for new comment-related messages.
- Introduced a TODO list for future enhancements in the comment module.
2025-09-09 00:24:25 +08:00

24 lines
544 B
Go

package service
import (
"context"
"github.com/snowykami/neo-blog/internal/ctxutils"
"github.com/snowykami/neo-blog/internal/repo"
"github.com/snowykami/neo-blog/pkg/errs"
)
type LikeService struct{}
func NewLikeService() *LikeService {
return &LikeService{}
}
func (ls *LikeService) ToggleLike(ctx context.Context, targetID uint, targetType string) (bool, error) {
currentUser, ok := ctxutils.GetCurrentUser(ctx)
if !ok {
return false, errs.ErrUnauthorized
}
return repo.Like.ToggleLike(currentUser.ID, targetID, targetType)
}