Files
quyun/backend_v1/app/http/admin/routes.gen.go

226 lines
8.5 KiB
Go

// Code generated by atomctl. DO NOT EDIT.
// Package admin provides HTTP route definitions and registration
// for the quyun/v2 application.
package admin
import (
"go.ipao.vip/gen/field"
"quyun/v2/app/http/dto"
"quyun/v2/app/middlewares"
"quyun/v2/app/requests"
"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 admin module.
//
// @provider contracts.HttpRoute atom.GroupRoutes
type Routes struct {
log *log.Entry `inject:"false"`
middlewares *middlewares.Middlewares
// Controller instances
auth *auth
medias *medias
orders *orders
posts *posts
smsCodeSends *smsCodeSends
statistics *statistics
uploads *uploads
users *users
}
// Prepare initializes the routes provider with logging configuration.
func (r *Routes) Prepare() error {
r.log = log.WithField("module", "routes.admin")
r.log.Info("Initializing routes module")
return nil
}
// Name returns the unique identifier for this routes provider.
func (r *Routes) Name() string {
return "admin"
}
// 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 /admin/v1/auth -> auth.Login")
router.Post("/admin/v1/auth"[len(r.Path()):], DataFunc1(
r.auth.Login,
Body[AuthBody]("body"),
))
// Register routes for controller: medias
r.log.Debugf("Registering route: Delete /admin/v1/medias/:id -> medias.Delete")
router.Delete("/admin/v1/medias/:id"[len(r.Path()):], Func1(
r.medias.Delete,
func(ctx fiber.Ctx) (*models.Medium, error) {
v := fiber.Params[int](ctx, "id")
return models.MediumQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
},
))
r.log.Debugf("Registering route: Get /admin/v1/medias -> medias.List")
router.Get("/admin/v1/medias"[len(r.Path()):], DataFunc1(
r.medias.List,
Query[dto.ListQuery]("query"),
))
r.log.Debugf("Registering route: Get /admin/v1/medias/:id -> medias.Show")
router.Get("/admin/v1/medias/:id"[len(r.Path()):], Func1(
r.medias.Show,
func(ctx fiber.Ctx) (*models.Medium, error) {
v := fiber.Params[int](ctx, "id")
return models.MediumQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
},
))
// Register routes for controller: orders
r.log.Debugf("Registering route: Get /admin/v1/orders -> orders.List")
router.Get("/admin/v1/orders"[len(r.Path()):], DataFunc1(
r.orders.List,
Query[dto.OrderListQuery]("query"),
))
r.log.Debugf("Registering route: Post /admin/v1/orders/:id/refund -> orders.Refund")
router.Post("/admin/v1/orders/:id/refund"[len(r.Path()):], Func1(
r.orders.Refund,
func(ctx fiber.Ctx) (*models.Order, error) {
v := fiber.Params[int](ctx, "id")
return models.OrderQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
},
))
// Register routes for controller: posts
r.log.Debugf("Registering route: Delete /admin/v1/posts/:id -> posts.Delete")
router.Delete("/admin/v1/posts/:id"[len(r.Path()):], Func1(
r.posts.Delete,
func(ctx fiber.Ctx) (*models.Post, error) {
v := fiber.Params[int](ctx, "id")
return models.PostQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
},
))
r.log.Debugf("Registering route: Get /admin/v1/posts -> posts.List")
router.Get("/admin/v1/posts"[len(r.Path()):], DataFunc1(
r.posts.List,
Query[dto.PostListQuery]("query"),
))
r.log.Debugf("Registering route: Get /admin/v1/posts/:id -> posts.Show")
router.Get("/admin/v1/posts/:id"[len(r.Path()):], DataFunc1(
r.posts.Show,
func(ctx fiber.Ctx) (*models.Post, error) {
v := fiber.Params[int](ctx, "id")
return models.PostQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
},
))
r.log.Debugf("Registering route: Get /admin/v1/posts/:id/buyers -> posts.Buyers")
router.Get("/admin/v1/posts/:id/buyers"[len(r.Path()):], DataFunc2(
r.posts.Buyers,
func(ctx fiber.Ctx) (*models.Post, error) {
v := fiber.Params[int](ctx, "id")
return models.PostQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
},
Query[requests.Pagination]("pagination"),
))
r.log.Debugf("Registering route: Post /admin/v1/posts -> posts.Create")
router.Post("/admin/v1/posts"[len(r.Path()):], Func1(
r.posts.Create,
Body[PostForm]("form"),
))
r.log.Debugf("Registering route: Post /admin/v1/posts/:id/send-to/:userId -> posts.SendTo")
router.Post("/admin/v1/posts/:id/send-to/:userId"[len(r.Path()):], Func2(
r.posts.SendTo,
func(ctx fiber.Ctx) (*models.Post, error) {
v := fiber.Params[int](ctx, "id")
return models.PostQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
},
func(ctx fiber.Ctx) (*models.User, error) {
v := fiber.Params[int](ctx, "userId")
return models.UserQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
},
))
r.log.Debugf("Registering route: Put /admin/v1/posts/:id -> posts.Update")
router.Put("/admin/v1/posts/:id"[len(r.Path()):], Func2(
r.posts.Update,
func(ctx fiber.Ctx) (*models.Post, error) {
v := fiber.Params[int](ctx, "id")
return models.PostQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
},
Body[PostForm]("form"),
))
// Register routes for controller: smsCodeSends
r.log.Debugf("Registering route: Get /admin/v1/sms-code-sends -> smsCodeSends.List")
router.Get("/admin/v1/sms-code-sends"[len(r.Path()):], DataFunc1(
r.smsCodeSends.List,
Query[dto.SmsCodeSendListQuery]("query"),
))
// Register routes for controller: statistics
r.log.Debugf("Registering route: Get /admin/v1/statistics -> statistics.statistics")
router.Get("/admin/v1/statistics"[len(r.Path()):], DataFunc0(
r.statistics.statistics,
))
// Register routes for controller: uploads
r.log.Debugf("Registering route: Get /admin/v1/uploads/pre-uploaded-check/:md5.:ext -> uploads.PreUploadCheck")
router.Get("/admin/v1/uploads/pre-uploaded-check/:md5.:ext"[len(r.Path()):], DataFunc3(
r.uploads.PreUploadCheck,
PathParam[string]("md5"),
PathParam[string]("ext"),
QueryParam[string]("mime"),
))
r.log.Debugf("Registering route: Post /admin/v1/uploads/post-uploaded-action -> uploads.PostUploadedAction")
router.Post("/admin/v1/uploads/post-uploaded-action"[len(r.Path()):], Func1(
r.uploads.PostUploadedAction,
Body[PostUploadedForm]("body"),
))
// Register routes for controller: users
r.log.Debugf("Registering route: Get /admin/v1/users -> users.List")
router.Get("/admin/v1/users"[len(r.Path()):], DataFunc1(
r.users.List,
Query[dto.UserListQuery]("query"),
))
r.log.Debugf("Registering route: Post /admin/v1/users -> users.Create")
router.Post("/admin/v1/users"[len(r.Path()):], DataFunc1(
r.users.Create,
Body[UserCreateForm]("form"),
))
r.log.Debugf("Registering route: Get /admin/v1/users/:id -> users.Show")
router.Get("/admin/v1/users/:id"[len(r.Path()):], DataFunc1(
r.users.Show,
func(ctx fiber.Ctx) (*models.User, error) {
v := fiber.Params[int](ctx, "id")
return models.UserQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
},
))
r.log.Debugf("Registering route: Get /admin/v1/users/:id/articles -> users.Articles")
router.Get("/admin/v1/users/:id/articles"[len(r.Path()):], DataFunc2(
r.users.Articles,
func(ctx fiber.Ctx) (*models.User, error) {
v := fiber.Params[int](ctx, "id")
return models.UserQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
},
Query[requests.Pagination]("pagination"),
))
r.log.Debugf("Registering route: Post /admin/v1/users/:id/balance -> users.Balance")
router.Post("/admin/v1/users/:id/balance"[len(r.Path()):], Func2(
r.users.Balance,
func(ctx fiber.Ctx) (*models.User, error) {
v := fiber.Params[int](ctx, "id")
return models.UserQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
},
Body[UserBalance]("balance"),
))
r.log.Debugf("Registering route: Post /admin/v1/users/:id/phone -> users.SetPhone")
router.Post("/admin/v1/users/:id/phone"[len(r.Path()):], Func2(
r.users.SetPhone,
func(ctx fiber.Ctx) (*models.User, error) {
v := fiber.Params[int](ctx, "id")
return models.UserQuery.WithContext(ctx).Where(field.NewUnsafeFieldRaw("id = ?", v)).First()
},
Body[UserPhoneForm]("form"),
))
r.log.Info("Successfully registered all routes")
}