瀏覽代碼

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

guanhailong 3 年之前
父節點
當前提交
99d055db99
共有 1 個文件被更改,包括 8 次插入7 次删除
  1. 8 7
      AdminController/DeviceManagementController.py

+ 8 - 7
AdminController/DeviceManagementController.py

@@ -119,7 +119,7 @@ class DeviceManagement(View):
         # 添加APP设备类型
         app_bundle = request_dict.get(
             'AppBundle', '')[
-                   1:-1].split(',')  # '[1,2]' -> ['1','2']
+                     1:-1].split(',')  # '[1,2]' -> ['1','2']
         # app_device_type表数据
         model = request_dict.get('model', 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)
             if 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(
                 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')
             if not app_bundle_qs.exists():
                 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()
             app_bundle_qs = app_bundle_qs[(page - 1) * line:page * line]
             app_device_type_list = [app_bundle for app_bundle in app_bundle_qs]