package com.sysu.admin.controller.crop;

import com.xiesx.fastboot.core.jpa.JpaPlusRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;


public interface CropPointRepository extends JpaPlusRepository<CropPoint, Long> {


    @Query(value = "select id,gridcode,crop_type,st_asgeojson(center_point) as geojson,status,receiver,name,address,growing_period from p_crop where status in ?3 and St_within(center_point," +
            " ST_Buffer(st_geomfromtext(?1,4326),?2, 'quad_segs=8')" +
            ") limit 50",nativeQuery = true)
    List<CropPoint> findByBufferAndStatus(String pointWKT, Double degree, Integer[] status);


    @Query(value = "select ST_AsText(ST_Buffer(st_geomfromtext(?1),?2, 'quad_segs=8'))", nativeQuery = true)
    String getBuffer(String pointWKT, Double degree);



}
