reply.go 1012 B

1234567891011121314151617181920212223242526272829303132333435363738
  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 (
  10. _replyState = "0" // 0: open, 1: close
  11. _replyURL = "http://api.bilibili.co/x/internal/v2/reply/subject/regist"
  12. _gameOfficial = 32708316
  13. )
  14. // RegReply opens eports's reply.
  15. func (d *Dao) RegReply(c context.Context, maid, adid int64, replyType string) (err error) {
  16. params := url.Values{}
  17. params.Set("adid", strconv.FormatInt(adid, 10))
  18. params.Set("mid", strconv.FormatInt(_gameOfficial, 10))
  19. params.Set("oid", strconv.FormatInt(maid, 10))
  20. params.Set("type", replyType)
  21. params.Set("state", _replyState)
  22. var res struct {
  23. Code int `json:"code"`
  24. }
  25. if err = d.replyClient.Post(c, _replyURL, "", params, &res); err != nil {
  26. log.Error("d.replyClient.Post(%s) error(%v)", _replyURL+"?"+params.Encode(), err)
  27. return
  28. }
  29. if res.Code != ecode.OK.Code() {
  30. log.Error("d.replyClient.Post(%s) error(%v)", _replyURL+"?"+params.Encode(), err)
  31. err = ecode.Int(res.Code)
  32. }
  33. return
  34. }