package kr.co.accura.wtm.domain.wbs.repository;

import kr.co.accura.wtm.domain.wbs.entity.CanonicalWbs;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;
import java.util.Set;

@Repository
public interface CanonicalWbsRepository extends JpaRepository<CanonicalWbs, Long> {

    List<CanonicalWbs> findByProjectIdAndIsActiveTrue(Long projectId);

    Optional<CanonicalWbs> findByProjectIdAndWbsCode(Long projectId, String wbsCode);

    @Query("SELECT c.wbsCode FROM CanonicalWbs c WHERE c.projectId = :projectId AND c.isActive = true")
    Set<String> findActiveCodesByProjectId(@Param("projectId") Long projectId);
}
