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

@@ -41,6 +41,42 @@ func (t *user) FindByUsername(ctx context.Context, username string) (*models.Use
return model, nil
}
// Detail 查询用户详情(超级管理员侧,返回脱敏后的 DTO
func (t *user) Detail(ctx context.Context, userID int64) (*dto.UserItem, error) {
if userID <= 0 {
return nil, errors.New("user_id must be > 0")
}
model, err := t.FindByID(ctx, userID)
if err != nil {
return nil, err
}
ownedTenantCounts, err := t.UserOwnedTenantCountMapping(ctx, []int64{model.ID})
if err != nil {
return nil, err
}
joinedTenantCounts, err := t.UserJoinedTenantCountMapping(ctx, []int64{model.ID})
if err != nil {
return nil, err
}
return &dto.UserItem{
ID: model.ID,
Username: model.Username,
Roles: model.Roles,
Status: model.Status,
StatusDescription: model.Status.Description(),
Balance: model.Balance,
BalanceFrozen: model.BalanceFrozen,
VerifiedAt: model.VerifiedAt,
CreatedAt: model.CreatedAt,
UpdatedAt: model.UpdatedAt,
OwnedTenantCount: ownedTenantCounts[model.ID],
JoinedTenantCount: joinedTenantCounts[model.ID],
}, nil
}
func (t *user) Create(ctx context.Context, user *models.User) (*models.User, error) {
if err := user.Create(ctx); err != nil {
return nil, errors.Wrapf(err, "Create user failed, %s", user.Username)