databus.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package dao
  2. import (
  3. "context"
  4. "strconv"
  5. artmdl "go-common/app/interface/openplatform/article/model"
  6. "go-common/library/log"
  7. )
  8. var _defaultAdd = int64(1)
  9. // PubView adds a view count.
  10. func (d *Dao) PubView(c context.Context, mid int64, aid int64, ip string, cheat *artmdl.CheatInfo) (err error) {
  11. msg := &artmdl.StatMsg{
  12. Aid: aid,
  13. Mid: mid,
  14. IP: ip,
  15. View: &_defaultAdd,
  16. CheatInfo: cheat,
  17. }
  18. if err = d.statDbus.Send(c, strconv.FormatInt(aid, 10), msg); err != nil {
  19. PromError("databus:发送浏览")
  20. log.Error("d.databus.SendView(%+v) error(%+v)", msg, err)
  21. return
  22. }
  23. PromInfo("databus:发送浏览")
  24. log.Info("s.PubView(mid: %v, aid: %v, ip: %v, cheat: %+v)", msg.Mid, msg.Aid, msg.IP, cheat)
  25. return
  26. }
  27. // PubShare add share count
  28. func (d *Dao) PubShare(c context.Context, mid int64, aid int64, ip string) (err error) {
  29. msg := &artmdl.StatMsg{
  30. Aid: aid,
  31. Mid: mid,
  32. IP: ip,
  33. Share: &_defaultAdd,
  34. }
  35. if err = d.statDbus.Send(c, strconv.FormatInt(aid, 10), msg); err != nil {
  36. PromError("databus:发送分享")
  37. log.Error("d.databus.SendShare(%+v) error(%+v)", msg, err)
  38. return
  39. }
  40. PromInfo("databus:发送分享")
  41. log.Info("s.PubShare(mid: %v, aid: %v, ip: %v)", msg.Mid, msg.Aid, msg.IP)
  42. return
  43. }