http.go 898 B

123456789101112131415161718192021222324252627282930313233343536
  1. package dao
  2. import (
  3. "context"
  4. "go-common/library/log"
  5. "go-common/library/net/metadata"
  6. "net/url"
  7. "strconv"
  8. "github.com/pkg/errors"
  9. )
  10. const (
  11. couponSystemNotify = 4
  12. couponMC = "10_99_1"
  13. sendMessage = "/api/notify/send.user.notify.do"
  14. )
  15. //SendMessage send message.
  16. func (d *Dao) SendMessage(c context.Context, mids, content, title string) (err error) {
  17. params := url.Values{}
  18. params.Set("mc", couponMC)
  19. params.Set("title", title)
  20. params.Set("context", content)
  21. params.Set("data_type", strconv.FormatInt(couponSystemNotify, 10))
  22. params.Set("mid_list", mids)
  23. defer func() {
  24. log.Info("send message url:%+v params:%+v err:%+v ", d.c.Property.MessageURL+sendMessage, params, err)
  25. }()
  26. ip := metadata.String(c, metadata.RemoteIP)
  27. if err = d.client.Post(c, d.c.Property.MessageURL+sendMessage, ip, params, nil); err != nil {
  28. err = errors.WithStack(err)
  29. }
  30. return
  31. }