package com.alterdekim.game.repository;

import com.alterdekim.game.entity.Good;
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 GoodRepository extends JpaRepository<Good, Long> {
    Optional<Good> findById(Long id);

    @Query(value = "SELECT g FROM Good g WHERE g.goodTypeId = :goodTypeId")
    List<Good> findByGoodTypeId(@Param("goodTypeId") Integer goodTypeId);

    @Query(value = "SELECT g FROM Good g WHERE g.mRId = :mrid")
    Optional<Good> findByMRId(@Param("mrid") Integer mrid);

    List<Good> findAll();
}
