databus.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package recommend
  2. import (
  3. "context"
  4. "strconv"
  5. "time"
  6. "go-common/library/log"
  7. "github.com/pkg/errors"
  8. )
  9. // PubDislike is.
  10. func (d *Dao) PubDislike(c context.Context, buvid, gt string, id, mid, reasonID, cmreasonID, feedbackID, upperID, rid, tagID int64, adcb string, now time.Time) (err error) {
  11. return d.pub(c, buvid, gt, id, mid, reasonID, cmreasonID, feedbackID, upperID, rid, tagID, adcb, 1, now)
  12. }
  13. // PubDislikeCancel is.
  14. func (d *Dao) PubDislikeCancel(c context.Context, buvid, gt string, id, mid, reasonID, cmreasonID, feedbackID, upperID, rid, tagID int64, adcb string, now time.Time) (err error) {
  15. return d.pub(c, buvid, gt, id, mid, reasonID, cmreasonID, feedbackID, upperID, rid, tagID, adcb, 2, now)
  16. }
  17. func (d *Dao) pub(c context.Context, buvid, gt string, id, mid, reasonID, cmreasonID, feedbackID, upperID, rid, tagID int64, adcb string, state int8, now time.Time) (err error) {
  18. key := strconv.FormatInt(mid, 10)
  19. msg := struct {
  20. Buvid string `json:"buvid"`
  21. Goto string `json:"goto"`
  22. ID int64 `json:"id"`
  23. Mid int64 `json:"mid"`
  24. ReasonID int64 `json:"reason_id"`
  25. CMReasonID int64 `json:"cm_reason_id"`
  26. FeedbackID int64 `json:"feedback_id"`
  27. UpperID int64 `json:"upper_id"`
  28. Rid int64 `json:"rid"`
  29. TagID int64 `json:"tag_id"`
  30. ADCB string `json:"ad_cb"`
  31. State int8 `json:"state"`
  32. Time int64 `json:"time"`
  33. }{Buvid: buvid, Goto: gt, ID: id, Mid: mid, ReasonID: reasonID, CMReasonID: cmreasonID, FeedbackID: feedbackID, UpperID: upperID, Rid: rid, TagID: tagID, ADCB: adcb, State: state, Time: now.Unix()}
  34. if err = d.databus.Send(c, key, msg); err != nil {
  35. err = errors.Wrapf(err, "%s %v", key, msg)
  36. return
  37. }
  38. log.Info("d.dataBus.Pub(%s,%v)", key, msg)
  39. return
  40. }