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

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xunhong.erp.turbo.api.infra.dto.qry.AgreementPageQry;
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;

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

	private final AgreementGateway agreementGateway;
	private final AgreementAssembler agreementAssembler;

	public IPage<AgreementVO> execute(AgreementPageQry agreementPageQry) {
		IPage<Agreement> page = agreementGateway.page(agreementPageQry);
		return page.convert(agreementAssembler::toAgreementVO);
	}
}

