MCPcopy Index your code
hub / github.com/cloudreve/cloudreve / ListUsers

Method ListUsers

inventory/user.go:448–483  ·  view source on GitHub ↗
(ctx context.Context, args *ListUserParameters)

Source from the content-addressed store, hash-verified

446}
447
448func (c *userClient) ListUsers(ctx context.Context, args *ListUserParameters) (*ListUserResult, error) {
449 query := c.client.User.Query()
450 if args.GroupID != 0 {
451 query = query.Where(user.GroupUsers(args.GroupID))
452 }
453 if args.Status != "" {
454 query = query.Where(user.StatusEQ(args.Status))
455 }
456 if args.Nick != "" {
457 query = query.Where(user.NickContainsFold(args.Nick))
458 }
459 if args.Email != "" {
460 query = query.Where(user.EmailContainsFold(args.Email))
461 }
462 query.Order(getUserOrderOption(args)...)
463
464 // Count total items
465 total, err := query.Clone().Count(ctx)
466 if err != nil {
467 return nil, err
468 }
469
470 users, err := withUserEagerLoading(ctx, query).Limit(args.PageSize).Offset(args.Page * args.PageSize).All(ctx)
471 if err != nil {
472 return nil, err
473 }
474
475 return &ListUserResult{
476 PaginationResults: &PaginationResults{
477 TotalItems: total,
478 Page: args.Page,
479 PageSize: args.PageSize,
480 },
481 Users: users,
482 }, nil
483}
484
485func (c *userClient) Upsert(ctx context.Context, u *ent.User, password, twoFa string) (*ent.User, error) {
486 if u.ID == 0 {

Callers

nothing calls this directly

Calls 14

GroupUsersFunction · 0.92
StatusEQFunction · 0.92
NickContainsFoldFunction · 0.92
EmailContainsFoldFunction · 0.92
getUserOrderOptionFunction · 0.85
withUserEagerLoadingFunction · 0.85
OrderMethod · 0.65
CountMethod · 0.65
OffsetMethod · 0.65
LimitMethod · 0.65
QueryMethod · 0.45
WhereMethod · 0.45

Tested by

no test coverage detected