|
@@ -68,6 +68,8 @@ class DeviceManagement(View):
|
|
|
return self.get_app_device_type_list(request_dict, response)
|
|
|
elif operation == 'getAppBundleIdList': # 获取app包id数据
|
|
|
return self.get_app_bundle_id_list(response)
|
|
|
+ elif operation == 'editAppDeviceType': # 编辑app设备类型数据
|
|
|
+ return self.edit_app_device_type(request_dict, response)
|
|
|
else:
|
|
|
return response.json(444, 'operation')
|
|
|
|
|
@@ -376,11 +378,8 @@ class DeviceManagement(View):
|
|
|
|
|
|
@staticmethod
|
|
|
def get_app_device_type_list(request_dict, response):
|
|
|
- app_bundle_id = request_dict.get('appBundleId', 'com.ansjer.zccloud')
|
|
|
- model = request_dict.get('model', None)
|
|
|
- type = request_dict.get('type', None)
|
|
|
+ app_bundle_id = request_dict.get('appBundleId', None)
|
|
|
lang = request_dict.get('lang', 'cn')
|
|
|
- name = request_dict.get('name', None)
|
|
|
|
|
|
pageNo = request_dict.get('pageNo', None)
|
|
|
pageSize = request_dict.get('pageSize', None)
|
|
@@ -391,21 +390,23 @@ class DeviceManagement(View):
|
|
|
page = int(pageNo)
|
|
|
line = int(pageSize)
|
|
|
try:
|
|
|
- app_bundle_qs = AppBundle.objects.filter()
|
|
|
- if app_bundle_id:
|
|
|
- app_bundle_qs = app_bundle_qs.filter(app_bundle_id=app_bundle_id)
|
|
|
+ if not app_bundle_id:
|
|
|
+ app_bundle_id = 'com.ansjer.zccloud'
|
|
|
+ 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)
|
|
|
|
|
|
- total = app_bundle_qs.count()
|
|
|
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'),
|
|
|
lang=F('app_device_type__devicenamelanguage__lang'),
|
|
|
name=F('app_device_type__devicenamelanguage__name'),
|
|
|
- sort=F('app_device_type__devicenamelanguage__sort')).values('model', 'type', 'icon', 'lang', 'name',
|
|
|
- 'sort')[(page - 1) * line:page * line]
|
|
|
+ sort=F('app_device_type__devicenamelanguage__sort')).values('id', 'app_device_type__id', 'model', 'type', 'icon', 'lang',
|
|
|
+ 'name', 'sort').order_by(
|
|
|
+ 'app_device_type__devicenamelanguage__sort')
|
|
|
if not app_bundle_qs.exists():
|
|
|
return response.json(0)
|
|
|
+ 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]
|
|
|
return response.json(0, {'list': app_device_type_list, 'total': total})
|
|
|
except Exception as e:
|
|
@@ -421,3 +422,19 @@ class DeviceManagement(View):
|
|
|
except Exception as e:
|
|
|
print(e)
|
|
|
return response.json(500, repr(e))
|
|
|
+
|
|
|
+ @staticmethod
|
|
|
+ def edit_app_device_type(request_dict, response):
|
|
|
+ app_device_type_id = request_dict.get('app_device_type__id', None)
|
|
|
+ model = request_dict.get('model', None)
|
|
|
+ type = request_dict.get('type', None)
|
|
|
+ lang = request_dict.get('lang', None)
|
|
|
+ name = request_dict.get('name', None)
|
|
|
+ sort = request_dict.get('sort', None)
|
|
|
+ icon = request_dict.get('icon', None)
|
|
|
+
|
|
|
+ try:
|
|
|
+ return response.json(0)
|
|
|
+ except Exception as e:
|
|
|
+ print(e)
|
|
|
+ return response.json(500, repr(e))
|