DB db = DbManager.getInstance().getDataDb(); Jongo jongo = new Jongo(db); MongoCollection sysLogs = jongo.getCollection("sys_logs"); Map<String, Object> map = new HashMap<>(); Criteria criteria = new Criteria(); try { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); Date start = simpleDateFormat.parse(startTime); Date end = simpleDateFormat.parse(endTime); criteria.and("handleTime").gte(10l).lte(10000000000000l); } catch (ParseException e) { e.printStackTrace(); } if (Objects.nonNull(username)) { // map.put("username", username); criteria.and("username").equals(username); } String query = new org.springframework.data.mongodb.core.query.Query(criteria).getQueryObject().toJson(); MongoCursor<Map> as = sysLogs.find(query).skip((pagination.getCurrent() - 1) * pagination.getPageSize()) .limit(pagination.getPageSize()).as(Map.class);
原文地址:https://www.cnblogs.com/notchangeworld/p/12407512.html
时间: 2024-10-28 11:22:14