后台用户列表此前仅分页,数据量大时无法定位用户。 - 后端:List 新增 ListQuery(关键词 + 状态),抽出 applyUserFilter 对总数与列表查询统一加筛选;关键词为纯数字时同时按用户 ID 精确匹配, 否则按手机号/昵称模糊匹配 - 前端:AdminUsersView 新增筛选栏(关键词:手机号/昵称/用户ID, 状态:正常/已冻结/已禁用),回车/清空/选择即查,查询重置到第 1 页 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
57 lines
1.4 KiB
Go
57 lines
1.4 KiB
Go
package adminuser
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
)
|
|
|
|
var (
|
|
ErrDependencyUnavailable = errors.New("dependency unavailable")
|
|
ErrInvalidUser = errors.New("invalid user")
|
|
)
|
|
|
|
type Service struct {
|
|
repo *Repository
|
|
}
|
|
|
|
func NewService(repo *Repository) *Service {
|
|
return &Service{repo: repo}
|
|
}
|
|
|
|
func (s *Service) List(ctx context.Context, page, pageSize int, query ListQuery) (*PaginatedResult, error) {
|
|
if s.repo == nil {
|
|
return nil, ErrDependencyUnavailable
|
|
}
|
|
return s.repo.List(ctx, page, pageSize, query)
|
|
}
|
|
|
|
func (s *Service) Freeze(ctx context.Context, adminID uint64, userID uint64, req FreezeRequest, meta AuditMeta) (*UserDTO, error) {
|
|
if s.repo == nil {
|
|
return nil, ErrDependencyUnavailable
|
|
}
|
|
if userID == 0 {
|
|
return nil, ErrInvalidUser
|
|
}
|
|
return s.repo.Freeze(ctx, adminID, userID, req, meta)
|
|
}
|
|
|
|
func (s *Service) Unfreeze(ctx context.Context, adminID uint64, userID uint64, meta AuditMeta) (*UserDTO, error) {
|
|
if s.repo == nil {
|
|
return nil, ErrDependencyUnavailable
|
|
}
|
|
if userID == 0 {
|
|
return nil, ErrInvalidUser
|
|
}
|
|
return s.repo.Unfreeze(ctx, adminID, userID, meta)
|
|
}
|
|
|
|
func (s *Service) SetDepositFreeQuota(ctx context.Context, adminID uint64, userID uint64, req DepositFreeQuotaRequest, meta AuditMeta) (*UserDTO, error) {
|
|
if s.repo == nil {
|
|
return nil, ErrDependencyUnavailable
|
|
}
|
|
if userID == 0 || req.AmountCent < 0 {
|
|
return nil, ErrInvalidUser
|
|
}
|
|
return s.repo.SetDepositFreeQuota(ctx, adminID, userID, req, meta)
|
|
}
|