Compare commits
No commits in common. '7af0fbe8f42bf8b6f9551f902f97c44f2fd71eb5' and '0c470437570e21fc5d3856dc86dd3de8df92b324' have entirely different histories.
7af0fbe8f4
...
0c47043757
@ -0,0 +1,17 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
<groupId>cn.linghang</groupId> |
||||||
|
<artifactId>mywust</artifactId> |
||||||
|
<version>0.0.1-fixed</version> |
||||||
|
<packaging>pom</packaging> |
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>org.projectlombok</groupId> |
||||||
|
<artifactId>lombok</artifactId> |
||||||
|
<version>1.18.22</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
</project> |
@ -0,0 +1,58 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
<groupId>cn.linghang</groupId> |
||||||
|
<artifactId>mywust-core</artifactId> |
||||||
|
<version>0.0.1-fixed</version> |
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>cn.linghang</groupId> |
||||||
|
<artifactId>mywust-network</artifactId> |
||||||
|
<version>0.0.1-fixed</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>cn.linghang</groupId> |
||||||
|
<artifactId>mywust-util</artifactId> |
||||||
|
<version>0.0.1-fixed</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.slf4j</groupId> |
||||||
|
<artifactId>slf4j-api</artifactId> |
||||||
|
<version>2.0.3</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.jsoup</groupId> |
||||||
|
<artifactId>jsoup</artifactId> |
||||||
|
<version>1.15.3</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>cn.linghang</groupId> |
||||||
|
<artifactId>mywust-model</artifactId> |
||||||
|
<version>0.0.1-fixed</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>com.fasterxml.jackson.core</groupId> |
||||||
|
<artifactId>jackson-annotations</artifactId> |
||||||
|
<version>2.14.0-rc1</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>com.fasterxml.jackson.core</groupId> |
||||||
|
<artifactId>jackson-databind</artifactId> |
||||||
|
<version>2.14.0-rc1</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.projectlombok</groupId> |
||||||
|
<artifactId>lombok</artifactId> |
||||||
|
<version>1.18.22</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
</project> |
@ -1,188 +1,28 @@ |
|||||||
package cn.linghang.mywust.core.api; |
package cn.linghang.mywust.core.api; |
||||||
|
|
||||||
import cn.linghang.mywust.model.global.Building; |
|
||||||
import cn.linghang.mywust.model.global.Campus; |
|
||||||
import cn.linghang.mywust.model.global.College; |
|
||||||
import lombok.Getter; |
import lombok.Getter; |
||||||
|
|
||||||
import java.util.*; |
|
||||||
|
|
||||||
/** |
/** |
||||||
* <p>Bkjx(本科教学)系统对应的API常量列表(拼音咱就别吐槽了吧...)</p> |
* <p>Bkjx(本科教学)系统对应的API常量列表(拼音咱就别吐槽了吧...)</p> |
||||||
* <p>其实是本科生用的教务处系统</p> |
* <p>其实是本科生用的教务处系统</p> |
||||||
*/ |
*/ |
||||||
@Getter |
@Getter |
||||||
public class UndergradUrls { |
public class UndergradUrls { |
||||||
/** |
|
||||||
* 登录cookie获取url |
|
||||||
*/ |
|
||||||
public static final String BKJX_SESSION_COOKIE_API = "http://bkjx.wust.edu.cn/jsxsd/sso.jsp?ticket=%s"; |
public static final String BKJX_SESSION_COOKIE_API = "http://bkjx.wust.edu.cn/jsxsd/sso.jsp?ticket=%s"; |
||||||
|
|
||||||
/** |
|
||||||
* cookie测试url(空白页) |
|
||||||
*/ |
|
||||||
public static final String BKJX_TEST_API = "http://bkjx.wust.edu.cn/jsxsd/framework/blankPage.jsp"; |
public static final String BKJX_TEST_API = "http://bkjx.wust.edu.cn/jsxsd/framework/blankPage.jsp"; |
||||||
|
|
||||||
/** |
|
||||||
* 学生信息url |
|
||||||
*/ |
|
||||||
public static final String BKJX_STUDENT_INFO_API = "http://bkjx.wust.edu.cn/jsxsd/grxx/xsxx"; |
public static final String BKJX_STUDENT_INFO_API = "http://bkjx.wust.edu.cn/jsxsd/grxx/xsxx"; |
||||||
|
|
||||||
/** |
public static final String BKJX_EXAM_INFO_API = "http://bkjx.wust.edu.cn/jsxsd/kscj/cjcx_list"; |
||||||
* 成绩url |
|
||||||
*/ |
|
||||||
public static final String BKJX_SCORE_API = "http://bkjx.wust.edu.cn/jsxsd/kscj/cjcx_list"; |
|
||||||
|
|
||||||
/** |
public static final String BKJX_SCHEME_API = "http://bkjx.wust.edu.cn/jsxsd/pyfa/topyfamx"; |
||||||
* 培养计划url |
|
||||||
*/ |
|
||||||
public static final String BKJX_TRAINING_PLAN_API = "http://bkjx.wust.edu.cn/jsxsd/pyfa/topyfamx"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 课表url |
|
||||||
*/ |
|
||||||
public static final String BKJX_COURSE_TABLE_API = "http://bkjx.wust.edu.cn/jsxsd/xskb/xskb_list.do"; |
public static final String BKJX_COURSE_TABLE_API = "http://bkjx.wust.edu.cn/jsxsd/xskb/xskb_list.do"; |
||||||
|
|
||||||
/** |
|
||||||
* 学分修读计划首页url |
|
||||||
*/ |
|
||||||
public static final String BKJX_CREDIT_STATUS_INDEX_API = "http://bkjx.wust.edu.cn/jsxsd/xxwcqk/xxwcqk_idxOnzh.do"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 学分修读计划url |
|
||||||
*/ |
|
||||||
public static final String BKJX_CREDIT_STATUS_API = "http://bkjx.wust.edu.cn/jsxsd/xxwcqk/xxwcqkOnzh.do"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 考试活动列表url |
|
||||||
*/ |
|
||||||
public static final String BKJX_EXAM_ACTIVITY_LIST_API = "http://bkjx.wust.edu.cn/jsxsd/kscj/hksq_query_ajax?&xnxq01id=%s"; |
|
||||||
|
|
||||||
/** |
|
||||||
* 缓考申请url |
|
||||||
*/ |
|
||||||
public static final String BKJX_EXAM_DELAY_APPLICATION_LIST_API = "http://bkjx.wust.edu.cn/jsxsd/kscj/hksq_list"; |
|
||||||
|
|
||||||
public static class Legacy { |
public static class Legacy { |
||||||
public static final String BKJX_INDEX = "http://bkjx.wust.edu.cn"; |
public static final String BKJX_INDEX = "http://bkjx.wust.edu.cn"; |
||||||
public static final String BKJX_DATA_STRING_API = "http://bkjx.wust.edu.cn/Logon.do?method=logon&flag=sess"; |
public static final String BKJX_DATA_STRING_API = "http://bkjx.wust.edu.cn/Logon.do?method=logon&flag=sess"; |
||||||
public static final String BKJX_SESSION_COOKIE_API = "http://bkjx.wust.edu.cn/Logon.do?method=logon"; |
public static final String BKJX_SESSION_COOKIE_API = "http://bkjx.wust.edu.cn/Logon.do?method=logon"; |
||||||
} |
} |
||||||
|
|
||||||
/** |
|
||||||
* 一些需要用到的from参数,一般来说是写死固定的。 |
|
||||||
*/ |
|
||||||
// 别慌,大部分都是脚本自动生成的代码,肯定不会是手写的。
|
|
||||||
public static class ConstantParams { |
|
||||||
/** |
|
||||||
* 默认节次模式 |
|
||||||
*/ |
|
||||||
public static final String DEFAULT_TIME_MODEL = "9486203B90F3E3CBE0532914A8C03BE2"; |
|
||||||
|
|
||||||
private static final List<College> collegesTmp = new ArrayList<>(27); |
|
||||||
public static final List<College> COLLEGES = Collections.unmodifiableList(collegesTmp); |
|
||||||
|
|
||||||
static { |
|
||||||
collegesTmp.add(new College("00001", "[01]资源与环境工程学院")); |
|
||||||
collegesTmp.add(new College("00002", "[02]材料与冶金学院")); |
|
||||||
collegesTmp.add(new College("00003", "[03]机械自动化学院")); |
|
||||||
collegesTmp.add(new College("00004", "[04]信息科学与工程学院(人工智能学院)")); |
|
||||||
collegesTmp.add(new College("00005", "[05]管理学院(恒大管理学院)")); |
|
||||||
collegesTmp.add(new College("00006", "[06]法学与经济学院")); |
|
||||||
collegesTmp.add(new College("00007", "[07]理学院")); |
|
||||||
collegesTmp.add(new College("00008", "[08]城市建设学院")); |
|
||||||
collegesTmp.add(new College("00009", "[09]医学院")); |
|
||||||
collegesTmp.add(new College("00012", "[12]电子技术学院")); |
|
||||||
collegesTmp.add(new College("00013", "[13]计算机科学与技术学院")); |
|
||||||
collegesTmp.add(new College("00014", "[14]外国语学院")); |
|
||||||
collegesTmp.add(new College("00015", "[15]体育学院(恒大足球学院)")); |
|
||||||
collegesTmp.add(new College("0D5444D56D8A46EDB75633181B2042A7", "[16]图书馆")); |
|
||||||
collegesTmp.add(new College("26057DF4B9354C6EA85860F1357FE8EB", "[17]工程训练中心")); |
|
||||||
collegesTmp.add(new College("00018", "[18]生命科学与健康学院")); |
|
||||||
collegesTmp.add(new College("00019", "[19]艺术与设计学院")); |
|
||||||
collegesTmp.add(new College("00023", "[21]国际学院")); |
|
||||||
collegesTmp.add(new College("00024", "[22]化学与化工学院")); |
|
||||||
collegesTmp.add(new College("00025", "[23]汽车与交通工程学院")); |
|
||||||
collegesTmp.add(new College("00026", "[24]临床学院")); |
|
||||||
collegesTmp.add(new College("0W6z90XTY6", "[25]学生工作处")); |
|
||||||
collegesTmp.add(new College("jkwHhwCHLl", "[51]马克思主义学院")); |
|
||||||
collegesTmp.add(new College("0C4B597EE18B418B9AA5C52FDAB3EC73", "[52]香涛学院")); |
|
||||||
collegesTmp.add(new College("379A57BA53DD4F25BA7582CE3180C077", "[54]公共卫生学院")); |
|
||||||
collegesTmp.add(new College("9AA8C9B34EE74DEC8E02F4554B1B5125", "[60]研究生院")); |
|
||||||
collegesTmp.add(new College("86AC446406A94EF09DE1F8B7C17F994A", "[98]全校")); |
|
||||||
} |
|
||||||
|
|
||||||
private static final List<Campus> campusTmp = new ArrayList<>(3); |
|
||||||
public static final List<Campus> CAMPUS = Collections.unmodifiableList(campusTmp); |
|
||||||
|
|
||||||
static { |
|
||||||
campusTmp.add(new Campus("00001", "青山校区")); |
|
||||||
// tmp.add(new Campus("00002", "洪山校区");
|
|
||||||
// tmp.add(new Campus("00003", "医学院");
|
|
||||||
// tmp.add(new Campus("00004", "城市学院");
|
|
||||||
// tmp.add(new Campus("00005", "东湖教学区");
|
|
||||||
campusTmp.add(new Campus("00006", "黄家湖校区")); |
|
||||||
campusTmp.add(new Campus("00007", "附属医院")); |
|
||||||
// tmp.add(new Campus("00008", "武钢医院");
|
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* 教室,目前只做了黄家湖、青山和附属医学院的数据,其他校区在制作时相关数据都是空的, |
|
||||||
* 需要更多信息请请求相关接口获取 |
|
||||||
*/ |
|
||||||
private static final Map<Campus, List<Building>> buildingTmp = new HashMap<>(3); |
|
||||||
public static final Map<Campus, List<Building>> BUILDINGS = Collections.unmodifiableMap(buildingTmp); |
|
||||||
|
|
||||||
static { |
|
||||||
Campus qingshan = CAMPUS.get(0); |
|
||||||
List<Building> qingshanBuildings = new ArrayList<>(10); |
|
||||||
qingshanBuildings.add(new Building("FE88C3D75F9C4C8CA50B82ACDF83530B", "科大雅苑C栋", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("3B76302812FD4262B8BD703814D0D8C3", "科大雅苑A栋", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("90C06D274E254A2CADC88DF1CEBD8396", "教十楼", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00001", "主楼", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00002", "教一楼", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00003", "教二楼", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00004", "教三楼", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00005", "教四楼", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00006", "教五楼", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00007", "教六楼", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00008", "图书馆", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00009", "本部东院体育场", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00010", "机械厂", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00024", "本部西院体育场", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00025", "本部北院体育场", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00029", "教七楼", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00031", "本部教二楼化学实验区", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00032", "学院实验室", qingshan)); |
|
||||||
qingshanBuildings.add(new Building("00051", "校本部停用教室", qingshan)); |
|
||||||
buildingTmp.put(qingshan, qingshanBuildings); |
|
||||||
|
|
||||||
Campus huangjiahu = CAMPUS.get(1); |
|
||||||
List<Building> huangjiahuBuildings = new ArrayList<>(10); |
|
||||||
huangjiahuBuildings.add(new Building("D1521DE0E4CF4641AB4C49CA39EF5E47", "教八楼(管理学院)", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("FBD19C52EC3B4A93A6268B815EFA9A5A", "教九楼(汽车学院)", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("00034", "恒大楼一区", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("00035", "恒大楼二区", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("00036", "恒大楼三区", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("00037", "黄家湖校区体育场", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("00041", "黄家湖校区体育馆", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("00042", "教二楼(理学院)", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("00043", "教三楼(计算机学院)", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("00045", "教四楼二区(外国语学院)", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("00046", "教四楼一区(文法学院)", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("00048", "教五楼一区", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("00049", "教五楼二区", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("00050", "教六楼(医学院)", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("00052", "黄家湖校区停用教室", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("D29468E2AD8241769F47D82913C537EA", "黄家湖校区工程训练中心", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("F9A375E92D814DD3BC2EF30E33C4907B", "教七楼(艺术学院)", huangjiahu)); |
|
||||||
huangjiahuBuildings.add(new Building("DFC73608380C4079A44D4215BD81EB88", "教十一楼", huangjiahu)); |
|
||||||
buildingTmp.put(huangjiahu, huangjiahuBuildings); |
|
||||||
|
|
||||||
Campus medicineSchool = CAMPUS.get(2); |
|
||||||
List<Building> medicineSchoolBuildings = new ArrayList<>(1); |
|
||||||
medicineSchoolBuildings.add(new Building("00047", "附属医院教学楼", medicineSchool)); |
|
||||||
buildingTmp.put(medicineSchool, medicineSchoolBuildings); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
} |
||||||
|
@ -1,31 +0,0 @@ |
|||||||
package cn.linghang.mywust.core.parser.undergraduate; |
|
||||||
|
|
||||||
import cn.linghang.mywust.core.exception.ParseException; |
|
||||||
import cn.linghang.mywust.core.parser.Parser; |
|
||||||
import cn.linghang.mywust.core.util.JsoupUtil; |
|
||||||
import cn.linghang.mywust.core.util.PageFormExtractor; |
|
||||||
import org.jsoup.Jsoup; |
|
||||||
import org.jsoup.nodes.Element; |
|
||||||
import org.jsoup.select.Elements; |
|
||||||
|
|
||||||
import java.util.HashMap; |
|
||||||
import java.util.Map; |
|
||||||
|
|
||||||
public class UndergradCreditStatusIndexParser implements Parser<Map<String, String>> { |
|
||||||
|
|
||||||
private static final String FROM_PARAM_XPATH = "//*[@id=\"Form1\"]/table/tbody/tr/td[3]"; |
|
||||||
@Override |
|
||||||
public Map<String, String> parse(String html) throws ParseException { |
|
||||||
Elements paramElement = Jsoup.parse(html).selectXpath(FROM_PARAM_XPATH); |
|
||||||
if (paramElement.isEmpty()) { |
|
||||||
throw new ParseException("学分修读情况首页解析失败,关键元素不存在..."); |
|
||||||
} |
|
||||||
|
|
||||||
Element trimmedElement = paramElement.get(0); |
|
||||||
Elements paramElements = trimmedElement.getElementsByAttribute("name"); |
|
||||||
Map<String, String> targetMap = new HashMap<>(2); |
|
||||||
paramElements.forEach(element -> targetMap.put(element.attr("name"), element.attr("value"))); |
|
||||||
|
|
||||||
return targetMap; |
|
||||||
} |
|
||||||
} |
|
@ -1,57 +0,0 @@ |
|||||||
package cn.linghang.mywust.core.service.undergraduate; |
|
||||||
|
|
||||||
import cn.linghang.mywust.core.exception.ApiException; |
|
||||||
import cn.linghang.mywust.core.exception.ParseException; |
|
||||||
import cn.linghang.mywust.core.parser.undergraduate.UndergradCreditStatusIndexParser; |
|
||||||
import cn.linghang.mywust.core.request.undergrade.BkjxRequestFactory; |
|
||||||
import cn.linghang.mywust.network.RequestClientOption; |
|
||||||
import cn.linghang.mywust.network.Requester; |
|
||||||
import cn.linghang.mywust.network.entitys.HttpRequest; |
|
||||||
import cn.linghang.mywust.network.entitys.HttpResponse; |
|
||||||
|
|
||||||
import java.io.IOException; |
|
||||||
import java.util.Map; |
|
||||||
|
|
||||||
public class UndergradCreditStatusApiService extends UndergradApiServiceBase { |
|
||||||
private static final UndergradCreditStatusIndexParser parser = new UndergradCreditStatusIndexParser(); |
|
||||||
|
|
||||||
public UndergradCreditStatusApiService(Requester requester) { |
|
||||||
super(requester); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getPage(String cookie, Map<String, String> params, RequestClientOption option) throws ApiException, IOException { |
|
||||||
return this.getPage(cookie, option, false); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getPage(String cookie, Map<String, String> params) throws ApiException, IOException { |
|
||||||
return this.getPage(cookie, params, null); |
|
||||||
} |
|
||||||
|
|
||||||
public String getPage(String cookie, RequestClientOption option, boolean quick) throws IOException, ApiException { |
|
||||||
HttpRequest request; |
|
||||||
if (quick) { |
|
||||||
request = BkjxRequestFactory.creditStatusPageRequest(cookie); |
|
||||||
} else { |
|
||||||
HttpRequest indexRequest = BkjxRequestFactory.creditStatusIndexPageRequest(cookie); |
|
||||||
HttpResponse indexResponse = requester.get(indexRequest, option); |
|
||||||
this.checkResponse(indexResponse); |
|
||||||
|
|
||||||
String indexHtml = indexResponse.getStringBody(); |
|
||||||
Map<String, String> params; |
|
||||||
try { |
|
||||||
params = parser.parse(indexHtml); |
|
||||||
} catch (ParseException e) { |
|
||||||
throw new ApiException(ApiException.Code.COOKIE_INVALID); |
|
||||||
} |
|
||||||
|
|
||||||
request = BkjxRequestFactory.creditStatusPageRequest(cookie, params); |
|
||||||
} |
|
||||||
|
|
||||||
HttpResponse response = requester.post(request, option); |
|
||||||
this.checkResponse(response); |
|
||||||
|
|
||||||
return response.getStringBody(); |
|
||||||
} |
|
||||||
} |
|
@ -1,83 +0,0 @@ |
|||||||
package cn.linghang.mywust.core.service.undergraduate; |
|
||||||
|
|
||||||
import cn.linghang.mywust.core.exception.ApiException; |
|
||||||
import cn.linghang.mywust.core.request.undergrade.BkjxRequestFactory; |
|
||||||
import cn.linghang.mywust.network.RequestClientOption; |
|
||||||
import cn.linghang.mywust.network.Requester; |
|
||||||
import cn.linghang.mywust.network.entitys.HttpRequest; |
|
||||||
import cn.linghang.mywust.network.entitys.HttpResponse; |
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty; |
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper; |
|
||||||
|
|
||||||
import java.io.IOException; |
|
||||||
import java.util.Map; |
|
||||||
|
|
||||||
/** |
|
||||||
* 缓考申请查询 |
|
||||||
*/ |
|
||||||
public class UndergradExamDelayApiService extends UndergradApiServiceBase { |
|
||||||
public UndergradExamDelayApiService(Requester requester) { |
|
||||||
super(requester); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getPage(String cookie, Map<String, String> params, RequestClientOption option) throws ApiException, IOException { |
|
||||||
if (params == null) { |
|
||||||
throw new ApiException(ApiException.Code.INTERNAL_EXCEPTION); |
|
||||||
} |
|
||||||
|
|
||||||
String term = params.get("term"); |
|
||||||
String activityId = params.get("activityId"); |
|
||||||
if (term == null || activityId == null) { |
|
||||||
throw new ApiException(ApiException.Code.INTERNAL_EXCEPTION); |
|
||||||
} |
|
||||||
|
|
||||||
return this.getPage(term, activityId, cookie, option); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getPage(String cookie, Map<String, String> params) throws ApiException, IOException { |
|
||||||
return this.getPage(cookie, params, null); |
|
||||||
} |
|
||||||
|
|
||||||
public String getPage(String term, String activityId, String cookie, RequestClientOption option) throws ApiException, IOException { |
|
||||||
HttpRequest request = BkjxRequestFactory.examDelayApplicationListRequest(term, activityId, cookie); |
|
||||||
HttpResponse response = requester.post(request, option); |
|
||||||
this.checkResponse(response); |
|
||||||
|
|
||||||
return request.getStringData(); |
|
||||||
} |
|
||||||
|
|
||||||
public String getPage(String term, String activityId, String cookie) throws ApiException, IOException { |
|
||||||
return this.getPage(term, activityId, cookie, null); |
|
||||||
} |
|
||||||
|
|
||||||
public ExamActivity[] getActivities(String term, String cookie, RequestClientOption option) throws ApiException, IOException { |
|
||||||
HttpRequest request = BkjxRequestFactory.examActivityListRequest(term, cookie); |
|
||||||
HttpResponse response = requester.get(request, option); |
|
||||||
this.checkResponse(response); |
|
||||||
|
|
||||||
try { |
|
||||||
return new ObjectMapper().readValue(response.getBody(), ExamActivity[].class); |
|
||||||
} catch (IOException e) { |
|
||||||
throw new ApiException(ApiException.Code.UNKNOWN_EXCEPTION, "解析考试活动id列表失败:响应数据:" + response.getStringBody()); |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
public ExamActivity[] getActivities(String term, String cookie) throws ApiException, IOException { |
|
||||||
return this.getActivities(term, cookie, null); |
|
||||||
} |
|
||||||
|
|
||||||
public static class ExamActivity { |
|
||||||
@JsonProperty("cj0701id") |
|
||||||
public final String id; |
|
||||||
|
|
||||||
@JsonProperty("cjlrmc") |
|
||||||
public final String name; |
|
||||||
|
|
||||||
public ExamActivity(String id, String name) { |
|
||||||
this.id = id; |
|
||||||
this.name = name; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,16 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
<groupId>cn.linghang</groupId> |
||||||
|
<artifactId>mywust-model</artifactId> |
||||||
|
<version>0.0.1-fixed</version> |
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>org.projectlombok</groupId> |
||||||
|
<artifactId>lombok</artifactId> |
||||||
|
<version>1.18.22</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
</project> |
@ -1,32 +0,0 @@ |
|||||||
package cn.linghang.mywust.model.global; |
|
||||||
|
|
||||||
import java.util.StringJoiner; |
|
||||||
|
|
||||||
public final class Building { |
|
||||||
public final String id; |
|
||||||
public final String name; |
|
||||||
public final Campus campus; |
|
||||||
|
|
||||||
public Building(String id, String name, Campus campus) { |
|
||||||
this.id = id; |
|
||||||
this.name = name; |
|
||||||
this.campus = campus; |
|
||||||
} |
|
||||||
|
|
||||||
public String getId() { |
|
||||||
return id; |
|
||||||
} |
|
||||||
|
|
||||||
public String getName() { |
|
||||||
return name; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return new StringJoiner(", ", Building.class.getSimpleName() + "[", "]") |
|
||||||
.add("id='" + id + "'") |
|
||||||
.add("name='" + name + "'") |
|
||||||
.add("campus=" + campus) |
|
||||||
.toString(); |
|
||||||
} |
|
||||||
} |
|
@ -1,29 +0,0 @@ |
|||||||
package cn.linghang.mywust.model.global; |
|
||||||
|
|
||||||
import java.util.StringJoiner; |
|
||||||
|
|
||||||
public final class Campus { |
|
||||||
public final String id; |
|
||||||
public final String name; |
|
||||||
|
|
||||||
public Campus(String id, String name) { |
|
||||||
this.id = id; |
|
||||||
this.name = name; |
|
||||||
} |
|
||||||
|
|
||||||
public String getId() { |
|
||||||
return id; |
|
||||||
} |
|
||||||
|
|
||||||
public String getName() { |
|
||||||
return name; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return new StringJoiner(", ", Campus.class.getSimpleName() + "[", "]") |
|
||||||
.add("id='" + id + "'") |
|
||||||
.add("name='" + name + "'") |
|
||||||
.toString(); |
|
||||||
} |
|
||||||
} |
|
@ -1,29 +0,0 @@ |
|||||||
package cn.linghang.mywust.model.global; |
|
||||||
|
|
||||||
import java.util.StringJoiner; |
|
||||||
|
|
||||||
public final class College { |
|
||||||
public final String id; |
|
||||||
public final String name; |
|
||||||
|
|
||||||
public College(String id, String name) { |
|
||||||
this.id = id; |
|
||||||
this.name = name; |
|
||||||
} |
|
||||||
|
|
||||||
public String getId() { |
|
||||||
return id; |
|
||||||
} |
|
||||||
|
|
||||||
public String getName() { |
|
||||||
return name; |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String toString() { |
|
||||||
return new StringJoiner(", ", College.class.getSimpleName() + "[", "]") |
|
||||||
.add("id='" + id + "'") |
|
||||||
.add("name='" + name + "'") |
|
||||||
.toString(); |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,16 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
<groupId>cn.linghang</groupId> |
||||||
|
<artifactId>mywust-network-httpclient</artifactId> |
||||||
|
<version>0.0.1-fixed</version> |
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>org.projectlombok</groupId> |
||||||
|
<artifactId>lombok</artifactId> |
||||||
|
<version>1.18.22</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
</project> |
@ -0,0 +1,40 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
<groupId>cn.linghang</groupId> |
||||||
|
<artifactId>mywust-network-okhttp</artifactId> |
||||||
|
<version>0.0.1-fixed</version> |
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>com.squareup.okhttp3</groupId> |
||||||
|
<artifactId>okhttp</artifactId> |
||||||
|
<version>3.14.9</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.slf4j</groupId> |
||||||
|
<artifactId>slf4j-api</artifactId> |
||||||
|
<version>1.7.36</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>cn.linghang</groupId> |
||||||
|
<artifactId>mywust-network</artifactId> |
||||||
|
<version>0.0.1-fixed</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>cn.linghang</groupId> |
||||||
|
<artifactId>mywust-util</artifactId> |
||||||
|
<version>0.0.1-fixed</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.projectlombok</groupId> |
||||||
|
<artifactId>lombok</artifactId> |
||||||
|
<version>1.18.22</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
</project> |
@ -0,0 +1,22 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
<groupId>cn.linghang</groupId> |
||||||
|
<artifactId>mywust-network</artifactId> |
||||||
|
<version>0.0.1-fixed</version> |
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>cn.linghang</groupId> |
||||||
|
<artifactId>mywust-util</artifactId> |
||||||
|
<version>0.0.1-fixed</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.projectlombok</groupId> |
||||||
|
<artifactId>lombok</artifactId> |
||||||
|
<version>1.18.22</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
</project> |
@ -0,0 +1,49 @@ |
|||||||
|
import cn.linghang.mywust.core.exception.BasicException; |
||||||
|
import cn.linghang.mywust.core.parser.Parser; |
||||||
|
import cn.linghang.mywust.core.parser.undergraduate.CourseTableParser; |
||||||
|
import cn.linghang.mywust.core.service.undergraduate.CourseTableApiService; |
||||||
|
import cn.linghang.mywust.model.global.Course; |
||||||
|
import cn.linghang.mywust.network.RequestClientOption; |
||||||
|
import cn.linghang.mywust.network.Requester; |
||||||
|
import cn.linghang.mywust.network.okhttp.SimpleOkhttpRequester; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Scanner; |
||||||
|
|
||||||
|
public class CourseTableTest { |
||||||
|
@Test |
||||||
|
public void run() throws BasicException, IOException { |
||||||
|
System.out.println("课表"); |
||||||
|
System.out.println("Cookie:"); |
||||||
|
|
||||||
|
Scanner scanner = new Scanner(System.in); |
||||||
|
|
||||||
|
String cookie = scanner.nextLine(); |
||||||
|
|
||||||
|
System.out.println("使用Cookie:" + cookie); |
||||||
|
|
||||||
|
System.out.println("学期(如2022-2023-1):"); |
||||||
|
String term = scanner.nextLine(); |
||||||
|
System.out.println("使用学期:" + term); |
||||||
|
|
||||||
|
Requester requester = new SimpleOkhttpRequester(); |
||||||
|
CourseTableApiService service = new CourseTableApiService(requester); |
||||||
|
|
||||||
|
RequestClientOption option = new RequestClientOption(); |
||||||
|
option.setTimeout(5); |
||||||
|
RequestClientOption.Proxy proxy = new RequestClientOption.Proxy(); |
||||||
|
proxy.setPort(6060); |
||||||
|
proxy.setAddress("127.0.0.1"); |
||||||
|
option.setProxy(proxy); |
||||||
|
option.setFallowUrlRedirect(false); |
||||||
|
|
||||||
|
Parser<List<Course>> parser = new CourseTableParser(); |
||||||
|
List<Course> courses = parser.parse(service.getCourseTablePage(term, cookie, option)); |
||||||
|
|
||||||
|
for (Course info : courses) { |
||||||
|
System.out.println(info); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
import cn.linghang.mywust.core.exception.BasicException; |
||||||
|
import cn.linghang.mywust.core.parser.Parser; |
||||||
|
import cn.linghang.mywust.core.parser.undergraduate.ExamInfoParser; |
||||||
|
import cn.linghang.mywust.core.service.undergraduate.ExamInfoApiService; |
||||||
|
import cn.linghang.mywust.model.global.ExamInfo; |
||||||
|
import cn.linghang.mywust.network.RequestClientOption; |
||||||
|
import cn.linghang.mywust.network.Requester; |
||||||
|
import cn.linghang.mywust.network.okhttp.SimpleOkhttpRequester; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Scanner; |
||||||
|
|
||||||
|
public class ExamInfoTest { |
||||||
|
@Test |
||||||
|
public void run() throws BasicException, IOException { |
||||||
|
System.out.println("成绩获取"); |
||||||
|
System.out.println("Cookie:"); |
||||||
|
|
||||||
|
Scanner scanner = new Scanner(System.in); |
||||||
|
|
||||||
|
String cookie = scanner.nextLine(); |
||||||
|
|
||||||
|
System.out.println("使用Cookie:" + cookie); |
||||||
|
|
||||||
|
Requester requester = new SimpleOkhttpRequester(); |
||||||
|
ExamInfoApiService jwcService = new ExamInfoApiService(requester); |
||||||
|
|
||||||
|
RequestClientOption option = new RequestClientOption(); |
||||||
|
option.setTimeout(5); |
||||||
|
RequestClientOption.Proxy proxy = new RequestClientOption.Proxy(); |
||||||
|
proxy.setPort(8080); |
||||||
|
proxy.setAddress("127.0.0.1"); |
||||||
|
option.setProxy(proxy); |
||||||
|
option.setFallowUrlRedirect(false); |
||||||
|
|
||||||
|
Parser<List<ExamInfo>> parser = new ExamInfoParser(); |
||||||
|
List<ExamInfo> infos = parser.parse(jwcService.getExamInfoPage(cookie, option)); |
||||||
|
|
||||||
|
for (ExamInfo info : infos) { |
||||||
|
|
||||||
|
System.out.println(info); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
import cn.linghang.mywust.core.exception.BasicException; |
||||||
|
import cn.linghang.mywust.core.service.auth.UnionLogin; |
||||||
|
import cn.linghang.mywust.core.service.auth.JwcLogin; |
||||||
|
import cn.linghang.mywust.network.RequestClientOption; |
||||||
|
import cn.linghang.mywust.network.Requester; |
||||||
|
import cn.linghang.mywust.network.okhttp.SimpleOkhttpRequester; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.Scanner; |
||||||
|
|
||||||
|
public class JwcLoginTest { |
||||||
|
@Test |
||||||
|
public void run() throws BasicException, IOException { |
||||||
|
System.out.println("bkjx登录测试(统一身份验证)"); |
||||||
|
System.out.println("输入账号(学号)和密码,用“ ”(空格)分割"); |
||||||
|
|
||||||
|
Scanner scanner = new Scanner(System.in); |
||||||
|
|
||||||
|
String input = scanner.nextLine(); |
||||||
|
|
||||||
|
String username = input.split(" ")[0]; |
||||||
|
String password = input.split(" ")[1]; |
||||||
|
|
||||||
|
System.out.println("账号:" + username); |
||||||
|
System.out.println("密码:" + password); |
||||||
|
|
||||||
|
Requester requester = new SimpleOkhttpRequester(); |
||||||
|
JwcLogin jwcLogin = new JwcLogin(requester); |
||||||
|
|
||||||
|
RequestClientOption option = new RequestClientOption(); |
||||||
|
option.setTimeout(5); |
||||||
|
option.setFallowUrlRedirect(false); |
||||||
|
RequestClientOption.Proxy proxy = new RequestClientOption.Proxy(); |
||||||
|
proxy.setPort(6060); |
||||||
|
proxy.setAddress("127.0.0.1"); |
||||||
|
option.setProxy(proxy); |
||||||
|
|
||||||
|
String cookies = jwcLogin.getLoginCookie(username, password, option); |
||||||
|
|
||||||
|
System.out.printf("获取到Cookies: %s \n", cookies); |
||||||
|
|
||||||
|
System.out.printf("检查Cookies: %s", jwcLogin.checkCookies(cookies, RequestClientOption.DEFAULT_OPTION)); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
import cn.linghang.mywust.core.exception.BasicException; |
||||||
|
import cn.linghang.mywust.core.service.auth.UnionLogin; |
||||||
|
import cn.linghang.mywust.core.service.auth.LibraryLogin; |
||||||
|
import cn.linghang.mywust.network.RequestClientOption; |
||||||
|
import cn.linghang.mywust.network.Requester; |
||||||
|
import cn.linghang.mywust.network.okhttp.SimpleOkhttpRequester; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.Scanner; |
||||||
|
|
||||||
|
public class LibraryLoginTest { |
||||||
|
@Test |
||||||
|
public void run() throws BasicException, IOException { |
||||||
|
System.out.println("图书馆登陆测试"); |
||||||
|
System.out.println("输入账号(学号)和密码,用“ ”(空格)分割"); |
||||||
|
|
||||||
|
Scanner scanner = new Scanner(System.in); |
||||||
|
|
||||||
|
String input = scanner.nextLine(); |
||||||
|
|
||||||
|
String username = input.split(" ")[0]; |
||||||
|
String password = input.split(" ")[1]; |
||||||
|
|
||||||
|
System.out.println("账号:" + username); |
||||||
|
System.out.println("密码:" + password); |
||||||
|
|
||||||
|
Requester requester = new SimpleOkhttpRequester(); |
||||||
|
LibraryLogin libraryLogin = new LibraryLogin(requester); |
||||||
|
|
||||||
|
RequestClientOption option = RequestClientOption.DEFAULT_OPTION; |
||||||
|
|
||||||
|
String cookies = libraryLogin.getLibraryLoginCookie(username, password, option); |
||||||
|
|
||||||
|
System.out.printf("获取到的cookies: %s \n", cookies); |
||||||
|
|
||||||
|
System.out.printf("检查Cookies: %s", libraryLogin.checkCookie(cookies)); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
import cn.linghang.mywust.core.exception.BasicException; |
||||||
|
import cn.linghang.mywust.core.service.undergraduate.TrainingPlanApiService; |
||||||
|
import cn.linghang.mywust.network.RequestClientOption; |
||||||
|
import cn.linghang.mywust.network.Requester; |
||||||
|
import cn.linghang.mywust.network.okhttp.SimpleOkhttpRequester; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.Scanner; |
||||||
|
|
||||||
|
public class SchemeTest { |
||||||
|
@Test |
||||||
|
public void run() throws BasicException, IOException { |
||||||
|
System.out.println("培养方案获取"); |
||||||
|
System.out.println("Cookie:"); |
||||||
|
|
||||||
|
Scanner scanner = new Scanner(System.in); |
||||||
|
|
||||||
|
String cookie = scanner.nextLine(); |
||||||
|
|
||||||
|
System.out.println("使用Cookie:" + cookie); |
||||||
|
|
||||||
|
RequestClientOption option = new RequestClientOption(); |
||||||
|
option.setTimeout(5); |
||||||
|
RequestClientOption.Proxy proxy = new RequestClientOption.Proxy(); |
||||||
|
proxy.setPort(6060); |
||||||
|
proxy.setAddress("127.0.0.1"); |
||||||
|
option.setProxy(null); |
||||||
|
option.setFallowUrlRedirect(false); |
||||||
|
|
||||||
|
Requester requester = new SimpleOkhttpRequester(); |
||||||
|
TrainingPlanApiService jwcService = new TrainingPlanApiService(requester); |
||||||
|
|
||||||
|
String page = jwcService.getTrainingPlanPage(cookie, option); |
||||||
|
|
||||||
|
System.out.println(page); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,39 @@ |
|||||||
|
import cn.linghang.mywust.core.exception.BasicException; |
||||||
|
import cn.linghang.mywust.core.parser.Parser; |
||||||
|
import cn.linghang.mywust.core.parser.undergraduate.StudentInfoPageParser; |
||||||
|
import cn.linghang.mywust.core.service.undergraduate.StudentInfoApiService; |
||||||
|
import cn.linghang.mywust.model.global.StudentInfo; |
||||||
|
import cn.linghang.mywust.network.RequestClientOption; |
||||||
|
import cn.linghang.mywust.network.Requester; |
||||||
|
import cn.linghang.mywust.network.okhttp.SimpleOkhttpRequester; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.Scanner; |
||||||
|
|
||||||
|
public class StudentInfoPageTest { |
||||||
|
@Test |
||||||
|
public void run() throws BasicException, IOException { |
||||||
|
System.out.println("学生信息获取"); |
||||||
|
System.out.println("Cookie:"); |
||||||
|
|
||||||
|
Scanner scanner = new Scanner(System.in); |
||||||
|
|
||||||
|
String cookie = scanner.nextLine(); |
||||||
|
|
||||||
|
System.out.println("使用Cookie:" + cookie); |
||||||
|
|
||||||
|
Requester requester = new SimpleOkhttpRequester(); |
||||||
|
StudentInfoApiService jwcService = new StudentInfoApiService(requester); |
||||||
|
|
||||||
|
RequestClientOption option = new RequestClientOption(); |
||||||
|
option.setTimeout(5); |
||||||
|
option.setProxy(null); |
||||||
|
option.setFallowUrlRedirect(false); |
||||||
|
|
||||||
|
Parser<StudentInfo> parser = new StudentInfoPageParser(); |
||||||
|
StudentInfo info = parser.parse(jwcService.getStudentInfoPage(cookie, option)); |
||||||
|
|
||||||
|
System.out.println(info); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,2 @@ |
|||||||
|
public class UnderGraduateTest { |
||||||
|
} |
@ -0,0 +1,58 @@ |
|||||||
|
import cn.linghang.mywust.core.exception.BasicException; |
||||||
|
import cn.linghang.mywust.core.parser.Parser; |
||||||
|
import cn.linghang.mywust.core.parser.physics.PhysicsCoursePageParser; |
||||||
|
import cn.linghang.mywust.core.service.auth.PhysicsLogin; |
||||||
|
import cn.linghang.mywust.core.service.physics.PhysicsApiService; |
||||||
|
import cn.linghang.mywust.model.global.Course; |
||||||
|
import cn.linghang.mywust.model.physics.PhysicsCourse; |
||||||
|
import cn.linghang.mywust.network.RequestClientOption; |
||||||
|
import cn.linghang.mywust.network.Requester; |
||||||
|
import cn.linghang.mywust.network.okhttp.SimpleOkhttpRequester; |
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
|
||||||
|
import java.io.IOException; |
||||||
|
import java.util.List; |
||||||
|
import java.util.Scanner; |
||||||
|
|
||||||
|
public class WlsyLoginTest { |
||||||
|
@Test |
||||||
|
public void run() throws BasicException, IOException { |
||||||
|
System.out.println("物理实验登陆测试"); |
||||||
|
System.out.println("输入账号(学号)和密码,用“ ”(空格)分割"); |
||||||
|
|
||||||
|
Scanner scanner = new Scanner(System.in); |
||||||
|
|
||||||
|
String input = scanner.nextLine(); |
||||||
|
|
||||||
|
String username = input.split(" ")[0]; |
||||||
|
String password = input.split(" ")[1]; |
||||||
|
|
||||||
|
System.out.println("账号:" + username); |
||||||
|
System.out.println("密码:" + password); |
||||||
|
|
||||||
|
Requester requester = new SimpleOkhttpRequester(); |
||||||
|
PhysicsLogin physicsLogin = new PhysicsLogin(requester); |
||||||
|
|
||||||
|
RequestClientOption option = RequestClientOption.DEFAULT_OPTION; |
||||||
|
RequestClientOption.Proxy proxy = new RequestClientOption.Proxy(); |
||||||
|
proxy.setAddress("127.0.0.1"); |
||||||
|
proxy.setPort(8080); |
||||||
|
option.setProxy(proxy); |
||||||
|
|
||||||
|
String cookies = physicsLogin.getLoginCookie(username, password, option); |
||||||
|
|
||||||
|
System.out.printf("获取到的cookies: %s \n", cookies); |
||||||
|
|
||||||
|
option.setFallowUrlRedirect(false); |
||||||
|
PhysicsApiService api = new PhysicsApiService(requester); |
||||||
|
String response = api.getCoursePage(cookies, option); |
||||||
|
System.out.println(response); |
||||||
|
|
||||||
|
Parser<List<PhysicsCourse>> parser = new PhysicsCoursePageParser(); |
||||||
|
List<PhysicsCourse> courses = parser.parse(response); |
||||||
|
|
||||||
|
for (Course info : courses) { |
||||||
|
System.out.println(info); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||||
|
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||||
|
<modelVersion>4.0.0</modelVersion> |
||||||
|
<groupId>cn.linghang</groupId> |
||||||
|
<artifactId>mywust-util</artifactId> |
||||||
|
<version>0.0.1-fixed</version> |
||||||
|
<dependencies> |
||||||
|
<dependency> |
||||||
|
<groupId>commons-codec</groupId> |
||||||
|
<artifactId>commons-codec</artifactId> |
||||||
|
<version>1.15</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>com.google.guava</groupId> |
||||||
|
<artifactId>guava</artifactId> |
||||||
|
<version>31.1-jre</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.projectlombok</groupId> |
||||||
|
<artifactId>lombok</artifactId> |
||||||
|
<version>1.18.22</version> |
||||||
|
<scope>compile</scope> |
||||||
|
</dependency> |
||||||
|
</dependencies> |
||||||
|
</project> |
Loading…
Reference in new issue