bnj.go 924 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "strconv"
  6. "strings"
  7. "go-common/library/ecode"
  8. "github.com/pkg/errors"
  9. )
  10. const _bnjConfURI = "/activity/v0/bainian/config"
  11. // Bnj2019Conf .
  12. func (d *Dao) Bnj2019Conf(c context.Context) (mids []int64, err error) {
  13. var res struct {
  14. Code int `json:"code"`
  15. Data struct {
  16. GreyStatus int `json:"grey_status"`
  17. GreyUids string `json:"grey_uids"`
  18. } `json:"data"`
  19. }
  20. if err = d.httpR.Get(c, d.bnjConfURL, "", nil, &res); err != nil {
  21. return
  22. }
  23. if res.Code != ecode.OK.Code() {
  24. err = errors.Wrap(ecode.Int(res.Code), d.bnjConfURL)
  25. return
  26. }
  27. if res.Data.GreyStatus == 1 {
  28. midsStr := strings.Split(res.Data.GreyUids, ",")
  29. for _, midStr := range midsStr {
  30. var mid int64
  31. if mid, err = strconv.ParseInt(midStr, 10, 64); err != nil {
  32. err = fmt.Errorf("live grey_uids(%s)", res.Data.GreyUids)
  33. return
  34. }
  35. mids = append(mids, mid)
  36. }
  37. }
  38. return
  39. }