category.go 825 B

1234567891011121314151617181920212223242526272829303132
  1. package newbiedao
  2. import (
  3. "context"
  4. "github.com/pkg/errors"
  5. "go-common/app/interface/main/growup/model"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. "go-common/library/net/metadata"
  9. "net/url"
  10. )
  11. // GetCategories get categories
  12. func (d *Dao) GetCategories(c context.Context) (err error) {
  13. categoriesRes := new(model.CategoriesRes)
  14. err = d.httpRead.Get(c, d.c.Host.CategoriesURI, metadata.String(c, metadata.RemoteIP), url.Values{}, categoriesRes)
  15. if err != nil {
  16. log.Error("s.dao.GetCategories error(%v)", err)
  17. return
  18. }
  19. if categoriesRes.Code != ecode.OK.Code() || len(categoriesRes.Data) <= 0 {
  20. err = errors.Wrap(ecode.Int(categoriesRes.Code), "get categories failed")
  21. log.Error("s.dao.GetCategories failed, ecode: %d", categoriesRes.Code)
  22. return
  23. }
  24. Categories = categoriesRes.Data
  25. return
  26. }