parent
4777fc11eb
commit
26aaad57cc
@ -0,0 +1,7 @@ |
||||
package cn.wustlinghang.wusthelper.rpc.util; |
||||
|
||||
public class EnumUtil { |
||||
public static <E extends Enum<E>> boolean equal(int value, Enum<E> e) { |
||||
return e.ordinal() == value; |
||||
} |
||||
} |
@ -0,0 +1,93 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
||||
<artifactId>graduate</artifactId> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-resteasy-reactive-jackson</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-hibernate-validator</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-resteasy-reactive</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-arc</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.wustlinghang.mywust</groupId> |
||||
<artifactId>mywust-core</artifactId> |
||||
<version>0.0.2-SNAPSHOT</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.wustlinghang.mywust</groupId> |
||||
<artifactId>mywust-network-okhttp</artifactId> |
||||
<version>0.0.2-SNAPSHOT</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
||||
<artifactId>common</artifactId> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>jakarta.annotation</groupId> |
||||
<artifactId>jakarta.annotation-api</artifactId> |
||||
<version>2.1.1</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>javax.annotation</groupId> |
||||
<artifactId>javax.annotation-api</artifactId> |
||||
<version>1.3.2</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
<version>1.18.26</version> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
<repositories> |
||||
<repository> |
||||
<id>central</id> |
||||
<url>https://repo1.maven.org/maven2</url> |
||||
</repository> |
||||
<repository> |
||||
<snapshots> |
||||
<enabled>true</enabled> |
||||
</snapshots> |
||||
<id>github</id> |
||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
||||
</repository> |
||||
</repositories> |
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>io.quarkus.platform</groupId> |
||||
<artifactId>quarkus-maven-plugin</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<extensions>true</extensions> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
</project> |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -0,0 +1,93 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
||||
<artifactId>library</artifactId> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-resteasy-reactive-jackson</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-hibernate-validator</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-resteasy-reactive</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-arc</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.wustlinghang.mywust</groupId> |
||||
<artifactId>mywust-core</artifactId> |
||||
<version>0.0.2-SNAPSHOT</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.wustlinghang.mywust</groupId> |
||||
<artifactId>mywust-network-okhttp</artifactId> |
||||
<version>0.0.2-SNAPSHOT</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
||||
<artifactId>common</artifactId> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>jakarta.annotation</groupId> |
||||
<artifactId>jakarta.annotation-api</artifactId> |
||||
<version>2.1.1</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>javax.annotation</groupId> |
||||
<artifactId>javax.annotation-api</artifactId> |
||||
<version>1.3.2</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
<version>1.18.26</version> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
<repositories> |
||||
<repository> |
||||
<id>central</id> |
||||
<url>https://repo1.maven.org/maven2</url> |
||||
</repository> |
||||
<repository> |
||||
<snapshots> |
||||
<enabled>true</enabled> |
||||
</snapshots> |
||||
<id>github</id> |
||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
||||
</repository> |
||||
</repositories> |
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>io.quarkus.platform</groupId> |
||||
<artifactId>quarkus-maven-plugin</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<extensions>true</extensions> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
</project> |
@ -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<Score> 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<Score> parse(String html) throws RpcException { |
||||
// return parseService.parseScore(html);
|
||||
return null; |
||||
} |
||||
} |
@ -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<Score> 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<Score> parse(String html) throws RpcException { |
||||
// return parseService.parseScore(html);
|
||||
return null; |
||||
} |
||||
} |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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<Score> parse(String html) throws RpcException { |
||||
throw RpcException.ApiNotImplement(); |
||||
} |
||||
} |
@ -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<ExamDelayApplication> get( |
||||
@QueryParam("cookie") @NotNull String cookie, |
||||
@QueryParam("term") @NotNull String term, |
||||
@QueryParam("activity_id") @NotNull String activityId) |
||||
throws RpcException { |
||||
return this.parse(this.agent(cookie, term, activityId)); |
||||
} |
||||
|
||||
@GET |
||||
@Path("/agent") |
||||
public String agent(@QueryParam("cookie") @NotNull String cookie, |
||||
@QueryParam("term") @NotNull String term, |
||||
@QueryParam("activity_id") @NotNull String activityId) |
||||
throws RpcException { |
||||
return agentService.getExamDelayApplications(cookie, term, activityId); |
||||
} |
||||
|
||||
@POST |
||||
@Path("/parse") |
||||
public List<ExamDelayApplication> parse(String html) throws RpcException { |
||||
return parseService.parseExamDelayApplications(html); |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
@ -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<Course> 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<Score> 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<ExamDelayApplication> 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 |
||||
); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,93 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
||||
<artifactId>physics</artifactId> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-resteasy-reactive-jackson</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-hibernate-validator</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-resteasy-reactive</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-arc</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.wustlinghang.mywust</groupId> |
||||
<artifactId>mywust-core</artifactId> |
||||
<version>0.0.2-SNAPSHOT</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.wustlinghang.mywust</groupId> |
||||
<artifactId>mywust-network-okhttp</artifactId> |
||||
<version>0.0.2-SNAPSHOT</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
||||
<artifactId>common</artifactId> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>jakarta.annotation</groupId> |
||||
<artifactId>jakarta.annotation-api</artifactId> |
||||
<version>2.1.1</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>javax.annotation</groupId> |
||||
<artifactId>javax.annotation-api</artifactId> |
||||
<version>1.3.2</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
<version>1.18.26</version> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
<repositories> |
||||
<repository> |
||||
<id>central</id> |
||||
<url>https://repo1.maven.org/maven2</url> |
||||
</repository> |
||||
<repository> |
||||
<snapshots> |
||||
<enabled>true</enabled> |
||||
</snapshots> |
||||
<id>github</id> |
||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
||||
</repository> |
||||
</repositories> |
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>io.quarkus.platform</groupId> |
||||
<artifactId>quarkus-maven-plugin</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<extensions>true</extensions> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
</project> |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -0,0 +1,93 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
||||
<artifactId>undergrad</artifactId> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-resteasy-reactive-jackson</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-hibernate-validator</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-resteasy-reactive</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>io.quarkus</groupId> |
||||
<artifactId>quarkus-arc</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.wustlinghang.mywust</groupId> |
||||
<artifactId>mywust-core</artifactId> |
||||
<version>0.0.2-SNAPSHOT</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.wustlinghang.mywust</groupId> |
||||
<artifactId>mywust-network-okhttp</artifactId> |
||||
<version>0.0.2-SNAPSHOT</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>cn.wustlinghang.wusthelper</groupId> |
||||
<artifactId>common</artifactId> |
||||
<version>0.0.1-SNAPSHOT</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>jakarta.annotation</groupId> |
||||
<artifactId>jakarta.annotation-api</artifactId> |
||||
<version>2.1.1</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>javax.annotation</groupId> |
||||
<artifactId>javax.annotation-api</artifactId> |
||||
<version>1.3.2</version> |
||||
<scope>compile</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.projectlombok</groupId> |
||||
<artifactId>lombok</artifactId> |
||||
<version>1.18.26</version> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
</dependencies> |
||||
<repositories> |
||||
<repository> |
||||
<id>central</id> |
||||
<url>https://repo1.maven.org/maven2</url> |
||||
</repository> |
||||
<repository> |
||||
<snapshots> |
||||
<enabled>true</enabled> |
||||
</snapshots> |
||||
<id>github</id> |
||||
<url>https://maven.pkg.github.com/LingHangStudio/mywust</url> |
||||
</repository> |
||||
</repositories> |
||||
<build> |
||||
<plugins> |
||||
<plugin> |
||||
<groupId>io.quarkus.platform</groupId> |
||||
<artifactId>quarkus-maven-plugin</artifactId> |
||||
<version>3.1.3.Final</version> |
||||
<extensions>true</extensions> |
||||
</plugin> |
||||
</plugins> |
||||
</build> |
||||
</project> |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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; |
@ -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); |
||||
} |
||||
} |
Loading…
Reference in new issue