|
@@ -0,0 +1,91 @@
|
|
|
+package com.miaxis.test;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.miaxis.ZzjsApplication;
|
|
|
+import com.miaxis.feign.service.IYdtService;
|
|
|
+import com.miaxis.question.domain.QuestionInfoTwo;
|
|
|
+import com.miaxis.question.service.IQuestionInfoTwoService;
|
|
|
+import org.junit.Test;
|
|
|
+import org.junit.runner.RunWith;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+import org.springframework.test.context.junit4.SpringRunner;
|
|
|
+
|
|
|
+@SpringBootTest(classes = ZzjsApplication.class)
|
|
|
+@RunWith(SpringRunner.class)
|
|
|
+public class YdtTest {
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IYdtService ydtService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IQuestionInfoTwoService questionInfoTwoService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取一点通题库
|
|
|
+ */
|
|
|
+ @Test
|
|
|
+ public void getInfo(){
|
|
|
+ Long kemu = 1l;
|
|
|
+ String cartype = "3";
|
|
|
+
|
|
|
+ String result = ydtService.getInfo(kemu,cartype);
|
|
|
+ JSONObject json = JSONObject.parseObject(result);
|
|
|
+ JSONObject result2 = json.getJSONObject("result");
|
|
|
+ JSONArray questionList = result2.getJSONArray("questionList");
|
|
|
+
|
|
|
+ for (int i = 0; i < questionList.size(); i++) {
|
|
|
+ JSONObject json1 = (JSONObject)questionList.get(i);
|
|
|
+ String id = json1.getString("id");
|
|
|
+ String name = json1.getString("name");
|
|
|
+ String rightAnswer = json1.getString("rightAnswer");
|
|
|
+ String image = json1.getString("image");
|
|
|
+ String explain = json1.getString("explain");
|
|
|
+ String type = json1.getString("type");
|
|
|
+
|
|
|
+
|
|
|
+ JSONArray option = json1.getJSONArray("option");
|
|
|
+ QuestionInfoTwo questionInfoTwo = new QuestionInfoTwo();
|
|
|
+ for (int j = 0; j <option.size() ; j++) {
|
|
|
+ JSONObject json2 = (JSONObject)option.get(j);
|
|
|
+ String oid = json2.getString("id");
|
|
|
+ String oname = json2.getString("name");
|
|
|
+ if("A".equals(oid)) {
|
|
|
+ questionInfoTwo.setAn1(oname);
|
|
|
+ } else if ("B".equals(oid)) {
|
|
|
+ questionInfoTwo.setAn2(oname);
|
|
|
+ } else if ("C".equals(oid)) {
|
|
|
+ questionInfoTwo.setAn3(oname);
|
|
|
+ } else if ("D".equals(oid)) {
|
|
|
+ questionInfoTwo.setAn4(oname);
|
|
|
+ } else if ("E".equals(oid)) {
|
|
|
+ questionInfoTwo.setAn5(oname);
|
|
|
+ } else if ("F".equals(oid)) {
|
|
|
+ questionInfoTwo.setAn6(oname);
|
|
|
+ } else if ("G".equals(oid)) {
|
|
|
+ questionInfoTwo.setAn7(oname);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ questionInfoTwo.setNum(Long.parseLong(id));
|
|
|
+ questionInfoTwo.setName(name);
|
|
|
+ questionInfoTwo.setImage(image);
|
|
|
+ questionInfoTwo.setRightAnswer(Long.parseLong(rightAnswer));
|
|
|
+ questionInfoTwo.setExplainJs(explain);
|
|
|
+ questionInfoTwo.setKemu(kemu);
|
|
|
+ questionInfoTwo.setCartype(cartype);
|
|
|
+ questionInfoTwo.setType(Long.parseLong(type));
|
|
|
+ System.out.println(questionInfoTwo);
|
|
|
+ questionInfoTwoService.save(questionInfoTwo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|