/** * Query the records of model. */ default QueryListResult queryList(QueryOptions options) { return queryList(options, null); }
/** * Query the records of model with the given filter fields. */ default QueryListResult queryList(QueryOptions options, Map<String, Object> filters) { return queryList(options, filters, null); }
public List<Record> queryList(QueryOptions options) { return newQueryExecutor().queryList(options).list; }
public QueryListResult query(QueryOptions options) { return newQueryExecutor().queryList(options); }
/** * Query the model records with the {@link QueryOptions}. */ protected ApiResponse<List<T>> queryList(QueryOptions options, Map<String, Object> filters, Consumer<ModelQueryExecutor> executorCallback, Consumer<CriteriaQuery> queryCallback, boolean filterByParams) { ModelQueryExecutor executor = mef.newQueryExecutor(mec); if(null != executorCallback) { executorCallback.accept(executor); } QueryListResult result = executor.queryList(options, filters, queryCallback, filterByParams); if (result.getCount() == -1) { return ApiResponse.of(result.getList()); } else { return ApiResponse.of(result.getList()).setHeader("X-Total-Count", String.valueOf(result.getCount())); } }
@Override public Object apply(ActionParams params) { MApiModel am = am(); ModelExecutorContext context = new SimpleModelExecutorContext(api, dao, am, em, params); ModelQueryExecutor executor = newQueryExecutor(context); QueryOptions options = getWithoutId(params, 0); QueryListResult result = executor.queryList(options); if (null != result.getEntity()) { return ApiResponse.of(result.getEntity()); } if (result.getCount() == -1) { return ApiResponse.of(result.getList()); } else { return ApiResponse.of(result.getList()).setHeader("X-Total-Count", String.valueOf(result.getCount())); } }