Procházet zdrojové kódy

优化 获取app设备类型数据(添加筛选参数)

guanhailong před 3 roky
rodič
revize
99d055db99
1 změnil soubory, kde provedl 8 přidání a 7 odebrání
  1. 8 7
      AdminController/DeviceManagementController.py

+ 8 - 7
AdminController/DeviceManagementController.py

@@ -119,7 +119,7 @@ class DeviceManagement(View):
         # 添加APP设备类型
         # 添加APP设备类型
         app_bundle = request_dict.get(
         app_bundle = request_dict.get(
             'AppBundle', '')[
             'AppBundle', '')[
-                   1:-1].split(',')  # '[1,2]' -> ['1','2']
+                     1:-1].split(',')  # '[1,2]' -> ['1','2']
         # app_device_type表数据
         # app_device_type表数据
         model = request_dict.get('model', None)
         model = request_dict.get('model', None)
         type = request_dict.get('type', None)
         type = request_dict.get('type', None)
@@ -473,12 +473,6 @@ class DeviceManagement(View):
             app_bundle_qs = AppBundle.objects.filter(app_bundle_id=app_bundle_id)
             app_bundle_qs = AppBundle.objects.filter(app_bundle_id=app_bundle_id)
             if lang:
             if lang:
                 app_bundle_qs = app_bundle_qs.filter(app_device_type__devicenamelanguage__lang=lang)
                 app_bundle_qs = app_bundle_qs.filter(app_device_type__devicenamelanguage__lang=lang)
-            if name:
-                app_bundle_qs = app_bundle_qs.filter(app_device_type__devicenamelanguage__name=name)
-            if model:
-                app_bundle_qs = app_bundle_qs.filter(app_device_type__model=model)
-            if type:
-                app_bundle_qs = app_bundle_qs.filter(app_device_type__type=type)
 
 
             app_bundle_qs = app_bundle_qs.annotate(
             app_bundle_qs = app_bundle_qs.annotate(
                 model=F('app_device_type__model'), type=F('app_device_type__type'), icon=F('app_device_type__icon'),
                 model=F('app_device_type__model'), type=F('app_device_type__type'), icon=F('app_device_type__icon'),
@@ -491,6 +485,13 @@ class DeviceManagement(View):
                 'app_device_type__devicenamelanguage__sort')
                 'app_device_type__devicenamelanguage__sort')
             if not app_bundle_qs.exists():
             if not app_bundle_qs.exists():
                 return response.json(0)
                 return response.json(0)
+            app_bundle_qs = app_bundle_qs.all()
+            if name:
+                app_bundle_qs = app_bundle_qs.filter(name=name)
+            if model:
+                app_bundle_qs = app_bundle_qs.filter(model=model)
+            if type:
+                app_bundle_qs = app_bundle_qs.filter(type=type)
             total = app_bundle_qs.count()
             total = app_bundle_qs.count()
             app_bundle_qs = app_bundle_qs[(page - 1) * line:page * line]
             app_bundle_qs = app_bundle_qs[(page - 1) * line:page * line]
             app_device_type_list = [app_bundle for app_bundle in app_bundle_qs]
             app_device_type_list = [app_bundle for app_bundle in app_bundle_qs]