stat.go 630 B

1234567891011121314151617181920212223242526272829303132
  1. package archive
  2. import (
  3. "context"
  4. "fmt"
  5. "net/url"
  6. "strconv"
  7. "go-common/library/log"
  8. )
  9. // Stat get archive stat.
  10. func (d *Dao) Stat(c context.Context, aid int64) (click int, err error) {
  11. params := url.Values{}
  12. params.Set("aid", strconv.FormatInt(aid, 10))
  13. var res struct {
  14. Code int `json:"code"`
  15. Data struct {
  16. Click int `json:"click"`
  17. } `json:"data"`
  18. }
  19. if err = d.client.Get(c, d.statURI, "", params, &res); err != nil {
  20. log.Error("archive stat url(%s) error(%v)", d.statURI, err)
  21. return
  22. }
  23. if res.Code != 0 {
  24. err = fmt.Errorf("archive stat call failed")
  25. return
  26. }
  27. click = res.Data.Click
  28. return
  29. }