feat: implement new structure
This commit is contained in:
308
backend/app/http/v1/super.go
Normal file
308
backend/app/http/v1/super.go
Normal file
@@ -0,0 +1,308 @@
|
||||
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
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.LoginForm true "Login form"
|
||||
// @Success 200 {object} dto.LoginResponse
|
||||
// @Bind form body
|
||||
func (s *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
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.LoginResponse
|
||||
func (s *Super) CheckToken(ctx fiber.Ctx) (*dto.LoginResponse, error) {
|
||||
return services.Super.CheckToken(ctx.Context())
|
||||
}
|
||||
|
||||
// List Users
|
||||
//
|
||||
// @Router /v1/users [get]
|
||||
// @Summary User list
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Param username query string false "Username"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.UserItem}
|
||||
// @Bind page query
|
||||
// @Bind limit query
|
||||
// @Bind username query
|
||||
func (s *Super) ListUsers(ctx fiber.Ctx, page, limit int, username string) (*requests.Pager, error) {
|
||||
return services.Super.ListUsers(ctx.Context(), page, limit, username)
|
||||
}
|
||||
|
||||
// Get User
|
||||
//
|
||||
// @Router /v1/users/:id [get]
|
||||
// @Summary Get User
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Success 200 {object} dto.UserItem
|
||||
// @Bind id path
|
||||
func (s *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
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Param form body dto.UserStatusUpdateForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (s *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
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Param form body dto.UserRolesUpdateForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (s *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 Tenant list
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Param name query string false "Name"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.TenantItem}
|
||||
// @Bind page query
|
||||
// @Bind limit query
|
||||
// @Bind name query
|
||||
func (s *Super) ListTenants(ctx fiber.Ctx, page, limit int, name string) (*requests.Pager, error) {
|
||||
return services.Super.ListTenants(ctx.Context(), page, limit, name)
|
||||
}
|
||||
|
||||
// Create Tenant
|
||||
//
|
||||
// @Router /v1/tenants [post]
|
||||
// @Summary Create Tenant
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param form body dto.TenantCreateForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind form body
|
||||
func (s *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
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Success 200 {object} dto.TenantItem
|
||||
// @Bind id path
|
||||
func (s *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
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Param form body dto.TenantStatusUpdateForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (s *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
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Param form body dto.TenantExpireUpdateForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (s *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 Content list
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.SuperTenantContentItem}
|
||||
// @Bind page query
|
||||
// @Bind limit query
|
||||
func (s *Super) ListContents(ctx fiber.Ctx, page, limit int) (*requests.Pager, error) {
|
||||
return services.Super.ListContents(ctx.Context(), page, limit)
|
||||
}
|
||||
|
||||
// Update Content Status
|
||||
//
|
||||
// @Router /v1/tenants/:tenantID/contents/:contentID/status [patch]
|
||||
// @Summary Update Content Status
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param tenantID path int64 true "TenantID"
|
||||
// @Param contentID path int64 true "ContentID"
|
||||
// @Param form body dto.SuperTenantContentStatusUpdateForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind tenantID path
|
||||
// @Bind contentID path
|
||||
// @Bind form body
|
||||
func (s *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 Order list
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param page query int false "Page"
|
||||
// @Param limit query int false "Limit"
|
||||
// @Success 200 {object} requests.Pager{items=[]dto.SuperOrderItem}
|
||||
// @Bind page query
|
||||
// @Bind limit query
|
||||
func (s *Super) ListOrders(ctx fiber.Ctx, page, limit int) (*requests.Pager, error) {
|
||||
return services.Super.ListOrders(ctx.Context(), page, limit)
|
||||
}
|
||||
|
||||
// Get Order
|
||||
//
|
||||
// @Router /v1/orders/:id [get]
|
||||
// @Summary Get Order
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Success 200 {object} dto.SuperOrderDetail
|
||||
// @Bind id path
|
||||
func (s *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
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path int64 true "ID"
|
||||
// @Param form body dto.SuperOrderRefundForm true "Form"
|
||||
// @Success 200
|
||||
// @Bind id path
|
||||
// @Bind form body
|
||||
func (s *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
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {object} dto.OrderStatisticsResponse
|
||||
func (s *Super) OrderStatistics(ctx fiber.Ctx) (*dto.OrderStatisticsResponse, error) {
|
||||
return services.Super.OrderStatistics(ctx.Context())
|
||||
}
|
||||
|
||||
// User Statistics
|
||||
//
|
||||
// @Router /v1/users/statistics [get]
|
||||
// @Summary User Statistics
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} dto.UserStatistics
|
||||
func (s *Super) UserStatistics(ctx fiber.Ctx) ([]dto.UserStatistics, error) {
|
||||
return services.Super.UserStatistics(ctx.Context())
|
||||
}
|
||||
|
||||
// User Statuses
|
||||
//
|
||||
// @Router /v1/users/statuses [get]
|
||||
// @Summary User Statuses Enum
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} requests.KV
|
||||
func (s *Super) UserStatuses(ctx fiber.Ctx) ([]requests.KV, error) {
|
||||
return services.Super.UserStatuses(ctx.Context())
|
||||
}
|
||||
|
||||
// Tenant Statuses
|
||||
//
|
||||
// @Router /v1/tenants/statuses [get]
|
||||
// @Summary Tenant Statuses Enum
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {array} requests.KV
|
||||
func (s *Super) TenantStatuses(ctx fiber.Ctx) ([]requests.KV, error) {
|
||||
return services.Super.TenantStatuses(ctx.Context())
|
||||
}
|
||||
Reference in New Issue
Block a user