feat: add TenantDetail and UserDetail views with comprehensive functionality

- Implemented TenantDetail.vue to display tenant information, manage tenant status, and handle tenant renewals.
- Added user management features in UserDetail.vue, including user status updates and role management.
- Integrated data loading for tenant users and orders in TenantDetail.vue.
- Included search and pagination functionalities for owned and joined tenants in UserDetail.vue.
- Enhanced user experience with toast notifications for success and error messages.
This commit is contained in:
2025-12-24 15:10:49 +08:00
parent 40776b78e2
commit 8fa321dbf6
18 changed files with 4106 additions and 190 deletions

View File

@@ -26,6 +26,49 @@ import (
// @provider
type tenant struct{}
// SuperDetail 查询单个租户详情(平台侧)。
func (t *tenant) SuperDetail(ctx context.Context, tenantID int64) (*superdto.TenantItem, error) {
if tenantID <= 0 {
return nil, errors.New("tenant_id must be > 0")
}
tbl, query := models.TenantQuery.QueryContext(ctx)
m, err := query.Where(tbl.ID.Eq(tenantID)).First()
if err != nil {
return nil, err
}
userCountMapping, err := t.TenantUserCountMapping(ctx, []int64{m.ID})
if err != nil {
return nil, err
}
incomeMapping, err := t.TenantIncomePaidMapping(ctx, []int64{m.ID})
if err != nil {
return nil, err
}
item := &superdto.TenantItem{
Tenant: m,
UserCount: lo.ValueOr(userCountMapping, m.ID, 0),
IncomeAmountPaidSum: lo.ValueOr(incomeMapping, m.ID, 0),
StatusDescription: m.Status.Description(),
}
ownerMapping, err := t.TenantOwnerUserMapping(ctx, []*models.Tenant{m})
if err != nil {
return nil, err
}
item.Owner = ownerMapping[m.ID]
adminMapping, err := t.TenantAdminUsersMapping(ctx, []int64{m.ID})
if err != nil {
return nil, err
}
item.AdminUsers = adminMapping[m.ID]
return item, nil
}
// SuperCreateTenant 超级管理员创建租户,并将指定用户设为租户管理员。
func (t *tenant) SuperCreateTenant(ctx context.Context, form *superdto.TenantCreateForm) (*models.Tenant, error) {
if form == nil {