Skip to content

Commit 839fb14

Browse files
author
magiclu550
committed
[JSMOD@2_482_COMMIT] web api
1 parent 9a50d8e commit 839fb14

9 files changed

Lines changed: 307 additions & 13 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"Server":{
3+
"get":"Map",
4+
"values":[{"0":"UN"}],
5+
"Map":{
6+
"name":"12"
7+
}
8+
}
9+
}

JSMod2Starter/target/classes/ini.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ org=jsmod2-java-c
1111
github.name=jsmod2
1212
github.password=85027859yhn*
1313

14-
jsmod2.about=Java Server Mod 2[BETA1.0] NoyarkGroup&JSMod2CN GITHUB_OPEN Build[000]
14+
jsmod2.about=Java Server Mod 2[BETA1.0] NoyarkGroup&JSMod2CN GITHUB_OPEN Build[001]

JSMod2Web/JSMod2Web.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,6 @@
9393
<orderEntry type="library" name="Maven: org.springframework:spring-core:5.1.8.RELEASE" level="project" />
9494
<orderEntry type="library" scope="TEST" name="Maven: org.springframework:spring-test:5.1.8.RELEASE" level="project" />
9595
<orderEntry type="library" scope="TEST" name="Maven: org.xmlunit:xmlunit-core:2.6.2" level="project" />
96+
<orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.47" level="project" />
9697
</component>
9798
</module>

JSMod2Web/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
<artifactId>spring-boot-starter-test</artifactId>
5656
<scope>test</scope>
5757
</dependency>
58+
<dependency>
59+
<groupId>com.alibaba</groupId>
60+
<artifactId>fastjson</artifactId>
61+
<version>1.2.47</version>
62+
</dependency>
5863
</dependencies>
5964

6065
<repositories>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package cn.jsmod2;
2+
3+
import java.lang.reflect.Method;
4+
import java.util.List;
5+
6+
public class MethodInvoker {
7+
8+
private List<Object> objVals;
9+
10+
private Method method;
11+
12+
public MethodInvoker(List<Object> objVals, Method method) {
13+
this.objVals = objVals;
14+
this.method = method;
15+
}
16+
17+
public List<Object> getObjVals() {
18+
return objVals;
19+
}
20+
21+
public void setObjVals(List<Object> objVals) {
22+
this.objVals = objVals;
23+
}
24+
25+
public Method getMethod() {
26+
return method;
27+
}
28+
29+
public void setMethod(Method method) {
30+
this.method = method;
31+
}
32+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package cn.jsmod2;
2+
3+
public class ResponseValue<T> {
4+
5+
private String message;
6+
7+
private T responseValue;
8+
9+
private int state;
10+
11+
public ResponseValue(String message, T responseValue, int state) {
12+
this.message = message;
13+
this.responseValue = responseValue;
14+
this.state = state;
15+
}
16+
17+
public String getMessage() {
18+
return message;
19+
}
20+
21+
public void setMessage(String message) {
22+
this.message = message;
23+
}
24+
25+
public T getResponseValue() {
26+
return responseValue;
27+
}
28+
29+
public void setResponseValue(T responseValue) {
30+
this.responseValue = responseValue;
31+
}
32+
33+
public int getState() {
34+
return state;
35+
}
36+
37+
public void setState(int state) {
38+
this.state = state;
39+
}
40+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package cn.jsmod2.ex;
2+
3+
import cn.jsmod2.core.ex.ServerRuntimeException;
4+
5+
public class ApiErrorException extends ServerRuntimeException {
6+
7+
public ApiErrorException() {
8+
}
9+
10+
public ApiErrorException(String message) {
11+
super(message);
12+
}
13+
14+
public ApiErrorException(String message, Throwable cause) {
15+
super(message, cause);
16+
}
17+
18+
public ApiErrorException(Throwable cause) {
19+
super(cause);
20+
}
21+
22+
public ApiErrorException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
23+
super(message, cause, enableSuppression, writableStackTrace);
24+
}
25+
}

JSMod2Web/src/main/java/cn/jsmod2/web/PanelController.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package cn.jsmod2.web;
22

3+
import cn.jsmod2.ResponseValue;
4+
import cn.jsmod2.core.ex.ServerRuntimeException;
35
import org.springframework.beans.factory.annotation.Autowired;
6+
import org.springframework.web.bind.annotation.ExceptionHandler;
47
import org.springframework.web.bind.annotation.PathVariable;
58
import org.springframework.web.bind.annotation.RequestMapping;
69
import org.springframework.web.bind.annotation.RestController;
@@ -17,6 +20,16 @@ public Object api(@PathVariable("message") String message){
1720
return o;
1821
}
1922

23+
@RequestMapping("/multi/{message}")
24+
public Object multiApi(@PathVariable("message")String message){
25+
try{
26+
return new ResponseValue<>("success",service.multiApi(message),200);
27+
}catch (Exception e){
28+
return new ResponseValue<>(e.getMessage(),e,500);
29+
}
30+
31+
}
32+
2033
@RequestMapping("/api")
2134
public Object apiParam(String message){
2235
return service.api(message);

0 commit comments

Comments
 (0)