mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-23 17:46:22 +00:00
feat: implement advanced comment features including reply and like functionality
All checks were successful
Push to Helm Chart Repository / build (push) Successful in 13s
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:
@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user