新增本科生的全校教室课表、课程课表、教师课表页面获取,新增教学楼信息获取;添加一些参数常量

old-package
lensfrex 2 years ago
parent 25c78714c5
commit 29e482943b
Signed by: lensfrex
GPG Key ID: 947ADABD8533C476
  1. 1
      .gitignore
  2. 159
      mywust-core/src/main/java/cn/linghang/mywust/core/api/ConstantParams.java
  3. 145
      mywust-core/src/main/java/cn/linghang/mywust/core/api/UndergradUrls.java
  4. 3
      mywust-core/src/main/java/cn/linghang/mywust/core/exception/ApiException.java
  5. 9
      mywust-core/src/main/java/cn/linghang/mywust/core/request/undergrade/BkjxRequestFactory.java
  6. 72
      mywust-core/src/main/java/cn/linghang/mywust/core/request/undergrade/global/BkjxAllCourseRequestFactory.java
  7. 45
      mywust-core/src/main/java/cn/linghang/mywust/core/service/undergraduate/global/UndergradAllCourseScheduleApiService.java
  8. 74
      mywust-core/src/main/java/cn/linghang/mywust/core/service/undergraduate/global/UndergradBuildingIdApiService.java
  9. 46
      mywust-core/src/main/java/cn/linghang/mywust/core/service/undergraduate/global/UndergradClassroomCourseApiService.java
  10. 45
      mywust-core/src/main/java/cn/linghang/mywust/core/service/undergraduate/global/UndergradTeacherCourseApiService.java
  11. 6
      mywust-model/src/main/java/cn/linghang/mywust/model/global/Building.java
  12. 4
      mywust-network/src/main/java/cn/linghang/mywust/network/entitys/FormBodyBuilder.java

1
.gitignore vendored

@ -33,3 +33,4 @@ build/
.vscode/ .vscode/
*/.flattened-pom.xml */.flattened-pom.xml
/.flattened-pom.xml

@ -0,0 +1,159 @@
package cn.linghang.mywust.core.api;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* 一些需要用到的from参数一般来说是写死固定的
* 别慌都是脚本自动处理生成的代码肯定不会是手写的
*/
public class ConstantParams {
/**
* 默认节次模式
*/
public static final String DEFAULT_TIME_MODEL = "9486203B90F3E3CBE0532914A8C03BE2";
private static final Map<String, String> collegesTmp = new HashMap<>(27);
public static final Map<String, String> COLLEGES = Collections.unmodifiableMap(collegesTmp);
static {
collegesTmp.put("00001", "资源与环境工程学院");
collegesTmp.put("00002", "材料与冶金学院");
collegesTmp.put("00003", "机械自动化学院");
collegesTmp.put("00004", "信息科学与工程学院(人工智能学院)");
collegesTmp.put("00005", "管理学院(恒大管理学院)");
collegesTmp.put("00006", "法学与经济学院");
collegesTmp.put("00007", "理学院");
collegesTmp.put("00008", "城市建设学院");
collegesTmp.put("00009", "医学院");
collegesTmp.put("00012", "电子技术学院");
collegesTmp.put("00013", "计算机科学与技术学院");
collegesTmp.put("00014", "外国语学院");
collegesTmp.put("00015", "体育学院(恒大足球学院)");
collegesTmp.put("0D5444D56D8A46EDB75633181B2042A7", "图书馆");
collegesTmp.put("26057DF4B9354C6EA85860F1357FE8EB", "工程训练中心");
collegesTmp.put("00018", "生命科学与健康学院");
collegesTmp.put("00019", "艺术与设计学院");
collegesTmp.put("00023", "国际学院");
collegesTmp.put("00024", "化学与化工学院");
collegesTmp.put("00025", "汽车与交通工程学院");
collegesTmp.put("00026", "临床学院");
collegesTmp.put("0W6z90XTY6", "学生工作处");
collegesTmp.put("jkwHhwCHLl", "马克思主义学院");
collegesTmp.put("0C4B597EE18B418B9AA5C52FDAB3EC73", "香涛学院");
collegesTmp.put("379A57BA53DD4F25BA7582CE3180C077", "公共卫生学院");
collegesTmp.put("9AA8C9B34EE74DEC8E02F4554B1B5125", "研究生院");
collegesTmp.put("86AC446406A94EF09DE1F8B7C17F994A", "全校");
// 手动补充两个,虽然在这里没啥用,查不出什么东西出来
collegesTmp.put("34EFAEAE2B6A470781B9BCFF364D3980", "党委宣传部");
collegesTmp.put("9C6FD49D03D74209B062A632A860FECA", "创新创业学院");
}
private static final Map<String, String[]> collegePartsTmp = new HashMap<>();
public static final Map<String, String[]> COLLEGE_PARTS = Collections.unmodifiableMap(collegePartsTmp);
static {
collegePartsTmp.put("00001", new String[]{"0101", "0105", "0106", "0107", "0150", "0151", "0152", "0153", "0198",});
collegePartsTmp.put("00002", new String[]{"0201", "0202", "0203", "0204", "0205", "0206", "0250", "0251", "0252", "0253", "0254", "0255", "0298", "200099",});
collegePartsTmp.put("00003", new String[]{"0302", "0304", "0305", "0307", "0308", "0309", "0350", "0398",});
collegePartsTmp.put("00004", new String[]{"0401", "0402", "0403", "0404", "0405", "0406", "0450", "0452", "0498",});
collegePartsTmp.put("00005", new String[]{"0501", "0502", "0503", "0504", "0505", "0506", "0507", "0550", "0598",});
collegePartsTmp.put("00006", new String[]{"0602", "0603", "0604", "0607", "0609", "0610", "0650", "0698",});
collegePartsTmp.put("00007", new String[]{"0701", "0702", "0703", "0750", "0751", "0752", "0753", "0754", "0798",});
collegePartsTmp.put("00008", new String[]{"0802", "0803", "0806", "0807", "0811", "0850", "0851", "0852", "FB5251B1BD064A178FFB96C64DDAE87A", "0898",});
collegePartsTmp.put("00009", new String[]{"0924", "0925", "0926", "0927", "0928", "0950", "0951", "0952", "0953", "0954", "0955", "0998",});
collegePartsTmp.put("00012", new String[]{"200096", "200114",});
collegePartsTmp.put("00013", new String[]{"1302", "1303", "1304", "1305", "1306", "1350", "1351", "1398",});
collegePartsTmp.put("00014", new String[]{"1401", "1402", "1403", "1404", "1405", "1450", "1498",});
collegePartsTmp.put("00015", new String[]{"1501", "1502", "1598",});
collegePartsTmp.put("0D5444D56D8A46EDB75633181B2042A7", new String[]{"1601", "1698",});
collegePartsTmp.put("26057DF4B9354C6EA85860F1357FE8EB", new String[]{"1701", "1798",});
collegePartsTmp.put("00018", new String[]{"1801", "1850", "1898",});
collegePartsTmp.put("00019", new String[]{"1904", "1906", "1908", "1950", "1998",});
collegePartsTmp.put("00023", new String[]{"2101", "2102", "2103", "2104", "2105", "2198",});
collegePartsTmp.put("00024", new String[]{"2202", "2203", "2204", "2206", "2250", "2251", "2252", "2253", "2254", "2298",});
collegePartsTmp.put("00025", new String[]{"2301", "2302", "2303", "2350", "2351", "2352", "2398",});
collegePartsTmp.put("00026", new String[]{"2401", "2402", "2403", "2404", "2405", "2406", "2407", "2408", "2410", "2411", "2412", "2413", "2498",});
collegePartsTmp.put("0W6z90XTY6", new String[]{"2501", "2502", "2503", "2504", "2598",});
collegePartsTmp.put("jkwHhwCHLl", new String[]{"5101", "5102", "5103", "5104", "5105", "5106", "5198",});
collegePartsTmp.put("0C4B597EE18B418B9AA5C52FDAB3EC73", new String[]{});
collegePartsTmp.put("379A57BA53DD4F25BA7582CE3180C077", new String[]{});
collegePartsTmp.put("34EFAEAE2B6A470781B9BCFF364D3980", new String[]{"C53EBF84BD4240A5B320BEC25F90B9E5",});
collegePartsTmp.put("9AA8C9B34EE74DEC8E02F4554B1B5125", new String[]{"6001", "6098",});
collegePartsTmp.put("9C6FD49D03D74209B062A632A860FECA", new String[]{"9A52123E0AC842C1A0FEFB2E24359904",});
collegePartsTmp.put("86AC446406A94EF09DE1F8B7C17F994A", new String[]{"0756C43634094A0FA92FE3FE0E1F0503",});
}
private static final Map<String, String> campusTmp = new HashMap<>(3);
public static final Map<String, String> CAMPUS = Collections.unmodifiableMap(campusTmp);
static {
campusTmp.put("00001", "青山校区");
// campusTmp.put("00002", "洪山校区");
// campusTmp.put("00003", "医学院");
// campusTmp.put("00004", "城市学院");
// campusTmp.put("00005", "东湖教学区");
campusTmp.put("00006", "黄家湖校区");
campusTmp.put("00007", "附属医院");
// campusTmp.put("00008", "武钢医院");
}
/**
* 教室目前只做了黄家湖青山和附属医学院的数据其他校区在制作时相关数据都是空的
* 需要更多信息请请求相关接口获取
*/
private static final Map<String, String> qingshanBuildingTmp = new HashMap<>(10);
public static final Map<String, String> QINGSHAN_BUILDINGS = Collections.unmodifiableMap(qingshanBuildingTmp);
private static final Map<String, String> huangjiahuBuildingTmp = new HashMap<>(10);
public static final Map<String, String> huangjiahu_BUILDINGS = Collections.unmodifiableMap(huangjiahuBuildingTmp);
private static final Map<String, String> medicineSchoolBuildingTmp = new HashMap<>(10);
public static final Map<String, String> medicineSchool_BUILDINGS = Collections.unmodifiableMap(medicineSchoolBuildingTmp);
static {
qingshanBuildingTmp.put("FE88C3D75F9C4C8CA50B82ACDF83530B", "科大雅苑C栋");
qingshanBuildingTmp.put("3B76302812FD4262B8BD703814D0D8C3", "科大雅苑A栋");
qingshanBuildingTmp.put("90C06D274E254A2CADC88DF1CEBD8396", "教十楼");
qingshanBuildingTmp.put("00001", "主楼");
qingshanBuildingTmp.put("00002", "教一楼");
qingshanBuildingTmp.put("00003", "教二楼");
qingshanBuildingTmp.put("00004", "教三楼");
qingshanBuildingTmp.put("00005", "教四楼");
qingshanBuildingTmp.put("00006", "教五楼");
qingshanBuildingTmp.put("00007", "教六楼");
qingshanBuildingTmp.put("00008", "图书馆");
qingshanBuildingTmp.put("00009", "本部东院体育场");
qingshanBuildingTmp.put("00010", "机械厂");
qingshanBuildingTmp.put("00024", "本部西院体育场");
qingshanBuildingTmp.put("00025", "本部北院体育场");
qingshanBuildingTmp.put("00029", "教七楼");
qingshanBuildingTmp.put("00031", "本部教二楼化学实验区");
qingshanBuildingTmp.put("00032", "学院实验室");
qingshanBuildingTmp.put("00051", "校本部停用教室");
huangjiahuBuildingTmp.put("D1521DE0E4CF4641AB4C49CA39EF5E47", "教八楼(管理学院)");
huangjiahuBuildingTmp.put("FBD19C52EC3B4A93A6268B815EFA9A5A", "教九楼(汽车学院)");
huangjiahuBuildingTmp.put("00034", "恒大楼一区");
huangjiahuBuildingTmp.put("00035", "恒大楼二区");
huangjiahuBuildingTmp.put("00036", "恒大楼三区");
huangjiahuBuildingTmp.put("00037", "黄家湖校区体育场");
huangjiahuBuildingTmp.put("00041", "黄家湖校区体育馆");
huangjiahuBuildingTmp.put("00042", "教二楼(理学院)");
huangjiahuBuildingTmp.put("00043", "教三楼(计算机学院)");
huangjiahuBuildingTmp.put("00045", "教四楼二区(外国语学院)");
huangjiahuBuildingTmp.put("00046", "教四楼一区(文法学院)");
huangjiahuBuildingTmp.put("00048", "教五楼一区");
huangjiahuBuildingTmp.put("00049", "教五楼二区");
huangjiahuBuildingTmp.put("00050", "教六楼(医学院)");
huangjiahuBuildingTmp.put("00052", "黄家湖校区停用教室");
huangjiahuBuildingTmp.put("D29468E2AD8241769F47D82913C537EA", "黄家湖校区工程训练中心");
huangjiahuBuildingTmp.put("F9A375E92D814DD3BC2EF30E33C4907B", "教七楼(艺术学院)");
huangjiahuBuildingTmp.put("DFC73608380C4079A44D4215BD81EB88", "教十一楼");
medicineSchoolBuildingTmp.put("00047", "附属医院教学楼");
}
}

@ -1,8 +1,5 @@
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.*; import java.util.*;
@ -58,131 +55,41 @@ public class UndergradUrls {
*/ */
public static final String BKJX_EXAM_ACTIVITY_LIST_API = "http://bkjx.wust.edu.cn/jsxsd/kscj/hksq_query_ajax?&xnxq01id=%s"; 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_BUILDING_LIST_API = "http://bkjx.wust.edu.cn/jsxsd/kbcx/getJxlByAjax";
/** /**
* 缓考申请url * 缓考申请url
*/ */
public static final String BKJX_EXAM_DELAY_APPLICATION_LIST_API = "http://bkjx.wust.edu.cn/jsxsd/kscj/hksq_list"; 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 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_SESSION_COOKIE_API = "http://bkjx.wust.edu.cn/Logon.do?method=logon";
}
/** /**
* 一些需要用到的from参数一般来说是写死固定的 * 教室课表url
*/ */
// 别慌,大部分都是脚本自动生成的代码,肯定不会是手写的。 public static final String BKJX_CLASSROOM_COURSE_API = "http://bkjx.wust.edu.cn/jsxsd/kbcx/kbxx_classroom_ifr";
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); * 课程课表url
*/
static { public static final String BKJX_ALL_COURSE_SCHEDULE_API = "http://bkjx.wust.edu.cn/jsxsd/kbcx/kbxx_kc_ifr";
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", "武钢医院");
}
/** /**
* 教室目前只做了黄家湖青山和附属医学院的数据其他校区在制作时相关数据都是空的 * 教师课表url
* 需要更多信息请请求相关接口获取 */
*/ public static final String BKJX_TEACHER_COURSE_API = "http://bkjx.wust.edu.cn/jsxsd/kbcx/kbxx_teacher_ifr";
private static final Map<Campus, List<Building>> buildingTmp = new HashMap<>(3);
public static final Map<Campus, List<Building>> BUILDINGS = Collections.unmodifiableMap(buildingTmp); /**
* 班级课表url
static { */
Campus qingshan = CAMPUS.get(0); public static final String BKJX_CLASS_COURSE_API = "http://bkjx.wust.edu.cn/jsxsd/kbcx/kbxx_xzb_ifr";
List<Building> qingshanBuildings = new ArrayList<>(10);
qingshanBuildings.add(new Building("FE88C3D75F9C4C8CA50B82ACDF83530B", "科大雅苑C栋", qingshan)); public static class Legacy {
qingshanBuildings.add(new Building("3B76302812FD4262B8BD703814D0D8C3", "科大雅苑A栋", qingshan)); public static final String BKJX_INDEX = "http://bkjx.wust.edu.cn";
qingshanBuildings.add(new Building("90C06D274E254A2CADC88DF1CEBD8396", "教十楼", qingshan)); public static final String BKJX_DATA_STRING_API = "http://bkjx.wust.edu.cn/Logon.do?method=logon&flag=sess";
qingshanBuildings.add(new Building("00001", "主楼", qingshan)); public static final String BKJX_SESSION_COOKIE_API = "http://bkjx.wust.edu.cn/Logon.do?method=logon";
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);
}
} }
} }

@ -4,6 +4,7 @@ public class ApiException extends BasicException {
private final Code code; private final Code code;
public ApiException(Code code) { public ApiException(Code code) {
super(code.toString());
this.code = code; this.code = code;
} }
@ -34,7 +35,7 @@ public class ApiException extends BasicException {
@Override @Override
public String toString() { public String toString() {
return "Mywust接口调用异常: " + code + ";" + getMessage(); return "接口调用异常: " + code + ";" + ((getMessage() == null && code == Code.UNKNOWN_EXCEPTION) ? "" : getMessage());
} }
public enum Code { public enum Code {

@ -20,7 +20,7 @@ public class BkjxRequestFactory extends RequestFactory {
} }
public static HttpRequest examScoreInfoRequest(String cookies, String time, String courseKind, String courseName) { public static HttpRequest examScoreInfoRequest(String cookies, String time, String courseKind, String courseName) {
FormBodyBuilder formBodyBuilder = new FormBodyBuilder(); FormBodyBuilder formBodyBuilder = new FormBodyBuilder(4);
// 开课时间(学期) // 开课时间(学期)
formBodyBuilder.add("kksj", time); formBodyBuilder.add("kksj", time);
@ -95,7 +95,8 @@ public class BkjxRequestFactory extends RequestFactory {
} }
public static HttpRequest buildingListRequest(String campus, String cookie) { public static HttpRequest buildingListRequest(String campus, String cookie) {
return null; // campus可以为空(就是不知道获取到的是哪个校区的楼了),但是null不行
return makeStringDataHttpRequest(UndergradUrls.BKJX_BUILDING_LIST_API, campus == null ? "" : campus, cookie);
} }
public static HttpRequest buildingListRequest(Campus campus, String cookie) { public static HttpRequest buildingListRequest(Campus campus, String cookie) {
@ -108,14 +109,14 @@ public class BkjxRequestFactory extends RequestFactory {
} }
public static HttpRequest ticketRedirectRequest(String encode) { public static HttpRequest ticketRedirectRequest(String encode) {
Map<String, String> queryParams = new HashMap<>(); Map<String, String> queryParams = new HashMap<>(4);
queryParams.put("userAccount", ""); queryParams.put("userAccount", "");
queryParams.put("userPassword", ""); queryParams.put("userPassword", "");
queryParams.put("encoded", encode); queryParams.put("encoded", encode);
String queryString = StringUtil.generateQueryString(queryParams); String queryString = StringUtil.generateQueryString(queryParams);
Map<String, String> extendHeaders = new HashMap<>(); Map<String, String> extendHeaders = new HashMap<>(2);
extendHeaders.put("Referer", "http://bkjx.wust.edu.cn/"); extendHeaders.put("Referer", "http://bkjx.wust.edu.cn/");
extendHeaders.put("Origin", "http://bkjx.wust.edu.cn"); extendHeaders.put("Origin", "http://bkjx.wust.edu.cn");

@ -0,0 +1,72 @@
package cn.linghang.mywust.core.request.undergrade.global;
import cn.linghang.mywust.core.api.ConstantParams;
import cn.linghang.mywust.core.api.UndergradUrls;
import cn.linghang.mywust.core.request.undergrade.BkjxRequestFactory;
import cn.linghang.mywust.network.entitys.FormBodyBuilder;
import cn.linghang.mywust.network.entitys.HttpRequest;
public class BkjxAllCourseRequestFactory extends BkjxRequestFactory {
public static HttpRequest classroomCoursePageRequest(String cookies, String term, String timeMode, String collegeId, String campusId, String buildingId, String classroomName) {
FormBodyBuilder formBodyBuilder = new FormBodyBuilder(13);
formBodyBuilder
.add("xnxqh", term)
.add("kbjcmsid", timeMode == null ? ConstantParams.DEFAULT_TIME_MODEL : timeMode)
// 上课学院,虽然能获取到,但是不符合预期的功能,得到的结果是这个学院上的课,而不是这个学院开的课
.add("skyx", collegeId)
.add("xqid", campusId)
.add("jzwid", buildingId)
.add("skjs", classroomName)
.add("skjsid", "")
.add("zc1", "")
.add("zc2", "")
.add("skxq1", "")
.add("skxq2", "")
.add("jc1", "")
.add("jc2", "");
return makeStringDataHttpRequest(UndergradUrls.BKJX_CLASSROOM_COURSE_API, formBodyBuilder.buildAndToString(), cookies);
}
public static HttpRequest teacherCoursePageRequest(String cookies, String term, String timeMode, String collegeId, String teacherName) {
FormBodyBuilder formBodyBuilder = new FormBodyBuilder(10);
formBodyBuilder
.add("xnxqh", term)
.add("kbjcmsid", timeMode == null ? ConstantParams.DEFAULT_TIME_MODEL : timeMode)
// 这里的学院其实不是真正开课的学院,观察发现其实是这个学院的老师上的课,但是课不一定是这个学院开的
.add("skyx", collegeId)
.add("skjs", teacherName)
.add("zc1", "")
.add("zc2", "")
.add("skxq1", "")
.add("skxq2", "")
.add("jc1", "")
.add("jc2", "");
return makeStringDataHttpRequest(UndergradUrls.BKJX_CLASSROOM_COURSE_API, formBodyBuilder.buildAndToString(), cookies);
}
public static HttpRequest allCourseSchedulePageRequest(String cookies, String term, String timeMode, String subCollegeId, String courseName) {
FormBodyBuilder formBodyBuilder = new FormBodyBuilder(15);
formBodyBuilder
.add("xnxqh", term)
.add("kbjcmsid", timeMode == null ? ConstantParams.DEFAULT_TIME_MODEL : timeMode)
// 上课学院,虽然能获取到,但是不符合预期的功能,得到的结果是这个学院上的课,而不是这个学院开的课
.add("skyx", "")
// 开课学院应该在这里指定,但是直接用学院id是获取不到的,只能用学院下级的id来获取,相关参数详见cn.linghang.mywust.core.api.ConstantParams
.add("kkyx", subCollegeId)
.add("kcmc", courseName)
.add("zzdKcSX", "")
.add("kcid", "")
.add("zc1", "")
.add("zc1", "")
.add("zc1", "")
.add("zc2", "")
.add("skxq1", "")
.add("skxq2", "")
.add("jc1", "")
.add("jc2", "");
return makeStringDataHttpRequest(UndergradUrls.BKJX_ALL_COURSE_SCHEDULE_API, formBodyBuilder.buildAndToString(), cookies);
}
}

@ -0,0 +1,45 @@
package cn.linghang.mywust.core.service.undergraduate.global;
import cn.linghang.mywust.core.exception.ApiException;
import cn.linghang.mywust.core.request.undergrade.global.BkjxAllCourseRequestFactory;
import cn.linghang.mywust.core.service.undergraduate.UndergradApiServiceBase;
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 UndergradAllCourseScheduleApiService extends UndergradApiServiceBase {
public UndergradAllCourseScheduleApiService(Requester requester) {
super(requester);
}
@Override
public String getPage(String cookie, Map<String, String> params, RequestClientOption option) throws ApiException, IOException {
String term = params.get("term");
String timeMode = params.get("timeMode");
String subCollegeId = params.get("subCollege");
String courseName = params.get("courseName");
return this.getPage(cookie, term, timeMode, subCollegeId, courseName, option);
}
@Override
public String getPage(String cookie, Map<String, String> params) throws ApiException, IOException {
return this.getPage(cookie, params, null);
}
public String getPage(String cookies, String term, String timeMode, String subCollegeId, String courseName, RequestClientOption option) throws ApiException, IOException {
HttpRequest request = BkjxAllCourseRequestFactory.allCourseSchedulePageRequest(cookies, term, timeMode, subCollegeId, courseName);
HttpResponse response = requester.post(request, option);
this.checkResponse(response);
return response.getStringBody();
}
public String getPage(String cookies, String term, String timeMode, String subCollegeId, String courseName) throws ApiException, IOException {
return this.getPage(cookies, term, timeMode, subCollegeId, courseName, null);
}
}

@ -0,0 +1,74 @@
package cn.linghang.mywust.core.service.undergraduate.global;
import cn.linghang.mywust.core.api.ConstantParams;
import cn.linghang.mywust.core.api.UndergradUrls;
import cn.linghang.mywust.core.exception.ApiException;
import cn.linghang.mywust.core.request.undergrade.BkjxRequestFactory;
import cn.linghang.mywust.core.service.undergraduate.UndergradApiServiceBase;
import cn.linghang.mywust.model.global.Building;
import cn.linghang.mywust.model.global.Campus;
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.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class UndergradBuildingIdApiService extends UndergradApiServiceBase {
private static final ObjectMapper objectMapper = new ObjectMapper();
public UndergradBuildingIdApiService(Requester requester) {
super(requester);
}
@Override
public String getPage(String cookie, Map<String, String> params, RequestClientOption option) throws ApiException, IOException {
List<Building> buildings = this.getBuildings(cookie, params.get("campus"), option);
return objectMapper.writeValueAsString(buildings);
}
@Override
public String getPage(String cookie, Map<String, String> params) throws ApiException, IOException {
List<Building> buildings = this.getBuildings(cookie, params.get("campus"));
return objectMapper.writeValueAsString(buildings);
}
public List<Building> getBuildings(String cookie, String campusId, RequestClientOption option) throws ApiException, IOException {
HttpRequest request = BkjxRequestFactory.buildingListRequest(campusId, cookie);
HttpResponse response = requester.post(request, option);
this.checkResponse(response);
JsonNode rootNode = objectMapper.readTree(response.getStringBody());
List<Building> buildings = new ArrayList<>(rootNode.size());
for (JsonNode buildingObject : rootNode) {
Building building = new Building(
buildingObject.get("dm").asText(), buildingObject.get("dmmc").asText(),
new Campus(campusId, ConstantParams.CAMPUS.get(campusId)));
buildings.add(building);
}
return buildings;
}
public List<Building> getBuildings(String cookie, String campusId) throws ApiException, IOException {
return this.getBuildings(cookie, campusId, null);
}
public String getBuildingsJson(String cookie, String campusId, RequestClientOption option) throws ApiException, IOException {
List<Building> buildings = this.getBuildings(cookie, campusId, option);
return objectMapper.writeValueAsString(buildings);
}
public String getBuildingsJson(String cookie, String campusId) throws ApiException, IOException {
return this.getBuildingsJson(cookie, campusId, null);
}
}

@ -0,0 +1,46 @@
package cn.linghang.mywust.core.service.undergraduate.global;
import cn.linghang.mywust.core.exception.ApiException;
import cn.linghang.mywust.core.request.undergrade.global.BkjxAllCourseRequestFactory;
import cn.linghang.mywust.core.service.undergraduate.UndergradApiServiceBase;
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 UndergradClassroomCourseApiService extends UndergradApiServiceBase {
public UndergradClassroomCourseApiService(Requester requester) {
super(requester);
}
@Override
public String getPage(String cookie, Map<String, String> params, RequestClientOption option) throws ApiException, IOException {
String term = params.get("term");
String collegeId = params.get("college");
String campusId = params.get("campus");
String buildingId = params.get("building");
String classroomName = params.get("classroomName");
return this.getPage(cookie, term, collegeId, campusId, buildingId, classroomName, option);
}
@Override
public String getPage(String cookie, Map<String, String> params) throws ApiException, IOException {
return this.getPage(cookie, params, null);
}
public String getPage(String cookies, String term, String collegeId, String campusId, String buildingId, String classroomName, RequestClientOption option) throws ApiException, IOException {
HttpRequest request = BkjxAllCourseRequestFactory.classroomCoursePageRequest(cookies, term, null, collegeId, campusId, buildingId, classroomName);
HttpResponse response = requester.post(request, option);
this.checkResponse(response);
return response.getStringBody();
}
public String getPage(String cookies, String term, String collegeId, String campusId, String buildingId, String classroomName) throws ApiException, IOException {
return this.getPage(cookies, term, collegeId, campusId, buildingId, classroomName, null);
}
}

@ -0,0 +1,45 @@
package cn.linghang.mywust.core.service.undergraduate.global;
import cn.linghang.mywust.core.exception.ApiException;
import cn.linghang.mywust.core.request.undergrade.global.BkjxAllCourseRequestFactory;
import cn.linghang.mywust.core.service.undergraduate.UndergradApiServiceBase;
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 UndergradTeacherCourseApiService extends UndergradApiServiceBase {
public UndergradTeacherCourseApiService(Requester requester) {
super(requester);
}
@Override
public String getPage(String cookie, Map<String, String> params, RequestClientOption option) throws ApiException, IOException {
String term = params.get("term");
String timeMode = params.get("timeMode");
String collegeId = params.get("collegeId");
String teacherName = params.get("teacherName");
return this.getPage(cookie, term, timeMode, collegeId, teacherName, option);
}
@Override
public String getPage(String cookie, Map<String, String> params) throws ApiException, IOException {
return this.getPage(cookie, params, null);
}
public String getPage(String cookies, String term, String timeMode, String collegeId, String teacherName, RequestClientOption option) throws ApiException, IOException {
HttpRequest request = BkjxAllCourseRequestFactory.teacherCoursePageRequest(cookies, term, timeMode, collegeId, teacherName);
HttpResponse response = requester.post(request, option);
this.checkResponse(response);
return response.getStringBody();
}
public String getPage(String cookies, String term, String timeMode, String collegeId, String teacherName) throws ApiException, IOException {
return this.getPage(cookies, term, timeMode, collegeId, teacherName, null);
}
}

@ -13,6 +13,12 @@ public final class Building {
this.campus = campus; this.campus = campus;
} }
public Building(String id, String name) {
this.id = id;
this.name = name;
this.campus = new Campus("", "");
}
public String getId() { public String getId() {
return id; return id;
} }

@ -39,7 +39,7 @@ public class FormBodyBuilder {
} }
public FormBodyBuilder add(String key, String value) { public FormBodyBuilder add(String key, String value) {
this.queryParams.put(key, value); this.queryParams.put(key, value == null ? "" : value);
return this; return this;
} }
@ -52,5 +52,3 @@ public class FormBodyBuilder {
} }
} }

Loading…
Cancel
Save