package com.reyun.repository;

import java.math.BigInteger;
import java.util.List;

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

import com.reyun.model.Funnel;
public interface FunnelRepository extends JpaRepository<Funnel, Long> {

	@Query(value="select f.*,a.email as cAccount from funnel f, account a where f.app=?1 and f.del_flag is not true and a.id=f.create_account order by f.modify_time desc",nativeQuery=true)
	List<Funnel> findAllByApp(Long app);

	@Query(value="select * from funnel where app=?2 and del_flag is not true and name=?1",nativeQuery=true)
	Funnel findByNameAndApp(String name, Long app);

    @Query(value="select count(*) from funnel where create_account = ?1 and app=?2 and name like ?3% ",nativeQuery=true)
    BigInteger findCountLikeName(Long accountId,Long appId,String name);
	
}
