use of org.summerb.approaches.jdbccrud.rest.dto.MultipleItemsResult in project summerb by skarpushin.
the class EasyCrudRestControllerBase method getListWithQuery.
@PostMapping(path = "/query", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
public MultipleItemsResult<TId, TDto> getListWithQuery(@RequestBody EasyCrudQueryParams filteringParams, @RequestParam(value = "needPerms", required = false) boolean needPerms, @RequestParam(value = "referencesToResolve", required = false) List<String> referencesToResolve, @ApiIgnore PathVariablesMap pathVariables) throws Exception {
Query query = filteringParamsToQueryConverter.convert(filteringParams.getFilterParams(), service.getDtoClass());
query = queryNarrowerStrategy.narrow(query, pathVariables);
PaginatedList<TDto> rows = service.query(filteringParams.getPagerParams(), query, filteringParams.getOrderBy());
MultipleItemsResult<TId, TDto> ret = new MultipleItemsResult<>(service.getEntityTypeMessageCode(), rows);
if (needPerms) {
Preconditions.checkArgument(permissionsResolverStrategy != null, PERM_RESOLVER_REQ);
permissionsResolverStrategy.resolvePermissions(ret, pathVariables);
}
if (rows.getHasItems() && !CollectionUtils.isEmpty(referencesToResolve)) {
resolveReferences(referencesToResolve, ret, rows.getItems());
}
return convertBeforeReturnStrategy.convert(ret);
}
Aggregations