up.go 731 B

123456789101112131415161718192021222324252627282930313233
  1. package manager
  2. import (
  3. "context"
  4. "github.com/pkg/errors"
  5. "go-common/app/admin/main/videoup/model/manager"
  6. "go-common/library/log"
  7. "net/url"
  8. )
  9. const (
  10. _upGroupURI = "/x/internal/uper/group/get"
  11. )
  12. // UpGroups get all up groups
  13. func (d *Dao) UpGroups(c context.Context) (groups map[int64]*manager.UpGroup, err error) {
  14. groups = make(map[int64]*manager.UpGroup)
  15. params := url.Values{}
  16. params.Set("state", "1")
  17. var res *manager.UpGroupData
  18. if err = d.httpClient.Get(c, d.c.Host.API+_upGroupURI, "", params, &res); err != nil {
  19. log.Error("d.UpGroups() error(%v)", err)
  20. return
  21. }
  22. if res == nil {
  23. err = errors.New("error when get up groups")
  24. return
  25. }
  26. for _, v := range res.Data {
  27. groups[v.ID] = v
  28. }
  29. return
  30. }