Refactor super module: Move HTTP handlers to new super/v1 package
- Deleted old super.go file and moved all related HTTP handlers to new package structure under backend/app/http/super/v1. - Updated service imports in super.go and super_test.go to reflect new DTO paths. - Created new auth, contents, orders, tenants, and users handlers with corresponding routes and methods. - Added new DTO definitions for authentication and content management in the super/v1/dto directory. - Implemented new migration for content_access table and created model for it.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
super_v1 "quyun/v2/app/http/super/v1"
|
||||
v1 "quyun/v2/app/http/v1"
|
||||
|
||||
"go.ipao.vip/atom/container"
|
||||
@@ -9,5 +10,6 @@ import (
|
||||
func Providers() container.Providers {
|
||||
return container.Providers{
|
||||
{Provider: v1.Provide},
|
||||
{Provider: super_v1.Provide},
|
||||
}
|
||||
}
|
||||
|
||||
39
backend/app/http/super/v1/auth.go
Normal file
39
backend/app/http/super/v1/auth.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
dto "quyun/v2/app/http/super/v1/dto"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type auth struct{}
|
||||
|
||||
// Login
|
||||
//
|
||||
// @Router /super/v1/auth/login [post]
|
||||
// @Summary Login
|
||||
// @Description Login
|
||||
// @Tags Auth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.LoginForm true "Login form"
|
||||
// @Success 200 {object} dto.LoginResponse
|
||||
// @Bind form body
|
||||
func (c *auth) Login(ctx fiber.Ctx, form *dto.LoginForm) (*dto.LoginResponse, error) {
|
||||
return services.Super.Login(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// Check Token
|
||||
//
|
||||
// @Router /super/v1/auth/token [get]
|
||||
// @Summary Check token
|
||||
// @Description Check token
|
||||
// @Tags Auth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.LoginResponse
|
||||
func (c *auth) CheckToken(ctx fiber.Ctx) (*dto.LoginResponse, error) {
|
||||
return services.Super.CheckToken(ctx.Context())
|
||||
}
|
||||
47
backend/app/http/super/v1/contents.go
Normal file
47
backend/app/http/super/v1/contents.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
dto "quyun/v2/app/http/super/v1/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type contents struct{}
|
||||
|
||||
// List contents
|
||||
//
|
||||
// @Router /super/v1/contents [get]
|
||||
// @Summary List contents
|
||||
// @Description List contents
|
||||
// @Tags Content
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page number"
|
||||
// @Param limit query int false "Page size"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.AdminContentItem}
|
||||
// @Bind filter query
|
||||
func (c *contents) List(ctx fiber.Ctx, filter *dto.SuperContentListFilter) (*requests.Pager, error) {
|
||||
return services.Super.ListContents(ctx.Context(), filter)
|
||||
}
|
||||
|
||||
// Update content status
|
||||
//
|
||||
// @Router /super/v1/tenants/:tenantID/contents/:contentID/status [patch]
|
||||
// @Summary Update content status
|
||||
// @Description Update content status
|
||||
// @Tags Content
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "Tenant ID"
|
||||
// @Param contentID path int64 true "Content ID"
|
||||
// @Param form body dto.SuperTenantContentStatusUpdateForm true "Update form"
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind tenantID path
|
||||
// @Bind contentID path
|
||||
// @Bind form body
|
||||
func (c *contents) UpdateStatus(ctx fiber.Ctx, tenantID, contentID int64, form *dto.SuperTenantContentStatusUpdateForm) error {
|
||||
return services.Super.UpdateContentStatus(ctx.Context(), tenantID, contentID, form)
|
||||
}
|
||||
32
backend/app/http/super/v1/dto/auth.go
Normal file
32
backend/app/http/super/v1/dto/auth.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package dto
|
||||
|
||||
import "quyun/v2/pkg/consts"
|
||||
|
||||
type LoginForm struct {
|
||||
Phone string `json:"phone"`
|
||||
OTP string `json:"otp"`
|
||||
}
|
||||
|
||||
type LoginResponse struct {
|
||||
Token string `json:"token"`
|
||||
User *User `json:"user"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID string `json:"id"`
|
||||
Phone string `json:"phone"`
|
||||
Nickname string `json:"nickname"`
|
||||
Avatar string `json:"avatar"`
|
||||
Gender consts.Gender `json:"gender"`
|
||||
Bio string `json:"bio"`
|
||||
Birthday string `json:"birthday"` // YYYY-MM-DD
|
||||
Location *Location `json:"location"`
|
||||
Balance float64 `json:"balance"`
|
||||
Points int64 `json:"points"`
|
||||
IsRealNameVerified bool `json:"is_real_name_verified"`
|
||||
}
|
||||
|
||||
type Location struct {
|
||||
Province string `json:"province"`
|
||||
City string `json:"city"`
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
v1_dto "quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/pkg/consts"
|
||||
)
|
||||
@@ -120,12 +121,12 @@ type TenantStatusUpdateForm struct {
|
||||
}
|
||||
|
||||
type SuperTenantContentItem struct {
|
||||
Content *ContentItem `json:"content"`
|
||||
Content *v1_dto.ContentItem `json:"content"`
|
||||
StatusDescription string `json:"status_description"`
|
||||
VisibilityDescription string `json:"visibility_description"`
|
||||
Tenant *SuperContentTenantLite `json:"tenant"`
|
||||
Owner *SuperUserLite `json:"owner"`
|
||||
Price *ContentPrice `json:"price"` // Reuse or define specific price struct
|
||||
Price *v1_dto.ContentPrice `json:"price"`
|
||||
}
|
||||
|
||||
type SuperContentTenantLite struct {
|
||||
@@ -209,9 +210,9 @@ type SuperOrderRefundForm struct {
|
||||
|
||||
// AdminContentItem for super admin view
|
||||
type AdminContentItem struct {
|
||||
Content *ContentItem `json:"content"`
|
||||
Content *v1_dto.ContentItem `json:"content"`
|
||||
Owner *AdminContentOwnerLite `json:"owner"`
|
||||
Price *ContentPrice `json:"price"`
|
||||
Price *v1_dto.ContentPrice `json:"price"`
|
||||
StatusDescription string `json:"status_description"`
|
||||
VisibilityDescription string `json:"visibility_description"`
|
||||
}
|
||||
73
backend/app/http/super/v1/orders.go
Normal file
73
backend/app/http/super/v1/orders.go
Normal file
@@ -0,0 +1,73 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
dto "quyun/v2/app/http/super/v1/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type orders struct{}
|
||||
|
||||
// List orders
|
||||
//
|
||||
// @Router /super/v1/orders [get]
|
||||
// @Summary List orders
|
||||
// @Description List orders
|
||||
// @Tags Order
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page number"
|
||||
// @Param limit query int false "Page size"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.SuperOrderItem}
|
||||
// @Bind filter query
|
||||
func (c *orders) List(ctx fiber.Ctx, filter *dto.SuperOrderListFilter) (*requests.Pager, error) {
|
||||
return services.Super.ListOrders(ctx.Context(), filter)
|
||||
}
|
||||
|
||||
// Get order
|
||||
//
|
||||
// @Router /super/v1/orders/:id [get]
|
||||
// @Summary Get order
|
||||
// @Description Get order
|
||||
// @Tags Order
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Order ID"
|
||||
// @Success 200 {object} dto.SuperOrderDetail
|
||||
// @Bind id path
|
||||
func (c *orders) Get(ctx fiber.Ctx, id int64) (*dto.SuperOrderDetail, error) {
|
||||
return services.Super.GetOrder(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Refund order
|
||||
//
|
||||
// @Router /super/v1/orders/:id/refund [post]
|
||||
// @Summary Refund order
|
||||
// @Description Refund order
|
||||
// @Tags Order
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Order ID"
|
||||
// @Param form body dto.SuperOrderRefundForm true "Refund form"
|
||||
// @Success 200 {string} string "Refunded"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *orders) Refund(ctx fiber.Ctx, id int64, form *dto.SuperOrderRefundForm) error {
|
||||
return services.Super.RefundOrder(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Order statistics
|
||||
//
|
||||
// @Router /super/v1/orders/statistics [get]
|
||||
// @Summary Order statistics
|
||||
// @Description Order statistics
|
||||
// @Tags Order
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.OrderStatisticsResponse
|
||||
func (c *orders) Statistics(ctx fiber.Ctx) (*dto.OrderStatisticsResponse, error) {
|
||||
return services.Super.OrderStatistics(ctx.Context())
|
||||
}
|
||||
73
backend/app/http/super/v1/provider.gen.go
Executable file
73
backend/app/http/super/v1/provider.gen.go
Executable file
@@ -0,0 +1,73 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"quyun/v2/app/middlewares"
|
||||
|
||||
"go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/container"
|
||||
"go.ipao.vip/atom/contracts"
|
||||
"go.ipao.vip/atom/opt"
|
||||
)
|
||||
|
||||
func Provide(opts ...opt.Option) error {
|
||||
if err := container.Container.Provide(func() (*auth, error) {
|
||||
obj := &auth{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*contents, error) {
|
||||
obj := &contents{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*orders, error) {
|
||||
obj := &orders{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func(
|
||||
auth *auth,
|
||||
contents *contents,
|
||||
middlewares *middlewares.Middlewares,
|
||||
orders *orders,
|
||||
tenants *tenants,
|
||||
users *users,
|
||||
) (contracts.HttpRoute, error) {
|
||||
obj := &Routes{
|
||||
auth: auth,
|
||||
contents: contents,
|
||||
middlewares: middlewares,
|
||||
orders: orders,
|
||||
tenants: tenants,
|
||||
users: users,
|
||||
}
|
||||
if err := obj.Prepare(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj, nil
|
||||
}, atom.GroupRoutes); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*tenants, error) {
|
||||
obj := &tenants{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*users, error) {
|
||||
obj := &users{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
157
backend/app/http/super/v1/routes.gen.go
Normal file
157
backend/app/http/super/v1/routes.gen.go
Normal file
@@ -0,0 +1,157 @@
|
||||
// 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"
|
||||
|
||||
"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
|
||||
contents *contents
|
||||
orders *orders
|
||||
tenants *tenants
|
||||
users *users
|
||||
}
|
||||
|
||||
// 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: Get /super/v1/auth/token -> auth.CheckToken")
|
||||
router.Get("/super/v1/auth/token"[len(r.Path()):], DataFunc0(
|
||||
r.auth.CheckToken,
|
||||
))
|
||||
r.log.Debugf("Registering route: Post /super/v1/auth/login -> auth.Login")
|
||||
router.Post("/super/v1/auth/login"[len(r.Path()):], DataFunc1(
|
||||
r.auth.Login,
|
||||
Body[dto.LoginForm]("form"),
|
||||
))
|
||||
// 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: Patch /super/v1/tenants/:tenantID/contents/:contentID/status -> contents.UpdateStatus")
|
||||
router.Patch("/super/v1/tenants/:tenantID/contents/:contentID/status"[len(r.Path()):], Func3(
|
||||
r.contents.UpdateStatus,
|
||||
PathParam[int64]("tenantID"),
|
||||
PathParam[int64]("contentID"),
|
||||
Body[dto.SuperTenantContentStatusUpdateForm]("form"),
|
||||
))
|
||||
// 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 -> orders.Get")
|
||||
router.Get("/super/v1/orders/:id"[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/refund -> orders.Refund")
|
||||
router.Post("/super/v1/orders/:id/refund"[len(r.Path()):], Func2(
|
||||
r.orders.Refund,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.SuperOrderRefundForm]("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 -> tenants.Get")
|
||||
router.Get("/super/v1/tenants/:id"[len(r.Path()):], DataFunc1(
|
||||
r.tenants.Get,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
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 -> tenants.UpdateExpire")
|
||||
router.Patch("/super/v1/tenants/:id"[len(r.Path()):], Func2(
|
||||
r.tenants.UpdateExpire,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.TenantExpireUpdateForm]("form"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Patch /super/v1/tenants/:id/status -> tenants.UpdateStatus")
|
||||
router.Patch("/super/v1/tenants/:id/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 -> users.Get")
|
||||
router.Get("/super/v1/users/:id"[len(r.Path()):], DataFunc1(
|
||||
r.users.Get,
|
||||
PathParam[int64]("id"),
|
||||
))
|
||||
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/roles -> users.UpdateRoles")
|
||||
router.Patch("/super/v1/users/:id/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/status -> users.UpdateStatus")
|
||||
router.Patch("/super/v1/users/:id/status"[len(r.Path()):], Func2(
|
||||
r.users.UpdateStatus,
|
||||
PathParam[int64]("id"),
|
||||
Body[dto.UserStatusUpdateForm]("form"),
|
||||
))
|
||||
|
||||
r.log.Info("Successfully registered all routes")
|
||||
}
|
||||
9
backend/app/http/super/v1/routes.manual.go
Normal file
9
backend/app/http/super/v1/routes.manual.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package v1
|
||||
|
||||
func (r *Routes) Path() string {
|
||||
return "/super/v1"
|
||||
}
|
||||
|
||||
func (r *Routes) Middlewares() []any {
|
||||
return nil
|
||||
}
|
||||
106
backend/app/http/super/v1/tenants.go
Normal file
106
backend/app/http/super/v1/tenants.go
Normal file
@@ -0,0 +1,106 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
dto "quyun/v2/app/http/super/v1/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type tenants struct{}
|
||||
|
||||
// List tenants
|
||||
//
|
||||
// @Router /super/v1/tenants [get]
|
||||
// @Summary List tenants
|
||||
// @Description List tenants
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page number"
|
||||
// @Param limit query int false "Page size"
|
||||
// @Param name query string false "Name"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.TenantItem}
|
||||
// @Bind filter query
|
||||
func (c *tenants) List(ctx fiber.Ctx, filter *dto.TenantListFilter) (*requests.Pager, error) {
|
||||
return services.Super.ListTenants(ctx.Context(), filter)
|
||||
}
|
||||
|
||||
// Create tenant
|
||||
//
|
||||
// @Router /super/v1/tenants [post]
|
||||
// @Summary Create tenant
|
||||
// @Description Create tenant
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.TenantCreateForm true "Create form"
|
||||
// @Success 200 {string} string "Created"
|
||||
// @Bind form body
|
||||
func (c *tenants) Create(ctx fiber.Ctx, form *dto.TenantCreateForm) error {
|
||||
return services.Super.CreateTenant(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// Get tenant
|
||||
//
|
||||
// @Router /super/v1/tenants/:id [get]
|
||||
// @Summary Get tenant
|
||||
// @Description Get tenant
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Tenant ID"
|
||||
// @Success 200 {object} dto.TenantItem
|
||||
// @Bind id path
|
||||
func (c *tenants) Get(ctx fiber.Ctx, id int64) (*dto.TenantItem, error) {
|
||||
return services.Super.GetTenant(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Update tenant status
|
||||
//
|
||||
// @Router /super/v1/tenants/:id/status [patch]
|
||||
// @Summary Update tenant status
|
||||
// @Description Update tenant status
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Tenant ID"
|
||||
// @Param form body dto.TenantStatusUpdateForm true "Update form"
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *tenants) UpdateStatus(ctx fiber.Ctx, id int64, form *dto.TenantStatusUpdateForm) error {
|
||||
return services.Super.UpdateTenantStatus(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Update tenant expire
|
||||
//
|
||||
// @Router /super/v1/tenants/:id [patch]
|
||||
// @Summary Update tenant expire
|
||||
// @Description Update tenant expire
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Tenant ID"
|
||||
// @Param form body dto.TenantExpireUpdateForm true "Update form"
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *tenants) UpdateExpire(ctx fiber.Ctx, id int64, form *dto.TenantExpireUpdateForm) error {
|
||||
return services.Super.UpdateTenantExpire(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Tenant statuses
|
||||
//
|
||||
// @Router /super/v1/tenants/statuses [get]
|
||||
// @Summary Tenant statuses
|
||||
// @Description Tenant statuses
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} requests.KV
|
||||
func (c *tenants) Statuses(ctx fiber.Ctx) ([]requests.KV, error) {
|
||||
return services.Super.TenantStatuses(ctx.Context())
|
||||
}
|
||||
104
backend/app/http/super/v1/users.go
Normal file
104
backend/app/http/super/v1/users.go
Normal file
@@ -0,0 +1,104 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
dto "quyun/v2/app/http/super/v1/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type users struct{}
|
||||
|
||||
// List users
|
||||
//
|
||||
// @Router /super/v1/users [get]
|
||||
// @Summary List users
|
||||
// @Description List users
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page number"
|
||||
// @Param limit query int false "Page size"
|
||||
// @Param username query string false "Username"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.UserItem}
|
||||
// @Bind filter query
|
||||
func (c *users) List(ctx fiber.Ctx, filter *dto.UserListFilter) (*requests.Pager, error) {
|
||||
return services.Super.ListUsers(ctx.Context(), filter)
|
||||
}
|
||||
|
||||
// Get user
|
||||
//
|
||||
// @Router /super/v1/users/:id [get]
|
||||
// @Summary Get user
|
||||
// @Description Get user
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "User ID"
|
||||
// @Success 200 {object} dto.UserItem
|
||||
// @Bind id path
|
||||
func (c *users) Get(ctx fiber.Ctx, id int64) (*dto.UserItem, error) {
|
||||
return services.Super.GetUser(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Update user status
|
||||
//
|
||||
// @Router /super/v1/users/:id/status [patch]
|
||||
// @Summary Update user status
|
||||
// @Description Update user status
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "User ID"
|
||||
// @Param form body dto.UserStatusUpdateForm true "Update form"
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *users) UpdateStatus(ctx fiber.Ctx, id int64, form *dto.UserStatusUpdateForm) error {
|
||||
return services.Super.UpdateUserStatus(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Update user roles
|
||||
//
|
||||
// @Router /super/v1/users/:id/roles [patch]
|
||||
// @Summary Update user roles
|
||||
// @Description Update user roles
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "User ID"
|
||||
// @Param form body dto.UserRolesUpdateForm true "Update form"
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *users) UpdateRoles(ctx fiber.Ctx, id int64, form *dto.UserRolesUpdateForm) error {
|
||||
return services.Super.UpdateUserRoles(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// User statistics
|
||||
//
|
||||
// @Router /super/v1/users/statistics [get]
|
||||
// @Summary User statistics
|
||||
// @Description User statistics
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.UserStatistics
|
||||
func (c *users) Statistics(ctx fiber.Ctx) ([]dto.UserStatistics, error) {
|
||||
return services.Super.UserStatistics(ctx.Context())
|
||||
}
|
||||
|
||||
// User statuses
|
||||
//
|
||||
// @Router /super/v1/users/statuses [get]
|
||||
// @Summary User statuses
|
||||
// @Description User statuses
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} requests.KV
|
||||
func (c *users) Statuses(ctx fiber.Ctx) ([]requests.KV, error) {
|
||||
return services.Super.UserStatuses(ctx.Context())
|
||||
}
|
||||
@@ -44,7 +44,6 @@ func Provide(opts ...opt.Option) error {
|
||||
content *Content,
|
||||
creator *Creator,
|
||||
middlewares *middlewares.Middlewares,
|
||||
super *Super,
|
||||
tenant *Tenant,
|
||||
transaction *Transaction,
|
||||
user *User,
|
||||
@@ -55,7 +54,6 @@ func Provide(opts ...opt.Option) error {
|
||||
content: content,
|
||||
creator: creator,
|
||||
middlewares: middlewares,
|
||||
super: super,
|
||||
tenant: tenant,
|
||||
transaction: transaction,
|
||||
user: user,
|
||||
@@ -68,13 +66,6 @@ func Provide(opts ...opt.Option) error {
|
||||
}, atom.GroupRoutes); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*Super, error) {
|
||||
obj := &Super{}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*Tenant, error) {
|
||||
obj := &Tenant{}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ type Routes struct {
|
||||
common *Common
|
||||
content *Content
|
||||
creator *Creator
|
||||
super *Super
|
||||
tenant *Tenant
|
||||
transaction *Transaction
|
||||
user *User
|
||||
@@ -169,109 +168,6 @@ func (r *Routes) Register(router fiber.Router) {
|
||||
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()):], DataFunc1(
|
||||
r.super.ListContents,
|
||||
Query[dto.SuperContentListFilter]("filter"),
|
||||
))
|
||||
r.log.Debugf("Registering route: Get /v1/orders -> super.ListOrders")
|
||||
router.Get("/v1/orders"[len(r.Path()):], DataFunc1(
|
||||
r.super.ListOrders,
|
||||
Query[dto.SuperOrderListFilter]("filter"),
|
||||
))
|
||||
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()):], DataFunc1(
|
||||
r.super.ListTenants,
|
||||
Query[dto.TenantListFilter]("filter"),
|
||||
))
|
||||
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()):], DataFunc1(
|
||||
r.super.ListUsers,
|
||||
Query[dto.UserListFilter]("filter"),
|
||||
))
|
||||
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(
|
||||
|
||||
@@ -1,322 +0,0 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"quyun/v2/app/http/v1/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
|
||||
// @provider
|
||||
type Super struct{}
|
||||
|
||||
// Login
|
||||
//
|
||||
// @Router /v1/auth/login [post]
|
||||
// @Summary Login
|
||||
// @Description Login
|
||||
// @Tags Auth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.LoginForm true "Login form"
|
||||
// @Success 200 {object} dto.LoginResponse
|
||||
// @Bind form body
|
||||
func (c *Super) Login(ctx fiber.Ctx, form *dto.LoginForm) (*dto.LoginResponse, error) {
|
||||
return services.Super.Login(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// Check Token
|
||||
//
|
||||
// @Router /v1/auth/token [get]
|
||||
// @Summary Check token
|
||||
// @Description Check token
|
||||
// @Tags Auth
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.LoginResponse
|
||||
func (c *Super) CheckToken(ctx fiber.Ctx) (*dto.LoginResponse, error) {
|
||||
return services.Super.CheckToken(ctx.Context())
|
||||
}
|
||||
|
||||
// List users
|
||||
//
|
||||
// @Router /v1/users [get]
|
||||
// @Summary List users
|
||||
// @Description List users
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page number"
|
||||
// @Param limit query int false "Page size"
|
||||
// @Param username query string false "Username"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.UserItem}
|
||||
// @Bind filter query
|
||||
func (c *Super) ListUsers(ctx fiber.Ctx, filter *dto.UserListFilter) (*requests.Pager, error) {
|
||||
return services.Super.ListUsers(ctx.Context(), filter)
|
||||
}
|
||||
|
||||
// Get user
|
||||
//
|
||||
// @Router /v1/users/:id [get]
|
||||
// @Summary Get user
|
||||
// @Description Get user
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "User ID"
|
||||
// @Success 200 {object} dto.UserItem
|
||||
// @Bind id path
|
||||
func (c *Super) GetUser(ctx fiber.Ctx, id int64) (*dto.UserItem, error) {
|
||||
return services.Super.GetUser(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Update user status
|
||||
//
|
||||
// @Router /v1/users/:id/status [patch]
|
||||
// @Summary Update user status
|
||||
// @Description Update user status
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "User ID"
|
||||
// @Param form body dto.UserStatusUpdateForm true "Update form"
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *Super) UpdateUserStatus(ctx fiber.Ctx, id int64, form *dto.UserStatusUpdateForm) error {
|
||||
return services.Super.UpdateUserStatus(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Update user roles
|
||||
//
|
||||
// @Router /v1/users/:id/roles [patch]
|
||||
// @Summary Update user roles
|
||||
// @Description Update user roles
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "User ID"
|
||||
// @Param form body dto.UserRolesUpdateForm true "Update form"
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *Super) UpdateUserRoles(ctx fiber.Ctx, id int64, form *dto.UserRolesUpdateForm) error {
|
||||
return services.Super.UpdateUserRoles(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// List tenants
|
||||
//
|
||||
// @Router /v1/tenants [get]
|
||||
// @Summary List tenants
|
||||
// @Description List tenants
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page number"
|
||||
// @Param limit query int false "Page size"
|
||||
// @Param name query string false "Name"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.TenantItem}
|
||||
// @Bind filter query
|
||||
func (c *Super) ListTenants(ctx fiber.Ctx, filter *dto.TenantListFilter) (*requests.Pager, error) {
|
||||
return services.Super.ListTenants(ctx.Context(), filter)
|
||||
}
|
||||
|
||||
// Create tenant
|
||||
//
|
||||
// @Router /v1/tenants [post]
|
||||
// @Summary Create tenant
|
||||
// @Description Create tenant
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.TenantCreateForm true "Create form"
|
||||
// @Success 200 {string} string "Created"
|
||||
// @Bind form body
|
||||
func (c *Super) CreateTenant(ctx fiber.Ctx, form *dto.TenantCreateForm) error {
|
||||
return services.Super.CreateTenant(ctx.Context(), form)
|
||||
}
|
||||
|
||||
// Get tenant
|
||||
//
|
||||
// @Router /v1/tenants/:id [get]
|
||||
// @Summary Get tenant
|
||||
// @Description Get tenant
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Tenant ID"
|
||||
// @Success 200 {object} dto.TenantItem
|
||||
// @Bind id path
|
||||
func (c *Super) GetTenant(ctx fiber.Ctx, id int64) (*dto.TenantItem, error) {
|
||||
return services.Super.GetTenant(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Update tenant status
|
||||
//
|
||||
// @Router /v1/tenants/:id/status [patch]
|
||||
// @Summary Update tenant status
|
||||
// @Description Update tenant status
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Tenant ID"
|
||||
// @Param form body dto.TenantStatusUpdateForm true "Update form"
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *Super) UpdateTenantStatus(ctx fiber.Ctx, id int64, form *dto.TenantStatusUpdateForm) error {
|
||||
return services.Super.UpdateTenantStatus(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Update tenant expire
|
||||
//
|
||||
// @Router /v1/tenants/:id [patch]
|
||||
// @Summary Update tenant expire
|
||||
// @Description Update tenant expire
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Tenant ID"
|
||||
// @Param form body dto.TenantExpireUpdateForm true "Update form"
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *Super) UpdateTenantExpire(ctx fiber.Ctx, id int64, form *dto.TenantExpireUpdateForm) error {
|
||||
return services.Super.UpdateTenantExpire(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// List contents
|
||||
//
|
||||
// @Router /v1/contents [get]
|
||||
// @Summary List contents
|
||||
// @Description List contents
|
||||
// @Tags Content
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page number"
|
||||
// @Param limit query int false "Page size"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.AdminContentItem}
|
||||
// @Bind filter query
|
||||
func (c *Super) ListContents(ctx fiber.Ctx, filter *dto.SuperContentListFilter) (*requests.Pager, error) {
|
||||
return services.Super.ListContents(ctx.Context(), filter)
|
||||
}
|
||||
|
||||
// Update content status
|
||||
//
|
||||
// @Router /v1/tenants/:tenantID/contents/:contentID/status [patch]
|
||||
// @Summary Update content status
|
||||
// @Description Update content status
|
||||
// @Tags Content
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "Tenant ID"
|
||||
// @Param contentID path int64 true "Content ID"
|
||||
// @Param form body dto.SuperTenantContentStatusUpdateForm true "Update form"
|
||||
// @Success 200 {string} string "Updated"
|
||||
// @Bind tenantID path
|
||||
// @Bind contentID path
|
||||
// @Bind form body
|
||||
func (c *Super) UpdateContentStatus(ctx fiber.Ctx, tenantID, contentID int64, form *dto.SuperTenantContentStatusUpdateForm) error {
|
||||
return services.Super.UpdateContentStatus(ctx.Context(), tenantID, contentID, form)
|
||||
}
|
||||
|
||||
// List orders
|
||||
//
|
||||
// @Router /v1/orders [get]
|
||||
// @Summary List orders
|
||||
// @Description List orders
|
||||
// @Tags Order
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page number"
|
||||
// @Param limit query int false "Page size"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.SuperOrderItem}
|
||||
// @Bind filter query
|
||||
func (c *Super) ListOrders(ctx fiber.Ctx, filter *dto.SuperOrderListFilter) (*requests.Pager, error) {
|
||||
return services.Super.ListOrders(ctx.Context(), filter)
|
||||
}
|
||||
|
||||
// Get order
|
||||
//
|
||||
// @Router /v1/orders/:id [get]
|
||||
// @Summary Get order
|
||||
// @Description Get order
|
||||
// @Tags Order
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Order ID"
|
||||
// @Success 200 {object} dto.SuperOrderDetail
|
||||
// @Bind id path
|
||||
func (c *Super) GetOrder(ctx fiber.Ctx, id int64) (*dto.SuperOrderDetail, error) {
|
||||
return services.Super.GetOrder(ctx.Context(), id)
|
||||
}
|
||||
|
||||
// Refund order
|
||||
//
|
||||
// @Router /v1/orders/:id/refund [post]
|
||||
// @Summary Refund order
|
||||
// @Description Refund order
|
||||
// @Tags Order
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "Order ID"
|
||||
// @Param form body dto.SuperOrderRefundForm true "Refund form"
|
||||
// @Success 200 {string} string "Refunded"
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (c *Super) RefundOrder(ctx fiber.Ctx, id int64, form *dto.SuperOrderRefundForm) error {
|
||||
return services.Super.RefundOrder(ctx.Context(), id, form)
|
||||
}
|
||||
|
||||
// Order statistics
|
||||
//
|
||||
// @Router /v1/orders/statistics [get]
|
||||
// @Summary Order statistics
|
||||
// @Description Order statistics
|
||||
// @Tags Order
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.OrderStatisticsResponse
|
||||
func (c *Super) OrderStatistics(ctx fiber.Ctx) (*dto.OrderStatisticsResponse, error) {
|
||||
return services.Super.OrderStatistics(ctx.Context())
|
||||
}
|
||||
|
||||
// User statistics
|
||||
//
|
||||
// @Router /v1/users/statistics [get]
|
||||
// @Summary User statistics
|
||||
// @Description User statistics
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.UserStatistics
|
||||
func (c *Super) UserStatistics(ctx fiber.Ctx) ([]dto.UserStatistics, error) {
|
||||
return services.Super.UserStatistics(ctx.Context())
|
||||
}
|
||||
|
||||
// User statuses
|
||||
//
|
||||
// @Router /v1/users/statuses [get]
|
||||
// @Summary User statuses
|
||||
// @Description User statuses
|
||||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} requests.KV
|
||||
func (c *Super) UserStatuses(ctx fiber.Ctx) ([]requests.KV, error) {
|
||||
return services.Super.UserStatuses(ctx.Context())
|
||||
}
|
||||
|
||||
// Tenant statuses
|
||||
//
|
||||
// @Router /v1/tenants/statuses [get]
|
||||
// @Summary Tenant statuses
|
||||
// @Description Tenant statuses
|
||||
// @Tags Tenant
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} requests.KV
|
||||
func (c *Super) TenantStatuses(ctx fiber.Ctx) ([]requests.KV, error) {
|
||||
return services.Super.TenantStatuses(ctx.Context())
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/errorx"
|
||||
super_dto "quyun/v2/app/http/v1/dto"
|
||||
super_dto "quyun/v2/app/http/super/v1/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"quyun/v2/app/commands/testx"
|
||||
super_dto "quyun/v2/app/http/v1/dto"
|
||||
super_dto "quyun/v2/app/http/super/v1/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/database"
|
||||
"quyun/v2/database/models"
|
||||
@@ -54,7 +54,7 @@ func (s *SuperTestSuite) Test_ListUsers() {
|
||||
res, err := Super.ListUsers(ctx, filter)
|
||||
So(err, ShouldBeNil)
|
||||
So(res.Total, ShouldEqual, 2)
|
||||
|
||||
|
||||
items := res.Items.([]super_dto.UserItem)
|
||||
So(items[0].Username, ShouldEqual, "user2") // Desc order
|
||||
})
|
||||
@@ -97,4 +97,4 @@ func (s *SuperTestSuite) Test_CreateTenant() {
|
||||
So(t.Status, ShouldEqual, consts.TenantStatusVerified)
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user