ソースを参照

优化:更改参数名

guanhailong 3 年 前
コミット
f2a5ea7b17
1 ファイル変更19 行追加3 行削除
  1. 19 3
      AdminController/DeviceManagementController.py

+ 19 - 3
AdminController/DeviceManagementController.py

@@ -83,7 +83,23 @@ class DeviceManagement(View):
 
     @staticmethod
     def up_file(request_dict, request, response):
-        pass
+        model = request_dict.get('model', None)
+        type = request_dict.get('type', None)
+        iconFile = request.FILES.get('iconFile', None)
+        lang = request_dict.get('lang', None)
+        name = request_dict.get('name', None)
+        sort = request_dict.get('sort', None)
+
+        if not all([model, type, iconFile, lang, name, sort]):
+            return response.json(444)
+        model = int(model)
+        icon = iconFile.name
+        now_time = int(time.time())
+        auth = oss2.Auth(OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET)
+        bucket = oss2.Bucket(auth, 'oss-cn-shenzhen.aliyuncs.com', 'ansjer-static-resources')
+        key = '' + icon  # 选择存放图片的位置
+        # 地址:
+        bucket.put_object(key=key, data=iconFile)
 
 
     @classmethod
@@ -105,7 +121,7 @@ class DeviceManagement(View):
         # 添加APP设备类型
         app_bundle_name = request_dict.get('appbundleName', None)
         app_bundle_id = request_dict.get(
-            'appBundleId', '')[
+            'app_bundle_id', '')[
                      1:-1].split(',')  # '[1,2]' -> ['1','2']
         # app_device_type表数据
         model = request_dict.get('model', None)
@@ -444,7 +460,7 @@ class DeviceManagement(View):
 
     @staticmethod
     def get_app_device_type_list(request_dict, response):
-        app_bundle_id = request_dict.get('appBundleId', None)
+        app_bundle_id = request_dict.get('app_bundle_id', None)
         lang = request_dict.get('lang', 'cn')
         model = request_dict.get('model', None)
         type = request_dict.get('type', None)