Compare commits
No commits in common. "3b6b3612fb5380e948007825166ffa26ad9363ae" and "8daa1612c18556a557f40fe23aa70979c7096959" have entirely different histories.
3b6b3612fb
...
8daa1612c1
|
|
@ -60,7 +60,7 @@ func SetDeviceStatusV2(c *gin.Context) {
|
||||||
for _, v := range devices {
|
for _, v := range devices {
|
||||||
if v == req.ID {
|
if v == req.ID {
|
||||||
// 继续处理请求
|
// 继续处理请求
|
||||||
worker.SetRedisWithExpire(req.ID, "1", time.Second*300)
|
worker.SetRedisWithExpire(req.ID, "1", 300)
|
||||||
c.JSON(200, gin.H{"code": 0, "message": "success"})
|
c.JSON(200, gin.H{"code": 0, "message": "success"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -231,12 +231,15 @@ func ScanDeviceStatus() {
|
||||||
devices := worker.GetRedisSetMembers("627gyf3488h")
|
devices := worker.GetRedisSetMembers("627gyf3488h")
|
||||||
offline := ""
|
offline := ""
|
||||||
for _, v := range devices {
|
for _, v := range devices {
|
||||||
|
res := worker.GetRedis(v)
|
||||||
|
if res == "" {
|
||||||
c := worker.IsContainKey("monitor_" + v)
|
c := worker.IsContainKey("monitor_" + v)
|
||||||
if c == false {
|
if c == false {
|
||||||
worker.SetRedisWithExpire("monitor_"+v, "1", time.Hour*24)
|
worker.SetRedisWithExpire("monitor_"+v, "1", time.Hour*12)
|
||||||
offline += v + ","
|
offline += v + ","
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if offline != "" {
|
if offline != "" {
|
||||||
title := "设备状态异常"
|
title := "设备状态异常"
|
||||||
|
|
@ -247,12 +250,6 @@ func ScanDeviceStatus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendMail(title, content string) {
|
func SendMail(title, content string) {
|
||||||
//捕获异常
|
|
||||||
defer func() {
|
|
||||||
if err := recover(); err != nil {
|
|
||||||
fmt.Errorf("tool send mail error: %s", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
// TODO
|
// TODO
|
||||||
// 发送邮件
|
// 发送邮件
|
||||||
// 邮件内容
|
// 邮件内容
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package worker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"log"
|
||||||
"net/smtp"
|
"net/smtp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -14,13 +15,6 @@ type MyEmail struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *MyEmail) Send(title, content string, toEmail []string) error {
|
func (e *MyEmail) Send(title, content string, toEmail []string) error {
|
||||||
//捕获异常
|
|
||||||
defer func() {
|
|
||||||
if err := recover(); err != nil {
|
|
||||||
fmt.Errorf("MyEmail send mail error: %s", err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// 设置邮件头部
|
// 设置邮件头部
|
||||||
header := make(map[string]string)
|
header := make(map[string]string)
|
||||||
header["From"] = e.SmtpUserName
|
header["From"] = e.SmtpUserName
|
||||||
|
|
@ -37,8 +31,7 @@ func (e *MyEmail) Send(title, content string, toEmail []string) error {
|
||||||
// 发送邮件
|
// 发送邮件
|
||||||
err := smtp.SendMail(e.SmtpHost, smtp.PlainAuth("", e.SmtpUserName, e.SmtpPassword, "pop.qq.com"), e.SmtpUserName, toEmail, []byte(message))
|
err := smtp.SendMail(e.SmtpHost, smtp.PlainAuth("", e.SmtpUserName, e.SmtpPassword, "pop.qq.com"), e.SmtpUserName, toEmail, []byte(message))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//log.Fatalf("smtp error: %s", err)
|
log.Fatalf("smtp error: %s", err)
|
||||||
fmt.Errorf("send mail error: %s", err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue