diff --git a/mywust-common/src/main/java/cn/wustlinghang/mywust/exception/ApiException.java b/mywust-common/src/main/java/cn/wustlinghang/mywust/exception/ApiException.java index fe126be..5c93f0f 100644 --- a/mywust-common/src/main/java/cn/wustlinghang/mywust/exception/ApiException.java +++ b/mywust-common/src/main/java/cn/wustlinghang/mywust/exception/ApiException.java @@ -104,6 +104,11 @@ public class ApiException extends BasicException { */ UNDERGRAD_BANNED_IN_EXCLUSIVE_TIME(100108, "本科生登录:专属选课时间段账号被禁用"), + /** + * 用户名信息不存在(新生信息未录入或者老生删档) + */ + UNDERGRAD_USERINFO_NOT_EXISTS(100109, "本科生登录:用户名信息(新生信息未录入或者老生删档)"), + // -------------------------------- // 共有异常码:cookie无效 diff --git a/mywust-core/src/main/java/cn/wustlinghang/mywust/core/request/service/auth/UndergraduateLogin.java b/mywust-core/src/main/java/cn/wustlinghang/mywust/core/request/service/auth/UndergraduateLogin.java index 547dbe5..f85fccc 100644 --- a/mywust-core/src/main/java/cn/wustlinghang/mywust/core/request/service/auth/UndergraduateLogin.java +++ b/mywust-core/src/main/java/cn/wustlinghang/mywust/core/request/service/auth/UndergraduateLogin.java @@ -115,6 +115,9 @@ public class UndergraduateLogin { } else if (test.contains("禁用")) { // 选课时间段 throw new ApiException(ApiException.Code.UNDERGRAD_BANNED_IN_EXCLUSIVE_TIME); + } else if (test.contains("不存在")) { + // 新生信息未录入/老生被删号 + throw new ApiException(ApiException.Code.UNDERGRAD_USERINFO_NOT_EXISTS); } return true; diff --git a/mywust-core/src/main/java/cn/wustlinghang/mywust/core/request/service/undergraduate/UndergradApiServiceBase.java b/mywust-core/src/main/java/cn/wustlinghang/mywust/core/request/service/undergraduate/UndergradApiServiceBase.java index bbed51e..87c749e 100644 --- a/mywust-core/src/main/java/cn/wustlinghang/mywust/core/request/service/undergraduate/UndergradApiServiceBase.java +++ b/mywust-core/src/main/java/cn/wustlinghang/mywust/core/request/service/undergraduate/UndergradApiServiceBase.java @@ -1,13 +1,13 @@ package cn.wustlinghang.mywust.core.request.service.undergraduate; import cn.wustlinghang.mywust.core.api.UndergradUrls; -import cn.wustlinghang.mywust.network.request.RequestFactory; import cn.wustlinghang.mywust.core.util.BkjxUtil; import cn.wustlinghang.mywust.exception.ApiException; import cn.wustlinghang.mywust.network.RequestClientOption; import cn.wustlinghang.mywust.network.Requester; import cn.wustlinghang.mywust.network.entitys.HttpRequest; import cn.wustlinghang.mywust.network.entitys.HttpResponse; +import cn.wustlinghang.mywust.network.request.RequestFactory; import java.io.IOException; import java.util.Map; @@ -21,12 +21,13 @@ public abstract class UndergradApiServiceBase { public void checkResponse(HttpResponse response) throws ApiException { // 检查响应是否正确 - if (response.getBody() == null || + boolean cookieInvalid = response.getBody() == null || response.getStatusCode() != HttpResponse.HTTP_OK || - BkjxUtil.needLogin(response.getBody()) || - BkjxUtil.isBannedResponse(response)) { - + BkjxUtil.needLogin(response.getBody()); + if (cookieInvalid) { throw new ApiException(ApiException.Code.COOKIE_INVALID); + } else if (BkjxUtil.isBannedResponse(response)) { + throw new ApiException(ApiException.Code.UNDERGRAD_BANNED_IN_EXCLUSIVE_TIME); } }