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

import com.xunhong.erp.turbo.api.user.dto.cmd.UserCreateCmd;
import com.xunhong.erp.turbo.api.user.dto.vo.UserVO;
import com.xunhong.erp.turbo.user.app.assembler.UserAssembler;
import com.xunhong.erp.turbo.user.domain.entity.User;
import com.xunhong.erp.turbo.user.domain.gateway.UserGateway;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;


@Component
@RequiredArgsConstructor
public class UserCreateCmdExe {
	private final UserGateway userGateway;
	private final UserAssembler userAssembler;

	@Transactional
	public UserVO execute(UserCreateCmd userCreateCmd) {
		User user = userGateway.create(userCreateCmd);

		return userAssembler.toUserVO(user);
	}
}
