// Package controller ----------------------------- // @file : led.go // @author : JJXu // @contact : wavingbear@163.com // @time : 2024/5/21 上午10:31 // ------------------------------------------- package controller import ( "esp8266Server/httpServer/dto" "esp8266Server/tcp" "github.com/gin-gonic/gin" ) type Led struct { } func (h *Led) LedControl(c *gin.Context) { var req dto.LedControlRequest if err := c.ShouldBindJSON(&req); err != nil { c.JSON(400, gin.H{"error": err.Error()}) return } err := tcp.TcpServerIns.SendMsg(req.MchId, req.TcpMsg()) if err != nil { c.JSON(500, gin.H{"error": err.Error()}) return } c.JSON(200, gin.H{"msg": "success"}) }