media.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package dao
  2. import (
  3. "context"
  4. "net/url"
  5. "strconv"
  6. "go-common/library/ecode"
  7. "go-common/library/log"
  8. )
  9. const _delScoreURL = "http://api.bilibili.co/pgc/internal/review/score/delete"
  10. // DelScore .
  11. func (d *Dao) DelScore(c context.Context, aid, mediaID, mid int64) (err error) {
  12. if mediaID == 0 || mid == 0 || aid == 0 {
  13. return
  14. }
  15. params := url.Values{}
  16. params.Set("media_id", strconv.FormatInt(mediaID, 10))
  17. params.Set("mid", strconv.FormatInt(mid, 10))
  18. params.Set("oid", strconv.FormatInt(aid, 10))
  19. params.Set("from", "1")
  20. var resp struct {
  21. Code int `json:"code"`
  22. Message string `json:"message"`
  23. }
  24. err = d.httpClient.Post(c, _delScoreURL, "", params, &resp)
  25. if err != nil {
  26. PromError("media:番剧删除评分接口")
  27. log.Error("media: d.client.Post(%s, data:%s) error(%+v)", _delScoreURL, params.Encode(), err)
  28. return
  29. }
  30. if resp.Code != 0 {
  31. PromError("media:番剧删除评分接口")
  32. log.Error("media: d.client.Post(%s, data:%s) res: %+v", _delScoreURL, params.Encode(), resp)
  33. err = ecode.Int(resp.Code)
  34. }
  35. log.Info("media: del score success(media_id: %d, mid: %d, oid: %d)", mediaID, mid, aid)
  36. return
  37. }