Browse Source

Merge branch 'test' of http://192.168.136.99:3000/servers/ASJServer into ming

zhangdongming 3 years ago
parent
commit
d446041303
1 changed files with 32 additions and 4 deletions
  1. 32 4
      AdminController/DeviceManagementController.py

+ 32 - 4
AdminController/DeviceManagementController.py

@@ -11,7 +11,7 @@ from django.views.generic.base import View
 from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET
 from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET
 from Model.models import Device_Info, UidSetModel, LogModel, UID_Bucket, Unused_Uid_Meal, Order_Model, StsCrdModel, \
 from Model.models import Device_Info, UidSetModel, LogModel, UID_Bucket, Unused_Uid_Meal, Order_Model, StsCrdModel, \
     VodHlsModel, ExperienceContextModel, DeviceTypeModel, Equipment_Info, UidUserModel, ExperienceAiModel, AiService, \
     VodHlsModel, ExperienceContextModel, DeviceTypeModel, Equipment_Info, UidUserModel, ExperienceAiModel, AiService, \
-    AppBundle, App_Info
+    AppBundle, App_Info, AppDeviceType, DeviceNameLanguage
 from Object.ResponseObject import ResponseObject
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
 from Object.TokenObject import TokenObject
 from Service.CommonService import CommonService
 from Service.CommonService import CommonService
@@ -70,6 +70,8 @@ class DeviceManagement(View):
                 return self.get_app_bundle_id_list(response)
                 return self.get_app_bundle_id_list(response)
             elif operation == 'editAppDeviceType':  # 编辑app设备类型数据
             elif operation == 'editAppDeviceType':  # 编辑app设备类型数据
                 return self.edit_app_device_type(request_dict, response)
                 return self.edit_app_device_type(request_dict, response)
+            elif operation == 'deleteAppDeviceType':  # 删除app设备类型数据
+                return self.delete_app_device_type(request_dict, response)
             else:
             else:
                 return response.json(444, 'operation')
                 return response.json(444, 'operation')
 
 
@@ -400,8 +402,10 @@ class DeviceManagement(View):
                 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'),
                 lang=F('app_device_type__devicenamelanguage__lang'),
                 lang=F('app_device_type__devicenamelanguage__lang'),
                 name=F('app_device_type__devicenamelanguage__name'),
                 name=F('app_device_type__devicenamelanguage__name'),
-                sort=F('app_device_type__devicenamelanguage__sort')).values('id', 'app_device_type__id', 'model', 'type', 'icon', 'lang',
-                                                                            'name', 'sort').order_by(
+                sort=F('app_device_type__devicenamelanguage__sort')).values('id', 'app_device_type__id', 'model',
+                                                                            'type', 'icon',
+                                                                            'app_device_type__devicenamelanguage__id',
+                                                                            'lang', 'name', 'sort').order_by(
                 '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)
@@ -425,15 +429,39 @@ class DeviceManagement(View):
 
 
     @staticmethod
     @staticmethod
     def edit_app_device_type(request_dict, response):
     def edit_app_device_type(request_dict, response):
+        # app_device_type表数据
         app_device_type_id = request_dict.get('app_device_type__id', None)
         app_device_type_id = request_dict.get('app_device_type__id', None)
         model = request_dict.get('model', None)
         model = request_dict.get('model', None)
         type = request_dict.get('type', None)
         type = request_dict.get('type', None)
+        icon = request_dict.get('icon', None)
+        # device_name_language表数据
+        device_name_language_id = request_dict.get('app_device_type__devicenamelanguage__id', None)
         lang = request_dict.get('lang', None)
         lang = request_dict.get('lang', None)
         name = request_dict.get('name', None)
         name = request_dict.get('name', None)
         sort = request_dict.get('sort', None)
         sort = request_dict.get('sort', None)
-        icon = request_dict.get('icon', None)
 
 
+        if not all([app_device_type_id, model, type, icon, device_name_language_id, lang, name, sort]):
+            return response.json(444)
+
+        try:
+            with transaction.atomic():
+                AppDeviceType.objects.filter(id=app_device_type_id).update(model=model, type=type, icon=icon)
+                DeviceNameLanguage.objects.filter(id=device_name_language_id).update(lang=lang, name=name, sort=sort)
+            return response.json(0)
+        except Exception as e:
+            print(e)
+            return response.json(500, repr(e))
+
+    @staticmethod
+    def delete_app_device_type(request_dict, response):
+        app_bundle_id = request_dict.get('appBundleId', None)
+        app_device_type_id = request_dict.get('appDeviceTypeId', None)
+        if not all([app_bundle_id, app_device_type_id]):
+            return response.json(444)
         try:
         try:
+            app_bundle_qs = AppBundle.objects.get(id=app_bundle_id)
+            app_device_type_qs = AppDeviceType.objects.filter(id=app_device_type_id)
+            app_bundle_qs.app_device_type.remove(*app_device_type_qs)
             return response.json(0)
             return response.json(0)
         except Exception as e:
         except Exception as e:
             print(e)
             print(e)