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


import com.xunhong.erp.turbo.api.infra.dto.cmd.CategoryCreateCmd;
import com.xunhong.erp.turbo.api.infra.dto.vo.CategoryVO;
import com.xunhong.erp.turbo.infra.app.assembler.CategoryAssembler;
import com.xunhong.erp.turbo.infra.domain.entity.Category;
import com.xunhong.erp.turbo.infra.domain.gateway.CategoryGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
@RequiredArgsConstructor
public class CategoryCreateCmdExe {
	private final CategoryAssembler categoryAssembler;

	private final CategoryGateway categoryGateway;

	public CategoryVO execute(CategoryCreateCmd categoryCreateCmd) {
		Category category = categoryGateway.save(categoryCreateCmd);
		return categoryAssembler.toCategoryVO(category);
	}
}
