package com.sysu.admin.controller.lz.tree;

import com.querydsl.core.types.Predicate;
import com.sysu.admin.controller.aland.Land;
import com.sysu.admin.controller.lz.period.LzPeriod;
import com.xiesx.fastboot.core.jpa.JpaPlusRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface LzTreeRepository extends JpaPlusRepository<LzTree, Integer> {

     LzTree findByCode(String code);

     @Query(value = "SELECT * FROM lz_tree where St_within(point, ST_Buffer(st_geomfromtext(?1),?2, 'quad_segs=8')) limit 1", nativeQuery = true)
     LzTree findByPoint(String wkt, Double m);

     @Query(value = "SELECT a, b, c FROM LzTree a JOIN FETCH a.lzEveryday b JOIN FETCH a.clazz c")
     List<LzTree> findAll(Predicate predicate);

}
