event.go 778 B

123456789101112131415161718192021222324252627282930313233
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/app/admin/main/reply/model"
  6. "go-common/library/log"
  7. )
  8. type event struct {
  9. Action string `json:"action"`
  10. Mid int64 `json:"mid"`
  11. Subject *model.Subject `json:"subject"`
  12. Reply *model.Reply `json:"reply"`
  13. Report *model.Report `json:"report,omitempty"`
  14. }
  15. // PubEvent pub reply event.
  16. func (d *Dao) PubEvent(c context.Context, action string, mid int64, sub *model.Subject, rp *model.Reply, report *model.Report) error {
  17. e := &event{
  18. Action: action,
  19. Mid: mid,
  20. Subject: sub,
  21. Reply: rp,
  22. Report: report,
  23. }
  24. if sub == nil {
  25. log.Error("PubEvent failed,sub is nil!value: %v %v %v %v", action, mid, rp, report)
  26. return nil
  27. }
  28. return d.eventBus.Send(c, fmt.Sprint(sub.Oid), &e)
  29. }