| 123456789101112131415161718192021222324252627282930313233343536 |
- package com.izouma.nineth.repo;
- import com.izouma.nineth.domain.Rice;
- import io.lettuce.core.dynamic.annotation.Param;
- import org.springframework.data.jpa.repository.JpaRepository;
- import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
- import org.springframework.data.jpa.repository.Modifying;
- import org.springframework.data.jpa.repository.Query;
- import javax.transaction.Transactional;
- import java.util.List;
- import java.util.Optional;
- public interface RiceRepo extends JpaRepository<Rice, Long>, JpaSpecificationExecutor<Rice> {
- @Query("update Rice t set t.del = true where t.id = ?1")
- @Modifying
- @Transactional
- void softDelete(Long id);
- @Query(value = "select * from rice where user_id = ?1 ", nativeQuery = true)
- Optional<Rice> findByUserId(Long userId);
- @Query("update Rice t set t.nickname = ?2 where t.userId = ?1")
- @Modifying
- @Transactional
- void updateNickName(String userId, String nickname);
- @Query("SELECT COUNT(r) + 1 FROM Rice r WHERE r.selfScore > :score")
- Integer findRankByScore(@Param("score") Long score);
- List<Rice> findTop100ByOrderBySelfScoreDesc();
- }
|