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


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xunhong.erp.turbo.api.infra.dto.qry.CategoryPageQry;
import com.xunhong.erp.turbo.api.infra.dto.vo.CategoryVO;
import com.xunhong.erp.turbo.infra.app.assembler.CategoryAssembler;
import com.xunhong.erp.turbo.infra.domain.entity.Category;
import com.xunhong.erp.turbo.infra.domain.gateway.CategoryGateway;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@RequiredArgsConstructor
public class CategoryPageQryExe {
	private final CategoryGateway categoryGateway;
	private final CategoryAssembler categoryAssembler;

	public IPage<CategoryVO> execute(CategoryPageQry categoryPageQry) {
		IPage<Category> page = categoryGateway.page(categoryPageQry);
		return page.convert(categoryAssembler::toCategoryVO);
	}
}
