feat(m5): add simulated callback event delivery for testing

This commit is contained in:
2026-05-25 15:04:03 +08:00
parent ca1279162b
commit 1cef437fb3
3 changed files with 74 additions and 3 deletions
@@ -1,6 +1,9 @@
package cn.craftlabs.platform.api.callback;
import cn.craftlabs.platform.api.service.CallbackEventIngestService;
import cn.craftlabs.platform.api.service.CallbackInboxService;
import cn.craftlabs.platform.api.web.dto.CallbackEventIngestRequest;
import cn.craftlabs.platform.api.web.dto.CallbackEventIngestResponse;
import cn.craftlabs.platform.api.web.dto.CallbackInboxLinkPatchRequest;
import cn.craftlabs.platform.api.web.dto.CallbackInboxResponse;
import cn.craftlabs.platform.api.web.dto.CallbackInboxStatusPatchRequest;
@@ -10,15 +13,17 @@ import cn.craftlabs.platform.api.web.dto.PageResponse;
import jakarta.validation.Valid;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RestController;
import java.time.OffsetDateTime;
@@ -30,9 +35,11 @@ import java.time.OffsetDateTime;
public class CallbackInboxController {
private final CallbackInboxService callbackInboxService;
private final CallbackEventIngestService callbackEventIngestService;
public CallbackInboxController(CallbackInboxService callbackInboxService) {
public CallbackInboxController(CallbackInboxService callbackInboxService, CallbackEventIngestService callbackEventIngestService) {
this.callbackInboxService = callbackInboxService;
this.callbackEventIngestService = callbackEventIngestService;
}
@GetMapping
@@ -77,6 +84,14 @@ public class CallbackInboxController {
return callbackInboxService.patchLink(id, request);
}
/** M5-F10:模拟投递(仅测试环境),手动 POST 模拟 Callback 事件。 */
@PostMapping("/simulate")
public CallbackEventIngestResponse simulate(
@Valid @RequestBody CallbackEventIngestRequest request,
@RequestHeader(value = "Idempotency-Key", required = false) String idempotencyKey) {
return callbackEventIngestService.ingest(request, idempotencyKey);
}
/** I8:代理 OPS 调用 Webhook,将关联收据的 {@code DEAD} 出库重新入队。 */
@PostMapping("/{id}/replay-webhook-delivery")
public CallbackWebhookReplayResponse replayWebhookDelivery(@PathVariable("id") long id) {