|
@@ -7,6 +7,7 @@ import com.adx.tencent.conversionsync.ConversionSyncRunner;
|
|
|
import com.adx.tencent.conversionsync.ConversionSyncService;
|
|
import com.adx.tencent.conversionsync.ConversionSyncService;
|
|
|
import com.adx.tencent.conversionsync.ManualTencentCallbackService;
|
|
import com.adx.tencent.conversionsync.ManualTencentCallbackService;
|
|
|
import com.adx.tencent.conversionsync.RetryService;
|
|
import com.adx.tencent.conversionsync.RetryService;
|
|
|
|
|
+import com.adx.tencent.vivo.service.VivoRetryService;
|
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.lang.Nullable;
|
|
import org.springframework.lang.Nullable;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -28,19 +29,22 @@ public class AdminController {
|
|
|
private final ConversionSyncService conversionSyncer;
|
|
private final ConversionSyncService conversionSyncer;
|
|
|
private final RetryService retryService;
|
|
private final RetryService retryService;
|
|
|
private final ManualTencentCallbackService manualTencentCallbackService;
|
|
private final ManualTencentCallbackService manualTencentCallbackService;
|
|
|
|
|
+ private final VivoRetryService vivoRetryService;
|
|
|
|
|
|
|
|
public AdminController(ConversionClient conversionClient,
|
|
public AdminController(ConversionClient conversionClient,
|
|
|
@Nullable ConversionSyncRunner conversionSyncRunner,
|
|
@Nullable ConversionSyncRunner conversionSyncRunner,
|
|
|
@Nullable ConversionBackfillJobService backfillJobService,
|
|
@Nullable ConversionBackfillJobService backfillJobService,
|
|
|
@Nullable ConversionSyncService conversionSyncer,
|
|
@Nullable ConversionSyncService conversionSyncer,
|
|
|
@Nullable RetryService retryService,
|
|
@Nullable RetryService retryService,
|
|
|
- @Nullable ManualTencentCallbackService manualTencentCallbackService) {
|
|
|
|
|
|
|
+ @Nullable ManualTencentCallbackService manualTencentCallbackService,
|
|
|
|
|
+ @Nullable VivoRetryService vivoRetryService) {
|
|
|
this.conversionClient = conversionClient;
|
|
this.conversionClient = conversionClient;
|
|
|
this.conversionSyncRunner = conversionSyncRunner;
|
|
this.conversionSyncRunner = conversionSyncRunner;
|
|
|
this.backfillJobService = backfillJobService;
|
|
this.backfillJobService = backfillJobService;
|
|
|
this.conversionSyncer = conversionSyncer;
|
|
this.conversionSyncer = conversionSyncer;
|
|
|
this.retryService = retryService;
|
|
this.retryService = retryService;
|
|
|
this.manualTencentCallbackService = manualTencentCallbackService;
|
|
this.manualTencentCallbackService = manualTencentCallbackService;
|
|
|
|
|
+ this.vivoRetryService = vivoRetryService;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@PostMapping("/conversions/query")
|
|
@PostMapping("/conversions/query")
|
|
@@ -103,6 +107,18 @@ public class AdminController {
|
|
|
return manualTencentCallbackService.replayDeductedCallback(id);
|
|
return manualTencentCallbackService.replayDeductedCallback(id);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @PostMapping("/callbacks/vivo/replay-src-id")
|
|
|
|
|
+ public Object replayVivoCallbacksReplacingSrcId(@RequestBody(required = false) Map<String, Object> body) {
|
|
|
|
|
+ if (vivoRetryService == null) {
|
|
|
|
|
+ throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE,
|
|
|
|
|
+ "vivo retry service is not configured");
|
|
|
|
|
+ }
|
|
|
|
|
+ String oldSrcId = toStringValue(body != null ? body.get("oldSrcId") : null, "ds-202608201718");
|
|
|
|
|
+ String newSrcId = toStringValue(body != null ? body.get("newSrcId") : null, "ds-202608253668");
|
|
|
|
|
+ int limit = toInt(body != null ? body.get("limit") : null);
|
|
|
|
|
+ return vivoRetryService.replayFailedCallbacksReplacingSrcId(oldSrcId, newSrcId, limit);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private static int toInt(Object v) {
|
|
private static int toInt(Object v) {
|
|
|
if (v == null) return 0;
|
|
if (v == null) return 0;
|
|
|
if (v instanceof Number n) return n.intValue();
|
|
if (v instanceof Number n) return n.intValue();
|
|
@@ -115,6 +131,12 @@ public class AdminController {
|
|
|
try { return Long.parseLong(v.toString()); } catch (NumberFormatException e) { return 0L; }
|
|
try { return Long.parseLong(v.toString()); } catch (NumberFormatException e) { return 0L; }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static String toStringValue(Object v, String defaultValue) {
|
|
|
|
|
+ if (v == null) return defaultValue;
|
|
|
|
|
+ String s = v.toString();
|
|
|
|
|
+ return s == null || s.isBlank() ? defaultValue : s.trim();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private static List<Integer> parseOffsets(Map<String, Object> body) {
|
|
private static List<Integer> parseOffsets(Map<String, Object> body) {
|
|
|
if (body == null || body.isEmpty()) {
|
|
if (body == null || body.isEmpty()) {
|
|
|
return defaultBackfillOffsets();
|
|
return defaultBackfillOffsets();
|