dao.go 777 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package monitor
  2. import (
  3. "context"
  4. "net/url"
  5. "go-common/app/job/main/videoup/conf"
  6. xhttp "go-common/library/net/http/blademaster"
  7. )
  8. // Dao is message dao.
  9. type Dao struct {
  10. c *conf.Config
  11. client *xhttp.Client
  12. uri string
  13. }
  14. // New new a message dao.
  15. func New(c *conf.Config) (d *Dao) {
  16. //http://ops-mng.bilibili.co/api/sendsms&message=test&token=
  17. d = &Dao{
  18. c: c,
  19. client: xhttp.NewClient(c.HTTPClient),
  20. uri: c.Host.Monitor + "/api/sendsms",
  21. }
  22. return
  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", d.c.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. }