Bläddra i källkod

feature:
优化设备影子代码,增加alexa架构

chenjunkai 5 år sedan
förälder
incheckning
52b2de0ab7
3 ändrade filer med 32 tillägg och 56 borttagningar
  1. 30 53
      Controller/EquipmentManager.py
  2. 2 0
      Model/models.py
  3. 0 3
      Object/UidTokenObject.py

+ 30 - 53
Controller/EquipmentManager.py

@@ -833,6 +833,7 @@ def update_uid_set(request):
 # test.shadow.dvema.com
 # 生产环境
 # shadow.dvema.com
+# http://test.dvema.com/deviceShadow/update?etk=JVJWbFpFU0VOV1FsbEVTMFpOU2xKWFFURXhNVUU9Xz0=&ucode=1234&version=1324&p2p_region=CN
 # 设备影子更新
 def update_device_shadow(request):
     request.encoding = 'utf-8'
@@ -865,6 +866,7 @@ def update_device_shadow(request):
         push_status = request_dict.get('push_status', None)
         pwd = request_dict.get('pwd', None)
         resetTime = request_dict.get('resetTime', None)
+        is_alexa = request_dict.get('is_alexa', None)
 
         us_qs = UidSetModel.objects.filter(uid=uid)
         # 更新
@@ -873,64 +875,39 @@ def update_device_shadow(request):
         print('-------')
         print(resetTime)
         print('-------')
-
+        qs_dict = {
+            'updTime': nowTime,
+            'ip': ip
+        }
+        if channel:
+            qs_dict['channel'] = channel
+        if p2p_region:
+            qs_dict['p2p_region'] = p2p_region
+        if ucode:
+            qs_dict['ucode'] = ucode
+        if version:
+            qs_dict['version'] = version
+        if tz:
+            qs_dict['tz'] = tz
+        if video_code:
+            qs_dict['video'] = video_code
+        if cloud_vod:
+            qs_dict['cloud_vod'] = cloud_vod
+        if push_status:
+            qs_dict['detect_status'] = push_status
+        if pwd:
+            qs_dict['pwd'] = pwd
+        if is_alexa:
+            qs_dict['is_alexa'] = is_alexa
         if us_qs.exists():
-            update_dict = {
-                'updTime': nowTime,
-                'ip': ip
-            }
-            if channel:
-                update_dict['channel'] = channel
-            if p2p_region:
-                update_dict['p2p_region'] = p2p_region
-            if ucode:
-                update_dict['ucode'] = ucode
-            if version:
-                update_dict['version'] = version
-            if tz:
-                update_dict['tz'] = tz
-            if video_code:
-                update_dict['video'] = video_code
-            if cloud_vod:
-                update_dict['cloud_vod'] = cloud_vod
-            if push_status:
-                update_dict['detect_status'] = push_status
-            if pwd:
-                update_dict['pwd'] = pwd
-            us_qs.update(**update_dict)
+            us_qs.update(**qs_dict)
             # 如果推送状态开启,返回推送url
-            data = {}
-
             return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': {}})
         # 新增
         else:
-            create_dict = {
-                'uid': uid,
-                'addTime': nowTime,
-                'updTime': nowTime,
-                'ip': ip
-            }
-            if channel:
-                create_dict['channel'] = channel
-            if p2p_region:
-                create_dict['p2p_region'] = p2p_region
-            if ucode:
-                create_dict['ucode'] = ucode
-            if version:
-                create_dict['version'] = version
-            if tz:
-                create_dict['tz'] = tz
-            if video_code:
-                create_dict['video_code'] = video_code
-            if cloud_vod:
-                create_dict['cloud_vod'] = cloud_vod
-            if push_status:
-                create_dict['detect_status'] = push_status
-            if pwd:
-                create_dict['pwd'] = pwd
-            if resetTime:
-                create_dict['resetTime'] = resetTime
-            UidSetModel.objects.create(**create_dict)
+            qs_dict['uid'] = uid
+            qs_dict['addTime'] = nowTime
+            UidSetModel.objects.create(**qs_dict)
             # 如果推送状态开启,返回推送url
             return JsonResponse(status=200, data={'code': 0, 'msg': 'success', 'data': {}})
     else:

+ 2 - 0
Model/models.py

@@ -642,6 +642,8 @@ class UidSetModel(models.Model):
     pwd = models.CharField(max_length=32, default='', verbose_name=u'设备密码')
     # 设备重置后第一次启动时间
     resetTime = models.IntegerField(default=0, verbose_name='设备重置时间')
+    is_alexa = models.IntegerField(default=0, verbose_name='会否支持alexa') # 0:否,1:是
+    # is_azpush = models.IntegerField(default=0, verbose_name='会否自家推送服务') # 0:否,1:是
 
     class Meta:
         db_table = 'uid_set'

+ 0 - 3
Object/UidTokenObject.py

@@ -56,6 +56,3 @@ class UidTokenObject:
 
 # print(utko)
 
-'''
-
-'''