Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,23 @@ List<Long> findPaymentIdsByUserAndStatus(
@Param("limit") int limit
);

@Query(value = """
SELECT p.id FROM payments p
WHERE p.user_id = :userId
AND p.status = :status
ORDER BY p.cancelled_at DESC
LIMIT :limit OFFSET :offset
""", nativeQuery = true)
List<Long> findCancelledPaymentIdsByUserAndStatus(
@Param("userId") Long userId,
@Param("status") String status,
@Param("offset") int offset,
@Param("limit") int limit
);

@Query("""
SELECT p FROM Payment p
LEFT JOIN FETCH p.lesson
LEFT JOIN FETCH p.userCoupon
WHERE p.id IN :ids
""")
List<Payment> findAllWithAssociationsByIds(@Param("ids") List<Long> ids);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
package com.threestar.trainus.domain.payment.repository;

import java.util.List;
import java.util.Optional;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.threestar.trainus.domain.payment.entity.TossPayment;

public interface TossPaymentRepository extends JpaRepository<TossPayment, Long> {

Optional<TossPayment> findByOrderId(String orderId);

@Query("""
SELECT t FROM TossPayment t
WHERE t.orderId IN :orderIds
""")
List<TossPayment> findAllByOrderIds(@Param("orderIds") List<String> orderIds);
}