bilibili-backup/app/admin/main/reply/dao/event.go

34 lines
778 B
Go
Raw Normal View History

2019-04-22 10:59:20 +08:00
package dao
import (
"context"
"fmt"
"go-common/app/admin/main/reply/model"
"go-common/library/log"
)
type event struct {
Action string `json:"action"`
Mid int64 `json:"mid"`
Subject *model.Subject `json:"subject"`
Reply *model.Reply `json:"reply"`
Report *model.Report `json:"report,omitempty"`
}
// PubEvent pub reply event.
func (d *Dao) PubEvent(c context.Context, action string, mid int64, sub *model.Subject, rp *model.Reply, report *model.Report) error {
e := &event{
Action: action,
Mid: mid,
Subject: sub,
Reply: rp,
Report: report,
}
if sub == nil {
log.Error("PubEvent failed,sub is nil!value: %v %v %v %v", action, mid, rp, report)
return nil
}
return d.eventBus.Send(c, fmt.Sprint(sub.Oid), &e)
}