package org.jebot.repository.xxpay;

import org.jebot.models.xxpay.PayPassage;
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.stereotype.Component;

import javax.transaction.Transactional;
import java.util.List;

@Component
public interface PayPassageRepository extends JpaRepository<PayPassage, Long> {

    @Query("SELECT t FROM t_pay_passage t WHERE t.id in (:passageIds)")
    List<PayPassage> findByPassageIds(List<Long> passageIds);

    @Query("SELECT t FROM t_pay_passage t WHERE t.codepro =:codepro")
    List<PayPassage> findByCodepro(Long codepro);

    @Query("SELECT t FROM t_pay_passage t WHERE t.id =:passageId")
    PayPassage findByPassageId(Long passageId);

    @Modifying
    @Transactional
    @Query("UPDATE t_pay_passage t SET t.status =:status WHERE t.id =:id")
    int updateStatusByIdI(@Param("status") Integer Status, Long id);

}
