author.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package dao
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. "go-common/app/interface/openplatform/article/model"
  7. "go-common/library/log"
  8. )
  9. // RecommendAuthors .
  10. func (d *Dao) RecommendAuthors(c context.Context, platform string, mobiApp string, device string, build int, clientIP string, userID int64, buvid string, recType string, serviceArea string, _rapagesizen int, mid int64) (res []*model.RecommendAuthor, err error) {
  11. params := url.Values{}
  12. params.Set("platform", platform)
  13. params.Set("mobi_app", mobiApp)
  14. params.Set("device", device)
  15. params.Set("clientip", clientIP)
  16. params.Set("buvid", buvid)
  17. params.Set("rec_type", recType)
  18. params.Set("service_area", serviceArea)
  19. params.Set("userid", strconv.FormatInt(userID, 10))
  20. params.Set("build", strconv.Itoa(build))
  21. params.Set("context_id", strconv.FormatInt(mid, 10))
  22. var r struct {
  23. Code int `json:"code"`
  24. Data []*model.RecommendAuthor
  25. }
  26. if err = d.httpClient.Get(c, d.c.Article.RecommendAuthorsURL, "", params, &r); err != nil {
  27. log.Error("activity: RecommendAuthors url(%s) error(%+v)", d.c.Article.RecommendAuthorsURL+"?"+params.Encode(), err)
  28. return
  29. }
  30. if r.Code != 0 {
  31. log.Error("activity: RecommendAuthors url(%s) res(%d) error(%+v)", d.c.Article.RecommendAuthorsURL+"?"+params.Encode(), r.Code, err)
  32. return
  33. }
  34. res = r.Data
  35. return
  36. }