package com.ssj.dao.weixin.card.dao;

import java.util.List;

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.Repository;

import com.ssj.bean.weixin.card.domain.LibCardDetail;


@Repository
public interface ILibCardDao extends JpaRepository<LibCardDetail, String> {
	
	LibCardDetail findByCardIdAndUserCardCode(String cardId, String userCardCode);
	
	LibCardDetail findByUserCardCode(String userCardCode);
	
	@Query(nativeQuery = true, value = "SELECT * from tb_lib_card_detail t where t.card_id=?1 and t.open_id=?2 AND card_stat=?3  ")
	List<LibCardDetail> findByOpenIdAndCardId(String cardId, String openid,String stat);
	
	
	@Modifying
	@Query(nativeQuery = true, value = "update tb_lib_card_detail set card_stat=?1 , updated_date =now()  where card_id=?2 and user_card_code=?3")
	public void updateCardStatByCarIdAndUserCardCode(String cardStat,String cardId,String userCardCode);
	
}
