From 26aaad57cc02472d9cdbd665a537db7325833439 Mon Sep 17 00:00:00 2001 From: lensferno Date: Tue, 11 Jul 2023 09:59:58 +0800 Subject: [PATCH] backup --- backend-main/web/pom.xml | 14 ++ .../wusthelper/rpc/util/EnumUtil.java | 7 + sub-services/graduate/.flattened-pom.xml | 93 +++++++++++ .../api/{json => http}/CookieApi.java | 2 +- .../api/{json => http}/CourseTableApi.java | 2 +- .../graduate/api/{json => http}/ScoreApi.java | 2 +- .../api/{json => http}/StudentInfoApi.java | 2 +- .../api/{json => http}/TrainingPlanApi.java | 2 +- .../handler/BaseExceptionHandler.java | 2 +- .../handler/DefaultExceptionHandler.java | 2 +- .../handler/IOExceptionHandler.java | 2 +- .../handler/ParseExceptionHandler.java | 2 +- .../handler/RpcExceptionHandler.java | 2 +- .../handler/ValidationExceptionHandler.java | 2 +- .../WebApplicationExceptionHandler.java | 2 +- .../ResponseWrapperInterceptor.java | 4 +- .../exception/GraduateRpcException.java | 2 +- .../graduate/services/LoginService.java | 2 +- sub-services/library/.flattened-pom.xml | 93 +++++++++++ .../BookCoverImageApi.java} | 29 ++-- .../ScoreApi.java => http/BookDetailApi.java} | 21 +-- .../library/api/{json => http}/CookieApi.java | 4 +- .../CurrentLoanApi.java} | 25 ++- .../LoanHistoryApi.java} | 26 +-- .../library/api/http/OverdueSoonApi.java | 48 ++++++ .../internal/library/api/http/SearchApi.java | 50 ++++++ .../handler/BaseExceptionHandler.java | 2 +- .../handler/DefaultExceptionHandler.java | 2 +- .../api/http}/handler/IOExceptionHandler.java | 2 +- .../http}/handler/ParseExceptionHandler.java | 2 +- .../handler/RpcExceptionHandler.java | 2 +- .../handler/ValidationExceptionHandler.java | 2 +- .../WebApplicationExceptionHandler.java | 12 +- .../ResponseWrapperInterceptor.java | 4 +- .../library/api/json/ExamActivitiesApi.java | 48 ------ .../api/json/ExamDelayApplicationApi.java | 52 ------ .../library/bean/MywustParserBeans.java | 36 ----- .../library/bean/MywustRequestAgentBeans.java | 35 +--- ...xception.java => LibraryRpcException.java} | 22 ++- .../library/services/LoginService.java | 70 ++++---- .../library/services/ParseService.java | 131 --------------- .../library/services/RequestAgentService.java | 151 +++++++----------- sub-services/physics/.flattened-pom.xml | 93 +++++++++++ .../physics/api/{json => http}/CookieApi.java | 2 +- .../api/{json => http}/CourseTableApi.java | 2 +- .../physics/api/{json => http}/ScoreApi.java | 2 +- .../handler/BaseExceptionHandler.java | 2 +- .../handler/DefaultExceptionHandler.java | 2 +- .../api/http}/handler/IOExceptionHandler.java | 2 +- .../http}/handler/ParseExceptionHandler.java | 2 +- .../handler/RpcExceptionHandler.java | 2 +- .../handler/ValidationExceptionHandler.java | 2 +- .../WebApplicationExceptionHandler.java | 2 +- .../ResponseWrapperInterceptor.java | 4 +- .../exception/PhysicsRpcException.java | 2 +- .../physics/services/LoginService.java | 4 +- sub-services/undergrad/.flattened-pom.xml | 93 +++++++++++ .../api/{json => http}/CookieApi.java | 4 +- .../api/{json => http}/CourseTableApi.java | 5 +- .../api/{json => http}/CreditStatusApi.java | 6 +- .../api/{json => http}/ExamActivitiesApi.java | 2 +- .../ExamDelayApplicationApi.java | 2 +- .../api/{json => http}/ScoreApi.java | 5 +- .../undergrad/api/http}/StudentInfoApi.java | 6 +- .../api/{json => http}/TrainingPlanApi.java | 6 +- .../handler/BaseExceptionHandler.java | 2 +- .../handler/DefaultExceptionHandler.java | 2 +- .../handler/IOExceptionHandler.java | 2 +- .../handler/ParseExceptionHandler.java | 2 +- .../handler/RpcExceptionHandler.java | 2 +- .../handler/ValidationExceptionHandler.java | 2 +- .../WebApplicationExceptionHandler.java | 2 +- .../ResponseWrapperInterceptor.java | 4 +- .../undergrad/api/json/StudentInfoApi.java | 50 ------ .../exception/UndergradRpcException.java | 2 +- .../undergrad/services/LoginService.java | 2 +- 76 files changed, 718 insertions(+), 621 deletions(-) create mode 100644 common/src/main/java/cn/wustlinghang/wusthelper/rpc/util/EnumUtil.java create mode 100644 sub-services/graduate/.flattened-pom.xml rename sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/{json => http}/CookieApi.java (93%) rename sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/{json => http}/CourseTableApi.java (95%) rename sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/{json => http}/ScoreApi.java (95%) rename sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/{json => http}/StudentInfoApi.java (95%) rename sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/{json => http}/TrainingPlanApi.java (95%) rename sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/{json => http}/handler/BaseExceptionHandler.java (96%) rename sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/{json => http}/handler/DefaultExceptionHandler.java (90%) rename sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/{json => http}/handler/IOExceptionHandler.java (90%) rename sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/{json => http}/handler/ParseExceptionHandler.java (91%) rename sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/{json => http}/handler/RpcExceptionHandler.java (88%) rename sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/{json => http}/handler/ValidationExceptionHandler.java (91%) rename sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/{json => http}/handler/WebApplicationExceptionHandler.java (94%) rename sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/{json => http}/interceptor/ResponseWrapperInterceptor.java (91%) create mode 100644 sub-services/library/.flattened-pom.xml rename sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/{json/CreditStatusApi.java => http/BookCoverImageApi.java} (54%) rename sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/{json/ScoreApi.java => http/BookDetailApi.java} (64%) rename sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/{json => http}/CookieApi.java (87%) rename sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/{json/CourseTableApi.java => http/CurrentLoanApi.java} (55%) rename sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/{json/TrainingPlanApi.java => http/LoanHistoryApi.java} (54%) create mode 100644 sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/OverdueSoonApi.java create mode 100644 sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/SearchApi.java rename sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/{json => http}/handler/BaseExceptionHandler.java (96%) rename sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/{json => http}/handler/DefaultExceptionHandler.java (90%) rename sub-services/{physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json => library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http}/handler/IOExceptionHandler.java (90%) rename sub-services/{physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json => library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http}/handler/ParseExceptionHandler.java (91%) rename sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/{json => http}/handler/RpcExceptionHandler.java (88%) rename sub-services/{physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json => library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http}/handler/ValidationExceptionHandler.java (91%) rename sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/{json => http}/handler/WebApplicationExceptionHandler.java (59%) rename sub-services/{physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json => library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http}/interceptor/ResponseWrapperInterceptor.java (91%) delete mode 100644 sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/ExamActivitiesApi.java delete mode 100644 sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/ExamDelayApplicationApi.java delete mode 100644 sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/bean/MywustParserBeans.java rename sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/exception/{UndergradRpcException.java => LibraryRpcException.java} (70%) delete mode 100644 sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/services/ParseService.java create mode 100644 sub-services/physics/.flattened-pom.xml rename sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/{json => http}/CookieApi.java (93%) rename sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/{json => http}/CourseTableApi.java (95%) rename sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/{json => http}/ScoreApi.java (96%) rename sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/{json => http}/handler/BaseExceptionHandler.java (96%) rename sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/{json => http}/handler/DefaultExceptionHandler.java (90%) rename sub-services/{library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json => physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http}/handler/IOExceptionHandler.java (90%) rename sub-services/{library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json => physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http}/handler/ParseExceptionHandler.java (91%) rename sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/{json => http}/handler/RpcExceptionHandler.java (88%) rename sub-services/{library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json => physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http}/handler/ValidationExceptionHandler.java (91%) rename sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/{json => http}/handler/WebApplicationExceptionHandler.java (94%) rename sub-services/{library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json => physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http}/interceptor/ResponseWrapperInterceptor.java (91%) create mode 100644 sub-services/undergrad/.flattened-pom.xml rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/CookieApi.java (90%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/CourseTableApi.java (88%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/CreditStatusApi.java (87%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/ExamActivitiesApi.java (95%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/ExamDelayApplicationApi.java (96%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/ScoreApi.java (87%) rename sub-services/{library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json => undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http}/StudentInfoApi.java (84%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/TrainingPlanApi.java (86%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/handler/BaseExceptionHandler.java (96%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/handler/DefaultExceptionHandler.java (90%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/handler/IOExceptionHandler.java (90%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/handler/ParseExceptionHandler.java (91%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/handler/RpcExceptionHandler.java (88%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/handler/ValidationExceptionHandler.java (91%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/handler/WebApplicationExceptionHandler.java (94%) rename sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/{json => http}/interceptor/ResponseWrapperInterceptor.java (91%) delete mode 100644 sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/StudentInfoApi.java diff --git a/backend-main/web/pom.xml b/backend-main/web/pom.xml index dc67f63..4ba8d4d 100644 --- a/backend-main/web/pom.xml +++ b/backend-main/web/pom.xml @@ -15,6 +15,20 @@ 17 17 UTF-8 + + 3.1.1 + + + + + org.springframework.boot + spring-boot-dependencies + ${springboot.version} + pom + import + + + \ No newline at end of file diff --git a/common/src/main/java/cn/wustlinghang/wusthelper/rpc/util/EnumUtil.java b/common/src/main/java/cn/wustlinghang/wusthelper/rpc/util/EnumUtil.java new file mode 100644 index 0000000..344700d --- /dev/null +++ b/common/src/main/java/cn/wustlinghang/wusthelper/rpc/util/EnumUtil.java @@ -0,0 +1,7 @@ +package cn.wustlinghang.wusthelper.rpc.util; + +public class EnumUtil { + public static > boolean equal(int value, Enum e) { + return e.ordinal() == value; + } +} diff --git a/sub-services/graduate/.flattened-pom.xml b/sub-services/graduate/.flattened-pom.xml new file mode 100644 index 0000000..afa31a6 --- /dev/null +++ b/sub-services/graduate/.flattened-pom.xml @@ -0,0 +1,93 @@ + + + 4.0.0 + cn.wustlinghang.wusthelper + graduate + 0.0.1-SNAPSHOT + + + io.quarkus + quarkus-resteasy-reactive-jackson + 3.1.3.Final + compile + + + io.quarkus + quarkus-hibernate-validator + 3.1.3.Final + compile + + + io.quarkus + quarkus-resteasy-reactive + 3.1.3.Final + compile + + + io.quarkus + quarkus-arc + 3.1.3.Final + compile + + + cn.wustlinghang.mywust + mywust-core + 0.0.2-SNAPSHOT + compile + + + cn.wustlinghang.mywust + mywust-network-okhttp + 0.0.2-SNAPSHOT + compile + + + cn.wustlinghang.wusthelper + common + 0.0.1-SNAPSHOT + compile + + + jakarta.annotation + jakarta.annotation-api + 2.1.1 + compile + + + javax.annotation + javax.annotation-api + 1.3.2 + compile + + + org.projectlombok + lombok + 1.18.26 + provided + + + + + central + https://repo1.maven.org/maven2 + + + + true + + github + https://maven.pkg.github.com/LingHangStudio/mywust + + + + + + io.quarkus.platform + quarkus-maven-plugin + 3.1.3.Final + true + + + + diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/CookieApi.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/CookieApi.java similarity index 93% rename from sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/CookieApi.java rename to sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/CookieApi.java index 33fdadf..f2a7385 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/CookieApi.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/CookieApi.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.graduate.api.json; +package cn.wustlinghang.wusthelper.internal.graduate.api.http; import cn.wustlinghang.wusthelper.internal.graduate.services.LoginService; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/CourseTableApi.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/CourseTableApi.java similarity index 95% rename from sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/CourseTableApi.java rename to sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/CourseTableApi.java index aa70ba9..05bc712 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/CourseTableApi.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/CourseTableApi.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.graduate.api.json; +package cn.wustlinghang.wusthelper.internal.graduate.api.http; import cn.wustlinghang.mywust.data.global.Course; import cn.wustlinghang.wusthelper.internal.graduate.services.ParseService; diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/ScoreApi.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/ScoreApi.java similarity index 95% rename from sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/ScoreApi.java rename to sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/ScoreApi.java index 0cbd34e..8d7431e 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/ScoreApi.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/ScoreApi.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.graduate.api.json; +package cn.wustlinghang.wusthelper.internal.graduate.api.http; import cn.wustlinghang.mywust.data.global.Score; import cn.wustlinghang.wusthelper.internal.graduate.services.ParseService; diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/StudentInfoApi.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/StudentInfoApi.java similarity index 95% rename from sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/StudentInfoApi.java rename to sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/StudentInfoApi.java index b1e414e..a8acf10 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/StudentInfoApi.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/StudentInfoApi.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.graduate.api.json; +package cn.wustlinghang.wusthelper.internal.graduate.api.http; import cn.wustlinghang.mywust.data.global.StudentInfo; import cn.wustlinghang.wusthelper.internal.graduate.services.ParseService; diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/TrainingPlanApi.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/TrainingPlanApi.java similarity index 95% rename from sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/TrainingPlanApi.java rename to sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/TrainingPlanApi.java index 9a72587..a1fb13a 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/TrainingPlanApi.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/TrainingPlanApi.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.graduate.api.json; +package cn.wustlinghang.wusthelper.internal.graduate.api.http; import cn.wustlinghang.wusthelper.internal.graduate.services.ParseService; import cn.wustlinghang.wusthelper.internal.graduate.services.RequestAgentService; diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/BaseExceptionHandler.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/BaseExceptionHandler.java similarity index 96% rename from sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/BaseExceptionHandler.java rename to sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/BaseExceptionHandler.java index c5b30c8..90099e9 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/BaseExceptionHandler.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/BaseExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.graduate.api.json.handler; +package cn.wustlinghang.wusthelper.internal.graduate.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import cn.wustlinghang.wusthelper.rpc.response.RpcResponse; diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/DefaultExceptionHandler.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/DefaultExceptionHandler.java similarity index 90% rename from sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/DefaultExceptionHandler.java rename to sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/DefaultExceptionHandler.java index 65d4983..91517e7 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/DefaultExceptionHandler.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/DefaultExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.graduate.api.json.handler; +package cn.wustlinghang.wusthelper.internal.graduate.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import jakarta.ws.rs.core.Response; diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/IOExceptionHandler.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/IOExceptionHandler.java similarity index 90% rename from sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/IOExceptionHandler.java rename to sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/IOExceptionHandler.java index 2ac80bd..4a2c037 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/IOExceptionHandler.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/IOExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.graduate.api.json.handler; +package cn.wustlinghang.wusthelper.internal.graduate.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import jakarta.ws.rs.core.Response; diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/ParseExceptionHandler.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/ParseExceptionHandler.java similarity index 91% rename from sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/ParseExceptionHandler.java rename to sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/ParseExceptionHandler.java index 4ea86cf..cf2e10b 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/ParseExceptionHandler.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/ParseExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.graduate.api.json.handler; +package cn.wustlinghang.wusthelper.internal.graduate.api.http.handler; import cn.wustlinghang.mywust.exception.ParseException; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/RpcExceptionHandler.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/RpcExceptionHandler.java similarity index 88% rename from sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/RpcExceptionHandler.java rename to sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/RpcExceptionHandler.java index 3ec3734..e9da549 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/RpcExceptionHandler.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/RpcExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.graduate.api.json.handler; +package cn.wustlinghang.wusthelper.internal.graduate.api.http.handler; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; import jakarta.ws.rs.core.Response; diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/ValidationExceptionHandler.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/ValidationExceptionHandler.java similarity index 91% rename from sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/ValidationExceptionHandler.java rename to sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/ValidationExceptionHandler.java index 04e8a75..1a613dc 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/ValidationExceptionHandler.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/ValidationExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.graduate.api.json.handler; +package cn.wustlinghang.wusthelper.internal.graduate.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import jakarta.validation.ValidationException; diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/WebApplicationExceptionHandler.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/WebApplicationExceptionHandler.java similarity index 94% rename from sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/WebApplicationExceptionHandler.java rename to sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/WebApplicationExceptionHandler.java index 660213b..67efa90 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/handler/WebApplicationExceptionHandler.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/handler/WebApplicationExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.graduate.api.json.handler; +package cn.wustlinghang.wusthelper.internal.graduate.api.http.handler; import cn.wustlinghang.wusthelper.internal.graduate.exception.GraduateRpcException; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/interceptor/ResponseWrapperInterceptor.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/interceptor/ResponseWrapperInterceptor.java similarity index 91% rename from sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/interceptor/ResponseWrapperInterceptor.java rename to sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/interceptor/ResponseWrapperInterceptor.java index c66bba6..d885d6a 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/json/interceptor/ResponseWrapperInterceptor.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/api/http/interceptor/ResponseWrapperInterceptor.java @@ -1,6 +1,6 @@ -package cn.wustlinghang.wusthelper.internal.graduate.api.json.interceptor; +package cn.wustlinghang.wusthelper.internal.graduate.api.http.interceptor; -import cn.wustlinghang.wusthelper.internal.graduate.api.json.handler.BaseExceptionHandler; +import cn.wustlinghang.wusthelper.internal.graduate.api.http.handler.BaseExceptionHandler; import cn.wustlinghang.wusthelper.rpc.response.RpcResponse; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.ws.rs.WebApplicationException; diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/exception/GraduateRpcException.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/exception/GraduateRpcException.java index b92a87f..55fdacb 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/exception/GraduateRpcException.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/exception/GraduateRpcException.java @@ -13,7 +13,7 @@ public class GraduateRpcException extends RpcException { super(UNDERGRAD_MODULE, typeCode.ordinal(), subModuleCode.ordinal() * 100 + errorCode.ordinal(), - new StringJoiner("-") + new StringJoiner("/") .add("GRADUATE") .add(typeCode.name()) .add(subModuleCode.name()) diff --git a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/services/LoginService.java b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/services/LoginService.java index 1e88c1e..babfa3b 100644 --- a/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/services/LoginService.java +++ b/sub-services/graduate/src/main/java/cn/wustlinghang/wusthelper/internal/graduate/services/LoginService.java @@ -80,7 +80,7 @@ public class LoginService { }; return new GraduateRpcException( - GraduateRpcException.TypeCode.NETWORK_EXCEPTION, + GraduateRpcException.TypeCode.AUTH_EXCEPTION, GraduateRpcException.SubModuleCode.AUTH, errorCode ); diff --git a/sub-services/library/.flattened-pom.xml b/sub-services/library/.flattened-pom.xml new file mode 100644 index 0000000..ff849b8 --- /dev/null +++ b/sub-services/library/.flattened-pom.xml @@ -0,0 +1,93 @@ + + + 4.0.0 + cn.wustlinghang.wusthelper + library + 0.0.1-SNAPSHOT + + + io.quarkus + quarkus-resteasy-reactive-jackson + 3.1.3.Final + compile + + + io.quarkus + quarkus-hibernate-validator + 3.1.3.Final + compile + + + io.quarkus + quarkus-resteasy-reactive + 3.1.3.Final + compile + + + io.quarkus + quarkus-arc + 3.1.3.Final + compile + + + cn.wustlinghang.mywust + mywust-core + 0.0.2-SNAPSHOT + compile + + + cn.wustlinghang.mywust + mywust-network-okhttp + 0.0.2-SNAPSHOT + compile + + + cn.wustlinghang.wusthelper + common + 0.0.1-SNAPSHOT + compile + + + jakarta.annotation + jakarta.annotation-api + 2.1.1 + compile + + + javax.annotation + javax.annotation-api + 1.3.2 + compile + + + org.projectlombok + lombok + 1.18.26 + provided + + + + + central + https://repo1.maven.org/maven2 + + + + true + + github + https://maven.pkg.github.com/LingHangStudio/mywust + + + + + + io.quarkus.platform + quarkus-maven-plugin + 3.1.3.Final + true + + + + diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/CreditStatusApi.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/BookCoverImageApi.java similarity index 54% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/CreditStatusApi.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/BookCoverImageApi.java index 0214f11..bbf178e 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/CreditStatusApi.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/BookCoverImageApi.java @@ -1,5 +1,6 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json; +package cn.wustlinghang.wusthelper.internal.library.api.http; +import cn.wustlinghang.mywust.data.global.Score; import cn.wustlinghang.wusthelper.internal.library.services.ParseService; import cn.wustlinghang.wusthelper.internal.library.services.RequestAgentService; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; @@ -10,36 +11,38 @@ import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.QueryParam; -@Path("/credit_status") +import java.util.List; + +@Path("/cover_image") @ApplicationScoped -public class CreditStatusApi { +public class BookCoverImageApi { private final RequestAgentService agentService; private final ParseService parseService; - public CreditStatusApi(RequestAgentService agentService, - ParseService parseService) { + public BookCoverImageApi(RequestAgentService agentService, + ParseService parseService) { this.agentService = agentService; this.parseService = parseService; } - + @GET @Path("/") - public String get(@QueryParam("cookie") @NotNull String cookie) + public List get(@QueryParam("isbn") @NotNull String isbn) throws RpcException { - String html = this.agent(cookie); - return this.parse(html); + return this.parse(this.agent(isbn)); } @GET @Path("/agent") - public String agent(@QueryParam("cookie") @NotNull String cookie) + public String agent(@QueryParam("isbn") @NotNull String isbn) throws RpcException { - return agentService.getCreditStatus(cookie); + return agentService.getBookCoverImageUrl(isbn); } @POST @Path("/parse") - public String parse(String html) throws RpcException { - return parseService.parseCreditStatus(html); + public List parse(String html) throws RpcException { +// return parseService.parseScore(html); + return null; } } diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/ScoreApi.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/BookDetailApi.java similarity index 64% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/ScoreApi.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/BookDetailApi.java index a043a9f..0db43db 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/ScoreApi.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/BookDetailApi.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json; +package cn.wustlinghang.wusthelper.internal.library.api.http; import cn.wustlinghang.mywust.data.global.Score; import cn.wustlinghang.wusthelper.internal.library.services.ParseService; @@ -13,35 +13,36 @@ import jakarta.ws.rs.QueryParam; import java.util.List; -@Path("/score") +@Path("/book_detail") @ApplicationScoped -public class ScoreApi { +public class BookDetailApi { private final RequestAgentService agentService; private final ParseService parseService; - public ScoreApi(RequestAgentService agentService, - ParseService parseService) { + public BookDetailApi(RequestAgentService agentService, + ParseService parseService) { this.agentService = agentService; this.parseService = parseService; } @GET @Path("/") - public List get(@QueryParam("cookie") @NotNull String cookie) + public List get(@QueryParam("isbn") @NotNull String isbn) throws RpcException { - return this.parse(this.agent(cookie)); + return this.parse(this.agent(isbn)); } @GET @Path("/agent") - public String agent(@QueryParam("cookie") @NotNull String cookie) + public String agent(@QueryParam("isbn") @NotNull String isbn) throws RpcException { - return agentService.getScore(cookie); + return agentService.getBookCoverImageUrl(isbn); } @POST @Path("/parse") public List parse(String html) throws RpcException { - return parseService.parseScore(html); +// return parseService.parseScore(html); + return null; } } diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/CookieApi.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/CookieApi.java similarity index 87% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/CookieApi.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/CookieApi.java index 0592d45..5dcde27 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/CookieApi.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/CookieApi.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json; +package cn.wustlinghang.wusthelper.internal.library.api.http; import cn.wustlinghang.wusthelper.internal.library.services.LoginService; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; @@ -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 diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/CourseTableApi.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/CurrentLoanApi.java similarity index 55% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/CourseTableApi.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/CurrentLoanApi.java index 83f7422..de2fe3c 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/CourseTableApi.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/CurrentLoanApi.java @@ -1,6 +1,6 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json; +package cn.wustlinghang.wusthelper.internal.library.api.http; -import cn.wustlinghang.mywust.data.global.Course; +import cn.wustlinghang.mywust.data.global.Score; import cn.wustlinghang.wusthelper.internal.library.services.ParseService; import cn.wustlinghang.wusthelper.internal.library.services.RequestAgentService; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; @@ -13,13 +13,13 @@ import jakarta.ws.rs.QueryParam; import java.util.List; -@Path("/course_table") +@Path("/current_loan") @ApplicationScoped -public class CourseTableApi { +public class CurrentLoanApi { private final RequestAgentService agentService; private final ParseService parseService; - public CourseTableApi(RequestAgentService agentService, + public CurrentLoanApi(RequestAgentService agentService, ParseService parseService) { this.agentService = agentService; this.parseService = parseService; @@ -27,23 +27,22 @@ public class CourseTableApi { @GET @Path("/") - public List get(@QueryParam("cookie") @NotNull String cookie, - @QueryParam("term") String term) + public List get(@QueryParam("isbn") @NotNull String isbn) throws RpcException { - return this.parse(this.agent(cookie, term)); + return this.parse(this.agent(isbn)); } @GET @Path("/agent") - public String agent(@QueryParam("cookie") @NotNull String cookie, - @QueryParam("term") String term) + public String agent(@QueryParam("isbn") @NotNull String isbn) throws RpcException { - return agentService.getCourseTable(cookie, term); + return agentService.getBookCoverImageUrl(isbn); } @POST @Path("/parse") - public List parse(String html) throws RpcException { - return parseService.parseCourseTable(html); + public List parse(String html) throws RpcException { +// return parseService.parseScore(html); + return null; } } diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/TrainingPlanApi.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/LoanHistoryApi.java similarity index 54% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/TrainingPlanApi.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/LoanHistoryApi.java index 6e83de8..3af4d41 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/TrainingPlanApi.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/LoanHistoryApi.java @@ -1,5 +1,6 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json; +package cn.wustlinghang.wusthelper.internal.library.api.http; +import cn.wustlinghang.mywust.data.global.Score; import cn.wustlinghang.wusthelper.internal.library.services.ParseService; import cn.wustlinghang.wusthelper.internal.library.services.RequestAgentService; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; @@ -10,35 +11,38 @@ import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.QueryParam; -@Path("/training_plan") +import java.util.List; + +@Path("/loan_history") @ApplicationScoped -public class TrainingPlanApi { +public class LoanHistoryApi { private final RequestAgentService agentService; private final ParseService parseService; - public TrainingPlanApi(RequestAgentService agentService, - ParseService parseService) { + public LoanHistoryApi(RequestAgentService agentService, + ParseService parseService) { this.agentService = agentService; this.parseService = parseService; } @GET @Path("/") - public String get(@QueryParam("cookie") @NotNull String cookie) + public List get(@QueryParam("isbn") @NotNull String isbn) throws RpcException { - return this.parse(this.agent(cookie)); + return this.parse(this.agent(isbn)); } @GET @Path("/agent") - public String agent(@QueryParam("cookie") @NotNull String cookie) + public String agent(@QueryParam("isbn") @NotNull String isbn) throws RpcException { - return agentService.getTrainingPlan(cookie); + return agentService.getBookCoverImageUrl(isbn); } @POST @Path("/parse") - public String parse(String html) throws RpcException { - return parseService.parseTrainingPlan(html); + public List parse(String html) throws RpcException { +// return parseService.parseScore(html); + return null; } } diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/OverdueSoonApi.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/OverdueSoonApi.java new file mode 100644 index 0000000..075e7a0 --- /dev/null +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/OverdueSoonApi.java @@ -0,0 +1,48 @@ +package cn.wustlinghang.wusthelper.internal.library.api.http; + +import cn.wustlinghang.mywust.data.global.Score; +import cn.wustlinghang.wusthelper.internal.library.services.ParseService; +import cn.wustlinghang.wusthelper.internal.library.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("/overdue_soon") +@ApplicationScoped +public class OverdueSoonApi { + private final RequestAgentService agentService; + private final ParseService parseService; + + public OverdueSoonApi(RequestAgentService agentService, + ParseService parseService) { + this.agentService = agentService; + this.parseService = parseService; + } + + @GET + @Path("/") + public List get(@QueryParam("isbn") @NotNull String isbn) + throws RpcException { + return this.parse(this.agent(isbn)); + } + + @GET + @Path("/agent") + public String agent(@QueryParam("isbn") @NotNull String isbn) + throws RpcException { + return agentService.getBookCoverImageUrl(isbn); + } + + @POST + @Path("/parse") + public List parse(String html) throws RpcException { +// return parseService.parseScore(html); + return null; + } +} diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/SearchApi.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/SearchApi.java new file mode 100644 index 0000000..03b956a --- /dev/null +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/SearchApi.java @@ -0,0 +1,50 @@ +package cn.wustlinghang.wusthelper.internal.library.api.http; + +import cn.wustlinghang.mywust.data.global.Score; +import cn.wustlinghang.wusthelper.internal.library.services.ParseService; +import cn.wustlinghang.wusthelper.internal.library.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("/search") +@ApplicationScoped +public class SearchApi { + private final RequestAgentService agentService; + private final ParseService parseService; + + public SearchApi(RequestAgentService agentService, + ParseService parseService) { + this.agentService = agentService; + this.parseService = parseService; + } + + @GET + @Path("/") + public List get(@QueryParam("isbn") @NotNull String isbn) + throws RpcException { + return this.parse(this.agent(isbn)); + } + + @GET + @Path("/agent") + public String agent(@QueryParam("keyword") @NotNull String keyword, + @QueryParam("page") @NotNull int page, + @QueryParam("page_size") @NotNull int pageSize) + throws RpcException { + return agentService.search(keyword, page, pageSize); + } + + @POST + @Path("/parse") + public List parse(String html) throws RpcException { +// return parseService.parseScore(html); + return null; + } +} diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/BaseExceptionHandler.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/BaseExceptionHandler.java similarity index 96% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/BaseExceptionHandler.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/BaseExceptionHandler.java index 3c51a4e..e203af6 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/BaseExceptionHandler.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/BaseExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json.handler; +package cn.wustlinghang.wusthelper.internal.library.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import cn.wustlinghang.wusthelper.rpc.response.RpcResponse; diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/DefaultExceptionHandler.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/DefaultExceptionHandler.java similarity index 90% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/DefaultExceptionHandler.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/DefaultExceptionHandler.java index d65e13d..28a065d 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/DefaultExceptionHandler.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/DefaultExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json.handler; +package cn.wustlinghang.wusthelper.internal.library.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import jakarta.ws.rs.core.Response; diff --git a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/IOExceptionHandler.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/IOExceptionHandler.java similarity index 90% rename from sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/IOExceptionHandler.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/IOExceptionHandler.java index 47a579d..3cede13 100644 --- a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/IOExceptionHandler.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/IOExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.physics.api.json.handler; +package cn.wustlinghang.wusthelper.internal.library.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import jakarta.ws.rs.core.Response; diff --git a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/ParseExceptionHandler.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/ParseExceptionHandler.java similarity index 91% rename from sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/ParseExceptionHandler.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/ParseExceptionHandler.java index 5f16ec4..6886d5d 100644 --- a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/ParseExceptionHandler.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/ParseExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.physics.api.json.handler; +package cn.wustlinghang.wusthelper.internal.library.api.http.handler; import cn.wustlinghang.mywust.exception.ParseException; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/RpcExceptionHandler.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/RpcExceptionHandler.java similarity index 88% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/RpcExceptionHandler.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/RpcExceptionHandler.java index 4dbb274..46c8084 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/RpcExceptionHandler.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/RpcExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json.handler; +package cn.wustlinghang.wusthelper.internal.library.api.http.handler; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; import jakarta.ws.rs.core.Response; diff --git a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/ValidationExceptionHandler.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/ValidationExceptionHandler.java similarity index 91% rename from sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/ValidationExceptionHandler.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/ValidationExceptionHandler.java index 0b0cf8d..67b9559 100644 --- a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/ValidationExceptionHandler.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/ValidationExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.physics.api.json.handler; +package cn.wustlinghang.wusthelper.internal.library.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import jakarta.validation.ValidationException; diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/WebApplicationExceptionHandler.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/WebApplicationExceptionHandler.java similarity index 59% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/WebApplicationExceptionHandler.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/WebApplicationExceptionHandler.java index 0916250..95ee7ef 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/WebApplicationExceptionHandler.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/handler/WebApplicationExceptionHandler.java @@ -1,6 +1,6 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json.handler; +package cn.wustlinghang.wusthelper.internal.library.api.http.handler; -import cn.wustlinghang.wusthelper.internal.library.exception.UndergradRpcException; +import cn.wustlinghang.wusthelper.internal.library.exception.LibraryRpcException; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.core.Response; @@ -14,10 +14,10 @@ public class WebApplicationExceptionHandler extends BaseExceptionHandler impleme return super.toResponse( e.getResponse().getStatus(), RpcException.toIntCode( - UndergradRpcException.UNDERGRAD_MODULE, - UndergradRpcException.SubModuleCode.COMMON.ordinal(), - UndergradRpcException.TypeCode.OTHER_EXCEPTION.ordinal() * 100 - + UndergradRpcException.ErrorCode.REQUEST_INVALID.ordinal() + LibraryRpcException.LIBRARY_MODULE, + LibraryRpcException.SubModuleCode.COMMON.ordinal(), + LibraryRpcException.TypeCode.OTHER_EXCEPTION.ordinal() * 100 + + LibraryRpcException.ErrorCode.REQUEST_INVALID.ordinal() ), e.getMessage(), "WebApplicationExceptionHandler" diff --git a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/interceptor/ResponseWrapperInterceptor.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/interceptor/ResponseWrapperInterceptor.java similarity index 91% rename from sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/interceptor/ResponseWrapperInterceptor.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/interceptor/ResponseWrapperInterceptor.java index 6e969ac..aa4591a 100644 --- a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/interceptor/ResponseWrapperInterceptor.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/http/interceptor/ResponseWrapperInterceptor.java @@ -1,6 +1,6 @@ -package cn.wustlinghang.wusthelper.internal.physics.api.json.interceptor; +package cn.wustlinghang.wusthelper.internal.library.api.http.interceptor; -import cn.wustlinghang.wusthelper.internal.physics.api.json.handler.BaseExceptionHandler; +import cn.wustlinghang.wusthelper.internal.library.api.http.handler.BaseExceptionHandler; import cn.wustlinghang.wusthelper.rpc.response.RpcResponse; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.ws.rs.WebApplicationException; diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/ExamActivitiesApi.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/ExamActivitiesApi.java deleted file mode 100644 index 6ada2db..0000000 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/ExamActivitiesApi.java +++ /dev/null @@ -1,48 +0,0 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json; - -import cn.wustlinghang.mywust.core.request.service.undergraduate.UndergradExamDelayApiService; -import cn.wustlinghang.mywust.data.global.Score; -import cn.wustlinghang.wusthelper.internal.library.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 parse(String html) throws RpcException { - throw RpcException.ApiNotImplement(); - } -} diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/ExamDelayApplicationApi.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/ExamDelayApplicationApi.java deleted file mode 100644 index 2ed3036..0000000 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/ExamDelayApplicationApi.java +++ /dev/null @@ -1,52 +0,0 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json; - -import cn.wustlinghang.mywust.data.undergrad.ExamDelayApplication; -import cn.wustlinghang.wusthelper.internal.library.services.ParseService; -import cn.wustlinghang.wusthelper.internal.library.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 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 parse(String html) throws RpcException { - return parseService.parseExamDelayApplications(html); - } -} diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/bean/MywustParserBeans.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/bean/MywustParserBeans.java deleted file mode 100644 index a337fe6..0000000 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/bean/MywustParserBeans.java +++ /dev/null @@ -1,36 +0,0 @@ -package cn.wustlinghang.wusthelper.internal.library.bean; - -import cn.wustlinghang.mywust.core.parser.undergraduate.*; -import jakarta.enterprise.context.ApplicationScoped; - -public class MywustParserBeans { - @ApplicationScoped - public UndergradCourseTableParser undergradCourseTableParser() { - return new UndergradCourseTableParser(); - } - - @ApplicationScoped - public UndergradScoreParser undergradScoreParser() { - return new UndergradScoreParser(); - } - - @ApplicationScoped - public UndergradStudentInfoPageParser undergradStudentInfoPageParser() { - return new UndergradStudentInfoPageParser(); - } - - @ApplicationScoped - public UndergradTrainingPlanPageParser undergradTrainingPlanPageParser() { - return new UndergradTrainingPlanPageParser(); - } - - @ApplicationScoped - public UndergradCreditStatusParser undergradCreditStatusParser() { - return new UndergradCreditStatusParser(); - } - - @ApplicationScoped - public UndergradExamDelayParser undergradExamDelayParser() { - return new UndergradExamDelayParser(); - } -} diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/bean/MywustRequestAgentBeans.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/bean/MywustRequestAgentBeans.java index c67d89d..d747890 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/bean/MywustRequestAgentBeans.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/bean/MywustRequestAgentBeans.java @@ -1,6 +1,8 @@ package cn.wustlinghang.wusthelper.internal.library.bean; +import cn.wustlinghang.mywust.core.request.service.auth.LibraryLogin; import cn.wustlinghang.mywust.core.request.service.auth.UndergraduateLogin; +import cn.wustlinghang.mywust.core.request.service.library.LibraryApiService; import cn.wustlinghang.mywust.core.request.service.undergraduate.*; import cn.wustlinghang.mywust.network.RequestClientOption; import cn.wustlinghang.mywust.network.Requester; @@ -27,37 +29,12 @@ public class MywustRequestAgentBeans { } @Singleton - public UndergraduateLogin undergraduateLogin(Requester requester) { - return new UndergraduateLogin(requester); + public LibraryLogin libraryLogin(Requester requester) { + return new LibraryLogin(requester); } @Singleton - public UndergradCourseTableApiService undergradCourseTableApiService(Requester requester) { - return new UndergradCourseTableApiService(requester); - } - - @Singleton - public UndergradScoreApiService undergradScoreApiService(Requester requester) { - return new UndergradScoreApiService(requester); - } - - @Singleton - public UndergradStudentInfoApiService undergradStudentInfoApiService(Requester requester) { - return new UndergradStudentInfoApiService(requester); - } - - @Singleton - public UndergradTrainingPlanApiService undergradTrainingPlanApiService(Requester requester) { - return new UndergradTrainingPlanApiService(requester); - } - - @Singleton - public UndergradCreditStatusApiService undergradCreditStatusApiService(Requester requester) { - return new UndergradCreditStatusApiService(requester); - } - - @Singleton - public UndergradExamDelayApiService undergradExamDelayApiService(Requester requester) { - return new UndergradExamDelayApiService(requester); + public LibraryApiService libraryApiService(Requester requester) { + return new LibraryApiService(requester); } } \ No newline at end of file diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/exception/UndergradRpcException.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/exception/LibraryRpcException.java similarity index 70% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/exception/UndergradRpcException.java rename to sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/exception/LibraryRpcException.java index 61493f8..61e49d5 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/exception/UndergradRpcException.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/exception/LibraryRpcException.java @@ -4,17 +4,17 @@ import cn.wustlinghang.wusthelper.rpc.exception.RpcException; import java.util.StringJoiner; -public class UndergradRpcException extends RpcException { - public static final int UNDERGRAD_MODULE = 1; +public class LibraryRpcException extends RpcException { + public static final int LIBRARY_MODULE = 3; - public UndergradRpcException(TypeCode typeCode, - SubModuleCode subModuleCode, - ErrorCode errorCode) { - super(UNDERGRAD_MODULE, + public LibraryRpcException(TypeCode typeCode, + SubModuleCode subModuleCode, + ErrorCode errorCode) { + super(LIBRARY_MODULE, typeCode.ordinal(), subModuleCode.ordinal() * 100 + errorCode.ordinal(), - new StringJoiner("-") - .add("UNDERGRAD") + new StringJoiner("/") + .add("LIBRARY") .add(typeCode.name()) .add(subModuleCode.name()) .add(errorCode.name()) @@ -42,8 +42,7 @@ public class UndergradRpcException extends RpcException { * 子模块编码 */ public enum SubModuleCode { - COMMON, AUTH, COURSE_TABLE, CREDIT_STATUS, SCORE, - STUDENT_INFO, TRAINING_PLAN, EXAM_ACTIVITIES, EXAM_DELAY_APPLICATION + COMMON, AUTH, PUBLIC_API, PERSONAL_API } /** @@ -56,9 +55,6 @@ public class UndergradRpcException extends RpcException { NETWORK_ERROR, PARSE_ERROR, - // 需要评教 - NEED_EVALUATE, - AUTH_PASSWORD_WRONG, // 用户不存在 AUTH_USER_NOT_EXISTS, diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/services/LoginService.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/services/LoginService.java index 2675a31..9463c12 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/services/LoginService.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/services/LoginService.java @@ -1,9 +1,9 @@ package cn.wustlinghang.wusthelper.internal.library.services; -import cn.wustlinghang.mywust.core.request.service.auth.UndergraduateLogin; +import cn.wustlinghang.mywust.core.request.service.auth.LibraryLogin; import cn.wustlinghang.mywust.exception.ApiException; import cn.wustlinghang.mywust.network.RequestClientOption; -import cn.wustlinghang.wusthelper.internal.library.exception.UndergradRpcException; +import cn.wustlinghang.wusthelper.internal.library.exception.LibraryRpcException; import jakarta.enterprise.context.ApplicationScoped; import lombok.extern.slf4j.Slf4j; @@ -13,65 +13,61 @@ import java.io.IOException; @ApplicationScoped public class LoginService { private final RequestClientOption option; - private final UndergraduateLogin undergraduateLogin; + private final LibraryLogin libraryLogin; public LoginService(RequestClientOption option, - UndergraduateLogin undergraduateLogin) { + LibraryLogin libraryLogin) { this.option = option; - this.undergraduateLogin = undergraduateLogin; + this.libraryLogin = libraryLogin; } - public String login(String username, String password, boolean legacy) throws UndergradRpcException { + public String login(String username, String password) throws LibraryRpcException { try { - if (legacy) { - return undergraduateLogin.getLoginCookieLegacy(username, password, option); - } else { - return undergraduateLogin.getLoginCookie(username, password, option); - } + return libraryLogin.getLoginCookie(username, password, option); } catch (ApiException e) { throw wrapApiException(e); } catch (IOException e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.NETWORK_EXCEPTION, - UndergradRpcException.SubModuleCode.AUTH, - UndergradRpcException.ErrorCode.NETWORK_ERROR + throw new LibraryRpcException( + LibraryRpcException.TypeCode.NETWORK_EXCEPTION, + LibraryRpcException.SubModuleCode.AUTH, + LibraryRpcException.ErrorCode.NETWORK_ERROR ); } } - public boolean verify(String cookie) throws UndergradRpcException { + public boolean verify(String cookie) throws LibraryRpcException { try { - return !undergraduateLogin.checkCookiesFail(cookie); + return libraryLogin.checkCookie(cookie, option); } catch (IOException e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.NETWORK_EXCEPTION, - UndergradRpcException.SubModuleCode.AUTH, - UndergradRpcException.ErrorCode.NETWORK_ERROR + throw new LibraryRpcException( + LibraryRpcException.TypeCode.NETWORK_EXCEPTION, + LibraryRpcException.SubModuleCode.AUTH, + LibraryRpcException.ErrorCode.NETWORK_ERROR ); } } - private UndergradRpcException wrapApiException(ApiException e) { - UndergradRpcException.ErrorCode errorCode = switch (e.getCode()) { - case NETWORK_EXCEPTION -> UndergradRpcException.ErrorCode.NETWORK_ERROR; - case UNI_LOGIN_PASSWORD_WRONG -> UndergradRpcException.ErrorCode.AUTH_PASSWORD_WRONG; - case UNI_LOGIN_USER_NOT_EXISTS -> UndergradRpcException.ErrorCode.AUTH_USER_NOT_EXISTS; - case UNI_LOGIN_USER_BANNED -> UndergradRpcException.ErrorCode.AUTH_USER_BANNED; - case UNI_LOGIN_USER_DISABLED -> UndergradRpcException.ErrorCode.AUTH_USER_DISABLED; - case UNI_LOGIN_NEED_CHANGE_PASSWORD -> UndergradRpcException.ErrorCode.AUTH_NEED_CHANGE_PASSWORD; - case UNI_LOGIN_USER_NOT_ONLY -> UndergradRpcException.ErrorCode.AUTH_UNKNOWN_ERROR; - case UNI_LOGIN_NO_REGISTER -> UndergradRpcException.ErrorCode.AUTH_UNKNOWN_ERROR; - case UNI_LOGIN_NEED_TFA -> UndergradRpcException.ErrorCode.AUTH_UNKNOWN_ERROR; + private LibraryRpcException wrapApiException(ApiException e) { + LibraryRpcException.ErrorCode errorCode = switch (e.getCode()) { + case NETWORK_EXCEPTION -> LibraryRpcException.ErrorCode.NETWORK_ERROR; + case UNI_LOGIN_PASSWORD_WRONG -> LibraryRpcException.ErrorCode.AUTH_PASSWORD_WRONG; + case UNI_LOGIN_USER_NOT_EXISTS -> LibraryRpcException.ErrorCode.AUTH_USER_NOT_EXISTS; + case UNI_LOGIN_USER_BANNED -> LibraryRpcException.ErrorCode.AUTH_USER_BANNED; + case UNI_LOGIN_USER_DISABLED -> LibraryRpcException.ErrorCode.AUTH_USER_DISABLED; + case UNI_LOGIN_NEED_CHANGE_PASSWORD -> LibraryRpcException.ErrorCode.AUTH_NEED_CHANGE_PASSWORD; + case UNI_LOGIN_USER_NOT_ONLY -> LibraryRpcException.ErrorCode.AUTH_UNKNOWN_ERROR; + case UNI_LOGIN_NO_REGISTER -> LibraryRpcException.ErrorCode.AUTH_UNKNOWN_ERROR; + case UNI_LOGIN_NEED_TFA -> LibraryRpcException.ErrorCode.AUTH_UNKNOWN_ERROR; default -> { - log.error("本科生:登录代理请求异常,异常未处理"); + log.error("图书馆:登录代理请求异常,异常未处理"); log.error("异常:", e); - yield UndergradRpcException.ErrorCode.AUTH_UNKNOWN_ERROR; + yield LibraryRpcException.ErrorCode.AUTH_UNKNOWN_ERROR; } }; - return new UndergradRpcException( - UndergradRpcException.TypeCode.NETWORK_EXCEPTION, - UndergradRpcException.SubModuleCode.AUTH, + return new LibraryRpcException( + LibraryRpcException.TypeCode.AUTH_EXCEPTION, + LibraryRpcException.SubModuleCode.AUTH, errorCode ); } diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/services/ParseService.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/services/ParseService.java deleted file mode 100644 index 72005f2..0000000 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/services/ParseService.java +++ /dev/null @@ -1,131 +0,0 @@ -package cn.wustlinghang.wusthelper.internal.library.services; - -import cn.wustlinghang.mywust.core.parser.undergraduate.*; -import cn.wustlinghang.mywust.data.global.Course; -import cn.wustlinghang.mywust.data.global.Score; -import cn.wustlinghang.mywust.data.global.StudentInfo; -import cn.wustlinghang.mywust.data.undergrad.ExamDelayApplication; -import cn.wustlinghang.wusthelper.internal.library.exception.UndergradRpcException; -import cn.wustlinghang.wusthelper.rpc.exception.RpcException; -import jakarta.enterprise.context.ApplicationScoped; - -import java.util.List; - -@ApplicationScoped -public class ParseService { - private final UndergradCourseTableParser courseTableParser; - private final UndergradScoreParser scoreParser; - private final UndergradStudentInfoPageParser studentInfoPageParser; - private final UndergradTrainingPlanPageParser trainingPlanPageParser; - private final UndergradCreditStatusParser creditStatusParser; - private final UndergradExamDelayParser examDelayParser; - - public ParseService(UndergradCourseTableParser courseTableParser, - UndergradScoreParser scoreParser, - UndergradStudentInfoPageParser studentInfoPageParser, - UndergradTrainingPlanPageParser trainingPlanPageParser, - UndergradCreditStatusParser creditStatusParser, - UndergradExamDelayParser examDelayParser) { - - this.courseTableParser = courseTableParser; - this.scoreParser = scoreParser; - this.studentInfoPageParser = studentInfoPageParser; - this.trainingPlanPageParser = trainingPlanPageParser; - this.creditStatusParser = creditStatusParser; - this.examDelayParser = examDelayParser; - } - - public List parseCourseTable(String data) throws UndergradRpcException { - try { - if (data.contains("评教")) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.PARSE_EXCEPTION, - UndergradRpcException.SubModuleCode.COURSE_TABLE, - UndergradRpcException.ErrorCode.NEED_EVALUATE - ); - } - - return courseTableParser.parse(data); - - } catch (UndergradRpcException e) { - throw e; - } catch (Exception e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.PARSE_EXCEPTION, - UndergradRpcException.SubModuleCode.COURSE_TABLE, - UndergradRpcException.ErrorCode.PARSE_ERROR - ); - } - } - - public List parseScore(String data) throws RpcException { - try { - if (data.contains("评教")) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.PARSE_EXCEPTION, - UndergradRpcException.SubModuleCode.SCORE, - UndergradRpcException.ErrorCode.NEED_EVALUATE - ); - } - - return scoreParser.parse(data); - - } catch (UndergradRpcException e) { - throw e; - } catch (Exception e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.PARSE_EXCEPTION, - UndergradRpcException.SubModuleCode.SCORE, - UndergradRpcException.ErrorCode.PARSE_ERROR - ); - } - } - - public StudentInfo parseStudentInfo(String data) throws RpcException { - try { - return studentInfoPageParser.parse(data); - } catch (Exception e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.PARSE_EXCEPTION, - UndergradRpcException.SubModuleCode.STUDENT_INFO, - UndergradRpcException.ErrorCode.PARSE_ERROR - ); - } - } - - public String parseTrainingPlan(String data) throws RpcException { - try { - return trainingPlanPageParser.parse(data); - } catch (Exception e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.PARSE_EXCEPTION, - UndergradRpcException.SubModuleCode.TRAINING_PLAN, - UndergradRpcException.ErrorCode.PARSE_ERROR - ); - } - } - - public String parseCreditStatus(String data) throws RpcException { - try { - return creditStatusParser.parse(data); - } catch (Exception e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.PARSE_EXCEPTION, - UndergradRpcException.SubModuleCode.CREDIT_STATUS, - UndergradRpcException.ErrorCode.PARSE_ERROR - ); - } - } - - public List parseExamDelayApplications(String data) throws RpcException { - try { - return examDelayParser.parse(data); - } catch (Exception e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.PARSE_EXCEPTION, - UndergradRpcException.SubModuleCode.EXAM_DELAY_APPLICATION, - UndergradRpcException.ErrorCode.PARSE_ERROR - ); - } - } -} diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/services/RequestAgentService.java b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/services/RequestAgentService.java index a4eee8a..3e9ec41 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/services/RequestAgentService.java +++ b/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/services/RequestAgentService.java @@ -1,9 +1,9 @@ package cn.wustlinghang.wusthelper.internal.library.services; -import cn.wustlinghang.mywust.core.request.service.undergraduate.*; +import cn.wustlinghang.mywust.core.request.service.library.LibraryApiService; import cn.wustlinghang.mywust.exception.ApiException; import cn.wustlinghang.mywust.network.RequestClientOption; -import cn.wustlinghang.wusthelper.internal.library.exception.UndergradRpcException; +import cn.wustlinghang.wusthelper.internal.library.exception.LibraryRpcException; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; import jakarta.enterprise.context.ApplicationScoped; import lombok.extern.slf4j.Slf4j; @@ -13,152 +13,115 @@ import java.io.IOException; @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 LibraryApiService libraryApiService; - 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; - - this.requestClientOption = requestClientOption; - } - - public String getStudentInfoPage(String cookie) throws RpcException { - try { - return studentInfoApiService.getPage(cookie); - } catch (ApiException e) { - throw wrapApiException(e, UndergradRpcException.SubModuleCode.STUDENT_INFO); - } catch (IOException e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.NETWORK_EXCEPTION, - UndergradRpcException.SubModuleCode.STUDENT_INFO, - UndergradRpcException.ErrorCode.NETWORK_ERROR - ); - } + public RequestAgentService(LibraryApiService libraryApiService) { + this.libraryApiService = libraryApiService; } - public String getCourseTable(String cookie, String term) throws RpcException { + public String getBookCoverImageUrl(String isbn) throws RpcException { try { - return courseTableApiService.getPage(term, cookie); + return libraryApiService.getBookCoverImageUrl(isbn); } catch (ApiException e) { - throw wrapApiException(e, UndergradRpcException.SubModuleCode.COURSE_TABLE); + throw wrapApiException(e, LibraryRpcException.SubModuleCode.PUBLIC_API); } catch (IOException e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.NETWORK_EXCEPTION, - UndergradRpcException.SubModuleCode.COURSE_TABLE, - UndergradRpcException.ErrorCode.NETWORK_ERROR + throw new LibraryRpcException( + LibraryRpcException.TypeCode.NETWORK_EXCEPTION, + LibraryRpcException.SubModuleCode.PUBLIC_API, + LibraryRpcException.ErrorCode.NETWORK_ERROR ); } } - public String getScore(String cookie) throws RpcException { + public String getBookDetail(String bookId) throws RpcException { try { - return scoreApiService.getPage(cookie); + return libraryApiService.getBookDetail(bookId); } catch (ApiException e) { - throw wrapApiException(e, UndergradRpcException.SubModuleCode.SCORE); + throw wrapApiException(e, LibraryRpcException.SubModuleCode.PUBLIC_API); } catch (IOException e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.NETWORK_EXCEPTION, - UndergradRpcException.SubModuleCode.SCORE, - UndergradRpcException.ErrorCode.NETWORK_ERROR + throw new LibraryRpcException( + LibraryRpcException.TypeCode.NETWORK_EXCEPTION, + LibraryRpcException.SubModuleCode.PUBLIC_API, + LibraryRpcException.ErrorCode.NETWORK_ERROR ); } } - public String getTrainingPlan(String cookie) throws RpcException { + public String getCurrentLoan(String cookie) throws RpcException { try { - return trainingPlanApiService.getPage(cookie); + return libraryApiService.getCurrentLoan(cookie); } catch (ApiException e) { - throw wrapApiException(e, UndergradRpcException.SubModuleCode.TRAINING_PLAN); + throw wrapApiException(e, LibraryRpcException.SubModuleCode.PERSONAL_API); } catch (IOException e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.NETWORK_EXCEPTION, - UndergradRpcException.SubModuleCode.TRAINING_PLAN, - UndergradRpcException.ErrorCode.NETWORK_ERROR + throw new LibraryRpcException( + LibraryRpcException.TypeCode.NETWORK_EXCEPTION, + LibraryRpcException.SubModuleCode.PERSONAL_API, + LibraryRpcException.ErrorCode.NETWORK_ERROR ); } } - public String getCreditStatus(String cookie) throws RpcException { + public String search(String keyword, int page, int pageSize) throws RpcException { try { - return creditStatusApiService.getPage(cookie, requestClientOption, false); + return libraryApiService.search(keyword, page, pageSize); } catch (ApiException e) { - throw wrapApiException(e, UndergradRpcException.SubModuleCode.CREDIT_STATUS); + throw wrapApiException(e, LibraryRpcException.SubModuleCode.PUBLIC_API); } catch (IOException e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.NETWORK_EXCEPTION, - UndergradRpcException.SubModuleCode.CREDIT_STATUS, - UndergradRpcException.ErrorCode.NETWORK_ERROR + throw new LibraryRpcException( + LibraryRpcException.TypeCode.NETWORK_EXCEPTION, + LibraryRpcException.SubModuleCode.PUBLIC_API, + LibraryRpcException.ErrorCode.NETWORK_ERROR ); } } - public UndergradExamDelayApiService.ExamActivity[] getExamActivities(String cookie, String term) - throws RpcException { + public String getLoanHistory(String cookie) throws RpcException { try { - return examDelayApiService.getActivities(term, cookie); + return libraryApiService.getLoanHistory(cookie); } catch (ApiException e) { - throw wrapApiException(e, UndergradRpcException.SubModuleCode.EXAM_ACTIVITIES); + throw wrapApiException(e, LibraryRpcException.SubModuleCode.PERSONAL_API); } catch (IOException e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.NETWORK_EXCEPTION, - UndergradRpcException.SubModuleCode.EXAM_ACTIVITIES, - UndergradRpcException.ErrorCode.NETWORK_ERROR + throw new LibraryRpcException( + LibraryRpcException.TypeCode.NETWORK_EXCEPTION, + LibraryRpcException.SubModuleCode.PERSONAL_API, + LibraryRpcException.ErrorCode.NETWORK_ERROR ); } } - public String getExamDelayApplications(String cookie, String term, String activityId) - throws RpcException { + public String getOverdueSoon(String cookie) throws RpcException { try { - return examDelayApiService.getPage(term, activityId, cookie); + return libraryApiService.getOverdueSoon(cookie); } catch (ApiException e) { - throw wrapApiException(e, UndergradRpcException.SubModuleCode.EXAM_DELAY_APPLICATION); + throw wrapApiException(e, LibraryRpcException.SubModuleCode.PERSONAL_API); } catch (IOException e) { - throw new UndergradRpcException( - UndergradRpcException.TypeCode.NETWORK_EXCEPTION, - UndergradRpcException.SubModuleCode.EXAM_DELAY_APPLICATION, - UndergradRpcException.ErrorCode.NETWORK_ERROR + throw new LibraryRpcException( + LibraryRpcException.TypeCode.NETWORK_EXCEPTION, + LibraryRpcException.SubModuleCode.PERSONAL_API, + LibraryRpcException.ErrorCode.NETWORK_ERROR ); } } - private UndergradRpcException wrapApiException(ApiException e, UndergradRpcException.SubModuleCode subModuleCode) { + private LibraryRpcException wrapApiException(ApiException e, LibraryRpcException.SubModuleCode subModuleCode) { return switch (e.getCode()) { - case NETWORK_EXCEPTION -> new UndergradRpcException( - UndergradRpcException.TypeCode.NETWORK_EXCEPTION, + case NETWORK_EXCEPTION -> new LibraryRpcException( + LibraryRpcException.TypeCode.NETWORK_EXCEPTION, subModuleCode, - UndergradRpcException.ErrorCode.NETWORK_ERROR + LibraryRpcException.ErrorCode.NETWORK_ERROR ); - case COOKIE_INVALID -> new UndergradRpcException( - UndergradRpcException.TypeCode.AUTH_EXCEPTION, + case COOKIE_INVALID -> new LibraryRpcException( + LibraryRpcException.TypeCode.AUTH_EXCEPTION, subModuleCode, - UndergradRpcException.ErrorCode.COOKIE_INVALID + LibraryRpcException.ErrorCode.COOKIE_INVALID ); default -> { log.error("本科生:{}代理请求异常,异常未处理", subModuleCode.name()); log.error("异常:", e); - yield new UndergradRpcException( - UndergradRpcException.TypeCode.AUTH_EXCEPTION, + yield new LibraryRpcException( + LibraryRpcException.TypeCode.AUTH_EXCEPTION, subModuleCode, - UndergradRpcException.ErrorCode.COOKIE_INVALID + LibraryRpcException.ErrorCode.COOKIE_INVALID ); } }; diff --git a/sub-services/physics/.flattened-pom.xml b/sub-services/physics/.flattened-pom.xml new file mode 100644 index 0000000..48c8b5c --- /dev/null +++ b/sub-services/physics/.flattened-pom.xml @@ -0,0 +1,93 @@ + + + 4.0.0 + cn.wustlinghang.wusthelper + physics + 0.0.1-SNAPSHOT + + + io.quarkus + quarkus-resteasy-reactive-jackson + 3.1.3.Final + compile + + + io.quarkus + quarkus-hibernate-validator + 3.1.3.Final + compile + + + io.quarkus + quarkus-resteasy-reactive + 3.1.3.Final + compile + + + io.quarkus + quarkus-arc + 3.1.3.Final + compile + + + cn.wustlinghang.mywust + mywust-core + 0.0.2-SNAPSHOT + compile + + + cn.wustlinghang.mywust + mywust-network-okhttp + 0.0.2-SNAPSHOT + compile + + + cn.wustlinghang.wusthelper + common + 0.0.1-SNAPSHOT + compile + + + jakarta.annotation + jakarta.annotation-api + 2.1.1 + compile + + + javax.annotation + javax.annotation-api + 1.3.2 + compile + + + org.projectlombok + lombok + 1.18.26 + provided + + + + + central + https://repo1.maven.org/maven2 + + + + true + + github + https://maven.pkg.github.com/LingHangStudio/mywust + + + + + + io.quarkus.platform + quarkus-maven-plugin + 3.1.3.Final + true + + + + diff --git a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/CookieApi.java b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/CookieApi.java similarity index 93% rename from sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/CookieApi.java rename to sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/CookieApi.java index c8c7cdc..7db2654 100644 --- a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/CookieApi.java +++ b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/CookieApi.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.physics.api.json; +package cn.wustlinghang.wusthelper.internal.physics.api.http; import cn.wustlinghang.wusthelper.internal.physics.services.LoginService; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; diff --git a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/CourseTableApi.java b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/CourseTableApi.java similarity index 95% rename from sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/CourseTableApi.java rename to sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/CourseTableApi.java index 1ec7fcc..0d774c5 100644 --- a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/CourseTableApi.java +++ b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/CourseTableApi.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.physics.api.json; +package cn.wustlinghang.wusthelper.internal.physics.api.http; import cn.wustlinghang.mywust.data.physics.PhysicsCourse; import cn.wustlinghang.wusthelper.internal.physics.services.ParseService; diff --git a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/ScoreApi.java b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/ScoreApi.java similarity index 96% rename from sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/ScoreApi.java rename to sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/ScoreApi.java index 65fbf30..3dd7c4f 100644 --- a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/ScoreApi.java +++ b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/ScoreApi.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.physics.api.json; +package cn.wustlinghang.wusthelper.internal.physics.api.http; import cn.wustlinghang.mywust.data.global.Score; import cn.wustlinghang.wusthelper.internal.physics.services.ParseService; diff --git a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/BaseExceptionHandler.java b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/BaseExceptionHandler.java similarity index 96% rename from sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/BaseExceptionHandler.java rename to sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/BaseExceptionHandler.java index 07b7151..58ed838 100644 --- a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/BaseExceptionHandler.java +++ b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/BaseExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.physics.api.json.handler; +package cn.wustlinghang.wusthelper.internal.physics.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import cn.wustlinghang.wusthelper.rpc.response.RpcResponse; diff --git a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/DefaultExceptionHandler.java b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/DefaultExceptionHandler.java similarity index 90% rename from sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/DefaultExceptionHandler.java rename to sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/DefaultExceptionHandler.java index 9fe5080..fb89811 100644 --- a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/DefaultExceptionHandler.java +++ b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/DefaultExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.physics.api.json.handler; +package cn.wustlinghang.wusthelper.internal.physics.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import jakarta.ws.rs.core.Response; diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/IOExceptionHandler.java b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/IOExceptionHandler.java similarity index 90% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/IOExceptionHandler.java rename to sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/IOExceptionHandler.java index 63b6758..4a096d5 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/IOExceptionHandler.java +++ b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/IOExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json.handler; +package cn.wustlinghang.wusthelper.internal.physics.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import jakarta.ws.rs.core.Response; diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/ParseExceptionHandler.java b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/ParseExceptionHandler.java similarity index 91% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/ParseExceptionHandler.java rename to sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/ParseExceptionHandler.java index 6e7ee39..601b05b 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/ParseExceptionHandler.java +++ b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/ParseExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json.handler; +package cn.wustlinghang.wusthelper.internal.physics.api.http.handler; import cn.wustlinghang.mywust.exception.ParseException; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; diff --git a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/RpcExceptionHandler.java b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/RpcExceptionHandler.java similarity index 88% rename from sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/RpcExceptionHandler.java rename to sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/RpcExceptionHandler.java index 3a38080..0630455 100644 --- a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/RpcExceptionHandler.java +++ b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/RpcExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.physics.api.json.handler; +package cn.wustlinghang.wusthelper.internal.physics.api.http.handler; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; import jakarta.ws.rs.core.Response; diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/ValidationExceptionHandler.java b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/ValidationExceptionHandler.java similarity index 91% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/ValidationExceptionHandler.java rename to sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/ValidationExceptionHandler.java index 2f8ed29..11dc7d1 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/handler/ValidationExceptionHandler.java +++ b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/ValidationExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json.handler; +package cn.wustlinghang.wusthelper.internal.physics.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import jakarta.validation.ValidationException; diff --git a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/WebApplicationExceptionHandler.java b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/WebApplicationExceptionHandler.java similarity index 94% rename from sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/WebApplicationExceptionHandler.java rename to sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/WebApplicationExceptionHandler.java index 641dce5..346f267 100644 --- a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/json/handler/WebApplicationExceptionHandler.java +++ b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/handler/WebApplicationExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.physics.api.json.handler; +package cn.wustlinghang.wusthelper.internal.physics.api.http.handler; import cn.wustlinghang.wusthelper.internal.physics.exception.PhysicsRpcException; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/interceptor/ResponseWrapperInterceptor.java b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/interceptor/ResponseWrapperInterceptor.java similarity index 91% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/interceptor/ResponseWrapperInterceptor.java rename to sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/interceptor/ResponseWrapperInterceptor.java index 6fcdedf..bb39d54 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/interceptor/ResponseWrapperInterceptor.java +++ b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/api/http/interceptor/ResponseWrapperInterceptor.java @@ -1,6 +1,6 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json.interceptor; +package cn.wustlinghang.wusthelper.internal.physics.api.http.interceptor; -import cn.wustlinghang.wusthelper.internal.library.api.json.handler.BaseExceptionHandler; +import cn.wustlinghang.wusthelper.internal.physics.api.http.handler.BaseExceptionHandler; import cn.wustlinghang.wusthelper.rpc.response.RpcResponse; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.ws.rs.WebApplicationException; diff --git a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/exception/PhysicsRpcException.java b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/exception/PhysicsRpcException.java index 699c061..c368ff8 100644 --- a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/exception/PhysicsRpcException.java +++ b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/exception/PhysicsRpcException.java @@ -13,7 +13,7 @@ public class PhysicsRpcException extends RpcException { super(PHYSICS_MODULE, typeCode.ordinal(), subModuleCode.ordinal() * 100 + errorCode.ordinal(), - new StringJoiner("-") + new StringJoiner("/") .add("PHYSICS") .add(typeCode.name()) .add(subModuleCode.name()) diff --git a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/services/LoginService.java b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/services/LoginService.java index 6c367e5..81cb646 100644 --- a/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/services/LoginService.java +++ b/sub-services/physics/src/main/java/cn/wustlinghang/wusthelper/internal/physics/services/LoginService.java @@ -37,7 +37,7 @@ public class LoginService { } catch (ParseException e) { log.error("物理实验:登录时出现页面参数解析问题", e); throw new PhysicsRpcException( - PhysicsRpcException.TypeCode.NETWORK_EXCEPTION, + PhysicsRpcException.TypeCode.PARSE_EXCEPTION, PhysicsRpcException.SubModuleCode.AUTH, PhysicsRpcException.ErrorCode.AUTH_UNKNOWN_ERROR ); @@ -69,7 +69,7 @@ public class LoginService { }; return new PhysicsRpcException( - PhysicsRpcException.TypeCode.NETWORK_EXCEPTION, + PhysicsRpcException.TypeCode.AUTH_EXCEPTION, PhysicsRpcException.SubModuleCode.AUTH, errorCode ); diff --git a/sub-services/undergrad/.flattened-pom.xml b/sub-services/undergrad/.flattened-pom.xml new file mode 100644 index 0000000..0c24ec8 --- /dev/null +++ b/sub-services/undergrad/.flattened-pom.xml @@ -0,0 +1,93 @@ + + + 4.0.0 + cn.wustlinghang.wusthelper + undergrad + 0.0.1-SNAPSHOT + + + io.quarkus + quarkus-resteasy-reactive-jackson + 3.1.3.Final + compile + + + io.quarkus + quarkus-hibernate-validator + 3.1.3.Final + compile + + + io.quarkus + quarkus-resteasy-reactive + 3.1.3.Final + compile + + + io.quarkus + quarkus-arc + 3.1.3.Final + compile + + + cn.wustlinghang.mywust + mywust-core + 0.0.2-SNAPSHOT + compile + + + cn.wustlinghang.mywust + mywust-network-okhttp + 0.0.2-SNAPSHOT + compile + + + cn.wustlinghang.wusthelper + common + 0.0.1-SNAPSHOT + compile + + + jakarta.annotation + jakarta.annotation-api + 2.1.1 + compile + + + javax.annotation + javax.annotation-api + 1.3.2 + compile + + + org.projectlombok + lombok + 1.18.26 + provided + + + + + central + https://repo1.maven.org/maven2 + + + + true + + github + https://maven.pkg.github.com/LingHangStudio/mywust + + + + + + io.quarkus.platform + quarkus-maven-plugin + 3.1.3.Final + true + + + + diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/CookieApi.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/CookieApi.java similarity index 90% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/CookieApi.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/CookieApi.java index aa5264d..63e2904 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/CookieApi.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/CookieApi.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http; import cn.wustlinghang.wusthelper.internal.undergrad.services.LoginService; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; @@ -7,8 +7,6 @@ import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.QueryParam; -import java.io.IOException; - @Path("/cookie") public class CookieApi { private final LoginService loginService; diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/CourseTableApi.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/CourseTableApi.java similarity index 88% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/CourseTableApi.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/CourseTableApi.java index ec94278..cc200c0 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/CourseTableApi.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/CourseTableApi.java @@ -1,8 +1,6 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http; import cn.wustlinghang.mywust.data.global.Course; -import cn.wustlinghang.mywust.exception.ApiException; -import cn.wustlinghang.mywust.exception.ParseException; import cn.wustlinghang.wusthelper.internal.undergrad.services.ParseService; import cn.wustlinghang.wusthelper.internal.undergrad.services.RequestAgentService; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; @@ -13,7 +11,6 @@ import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.QueryParam; -import java.io.IOException; import java.util.List; @Path("/course_table") diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/CreditStatusApi.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/CreditStatusApi.java similarity index 87% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/CreditStatusApi.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/CreditStatusApi.java index 258d5f3..b10377c 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/CreditStatusApi.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/CreditStatusApi.java @@ -1,7 +1,5 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http; -import cn.wustlinghang.mywust.exception.ApiException; -import cn.wustlinghang.mywust.exception.ParseException; import cn.wustlinghang.wusthelper.internal.undergrad.services.ParseService; import cn.wustlinghang.wusthelper.internal.undergrad.services.RequestAgentService; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; @@ -12,8 +10,6 @@ import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.QueryParam; -import java.io.IOException; - @Path("/credit_status") @ApplicationScoped public class CreditStatusApi { diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/ExamActivitiesApi.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/ExamActivitiesApi.java similarity index 95% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/ExamActivitiesApi.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/ExamActivitiesApi.java index 9f0011d..4e5e362 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/ExamActivitiesApi.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/ExamActivitiesApi.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http; import cn.wustlinghang.mywust.core.request.service.undergraduate.UndergradExamDelayApiService; import cn.wustlinghang.mywust.data.global.Score; diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/ExamDelayApplicationApi.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/ExamDelayApplicationApi.java similarity index 96% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/ExamDelayApplicationApi.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/ExamDelayApplicationApi.java index 8cc0287..cedf5ef 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/ExamDelayApplicationApi.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/ExamDelayApplicationApi.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http; import cn.wustlinghang.mywust.data.undergrad.ExamDelayApplication; import cn.wustlinghang.wusthelper.internal.undergrad.services.ParseService; diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/ScoreApi.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/ScoreApi.java similarity index 87% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/ScoreApi.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/ScoreApi.java index 6435534..c284187 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/ScoreApi.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/ScoreApi.java @@ -1,8 +1,6 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http; import cn.wustlinghang.mywust.data.global.Score; -import cn.wustlinghang.mywust.exception.ApiException; -import cn.wustlinghang.mywust.exception.ParseException; import cn.wustlinghang.wusthelper.internal.undergrad.services.ParseService; import cn.wustlinghang.wusthelper.internal.undergrad.services.RequestAgentService; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; @@ -13,7 +11,6 @@ import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.QueryParam; -import java.io.IOException; import java.util.List; @Path("/score") diff --git a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/StudentInfoApi.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/StudentInfoApi.java similarity index 84% rename from sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/StudentInfoApi.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/StudentInfoApi.java index f6a97a7..d1079e7 100644 --- a/sub-services/library/src/main/java/cn/wustlinghang/wusthelper/internal/library/api/json/StudentInfoApi.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/StudentInfoApi.java @@ -1,8 +1,8 @@ -package cn.wustlinghang.wusthelper.internal.library.api.json; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http; import cn.wustlinghang.mywust.data.global.StudentInfo; -import cn.wustlinghang.wusthelper.internal.library.services.ParseService; -import cn.wustlinghang.wusthelper.internal.library.services.RequestAgentService; +import cn.wustlinghang.wusthelper.internal.undergrad.services.ParseService; +import cn.wustlinghang.wusthelper.internal.undergrad.services.RequestAgentService; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; import jakarta.enterprise.context.ApplicationScoped; import jakarta.validation.constraints.NotNull; diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/TrainingPlanApi.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/TrainingPlanApi.java similarity index 86% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/TrainingPlanApi.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/TrainingPlanApi.java index aeebf99..5536c4f 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/TrainingPlanApi.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/TrainingPlanApi.java @@ -1,7 +1,5 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http; -import cn.wustlinghang.mywust.exception.ApiException; -import cn.wustlinghang.mywust.exception.ParseException; import cn.wustlinghang.wusthelper.internal.undergrad.services.ParseService; import cn.wustlinghang.wusthelper.internal.undergrad.services.RequestAgentService; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; @@ -12,8 +10,6 @@ import jakarta.ws.rs.POST; import jakarta.ws.rs.Path; import jakarta.ws.rs.QueryParam; -import java.io.IOException; - @Path("/training_plan") @ApplicationScoped public class TrainingPlanApi { diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/BaseExceptionHandler.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/BaseExceptionHandler.java similarity index 96% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/BaseExceptionHandler.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/BaseExceptionHandler.java index 7b284d7..e5e1fee 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/BaseExceptionHandler.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/BaseExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json.handler; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import cn.wustlinghang.wusthelper.rpc.response.RpcResponse; diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/DefaultExceptionHandler.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/DefaultExceptionHandler.java similarity index 90% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/DefaultExceptionHandler.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/DefaultExceptionHandler.java index 47ae2c2..20d3112 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/DefaultExceptionHandler.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/DefaultExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json.handler; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import jakarta.ws.rs.core.Response; diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/IOExceptionHandler.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/IOExceptionHandler.java similarity index 90% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/IOExceptionHandler.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/IOExceptionHandler.java index 73274f1..f8e06f4 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/IOExceptionHandler.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/IOExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json.handler; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import jakarta.ws.rs.core.Response; diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/ParseExceptionHandler.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/ParseExceptionHandler.java similarity index 91% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/ParseExceptionHandler.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/ParseExceptionHandler.java index 8d15675..1bd6177 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/ParseExceptionHandler.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/ParseExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json.handler; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http.handler; import cn.wustlinghang.mywust.exception.ParseException; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/RpcExceptionHandler.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/RpcExceptionHandler.java similarity index 88% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/RpcExceptionHandler.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/RpcExceptionHandler.java index a5652b3..5760852 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/RpcExceptionHandler.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/RpcExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json.handler; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http.handler; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; import jakarta.ws.rs.core.Response; diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/ValidationExceptionHandler.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/ValidationExceptionHandler.java similarity index 91% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/ValidationExceptionHandler.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/ValidationExceptionHandler.java index a5c3e15..1e39096 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/ValidationExceptionHandler.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/ValidationExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json.handler; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http.handler; import cn.wustlinghang.wusthelper.rpc.response.ResponseCode; import jakarta.validation.ValidationException; diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/WebApplicationExceptionHandler.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/WebApplicationExceptionHandler.java similarity index 94% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/WebApplicationExceptionHandler.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/WebApplicationExceptionHandler.java index bed20bd..0a16d96 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/handler/WebApplicationExceptionHandler.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/handler/WebApplicationExceptionHandler.java @@ -1,4 +1,4 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json.handler; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http.handler; import cn.wustlinghang.wusthelper.internal.undergrad.exception.UndergradRpcException; import cn.wustlinghang.wusthelper.rpc.exception.RpcException; diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/interceptor/ResponseWrapperInterceptor.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/interceptor/ResponseWrapperInterceptor.java similarity index 91% rename from sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/interceptor/ResponseWrapperInterceptor.java rename to sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/interceptor/ResponseWrapperInterceptor.java index a6b16f4..250bc0a 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/interceptor/ResponseWrapperInterceptor.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/http/interceptor/ResponseWrapperInterceptor.java @@ -1,6 +1,6 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json.interceptor; +package cn.wustlinghang.wusthelper.internal.undergrad.api.http.interceptor; -import cn.wustlinghang.wusthelper.internal.undergrad.api.json.handler.BaseExceptionHandler; +import cn.wustlinghang.wusthelper.internal.undergrad.api.http.handler.BaseExceptionHandler; import cn.wustlinghang.wusthelper.rpc.response.RpcResponse; import com.fasterxml.jackson.databind.ObjectMapper; import jakarta.ws.rs.WebApplicationException; diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/StudentInfoApi.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/StudentInfoApi.java deleted file mode 100644 index 3e09b2b..0000000 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/api/json/StudentInfoApi.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.wustlinghang.wusthelper.internal.undergrad.api.json; - -import cn.wustlinghang.mywust.data.global.StudentInfo; -import cn.wustlinghang.mywust.exception.ApiException; -import cn.wustlinghang.mywust.exception.ParseException; -import cn.wustlinghang.wusthelper.internal.undergrad.exception.UndergradRpcException; -import cn.wustlinghang.wusthelper.internal.undergrad.services.ParseService; -import cn.wustlinghang.wusthelper.internal.undergrad.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.io.IOException; - -@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); - } -} diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/exception/UndergradRpcException.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/exception/UndergradRpcException.java index a8ed179..c40c566 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/exception/UndergradRpcException.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/exception/UndergradRpcException.java @@ -13,7 +13,7 @@ public class UndergradRpcException extends RpcException { super(UNDERGRAD_MODULE, typeCode.ordinal(), subModuleCode.ordinal() * 100 + errorCode.ordinal(), - new StringJoiner("-") + new StringJoiner("/") .add("UNDERGRAD") .add(typeCode.name()) .add(subModuleCode.name()) diff --git a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/services/LoginService.java b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/services/LoginService.java index a6d573d..c4fc1fa 100644 --- a/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/services/LoginService.java +++ b/sub-services/undergrad/src/main/java/cn/wustlinghang/wusthelper/internal/undergrad/services/LoginService.java @@ -70,7 +70,7 @@ public class LoginService { }; return new UndergradRpcException( - UndergradRpcException.TypeCode.NETWORK_EXCEPTION, + UndergradRpcException.TypeCode.AUTH_EXCEPTION, UndergradRpcException.SubModuleCode.AUTH, errorCode );