Prechádzať zdrojové kódy

修复添加设备不成功问题

locky 4 rokov pred
rodič
commit
2be2a1bf7e
1 zmenil súbory, kde vykonal 9 pridanie a 9 odobranie
  1. 9 9
      Controller/EquipmentManagerV3.py

+ 9 - 9
Controller/EquipmentManagerV3.py

@@ -68,13 +68,16 @@ class EquipmentManagerV3(View):
         encrypt_pass = View_Password
         print("准备解密")
         View_Password = self.decode_pwd(View_Password)
-        Type = int(request_dict.get('Type', None))
-        ChannelIndex = int(request_dict.get('ChannelIndex', None))
+        Type = request_dict.get('Type', None)
+        ChannelIndex = request_dict.get('ChannelIndex', None)
         version = request_dict.get('version', '')
         isCheckMainUser = request_dict.get('isCheckMainUser', None)
         isMainUserExists = False
-        if not all([UID, NickName, View_Account]):  # Type和ChannelIndex可能为0
-            return response.json(444, {'param': 'UID, NickName, View_Account'})
+        if not all([UID, NickName, View_Account, Type, ChannelIndex]):  # Type和ChannelIndex可能为0
+            return response.json(444, {'param': 'UID, NickName, View_Account, Type, ChannelIndex'})
+
+        Type = int(Type)
+        ChannelIndex = int(ChannelIndex)
 
         re_uid = re.compile(r'^[A-Za-z0-9]{14,20}$')
         if not re_uid.match(UID):
@@ -226,13 +229,10 @@ class EquipmentManagerV3(View):
 
             iotqs = iotdeviceInfoModel.objects.filter(serial_number=dvql[0]['serial_number'])
             if iotqs.exists():
-                res['iot'].append(
-                    {
+                res['iot'] = {
                         'endpoint': iotqs[0].endpoint,
                         'token_iot_number': iotqs[0].endpoint
-
-                    }
-                )
+                }
 
             return response.json(0, res)