package com.xunhong.erp.turbo.biz.app.executor.cmd;

import com.xunhong.erp.turbo.api.biz.dto.cmd.ProductCreateCmd;
import com.xunhong.erp.turbo.api.biz.dto.vo.ProductVO;
import com.xunhong.erp.turbo.biz.app.assembler.ProductAssembler;
import com.xunhong.erp.turbo.biz.domain.entity.Product;
import com.xunhong.erp.turbo.biz.domain.gateway.ProductGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author shenyifei
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class ProductCreateCmdExe {

    private final ProductAssembler productAssembler;
    private final ProductGateway productGateway;

    public ProductVO execute(ProductCreateCmd productCreateCmd) {
        Product product = productGateway.save(productCreateCmd);

        return productAssembler.toProductVO(product);
    }
}

