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

@ -2,6 +2,7 @@ package model
import (
"fmt"
"github.com/snowykami/neo-blog/pkg/constant"
"gorm.io/gorm"
)
@ -32,10 +33,10 @@ func (l *Like) AfterDelete(tx *gorm.DB) (err error) {
switch l.TargetType {
case constant.TargetTypePost:
return tx.Model(&Post{}).Where("id = ?", l.TargetID).
UpdateColumn("like_count", gorm.Expr("GREATEST(like_count - ?, 0)", 1)).Error
UpdateColumn("like_count", gorm.Expr("like_count - ?", 1)).Error
case constant.TargetTypeComment:
return tx.Model(&Comment{}).Where("id = ?", l.TargetID).
UpdateColumn("like_count", gorm.Expr("GREATEST(like_count - ?, 0)", 1)).Error
UpdateColumn("like_count", gorm.Expr("like_count - ?", 1)).Error
default:
return fmt.Errorf("不支持的目标类型: %s", l.TargetType)
}