create_code.go 1.0 KB

123456789101112131415161718192021222324252627282930
  1. package util
  2. import (
  3. "fmt"
  4. "go.uber.org/zap"
  5. "log"
  6. "ydMonitoring/config"
  7. )
  8. func SendModel(phone string, msg []string, lenght int) error {
  9. ss := NewSMS(config.Config.GetString("submail.appid"), config.Config.GetString("submail.signature"))
  10. if lenght > 10 {
  11. sprintf := fmt.Sprintf("【数据预警提示】当前出现%d条异常数据,请及时处理!", lenght)
  12. res, err := ss.Send(phone, sprintf)
  13. if err != nil || res.Status != SUCCESS {
  14. log.Println("发送短信验证码出现异常", zap.Any("res", res), zap.Error(err))
  15. return err
  16. }
  17. log.Println("发送短信验证码成功", zap.Any("res", res))
  18. } else if lenght > 0 {
  19. content := fmt.Sprintf("【数据预警提示】以下数据出现异常\n:%s\n共有%d条异常数据", msg, lenght)
  20. res, err := ss.Send(phone, content)
  21. if err != nil || res.Status != SUCCESS {
  22. log.Println("发送短信验证码出现异常", zap.Any("res", res), zap.Error(err))
  23. return err
  24. }
  25. log.Println("发送短信验证码成功", zap.Any("res", res))
  26. }
  27. return nil
  28. }