Search in sources :

Example 1 with MultipleItemsResult

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);
}
Also used : MultipleItemsResult(org.summerb.approaches.jdbccrud.rest.dto.MultipleItemsResult) Query(org.summerb.approaches.jdbccrud.api.query.Query) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

PostMapping (org.springframework.web.bind.annotation.PostMapping)1 Query (org.summerb.approaches.jdbccrud.api.query.Query)1 MultipleItemsResult (org.summerb.approaches.jdbccrud.rest.dto.MultipleItemsResult)1