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

import com.xunhong.erp.turbo.api.biz.dto.qry.SupplierListQry;
import com.xunhong.erp.turbo.api.biz.dto.vo.SupplierVO;
import com.xunhong.erp.turbo.biz.app.assembler.SupplierAssembler;
import com.xunhong.erp.turbo.biz.domain.entity.Supplier;
import com.xunhong.erp.turbo.biz.domain.gateway.SupplierGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

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

	private final SupplierGateway supplierGateway;
	private final SupplierAssembler supplierAssembler;

	public List<SupplierVO> execute(SupplierListQry supplierListQry) {
		List<Supplier> supplierList = supplierGateway.list(supplierListQry);
		return supplierList.stream().map(supplierAssembler::toSupplierVO).toList();
	}
}

