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


import com.xunhong.erp.turbo.api.infra.dto.qry.CategoryTreeQry;
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;

import java.util.List;

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

	public List<CategoryVO> execute(CategoryTreeQry categoryTreeQry) {
		List<Category> menuList = categoryGateway.list(categoryTreeQry);

		return menuList.stream().map(categoryAssembler::toCategoryVO).toList();
	}
}
