package com.xunhong.erp.turbo.rbac.infrastructure.gateway;

import com.xunhong.erp.turbo.api.rbac.dto.qry.RoleMenuTreeQry;
import com.xunhong.erp.turbo.rbac.domain.entity.RoleMenu;
import com.xunhong.erp.turbo.rbac.domain.gateway.RoleMenuGateway;
import com.xunhong.erp.turbo.rbac.infrastructure.convert.RoleMenuConvert;
import com.xunhong.erp.turbo.rbac.infrastructure.entity.RoleMenuDO;
import com.xunhong.erp.turbo.rbac.infrastructure.mapper.RoleMenuMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@RequiredArgsConstructor
public class RoleMenuGatewayImpl implements RoleMenuGateway {
	private final RoleMenuMapper roleMenuMapper;
	private final RoleMenuConvert roleMenuConvert;

	@Override
	public List<RoleMenu> list(RoleMenuTreeQry roleMenuTreeQry) {
		List<RoleMenuDO> roleMenuDOList = roleMenuMapper.selectByRoleList(roleMenuTreeQry);
		return roleMenuDOList.stream().map(roleMenuConvert::toRoleMenu).toList();
	}
}
