Skip to content

Commit

Permalink
Params-aware JDBC queries in the pages and API handlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmihajlovski committed Feb 23, 2017
1 parent 37fb4f3 commit 36c722f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Expand Up @@ -44,9 +44,9 @@ public APIHandler(APIConfig api) {
@Override
public Object execute(Req req, Resp resp) {
if (HttpUtils.isGetReq(req)) {
return JDBC.query(api.sql);
return JDBC.query(api.sql, req.params());
} else {
int changes = JDBC.execute(api.sql);
int changes = JDBC.execute(api.sql, req.params());
return U.map("success", true, "changes", changes); // FIXME improve
}
}
Expand Down
Expand Up @@ -30,6 +30,9 @@
import org.rapidoid.jdbc.JDBC;
import org.rapidoid.web.config.bean.PageConfig;

import java.util.List;
import java.util.Map;

@Authors("Nikolche Mihajlovski")
@Since("5.3.0")
public class PageHandler extends RapidoidThing implements ReqRespHandler {
Expand All @@ -42,7 +45,8 @@ public PageHandler(PageConfig page) {

@Override
public Object execute(Req req, Resp resp) {
return GUI.grid(JDBC.query(page.sql));
List<Map<String, Object>> items = JDBC.query(page.sql, req.params());
return GUI.grid(items);
}

}

0 comments on commit 36c722f

Please sign in to comment.