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.MaterialPageQry;
import com.xunhong.erp.turbo.api.infra.dto.vo.MaterialVO;
import com.xunhong.erp.turbo.infra.app.assembler.MaterialAssembler;
import com.xunhong.erp.turbo.infra.domain.entity.Material;
import com.xunhong.erp.turbo.infra.domain.gateway.MaterialGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class MaterialPageQryExe {
	private final MaterialGateway materialGateway;
	private final MaterialAssembler materialAssembler;

	public IPage<MaterialVO> execute(MaterialPageQry materialPageQry) {
		IPage<Material> page = materialGateway.page(materialPageQry);
		return page.convert(materialAssembler::toMaterialVO);
	}
}
