|
|
|
@ -1,22 +1,19 @@
|
|
|
|
|
package com.sztzjy.forex.trading_trading.util;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
|
|
import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
|
|
import cn.hutool.http.HttpStatus;
|
|
|
|
|
import cn.hutool.http.HttpUtil;
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.nimbusds.jose.shaded.gson.JsonObject;
|
|
|
|
|
import com.sztzjy.forex.trading_trading.config.security.JwtUser;
|
|
|
|
|
import com.sztzjy.forex.trading_trading.config.security.TokenProvider;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public class TzApi {
|
|
|
|
@ -28,11 +25,8 @@ public class TzApi {
|
|
|
|
|
private final static String GET_CLASS = API_URL + "/Account/GetClassBySchoolIdForForeignExchangeTrading";
|
|
|
|
|
|
|
|
|
|
private final static String GET_MAJOR = API_URL + "/Account/GetMajorIdForForeignExchangeTrading";
|
|
|
|
|
|
|
|
|
|
private final static String GET_CLASS_BY_MAJOR = API_URL + "/Account/GetClassByMajorIdForForeignExchangeTrading";
|
|
|
|
|
|
|
|
|
|
private final static String GET_STUDENT_BY_ClALL = API_URL + "/Account/GetStudentInfoByClassIdForForeignExchangeTrading";
|
|
|
|
|
|
|
|
|
|
private final static String GET_STUDENT_BY_KEYWORD = API_URL + "/Account/GetStudentInfoByKeywordForForeignExchangeTrading";
|
|
|
|
|
private final static String PAGE_STUDENT_BY_KEYWORD = API_URL + "/Account/PagedListStudentInfoByClassIdForForeignExchangeTrading";
|
|
|
|
|
|
|
|
|
@ -104,7 +98,7 @@ public class TzApi {
|
|
|
|
|
public static List<Map<String, Object>> GetStudentInfoByClassIdForForeignExchangeTrading(String classIds, JwtUser user) {
|
|
|
|
|
String token = getToken(user);
|
|
|
|
|
String url = GET_STUDENT_BY_ClALL + "?classList=" + classIds;
|
|
|
|
|
return getDataFromApi(url, token);
|
|
|
|
|
return getStudentsFromApi(url, token);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<Map<String, Object>> GetStudentInfoByKeywordForForeignExchangeTrading(JwtUser user, String keyword) {
|
|
|
|
@ -135,7 +129,34 @@ public class TzApi {
|
|
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
|
|
dataMap.put("id", node.get("id").asText());
|
|
|
|
|
dataMap.put("name", node.get("name").asText());
|
|
|
|
|
dataList.add(dataMap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new IllegalArgumentException("获取数据异常");
|
|
|
|
|
}
|
|
|
|
|
return dataList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<Map<String, Object>> getStudentsFromApi(String url, String token) {
|
|
|
|
|
List<Map<String, Object>> dataList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
String responseBody = HttpUtils.sendGet(url, token);
|
|
|
|
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
JsonNode jsonNode = objectMapper.readTree(responseBody);
|
|
|
|
|
|
|
|
|
|
JsonNode resultNode = jsonNode.get("result");
|
|
|
|
|
JsonNode dataNode = resultNode.get("data");
|
|
|
|
|
if (dataNode.isArray()) {
|
|
|
|
|
for (JsonNode node : dataNode) {
|
|
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
|
|
dataMap.put("id", node.get("id").asText());
|
|
|
|
|
dataMap.put("name", node.get("name").asText());
|
|
|
|
|
dataMap.put("majorName",node.get("majorName").asText());
|
|
|
|
|
dataMap.put("className",node.get("className").asText());
|
|
|
|
|
dataMap.put("classId",node.get("classId").asText());
|
|
|
|
|
dataList.add(dataMap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|