From 3b80a7c5da22031f0703884e04d0a17f1cc73c7c Mon Sep 17 00:00:00 2001 From: Leon <147289645+LeoninCS@users.noreply.github.com> Date: Sun, 7 Dec 2025 21:22:54 +0800 Subject: [PATCH] fix: delete ListLatest(func) --- internal/http/router.go | 1 - internal/http/video_handler.go | 9 --------- internal/video/repo.go | 13 ------------- internal/video/service.go | 8 -------- 4 files changed, 31 deletions(-) diff --git a/internal/http/router.go b/internal/http/router.go index eea1fe5..7b58e9e 100644 --- a/internal/http/router.go +++ b/internal/http/router.go @@ -36,7 +36,6 @@ func SetRouter(db *gorm.DB) *gin.Engine { videoGroup := r.Group("/video") { videoGroup.POST("/listByAuthorID", videoHandler.ListByAuthorID) - videoGroup.POST("/listLatest", videoHandler.ListLatest) videoGroup.POST("/getDetail", videoHandler.GetDetail) } protectedVideoGroup := videoGroup.Group("") diff --git a/internal/http/video_handler.go b/internal/http/video_handler.go index f12ae99..20d95a7 100644 --- a/internal/http/video_handler.go +++ b/internal/http/video_handler.go @@ -81,15 +81,6 @@ func (vh *VideoHandler) ListByAuthorID(c *gin.Context) { c.JSON(200, videos) } -func (vh *VideoHandler) ListLatest(c *gin.Context) { - videos, err := vh.service.ListLatest(c) - if err != nil { - c.JSON(400, gin.H{"error": err.Error()}) - return - } - c.JSON(200, videos) -} - func (vh *VideoHandler) GetDetail(c *gin.Context) { var req GetDetailRequest if err := c.ShouldBindJSON(&req); err != nil { diff --git a/internal/video/repo.go b/internal/video/repo.go index c470e28..2b18561 100644 --- a/internal/video/repo.go +++ b/internal/video/repo.go @@ -26,19 +26,6 @@ func (vr *VideoRepository) ListByAuthorID(ctx context.Context, authorID int64) ( if err := vr.db.WithContext(ctx). Where("author_id = ?", authorID). Order("create_time desc"). - Limit(5). - Offset(0). - Find(&videos).Error; err != nil { - return nil, err - } - return videos, nil -} - -func (vr *VideoRepository) ListLatest(ctx context.Context) ([]Video, error) { - var videos []Video - if err := vr.db.WithContext(ctx). - Order("create_time desc"). - Limit(5). Offset(0). Find(&videos).Error; err != nil { return nil, err diff --git a/internal/video/service.go b/internal/video/service.go index 85e7f78..8d6c116 100644 --- a/internal/video/service.go +++ b/internal/video/service.go @@ -34,14 +34,6 @@ func (vs *VideoService) ListByAuthorID(ctx context.Context, authorID uint) ([]Vi return videos, nil } -func (vs *VideoService) ListLatest(ctx context.Context) ([]Video, error) { - videos, err := vs.repo.ListLatest(ctx) - if err != nil { - return nil, err - } - return videos, nil -} - func (vs *VideoService) GetDetail(ctx context.Context, id uint) (*Video, error) { video, err := vs.repo.GetByID(ctx, id) if err != nil {