// Code generated by the atomctl ; DO NOT EDIT.

package admin

import (
	"github.com/gofiber/fiber/v3"
	log "github.com/sirupsen/logrus"
	_ "go.ipao.vip/atom"
	_ "go.ipao.vip/atom/contracts"
	. "go.ipao.vip/atom/fen"
	"quyun/app/requests"
)

// @provider contracts.HttpRoute atom.GroupRoutes
type Routes struct {
	log        *log.Entry `inject:"false"`
	auth       *auth
	medias     *medias
	orders     *orders
	posts      *posts
	statistics *statistics
	uploads    *uploads
	users      *users
}

func (r *Routes) Prepare() error {
	r.log = log.WithField("module", "routes.admin")
	return nil
}

func (r *Routes) Name() string {
	return "admin"
}

func (r *Routes) Register(router fiber.Router) {
	// 注册路由组: auth
	router.Post("/admin/auth", DataFunc1(
		r.auth.Login,
		Body[AuthBody]("body"),
	))

	// 注册路由组: medias
	router.Get("/admin/medias", DataFunc2(
		r.medias.List,
		Query[requests.Pagination]("pagination"),
		Query[ListQuery]("query"),
	))

	router.Get("/admin/medias/:id", Func1(
		r.medias.Show,
		PathParam[int64]("id"),
	))

	router.Delete("/admin/medias/:id", Func1(
		r.medias.Delete,
		PathParam[int64]("id"),
	))

	// 注册路由组: orders
	router.Get("/admin/orders", DataFunc2(
		r.orders.List,
		Query[requests.Pagination]("pagination"),
		Query[OrderListQuery]("query"),
	))

	router.Post("/admin/orders/:id/refund", Func1(
		r.orders.Refund,
		PathParam[int64]("id"),
	))

	// 注册路由组: posts
	router.Get("/admin/posts", DataFunc2(
		r.posts.List,
		Query[requests.Pagination]("pagination"),
		Query[ListQuery]("query"),
	))

	router.Post("/admin/posts", Func1(
		r.posts.Create,
		Body[PostForm]("form"),
	))

	router.Put("/admin/posts/:id", Func2(
		r.posts.Update,
		PathParam[int64]("id"),
		Body[PostForm]("form"),
	))

	router.Delete("/admin/posts/:id", Func1(
		r.posts.Delete,
		PathParam[int64]("id"),
	))

	router.Get("/admin/posts/:id", DataFunc1(
		r.posts.Show,
		PathParam[int64]("id"),
	))

	router.Post("/admin/posts/:id/send-to/:userId", Func2(
		r.posts.SendTo,
		PathParam[int64]("id"),
		PathParam[int64]("userId"),
	))

	// 注册路由组: statistics
	router.Get("/admin/statistics", DataFunc0(
		r.statistics.statistics,
	))

	// 注册路由组: uploads
	router.Get("/admin/uploads/pre-uploaded-check/:md5.:ext", DataFunc3(
		r.uploads.PreUploadCheck,
		PathParam[string]("md5"),
		PathParam[string]("ext"),
		QueryParam[string]("mime"),
	))

	router.Post("/admin/uploads/post-uploaded-action", Func1(
		r.uploads.PostUploadedAction,
		Body[PostUploadedForm]("body"),
	))

	// 注册路由组: users
	router.Get("/admin/users", DataFunc2(
		r.users.List,
		Query[requests.Pagination]("pagination"),
		Query[UserListQuery]("query"),
	))

	router.Get("/admin/users/:id", DataFunc1(
		r.users.Show,
		PathParam[int64]("id"),
	))

	router.Get("/admin/users/:id/articles", DataFunc2(
		r.users.Articles,
		PathParam[int64]("id"),
		Query[requests.Pagination]("pagination"),
	))

	router.Post("/admin/users/:id/balance", Func2(
		r.users.Balance,
		PathParam[int64]("id"),
		Body[UserBalance]("balance"),
	))

}
