alarm_msg.go 840 B

123456789101112131415161718192021222324252627282930313233
  1. package alarm_msg
  2. import (
  3. "encoding/json"
  4. "eta/eta_mobile/utils"
  5. "github.com/rdlucklib/rdluck_tools/http"
  6. )
  7. type WechatWarningReq struct {
  8. Content string `description:"预警信息"`
  9. }
  10. // SendAlarmMsg
  11. // projectName-项目名称
  12. // runMode-运行模式
  13. // msgBody-消息内容
  14. // level:消息基本,1:提示消息,2:警告消息,3:严重错误信息,默认为1 提示消息
  15. func SendAlarmMsg(msgBody string, level int) {
  16. if utils.AlarmMsgUrl == "" {
  17. return
  18. }
  19. params := make(map[string]interface{})
  20. params["ProjectName"] = utils.APPNAME
  21. params["RunMode"] = utils.RunMode
  22. params["MsgBody"] = msgBody
  23. params["Level"] = level
  24. param, err := json.Marshal(params)
  25. if err != nil {
  26. utils.FileLog.Info("SendAlarmMsg json.Marshal Err:" + err.Error())
  27. return
  28. }
  29. http.Post(utils.AlarmMsgUrl, string(param), "application/json")
  30. }