From e8b26991047182cf4a9962af6ccbc5458444a67f Mon Sep 17 00:00:00 2001 From: Rogee Date: Tue, 16 Dec 2025 23:25:46 +0800 Subject: [PATCH] feat: enhance tenant management with status description and improved UI components --- backend/app/http/super/dto/tenant.go | 5 +- backend/app/http/super/static.go | 14 +- backend/app/services/tenant.go | 7 +- backend/pkg/consts/consts.go | 14 ++ frontend/superadmin/dist/index.html | 4 +- frontend/superadmin/src/App.vue | 43 +++- frontend/superadmin/src/auth.ts | 12 + frontend/superadmin/src/main.ts | 4 + frontend/superadmin/src/router.ts | 4 +- frontend/superadmin/src/views/LoginPage.vue | 82 +++++-- frontend/superadmin/src/views/TenantsPage.vue | 229 ++++++++++++++---- 11 files changed, 320 insertions(+), 98 deletions(-) diff --git a/backend/app/http/super/dto/tenant.go b/backend/app/http/super/dto/tenant.go index 295c4d9..40b4f39 100644 --- a/backend/app/http/super/dto/tenant.go +++ b/backend/app/http/super/dto/tenant.go @@ -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 { diff --git a/backend/app/http/super/static.go b/backend/app/http/super/static.go index 7bb6011..a0db12b 100644 --- a/backend/app/http/super/static.go +++ b/backend/app/http/super/static.go @@ -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) } diff --git a/backend/app/services/tenant.go b/backend/app/services/tenant.go index 030dc93..28e5788 100644 --- a/backend/app/services/tenant.go +++ b/backend/app/services/tenant.go @@ -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(), } }) diff --git a/backend/pkg/consts/consts.go b/backend/pkg/consts/consts.go index 3308f4f..5398dfb 100644 --- a/backend/pkg/consts/consts.go +++ b/backend/pkg/consts/consts.go @@ -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 diff --git a/frontend/superadmin/dist/index.html b/frontend/superadmin/dist/index.html index 98d8d8a..58bfb6b 100644 --- a/frontend/superadmin/dist/index.html +++ b/frontend/superadmin/dist/index.html @@ -4,8 +4,8 @@ QuyUn Super Admin - - + +
diff --git a/frontend/superadmin/src/App.vue b/frontend/superadmin/src/App.vue index 6fcd9cc..b0f5b10 100644 --- a/frontend/superadmin/src/App.vue +++ b/frontend/superadmin/src/App.vue @@ -1,20 +1,31 @@