|
|
|
@ -20,13 +20,15 @@ public class TzApi {
|
|
|
|
|
|
|
|
|
|
private final static String API_URL = "http://Cloud.sztzjy.com";
|
|
|
|
|
|
|
|
|
|
private final static String LOGIN_URL = API_URL + "/Account/ForeignExchangeTradingLogin";
|
|
|
|
|
private final static String NEW_API_URL = "http://zycloud.sztzjy.com:9090";
|
|
|
|
|
// private final static String NEW_API_URL = "http://localhost:9090";
|
|
|
|
|
private final static String LOGIN_URL = NEW_API_URL + "/server/account/findByUsernameAndPwd.json";
|
|
|
|
|
|
|
|
|
|
private final static String GET_CLASS = API_URL + "/Account/GetClassBySchoolIdForForeignExchangeTrading";
|
|
|
|
|
private final static String GET_CLASS = NEW_API_URL + "/server/account/findClassesBySchoolId.json";
|
|
|
|
|
|
|
|
|
|
private final static String GET_MAJOR = API_URL + "/Account/GetMajorIdForForeignExchangeTrading";
|
|
|
|
|
private final static String GET_MAJOR = NEW_API_URL + "/server/account/findMajorsBySchoolId.json";
|
|
|
|
|
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_ClALL = NEW_API_URL + "/server/account/getStudentsByClassId.json";
|
|
|
|
|
private final static String GET_STUDENT_BY_KEYWORD = API_URL + "/Account/GetStudentInfoByKeywordForForeignExchangeTrading";
|
|
|
|
|
private final static String PAGE_STUDENT_BY_KEYWORD = API_URL + "/Account/PagedListStudentInfoByClassIdForForeignExchangeTrading";
|
|
|
|
|
|
|
|
|
@ -47,27 +49,31 @@ public class TzApi {
|
|
|
|
|
if (object == null) {
|
|
|
|
|
throw new IllegalArgumentException("登录失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONObject jsonObject = object.getJSONObject("respString");
|
|
|
|
|
JSONObject resultObject = jsonObject.getJSONObject("result");
|
|
|
|
|
int code = resultObject.getInt("code");
|
|
|
|
|
int code = object.getInt("statusCode");
|
|
|
|
|
if (code != HttpStatus.HTTP_OK) {
|
|
|
|
|
throw new IllegalArgumentException("登录失败");
|
|
|
|
|
}
|
|
|
|
|
JSONObject dataObject = resultObject.getJSONObject("data");
|
|
|
|
|
JSONObject jsonObject = object.getJSONObject("respString");
|
|
|
|
|
JSONObject dataObject = jsonObject.getJSONObject("data");
|
|
|
|
|
|
|
|
|
|
JwtUser user = new JwtUser();
|
|
|
|
|
user.setUserId(dataObject.getStr("userId"));
|
|
|
|
|
user.setUserId(dataObject.getStr("userid"));
|
|
|
|
|
user.setName(dataObject.getStr("name"));
|
|
|
|
|
user.setRoleId(dataObject.getInt("roleId"));
|
|
|
|
|
user.setSchoolId(dataObject.getInt("schoolId"));
|
|
|
|
|
user.setClassId(dataObject.getInt("classId"));
|
|
|
|
|
user.setMajorId(dataObject.getInt("majorId"));
|
|
|
|
|
user.setClassName(dataObject.getStr("className"));
|
|
|
|
|
user.setMajorName(dataObject.getStr("majorName"));
|
|
|
|
|
user.setSchoolName(dataObject.getStr("schoolName"));
|
|
|
|
|
user.setCollegeId(dataObject.getInt("collegeId"));
|
|
|
|
|
user.setCollegeName(dataObject.getStr("collegeName"));
|
|
|
|
|
String roleName = dataObject.getStr("rolename");
|
|
|
|
|
Integer roleId = roleName.equals("学生") ? 4 : 3;
|
|
|
|
|
user.setRoleId(roleId);
|
|
|
|
|
user.setSchoolId(dataObject.getInt("schoolid"));
|
|
|
|
|
if(roleId==4){
|
|
|
|
|
user.setClassId(dataObject.getInt("classid"));
|
|
|
|
|
user.setClassName(dataObject.getStr("classname"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// user.setMajorId(dataObject.getStr("majorid"));
|
|
|
|
|
|
|
|
|
|
user.setMajorName(dataObject.getStr("majorname"));
|
|
|
|
|
user.setSchoolName(dataObject.getStr("schoolname"));
|
|
|
|
|
user.setCollegeId(dataObject.getInt("collegeid"));
|
|
|
|
|
user.setCollegeName(dataObject.getStr("collegename"));
|
|
|
|
|
user.setUsername(userName);
|
|
|
|
|
user.setPassword(password);
|
|
|
|
|
return user;
|
|
|
|
@ -79,13 +85,13 @@ public class TzApi {
|
|
|
|
|
|
|
|
|
|
public static List<Map<String, Object>> GetClassBySchoolIdForForeignExchangeTrading(JwtUser user) {
|
|
|
|
|
String token = getToken(user);
|
|
|
|
|
String url = GET_CLASS;
|
|
|
|
|
String url = GET_CLASS+"?schoolId=" + user.getSchoolId();
|
|
|
|
|
return getDataFromApi(url, token);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static List<Map<String, Object>> GetMajorIdForForeignExchangeTrading(JwtUser user) {
|
|
|
|
|
String token = getToken(user);
|
|
|
|
|
String url = GET_MAJOR;
|
|
|
|
|
String url = GET_MAJOR+"?schoolId=" + user.getSchoolId();
|
|
|
|
|
return getDataFromApi(url, token);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -122,8 +128,8 @@ public class TzApi {
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
JsonNode jsonNode = objectMapper.readTree(responseBody);
|
|
|
|
|
|
|
|
|
|
JsonNode resultNode = jsonNode.get("result");
|
|
|
|
|
JsonNode dataNode = resultNode.get("data");
|
|
|
|
|
JsonNode dataNode = jsonNode.get("data");
|
|
|
|
|
|
|
|
|
|
if (dataNode.isArray()) {
|
|
|
|
|
for (JsonNode node : dataNode) {
|
|
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
|
@ -147,17 +153,16 @@ public class TzApi {
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
JsonNode jsonNode = objectMapper.readTree(responseBody);
|
|
|
|
|
|
|
|
|
|
JsonNode resultNode = jsonNode.get("result");
|
|
|
|
|
JsonNode dataNode = resultNode.get("data");
|
|
|
|
|
JsonNode dataNode = jsonNode.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());
|
|
|
|
|
dataMap.put("studentNo",node.get("studentNo").asText());
|
|
|
|
|
// dataMap.put("majorName",node.get("majorName").asText());
|
|
|
|
|
dataMap.put("className",node.get("classname").asText());
|
|
|
|
|
dataMap.put("classId",node.get("classid").asText());
|
|
|
|
|
dataMap.put("studentNo",node.get("studentno").asText());
|
|
|
|
|
dataList.add(dataMap);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|