feat: implement advanced comment features including reply and like functionality
All checks were successful
Push to Helm Chart Repository / build (push) Successful in 13s

- 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.
This commit is contained in:
2025-09-09 00:24:25 +08:00
parent 382132f550
commit dd7641bf6e
28 changed files with 422 additions and 101 deletions

View File

@ -1,11 +1,12 @@
package repo
import (
"net/http"
"slices"
"github.com/snowykami/neo-blog/internal/model"
"github.com/snowykami/neo-blog/pkg/constant"
"github.com/snowykami/neo-blog/pkg/errs"
"net/http"
"slices"
)
type postRepo struct{}
@ -73,13 +74,13 @@ func (p *postRepo) ListPosts(currentUserID uint, keywords []string, page, size u
return items, nil
}
func (p *postRepo) ToggleLikePost(postID uint, userID uint) error {
func (p *postRepo) ToggleLikePost(postID uint, userID uint) (bool, error) {
if postID == 0 || userID == 0 {
return errs.New(http.StatusBadRequest, "invalid post ID or user ID", nil)
return false, errs.New(http.StatusBadRequest, "invalid post ID or user ID", nil)
}
err := Like.ToggleLike(userID, postID, constant.TargetTypePost)
liked, err := Like.ToggleLike(userID, postID, constant.TargetTypePost)
if err != nil {
return err
return false, err
}
return nil
return liked, nil
}