search.go 490 B

123456789101112131415161718192021222324
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/account/model"
  5. "github.com/pkg/errors"
  6. )
  7. // MidsByName is.
  8. func (d *Dao) MidsByName(ctx context.Context, names []string) ([]int64, error) {
  9. r := d.es.NewRequest("member_user").
  10. Fields("mid").
  11. Index("user_base").
  12. WhereIn("kwname", names).
  13. Ps(len(names)).
  14. Pn(1)
  15. result := &model.SearchMemberResult{}
  16. if err := r.Scan(ctx, &result); err != nil {
  17. return nil, errors.WithStack(err)
  18. }
  19. return result.Mids(), nil
  20. }