package click.kamil.examples.statemachine.layered.web;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Demonstrates the full two-hop dispatch chain with string literals:
 * string key → {@link click.kamil.examples.statemachine.layered.command.DomainCommand}
 * → transition event.
 */
@RestController
@RequestMapping("/api/string-dispatch")
public class StringDispatchController {

    private final CommandGateway commandGateway;

    public StringDispatchController(CommandGateway commandGateway) {
        this.commandGateway = commandGateway;
    }

    @PostMapping("/orders/pay")
    public void payWithStringKey() {
        commandGateway.executeViaMapper("order.pay");
    }

    @PostMapping("/orders/ship")
    public void shipWithStringKey() {
        commandGateway.executeViaMapper("order.ship");
    }
}
