瀏覽代碼

修改modify的逻辑

tanghongbin 4 年之前
父節點
當前提交
605013919a
共有 1 個文件被更改,包括 8 次插入4 次删除
  1. 8 4
      Controller/EquipmentManagerV3.py

+ 8 - 4
Controller/EquipmentManagerV3.py

@@ -135,6 +135,8 @@ class EquipmentManagerV3(View):
         userID = tko.userID
         if userID is None:
             return response.json(309)
+        deviceData = None
+        dev_info_qs = None
         try:
             # deviceData = json.loads(deviceContent)
             deviceData = eval(deviceContent)
@@ -147,7 +149,8 @@ class EquipmentManagerV3(View):
             print(e)
             return response.json(177, repr(e))
         else:
-            qs = Device_Info.objects.filter(userID_id=userID, id=id)
+            # qs = Device_Info.objects.filter(userID_id=userID, id=id)
+            qs = dev_info_qs
             res = CommonService.qs_to_dict(qs)
             if qs.exists():
                 uid = qs[0].UID
@@ -155,7 +158,8 @@ class EquipmentManagerV3(View):
                 # 增加设备影子信息修改昵称 start
                 us_qs = UidSetModel.objects.filter(uid=uid)
                 if us_qs.exists():
-                    us_qs.update(nickname=nickname)
+                    if deviceData.__contains__('NickName'):
+                        us_qs.update(nickname=nickname)
                 else:
                     ChannelIndex = qs[0].ChannelIndex
                     nowTime = int(time.time())
@@ -168,8 +172,8 @@ class EquipmentManagerV3(View):
                         'nickname': nickname,
                     }
                     UidSetModel.objects.create(**uid_set_create_dict)
-                di_qs = Device_Info.objects.filter(UID=uid)
-                di_qs.update(NickName=nickname)
+                # di_qs = Device_Info.objects.filter(UID=uid)
+                # di_qs.update(NickName=nickname)
             # redisObj = RedisObject(db=8)
             # redisObj.del_data(key='uid_qs_' + userID)
             return response.json(0, res)