full.go 894 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "net/url"
  6. "go-common/app/admin/main/tv/model"
  7. "go-common/library/ecode"
  8. "go-common/library/log"
  9. )
  10. type msgReturn struct {
  11. Code int `json:"code"`
  12. Message string `json:"message"`
  13. Data []*model.APKInfo `json:"data"`
  14. }
  15. // FullImport .
  16. func (d *Dao) FullImport(c context.Context, build int) (result []*model.APKInfo, err error) {
  17. var (
  18. res = &msgReturn{}
  19. fullURL = d.fullURL
  20. )
  21. params := url.Values{}
  22. params.Set("version_code", fmt.Sprintf("%d", build))
  23. err = d.httpSearch.Get(c, fullURL, "", params, res)
  24. if err != nil {
  25. log.Error("d.httpSearch.Get(%s) error(%v)", fullURL+"?"+params.Encode(), err)
  26. return
  27. }
  28. result = res.Data
  29. if res.Code != ecode.OK.Code() {
  30. err = fmt.Errorf("return code:%d", res.Code)
  31. log.Error("d.httpSearch.Get(%s) error(%v)", fullURL+"?"+params.Encode(), err)
  32. }
  33. return
  34. }