323 lines
8.9 KiB
Go
323 lines
8.9 KiB
Go
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())
|
|
}
|