package com.sysu.admin.controller.crop.range;

import com.sysu.admin.controller.crop.CropPoint;
import com.xiesx.fastboot.core.jpa.JpaPlusRepository;
import org.springframework.data.jpa.repository.Query;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.List;

public interface LandRangeIndexRepository extends JpaPlusRepository<LandRangeIndex, PKRP> {


    @Query(value = "SELECT table_name from p_land_range_index where  St_within(" +
            " st_geomfromtext(?1,4326) " +
            ",geom);",nativeQuery = true)
    String findTableNameByPoint(String pointWKT);

    @Query(value = "SELECT table_name from p_land_range_index where  ST_Intersects(" +
            " st_geomfromtext(?1,4326)" +
            ",geom);",nativeQuery = true)
    String[] findTableNameByWkt(String wkt);

    @Query(value = "SELECT table_name from p_land_range_index;",nativeQuery = true)
    String[] findAllTableName();

}
