feat: enhance tenant management with status description and improved UI components

This commit is contained in:
2025-12-16 23:25:46 +08:00
parent 2a12e1c3a9
commit e8b2699104
11 changed files with 320 additions and 98 deletions

View File

@@ -18,8 +18,9 @@ type TenantFilter struct {
type TenantItem struct {
*models.Tenant
UserCount int64
UserBalance int64
UserCount int64 `json:"user_count"`
UserBalance int64 `json:"user_balance"`
StatusDescription string `json:"status_description"`
}
type TenantExpireUpdateForm struct {

View File

@@ -1,6 +1,9 @@
package super
import (
"os"
"path/filepath"
"github.com/gofiber/fiber/v3"
)
@@ -12,9 +15,14 @@ type staticController struct{}
// @Tags Super
// @Router /super/*
func (ctl *staticController) static(ctx fiber.Ctx) error {
root := "/home/rogee/Projects/quyun_v2/frontend/superadmin/dist/"
param := ctx.Params("*")
if param == "" {
param = "index.html"
file := filepath.Join(root, param)
// if file not exits use index.html
if _, err := os.Stat(file); os.IsNotExist(err) {
file = filepath.Join(root, "index.html")
}
return ctx.SendFile("/home/rogee/Projects/quyun_v2/frontend/superadmin/dist/" + param)
return ctx.SendFile(file)
}

View File

@@ -102,9 +102,10 @@ func (t *tenant) Pager(ctx context.Context, filter *dto.TenantFilter) (*requests
items := lo.Map(mm, func(model *models.Tenant, _ int) *dto.TenantItem {
return &dto.TenantItem{
Tenant: model,
UserCount: lo.ValueOr(userCountMapping, model.ID, 0),
UserBalance: lo.ValueOr(userBalanceMapping, model.ID, 0),
Tenant: model,
UserCount: lo.ValueOr(userCountMapping, model.ID, 0),
UserBalance: lo.ValueOr(userBalanceMapping, model.ID, 0),
StatusDescription: model.Status.Description(),
}
})

View File

@@ -21,6 +21,20 @@ type UserStatus string
// ENUM( pending_verify, verified, banned )
type TenantStatus string
// Description in chinese
func (t TenantStatus) Description() string {
switch t {
case "pending_verify":
return "待审核"
case "verified":
return "已审核"
case "banned":
return "已封禁"
default:
return "未知状态"
}
}
// swagger:enum TenantUserRole
// ENUM( member, tenant_admin)
type TenantUserRole string