move handler from http to module
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
package http
|
package account
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"feedsystem_video_go/internal/account"
|
"feedsystem_video_go/internal/account"
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package http
|
package feed
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"feedsystem_video_go/internal/feed"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@@ -13,10 +12,10 @@ type ListLatestRequest struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FeedHandler struct {
|
type FeedHandler struct {
|
||||||
service *feed.FeedService
|
service *FeedService
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFeedHandler(service *feed.FeedService) *FeedHandler {
|
func NewFeedHandler(service *FeedService) *FeedHandler {
|
||||||
return &FeedHandler{service: service}
|
return &FeedHandler{service: service}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ func SetRouter(db *gorm.DB) *gin.Engine {
|
|||||||
// account
|
// account
|
||||||
accountRepository := account.NewAccountRepository(db)
|
accountRepository := account.NewAccountRepository(db)
|
||||||
accountService := account.NewAccountService(accountRepository)
|
accountService := account.NewAccountService(accountRepository)
|
||||||
accountHandler := NewAccountHandler(accountService)
|
accountHandler := account.NewAccountHandler(accountService)
|
||||||
accountGroup := r.Group("/account")
|
accountGroup := r.Group("/account")
|
||||||
{
|
{
|
||||||
accountGroup.POST("/register", accountHandler.CreateAccount)
|
accountGroup.POST("/register", accountHandler.CreateAccount)
|
||||||
@@ -33,7 +33,7 @@ func SetRouter(db *gorm.DB) *gin.Engine {
|
|||||||
// video
|
// video
|
||||||
videoRepository := video.NewVideoRepository(db)
|
videoRepository := video.NewVideoRepository(db)
|
||||||
videoService := video.NewVideoService(videoRepository)
|
videoService := video.NewVideoService(videoRepository)
|
||||||
videoHandler := NewVideoHandler(videoService)
|
videoHandler := video.NewVideoHandler(videoService)
|
||||||
videoGroup := r.Group("/video")
|
videoGroup := r.Group("/video")
|
||||||
{
|
{
|
||||||
videoGroup.POST("/listByAuthorID", videoHandler.ListByAuthorID)
|
videoGroup.POST("/listByAuthorID", videoHandler.ListByAuthorID)
|
||||||
@@ -48,7 +48,7 @@ func SetRouter(db *gorm.DB) *gin.Engine {
|
|||||||
// feed
|
// feed
|
||||||
feedRepository := feed.NewFeedRepository(db)
|
feedRepository := feed.NewFeedRepository(db)
|
||||||
feedService := feed.NewFeedService(feedRepository)
|
feedService := feed.NewFeedService(feedRepository)
|
||||||
feedHandler := NewFeedHandler(feedService)
|
feedHandler := feed.NewFeedHandler(feedService)
|
||||||
feedGroup := r.Group("/feed")
|
feedGroup := r.Group("/feed")
|
||||||
{
|
{
|
||||||
feedGroup.POST("/listLatest", feedHandler.ListLatest)
|
feedGroup.POST("/listLatest", feedHandler.ListLatest)
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
package http
|
package video
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"feedsystem_video_go/internal/video"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type VideoHandler struct {
|
type VideoHandler struct {
|
||||||
service *video.VideoService
|
service *VideoService
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewVideoHandler(service *video.VideoService) *VideoHandler {
|
func NewVideoHandler(service *VideoService) *VideoHandler {
|
||||||
return &VideoHandler{service: service}
|
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"})
|
c.JSON(400, gin.H{"error": "accountID has invalid type"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
video := &video.Video{
|
video := &Video{
|
||||||
AuthorID: authorID,
|
AuthorID: authorID,
|
||||||
Title: req.Title,
|
Title: req.Title,
|
||||||
Description: req.Description,
|
Description: req.Description,
|
||||||
Reference in New Issue
Block a user