package gc.mda.kcg.permission;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

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

public interface PermRepository extends JpaRepository<Perm, Long> {

    List<Perm> findByRoleSn(Long roleSn);

    Optional<Perm> findByRoleSnAndRsrcCdAndOperCd(Long roleSn, String rsrcCd, String operCd);

    @Query("SELECT p FROM Perm p WHERE p.roleSn IN :roleSns")
    List<Perm> findByRoleSnIn(@Param("roleSns") List<Long> roleSns);

    void deleteByRoleSn(Long roleSn);

    void deleteByRoleSnAndRsrcCdAndOperCd(Long roleSn, String rsrcCd, String operCd);
}
