Skip to content

Commit

Permalink
fix: 处理了一下成绩空指针
Browse files Browse the repository at this point in the history
  • Loading branch information
flben233 committed Sep 19, 2024
1 parent 31abc1d commit 0f23d2b
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.hc.client5.http.cookie.CookieStore;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.shirakawatyu.handixikebackend.api.ScoreApi;
import org.shirakawatyu.handixikebackend.exception.NotLoginException;
import org.shirakawatyu.handixikebackend.exception.OutOfCreditException;
import org.shirakawatyu.handixikebackend.pojo.GradePointAverage;
import org.shirakawatyu.handixikebackend.pojo.Score;
Expand Down Expand Up @@ -64,10 +66,11 @@ public LinkedHashMap<String, ArrayList<Score>> getScore(CookieStore cookieStore)
throw new OutOfCreditException();
}
resp = Requests.getForString(SCORE_URL + "?event=studentProfile:courseMark", "", cookieStore);
scores = Jsoup.parse(resp).getElementsByClass("UItable").select("tr").eachText();
if (scores.isEmpty()) {
return null;
Document document = Jsoup.parse(resp);
if (document.getElementById("blueBar") == null) {
throw new NotLoginException();
}
scores = document.getElementsByClass("UItable").select("tr").eachText();
return processScore(scores);
} catch (Exception e) {
if (scores != null) {
Expand All @@ -83,9 +86,6 @@ private LinkedHashMap<String, ArrayList<Score>> processScore(List<String> scoreS
ScoreUtils.requiredScoreFilter(scores, hashMap);
ScoreUtils.optionalScoreFilter(scores, hashMap);
ScoreUtils.cetScoreFilter(scores, hashMap);
if (hashMap.isEmpty()) {
return null;
}
if (!scores.isEmpty()) {
log.warn(scores.toString());
}
Expand Down

0 comments on commit 0f23d2b

Please sign in to comment.