message.go 560 B

123456789101112131415161718192021222324252627
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/admin/main/workflow/model/param"
  5. "go-common/library/ecode"
  6. )
  7. const _userNotifyURI = "http://message.bilibili.co/api/notify/send.user.notify.do"
  8. // SendMessage send message to upper.
  9. func (d *Dao) SendMessage(c context.Context, msg *param.MessageParam) (err error) {
  10. uri := _userNotifyURI
  11. params := msg.Query()
  12. var res struct {
  13. Code int `json:"code"`
  14. }
  15. if err = d.httpWrite.Post(c, uri, "", params, &res); err != nil {
  16. return
  17. }
  18. if res.Code != 0 {
  19. err = ecode.Int(res.Code)
  20. return
  21. }
  22. return
  23. }