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

import com.xunhong.erp.turbo.api.biz.dto.qry.CompanyListQry;
import com.xunhong.erp.turbo.api.biz.dto.vo.CompanyVO;
import com.xunhong.erp.turbo.biz.app.assembler.CompanyAssembler;
import com.xunhong.erp.turbo.biz.domain.entity.Company;
import com.xunhong.erp.turbo.biz.domain.gateway.CompanyGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

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

	private final CompanyGateway companyGateway;
	private final CompanyAssembler companyAssembler;

	public List<CompanyVO> execute(CompanyListQry companyListQry) {
		List<Company> companyList = companyGateway.list(companyListQry);
		return companyList.stream().map(companyAssembler::toCompanyVO).toList();
	}
}

