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

import com.xunhong.erp.turbo.api.biz.dto.cmd.CompanyCreateCmd;
import com.xunhong.erp.turbo.api.biz.dto.vo.CompanyVO;
import com.xunhong.erp.turbo.biz.app.assembler.CompanyAssembler;
import com.xunhong.erp.turbo.biz.domain.entity.Company;
import com.xunhong.erp.turbo.biz.domain.gateway.CompanyGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

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

	private final CompanyAssembler companyAssembler;
	private final CompanyGateway companyGateway;

	public CompanyVO execute(CompanyCreateCmd companyCreateCmd) {
		Company company = companyGateway.save(companyCreateCmd);

		return companyAssembler.toCompanyVO(company);
	}
}

