分页查询:
public List<DoorEventsVo> pageList(List<Object> dataList, int pageSize, int pageNo) {
List<DoorEventsVo> currentPageList = new ArrayList<>();
if (dataList != null && dataList.size() > 0) {
int currIdx = (pageNo > 1 ? (pageNo - 1) * pageSize : 0);
for (int i = 0; i < pageSize && i < dataList.size() - currIdx; i++) {
DoorEventsVo data = dataList.get(currIdx + i);
currentPageList.add(data);
}
}
return currentPageList;
}
多条件模糊查询
public List<DoorEventsVo> findPersonsByCondition(List<DoorEventsVo> persons, String var1, String var2) {
if (StringUtils.isNotEmpty(var1)) {
persons = persons.stream().filter(item ->
StringUtils.isNotEmpty(item.getPersonName()) ? item.getPersonName().contains(var1) : true).collect(Collectors.toList());
}
if (StringUtils.isNotEmpty(var2)) {
persons = persons.stream().filter(item ->
StringUtils.isNotEmpty(item.getOrgPathName()) ? item.getOrgPathName().contains(var2) : true).collect(Collectors.toList());
}
return persons;
}