|
@@ -1,5 +1,6 @@
|
|
|
package com.sysu.admin.controller.aland;
|
|
|
|
|
|
+import com.querydsl.core.types.Predicate;
|
|
|
import com.sysu.admin.controller.city.CityRepository;
|
|
|
import com.sysu.admin.controller.city.DistrictRepository;
|
|
|
import com.sysu.admin.controller.city.TownRepository;
|
|
@@ -93,7 +94,7 @@ public class LandService extends BaseService<Land,Long> {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- public List<Land> list(String district, Integer townId, Integer limit){
|
|
|
+ public List<Land> list(String district, Integer townId, Integer limit, String cropType){
|
|
|
limit = limit == null ? 50 : limit;
|
|
|
String wkt = null;
|
|
|
if(townId != null) {
|
|
@@ -102,10 +103,17 @@ public class LandService extends BaseService<Land,Long> {
|
|
|
wkt = districtRepository.findWktByCode(district);
|
|
|
}
|
|
|
if(wkt == null) {
|
|
|
+ Predicate predicate = null;
|
|
|
Pageable pageable = PageRequest.of(1, limit, Sort.by(Land.FIELDS.id));
|
|
|
- return landRepository.findAll(pageable).toList();
|
|
|
+ QLand qLand = QLand.land;
|
|
|
+ predicate = StringUtils.isNotBlank(cropType) ?
|
|
|
+ qLand.crop_type.eq(cropType) :
|
|
|
+ null;
|
|
|
+ return landRepository.findAll(predicate, pageable).toList();
|
|
|
}else{
|
|
|
- return landRepository.findListByWkt(wkt, limit);
|
|
|
+ return StringUtils.isNotBlank(cropType) ?
|
|
|
+ landRepository.findListByWktAndCropType(wkt, cropType, limit) :
|
|
|
+ landRepository.findListByWkt(wkt, limit);
|
|
|
}
|
|
|
}
|
|
|
|