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.ProductPageQry;
import com.xunhong.erp.turbo.api.biz.dto.vo.ProductVO;
import com.xunhong.erp.turbo.biz.app.assembler.ProductAssembler;
import com.xunhong.erp.turbo.biz.domain.entity.Product;
import com.xunhong.erp.turbo.biz.domain.gateway.ProductGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

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

    private final ProductGateway productGateway;
    private final ProductAssembler productAssembler;

    public IPage<ProductVO> execute(ProductPageQry productPageQry) {
        IPage<Product> page = productGateway.page(productPageQry);
        return page.convert(productAssembler::toProductVO);
    }
}

