ShowroomRepo.java 901 B

1234567891011121314151617181920212223242526
  1. package com.izouma.nineth.repo;
  2. import com.izouma.nineth.domain.Showroom;
  3. import org.springframework.data.jpa.repository.JpaRepository;
  4. import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
  5. import org.springframework.data.jpa.repository.Modifying;
  6. import org.springframework.data.jpa.repository.Query;
  7. import javax.transaction.Transactional;
  8. import java.util.Optional;
  9. public interface ShowroomRepo extends JpaRepository<Showroom, Long>, JpaSpecificationExecutor<Showroom> {
  10. @Query("update Showroom t set t.del = true where t.id = ?1")
  11. @Modifying
  12. @Transactional
  13. void softDelete(Long id);
  14. @Query("update Showroom t set t.likes = t.likes + ?2 where t.id = ?1")
  15. @Modifying
  16. @Transactional
  17. void addLike(Long id, int num);
  18. Optional<Showroom> findByUserIdAndAssetId(Long userId, Long assetId);
  19. Optional<Showroom> findByAssetId(Long assetId);
  20. }