|
|
@@ -1,10 +1,6 @@
|
|
|
package com.zhongshu.card.server.core.service.quest;
|
|
|
|
|
|
-import cn.hutool.json.JSONArray;
|
|
|
-import cn.hutool.json.JSONObject;
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
-import com.github.microservice.core.util.bean.BeanUtil;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.zhongshu.card.client.model.quest.*;
|
|
|
import com.zhongshu.card.client.utils.DateUtils;
|
|
|
@@ -27,10 +23,7 @@ import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -118,34 +111,61 @@ public class QuestService {
|
|
|
if (page.getContent() != null) {
|
|
|
List<QuestInfo> list = page.getContent();
|
|
|
maps = list.parallelStream().map(it -> {
|
|
|
- Map<String, Object> map = BeanUtil.bean2Map(it);
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
try {
|
|
|
Object data = it.getData();
|
|
|
if (data != null) {
|
|
|
- JSONArray jsonArray = JSONUtil.parseArray(data.toString());
|
|
|
- for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
- JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
- String questionId = jsonObject.get("questionId").toString();
|
|
|
+ List<LinkedHashMap> linkedHashMaps = (List<LinkedHashMap>) data;
|
|
|
+ for (LinkedHashMap linkedHashMap : linkedHashMaps) {
|
|
|
+ String questionId = linkedHashMap.get("questionId").toString();
|
|
|
if (!titleMap.containsKey(questionId)) {
|
|
|
QuestTitleModel titleModel = new QuestTitleModel();
|
|
|
titleModel.setQuestionId(questionId);
|
|
|
- String question = jsonObject.get("question").toString();
|
|
|
+ String question = linkedHashMap.get("question").toString();
|
|
|
titleModel.setQuestion(question);
|
|
|
titles.add(titleModel);
|
|
|
titleMap.put(questionId, question);
|
|
|
}
|
|
|
- Object answer = jsonObject.get("answer");
|
|
|
+ Object answer = linkedHashMap.get("answer");
|
|
|
String value = "";
|
|
|
if (answer != null) {
|
|
|
- if (answer instanceof JSONArray) {
|
|
|
- JSONArray arr = (JSONArray) answer;
|
|
|
- value = arr.toString();
|
|
|
+ if (answer instanceof List<?>) {
|
|
|
+
|
|
|
+ } else if (answer instanceof String) {
|
|
|
+ value = answer.toString();
|
|
|
} else {
|
|
|
value = answer.toString();
|
|
|
}
|
|
|
}
|
|
|
map.put(questionId, value);
|
|
|
}
|
|
|
+
|
|
|
+// log.info("1112 : {}", data.toString());
|
|
|
+// String str = data.toString();
|
|
|
+// JSONArray jsonArray = new JSONArray(str);
|
|
|
+// for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
+// JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
+// String questionId = jsonObject.get("questionId").toString();
|
|
|
+// if (!titleMap.containsKey(questionId)) {
|
|
|
+// QuestTitleModel titleModel = new QuestTitleModel();
|
|
|
+// titleModel.setQuestionId(questionId);
|
|
|
+// String question = jsonObject.get("question").toString();
|
|
|
+// titleModel.setQuestion(question);
|
|
|
+// titles.add(titleModel);
|
|
|
+// titleMap.put(questionId, question);
|
|
|
+// }
|
|
|
+// Object answer = jsonObject.get("answer");
|
|
|
+// String value = "";
|
|
|
+// if (answer != null) {
|
|
|
+// if (answer instanceof JSONArray) {
|
|
|
+// JSONArray arr = (JSONArray) answer;
|
|
|
+// value = arr.toString();
|
|
|
+// } else {
|
|
|
+// value = answer.toString();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// map.put(questionId, value);
|
|
|
+// }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|