|
@@ -9,9 +9,13 @@ import com.sysu.admin.controller.city.TownService;
|
|
|
import com.sysu.admin.support.base.BaseService;
|
|
|
import com.sysu.admin.utils.MySimpleDateFormat;
|
|
|
import com.sysu.admin.utils.TextUtil;
|
|
|
+import com.xiesx.fastboot.base.pagination.PaginationHelper;
|
|
|
+import com.xiesx.fastboot.base.pagination.PaginationResult;
|
|
|
+import com.xiesx.fastboot.base.pagination.PaginationVo;
|
|
|
import com.xiesx.fastboot.core.jpa.JpaPlusRepository;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.PageRequest;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.domain.Sort;
|
|
@@ -171,8 +175,7 @@ public class LandService extends BaseService<Land,Long> {
|
|
|
return townStatList;
|
|
|
}
|
|
|
|
|
|
- public List<Land> list(String district, Integer townId, Integer limit, String cropType){
|
|
|
- limit = limit == null ? 50 : limit;
|
|
|
+ public PaginationResult list(String district, Integer townId, PaginationVo page, String cropType){
|
|
|
String wkt = null;
|
|
|
if(townId != null) {
|
|
|
wkt = townService.findWktById(townId);
|
|
@@ -181,17 +184,27 @@ public class LandService extends BaseService<Land,Long> {
|
|
|
}
|
|
|
if(wkt == null) {
|
|
|
Predicate predicate = null;
|
|
|
- Pageable pageable = PageRequest.of(1, limit, Sort.by(Land.FIELDS.id));
|
|
|
+ Pageable pageable = PageRequest.of(page.getPage(), page.getLimit(), Sort.by(Land.FIELDS.id));
|
|
|
QLand qLand = QLand.land;
|
|
|
+ Page<Land> pageData = null;
|
|
|
if(StringUtils.isNotBlank(cropType)){
|
|
|
- return landRepository.findAll(qLand.crop_type.eq(cropType), pageable).toList();
|
|
|
+ pageData = landRepository.findAll(qLand.crop_type.eq(cropType), pageable);
|
|
|
}else{
|
|
|
- return landRepository.findAll(pageable).toList();
|
|
|
+ pageData = landRepository.findAll(pageable);
|
|
|
}
|
|
|
+ return PaginationHelper.create(pageData.getContent(), pageData.getTotalPages(), pageData.getPageable().getPageNumber());
|
|
|
}else{
|
|
|
- return StringUtils.isNotBlank(cropType) ?
|
|
|
- landRepository.findListByWktAndCropType(wkt, cropType, limit) :
|
|
|
- landRepository.findListByWkt(wkt, limit);
|
|
|
+ List<Land> data = null;
|
|
|
+ int count = 0;
|
|
|
+ if(StringUtils.isNotBlank(cropType)){
|
|
|
+ data = landRepository.findListByWktAndCropType(wkt, cropType, page.getLimit());
|
|
|
+ count = landRepository.findCountByWktAndCropType(wkt, cropType);
|
|
|
+ }else{
|
|
|
+ data = landRepository.findListByWkt(wkt, page.getLimit());
|
|
|
+ count = landRepository.findCountByWkt(wkt);
|
|
|
+ }
|
|
|
+ return PaginationHelper.create(data, count, page.getPage());
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|