|
@@ -8,6 +8,8 @@ import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.jfinal.core.Controller;
|
|
|
import com.jfinal.kit.PropKit;
|
|
|
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
|
@@ -41,6 +43,44 @@ public class ViewController extends Controller {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ public void testget() {
|
|
|
+ Map <String,String> map = new HashMap<String,String>();
|
|
|
+ map.put("institution_id", PropKit.get("institution_id"));
|
|
|
+ map.put("num","30");
|
|
|
+ String content = postWithParameters("https://117.156.67.61:9600/butt/getExam", map);
|
|
|
+ JSONObject jsonObject = JSON.parseObject(content);
|
|
|
+ if (!jsonObject.getString("msg").equals("success")) {
|
|
|
+// return null;
|
|
|
+ }
|
|
|
+ JSONArray jsonArray = JSON.parseArray(jsonObject.getString("data"));
|
|
|
+// return jsonArray;
|
|
|
+ this.renderJson(jsonArray);
|
|
|
+
|
|
|
+ }
|
|
|
+public static String postWithParameters(String url, Map<String, String> map) {
|
|
|
+
|
|
|
+ FormBody.Builder formbody = new FormBody.Builder();
|
|
|
+
|
|
|
+ for (Map.Entry<String, String> entry : map.entrySet()) {
|
|
|
+ formbody.add(entry.getKey(), entry.getValue());
|
|
|
+ }
|
|
|
+ RequestBody requestBody = formbody.build();
|
|
|
+
|
|
|
+ Request request = new Request.Builder()
|
|
|
+ .url(url)
|
|
|
+ .post(requestBody)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ try (Response response = OKHTTP_CLIENT.newCall(request).execute()) {
|
|
|
+ if (!response.isSuccessful()) throw new IOException("Unexpected code " + response);
|
|
|
+ String content = response.body().string();
|
|
|
+ return content;
|
|
|
+ } catch (IOException e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }
|
|
|
public static DruidPlugin createConnectedDruidPlugin() {
|
|
|
|
|
|
return new DruidPlugin(PropKit.get("jdbcUrl_connected"), PropKit.get("user_connected"),PropKit.get("password_connected").trim());
|