Pārlūkot izejas kodu

alexa的添加和更新接口添加传递password

tanghongbin 4 gadi atpakaļ
vecāks
revīzija
8c9e33de8f
2 mainītis faili ar 16 papildinājumiem un 15 dzēšanām
  1. 13 13
      Controller/EquipmentManagerV3.py
  2. 3 2
      Service/ModelService.py

+ 13 - 13
Controller/EquipmentManagerV3.py

@@ -52,9 +52,9 @@ class EquipmentManagerV3(View):
         UID = request_dict.get('UID', None)
         NickName = request_dict.get('NickName', None)
         View_Account = request_dict.get('View_Account', None)
-        View_Password = request_dict.get('View_Password', '')
+        View_Password_Encypt = request_dict.get('View_Password', '')
         print("准备解密")
-        View_Password = self.decode_pwd(View_Password)
+        View_Password = self.decode_pwd(View_Password_Encypt)
         Type = request_dict.get('Type', None)
         ChannelIndex = request_dict.get('ChannelIndex', None)
 
@@ -73,11 +73,11 @@ class EquipmentManagerV3(View):
                             return response.json(174)
                         else:
                             is_exist.delete()
-                    if UID == '98UXAA8BRPA35VAL111A':
-                        asy = threading.Thread(target=ModelService.add_log,
-                                               args=(CommonService.get_ip_address(request), userID, 'addV3'))
-                        asy.start()
-                        return response.json(10, 'illegal uid: {uid}'.format(uid=UID))
+                    # if UID == '98UXAA8BRPA35VAL111A':
+                    #     asy = threading.Thread(target=ModelService.add_log,
+                    #                            args=(CommonService.get_ip_address(request), userID, 'addV3'))
+                    #     asy.start()
+                    #     return response.json(10, 'illegal uid: {uid}'.format(uid=UID))
                     # is_bind = Device_Info.objects.filter(UID=UID, isShare=False)
                     # # 判断是否有已绑定用户
                     # if is_bind:
@@ -108,7 +108,7 @@ class EquipmentManagerV3(View):
                             us_qs = UidSetModel.objects.filter(uid=UID)
 
                         if us_qs.exists() and us_qs[0].is_alexa == 1:
-                            asy = threading.Thread(target=ModelService.notify_alexa_add, args=(UID, userID, NickName))
+                            asy = threading.Thread(target=ModelService.notify_alexa_add, args=(UID, userID, NickName, View_Password_Encypt))
                             asy.start()
 
                         # redisObj = RedisObject(db=8)
@@ -176,10 +176,10 @@ class EquipmentManagerV3(View):
             res = CommonService.qs_to_dict(qs)
             if qs.exists():
                 uid = qs[0].UID
-                if uid == '98UXAA8BRPA35VAL111A':
-                    asy = threading.Thread(target=ModelService.update_log,
-                                           args=(CommonService.get_ip_address(request), userID, 'modifyV3', deviceData, id))
-                    asy.start()
+                # if uid == '98UXAA8BRPA35VAL111A':
+                #     asy = threading.Thread(target=ModelService.update_log,
+                #                            args=(CommonService.get_ip_address(request), userID, 'modifyV3', deviceData, id))
+                #     asy.start()
                 nickname = qs[0].NickName
                 # 增加设备影子信息修改昵称 start
                 us_qs = UidSetModel.objects.filter(uid=uid)
@@ -201,7 +201,7 @@ class EquipmentManagerV3(View):
                 di_qs.update(NickName=nickname)
                 if deviceData is not None and deviceData.__contains__('NickName') and us_qs[0].is_alexa == 1:
 
-                    asy = threading.Thread(target=ModelService.notify_alexa_add, args=(uid, userID, nickname))
+                    asy = threading.Thread(target=ModelService.notify_alexa_add, args=(uid, userID, nickname, self.encrypt_pwd(di_qs[0].View_Password)))
                     asy.start()
             # redisObj = RedisObject(db=8)
             # redisObj.del_data(key='uid_qs_' + userID)

+ 3 - 2
Service/ModelService.py

@@ -160,12 +160,13 @@ class ModelService:
         return list(uid_list)
 
     @staticmethod
-    def notify_alexa_add(uid, userID, nickname):
+    def notify_alexa_add(uid, userID, nickname, password):
         url = 'https://www.zositech.xyz/deviceStatus/addOrUpdate'
         data = {
             'UID': uid,
             'userID': userID,
-            'uid_nick': nickname
+            'uid_nick': nickname,
+            'password': password
         }
         try:
             res = requests.post(url, data=data, timeout=10)