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

import com.xunhong.erp.turbo.api.user.dto.qry.EmployeeListQry;
import com.xunhong.erp.turbo.api.user.dto.vo.EmployeeVO;
import com.xunhong.erp.turbo.user.app.assembler.EmployeeAssembler;
import com.xunhong.erp.turbo.user.domain.entity.Employee;
import com.xunhong.erp.turbo.user.domain.gateway.EmployeeGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

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

	private final EmployeeGateway employeeGateway;
	private final EmployeeAssembler employeeAssembler;

	public List<EmployeeVO> execute(EmployeeListQry employeeListQry) {
		List<Employee> employeeList = employeeGateway.list(employeeListQry);
		return employeeList.stream().map(employeeAssembler::toEmployeeVO).toList();
	}
}
