50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package super
|
|
|
|
import (
|
|
"quyun/v2/app/errorx"
|
|
"quyun/v2/app/http/super/dto"
|
|
"quyun/v2/app/requests"
|
|
"quyun/v2/app/services"
|
|
|
|
"github.com/gofiber/fiber/v3"
|
|
)
|
|
|
|
// @provider
|
|
type tenant struct{}
|
|
|
|
// list
|
|
//
|
|
// @Summary 租户列表
|
|
// @Tags Super
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param filter query dto.TenantFilter true "Filter"
|
|
// @Success 200 {object} requests.Pager{items=dto.TenantItem}
|
|
//
|
|
// @Router /super/v1/tenants [get]
|
|
// @Bind filter query
|
|
func (*tenant) list(ctx fiber.Ctx, filter *dto.TenantFilter) (*requests.Pager, error) {
|
|
return services.Tenant.Pager(ctx, filter)
|
|
}
|
|
|
|
// updateExpire
|
|
//
|
|
// @Summary 更新过期时间
|
|
// @Tags Super
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param tenantID path int64 true "TenantID"
|
|
// @Param form body dto.TenantExpireUpdateForm true "Form"
|
|
//
|
|
// @Router /super/v1/tenants/:tenantID [patch]
|
|
// @Bind tenantID path
|
|
// @Bind form body
|
|
func (*tenant) updateExpire(ctx fiber.Ctx, tenantID int64, form *dto.TenantExpireUpdateForm) error {
|
|
duration, err := form.ParseDuration()
|
|
if err != nil {
|
|
return errorx.Wrap(err).WithMsg("时间解析出错")
|
|
}
|
|
|
|
return services.Tenant.AddExpireDuration(ctx, tenantID, duration)
|
|
}
|