refactor:优化了like和unlike功能

This commit is contained in:
Leon
2025-12-23 02:20:08 +08:00
parent de732abeb1
commit b0a7c85a8d
3 changed files with 38 additions and 84 deletions

View File

@@ -89,21 +89,3 @@ func (lh *LikeHandler) IsLiked(c *gin.Context) {
}
c.JSON(200, gin.H{"is_liked": isLiked})
}
func (lh *LikeHandler) GetLikesCount(c *gin.Context) {
var req LikeRequest
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return
}
if req.VideoID <= 0 {
c.JSON(400, gin.H{"error": "video_id is required"})
return
}
likesCount, err := lh.service.GetLikesCount(c.Request.Context(), req.VideoID)
if err != nil {
c.JSON(500, gin.H{"error": err.Error()})
return
}
c.JSON(200, gin.H{"likes_count": likesCount})
}