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

import com.xunhong.erp.turbo.api.biz.dto.cmd.SupplierCreateCmd;
import com.xunhong.erp.turbo.api.biz.dto.vo.SupplierVO;
import com.xunhong.erp.turbo.biz.app.assembler.SupplierAssembler;
import com.xunhong.erp.turbo.biz.domain.entity.Supplier;
import com.xunhong.erp.turbo.biz.domain.gateway.SupplierGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

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

	private final SupplierAssembler supplierAssembler;
	private final SupplierGateway supplierGateway;

	public SupplierVO execute(SupplierCreateCmd supplierCreateCmd) {
		Supplier supplier = supplierGateway.save(supplierCreateCmd);

		return supplierAssembler.toSupplierVO(supplier);
	}
}

