107 lines
2.8 KiB
Go
107 lines
2.8 KiB
Go
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, 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, 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, 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, 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, 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)
|
|
}
|