databus.go 640 B

12345678910111213141516171819202122232425262728293031
  1. package dao
  2. import (
  3. "context"
  4. "strconv"
  5. "time"
  6. "go-common/app/service/main/share/model"
  7. )
  8. // PubShare .
  9. func (d *Dao) PubShare(c context.Context, p *model.ShareParams) (err error) {
  10. msg := &model.MIDShare{
  11. OID: p.OID,
  12. MID: p.MID,
  13. TP: p.TP,
  14. Time: time.Now().Unix(),
  15. }
  16. return d.databus.Send(c, strconv.FormatInt(p.MID, 10), &msg)
  17. }
  18. // PubStatShare .
  19. func (d *Dao) PubStatShare(c context.Context, typ string, oid, count int64) (err error) {
  20. msg := &model.ArchiveShare{
  21. Type: typ,
  22. ID: oid,
  23. Count: int(count),
  24. Ts: time.Now().Unix(),
  25. }
  26. return d.archiveDatabus.Send(c, strconv.FormatInt(oid, 10), &msg)
  27. }