refactor(video): clean handler/service/repo boundaries

This commit is contained in:
Leon
2025-12-09 13:53:36 +08:00
parent 172fd0a35d
commit 5c79e99b70

View File

@@ -34,14 +34,7 @@ func (vh *VideoHandler) PublishVideo(c *gin.Context) {
c.JSON(400, gin.H{"error": err.Error()}) c.JSON(400, gin.H{"error": err.Error()})
return return
} }
if req.Title == "" {
c.JSON(400, gin.H{"error": "title is required"})
return
}
if req.PlayURL == "" {
c.JSON(400, gin.H{"error": "play url is required"})
return
}
uidValue, exists := c.Get("accountID") uidValue, exists := c.Get("accountID")
if !exists { if !exists {
c.JSON(400, gin.H{"error": "accountID not found"}) c.JSON(400, gin.H{"error": "accountID not found"})
@@ -59,7 +52,7 @@ func (vh *VideoHandler) PublishVideo(c *gin.Context) {
PlayURL: req.PlayURL, PlayURL: req.PlayURL,
CreateTime: time.Now(), CreateTime: time.Now(),
} }
if err := vh.service.Publish(c, video); err != nil { if err := vh.service.Publish(c.Request.Context(), video); err != nil {
c.JSON(400, gin.H{"error": err.Error()}) c.JSON(400, gin.H{"error": err.Error()})
return return
} }
@@ -72,7 +65,7 @@ func (vh *VideoHandler) ListByAuthorID(c *gin.Context) {
c.JSON(400, gin.H{"error": err.Error()}) c.JSON(400, gin.H{"error": err.Error()})
return return
} }
videos, err := vh.service.ListByAuthorID(c, req.AuthorID) videos, err := vh.service.ListByAuthorID(c.Request.Context(), req.AuthorID)
if err != nil { if err != nil {
c.JSON(400, gin.H{"error": err.Error()}) c.JSON(400, gin.H{"error": err.Error()})
return return
@@ -86,7 +79,7 @@ func (vh *VideoHandler) GetDetail(c *gin.Context) {
c.JSON(400, gin.H{"error": err.Error()}) c.JSON(400, gin.H{"error": err.Error()})
return return
} }
video, err := vh.service.GetDetail(c, req.ID) video, err := vh.service.GetDetail(c.Request.Context(), req.ID)
if err != nil { if err != nil {
c.JSON(400, gin.H{"error": err.Error()}) c.JSON(400, gin.H{"error": err.Error()})
return return