feat: 添加用户租户管理功能,优化用户列表和租户信息展示,增强查询过滤条件
This commit is contained in:
@@ -1,24 +1,57 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen/types"
|
||||
)
|
||||
|
||||
type UserPageFilter struct {
|
||||
requests.Pagination
|
||||
requests.SortQueryFilter
|
||||
requests.Pagination `json:",inline" query:",inline"`
|
||||
requests.SortQueryFilter `json:",inline" query:",inline"`
|
||||
|
||||
Username *string `query:"username"`
|
||||
Status *consts.UserStatus `query:"status"`
|
||||
TenantID *int64 `query:"tenant_id"`
|
||||
ID *int64 `json:"id,omitempty" query:"id"`
|
||||
Username *string `json:"username,omitempty" query:"username"`
|
||||
Status *consts.UserStatus `json:"status,omitempty" query:"status"`
|
||||
|
||||
// TenantID filters users by membership in the given tenant.
|
||||
TenantID *int64 `json:"tenant_id,omitempty" query:"tenant_id"`
|
||||
|
||||
// Role filters users containing a role (user/super_admin).
|
||||
Role *consts.Role `json:"role,omitempty" query:"role"`
|
||||
|
||||
CreatedAtFrom *time.Time `json:"created_at_from,omitempty" query:"created_at_from"`
|
||||
CreatedAtTo *time.Time `json:"created_at_to,omitempty" query:"created_at_to"`
|
||||
VerifiedAtFrom *time.Time `json:"verified_at_from,omitempty" query:"verified_at_from"`
|
||||
VerifiedAtTo *time.Time `json:"verified_at_to,omitempty" query:"verified_at_to"`
|
||||
}
|
||||
|
||||
func (f *UserPageFilter) UsernameTrimmed() string {
|
||||
if f == nil || f.Username == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.Username)
|
||||
}
|
||||
|
||||
type UserItem struct {
|
||||
*models.User
|
||||
ID int64 `json:"id"`
|
||||
Username string `json:"username"`
|
||||
Roles types.Array[consts.Role] `json:"roles"`
|
||||
Status consts.UserStatus `json:"status"`
|
||||
StatusDescription string `json:"status_description,omitempty"`
|
||||
|
||||
StatusDescription string `json:"status_description,omitempty"`
|
||||
Balance int64 `json:"balance"`
|
||||
BalanceFrozen int64 `json:"balance_frozen"`
|
||||
VerifiedAt time.Time `json:"verified_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
|
||||
OwnedTenantCount int64 `json:"owned_tenant_count"`
|
||||
JoinedTenantCount int64 `json:"joined_tenant_count"`
|
||||
}
|
||||
|
||||
type UserStatusUpdateForm struct {
|
||||
|
||||
60
backend/app/http/super/dto/user_tenant.go
Normal file
60
backend/app/http/super/dto/user_tenant.go
Normal file
@@ -0,0 +1,60 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/pkg/consts"
|
||||
|
||||
"go.ipao.vip/gen/types"
|
||||
)
|
||||
|
||||
type UserTenantPageFilter struct {
|
||||
requests.Pagination `json:",inline" query:",inline"`
|
||||
|
||||
TenantID *int64 `json:"tenant_id,omitempty" query:"tenant_id"`
|
||||
Code *string `json:"code,omitempty" query:"code"`
|
||||
Name *string `json:"name,omitempty" query:"name"`
|
||||
|
||||
// Role filters tenant_users.role containing a role (tenant_admin/member).
|
||||
Role *consts.TenantUserRole `json:"role,omitempty" query:"role"`
|
||||
// Status filters tenant_users.status.
|
||||
Status *consts.UserStatus `json:"status,omitempty" query:"status"`
|
||||
|
||||
CreatedAtFrom *time.Time `json:"created_at_from,omitempty" query:"created_at_from"`
|
||||
CreatedAtTo *time.Time `json:"created_at_to,omitempty" query:"created_at_to"`
|
||||
}
|
||||
|
||||
func (f *UserTenantPageFilter) CodeTrimmed() string {
|
||||
if f == nil || f.Code == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.ToLower(strings.TrimSpace(*f.Code))
|
||||
}
|
||||
|
||||
func (f *UserTenantPageFilter) NameTrimmed() string {
|
||||
if f == nil || f.Name == nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(*f.Name)
|
||||
}
|
||||
|
||||
type UserTenantItem struct {
|
||||
TenantID int64 `json:"tenant_id"`
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
|
||||
TenantStatus consts.TenantStatus `json:"tenant_status"`
|
||||
TenantStatusDescription string `json:"tenant_status_description,omitempty"`
|
||||
ExpiredAt time.Time `json:"expired_at"`
|
||||
|
||||
Owner *TenantOwnerUserLite `json:"owner,omitempty"`
|
||||
|
||||
Role types.Array[consts.TenantUserRole] `json:"role"`
|
||||
|
||||
MemberStatus consts.UserStatus `json:"member_status"`
|
||||
MemberStatusDescription string `json:"member_status_description,omitempty"`
|
||||
|
||||
JoinedAt time.Time `json:"joined_at"`
|
||||
}
|
||||
Reference in New Issue
Block a user