Преглед на файлове

优化518算法小店获取OTA链接

zhangdongming преди 1 година
родител
ревизия
215a2ec7ad
променени са 1 файла, в които са добавени 8 реда и са изтрити 1 реда
  1. 8 1
      Controller/AlgorithmShop/AlgorithmShopController.py

+ 8 - 1
Controller/AlgorithmShop/AlgorithmShopController.py

@@ -315,6 +315,9 @@ class AlgorithmShopView(View):
             uid = request_dict.get('uid', None)
             version = request_dict.get('version', 'v1')
             algorithm_qs = DeviceAlgorithmExplain.objects.filter(lang=lang)
+            device_ver = request_dict.get('deviceVer', None)
+            device_code = request_dict.get('deviceCode', None)
+            LOGGER.info(f'AlgorithmShopView.algorithm_list ver:{device_ver},code:{device_code}')
             types = [0, 1, 3, 4, 5]
             if version == 'v1':
                 algorithm_qs = algorithm_qs.filter(algorithm_type__type__in=types)
@@ -325,6 +328,8 @@ class AlgorithmShopView(View):
                         'algorithm_type__basic_function', 'concerning',
                         'algorithm_type__resource')
             algorithm_list = []
+            device_code = device_code[0:4] if device_code else device_code
+
             if not algorithm_qs.exists():
                 return response.json(0, algorithm_list)
             for item in algorithm_qs:
@@ -332,6 +337,8 @@ class AlgorithmShopView(View):
                 if uid:
                     setting = cls.get_uid_algorithm_info(item['algorithm_type__id'], uid)
                     setting = setting if setting else {'status': 0, 'function': {}}
+                resource = item['algorithm_type__resource']
+                resource = resource.get(device_code, '') if resource else ''
                 algorithm_list.append({
                     'typeId': item['algorithm_type__id'],
                     'type': item['algorithm_type__type'],
@@ -342,7 +349,7 @@ class AlgorithmShopView(View):
                     'setting': setting,
                     'basicFunction': item['algorithm_type__basic_function'],
                     'concerning': item['concerning'],
-                    'resource': item['algorithm_type__resource']
+                    'resource': resource
                 })
             return response.json(0, algorithm_list)
         except Exception as e: