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

import com.xunhong.erp.turbo.api.biz.dto.qry.ProductListQry;
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;

import java.util.List;

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

    private final ProductGateway productGateway;
    private final ProductAssembler productAssembler;

    public List<ProductVO> execute(ProductListQry productListQry) {
        List<Product> productList = productGateway.list(productListQry);
        return productList.stream().map(productAssembler::toProductVO).toList();
    }
}

