feat:添加热榜功能并添加了增加热度的方法。

This commit is contained in:
Leon
2025-12-26 22:49:17 +08:00
parent 14a905e194
commit 328fae5f07
12 changed files with 327 additions and 10 deletions

View File

@@ -10,10 +10,11 @@ import (
type CommentHandler struct {
service *CommentService
accountService *account.AccountService
videoService *VideoService
}
func NewCommentHandler(service *CommentService, accountService *account.AccountService) *CommentHandler {
return &CommentHandler{service: service, accountService: accountService}
func NewCommentHandler(service *CommentService, accountService *account.AccountService, videoService *VideoService) *CommentHandler {
return &CommentHandler{service: service, accountService: accountService, videoService: videoService}
}
func (h *CommentHandler) PublishComment(c *gin.Context) {
var req PublishCommentRequest
@@ -49,6 +50,10 @@ func (h *CommentHandler) PublishComment(c *gin.Context) {
c.JSON(400, gin.H{"error": err.Error()})
return
}
if err := h.videoService.UpdatePopularity(c.Request.Context(), req.VideoID, 1); err != nil {
c.JSON(500, gin.H{"error": err.Error()})
return
}
c.JSON(200, gin.H{"message": "comment published successfully"})
}
@@ -71,6 +76,7 @@ func (h *CommentHandler) DeleteComment(c *gin.Context) {
c.JSON(400, gin.H{"error": err.Error()})
return
}
c.JSON(200, gin.H{"message": "comment deleted successfully"})
}