Контроллер
@RequestMapping(value = "/getFilteredReport", method = RequestMethod.GET, produces = "application/json")
public CustomResponseEntity getFilteredReport(@RequestParam HashMap<String, Object> keyAndValue) throws ApplicationException {
@SuppressWarnings("unchecked")
HashMap<String, Object> map = objectMapper.convertValue(keyAndValue, HashMap.class);
List<ProcessCapabilityIOT> list = processCapabilityIOTServiceImpl.retrieveData(map);
return buildSuccessResponse("data.found", null, list);
}
ProcessCapabilityIOTServiceImpl
public List<ProcessCapabilityIOT> retrieveData (HashMap<String, Object> map) {
Query query = new Query();
List<Criteria> docCriterias = new ArrayList<Criteria>();
for (@SuppressWarnings("rawtypes") Map.Entry mapElement : map.entrySet()) {
docCriterias.add(Criteria.where((String)mapElement.getKey()).is(mapElement.getValue()));
}
Criteria criteria = new Criteria();
criteria.andOperator(docCriterias.toArray(new Criteria[docCriterias.size()]));
query.addCriteria(criteria);
List<ProcessCapabilityIOT> list = mongoTemplate.find(query, ProcessCapabilityIOT.class);
return list;
}