uper.go 896 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package data
  2. import (
  3. "context"
  4. "go-common/app/job/main/videoup-report/model/manager"
  5. "go-common/library/log"
  6. "net/url"
  7. "strconv"
  8. )
  9. const (
  10. _midGroupsURI = "/x/internal/uper/special/get_by_mid"
  11. )
  12. // UpGroups get all up groups
  13. func (d *Dao) MidGroups(c context.Context, mid int64) (groups map[int64]*manager.UpGroup, err error) {
  14. groups = make(map[int64]*manager.UpGroup)
  15. params := url.Values{}
  16. params.Set("mid", strconv.FormatInt(mid, 10))
  17. var res struct {
  18. Code int `json:"code"`
  19. Msg string `json:"message"`
  20. Data []*manager.UpGroup `json:"data"`
  21. }
  22. if err = d.client.Get(c, d.c.Host.API+_midGroupsURI, "", params, &res); err != nil {
  23. log.Error("d.UpGroups() error(%v)", err)
  24. return
  25. }
  26. if res.Data == nil {
  27. log.Warn("MidGroups(%d) error when get up groups", mid)
  28. return
  29. }
  30. for _, v := range res.Data {
  31. groups[v.GroupID] = v
  32. }
  33. return
  34. }