liuxiulin 8 miesięcy temu
rodzic
commit
dfe2b757b4

+ 3 - 8
pkg/deviceStatus/deviceStatus.go

@@ -1,9 +1,7 @@
 package deviceStatus
 
 import (
-	"fmt"
 	"github.com/gogf/gf/database/gredis"
-	"github.com/gogf/gf/encoding/gjson"
 )
 
 const (
@@ -43,15 +41,12 @@ func NewDevStatusManager(host string, port int) *DevStatusManager {
 	return mgr
 }
 
-func (mgr *DevStatusManager) GetDeviceStatus(id string) (*gjson.Json, error) {
+func (mgr *DevStatusManager) GetDeviceStatus(id string) (string, error) {
 	key := KeyPrefix + id
-	fmt.Println(key)
-	var status SplitStatus
 	// get status from redis
 	result, err := mgr.redisClient.DoVar("GET", key)
 	if err != nil {
-		return nil, err
+		return "", err
 	}
-	err = result.Struct(&status)
-	return gjson.New(result.String()), nil
+	return result.String(), nil
 }

+ 1 - 2
pkg/rpcs/access.go

@@ -1,7 +1,6 @@
 package rpcs
 
 import (
-	"github.com/gogf/gf/encoding/gjson"
 	"sparrow/pkg/protocol"
 )
 
@@ -62,5 +61,5 @@ type ChunkUpgrade struct {
 }
 
 type ReplyStatus struct {
-	Status gjson.Json
+	Status string
 }

+ 2 - 2
services/devicemanager/manager.go

@@ -124,8 +124,8 @@ func (dm *DeviceManager) GetDeviceStatus(args rpcs.ArgsGetStatus, reply *rpcs.Re
 	if err != nil {
 		return err
 	}
-	if status != nil {
-		reply.Status = *status
+	if status != "" {
+		reply.Status = status
 	}
 	return nil
 }

+ 1 - 1
services/knowoapi/services/device.go

@@ -186,7 +186,7 @@ func (a deviceservice) GetDeviceStatus(deviceId string) (*gjson.Json, error) {
 		return nil, err
 	}
 
-	return &reply.Status, nil
+	return gjson.New(reply.Status), nil
 }
 
 func (a deviceservice) GetSplitInfo(deviceId string) error {