Skip to content

Commit d31172a

Browse files
committed
使用整合 apijson-router 后的 apijson-framework
1 parent ddd80b3 commit d31172a

File tree

5 files changed

+20
-24
lines changed

5 files changed

+20
-24
lines changed

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/pom.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,16 @@
6161
<artifactId>APIJSON</artifactId>
6262
<version>8.0.0.1</version>
6363
</dependency>
64-
<dependency>
65-
<groupId>com.github.APIJSON</groupId>
66-
<artifactId>apijson-framework</artifactId>
67-
<version>7.2.0.1</version>
68-
</dependency>
69-
<dependency>
70-
<groupId>com.github.APIJSON</groupId>
71-
<artifactId>apijson-router</artifactId>
72-
<version>2.2.0.1</version>
73-
</dependency>
64+
<!-- <dependency>-->
65+
<!-- <groupId>com.github.APIJSON</groupId>-->
66+
<!-- <artifactId>apijson-framework</artifactId>-->
67+
<!-- <version>7.2.0.1</version>-->
68+
<!-- </dependency>-->
69+
<!-- <dependency>-->
70+
<!-- <groupId>com.github.APIJSON</groupId>-->
71+
<!-- <artifactId>apijson-router</artifactId>-->
72+
<!-- <version>2.2.0.1</version>-->
73+
<!-- </dependency>-->
7474

7575
<!-- 7.9.0 及以下需要依赖 apijson-column -->
7676
<!-- <dependency>-->

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/boot/DemoApplication.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package apijson.boot;
1616

1717
import apijson.JSONParser;
18-
import apijson.framework.APIJSONSQLConfig;
18+
import apijson.framework.*;
1919
import com.alibaba.fastjson.JSON;
2020
import com.alibaba.fastjson.JSONArray;
2121
import com.alibaba.fastjson.JSONObject;
@@ -47,16 +47,12 @@
4747
import apijson.demo.DemoSQLConfig;
4848
import apijson.demo.DemoSQLExecutor;
4949
import apijson.demo.DemoVerifier;
50-
import apijson.framework.APIJSONApplication;
51-
import apijson.framework.APIJSONCreator;
52-
import apijson.framework.APIJSONParser;
5350
import apijson.orm.AbstractVerifier;
5451
import apijson.orm.FunctionParser;
5552
import apijson.orm.Parser;
5653
import apijson.orm.SQLConfig;
5754
import apijson.orm.SQLExecutor;
5855
import apijson.orm.Verifier;
59-
import apijson.router.APIJSONRouterApplication;
6056
//import unitauto.MethodUtil;
6157
//import unitauto.MethodUtil.Argument;
6258
//import unitauto.MethodUtil.InstanceGetter;
@@ -97,10 +93,10 @@ public static void main(String[] args) throws Exception {
9793
//unitauto.Log.DEBUG = true;
9894
Log.DEBUG = true; // 是否开启调试模式(打印详细日志、返回详细调试信息等)
9995
APIJSONParser.IS_PRINT_BIG_LOG = true; // 是否打印大日志
100-
// APIJSONParser.IS_START_FROM_1 = true; // 分页页码是否从 1 开始,true - 从 1 开始;false - 从 0 开始
101-
// APIJSONSQLConfig.ENABLE_COLUMN_CONFIG = true; // apijson-framework 已集成字段插件 apijson-column,支持 !key 反选字段 和 字段名映射
96+
APIJSONVerifier.ENABLE_APIJSON_ROUTER = true; // 是否开启 接口路由 模式,支持简单接口转为 APIJSON JSON
97+
//APIJSONParser.IS_START_FROM_1 = true; // 分页页码是否从 1 开始,true - 从 1 开始;false - 从 0 开始
98+
//APIJSONSQLConfig.ENABLE_COLUMN_CONFIG = true; // apijson-framework 已集成字段插件 apijson-column,支持 !key 反选字段 和 字段名映射
10299
APIJSONApplication.init(false);
103-
APIJSONRouterApplication.init(false);
104100
System.out.println("\n\n<<<<<<<<< 本 Demo 在 resources/static 内置了 APIAuto,Chrome/Firefox 打开 http://localhost:8080 即可调试(端口号根据项目配置而定) ^_^ >>>>>>>>>\n");
105101
}
106102

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/boot/DemoController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package apijson.boot;
1616

17+
import apijson.framework.APIJSONController;
1718
import apijson.framework.APIJSONParser;
1819
import apijson.orm.exception.*;
1920
import com.alibaba.fastjson.JSONArray;
@@ -59,7 +60,6 @@
5960
import apijson.demo.model.Verify;
6061
import apijson.framework.BaseModel;
6162
import apijson.orm.JSONRequest;
62-
import apijson.router.APIJSONRouterController;
6363
import unitauto.MethodUtil;
6464

6565
import static apijson.JSON.getString;
@@ -97,7 +97,7 @@
9797
@Service
9898
@RestController
9999
@RequestMapping("")
100-
public class DemoController extends APIJSONRouterController<Long, JSONObject, JSONArray> { // APIJSONController<Long, JSONObject, JSONArray> {
100+
public class DemoController extends APIJSONController<Long, JSONObject, JSONArray> {
101101
private static final String TAG = "DemoController";
102102

103103
public String getRequestBaseURL() {

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/demo/DemoParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,12 @@ public APIJSONObjectParser<Long, JSONObject, JSONArray> createObjectParser(JSONO
127127
private String dbPassword;
128128
@Override
129129
public APIJSONParser<Long, JSONObject, JSONArray> setSession(HttpSession session) {
130-
Boolean asDBAccount = (Boolean) session.getAttribute(DemoController.AS_DB_ACCOUNT);
130+
Boolean asDBAccount = session == null ? null : (Boolean) session.getAttribute(DemoController.AS_DB_ACCOUNT);
131131
this.asDBAccount = asDBAccount != null && asDBAccount;
132132
if (this.asDBAccount) {
133133
// User user = (User) session.getAttribute(DemoController.USER_);
134134
// this.dbAccount = user.getName();
135-
Privacy privacy = (Privacy) session.getAttribute(DemoController.PRIVACY_);
135+
Privacy privacy = session == null ? null : (Privacy) session.getAttribute(DemoController.PRIVACY_);
136136
this.dbAccount = privacy.getPhone();
137137
this.dbPassword = privacy.get__password();
138138
}

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/demo/DemoVerifier.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
package apijson.demo;
1616

17-
import apijson.router.APIJSONRouterVerifier;
17+
import apijson.framework.APIJSONVerifier;
1818
import com.alibaba.fastjson.JSONArray;
1919
import com.alibaba.fastjson.JSONObject;
2020

@@ -25,7 +25,7 @@
2525
* 具体见 https://github.com/Tencent/APIJSON/issues/12
2626
* @author Lemon
2727
*/
28-
public class DemoVerifier extends APIJSONRouterVerifier<Long, JSONObject, JSONArray> { // APIJSONVerifier<Long, JSONObject, JSONArray> {
28+
public class DemoVerifier extends APIJSONVerifier<Long, JSONObject, JSONArray> {
2929
public static final String TAG = "DemoVerifier";
3030

3131
static {

0 commit comments

Comments
 (0)