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

import com.xunhong.erp.turbo.api.biz.dto.qry.ExpenseRecordListQry;
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;

import java.util.List;

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

    private final ExpenseRecordGateway expenseRecordGateway;
    private final ExpenseRecordAssembler expenseRecordAssembler;

    public List<ExpenseRecordVO> execute(ExpenseRecordListQry expenseRecordListQry) {
        List<ExpenseRecord> expenseRecordList = expenseRecordGateway.list(expenseRecordListQry);
        return expenseRecordList.stream().map(expenseRecordAssembler::toExpenseRecordVO).toList();
    }
}

