package com.ssj.dao.sys.fx.dao;

import com.ssj.bean.sys.fx.domain.MerchantArea;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface MerchantAreaDao extends JpaRepository<MerchantArea, String> {
	
	@Query(nativeQuery = true, value = " SELECT * from fx_merchant_area t where t.merchant_id=?1 ORDER BY t.create_time ASC ")
	public List<MerchantArea> findSchoolByMerchantList(String merchantId);

	@Query(nativeQuery = true, value = " SELECT * from fx_merchant_area t where t.merchant_id=?2 and t.cn_area_id=?1 ORDER BY t.create_time ASC limit 1 ")
    MerchantArea findBySchoolIdAndMerchant(String areaId, String merchantId);

	@Query(nativeQuery = true, value = " SELECT count(1) from fx_merchant_area t join fx_merchant t11 on t.merchant_id = t11.id join tb_lib_join t12 on t11.lib_id = t12.id where t.school_name=?1  ")
    int findLibCountBySchoolName(String schoolName);
}
