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

import com.xunhong.erp.turbo.api.biz.dto.qry.OrderListQry;
import com.xunhong.erp.turbo.api.biz.dto.vo.OrderVO;
import com.xunhong.erp.turbo.biz.app.assembler.OrderAssembler;
import com.xunhong.erp.turbo.biz.domain.entity.Order;
import com.xunhong.erp.turbo.biz.domain.gateway.OrderGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

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

	private final OrderGateway orderGateway;
	private final OrderAssembler orderAssembler;

	public List<OrderVO> execute(OrderListQry orderListQry) {
		List<Order> orderList = orderGateway.list(orderListQry);
		return orderList.stream().map(orderAssembler::toOrderVO).toList();
	}
}

