|
|
@ -12,7 +12,9 @@ import com.example.todoapp.model.ToBuys; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.data.jpa.repository.JpaRepository; |
|
|
|
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.jpa.repository.Query; |
|
|
|
|
|
|
|
import org.springframework.data.repository.query.Param; |
|
|
|
import org.springframework.stereotype.Repository; |
|
|
|
import org.springframework.stereotype.Repository; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -24,13 +26,24 @@ import org.springframework.stereotype.Repository; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Repository |
|
|
|
@Repository |
|
|
|
public interface ToBuysRepository extends JpaRepository<ToBuys, Integer> { |
|
|
|
public interface ToBuysRepository extends JpaRepository<ToBuys, Integer> { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 指定されたユーザーIDに基づいて「買うもの」リストを取得する |
|
|
|
* 指定されたユーザーIDに基づいて「買うもの」リストを取得する |
|
|
|
* |
|
|
|
* |
|
|
|
* @param userId ユーザーID |
|
|
|
* @param userId ユーザーID |
|
|
|
* @return 「買うもの」リスト |
|
|
|
* @return 「買うもの」リスト |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
@Query("SELECT t FROM ToBuys t WHERE t.user_id.id = ?1") |
|
|
|
@Query("SELECT t FROM ToBuys t WHERE t.user_id.id = ?1") |
|
|
|
List<ToBuys> findByUserId(Long user_id); |
|
|
|
List<ToBuys> findByUserId(Long user_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 指定されたユーザーIDに基づいて「買うもの」リストを取得する |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param userId ユーザーID |
|
|
|
|
|
|
|
* @param tobuyId 「買うもの」ID |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Modifying |
|
|
|
|
|
|
|
@Query("DELETE FROM ToBuys t WHERE t.user_id.id = :userId AND t.tobuy_id = :tobuyId") |
|
|
|
|
|
|
|
int deleteByUserIdAndTobuyId(@Param("userId") Long userId, @Param("tobuyId") int tobuyId); |
|
|
|
} |
|
|
|
} |