package com.kamco.cd.kamcoback.postgres.core;

import com.kamco.cd.kamcoback.menu.dto.MenuDto;
import com.kamco.cd.kamcoback.postgres.entity.MenuEntity;
import com.kamco.cd.kamcoback.postgres.repository.menu.MenuRepository;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class MenuCoreService {

  private final MenuRepository menuRepository;

  public List<MenuDto.Basic> getFindAll() {
    return menuRepository.getFindAll().stream().map(MenuEntity::toDto).toList();
  }

  /**
   * 권한별 메뉴 목록
   *
   * @param role
   * @return
   */
  public List<MenuDto.Basic> getFindByRole(String role) {
    return menuRepository.getFindByRole(role).stream().map(MenuEntity::toDto).toList();
  }

  /**
   * 메뉴별 권한 조회
   *
   * @return
   */
  public List<MenuDto.MenuWithRolesDto> getMenuWithRoles() {
    return menuRepository.getFindByMenuWithRoles();
  }
}
