Эх сурвалжийг харах

新增算法小店新增获取OTA下载链接

zhangdongming 1 жил өмнө
parent
commit
12216abc7e

+ 11 - 2
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)
@@ -322,8 +325,11 @@ class AlgorithmShopView(View):
                 .values('algorithm_type__id', 'algorithm_type__type',
                         'algorithm_type__icon_url',
                         'title', 'subtitle', 'algorithm_type__image_url',
-                        'algorithm_type__basic_function', 'concerning')
+                        '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:
@@ -331,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'],
@@ -340,7 +348,8 @@ class AlgorithmShopView(View):
                     'subtitle': item['subtitle'],
                     'setting': setting,
                     'basicFunction': item['algorithm_type__basic_function'],
-                    'concerning': item['concerning']
+                    'concerning': item['concerning'],
+                    'resource': resource
                 })
             return response.json(0, algorithm_list)
         except Exception as e:

+ 1 - 0
Model/models.py

@@ -3092,6 +3092,7 @@ class DeviceAlgorithmType(models.Model):
     image_url = models.CharField(max_length=255, default='', verbose_name='图片地址')
     details_img_url = models.CharField(max_length=255, default='', verbose_name='详情图')
     icon_url = models.CharField(max_length=255, default='', verbose_name='图标地址')
+    resource = models.JSONField(null=True, verbose_name='算法模型bin文件地址JSON格式')
     created_time = models.IntegerField(default=0, verbose_name='创建时间')
 
     class Meta: