|
@@ -15,6 +15,7 @@ import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/gin-gonic/gin"
|
|
log "github.com/sirupsen/logrus"
|
|
log "github.com/sirupsen/logrus"
|
|
"io/ioutil"
|
|
"io/ioutil"
|
|
|
|
+ "os"
|
|
"strconv"
|
|
"strconv"
|
|
"strings"
|
|
"strings"
|
|
"time"
|
|
"time"
|
|
@@ -591,6 +592,38 @@ func WriteDataEmq(c *gin.Context) {
|
|
// @Success 200 {string} string "ok"
|
|
// @Success 200 {string} string "ok"
|
|
// @Router /v2/gateway/find [get]
|
|
// @Router /v2/gateway/find [get]
|
|
func FindGateway(c *gin.Context) {
|
|
func FindGateway(c *gin.Context) {
|
|
- response.Success("查询网关设备完成", global.GatewayList, c)
|
|
|
|
|
|
+ marshal, err := json.Marshal(global.GatewayList)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ response.Success("查询网关设备完成", marshal, c)
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// SetGatewayMac
|
|
|
|
+// PingExample confrontation-training
|
|
|
|
+// @Summary 保存网关MAC
|
|
|
|
+// @Schemes
|
|
|
|
+// @Description 保存网关MAC-脑电写入指令
|
|
|
|
+// @Tags 设备管理
|
|
|
|
+// @Param mac body string true "mac:网关MAC地址 "
|
|
|
|
+// @Accept json
|
|
|
|
+// @Produce json
|
|
|
|
+// @Success 200 {string} string "ok"
|
|
|
|
+// @Router /v2/gateway/set [post]
|
|
|
|
+func SetGatewayMac(c *gin.Context) {
|
|
|
|
+ var param gateway.GatewayInfo
|
|
|
|
+ c.ShouldBindJSON(¶m)
|
|
|
|
+ file, err := os.OpenFile("./config/application.yaml", os.O_APPEND, 0666)
|
|
|
|
+ if err != nil {
|
|
|
|
+ response.Failed("读取配置文件失败", c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ _, err = file.Write([]byte(param.Mac))
|
|
|
|
+ if err != nil {
|
|
|
|
+ response.Failed("写入配置文件失败", c)
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ response.Success("网关信息保存成功,请重启软件!", "", c)
|
|
return
|
|
return
|
|
}
|
|
}
|