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

import com.xunhong.erp.turbo.api.rbac.dto.qry.MenuListQry;
import com.xunhong.erp.turbo.api.rbac.dto.vo.MenuVO;
import com.xunhong.erp.turbo.rbac.app.assembler.MenuAssembler;
import com.xunhong.erp.turbo.rbac.domain.entity.Menu;
import com.xunhong.erp.turbo.rbac.domain.gateway.MenuGateway;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author shenyifei
 */
@Component
@RequiredArgsConstructor
public class MenuListQryExe {
	private final MenuGateway menuGateway;
	private final MenuAssembler menuAssembler;

	public List<MenuVO> execute(MenuListQry menuListQry) {
		List<Menu> menuList = menuGateway.list(menuListQry);
		return menuList.stream().map(menuAssembler::toMenuVO).toList();
	}
}
