更新
This commit is contained in:
@@ -7,6 +7,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.modules.log.service.RootLogService;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
@@ -93,17 +94,25 @@ public class RootLogServiceImpl implements RootLogService {
|
||||
.lte(end_time));
|
||||
}
|
||||
|
||||
//根据条件得到的总条数
|
||||
|
||||
Pageable pageable = PageRequest.of(page.getPageNumber(), page.getPageSize());
|
||||
long totalCount = mongoTemplate.count(query,device_code);
|
||||
|
||||
List<Map> result = mongoTemplate.find(query.with(pageable), Map.class, device_code);
|
||||
|
||||
long totalPage = totalCount % page.getPageSize() == 0 ? totalCount / page.getPageSize() : totalCount / page.getPageSize() + 1;
|
||||
/* //根据条件得到的总条数
|
||||
long totalSize = mongoTemplate.count(query, Map.class, device_code);
|
||||
|
||||
//处理分页
|
||||
query.skip(page.getPageNumber()).limit(page.getPageSize());
|
||||
List<Map> list = mongoTemplate.find(query,Map.class, device_code);
|
||||
|
||||
List<Map> list = mongoTemplate.find(query,Map.class, device_code);*/
|
||||
//封装前端分页查询结果
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("content", list);
|
||||
result.put("totalElements", totalSize);
|
||||
return result;
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("content", result);
|
||||
jo.put("totalElements", totalCount);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user