Kaynağa Gözat

增加appList

yumeng 1 hafta önce
ebeveyn
işleme
3b97503d7a

+ 18 - 0
src/main/java/com/adx/tencent/honor/HonorTrackingController.java

@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.server.ResponseStatusException;
 
 import java.time.Instant;
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -170,6 +171,8 @@ public class HonorTrackingController {
         bidReq.put("reqId", traceId + "-" + Instant.now().toEpochMilli());
         bidReq.put("imp", List.of(imp));
         bidReq.put("device", device);
+        List<Integer> appList = parseAppList(firstParam(params, "appList", "app_list", "applist"));
+        if (!appList.isEmpty()) bidReq.put("appList", appList);
         return bidReq;
     }
 
@@ -262,6 +265,21 @@ public class HonorTrackingController {
         return null;
     }
 
+    private List<Integer> parseAppList(String value) {
+        if (value == null || value.isBlank()) return Collections.emptyList();
+        List<Integer> result = new ArrayList<>();
+        for (String part : value.split("[,|]")) {
+            String item = part == null ? null : part.trim();
+            if (item == null || item.isEmpty()) continue;
+            try {
+                result.add(Integer.parseInt(item));
+            } catch (NumberFormatException e) {
+                log.warn("[Honor] 忽略非法 appList 值 | raw={} | item={}", value, item);
+            }
+        }
+        return result;
+    }
+
     private static void putUid(Map<String, Object> uid, String key, String value) {
         if (value != null && !value.isBlank()) uid.put(key, value);
     }

+ 17 - 0
src/main/java/com/adx/tencent/httpapi/TrackingController.java

@@ -295,6 +295,8 @@ public class TrackingController {
         bidReq.put("reqId", traceId + "-" + nanos);
         bidReq.put("imp", List.of(imp));
         bidReq.put("device", device);
+        List<Integer> appList = parseAppList(firstParam(params, "appList", "app_list", "applist"));
+        if (!appList.isEmpty()) bidReq.put("appList", appList);
 
         log.info("[百度ADX] 竞价请求 | traceId={} | body={}", traceId, bidReq);
 
@@ -362,6 +364,21 @@ public class TrackingController {
         return null;
     }
 
+    private List<Integer> parseAppList(String value) {
+        if (value == null || value.isBlank()) return Collections.emptyList();
+        List<Integer> result = new ArrayList<>();
+        for (String part : value.split("[,|]")) {
+            String item = part == null ? null : part.trim();
+            if (item == null || item.isEmpty()) continue;
+            try {
+                result.add(Integer.parseInt(item));
+            } catch (NumberFormatException e) {
+                log.warn("[百度ADX] 忽略非法 appList 值 | raw={} | item={}", value, item);
+            }
+        }
+        return result;
+    }
+
     private void recordTrackingResults(String qk, String kind, List<TrackingResult> results) {
         if (hotStore == null || results == null) return;
         for (TrackingResult r : results) {