package org.jebot.repository.xxpay;

import org.jebot.models.xxpay.MchAccount;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Component;

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

@Component
public interface MchAccountRepository extends JpaRepository<MchAccount, String> {

    @Query("SELECT t FROM t_mch_account t WHERE t.mchId =:mchId")
    MchAccount findByMchId(Long mchId);

    @Query("SELECT t FROM t_mch_account t WHERE t.mchId IN (:mchIds)")
    List<MchAccount> findByMchIds(List<Long> mchIds);

    @Modifying
    @Transactional
    @Query("UPDATE t_mch_account t SET t.status =:status WHERE t.mchId =:mchId")
    int updateStatusByMchId(Long mchId, int status);
}
