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

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xunhong.erp.turbo.api.biz.dto.qry.CompanyPageQry;
import com.xunhong.erp.turbo.api.biz.dto.vo.CompanyVO;
import com.xunhong.erp.turbo.biz.app.assembler.CompanyAssembler;
import com.xunhong.erp.turbo.biz.domain.entity.Company;
import com.xunhong.erp.turbo.biz.domain.gateway.CompanyGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

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

	private final CompanyGateway companyGateway;
	private final CompanyAssembler companyAssembler;

	public IPage<CompanyVO> execute(CompanyPageQry companyPageQry) {
		IPage<Company> page = companyGateway.page(companyPageQry);
		return page.convert(companyAssembler::toCompanyVO);
	}
}

