package ru.kayashov.bar.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;
import ru.kayashov.bar.model.entity.CocktailEntity;

public interface CocktailRepository extends JpaRepository<CocktailEntity, Long> {
    @Modifying
    @Transactional
    @Query("UPDATE CocktailEntity c SET c.isFavorite = :favorite WHERE c.id = :id")
    void updateFavouriteById(@Param("id") Long id, @Param("favorite") Boolean favorite);

    @Modifying
    @Transactional
    @Query("UPDATE CocktailEntity c SET c.rating = :rating WHERE c.id = :id")
    void updateRatingById(@Param("id") Long id, @Param("rating") Integer rating);
}