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

import com.xunhong.erp.turbo.api.infra.dto.qry.PlatformListQry;
import com.xunhong.erp.turbo.api.infra.dto.vo.PlatformVO;
import com.xunhong.erp.turbo.infra.app.assembler.PlatformAssembler;
import com.xunhong.erp.turbo.infra.domain.entity.Platform;
import com.xunhong.erp.turbo.infra.domain.gateway.PlatformGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

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

	private final PlatformGateway platformGateway;

	private final PlatformAssembler platformAssembler;

	public List<PlatformVO> execute(PlatformListQry platformListQry) {
		List<Platform> platformList = platformGateway.list(platformListQry);
		return platformList.stream().map(platformAssembler::toPlatformVO).toList();
	}
}
