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

import com.xunhong.erp.turbo.api.biz.dto.cmd.ExpenseRecordCreateCmd;
import com.xunhong.erp.turbo.api.biz.dto.vo.ExpenseRecordVO;
import com.xunhong.erp.turbo.biz.app.assembler.ExpenseRecordAssembler;
import com.xunhong.erp.turbo.biz.domain.entity.ExpenseRecord;
import com.xunhong.erp.turbo.biz.domain.gateway.ExpenseRecordGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

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

    private final ExpenseRecordAssembler expenseRecordAssembler;
    private final ExpenseRecordGateway expenseRecordGateway;

    public ExpenseRecordVO execute(ExpenseRecordCreateCmd expenseRecordCreateCmd) {
        ExpenseRecord expenseRecord = expenseRecordGateway.save(expenseRecordCreateCmd);

        return expenseRecordAssembler.toExpenseRecordVO(expenseRecord);
    }
}

