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

import com.xunhong.erp.turbo.api.infra.dto.qry.AgreementListQry;
import com.xunhong.erp.turbo.api.infra.dto.vo.AgreementVO;
import com.xunhong.erp.turbo.infra.app.assembler.AgreementAssembler;
import com.xunhong.erp.turbo.infra.domain.entity.Agreement;
import com.xunhong.erp.turbo.infra.domain.gateway.AgreementGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

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

	private final AgreementGateway agreementGateway;
	private final AgreementAssembler agreementAssembler;

	public List<AgreementVO> execute(AgreementListQry agreementListQry) {
		List<Agreement> agreementList = agreementGateway.list(agreementListQry);
		return agreementList.stream().map(agreementAssembler::toAgreementVO).toList();
	}
}

