|
1 | 1 | package org.example.Operations; |
2 | 2 |
|
| 3 | +import org.example.Properties.DataObject.DataObjectTouchParams; |
3 | 4 | import org.example.Properties.Query.QueryExecuteGenqueryParams; |
| 5 | +import org.example.Properties.Query.QueryExecuteSpecifcQueryParams; |
4 | 6 | import org.example.Wrapper; |
5 | 7 | import org.example.Util.HttpRequestUtil; |
6 | 8 | import org.example.Util.Response; |
@@ -51,30 +53,42 @@ public Response execute_genquery(String token, String query) { |
51 | 53 | return this.execute_genquery(token, query, params); |
52 | 54 | } |
53 | 55 |
|
54 | | - public Response execute_specific_query(String token, String name, String args, String argsDelimiter, |
55 | | - int offset, int count) throws IOException, InterruptedException { |
| 56 | + public Response execute_specific_query(String token, String name, QueryExecuteSpecifcQueryParams params) { |
56 | 57 | Map<Object, Object> formData = new HashMap<>(); |
57 | 58 | formData.put("op", "execute_specific_query"); |
58 | 59 | formData.put("name", name); |
59 | | - if (args != null) { |
60 | | - formData.put("args", args); |
61 | | - } |
62 | | - if (argsDelimiter != null) { |
63 | | - formData.put("args-delimiter", argsDelimiter); |
64 | | - } else { |
65 | | - formData.put("args-delimiter", ","); // default |
66 | | - } |
67 | | - if (offset != -1) { |
68 | | - formData.put("offset", String.valueOf(offset)); |
69 | | - } else { |
70 | | - formData.put("offset", "0"); // default |
71 | | - } |
72 | | - if (count != -1) { |
73 | | - formData.put("count", String.valueOf(count)); |
74 | | - } |
| 60 | + params.getArgs().ifPresent(val -> formData.put("args", val)); |
| 61 | + params.getArgsDelimiter().ifPresent(val -> formData.put("args-delimiter", val)); |
| 62 | + params.getOffset().ifPresent(val -> formData.put("offset", String.valueOf(val))); |
| 63 | + params.getCount().ifPresent(val -> formData.put("count", String.valueOf(val))); |
75 | 64 |
|
76 | 65 | HttpResponse<String> response = HttpRequestUtil.sendAndParseGET(formData, baseUrl, token, client.getClient()); |
77 | 66 | return new Response(response.statusCode(), response.body()); |
78 | 67 | } |
79 | 68 |
|
| 69 | + public Response execute_specific_query(String token, String name) { |
| 70 | + QueryExecuteSpecifcQueryParams param = new QueryExecuteSpecifcQueryParams(); |
| 71 | + return this.execute_specific_query(token, name, param); |
| 72 | + } |
| 73 | + |
| 74 | + public Response add_specific_query(String token, String name, String sql) { |
| 75 | + Map<Object, Object> formData = new HashMap<>(); |
| 76 | + formData.put("op", "add_specific_query"); |
| 77 | + formData.put("name", name); |
| 78 | + formData.put("sql", sql); |
| 79 | + |
| 80 | + HttpResponse<String> response = HttpRequestUtil.sendAndParsePOST(formData, baseUrl, token, client.getClient()); |
| 81 | + return new Response(response.statusCode(), response.body()); |
| 82 | + } |
| 83 | + |
| 84 | + public Response remove_specific_query(String token, String name) { |
| 85 | + Map<Object, Object> formData = new HashMap<>(); |
| 86 | + formData.put("op", "remove_specific_query"); |
| 87 | + formData.put("name", name); |
| 88 | + |
| 89 | + HttpResponse<String> response = HttpRequestUtil.sendAndParsePOST(formData, baseUrl, token, client.getClient()); |
| 90 | + return new Response(response.statusCode(), response.body()); |
| 91 | + } |
| 92 | + |
| 93 | + |
80 | 94 | } |
0 commit comments