admin_backend/controller/alibaba.go
2026-02-25 10:16:35 +08:00

65 lines
1.4 KiB
Go

package controller
import (
"backend/Type"
"backend/alibaba"
"backend/util"
"fmt"
"log"
"github.com/gin-gonic/gin"
)
func AlibabaNotify(c *gin.Context) {
r := Type.NotifyData{}
if err := c.ShouldBindJSON(&r); err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return
}
err := alibaba.SendZabbixMsg(&r)
if err != nil {
log.Printf("failed to send notify message: %v", err)
}
}
func AlibabaGameNotify(c *gin.Context) {
r := Type.AlibabaNotifyData{}
if err := c.ShouldBindJSON(&r); err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return
}
content := util.ParseTmpl("./template/alibaba_notify.tmpl", r)
err := alibaba.SendStandardMsg2("游戏服务报警通知", content, "red")
if err != nil {
log.Printf("failed to send notify message: %v", err)
}
}
func AlibabaRecovery(c *gin.Context) {
r := Type.NotifyRecoveryData{}
if err := c.ShouldBindJSON(&r); err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return
}
err := alibaba.SendZabbixRecoveryMsg(&r)
if err != nil {
log.Printf("failed to send recovery message: %v", err)
}
}
func AlibabaNotifyOrder(c *gin.Context) {
r := Type.OrderData{}
if err := c.ShouldBindJSON(&r); err != nil {
c.JSON(400, gin.H{"error": err.Error()})
return
}
err := alibaba.SendOrderMsg(&r)
if err != nil {
fmt.Printf("failed to send notify message: %v", err)
}
c.JSON(200, gin.H{"success": err.Error()})
}