refactor:优化了like和unlike功能
This commit is contained in:
@@ -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})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user