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

import com.xunhong.erp.turbo.api.biz.dto.qry.DealerListQry;
import com.xunhong.erp.turbo.api.biz.dto.vo.DealerVO;
import com.xunhong.erp.turbo.biz.app.assembler.DealerAssembler;
import com.xunhong.erp.turbo.biz.domain.entity.Dealer;
import com.xunhong.erp.turbo.biz.domain.gateway.DealerGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

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

	private final DealerGateway dealerGateway;
	private final DealerAssembler dealerAssembler;

	public List<DealerVO> execute(DealerListQry dealerListQry) {
		List<Dealer> dealerList = dealerGateway.list(dealerListQry);
		return dealerList.stream().map(dealerAssembler::toDealerVO).toList();
	}
}

