main
lensfrex 1 year ago
parent c792263bed
commit 4777fc11eb
Signed by: lensfrex
GPG Key ID: 0F69A0A2FBEE98A0
  1. 2
      external-library/mywust
  2. 1
      sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/exception/GraduateRpcException.java
  3. 3
      sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/services/LoginService.java
  4. 2
      sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/Main.java
  5. 2
      sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/Main.java
  6. 2
      sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/CookieApi.java
  7. 14
      sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/CourseTableApi.java
  8. 45
      sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/CreditStatusApi.java
  9. 48
      sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/ExamActivitiesApi.java
  10. 52
      sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/ExamDelayApplicationApi.java
  11. 10
      sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/ScoreApi.java
  12. 45
      sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/StudentInfoApi.java
  13. 44
      sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/TrainingPlanApi.java
  14. 6
      sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/exception/PhysicsRpcException.java
  15. 39
      sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/services/LoginService.java
  16. 70
      sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/services/ParseService.java
  17. 115
      sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/services/RequestAgentService.java

@ -1 +1 @@
Subproject commit b7c61453c566c9879314e881648cdb34bf90aaa9
Subproject commit e186a0d9f014c27aecbfd0775302dcb99ce89619

@ -59,6 +59,7 @@ public class GraduateRpcException extends RpcException {
NEED_EVALUATE,
AUTH_PASSWORD_WRONG,
AUTH_CAPTCHA_WRONG,
AUTH_UNKNOWN_ERROR
}
}

@ -71,8 +71,9 @@ public class LoginService {
GraduateRpcException.ErrorCode errorCode = switch (e.getCode()) {
case NETWORK_EXCEPTION -> GraduateRpcException.ErrorCode.NETWORK_ERROR;
case GRADUATE_PASSWORD_WRONG -> GraduateRpcException.ErrorCode.AUTH_PASSWORD_WRONG;
case GRADUATE_CAPTCHA_WRONG -> GraduateRpcException.ErrorCode.AUTH_CAPTCHA_WRONG;
default -> {
log.error("本科生:登录代理请求异常,异常未处理");
log.error("研究生:登录代理请求异常,异常未处理");
log.error("异常:", e);
yield GraduateRpcException.ErrorCode.AUTH_UNKNOWN_ERROR;
}

@ -11,6 +11,6 @@ import lombok.extern.slf4j.Slf4j;
public class Main {
@PostConstruct
public void run() {
log.info("Undergrad service started.");
log.info("Library service started.");
}
}

@ -11,6 +11,6 @@ import lombok.extern.slf4j.Slf4j;
public class Main {
@PostConstruct
public void run() {
log.info("Undergrad service started.");
log.info("Physics service started.");
}
}

@ -19,7 +19,7 @@ public class CookieApi {
@Path("/")
public String login(@QueryParam("username") @NotNull String username,
@QueryParam("password") @NotNull String password) throws RpcException {
return loginService.login(username, password, false);
return loginService.login(username, password);
}
@GET

@ -1,6 +1,6 @@
package cn.wustlinghang.wusthelper.internal.physics.api.json;
import cn.wustlinghang.mywust.data.global.Course;
import cn.wustlinghang.mywust.data.physics.PhysicsCourse;
import cn.wustlinghang.wusthelper.internal.physics.services.ParseService;
import cn.wustlinghang.wusthelper.internal.physics.services.RequestAgentService;
import cn.wustlinghang.wusthelper.rpc.exception.RpcException;
@ -27,23 +27,21 @@ public class CourseTableApi {
@GET
@Path("/")
public List<Course> get(@QueryParam("cookie") @NotNull String cookie,
@QueryParam("term") String term)
public List<PhysicsCourse> get(@QueryParam("cookie") @NotNull String cookie)
throws RpcException {
return this.parse(this.agent(cookie, term));
return this.parse(this.agent(cookie));
}
@GET
@Path("/agent")
public String agent(@QueryParam("cookie") @NotNull String cookie,
@QueryParam("term") String term)
public String agent(@QueryParam("cookie") @NotNull String cookie)
throws RpcException {
return agentService.getCourseTable(cookie, term);
return agentService.getCourseTable(cookie);
}
@POST
@Path("/parse")
public List<Course> parse(String html) throws RpcException {
public List<PhysicsCourse> parse(String html) throws RpcException {
return parseService.parseCourseTable(html);
}
}

@ -1,45 +0,0 @@
package cn.wustlinghang.wusthelper.internal.physics.api.json;
import cn.wustlinghang.wusthelper.internal.physics.services.ParseService;
import cn.wustlinghang.wusthelper.internal.physics.services.RequestAgentService;
import cn.wustlinghang.wusthelper.rpc.exception.RpcException;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;
@Path("/credit_status")
@ApplicationScoped
public class CreditStatusApi {
private final RequestAgentService agentService;
private final ParseService parseService;
public CreditStatusApi(RequestAgentService agentService,
ParseService parseService) {
this.agentService = agentService;
this.parseService = parseService;
}
@GET
@Path("/")
public String get(@QueryParam("cookie") @NotNull String cookie)
throws RpcException {
String html = this.agent(cookie);
return this.parse(html);
}
@GET
@Path("/agent")
public String agent(@QueryParam("cookie") @NotNull String cookie)
throws RpcException {
return agentService.getCreditStatus(cookie);
}
@POST
@Path("/parse")
public String parse(String html) throws RpcException {
return parseService.parseCreditStatus(html);
}
}

@ -1,48 +0,0 @@
package cn.wustlinghang.wusthelper.internal.physics.api.json;
import cn.wustlinghang.mywust.core.request.service.undergraduate.UndergradExamDelayApiService;
import cn.wustlinghang.mywust.data.global.Score;
import cn.wustlinghang.wusthelper.internal.physics.services.RequestAgentService;
import cn.wustlinghang.wusthelper.rpc.exception.RpcException;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;
import java.util.List;
@Path("/exam_activities")
@ApplicationScoped
public class ExamActivitiesApi {
private final RequestAgentService agentService;
public ExamActivitiesApi(RequestAgentService agentService) {
this.agentService = agentService;
}
@GET
@Path("/")
public UndergradExamDelayApiService.ExamActivity[] get(
@QueryParam("cookie") @NotNull String cookie,
@QueryParam("term") @NotNull String term)
throws RpcException {
return this.agent(cookie, term);
}
@GET
@Path("/agent")
public UndergradExamDelayApiService.ExamActivity[] agent(
@QueryParam("cookie") @NotNull String cookie,
@QueryParam("term") @NotNull String term)
throws RpcException {
return agentService.getExamActivities(cookie, term);
}
@POST
@Path("/parse")
public List<Score> parse(String html) throws RpcException {
throw RpcException.ApiNotImplement();
}
}

@ -1,52 +0,0 @@
package cn.wustlinghang.wusthelper.internal.physics.api.json;
import cn.wustlinghang.mywust.data.undergrad.ExamDelayApplication;
import cn.wustlinghang.wusthelper.internal.physics.services.ParseService;
import cn.wustlinghang.wusthelper.internal.physics.services.RequestAgentService;
import cn.wustlinghang.wusthelper.rpc.exception.RpcException;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;
import java.util.List;
@Path("/exam_delay_application")
@ApplicationScoped
public class ExamDelayApplicationApi {
private final RequestAgentService agentService;
private final ParseService parseService;
public ExamDelayApplicationApi(RequestAgentService agentService,
ParseService parseService) {
this.agentService = agentService;
this.parseService = parseService;
}
@GET
@Path("/")
public List<ExamDelayApplication> get(
@QueryParam("cookie") @NotNull String cookie,
@QueryParam("term") @NotNull String term,
@QueryParam("activity_id") @NotNull String activityId)
throws RpcException {
return this.parse(this.agent(cookie, term, activityId));
}
@GET
@Path("/agent")
public String agent(@QueryParam("cookie") @NotNull String cookie,
@QueryParam("term") @NotNull String term,
@QueryParam("activity_id") @NotNull String activityId)
throws RpcException {
return agentService.getExamDelayApplications(cookie, term, activityId);
}
@POST
@Path("/parse")
public List<ExamDelayApplication> parse(String html) throws RpcException {
return parseService.parseExamDelayApplications(html);
}
}

@ -29,12 +29,12 @@ public class ScoreApi {
@Path("/")
public List<Score> get(@QueryParam("cookie") @NotNull String cookie)
throws RpcException {
return this.parse(this.agent(cookie));
return this.parseAll(this.agent(cookie));
}
@GET
@Path("/agent")
public String agent(@QueryParam("cookie") @NotNull String cookie)
public List<String> agent(@QueryParam("cookie") @NotNull String cookie)
throws RpcException {
return agentService.getScore(cookie);
}
@ -44,4 +44,10 @@ public class ScoreApi {
public List<Score> parse(String html) throws RpcException {
return parseService.parseScore(html);
}
@POST
@Path("/parse/all")
public List<Score> parseAll(List<String> pages) throws RpcException {
return parseService.parseAllScore(pages);
}
}

@ -1,45 +0,0 @@
package cn.wustlinghang.wusthelper.internal.physics.api.json;
import cn.wustlinghang.mywust.data.global.StudentInfo;
import cn.wustlinghang.wusthelper.internal.physics.services.ParseService;
import cn.wustlinghang.wusthelper.internal.physics.services.RequestAgentService;
import cn.wustlinghang.wusthelper.rpc.exception.RpcException;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;
@Path("/student_info")
@ApplicationScoped
public class StudentInfoApi {
private final RequestAgentService agentService;
private final ParseService parseService;
public StudentInfoApi(RequestAgentService agentService,
ParseService parseService) {
this.agentService = agentService;
this.parseService = parseService;
}
@GET
@Path("/")
public StudentInfo get(@QueryParam("cookie") @NotNull String cookie)
throws RpcException {
return this.parse(this.agent(cookie));
}
@GET
@Path("/agent")
public String agent(@QueryParam("cookie") @NotNull String cookie)
throws RpcException {
return agentService.getStudentInfoPage(cookie);
}
@POST
@Path("/parse")
public StudentInfo parse(String html) throws RpcException {
return parseService.parseStudentInfo(html);
}
}

@ -1,44 +0,0 @@
package cn.wustlinghang.wusthelper.internal.physics.api.json;
import cn.wustlinghang.wusthelper.internal.physics.services.ParseService;
import cn.wustlinghang.wusthelper.internal.physics.services.RequestAgentService;
import cn.wustlinghang.wusthelper.rpc.exception.RpcException;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.QueryParam;
@Path("/training_plan")
@ApplicationScoped
public class TrainingPlanApi {
private final RequestAgentService agentService;
private final ParseService parseService;
public TrainingPlanApi(RequestAgentService agentService,
ParseService parseService) {
this.agentService = agentService;
this.parseService = parseService;
}
@GET
@Path("/")
public String get(@QueryParam("cookie") @NotNull String cookie)
throws RpcException {
return this.parse(this.agent(cookie));
}
@GET
@Path("/agent")
public String agent(@QueryParam("cookie") @NotNull String cookie)
throws RpcException {
return agentService.getTrainingPlan(cookie);
}
@POST
@Path("/parse")
public String parse(String html) throws RpcException {
return parseService.parseTrainingPlan(html);
}
}

@ -14,7 +14,7 @@ public class PhysicsRpcException extends RpcException {
typeCode.ordinal(),
subModuleCode.ordinal() * 100 + errorCode.ordinal(),
new StringJoiner("-")
.add("UNDERGRAD")
.add("PHYSICS")
.add(typeCode.name())
.add(subModuleCode.name())
.add(errorCode.name())
@ -56,6 +56,8 @@ public class PhysicsRpcException extends RpcException {
PARSE_ERROR,
AUTH_PASSWORD_WRONG,
AUTH_UNKNOWN_ERROR
AUTH_UNKNOWN_ERROR,
AUTH_USER_NOT_CURRENT_TERM
}
}

@ -1,7 +1,8 @@
package cn.wustlinghang.wusthelper.internal.physics.services;
import cn.wustlinghang.mywust.core.request.service.auth.UndergraduateLogin;
import cn.wustlinghang.mywust.core.request.service.auth.PhysicsLogin;
import cn.wustlinghang.mywust.exception.ApiException;
import cn.wustlinghang.mywust.exception.ParseException;
import cn.wustlinghang.mywust.network.RequestClientOption;
import cn.wustlinghang.wusthelper.internal.physics.exception.PhysicsRpcException;
import jakarta.enterprise.context.ApplicationScoped;
@ -13,21 +14,18 @@ import java.io.IOException;
@ApplicationScoped
public class LoginService {
private final RequestClientOption option;
private final UndergraduateLogin undergraduateLogin;
private final PhysicsLogin physicsLogin;
public LoginService(RequestClientOption option,
UndergraduateLogin undergraduateLogin) {
PhysicsLogin physicsLogin) {
this.option = option;
this.undergraduateLogin = undergraduateLogin;
this.physicsLogin = physicsLogin;
}
public String login(String username, String password, boolean legacy) throws PhysicsRpcException {
public String login(String username, String password) throws PhysicsRpcException {
try {
if (legacy) {
return undergraduateLogin.getLoginCookieLegacy(username, password, option);
} else {
return undergraduateLogin.getLoginCookie(username, password, option);
}
return physicsLogin.getLoginCookie(username, password, option);
} catch (ApiException e) {
throw wrapApiException(e);
} catch (IOException e) {
@ -36,12 +34,19 @@ public class LoginService {
PhysicsRpcException.SubModuleCode.AUTH,
PhysicsRpcException.ErrorCode.NETWORK_ERROR
);
} catch (ParseException e) {
log.error("物理实验:登录时出现页面参数解析问题", e);
throw new PhysicsRpcException(
PhysicsRpcException.TypeCode.NETWORK_EXCEPTION,
PhysicsRpcException.SubModuleCode.AUTH,
PhysicsRpcException.ErrorCode.AUTH_UNKNOWN_ERROR
);
}
}
public boolean verify(String cookie) throws PhysicsRpcException {
try {
return !undergraduateLogin.checkCookiesFail(cookie);
return physicsLogin.checkCookie(cookie, option);
} catch (IOException e) {
throw new PhysicsRpcException(
PhysicsRpcException.TypeCode.NETWORK_EXCEPTION,
@ -54,16 +59,10 @@ public class LoginService {
private PhysicsRpcException wrapApiException(ApiException e) {
PhysicsRpcException.ErrorCode errorCode = switch (e.getCode()) {
case NETWORK_EXCEPTION -> PhysicsRpcException.ErrorCode.NETWORK_ERROR;
case UNI_LOGIN_PASSWORD_WRONG -> PhysicsRpcException.ErrorCode.AUTH_PASSWORD_WRONG;
case UNI_LOGIN_USER_NOT_EXISTS -> PhysicsRpcException.ErrorCode.AUTH_USER_NOT_EXISTS;
case UNI_LOGIN_USER_BANNED -> PhysicsRpcException.ErrorCode.AUTH_USER_BANNED;
case UNI_LOGIN_USER_DISABLED -> PhysicsRpcException.ErrorCode.AUTH_USER_DISABLED;
case UNI_LOGIN_NEED_CHANGE_PASSWORD -> PhysicsRpcException.ErrorCode.AUTH_NEED_CHANGE_PASSWORD;
case UNI_LOGIN_USER_NOT_ONLY -> PhysicsRpcException.ErrorCode.AUTH_UNKNOWN_ERROR;
case UNI_LOGIN_NO_REGISTER -> PhysicsRpcException.ErrorCode.AUTH_UNKNOWN_ERROR;
case UNI_LOGIN_NEED_TFA -> PhysicsRpcException.ErrorCode.AUTH_UNKNOWN_ERROR;
case PHYSICS_PASSWORD_WRONG -> PhysicsRpcException.ErrorCode.AUTH_PASSWORD_WRONG;
case PHYSICS_NOT_CURRENT_TERM -> PhysicsRpcException.ErrorCode.AUTH_USER_NOT_CURRENT_TERM;
default -> {
log.error("本科生:登录代理请求异常,异常未处理");
log.error("物理实验:登录代理请求异常,异常未处理");
log.error("异常:", e);
yield PhysicsRpcException.ErrorCode.AUTH_UNKNOWN_ERROR;
}

@ -1,20 +1,26 @@
package cn.wustlinghang.wusthelper.internal.physics.services;
import cn.wustlinghang.mywust.core.parser.physics.PhysicsCoursePageParser;
import cn.wustlinghang.mywust.data.global.Course;
import cn.wustlinghang.mywust.core.parser.physics.PhysicsScorePageParser;
import cn.wustlinghang.mywust.data.global.Score;
import cn.wustlinghang.mywust.data.global.StudentInfo;
import cn.wustlinghang.mywust.data.physics.PhysicsCourse;
import cn.wustlinghang.mywust.data.undergrad.ExamDelayApplication;
import cn.wustlinghang.wusthelper.internal.physics.exception.PhysicsRpcException;
import cn.wustlinghang.wusthelper.rpc.exception.RpcException;
import jakarta.enterprise.context.ApplicationScoped;
import java.util.ArrayList;
import java.util.List;
@ApplicationScoped
public class ParseService {
private final PhysicsCoursePageParser coursePageParser;
private final PhysicsScorePageParser scorePageParser;
public ParseService(PhysicsCoursePageParser coursePageParser,
PhysicsScorePageParser scorePageParser) {
this.coursePageParser = coursePageParser;
this.scorePageParser = scorePageParser;
}
public List<PhysicsCourse> parseCourseTable(String data) throws PhysicsRpcException {
try {
@ -30,16 +36,7 @@ public class ParseService {
public List<Score> parseScore(String data) throws RpcException {
try {
if (data.contains("评教")) {
throw new PhysicsRpcException(
PhysicsRpcException.TypeCode.PARSE_EXCEPTION,
PhysicsRpcException.SubModuleCode.SCORE,
PhysicsRpcException.ErrorCode.NEED_EVALUATE
);
}
return scoreParser.parse(data);
return scorePageParser.parse(data);
} catch (PhysicsRpcException e) {
throw e;
} catch (Exception e) {
@ -51,49 +48,20 @@ public class ParseService {
}
}
public StudentInfo parseStudentInfo(String data) throws RpcException {
try {
return studentInfoPageParser.parse(data);
} catch (Exception e) {
throw new PhysicsRpcException(
PhysicsRpcException.TypeCode.PARSE_EXCEPTION,
PhysicsRpcException.SubModuleCode.STUDENT_INFO,
PhysicsRpcException.ErrorCode.PARSE_ERROR
);
}
}
public String parseTrainingPlan(String data) throws RpcException {
public List<Score> parseAllScore(List<String> pages) throws RpcException {
try {
return trainingPlanPageParser.parse(data);
} catch (Exception e) {
throw new PhysicsRpcException(
PhysicsRpcException.TypeCode.PARSE_EXCEPTION,
PhysicsRpcException.SubModuleCode.TRAINING_PLAN,
PhysicsRpcException.ErrorCode.PARSE_ERROR
);
}
}
public String parseCreditStatus(String data) throws RpcException {
try {
return creditStatusParser.parse(data);
} catch (Exception e) {
throw new PhysicsRpcException(
PhysicsRpcException.TypeCode.PARSE_EXCEPTION,
PhysicsRpcException.SubModuleCode.CREDIT_STATUS,
PhysicsRpcException.ErrorCode.PARSE_ERROR
);
}
}
List<Score> scores = new ArrayList<>();
for (String page : pages) {
scores.addAll(scorePageParser.parse(page));
}
public List<ExamDelayApplication> parseExamDelayApplications(String data) throws RpcException {
try {
return examDelayParser.parse(data);
return scores;
} catch (PhysicsRpcException e) {
throw e;
} catch (Exception e) {
throw new PhysicsRpcException(
PhysicsRpcException.TypeCode.PARSE_EXCEPTION,
PhysicsRpcException.SubModuleCode.EXAM_DELAY_APPLICATION,
PhysicsRpcException.SubModuleCode.SCORE,
PhysicsRpcException.ErrorCode.PARSE_ERROR
);
}

@ -1,7 +1,9 @@
package cn.wustlinghang.wusthelper.internal.physics.services;
import cn.wustlinghang.mywust.core.request.service.undergraduate.*;
import cn.wustlinghang.mywust.core.request.service.physics.PhysicsCourseApiService;
import cn.wustlinghang.mywust.core.request.service.physics.PhysicsScoreApiService;
import cn.wustlinghang.mywust.exception.ApiException;
import cn.wustlinghang.mywust.exception.ParseException;
import cn.wustlinghang.mywust.network.RequestClientOption;
import cn.wustlinghang.wusthelper.internal.physics.exception.PhysicsRpcException;
import cn.wustlinghang.wusthelper.rpc.exception.RpcException;
@ -9,54 +11,29 @@ import jakarta.enterprise.context.ApplicationScoped;
import lombok.extern.slf4j.Slf4j;
import java.io.IOException;
import java.util.List;
@Slf4j
@ApplicationScoped
public class RequestAgentService {
private final UndergradCourseTableApiService courseTableApiService;
private final UndergradScoreApiService scoreApiService;
private final UndergradStudentInfoApiService studentInfoApiService;
private final UndergradTrainingPlanApiService trainingPlanApiService;
private final UndergradCreditStatusApiService creditStatusApiService;
private final UndergradExamDelayApiService examDelayApiService;
private final RequestClientOption requestClientOption;
public RequestAgentService(UndergradCourseTableApiService courseTableApiService,
UndergradScoreApiService scoreApiService,
UndergradStudentInfoApiService studentInfoApiService,
UndergradTrainingPlanApiService trainingPlanApiService,
UndergradCreditStatusApiService creditStatusApiService,
UndergradExamDelayApiService examDelayApiService,
RequestClientOption requestClientOption) {
this.courseTableApiService = courseTableApiService;
this.scoreApiService = scoreApiService;
this.studentInfoApiService = studentInfoApiService;
this.trainingPlanApiService = trainingPlanApiService;
this.creditStatusApiService = creditStatusApiService;
this.examDelayApiService = examDelayApiService;
private final PhysicsCourseApiService physicsCourseApiService;
private final PhysicsScoreApiService physicsScoreApiService;
public RequestAgentService(RequestClientOption requestClientOption,
PhysicsCourseApiService physicsCourseApiService,
PhysicsScoreApiService physicsScoreApiService) {
this.requestClientOption = requestClientOption;
}
public String getStudentInfoPage(String cookie) throws RpcException {
try {
return studentInfoApiService.getPage(cookie);
} catch (ApiException e) {
throw wrapApiException(e, PhysicsRpcException.SubModuleCode.STUDENT_INFO);
} catch (IOException e) {
throw new PhysicsRpcException(
PhysicsRpcException.TypeCode.NETWORK_EXCEPTION,
PhysicsRpcException.SubModuleCode.STUDENT_INFO,
PhysicsRpcException.ErrorCode.NETWORK_ERROR
);
}
this.physicsCourseApiService = physicsCourseApiService;
this.physicsScoreApiService = physicsScoreApiService;
}
public String getCourseTable(String cookie, String term) throws RpcException {
public String getCourseTable(String cookie) throws RpcException {
try {
return courseTableApiService.getPage(term, cookie);
return physicsCourseApiService.getPage(cookie, requestClientOption);
} catch (ApiException e) {
throw wrapApiException(e, PhysicsRpcException.SubModuleCode.COURSE_TABLE);
} catch (IOException e) {
@ -68,9 +45,9 @@ public class RequestAgentService {
}
}
public String getScore(String cookie) throws RpcException {
public List<String> getScore(String cookie) throws RpcException {
try {
return scoreApiService.getPage(cookie);
return physicsScoreApiService.getAllPages(cookie, requestClientOption);
} catch (ApiException e) {
throw wrapApiException(e, PhysicsRpcException.SubModuleCode.SCORE);
} catch (IOException e) {
@ -79,63 +56,11 @@ public class RequestAgentService {
PhysicsRpcException.SubModuleCode.SCORE,
PhysicsRpcException.ErrorCode.NETWORK_ERROR
);
}
}
public String getTrainingPlan(String cookie) throws RpcException {
try {
return trainingPlanApiService.getPage(cookie);
} catch (ApiException e) {
throw wrapApiException(e, PhysicsRpcException.SubModuleCode.TRAINING_PLAN);
} catch (IOException e) {
} catch (ParseException e) {
throw new PhysicsRpcException(
PhysicsRpcException.TypeCode.NETWORK_EXCEPTION,
PhysicsRpcException.SubModuleCode.TRAINING_PLAN,
PhysicsRpcException.ErrorCode.NETWORK_ERROR
);
}
}
public String getCreditStatus(String cookie) throws RpcException {
try {
return creditStatusApiService.getPage(cookie, requestClientOption, false);
} catch (ApiException e) {
throw wrapApiException(e, PhysicsRpcException.SubModuleCode.CREDIT_STATUS);
} catch (IOException e) {
throw new PhysicsRpcException(
PhysicsRpcException.TypeCode.NETWORK_EXCEPTION,
PhysicsRpcException.SubModuleCode.CREDIT_STATUS,
PhysicsRpcException.ErrorCode.NETWORK_ERROR
);
}
}
public UndergradExamDelayApiService.ExamActivity[] getExamActivities(String cookie, String term)
throws RpcException {
try {
return examDelayApiService.getActivities(term, cookie);
} catch (ApiException e) {
throw wrapApiException(e, PhysicsRpcException.SubModuleCode.EXAM_ACTIVITIES);
} catch (IOException e) {
throw new PhysicsRpcException(
PhysicsRpcException.TypeCode.NETWORK_EXCEPTION,
PhysicsRpcException.SubModuleCode.EXAM_ACTIVITIES,
PhysicsRpcException.ErrorCode.NETWORK_ERROR
);
}
}
public String getExamDelayApplications(String cookie, String term, String activityId)
throws RpcException {
try {
return examDelayApiService.getPage(term, activityId, cookie);
} catch (ApiException e) {
throw wrapApiException(e, PhysicsRpcException.SubModuleCode.EXAM_DELAY_APPLICATION);
} catch (IOException e) {
throw new PhysicsRpcException(
PhysicsRpcException.TypeCode.NETWORK_EXCEPTION,
PhysicsRpcException.SubModuleCode.EXAM_DELAY_APPLICATION,
PhysicsRpcException.ErrorCode.NETWORK_ERROR
PhysicsRpcException.TypeCode.OTHER_EXCEPTION,
PhysicsRpcException.SubModuleCode.SCORE,
PhysicsRpcException.ErrorCode.PARSE_ERROR
);
}
}
@ -153,7 +78,7 @@ public class RequestAgentService {
PhysicsRpcException.ErrorCode.COOKIE_INVALID
);
default -> {
log.error("本科生:{}代理请求异常,异常未处理", subModuleCode.name());
log.error("物理实验:{}代理请求异常,异常未处理", subModuleCode.name());
log.error("异常:", e);
yield new PhysicsRpcException(
PhysicsRpcException.TypeCode.AUTH_EXCEPTION,

Loading…
Cancel
Save