Search in sources :

Example 1 with FlashPlaceOrderCommand

use of com.actionworks.flashsale.app.model.command.FlashPlaceOrderCommand in project flash-sale by ThoughtsBeta.

the class FlashOrderController method placeOrder.

@PostMapping(value = "/flash-orders")
@SentinelResource("PlaceOrderResource")
public SingleResponse<PlaceOrderResult> placeOrder(@RequestAttribute Long userId, @RequestBody FlashPlaceOrderRequest flashPlaceOrderRequest) {
    FlashPlaceOrderCommand placeOrderCommand = FlashOrderBuilder.toCommand(flashPlaceOrderRequest);
    AppSimpleResult<PlaceOrderResult> placeOrderResult = flashOrderAppService.placeOrder(userId, placeOrderCommand);
    if (!placeOrderResult.isSuccess() || placeOrderResult.getData() == null) {
        return ResponseBuilder.withSingle(placeOrderResult);
    }
    return SingleResponse.of(placeOrderResult.getData());
}
Also used : PlaceOrderResult(com.actionworks.flashsale.app.model.result.PlaceOrderResult) FlashPlaceOrderCommand(com.actionworks.flashsale.app.model.command.FlashPlaceOrderCommand) PostMapping(org.springframework.web.bind.annotation.PostMapping) SentinelResource(com.alibaba.csp.sentinel.annotation.SentinelResource)

Example 2 with FlashPlaceOrderCommand

use of com.actionworks.flashsale.app.model.command.FlashPlaceOrderCommand in project flash-sale by ThoughtsBeta.

the class FlashOrderBuilder method toCommand.

public static FlashPlaceOrderCommand toCommand(FlashPlaceOrderRequest flashPlaceOrderRequest) {
    FlashPlaceOrderCommand flashPlaceOrderCommand = new FlashPlaceOrderCommand();
    BeanUtils.copyProperties(flashPlaceOrderRequest, flashPlaceOrderCommand);
    return flashPlaceOrderCommand;
}
Also used : FlashPlaceOrderCommand(com.actionworks.flashsale.app.model.command.FlashPlaceOrderCommand)

Aggregations

FlashPlaceOrderCommand (com.actionworks.flashsale.app.model.command.FlashPlaceOrderCommand)2 PlaceOrderResult (com.actionworks.flashsale.app.model.result.PlaceOrderResult)1 SentinelResource (com.alibaba.csp.sentinel.annotation.SentinelResource)1 PostMapping (org.springframework.web.bind.annotation.PostMapping)1