Internal error occurred but is skipped: FindTagsByCommitIDs

Files
VLoop/internal/http/router.go

105 lines
3.9 KiB
Go
Raw Normal View History

package http
import (
"feedsystem_video_go/internal/account"
2025-12-07 22:46:45 +08:00
"feedsystem_video_go/internal/feed"
2025-12-05 14:03:57 +08:00
"feedsystem_video_go/internal/middleware"
2025-12-23 02:26:29 +08:00
rediscache "feedsystem_video_go/internal/redis"
2025-12-19 19:03:42 +08:00
"feedsystem_video_go/internal/social"
"feedsystem_video_go/internal/video"
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
2025-12-23 02:26:29 +08:00
func SetRouter(db *gorm.DB, cache *rediscache.Client) *gin.Engine {
r := gin.Default()
// account
2025-12-05 14:25:39 +08:00
accountRepository := account.NewAccountRepository(db)
accountService := account.NewAccountService(accountRepository)
2025-12-08 20:35:56 +08:00
accountHandler := account.NewAccountHandler(accountService)
2025-12-05 14:25:39 +08:00
accountGroup := r.Group("/account")
{
2025-12-05 14:25:39 +08:00
accountGroup.POST("/register", accountHandler.CreateAccount)
accountGroup.POST("/login", accountHandler.Login)
2025-12-05 14:25:39 +08:00
accountGroup.POST("/changePassword", accountHandler.ChangePassword)
accountGroup.POST("/findByID", accountHandler.FindByID)
accountGroup.POST("/findByUsername", accountHandler.FindByUsername)
}
protectedAccountGroup := accountGroup.Group("")
protectedAccountGroup.Use(middleware.JWTAuth(accountRepository))
2025-12-05 14:03:57 +08:00
{
protectedAccountGroup.POST("/logout", accountHandler.Logout)
protectedAccountGroup.POST("/rename", accountHandler.Rename)
2025-12-05 14:03:57 +08:00
}
// video
videoRepository := video.NewVideoRepository(db)
videoService := video.NewVideoService(videoRepository, cache)
2025-12-15 17:34:55 +08:00
videoHandler := video.NewVideoHandler(videoService, accountService)
videoGroup := r.Group("/video")
{
videoGroup.POST("/listByAuthorID", videoHandler.ListByAuthorID)
videoGroup.POST("/getDetail", videoHandler.GetDetail)
}
protectedVideoGroup := videoGroup.Group("")
protectedVideoGroup.Use(middleware.JWTAuth(accountRepository))
{
protectedVideoGroup.POST("/publish", videoHandler.PublishVideo)
}
// like
likeRepository := video.NewLikeRepository(db)
likeService := video.NewLikeService(likeRepository, videoRepository)
likeHandler := video.NewLikeHandler(likeService)
likeGroup := r.Group("/like")
protectedLikeGroup := likeGroup.Group("")
protectedLikeGroup.Use(middleware.JWTAuth(accountRepository))
{
protectedLikeGroup.POST("/like", likeHandler.Like)
protectedLikeGroup.POST("/unlike", likeHandler.Unlike)
protectedLikeGroup.POST("/isLiked", likeHandler.IsLiked)
}
2025-12-16 18:51:50 +08:00
// comment
commentRepository := video.NewCommentRepository(db)
commentService := video.NewCommentService(commentRepository, videoRepository)
commentHandler := video.NewCommentHandler(commentService, accountService)
commentGroup := r.Group("/comment")
{
commentGroup.POST("/listAll", commentHandler.GetAllComments)
}
protectedCommentGroup := commentGroup.Group("")
protectedCommentGroup.Use(middleware.JWTAuth(accountRepository))
{
protectedCommentGroup.POST("/publish", commentHandler.PublishComment)
protectedCommentGroup.POST("/delete", commentHandler.DeleteComment)
}
2025-12-19 19:03:42 +08:00
// social
socialRepository := social.NewSocialRepository(db)
socialService := social.NewSocialService(socialRepository, accountRepository)
socialHandler := social.NewSocialHandler(socialService)
socialGroup := r.Group("/social")
protectedSocialGroup := socialGroup.Group("")
protectedSocialGroup.Use(middleware.JWTAuth(accountRepository))
{
protectedSocialGroup.POST("/follow", socialHandler.Follow)
protectedSocialGroup.POST("/unfollow", socialHandler.Unfollow)
protectedSocialGroup.POST("/getAllFollowers", socialHandler.GetAllFollowers)
protectedSocialGroup.POST("/getAllVloggers", socialHandler.GetAllVloggers)
}
2025-12-07 22:46:45 +08:00
// feed
feedRepository := feed.NewFeedRepository(db)
2025-12-23 02:26:29 +08:00
feedService := feed.NewFeedService(feedRepository, likeRepository, cache)
2025-12-08 20:35:56 +08:00
feedHandler := feed.NewFeedHandler(feedService)
2025-12-07 22:46:45 +08:00
feedGroup := r.Group("/feed")
2025-12-16 18:51:50 +08:00
feedGroup.Use(middleware.SoftJWTAuth(accountRepository))
2025-12-07 22:46:45 +08:00
{
feedGroup.POST("/listLatest", feedHandler.ListLatest)
2025-12-16 14:02:17 +08:00
feedGroup.POST("/listLikesCount", feedHandler.ListLikesCount)
2025-12-07 22:46:45 +08:00
}
2025-12-19 19:20:52 +08:00
protectedFeedGroup := feedGroup.Group("")
protectedFeedGroup.Use(middleware.JWTAuth(accountRepository))
{
protectedFeedGroup.POST("/listByFollowing", feedHandler.ListByFollowing)
}
return r
}