Kaynağa Gözat

设备影子信息优化 及修正

chenjunkai 6 yıl önce
ebeveyn
işleme
49f10ec95c

+ 1 - 4
Controller/DetectController.py

@@ -14,24 +14,21 @@
 import json
 import json
 import os
 import os
 import time
 import time
-import urllib
 from pyfcm import FCMNotification
 from pyfcm import FCMNotification
 
 
 import apns2
 import apns2
 import jpush as jpush
 import jpush as jpush
 import oss2
 import oss2
-import requests
 from django.utils.decorators import method_decorator
 from django.utils.decorators import method_decorator
 from django.views.decorators.csrf import csrf_exempt
 from django.views.decorators.csrf import csrf_exempt
 from django.views.generic.base import View
 from django.views.generic.base import View
-from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, SERVER_DOMAIN, BASE_DIR, DETECT_PUSH_DOMAIN
+from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, BASE_DIR, DETECT_PUSH_DOMAIN
 from Model.models import Device_Info, VodHlsModel, Equipment_Info, UidSetModel, UidPushModel
 from Model.models import Device_Info, VodHlsModel, Equipment_Info, UidSetModel, UidPushModel
 from Object.ResponseObject import ResponseObject
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
 from Object.TokenObject import TokenObject
 from Object.UidTokenObject import UidTokenObject
 from Object.UidTokenObject import UidTokenObject
 from django.http import JsonResponse
 from django.http import JsonResponse
 from Object.RedisObject import RedisObject
 from Object.RedisObject import RedisObject
-from django.db import transaction
 
 
 
 
 # http://192.168.136.40:8077/detect/changeStatus?uid=JW3684H8BSHG9TTM111A&token_val=18071adc03536302f34&appBundleId=com.ansjer.zccloud_ab&push_type=2&token=local&status=1&app_type=1
 # http://192.168.136.40:8077/detect/changeStatus?uid=JW3684H8BSHG9TTM111A&token_val=18071adc03536302f34&appBundleId=com.ansjer.zccloud_ab&push_type=2&token=local&status=1&app_type=1

+ 22 - 3
Controller/EquipmentManager.py

@@ -5,7 +5,7 @@ import threading
 
 
 import simplejson as json
 import simplejson as json
 from django.utils import timezone
 from django.utils import timezone
-from Model.models import Device_User, Device_Info, UID_Bucket, UID_Preview, UidSetModel, Equipment_Info
+from Model.models import Device_User, Device_Info, UID_Bucket, UID_Preview, UidSetModel, UidPushModel
 from django.db.models import Q
 from django.db.models import Q
 from Object.ResponseObject import ResponseObject
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
 from Object.TokenObject import TokenObject
@@ -197,6 +197,13 @@ def modifyUserEquipmentInterface(request):
     else:
     else:
         qs = Device_Info.objects.filter(userID_id=userID, id=id)
         qs = Device_Info.objects.filter(userID_id=userID, id=id)
         res = CommonService.qs_to_dict(qs)
         res = CommonService.qs_to_dict(qs)
+        uid = qs[0].UID
+        nickname = qs[0].NickName
+        # 增加设备影子信息修改昵称 start
+        us_qs = UidSetModel.objects.filter(uid=uid)
+        if us_qs.exists():
+            us_qs.update(nickname=nickname)
+        # end
         return response.json(0, res)
         return response.json(0, res)
 
 
 
 
@@ -330,6 +337,16 @@ def addInterface(request):
                                                  NickName=NickName, View_Account=View_Account,
                                                  NickName=NickName, View_Account=View_Account,
                                                  View_Password=View_Password, Type=Type, ChannelIndex=ChannelIndex)
                                                  View_Password=View_Password, Type=Type, ChannelIndex=ChannelIndex)
                         userDevice.save()
                         userDevice.save()
+                        nowTime = int(time.time())
+                        uid_set_create_dict = {
+                            'uid': UID,
+                            'addTime': nowTime,
+                            'updTime': nowTime,
+                            'ip': CommonService.get_ip_address(request),
+                            'channel': ChannelIndex,
+                            'nickname': NickName,
+                        }
+                        UidSetModel.objects.create(**uid_set_create_dict)
                     except Exception as e:
                     except Exception as e:
                         return response.json(10, repr(e))
                         return response.json(10, repr(e))
                     else:
                     else:
@@ -549,9 +566,11 @@ def deleteInterface(request):
             if dv_qs[0].isShare:
             if dv_qs[0].isShare:
                 dv_qs.delete()
                 dv_qs.delete()
             else:
             else:
-                # 主用户删除设备
+                # a.主用户删除设备
                 dv_qs.delete()
                 dv_qs.delete()
-                # 分享获得用户假删除
+                # 删除设备影子信息uid_set   外键关联删除设备推送配置信息 uid_push
+                UidSetModel.objects.filter(uid=uid).delete()
+                # b.分享获得用户假删除
                 ud_dv_qs = Device_Info.objects.filter(UID=uid, isShare=True, primaryUserID=userID)
                 ud_dv_qs = Device_Info.objects.filter(UID=uid, isShare=True, primaryUserID=userID)
                 if ud_dv_qs.exists():
                 if ud_dv_qs.exists():
                     ud_dv_qs.update(isExist=0)
                     ud_dv_qs.update(isExist=0)