feat: 点赞相关rabbitMQ

This commit is contained in:
Leon
2025-12-30 01:23:54 +08:00
parent 0d96f8df88
commit 3800373166
5 changed files with 380 additions and 43 deletions

View File

@@ -7,12 +7,11 @@ import (
)
type LikeHandler struct {
service *LikeService
videoService *VideoService
service *LikeService
}
func NewLikeHandler(service *LikeService, videoService *VideoService) *LikeHandler {
return &LikeHandler{service: service, videoService: videoService}
func NewLikeHandler(service *LikeService) *LikeHandler {
return &LikeHandler{service: service}
}
func (lh *LikeHandler) Like(c *gin.Context) {
@@ -40,10 +39,6 @@ func (lh *LikeHandler) Like(c *gin.Context) {
c.JSON(500, gin.H{"error": err.Error()})
return
}
if err := lh.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": "like success"})
}
@@ -72,10 +67,6 @@ func (lh *LikeHandler) Unlike(c *gin.Context) {
c.JSON(500, gin.H{"error": err.Error()})
return
}
if err := lh.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": "unlike success"})
}