archive.go 862 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "net/url"
  6. "go-common/app/interface/main/dm/model"
  7. "go-common/library/log"
  8. )
  9. const (
  10. _cidInfo = "/videoup/cid"
  11. )
  12. func (d *Dao) cidInfoURI() string {
  13. return d.conf.Host.Archive + _cidInfo
  14. }
  15. // CidInfo 获取cid详细信息
  16. func (d *Dao) CidInfo(c context.Context, cid int64) (info *model.CidInfo, err error) {
  17. var (
  18. res = &struct {
  19. Code int `json:"code"`
  20. Data *model.CidInfo `json:"data"`
  21. }{}
  22. params = url.Values{}
  23. uri = d.cidInfoURI()
  24. )
  25. params.Set("cid", fmt.Sprint(cid))
  26. if err = d.httpClient.Get(c, uri, "", params, &res); err != nil {
  27. log.Error("d.httpClient.Get(%s,%v,%d)", uri, params, err)
  28. return
  29. }
  30. if res.Code != 0 {
  31. err = fmt.Errorf("code is:%d", res.Code)
  32. log.Error("d.httpClient.Get(%s,%v,%v,%d)", uri, params, err, res.Code)
  33. return
  34. }
  35. return res.Data, nil
  36. }