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

import com.xunhong.erp.turbo.api.infra.dto.cmd.MaterialCreateCmd;
import com.xunhong.erp.turbo.api.infra.dto.vo.MaterialVO;
import com.xunhong.erp.turbo.infra.app.assembler.MaterialAssembler;
import com.xunhong.erp.turbo.infra.domain.entity.Material;
import com.xunhong.erp.turbo.infra.domain.gateway.MaterialGateway;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

@Component
@RequiredArgsConstructor
public class MaterialCreateCmdExe {
	private final MaterialGateway materialGateway;
	private final MaterialAssembler materialAssembler;

	public MaterialVO execute(MaterialCreateCmd materialCreateCmd) {
		Material material = materialGateway.save(materialCreateCmd);
		return materialAssembler.toMaterialVO(material);
	}
}
