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

import com.xunhong.erp.turbo.api.biz.dto.cmd.DealerCreateCmd;
import com.xunhong.erp.turbo.api.biz.dto.vo.DealerVO;
import com.xunhong.erp.turbo.biz.app.assembler.DealerAssembler;
import com.xunhong.erp.turbo.biz.domain.entity.Dealer;
import com.xunhong.erp.turbo.biz.domain.gateway.DealerGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

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

	private final DealerAssembler dealerAssembler;
	private final DealerGateway dealerGateway;

	public DealerVO execute(DealerCreateCmd dealerCreateCmd) {
		Dealer dealer = dealerGateway.save(dealerCreateCmd);

		return dealerAssembler.toDealerVO(dealer);
	}
}

