diff --git a/internal/http/account_handler.go b/internal/account/handler.go similarity index 99% rename from internal/http/account_handler.go rename to internal/account/handler.go index ca2be4a..7f4f1aa 100644 --- a/internal/http/account_handler.go +++ b/internal/account/handler.go @@ -1,4 +1,4 @@ -package http +package account import ( "feedsystem_video_go/internal/account" diff --git a/internal/http/feed_handler.go b/internal/feed/handler.go similarity index 84% rename from internal/http/feed_handler.go rename to internal/feed/handler.go index ef6a56d..97ab99b 100644 --- a/internal/http/feed_handler.go +++ b/internal/feed/handler.go @@ -1,7 +1,6 @@ -package http +package feed import ( - "feedsystem_video_go/internal/feed" "time" "github.com/gin-gonic/gin" @@ -13,10 +12,10 @@ type ListLatestRequest struct { } type FeedHandler struct { - service *feed.FeedService + service *FeedService } -func NewFeedHandler(service *feed.FeedService) *FeedHandler { +func NewFeedHandler(service *FeedService) *FeedHandler { return &FeedHandler{service: service} } diff --git a/internal/http/router.go b/internal/http/router.go index 3dc9aab..5c7e379 100644 --- a/internal/http/router.go +++ b/internal/http/router.go @@ -15,7 +15,7 @@ func SetRouter(db *gorm.DB) *gin.Engine { // account accountRepository := account.NewAccountRepository(db) accountService := account.NewAccountService(accountRepository) - accountHandler := NewAccountHandler(accountService) + accountHandler := account.NewAccountHandler(accountService) accountGroup := r.Group("/account") { accountGroup.POST("/register", accountHandler.CreateAccount) @@ -33,7 +33,7 @@ func SetRouter(db *gorm.DB) *gin.Engine { // video videoRepository := video.NewVideoRepository(db) videoService := video.NewVideoService(videoRepository) - videoHandler := NewVideoHandler(videoService) + videoHandler := video.NewVideoHandler(videoService) videoGroup := r.Group("/video") { videoGroup.POST("/listByAuthorID", videoHandler.ListByAuthorID) @@ -48,7 +48,7 @@ func SetRouter(db *gorm.DB) *gin.Engine { // feed feedRepository := feed.NewFeedRepository(db) feedService := feed.NewFeedService(feedRepository) - feedHandler := NewFeedHandler(feedService) + feedHandler := feed.NewFeedHandler(feedService) feedGroup := r.Group("/feed") { feedGroup.POST("/listLatest", feedHandler.ListLatest) diff --git a/internal/http/video_handler.go b/internal/video/handler.go similarity index 91% rename from internal/http/video_handler.go rename to internal/video/handler.go index 20d95a7..f92a5bc 100644 --- a/internal/http/video_handler.go +++ b/internal/video/handler.go @@ -1,17 +1,16 @@ -package http +package video import ( - "feedsystem_video_go/internal/video" "time" "github.com/gin-gonic/gin" ) type VideoHandler struct { - service *video.VideoService + service *VideoService } -func NewVideoHandler(service *video.VideoService) *VideoHandler { +func NewVideoHandler(service *VideoService) *VideoHandler { return &VideoHandler{service: service} } @@ -53,7 +52,7 @@ func (vh *VideoHandler) PublishVideo(c *gin.Context) { c.JSON(400, gin.H{"error": "accountID has invalid type"}) return } - video := &video.Video{ + video := &Video{ AuthorID: authorID, Title: req.Title, Description: req.Description,