diff --git a/handler/tool.go b/handler/tool.go index 1ddb1a0..f9ec7d0 100644 --- a/handler/tool.go +++ b/handler/tool.go @@ -47,12 +47,12 @@ func SetDeviceStatusV2(c *gin.Context) { c.JSON(200, gin.H{"code": 400, "message": "参数错误"}) return } else { - token, _ := c.Get("token") - if token == nil { + token := c.Request.Header.Get("token") + if token == "" { c.JSON(200, gin.H{"code": 401, "message": "token为空"}) return } - devices := worker.GetRedisSetMembers(token.(string)) + devices := worker.GetRedisSetMembers(token) if len(devices) == 0 { c.JSON(200, gin.H{"code": 402, "message": "设备为空"}) return