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

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xunhong.erp.turbo.api.user.dto.qry.EmployeePageQry;
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;

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

	private final EmployeeGateway employeeGateway;
	private final EmployeeAssembler employeeAssembler;

	public IPage<EmployeeVO> execute(EmployeePageQry employeePageQry) {
		IPage<Employee> page = employeeGateway.page(employeePageQry);
		return page.convert(employeeAssembler::toEmployeeVO);
	}
}
