api.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package monitor
  2. import (
  3. "context"
  4. "go-common/app/job/main/aegis/model/monitor"
  5. "go-common/library/ecode"
  6. "go-common/library/log"
  7. "net/url"
  8. "strconv"
  9. )
  10. const (
  11. _arcAdditURL = "/videoup/archive/addit"
  12. )
  13. // ArchiveAttr 获取稿件都附加属性
  14. func (d *Dao) ArchiveAttr(c context.Context, aid int64) (addit *monitor.ArchiveAddit, err error) {
  15. params := url.Values{}
  16. params.Set("aid", strconv.FormatInt(aid, 10))
  17. var res struct {
  18. Code int `json:"code"`
  19. Data *monitor.ArchiveAddit `json:"data"`
  20. }
  21. if err = d.http.Get(c, d.URLArcAddit, "", params, &res); err != nil {
  22. log.Error("d.ArchiveAttr(%s) error(%v)", d.URLArcAddit+"?"+params.Encode(), err)
  23. return
  24. }
  25. if res.Code != 0 {
  26. err = ecode.Int(res.Code)
  27. log.Error("d.ArchiveAttr(%s) Code=(%d)", d.URLArcAddit+"?"+params.Encode(), res.Code)
  28. return
  29. }
  30. if res.Data == nil {
  31. err = ecode.NothingFound
  32. log.Warn("d.ArchiveAttr(%s) Code=(%d) data nil", d.URLArcAddit+"?"+params.Encode(), res.Code)
  33. return
  34. }
  35. addit = res.Data
  36. return
  37. }