395 lines
14 KiB
Go
395 lines
14 KiB
Go
// Code generated by atomctl. DO NOT EDIT.
|
|
|
|
// Package v1 provides HTTP route definitions and registration
|
|
// for the quyun/v2 application.
|
|
package v1
|
|
|
|
import (
|
|
"mime/multipart"
|
|
"quyun/v2/app/http/v1/dto"
|
|
"quyun/v2/app/middlewares"
|
|
|
|
"github.com/gofiber/fiber/v3"
|
|
log "github.com/sirupsen/logrus"
|
|
_ "go.ipao.vip/atom"
|
|
_ "go.ipao.vip/atom/contracts"
|
|
. "go.ipao.vip/atom/fen"
|
|
)
|
|
|
|
// Routes implements the HttpRoute contract and provides route registration
|
|
// for all controllers in the v1 module.
|
|
//
|
|
// @provider contracts.HttpRoute atom.GroupRoutes
|
|
type Routes struct {
|
|
log *log.Entry `inject:"false"`
|
|
middlewares *middlewares.Middlewares
|
|
// Controller instances
|
|
auth *Auth
|
|
common *Common
|
|
content *Content
|
|
creator *Creator
|
|
super *Super
|
|
tenant *Tenant
|
|
transaction *Transaction
|
|
user *User
|
|
}
|
|
|
|
// Prepare initializes the routes provider with logging configuration.
|
|
func (r *Routes) Prepare() error {
|
|
r.log = log.WithField("module", "routes.v1")
|
|
r.log.Info("Initializing routes module")
|
|
return nil
|
|
}
|
|
|
|
// Name returns the unique identifier for this routes provider.
|
|
func (r *Routes) Name() string {
|
|
return "v1"
|
|
}
|
|
|
|
// Register registers all HTTP routes with the provided fiber router.
|
|
// Each route is registered with its corresponding controller action and parameter bindings.
|
|
func (r *Routes) Register(router fiber.Router) {
|
|
// Register routes for controller: Auth
|
|
r.log.Debugf("Registering route: Post /v1/auth/login -> auth.Login")
|
|
router.Post("/v1/auth/login"[len(r.Path()):], DataFunc1(
|
|
r.auth.Login,
|
|
Body[dto.LoginForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/auth/otp -> auth.SendOTP")
|
|
router.Post("/v1/auth/otp"[len(r.Path()):], Func1(
|
|
r.auth.SendOTP,
|
|
Body[dto.SendOTPForm]("form"),
|
|
))
|
|
// Register routes for controller: Common
|
|
r.log.Debugf("Registering route: Post /v1/upload -> common.Upload")
|
|
router.Post("/v1/upload"[len(r.Path()):], DataFunc2(
|
|
r.common.Upload,
|
|
File[multipart.FileHeader]("file"),
|
|
Body[string]("type"),
|
|
))
|
|
// Register routes for controller: Content
|
|
r.log.Debugf("Registering route: Get /v1/contents -> content.List")
|
|
router.Get("/v1/contents"[len(r.Path()):], DataFunc5(
|
|
r.content.List,
|
|
QueryParam[string]("keyword"),
|
|
QueryParam[string]("genre"),
|
|
QueryParam[string]("tenantId"),
|
|
QueryParam[string]("sort"),
|
|
QueryParam[int]("page"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/contents/:id -> content.Get")
|
|
router.Get("/v1/contents/:id"[len(r.Path()):], DataFunc1(
|
|
r.content.Get,
|
|
PathParam[string]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/contents/:id/comments -> content.ListComments")
|
|
router.Get("/v1/contents/:id/comments"[len(r.Path()):], DataFunc2(
|
|
r.content.ListComments,
|
|
PathParam[string]("id"),
|
|
QueryParam[int]("page"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/topics -> content.ListTopics")
|
|
router.Get("/v1/topics"[len(r.Path()):], DataFunc0(
|
|
r.content.ListTopics,
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/comments/:id/like -> content.LikeComment")
|
|
router.Post("/v1/comments/:id/like"[len(r.Path()):], Func1(
|
|
r.content.LikeComment,
|
|
PathParam[string]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/contents/:id/comments -> content.CreateComment")
|
|
router.Post("/v1/contents/:id/comments"[len(r.Path()):], Func2(
|
|
r.content.CreateComment,
|
|
PathParam[string]("id"),
|
|
Body[dto.CommentCreateForm]("form"),
|
|
))
|
|
// Register routes for controller: Creator
|
|
r.log.Debugf("Registering route: Delete /v1/creator/contents/:id -> creator.DeleteContent")
|
|
router.Delete("/v1/creator/contents/:id"[len(r.Path()):], Func1(
|
|
r.creator.DeleteContent,
|
|
PathParam[string]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Delete /v1/creator/payout-accounts -> creator.RemovePayoutAccount")
|
|
router.Delete("/v1/creator/payout-accounts"[len(r.Path()):], Func1(
|
|
r.creator.RemovePayoutAccount,
|
|
QueryParam[string]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/creator/contents -> creator.ListContents")
|
|
router.Get("/v1/creator/contents"[len(r.Path()):], DataFunc3(
|
|
r.creator.ListContents,
|
|
QueryParam[string]("status"),
|
|
QueryParam[string]("genre"),
|
|
QueryParam[string]("keyword"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/creator/dashboard -> creator.Dashboard")
|
|
router.Get("/v1/creator/dashboard"[len(r.Path()):], DataFunc0(
|
|
r.creator.Dashboard,
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/creator/orders -> creator.ListOrders")
|
|
router.Get("/v1/creator/orders"[len(r.Path()):], DataFunc2(
|
|
r.creator.ListOrders,
|
|
QueryParam[string]("status"),
|
|
QueryParam[string]("keyword"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/creator/payout-accounts -> creator.ListPayoutAccounts")
|
|
router.Get("/v1/creator/payout-accounts"[len(r.Path()):], DataFunc0(
|
|
r.creator.ListPayoutAccounts,
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/creator/settings -> creator.GetSettings")
|
|
router.Get("/v1/creator/settings"[len(r.Path()):], DataFunc0(
|
|
r.creator.GetSettings,
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/creator/apply -> creator.Apply")
|
|
router.Post("/v1/creator/apply"[len(r.Path()):], Func1(
|
|
r.creator.Apply,
|
|
Body[dto.ApplyForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/creator/contents -> creator.CreateContent")
|
|
router.Post("/v1/creator/contents"[len(r.Path()):], Func1(
|
|
r.creator.CreateContent,
|
|
Body[dto.ContentCreateForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/creator/orders/:id/refund -> creator.Refund")
|
|
router.Post("/v1/creator/orders/:id/refund"[len(r.Path()):], Func2(
|
|
r.creator.Refund,
|
|
PathParam[string]("id"),
|
|
Body[dto.RefundForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/creator/payout-accounts -> creator.AddPayoutAccount")
|
|
router.Post("/v1/creator/payout-accounts"[len(r.Path()):], Func1(
|
|
r.creator.AddPayoutAccount,
|
|
Body[dto.PayoutAccount]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/creator/withdraw -> creator.Withdraw")
|
|
router.Post("/v1/creator/withdraw"[len(r.Path()):], Func1(
|
|
r.creator.Withdraw,
|
|
Body[dto.WithdrawForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Put /v1/creator/contents/:id -> creator.UpdateContent")
|
|
router.Put("/v1/creator/contents/:id"[len(r.Path()):], Func2(
|
|
r.creator.UpdateContent,
|
|
PathParam[string]("id"),
|
|
Body[dto.ContentUpdateForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Put /v1/creator/settings -> creator.UpdateSettings")
|
|
router.Put("/v1/creator/settings"[len(r.Path()):], Func1(
|
|
r.creator.UpdateSettings,
|
|
Body[dto.Settings]("form"),
|
|
))
|
|
// Register routes for controller: Super
|
|
r.log.Debugf("Registering route: Get /v1/auth/token -> super.CheckToken")
|
|
router.Get("/v1/auth/token"[len(r.Path()):], DataFunc0(
|
|
r.super.CheckToken,
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/contents -> super.ListContents")
|
|
router.Get("/v1/contents"[len(r.Path()):], DataFunc2(
|
|
r.super.ListContents,
|
|
QueryParam[int]("page"),
|
|
QueryParam[int]("limit"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/orders -> super.ListOrders")
|
|
router.Get("/v1/orders"[len(r.Path()):], DataFunc2(
|
|
r.super.ListOrders,
|
|
QueryParam[int]("page"),
|
|
QueryParam[int]("limit"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/orders/:id -> super.GetOrder")
|
|
router.Get("/v1/orders/:id"[len(r.Path()):], DataFunc1(
|
|
r.super.GetOrder,
|
|
PathParam[int64]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/orders/statistics -> super.OrderStatistics")
|
|
router.Get("/v1/orders/statistics"[len(r.Path()):], DataFunc0(
|
|
r.super.OrderStatistics,
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/tenants -> super.ListTenants")
|
|
router.Get("/v1/tenants"[len(r.Path()):], DataFunc3(
|
|
r.super.ListTenants,
|
|
QueryParam[int]("page"),
|
|
QueryParam[int]("limit"),
|
|
QueryParam[string]("name"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/tenants/:id -> super.GetTenant")
|
|
router.Get("/v1/tenants/:id"[len(r.Path()):], DataFunc1(
|
|
r.super.GetTenant,
|
|
PathParam[int64]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/tenants/statuses -> super.TenantStatuses")
|
|
router.Get("/v1/tenants/statuses"[len(r.Path()):], DataFunc0(
|
|
r.super.TenantStatuses,
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/users -> super.ListUsers")
|
|
router.Get("/v1/users"[len(r.Path()):], DataFunc3(
|
|
r.super.ListUsers,
|
|
QueryParam[int]("page"),
|
|
QueryParam[int]("limit"),
|
|
QueryParam[string]("username"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/users/:id -> super.GetUser")
|
|
router.Get("/v1/users/:id"[len(r.Path()):], DataFunc1(
|
|
r.super.GetUser,
|
|
PathParam[int64]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/users/statistics -> super.UserStatistics")
|
|
router.Get("/v1/users/statistics"[len(r.Path()):], DataFunc0(
|
|
r.super.UserStatistics,
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/users/statuses -> super.UserStatuses")
|
|
router.Get("/v1/users/statuses"[len(r.Path()):], DataFunc0(
|
|
r.super.UserStatuses,
|
|
))
|
|
r.log.Debugf("Registering route: Patch /v1/tenants/:id -> super.UpdateTenantExpire")
|
|
router.Patch("/v1/tenants/:id"[len(r.Path()):], Func2(
|
|
r.super.UpdateTenantExpire,
|
|
PathParam[int64]("id"),
|
|
Body[dto.TenantExpireUpdateForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Patch /v1/tenants/:id/status -> super.UpdateTenantStatus")
|
|
router.Patch("/v1/tenants/:id/status"[len(r.Path()):], Func2(
|
|
r.super.UpdateTenantStatus,
|
|
PathParam[int64]("id"),
|
|
Body[dto.TenantStatusUpdateForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Patch /v1/tenants/:tenantID/contents/:contentID/status -> super.UpdateContentStatus")
|
|
router.Patch("/v1/tenants/:tenantID/contents/:contentID/status"[len(r.Path()):], Func3(
|
|
r.super.UpdateContentStatus,
|
|
PathParam[int64]("tenantID"),
|
|
PathParam[int64]("contentID"),
|
|
Body[dto.SuperTenantContentStatusUpdateForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Patch /v1/users/:id/roles -> super.UpdateUserRoles")
|
|
router.Patch("/v1/users/:id/roles"[len(r.Path()):], Func2(
|
|
r.super.UpdateUserRoles,
|
|
PathParam[int64]("id"),
|
|
Body[dto.UserRolesUpdateForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Patch /v1/users/:id/status -> super.UpdateUserStatus")
|
|
router.Patch("/v1/users/:id/status"[len(r.Path()):], Func2(
|
|
r.super.UpdateUserStatus,
|
|
PathParam[int64]("id"),
|
|
Body[dto.UserStatusUpdateForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/auth/login -> super.Login")
|
|
router.Post("/v1/auth/login"[len(r.Path()):], DataFunc1(
|
|
r.super.Login,
|
|
Body[dto.LoginForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/orders/:id/refund -> super.RefundOrder")
|
|
router.Post("/v1/orders/:id/refund"[len(r.Path()):], Func2(
|
|
r.super.RefundOrder,
|
|
PathParam[int64]("id"),
|
|
Body[dto.SuperOrderRefundForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/tenants -> super.CreateTenant")
|
|
router.Post("/v1/tenants"[len(r.Path()):], Func1(
|
|
r.super.CreateTenant,
|
|
Body[dto.TenantCreateForm]("form"),
|
|
))
|
|
// Register routes for controller: Tenant
|
|
r.log.Debugf("Registering route: Delete /v1/tenants/:id/follow -> tenant.Unfollow")
|
|
router.Delete("/v1/tenants/:id/follow"[len(r.Path()):], Func1(
|
|
r.tenant.Unfollow,
|
|
PathParam[string]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/tenants/:id -> tenant.Get")
|
|
router.Get("/v1/tenants/:id"[len(r.Path()):], DataFunc1(
|
|
r.tenant.Get,
|
|
PathParam[string]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/tenants/:id/follow -> tenant.Follow")
|
|
router.Post("/v1/tenants/:id/follow"[len(r.Path()):], Func1(
|
|
r.tenant.Follow,
|
|
PathParam[string]("id"),
|
|
))
|
|
// Register routes for controller: Transaction
|
|
r.log.Debugf("Registering route: Get /v1/orders/:id/status -> transaction.Status")
|
|
router.Get("/v1/orders/:id/status"[len(r.Path()):], DataFunc1(
|
|
r.transaction.Status,
|
|
PathParam[string]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/orders -> transaction.Create")
|
|
router.Post("/v1/orders"[len(r.Path()):], DataFunc1(
|
|
r.transaction.Create,
|
|
Body[dto.OrderCreateForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/orders/:id/pay -> transaction.Pay")
|
|
router.Post("/v1/orders/:id/pay"[len(r.Path()):], DataFunc2(
|
|
r.transaction.Pay,
|
|
PathParam[string]("id"),
|
|
Body[dto.OrderPayForm]("form"),
|
|
))
|
|
// Register routes for controller: User
|
|
r.log.Debugf("Registering route: Delete /v1/me/favorites/:contentId -> user.RemoveFavorite")
|
|
router.Delete("/v1/me/favorites/:contentId"[len(r.Path()):], Func1(
|
|
r.user.RemoveFavorite,
|
|
PathParam[string]("contentId"),
|
|
))
|
|
r.log.Debugf("Registering route: Delete /v1/me/likes/:contentId -> user.RemoveLike")
|
|
router.Delete("/v1/me/likes/:contentId"[len(r.Path()):], Func1(
|
|
r.user.RemoveLike,
|
|
PathParam[string]("contentId"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/me -> user.Me")
|
|
router.Get("/v1/me"[len(r.Path()):], DataFunc0(
|
|
r.user.Me,
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/me/favorites -> user.Favorites")
|
|
router.Get("/v1/me/favorites"[len(r.Path()):], DataFunc0(
|
|
r.user.Favorites,
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/me/library -> user.Library")
|
|
router.Get("/v1/me/library"[len(r.Path()):], DataFunc0(
|
|
r.user.Library,
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/me/likes -> user.Likes")
|
|
router.Get("/v1/me/likes"[len(r.Path()):], DataFunc0(
|
|
r.user.Likes,
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/me/notifications -> user.Notifications")
|
|
router.Get("/v1/me/notifications"[len(r.Path()):], DataFunc1(
|
|
r.user.Notifications,
|
|
QueryParam[string]("type"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/me/orders -> user.ListOrders")
|
|
router.Get("/v1/me/orders"[len(r.Path()):], DataFunc1(
|
|
r.user.ListOrders,
|
|
QueryParam[string]("status"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/me/orders/:id -> user.GetOrder")
|
|
router.Get("/v1/me/orders/:id"[len(r.Path()):], DataFunc1(
|
|
r.user.GetOrder,
|
|
PathParam[string]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /v1/me/wallet -> user.Wallet")
|
|
router.Get("/v1/me/wallet"[len(r.Path()):], DataFunc0(
|
|
r.user.Wallet,
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/me/favorites -> user.AddFavorite")
|
|
router.Post("/v1/me/favorites"[len(r.Path()):], Func1(
|
|
r.user.AddFavorite,
|
|
QueryParam[string]("contentId"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/me/likes -> user.AddLike")
|
|
router.Post("/v1/me/likes"[len(r.Path()):], Func1(
|
|
r.user.AddLike,
|
|
QueryParam[string]("contentId"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/me/realname -> user.RealName")
|
|
router.Post("/v1/me/realname"[len(r.Path()):], Func1(
|
|
r.user.RealName,
|
|
Body[dto.RealNameForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /v1/me/wallet/recharge -> user.Recharge")
|
|
router.Post("/v1/me/wallet/recharge"[len(r.Path()):], DataFunc1(
|
|
r.user.Recharge,
|
|
Body[dto.RechargeForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Put /v1/me -> user.Update")
|
|
router.Put("/v1/me"[len(r.Path()):], Func1(
|
|
r.user.Update,
|
|
Body[dto.UserUpdate]("form"),
|
|
))
|
|
|
|
r.log.Info("Successfully registered all routes")
|
|
}
|