224 lines
8.7 KiB
Go
224 lines
8.7 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 (
|
|
dto "quyun/v2/app/http/super/v1/dto"
|
|
"quyun/v2/app/middlewares"
|
|
"quyun/v2/database/models"
|
|
|
|
"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
|
|
contents *contents
|
|
coupons *coupons
|
|
creators *creators
|
|
orders *orders
|
|
reports *reports
|
|
tenants *tenants
|
|
users *users
|
|
withdrawals *withdrawals
|
|
}
|
|
|
|
// 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: contents
|
|
r.log.Debugf("Registering route: Get /super/v1/contents -> contents.List")
|
|
router.Get("/super/v1/contents"[len(r.Path()):], DataFunc1(
|
|
r.contents.List,
|
|
Query[dto.SuperContentListFilter]("filter"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /super/v1/tenants/:tenantID<int>/contents -> contents.ListTenantContents")
|
|
router.Get("/super/v1/tenants/:tenantID<int>/contents"[len(r.Path()):], DataFunc2(
|
|
r.contents.ListTenantContents,
|
|
PathParam[int64]("tenantID"),
|
|
Query[dto.SuperContentListFilter]("filter"),
|
|
))
|
|
r.log.Debugf("Registering route: Patch /super/v1/tenants/:tenantID<int>/contents/:contentID<int>/status -> contents.UpdateStatus")
|
|
router.Patch("/super/v1/tenants/:tenantID<int>/contents/:contentID<int>/status"[len(r.Path()):], Func3(
|
|
r.contents.UpdateStatus,
|
|
PathParam[int64]("tenantID"),
|
|
PathParam[int64]("contentID"),
|
|
Body[dto.SuperTenantContentStatusUpdateForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /super/v1/contents/:id<int>/review -> contents.Review")
|
|
router.Post("/super/v1/contents/:id<int>/review"[len(r.Path()):], Func3(
|
|
r.contents.Review,
|
|
Local[*models.User]("__ctx_user"),
|
|
PathParam[int64]("id"),
|
|
Body[dto.SuperContentReviewForm]("form"),
|
|
))
|
|
// Register routes for controller: coupons
|
|
r.log.Debugf("Registering route: Get /super/v1/coupons -> coupons.List")
|
|
router.Get("/super/v1/coupons"[len(r.Path()):], DataFunc1(
|
|
r.coupons.List,
|
|
Query[dto.SuperCouponListFilter]("filter"),
|
|
))
|
|
// Register routes for controller: creators
|
|
r.log.Debugf("Registering route: Get /super/v1/creators -> creators.List")
|
|
router.Get("/super/v1/creators"[len(r.Path()):], DataFunc1(
|
|
r.creators.List,
|
|
Query[dto.TenantListFilter]("filter"),
|
|
))
|
|
// Register routes for controller: orders
|
|
r.log.Debugf("Registering route: Get /super/v1/orders -> orders.List")
|
|
router.Get("/super/v1/orders"[len(r.Path()):], DataFunc1(
|
|
r.orders.List,
|
|
Query[dto.SuperOrderListFilter]("filter"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /super/v1/orders/:id<int> -> orders.Get")
|
|
router.Get("/super/v1/orders/:id<int>"[len(r.Path()):], DataFunc1(
|
|
r.orders.Get,
|
|
PathParam[int64]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /super/v1/orders/statistics -> orders.Statistics")
|
|
router.Get("/super/v1/orders/statistics"[len(r.Path()):], DataFunc0(
|
|
r.orders.Statistics,
|
|
))
|
|
r.log.Debugf("Registering route: Post /super/v1/orders/:id<int>/refund -> orders.Refund")
|
|
router.Post("/super/v1/orders/:id<int>/refund"[len(r.Path()):], Func2(
|
|
r.orders.Refund,
|
|
PathParam[int64]("id"),
|
|
Body[dto.SuperOrderRefundForm]("form"),
|
|
))
|
|
// Register routes for controller: reports
|
|
r.log.Debugf("Registering route: Get /super/v1/reports/overview -> reports.Overview")
|
|
router.Get("/super/v1/reports/overview"[len(r.Path()):], DataFunc1(
|
|
r.reports.Overview,
|
|
Query[dto.SuperReportOverviewFilter]("filter"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /super/v1/reports/export -> reports.Export")
|
|
router.Post("/super/v1/reports/export"[len(r.Path()):], DataFunc1(
|
|
r.reports.Export,
|
|
Body[dto.SuperReportExportForm]("form"),
|
|
))
|
|
// Register routes for controller: tenants
|
|
r.log.Debugf("Registering route: Get /super/v1/tenants -> tenants.List")
|
|
router.Get("/super/v1/tenants"[len(r.Path()):], DataFunc1(
|
|
r.tenants.List,
|
|
Query[dto.TenantListFilter]("filter"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /super/v1/tenants/:id<int> -> tenants.Get")
|
|
router.Get("/super/v1/tenants/:id<int>"[len(r.Path()):], DataFunc1(
|
|
r.tenants.Get,
|
|
PathParam[int64]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /super/v1/tenants/:tenantID<int>/users -> tenants.ListUsers")
|
|
router.Get("/super/v1/tenants/:tenantID<int>/users"[len(r.Path()):], DataFunc2(
|
|
r.tenants.ListUsers,
|
|
PathParam[int64]("tenantID"),
|
|
Query[dto.SuperTenantUserListFilter]("filter"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /super/v1/tenants/health -> tenants.Health")
|
|
router.Get("/super/v1/tenants/health"[len(r.Path()):], DataFunc1(
|
|
r.tenants.Health,
|
|
Query[dto.TenantListFilter]("filter"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /super/v1/tenants/statuses -> tenants.Statuses")
|
|
router.Get("/super/v1/tenants/statuses"[len(r.Path()):], DataFunc0(
|
|
r.tenants.Statuses,
|
|
))
|
|
r.log.Debugf("Registering route: Patch /super/v1/tenants/:id<int> -> tenants.UpdateExpire")
|
|
router.Patch("/super/v1/tenants/:id<int>"[len(r.Path()):], Func2(
|
|
r.tenants.UpdateExpire,
|
|
PathParam[int64]("id"),
|
|
Body[dto.TenantExpireUpdateForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Patch /super/v1/tenants/:id<int>/status -> tenants.UpdateStatus")
|
|
router.Patch("/super/v1/tenants/:id<int>/status"[len(r.Path()):], Func2(
|
|
r.tenants.UpdateStatus,
|
|
PathParam[int64]("id"),
|
|
Body[dto.TenantStatusUpdateForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /super/v1/tenants -> tenants.Create")
|
|
router.Post("/super/v1/tenants"[len(r.Path()):], Func1(
|
|
r.tenants.Create,
|
|
Body[dto.TenantCreateForm]("form"),
|
|
))
|
|
// Register routes for controller: users
|
|
r.log.Debugf("Registering route: Get /super/v1/users -> users.List")
|
|
router.Get("/super/v1/users"[len(r.Path()):], DataFunc1(
|
|
r.users.List,
|
|
Query[dto.UserListFilter]("filter"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /super/v1/users/:id<int> -> users.Get")
|
|
router.Get("/super/v1/users/:id<int>"[len(r.Path()):], DataFunc1(
|
|
r.users.Get,
|
|
PathParam[int64]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /super/v1/users/:id<int>/tenants -> users.ListTenants")
|
|
router.Get("/super/v1/users/:id<int>/tenants"[len(r.Path()):], DataFunc2(
|
|
r.users.ListTenants,
|
|
PathParam[int64]("id"),
|
|
Query[dto.SuperUserTenantListFilter]("filter"),
|
|
))
|
|
r.log.Debugf("Registering route: Get /super/v1/users/statistics -> users.Statistics")
|
|
router.Get("/super/v1/users/statistics"[len(r.Path()):], DataFunc0(
|
|
r.users.Statistics,
|
|
))
|
|
r.log.Debugf("Registering route: Get /super/v1/users/statuses -> users.Statuses")
|
|
router.Get("/super/v1/users/statuses"[len(r.Path()):], DataFunc0(
|
|
r.users.Statuses,
|
|
))
|
|
r.log.Debugf("Registering route: Patch /super/v1/users/:id<int>/roles -> users.UpdateRoles")
|
|
router.Patch("/super/v1/users/:id<int>/roles"[len(r.Path()):], Func2(
|
|
r.users.UpdateRoles,
|
|
PathParam[int64]("id"),
|
|
Body[dto.UserRolesUpdateForm]("form"),
|
|
))
|
|
r.log.Debugf("Registering route: Patch /super/v1/users/:id<int>/status -> users.UpdateStatus")
|
|
router.Patch("/super/v1/users/:id<int>/status"[len(r.Path()):], Func2(
|
|
r.users.UpdateStatus,
|
|
PathParam[int64]("id"),
|
|
Body[dto.UserStatusUpdateForm]("form"),
|
|
))
|
|
// Register routes for controller: withdrawals
|
|
r.log.Debugf("Registering route: Get /super/v1/withdrawals -> withdrawals.List")
|
|
router.Get("/super/v1/withdrawals"[len(r.Path()):], DataFunc1(
|
|
r.withdrawals.List,
|
|
Query[dto.SuperOrderListFilter]("filter"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /super/v1/withdrawals/:id<int>/approve -> withdrawals.Approve")
|
|
router.Post("/super/v1/withdrawals/:id<int>/approve"[len(r.Path()):], Func2(
|
|
r.withdrawals.Approve,
|
|
Local[*models.User]("__ctx_user"),
|
|
PathParam[int64]("id"),
|
|
))
|
|
r.log.Debugf("Registering route: Post /super/v1/withdrawals/:id<int>/reject -> withdrawals.Reject")
|
|
router.Post("/super/v1/withdrawals/:id<int>/reject"[len(r.Path()):], Func3(
|
|
r.withdrawals.Reject,
|
|
Local[*models.User]("__ctx_user"),
|
|
PathParam[int64]("id"),
|
|
Body[dto.SuperWithdrawalRejectForm]("form"),
|
|
))
|
|
|
|
r.log.Info("Successfully registered all routes")
|
|
}
|