소스 검색

修复添加时分享主用户问题

chenshibin 4 년 전
부모
커밋
55073e3315
2개의 변경된 파일34개의 추가작업 그리고 50개의 파일을 삭제
  1. 17 31
      Controller/EquipmentManager.py
  2. 17 19
      Controller/EquipmentManagerV3.py

+ 17 - 31
Controller/EquipmentManager.py

@@ -392,49 +392,35 @@ def addInterface(request):
                 pass
 
                 pk = CommonService.getUserID(getUser=False)
-
-
-
                 userName = Device_User.objects.get(userID=userID).username
                 main_exist = Device_Info.objects.filter(UID=UID)
                 main_exist = main_exist.filter(~Q(vodPrimaryUserID='')).values('vodPrimaryUserID', 'vodPrimaryMaster')
-                vodPrimaryUserID = userID
+
+                vodPrimaryUserID = ''
                 vodPrimaryMaster = userName
+                primaryUserID = ''
+                primaryMaster = ''
+                isShare = False
+
+                is_bind = Device_Info.objects.filter(UID=UID, isShare=False).values('userID__userID', 'primaryUserID', 'primaryMaster')
+
                 if main_exist.exists():
                     vodPrimaryUserID = main_exist[0]['vodPrimaryUserID']
                     vodPrimaryMaster = main_exist[0]['vodPrimaryMaster']
 
-                is_bind = Device_Info.objects.filter(UID=UID, isShare=False).values('userID__userID', 'vodPrimaryUserID')
-                # 判断是否有已绑定用户
-                isvodPrimaryUserID = ''
-                for forbind in is_bind:
-                    if forbind['vodPrimaryUserID'] != '':
-                        isvodPrimaryUserID = forbind['vodPrimaryUserID']
-
-                if isCheckMainUser != '1':
-                    if main_exist.exists():
-                        vodPrimaryUserID = main_exist[0]['vodPrimaryUserID']
-                        vodPrimaryMaster = main_exist[0]['vodPrimaryMaster']
-                    else:
-                        vodPrimaryUserID = ''
-                        vodPrimaryMaster = ''
+                if is_bind.exists():
+                    primaryUserID = is_bind[0]['primaryUserID']
+                    primaryMaster = is_bind[0]['primaryMaster']
+                    isShare = True
 
                 isusermain = False
-                if is_bind and isvodPrimaryUserID != userID and isvodPrimaryUserID != '':
+                if (vodPrimaryUserID != userID and vodPrimaryUserID != '') or (primaryUserID != userID and primaryUserID != ''):
                     isusermain = True
 
-                # uid_main_exist = UIDMainUser.objects.filter(UID=UID).values('UID', 'user_id')
-                # if uid_main_exist.exists():
-                #     vodPrimaryUserID = uid_main_exist[0]['user_id']
-                #     vodPrimaryMaster = Device_User.objects.get(userID=vodPrimaryUserID).username
-                #
-                #     if vodPrimaryUserID != userID:
-                #         isusermain = True
-
                 # 判断是否有已绑定用户
                 if isCheckMainUser == '1' and isusermain:
                     res = {
-                        'id': pk,
+                        'id': id,
                         'userID': userID,
                         'NickName': NickName,
                         'UID': UID,
@@ -442,9 +428,9 @@ def addInterface(request):
                         'View_Password': View_Password,
                         'ChannelIndex': ChannelIndex,
                         'Type': Type,
-                        'isShare': False,
-                        'primaryUserID': '',
-                        'primaryMaster': '',
+                        'isShare': isShare,
+                        'primaryUserID': primaryUserID,
+                        'primaryMaster': primaryMaster,
                         'vodPrimaryUserID': vodPrimaryUserID,
                         'vodPrimaryMaster': vodPrimaryMaster,
                         'data_joined': '',

+ 17 - 19
Controller/EquipmentManagerV3.py

@@ -77,7 +77,7 @@ class EquipmentManagerV3(View):
         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]):  # Type和ChannelIndex可能为0
             return response.json(444, {'param': 'UID, NickName, View_Account, Type, ChannelIndex'})
 
@@ -100,29 +100,27 @@ class EquipmentManagerV3(View):
         userName = Device_User.objects.get(userID=userID).username
         main_exist = Device_Info.objects.filter(UID=UID)
         main_exist = main_exist.filter(~Q(vodPrimaryUserID='')).values('vodPrimaryUserID', 'vodPrimaryMaster')
-        vodPrimaryUserID = userID
+
+        vodPrimaryUserID = ''
         vodPrimaryMaster = userName
+        primaryUserID = ''
+        primaryMaster = ''
+        isShare = False
+
+        is_bind = Device_Info.objects.filter(UID=UID, isShare=False).values('userID__userID', 'primaryUserID', 'primaryMaster')
+
         if main_exist.exists():
             vodPrimaryUserID = main_exist[0]['vodPrimaryUserID']
             vodPrimaryMaster = main_exist[0]['vodPrimaryMaster']
 
-        is_bind = Device_Info.objects.filter(UID=UID, isShare=False).values('userID__userID', 'vodPrimaryUserID')
-        isvodPrimaryUserID = ''
-
-        for forbind in is_bind:
-            if forbind['vodPrimaryUserID'] != '':
-                isvodPrimaryUserID = forbind['vodPrimaryUserID']
+        if is_bind.exists():
+            primaryUserID = is_bind[0]['primaryUserID']
+            primaryMaster = is_bind[0]['primaryMaster']
+            isShare = True
 
-        if isCheckMainUser != '1' :
-            if main_exist.exists():
-                vodPrimaryUserID = main_exist[0]['vodPrimaryUserID']
-                vodPrimaryMaster = main_exist[0]['vodPrimaryMaster']
-            else:
-                vodPrimaryUserID = ''
-                vodPrimaryMaster = ''
 
         isusermain = False
-        if is_bind and isvodPrimaryUserID != userID and isvodPrimaryUserID != '':
+        if (vodPrimaryUserID != userID and vodPrimaryUserID != '') or (primaryUserID != userID and primaryUserID != ''):
             isusermain = True
 
         # 判断是否有已绑定用户
@@ -136,9 +134,9 @@ class EquipmentManagerV3(View):
                 'View_Password': View_Password,
                 'ChannelIndex': ChannelIndex,
                 'Type': Type,
-                'isShare': False,
-                'primaryUserID': '',
-                'primaryMaster': '',
+                'isShare': isShare,
+                'primaryUserID': primaryUserID,
+                'primaryMaster': primaryMaster,
                 'vodPrimaryUserID': vodPrimaryUserID,
                 'vodPrimaryMaster': vodPrimaryMaster,
                 'data_joined': '',