dao.go 841 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package monitor
  2. import (
  3. "context"
  4. "net/url"
  5. "go-common/app/interface/main/creative/conf"
  6. "go-common/app/interface/main/creative/model/monitor"
  7. httpx "go-common/library/net/http/blademaster"
  8. )
  9. // Dao is message dao.
  10. type Dao struct {
  11. c *conf.Config
  12. client *httpx.Client
  13. uri string
  14. }
  15. // New new a message dao.
  16. func New(c *conf.Config) *Dao {
  17. //http://ops-mng.bilibili.co/api/sendsms&message=test&token=
  18. return &Dao{
  19. c: c,
  20. client: httpx.NewClient(c.HTTPClient.Normal),
  21. uri: c.Host.Monitor + "/api/sendsms",
  22. }
  23. }
  24. // Send send message to upper.
  25. func (d *Dao) Send(c context.Context, msg string) (err error) {
  26. params := url.Values{}
  27. params.Set("phone", monitor.Tels)
  28. params.Set("message", msg)
  29. params.Set("token", "f5a658b2-5926-4b71-96c3-7d3777b7d256")
  30. d.client.Get(c, d.uri, "", params, nil)
  31. return
  32. }