package controller import ( "backend/Type" "backend/common" "backend/middleware/feishu" "backend/model" "backend/util" "fmt" "log" "github.com/gin-gonic/gin" ) func FeishuSendInfo(c *gin.Context) { AppConf, err := util.GetAppConfig(common.UK_APP_ID) Result, err := util.GetOperation(AppConf) if err != nil { log.Printf("failed to get operation: %v", err) return } err = feishu.SendOperationMsg(Result) if err != nil { log.Printf("failed to send operation message: %v", err) } } func FeishuSendInfo2(c *gin.Context) { err := feishu.SendOperationMsg2(common.US_APP_ID) if err != nil { log.Printf("failed to send operation message: %v", err) } } func FeishuSendWeekInfo(c *gin.Context) { AppConf, err := util.GetAppConfig(common.UK_APP_ID) Result, err := util.GetOperation(AppConf) if err != nil { log.Printf("failed to get operation: %v", err) return } err = feishu.SendOperationMsg(Result) if err != nil { log.Printf("failed to send operation message: %v", err) } } func FeishuUpdateApp(c *gin.Context) { type result struct { AppId int `json:"AppId"` Step int `json:"Step"` } var r result if err := c.ShouldBindJSON(&r); err != nil { c.JSON(400, gin.H{"error": err.Error()}) return } if r.Step == 0 { err := feishu.SendUpdateCard() if err != nil { log.Printf("failed to send update card: %v", err) } } if r.Step == 1 { Server := model.Server{} Server.AppId = r.AppId go Server.UpdateApp() } } func FeishuServerInfo(c *gin.Context) { } func FeishuNotify(c *gin.Context) { r := Type.NotifyData{} if err := c.ShouldBindJSON(&r); err != nil { c.JSON(400, gin.H{"error": err.Error()}) return } err := feishu.SendNotifyMsg(&r) if err != nil { log.Printf("failed to send notify message: %v", err) } } func FeishuNotifyClient(c *gin.Context) { r := Type.NotifyClientData{} if err := c.ShouldBindJSON(&r); err != nil { c.JSON(400, gin.H{"error": err.Error()}) return } err := feishu.SendNotifyClientMsg(&r) if err != nil { log.Printf("failed to send notify message: %v", err) } } func FeishuNotifyOrder(c *gin.Context) { r := Type.OrderData{} if err := c.ShouldBindJSON(&r); err != nil { c.JSON(400, gin.H{"error": err.Error()}) return } err := feishu.SendNotifyOrderMsg(&r) if err != nil { fmt.Printf("failed to send notify message: %v", err) } c.JSON(200, gin.H{"success": err.Error()}) }