|
@@ -12,7 +12,6 @@ import org.slf4j.LoggerFactory;
|
|
|
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.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.ResponseStatus;
|
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
import org.springframework.web.server.ResponseStatusException;
|
|
import org.springframework.web.server.ResponseStatusException;
|
|
|
|
|
|
|
@@ -46,11 +45,10 @@ public class HonorTrackingController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping("/honor/impression")
|
|
@GetMapping("/honor/impression")
|
|
|
- @ResponseStatus(HttpStatus.NO_CONTENT)
|
|
|
|
|
- public void impression(HttpServletRequest request) throws Exception {
|
|
|
|
|
|
|
+ public Object impression(HttpServletRequest request) throws Exception {
|
|
|
impressionSemaphore.acquire();
|
|
impressionSemaphore.acquire();
|
|
|
try {
|
|
try {
|
|
|
- doImpression(request);
|
|
|
|
|
|
|
+ return doImpression(request);
|
|
|
} finally {
|
|
} finally {
|
|
|
impressionSemaphore.release();
|
|
impressionSemaphore.release();
|
|
|
}
|
|
}
|
|
@@ -66,7 +64,7 @@ public class HonorTrackingController {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private void doImpression(HttpServletRequest request) throws Exception {
|
|
|
|
|
|
|
+ private Object doImpression(HttpServletRequest request) throws Exception {
|
|
|
if (placement == null) throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, "honor placement not configured");
|
|
if (placement == null) throw new ResponseStatusException(HttpStatus.SERVICE_UNAVAILABLE, "honor placement not configured");
|
|
|
Map<String, String> params = normalizeParams(request);
|
|
Map<String, String> params = normalizeParams(request);
|
|
|
String tagId = requireTagId(params);
|
|
String tagId = requireTagId(params);
|
|
@@ -81,10 +79,12 @@ public class HonorTrackingController {
|
|
|
HonorBidRecord record = bidRecordFromResponse(response, traceId, "impression", params);
|
|
HonorBidRecord record = bidRecordFromResponse(response, traceId, "impression", params);
|
|
|
hotStore.recordBid(record);
|
|
hotStore.recordBid(record);
|
|
|
|
|
|
|
|
|
|
+ List<TrackingResult> tracking = Collections.emptyList();
|
|
|
if (response.getBid() != null && response.getBid().getShowUrls() != null && !response.getBid().getShowUrls().isEmpty()) {
|
|
if (response.getBid() != null && response.getBid().getShowUrls() != null && !response.getBid().getShowUrls().isEmpty()) {
|
|
|
- List<TrackingResult> tracking = adxClient.reportImpression(response.getBid().getShowUrls(), response.getBid().getPrice());
|
|
|
|
|
|
|
+ tracking = adxClient.reportImpression(response.getBid().getShowUrls(), response.getBid().getPrice());
|
|
|
recordTracking(record.getQk(), tagId, "impression", tracking);
|
|
recordTracking(record.getQk(), tagId, "impression", tracking);
|
|
|
}
|
|
}
|
|
|
|
|
+ return Map.of("qk", record.getQk(), "traceId", traceId, "tagId", tagId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private Object doClick(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
private Object doClick(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
@@ -120,7 +120,7 @@ public class HonorTrackingController {
|
|
|
response.sendRedirect(destination);
|
|
response.sendRedirect(destination);
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
- return Map.of("qk", record.getQk(), "traceId", traceId, "tagId", tagId, "tracking", tracking);
|
|
|
|
|
|
|
+ return Map.of("qk", record.getQk(), "traceId", traceId, "tagId", tagId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private Map<String, Object> buildBidRequest(HttpServletRequest request, String traceId, Map<String, String> params) {
|
|
private Map<String, Object> buildBidRequest(HttpServletRequest request, String traceId, Map<String, String> params) {
|