(ctx context.Context, args *ListUserParameters)
| 446 | } |
| 447 | |
| 448 | func (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 | |
| 485 | func (c *userClient) Upsert(ctx context.Context, u *ent.User, password, twoFa string) (*ent.User, error) { |
| 486 | if u.ID == 0 { |
nothing calls this directly
no test coverage detected