فهرست منبع

2024-10-18 文章匹配小程序服务 minigram 接口增加 choose_minigram接口的重定向

luojunhui 6 ماه پیش
والد
کامیت
57667ce3f6
1فایلهای تغییر یافته به همراه20 افزوده شده و 1 حذف شده
  1. 20 1
      applications/deal/minigram.py

+ 20 - 1
applications/deal/minigram.py

@@ -1,6 +1,8 @@
 """
 """
 @author: luojunhui
 @author: luojunhui
 """
 """
+from applications.functions.forward import forward_requests
+
 minigram_map = {
 minigram_map = {
     1: {
     1: {
         # 25: {
         # 25: {
@@ -57,8 +59,10 @@ class Minigram(object):
     """
     """
     小程序卡片
     小程序卡片
     """
     """
+    NEW_STRATEGY = "strategy_v2"
 
 
     def __init__(self, params):
     def __init__(self, params):
+        self.strategy = None
         self.params = params
         self.params = params
         self.business_type = None
         self.business_type = None
         self.mini_code = None
         self.mini_code = None
@@ -73,6 +77,9 @@ class Minigram(object):
             self.business_type = self.params['businessType']
             self.business_type = self.params['businessType']
             self.mini_code = self.params['miniCode']
             self.mini_code = self.params['miniCode']
             self.trace_id = self.params['traceId']
             self.trace_id = self.params['traceId']
+            self.strategy = self.params.get('strategy')
+            if not self.strategy:
+                self.strategy = "strategy_v1"
             return None
             return None
         except Exception as e:
         except Exception as e:
             response = {
             response = {
@@ -107,4 +114,16 @@ class Minigram(object):
         """
         """
         :return:
         :return:
         """
         """
-        return self.check_params() if self.check_params() else self.choose_minigram()
+        params_error = self.check_params()
+        if params_error:
+            return params_error
+        else:
+            if self.strategy == self.NEW_STRATEGY:
+                response = await forward_requests(
+                    params=self.params,
+                    api="choose_minigram"
+                )
+                return response
+            else:
+                return self.choose_minigram()
+