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

算法小店查看详情增加返回推荐设备类型以及购买链接

zhangdongming 2 жил өмнө
parent
commit
9015420200

+ 9 - 1
Controller/AlgorithmShop/AlgorithmShopController.py

@@ -9,9 +9,10 @@
 import logging
 import time
 
+from django.db.models import F
 from django.views.generic.base import View
 
-from Model.models import DeviceAlgorithmExplain, DeviceAlgorithmBanner, DeviceUidAlgorithmType
+from Model.models import DeviceAlgorithmExplain, DeviceAlgorithmBanner, DeviceUidAlgorithmType, DeviceTypeAlgorithmInfo
 from Object.ResponseObject import ResponseObject
 from Object.TokenObject import TokenObject
 
@@ -135,6 +136,13 @@ class AlgorithmShopView(View):
                 'riskWarning': item['risk_warning'],
                 'basicFunction': item['algorithm_type__basic_function'],
             }
+            dt_info_qs = DeviceTypeAlgorithmInfo.objects.filter(algorithm_type=algorithm_dict['type']) \
+                .annotate(deviceName=F('device_name'), deviceType=F('device_type'),
+                          algorithmType=F('algorithm_type'),
+                          typeIcon=F('type_icon'),
+                          deviceLink=F('device_link'), ) \
+                .values('deviceName', 'deviceType', 'typeIcon', 'deviceLink')
+            algorithm_dict['recommendDevices'] = list(dt_info_qs)
             if uid:
                 setting = cls.get_uid_algorithm_info(item['algorithm_type__id'], uid)
                 algorithm_dict['setting'] = setting if setting else {'status': 0, 'function': {}}