package com.alterdekim.game.repository;

import com.alterdekim.game.entity.MediaResource;
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;

@Repository
public interface MediaResourceRepository extends JpaRepository<MediaResource, Long> {
    Optional<MediaResource> findById(Long id);

    @Query(value = "SELECT m FROM MediaResource m WHERE m.url = :url AND m.tId = :tid")
    Optional<MediaResource> findByUrl(@Param("url") String url, @Param("tid") Integer tid);

    List<MediaResource> findAll();
}
