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:
2025-12-29 17:17:07 +08:00
parent bdf20fb0c6
commit 33e1921e17
18 changed files with 665 additions and 443 deletions

View 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())
}