From df94056f1297437a9b27b76095a81075e355a558 Mon Sep 17 00:00:00 2001 From: TommyLemon <1184482681@qq.com> Date: Sat, 3 Feb 2018 22:56:34 +0800 Subject: [PATCH] =?UTF-8?q?Server:=E5=88=A0=E9=99=A41.9.0=E7=9A=84?= =?UTF-8?q?=E5=A4=87=E4=BB=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../APIJSON-Eclipse1.9.0/.gitignore | 24 - .../.mvn/wrapper/maven-wrapper.jar | Bin 49502 -> 0 bytes .../.mvn/wrapper/maven-wrapper.properties | 1 - .../APIJSON-Eclipse1.9.0/.travis.yml | 4 - .../WebContent/META-INF/MANIFEST.MF | 3 - .../WebContent/WEB-INF/web.xml | 3 - .../APIJSON-Eclipse1.9.0/apijson.eml | 75 - .../apijson.userlibraries | 148 -- APIJSON-Java-Server/APIJSON-Eclipse1.9.0/mvnw | 233 --- .../APIJSON-Eclipse1.9.0/mvnw.cmd | 145 -- .../APIJSON-Eclipse1.9.0/pom.xml | 89 -- .../demo/server/APIJSONApplication.java | 82 - .../java/apijson/demo/server/Controller.java | 878 ----------- .../java/apijson/demo/server/Function.java | 295 ---- .../apijson/demo/server/FunctionList.java | 143 -- .../java/apijson/demo/server/Verifier.java | 344 ----- .../apijson/demo/server/model/BaseModel.java | 304 ---- .../apijson/demo/server/model/Comment.java | 24 - .../java/apijson/demo/server/model/Login.java | 62 - .../apijson/demo/server/model/Moment.java | 32 - .../apijson/demo/server/model/Privacy.java | 99 -- .../java/apijson/demo/server/model/User.java | 102 -- .../apijson/demo/server/model/Verify.java | 88 -- .../demo/server/model/package-info.java | 26 - .../apijson/demo/server/package-info.java | 8 - .../src/main/java/zuo/biao/apijson/JSON.java | 276 ---- .../java/zuo/biao/apijson/JSONObject.java | 374 ----- .../java/zuo/biao/apijson/JSONRequest.java | 147 -- .../java/zuo/biao/apijson/JSONResponse.java | 400 ----- .../src/main/java/zuo/biao/apijson/Log.java | 74 - .../java/zuo/biao/apijson/MethodAccess.java | 73 - .../zuo/biao/apijson/MethodStructure.java | 58 - .../java/zuo/biao/apijson/RequestMethod.java | 94 -- .../java/zuo/biao/apijson/RequestRole.java | 63 - .../src/main/java/zuo/biao/apijson/SQL.java | 389 ----- .../java/zuo/biao/apijson/StringUtil.java | 842 ----------- .../java/zuo/biao/apijson/model/Column.java | 30 - .../java/zuo/biao/apijson/model/Document.java | 30 - .../java/zuo/biao/apijson/model/Request.java | 28 - .../java/zuo/biao/apijson/model/Response.java | 28 - .../java/zuo/biao/apijson/model/Table.java | 30 - .../java/zuo/biao/apijson/model/Test.java | 28 - .../zuo/biao/apijson/model/package-info.java | 8 - .../java/zuo/biao/apijson/package-info.java | 22 - .../java/zuo/biao/apijson/server/Entry.java | 59 - .../zuo/biao/apijson/server/JSONRequest.java | 102 -- .../java/zuo/biao/apijson/server/Logic.java | 145 -- .../zuo/biao/apijson/server/ObjectParser.java | 678 --------- .../biao/apijson/server/OnParseCallback.java | 70 - .../zuo/biao/apijson/server/Operation.java | 68 - .../java/zuo/biao/apijson/server/Pair.java | 159 -- .../java/zuo/biao/apijson/server/Parser.java | 904 ----------- .../biao/apijson/server/ParserAdapter.java | 59 - .../zuo/biao/apijson/server/Structure.java | 600 -------- .../exception/ConditionErrorException.java | 33 - .../server/exception/ConflictException.java | 33 - .../server/exception/NotExistException.java | 34 - .../exception/NotLoggedInException.java | 33 - .../server/exception/OutOfRangeException.java | 33 - .../server/exception/package-info.java | 22 - .../zuo/biao/apijson/server/package-info.java | 22 - .../biao/apijson/server/sql/SQLConfig.java | 1324 ----------------- .../biao/apijson/server/sql/SQLExecutor.java | 292 ---- .../biao/apijson/server/sql/package-info.java | 22 - .../src/main/resources/application.properties | 0 .../biao/apijson/server/ApplicationTests.java | 17 - .../APIJSON-Idea1.9.0/.gitignore | 24 - .../.mvn/wrapper/maven-wrapper.jar | Bin 49502 -> 0 bytes .../.mvn/wrapper/maven-wrapper.properties | 1 - .../APIJSON-Idea1.9.0/.travis.yml | 4 - APIJSON-Java-Server/APIJSON-Idea1.9.0/mvnw | 233 --- .../APIJSON-Idea1.9.0/mvnw.cmd | 145 -- APIJSON-Java-Server/APIJSON-Idea1.9.0/pom.xml | 89 -- .../demo/server/APIJSONApplication.java | 82 - .../java/apijson/demo/server/Controller.java | 878 ----------- .../java/apijson/demo/server/Function.java | 295 ---- .../apijson/demo/server/FunctionList.java | 143 -- .../java/apijson/demo/server/Verifier.java | 344 ----- .../apijson/demo/server/model/BaseModel.java | 304 ---- .../apijson/demo/server/model/Comment.java | 24 - .../java/apijson/demo/server/model/Login.java | 62 - .../apijson/demo/server/model/Moment.java | 32 - .../apijson/demo/server/model/Privacy.java | 99 -- .../java/apijson/demo/server/model/User.java | 102 -- .../apijson/demo/server/model/Verify.java | 88 -- .../demo/server/model/package-info.java | 26 - .../apijson/demo/server/package-info.java | 8 - .../src/main/java/zuo/biao/apijson/JSON.java | 276 ---- .../java/zuo/biao/apijson/JSONObject.java | 374 ----- .../java/zuo/biao/apijson/JSONRequest.java | 147 -- .../java/zuo/biao/apijson/JSONResponse.java | 400 ----- .../src/main/java/zuo/biao/apijson/Log.java | 74 - .../java/zuo/biao/apijson/MethodAccess.java | 73 - .../zuo/biao/apijson/MethodStructure.java | 58 - .../java/zuo/biao/apijson/RequestMethod.java | 94 -- .../java/zuo/biao/apijson/RequestRole.java | 63 - .../src/main/java/zuo/biao/apijson/SQL.java | 389 ----- .../java/zuo/biao/apijson/StringUtil.java | 842 ----------- .../java/zuo/biao/apijson/model/Column.java | 30 - .../java/zuo/biao/apijson/model/Document.java | 30 - .../java/zuo/biao/apijson/model/Request.java | 28 - .../java/zuo/biao/apijson/model/Response.java | 28 - .../java/zuo/biao/apijson/model/Table.java | 30 - .../java/zuo/biao/apijson/model/Test.java | 28 - .../zuo/biao/apijson/model/package-info.java | 8 - .../java/zuo/biao/apijson/package-info.java | 22 - .../java/zuo/biao/apijson/server/Entry.java | 59 - .../zuo/biao/apijson/server/JSONRequest.java | 102 -- .../java/zuo/biao/apijson/server/Logic.java | 145 -- .../zuo/biao/apijson/server/ObjectParser.java | 678 --------- .../biao/apijson/server/OnParseCallback.java | 70 - .../zuo/biao/apijson/server/Operation.java | 68 - .../java/zuo/biao/apijson/server/Pair.java | 159 -- .../java/zuo/biao/apijson/server/Parser.java | 904 ----------- .../biao/apijson/server/ParserAdapter.java | 59 - .../zuo/biao/apijson/server/Structure.java | 600 -------- .../exception/ConditionErrorException.java | 33 - .../server/exception/ConflictException.java | 33 - .../server/exception/NotExistException.java | 34 - .../exception/NotLoggedInException.java | 33 - .../server/exception/OutOfRangeException.java | 33 - .../server/exception/package-info.java | 22 - .../zuo/biao/apijson/server/package-info.java | 22 - .../biao/apijson/server/sql/SQLConfig.java | 1324 ----------------- .../biao/apijson/server/sql/SQLExecutor.java | 292 ---- .../biao/apijson/server/sql/package-info.java | 22 - .../src/main/resources/application.properties | 0 .../biao/apijson/server/ApplicationTests.java | 17 - 128 files changed, 21601 deletions(-) delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.gitignore delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.mvn/wrapper/maven-wrapper.jar delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.mvn/wrapper/maven-wrapper.properties delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.travis.yml delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/WebContent/META-INF/MANIFEST.MF delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/WebContent/WEB-INF/web.xml delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/apijson.eml delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/apijson.userlibraries delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/mvnw delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/mvnw.cmd delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/pom.xml delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/APIJSONApplication.java delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/Controller.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/Function.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/FunctionList.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/Verifier.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/BaseModel.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Comment.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Login.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Moment.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Privacy.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/User.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Verify.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/package-info.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/package-info.java delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSON.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSONObject.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSONRequest.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSONResponse.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/Log.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/MethodAccess.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/MethodStructure.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/RequestMethod.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/RequestRole.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/SQL.java delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/StringUtil.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Column.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Document.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Request.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Response.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Table.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Test.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/package-info.java delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/package-info.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Entry.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/JSONRequest.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Logic.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/ObjectParser.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/OnParseCallback.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Operation.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Pair.java delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Parser.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/ParserAdapter.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Structure.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConditionErrorException.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConflictException.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotExistException.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotLoggedInException.java delete mode 100644 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/OutOfRangeException.java delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/package-info.java delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/package-info.java delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLConfig.java delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLExecutor.java delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/sql/package-info.java delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/resources/application.properties delete mode 100755 APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/test/java/zuo/biao/apijson/server/ApplicationTests.java delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/.gitignore delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/.mvn/wrapper/maven-wrapper.jar delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/.mvn/wrapper/maven-wrapper.properties delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/.travis.yml delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/mvnw delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/mvnw.cmd delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/pom.xml delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/APIJSONApplication.java delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/Controller.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/Function.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/FunctionList.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/Verifier.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/BaseModel.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Comment.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Login.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Moment.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Privacy.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/User.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Verify.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/package-info.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/package-info.java delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSON.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSONObject.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSONRequest.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSONResponse.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/Log.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/MethodAccess.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/MethodStructure.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/RequestMethod.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/RequestRole.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/SQL.java delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/StringUtil.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Column.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Document.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Request.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Response.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Table.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Test.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/package-info.java delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/package-info.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Entry.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/JSONRequest.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Logic.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/ObjectParser.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/OnParseCallback.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Operation.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Pair.java delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Parser.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/ParserAdapter.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Structure.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConditionErrorException.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConflictException.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotExistException.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotLoggedInException.java delete mode 100644 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/OutOfRangeException.java delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/package-info.java delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/package-info.java delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLConfig.java delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLExecutor.java delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/sql/package-info.java delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/resources/application.properties delete mode 100755 APIJSON-Java-Server/APIJSON-Idea1.9.0/src/test/java/zuo/biao/apijson/server/ApplicationTests.java diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.gitignore b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.gitignore deleted file mode 100755 index 2af7cefb0..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -nbproject/private/ -build/ -nbbuild/ -dist/ -nbdist/ -.nb-gradle/ \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.mvn/wrapper/maven-wrapper.jar b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.mvn/wrapper/maven-wrapper.jar deleted file mode 100755 index 5fd4d5023f1463b5ba3970e33c460c1eb26d748d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49502 zcmb@tV|1n6wzeBvGe*U>ZQHh;%-Bg)Y}={WHY%yuwkkF%MnzxVwRUS~wY|@J_gP;% z^VfXZ{5793?z><89(^dufT2xlYVOQnYG>@?lA@vQF|UF0&X7tk8BUf?wq2J& zZe&>>paKUg4@;fwk0yeUPvM$yk)=f>TSFFB^a8f|_@mbE#MaBnd5qf6;hXq}c%IeK zn7gB0Kldbedq-vl@2wxJi{$%lufroKUjQLSFmt|<;M8~<5otM5ur#Dgc@ivmwRiYZW(Oco7kb8DWmo|a{coqYMU2raB9r6e9viK6MI3c&%jp05-Tf*O#6@8Ra=egYy01 z-V!G;_omANEvU-8!*>*)lWka9M<+IkNsrsenbXOfLc6qrYe`;lpst;vfs*70$z9UM zq%L>pFCOr$X*|9&3L2h;?VA9-IU*iR6FiGlJ=b~DzE5s^thxXUs4%~*zD#K&k>wZAU8 zpaa!M+Z-zjkfGK15N!&o<3=cgbZV7%ex@j^)Q9V`q^i;Fsbkbe6eHJ;dx{QbdCCs1 zdxq^WxoPsr`eiK3D0Ep}k$ank-0G&+lY!ZHDZBYEx%% z2FyE?Lb0cflLB)kDIj;G=m`^UO<4h(RWdF-DT>p{1J5J90!K!AgC0)?jxPbm$KUjg zJED+#7xQmAmr`(S%BQTV-c97As~r3zD$E;3S)@}p5udA@m6pLgRL5h-;m>LvCq?&Q zokC7Vnk-zBEaa;=Y;6(LJHS>mOJV&%0YfRdU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)_mC$8U`F#qlHOCD&RSroexT?YJLzvne^0W z@;=|QRR6AVW@n3W0fEJOGM5gbEhzW#FFa{0FL+k>kgt~r3DnajgxZvn2mk*LWvgsJNdYFw~S!X4cFe+Q;Q-_W%N z9+%cg5D+rIfU$v>NB;`!-|$Y|w(+s#2VpgER|yU}|IL~d1DHEF1OAnnMj?dmwqP?|!Tm)27hExl-^LX;b^(CT z!UODGtX!?!0czl=9(xOLEjt>6{g40iN!)JVBc;&q!{D7LBTNX0>kPC%g@yXJ??CR3 z^oF;AH}dO}OTni1fx&;Ra!+t5|8G{gf|ZL4*w`O!41NfJAE&N>zi#R(&V#)+FzyN% z_g90{z|?BLiTfv@hp{u@$1u7B_-1N#iJ#RBzM2BR!2c8QKQ->n9NpJB+kXlz_@(`y zApg-W%GVs=-$=u6Jp_Mfr34rf;5=qxnT`lG`0>Z&B#n)_ODW`1+jPPicN} zhgOBZJau)7R=(j9e&@_!Y{d>iX#+|6|i>`&Q={(}Kji+O zpFcjFOMd9Ss|3O?C362PVeDvZY6)PztKhZE=cg?HTJXn${I25H4xgVwR(eM*+@Z8Irh^0H1^@(vM%fLB8x9<0IcS*cf20Th OJOEd-=rxTO#Qy`$*1Hh^ diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.mvn/wrapper/maven-wrapper.properties b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.mvn/wrapper/maven-wrapper.properties deleted file mode 100755 index c954cec91..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1 +0,0 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.travis.yml b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.travis.yml deleted file mode 100755 index d036b68c1..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: java -sudo: false -jdk: - - oraclejdk7 \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/WebContent/META-INF/MANIFEST.MF b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/WebContent/META-INF/MANIFEST.MF deleted file mode 100755 index 5e9495128..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/WebContent/META-INF/MANIFEST.MF +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -Class-Path: - diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/WebContent/WEB-INF/web.xml b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/WebContent/WEB-INF/web.xml deleted file mode 100755 index adb90bb16..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/WebContent/WEB-INF/web.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/apijson.eml b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/apijson.eml deleted file mode 100755 index c9bcaf1c5..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/apijson.eml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/apijson.userlibraries b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/apijson.userlibraries deleted file mode 100755 index 1f093e3b1..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/apijson.userlibraries +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/mvnw b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/mvnw deleted file mode 100755 index a1ba1bf55..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/mvnw +++ /dev/null @@ -1,233 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # - # Look for the Apple JDKs first to preserve the existing behaviour, and then look - # for the new JDKs provided by Oracle. - # - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then - # - # Oracle JDKs - # - export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then - # - # Apple JDKs - # - export JAVA_HOME=`/usr/libexec/java_home` - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Migwn, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` -fi - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - local basedir=$(pwd) - local wdir=$(pwd) - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - wdir=$(cd "$wdir/.."; pwd) - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} "$@" diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/mvnw.cmd b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/mvnw.cmd deleted file mode 100755 index 2b934e89d..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/mvnw.cmd +++ /dev/null @@ -1,145 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -set MAVEN_CMD_LINE_ARGS=%* - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/pom.xml b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/pom.xml deleted file mode 100755 index 95b801dc2..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - 4.0.0 - - zuo.biao.apijson.server - apijson - 0.0.1-SNAPSHOT - jar - - APIJSON - APIJSON Server project using Spring Boot - - - org.springframework.boot - spring-boot-starter-parent - 1.4.1.RELEASE - - - - - UTF-8 - UTF-8 - 1.7 - - - - - mysql - mysql-connector-java - 5.1.40 - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.boot - spring-boot-starter-web - - - - com.alibaba - fastjson - 1.2.21 - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - - - spring-snapshots - http://repo.spring.io/snapshot - true - - - spring-milestones - http://repo.spring.io/milestone - true - - - - - spring-snapshots - http://repo.spring.io/snapshot - - - spring-milestones - http://repo.spring.io/milestone - - - - diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/APIJSONApplication.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/APIJSONApplication.java deleted file mode 100755 index 5a275143d..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/APIJSONApplication.java +++ /dev/null @@ -1,82 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.web.cors.CorsConfiguration; -import org.springframework.web.cors.UrlBasedCorsConfigurationSource; -import org.springframework.web.filter.CorsFilter; - -import zuo.biao.apijson.server.Structure; - -/**application - * @author Lemon - */ -@SpringBootApplication -public class APIJSONApplication { - - public static void main(String[] args) throws Exception { - SpringApplication.run(APIJSONApplication.class, args); - - System.out.println("\n\n\n\n\n<<<<<<<<<<<<<<<<<<<<<<<<< APIJSON >>>>>>>>>>>>>>>>>>>>>>>>\n"); - System.out.println("开始测试:远程函数 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); - try { - Function.test(); - } catch (Exception e) { - e.printStackTrace(); - } - System.out.println("\n完成测试:远程函数 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - - - System.out.println("\n\n\n开始测试:请求校验 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); - try { - Structure.test(); - } catch (Exception e) { - e.printStackTrace(); - } - System.out.println("\n完成测试:请求校验 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - - System.out.println("\n\n<<<<<<<<<<<<<<<<<<<<<<<<< APIJSON已启动 >>>>>>>>>>>>>>>>>>>>>>>>\n"); - } - - - - //支持JavaScript跨域请求<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /** - * 跨域过滤器 - * @return - */ - @Bean - public CorsFilter corsFilter() { - UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); - source.registerCorsConfiguration("/**", buildConfig()); - return new CorsFilter(source); - } - /**CORS跨域配置 - * @return - */ - private CorsConfiguration buildConfig() { - CorsConfiguration corsConfiguration = new CorsConfiguration(); - corsConfiguration.addAllowedOrigin("*"); //允许的域名或IP地址 - corsConfiguration.addAllowedHeader("*"); //允许的请求头 - corsConfiguration.addAllowedMethod("*"); //允许的HTTP请求方法 - corsConfiguration.setAllowCredentials(true); //允许发送跨域凭据,前端Axios存取JSESSIONID必须要 - return corsConfiguration; - } - //支持JavaScript跨域请求 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/Controller.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/Controller.java deleted file mode 100755 index 7bf484f58..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/Controller.java +++ /dev/null @@ -1,878 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server; - -import static zuo.biao.apijson.RequestMethod.DELETE; -import static zuo.biao.apijson.RequestMethod.GET; -import static zuo.biao.apijson.RequestMethod.GETS; -import static zuo.biao.apijson.RequestMethod.HEAD; -import static zuo.biao.apijson.RequestMethod.HEADS; -import static zuo.biao.apijson.RequestMethod.POST; -import static zuo.biao.apijson.RequestMethod.PUT; - -import java.net.URLDecoder; -import java.util.Random; -import java.util.concurrent.TimeoutException; - -import javax.servlet.http.HttpSession; - -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.alibaba.fastjson.JSONObject; - -import apijson.demo.server.model.BaseModel; -import apijson.demo.server.model.Comment; -import apijson.demo.server.model.Moment; -import apijson.demo.server.model.Privacy; -import apijson.demo.server.model.User; -import apijson.demo.server.model.Verify; -import zuo.biao.apijson.JSON; -import zuo.biao.apijson.JSONResponse; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.RequestMethod; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.server.JSONRequest; -import zuo.biao.apijson.server.Parser; -import zuo.biao.apijson.server.exception.ConditionErrorException; -import zuo.biao.apijson.server.exception.ConflictException; -import zuo.biao.apijson.server.exception.NotExistException; -import zuo.biao.apijson.server.exception.OutOfRangeException; - -/**request controller - *
建议全通过HTTP POST来请求: - *
1.减少代码 - 客户端无需写HTTP GET,PUT等各种方式的请求代码 - *
2.提高性能 - 无需URL encode和decode - *
3.调试方便 - 建议使用 APIJSON在线测试工具 或 Postman - * @author Lemon - */ -@RestController -@RequestMapping("") -public class Controller { - private static final String TAG = "Controller"; - - //通用接口,非事务型操作 和 简单事务型操作 都可通过这些接口自动化实现<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - - /**获取 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#GET} - */ - @PostMapping(value = "get") - public String get(@RequestBody String request, HttpSession session) { - return new Parser(GET).setSession(session).parse(request); - } - - /**计数 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#HEAD} - */ - @PostMapping("head") - public String head(@RequestBody String request, HttpSession session) { - return new Parser(HEAD).setSession(session).parse(request); - } - - /**限制性GET,request和response都非明文,浏览器看不到,用于对安全性要求高的GET请求 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#GETS} - */ - @PostMapping("gets") - public String gets(@RequestBody String request, HttpSession session) { - return new Parser(GETS).setSession(session).parse(request); - } - - /**限制性HEAD,request和response都非明文,浏览器看不到,用于对安全性要求高的HEAD请求 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#HEADS} - */ - @PostMapping("heads") - public String heads(@RequestBody String request, HttpSession session) { - return new Parser(HEADS).setSession(session).parse(request); - } - - /**新增 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#POST} - */ - @PostMapping("post") - public String post(@RequestBody String request, HttpSession session) { - return new Parser(POST).setSession(session).parse(request); - } - - /**修改 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#PUT} - */ - @PostMapping("put") - public String put(@RequestBody String request, HttpSession session) { - return new Parser(PUT).setSession(session).parse(request); - } - - /**删除 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#DELETE} - */ - @PostMapping("delete") - public String delete(@RequestBody String request, HttpSession session) { - return new Parser(DELETE).setSession(session).parse(request); - } - - - - - - /**获取 - * 只为兼容HTTP GET请求,推荐用HTTP POST,可删除 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#GET} - */ - @RequestMapping("get/{request}") - public String openGet(@PathVariable String request, HttpSession session) { - try { - request = URLDecoder.decode(request, StringUtil.UTF_8); - } catch (Exception e) { - // Parser会报错 - } - return get(request, session); - } - - /**计数 - * 只为兼容HTTP GET请求,推荐用HTTP POST,可删除 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#HEAD} - */ - @RequestMapping("head/{request}") - public String openHead(@PathVariable String request, HttpSession session) { - try { - request = URLDecoder.decode(request, StringUtil.UTF_8); - } catch (Exception e) { - // Parser会报错 - } - return head(request, session); - } - - - //通用接口,非事务型操作 和 简单事务型操作 都可通过这些接口自动化实现>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - - - - - - - - - - public static final String USER_; - public static final String PRIVACY_; - public static final String MOMENT_; - public static final String COMMENT_; - public static final String VERIFY_; //加下划线后缀是为了避免 Verify 和 verify 都叫VERIFY,分不清 - static { - USER_ = User.class.getSimpleName(); - PRIVACY_ = Privacy.class.getSimpleName(); - MOMENT_ = Moment.class.getSimpleName(); - COMMENT_ = Comment.class.getSimpleName(); - VERIFY_ = Verify.class.getSimpleName(); - } - - public static final String VERSION = JSONRequest.KEY_VERSION; - public static final String COUNT = JSONResponse.KEY_COUNT; - public static final String TOTAL = JSONResponse.KEY_TOTAL; - - public static final String RANGE = "range"; - - public static final String ID = "id"; - public static final String USER_ID = "userId"; - public static final String CURRENT_USER_ID = "currentUserId"; - - public static final String NAME = "name"; - public static final String PHONE = "phone"; - public static final String PASSWORD = "password"; - public static final String _PASSWORD = "_password"; - public static final String _PAY_PASSWORD = "_payPassword"; - public static final String OLD_PASSWORD = "oldPassword"; - public static final String VERIFY = "verify"; - - public static final String SEX = "sex"; - public static final String TYPE = "type"; - public static final String WAY = "way"; - public static final String CONTENT = "content"; - - - - - - public static final String DATE_UP = "date+";//同 "date ASC" - public static final String DATE_DOWN = "date-";//同 "date DESC" - - public static final String ID_AT = ID + "@"; - public static final String USER_ID_AT = USER_ID + "@"; - public static final String MOMENT_ID_AT = "momentId@"; - public static final String COMMENT_ID_AT = "commentId@"; - - public static final String ID_IN = ID + "{}"; - public static final String USER_ID_IN = USER_ID + "{}"; - public static final String MOMENT_ID_IN = "momentId{}"; - public static final String COMMENT_ID_IN = "commentId{}"; - - public static final String NAME_SEARCH = NAME + "$"; - public static final String PHONE_SEARCH = PHONE + "$"; - public static final String CONTENT_SEARCH = CONTENT + "$"; - - - - public static final String COLUMNS_USER_SIMPLE = "id,name"; - public static final String COLUMNS_USER = "id,sex,name,head"; - - - - - /**生成验证码,修改为post请求 - * @param request - * @return - */ - @PostMapping("post/verify") - public JSONObject postVerify(@RequestBody String request) { - JSONObject requestObject = null; - int type; - String phone; - try { - requestObject = Parser.parseRequest(request, POST); - type = requestObject.getIntValue(TYPE); - phone = requestObject.getString(PHONE); - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - - new Parser(DELETE, true).parse(newVerifyRequest(type, phone, null)); - - JSONObject response = new Parser(POST, true).parseResponse( - newVerifyRequest(type, phone, "" + (new Random().nextInt(9999) + 1000))); - - JSONObject verify = null; - try { - verify = response.getJSONObject(VERIFY_); - } catch (Exception e) { - // TODO: handle exception - } - if (verify == null || JSONResponse.isSuccess(verify.getIntValue(JSONResponse.KEY_CODE)) == false) { - new Parser(DELETE, true).parseResponse(new JSONRequest(new Verify(type, phone))); - return response; - } - - //TODO 这里直接返回验证码,方便测试。实际上应该只返回成功信息,验证码通过短信发送 - JSONObject object = new JSONObject(); - object.put(TYPE, type); - object.put(PHONE, phone); - return getVerify(JSON.toJSONString(object)); - } - - /**获取验证码 - * @param request - * @return - */ - @PostMapping("gets/verify") - public JSONObject getVerify(@RequestBody String request) { - JSONObject requestObject = null; - int type; - String phone; - try { - requestObject = Parser.parseRequest(request, GETS); - type = requestObject.getIntValue(TYPE); - phone = requestObject.getString(PHONE); - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - return new Parser(GETS, true).parseResponse(newVerifyRequest(type, phone, null)); - } - - /**校验验证码 - * @param request - * @return - */ - @PostMapping("heads/verify") - public JSONObject headVerify(@RequestBody String request) { - JSONObject requestObject = null; - int type; - String phone; - String verify; - try { - requestObject = Parser.parseRequest(request, HEADS); - type = requestObject.getIntValue(TYPE); - phone = requestObject.getString(PHONE); - verify = requestObject.getString(VERIFY); - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - return headVerify(type, phone, verify); - } - - /**校验验证码 - * @author Lemon - * @param type - * @param phone - * @param code - * @return - */ - public JSONObject headVerify(int type, String phone, String code) { - JSONResponse response = new JSONResponse( - new Parser(GETS, true).parseResponse( - new JSONRequest( - new Verify(type, phone) - .setVerify(code) - ).setTag(VERIFY_) - ) - ); - Verify verify = response.getObject(Verify.class); - if (verify == null) { - return Parser.newErrorResult(StringUtil.isEmpty(code, true) - ? new NotExistException("验证码不存在!") : new ConditionErrorException("手机号或验证码错误!")); - } - - //验证码过期 - if (System.currentTimeMillis() > (60*1000 + BaseModel.getTimeMillis(verify.getDate()))) { - new Parser(DELETE, true).parseResponse( - new JSONRequest(new Verify(type, phone)).setTag(VERIFY_) - ); - return Parser.newErrorResult(new TimeoutException("验证码已过期!")); - } - - return new JSONResponse( - new Parser(HEADS, true).parseResponse( - new JSONRequest(new Verify(type, phone).setVerify(code)) - ) - ); - } - - - - /**新建一个验证码请求 - * @param phone - * @param verify - * @return - */ - private JSONObject newVerifyRequest(int type, String phone, String verify) { - return new JSONRequest(new Verify(type, phone).setVerify(verify)).setTag(VERIFY_); - } - - - public static final String LOGIN = "login"; - - public static final int LOGIN_TYPE_PASSWORD = 0;//密码登录 - public static final int LOGIN_TYPE_VERIFY = 1;//验证码登录 - /**用户登录 - * @param request 只用String,避免encode后未decode - * @return - * @see - *
-		{
-			"type": 0,  //登录方式,非必须  0-密码 1-验证码
-			"phone": "13000082001",
-			"password": "1234567",
-			"version": 1 //全局版本号,非必须
-		}
-	 * 
- */ - @PostMapping("login") - public JSONObject login(@RequestBody String request, HttpSession session) { - JSONObject requestObject = null; - boolean isPassword; - String phone; - String password; - int version; - try { - requestObject = Parser.parseRequest(request, POST); - - isPassword = requestObject.getIntValue(TYPE) == LOGIN_TYPE_PASSWORD;//登录方式 - phone = requestObject.getString(PHONE);//手机 - password = requestObject.getString(PASSWORD);//密码 - - if (StringUtil.isPhone(phone) == false) { - throw new IllegalArgumentException("手机号不合法!"); - } - - if (isPassword) { - if (StringUtil.isPassword(password) == false) { - throw new IllegalArgumentException("密码不合法!"); - } - } else { - if (StringUtil.isVerify(password) == false) { - throw new IllegalArgumentException("验证码不合法!"); - } - } - - //全局版本号 - version = requestObject.getIntValue(VERSION); - requestObject.remove(VERSION); - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - - - - //手机号是否已注册 - JSONObject phoneResponse = new Parser(HEADS, true).parseResponse( - new JSONRequest( - new Privacy().setPhone(phone) - ) - ); - JSONResponse response = new JSONResponse(phoneResponse).getJSONResponse(PRIVACY_); - if (JSONResponse.isSuccess(response) == false) { - return response; - } - if(JSONResponse.isExist(response) == false) { - return Parser.newErrorResult(new NotExistException("手机号未注册")); - } - - //根据phone获取User - JSONObject privacyResponse = new Parser(GETS, true).parseResponse( - new JSONRequest( - new Privacy().setPhone(phone) - ) - ); - response = new JSONResponse(privacyResponse); - - Privacy privacy = response == null ? null : response.getObject(Privacy.class); - long userId = privacy == null ? 0 : BaseModel.value(privacy.getId()); - if (userId <= 0) { - return privacyResponse; - } - - //校验凭证 - if (isPassword) {//password密码登录 - response = new JSONResponse( - new Parser(HEADS, true).parseResponse( - new JSONRequest(new Privacy(userId).setPassword(password)) - ) - ); - } else {//verify手机验证码登录 - response = new JSONResponse(headVerify(Verify.TYPE_LOGIN, phone, password)); - } - if (JSONResponse.isSuccess(response) == false) { - return response; - } - response = response.getJSONResponse(isPassword ? PRIVACY_ : VERIFY_); - if (JSONResponse.isExist(response) == false) { - return Parser.newErrorResult(new ConditionErrorException("账号或密码错误")); - } - - response = new JSONResponse( - new Parser(GETS, true).parseResponse( - new JSONRequest(new User(userId)) - ) - ); - User user = response.getObject(User.class); - if (user == null || BaseModel.value(user.getId()) != userId) { - return Parser.newErrorResult(new NullPointerException("服务器内部错误")); - } - - //登录状态保存至session - session.setAttribute(USER_ID, userId);//用户id - session.setAttribute(TYPE, isPassword ? LOGIN_TYPE_PASSWORD : LOGIN_TYPE_VERIFY);//登录方式 - session.setAttribute(USER_, user);//用户 - session.setAttribute(PRIVACY_, privacy);//用户隐私信息 - session.setAttribute(VERSION, version);//用户隐私信息 - // session.setMaxInactiveInterval(1*60);//设置session过期时间 - - return response; - } - - /**退出登录,清空session - * @param session - * @return - */ - @PostMapping("logout") - public JSONObject logout(HttpSession session) { - long userId; - try { - userId = Verifier.getUserId(session);//必须在session.invalidate();前! - Log.d(TAG, "logout userId = " + userId + "; session.getId() = " + (session == null ? null : session.getId())); - session.invalidate(); - } catch (Exception e) { - return Parser.newErrorResult(e); - } - - JSONObject result = Parser.newSuccessResult(); - JSONObject user = Parser.newSuccessResult(); - user.put(ID, userId); - user.put(COUNT, 1); - result.put(USER_, user); - - return result; - } - - - private static final String REGISTER = "register"; - /**注册 - * @param request 只用String,避免encode后未decode - * @return - * @see - *
-		{
-			"Privacy": {
-				"phone": "13000082222",
-				"_password": "123456"
-			},
-			"User": {
-				"name": "APIJSONUser"
-			},
-			"verify": "1234"
-		}
-	 * 
- */ - @PostMapping(REGISTER) - public JSONObject register(@RequestBody String request) { - JSONObject requestObject = null; - - JSONObject privacyObj; - - String phone; - String verify; - String password; - try { - requestObject = Parser.parseRequest(request, POST); - privacyObj = requestObject.getJSONObject(PRIVACY_); - - phone = StringUtil.getString(privacyObj.getString(PHONE)); - verify = requestObject.getString(VERIFY); - password = privacyObj.getString(_PASSWORD); - - if (StringUtil.isPhone(phone) == false) { - return newIllegalArgumentResult(requestObject, PRIVACY_ + "/" + PHONE); - } - if (StringUtil.isPassword(password) == false) { - return newIllegalArgumentResult(requestObject, PRIVACY_ + "/" + _PASSWORD); - } - if (StringUtil.isVerify(verify) == false) { - return newIllegalArgumentResult(requestObject, VERIFY); - } - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - - - JSONResponse response = new JSONResponse(headVerify(Verify.TYPE_REGISTER, phone, verify)); - if (JSONResponse.isSuccess(response) == false) { - return response; - } - //手机号或验证码错误 - if (JSONResponse.isExist(response.getJSONResponse(VERIFY_)) == false) { - return Parser.extendErrorResult(response, new ConditionErrorException("手机号或验证码错误!")); - } - - - - //生成User和Privacy - if (StringUtil.isEmpty(requestObject.getString(JSONRequest.KEY_TAG), true)) { - requestObject.put(JSONRequest.KEY_TAG, REGISTER); - } - response = new JSONResponse( - new Parser(POST).setNoVerifyLogin(true).parseResponse(requestObject) - ); - - //验证User和Privacy - User user = response.getObject(User.class); - long userId = user == null ? 0 : BaseModel.value(user.getId()); - Privacy privacy = response.getObject(Privacy.class); - long userId2 = privacy == null ? 0 : BaseModel.value(privacy.getId()); - Exception e = null; - if (userId <= 0 || userId != userId2) { //id不同 - e = new Exception("服务器内部错误!写入User或Privacy失败!"); - } - - if (e != null) { //出现错误,回退 - new Parser(DELETE, true).parseResponse( - new JSONRequest(new User(userId)) - ); - new Parser(DELETE, true).parseResponse( - new JSONRequest(new Privacy(userId2)) - ); - } - - return response; - } - - - /** - * @param requestObject - * @param key - * @return - */ - public static JSONObject newIllegalArgumentResult(JSONObject requestObject, String key) { - return newIllegalArgumentResult(requestObject, key, null); - } - /** - * @param requestObject - * @param key - * @param msg 详细说明 - * @return - */ - public static JSONObject newIllegalArgumentResult(JSONObject requestObject, String key, String msg) { - return Parser.extendErrorResult(requestObject - , new IllegalArgumentException(key + ":value 中value不合法!" + StringUtil.getString(msg))); - } - - - /**设置密码 - * @param request 只用String,避免encode后未decode - * @return - * @see - *
-	    使用旧密码修改
-		{
-			"oldPassword": 123456,
-			"Privacy":{
-			  "id": 13000082001,
-			  "_password": "1234567"
-			}
-		}
-		或使用手机号+验证码修改
-		{
-			"verify": "1234",
-			"Privacy":{
-			  "phone": "13000082001",
-			  "_password": "1234567"
-			}
-		}
-	 * 
- */ - @PostMapping("put/password") - public JSONObject putPassword(@RequestBody String request){ - JSONObject requestObject = null; - String oldPassword; - String verify; - - int type = Verify.TYPE_PASSWORD; - - JSONObject privacyObj; - long userId; - String phone; - String password; - try { - requestObject = Parser.parseRequest(request, PUT); - oldPassword = StringUtil.getString(requestObject.getString(OLD_PASSWORD)); - verify = StringUtil.getString(requestObject.getString(VERIFY)); - - requestObject.remove(OLD_PASSWORD); - requestObject.remove(VERIFY); - - privacyObj = requestObject.getJSONObject(PRIVACY_); - if (privacyObj == null) { - throw new IllegalArgumentException(PRIVACY_ + " 不能为空!"); - } - userId = privacyObj.getLongValue(ID); - phone = privacyObj.getString(PHONE); - password = privacyObj.getString(_PASSWORD); - - if (StringUtil.isEmpty(password, true)) { //支付密码 - type = Verify.TYPE_PAY_PASSWORD; - password = privacyObj.getString(_PAY_PASSWORD); - if (StringUtil.isNumberPassword(password) == false) { - throw new IllegalArgumentException(PRIVACY_ + "/" + _PAY_PASSWORD + ":value 中value不合法!"); - } - } else { //登录密码 - if (StringUtil.isPassword(password) == false) { - throw new IllegalArgumentException(PRIVACY_ + "/" + _PASSWORD + ":value 中value不合法!"); - } - } - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - - - if (StringUtil.isPassword(oldPassword)) { - if (userId <= 0) { //手机号+验证码不需要userId - return Parser.extendErrorResult(requestObject, new IllegalArgumentException(ID + ":value 中value不合法!")); - } - if (oldPassword.equals(password)) { - return Parser.extendErrorResult(requestObject, new ConflictException("新旧密码不能一样!")); - } - - //验证旧密码 - Privacy privacy = new Privacy(userId); - if (type == Verify.TYPE_PASSWORD) { - privacy.setPassword(oldPassword); - } else { - privacy.setPayPassword(oldPassword); - } - JSONResponse response = new JSONResponse( - new Parser(HEAD, true).parseResponse( - new JSONRequest(privacy) - ) - ); - if (JSONResponse.isExist(response.getJSONResponse(PRIVACY_)) == false) { - return Parser.extendErrorResult(requestObject, new ConditionErrorException("账号或原密码错误,请重新输入!")); - } - } - else if (StringUtil.isPhone(phone) && StringUtil.isVerify(verify)) { - JSONResponse response = new JSONResponse(headVerify(type, phone, verify)); - if (JSONResponse.isSuccess(response) == false) { - return response; - } - if (JSONResponse.isExist(response.getJSONResponse(VERIFY_)) == false) { - return Parser.extendErrorResult(response, new ConditionErrorException("手机号或验证码错误!")); - } - response = new JSONResponse( - new Parser(GET, true).parseResponse( - new JSONRequest( - new Privacy().setPhone(phone) - ) - ) - ); - Privacy privacy = response.getObject(Privacy.class); - long id = privacy == null ? 0 : BaseModel.value(privacy.getId()); - privacyObj.remove(PHONE); - privacyObj.put(ID, id); - - requestObject.put(PRIVACY_, privacyObj); - } else { - return Parser.extendErrorResult(requestObject, new IllegalArgumentException("请输入合法的 旧密码 或 手机号+验证码 !")); - } - //TODO 上线版加上 password = MD5Util.MD5(password); - - - // requestObject.put(JSONRequest.KEY_TAG, "Password"); - //修改密码 - return new Parser(PUT, true).parseResponse(requestObject); - } - - - - /**充值/提现 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see - *
-		{
-			"Privacy": {
-				"id": 82001,
-				"balance+": 100,
-				"_payPassword": "123456"
-			}
-		}
-	 * 
- */ - @PostMapping("put/balance") - public JSONObject putBalance(@RequestBody String request, HttpSession session) { - JSONObject requestObject = null; - JSONObject privacyObj; - long userId; - String payPassword; - double change; - try { - Verifier.verifyLogin(session); - requestObject = Parser.getCorrectRequest(PUT, Parser.parseRequest(request, PUT)); - - privacyObj = requestObject.getJSONObject(PRIVACY_); - if (privacyObj == null) { - throw new NullPointerException("请设置 " + PRIVACY_ + "!"); - } - userId = privacyObj.getLongValue(ID); - payPassword = privacyObj.getString(_PAY_PASSWORD); - change = privacyObj.getDoubleValue("balance+"); - - if (userId <= 0) { - throw new IllegalArgumentException(PRIVACY_ + "." + ID + ":value 中value不合法!"); - } - if (StringUtil.isPassword(payPassword) == false) { - throw new IllegalArgumentException(PRIVACY_ + "." + _PAY_PASSWORD + ":value 中value不合法!"); - } - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - - //验证密码<<<<<<<<<<<<<<<<<<<<<<< - - privacyObj.remove("balance+"); - JSONResponse response = new JSONResponse( - new Parser(HEADS, true).setSession(session).parseResponse( - new JSONRequest(PRIVACY_, privacyObj) - ) - ); - response = response.getJSONResponse(PRIVACY_); - if (JSONResponse.isExist(response) == false) { - return Parser.extendErrorResult(requestObject, new ConditionErrorException("支付密码错误!")); - } - - //验证密码>>>>>>>>>>>>>>>>>>>>>>>> - - - //验证金额范围<<<<<<<<<<<<<<<<<<<<<<< - - if (change == 0) { - return Parser.extendErrorResult(requestObject, new OutOfRangeException("balance+的值不能为0!")); - } - if (Math.abs(change) > 10000) { - return Parser.extendErrorResult(requestObject, new OutOfRangeException("单次 充值/提现 的金额不能超过10000元!")); - } - - //验证金额范围>>>>>>>>>>>>>>>>>>>>>>>> - - if (change < 0) {//提现 - response = new JSONResponse( - new Parser(GETS, true).parseResponse( - new JSONRequest( - new Privacy(userId) - ) - ) - ); - Privacy privacy = response == null ? null : response.getObject(Privacy.class); - long id = privacy == null ? 0 : BaseModel.value(privacy.getId()); - if (id != userId) { - return Parser.extendErrorResult(requestObject, new Exception("服务器内部错误!")); - } - - if (BaseModel.value(privacy.getBalance()) < -change) { - return Parser.extendErrorResult(requestObject, new OutOfRangeException("余额不足!")); - } - } - - - privacyObj.remove(_PAY_PASSWORD); - privacyObj.put("balance+", change); - requestObject.put(PRIVACY_, privacyObj); - requestObject.put(JSONRequest.KEY_TAG, PRIVACY_); - //不免验证,里面会验证身份 - return new Parser(PUT).setSession(session).parseResponse(requestObject); - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/Function.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/Function.java deleted file mode 100644 index 2995482cf..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/Function.java +++ /dev/null @@ -1,295 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -import apijson.demo.server.model.BaseModel; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.server.Entry; -import zuo.biao.apijson.server.Pair; - -/**可远程调用的函数类 - * @author Lemon - */ -public class Function implements FunctionList { - private static final String TAG = "Function"; - - - public static void test() throws Exception { - int i0 = 1, i1 = -2; - Map jsonMap = new HashMap(); - jsonMap.put("id", 10); - jsonMap.put("i0", i0); - jsonMap.put("i1", i1); - JSONArray arr = new JSONArray(); - arr.add(new JSONObject()); - jsonMap.put("arr", arr); - - JSONArray collection = new JSONArray(); - collection.add(1);//new JSONObject()); - collection.add(2);//new JSONObject()); - collection.add(4);//new JSONObject()); - collection.add(10);//new JSONObject()); - jsonMap.put("collection", collection); - - jsonMap.put("position", 1); - jsonMap.put("@position", 0); - - jsonMap.put("key", "key"); - Map map = new HashMap(); - map.put("key", true); - jsonMap.put("map", map); - - - Log.i(TAG, "plus(1, -2) = " + invoke(jsonMap, "plus(long:i0,long:i1)")); - Log.i(TAG, "count([1,2,4,10]) = " + invoke(jsonMap, "count(Collection:collection)")); - Log.i(TAG, "isContain([1,2,4,10], 10) = " + invoke(jsonMap, "isContain(Collection:collection,Object:id)")); - Log.i(TAG, "get({key:true}, key) = " + invoke(jsonMap, "get(Map:map,key)")); - Log.i(TAG, "get([1,2,4,10], 0) = " + invoke(jsonMap, "get(Collection:collection,int:@position)")); - Log.i(TAG, "Integer:get({key:true}, key) = " + invoke(jsonMap, "Integer:get(Map:map,key)")); - } - - /**反射调用 - * @param jsonMap - * @param function 例如get(Map:map,key),参数只允许引用,不能直接传值 - * @return - */ - public static Object invoke(Map jsonMap, String function) throws Exception { - - int start = function.indexOf("("); - int end = function.lastIndexOf(")"); - Entry method = Pair.parseVariableEntry(function.substring(0, start)); - if (method == null || StringUtil.isNotEmpty(method.getValue(), true) == false) { - Log.i(TAG, "invoke method == null || StringUtil.isNotEmpty(method.getValue(), true) == false" - + " >> return null;"); - return null; - } - - String[] typeValues = StringUtil.split(function.substring(start + 1, end)); - - Class[] types = null; - Object[] values = null; - if (typeValues != null && typeValues.length > 0) { - types = new Class[typeValues.length]; - values = new Object[typeValues.length]; - - Entry, Object> entry; - for (int i = 0; i < typeValues.length; i++) { - entry = Pair.parseVariableEntry(typeValues[i], jsonMap); - if (entry != null && entry.isEmpty() == false) { - types[i] = entry.getKey(); - values[i] = entry.getValue(); - } - } - } - return invoke(method.getValue(), types, values); - } - /**反射调用 - * @param methodName - * @param parameterTypes - * @param args - * @return - */ - public static Object invoke(String methodName, Class[] parameterTypes, Object[] args) throws Exception { - Function obj = new Function(); - Class clazz = obj.getClass(); - return clazz.getDeclaredMethod(methodName, parameterTypes).invoke(obj, args); - } - - - - - public String search(String key) { - return null; - } - - public long plus(long i0, long i1) { - return i0 + i1; - } - - - //判断是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**判断collection是否为空 - * @param collection - * @return - */ - @Override - public boolean isEmpty(Collection collection) { - return BaseModel.isEmpty(collection); - } - /**判断map是否为空 - * @param - * @param - * @param map - * @return - */ - @Override - public boolean isEmpty(Map map) { - return BaseModel.isEmpty(map); - } - //判断是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //判断是否为包含 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**判断collection是否包含object - * @param collection - * @param object - * @return - */ - @Override - public boolean isContain(Collection collection, T object) { - return BaseModel.isContain(collection, object); - } - /**判断map是否包含key - * @param - * @param - * @param map - * @param key - * @return - */ - @Override - public boolean isContainKey(Map map, K key) { - return BaseModel.isContainKey(map, key); - } - /**判断map是否包含value - * @param - * @param - * @param map - * @param value - * @return - */ - @Override - public boolean isContainValue(Map map, V value) { - return BaseModel.isContainValue(map, value); - } - //判断是否为包含 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取数量 - * @param - * @param array - * @return - */ - @Override - public int count(T[] array) { - return BaseModel.count(array); - } - /**获取数量 - * @param - * @param collection List, Vector, Set等都是Collection的子类 - * @return - */ - @Override - public int count(Collection collection) { - return BaseModel.count(collection); - } - /**获取数量 - * @param - * @param - * @param map - * @return - */ - @Override - public int count(Map map) { - return BaseModel.count(map); - } - //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取 - * @param - * @param array - * @return - */ - @Override - public T get(T[] array, int position) { - return BaseModel.get(array, position); - } - /**获取 - * @param - * @param collection List, Vector, Set等都是Collection的子类 - * @return - */ - @Override - public T get(Collection collection, int position) { - return BaseModel.get(collection, position); - } - /**获取 - * @param - * @param - * @param map null ? null - * @param key null ? null : map.get(key); - * @return - */ - @Override - public V get(Map map, K key) { - return BaseModel.get(map, key); - } - //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //获取非基本类型对应基本类型的非空值 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取非空值 - * @param value - * @return - */ - @Override - public boolean value(Boolean value) { - return BaseModel.value(value); - } - /**获取非空值 - * @param value - * @return - */ - @Override - public int value(Integer value) { - return BaseModel.value(value); - } - /**获取非空值 - * @param value - * @return - */ - @Override - public long value(Long value) { - return BaseModel.value(value); - } - /**获取非空值 - * @param value - * @return - */ - @Override - public float value(Float value) { - return BaseModel.value(value); - } - /**获取非空值 - * @param value - * @return - */ - @Override - public double value(Double value) { - return BaseModel.value(value); - } - //获取非基本类型对应基本类型的非空值 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - -} \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/FunctionList.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/FunctionList.java deleted file mode 100644 index b087a4c61..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/FunctionList.java +++ /dev/null @@ -1,143 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server; - -import java.util.Collection; -import java.util.Map; - -//TODO 新增 @FunctionList ,被它注解过的List可以传到 FuntionUtil.invoke(FunctionList list, ...) -/**可远程调用的函数列表,暴露功能和使用方式,而不是具体的实现细节。 - * @author Lemon - */ -public interface FunctionList { - - //判断是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**判断collection是否为空 - * @param collection - * @return - */ - public boolean isEmpty(Collection collection); - /**判断map是否为空 - * @param - * @param - * @param map - * @return - */ - public boolean isEmpty(Map map); - //判断是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //判断是否为包含 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**判断collection是否包含object - * @param collection - * @param object - * @return - */ - public boolean isContain(Collection collection, T object); - /**判断map是否包含key - * @param - * @param - * @param map - * @param key - * @return - */ - public boolean isContainKey(Map map, K key); - /**判断map是否包含value - * @param - * @param - * @param map - * @param value - * @return - */ - public boolean isContainValue(Map map, V value); - //判断是否为包含 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取数量 - * @param - * @param array - * @return - */ - public int count(T[] array); - /**获取数量 - * @param - * @param collection List, Vector, Set等都是Collection的子类 - * @return - */ - public int count(Collection collection); - /**获取数量 - * @param - * @param - * @param map - * @return - */ - public int count(Map map); - //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取 - * @param - * @param array - * @return - */ - public T get(T[] array, int position); - /**获取 - * @param - * @param collection List, Vector, Set等都是Collection的子类 - * @return - */ - public T get(Collection collection, int position); - /**获取 - * @param - * @param - * @param map null ? null - * @param key null ? null : map.get(key); - * @return - */ - public V get(Map map, K key); - //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //获取非基本类型对应基本类型的非空值 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取非空值 - * @param value - * @return - */ - public boolean value(Boolean value); - /**获取非空值 - * @param value - * @return - */ - public int value(Integer value); - /**获取非空值 - * @param value - * @return - */ - public long value(Long value); - /**获取非空值 - * @param value - * @return - */ - public float value(Float value); - /**获取非空值 - * @param value - * @return - */ - public double value(Double value); - //获取非基本类型对应基本类型的非空值 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - -} \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/Verifier.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/Verifier.java deleted file mode 100644 index b49c482ab..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/Verifier.java +++ /dev/null @@ -1,344 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server; - -import static zuo.biao.apijson.RequestMethod.DELETE; -import static zuo.biao.apijson.RequestMethod.GET; -import static zuo.biao.apijson.RequestMethod.HEAD; -import static zuo.biao.apijson.RequestMethod.POST; -import static zuo.biao.apijson.RequestMethod.GETS; -import static zuo.biao.apijson.RequestMethod.HEADS; -import static zuo.biao.apijson.RequestMethod.PUT; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.activation.UnsupportedDataTypeException; -import javax.servlet.http.HttpSession; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -import apijson.demo.server.model.BaseModel; -import apijson.demo.server.model.Comment; -import apijson.demo.server.model.Login; -import apijson.demo.server.model.Moment; -import apijson.demo.server.model.Privacy; -import apijson.demo.server.model.User; -import apijson.demo.server.model.Verify; -import zuo.biao.apijson.JSON; -import zuo.biao.apijson.JSONResponse; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.MethodAccess; -import zuo.biao.apijson.RequestMethod; -import zuo.biao.apijson.RequestRole; -import zuo.biao.apijson.model.Column; -import zuo.biao.apijson.model.Document; -import zuo.biao.apijson.model.Request; -import zuo.biao.apijson.model.Response; -import zuo.biao.apijson.model.Table; -import zuo.biao.apijson.model.Test; -import zuo.biao.apijson.server.JSONRequest; -import zuo.biao.apijson.server.Parser; -import zuo.biao.apijson.server.exception.ConflictException; -import zuo.biao.apijson.server.exception.NotLoggedInException; -import zuo.biao.apijson.server.sql.SQLConfig; - -/**权限验证类 - * @author Lemon - */ -public class Verifier { - private static final String TAG = "Verifier"; - - - public static final String KEY_PASSWORD = "password"; - public static final String KEY_LOGIN_PASSWORD = "loginPassword"; - public static final String KEY_PAY_PASSWORD = "payPassword"; - public static final String KEY_OLD_PASSWORD = "oldPassword"; - - - // > - // > - public static final Map> ACCESS_MAP; - static { - ACCESS_MAP = new HashMap>(); - - ACCESS_MAP.put(Table.class.getSimpleName(), getAccessMap(Table.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Column.class.getSimpleName(), getAccessMap(Column.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Test.class.getSimpleName(), getAccessMap(Test.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Request.class.getSimpleName(), getAccessMap(Request.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Response.class.getSimpleName(), getAccessMap(Response.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Document.class.getSimpleName(), getAccessMap(Document.class.getAnnotation(MethodAccess.class))); - - ACCESS_MAP.put(User.class.getSimpleName(), getAccessMap(User.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Privacy.class.getSimpleName(), getAccessMap(Privacy.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Moment.class.getSimpleName(), getAccessMap(Moment.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Comment.class.getSimpleName(), getAccessMap(Comment.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Verify.class.getSimpleName(), getAccessMap(Verify.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Login.class.getSimpleName(), getAccessMap(Login.class.getAnnotation(MethodAccess.class))); - } - - /**获取权限Map,每种操作都只允许对应的角色 - * @param access - * @return - */ - private static HashMap getAccessMap(MethodAccess access) { - if (access == null) { - return null; - } - - HashMap map = new HashMap<>(); - map.put(GET, access.GET()); - map.put(HEAD, access.HEAD()); - map.put(GETS, access.GETS()); - map.put(HEADS, access.HEADS()); - map.put(POST, access.POST()); - map.put(PUT, access.PUT()); - map.put(DELETE, access.DELETE()); - - return map; - } - - - /**验证权限是否通过 - * @param config - * @param visitor - * @return - * @throws Exception - */ - public static boolean verify(SQLConfig config, User visitor) throws Exception { - String table = config == null ? null : config.getTable(); - if (table == null) { - return true; - } - RequestRole role = config.getRole(); - if (role == null) { - role = RequestRole.UNKNOWN; - } - - long userId = visitor == null ? 0 : visitor.getId(); - //TODO 暂时去掉,方便测试 - if (role != RequestRole.UNKNOWN) {//未登录的角色 - verifyLogin(userId); - } - - RequestMethod method = config.getMethod(); - //验证允许的角色 - verifyRole(table, method, role); - - - //验证角色,假定真实强制匹配<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - String userIdkey = Controller.USER_.equals(config.getTable()) || Controller.PRIVACY_.equals(config.getTable()) - ? Controller.ID : Controller.USER_ID; - - Number requestId; - switch (role) { - case LOGIN://verifyRole通过就行 - break; - case CONTACT: - case CIRCLE: - //TODO 做一个缓存contactMap,提高[]:{}查询性能, removeAccessInfo时map.remove(userId) - //不能在User内null -> [] ! 否则会导致某些查询加上不需要的条件! - List list = visitor == null || visitor.getContactIdList() == null - ? new ArrayList() : new ArrayList(visitor.getContactIdList()); - if (role == RequestRole.CIRCLE) { - list.add(userId); - } - - //key!{}:[] 或 其它没有明确id的条件 等 可以和key{}:list组合。类型错误就报错 - requestId = (Number) config.getWhere(userIdkey, true);//JSON里数值不能保证是Long,可能是Integer - JSONArray requestIdArray = (JSONArray) config.getWhere(userIdkey + "{}", true);//不能是 &{}, |{} 不要传,直接{} - if (requestId != null) { - if (requestIdArray == null) { - requestIdArray = new JSONArray(); - } - requestIdArray.add(requestId); - } - - if (requestIdArray == null) {//可能是@得到 || requestIdArray.isEmpty()) {//请求未声明key:id或key{}:[...]条件,自动补全 - config.addWhere(userIdkey+"{}", JSON.parseArray(list)); //key{}:[]有效,SQLConfig里throw NotExistException - } - else {//请求已声明key:id或key{}:[]条件,直接验证 - for (Object id : requestIdArray) { - if (id == null) { - continue; - } - if (id instanceof Number == false) {//不能准确地判断Long,可能是Integer - throw new UnsupportedDataTypeException(table + ".id类型错误,id类型必须是Long!"); - } - if (list.contains(new Long("" + id)) == false) {//Integer等转为Long才能正确判断。强转崩溃 - throw new IllegalAccessException(userIdkey + " = " + id + " 的 " + table - + " 不允许 " + role.name() + " 用户的 " + method.name() + " 请求!"); - } - } - } - break; - case OWNER: - requestId = (Number) config.getWhere(userIdkey, true);//JSON里数值不能保证是Long,可能是Integer - if (requestId != null && requestId.longValue() != userId) { - throw new IllegalAccessException(userIdkey + " = " + requestId + " 的 " + table - + " 不允许 " + role.name() + " 用户的 " + method.name() + " 请求!"); - } - config.addWhere(userIdkey, userId); - break; - case ADMIN://这里不好做,在特定接口内部判断? TODO /get/admin + 固定秘钥 Parser#noVerify,之后全局跳过验证 - break; - default://unknown,verifyRole通过就行 - break; - } - - //验证角色,假定真实强制匹配>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - return true; - } - - - /**允许请求,角色不好判断,让访问者发过来角色名,OWNER,CONTACT,ADMIN等 - * @param table - * @param method - * @param role - * @return - * @throws Exception - * @see {@link zuo.biao.apijson.JSONObject#KEY_ROLE} - */ - public static void verifyRole(String table, RequestMethod method, RequestRole role) throws Exception { - Log.d(TAG, "verifyRole table = " + table + "; method = " + method + "; role = " + role); - if (table != null) { - if (method == null) { - method = GET; - } - if (role == null) { - role = RequestRole.UNKNOWN; - } - Map map = ACCESS_MAP.get(table); - - if (map == null || BaseModel.isContain(map.get(method), role) == false) { - throw new IllegalAccessException(table + " 不允许 " + role.name() + " 用户的 " + method.name() + " 请求!"); - } - } - } - - - /**登录校验 - * @author - * @modifier Lemon - * @param session - * @throws Exception - */ - public static void verifyLogin(HttpSession session) throws Exception { - Log.d(TAG, "verifyLogin session.getId() = " + (session == null ? null : session.getId())); - verifyLogin(getUserId(session)); - } - /**登录校验 - * @author Lemon - * @param userId - * @throws Exception - */ - public static void verifyLogin(Long userId) throws Exception { - //未登录没有权限操作 - if (BaseModel.value(userId) <= 0) { - throw new NotLoggedInException("未登录,请登录后再操作!"); - } - } - - - - /**验证是否重复 - * @param table - * @param key - * @param value - * @throws Exception - */ - public static void verifyRepeat(String table, String key, Object value) throws Exception { - verifyRepeat(table, key, value, 0); - } - /**验证是否重复 - * @param table - * @param key - * @param value - * @param exceptId 不包含id - * @throws Exception - */ - public static void verifyRepeat(String table, String key, Object value, long exceptId) throws Exception { - if (key == null || value == null) { - Log.e(TAG, "verifyRepeat key == null || value == null >> return;"); - return; - } - if (value instanceof JSON) { - throw new UnsupportedDataTypeException(key + ":value 中value的类型不能为JSON!"); - } - - JSONRequest request = new JSONRequest(key, value); - if (exceptId > 0) {//允许修改自己的属性为该属性原来的值 - request.put(JSONRequest.KEY_ID + "!", exceptId); - } - JSONObject repeat = new Parser(HEAD, true).parseResponse( - new JSONRequest(table, request) - ); - repeat = repeat == null ? null : repeat.getJSONObject(table); - if (repeat == null) { - throw new Exception("服务器内部错误 verifyRepeat repeat == null"); - } - if (repeat.getIntValue(JSONResponse.KEY_COUNT) > 0) { - throw new ConflictException(key + ": " + value + " 已经存在,不能重复!"); - } - } - - - /**获取来访用户的id - * @author Lemon - * @param session - * @return - */ - public static long getUserId(HttpSession session) { - if (session == null) { - return 0; - } - Long userId = (Long) session.getAttribute(Controller.USER_ID); - if (userId == null) { - User user = getUser(session); - userId = user == null ? 0 : BaseModel.value(user.getId()); - session.setAttribute(Controller.USER_ID, userId); - } - return BaseModel.value(userId); - } - /**获取来访用户 - * @param session - * @return - */ - public static User getUser(HttpSession session) { - return session == null ? null : (User) session.getAttribute(Controller.USER_); - } - - - /**删除请求里的权限信息 - * @param requestObject - * @return - */ - public static JSONObject removeAccessInfo(JSONObject requestObject) { - if (requestObject != null) { - requestObject.remove(KEY_PASSWORD); - requestObject.remove(KEY_LOGIN_PASSWORD); - requestObject.remove(KEY_PAY_PASSWORD); - requestObject.remove(KEY_OLD_PASSWORD); - } - return requestObject; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/BaseModel.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/BaseModel.java deleted file mode 100644 index 8dec7d729..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/BaseModel.java +++ /dev/null @@ -1,304 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.Map; - -import com.alibaba.fastjson.JSON; - -import zuo.biao.apijson.StringUtil; - -/**base model for reduce model codes - * @author Lemon - * @use extends BaseModel - */ -public abstract class BaseModel implements Serializable { - private static final long serialVersionUID = 1L; - - private Long id; //主键,唯一标识 - private Long userId; //对应User表中的id,外键 - private String date; //创建时间,JSON没有Date,TimeStamp类型,都会被转成Long,不能用! - - public Long getId() { - return id; - } - public BaseModel setId(Long id) { - this.id = id; - return this; - } - public Long getUserId() { - return userId; - } - public BaseModel setUserId(Long userId) { - this.userId = userId; - return this; - } - public String getDate() { - return date; - } - public BaseModel setDate(String date) { - this.date = date; - return this; - } - - - @Override - public String toString() { - return JSON.toJSONString(this); - } - - - /**获取当前时间戳 - * @return - */ - public static Timestamp currentTimeStamp() { - return new Timestamp(new Date().getTime()); - } - /**获取时间戳 TODO 判空? 还是要报错? - * @param time - * @return - */ - public static Timestamp getTimeStamp(String time) { - return Timestamp.valueOf(time); - } - /**获取时间毫秒值 TODO 判空? 还是要报错? - * @param time - * @return - */ - public static long getTimeMillis(String time) { - return StringUtil.isEmpty(time, true) ? 0 : getTimeStamp(time).getTime(); - } - - - //判断是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**判断array是否为空 - * @param array - * @return - */ - public static boolean isEmpty(T[] array) { - return array == null || array.length <= 0; - } - /**判断collection是否为空 - * @param collection - * @return - */ - public static boolean isEmpty(Collection collection) { - return collection == null || collection.isEmpty(); - } - /**判断map是否为空 - * @param - * @param - * @param map - * @return - */ - public static boolean isEmpty(Map map) { - return map == null || map.isEmpty(); - } - //判断是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //判断是否包含 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**判断array是否包含a - * @param array - * @param a - * @return - */ - public static boolean isContain(T[] array, T a) { - return array == null ? false : Arrays.asList(array).contains(a); - } - /**判断collection是否包含object - * @param collection - * @param object - * @return - */ - public static boolean isContain(Collection collection, T object) { - return collection != null && collection.contains(object); - } - /**判断map是否包含key - * @param - * @param - * @param map - * @param key - * @return - */ - public static boolean isContainKey(Map map, K key) { - return map != null && map.containsKey(key); - } - /**判断map是否包含value - * @param - * @param - * @param map - * @param value - * @return - */ - public static boolean isContainValue(Map map, V value) { - return map != null && map.containsValue(value); - } - //判断是否为包含 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取数量 - * @param - * @param array - * @return - */ - public static int count(T[] array) { - return array == null ? 0 : array.length; - } - /**获取数量 - * @param - * @param collection List, Vector, Set等都是Collection的子类 - * @return - */ - public static int count(Collection collection) { - return collection == null ? 0 : collection.size(); - } - /**获取数量 - * @param - * @param - * @param map - * @return - */ - public static int count(Map map) { - return map == null ? 0 : map.size(); - } - //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取 - * @param - * @param array - * @return - */ - public static T get(T[] array, int position) { - return position < 0 || position >= count(array) ? null : array[position]; - } - /**获取 - * @param - * @param collection List, Vector, Set等都是Collection的子类 - * @return - */ - @SuppressWarnings("unchecked") - public static T get(Collection collection, int position) { - return collection == null ? null : (T) get(collection.toArray(), position); - } - /**获取 - * @param - * @param - * @param map null ? null - * @param key null ? null : map.get(key); - * @return - */ - public static V get(Map map, K key) { - return key == null || map == null ? null : map.get(key); - } - //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //获取非基本类型对应基本类型的非空值 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取非空值 - * @param value - * @return - */ - public static boolean value(Boolean value) { - return value == null ? false : value; - } - /**获取非空值 - * @param value - * @return - */ - public static int value(Integer value) { - return value == null ? 0 : value; - } - /**获取非空值 - * @param value - * @return - */ - public static long value(Long value) { - return value == null ? 0 : value; - } - /**获取非空值 - * @param value - * @return - */ - public static float value(Float value) { - return value == null ? 0 : value; - } - /**获取非空值 - * @param value - * @return - */ - public static double value(Double value) { - return value == null ? 0 : value; - } - //获取非基本类型对应基本类型的非空值 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - /**index是否在arr长度范围内 - * @param index - * @param array - * @return - */ - public static boolean isIndexInRange(Integer index, Object[] array) { - return index != null && index >= 0 && index < count(array); - } - - /**获取在arr长度范围内的index - * defaultIndex = 0 - * @param index - * @param array - * @return - */ - public static int getIndexInRange(Integer index, Object[] array) { - return getIndexInRange(index, array, 0); - } - /**获取在arr长度范围内的index - * @param index - * @param array - * @param defaultIndex - * @return - */ - public static int getIndexInRange(Integer index, Object[] array, int defaultIndex) { - return isIndexInRange(index, array) ? index : defaultIndex; - } - - /**获取在arr长度范围内的index - * defaultIndex = 0 - * @param - * @param index - * @param array - * @return - */ - public static T getInRange(Integer index, T[] array) { - return getInRange(index, array, 0); - } - /**获取在arr长度范围内的index - * @param - * @param index - * @param array - * @param defaultIndex - * @return - */ - public static T getInRange(Integer index, T[] array, int defaultIndex) { - return get(array, getIndexInRange(index, array, defaultIndex)); - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Comment.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Comment.java deleted file mode 100644 index 5bbdb50fc..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Comment.java +++ /dev/null @@ -1,24 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import zuo.biao.apijson.MethodAccess; - -/**评论类 - * @author Lemon - */ -@MethodAccess -public class Comment { -} \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Login.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Login.java deleted file mode 100644 index 6a0973bf0..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Login.java +++ /dev/null @@ -1,62 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.CONTACT; -import static zuo.biao.apijson.RequestRole.LOGIN; -import static zuo.biao.apijson.RequestRole.OWNER; -import static zuo.biao.apijson.RequestRole.UNKNOWN; - -import zuo.biao.apijson.MethodAccess; - -/**登录日志表 - * @author Lemon - */ -@SuppressWarnings("serial") -@MethodAccess( - GET = {}, - HEAD = {}, - GETS = {UNKNOWN, LOGIN, CONTACT, OWNER, ADMIN}, - HEADS = {UNKNOWN, LOGIN, CONTACT, OWNER, ADMIN}, - POST = {ADMIN}, - PUT = {ADMIN}, - DELETE = {ADMIN} - ) -public class Login extends BaseModel { - - public static final int TYPE_PASSWORD = 0;//密码登录 - public static final int TYPE_VERIFY = 1;//验证码登录 - - private Integer type; - - public Login() { - super(); - } - public Login(long userId) { - this(); - setUserId(userId); - } - - - public Integer getType() { - return type; - } - public Login setType(Integer type) { - this.type = type; - return this; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Moment.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Moment.java deleted file mode 100644 index 8fc89e5ed..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Moment.java +++ /dev/null @@ -1,32 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.CIRCLE; -import static zuo.biao.apijson.RequestRole.CONTACT; -import static zuo.biao.apijson.RequestRole.LOGIN; -import static zuo.biao.apijson.RequestRole.OWNER; - -import zuo.biao.apijson.MethodAccess; - -/**动态类 - * @author Lemon - */ -@MethodAccess( - PUT = {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}//TODO 还要细分,LOGIN,CONTACT只允许修改praiseUserIdList。数据库加role没用,应该将praiseUserIdList移到Praise表 - ) -public class Moment { -} \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Privacy.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Privacy.java deleted file mode 100644 index 48516110e..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Privacy.java +++ /dev/null @@ -1,99 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.CIRCLE; -import static zuo.biao.apijson.RequestRole.OWNER; -import static zuo.biao.apijson.RequestRole.UNKNOWN; - -import zuo.biao.apijson.MethodAccess; - -/**用户隐私信息 - * @author Lemon - */ -@MethodAccess( - GET = {}, - GETS = {CIRCLE, OWNER, ADMIN}, - POST = {UNKNOWN, ADMIN}, - DELETE = {ADMIN} - ) -public class Privacy extends BaseModel { - private static final long serialVersionUID = 1L; - - public static final int PASSWORD_TYPE_LOGIN = 0; - public static final int PASSWORD_TYPE_PAY = 1; - - private String phone; //手机 - private String password; //登录密码,隐藏字段 - private String payPassword; //支付密码,隐藏字段 - private Double balance; //余额 - - public Privacy() { - super(); - } - - public Privacy(long id) { - this(); - setId(id); - } - - public Privacy(String phone, String password) { - this(); - setPhone(phone); - setPassword(password); - } - - - - public String getPhone() { - return phone; - } - public Privacy setPhone(String phone) { - this.phone = phone; - return this; - } - - /**get_password会转为password - * @return - */ - public String get__password() { - return password; - } - public Privacy setPassword(String password) { - this.password = password; - return this; - } - - /**get_PayPassword会转为PayPassword - * @return - */ - public String get__payPassword() { - return payPassword; - } - public Privacy setPayPassword(String payPassword) { - this.payPassword = payPassword; - return this; - } - - public Double getBalance() { - return balance; - } - public Privacy setBalance(Double balance) { - this.balance = balance; - return this; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/User.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/User.java deleted file mode 100644 index 75f0c7682..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/User.java +++ /dev/null @@ -1,102 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.UNKNOWN; - -import java.util.List; - -import zuo.biao.apijson.MethodAccess; - -/**用户类 - * @author Lemon - */ -@MethodAccess( - POST = {UNKNOWN, ADMIN}, - DELETE = {ADMIN} - ) -public class User extends BaseModel { - private static final long serialVersionUID = 1L; - - public static final int SEX_MAIL = 0; - public static final int SEX_FEMALE = 1; - public static final int SEX_UNKNOWN = 2; - - - private Integer sex; //性别 - private String head; //头像url - private String name; //姓名 - private String tag; //标签 - private List pictureList; //照片列表 - private List contactIdList; //朋友列表 - - /**默认构造方法,JSON等解析时必须要有 - */ - public User() { - super(); - } - public User(long id) { - this(); - setId(id); - } - - public Integer getSex() { - return sex; - } - public User setSex(Integer sex) { - this.sex = sex; - return this; - } - public String getHead() { - return head; - } - public User setHead(String head) { - this.head = head; - return this; - } - public String getName() { - return name; - } - public User setName(String name) { - this.name = name; - return this; - } - public List getPictureList() { - return pictureList; - } - public User setPictureList(List pictureList) { - this.pictureList = pictureList; - return this; - } - - public String getTag() { - return tag; - } - public User setTag(String tag) { - this.tag = tag; - return this; - } - - public List getContactIdList() { - return contactIdList; - } - public User setContactIdList(List contactIdList) { - this.contactIdList = contactIdList; - return this; - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Verify.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Verify.java deleted file mode 100644 index b88cd2a98..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/Verify.java +++ /dev/null @@ -1,88 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.CIRCLE; -import static zuo.biao.apijson.RequestRole.CONTACT; -import static zuo.biao.apijson.RequestRole.LOGIN; -import static zuo.biao.apijson.RequestRole.OWNER; -import static zuo.biao.apijson.RequestRole.UNKNOWN; - -import zuo.biao.apijson.MethodAccess; - -/**验证码 - * @author Lemon - */ -@MethodAccess( - GET = {}, - HEAD = {}, - GETS = {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}, - HEADS = {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}, - POST = {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}, - PUT = {ADMIN}, - DELETE = {ADMIN} - ) -public class Verify extends BaseModel { - private static final long serialVersionUID = 1L; - - public static final int TYPE_LOGIN = 0; //登录 - public static final int TYPE_REGISTER = 1; //注册 - public static final int TYPE_PASSWORD = 2; //登录密码 - public static final int TYPE_PAY_PASSWORD = 3; //支付密码 - - private String phone; //手机 - private String verify; //验证码 - private Integer type; //验证类型 - - public Verify() { - super(); - } - /**type和phone为联合主键,必传 - * @param type - * @param phone - */ - public Verify(int type, String phone) { - this(); - setType(type); - setPhone(phone); - } - - - public String getVerify() { - return verify; - } - public Verify setVerify(String verify) { - this.verify = verify; - return this; - } - - public String getPhone() { - return phone; - } - public Verify setPhone(String phone) { - this.phone = phone; - return this; - } - - public Integer getType() { - return type; - } - public Verify setType(Integer type) { - this.type = type; - return this; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/package-info.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/package-info.java deleted file mode 100644 index 7a82728b7..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/model/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -/** - * 服务端给出的model - * the names of classes equal the names of tables in Server database one by one, so do the variables and columns - * (name) : model <=> table - * (name, type) : variable <=> column - * @warn don't use any base type like int or char in models, use Integer and String instead - */ -/** - * @author Lemon - * - */ -package apijson.demo.server.model; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/package-info.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/package-info.java deleted file mode 100644 index 487e27c06..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/apijson/demo/server/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * 示例服务端工程包 - */ -/** - * @author Lemon - * - */ -package apijson.demo.server; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSON.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSON.java deleted file mode 100755 index 7bd24b97d..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSON.java +++ /dev/null @@ -1,276 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import java.util.List; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.parser.Feature; -import com.alibaba.fastjson.serializer.SerializerFeature; - -/**阿里FastJSON封装类 防止解析时异常 - * @author Lemon - */ -public class JSON { - private static final String TAG = "JSON"; - - /**判断json格式是否正确 - * @param s - * @return - */ - public static boolean isJsonCorrect(String s) { - //太长 Log.i(TAG, "isJsonCorrect <<<< " + s + " >>>>>>>"); - if (s == null - // || s.equals("[]") - // || s.equals("{}") - || s.equals("") - || s.equals("[null]") - || s.equals("{null}") - || s.equals("null")) { - return false; - } - return true; - } - - /**获取有效的json - * @param s - * @return - */ - public static String getCorrectJson(String s) { - return getCorrectJson(s, false); - } - /**获取有效的json - * @param s - * @param isArray - * @return - */ - public static String getCorrectJson(String s, boolean isArray) { - s = StringUtil.getTrimedString(s); - // if (isArray) { - // while (s.startsWith("\"")) { - // s = s.substring(1); - // } - // while (s.endsWith("\"")) { - // s = s.substring(0, s.length() - 1); - // } - // } - return s;//isJsonCorrect(s) ? s : null; - } - - /**obj转JSONObject - * @param json - * @return - */ - public static JSONObject parseObject(Object obj) { - if (obj instanceof JSONObject) { - return (JSONObject) obj; - } - return parseObject(toJSONString(obj)); - } - /**json转JSONObject - * @param json - * @return - */ - public static JSONObject parseObject(String json) { - int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE; - features |= Feature.OrderedField.getMask(); - return parseObject(json, features); - } - /**json转JSONObject - * @param json - * @param features - * @return - */ - public static JSONObject parseObject(String json, int features) { - try { - return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), JSONObject.class, features); - } catch (Exception e) { - Log.i(TAG, "parseObject catch \n" + e.getMessage()); - } - return null; - } - - /**JSONObject转实体类 - * @param object - * @param clazz - * @return - */ - public static T parseObject(JSONObject object, Class clazz) { - return parseObject(toJSONString(object), clazz); - } - /**json转实体类 - * @param json - * @param clazz - * @return - */ - public static T parseObject(String json, Class clazz) { - if (clazz == null) { - Log.e(TAG, "parseObject clazz == null >> return null;"); - } else { - try { - int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE; - features |= Feature.OrderedField.getMask(); - return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), clazz, features); - } catch (Exception e) { - Log.i(TAG, "parseObject catch \n" + e.getMessage()); - } - } - return null; - } - - /**list转JSONArray - * @param list - * @return - */ - public static JSONArray parseArray(List list) { - return new JSONArray(list); - } - /**obj转JSONArray - * @param json - * @return - */ - public static JSONArray parseArray(Object obj) { - if (obj instanceof JSONArray) { - return (JSONArray) obj; - } - return parseArray(toJSONString(obj)); - } - /**json转JSONArray - * @param json - * @return - */ - public static JSONArray parseArray(String json) { - try { - return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json, true)); - } catch (Exception e) { - Log.i(TAG, "parseArray catch \n" + e.getMessage()); - } - return null; - } - /**JSONArray转实体类列表 - * @param array - * @param clazz - * @return - */ - public static List parseArray(JSONArray array, Class clazz) { - return parseArray(toJSONString(array), clazz); - } - /**json转实体类列表 - * @param json - * @param clazz - * @return - */ - public static List parseArray(String json, Class clazz) { - if (clazz == null) { - Log.e(TAG, "parseArray clazz == null >> return null;"); - } else { - try { - return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json, true), clazz); - } catch (Exception e) { - Log.i(TAG, "parseArray catch \n" + e.getMessage()); - } - } - return null; - } - - /**实体类转json - * @param obj - * @return - */ - public static String toJSONString(Object obj) { - if (obj instanceof String) { - return (String) obj; - } - try { - return com.alibaba.fastjson.JSON.toJSONString(obj); - } catch (Exception e) { - Log.e(TAG, "toJSONString catch \n" + e.getMessage()); - } - return null; - } - - /**实体类转json - * @param obj - * @param features - * @return - */ - public static String toJSONString(Object obj, SerializerFeature... features) { - if (obj instanceof String) { - return (String) obj; - } - try { - return com.alibaba.fastjson.JSON.toJSONString(obj, features); - } catch (Exception e) { - Log.e(TAG, "parseArray catch \n" + e.getMessage()); - } - return null; - } - - /**格式化,显示更好看 - * @param json - * @return - */ - public static String format(String json) { - return format(parseObject(json)); - } - /**格式化,显示更好看 - * @param object - * @return - */ - public static String format(JSONObject object) { - return toJSONString(object, SerializerFeature.PrettyFormat); - } - - /**判断是否为JSONObject - * @param obj instanceof String ? parseObject - * @return - */ - public static boolean isJSONObject(Object obj) { - if (obj instanceof JSONObject) { - return true; - } - if (obj instanceof String) { - try { - JSONObject json = parseObject((String) obj); - return json != null && json.isEmpty() == false; - } catch (Exception e) { - Log.e(TAG, "isJSONObject catch \n" + e.getMessage()); - } - } - - return false; - } - /**判断是否为JSONArray - * @param obj instanceof String ? parseArray - * @return - */ - public static boolean isJSONArray(Object obj) { - if (obj instanceof JSONArray) { - return true; - } - if (obj instanceof String) { - try { - JSONArray json = parseArray((String) obj); - return json != null && json.isEmpty() == false; - } catch (Exception e) { - Log.e(TAG, "isJSONArray catch \n" + e.getMessage()); - } - } - - return false; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSONObject.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSONObject.java deleted file mode 100644 index 3c9e0d1cf..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSONObject.java +++ /dev/null @@ -1,374 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import java.util.List; -import java.util.Map; - -/**use this class instead of com.alibaba.fastjson.JSONObject - * @author Lemon - * @see #put - * @see #puts - * @see #putsAll - */ -public class JSONObject extends com.alibaba.fastjson.JSONObject { - private static final long serialVersionUID = 1L; - - private static final String TAG = "JSONObject"; - - - /**ordered - */ - public JSONObject() { - super(true); - } - /**transfer Object to JSONObject - * @param object - * @see {@link #JSONObject(Object, boolean)} - */ - public JSONObject(Object object) { - this(toJSONString(object)); - } - /**parse JSONObject with JSON String - * @param json - * @see {@link #JSONObject(String, boolean)} - */ - public JSONObject(String json) { - this(parseObject(json)); - } - /**transfer com.alibaba.fastjson.JSONObject to JSONObject - * @param object - * @see {@link #putsAll(com.alibaba.fastjson.JSONObject)} - */ - public JSONObject(com.alibaba.fastjson.JSONObject object) { - this(); - putsAll(object); - } - - - - - //judge <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - public static final String KEY_ARRAY = "[]"; - - /**判断是否为Array的key - * @param key - * @return - */ - public static boolean isArrayKey(String key) { - return key != null && key.endsWith(KEY_ARRAY); - } - /**判断是否为对应Table的key - * @param key - * @return - */ - public static boolean isTableKey(String key) { - return StringUtil.isBigName(key); - } - //judge >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //JSONObject内关键词 key <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - - public static final String KEY_ID = "id"; - public static final String KEY_ID_IN = KEY_ID + "{}"; - - /**set "id":id in Table layer - * @param id - * @return - */ - public JSONObject setId(Long id) { - return puts(KEY_ID, id); - } - /**set id{}:[] in Table layer - * @param list - * @return - */ - public JSONObject setIdIn(List list) { - return puts(KEY_ID_IN, list); - } - - - //@key关键字都放这个类 <<<<<<<<<<<<<<<<<<<<<< - public static final String KEY_ROLE = "@role"; //角色,拥有对某些数据的某些操作的权限 - public static final String KEY_CONDITION = "@condition"; //条件 TODO 用 @where& @where| @where! 替代? - public static final String KEY_TRY = "@try"; //尝试,忽略异常 - public static final String KEY_DROP = "@drop"; //丢弃,不返回 - public static final String KEY_CORRECT = "@correct"; //字段校正 - - public static final String KEY_SCHEMA = "@schema"; //数据库,Table在非默认schema内时需要声明 - public static final String KEY_ABOUT = "@about"; //关于,返回数据库表的信息,包括表说明和字段说明 - public static final String KEY_COLUMN = "@column"; //查询的Table字段或SQL函数 - public static final String KEY_GROUP = "@group"; //分组方式 - public static final String KEY_HAVING = "@having"; //聚合函数条件,一般和@group一起用 - public static final String KEY_ORDER = "@order"; //排序方式 - //@key关键字都放这个类 >>>>>>>>>>>>>>>>>>>>>> - - - /**set role of request sender - * @param role - * @return this - */ - public JSONObject setRole(String role) { - return puts(KEY_ROLE, role); - } - - /**set try, ignore exceptions - * @param tri - * @return this - */ - public JSONObject setTry(boolean tri) { - return puts(KEY_TRY, tri); - } - - /**set drop, data dropped will not return - * @param drop - * @return this - */ - public JSONObject setDrop(boolean drop) { - return puts(KEY_DROP, drop); - } - - /**set correct, correct keys to target ones - * @param correct Map{originKey, [posibleKeys]}, posibleKey之间用 , 隔开 - * @return this - */ - public JSONObject setCorrect(Map correct) { - return puts(KEY_CORRECT, correct); - } - - - - /**set schema where table was puts - * @param schema - * @return this - */ - public JSONObject setSchema(String schema) { - return puts(KEY_SCHEMA, schema); - } - - /**set about - * @param about - * @return this - */ - public JSONObject setAbout(boolean about) { - return puts(KEY_ABOUT, about); - } - - /**set keys need to be returned - * @param keys key0, key1, key2 ... - * @return {@link #setColumn(String)} - */ - public JSONObject setColumn(String... keys) { - return setColumn(StringUtil.getString(keys, true)); - } - /**set keys need to be returned - * @param keys "key0,key1,key2..." - * @return - */ - public JSONObject setColumn(String keys) { - return puts(KEY_COLUMN, keys); - } - - /**set keys for group by - * @param keys key0, key1, key2 ... - * @return {@link #setGroup(String)} - */ - public JSONObject setGroup(String... keys) { - return setGroup(StringUtil.getString(keys, true)); - } - /**set keys for group by - * @param keys "key0,key1,key2..." - * @return - */ - public JSONObject setGroup(String keys) { - return puts(KEY_GROUP, keys); - } - - /**set keys for having - * @param keys count(key0) > 1, sum(key1) <= 5, function2(key2) ? value2 ... - * @return {@link #setHaving(String)} - */ - public JSONObject setHaving(String... keys) { - return setHaving(StringUtil.getString(keys, true)); - } - /**set keys for having - * @param keys "key0,key1,key2..." - * @return - */ - public JSONObject setHaving(String keys) { - return puts(KEY_HAVING, keys); - } - - /**set keys for order by - * @param keys key0, key1+, key2- ... - * @return {@link #setOrder(String)} - */ - public JSONObject setOrder(String... keys) { - return setOrder(StringUtil.getString(keys, true)); - } - /**set keys for order by - * @param keys "key0,key1+,key2-..." - * @return - */ - public JSONObject setOrder(String keys) { - return puts(KEY_ORDER, keys); - } - - - //JSONObject内关键词 key >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //Request <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - - /** - * @param key - * @param keys path = keys[0] + "/" + keys[1] + "/" + keys[2] + ... - * @return {@link #puts(String, Object)} - */ - public JSONObject putsPath(String key, String... keys) { - return puts(key+"@", StringUtil.getString(keys, "/")); - } - - /** - * @param key - * @param isNull - * @return {@link #puts(String, Object)} - */ - public JSONObject putsNull(String key, boolean isNull) { - return puts(key+"{}", SQL.isNull(isNull)); - } - /** - * trim = false - * @param key - * @param isEmpty - * @return {@link #putsEmpty(String, boolean, boolean)} - */ - public JSONObject putsEmpty(String key, boolean isEmpty) { - return putsEmpty(key, isEmpty, false); - } - /** - * @param key - * @param isEmpty - * @return {@link #puts(String, Object)} - */ - public JSONObject putsEmpty(String key, boolean isEmpty, boolean trim) { - return puts(key+"{}", SQL.isEmpty(key, isEmpty, trim)); - } - /** - * @param key - * @param compare <=0, >5 ... - * @return {@link #puts(String, Object)} - */ - public JSONObject putsLength(String key, String compare) { - return puts(key+"{}", SQL.length(key) + compare); - } - - /**设置搜索 - * type = SEARCH_TYPE_CONTAIN_FULL - * @param key - * @param value - * @return {@link #putsSearch(String, String, int)} - */ - public JSONObject putsSearch(String key, String value) { - return putsSearch(key, value, SQL.SEARCH_TYPE_CONTAIN_FULL); - } - /**设置搜索 - * @param key - * @param value - * @param type - * @return {@link #puts(String, Object)} - */ - public JSONObject putsSearch(String key, String value, int type) { - return puts(key+"$", SQL.search(value, type)); - } - - //Request >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - /**puts key-value in object into this - * @param object - * @return this - */ - public JSONObject putsAll(Map map) { - putAll(map); - return this; - } - @Override - public void putAll(Map map) { - if (map != null && map.isEmpty() == false) { - super.putAll(map); - } - } - - - - /**put and return this - * @param value must be annotated by {@link MethodAccess} - * @return {@link #puts(String, boolean)} - */ - public JSONObject puts(Object value) { - return puts(null, value); - } - /**put and return this - * @param key - * @param value - * @return this - * @see {@link #put(String, Object)} - */ - public JSONObject puts(String key, Object value) { - put(key, value); - return this; - } - - /**put and return value - * @param value must be annotated by {@link MethodAccess} - * @return {@link #put(String, boolean)} - */ - public Object put(Object value) { - return put(null, value); - } - /**put and return value - * @param key StringUtil.isEmpty(key, true) ? key = value.getClass().getSimpleName(); - * @param value - * @return value - */ - @Override - public Object put(String key, Object value) { - if (value == null) { - Log.e(TAG, "put value == null >> return null;"); - return null; - } - if (StringUtil.isEmpty(key, true)) { - Class clazz = value.getClass(); - if (clazz == null || clazz.getAnnotation(MethodAccess.class) == null) { - throw new IllegalArgumentException("puts StringUtil.isNotEmpty(key, true) == false" + - " && clazz == null || clazz.getAnnotation(MethodAccess.class) == null" + - " \n key为空时仅支持 类型被@MethodAccess注解 的value !!!" + - " \n 如果一定要这么用,请对 " + clazz.getName() + " 注解!" + - " \n 如果是类似 key[]:{} 结构的请求,建议用 putsAll(...) !"); - } - key = value.getClass().getSimpleName(); - } - return super.put(key, value); - } - - - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSONRequest.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSONRequest.java deleted file mode 100644 index 51d064731..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSONRequest.java +++ /dev/null @@ -1,147 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import java.util.Map; - -/**wrapper for request - * @author Lemon - * @see #puts - * @see #toArray - * @use JSONRequest request = new JSONRequest(...); - *
request.puts(...);//not a must - *
request.toArray(...);//not a must - */ -public class JSONRequest extends JSONObject { - private static final long serialVersionUID = 1L; - - public JSONRequest() { - super(); - } - /** - * @param object must be annotated by {@link MethodAccess} - * @see {@link #JSONRequest(String, Object)} - */ - public JSONRequest(Object object) { - this(null, object); - } - /** - * @param name - * @param object - * @see {@link #puts(String, Object)} - */ - public JSONRequest(String name, Object object) { - this(); - puts(name, object); - } - - - - - public static final String KEY_TAG = "tag";//只在最外层,最外层用JSONRequest - public static final String KEY_VERSION = "version";//只在最外层,最外层用JSONRequest - - /**set "tag":tag in outermost layer - * for write operations - * @param tag - * @return - */ - public JSONRequest setTag(String tag) { - return puts(KEY_TAG, tag); - } - /**set "version":version in outermost layer - * for target version of request - * @param version - * @return - */ - public JSONRequest setVersion(String version) { - return puts(KEY_VERSION, version); - } - - - //array object <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - public static final int QUERY_TABLE = 0; - public static final int QUERY_TOTAL = 1; - public static final int QUERY_ALL = 2; - - public static final String KEY_QUERY = "query"; - public static final String KEY_COUNT = "count"; - public static final String KEY_PAGE = "page"; - - /**set what to query in Array layer - * @param query what need to query, Table,total,ALL? - * @return - * @see {@link #QUERY_TABLE} - * @see {@link #QUERY_TOTAL} - * @see {@link #QUERY_ALL} - */ - public JSONRequest setQuery(int query) { - return puts(KEY_QUERY, query); - } - /**set maximum count of Tables to query in Array layer - * @param count <= 0 || >= max ? max : count - * @return - */ - public JSONRequest setCount(int count) { - return puts(KEY_COUNT, count); - } - /**set page of Tables to query in Array layer - * @param page <= 0 ? 0 : page - * @return - */ - public JSONRequest setPage(int page) { - return puts(KEY_PAGE, page); - } - //array object >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - /**create a parent JSONObject named KEY_ARRAY - * @param count - * @param page - * @return {@link #toArray(int, int, boolean)} - */ - public JSONRequest toArray(int count, int page) { - return toArray(count, page, null); - } - /**create a parent JSONObject named name+KEY_ARRAY. - * @param count - * @param page - * @param name - * @return {name+KEY_ARRAY : this}. if needs to be put, use {@link #add(com.alibaba.fastjson.JSONObject)} instead - */ - public JSONRequest toArray(int count, int page, String name) { - return new JSONRequest(StringUtil.getString(name) + KEY_ARRAY, this.setCount(count).setPage(page)); - } - - - @Override - public JSONObject putsAll(Map map) { - super.putsAll(map); - return this; - } - - @Override - public JSONRequest puts(Object value) { - return puts(null, value); - } - @Override - public JSONRequest puts(String key, Object value) { - super.puts(key, value); - return this; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSONResponse.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSONResponse.java deleted file mode 100644 index f9b6d3fc9..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/JSONResponse.java +++ /dev/null @@ -1,400 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import java.util.List; -import java.util.Set; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/**parser for response - * @author Lemon - * @see #getObject - * @see #getList - * @use JSONResponse response = new JSONResponse(json); - *
User user = response.getObject(User.class);//not a must - *
List commenntList = response.getList("Comment[]", Comment.class);//not a must - */ -public class JSONResponse extends zuo.biao.apijson.JSONObject { - private static final long serialVersionUID = 1L; - - private static final String TAG = "JSONResponse"; - - public JSONResponse() { - super(); - } - public JSONResponse(String json) { - this(parseObject(json)); - } - public JSONResponse(JSONObject object) { - super(format(object)); - } - - //状态信息,非GET请求获得的信息<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - public static final int CODE_SUCCESS = 200; //成功 - public static final int CODE_UNSUPPORTED_ENCODING = 400; //编码错误 - public static final int CODE_ILLEGAL_ACCESS = 401; //权限错误 - public static final int CODE_UNSUPPORTED_OPERATION = 403; //禁止操作 - public static final int CODE_NOT_FOUND = 404; //未找到 - public static final int CODE_ILLEGAL_ARGUMENT = 406; //参数错误 - public static final int CODE_NOT_LOGGED_IN = 407; //未登录 - public static final int CODE_TIME_OUT = 408; //超时 - public static final int CODE_CONFLICT = 409; //重复,已存在 - public static final int CODE_CONDITION_ERROR = 412; //条件错误,如密码错误 - public static final int CODE_UNSUPPORTED_TYPE = 415; //类型错误 - public static final int CODE_OUT_OF_RANGE = 416; //超出范围 - public static final int CODE_NULL_POINTER = 417; //对象为空 - public static final int CODE_SERVER_ERROR = 500; //服务器内部错误 - - - public static final String MSG_SUCCEED = "success"; //成功 - public static final String MSG_SERVER_ERROR = "Internal Server Error!"; //服务器内部错误 - - - public static final String KEY_CODE = "code"; - public static final String KEY_MSG = "msg"; - public static final String KEY_ID = "id"; - public static final String KEY_ID_IN = KEY_ID + "{}"; - public static final String KEY_COUNT = "count"; - public static final String KEY_TOTAL = "total"; - - /**获取状态 - * @return - */ - public int getCode() { - try { - return getIntValue(KEY_CODE); - } catch (Exception e) { - //empty - } - return 0; - } - /**获取信息 - * @return - */ - public String getMsg() { - return getString(KEY_MSG); - } - /**获取id - * @return - */ - public long getId() { - try { - return getLongValue(KEY_ID); - } catch (Exception e) { - //empty - } - return 0; - } - /**获取数量 - * @return - */ - public int getCount() { - try { - return getIntValue(KEY_COUNT); - } catch (Exception e) { - //empty - } - return 0; - } - /**获取总数 - * @return - */ - public int getTotal() { - try { - return getIntValue(KEY_TOTAL); - } catch (Exception e) { - //empty - } - return 0; - } - - - /**是否成功 - * @return - */ - public boolean isSuccess() { - return isSuccess(getCode()); - } - /**是否成功 - * @param code - * @return - */ - public static boolean isSuccess(int code) { - return code == CODE_SUCCESS; - } - /**是否成功 - * @param response - * @return - */ - public static boolean isSuccess(JSONResponse response) { - return response != null && response.isSuccess(); - } - - /**校验服务端是否存在table - * @return - */ - public boolean isExist() { - return isExist(getCount()); - } - /**校验服务端是否存在table - * @param count - * @return - */ - public static boolean isExist(int count) { - return count > 0; - } - /**校验服务端是否存在table - * @param response - * @return - */ - public static boolean isExist(JSONResponse response) { - return response != null && response.isExist(); - } - - /**获取内部的JSONResponse - * @param key - * @return - */ - public JSONResponse getJSONResponse(String key) { - return getObject(key, JSONResponse.class); - } - //状态信息,非GET请求获得的信息>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - - - /** - * key = clazz.getSimpleName() - * @param clazz - * @return - */ - public T getObject(Class clazz) { - return getObject(clazz == null ? "" : clazz.getSimpleName(), clazz); - } - /** - * @param key - * @param clazz - * @return - */ - public T getObject(String key, Class clazz) { - return getObject(this, key, clazz); - } - /** - * @param object - * @param key - * @param clazz - * @return - */ - public static T getObject(JSONObject object, String key, Class clazz) { - return toObject(object == null ? null : object.getJSONObject(key), clazz); - } - - /** - * @param clazz - * @return - */ - public T toObject(Class clazz) { - return toObject(this, clazz); - } - /** - * @param object - * @param clazz - * @return - */ - public static T toObject(JSONObject object, Class clazz) { - return JSON.parseObject(JSON.toJSONString(object), clazz); - } - - - - - /** - * key = KEY_ARRAY - * @param clazz - * @return - */ - public List getList(Class clazz) { - return getList(KEY_ARRAY, clazz); - } - /** - * arrayObject = this - * @param key - * @param clazz - * @return - */ - public List getList(String key, Class clazz) { - return getList(this, key, clazz); - } - - /** - * key = KEY_ARRAY - * @param object - * @param clazz - * @return - */ - public static List getList(JSONObject object, Class clazz) { - return getList(object, KEY_ARRAY, clazz); - } - /** - * @param object - * @param key - * @param clazz - * @return - */ - public static List getList(JSONObject object, String key, Class clazz) { - return object == null ? null : JSON.parseArray(object.getString(replaceArray(key)), clazz); - } - - /** - * key = KEY_ARRAY - * @return - */ - public JSONArray getArray() { - return getArray(KEY_ARRAY); - } - /** - * @param key - * @return - */ - public JSONArray getArray(String key) { - return getArray(this, key); - } - /** - * @param object - * @return - */ - public static JSONArray getArray(JSONObject object) { - return getArray(object, KEY_ARRAY); - } - /** - * key = KEY_ARRAY - * @param object - * @param key - * @return - */ - public static JSONArray getArray(JSONObject object, String key) { - return object == null ? null : object.getJSONArray(replaceArray(key)); - } - - - // /** - // * @return - // */ - // public JSONObject format() { - // return format(this); - // } - /**格式化key名称 - * @param object - * @return - */ - public static JSONObject format(final JSONObject object) { - //太长查看不方便,不如debug Log.i(TAG, "format object = \n" + JSON.toJSONString(object)); - if (object == null || object.isEmpty()) { - Log.i(TAG, "format object == null || object.isEmpty() >> return object;"); - return object; - } - JSONObject formatedObject = new JSONObject(true); - - Set set = object.keySet(); - if (set != null) { - - Object value; - for (String key : set) { - value = object.get(key); - - if (value instanceof JSONArray) {//JSONArray,遍历来format内部项 - formatedObject.put(replaceArray(key), format((JSONArray) value)); - } - else if (value instanceof JSONObject) {//JSONObject,往下一级提取 - formatedObject.put(getSimpleName(key), format((JSONObject) value)); - } - else {//其它Object,直接填充 - formatedObject.put(getSimpleName(key), value); - } - } - } - - //太长查看不方便,不如debug Log.i(TAG, "format return formatedObject = " + JSON.toJSONString(formatedObject)); - return formatedObject; - } - - /**格式化key名称 - * @param array - * @return - */ - public static JSONArray format(final JSONArray array) { - //太长查看不方便,不如debug Log.i(TAG, "format array = \n" + JSON.toJSONString(array)); - if (array == null || array.isEmpty()) { - Log.i(TAG, "format array == null || array.isEmpty() >> return array;"); - return array; - } - JSONArray formatedArray = new JSONArray(); - - Object value; - for (int i = 0; i < array.size(); i++) { - value = array.get(i); - if (value instanceof JSONArray) {//JSONArray,遍历来format内部项 - formatedArray.add(format((JSONArray) value)); - } - else if (value instanceof JSONObject) {//JSONObject,往下一级提取 - formatedArray.add(format((JSONObject) value)); - } - else {//其它Object,直接填充 - formatedArray.add(value); - } - } - - //太长查看不方便,不如debug Log.i(TAG, "format return formatedArray = " + JSON.toJSONString(formatedArray)); - return formatedArray; - } - - /**替换key+KEY_ARRAY为keyList - * @param key - * @return getSimpleName(isArrayKey(key) ? getArrayKey(...) : key) {@link #getSimpleName(String)} - */ - public static String replaceArray(String key) { - if (isArrayKey(key)) { - key = getArrayKey(key.substring(0, key.lastIndexOf(KEY_ARRAY))); - } - return getSimpleName(key); - } - /**获取列表变量名 - * @param key => StringUtil.getNoBlankString(key) - * @return empty ? "list" : key + "List" 且首字母小写 - */ - public static String getArrayKey(String key) { - return StringUtil.addSuffix(key, "list"); - } - - /**获取简单名称 - * @param fullName name 或 name:alias - * @return name => name; name:alias => alias - */ - public static String getSimpleName(String fullName) { - //key:alias -> alias; key:alias[] -> alias[] - int index = fullName == null ? -1 : fullName.indexOf(":"); - if (index >= 0) { - fullName = fullName.substring(index + 1); - } - return fullName; - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/Log.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/Log.java deleted file mode 100644 index 4d58c621c..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/Log.java +++ /dev/null @@ -1,74 +0,0 @@ -/*Copyright ©2015 TommyLemon(https://github.com/TommyLemon) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -/**测试用Log - * @modifier Lemon - */ -public class Log { - - private static final boolean DEBUG = true; - - /** - * @param TAG - * @param msg - */ - public static void d(String TAG, String msg) { - if (DEBUG) { - System.err.println(TAG + ".DEBUG: " + msg); - } - } - - /** - * @param TAG - * @param msg - */ - public static void v(String TAG, String msg) { - if (DEBUG) { - System.out.println(TAG + ".VERBOSE: " + msg); - } - } - - /** - * @param TAG - * @param msg - */ - public static void i(String TAG, String msg) { - if (DEBUG) { - System.out.println(TAG + ".INFO: " + msg); - } - } - - /** - * @param TAG - * @param msg - */ - public static void e(String TAG, String msg) { - if (DEBUG) { - System.err.println(TAG + ".ERROR: " + msg); - } - } - - /** - * @param TAG - * @param msg - */ - public static void w(String TAG, String msg) { - if (DEBUG) { - System.err.println(TAG + ".WARN: " + msg); - } - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/MethodAccess.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/MethodAccess.java deleted file mode 100644 index 939571625..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/MethodAccess.java +++ /dev/null @@ -1,73 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.CIRCLE; -import static zuo.biao.apijson.RequestRole.CONTACT; -import static zuo.biao.apijson.RequestRole.LOGIN; -import static zuo.biao.apijson.RequestRole.OWNER; -import static zuo.biao.apijson.RequestRole.UNKNOWN; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/**请求方法权限,只允许某些角色通过对应方法访问 - * @author Lemon - */ -@Documented -@Retention(RUNTIME) -@Target(TYPE) -public @interface MethodAccess { - - /**@see {@link RequestMethod#GET} - * @return 该请求方法允许的角色 default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - */ - RequestRole[] GET() default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - - /**@see {@link RequestMethod#HEAD} - * @return 该请求方法允许的角色 default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - */ - RequestRole[] HEAD() default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - - /**@see {@link RequestMethod#GETS} - * @return 该请求方法允许的角色 default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - */ - RequestRole[] GETS() default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - - /**@see {@link RequestMethod#HEADS} - * @return 该请求方法允许的角色 default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - */ - RequestRole[] HEADS() default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - - /**@see {@link RequestMethod#POST} - * @return 该请求方法允许的角色 default {LOGIN, ADMIN}; - */ - RequestRole[] POST() default {LOGIN, ADMIN}; - - /**@see {@link RequestMethod#PUT} - * @return 该请求方法允许的角色 default {OWNER, ADMIN}; - */ - RequestRole[] PUT() default {OWNER, ADMIN}; - - /**@see {@link RequestMethod#DELETE} - * @return 该请求方法允许的角色 default {OWNER, ADMIN}; - */ - RequestRole[] DELETE() default {OWNER, ADMIN}; - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/MethodStructure.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/MethodStructure.java deleted file mode 100644 index 27c30c96d..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/MethodStructure.java +++ /dev/null @@ -1,58 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/**对应方法的请求结构。 - * 仅测试和基本的校验用,实际用Request表里的配置 - * @author Lemon - */ -@Documented -@Retention(RUNTIME) -@Target(TYPE) -public @interface MethodStructure { - - /**@see {@link RequestMethod#HEADS} - * @return 该请求方法允许的结构 - */ - String HEADS() default ""; - - /**@see {@link RequestMethod#GETS} - * @return 该请求方法允许的结构 - */ - String GETS() default ""; - - /**@see {@link RequestMethod#POST} - * @return 该请求方法允许的结构 - */ - String POST() default ""; - - /**@see {@link RequestMethod#PUT} - * @return 该请求方法允许的结构 - */ - String PUT() default ""; - - /**@see {@link RequestMethod#DELETE} - * @return 该请求方法允许的结构 - */ - String DELETE() default ""; - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/RequestMethod.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/RequestMethod.java deleted file mode 100644 index a450baad8..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/RequestMethod.java +++ /dev/null @@ -1,94 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -/**请求方法,对应org.springframework.web.bind.annotation.RequestMethod,多出GETS,HEADS方法 - * @author Lemon - */ -public enum RequestMethod { - - /** - * 常规获取数据方式 - */ - GET, - - /** - * 检查,默认是非空检查,返回数据总数 - */ - HEAD, - - /**Safe, Single, Simple - *
限制性GET,通过POST来GET数据,不显示请求内容和返回结果,并且校验请求,一般用于对安全要求比较高的请求 - */ - GETS, - - /**Safe, Single, Simple - *
限制性HEAD,通过POST来HEAD数据,不显示请求内容和返回结果,并且校验请求,一般用于对安全要求比较高的请求 - */ - HEADS, - - /** - * 新增(或者说插入)数据 - */ - POST, - - /** - * 修改数据,只修改传入字段对应的值 - */ - PUT, - - /** - * 删除数据 - */ - DELETE; - - - /**是否为GET请求方法 - * @param method - * @param containPrivate 包含私密(非明文)获取方法GETS - * @return - */ - public static boolean isGetMethod(RequestMethod method, boolean containPrivate) { - boolean is = method == null || method == GET; - return containPrivate == false ? is : is || method == GETS; - } - - /**是否为HEAD请求方法 - * @param method - * @param containPrivate 包含私密(非明文)获取方法HEADS - * @return - */ - public static boolean isHeadMethod(RequestMethod method, boolean containPrivate) { - boolean is = method == HEAD; - return containPrivate == false ? is : is || method == HEADS; - } - - /**是否为查询的请求方法 - * @param method - * @return 读操作(GET型或HEAD型) - true, 写操作(POST,PUT,DELETE) - false - */ - public static boolean isQueryMethod(RequestMethod method) { - return isGetMethod(method, true) || isHeadMethod(method, true); - } - - /**是否为开放(不限制请求的结构或内容;明文,浏览器能直接访问及查看)的请求方法 - * @param method - * @return - */ - public static boolean isPublicMethod(RequestMethod method) { - return method == null || method == GET || method == HEAD; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/RequestRole.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/RequestRole.java deleted file mode 100644 index f3a777d67..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/RequestRole.java +++ /dev/null @@ -1,63 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -/**来访的用户角色 - * @author Lemon - */ -public enum RequestRole { - - /**未登录,不明身份的用户 - */ - UNKNOWN, - - /**已登录的用户 - */ - LOGIN, - - /**联系人,必须已登录 - */ - CONTACT, - - /**圈子成员(CONTACT + OWNER),必须已登录 - */ - CIRCLE, - - /**拥有者,必须已登录 - */ - OWNER, - - /**管理员,必须已登录 - */ - ADMIN; - - //似乎不管怎么做,外部引用后都是空值。并且如果在注解内的位置不是最前的,还会导致被注解的类在其它类中import报错。 - //虽然直接打印显示正常,但被@MethodAccess内RequestRole[] GET()等方法引用后获取的是空值 - // public static final RequestRole[] ALL = {RequestRole.UNKNOWN};//values();//所有 - // public static final RequestRole[] HIGHS;//高级 - // static { - // HIGHS = new RequestRole[] {OWNER, ADMIN}; - // } - - public static RequestRole get(String name) { - try {//Enum.valueOf只要找不到对应的值就会抛异常 - return RequestRole.valueOf(StringUtil.toUpperCase(name)); - } catch (Exception e) { - //empty - } - return null; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/SQL.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/SQL.java deleted file mode 100644 index a9da023e5..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/SQL.java +++ /dev/null @@ -1,389 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -/**SQL语句,函数名尽量和JDK中相同或类似功能的函数的名称一致 - * @author Lemon - */ -public class SQL { - - public static final String OR = " OR "; - public static final String AND = " AND "; - public static final String NOT = " NOT "; - public static final String AS = " AS "; - public static final String IS = " is "; - public static final String NULL = " null "; - - //括号必须紧跟函数名! count (...) 报错! - public static final String COUNT = "count"; - public static final String SUM = "sum"; - public static final String MAX = "max"; - public static final String MIN = "min"; - public static final String AVG = "avg"; - - /** - * isNull = true - * @return {@link #isNull(boolean)} - */ - public static String isNull() { - return isNull(true); - } - /** - * @param isNull - * @return {@link #IS} + (isNull ? "" : {@link #NOT}) + {@link #NULL}; - */ - public static String isNull(boolean isNull) { - return IS + (isNull ? "" : NOT) + NULL; - } - /** - * isNull = true - * @param s - * @return {@link #isNull(String, boolean)} - */ - public static String isNull(String s) { - return isNull(s, true); - } - /** - * @param s - * @param isNull - * @return s + {@link #isNull(boolean)} - */ - public static String isNull(String s, boolean isNull) { - return s + isNull(isNull); - } - - /** - * isEmpty = true - * @param s - * @return {@link #isEmpty(String, boolean)} - */ - public static String isEmpty(String s) { - return isEmpty(s, true); - } - /** - * trim = false - * @param s - * @param isEmpty - * @return {@link #isEmpty(String, boolean, boolean)} - */ - public static String isEmpty(String s, boolean isEmpty) { - return isEmpty(s, isEmpty, false); - } - /** - * nullable = true - * @param s - * @param isEmpty <=0 - * @param trim s = trim(s); - * @return {@link #isEmpty(String, boolean, boolean, boolean)} - */ - public static String isEmpty(String s, boolean isEmpty, boolean trim) { - return isEmpty(s, isEmpty, trim, true); - } - /** - * @param s - * @param isEmpty <=0 - * @param trim s = trim(s); - * @param nullable isNull(s, true) + {@link #OR} + - * @return {@link #lengthCompare(String, String)} - */ - public static String isEmpty(String s, boolean isEmpty, boolean trim, boolean nullable) { - if (trim) { - s = trim(s); - } - return (nullable ? isNull(s, true) + OR : "") + lengthCompare(s, (isEmpty ? "<=" : ">") + "0"); - } - /** - * @param s 因为POWER(x,y)等函数含有不只一个key,所以需要客户端添加进去,服务端检测到条件中有'('和')'时就不转换,直接当SQL语句查询 - * @return {@link #length(String)} + compare - */ - public static String lengthCompare(String s, String compare) { - return length(s) + compare; - } - - - /** - * @param s 因为POWER(x,y)等函数含有不只一个key,所以需要客户端添加进去,服务端检测到条件中有'('和')'时就不转换,直接当SQL语句查询 - * @return "length(" + s + ")" - */ - public static String length(String s) { - return "length(" + s + ")"; - } - /** - * @param s 因为POWER(x,y)等函数含有不只一个key,所以需要客户端添加进去,服务端检测到条件中有'('和')'时就不转换,直接当SQL语句查询 - * @return "char_length(" + s + ")" - */ - public static String charLength(String s) { - return "char_length(" + s + ")"; - } - - /** - * @param s - * @return "trim(" + s + ")" - */ - public static String trim(String s) { - return "trim(" + s + ")"; - } - /** - * @param s - * @return "ltrim(" + s + ")" - */ - public static String trimLeft(String s) { - return "ltrim(" + s + ")"; - } - /** - * @param s - * @return "rtrim(" + s + ")" - */ - public static String trimRight(String s) { - return "rtrim(" + s + ")"; - } - - /** - * @param s - * @param n - * @return "left(" + s + "," + n + ")" - */ - public static String left(String s, int n) { - return "left(" + s + "," + n + ")"; - } - /** - * @param s - * @param n - * @return "right(" + s + "," + n + ")" - */ - public static String right(String s, int n) { - return "right(" + s + "," + n + ")"; - } - - /** - * @param s - * @param start - * @param end - * @return "substring(" + s + "," + start + "," + (end-start) + ")" - */ - public static String subString(String s, int start, int end) { - return "substring(" + s + "," + start + "," + (end-start) + ")"; - } - - /** - * @param s - * @param c -> 'c' - * @return "instr(" + s + ", '" + c + "')" - */ - public static String indexOf(String s, String c) { - return "instr(" + s + ", '" + c + "')"; - } - - /** - * @param s - * @param c1 -> 'c1' - * @param c2 -> 'c2' - * @return "replace(" + s + ", '" + c1 + "', '" + c2 + "')" - */ - public static String replace(String s, String c1, String c2) { - return "replace(" + s + ", '" + c1 + "', '" + c2 + "')"; - } - - /** - * @param s1 - * @param s2 -> 's2' - * @return "strcmp(" + s1 + ", '" + s2 + "')" - */ - public static String equals(String s1, String s2) { - return "strcmp(" + s1 + ", '" + s2 + "')"; - } - - /** - * @param s - * @return "upper(" + s + ")" - */ - public static String toUpperCase(String s) { - return "upper(" + s + ")"; - } - /** - * @param s - * @return "lower(" + s + ")" - */ - public static String toLowerCase(String s) { - return "lower(" + s + ")"; - } - - - - - //column and function<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**字段 - * @param column - * @return column.isEmpty() ? "*" : column; - */ - public static String column(String column) { - column = StringUtil.getTrimedString(column); - return column.isEmpty() ? "*" : column; - } - /**有别名的字段 - * @param column - * @return {@link #count(String)} + {@link #AS}; - */ - public static String columnAs(String column) { - return count(column) + AS; - } - - /**函数 - * @param column if (StringUtil.isEmpty(column, true) || column.contains(",")) -> column = null; - * @return " " + fun + "(" + {@link #column(String)} + ") "; - */ - public static String function(String fun, String column) { - if (StringUtil.isEmpty(column, true) || column.contains(",")) { - column = null; //解决 count(id,name) 这种多个字段导致的SQL异常 - } - return " " + fun + "(" + column(column) + ") "; - } - /**有别名的函数 - * @param column - * @return {@link #function(String, String)} + {@link #AS} + fun; - */ - public static String functionAs(String fun, String column) { - return function(fun, column) + AS + fun + " "; - } - - /**计数 - * column = null - * @return {@link #count(String)} - */ - public static String count() { - return count(null); - } - /**计数 - * fun = {@link #COUNT} - * @param column - * @return {@link #functionAs(String, String)} - */ - public static String count(String column) { - return functionAs(COUNT, column); - } - /**求和 - * fun = {@link #SUM} - * @param column - * @return {@link #functionAs(String, String)} - */ - public static String sum(String column) { - return functionAs(SUM, column); - } - /**最大值 - * fun = {@link #MAX} - * @param column - * @return {@link #functionAs(String, String)} - */ - public static String max(String column) { - return functionAs(MAX, column); - } - /**最小值 - * fun = {@link #MIN} - * @param column - * @return {@link #functionAs(String, String)} - */ - public static String min(String column) { - return functionAs(MIN, column); - } - /**平均值 - * fun = {@link #AVG} - * @param column - * @return {@link #functionAs(String, String)} - */ - public static String avg(String column) { - return functionAs(AVG, column); - } - - //column and function>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //search<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - public static final int SEARCH_TYPE_CONTAIN_FULL = 0; - public static final int SEARCH_TYPE_CONTAIN_ORDER = 1; - public static final int SEARCH_TYPE_CONTAIN_SINGLE = 2; - public static final int SEARCH_TYPE_CONTAIN_ANY = 3; - public static final int SEARCH_TYPE_START = 4; - public static final int SEARCH_TYPE_END = 5; - public static final int SEARCH_TYPE_START_SINGLE = 6; - public static final int SEARCH_TYPE_END_SINGLE = 7; - public static final int SEARCH_TYPE_PART_MATCH = 8; - /**获取搜索值 - * @param s - * @return - */ - public static String search(String s) { - return search(s, SEARCH_TYPE_CONTAIN_FULL); - } - /**获取搜索值 - * @param s - * @param type - * @return - */ - public static String search(String s, int type) { - return search(s, type, true); - } - /**获取搜索值 - * @param s - * @param type - * @param ignoreCase - * @return default SEARCH_TYPE_CONTAIN_FULL - */ - public static String search(String s, int type, boolean ignoreCase) { - if (s == null) { - return null; - } - switch (type) { - case SEARCH_TYPE_CONTAIN_SINGLE: - return "_" + s + "_"; - case SEARCH_TYPE_CONTAIN_ORDER: - char[] cs = s.toCharArray(); - if (cs == null) { - return null; - } - String value = "%"; - for (int i = 0; i < cs.length; i++) { - value += cs[i] + "%"; - } - return value; - case SEARCH_TYPE_START: - return s + "%"; - case SEARCH_TYPE_END: - return "%" + s; - case SEARCH_TYPE_START_SINGLE: - return s + "_"; - case SEARCH_TYPE_END_SINGLE: - return "_" + s; - case SEARCH_TYPE_CONTAIN_ANY: - case SEARCH_TYPE_PART_MATCH: - cs = s.toCharArray(); - if (cs == null) { - return null; - } - value = ""; - for (int i = 0; i < cs.length; i++) { - value += search("" + cs[i], SEARCH_TYPE_CONTAIN_FULL, ignoreCase); - } - return value; - default://SEARCH_TYPE_CONTAIN_FULL - return "%" + s + "%"; - } - } - - //search>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/StringUtil.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/StringUtil.java deleted file mode 100755 index b219b430a..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/StringUtil.java +++ /dev/null @@ -1,842 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import java.io.File; -import java.math.BigDecimal; -import java.text.DecimalFormat; -import java.util.regex.Pattern; - -/**通用字符串(String)相关类,为null时返回"" - * @author Lemon - * @use StringUtil. - */ -public class StringUtil { - private static final String TAG = "StringUtil"; - - public StringUtil() { - } - - public static final String UTF_8 = "utf-8"; - - public static final String EMPTY = "无"; - public static final String UNKNOWN = "未知"; - public static final String UNLIMITED = "不限"; - - public static final String I = "我"; - public static final String YOU = "你"; - public static final String HE = "他"; - public static final String SHE = "她"; - public static final String IT = "它"; - - public static final String MALE = "男"; - public static final String FEMALE = "女"; - - public static final String TODO = "未完成"; - public static final String DONE = "已完成"; - - public static final String FAIL = "失败"; - public static final String SUCCESS = "成功"; - - public static final String SUNDAY = "日"; - public static final String MONDAY = "一"; - public static final String TUESDAY = "二"; - public static final String WEDNESDAY = "三"; - public static final String THURSDAY = "四"; - public static final String FRIDAY = "五"; - public static final String SATURDAY = "六"; - - public static final String YUAN = "元"; - - - private static String currentString = ""; - /**获取刚传入处理后的string - * @must 上个影响currentString的方法 和 这个方法都应该在同一线程中,否则返回值可能不对 - * @return - */ - public static String getCurrentString() { - return currentString == null ? "" : currentString; - } - - //获取string,为null时返回"" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**获取string,为null则返回"" - * @param object - * @return - */ - public static String getString(Object object) { - return object == null ? "" : getString(String.valueOf(object)); - } - /**获取string,为null则返回"" - * @param cs - * @return - */ - public static String getString(CharSequence cs) { - return cs == null ? "" : getString(cs.toString()); - } - /**获取string,为null则返回"" - * @param s - * @return - */ - public static String getString(String s) { - return s == null ? "" : s; - } - /**获取string,为null则返回"" - * ignoreEmptyItem = false; - * split = "," - * @param array - * @return {@link #getString(String[], boolean)} - */ - public static String getString(Object[] array) { - return getString(array, false); - } - /**获取string,为null则返回"" - * split = "," - * @param array - * @param ignoreEmptyItem - * @return {@link #getString(String[], String, boolean)} - */ - public static String getString(Object[] array, boolean ignoreEmptyItem) { - return getString(array, null, ignoreEmptyItem); - } - /**获取string,为null则返回"" - * ignoreEmptyItem = false; - * @param array - * @param split - * @return {@link #getString(String[], String, boolean)} - */ - public static String getString(Object[] array, String split) { - return getString(array, split, false); - } - /**获取string,为null则返回"" - * @param array - * @param split - * @param ignoreEmptyItem - * @return - */ - public static String getString(Object[] array, String split, boolean ignoreEmptyItem) { - String s = ""; - if (array != null) { - if (split == null) { - split = ","; - } - for (int i = 0; i < array.length; i++) { - if (ignoreEmptyItem && isEmpty(array[i], true)) { - continue; - } - s += ((i > 0 ? split : "") + array[i]); - } - } - return getString(s); - } - - //获取string,为null时返回"" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //获取去掉前后空格后的string<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**获取去掉前后空格后的string,为null则返回"" - * @param object - * @return - */ - public static String getTrimedString(Object object) { - return getTrimedString(getString(object)); - } - /**获取去掉前后空格后的string,为null则返回"" - * @param cs - * @return - */ - public static String getTrimedString(CharSequence cs) { - return getTrimedString(getString(cs)); - } - /**获取去掉前后空格后的string,为null则返回"" - * @param s - * @return - */ - public static String getTrimedString(String s) { - return getString(s).trim(); - } - - //获取去掉前后空格后的string>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取去掉所有空格后的string <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**获取去掉所有空格后的string,为null则返回"" - * @param object - * @return - */ - public static String getNoBlankString(Object object) { - return getNoBlankString(getString(object)); - } - /**获取去掉所有空格后的string,为null则返回"" - * @param cs - * @return - */ - public static String getNoBlankString(CharSequence cs) { - return getNoBlankString(getString(cs)); - } - /**获取去掉所有空格后的string,为null则返回"" - * @param s - * @return - */ - public static String getNoBlankString(String s) { - return getString(s).replaceAll("\\s", ""); - } - - //获取去掉所有空格后的string >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取string的长度<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**获取string的长度,为null则返回0 - * @param object - * @param trim - * @return - */ - public static int getLength(Object object, boolean trim) { - return getLength(getString(object), trim); - } - /**获取string的长度,为null则返回0 - * @param cs - * @param trim - * @return - */ - public static int getLength(CharSequence cs, boolean trim) { - return getLength(getString(cs), trim); - } - /**获取string的长度,为null则返回0 - * @param s - * @param trim - * @return - */ - public static int getLength(String s, boolean trim) { - s = trim ? getTrimedString(s) : s; - return getString(s).length(); - } - - //获取string的长度>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //判断字符是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**判断字符是否为空 - * @param object - * @param trim - * @return - */ - public static boolean isEmpty(Object object, boolean trim) { - return isEmpty(getString(object), trim); - } - /**判断字符是否为空 - * @param cs - * @param trim - * @return - */ - public static boolean isEmpty(CharSequence cs, boolean trim) { - return isEmpty(getString(cs), trim); - } - /**判断字符是否为空 - * @param s - * @param trim - * @return - */ - public static boolean isEmpty(String s, boolean trim) { - // Log.i(TAG, "getTrimedString s = " + s); - if (s == null) { - return true; - } - if (trim) { - s = s.trim(); - } - if (s.isEmpty()) { - return true; - } - - currentString = s; - - return false; - } - - //判断字符是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //判断字符是否非空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**判断字符是否非空 - * @param object - * @param trim - * @return - */ - public static boolean isNotEmpty(Object object, boolean trim) { - return isNotEmpty(getString(object), trim); - } - /**判断字符是否非空 - * @param cs - * @param trim - * @return - */ - public static boolean isNotEmpty(CharSequence cs, boolean trim) { - return isNotEmpty(getString(cs), trim); - } - /**判断字符是否非空 - * @param s - * @param trim - * @return - */ - public static boolean isNotEmpty(String s, boolean trim) { - return ! isEmpty(s, trim); - } - - //判断字符是否非空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //判断字符类型 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - public static final Pattern PATTERN_NUMBER; - public static final Pattern PATTERN_PHONE; - public static final Pattern PATTERN_EMAIL; - public static final Pattern PATTERN_ID_CARD; - public static final Pattern PATTERN_ALPHA; - public static final Pattern PATTERN_PASSWORD; //TODO - public static final Pattern PATTERN_NAME; - public static final Pattern PATTERN_ALPHA_BIG; - public static final Pattern PATTERN_ALPHA_SMALL; - static { - PATTERN_NUMBER = Pattern.compile("^[0-9]+$"); - PATTERN_ALPHA = Pattern.compile("^[a-zA-Z]+$"); - PATTERN_ALPHA_BIG = Pattern.compile("^[A-Z]+$"); - PATTERN_ALPHA_SMALL = Pattern.compile("^[a-z]+$"); - PATTERN_NAME = Pattern.compile("^[0-9a-zA-Z_]+$");//已用55个中英字符测试通过 - PATTERN_PHONE = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0-2,5-9])|(17[0-9]))\\d{8}$"); - PATTERN_EMAIL = Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"); - PATTERN_ID_CARD = Pattern.compile("(^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{2}$)"); - PATTERN_PASSWORD = Pattern.compile("^[0-9a-zA-Z]+$"); - } - - /**判断手机格式是否正确 - * @param phone - * @return - */ - public static boolean isPhone(String phone) { - if (isNotEmpty(phone, true) == false) { - return false; - } - - currentString = phone; - return PATTERN_PHONE.matcher(phone).matches(); - } - /**判断手机格式是否正确 - * @param s - * @return - */ - public static boolean isPassword(String s) { - return getLength(s, false) >= 6 && PATTERN_PASSWORD.matcher(s).matches(); - } - /**判断是否全是数字密码 - * @param s - * @return - */ - public static boolean isNumberPassword(String s) { - return getLength(s, false) == 6 && isNumer(s); - } - /**判断email格式是否正确 - * @param email - * @return - */ - public static boolean isEmail(String email) { - if (isNotEmpty(email, true) == false) { - return false; - } - - currentString = email; - return PATTERN_EMAIL.matcher(email).matches(); - } - - - /**判断是否全是验证码 - * @param s - * @return - */ - public static boolean isVerify(String s) { - return getLength(s, false) >= 4 && isNumer(s); - } - /**判断是否全是数字 - * @param s - * @return - */ - public static boolean isNumer(String s) { - if (isNotEmpty(s, true) == false) { - return false; - } - - currentString = s; - return PATTERN_NUMBER.matcher(s).matches(); - } - /**判断是否全是字母 - * @param s - * @return - */ - public static boolean isAlpha(String s) { - if (isEmpty(s, true)) { - return false; - } - - currentString = s; - return PATTERN_ALPHA.matcher(s).matches(); - } - /**判断是否全是数字或字母 - * @param s - * @return - */ - public static boolean isNumberOrAlpha(String s) { - return isNumer(s) || isAlpha(s); - } - - /**判断是否为代码名称,只能包含字母,数字或下划线 - * @param s - * @return - */ - public static boolean isName(String s) { - return s != null && PATTERN_NAME.matcher(s).matches(); - } - /**判断是否为首字母大写的代码名称 - * @param key - * @return - */ - public static boolean isBigName(String s) { - s = getString(s); - if (s.isEmpty() || PATTERN_ALPHA_BIG.matcher(s.substring(0, 1)).matches() == false) { - return false; - } - return s.length() <= 1 ? true : isName(s.substring(1)); - } - /**判断是否为首字母小写的代码名称 - * @param key - * @return - */ - public static boolean isSmallName(String s) { - s = getString(s); - if (s.isEmpty() || PATTERN_ALPHA_SMALL.matcher(s.substring(0, 1)).matches() == false) { - return false; - } - return s.length() <= 1 ? true : isName(s.substring(1)); - } - - - /**判断字符类型是否是身份证号 - * @param number - * @return - */ - public static boolean isIDCard(String number) { - if (isNumberOrAlpha(number) == false) { - return false; - } - number = getString(number); - if (number.length() == 15) { - Log.i(TAG, "isIDCard number.length() == 15 old IDCard"); - currentString = number; - return true; - } - if (number.length() == 18) { - currentString = number; - return true; - } - - return false; - } - - public static final String HTTP = "http"; - public static final String URL_PREFIX = "http://"; - public static final String URL_PREFIXs = "https://"; - public static final String URL_STAFFIX = URL_PREFIX; - public static final String URL_STAFFIXs = URL_PREFIXs; - /**判断字符类型是否是网址 - * @param url - * @return - */ - public static boolean isUrl(String url) { - if (isNotEmpty(url, true) == false) { - return false; - } else if (! url.startsWith(URL_PREFIX) && ! url.startsWith(URL_PREFIXs)) { - return false; - } - - currentString = url; - return true; - } - - public static final String FILE_PATH_PREFIX = "file://"; - /**判断文件路径是否存在 - * @param path - * @return - */ - public static boolean isFilePathExist(String path) { - return StringUtil.isFilePath(path) && new File(path).exists(); - } - - public static final String SEPARATOR = "/"; - /**判断是否为路径 - * @param path - * @return - */ - public static boolean isPath(String path) { - return StringUtil.isNotEmpty(path, true) && path.contains(SEPARATOR) - && path.contains(SEPARATOR + SEPARATOR) == false && path.endsWith(SEPARATOR) == false; - } - - /**判断字符类型是否是路径 - * @param path - * @return - */ - public static boolean isFilePath(String path) { - if (isNotEmpty(path, true) == false) { - return false; - } - - if (! path.contains(".") || path.endsWith(".")) { - return false; - } - - currentString = path; - - return true; - } - - //判断字符类型 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //提取特殊字符<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**去掉string内所有非数字类型字符 - * @param object - * @return - */ - public static String getNumber(Object object) { - return getNumber(getString(object)); - } - /**去掉string内所有非数字类型字符 - * @param cs - * @return - */ - public static String getNumber(CharSequence cs) { - return getNumber(getString(cs)); - } - /**去掉string内所有非数字类型字符 - * @param s - * @return - */ - public static String getNumber(String s) { - return getNumber(s, false); - } - /**去掉string内所有非数字类型字符 - * @param s - * @param onlyStart 中间有非数字时只获取前面的数字 - * @return - */ - public static String getNumber(String s, boolean onlyStart) { - if (isNotEmpty(s, true) == false) { - return ""; - } - - String numberString = ""; - String single; - for (int i = 0; i < s.length(); i++) { - single = s.substring(i, i + 1); - if (isNumer(single)) { - numberString += single; - } else { - if (onlyStart) { - return numberString; - } - } - } - - return numberString; - } - - //提取特殊字符>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //校正(自动补全等)字符串<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**获取网址,自动补全 - * @param url - * @return - */ - public static String getCorrectUrl(String url) { - Log.i(TAG, "getCorrectUrl : \n" + url); - if (isNotEmpty(url, true) == false) { - return ""; - } - - // if (! url.endsWith("/") && ! url.endsWith(".html")) { - // url = url + "/"; - // } - - if (isUrl(url) == false) { - return URL_PREFIX + url; - } - return url; - } - - /**获取去掉所有 空格 、"-" 、"+86" 后的phone - * @param phone - * @return - */ - public static String getCorrectPhone(String phone) { - if (isNotEmpty(phone, true) == false) { - return ""; - } - - phone = getNoBlankString(phone); - phone = phone.replaceAll("-", ""); - if (phone.startsWith("+86")) { - phone = phone.substring(3); - } - return phone; - } - - - /**获取邮箱,自动补全 - * @param email - * @return - */ - public static String getCorrectEmail(String email) { - if (isNotEmpty(email, true) == false) { - return ""; - } - - email = getNoBlankString(email); - if (isEmail(email) == false && ! email.endsWith(".com")) { - email += ".com"; - } - - return email; - } - - - public static final int PRICE_FORMAT_DEFAULT = 0; - public static final int PRICE_FORMAT_PREFIX = 1; - public static final int PRICE_FORMAT_SUFFIX = 2; - public static final int PRICE_FORMAT_PREFIX_WITH_BLANK = 3; - public static final int PRICE_FORMAT_SUFFIX_WITH_BLANK = 4; - public static final String[] PRICE_FORMATS = { - "", "¥", "元", "¥ ", " 元" - }; - - /**获取价格,保留两位小数 - * @param price - * @return - */ - public static String getPrice(String price) { - return getPrice(price, PRICE_FORMAT_DEFAULT); - } - /**获取价格,保留两位小数 - * @param price - * @param formatType 添加单位(元) - * @return - */ - public static String getPrice(String price, int formatType) { - if (isNotEmpty(price, true) == false) { - return getPrice(0, formatType); - } - - //单独写到getCorrectPrice? <<<<<<<<<<<<<<<<<<<<<< - String correctPrice = ""; - String s; - for (int i = 0; i < price.length(); i++) { - s = price.substring(i, i + 1); - if (".".equals(s) || isNumer(s)) { - correctPrice += s; - } - } - //单独写到getCorrectPrice? >>>>>>>>>>>>>>>>>>>>>> - - Log.i(TAG, "getPrice <<<<<<<<<<<<<<<<<< correctPrice = " + correctPrice); - if (correctPrice.contains(".")) { - // if (correctPrice.startsWith(".")) { - // correctPrice = 0 + correctPrice; - // } - if (correctPrice.endsWith(".")) { - correctPrice = correctPrice.replaceAll(".", ""); - } - } - - Log.i(TAG, "getPrice correctPrice = " + correctPrice + " >>>>>>>>>>>>>>>>"); - return isNotEmpty(correctPrice, true) ? getPrice(new BigDecimal(0 + correctPrice), formatType) : getPrice(0, formatType); - } - /**获取价格,保留两位小数 - * @param price - * @return - */ - public static String getPrice(BigDecimal price) { - return getPrice(price, PRICE_FORMAT_DEFAULT); - } - /**获取价格,保留两位小数 - * @param price - * @return - */ - public static String getPrice(double price) { - return getPrice(price, PRICE_FORMAT_DEFAULT); - } - /**获取价格,保留两位小数 - * @param price - * @param formatType 添加单位(元) - * @return - */ - public static String getPrice(BigDecimal price, int formatType) { - return getPrice(price == null ? 0 : price.doubleValue(), formatType); - } - /**获取价格,保留两位小数 - * @param price - * @param formatType 添加单位(元) - * @return - */ - public static String getPrice(double price, int formatType) { - String s = new DecimalFormat("#########0.00").format(price); - switch (formatType) { - case PRICE_FORMAT_PREFIX: - return PRICE_FORMATS[PRICE_FORMAT_PREFIX] + s; - case PRICE_FORMAT_SUFFIX: - return s + PRICE_FORMATS[PRICE_FORMAT_SUFFIX]; - case PRICE_FORMAT_PREFIX_WITH_BLANK: - return PRICE_FORMATS[PRICE_FORMAT_PREFIX_WITH_BLANK] + s; - case PRICE_FORMAT_SUFFIX_WITH_BLANK: - return s + PRICE_FORMATS[PRICE_FORMAT_SUFFIX_WITH_BLANK]; - default: - return s; - } - } - - - /**分割路径 - * @param path - * @return - */ - public static String[] splitPath(String path) { - if (StringUtil.isNotEmpty(path, true) == false) { - return null; - } - return isPath(path) ? split(path, SEPARATOR) : new String[] {path}; - } - /**将s分割成String[] - * @param s - * @return - */ - public static String[] split(String s) { - return split(s, null); - } - /**将s用split分割成String[] - * trim = true; - * @param s - * @param split - * @return - */ - public static String[] split(String s, String split) { - return split(s, split, true); - } - /**将s用split分割成String[] - * @param s - * @param split - * @param trim 去掉前后两端的split - * @return - */ - public static String[] split(String s, String split, boolean trim) { - s = getString(s); - if (s.isEmpty()) { - return null; - } - if (isNotEmpty(split, false) == false) { - split = ","; - } - if (trim) { - while (s.startsWith(split)) { - s = s.substring(split.length()); - } - while (s.endsWith(split)) { - s = s.substring(0, s.length() - split.length()); - } - } - return s.contains(split) ? s.split(split) : new String[]{s}; - } - - /** - * @param key - * @param suffix - * @return key + suffix,第一个字母小写 - */ - public static String addSuffix(String key, String suffix) { - key = getNoBlankString(key); - if (key.isEmpty()) { - return firstCase(suffix); - } - return firstCase(key) + firstCase(suffix, true); - } - /** - * @param key - */ - public static String firstCase(String key) { - return firstCase(key, false); - } - /** - * @param key - * @param upper - * @return - */ - public static String firstCase(String key, boolean upper) { - key = getString(key); - if (key.isEmpty()) { - return ""; - } - - String first = key.substring(0, 1); - key = (upper ? first.toUpperCase() : first.toLowerCase()) + key.substring(1, key.length()); - - return key; - } - - /**全部大写 - * @param s - * @return - */ - public static String toUpperCase(String s) { - return toUpperCase(s, false); - } - /**全部大写 - * @param s - * @param trim - * @return - */ - public static String toUpperCase(String s, boolean trim) { - s = trim ? getTrimedString(s) : getString(s); - return s.toUpperCase(); - } - /**全部小写 - * @param s - * @return - */ - public static String toLowerCase(String s) { - return toLowerCase(s, false); - } - /**全部小写 - * @param s - * @return - */ - public static String toLowerCase(String s, boolean trim) { - s = trim ? getTrimedString(s) : getString(s); - return s.toLowerCase(); - } - - //校正(自动补全等)字符串>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Column.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Column.java deleted file mode 100644 index 7e48716b4..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Column.java +++ /dev/null @@ -1,30 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.model; - -import zuo.biao.apijson.MethodAccess; - -/**字段(列名) - * @author Lemon - */ -@MethodAccess( - POST = {}, - PUT = {}, - DELETE = {} - ) -public class Column { - public static final String TAG = "`columns`"; - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Document.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Document.java deleted file mode 100644 index 6846dc847..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Document.java +++ /dev/null @@ -1,30 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.model; - -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.LOGIN; - -import zuo.biao.apijson.MethodAccess; - -/**测试用例文档类 - * @author Lemon - */ -@MethodAccess( - GET = {LOGIN, ADMIN}, - HEAD = {LOGIN, ADMIN} - ) -public class Document { -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Request.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Request.java deleted file mode 100644 index 09a6d4254..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Request.java +++ /dev/null @@ -1,28 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.model; - -import zuo.biao.apijson.MethodAccess; - -/**请求类 - * @author Lemon - */ -@MethodAccess( - POST = {}, - PUT = {}, - DELETE = {} - ) -public class Request { -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Response.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Response.java deleted file mode 100644 index e46dc8479..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Response.java +++ /dev/null @@ -1,28 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.model; - -import zuo.biao.apijson.MethodAccess; - -/**结果类 - * @author Lemon - */ -@MethodAccess( - POST = {}, - PUT = {}, - DELETE = {} - ) -public class Response { -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Table.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Table.java deleted file mode 100644 index 9346dc805..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Table.java +++ /dev/null @@ -1,30 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.model; - -import zuo.biao.apijson.MethodAccess; - -/**数据库表 - * @author Lemon - */ -@MethodAccess( - POST = {}, - PUT = {}, - DELETE = {} - ) -public class Table { - public static final String TAG = "`tables`"; - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Test.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Test.java deleted file mode 100644 index b090d72a3..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/Test.java +++ /dev/null @@ -1,28 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.model; - -import zuo.biao.apijson.MethodAccess; - -/**输入条件测试类 - * @author Lemon - */ -@MethodAccess( - POST = {}, - PUT = {}, - DELETE = {} - ) -public class Test { -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/package-info.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/package-info.java deleted file mode 100644 index 356cf4e4a..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/model/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * models for special tables - */ -/** - * @author Lemon - * - */ -package zuo.biao.apijson.model; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/package-info.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/package-info.java deleted file mode 100755 index 707b9d11a..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -/** - * the same files for server and client projects - */ -/** - * @author Lemon - * - */ -package zuo.biao.apijson; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Entry.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Entry.java deleted file mode 100644 index 0f6db45ac..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Entry.java +++ /dev/null @@ -1,59 +0,0 @@ -/*Copyright ©2015 TommyLemon(https://github.com/TommyLemon) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -/**自定义Entry - * *java.util.Map.Entry是interface,new Entry(...)不好用,其它的Entry也不好用 - * @author Lemon - * @param key - * @param value - * @use new Entry(...) - * @warn K,V都需要基本类型时不建议使用,判空麻烦,不如新建一个Model - */ -public class Entry { - - public K key; - public V value; - - public Entry() { - //default - } - public Entry(K key) { - this(key, null); - } - public Entry(K key, V value) { - this.key = key; - this.value = value; - } - - - public K getKey() { - return key; - } - public void setKey(K key) { - this.key = key; - } - public V getValue() { - return value; - } - public void setValue(V value) { - this.value = value; - } - - public boolean isEmpty() { - return key == null && value == null; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/JSONRequest.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/JSONRequest.java deleted file mode 100644 index 0a357656c..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/JSONRequest.java +++ /dev/null @@ -1,102 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import java.util.Map; - -import zuo.biao.apijson.JSON; -import zuo.biao.apijson.JSONObject; -import zuo.biao.apijson.StringUtil; - -/**JSONRequest for Server to replace zuo.biao.apijson.JSONRequest, - * put JSON.parseObject(value) and not encode in default cases - * @author Lemon - * @see #put(String, Object, boolean) - */ -public class JSONRequest extends zuo.biao.apijson.JSONRequest { - private static final long serialVersionUID = 1L; - - public JSONRequest() { - super(); - } - /** - * encode = true - * {@link #JSONRequest(String, Object)} - * @param object - */ - public JSONRequest(Object object) { - super(object); - } - /** - * @param name - * @param object - */ - public JSONRequest(String name, Object object) { - super(name, object); - } - - - - @Override - public JSONObject putsAll(Map map) { - super.putsAll(map); - return this; - } - - /** - * @param value - * @return {@link #puts(String, Object)} - */ - @Override - public JSONRequest puts(Object value) { - return puts(null, value); - } - /** - * @param key - * @param value - * @return this - * @see {@link #put(String, Object)} - */ - @Override - public JSONRequest puts(String key, Object value) { - put(key, value); - return this; - } - - /** - * @param value - * @return {@link #put(String, Object)} - */ - @Override - public Object put(Object value) { - return put(null, value); - } - /**自定义类型必须转为JSONObject或JSONArray,否则RequestParser解析不了 - */ - @Override - public Object put(String key, Object value) { - if (value == null) {// || key == null - return null; - } - - com.alibaba.fastjson.JSONObject target = JSON.parseObject(value); - // if (target == null) { // "tag":"User" 报错 - // return null; - // } - return super.put(StringUtil.isNotEmpty(key, true) ? key : value.getClass().getSimpleName() //must handle key here - , target == null ? value : target); - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Logic.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Logic.java deleted file mode 100644 index fc60aaefc..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Logic.java +++ /dev/null @@ -1,145 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import zuo.biao.apijson.StringUtil; - -/**& | !逻辑类 - * @author Lemon - */ -public class Logic { - - public static final int TYPE_OR = 0; - public static final int TYPE_AND = 1; - public static final int TYPE_NOT = 2; - public static final int[] TYPES = {TYPE_OR, TYPE_AND, TYPE_NOT}; - - public static final String CHAR_OR = "|"; - public static final String CHAR_AND = "&"; - public static final String CHAR_NOT = "!"; - public static final String[] CHARS = {CHAR_OR, CHAR_AND, CHAR_NOT}; - - public static final String NAME_OR = "OR"; - public static final String NAME_AND = "AND"; - public static final String NAME_NOT = "NOT"; - public static final String[] NAMES = {NAME_OR, NAME_AND, NAME_NOT}; - - - private int type; - private String key; - - public Logic() { - super(); - } - - public Logic(int type) { - this(); - this.type = type; - } - public Logic(String key) { - key = StringUtil.getString(key); - - int type = getType(key.isEmpty() ? "" : key.substring(key.length() - 1)); - - if (type >= 0 && type <= 2) { - key = key.substring(0, key.length() - 1); - } - if (type < 0) { - type = 0; - } - - - setType(type); - setKey(key); - } - - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public String getKey() { - return key; - } - public void setKey(String key) { - this.key = key; - } - - - public boolean isOr() { - return isOr(type); - } - public static boolean isOr(int type) { - return type == TYPE_OR; - } - public boolean isAnd() { - return isAnd(type); - } - public static boolean isAnd(int type) { - return type == TYPE_AND; - } - public boolean isNot() { - return isNot(type); - } - public static boolean isNot(int type) { - return type == TYPE_NOT; - } - - public boolean isCorrect() { - return isContain(getType()); - } - public static boolean isContain(String s) { - return isContain(getType(s)); - } - public static boolean isContain(int type) { - return type >= TYPE_OR && type <= TYPE_NOT; - } - - public static int getType(char logicChar) { - return getType(String.valueOf(logicChar)); - } - public static int getType(String logicChar) { - int type = -1; - if (logicChar != null && logicChar.length() == 1) { - if ("|".equals(logicChar)) { - type = 0; - } else if ("&".equals(logicChar)) { - type = 1; - } else if ("!".equals(logicChar)) { - type = 2; - } - } - return type; - } - - public String getChar() { - return getChar(type); - } - public static String getChar(int type) { - return type < 0 || type >= CHARS.length ? "" : CHARS[type]; - } - - public String getName() { - return getName(type); - } - public static String getName(int type) { - return type < 0 || type >= NAMES.length ? "" : NAMES[type]; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/ObjectParser.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/ObjectParser.java deleted file mode 100644 index 4f406cbe5..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/ObjectParser.java +++ /dev/null @@ -1,678 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import static zuo.biao.apijson.JSONObject.KEY_CORRECT; -import static zuo.biao.apijson.JSONObject.KEY_DROP; -import static zuo.biao.apijson.JSONObject.KEY_TRY; -import static zuo.biao.apijson.RequestMethod.PUT; -import static zuo.biao.apijson.JSONObject.KEY_CONDITION; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.regex.Pattern; - -import javax.validation.constraints.NotNull; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -import apijson.demo.server.Function; -import apijson.demo.server.model.BaseModel; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.RequestMethod; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.server.exception.ConflictException; -import zuo.biao.apijson.server.exception.NotExistException; -import zuo.biao.apijson.server.sql.SQLConfig; - -/**简化Parser,getObject和getArray(getArrayConfig)都能用 - * @author Lemon - */ -public abstract class ObjectParser implements ParserAdapter { - private static final String TAG = "ObjectParser"; - - - - private ParserAdapter adapter; - public ObjectParser init(ParserAdapter adapter) { - this.adapter = adapter; - return this; - } - public ParserAdapter getAdapter() { - return adapter == null ? this : adapter; - } - - - - public static final int TYPE_CHILD = 0; - public static final int TYPE_ITEM = 1; - public static final int TYPE_ITEM_CHILD_0 = 2; - - - /**for array item - * name = null - * @param parentPath - * @param request - * @throws Exception - */ - public ObjectParser(@NotNull JSONObject request, String parentPath, int type) throws Exception { - this(request, parentPath, type, null); - } - - protected JSONObject request;//不用final是为了recycle - protected String parentPath;//不用final是为了recycle - - protected final boolean isEmpty;//empty有效 User:{} - protected final int type; - protected String path;//不用final是为了recycle - protected String table;//不用final是为了recycle - protected final boolean isTableKey; - - protected final boolean tri; - /** - * TODO Parser内要不因为 非 TYPE_ITEM_CHILD_0 的Table 为空导致后续中断。 - */ - protected final boolean drop; - protected JSONObject correct; - - /**for single object - * @param parentPath - * @param request - * @param name - * @throws Exception - */ - public ObjectParser(@NotNull JSONObject request, String parentPath, int type, String name) throws Exception { - if (request == null) { - throw new IllegalArgumentException(TAG + ".ObjectParser request == null!!!"); - } - this.request = request; - this.parentPath = parentPath; - this.type = type; - - this.path = Parser.getAbsPath(parentPath, name); - this.table = Pair.parseEntry(name, true).getKey(); - this.isTableKey = zuo.biao.apijson.JSONObject.isTableKey(table); - - this.isEmpty = request.isEmpty(); - if (isEmpty) { - this.tri = false; - this.drop = false; - } else { - this.tri = request.getBooleanValue(KEY_TRY); - this.drop = request.getBooleanValue(KEY_DROP); - this.correct = request.getJSONObject(KEY_CORRECT); - - request.remove(KEY_TRY); - request.remove(KEY_DROP); - request.remove(KEY_CORRECT); - - try { - parseCorrect(); - } catch (Exception e) { - if (tri == false) { - throw e; - } - invalidate(); - } - } - - - Log.d(TAG, "ObjectParser table = " + table + "; isTableKey = " + isTableKey); - Log.d(TAG, "ObjectParser isEmpty = " + isEmpty + "; tri = " + tri + "; drop = " + drop); - } - - public static final Map COMPILE_MAP; - static { - COMPILE_MAP = new HashMap(); - COMPILE_MAP.put("phone", StringUtil.PATTERN_PHONE); - COMPILE_MAP.put("email", StringUtil.PATTERN_EMAIL); - COMPILE_MAP.put("idCard", StringUtil.PATTERN_ID_CARD); - } - - protected Map corrected; - /**解析 @correct 校正 - * @throws Exception - */ - protected ObjectParser parseCorrect() throws Exception { - Set set = correct == null ? null : new HashSet<>(correct.keySet()); - - if (set != null && set.isEmpty() == false) {//对每个需要校正的key进行正则表达式匹配校正 - corrected = new HashMap<>();//TODO 返回全部correct内的内容,包括未校正的? correct); - - String value; //13000082001 - String v; // phone,id_number,card_number - String[] posibleKeys; //[phone,email,id_number,card_number] - - for (String k : set) {// k = cert - v = k == null ? null : correct.getString(k); - value = v == null ? null : request.getString(k); - posibleKeys = value == null ? null : StringUtil.split(v); - - if (posibleKeys != null && posibleKeys.length > 0) { - String rk = null; - Pattern p; - for (String pk : posibleKeys) { - p = pk == null ? null : COMPILE_MAP.get(pk); - if (p != null && p.matcher(value).matches()) { - rk = pk; - break; - } - } - - if (rk == null) { - throw new IllegalArgumentException( - "格式错误!找不到 " + k + ":" + value + " 对应[" + v + "]内的任何一项!"); - } - request.put(rk, request.remove(k)); - corrected.put(k, rk); - } - } - } - - return this; - } - - - - private boolean invalidate = false; - public void invalidate() { - invalidate = true; - } - public boolean isInvalidate() { - return invalidate; - } - - private boolean breakParse = false; - public void breakParse() { - breakParse = true; - } - public boolean isBreakParse() { - return breakParse || isInvalidate(); - } - - - protected JSONObject response; - protected JSONObject sqlRequest; - protected JSONObject sqlReponse; - protected Map customMap; - protected Map functionMap; - protected Map childMap; - - /**解析成员 - * response重新赋值 - * @param config 传递给第0个Table - * @return null or this - * @throws Exception - */ - public ObjectParser parse() throws Exception { - if (isInvalidate() == false) { - breakParse = false; - - response = new JSONObject(true);//must init - - sqlRequest = new JSONObject(true);//must init - sqlReponse = null;//must init - customMap = null;//must init - functionMap = null;//must init - childMap = null;//must init - - Set> set = new LinkedHashSet>(request.entrySet()); - if (set != null && set.isEmpty() == false) {//判断换取少几个变量的初始化是否值得? - if (isTableKey) {//非Table下不必分离出去再添加进来 - customMap = new LinkedHashMap(); - childMap = new LinkedHashMap(); - } - functionMap = new LinkedHashMap();//必须执行 - - - //条件<<<<<<<<<<<<<<<<<<< - List conditionList = null; - if (method == PUT) { //这里只有PUTArray需要处理 || method == DELETE) { - String[] conditions = StringUtil.split(request.getString(KEY_CONDITION)); - //Arrays.asList()返回值不支持add方法! - conditionList = new ArrayList(Arrays.asList(conditions != null ? conditions : new String[]{})); - conditionList.add(zuo.biao.apijson.JSONRequest.KEY_ID); - conditionList.add(zuo.biao.apijson.JSONRequest.KEY_ID_IN); - } - //条件>>>>>>>>>>>>>>>>>>> - - String key; - Object value; - for (Entry entry : set) { - if (isBreakParse()) { - break; - } - - value = entry.getValue(); - if (value == null) { - continue; - } - key = entry.getKey(); - - try { - if (value instanceof JSONObject && key.startsWith("@") == false) {//JSONObject,往下一级提取 - putChild(key, (JSON) value); - } - else if (method == PUT && value instanceof JSONArray - && BaseModel.isContain(conditionList, key) == false) {//PUT JSONArray - onPUTArrayParse(key, (JSONArray) value); - } - else {//JSONArray或其它Object,直接填充 - if (onParse(key, value) == false) { - invalidate(); - } - } - } catch (Exception e) { - if (tri == false) { - throw e;//不忽略错误,抛异常 - } - invalidate();//忽略错误,还原request - } - } - } - } - - if (isInvalidate()) { - recycle(); - return null; - } - - return this; - } - - - - /** - * @param key - * @param value 类型不用JSON是因为JSON不能强转为JSONObject - * @throws Exception - */ - protected void putChild(String key, JSON child) throws Exception { - if (child != null) { - if (childMap != null) {//添加到childMap,最后再解析 - childMap.put(key, child); - } else {//直接解析并替换原来的 - response.put(key, onChildParse(key, child)); - } - } - } - - - /** - * @param key - * @param value - * @return - * @throws Exception - */ - protected JSON onChildParse(String key, JSON value) throws Exception { - return getAdapter().parseChild(path, key, value); - } - - /** - * @return - * @throws Exception - */ - protected JSONObject onSQLExecute() throws Exception { - return getAdapter().executeSQL(path, config); - } - - /**解析普通成员 - * @param key - * @param value - * @return whether parse succeed - */ - protected boolean onParse(@NotNull String key, @NotNull Object value) throws Exception { - if (key.endsWith("@")) {//StringUtil.isPath((String) value)) { - if (value instanceof String == false) { - throw new IllegalArgumentException("\"key@\": 后面必须为依赖路径String!"); - } - // System.out.println("getObject key.endsWith(@) >> parseRelation = " + parseRelation); - String replaceKey = key.substring(0, key.length() - 1);//key{}@ getRealKey - String targetPath = Parser.getValuePath(getType() == TYPE_ITEM - ? path : parentPath, new String((String) value)); - - //先尝试获取,尽量保留缺省依赖路径,这样就不需要担心路径改变 - Object target = getAdapter().getTarget(targetPath); - Log.i(TAG, "getObject targetPath = " + targetPath + "; target = " + target); - - if (target == null) {//String#equals(null)会出错 - Log.d(TAG, "getObject target == null >> continue;"); - return true; - } - if (targetPath.equals(target)) {//必须valuePath和保证getValueByPath传进去的一致! - Log.d(TAG, "getObject targetPath.equals(target) >>"); - - //非查询关键词 @key 不影响查询,直接跳过 - if (isTableKey && (key.startsWith("@") == false || SQLConfig.TABLE_KEY_LIST.contains(key))) { - Log.e(TAG, "getObject isTableKey && (key.startsWith(@) == false" - + " || SQLConfig.TABLE_KEY_LIST.contains(key)) >> return null;"); - return false;//获取不到就不用再做无效的query了。不考虑 Table:{Table:{}}嵌套 - } else { - Log.d(TAG, "getObject isTableKey(table) == false >> continue;"); - return true;//舍去,对Table无影响 - } - } - - - //直接替换原来的key@:path为key:target - Log.i(TAG, "getObject >> key = replaceKey; value = target;"); - key = replaceKey; - value = target; - Log.d(TAG, "getObject key = " + key + "; value = " + value); - } - - if (key.endsWith("()")) { - if (value instanceof String == false) { - throw new IllegalArgumentException(path + "/" + key + "():function() 后面必须为函数String!"); - } - functionMap.put(key, (String) value); - } else if (isTableKey && key.startsWith("@") && SQLConfig.TABLE_KEY_LIST.contains(key) == false) { - customMap.put(key, value); - } else { - sqlRequest.put(key, value); - } - - return true; - } - - - //TODO 改用 MySQL json_add,json_remove,json_contains 等函数! - /**PUT key:[] - * @param key - * @param array - * @throws Exception - */ - protected void onPUTArrayParse(@NotNull String key, @NotNull JSONArray array) throws Exception { - if (isTableKey == false || array.isEmpty()) { - Log.e(TAG, "onPUTArray isTableKey == false || array == null || array.isEmpty() >> return;"); - return; - } - - int putType = 0; - if (key.endsWith("+")) {//add - putType = 1; - } else if (key.endsWith("-")) {//remove - putType = 2; - } else {//replace - // throw new IllegalAccessException("PUT " + path + ", PUT Array不允许 " + key + - // " 这种没有 + 或 - 结尾的key!不允许整个替换掉原来的Array!"); - } - String realKey = SQLConfig.getRealKey(method, key, false, false); - - //GET > add all 或 remove all > PUT > remove key - - //GET <<<<<<<<<<<<<<<<<<<<<<<<< - JSONObject rq = new JSONObject(); - rq.put(JSONRequest.KEY_ID, request.get(JSONRequest.KEY_ID)); - rq.put(JSONRequest.KEY_COLUMN, realKey); - JSONObject rp = parseResponse(new JSONRequest(table, rq)); - //GET >>>>>>>>>>>>>>>>>>>>>>>>> - - - //add all 或 remove all <<<<<<<<<<<<<<<<<<<<<<<<< - if (rp != null) { - rp = rp.getJSONObject(table); - } - JSONArray targetArray = rp == null ? null : rp.getJSONArray(realKey); - if (targetArray == null) { - targetArray = new JSONArray(); - } - for (Object obj : array) { - if (obj == null) { - continue; - } - if (putType == 1) { - if (targetArray.contains(obj)) { - throw new ConflictException("PUT " + path + ", " + realKey + ":" + obj + " 已存在!"); - } - targetArray.add(obj); - } else if (putType == 2) { - if (targetArray.contains(obj) == false) { - throw new NullPointerException("PUT " + path + ", " + realKey + ":" + obj + " 不存在!"); - } - targetArray.remove(obj); - } - } - - //add all 或 remove all >>>>>>>>>>>>>>>>>>>>>>>>> - - //PUT <<<<<<<<<<<<<<<<<<<<<<<<< - sqlRequest.put(realKey, targetArray); - //PUT >>>>>>>>>>>>>>>>>>>>>>>>> - - } - - - /**SQL查询,for single object - * @return {@link #executeSQL(int, int, int)} - * @throws Exception - */ - public ObjectParser executeSQL() throws Exception { - return executeSQL(1, 0, 0); - } - - protected SQLConfig config = null;//array item复用 - /**SQL查询,for array item - * @param count - * @param page - * @param position - * @return this - * @throws Exception - */ - public ObjectParser executeSQL(int count, int page, int position) throws Exception { - //执行SQL操作数据库 - if (isTableKey == false) {//提高性能 - sqlReponse = new JSONObject(sqlRequest); - } else { - - try { - if (config == null) { - config = newSQLConfig(); - } - config.setCount(count).setPage(page).setPosition(position); - sqlReponse = onSQLExecute(); - } catch (Exception e) { - Log.e(TAG, "getObject try { response = getSQLObject(config2); } catch (Exception e) {"); - if (e instanceof NotExistException) {//非严重异常,有时候只是数据不存在 - // e.printStackTrace(); - sqlReponse = null;//内部吃掉异常,put到最外层 - // requestObject.put(JSONResponse.KEY_MSG - // , StringUtil.getString(requestObject.get(JSONResponse.KEY_MSG) - // + "; query " + path + " cath NotExistException:" - // + newErrorResult(e).getString(JSONResponse.KEY_MSG))); - } else { - throw e; - } - } - - if (drop) {//丢弃Table,只为了向下提供条件 - sqlReponse = null; - } - } - - return this; - } - - /** - * @return response - * @throws Exception - */ - public JSONObject response() throws Exception { - if (sqlReponse == null || sqlReponse.isEmpty()) { - if (isTableKey) {//Table自身都获取不到值,则里面的Child都无意义,不需要再解析 - return response; - } - } else { - response.putAll(sqlReponse); - } - - - //把已校正的字段键值对corrected添加进来,还是correct直接改? - if (corrected != null) { - response.put(KEY_CORRECT, corrected); - } - - //把isTableKey时取出去的custom重新添加回来 - if (customMap != null) { - response.putAll(customMap); - } - - - - //解析函数function - if (functionMap != null) { - Set> functionSet = functionMap == null ? null : functionMap.entrySet(); - if (functionSet != null && functionSet.isEmpty() == false) { - for (Entry entry : functionSet) { - response.put(SQLConfig.getRealKey(method, entry.getKey(), false, false) - , Function.invoke(response, entry.getValue())); - } - } - } - - //把isTableKey时取出去child解析后重新添加回来 - Set> set = childMap == null ? null : childMap.entrySet(); - if (set != null) { - for (Entry entry : set) { - if (entry != null) { - response.put(entry.getKey(), onChildParse(entry.getKey(), entry.getValue())); - } - } - } - - onComplete(); - - return response; - } - - protected SQLConfig newSQLConfig() throws Exception { - return SQLConfig.newSQLConfig(method, table, sqlRequest); - } - /** - * response has the final value after parse (and query if isTableKey) - */ - protected void onComplete() { - } - - - /**回收内存 - */ - public void recycle() { - //后面还可能用到,要还原 - if (tri) {//避免返回未传的字段 - request.put(KEY_TRY, tri); - } - if (drop) { - request.put(KEY_DROP, drop); - } - if (correct != null) { - request.put(KEY_CORRECT, correct); - } - - - correct = null; - corrected = null; - method = null; - parentPath = null; - path = null; - table = null; - - // if (response != null) { - // response.clear();//有效果? - // response = null; - // } - - request = null; - response = null; - sqlRequest = null; - sqlReponse = null; - - functionMap = null; - customMap = null; - childMap = null; - } - - - - - - - protected RequestMethod method; - public ObjectParser setMethod(RequestMethod method) { - if (this.method != method) { - this.method = method; - config = null; - //TODO ? sqlReponse = null; - } - return this; - } - public RequestMethod getMethod() { - return method; - } - - - - public int getType() { - return type; - } - public String getPath() { - return path; - } - public String getTable() { - return table; - } - public boolean isTableKey() { - return isTableKey; - } - - - - public SQLConfig getConfig() { - return config; - } - - public JSONObject getResponse() { - return response; - } - public JSONObject getSqlRequest() { - return sqlRequest; - } - public JSONObject getSqlReponse() { - return sqlReponse; - } - - - public Map getCustomMap() { - return customMap; - } - public Map getFunctionMap() { - return functionMap; - } - public Map getChildMap() { - return childMap; - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/OnParseCallback.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/OnParseCallback.java deleted file mode 100644 index ba691eefe..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/OnParseCallback.java +++ /dev/null @@ -1,70 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/** - * @author Lemon - */ -public abstract class OnParseCallback { - - - /** - * @param key - * @param to - * @param ro - * @return false ? continue - * @throws Exception - */ - protected boolean onParse(String key, Object to, Object ro) throws Exception { - return true; - } - - /** - * @param key - * @param to - * @param ro - * @return - * @throws Exception - */ - protected Object onParseObject(String key, Object to, Object ro) throws Exception { - return ro; - } - - /** - * @param key - * @param tobj - * @param robj - * @return - * @throws Exception - */ - protected JSONObject onParseJSONObject(String key, JSONObject tobj, JSONObject robj) throws Exception { - return robj; - } - - /** - * @param key - * @param tarray - * @param rarray - * @return - * @throws Exception - */ - protected JSONArray onParseJSONArray(String key, JSONArray tarray, JSONArray rarray) throws Exception { - return rarray; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Operation.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Operation.java deleted file mode 100644 index b5678a670..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Operation.java +++ /dev/null @@ -1,68 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import zuo.biao.apijson.StringUtil; - -/**对请求JSON的操作 - * @author Lemon - */ -public enum Operation { - - /** - * 不允许传的字段 - */ - DISALLOW, - /** - * 必须传的字段 - */ - NECESSARY, - - /** - * 验证是否符合预设的条件 - */ - VERIFY, - /** - * 验证是否不存在,除了本身的记录 - */ - UNIQUE, - - /** - * 添加,当要被添加的对象不存在时 - */ - ADD, - /** - * 强行放入,不存在时就添加,存在时就修改 - */ - PUT, - /** - * 替换,当要被替换的对象存在时 - */ - REPLACE, - /** - * 移除,当要被移除的对象存在时 - */ - REMOVE; - - public static Operation get(String name) { - try {//Enum.valueOf只要找不到对应的值就会抛异常 - return Operation.valueOf(StringUtil.toUpperCase(name)); - } catch (Exception e) { - //empty - } - return null; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Pair.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Pair.java deleted file mode 100644 index a19c8e447..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Pair.java +++ /dev/null @@ -1,159 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -import zuo.biao.apijson.StringUtil; - -/**key:value - * @author Lemon - */ -public class Pair extends Entry { - - private static final Map> classMap; - static { - classMap = new HashMap>(); - classMap.put(boolean.class.getSimpleName(), boolean.class); - classMap.put(int.class.getSimpleName(), int.class); - classMap.put(long.class.getSimpleName(), long.class); - classMap.put(float.class.getSimpleName(), float.class); - classMap.put(double.class.getSimpleName(), double.class); - classMap.put(Boolean.class.getSimpleName(), Boolean.class); - classMap.put(Integer.class.getSimpleName(), Integer.class); - classMap.put(Long.class.getSimpleName(), Long.class); - classMap.put(Float.class.getSimpleName(), Float.class); - classMap.put(Double.class.getSimpleName(), Double.class); - - classMap.put(Object.class.getSimpleName(), Object.class); - classMap.put(String.class.getSimpleName(), String.class); - classMap.put(Collection.class.getSimpleName(), Collection.class);//不允许指定 - classMap.put(Map.class.getSimpleName(), Map.class);//不允许指定 - classMap.put(JSONObject.class.getSimpleName(), JSONObject.class);//必须有,Map中没有getLongValue等方法 - classMap.put(JSONArray.class.getSimpleName(), JSONArray.class);//必须有,Collection中没有?等方法 - } - - - public Pair() { - super(); - } - - public boolean isEmpty(boolean trim) { - return StringUtil.isNotEmpty(key, trim) == false && StringUtil.isNotEmpty(value, trim) == false; - } - - /** - * @param - * @param pair - * @return - */ - public static boolean isCorrect(Entry pair) { - return pair != null && StringUtil.isNotEmpty(pair.getValue(), true); - } - - /** - * @param pair - * @return - */ - public String toPairString() { - return toPairString(getKey(), getValue()); - } - /** - * @param pair - * @return - */ - public static String toPairString(String typeKey, String valueKey) { - return (typeKey == null ? "" : typeKey + ":") + valueKey; - } - /** - * @param type - * @param value - * @return - */ - public static String toPairString(Class type, Object value) { - return toPairString(type == null ? null : type.getSimpleName(), StringUtil.getString(value)); - } - - /** - * isRightValueDefault = false; - * "key":null不应该出现?因为FastJSON内默认不存null - * @param pair leftKey:rightValue - * @return {@link #parseEntry(String, boolean)} - */ - public static Entry parseEntry(String pair) { - return parseEntry(pair, false); - } - /** - * isRightValueDefault = false; - * "key":null不应该出现?因为FastJSON内默认不存null - * @param pair leftKey:rightValue - * @param isRightValueDefault 右边值缺省,当pair不包含 : 时默认整个pair为leftKey;false-相反 - * @return {@link #parseEntry(String, boolean, String)} - */ - public static Entry parseEntry(String pair, boolean isRightValueDefault) { - return parseEntry(pair, isRightValueDefault, null); - } - /** - * "key":null不应该出现?因为FastJSON内默认不存null - * @param pair leftKey:rightValue - * @param isRightValueDefault 右边值缺省,当pair不包含 : 时默认整个pair为leftKey;false-相反 - * @param defaultValue 缺省值 - * @return @NonNull - */ - public static Entry parseEntry(String pair, boolean isRightValueDefault, String defaultValue) { - pair = StringUtil.getString(pair);//让客户端去掉所有空格 getNoBlankString(pair); - Entry entry = new Entry(); - if (pair.isEmpty() == false) { - int index = pair.indexOf(":"); - if (index < 0) { - entry.setKey(isRightValueDefault ? pair : defaultValue); - entry.setValue(isRightValueDefault ? defaultValue : pair); - } else { - entry.setKey(pair.substring(0, index)); - entry.setValue(pair.substring(index + 1, pair.length())); - } - - } - return entry; - } - /** - * @param pair - * @return - */ - public static Entry parseVariableEntry(String pair) { - return parseEntry(pair, false, Object.class.getSimpleName()); - } - /** - * @param pair - * @param valueMap - * @return - */ - public static Entry, Object> parseVariableEntry(String pair, Map valueMap) { - pair = StringUtil.getString(pair);//让客户端去掉所有空格 getNoBlankString(pair); - Entry, Object> entry = new Entry, Object>(); - if (pair.isEmpty() == false) { - int index = pair.contains(":") ? pair.indexOf(":") : -1; - - entry.setKey(classMap.get(index < 0 ? Object.class.getSimpleName() : pair.substring(0, index))); - entry.setValue(valueMap == null ? null : valueMap.get(pair.substring(index + 1, pair.length()))); - } - return entry; - } -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Parser.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Parser.java deleted file mode 100755 index 707994fe5..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Parser.java +++ /dev/null @@ -1,904 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import static zuo.biao.apijson.RequestMethod.GET; - -import java.io.UnsupportedEncodingException; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeoutException; - -import javax.activation.UnsupportedDataTypeException; -import javax.servlet.http.HttpSession; -import javax.validation.constraints.NotNull; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -import apijson.demo.server.Verifier; -import apijson.demo.server.model.User; -import zuo.biao.apijson.JSON; -import zuo.biao.apijson.JSONResponse; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.RequestMethod; -import zuo.biao.apijson.RequestRole; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.server.exception.ConditionErrorException; -import zuo.biao.apijson.server.exception.ConflictException; -import zuo.biao.apijson.server.exception.NotExistException; -import zuo.biao.apijson.server.exception.NotLoggedInException; -import zuo.biao.apijson.server.exception.OutOfRangeException; -import zuo.biao.apijson.server.sql.SQLConfig; -import zuo.biao.apijson.server.sql.SQLExecutor; - -/**parser for parsing request to JSONObject - * @author Lemon - */ -public class Parser { - private static final String TAG = "Parser"; - - - /** - * GET - */ - public Parser() { - this(null); - } - /** - * @param requestMethod null ? requestMethod = GET - */ - public Parser(RequestMethod method) { - this(method, false); - } - - private final RequestMethod requestMethod; - /** - * @param requestMethod null ? requestMethod = GET - * @param noVerify 仅限于为服务端提供方法免验证特权,普通请求不要设置为true! 如果对应Table有权限也建议用默认值false,保持和客户端权限一致 - */ - public Parser(RequestMethod method, boolean noVerify) { - super(); - this.requestMethod = method == null ? GET : method; - setNoVerifyRequest(noVerify); - setNoVerifyLogin(noVerify); - setNoVerifyRole(noVerify); - } - - private HttpSession session;//可能比较大,占内存。而且不是所有地方都用 - private User visitor;//来访用户 - private long visitorId;//来访用户id - public Parser setSession(@NotNull HttpSession session) { - this.session = session; - this.visitor = Verifier.getUser(session); - this.visitorId = Verifier.getUserId(session); - return this; - } - private RequestRole globleRole;//全局角色,对未指明角色的Table自动加上这个角色 - public Parser setGlobleRole(RequestRole globleRole) { - this.globleRole = globleRole; - return this; - } - - //一定要验证结构!对管理员也要验证! - private boolean noVerifyRequest = false; - private boolean noVerifyLogin = false; - private boolean noVerifyRole = false; - public Parser setNoVerifyRequest(boolean noVerifyRequest) { - this.noVerifyRequest = noVerifyRequest; - return this; - } - public Parser setNoVerifyLogin(boolean noVerifyLogin) { - this.noVerifyLogin = noVerifyLogin; - return this; - } - public Parser setNoVerifyRole(boolean noVerifyRole) { - this.noVerifyRole = noVerifyRole; - return this; - } - - - - - - - private JSONObject requestObject; - private SQLExecutor sqlExecutor; - private Map queryResultMap;//path-result - - - /**解析请求json并获取对应结果 - * @param request - * @return - */ - public String parse(String request) { - return JSON.toJSONString(parseResponse(request)); - } - /**解析请求json并获取对应结果 - * @param request - * @return - */ - @NotNull - public String parse(JSONObject request) { - return JSON.toJSONString(parseResponse(request)); - } - - /**解析请求json并获取对应结果 - * @param request 先parseRequest中URLDecoder.decode(request, UTF_8);再parseResponse(getCorrectRequest(...)) - * @return parseResponse(requestObject); - */ - @NotNull - public JSONObject parseResponse(String request) { - Log.d(TAG, "\n\n\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n" - + requestMethod + "/parseResponse request = \n" + request + "\n\n"); - - try { - requestObject = parseRequest(request, requestMethod); - } catch (Exception e) { - return newErrorResult(e); - } - - return parseResponse(requestObject); - } - - /**解析请求json并获取对应结果 - * @param request - * @return requestObject - */ - @NotNull - public JSONObject parseResponse(JSONObject request) { - long startTime = System.currentTimeMillis(); - Log.d(TAG, "parseResponse startTime = " + startTime - + "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n "); - - requestObject = request; - if (RequestMethod.isPublicMethod(requestMethod) == false) { - try { - //TODO - // if (noVerifyLogin == false) { - // Verifier.verifyLogin(session); - // } - if (noVerifyRequest == false) { - //补充全局缺省版本号 - if (session != null && requestObject.getIntValue(JSONRequest.KEY_VERSION) <= 0) { - requestObject.put(JSONRequest.KEY_VERSION, session.getAttribute(JSONRequest.KEY_VERSION)); - } - - requestObject = getCorrectRequest(requestMethod, requestObject); - } - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - } - - if (noVerifyRole == false && globleRole == null) { - setGlobleRole(RequestRole.get(requestObject.getString(JSONRequest.KEY_ROLE))); - } - - final String requestString = JSON.toJSONString(request);//request传进去解析后已经变了 - - - queryResultMap = new HashMap(); - - Exception error = null; - sqlExecutor = new SQLExecutor(); - try { - requestObject = getObject(null, null, request); - } catch (Exception e) { - e.printStackTrace(); - error = e; - } - sqlExecutor.close(); - sqlExecutor = null; - - - requestObject = Verifier.removeAccessInfo(requestObject); - requestObject = error == null ? extendSuccessResult(requestObject) : extendErrorResult(requestObject, error); - - - queryResultMap.clear(); - - //会不会导致原来的session = null? session = null; - - - Log.d(TAG, "\n\n\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n " - + requestMethod + "/parseResponse request = \n" + requestString + "\n\n"); - - Log.d(TAG, "parse return response = \n" + JSON.toJSONString(requestObject) - + "\n >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> \n\n\n"); - - long endTime = System.currentTimeMillis(); - Log.d(TAG, "parseResponse endTime = " + endTime + "; duration = " + (endTime - startTime) - + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n\n"); - - return requestObject; - } - - /**解析请求JSONObject - * @param request => URLDecoder.decode(request, UTF_8); - * @return - * @throws Exception - */ - @NotNull - public static JSONObject parseRequest(String request, RequestMethod method) throws Exception { - //全走HTTP POST,不用encode和decode - // if (RequestMethod.isPublicMethod(method)) { - // request = URLDecoder.decode(request, UTF_8); - // Log.d(TAG, "\n\n\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n " + method - // + "/parseRequest request = \n" + request + "\n\n"); - // } - if (method == null) { - method = GET; - } - JSONObject obj = JSON.parseObject(request); - if (obj == null) { - throw new UnsupportedEncodingException("JSON格式不合法!"); - } - return obj; - } - - - - - - /**新建带状态内容的JSONObject - * @param code - * @param msg - * @return - */ - public static JSONObject newResult(int code, String msg) { - return extendResult(null, code, msg); - } - /**添加JSONObject的状态内容,一般用于错误提示结果 - * @param object - * @param code - * @param msg - * @return - */ - public static JSONObject extendResult(JSONObject object, int code, String msg) { - if (object == null) { - object = new JSONObject(true); - } - if (object.containsKey(JSONResponse.KEY_CODE) == false) { - object.put(JSONResponse.KEY_CODE, code); - } - String m = StringUtil.getString(object.getString(JSONResponse.KEY_MSG)); - if (m.isEmpty() == false) { - msg = m + " \n " + StringUtil.getString(msg); - } - object.put(JSONResponse.KEY_MSG, msg); - return object; - } - - - /**添加请求成功的状态内容 - * @param object - * @return - */ - public static JSONObject extendSuccessResult(JSONObject object) { - return extendResult(object, JSONResponse.CODE_SUCCESS, JSONResponse.MSG_SUCCEED); - } - /**获取请求成功的状态内容 - * @return - */ - public static JSONObject newSuccessResult() { - return newResult(JSONResponse.CODE_SUCCESS, JSONResponse.MSG_SUCCEED); - } - /**添加请求成功的状态内容 - * @param object - * @return - */ - public static JSONObject extendErrorResult(JSONObject object, Exception e) { - JSONObject error = newErrorResult(e); - return extendResult(object, error.getIntValue(JSONResponse.KEY_CODE), error.getString(JSONResponse.KEY_MSG)); - } - /**新建错误状态内容 - * @param e - * @return - */ - public static JSONObject newErrorResult(Exception e) { - if (e != null) { - e.printStackTrace(); - - int code; - if (e instanceof UnsupportedEncodingException) { - code = JSONResponse.CODE_UNSUPPORTED_ENCODING; - } - else if (e instanceof IllegalAccessException) { - code = JSONResponse.CODE_ILLEGAL_ACCESS; - } - else if (e instanceof UnsupportedOperationException) { - code = JSONResponse.CODE_UNSUPPORTED_OPERATION; - } - else if (e instanceof NotExistException) { - code = JSONResponse.CODE_NOT_FOUND; - } - else if (e instanceof IllegalArgumentException) { - code = JSONResponse.CODE_ILLEGAL_ARGUMENT; - } - else if (e instanceof NotLoggedInException) { - code = JSONResponse.CODE_NOT_LOGGED_IN; - } - else if (e instanceof TimeoutException) { - code = JSONResponse.CODE_TIME_OUT; - } - else if (e instanceof ConflictException) { - code = JSONResponse.CODE_CONFLICT; - } - else if (e instanceof ConditionErrorException) { - code = JSONResponse.CODE_CONDITION_ERROR; - } - else if (e instanceof UnsupportedDataTypeException) { - code = JSONResponse.CODE_UNSUPPORTED_TYPE; - } - else if (e instanceof OutOfRangeException) { - code = JSONResponse.CODE_OUT_OF_RANGE; - } - else if (e instanceof NullPointerException) { - code = JSONResponse.CODE_NULL_POINTER; - } - else { - code = JSONResponse.CODE_SERVER_ERROR; - } - - return newResult(code, e.getMessage()); - } - - return newResult(JSONResponse.CODE_SERVER_ERROR, JSONResponse.MSG_SERVER_ERROR); - } - - - - - //TODO 启动时一次性加载Request所有内容,作为初始化。 - /**获取正确的请求,非GET请求必须是服务器指定的 - * @param method - * @param request - * @return - * @throws Exception - */ - public static JSONObject getCorrectRequest(@NotNull RequestMethod method, JSONObject request) throws Exception { - if (RequestMethod.isPublicMethod(method)) { - return request;//需要指定JSON结构的get请求可以改为post请求。一般只有对安全性要求高的才会指定,而这种情况用明文的GET方式几乎肯定不安全 - } - - String tag = request.getString(JSONRequest.KEY_TAG); - if (StringUtil.isNotEmpty(tag, true) == false) { - throw new IllegalArgumentException("请设置tag!一般是Table名"); - } - int version = request.getIntValue(JSONRequest.KEY_VERSION); - - JSONObject object = null; - String error = ""; - try { - object = getStructure(method, "Request", JSONRequest.KEY_TAG, tag, version); - } catch (Exception e) { - error = e.getMessage(); - } - if (object == null) {//empty表示随意操作 || object.isEmpty()) { - throw new UnsupportedOperationException("非开放请求必须是服务端允许的操作! \n " + error); - } - - JSONObject target = null; - if (zuo.biao.apijson.JSONObject.isTableKey(tag) && object.containsKey(tag) == false) {//tag是table名 - target = new JSONObject(true); - target.put(tag, object); - } else { - target = object; - } - //获取指定的JSON结构 >>>>>>>>>>>>>> - - request.remove(JSONRequest.KEY_TAG); - request.remove(JSONRequest.KEY_VERSION); - return Structure.parseRequest(method, "", (JSONObject) target.clone(), request); - } - - //TODO 优化性能! - /**获取正确的返回结果 - * @param method - * @param response - * @return - * @throws Exception - */ - public static JSONObject getCorrectResponse(@NotNull final RequestMethod method - , String table, JSONObject response) throws Exception { - // Log.d(TAG, "getCorrectResponse method = " + method + "; table = " + table); - // if (response == null || response.isEmpty()) {//避免无效空result:{}添加内容后变有效 - // Log.e(TAG, "getCorrectResponse response == null || response.isEmpty() >> return response;"); - return response; - // } - // - // JSONObject target = zuo.biao.apijson.JSONObject.isTableKey(table) == false - // ? new JSONObject() : getStructure(method, "Response", "model", table); - // - // return MethodStructure.parseResponse(method, table, target, response, new OnParseCallback() { - // - // @Override - // protected JSONObject onParseJSONObject(String key, JSONObject tobj, JSONObject robj) throws Exception { - // return getCorrectResponse(method, key, robj); - // } - // }); - } - - /**获取Request或Response内指定JSON结构 - * @param method - * @param table - * @param key - * @param value - * @param version - * @return - * @throws Exception - */ - public static JSONObject getStructure(@NotNull final RequestMethod method, @NotNull String table, - String key, String value, int version) throws Exception { - //获取指定的JSON结构 <<<<<<<<<<<<<< - SQLConfig config = new SQLConfig(GET, table); - config.setColumn("structure"); - - Map where = new HashMap(); - where.put("method", method.name()); - if (key != null) { - where.put(key, value); - } - if (version > 0) { - where.put(JSONRequest.KEY_VERSION + "{}", ">=" + version); - } - config.setWhere(where); - config.setOrder(JSONRequest.KEY_VERSION + (version > 0 ? "+" : "-")); - config.setCount(1); - - SQLExecutor qh = new SQLExecutor(); - - //too many connections error: 不try-catch,可以让客户端看到是服务器内部异常 - try { - JSONObject result = qh.execute(config.setCacheStatic(true)); - return getJSONObject(result, "structure");//解决返回值套了一层 "structure":{} - } finally { - qh.close(); - } - } - - - /**获取单个对象,该对象处于parentObject内 - * @param parentPath parentObject的路径 - * @param name parentObject的key - * @param request parentObject的value - * @return - * @throws Exception - */ - private JSONObject getObject(String parentPath, String name, JSONObject request) throws Exception { - return getObject(parentPath, name, request, null); - } - - // private SQLConfig itemConfig; - /**获取单个对象,该对象处于parentObject内 - * @param parentPath parentObject的路径 - * @param name parentObject的key - * @param request parentObject的value - * @param config for array item - * @return - * @throws Exception - */ - private JSONObject getObject(String parentPath, String name, final JSONObject request - , final SQLConfig arrayConfig) throws Exception { - Log.i(TAG, "\ngetObject: parentPath = " + parentPath - + ";\n name = " + name + "; request = " + JSON.toJSONString(request)); - if (request == null) {// Moment:{} || request.isEmpty()) {//key-value条件 - return null; - } - - final int type = arrayConfig == null ? 0 : arrayConfig.getType(); - final boolean isArrayItem = type == ObjectParser.TYPE_ITEM; - - ObjectParser op = new ObjectParser(request, parentPath, type, name) { - - @Override - public Object getTarget(@NotNull String path) { - return getValueByPath(path); - } - - @Override - public JSONObject executeSQL(@NotNull String path, @NotNull SQLConfig config) throws Exception { - JSONObject result = getSQLObject(config); - if (result != null) { - putQueryResult(path, result);//解决获取关联数据时requestObject里不存在需要的关联数据 - } - return result; - } - - com.alibaba.fastjson.JSON child; - boolean isFirst = true; - boolean isEmpty; - @Override - public com.alibaba.fastjson.JSON parseChild(@NotNull String path, @NotNull String key - , @NotNull com.alibaba.fastjson.JSON value) throws Exception { - if (zuo.biao.apijson.JSONObject.isArrayKey(key)) {//APIJSON Array - child = getArray(path, key, (JSONObject) value); - isEmpty = child == null || ((JSONArray) child).isEmpty(); - } else {//APIJSON Object - child = getObject(path, key, (JSONObject) value - , isFirst && isArrayItem ? arrayConfig.setType(TYPE_ITEM_CHILD_0) : null); - isEmpty = child == null || ((JSONObject) child).isEmpty(); - if (isFirst && isEmpty) { - invalidate(); - } - - isFirst = false; - } - Log.i(TAG, "getObject ObjectParser.onParse key = " + key + "; child = " + child); - - return isEmpty ? null : child;//只添加! isEmpty的值,可能数据库返回数据不够count - } - - @Override - public JSONObject parseResponse(JSONRequest request) throws Exception { - return new Parser(GET) - .setSession(session) - // .setNoVerifyRequest(noVerifyRequest) - .setNoVerifyLogin(noVerifyLogin) - .setNoVerifyRole(noVerifyRole) - .parseResponse(request); - } - - // @Override - // protected SQLConfig newQueryConfig() { - // if (itemConfig != null) { - // return itemConfig; - // } - // return super.newQueryConfig(); - // } - - //导致最多评论的(Strong 30个)的那个动态详情界面Android(82001)无姓名和头像,即User=null - // @Override - // protected void onComplete() { - // if (response != null) { - // putQueryResult(path, response);//解决获取关联数据时requestObject里不存在需要的关联数据 - // } - // } - - }.setMethod(requestMethod).parse(); - - - - JSONObject response = null; - if (op != null) {//TODO SQL查询结果为空时,functionMap和customMap还有没有意义? - if (arrayConfig == null) {//Common - response = op.executeSQL().response(); - } else {//Array Item Child - int query = arrayConfig.getQuery(); - - //total - if (type == ObjectParser.TYPE_ITEM_CHILD_0 && query != JSONRequest.QUERY_TABLE - && arrayConfig.getPosition() == 0) { - JSONObject rp = op.setMethod(RequestMethod.HEAD).executeSQL().getSqlReponse(); - if (rp != null) { - int index = parentPath.lastIndexOf("]/"); - if (index >= 0) { - int total = rp.getIntValue(JSONResponse.KEY_COUNT); - putQueryResult(parentPath.substring(0, index) + "]/" + JSONResponse.KEY_TOTAL, total); - - if (total <= arrayConfig.getCount()*arrayConfig.getPage()) { - query = JSONRequest.QUERY_TOTAL;//数量不够了,不再往后查询 - } - } - } - - op.setMethod(requestMethod); - } - - //Table - if (query == JSONRequest.QUERY_TOTAL) { - response = null;//不再往后查询 - } else { - response = op.executeSQL( - arrayConfig.getCount(), arrayConfig.getPage(), arrayConfig.getPosition() - ).response(); - // itemConfig = op.getConfig(); - } - } - - op.recycle(); - op = null; - } - - return response; - } - - /**获取对象数组,该对象数组处于parentObject内 - * @param parentPath parentObject的路径 - * @param name parentObject的key - * @param request parentObject的value - * @return - * @throws Exception - */ - private JSONArray getArray(String parentPath, String name, final JSONObject request) throws Exception { - Log.i(TAG, "\n\n\n getArray parentPath = " + parentPath - + "; name = " + name + "; request = " + JSON.toJSONString(request)); - //不能允许GETS,否则会被通过"[]":{"@role":"ADMIN"},"Table":{},"tag":"Table"绕过权限并能批量查询 - if (RequestMethod.isGetMethod(requestMethod, false) == false) { - throw new UnsupportedOperationException("key[]:{}只支持GET方法!不允许传 " + name + ":{} !"); - } - if (request == null || request.isEmpty()) {//jsonKey-jsonValue条件 - return null; - } - String path = getAbsPath(parentPath, name); - - //不能改变,因为后面可能继续用到,导致1以上都改变 []:{0:{Comment[]:{0:{Comment:{}},1:{...},...}},1:{...},...} - final int query = request.getIntValue(JSONRequest.KEY_QUERY); - final int count = request.getIntValue(JSONRequest.KEY_COUNT); - final int page = request.getIntValue(JSONRequest.KEY_PAGE); - request.remove(JSONRequest.KEY_QUERY); - request.remove(JSONRequest.KEY_COUNT); - request.remove(JSONRequest.KEY_PAGE); - Log.d(TAG, "getArray query = " + query + "; count = " + count + "; page = " + page); - - if (request.isEmpty()) {//如果条件成立,说明所有的 parentPath/name:request 中request都无效!!! - Log.e(TAG, "getArray request.isEmpty() >> return null;"); - return null; - } - - - //不用total限制数量了,只用中断机制,total只在query = 1,2的时候才获取 - int size = count <= 0 || count > 100 ? 100 : count;//count为每页数量,size为第page页实际数量,max(size) = count - Log.d(TAG, "getArray size = " + size + "; page = " + page); - - - //key[]:{Table:{}}中key equals Table时 提取Table - int index = name == null ? -1 : name.lastIndexOf("[]"); - String childPath = index <= 0 ? null : Pair.parseEntry(name.substring(0, index), true).getKey(); // Table-key1-key2... - - //判断第一个key,即Table是否存在,如果存在就提取 - String[] childKeys = StringUtil.split(childPath, "-", false); - if (childKeys == null || childKeys.length <= 0 || request.containsKey(childKeys[0]) == false) { - childKeys = null; - } - - - //Table<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - JSONArray response = new JSONArray(); - JSONObject parent; - SQLConfig config = new SQLConfig(requestMethod, size, page).setQuery(query); - //生成size个 - for (int i = 0; i < size; i++) { - parent = getObject(path, "" + i, request, config.setType(ObjectParser.TYPE_ITEM).setPosition(i)); - if (parent == null || parent.isEmpty()) { - break; - } - //key[]:{Table:{}}中key equals Table时 提取Table - response.add(getValue(parent, childKeys)); //null有意义 - } - //Table>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //后面还可能用到,要还原 - request.put(JSONRequest.KEY_QUERY, query); - request.put(JSONRequest.KEY_COUNT, count); - request.put(JSONRequest.KEY_PAGE, page); - - Log.i(TAG, "getArray return response = \n" + JSON.toJSONString(response) + "\n>>>>>>>>>>>>>>>\n\n\n"); - return response; - } - - - /**根据路径取值 - * @param parent - * @param pathKeys - * @return - */ - private static Object getValue(JSONObject parent, String[] pathKeys) { - if (parent == null || pathKeys == null || pathKeys.length <= 0) { - Log.w(TAG, "getChild parent == null || pathKeys == null || pathKeys.length <= 0 >> return parent;"); - return parent; - } - - //逐层到达child的直接容器JSONObject parent - final int last = pathKeys.length - 1; - for (int i = 0; i < last; i++) {//一步一步到达指定位置 - if (parent == null) {//不存在或路径错误(中间的key对应value不是JSONObject) - break; - } - parent = getJSONObject(parent, pathKeys[i]); - } - - return parent == null ? null : parent.get(pathKeys[last]); - } - - - /**获取被依赖引用的key的路径, 实时替换[] -> []/i - * @param parentPath - * @param valuePath - * @return - */ - public static String getValuePath(String parentPath, String valuePath) { - if (valuePath.startsWith("/")) { - valuePath = getAbsPath(parentPath, valuePath); - } else {//处理[] -> []/i - valuePath = replaceArrayChildPath(parentPath, valuePath); - } - return valuePath; - } - - /**获取绝对路径 - * @param path - * @param name - * @return - */ - public static String getAbsPath(String path, String name) { - Log.i(TAG, "getPath path = " + path + "; name = " + name + " <<<<<<<<<<<<<"); - path = StringUtil.getString(path); - name = StringUtil.getString(name); - if (StringUtil.isNotEmpty(path, false)) { - if (StringUtil.isNotEmpty(name, false)) { - path += ((name.startsWith("/") ? "" : "/") + name); - } - } else { - path = name; - } - if (path.startsWith("/")) { - path = path.substring(1); - } - Log.i(TAG, "getPath return " + path + " >>>>>>>>>>>>>>>>"); - return path; - } - - /**替换[] -> []/i - * 不能写在getAbsPath里,因为name不一定是依赖路径 - * @param parentPath - * @param valuePath - * @return - */ - public static String replaceArrayChildPath(String parentPath, String valuePath) { - String[] ps = StringUtil.split(parentPath, "]/");//"[]/"); - if (ps != null && ps.length > 1) { - String[] vs = StringUtil.split(valuePath, "]/"); - - if (vs != null && vs.length > 0) { - String pos; - for (int i = 0; i < ps.length - 1; i++) { - if (ps[i] == null || ps[i].equals(vs[i]) == false) {//允许""? - break; - } - - pos = ps[i+1].contains("/") == false ? ps[i+1] - : ps[i+1].substring(0, ps[i+1].indexOf("/")); - if ( - //StringUtil.isNumer(pos) && - vs[i+1].startsWith(pos + "/") == false) { - vs[i+1] = pos + "/" + vs[i+1]; - } - } - return StringUtil.getString(vs, "]/"); - } - } - return valuePath; - } - - //依赖引用关系 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**将已获取完成的object的内容替换requestObject里对应的值 - * @param path object的路径 - * @param result 需要被关联的object - */ - private synchronized void putQueryResult(String path, Object result) { - Log.i(TAG, "\n putQueryResult valuePath = " + path + "; result = " + result + "\n <<<<<<<<<<<<<<<<<<<<<<<"); - // if (queryResultMap.containsKey(valuePath)) {//只保存被关联的value - Log.d(TAG, "putQueryResult queryResultMap.containsKey(valuePath) >> queryResultMap.put(path, result);"); - queryResultMap.put(path, result); - // } - } - /**根据路径获取值 - * @param valuePath - * @return parent == null ? valuePath : parent.get(keys[keys.length - 1]) - */ - private Object getValueByPath(String valuePath) { - Log.i(TAG, "<<<<<<<<<<<<<<< \n getValueByPath valuePath = " + valuePath + "\n <<<<<<<<<<<<<<<<<<"); - if (StringUtil.isEmpty(valuePath, true)) { - Log.e(TAG, "getValueByPath StringUtil.isNotEmpty(valuePath, true) == false >> return null;"); - return null; - } - Object target = queryResultMap.get(valuePath); - if (target != null) { - return target; - } - - //取出key被valuePath包含的result,再从里面获取key对应的value - Set set = queryResultMap.keySet(); - JSONObject parent = null; - String[] keys = null; - for (String path : set) { - if (valuePath.startsWith(path + "/")) { - try { - parent = (JSONObject) queryResultMap.get(path); - } catch (Exception e) { - Log.e(TAG, "getValueByPath try { parent = (JSONObject) queryResultMap.get(path); } catch { " - + "\n parent not instanceof JSONObject!"); - parent = null; - } - if (parent != null) { - keys = StringUtil.splitPath(valuePath.substring(path.length())); - } - break; - } - } - - //逐层到达targetKey的直接容器JSONObject parent - if (keys != null && keys.length > 1) { - for (int i = 0; i < keys.length - 1; i++) {//一步一步到达指定位置parentPath - if (parent == null) {//不存在或路径错误(中间的key对应value不是JSONObject) - break; - } - parent = getJSONObject(parent, keys[i]); - } - } - - if (parent != null) { - Log.i(TAG, "getValueByPath >> get from queryResultMap >> return parent.get(keys[keys.length - 1]);"); - target = parent.get(keys[keys.length - 1]); //值为null应该报错NotExistExeption,一般都是id关联,不可为null,否则可能绕过安全机制 - if (target != null) { - Log.i(TAG, "getValueByPath >> getValue >> return target = " + target); - return target; - } - } - - - //从requestObject中取值 - target = getValue(requestObject, StringUtil.splitPath(valuePath)); - if (target != null) { - Log.i(TAG, "getValueByPath >> getValue >> return target = " + target); - return target; - } - - Log.i(TAG, "getValueByPath return valuePath;"); - return valuePath; - } - - //依赖引用关系 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - public static JSONObject getJSONObject(JSONObject object, String key) { - try { - return object.getJSONObject(key); - } catch (Exception e) { - Log.i(TAG, "getJSONObject try { return object.getJSONObject(key);" - + " } catch (Exception e) { \n" + e.getMessage()); - } - return null; - } - - - /**获取数据库返回的String - * @param config - * @return - * @throws Exception - */ - private synchronized JSONObject getSQLObject(SQLConfig config) throws Exception { - Log.i(TAG, "getSQLObject config = " + JSON.toJSONString(config)); - if (noVerifyRole == false) { - if (config.getRole() == null) { - if (globleRole != null) { - config.setRole(globleRole); - } else { - config.setRole(visitorId <= 0 ? RequestRole.UNKNOWN : RequestRole.LOGIN); - } - } - Verifier.verify(config, visitor); - } - return getCorrectResponse(requestMethod, config.getTable(), sqlExecutor.execute(config)); - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/ParserAdapter.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/ParserAdapter.java deleted file mode 100644 index 53cfb0e32..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/ParserAdapter.java +++ /dev/null @@ -1,59 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import javax.validation.constraints.NotNull; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; - -import zuo.biao.apijson.server.sql.SQLConfig; - -/** - * @author Lemon - */ -public interface ParserAdapter { - - /** - * @param path - * @return - */ - Object getTarget(@NotNull String path); - - /** - * @param path - * @param key - * @param value - * @return - * @throws Exception - */ - JSON parseChild(@NotNull String path, @NotNull String key, @NotNull JSON value) throws Exception; - - /** - * @param request - * @return - * @throws Exception - */ - JSONObject parseResponse(@NotNull JSONRequest request) throws Exception; - - /** - * @param path - * @param config - * @return - * @throws Exception - */ - JSONObject executeSQL(@NotNull String path, @NotNull SQLConfig config) throws Exception; - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Structure.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Structure.java deleted file mode 100644 index e5993b9a6..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/Structure.java +++ /dev/null @@ -1,600 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import static zuo.biao.apijson.JSONRequest.KEY_ID; -import static zuo.biao.apijson.JSONRequest.KEY_ID_IN; -import static zuo.biao.apijson.server.Operation.ADD; -import static zuo.biao.apijson.server.Operation.DISALLOW; -import static zuo.biao.apijson.server.Operation.NECESSARY; -import static zuo.biao.apijson.server.Operation.PUT; -import static zuo.biao.apijson.server.Operation.REMOVE; -import static zuo.biao.apijson.server.Operation.REPLACE; -import static zuo.biao.apijson.server.Operation.UNIQUE; -import static zuo.biao.apijson.server.Operation.VERIFY; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; -import java.util.regex.Pattern; - -import javax.activation.UnsupportedDataTypeException; -import javax.validation.constraints.NotNull; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -import apijson.demo.server.Verifier; -import apijson.demo.server.model.BaseModel; -import zuo.biao.apijson.JSON; -import zuo.biao.apijson.JSONResponse; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.RequestMethod; -import zuo.biao.apijson.RequestRole; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.model.Test; -import zuo.biao.apijson.server.sql.SQLConfig; -import zuo.biao.apijson.server.sql.SQLExecutor; - -//TODO 放到 zuo.biao.apijson 包内,供Android客户端校验请求结构 -/**结构类 - * 增删改查: OPERATION(ADD,REPLACE,PUT,REMOVE) OPERATION:{key0:value0, key1:value1 ...} - * 对值校验: VERIFY:{key0:value0, key1:value1 ...} (key{}:range,key$:"%m%"等) - * 对值重复性校验: UNIQUE:"key0:, key1 ..." (UNIQUE:"phone,email" 等) - * @author Lemon - */ -public class Structure { - private static final String TAG = "Structure"; - - - - private Structure() {} - - - - static final String requestString = "{\"Comment\":{\"DISALLOW\": \"id\", \"NECESSARY\": \"userId,momentId,content\"}, \"ADD\":{\"Comment:to\":{}}}"; - static final String responseString = "{\"User\":{\"REMOVE\": \"phone\", \"REPLACE\":{\"sex\":2}, \"ADD\":{\"name\":\"api\"}}, \"PUT\":{\"Comment:to\":{}}}"; - /**测试 - * @throws Exception - */ - public static void test() throws Exception { - JSONObject request; - try { - request = JSON.parseObject("{\"Comment\":{\"userId\":0}}"); - Log.d(TAG, "test parseRequest = " + parseRequest(RequestMethod.POST, "", JSON.parseObject(requestString), request)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - request = JSON.parseObject("{\"Comment\":{\"userId\":0, \"momentId\":0, \"content\":\"apijson\"}}"); - Log.d(TAG, "test parseRequest = " + parseRequest(RequestMethod.POST, "", JSON.parseObject(requestString), request)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - request = JSON.parseObject("{\"Comment\":{\"id\":0, \"userId\":0, \"momentId\":0, \"content\":\"apijson\"}}"); - Log.d(TAG, "test parseRequest = " + parseRequest(RequestMethod.POST, "", JSON.parseObject(requestString), request)); - } catch (Exception e) { - e.printStackTrace(); - } - - - JSONObject response; - try { - response = JSON.parseObject("{\"User\":{\"userId\":0}}"); - Log.d(TAG, "test parseResponse = " + parseResponse(RequestMethod.GET, "", JSON.parseObject(responseString), response, null)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - response = JSON.parseObject("{\"User\":{\"userId\":0, \"phone\":\"12345678\"}}"); - Log.d(TAG, "test parseResponse = " + parseResponse(RequestMethod.GET, "", JSON.parseObject(responseString), response, null)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - response = JSON.parseObject("{\"User\":{\"userId\":0, \"phone\":\"12345678\", \"sex\":1}}"); - Log.d(TAG, "test parseResponse = " + parseResponse(RequestMethod.GET, "", JSON.parseObject(responseString), response, null)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - response = JSON.parseObject("{\"User\":{\"id\":0, \"name\":\"tommy\", \"phone\":\"12345678\", \"sex\":1}}"); - Log.d(TAG, "test parseResponse = " + parseResponse(RequestMethod.GET, "", JSON.parseObject(responseString), response, null)); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - - - - - - /**从request提取target指定的内容 - * @param method - * @param name - * @param target - * @param request - * @return - * @throws Exception - */ - public static JSONObject parseRequest(@NotNull final RequestMethod method, final String name - , final JSONObject target, final JSONObject request) throws Exception { - Log.i(TAG, "parseRequest method = " + method + "; name = " + name - + "; target = \n" + JSON.toJSONString(target) - + "\n request = \n" + JSON.toJSONString(request)); - if (target == null || request == null) {// || request.isEmpty()) { - Log.i(TAG, "parseRequest target == null || request == null >> return null;"); - return null; - } - - //TODO globleRole要不要改成@role? 只允许服务端Request表中加上可控的ADMIN角色 - if (RequestRole.get(request.getString(JSONRequest.KEY_ROLE)) == RequestRole.ADMIN) { - throw new IllegalArgumentException("角色设置错误!不允许在写操作Request中传 " + name + - ":{ " + JSONRequest.KEY_ROLE + ":admin } !"); - } - - //解析 - return parse(name, target, request, new OnParseCallback() { - - @Override - public JSONObject onParseJSONObject(String key, JSONObject tobj, JSONObject robj) throws Exception { - // Log.i(TAG, "parseRequest.parse.onParseJSONObject key = " + key + "; robj = " + robj); - if (robj == null) { - if (tobj != null) {//不允许不传Target中指定的Table - throw new IllegalArgumentException(method.name() + "请求,请在 " + name + " 内传 " + key + ":{} !"); - } - } else if (zuo.biao.apijson.JSONObject.isTableKey(key)) { - if (method == RequestMethod.POST) { - if (robj.containsKey(KEY_ID)) { - throw new IllegalArgumentException("POST请求," + name + "/" + key + " 不能传 " + KEY_ID + " !"); - } - } else { - if (RequestMethod.isQueryMethod(method) == false) { - //单个修改或删除 - Object id = robj.get(KEY_ID); //如果必须传 id ,可在Request表中配置necessary - if (id != null) { - if (id instanceof Number == false) { - throw new IllegalArgumentException(method.name() + "请求," + name + "/" + key - + " 里面的 " + KEY_ID_IN + ":value 中value的类型只能是Long!"); - } - } else { - //批量修改或删除 - Object arr = robj.get(KEY_ID_IN); //如果必须传 id{} ,可在Request表中配置necessary - if (arr == null) { - throw new IllegalArgumentException(method.name() + "请求," + name + "/" + key - + " 里面 " + KEY_ID + " 和 " + KEY_ID_IN + " 必须传其中一个!"); - } - if (arr instanceof JSONArray == false) { - throw new IllegalArgumentException(method.name() + "请求," + name + "/" + key - + " 里面的 " + KEY_ID_IN + ":value 中value的类型只能是 [Long] !"); - } - if (((JSONArray)arr).size() > 10) { //不允许一次操作10条以上记录 - throw new IllegalArgumentException(method.name() + "请求," + name + "/" + key - + " 里面的 " + KEY_ID_IN + ":[] 中[]的长度不能超过10!"); - } - } - } - } - } - - return parseRequest(method, key, tobj, robj); - } - }); - - } - - - /**校验并将response转换为指定的内容和结构 - * @param method - * @param name - * @param target - * @param response - * @param callback - * @return - * @throws Exception - */ - public static JSONObject parseResponse(@NotNull final RequestMethod method, final String name - , final JSONObject target, final JSONObject response, OnParseCallback callback) throws Exception { - Log.i(TAG, "parseResponse method = " + method + "; name = " + name - + "; target = \n" + JSON.toJSONString(target) - + "\n response = \n" + JSON.toJSONString(response)); - if (target == null || response == null) {// || target.isEmpty() { - Log.i(TAG, "parseRequest target == null || response == null >> return response;"); - return response; - } - - //解析 - return parse(name, target, response, callback != null ? callback : new OnParseCallback() {}); - } - - - /**对request和response不同的解析用callback返回 - * @param target - * @param request - * @param callback - * @return - * @throws Exception - */ - public static JSONObject parse(String name, JSONObject target, JSONObject real - , @NotNull OnParseCallback callback) throws Exception { - if (target == null) { - return null; - } - - - //获取配置<<<<<<<<<<<<<<<<<<<<<<<<<<<< - JSONObject verify = target.getJSONObject(VERIFY.name()); - JSONObject add = target.getJSONObject(ADD.name()); - JSONObject put = target.getJSONObject(PUT.name()); - JSONObject replace = target.getJSONObject(REPLACE.name()); - - String unique = StringUtil.getNoBlankString(target.getString(UNIQUE.name())); - String remove = StringUtil.getNoBlankString(target.getString(REMOVE.name())); - String necessary = StringUtil.getNoBlankString(target.getString(NECESSARY.name())); - String disallow = StringUtil.getNoBlankString(target.getString(DISALLOW.name())); - - //不还原,传进来的target不应该是原来的 - target.remove(VERIFY.name()); - target.remove(ADD.name()); - target.remove(PUT.name()); - target.remove(REPLACE.name()); - - target.remove(UNIQUE.name()); - target.remove(REMOVE.name()); - target.remove(NECESSARY.name()); - target.remove(DISALLOW.name()); - //获取配置>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //移除字段<<<<<<<<<<<<<<<<<<< - String[] removes = StringUtil.split(remove); - if (removes != null && removes.length > 0) { - for (String r : removes) { - real.remove(r); - } - } - //移除字段>>>>>>>>>>>>>>>>>>> - - //判断必要字段是否都有<<<<<<<<<<<<<<<<<<< - String[] necessarys = StringUtil.split(necessary); - List necessaryList = necessarys == null ? new ArrayList() : Arrays.asList(necessarys); - for (String s : necessaryList) { - if (real.get(s) == null) {//可能传null进来,这里还会通过 real.containsKey(s) == false) { - throw new IllegalArgumentException(name - + " 里面不能缺少 " + s + " 等[" + necessary + "]内的任何字段!"); - } - } - //判断必要字段是否都有>>>>>>>>>>>>>>>>>>> - - - Set objKeySet = new HashSet(); //不能用tableKeySet,仅判断 Table:{} 会导致 key:{ Table:{} } 绕过判断 - - //解析内容<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - Set> set = new LinkedHashSet<>(target.entrySet()); - if (set.isEmpty() == false) { - - String key; - Object tvalue; - Object rvalue; - for (Entry entry : set) { - key = entry == null ? null : entry.getKey(); - if (key == null) { - continue; - } - tvalue = entry.getValue(); - rvalue = real.get(key); - if (callback.onParse(key, tvalue, rvalue) == false) { - continue; - } - - if (tvalue instanceof JSONObject) {//JSONObject,往下一级提取 - tvalue = callback.onParseJSONObject(key, (JSONObject) tvalue, (JSONObject) rvalue); - - objKeySet.add(key); - } else if (tvalue instanceof JSONArray) {//JSONArray - tvalue = callback.onParseJSONArray(key, (JSONArray) tvalue, (JSONArray) rvalue); - } else {//其它Object - tvalue = callback.onParseObject(key, tvalue, rvalue); - } - - if (tvalue != null) {//可以在target中加上一些不需要客户端传的键值对 - real.put(key, tvalue); - } - } - - } - - //解析内容>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - Set rkset = real.keySet(); //解析内容并没有改变rkset - - //解析不允许的字段<<<<<<<<<<<<<<<<<<< - List disallowList = new ArrayList(); - if ("!".equals(disallow)) {//所有非necessary,改成 !necessary 更好 - for (String key : rkset) {//对@key放行,@role,@column,自定义@position等 - if (key != null && key.startsWith("@") == false - && necessaryList.contains(key) == false && objKeySet.contains(key) == false) { - disallowList.add(key); - } - } - } else { - String[] disallows = StringUtil.split(disallow); - if (disallows != null && disallows.length > 0) { - disallowList.addAll(Arrays.asList(disallows)); - } - } - //解析不允许的字段>>>>>>>>>>>>>>>>>>> - - - //判断不允许传的key<<<<<<<<<<<<<<<<<<<<<<<<< - for (String rk : rkset) { - if (disallowList.contains(rk)) { //不允许的字段 - throw new IllegalArgumentException(name - + " 里面不允许传 " + rk + " 等" + StringUtil.getString(disallowList) + "内的任何字段!"); - } - - if (rk == null) { //无效的key - real.remove(rk); - continue; - } - - //不在target内的 key:{} - if (rk.startsWith("@") == false && objKeySet.contains(rk) == false && real.get(rk) instanceof JSONObject) { - throw new UnsupportedOperationException(name + " 里面不允许传 " + rk + ":{} !"); - } - } - //判断不允许传的key>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //校验与修改Request<<<<<<<<<<<<<<<<< - //在tableKeySet校验后操作,避免 导致put/add进去的Table 被当成原Request的内容 - real = operate(VERIFY, verify, real); - real = operate(ADD, add, real); - real = operate(PUT, put, real); - real = operate(REPLACE, replace, real); - //校验与修改Request>>>>>>>>>>>>>>>>> - - //TODO放在operate前?考虑性能、operate修改后再验证的值是否和原来一样 - //校验重复<<<<<<<<<<<<<<<<<<< - String[] uniques = StringUtil.split(unique); - if (BaseModel.isEmpty(uniques) == false) { - long exceptId = real.getLongValue(KEY_ID); - for (String u : uniques) { - Verifier.verifyRepeat(name, u, real.get(u), exceptId); - } - } - //校验重复>>>>>>>>>>>>>>>>>>> - - Log.i(TAG, "parse return real = " + JSON.toJSONString(real)); - return real; - } - - - - /**执行操作 - * @param opt - * @param targetChild - * @param real - * @return - * @throws Exception - */ - private static JSONObject operate(Operation opt, JSONObject targetChild, JSONObject real) throws Exception { - if (targetChild == null) { - return real; - } - if (real == null) { - throw new IllegalArgumentException("operate real == null!!!"); - } - - - Set> set = new LinkedHashSet<>(targetChild.entrySet()); - String tk; - Object tv; - - for (Entry e : set) { - tk = e == null ? null : e.getKey(); - if (tk == null) { - continue; - } - tv = e.getValue(); - - if (opt == VERIFY) { - verify(tk, tv, real); - } else if (opt == PUT) { - real.put(tk, tv); - } else { - if (real.containsKey(tk)) { - if (opt == REPLACE) { - real.put(tk, tv); - } - } else { - if (opt == ADD) { - real.put(tk, tv); - } - } - } - } - - return real; - } - - - /**验证值 - * @param tk - * @param tv - * @param real - * @throws Exception - */ - private static void verify(@NotNull String tk, @NotNull Object tv, @NotNull JSONObject real) throws Exception { - if (tv == null) { - throw new IllegalArgumentException("operate operate == VERIFY " + tk + ":" + tv + " , >> tv == null!!!"); - } - - String rk; - Object rv; - Logic logic; - if (tk.endsWith("$")) { //搜索 - sqlVerify("$", real, tk, tv); - } - else if (tk.endsWith("?")) { //正则表达式 - logic = new Logic(tk.substring(0, tk.length() - 1)); - rk = logic.getKey(); - rv = real.get(rk); - if (rv == null) { - return; - } - - JSONArray array = SQLConfig.newJSONArray(tv); - - boolean m; - boolean isOr = false; - Pattern reg; - for (Object r : array) { - if (r instanceof String == false) { - throw new UnsupportedDataTypeException(rk + ":" + rv + " 中value只支持 String 或 [String] 类型!"); - } - reg = ObjectParser.COMPILE_MAP.get(r); - if (reg == null) { - reg = Pattern.compile((String) r); - } - m = reg.matcher("" + rv).matches(); - if (m) { - if (logic.isNot()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - if (logic.isOr()) { - isOr = true; - break; - } - } else { - if (logic.isAnd()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - } - } - - if (isOr == false && logic.isOr()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - } - else if (tk.endsWith("{}")) { //rv符合tv条件或在tv内 - if (tv instanceof String) {//TODO >= 0, < 10 - sqlVerify("{}", real, tk, tv); - } - else if (tv instanceof JSONArray) { - logic = new Logic(tk.substring(0, tk.length() - 2)); - rk = logic.getKey(); - rv = real.get(rk); - if (rv == null) { - return; - } - - if (((JSONArray) tv).contains(rv) == logic.isNot()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - } - else { - throw new UnsupportedDataTypeException("服务器Request表verify配置错误!"); - } - } - else if (tk.endsWith("<>")) { //rv包含tv内的值 - logic = new Logic(tk.substring(0, tk.length() - 2)); - rk = logic.getKey(); - rv = real.get(rk); - if (rv == null) { - return; - } - - if (rv instanceof JSONArray == false) { - throw new UnsupportedDataTypeException("服务器Request表verify配置错误!"); - } - - JSONArray array = SQLConfig.newJSONArray(tv); - - boolean isOr = false; - for (Object o : array) { - if (((JSONArray) rv).contains(o)) { - if (logic.isNot()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - if (logic.isOr()) { - isOr = true; - break; - } - } else { - if (logic.isAnd()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - } - } - - if (isOr == false && logic.isOr()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - } - else { - throw new IllegalArgumentException("服务器Request表verify配置错误!"); - } - } - - /**通过数据库执行SQL语句来验证条件 - * @param funChar - * @param real - * @param tk - * @param tv - * @throws Exception - */ - private static void sqlVerify(@NotNull String funChar, JSONObject real, String tk, Object tv) throws Exception { - //不能用Parser, 0 这种不符合 StringUtil.isName ! - Logic logic = new Logic(tk.substring(0, tk.length() - funChar.length())); - String rk = logic.getKey(); - Object rv = real.get(rk); - if (rv == null) { - return; - } - - SQLConfig config = new SQLConfig(RequestMethod.HEAD, 1, 0); - config.setTable(Test.class.getSimpleName()); - config.setTest(true); - config.addWhere("'" + rv + "'" + logic.getChar() + funChar, tv); - - SQLExecutor executor = new SQLExecutor(); - JSONObject result = null; - try { - result = executor.execute(config); - } catch (Exception e) { - throw e; - } finally { - executor.close(); - } - if (result != null && JSONResponse.isExist(result.getIntValue(JSONResponse.KEY_COUNT)) == false) { - throw new IllegalArgumentException(rk + ":" + rv + "中value不合法!必须匹配 " + logic.getChar() + tv + " !"); - } - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConditionErrorException.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConditionErrorException.java deleted file mode 100644 index 3e7d81b19..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConditionErrorException.java +++ /dev/null @@ -1,33 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.exception; - -/**条件错误 - * @author Lemon - */ -public class ConditionErrorException extends Exception { - private static final long serialVersionUID = 1L; - - public ConditionErrorException(String msg) { - super(msg); - } - public ConditionErrorException(Throwable t) { - super(t); - } - public ConditionErrorException(String msg, Throwable t) { - super(msg, t); - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConflictException.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConflictException.java deleted file mode 100644 index b32e2a7ba..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConflictException.java +++ /dev/null @@ -1,33 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.exception; - -/**冲突 - * @author Lemon - */ -public class ConflictException extends Exception { - private static final long serialVersionUID = 1L; - - public ConflictException(String msg) { - super(msg); - } - public ConflictException(Throwable t) { - super(t); - } - public ConflictException(String msg, Throwable t) { - super(msg, t); - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotExistException.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotExistException.java deleted file mode 100644 index ef1e2f3d1..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotExistException.java +++ /dev/null @@ -1,34 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.exception; - -/**不存在,可接受,内部吃掉 - * @author Lemon - */ -public class NotExistException extends Exception { - private static final long serialVersionUID = 1L; - - public NotExistException(String msg) { - super(msg); - } - public NotExistException(Throwable t) { - super(t); - } - public NotExistException(String msg, Throwable t) { - super(msg, t); - } - -} - diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotLoggedInException.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotLoggedInException.java deleted file mode 100644 index 79bc9a8b6..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotLoggedInException.java +++ /dev/null @@ -1,33 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.exception; - -/**未登录 - * @author Lemon - */ -public class NotLoggedInException extends Exception { - private static final long serialVersionUID = 1L; - - public NotLoggedInException(String msg, Throwable t) { - super(msg, t); - } - public NotLoggedInException(String msg) { - super(msg); - } - public NotLoggedInException(Throwable t) { - super(t); - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/OutOfRangeException.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/OutOfRangeException.java deleted file mode 100644 index 09d9c5cb8..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/OutOfRangeException.java +++ /dev/null @@ -1,33 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.exception; - -/**超出范围 - * @author Lemon - */ -public class OutOfRangeException extends Exception { - private static final long serialVersionUID = 1L; - - public OutOfRangeException(String msg) { - super(msg); - } - public OutOfRangeException(Throwable t) { - super(t); - } - public OutOfRangeException(String msg, Throwable t) { - super(msg, t); - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/package-info.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/package-info.java deleted file mode 100755 index 06ff39e98..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/exception/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -/** - * exception files package - */ -/** - * @author Lemon - * - */ -package zuo.biao.apijson.server.exception; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/package-info.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/package-info.java deleted file mode 100755 index aadcdd817..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -/** - * server files package - */ -/** - * @author Lemon - * - */ -package zuo.biao.apijson.server; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLConfig.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLConfig.java deleted file mode 100755 index 730d2a3c6..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLConfig.java +++ /dev/null @@ -1,1324 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.sql; - -import static zuo.biao.apijson.JSONObject.KEY_ABOUT; -import static zuo.biao.apijson.JSONObject.KEY_COLUMN; -import static zuo.biao.apijson.JSONObject.KEY_CONDITION; -import static zuo.biao.apijson.JSONObject.KEY_GROUP; -import static zuo.biao.apijson.JSONObject.KEY_HAVING; -import static zuo.biao.apijson.JSONObject.KEY_ID; -import static zuo.biao.apijson.JSONObject.KEY_ID_IN; -import static zuo.biao.apijson.JSONObject.KEY_ORDER; -import static zuo.biao.apijson.JSONObject.KEY_ROLE; -import static zuo.biao.apijson.JSONObject.KEY_SCHEMA; -import static zuo.biao.apijson.JSONRequest.KEY_COUNT; -import static zuo.biao.apijson.JSONRequest.KEY_PAGE; -import static zuo.biao.apijson.JSONRequest.KEY_QUERY; -import static zuo.biao.apijson.RequestMethod.DELETE; -import static zuo.biao.apijson.RequestMethod.GET; -import static zuo.biao.apijson.RequestMethod.POST; -import static zuo.biao.apijson.RequestMethod.PUT; -import static zuo.biao.apijson.SQL.AND; -import static zuo.biao.apijson.SQL.NOT; -import static zuo.biao.apijson.SQL.OR; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.validation.constraints.NotNull; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.annotation.JSONField; - -import apijson.demo.server.model.BaseModel; -import apijson.demo.server.model.Privacy; -import apijson.demo.server.model.User; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.RequestMethod; -import zuo.biao.apijson.RequestRole; -import zuo.biao.apijson.SQL; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.model.Column; -import zuo.biao.apijson.model.Table; -import zuo.biao.apijson.server.Logic; -import zuo.biao.apijson.server.Pair; -import zuo.biao.apijson.server.exception.NotExistException; - -/**config sql for JSON Request - * @author Lemon - */ -public class SQLConfig { - private static final String TAG = "SQLConfig"; - - - - public static final String SCHEMA_INFORMATION = "`information_schema`"; - public static final String TABLE_SCHEMA = "`table_schema`"; - public static final String TABLE_NAME = "`table_name`"; - - - - - public static final List ARRAY_KEY_LIST; - static { - ARRAY_KEY_LIST = new ArrayList(); - ARRAY_KEY_LIST.add(KEY_QUERY); - ARRAY_KEY_LIST.add(KEY_COUNT); - ARRAY_KEY_LIST.add(KEY_PAGE); - } - public static final List TABLE_KEY_LIST; - static { - TABLE_KEY_LIST = new ArrayList(); - TABLE_KEY_LIST.add(KEY_ROLE); - TABLE_KEY_LIST.add(KEY_CONDITION); - TABLE_KEY_LIST.add(KEY_SCHEMA); - TABLE_KEY_LIST.add(KEY_ABOUT); - TABLE_KEY_LIST.add(KEY_COLUMN); - TABLE_KEY_LIST.add(KEY_GROUP); - TABLE_KEY_LIST.add(KEY_HAVING); - TABLE_KEY_LIST.add(KEY_ORDER); - } - - - - //表名映射,隐藏真实表名,对安全要求很高的表可以这么做 - public static final Map TABLE_KEY_MAP; - static { - TABLE_KEY_MAP = new HashMap(); - TABLE_KEY_MAP.put(Table.class.getSimpleName(), Table.TAG); - TABLE_KEY_MAP.put(Column.class.getSimpleName(), Column.TAG); - - TABLE_KEY_MAP.put(User.class.getSimpleName(), "apijson_user"); - TABLE_KEY_MAP.put(Privacy.class.getSimpleName(), "apijson_privacy"); - } - - - - private long id; //Table的id - private RequestMethod method; //操作方法 - /** - * TODO 被关联的表通过就忽略关联的表?(这个不行 User:{"sex@":"/Comment/toId"}) - */ - private RequestRole role; //发送请求的用户的角色 - private String schema; //Table所在的数据库 - private String table; //Table名 - private boolean about; //关于,返回数据库表的信息,包括表说明和字段说明 - private String group; //分组方式的字符串数组,','分隔 - private String having; //聚合函数的字符串数组,','分隔 - private String order; //排序方式的字符串数组,','分隔 - private String column; //Table内字段名(或函数名,仅查询操作可用)的字符串数组,','分隔 - private String values; //对应Table内字段的值的字符串数组,','分隔 - private Map content; //Request内容,key:value形式,column = content.keySet(),values = content.values() - private Map where; //筛选条件,key:value形式 - - - //array item <<<<<<<<<< - private int count; //Table数量 - private int page; //Table所在页码 - private int position; //Table在[]中的位置 - private int query; //JSONRequest.query - private int type; //ObjectParser.type - //array item >>>>>>>>>> - private boolean test; //测试 - private boolean cacheStatic; //静态缓存 - - public SQLConfig(RequestMethod method) { - setMethod(method); - } - public SQLConfig(RequestMethod method, String table) { - this(method); - setTable(table); - } - public SQLConfig(RequestMethod method, int count, int page) { - this(method); - setCount(count); - setPage(page); - } - - @NotNull - public RequestMethod getMethod() { - if (method == null) { - method = GET; - } - return method; - } - public SQLConfig setMethod(RequestMethod method) { - this.method = method; - return this; - } - - - - public long getId() { - return id; - } - public SQLConfig setId(long id) { - this.id = id; - return this; - } - - public RequestRole getRole() { - //不能 @NotNull , Parser#getSQLObject 内当getRole() == null时填充默认值 - return role; - } - public SQLConfig setRole(String roleName) { - return setRole(RequestRole.get(roleName)); - } - public SQLConfig setRole(RequestRole role) { - this.role = role; - return this; - } - - public String getSchema() { - String sqlTable = getSQLTable(); - if (sqlTable != null && sqlTable.startsWith("`")) { - return SCHEMA_INFORMATION; - } - return getSchema(schema); - } - public static String getSchema(String schema) { - if (StringUtil.isEmpty(schema, true)) { - schema = "sys"; //非默认Schema必须要有 - } - return schema; - } - public SQLConfig setSchema(String schema) { - this.schema = schema; - return this; - } - /**请求传进来的Table名 - * @return - * @see {@link #getSQLTable()} - */ - public String getTable() { - return table; - } - /**数据库里的真实Table名 - * 通过 {@link #TABLE_KEY_MAP} 映射 - * @return - */ - @JSONField(serialize = false) - public String getSQLTable() { - return TABLE_KEY_MAP.containsKey(table) ? TABLE_KEY_MAP.get(table) : table; - } - @JSONField(serialize = false) - public String getTablePath() { - return getSchema() + "." + getSQLTable(); - } - public SQLConfig setTable(String table) { - this.table = table; - return this; - } - - public boolean isAbout() { - return about; - } - public SQLConfig setAbout(boolean about) { - this.about = about; - return this; - } - - public String getGroup() { - return group; - } - public SQLConfig setGroup(String... keys) { - return setGroup(StringUtil.getString(keys)); - } - public SQLConfig setGroup(String group) { - this.group = group; - return this; - } - @JSONField(serialize = false) - public String getGroupString() { - group = StringUtil.getTrimedString(group); - return group.isEmpty() ? "" : " GROUP BY " + group; - } - - public String getHaving() { - return having; - } - public SQLConfig setHaving(String... conditions) { - return setHaving(StringUtil.getString(conditions)); - } - public SQLConfig setHaving(String having) { - this.having = having; - return this; - } - @JSONField(serialize = false) - public String getHavingString() { - having = StringUtil.getTrimedString(having); - return having.isEmpty() ? "" : " HAVING " + having; - } - - public String getOrder() { - return order; - } - public SQLConfig setOrder(String... conditions) { - return setOrder(StringUtil.getString(conditions)); - } - public SQLConfig setOrder(String order) { - this.order = order; - return this; - } - @JSONField(serialize = false) - public String getOrderString() { - order = StringUtil.getTrimedString(order); - if (order.isEmpty()) { - return ""; - } - if (order.contains("+")) {//replace没有包含的replacement会崩溃 - order = order.replaceAll("\\+", " ASC "); - } - if (order.contains("-")) { - order = order.replaceAll("-", " DESC "); - } - return " ORDER BY " + order; - } - - - - public String getColumn() { - return column; - } - public SQLConfig setColumn(String... keys) { - return setColumn(StringUtil.getString(keys)); - } - public SQLConfig setColumn(String column) { - this.column = column; - return this; - } - @JSONField(serialize = false) - public String getColumnString() throws NotExistException { - switch (getMethod()) { - case HEAD: - case HEADS: - return SQL.count(column); - case POST: - if (StringUtil.isEmpty(column, true)) { - throw new NotExistException(TAG + "getColumnString getMethod() = POST" - + " >> StringUtil.isEmpty(column, true)"); - } - return "(" + column + ")"; - default: - column = StringUtil.getString(column); - if (column.isEmpty()) { - return "*"; - } - return column.contains(":") == false ? column : column.replaceAll(":", " AS ");//不能在这里改,后续还要用到: - } - } - - - public String getValues() { - return values; - } - @JSONField(serialize = false) - public String getValuesString() { - return values; - } - public SQLConfig setValues(String[][] valuess) { - String s = ""; - if (BaseModel.isEmpty(valuess) == false) { - String[] items = new String[valuess.length]; - for (int i = 0; i < valuess.length; i++) { - items[i] = "(" + StringUtil.getString(valuess[i]) + ")"; - } - s = StringUtil.getString(items); - } - return setValues(s); - } - public SQLConfig setValues(String values) { - this.values = values; - return this; - } - - public Map getContent() { - return content; - } - public SQLConfig setContent(Map content) { - this.content = content; - return this; - } - - public int getCount() { - return count; - } - public SQLConfig setCount(int count) { - this.count = count; - return this; - } - public int getPage() { - return page; - } - public SQLConfig setPage(int page) { - this.page = page; - return this; - } - public int getPosition() { - return position; - } - public SQLConfig setPosition(int position) { - this.position = position; - return this; - } - - public int getQuery() { - return query; - } - public SQLConfig setQuery(int query) { - this.query = query; - return this; - } - public int getType() { - return type; - } - public SQLConfig setType(int type) { - this.type = type; - return this; - } - - public boolean isTest() { - return test; - } - public SQLConfig setTest(boolean test) { - this.test = test; - return this; - } - public boolean isCacheStatic() { - return cacheStatic; - } - public SQLConfig setCacheStatic(boolean cacheStatic) { - this.cacheStatic = cacheStatic; - return this; - } - - - /**获取初始位置offset - * @return - */ - @JSONField(serialize = false) - public int getOffset() { - return getOffset(getPage(), getCount()); - } - /**获取初始位置offset - * @param page - * @param count - * @return - */ - public static int getOffset(int page, int count) { - return page*count; - } - /**获取限制数量 - * @return - */ - @JSONField(serialize = false) - public String getLimitString() { - return getLimitString(getPage(), getCount());// + 1); - } - /**获取限制数量 - * @param limit - * @return - */ - public static String getLimitString(int page, int count) { - return count <= 0 ? "" : " LIMIT " + getOffset(page, count) + ", " + count; - } - - //WHERE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - public Map getWhere() { - return where; - } - public SQLConfig setWhere(Map where) { - this.where = where; - return this; - } - /** - * noFunctionChar = false - * @param key - * @return - */ - @JSONField(serialize = false) - public Object getWhere(String key) { - return getWhere(key, false); - } - /** - * @param key - * @param exactMatch - * @return - */ - @JSONField(serialize = false) - public Object getWhere(String key, boolean exactMatch) { - if (exactMatch) { - return where == null ? null : where.get(key); - } - - Set set = key == null || where == null ? null : where.keySet(); - if (set != null) { - synchronized (where) { - if (where != null) { - int index; - for (String k : set) { - index = k.indexOf(key); - if (index >= 0 && StringUtil.isName(k.substring(index)) == false) { - return where.get(k); - } - } - } - } - } - return null; - } - public SQLConfig addWhere(String key, Object value) { - if (key != null) { - if (where == null) { - where = new LinkedHashMap(); - } - where.put(key, value); - } - return this; - } - - /**获取WHERE - * @return - * @throws Exception - */ - @JSONField(serialize = false) - public String getWhereString() throws Exception { - return getWhereString(getMethod(), getWhere(), ! isTest()); - } - /**获取WHERE - * @param method - * @param where - * @return - * @throws Exception - */ - public static String getWhereString(RequestMethod method, Map where, boolean verifyName) throws Exception { - Set set = where == null ? null : where.keySet(); - if (BaseModel.isEmpty(set)) { - return ""; - } - String whereString = ""; - boolean isFirst = true; - - String condition; - for (String key : set) { - condition = getWhereItem(key, where.get(key), method, verifyName); - - if (StringUtil.isEmpty(condition, true)) {//避免SQL条件连接错误 - continue; - } - - whereString += (isFirst ? "" : AND) + "(" + condition + ")"; - - isFirst = false; - } - - String s = whereString.isEmpty() ? "" : " WHERE " + whereString; - - if (s.isEmpty() && RequestMethod.isQueryMethod(method) == false) { - throw new UnsupportedOperationException("写操作请求必须带条件!!!"); - } - - return s; - } - - /** - * @param key - * @param value - * @param method - * @param verifyName - * @return - * @throws Exception - */ - private static String getWhereItem(String key, Object value - , RequestMethod method, boolean verifyName) throws Exception { - Log.d(TAG, "getWhereItem key = " + key); - //避免筛选到全部 value = key == null ? null : where.get(key); - if (key == null || value == null || key.startsWith("@") || key.endsWith("()")) {//关键字||方法, +或-直接报错 - Log.d(TAG, "getWhereItem key == null || value == null" - + " || key.startsWith(@) || key.endsWith(()) >> continue;"); - return null; - } - if (key.endsWith("@")) {//引用 - // key = key.substring(0, key.lastIndexOf("@")); - throw new IllegalArgumentException(TAG + ".getWhereItem: 字符 " + key + " 不合法!"); - } - - int keyType; - if (key.endsWith("$")) { - keyType = 1; - } - else if (key.endsWith("?")) { - keyType = 2; - } - else if (key.endsWith("{}")) { - keyType = 3; - } - else if (key.endsWith("<>")) { - keyType = 4; - } - else { //else绝对不能省,避免再次踩坑! keyType = 0; 写在for循环外面都没注意! - keyType = 0; - } - key = getRealKey(method, key, false, true, verifyName); - - switch (keyType) { - case 1: - return getSearchString(key, value); - case 2: - return getRegExpString(key, value); - case 3: - return getRangeString(key, value); - case 4: - return getContainString(key, value); - default: - return (key + "='" + value + "'"); - } - } - - - //$ search <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**search key match value - * @param in - * @return {@link #getSearchString(String, Object[], int)} - * @throws IllegalArgumentException - */ - public static String getSearchString(String key, Object value) throws IllegalArgumentException { - if (value == null) { - return ""; - } - - Logic logic = new Logic(key); - key = logic.getKey(); - Log.i(TAG, "getRangeString key = " + key); - - JSONArray arr = newJSONArray(value); - if (arr.isEmpty()) { - return ""; - } - return getSearchString(key, arr.toArray(), logic.getType()); - } - /**search key match values - * @param in - * @return LOGIC [ key LIKE 'values[i]' ] - * @throws IllegalArgumentException - */ - public static String getSearchString(String key, Object[] values, int type) throws IllegalArgumentException { - if (values == null || values.length <= 0) { - return ""; - } - - String condition = ""; - for (int i = 0; i < values.length; i++) { - if (values[i] instanceof String == false) { - throw new IllegalArgumentException(key + "$\":value 中value只能为String或JSONArray!"); - } - condition += (i <= 0 ? "" : (Logic.isAnd(type) ? AND : OR)) + getLikeString(key, values[i]); - } - - return getCondition(Logic.isNot(type), condition); - } - - /**WHERE key LIKE 'value' - * @param key endsWith("!") ? key = key.substring(0, key.length() - 1) + NOT; - * @param value - * @return key LIKE 'value' - */ - public static String getLikeString(String key, Object value) { - return key + " LIKE '" + value + "'"; - } - //$ search >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //$ search <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**search key match RegExps value - * @param in - * @return {@link #getRegExpString(String, Object[], int)} - * @throws IllegalArgumentException - */ - public static String getRegExpString(String key, Object value) throws IllegalArgumentException { - if (value == null) { - return ""; - } - - Logic logic = new Logic(key); - key = logic.getKey(); - Log.i(TAG, "getRangeString key = " + key); - - JSONArray arr = newJSONArray(value); - if (arr.isEmpty()) { - return ""; - } - return getRegExpString(key, arr.toArray(), logic.getType()); - } - /**search key match RegExp values - * @param in - * @return LOGIC [ key REGEXP 'values[i]' ] - * @throws IllegalArgumentException - */ - public static String getRegExpString(String key, Object[] values, int type) throws IllegalArgumentException { - if (values == null || values.length <= 0) { - return ""; - } - - String condition = ""; - for (int i = 0; i < values.length; i++) { - if (values[i] instanceof String == false) { - throw new IllegalArgumentException(key + "$\":value 中value只能为String或JSONArray!"); - } - condition += (i <= 0 ? "" : (Logic.isAnd(type) ? AND : OR)) + getRegExpString(key, (String) values[i]); - } - - return getCondition(Logic.isNot(type), condition); - } - - /**WHERE key REGEXP 'value' - * @param key - * @param value - * @return key REGEXP 'value' - */ - public static String getRegExpString(String key, String value) { - return key + " REGEXP '" + value + "'"; - } - //$ search >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //{} range <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**WHERE key > 'key0' AND key <= 'key1' AND ... - * @param key - * @param range "condition0,condition1..." - * @return key condition0 AND key condition1 AND ... - * @throws Exception - */ - public static String getRangeString(String key, Object range) throws Exception { - Log.i(TAG, "getRangeString key = " + key); - if (range == null) {//依赖的对象都没有给出有效值,这个存在无意义。如果是客户端传的,那就能在客户端确定了。 - throw new NotExistException(TAG + "getRangeString(" + key + ", " + range - + ") range == null"); - } - - Logic logic = new Logic(key); - key = logic.getKey(); - Log.i(TAG, "getRangeString key = " + key); - - if (range instanceof List) { - if (logic.isOr() || logic.isNot()) { - return key + getInString(key, ((List) range).toArray(), logic.isNot()); - } - throw new IllegalArgumentException(key + "{}\":[] 中key末尾的逻辑运算符只能用'|','!'中的一种 !"); - } - if (range instanceof String) {//非Number类型需要客户端拼接成 < 'value0', >= 'value1'这种 - String[] conditions = StringUtil.split((String) range); - String condition = ""; - if (conditions != null) { - int index; - for (int i = 0; i < conditions.length; i++) {//对函数条件length(key)<=5这种不再在开头加key - index = conditions[i] == null ? -1 : conditions[i].indexOf("("); - condition += ((i <= 0 ? "" : (logic.isAnd() ? AND : OR))//连接方式 - + (index >= 0 && index < conditions[i].indexOf(")") ? "" : key + " ")//函数和非函数条件 - + conditions[i]);//单个条件 - } - } - if (condition.isEmpty()) { - return ""; - } - return getCondition(logic.isNot(), condition); - } - - throw new IllegalArgumentException(key + "{}:range 类型为" + range.getClass().getSimpleName() - + "!range只能是 用','分隔条件的字符串 或者 可取选项JSONArray!"); - } - /**WHERE key IN ('key0', 'key1', ... ) - * @param in - * @return IN ('key0', 'key1', ... ) - * @throws NotExistException - */ - public static String getInString(String key, Object[] in, boolean not) throws NotExistException { - String condition = ""; - if (in != null) {//返回 "" 会导致 id:[] 空值时效果和没有筛选id一样! - for (int i = 0; i < in.length; i++) { - condition += ((i > 0 ? "," : "") + "'" + in[i] + "'"); - } - } - if (condition.isEmpty()) {//条件如果存在必须执行,不能忽略。条件为空会导致出错,又很难保证条件不为空(@:条件),所以还是这样好 - throw new NotExistException(TAG + ".getInString(" + key + ", [], " + not - + ") >> condition.isEmpty() >> IN()"); - } - return (not ? NOT : "") + " IN (" + condition + ")"; - } - //{} range >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //<> contain <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**WHERE key contains value - * @param key - * @param value - * @return {@link #getContainString(String, Object[], int)} - * @throws NotExistException - */ - public static String getContainString(String key, Object value) throws NotExistException { - if (value == null) { - return ""; - } - - Logic logic = new Logic(key); - key = logic.getKey(); - Log.i(TAG, "getRangeString key = " + key); - - //TODO 直接调Like性能最好! - return getContainString(key, newJSONArray(value).toArray(), logic.getType()); - } - /**WHERE key contains childs - * @param key - * @param childs null ? "" : (empty ? no child : contains childs) - * @param type |, &, ! - * @return LOGIC [ ( key LIKE '[" + childs[i] + "]' OR key LIKE '[" + childs[i] + ", %' - * OR key LIKE '%, " + childs[i] + ", %' OR key LIKE '%, " + childs[i] + "]' ) ] - * @throws IllegalArgumentException - */ - public static String getContainString(String key, Object[] childs, int type) throws IllegalArgumentException { - String condition = ""; - if (childs != null) { - for (int i = 0; i < childs.length; i++) { - if (childs[i] != null) { - if (childs[i] instanceof JSON) { - throw new IllegalArgumentException(key + "<>\":value 中value类型不能为JSON!"); - } - if (childs[i] instanceof String) { - childs[i] = "\"" + childs[i] + "\""; - } - condition += (i <= 0 ? "" : (Logic.isAnd(type) ? AND : OR)) - + "(" + getSearchString( - key - , new String[]{ - "[" + childs[i] + "]", //全等 - "[" + childs[i] + ", %", //开始 - "%, " + childs[i] + ", %", //中间 - "%, " + childs[i] + "]" //末尾 - } - , Logic.TYPE_OR - ) + ")"; - } - } - if (condition.isEmpty()) { - condition = (SQL.isEmpty(key, true) + OR + getLikeString(key, "[]")); - } - } - if (condition.isEmpty()) { - return ""; - } - return getCondition(Logic.isNot(type), condition); - } - //<> contain >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - /**拼接条件 - * @param not - * @param condition - * @return - */ - private static String getCondition(boolean not, String condition) { - return not ? NOT + "(" + condition + ")" : condition; - } - - - /**转为JSONArray - * @param tv - * @return - */ - @NotNull - public static JSONArray newJSONArray(Object obj) { - JSONArray array = new JSONArray(); - if (obj != null) { - if (obj instanceof Collection) { - array.addAll((Collection) obj); - } else { - array.add(obj); - } - } - return array; - } - - //WHERE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //SET <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取SET - * @return - * @throws Exception - */ - @JSONField(serialize = false) - public String getSetString() throws Exception { - return getSetString(getMethod(), getContent(), ! isTest()); - } - /**获取SET - * @param method - * @param content - * @return - * @throws Exception - */ - public static String getSetString(RequestMethod method, Map content, boolean verifyName) throws Exception { - Set set = content == null ? null : content.keySet(); - if (set != null && set.size() > 0) { - String setString = ""; - boolean isFirst = true; - int keyType = 0;// 0 - =; 1 - +, 2 - - - Object value; - for (String key : set) { - //避免筛选到全部 value = key == null ? null : content.get(key); - if (key == null || KEY_ID.equals(key)) { - continue; - } - - if (key.endsWith("+")) { - keyType = 1; - } else if (key.endsWith("-")) { - keyType = 2; - } - value = content.get(key); - key = getRealKey(method, key, false, true, verifyName); - - setString += (isFirst ? "" : ", ") + (key + "=" + (keyType == 1 ? getAddString(key, value) : (keyType == 2 - ? getRemoveString(key, value) : "'" + value + "'") ) ); - - isFirst = false; - } - if (setString.isEmpty()) { - throw new NotExistException(TAG + "getSetString >> setString.isEmpty()"); - } - return " SET " + setString; - } - return ""; - } - - /**SET key = CONCAT (key, 'value') - * @param key - * @param value - * @return CONCAT (key, 'value') - * @throws IllegalArgumentException - */ - public static String getAddString(String key, Object value) throws IllegalArgumentException { - if (value instanceof Number) { - return key + " + " + value; - } - if (value instanceof String) { - return " CONCAT (" + key + ", '" + value + "') "; - } - throw new IllegalArgumentException(key + "+ 对应的值 " + value + " 不是Number,String,Array中的任何一种!"); - } - /**SET key = replace(key, 'value', '') - * @param key - * @param value - * @return REPLACE (key, 'value', '') - * @throws IllegalArgumentException - */ - public static String getRemoveString(String key, Object value) throws IllegalArgumentException { - if (value instanceof Number) { - return key + " - " + value; - } - if (value instanceof String) { - return SQL.replace(key, (String) value, "");// " replace(" + key + ", '" + value + "', '') "; - } - throw new IllegalArgumentException(key + "- 对应的值 " + value + " 不是Number,String,Array中的任何一种!"); - } - //SET >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - /** - * @return - * @throws Exception - */ - @JSONField(serialize = false) - public String getSQL() throws Exception { - return getSQL(this); - } - /** - * @param config - * @return - * @throws Exception - */ - public static String getSQL(SQLConfig config) throws Exception { - String tablePath = config == null ? null : config.getTablePath(); - if (StringUtil.isNotEmpty(tablePath, true) == false) { - Log.i(TAG, "getSQL StringUtil.isNotEmpty(tablePath, true) == false >> return null;"); - return null; - } - - switch (config.getMethod()) { - case POST: - return "INSERT INTO " + tablePath + config.getColumnString() + " VALUES" + config.getValuesString(); - case PUT: - return "UPDATE " + tablePath + config.getSetString() + config.getWhereString(); - case DELETE: - return "DELETE FROM " + tablePath + config.getWhereString(); - default: - String column = config.getColumnString(); - return "SELECT " + column + " FROM " + getConditionString(column, tablePath, config); - } - } - - /**获取条件SQL字符串 - * @param page - * @param column - * @param table - * @param where - * @return - * @throws Exception - */ - private static String getConditionString(String column, String table, SQLConfig config) throws Exception { - String where = config.getWhereString(); - - String condition = table + where + ( - RequestMethod.isGetMethod(config.getMethod(), true) == false ? - "" : config.getGroupString() + config.getHavingString() + config.getOrderString() - ) - ; //+ config.getLimitString(); - - //no need to optimize - // if (config.getPage() <= 0 || ID.equals(column.trim())) { - return condition + config.getLimitString(); - // } - // - // - // //order: id+ -> id >= idOfStartIndex; id- -> id <= idOfStartIndex <<<<<<<<<<<<<<<<<<< - // String order = StringUtil.getNoBlankString(config.getOrder()); - // List orderList = order.isEmpty() ? null : Arrays.asList(StringUtil.split(order)); - // - // int type = 0; - // if (BaseModel.isEmpty(orderList) || BaseModel.isContain(orderList, ID+"+")) { - // type = 1; - // } - // else if (BaseModel.isContain(orderList, ID+"-")) { - // type = 2; - // } - // - // if (type > 0) { - // return condition.replace("WHERE", - // "WHERE id " + (type == 1 ? ">=" : "<=") + " (SELECT id FROM " + table - // + where + " ORDER BY id " + (type == 1 ? "ASC" : "DESC") + " LIMIT " + config.getOffset() + ", 1) AND" - // ) - // + " LIMIT " + config.getCount(); //子查询起始id不一定准确,只能作为最小可能! ;// - // } - // //order: id+ -> id >= idOfStartIndex; id- -> id <= idOfStartIndex >>>>>>>>>>>>>>>>>> - // - // - // //结果错误!SELECT * FROM Test AS t0 INNER JOIN - // (SELECT id FROM Test ORDER BY date ASC LIMIT 20, 10) AS t1 ON t0.id = t1.id - // //common case, inner join - // condition += config.getLimitString(); - // return table + " AS t0 INNER JOIN (SELECT id FROM " + condition + ") AS t1 ON t0.id = t1.id"; - } - - /**获取查询配置 - * @param table - * @param request - * @return - * @throws Exception - */ - public static SQLConfig newSQLConfig(RequestMethod method, String table, JSONObject request) throws Exception { - if (request == null) { // User:{} 这种空内容在查询时也有效 - throw new NullPointerException(TAG + ": newSQLConfig request == null!"); - } - SQLConfig config = new SQLConfig(method, table); - - boolean isEmpty = request.isEmpty(); - if (isEmpty) { // User:{} 这种空内容在查询时也有效 - return config; //request.remove(key); 前都可以直接return,之后必须保证 put 回去 - } - - Object idIn = request.get(KEY_ID_IN); //可能是 id{}:">0" - - if (method == POST) { - if (idIn != null) { //不能在这里确定[]的长度,只能在外面传进来 - if ((idIn instanceof List == false) || ((List)idIn).isEmpty()) { // id{}:[] 表示同时插入多条记录 - throw new IllegalArgumentException("POST请求,生成多条记录请用 id{}:[] ! [] 类型为JSONArray且不能为空!"); - } - } else if (request.get(KEY_ID) == null) { - request.put(KEY_ID, System.currentTimeMillis()); - } - } - - //对id和id{}处理,这两个一定会作为条件 - Long id = request.getLong(KEY_ID); - if (id != null) { //null无效 - if (id <= 0) { //一定没有值 - throw new NotExistException(TAG + ": newSQLConfig " + table + ".id <= 0"); - } - - if (idIn != null && idIn instanceof List) { //共用idArr场景少性能差 - if (idIn != null && ((List) idIn).contains(id) == false) {//empty有效 BaseModel.isEmpty(idArr) == false) { - Log.w(TAG, "newSQLConfig id > 0 >> idInObj != null && idInObj.contains(id) == false >> return null;"); - throw new NotExistException(TAG + ": newSQLConfig idIn != null && ((JSONArray) idIn).contains(id) == false"); - } - } - } - - - String role = request.getString(KEY_ROLE); - String schema = request.getString(KEY_SCHEMA); - boolean about = request.getBooleanValue(KEY_ABOUT); - String condition = request.getString(KEY_CONDITION); - String column = request.getString(KEY_COLUMN); - String group = request.getString(KEY_GROUP); - String having = request.getString(KEY_HAVING); - String order = request.getString(KEY_ORDER); - - //强制作为条件且放在最前面优化性能 - request.remove(KEY_ID); - request.remove(KEY_ID_IN); - //关键词 - request.remove(KEY_ROLE); - request.remove(KEY_SCHEMA); - request.remove(KEY_ABOUT); - request.remove(KEY_CONDITION); - request.remove(KEY_COLUMN); - request.remove(KEY_GROUP); - request.remove(KEY_HAVING); - request.remove(KEY_ORDER); - - - Map tableWhere = new LinkedHashMap();//保证顺序好优化 WHERE id > 1 AND name LIKE... - if (about) { //查询字段属性 - if (RequestMethod.isQueryMethod(method) == false) { - throw new UnsupportedOperationException(config.getTable() - + " 被 " + KEY_ABOUT + " 标注,只能进行 GET,HEAD 等查询操作!"); - } - - tableWhere.put(TABLE_SCHEMA, SQLConfig.getSchema(schema)); - tableWhere.put(TABLE_NAME, config.getSQLTable()); - config.setTable(Column.class.getSimpleName()); - - schema = SCHEMA_INFORMATION; - - column = StringUtil.getString(column); - if (column.isEmpty() && RequestMethod.isHeadMethod(method, true) == false) { - column = "column_name,column_type,column_default,column_comment"; - } - } - - - //已经remove了id和id{},以及@key - Set set = request.keySet(); //前面已经判断request是否为空 - if (method == POST) {//POST操作 - if (BaseModel.isEmpty(set) == false) { //不能直接return,要走完下面的流程 - List idList; - if (id != null) { //单条记录 - if (idIn != null) { - throw new IllegalArgumentException("POST请求中 id 和 id{} 不能同时存在!"); - } - - idList = new ArrayList(1); - idList.add(id); - } else { //多条记录 - idList = new ArrayList((JSONArray) idIn); - } - - //idIn不为空时,valuesString有多条,唯一的区别就是id - String[] columns = set.toArray(new String[]{}); - - Collection valueCollection = request.values(); - Object[] values = valueCollection == null ? null : valueCollection.toArray(); - - if (values == null || values.length != columns.length) { - throw new Exception("服务器内部错误:\n" + TAG - + " newSQLConfig values == null || values.length != columns.length !"); - } - column = KEY_ID + "," + StringUtil.getString(columns); //set已经判断过不为空 - final int size = columns.length + 1; //以key数量为准 - - String[][] valuess = new String[idList.size()][]; // [idList.size()][] - String[] items; //(item0, item1, ...) - for (int i = 0; i < idList.size(); i++) { - items = new String[size]; - items[0] = "'" + idList.get(i) + "'"; //第0个就是id。所有的值都加 '' 避免SQL注入风险 - for (int j = 1; j < size; j++) { - items[j] = "'" + values[j-1] + "'"; //从第1个开始,允许"null" - } - valuess[i] = items; - } - config.setValues(valuess); - } - } - else { //非POST操作 - final boolean isWhere = method != PUT;//除了POST,PUT,其它全是条件!!! - - //条件<<<<<<<<<<<<<<<<<<< - List conditionList = null; - if (isWhere == false) { //减少不必要的步骤 - if (method == PUT || method == DELETE) { - String[] conditions = StringUtil.split(condition); - //Arrays.asList()返回值不支持add方法! - conditionList = BaseModel.isEmpty(conditions) ? null : Arrays.asList(conditions); - } - } - //条件>>>>>>>>>>>>>>>>>>> - - //强制作为条件且放在最前面优化性能 - if (id != null) { - tableWhere.put(KEY_ID, id); - } - if (idIn != null) { - tableWhere.put(KEY_ID_IN, idIn); - } - - Map tableContent = new HashMap(); - Object value; - for (String key : set) { - value = request.get(key); - if (value instanceof JSONObject == false) {//只允许常规Object - //解决AccessVerifier新增userId没有作为条件,而是作为内容,导致PUT,DELETE出错 - if (isWhere || BaseModel.isContain(conditionList, key)) { - tableWhere.put(key, value); - } else { - tableContent.put(key, value);//一样 instanceof JSONArray ? JSON.toJSONString(value) : value); - } - } - } - - config.setContent(tableContent); - } - - - config.setWhere(tableWhere); - - config.setId(BaseModel.value(id)); - //在 tableWhere 第0个 config.setIdIn(idIn); - - config.setRole(role); - //TODO condition组合,优先 | config.setCondition(condition); - config.setSchema(schema); - config.setAbout(about); - config.setColumn(column); - config.setGroup(group); - config.setHaving(having); - config.setOrder(order); - - //后面还可能用到,要还原 - //id或id{}条件 - request.put(KEY_ID, id); - request.put(KEY_ID_IN, idIn); - //关键词 - request.put(KEY_ROLE, role); - request.put(KEY_SCHEMA, schema); - request.put(KEY_ABOUT, about); - request.put(KEY_CONDITION, condition); - request.put(KEY_COLUMN, column); - request.put(KEY_GROUP, group); - request.put(KEY_HAVING, having); - request.put(KEY_ORDER, order); - - - return config; - } - - - - /**获取客户端实际需要的key - * verifyName = true - * @param method - * @param originKey - * @param isTableKey - * @param saveLogic 保留逻辑运算符 & | ! - * @return - */ - public static String getRealKey(RequestMethod method, String originKey - , boolean isTableKey, boolean saveLogic) throws Exception { - return getRealKey(method, originKey, isTableKey, saveLogic, true); - } - /**获取客户端实际需要的key - * @param method - * @param originKey - * @param isTableKey - * @param saveLogic 保留逻辑运算符 & | ! - * @param verifyName 验证key名是否符合代码变量/常量名 - * @return - */ - public static String getRealKey(RequestMethod method, String originKey - , boolean isTableKey, boolean saveLogic, boolean verifyName) throws Exception { - Log.i(TAG, "getRealKey saveLogic = " + saveLogic + "; originKey = " + originKey); - if (originKey == null || originKey.startsWith("`") || zuo.biao.apijson.JSONObject.isArrayKey(originKey)) { - Log.w(TAG, "getRealKey originKey == null || originKey.startsWith(`)" - + " || zuo.biao.apijson.JSONObject.isArrayKey(originKey) >> return originKey;"); - return originKey; - } - - String key = new String(originKey); - if (key.endsWith("$")) {//搜索,查询时处理 - key = key.substring(0, key.length() - 1); - } - else if (key.endsWith("?")) {//匹配正则表达式,查询时处理 - key = key.substring(0, key.length() - 1); - } - else if (key.endsWith("{}")) {//被包含,或者说key对应值处于value的范围内。查询时处理 - key = key.substring(0, key.length() - 2); - } - else if (key.endsWith("<>")) {//包含,或者说value处于key对应值的范围内。查询时处理 - key = key.substring(0, key.length() - 2); - } - else if (key.endsWith("()")) {//方法,查询完后处理,先用一个Map保存? - key = key.substring(0, key.length() - 2); - } - else if (key.endsWith("@")) {//引用,引用对象查询完后处理。fillTarget中暂时不用处理,因为非GET请求都是由给定的id确定,不需要引用 - key = key.substring(0, key.length() - 1); - } - else if (key.endsWith("+")) {//延长,PUT查询时处理 - if (method == PUT) {//不为PUT就抛异常 - key = key.substring(0, key.length() - 1); - } - } - else if (key.endsWith("-")) {//缩减,PUT查询时处理 - if (method == PUT) {//不为PUT就抛异常 - key = key.substring(0, key.length() - 1); - } - } - - String last = null;//不用Logic优化代码,否则 key 可能变为 key| 导致 key=value 变成 key|=value 而出错 - if (RequestMethod.isQueryMethod(method)) {//逻辑运算符仅供GET,HEAD方法使用 - last = key.isEmpty() ? "" : key.substring(key.length() - 1); - if ("&".equals(last) || "|".equals(last) || "!".equals(last)) { - key = key.substring(0, key.length() - 1); - } else { - last = null;//避免key + StringUtil.getString(last)错误延长 - } - } - - //"User:toUser":User转换"toUser":User, User为查询同名Table得到的JSONObject。交给客户端处理更好 - if (isTableKey) {//不允许在column key中使用Type:key形式 - key = Pair.parseEntry(key, true).getKey();//table以左边为准 - } else { - key = Pair.parseEntry(key).getValue();//column以右边为准 - } - - if (verifyName && StringUtil.isName(key.startsWith("@") ? key.substring(1) : key) == false) { - throw new IllegalArgumentException(method + "请求,字符 " + originKey + " 不合法!"); - } - - if (saveLogic && last != null) { - key = key + last; - } - Log.i(TAG, "getRealKey return key = " + key); - return key; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLExecutor.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLExecutor.java deleted file mode 100755 index 67d265fd3..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLExecutor.java +++ /dev/null @@ -1,292 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.sql; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.util.HashMap; -import java.util.Map; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; - -import zuo.biao.apijson.JSONResponse; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.server.Parser; - -/**executor for query(read) or update(write) MySQL database - * @author Lemon - */ -public class SQLExecutor { - private static final String TAG = "SQLExecutor"; - - public static final String MYSQL_URI = "jdbc:mysql://localhost:3306";//TODO 改成你自己的 - public static final String MYSQL_ACCOUNT = "root";//TODO 改成你自己的 - public static final String MYSQL_PASSWORD = "apijson";//TODO 改成你自己的 - - //访问一次后丢失,可能因为static导致内存共享,别的地方改变了内部对象的值 - // private static final Map> staticCacheMap; - // static { - // staticCacheMap = new HashMap>(); - // } - - /** - * 缓存map - */ - private Map> cacheMap = new HashMap>(); - static { - try {//调用Class.forName()方法加载驱动程序 - Class.forName("com.mysql.jdbc.Driver"); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - - /**获取连接 - * @return - * @throws Exception - */ - private synchronized Connection getConnection() throws Exception { - Log.i(TAG, "成功加载MySQL驱动!"); - return DriverManager.getConnection(MYSQL_URI + "?useUnicode=true&characterEncoding=UTF-8&user=" - + MYSQL_ACCOUNT + "&password=" + MYSQL_PASSWORD); - } - - /**保存缓存 - * @param sql - * @param map - * @param isStatic - */ - private synchronized void saveCache(String sql, Map map, boolean isStatic) { - if (sql == null || map == null) { //空map有效,说明查询过sql了 || map.isEmpty()) { - Log.i(TAG, "saveList sql == null || map == null >> return;"); - return; - } - // if (isStatic) { - // staticCacheMap.put(sql, map); - // } else { - cacheMap.put(sql, map); - // } - } - /**移除缓存 - * @param sql - * @param isStatic - */ - public synchronized void removeCache(String sql, boolean isStatic) { - if (sql == null) { - Log.i(TAG, "removeList sql == null >> return;"); - return; - } - // if (isStatic) { - // staticCacheMap.remove(sql); - // } else { - cacheMap.remove(sql); - // } - } - - /**获取缓存 - * @param sql - * @param position - * @param isStatic - * @return - */ - public JSONObject getFromCache(String sql, int position, boolean isStatic) { - Map map = /** isStatic ? staticCacheMap.get(sql) : */ cacheMap.get(sql); - //只要map不为null,则如果 map.get(position) == null,则返回 {} ,避免再次SQL查询 - if (map == null) { - return null; - } - JSONObject result = map.get(position); - return result != null ? result : new JSONObject(); - } - - private Connection connection; - private Statement statement; - /**关闭连接,释放资源 - */ - public void close() { - cacheMap.clear(); - try { - if (statement != null && statement.isClosed() == false) { - statement.close(); - } - if (connection != null && connection.isClosed() == false) { - connection.close(); - } - } catch (SQLException e) { - e.printStackTrace(); - } - statement = null; - cacheMap = null; - } - - /**执行SQL - * @param config - * @return - * @throws Exception - */ - public JSONObject execute(SQLConfig config) throws Exception { - - final String sql = SQLConfig.getSQL(config); - if (StringUtil.isNotEmpty(sql, true) == false) { - Log.e(TAG, "select config==null||StringUtil.isNotEmpty(config.getSQLTable(), true)==false>>return null;"); - return null; - } - JSONObject result = null; - - long startTime = System.currentTimeMillis(); - Log.d(TAG, "\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" - + "\n select startTime = " + startTime - + "\n sql = " + sql - + "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); - - if (connection == null || connection.isClosed()) { - Log.i(TAG, "select connection " + (connection == null ? " = null" : ("isClosed = " + connection.isClosed()))) ; - connection = getConnection(); - statement = connection.createStatement(); //创建Statement对象 - } - Log.i(TAG, "成功连接到数据库!"); - ResultSet rs = null; - switch (config.getMethod()) { - case HEAD: - case HEADS: - rs = statement.executeQuery(sql); - - result = rs.next() ? Parser.newSuccessResult() - : Parser.newErrorResult(new SQLException("数据库错误, rs.next() 失败!")); - result.put(JSONResponse.KEY_COUNT, rs.getLong(1)); - - rs.close(); - return result; - - case POST: - case PUT: - case DELETE: - long updateCount = statement.executeUpdate(sql); - - result = Parser.newResult(updateCount > 0 ? JSONResponse.CODE_SUCCESS : JSONResponse.CODE_NOT_FOUND - , updateCount > 0 ? JSONResponse.MSG_SUCCEED : "可能对象不存在!"); - - //id或id{}一定有,一定会返回,不用抛异常来阻止关联写操作时前面错误导致后面无条件执行! - if (config.getId() > 0) { - result.put(JSONResponse.KEY_ID, config.getId()); - } else { - result.put(JSONResponse.KEY_ID_IN, config.getWhere(JSONResponse.KEY_ID_IN, true)); - } - result.put(JSONResponse.KEY_COUNT, updateCount);//返回修改的记录数 - return result; - - case GET: - case GETS: - break; - - default://OPTIONS, TRACE等 - Log.e(TAG, "select sql = " + sql + " ; method = " + config.getMethod() + " >> return null;"); - return null; - } - - - final int position = config.getPosition(); - result = getFromCache(sql, position, config.isCacheStatic()); - Log.i(TAG, ">>> select result = getFromCache('" + sql + "', " + position + ") = " + result); - if (result != null) { - Log.d(TAG, "\n\n select result != null >> return result;" + "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n"); - return result; - } - - rs = statement.executeQuery(sql); - - // final boolean cache = config.getCount() != 1; - Map resultMap = new HashMap(); - // Log.d(TAG, "select cache = " + cache + "; resultMap" + (resultMap == null ? "=" : "!=") + "null"); - - int index = -1; - - ResultSetMetaData rsmd = rs.getMetaData(); - final int length = rsmd.getColumnCount(); - - while (rs.next()){ - index ++; - Log.d(TAG, "\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n select while (rs.next()){ index = " + index + "\n\n"); - - result = new JSONObject(true); - Object value; - - for (int i = 1; i <= length; i++) { - if (rsmd.getColumnName(i).startsWith("_")) { - Log.i(TAG, "select while (rs.next()){ ..." - + " >> rsmd.getColumnName(i).startsWith(_) >> continue;"); - continue; - } - - value = rs.getObject(i); - // Log.d(TAG, "name:" + rsmd.getColumnName(i)); - // Log.d(TAG, "lable:" + rsmd.getColumnLabel(i)); - // Log.d(TAG, "type:" + rsmd.getColumnType(i)); - // Log.d(TAG, "typeName:" + rsmd.getColumnTypeName(i)); - - // Log.i(TAG, "select while (rs.next()) { >> for (int i = 0; i < length; i++) {" - // + "\n >>> value = " + value); - - if (value != null) { //数据库查出来的null和empty值都有意义,去掉会导致 Moment:{ @column:"content" } 部分无结果及中断数组查询! - if (value instanceof Timestamp) { - value = ((Timestamp) value).toString(); - } - else if (value instanceof String && isJSONType(rsmd, i)) { //json String - value = JSON.parse((String) value); - } - } - - result.put(rsmd.getColumnLabel(i), value); - } - - resultMap.put(index, result); - Log.d(TAG, "\n select while (rs.next()) { resultMap.put( " + index + ", result); " - + "\n >>>>>>>>>>>>>>>>>>>>>>>>>>> \n\n"); - } - - rs.close(); - - saveCache(sql, resultMap, config.isCacheStatic()); - Log.i(TAG, ">>> select saveCache('" + sql + "', resultMap); resultMap.size() = " + resultMap.size()); - - long endTime = System.currentTimeMillis(); - Log.d(TAG, "\n\n select endTime = " + endTime + "; duration = " + (endTime - startTime) - + "\n return resultMap.get(" + position + ");" + "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n"); - return resultMap.get(position); - } - - /**判断是否为JSON类型 - * @param rsmd - * @param position - * @return - */ - private boolean isJSONType(ResultSetMetaData rsmd, int position) { - try { - return rsmd.getColumnType(position) == 1 || rsmd.getColumnTypeName(position).toLowerCase().contains("json"); - } catch (SQLException e) { - e.printStackTrace(); - } - return false; - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/sql/package-info.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/sql/package-info.java deleted file mode 100755 index ce9dee57e..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/java/zuo/biao/apijson/server/sql/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -/** - * package of files for sql - */ -/** - * @author Lemon - * - */ -package zuo.biao.apijson.server.sql; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/resources/application.properties b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/main/resources/application.properties deleted file mode 100755 index e69de29bb..000000000 diff --git a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/test/java/zuo/biao/apijson/server/ApplicationTests.java b/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/test/java/zuo/biao/apijson/server/ApplicationTests.java deleted file mode 100755 index 6dcfe9e64..000000000 --- a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/src/test/java/zuo/biao/apijson/server/ApplicationTests.java +++ /dev/null @@ -1,17 +0,0 @@ -package zuo.biao.apijson.server; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class ApplicationTests { - - @Test - public void contextLoads() { - //TODO Test Case,包括GitHub README介绍和简版demo - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/.gitignore b/APIJSON-Java-Server/APIJSON-Idea1.9.0/.gitignore deleted file mode 100755 index 2af7cefb0..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -target/ -!.mvn/wrapper/maven-wrapper.jar - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -nbproject/private/ -build/ -nbbuild/ -dist/ -nbdist/ -.nb-gradle/ \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/.mvn/wrapper/maven-wrapper.jar b/APIJSON-Java-Server/APIJSON-Idea1.9.0/.mvn/wrapper/maven-wrapper.jar deleted file mode 100755 index 5fd4d5023f1463b5ba3970e33c460c1eb26d748d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 49502 zcm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ZL4*w`O!41NfJAE&N>zi#R(&V#)+FzyN% z_g90{z|?BLiTfv@hp{u@$1u7B_-1N#iJ#RBzM2BR!2c8QKQ->n9NpJB+kXlz_@(`y zApg-W%GVs=-$=u6Jp_Mfr34rf;5=qxnT`lG`0>Z&B#n)_ODW`1+jPPicN} zhgOBZJau)7R=(j9e&@_!Y{d>iX#+|6|i>`&Q={(}Kji+O zpFcjFOMd9Ss|3O?C362PVeDvZY6)PztKhZE=cg?HTJXn${I25H4xgVwR(eM*+@Z8Irh^0H1^@(vM%fLB8x9<0IcS*cf20Th OJOEd-=rxTO#Qy`$*1Hh^ diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/.mvn/wrapper/maven-wrapper.properties b/APIJSON-Java-Server/APIJSON-Idea1.9.0/.mvn/wrapper/maven-wrapper.properties deleted file mode 100755 index c954cec91..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1 +0,0 @@ -distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/.travis.yml b/APIJSON-Java-Server/APIJSON-Idea1.9.0/.travis.yml deleted file mode 100644 index d036b68c1..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: java -sudo: false -jdk: - - oraclejdk7 \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/mvnw b/APIJSON-Java-Server/APIJSON-Idea1.9.0/mvnw deleted file mode 100755 index a1ba1bf55..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/mvnw +++ /dev/null @@ -1,233 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ] ; then - - if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - # - # Look for the Apple JDKs first to preserve the existing behaviour, and then look - # for the new JDKs provided by Oracle. - # - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then - # - # Apple JDKs - # - export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then - # - # Oracle JDKs - # - export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home - fi - - if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then - # - # Apple JDKs - # - export JAVA_HOME=`/usr/libexec/java_home` - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Migwn, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="`which javac`" - if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=`which readlink` - if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then - if $darwin ; then - javaHome="`dirname \"$javaExecutable\"`" - javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" - else - javaExecutable="`readlink -f \"$javaExecutable\"`" - fi - javaHome="`dirname \"$javaExecutable\"`" - javaHome=`expr "$javaHome" : '\(.*\)/bin'` - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --windows "$CLASSPATH"` -fi - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - local basedir=$(pwd) - local wdir=$(pwd) - while [ "$wdir" != '/' ] ; do - if [ -d "$wdir"/.mvn ] ; then - basedir=$wdir - break - fi - wdir=$(cd "$wdir/.."; pwd) - done - echo "${basedir}" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - echo "$(tr -s '\n' ' ' < "$1")" - fi -} - -export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# Provide a "standardized" way to retrieve the CLI args that will -# work with both Windows and non-Windows executions. -MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" -export MAVEN_CMD_LINE_ARGS - -WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} "$@" diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/mvnw.cmd b/APIJSON-Java-Server/APIJSON-Idea1.9.0/mvnw.cmd deleted file mode 100755 index 2b934e89d..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/mvnw.cmd +++ /dev/null @@ -1,145 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" -if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. -goto error - -@REM ==== END VALIDATION ==== - -:init - -set MAVEN_CMD_LINE_ARGS=%* - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" -set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain - -%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% -if ERRORLEVEL 1 goto error -goto end - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/pom.xml b/APIJSON-Java-Server/APIJSON-Idea1.9.0/pom.xml deleted file mode 100755 index 3e26692f0..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - 4.0.0 - - zuo.biao.apijson.server - apijson - 0.0.1-SNAPSHOT - jar - - APIJSON(Idea) - APIJSON Server project using Spring Boot - - - org.springframework.boot - spring-boot-starter-parent - 1.4.1.RELEASE - - - - - UTF-8 - UTF-8 - 1.7 - - - - - mysql - mysql-connector-java - 5.1.40 - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-test - test - - - org.springframework.boot - spring-boot-starter-web - - - - com.alibaba - fastjson - 1.2.21 - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - - - - - spring-snapshots - http://repo.spring.io/snapshot - true - - - spring-milestones - http://repo.spring.io/milestone - true - - - - - spring-snapshots - http://repo.spring.io/snapshot - - - spring-milestones - http://repo.spring.io/milestone - - - - diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/APIJSONApplication.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/APIJSONApplication.java deleted file mode 100755 index 5a275143d..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/APIJSONApplication.java +++ /dev/null @@ -1,82 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.web.cors.CorsConfiguration; -import org.springframework.web.cors.UrlBasedCorsConfigurationSource; -import org.springframework.web.filter.CorsFilter; - -import zuo.biao.apijson.server.Structure; - -/**application - * @author Lemon - */ -@SpringBootApplication -public class APIJSONApplication { - - public static void main(String[] args) throws Exception { - SpringApplication.run(APIJSONApplication.class, args); - - System.out.println("\n\n\n\n\n<<<<<<<<<<<<<<<<<<<<<<<<< APIJSON >>>>>>>>>>>>>>>>>>>>>>>>\n"); - System.out.println("开始测试:远程函数 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); - try { - Function.test(); - } catch (Exception e) { - e.printStackTrace(); - } - System.out.println("\n完成测试:远程函数 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - - - System.out.println("\n\n\n开始测试:请求校验 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); - try { - Structure.test(); - } catch (Exception e) { - e.printStackTrace(); - } - System.out.println("\n完成测试:请求校验 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"); - - System.out.println("\n\n<<<<<<<<<<<<<<<<<<<<<<<<< APIJSON已启动 >>>>>>>>>>>>>>>>>>>>>>>>\n"); - } - - - - //支持JavaScript跨域请求<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /** - * 跨域过滤器 - * @return - */ - @Bean - public CorsFilter corsFilter() { - UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); - source.registerCorsConfiguration("/**", buildConfig()); - return new CorsFilter(source); - } - /**CORS跨域配置 - * @return - */ - private CorsConfiguration buildConfig() { - CorsConfiguration corsConfiguration = new CorsConfiguration(); - corsConfiguration.addAllowedOrigin("*"); //允许的域名或IP地址 - corsConfiguration.addAllowedHeader("*"); //允许的请求头 - corsConfiguration.addAllowedMethod("*"); //允许的HTTP请求方法 - corsConfiguration.setAllowCredentials(true); //允许发送跨域凭据,前端Axios存取JSESSIONID必须要 - return corsConfiguration; - } - //支持JavaScript跨域请求 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/Controller.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/Controller.java deleted file mode 100755 index 7bf484f58..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/Controller.java +++ /dev/null @@ -1,878 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server; - -import static zuo.biao.apijson.RequestMethod.DELETE; -import static zuo.biao.apijson.RequestMethod.GET; -import static zuo.biao.apijson.RequestMethod.GETS; -import static zuo.biao.apijson.RequestMethod.HEAD; -import static zuo.biao.apijson.RequestMethod.HEADS; -import static zuo.biao.apijson.RequestMethod.POST; -import static zuo.biao.apijson.RequestMethod.PUT; - -import java.net.URLDecoder; -import java.util.Random; -import java.util.concurrent.TimeoutException; - -import javax.servlet.http.HttpSession; - -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import com.alibaba.fastjson.JSONObject; - -import apijson.demo.server.model.BaseModel; -import apijson.demo.server.model.Comment; -import apijson.demo.server.model.Moment; -import apijson.demo.server.model.Privacy; -import apijson.demo.server.model.User; -import apijson.demo.server.model.Verify; -import zuo.biao.apijson.JSON; -import zuo.biao.apijson.JSONResponse; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.RequestMethod; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.server.JSONRequest; -import zuo.biao.apijson.server.Parser; -import zuo.biao.apijson.server.exception.ConditionErrorException; -import zuo.biao.apijson.server.exception.ConflictException; -import zuo.biao.apijson.server.exception.NotExistException; -import zuo.biao.apijson.server.exception.OutOfRangeException; - -/**request controller - *
建议全通过HTTP POST来请求: - *
1.减少代码 - 客户端无需写HTTP GET,PUT等各种方式的请求代码 - *
2.提高性能 - 无需URL encode和decode - *
3.调试方便 - 建议使用 APIJSON在线测试工具 或 Postman - * @author Lemon - */ -@RestController -@RequestMapping("") -public class Controller { - private static final String TAG = "Controller"; - - //通用接口,非事务型操作 和 简单事务型操作 都可通过这些接口自动化实现<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - - /**获取 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#GET} - */ - @PostMapping(value = "get") - public String get(@RequestBody String request, HttpSession session) { - return new Parser(GET).setSession(session).parse(request); - } - - /**计数 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#HEAD} - */ - @PostMapping("head") - public String head(@RequestBody String request, HttpSession session) { - return new Parser(HEAD).setSession(session).parse(request); - } - - /**限制性GET,request和response都非明文,浏览器看不到,用于对安全性要求高的GET请求 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#GETS} - */ - @PostMapping("gets") - public String gets(@RequestBody String request, HttpSession session) { - return new Parser(GETS).setSession(session).parse(request); - } - - /**限制性HEAD,request和response都非明文,浏览器看不到,用于对安全性要求高的HEAD请求 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#HEADS} - */ - @PostMapping("heads") - public String heads(@RequestBody String request, HttpSession session) { - return new Parser(HEADS).setSession(session).parse(request); - } - - /**新增 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#POST} - */ - @PostMapping("post") - public String post(@RequestBody String request, HttpSession session) { - return new Parser(POST).setSession(session).parse(request); - } - - /**修改 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#PUT} - */ - @PostMapping("put") - public String put(@RequestBody String request, HttpSession session) { - return new Parser(PUT).setSession(session).parse(request); - } - - /**删除 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#DELETE} - */ - @PostMapping("delete") - public String delete(@RequestBody String request, HttpSession session) { - return new Parser(DELETE).setSession(session).parse(request); - } - - - - - - /**获取 - * 只为兼容HTTP GET请求,推荐用HTTP POST,可删除 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#GET} - */ - @RequestMapping("get/{request}") - public String openGet(@PathVariable String request, HttpSession session) { - try { - request = URLDecoder.decode(request, StringUtil.UTF_8); - } catch (Exception e) { - // Parser会报错 - } - return get(request, session); - } - - /**计数 - * 只为兼容HTTP GET请求,推荐用HTTP POST,可删除 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see {@link RequestMethod#HEAD} - */ - @RequestMapping("head/{request}") - public String openHead(@PathVariable String request, HttpSession session) { - try { - request = URLDecoder.decode(request, StringUtil.UTF_8); - } catch (Exception e) { - // Parser会报错 - } - return head(request, session); - } - - - //通用接口,非事务型操作 和 简单事务型操作 都可通过这些接口自动化实现>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - - - - - - - - - - public static final String USER_; - public static final String PRIVACY_; - public static final String MOMENT_; - public static final String COMMENT_; - public static final String VERIFY_; //加下划线后缀是为了避免 Verify 和 verify 都叫VERIFY,分不清 - static { - USER_ = User.class.getSimpleName(); - PRIVACY_ = Privacy.class.getSimpleName(); - MOMENT_ = Moment.class.getSimpleName(); - COMMENT_ = Comment.class.getSimpleName(); - VERIFY_ = Verify.class.getSimpleName(); - } - - public static final String VERSION = JSONRequest.KEY_VERSION; - public static final String COUNT = JSONResponse.KEY_COUNT; - public static final String TOTAL = JSONResponse.KEY_TOTAL; - - public static final String RANGE = "range"; - - public static final String ID = "id"; - public static final String USER_ID = "userId"; - public static final String CURRENT_USER_ID = "currentUserId"; - - public static final String NAME = "name"; - public static final String PHONE = "phone"; - public static final String PASSWORD = "password"; - public static final String _PASSWORD = "_password"; - public static final String _PAY_PASSWORD = "_payPassword"; - public static final String OLD_PASSWORD = "oldPassword"; - public static final String VERIFY = "verify"; - - public static final String SEX = "sex"; - public static final String TYPE = "type"; - public static final String WAY = "way"; - public static final String CONTENT = "content"; - - - - - - public static final String DATE_UP = "date+";//同 "date ASC" - public static final String DATE_DOWN = "date-";//同 "date DESC" - - public static final String ID_AT = ID + "@"; - public static final String USER_ID_AT = USER_ID + "@"; - public static final String MOMENT_ID_AT = "momentId@"; - public static final String COMMENT_ID_AT = "commentId@"; - - public static final String ID_IN = ID + "{}"; - public static final String USER_ID_IN = USER_ID + "{}"; - public static final String MOMENT_ID_IN = "momentId{}"; - public static final String COMMENT_ID_IN = "commentId{}"; - - public static final String NAME_SEARCH = NAME + "$"; - public static final String PHONE_SEARCH = PHONE + "$"; - public static final String CONTENT_SEARCH = CONTENT + "$"; - - - - public static final String COLUMNS_USER_SIMPLE = "id,name"; - public static final String COLUMNS_USER = "id,sex,name,head"; - - - - - /**生成验证码,修改为post请求 - * @param request - * @return - */ - @PostMapping("post/verify") - public JSONObject postVerify(@RequestBody String request) { - JSONObject requestObject = null; - int type; - String phone; - try { - requestObject = Parser.parseRequest(request, POST); - type = requestObject.getIntValue(TYPE); - phone = requestObject.getString(PHONE); - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - - new Parser(DELETE, true).parse(newVerifyRequest(type, phone, null)); - - JSONObject response = new Parser(POST, true).parseResponse( - newVerifyRequest(type, phone, "" + (new Random().nextInt(9999) + 1000))); - - JSONObject verify = null; - try { - verify = response.getJSONObject(VERIFY_); - } catch (Exception e) { - // TODO: handle exception - } - if (verify == null || JSONResponse.isSuccess(verify.getIntValue(JSONResponse.KEY_CODE)) == false) { - new Parser(DELETE, true).parseResponse(new JSONRequest(new Verify(type, phone))); - return response; - } - - //TODO 这里直接返回验证码,方便测试。实际上应该只返回成功信息,验证码通过短信发送 - JSONObject object = new JSONObject(); - object.put(TYPE, type); - object.put(PHONE, phone); - return getVerify(JSON.toJSONString(object)); - } - - /**获取验证码 - * @param request - * @return - */ - @PostMapping("gets/verify") - public JSONObject getVerify(@RequestBody String request) { - JSONObject requestObject = null; - int type; - String phone; - try { - requestObject = Parser.parseRequest(request, GETS); - type = requestObject.getIntValue(TYPE); - phone = requestObject.getString(PHONE); - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - return new Parser(GETS, true).parseResponse(newVerifyRequest(type, phone, null)); - } - - /**校验验证码 - * @param request - * @return - */ - @PostMapping("heads/verify") - public JSONObject headVerify(@RequestBody String request) { - JSONObject requestObject = null; - int type; - String phone; - String verify; - try { - requestObject = Parser.parseRequest(request, HEADS); - type = requestObject.getIntValue(TYPE); - phone = requestObject.getString(PHONE); - verify = requestObject.getString(VERIFY); - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - return headVerify(type, phone, verify); - } - - /**校验验证码 - * @author Lemon - * @param type - * @param phone - * @param code - * @return - */ - public JSONObject headVerify(int type, String phone, String code) { - JSONResponse response = new JSONResponse( - new Parser(GETS, true).parseResponse( - new JSONRequest( - new Verify(type, phone) - .setVerify(code) - ).setTag(VERIFY_) - ) - ); - Verify verify = response.getObject(Verify.class); - if (verify == null) { - return Parser.newErrorResult(StringUtil.isEmpty(code, true) - ? new NotExistException("验证码不存在!") : new ConditionErrorException("手机号或验证码错误!")); - } - - //验证码过期 - if (System.currentTimeMillis() > (60*1000 + BaseModel.getTimeMillis(verify.getDate()))) { - new Parser(DELETE, true).parseResponse( - new JSONRequest(new Verify(type, phone)).setTag(VERIFY_) - ); - return Parser.newErrorResult(new TimeoutException("验证码已过期!")); - } - - return new JSONResponse( - new Parser(HEADS, true).parseResponse( - new JSONRequest(new Verify(type, phone).setVerify(code)) - ) - ); - } - - - - /**新建一个验证码请求 - * @param phone - * @param verify - * @return - */ - private JSONObject newVerifyRequest(int type, String phone, String verify) { - return new JSONRequest(new Verify(type, phone).setVerify(verify)).setTag(VERIFY_); - } - - - public static final String LOGIN = "login"; - - public static final int LOGIN_TYPE_PASSWORD = 0;//密码登录 - public static final int LOGIN_TYPE_VERIFY = 1;//验证码登录 - /**用户登录 - * @param request 只用String,避免encode后未decode - * @return - * @see - *
-		{
-			"type": 0,  //登录方式,非必须  0-密码 1-验证码
-			"phone": "13000082001",
-			"password": "1234567",
-			"version": 1 //全局版本号,非必须
-		}
-	 * 
- */ - @PostMapping("login") - public JSONObject login(@RequestBody String request, HttpSession session) { - JSONObject requestObject = null; - boolean isPassword; - String phone; - String password; - int version; - try { - requestObject = Parser.parseRequest(request, POST); - - isPassword = requestObject.getIntValue(TYPE) == LOGIN_TYPE_PASSWORD;//登录方式 - phone = requestObject.getString(PHONE);//手机 - password = requestObject.getString(PASSWORD);//密码 - - if (StringUtil.isPhone(phone) == false) { - throw new IllegalArgumentException("手机号不合法!"); - } - - if (isPassword) { - if (StringUtil.isPassword(password) == false) { - throw new IllegalArgumentException("密码不合法!"); - } - } else { - if (StringUtil.isVerify(password) == false) { - throw new IllegalArgumentException("验证码不合法!"); - } - } - - //全局版本号 - version = requestObject.getIntValue(VERSION); - requestObject.remove(VERSION); - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - - - - //手机号是否已注册 - JSONObject phoneResponse = new Parser(HEADS, true).parseResponse( - new JSONRequest( - new Privacy().setPhone(phone) - ) - ); - JSONResponse response = new JSONResponse(phoneResponse).getJSONResponse(PRIVACY_); - if (JSONResponse.isSuccess(response) == false) { - return response; - } - if(JSONResponse.isExist(response) == false) { - return Parser.newErrorResult(new NotExistException("手机号未注册")); - } - - //根据phone获取User - JSONObject privacyResponse = new Parser(GETS, true).parseResponse( - new JSONRequest( - new Privacy().setPhone(phone) - ) - ); - response = new JSONResponse(privacyResponse); - - Privacy privacy = response == null ? null : response.getObject(Privacy.class); - long userId = privacy == null ? 0 : BaseModel.value(privacy.getId()); - if (userId <= 0) { - return privacyResponse; - } - - //校验凭证 - if (isPassword) {//password密码登录 - response = new JSONResponse( - new Parser(HEADS, true).parseResponse( - new JSONRequest(new Privacy(userId).setPassword(password)) - ) - ); - } else {//verify手机验证码登录 - response = new JSONResponse(headVerify(Verify.TYPE_LOGIN, phone, password)); - } - if (JSONResponse.isSuccess(response) == false) { - return response; - } - response = response.getJSONResponse(isPassword ? PRIVACY_ : VERIFY_); - if (JSONResponse.isExist(response) == false) { - return Parser.newErrorResult(new ConditionErrorException("账号或密码错误")); - } - - response = new JSONResponse( - new Parser(GETS, true).parseResponse( - new JSONRequest(new User(userId)) - ) - ); - User user = response.getObject(User.class); - if (user == null || BaseModel.value(user.getId()) != userId) { - return Parser.newErrorResult(new NullPointerException("服务器内部错误")); - } - - //登录状态保存至session - session.setAttribute(USER_ID, userId);//用户id - session.setAttribute(TYPE, isPassword ? LOGIN_TYPE_PASSWORD : LOGIN_TYPE_VERIFY);//登录方式 - session.setAttribute(USER_, user);//用户 - session.setAttribute(PRIVACY_, privacy);//用户隐私信息 - session.setAttribute(VERSION, version);//用户隐私信息 - // session.setMaxInactiveInterval(1*60);//设置session过期时间 - - return response; - } - - /**退出登录,清空session - * @param session - * @return - */ - @PostMapping("logout") - public JSONObject logout(HttpSession session) { - long userId; - try { - userId = Verifier.getUserId(session);//必须在session.invalidate();前! - Log.d(TAG, "logout userId = " + userId + "; session.getId() = " + (session == null ? null : session.getId())); - session.invalidate(); - } catch (Exception e) { - return Parser.newErrorResult(e); - } - - JSONObject result = Parser.newSuccessResult(); - JSONObject user = Parser.newSuccessResult(); - user.put(ID, userId); - user.put(COUNT, 1); - result.put(USER_, user); - - return result; - } - - - private static final String REGISTER = "register"; - /**注册 - * @param request 只用String,避免encode后未decode - * @return - * @see - *
-		{
-			"Privacy": {
-				"phone": "13000082222",
-				"_password": "123456"
-			},
-			"User": {
-				"name": "APIJSONUser"
-			},
-			"verify": "1234"
-		}
-	 * 
- */ - @PostMapping(REGISTER) - public JSONObject register(@RequestBody String request) { - JSONObject requestObject = null; - - JSONObject privacyObj; - - String phone; - String verify; - String password; - try { - requestObject = Parser.parseRequest(request, POST); - privacyObj = requestObject.getJSONObject(PRIVACY_); - - phone = StringUtil.getString(privacyObj.getString(PHONE)); - verify = requestObject.getString(VERIFY); - password = privacyObj.getString(_PASSWORD); - - if (StringUtil.isPhone(phone) == false) { - return newIllegalArgumentResult(requestObject, PRIVACY_ + "/" + PHONE); - } - if (StringUtil.isPassword(password) == false) { - return newIllegalArgumentResult(requestObject, PRIVACY_ + "/" + _PASSWORD); - } - if (StringUtil.isVerify(verify) == false) { - return newIllegalArgumentResult(requestObject, VERIFY); - } - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - - - JSONResponse response = new JSONResponse(headVerify(Verify.TYPE_REGISTER, phone, verify)); - if (JSONResponse.isSuccess(response) == false) { - return response; - } - //手机号或验证码错误 - if (JSONResponse.isExist(response.getJSONResponse(VERIFY_)) == false) { - return Parser.extendErrorResult(response, new ConditionErrorException("手机号或验证码错误!")); - } - - - - //生成User和Privacy - if (StringUtil.isEmpty(requestObject.getString(JSONRequest.KEY_TAG), true)) { - requestObject.put(JSONRequest.KEY_TAG, REGISTER); - } - response = new JSONResponse( - new Parser(POST).setNoVerifyLogin(true).parseResponse(requestObject) - ); - - //验证User和Privacy - User user = response.getObject(User.class); - long userId = user == null ? 0 : BaseModel.value(user.getId()); - Privacy privacy = response.getObject(Privacy.class); - long userId2 = privacy == null ? 0 : BaseModel.value(privacy.getId()); - Exception e = null; - if (userId <= 0 || userId != userId2) { //id不同 - e = new Exception("服务器内部错误!写入User或Privacy失败!"); - } - - if (e != null) { //出现错误,回退 - new Parser(DELETE, true).parseResponse( - new JSONRequest(new User(userId)) - ); - new Parser(DELETE, true).parseResponse( - new JSONRequest(new Privacy(userId2)) - ); - } - - return response; - } - - - /** - * @param requestObject - * @param key - * @return - */ - public static JSONObject newIllegalArgumentResult(JSONObject requestObject, String key) { - return newIllegalArgumentResult(requestObject, key, null); - } - /** - * @param requestObject - * @param key - * @param msg 详细说明 - * @return - */ - public static JSONObject newIllegalArgumentResult(JSONObject requestObject, String key, String msg) { - return Parser.extendErrorResult(requestObject - , new IllegalArgumentException(key + ":value 中value不合法!" + StringUtil.getString(msg))); - } - - - /**设置密码 - * @param request 只用String,避免encode后未decode - * @return - * @see - *
-	    使用旧密码修改
-		{
-			"oldPassword": 123456,
-			"Privacy":{
-			  "id": 13000082001,
-			  "_password": "1234567"
-			}
-		}
-		或使用手机号+验证码修改
-		{
-			"verify": "1234",
-			"Privacy":{
-			  "phone": "13000082001",
-			  "_password": "1234567"
-			}
-		}
-	 * 
- */ - @PostMapping("put/password") - public JSONObject putPassword(@RequestBody String request){ - JSONObject requestObject = null; - String oldPassword; - String verify; - - int type = Verify.TYPE_PASSWORD; - - JSONObject privacyObj; - long userId; - String phone; - String password; - try { - requestObject = Parser.parseRequest(request, PUT); - oldPassword = StringUtil.getString(requestObject.getString(OLD_PASSWORD)); - verify = StringUtil.getString(requestObject.getString(VERIFY)); - - requestObject.remove(OLD_PASSWORD); - requestObject.remove(VERIFY); - - privacyObj = requestObject.getJSONObject(PRIVACY_); - if (privacyObj == null) { - throw new IllegalArgumentException(PRIVACY_ + " 不能为空!"); - } - userId = privacyObj.getLongValue(ID); - phone = privacyObj.getString(PHONE); - password = privacyObj.getString(_PASSWORD); - - if (StringUtil.isEmpty(password, true)) { //支付密码 - type = Verify.TYPE_PAY_PASSWORD; - password = privacyObj.getString(_PAY_PASSWORD); - if (StringUtil.isNumberPassword(password) == false) { - throw new IllegalArgumentException(PRIVACY_ + "/" + _PAY_PASSWORD + ":value 中value不合法!"); - } - } else { //登录密码 - if (StringUtil.isPassword(password) == false) { - throw new IllegalArgumentException(PRIVACY_ + "/" + _PASSWORD + ":value 中value不合法!"); - } - } - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - - - if (StringUtil.isPassword(oldPassword)) { - if (userId <= 0) { //手机号+验证码不需要userId - return Parser.extendErrorResult(requestObject, new IllegalArgumentException(ID + ":value 中value不合法!")); - } - if (oldPassword.equals(password)) { - return Parser.extendErrorResult(requestObject, new ConflictException("新旧密码不能一样!")); - } - - //验证旧密码 - Privacy privacy = new Privacy(userId); - if (type == Verify.TYPE_PASSWORD) { - privacy.setPassword(oldPassword); - } else { - privacy.setPayPassword(oldPassword); - } - JSONResponse response = new JSONResponse( - new Parser(HEAD, true).parseResponse( - new JSONRequest(privacy) - ) - ); - if (JSONResponse.isExist(response.getJSONResponse(PRIVACY_)) == false) { - return Parser.extendErrorResult(requestObject, new ConditionErrorException("账号或原密码错误,请重新输入!")); - } - } - else if (StringUtil.isPhone(phone) && StringUtil.isVerify(verify)) { - JSONResponse response = new JSONResponse(headVerify(type, phone, verify)); - if (JSONResponse.isSuccess(response) == false) { - return response; - } - if (JSONResponse.isExist(response.getJSONResponse(VERIFY_)) == false) { - return Parser.extendErrorResult(response, new ConditionErrorException("手机号或验证码错误!")); - } - response = new JSONResponse( - new Parser(GET, true).parseResponse( - new JSONRequest( - new Privacy().setPhone(phone) - ) - ) - ); - Privacy privacy = response.getObject(Privacy.class); - long id = privacy == null ? 0 : BaseModel.value(privacy.getId()); - privacyObj.remove(PHONE); - privacyObj.put(ID, id); - - requestObject.put(PRIVACY_, privacyObj); - } else { - return Parser.extendErrorResult(requestObject, new IllegalArgumentException("请输入合法的 旧密码 或 手机号+验证码 !")); - } - //TODO 上线版加上 password = MD5Util.MD5(password); - - - // requestObject.put(JSONRequest.KEY_TAG, "Password"); - //修改密码 - return new Parser(PUT, true).parseResponse(requestObject); - } - - - - /**充值/提现 - * @param request 只用String,避免encode后未decode - * @param session - * @return - * @see - *
-		{
-			"Privacy": {
-				"id": 82001,
-				"balance+": 100,
-				"_payPassword": "123456"
-			}
-		}
-	 * 
- */ - @PostMapping("put/balance") - public JSONObject putBalance(@RequestBody String request, HttpSession session) { - JSONObject requestObject = null; - JSONObject privacyObj; - long userId; - String payPassword; - double change; - try { - Verifier.verifyLogin(session); - requestObject = Parser.getCorrectRequest(PUT, Parser.parseRequest(request, PUT)); - - privacyObj = requestObject.getJSONObject(PRIVACY_); - if (privacyObj == null) { - throw new NullPointerException("请设置 " + PRIVACY_ + "!"); - } - userId = privacyObj.getLongValue(ID); - payPassword = privacyObj.getString(_PAY_PASSWORD); - change = privacyObj.getDoubleValue("balance+"); - - if (userId <= 0) { - throw new IllegalArgumentException(PRIVACY_ + "." + ID + ":value 中value不合法!"); - } - if (StringUtil.isPassword(payPassword) == false) { - throw new IllegalArgumentException(PRIVACY_ + "." + _PAY_PASSWORD + ":value 中value不合法!"); - } - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - - //验证密码<<<<<<<<<<<<<<<<<<<<<<< - - privacyObj.remove("balance+"); - JSONResponse response = new JSONResponse( - new Parser(HEADS, true).setSession(session).parseResponse( - new JSONRequest(PRIVACY_, privacyObj) - ) - ); - response = response.getJSONResponse(PRIVACY_); - if (JSONResponse.isExist(response) == false) { - return Parser.extendErrorResult(requestObject, new ConditionErrorException("支付密码错误!")); - } - - //验证密码>>>>>>>>>>>>>>>>>>>>>>>> - - - //验证金额范围<<<<<<<<<<<<<<<<<<<<<<< - - if (change == 0) { - return Parser.extendErrorResult(requestObject, new OutOfRangeException("balance+的值不能为0!")); - } - if (Math.abs(change) > 10000) { - return Parser.extendErrorResult(requestObject, new OutOfRangeException("单次 充值/提现 的金额不能超过10000元!")); - } - - //验证金额范围>>>>>>>>>>>>>>>>>>>>>>>> - - if (change < 0) {//提现 - response = new JSONResponse( - new Parser(GETS, true).parseResponse( - new JSONRequest( - new Privacy(userId) - ) - ) - ); - Privacy privacy = response == null ? null : response.getObject(Privacy.class); - long id = privacy == null ? 0 : BaseModel.value(privacy.getId()); - if (id != userId) { - return Parser.extendErrorResult(requestObject, new Exception("服务器内部错误!")); - } - - if (BaseModel.value(privacy.getBalance()) < -change) { - return Parser.extendErrorResult(requestObject, new OutOfRangeException("余额不足!")); - } - } - - - privacyObj.remove(_PAY_PASSWORD); - privacyObj.put("balance+", change); - requestObject.put(PRIVACY_, privacyObj); - requestObject.put(JSONRequest.KEY_TAG, PRIVACY_); - //不免验证,里面会验证身份 - return new Parser(PUT).setSession(session).parseResponse(requestObject); - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/Function.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/Function.java deleted file mode 100644 index 2995482cf..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/Function.java +++ /dev/null @@ -1,295 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -import apijson.demo.server.model.BaseModel; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.server.Entry; -import zuo.biao.apijson.server.Pair; - -/**可远程调用的函数类 - * @author Lemon - */ -public class Function implements FunctionList { - private static final String TAG = "Function"; - - - public static void test() throws Exception { - int i0 = 1, i1 = -2; - Map jsonMap = new HashMap(); - jsonMap.put("id", 10); - jsonMap.put("i0", i0); - jsonMap.put("i1", i1); - JSONArray arr = new JSONArray(); - arr.add(new JSONObject()); - jsonMap.put("arr", arr); - - JSONArray collection = new JSONArray(); - collection.add(1);//new JSONObject()); - collection.add(2);//new JSONObject()); - collection.add(4);//new JSONObject()); - collection.add(10);//new JSONObject()); - jsonMap.put("collection", collection); - - jsonMap.put("position", 1); - jsonMap.put("@position", 0); - - jsonMap.put("key", "key"); - Map map = new HashMap(); - map.put("key", true); - jsonMap.put("map", map); - - - Log.i(TAG, "plus(1, -2) = " + invoke(jsonMap, "plus(long:i0,long:i1)")); - Log.i(TAG, "count([1,2,4,10]) = " + invoke(jsonMap, "count(Collection:collection)")); - Log.i(TAG, "isContain([1,2,4,10], 10) = " + invoke(jsonMap, "isContain(Collection:collection,Object:id)")); - Log.i(TAG, "get({key:true}, key) = " + invoke(jsonMap, "get(Map:map,key)")); - Log.i(TAG, "get([1,2,4,10], 0) = " + invoke(jsonMap, "get(Collection:collection,int:@position)")); - Log.i(TAG, "Integer:get({key:true}, key) = " + invoke(jsonMap, "Integer:get(Map:map,key)")); - } - - /**反射调用 - * @param jsonMap - * @param function 例如get(Map:map,key),参数只允许引用,不能直接传值 - * @return - */ - public static Object invoke(Map jsonMap, String function) throws Exception { - - int start = function.indexOf("("); - int end = function.lastIndexOf(")"); - Entry method = Pair.parseVariableEntry(function.substring(0, start)); - if (method == null || StringUtil.isNotEmpty(method.getValue(), true) == false) { - Log.i(TAG, "invoke method == null || StringUtil.isNotEmpty(method.getValue(), true) == false" - + " >> return null;"); - return null; - } - - String[] typeValues = StringUtil.split(function.substring(start + 1, end)); - - Class[] types = null; - Object[] values = null; - if (typeValues != null && typeValues.length > 0) { - types = new Class[typeValues.length]; - values = new Object[typeValues.length]; - - Entry, Object> entry; - for (int i = 0; i < typeValues.length; i++) { - entry = Pair.parseVariableEntry(typeValues[i], jsonMap); - if (entry != null && entry.isEmpty() == false) { - types[i] = entry.getKey(); - values[i] = entry.getValue(); - } - } - } - return invoke(method.getValue(), types, values); - } - /**反射调用 - * @param methodName - * @param parameterTypes - * @param args - * @return - */ - public static Object invoke(String methodName, Class[] parameterTypes, Object[] args) throws Exception { - Function obj = new Function(); - Class clazz = obj.getClass(); - return clazz.getDeclaredMethod(methodName, parameterTypes).invoke(obj, args); - } - - - - - public String search(String key) { - return null; - } - - public long plus(long i0, long i1) { - return i0 + i1; - } - - - //判断是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**判断collection是否为空 - * @param collection - * @return - */ - @Override - public boolean isEmpty(Collection collection) { - return BaseModel.isEmpty(collection); - } - /**判断map是否为空 - * @param - * @param - * @param map - * @return - */ - @Override - public boolean isEmpty(Map map) { - return BaseModel.isEmpty(map); - } - //判断是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //判断是否为包含 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**判断collection是否包含object - * @param collection - * @param object - * @return - */ - @Override - public boolean isContain(Collection collection, T object) { - return BaseModel.isContain(collection, object); - } - /**判断map是否包含key - * @param - * @param - * @param map - * @param key - * @return - */ - @Override - public boolean isContainKey(Map map, K key) { - return BaseModel.isContainKey(map, key); - } - /**判断map是否包含value - * @param - * @param - * @param map - * @param value - * @return - */ - @Override - public boolean isContainValue(Map map, V value) { - return BaseModel.isContainValue(map, value); - } - //判断是否为包含 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取数量 - * @param - * @param array - * @return - */ - @Override - public int count(T[] array) { - return BaseModel.count(array); - } - /**获取数量 - * @param - * @param collection List, Vector, Set等都是Collection的子类 - * @return - */ - @Override - public int count(Collection collection) { - return BaseModel.count(collection); - } - /**获取数量 - * @param - * @param - * @param map - * @return - */ - @Override - public int count(Map map) { - return BaseModel.count(map); - } - //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取 - * @param - * @param array - * @return - */ - @Override - public T get(T[] array, int position) { - return BaseModel.get(array, position); - } - /**获取 - * @param - * @param collection List, Vector, Set等都是Collection的子类 - * @return - */ - @Override - public T get(Collection collection, int position) { - return BaseModel.get(collection, position); - } - /**获取 - * @param - * @param - * @param map null ? null - * @param key null ? null : map.get(key); - * @return - */ - @Override - public V get(Map map, K key) { - return BaseModel.get(map, key); - } - //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //获取非基本类型对应基本类型的非空值 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取非空值 - * @param value - * @return - */ - @Override - public boolean value(Boolean value) { - return BaseModel.value(value); - } - /**获取非空值 - * @param value - * @return - */ - @Override - public int value(Integer value) { - return BaseModel.value(value); - } - /**获取非空值 - * @param value - * @return - */ - @Override - public long value(Long value) { - return BaseModel.value(value); - } - /**获取非空值 - * @param value - * @return - */ - @Override - public float value(Float value) { - return BaseModel.value(value); - } - /**获取非空值 - * @param value - * @return - */ - @Override - public double value(Double value) { - return BaseModel.value(value); - } - //获取非基本类型对应基本类型的非空值 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - -} \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/FunctionList.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/FunctionList.java deleted file mode 100644 index b087a4c61..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/FunctionList.java +++ /dev/null @@ -1,143 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server; - -import java.util.Collection; -import java.util.Map; - -//TODO 新增 @FunctionList ,被它注解过的List可以传到 FuntionUtil.invoke(FunctionList list, ...) -/**可远程调用的函数列表,暴露功能和使用方式,而不是具体的实现细节。 - * @author Lemon - */ -public interface FunctionList { - - //判断是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**判断collection是否为空 - * @param collection - * @return - */ - public boolean isEmpty(Collection collection); - /**判断map是否为空 - * @param - * @param - * @param map - * @return - */ - public boolean isEmpty(Map map); - //判断是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //判断是否为包含 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**判断collection是否包含object - * @param collection - * @param object - * @return - */ - public boolean isContain(Collection collection, T object); - /**判断map是否包含key - * @param - * @param - * @param map - * @param key - * @return - */ - public boolean isContainKey(Map map, K key); - /**判断map是否包含value - * @param - * @param - * @param map - * @param value - * @return - */ - public boolean isContainValue(Map map, V value); - //判断是否为包含 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取数量 - * @param - * @param array - * @return - */ - public int count(T[] array); - /**获取数量 - * @param - * @param collection List, Vector, Set等都是Collection的子类 - * @return - */ - public int count(Collection collection); - /**获取数量 - * @param - * @param - * @param map - * @return - */ - public int count(Map map); - //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取 - * @param - * @param array - * @return - */ - public T get(T[] array, int position); - /**获取 - * @param - * @param collection List, Vector, Set等都是Collection的子类 - * @return - */ - public T get(Collection collection, int position); - /**获取 - * @param - * @param - * @param map null ? null - * @param key null ? null : map.get(key); - * @return - */ - public V get(Map map, K key); - //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //获取非基本类型对应基本类型的非空值 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取非空值 - * @param value - * @return - */ - public boolean value(Boolean value); - /**获取非空值 - * @param value - * @return - */ - public int value(Integer value); - /**获取非空值 - * @param value - * @return - */ - public long value(Long value); - /**获取非空值 - * @param value - * @return - */ - public float value(Float value); - /**获取非空值 - * @param value - * @return - */ - public double value(Double value); - //获取非基本类型对应基本类型的非空值 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - -} \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/Verifier.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/Verifier.java deleted file mode 100644 index b49c482ab..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/Verifier.java +++ /dev/null @@ -1,344 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server; - -import static zuo.biao.apijson.RequestMethod.DELETE; -import static zuo.biao.apijson.RequestMethod.GET; -import static zuo.biao.apijson.RequestMethod.HEAD; -import static zuo.biao.apijson.RequestMethod.POST; -import static zuo.biao.apijson.RequestMethod.GETS; -import static zuo.biao.apijson.RequestMethod.HEADS; -import static zuo.biao.apijson.RequestMethod.PUT; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.activation.UnsupportedDataTypeException; -import javax.servlet.http.HttpSession; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -import apijson.demo.server.model.BaseModel; -import apijson.demo.server.model.Comment; -import apijson.demo.server.model.Login; -import apijson.demo.server.model.Moment; -import apijson.demo.server.model.Privacy; -import apijson.demo.server.model.User; -import apijson.demo.server.model.Verify; -import zuo.biao.apijson.JSON; -import zuo.biao.apijson.JSONResponse; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.MethodAccess; -import zuo.biao.apijson.RequestMethod; -import zuo.biao.apijson.RequestRole; -import zuo.biao.apijson.model.Column; -import zuo.biao.apijson.model.Document; -import zuo.biao.apijson.model.Request; -import zuo.biao.apijson.model.Response; -import zuo.biao.apijson.model.Table; -import zuo.biao.apijson.model.Test; -import zuo.biao.apijson.server.JSONRequest; -import zuo.biao.apijson.server.Parser; -import zuo.biao.apijson.server.exception.ConflictException; -import zuo.biao.apijson.server.exception.NotLoggedInException; -import zuo.biao.apijson.server.sql.SQLConfig; - -/**权限验证类 - * @author Lemon - */ -public class Verifier { - private static final String TAG = "Verifier"; - - - public static final String KEY_PASSWORD = "password"; - public static final String KEY_LOGIN_PASSWORD = "loginPassword"; - public static final String KEY_PAY_PASSWORD = "payPassword"; - public static final String KEY_OLD_PASSWORD = "oldPassword"; - - - // > - // > - public static final Map> ACCESS_MAP; - static { - ACCESS_MAP = new HashMap>(); - - ACCESS_MAP.put(Table.class.getSimpleName(), getAccessMap(Table.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Column.class.getSimpleName(), getAccessMap(Column.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Test.class.getSimpleName(), getAccessMap(Test.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Request.class.getSimpleName(), getAccessMap(Request.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Response.class.getSimpleName(), getAccessMap(Response.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Document.class.getSimpleName(), getAccessMap(Document.class.getAnnotation(MethodAccess.class))); - - ACCESS_MAP.put(User.class.getSimpleName(), getAccessMap(User.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Privacy.class.getSimpleName(), getAccessMap(Privacy.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Moment.class.getSimpleName(), getAccessMap(Moment.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Comment.class.getSimpleName(), getAccessMap(Comment.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Verify.class.getSimpleName(), getAccessMap(Verify.class.getAnnotation(MethodAccess.class))); - ACCESS_MAP.put(Login.class.getSimpleName(), getAccessMap(Login.class.getAnnotation(MethodAccess.class))); - } - - /**获取权限Map,每种操作都只允许对应的角色 - * @param access - * @return - */ - private static HashMap getAccessMap(MethodAccess access) { - if (access == null) { - return null; - } - - HashMap map = new HashMap<>(); - map.put(GET, access.GET()); - map.put(HEAD, access.HEAD()); - map.put(GETS, access.GETS()); - map.put(HEADS, access.HEADS()); - map.put(POST, access.POST()); - map.put(PUT, access.PUT()); - map.put(DELETE, access.DELETE()); - - return map; - } - - - /**验证权限是否通过 - * @param config - * @param visitor - * @return - * @throws Exception - */ - public static boolean verify(SQLConfig config, User visitor) throws Exception { - String table = config == null ? null : config.getTable(); - if (table == null) { - return true; - } - RequestRole role = config.getRole(); - if (role == null) { - role = RequestRole.UNKNOWN; - } - - long userId = visitor == null ? 0 : visitor.getId(); - //TODO 暂时去掉,方便测试 - if (role != RequestRole.UNKNOWN) {//未登录的角色 - verifyLogin(userId); - } - - RequestMethod method = config.getMethod(); - //验证允许的角色 - verifyRole(table, method, role); - - - //验证角色,假定真实强制匹配<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - String userIdkey = Controller.USER_.equals(config.getTable()) || Controller.PRIVACY_.equals(config.getTable()) - ? Controller.ID : Controller.USER_ID; - - Number requestId; - switch (role) { - case LOGIN://verifyRole通过就行 - break; - case CONTACT: - case CIRCLE: - //TODO 做一个缓存contactMap,提高[]:{}查询性能, removeAccessInfo时map.remove(userId) - //不能在User内null -> [] ! 否则会导致某些查询加上不需要的条件! - List list = visitor == null || visitor.getContactIdList() == null - ? new ArrayList() : new ArrayList(visitor.getContactIdList()); - if (role == RequestRole.CIRCLE) { - list.add(userId); - } - - //key!{}:[] 或 其它没有明确id的条件 等 可以和key{}:list组合。类型错误就报错 - requestId = (Number) config.getWhere(userIdkey, true);//JSON里数值不能保证是Long,可能是Integer - JSONArray requestIdArray = (JSONArray) config.getWhere(userIdkey + "{}", true);//不能是 &{}, |{} 不要传,直接{} - if (requestId != null) { - if (requestIdArray == null) { - requestIdArray = new JSONArray(); - } - requestIdArray.add(requestId); - } - - if (requestIdArray == null) {//可能是@得到 || requestIdArray.isEmpty()) {//请求未声明key:id或key{}:[...]条件,自动补全 - config.addWhere(userIdkey+"{}", JSON.parseArray(list)); //key{}:[]有效,SQLConfig里throw NotExistException - } - else {//请求已声明key:id或key{}:[]条件,直接验证 - for (Object id : requestIdArray) { - if (id == null) { - continue; - } - if (id instanceof Number == false) {//不能准确地判断Long,可能是Integer - throw new UnsupportedDataTypeException(table + ".id类型错误,id类型必须是Long!"); - } - if (list.contains(new Long("" + id)) == false) {//Integer等转为Long才能正确判断。强转崩溃 - throw new IllegalAccessException(userIdkey + " = " + id + " 的 " + table - + " 不允许 " + role.name() + " 用户的 " + method.name() + " 请求!"); - } - } - } - break; - case OWNER: - requestId = (Number) config.getWhere(userIdkey, true);//JSON里数值不能保证是Long,可能是Integer - if (requestId != null && requestId.longValue() != userId) { - throw new IllegalAccessException(userIdkey + " = " + requestId + " 的 " + table - + " 不允许 " + role.name() + " 用户的 " + method.name() + " 请求!"); - } - config.addWhere(userIdkey, userId); - break; - case ADMIN://这里不好做,在特定接口内部判断? TODO /get/admin + 固定秘钥 Parser#noVerify,之后全局跳过验证 - break; - default://unknown,verifyRole通过就行 - break; - } - - //验证角色,假定真实强制匹配>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - return true; - } - - - /**允许请求,角色不好判断,让访问者发过来角色名,OWNER,CONTACT,ADMIN等 - * @param table - * @param method - * @param role - * @return - * @throws Exception - * @see {@link zuo.biao.apijson.JSONObject#KEY_ROLE} - */ - public static void verifyRole(String table, RequestMethod method, RequestRole role) throws Exception { - Log.d(TAG, "verifyRole table = " + table + "; method = " + method + "; role = " + role); - if (table != null) { - if (method == null) { - method = GET; - } - if (role == null) { - role = RequestRole.UNKNOWN; - } - Map map = ACCESS_MAP.get(table); - - if (map == null || BaseModel.isContain(map.get(method), role) == false) { - throw new IllegalAccessException(table + " 不允许 " + role.name() + " 用户的 " + method.name() + " 请求!"); - } - } - } - - - /**登录校验 - * @author - * @modifier Lemon - * @param session - * @throws Exception - */ - public static void verifyLogin(HttpSession session) throws Exception { - Log.d(TAG, "verifyLogin session.getId() = " + (session == null ? null : session.getId())); - verifyLogin(getUserId(session)); - } - /**登录校验 - * @author Lemon - * @param userId - * @throws Exception - */ - public static void verifyLogin(Long userId) throws Exception { - //未登录没有权限操作 - if (BaseModel.value(userId) <= 0) { - throw new NotLoggedInException("未登录,请登录后再操作!"); - } - } - - - - /**验证是否重复 - * @param table - * @param key - * @param value - * @throws Exception - */ - public static void verifyRepeat(String table, String key, Object value) throws Exception { - verifyRepeat(table, key, value, 0); - } - /**验证是否重复 - * @param table - * @param key - * @param value - * @param exceptId 不包含id - * @throws Exception - */ - public static void verifyRepeat(String table, String key, Object value, long exceptId) throws Exception { - if (key == null || value == null) { - Log.e(TAG, "verifyRepeat key == null || value == null >> return;"); - return; - } - if (value instanceof JSON) { - throw new UnsupportedDataTypeException(key + ":value 中value的类型不能为JSON!"); - } - - JSONRequest request = new JSONRequest(key, value); - if (exceptId > 0) {//允许修改自己的属性为该属性原来的值 - request.put(JSONRequest.KEY_ID + "!", exceptId); - } - JSONObject repeat = new Parser(HEAD, true).parseResponse( - new JSONRequest(table, request) - ); - repeat = repeat == null ? null : repeat.getJSONObject(table); - if (repeat == null) { - throw new Exception("服务器内部错误 verifyRepeat repeat == null"); - } - if (repeat.getIntValue(JSONResponse.KEY_COUNT) > 0) { - throw new ConflictException(key + ": " + value + " 已经存在,不能重复!"); - } - } - - - /**获取来访用户的id - * @author Lemon - * @param session - * @return - */ - public static long getUserId(HttpSession session) { - if (session == null) { - return 0; - } - Long userId = (Long) session.getAttribute(Controller.USER_ID); - if (userId == null) { - User user = getUser(session); - userId = user == null ? 0 : BaseModel.value(user.getId()); - session.setAttribute(Controller.USER_ID, userId); - } - return BaseModel.value(userId); - } - /**获取来访用户 - * @param session - * @return - */ - public static User getUser(HttpSession session) { - return session == null ? null : (User) session.getAttribute(Controller.USER_); - } - - - /**删除请求里的权限信息 - * @param requestObject - * @return - */ - public static JSONObject removeAccessInfo(JSONObject requestObject) { - if (requestObject != null) { - requestObject.remove(KEY_PASSWORD); - requestObject.remove(KEY_LOGIN_PASSWORD); - requestObject.remove(KEY_PAY_PASSWORD); - requestObject.remove(KEY_OLD_PASSWORD); - } - return requestObject; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/BaseModel.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/BaseModel.java deleted file mode 100644 index 8dec7d729..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/BaseModel.java +++ /dev/null @@ -1,304 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import java.io.Serializable; -import java.sql.Timestamp; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.Map; - -import com.alibaba.fastjson.JSON; - -import zuo.biao.apijson.StringUtil; - -/**base model for reduce model codes - * @author Lemon - * @use extends BaseModel - */ -public abstract class BaseModel implements Serializable { - private static final long serialVersionUID = 1L; - - private Long id; //主键,唯一标识 - private Long userId; //对应User表中的id,外键 - private String date; //创建时间,JSON没有Date,TimeStamp类型,都会被转成Long,不能用! - - public Long getId() { - return id; - } - public BaseModel setId(Long id) { - this.id = id; - return this; - } - public Long getUserId() { - return userId; - } - public BaseModel setUserId(Long userId) { - this.userId = userId; - return this; - } - public String getDate() { - return date; - } - public BaseModel setDate(String date) { - this.date = date; - return this; - } - - - @Override - public String toString() { - return JSON.toJSONString(this); - } - - - /**获取当前时间戳 - * @return - */ - public static Timestamp currentTimeStamp() { - return new Timestamp(new Date().getTime()); - } - /**获取时间戳 TODO 判空? 还是要报错? - * @param time - * @return - */ - public static Timestamp getTimeStamp(String time) { - return Timestamp.valueOf(time); - } - /**获取时间毫秒值 TODO 判空? 还是要报错? - * @param time - * @return - */ - public static long getTimeMillis(String time) { - return StringUtil.isEmpty(time, true) ? 0 : getTimeStamp(time).getTime(); - } - - - //判断是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**判断array是否为空 - * @param array - * @return - */ - public static boolean isEmpty(T[] array) { - return array == null || array.length <= 0; - } - /**判断collection是否为空 - * @param collection - * @return - */ - public static boolean isEmpty(Collection collection) { - return collection == null || collection.isEmpty(); - } - /**判断map是否为空 - * @param - * @param - * @param map - * @return - */ - public static boolean isEmpty(Map map) { - return map == null || map.isEmpty(); - } - //判断是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //判断是否包含 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**判断array是否包含a - * @param array - * @param a - * @return - */ - public static boolean isContain(T[] array, T a) { - return array == null ? false : Arrays.asList(array).contains(a); - } - /**判断collection是否包含object - * @param collection - * @param object - * @return - */ - public static boolean isContain(Collection collection, T object) { - return collection != null && collection.contains(object); - } - /**判断map是否包含key - * @param - * @param - * @param map - * @param key - * @return - */ - public static boolean isContainKey(Map map, K key) { - return map != null && map.containsKey(key); - } - /**判断map是否包含value - * @param - * @param - * @param map - * @param value - * @return - */ - public static boolean isContainValue(Map map, V value) { - return map != null && map.containsValue(value); - } - //判断是否为包含 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取数量 - * @param - * @param array - * @return - */ - public static int count(T[] array) { - return array == null ? 0 : array.length; - } - /**获取数量 - * @param - * @param collection List, Vector, Set等都是Collection的子类 - * @return - */ - public static int count(Collection collection) { - return collection == null ? 0 : collection.size(); - } - /**获取数量 - * @param - * @param - * @param map - * @return - */ - public static int count(Map map) { - return map == null ? 0 : map.size(); - } - //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取集合长度 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取 - * @param - * @param array - * @return - */ - public static T get(T[] array, int position) { - return position < 0 || position >= count(array) ? null : array[position]; - } - /**获取 - * @param - * @param collection List, Vector, Set等都是Collection的子类 - * @return - */ - @SuppressWarnings("unchecked") - public static T get(Collection collection, int position) { - return collection == null ? null : (T) get(collection.toArray(), position); - } - /**获取 - * @param - * @param - * @param map null ? null - * @param key null ? null : map.get(key); - * @return - */ - public static V get(Map map, K key) { - return key == null || map == null ? null : map.get(key); - } - //获取集合长度 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //获取非基本类型对应基本类型的非空值 <<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取非空值 - * @param value - * @return - */ - public static boolean value(Boolean value) { - return value == null ? false : value; - } - /**获取非空值 - * @param value - * @return - */ - public static int value(Integer value) { - return value == null ? 0 : value; - } - /**获取非空值 - * @param value - * @return - */ - public static long value(Long value) { - return value == null ? 0 : value; - } - /**获取非空值 - * @param value - * @return - */ - public static float value(Float value) { - return value == null ? 0 : value; - } - /**获取非空值 - * @param value - * @return - */ - public static double value(Double value) { - return value == null ? 0 : value; - } - //获取非基本类型对应基本类型的非空值 >>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - /**index是否在arr长度范围内 - * @param index - * @param array - * @return - */ - public static boolean isIndexInRange(Integer index, Object[] array) { - return index != null && index >= 0 && index < count(array); - } - - /**获取在arr长度范围内的index - * defaultIndex = 0 - * @param index - * @param array - * @return - */ - public static int getIndexInRange(Integer index, Object[] array) { - return getIndexInRange(index, array, 0); - } - /**获取在arr长度范围内的index - * @param index - * @param array - * @param defaultIndex - * @return - */ - public static int getIndexInRange(Integer index, Object[] array, int defaultIndex) { - return isIndexInRange(index, array) ? index : defaultIndex; - } - - /**获取在arr长度范围内的index - * defaultIndex = 0 - * @param - * @param index - * @param array - * @return - */ - public static T getInRange(Integer index, T[] array) { - return getInRange(index, array, 0); - } - /**获取在arr长度范围内的index - * @param - * @param index - * @param array - * @param defaultIndex - * @return - */ - public static T getInRange(Integer index, T[] array, int defaultIndex) { - return get(array, getIndexInRange(index, array, defaultIndex)); - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Comment.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Comment.java deleted file mode 100644 index 5bbdb50fc..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Comment.java +++ /dev/null @@ -1,24 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import zuo.biao.apijson.MethodAccess; - -/**评论类 - * @author Lemon - */ -@MethodAccess -public class Comment { -} \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Login.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Login.java deleted file mode 100644 index 6a0973bf0..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Login.java +++ /dev/null @@ -1,62 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.CONTACT; -import static zuo.biao.apijson.RequestRole.LOGIN; -import static zuo.biao.apijson.RequestRole.OWNER; -import static zuo.biao.apijson.RequestRole.UNKNOWN; - -import zuo.biao.apijson.MethodAccess; - -/**登录日志表 - * @author Lemon - */ -@SuppressWarnings("serial") -@MethodAccess( - GET = {}, - HEAD = {}, - GETS = {UNKNOWN, LOGIN, CONTACT, OWNER, ADMIN}, - HEADS = {UNKNOWN, LOGIN, CONTACT, OWNER, ADMIN}, - POST = {ADMIN}, - PUT = {ADMIN}, - DELETE = {ADMIN} - ) -public class Login extends BaseModel { - - public static final int TYPE_PASSWORD = 0;//密码登录 - public static final int TYPE_VERIFY = 1;//验证码登录 - - private Integer type; - - public Login() { - super(); - } - public Login(long userId) { - this(); - setUserId(userId); - } - - - public Integer getType() { - return type; - } - public Login setType(Integer type) { - this.type = type; - return this; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Moment.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Moment.java deleted file mode 100644 index 8fc89e5ed..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Moment.java +++ /dev/null @@ -1,32 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.CIRCLE; -import static zuo.biao.apijson.RequestRole.CONTACT; -import static zuo.biao.apijson.RequestRole.LOGIN; -import static zuo.biao.apijson.RequestRole.OWNER; - -import zuo.biao.apijson.MethodAccess; - -/**动态类 - * @author Lemon - */ -@MethodAccess( - PUT = {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}//TODO 还要细分,LOGIN,CONTACT只允许修改praiseUserIdList。数据库加role没用,应该将praiseUserIdList移到Praise表 - ) -public class Moment { -} \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Privacy.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Privacy.java deleted file mode 100644 index 48516110e..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Privacy.java +++ /dev/null @@ -1,99 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.CIRCLE; -import static zuo.biao.apijson.RequestRole.OWNER; -import static zuo.biao.apijson.RequestRole.UNKNOWN; - -import zuo.biao.apijson.MethodAccess; - -/**用户隐私信息 - * @author Lemon - */ -@MethodAccess( - GET = {}, - GETS = {CIRCLE, OWNER, ADMIN}, - POST = {UNKNOWN, ADMIN}, - DELETE = {ADMIN} - ) -public class Privacy extends BaseModel { - private static final long serialVersionUID = 1L; - - public static final int PASSWORD_TYPE_LOGIN = 0; - public static final int PASSWORD_TYPE_PAY = 1; - - private String phone; //手机 - private String password; //登录密码,隐藏字段 - private String payPassword; //支付密码,隐藏字段 - private Double balance; //余额 - - public Privacy() { - super(); - } - - public Privacy(long id) { - this(); - setId(id); - } - - public Privacy(String phone, String password) { - this(); - setPhone(phone); - setPassword(password); - } - - - - public String getPhone() { - return phone; - } - public Privacy setPhone(String phone) { - this.phone = phone; - return this; - } - - /**get_password会转为password - * @return - */ - public String get__password() { - return password; - } - public Privacy setPassword(String password) { - this.password = password; - return this; - } - - /**get_PayPassword会转为PayPassword - * @return - */ - public String get__payPassword() { - return payPassword; - } - public Privacy setPayPassword(String payPassword) { - this.payPassword = payPassword; - return this; - } - - public Double getBalance() { - return balance; - } - public Privacy setBalance(Double balance) { - this.balance = balance; - return this; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/User.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/User.java deleted file mode 100644 index 75f0c7682..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/User.java +++ /dev/null @@ -1,102 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.UNKNOWN; - -import java.util.List; - -import zuo.biao.apijson.MethodAccess; - -/**用户类 - * @author Lemon - */ -@MethodAccess( - POST = {UNKNOWN, ADMIN}, - DELETE = {ADMIN} - ) -public class User extends BaseModel { - private static final long serialVersionUID = 1L; - - public static final int SEX_MAIL = 0; - public static final int SEX_FEMALE = 1; - public static final int SEX_UNKNOWN = 2; - - - private Integer sex; //性别 - private String head; //头像url - private String name; //姓名 - private String tag; //标签 - private List pictureList; //照片列表 - private List contactIdList; //朋友列表 - - /**默认构造方法,JSON等解析时必须要有 - */ - public User() { - super(); - } - public User(long id) { - this(); - setId(id); - } - - public Integer getSex() { - return sex; - } - public User setSex(Integer sex) { - this.sex = sex; - return this; - } - public String getHead() { - return head; - } - public User setHead(String head) { - this.head = head; - return this; - } - public String getName() { - return name; - } - public User setName(String name) { - this.name = name; - return this; - } - public List getPictureList() { - return pictureList; - } - public User setPictureList(List pictureList) { - this.pictureList = pictureList; - return this; - } - - public String getTag() { - return tag; - } - public User setTag(String tag) { - this.tag = tag; - return this; - } - - public List getContactIdList() { - return contactIdList; - } - public User setContactIdList(List contactIdList) { - this.contactIdList = contactIdList; - return this; - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Verify.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Verify.java deleted file mode 100644 index b88cd2a98..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/Verify.java +++ /dev/null @@ -1,88 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package apijson.demo.server.model; - -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.CIRCLE; -import static zuo.biao.apijson.RequestRole.CONTACT; -import static zuo.biao.apijson.RequestRole.LOGIN; -import static zuo.biao.apijson.RequestRole.OWNER; -import static zuo.biao.apijson.RequestRole.UNKNOWN; - -import zuo.biao.apijson.MethodAccess; - -/**验证码 - * @author Lemon - */ -@MethodAccess( - GET = {}, - HEAD = {}, - GETS = {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}, - HEADS = {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}, - POST = {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}, - PUT = {ADMIN}, - DELETE = {ADMIN} - ) -public class Verify extends BaseModel { - private static final long serialVersionUID = 1L; - - public static final int TYPE_LOGIN = 0; //登录 - public static final int TYPE_REGISTER = 1; //注册 - public static final int TYPE_PASSWORD = 2; //登录密码 - public static final int TYPE_PAY_PASSWORD = 3; //支付密码 - - private String phone; //手机 - private String verify; //验证码 - private Integer type; //验证类型 - - public Verify() { - super(); - } - /**type和phone为联合主键,必传 - * @param type - * @param phone - */ - public Verify(int type, String phone) { - this(); - setType(type); - setPhone(phone); - } - - - public String getVerify() { - return verify; - } - public Verify setVerify(String verify) { - this.verify = verify; - return this; - } - - public String getPhone() { - return phone; - } - public Verify setPhone(String phone) { - this.phone = phone; - return this; - } - - public Integer getType() { - return type; - } - public Verify setType(Integer type) { - this.type = type; - return this; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/package-info.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/package-info.java deleted file mode 100644 index 7a82728b7..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/model/package-info.java +++ /dev/null @@ -1,26 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -/** - * 服务端给出的model - * the names of classes equal the names of tables in Server database one by one, so do the variables and columns - * (name) : model <=> table - * (name, type) : variable <=> column - * @warn don't use any base type like int or char in models, use Integer and String instead - */ -/** - * @author Lemon - * - */ -package apijson.demo.server.model; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/package-info.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/package-info.java deleted file mode 100644 index 487e27c06..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/apijson/demo/server/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * 示例服务端工程包 - */ -/** - * @author Lemon - * - */ -package apijson.demo.server; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSON.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSON.java deleted file mode 100755 index 7bd24b97d..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSON.java +++ /dev/null @@ -1,276 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import java.util.List; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.parser.Feature; -import com.alibaba.fastjson.serializer.SerializerFeature; - -/**阿里FastJSON封装类 防止解析时异常 - * @author Lemon - */ -public class JSON { - private static final String TAG = "JSON"; - - /**判断json格式是否正确 - * @param s - * @return - */ - public static boolean isJsonCorrect(String s) { - //太长 Log.i(TAG, "isJsonCorrect <<<< " + s + " >>>>>>>"); - if (s == null - // || s.equals("[]") - // || s.equals("{}") - || s.equals("") - || s.equals("[null]") - || s.equals("{null}") - || s.equals("null")) { - return false; - } - return true; - } - - /**获取有效的json - * @param s - * @return - */ - public static String getCorrectJson(String s) { - return getCorrectJson(s, false); - } - /**获取有效的json - * @param s - * @param isArray - * @return - */ - public static String getCorrectJson(String s, boolean isArray) { - s = StringUtil.getTrimedString(s); - // if (isArray) { - // while (s.startsWith("\"")) { - // s = s.substring(1); - // } - // while (s.endsWith("\"")) { - // s = s.substring(0, s.length() - 1); - // } - // } - return s;//isJsonCorrect(s) ? s : null; - } - - /**obj转JSONObject - * @param json - * @return - */ - public static JSONObject parseObject(Object obj) { - if (obj instanceof JSONObject) { - return (JSONObject) obj; - } - return parseObject(toJSONString(obj)); - } - /**json转JSONObject - * @param json - * @return - */ - public static JSONObject parseObject(String json) { - int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE; - features |= Feature.OrderedField.getMask(); - return parseObject(json, features); - } - /**json转JSONObject - * @param json - * @param features - * @return - */ - public static JSONObject parseObject(String json, int features) { - try { - return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), JSONObject.class, features); - } catch (Exception e) { - Log.i(TAG, "parseObject catch \n" + e.getMessage()); - } - return null; - } - - /**JSONObject转实体类 - * @param object - * @param clazz - * @return - */ - public static T parseObject(JSONObject object, Class clazz) { - return parseObject(toJSONString(object), clazz); - } - /**json转实体类 - * @param json - * @param clazz - * @return - */ - public static T parseObject(String json, Class clazz) { - if (clazz == null) { - Log.e(TAG, "parseObject clazz == null >> return null;"); - } else { - try { - int features = com.alibaba.fastjson.JSON.DEFAULT_PARSER_FEATURE; - features |= Feature.OrderedField.getMask(); - return com.alibaba.fastjson.JSON.parseObject(getCorrectJson(json), clazz, features); - } catch (Exception e) { - Log.i(TAG, "parseObject catch \n" + e.getMessage()); - } - } - return null; - } - - /**list转JSONArray - * @param list - * @return - */ - public static JSONArray parseArray(List list) { - return new JSONArray(list); - } - /**obj转JSONArray - * @param json - * @return - */ - public static JSONArray parseArray(Object obj) { - if (obj instanceof JSONArray) { - return (JSONArray) obj; - } - return parseArray(toJSONString(obj)); - } - /**json转JSONArray - * @param json - * @return - */ - public static JSONArray parseArray(String json) { - try { - return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json, true)); - } catch (Exception e) { - Log.i(TAG, "parseArray catch \n" + e.getMessage()); - } - return null; - } - /**JSONArray转实体类列表 - * @param array - * @param clazz - * @return - */ - public static List parseArray(JSONArray array, Class clazz) { - return parseArray(toJSONString(array), clazz); - } - /**json转实体类列表 - * @param json - * @param clazz - * @return - */ - public static List parseArray(String json, Class clazz) { - if (clazz == null) { - Log.e(TAG, "parseArray clazz == null >> return null;"); - } else { - try { - return com.alibaba.fastjson.JSON.parseArray(getCorrectJson(json, true), clazz); - } catch (Exception e) { - Log.i(TAG, "parseArray catch \n" + e.getMessage()); - } - } - return null; - } - - /**实体类转json - * @param obj - * @return - */ - public static String toJSONString(Object obj) { - if (obj instanceof String) { - return (String) obj; - } - try { - return com.alibaba.fastjson.JSON.toJSONString(obj); - } catch (Exception e) { - Log.e(TAG, "toJSONString catch \n" + e.getMessage()); - } - return null; - } - - /**实体类转json - * @param obj - * @param features - * @return - */ - public static String toJSONString(Object obj, SerializerFeature... features) { - if (obj instanceof String) { - return (String) obj; - } - try { - return com.alibaba.fastjson.JSON.toJSONString(obj, features); - } catch (Exception e) { - Log.e(TAG, "parseArray catch \n" + e.getMessage()); - } - return null; - } - - /**格式化,显示更好看 - * @param json - * @return - */ - public static String format(String json) { - return format(parseObject(json)); - } - /**格式化,显示更好看 - * @param object - * @return - */ - public static String format(JSONObject object) { - return toJSONString(object, SerializerFeature.PrettyFormat); - } - - /**判断是否为JSONObject - * @param obj instanceof String ? parseObject - * @return - */ - public static boolean isJSONObject(Object obj) { - if (obj instanceof JSONObject) { - return true; - } - if (obj instanceof String) { - try { - JSONObject json = parseObject((String) obj); - return json != null && json.isEmpty() == false; - } catch (Exception e) { - Log.e(TAG, "isJSONObject catch \n" + e.getMessage()); - } - } - - return false; - } - /**判断是否为JSONArray - * @param obj instanceof String ? parseArray - * @return - */ - public static boolean isJSONArray(Object obj) { - if (obj instanceof JSONArray) { - return true; - } - if (obj instanceof String) { - try { - JSONArray json = parseArray((String) obj); - return json != null && json.isEmpty() == false; - } catch (Exception e) { - Log.e(TAG, "isJSONArray catch \n" + e.getMessage()); - } - } - - return false; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSONObject.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSONObject.java deleted file mode 100644 index 3c9e0d1cf..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSONObject.java +++ /dev/null @@ -1,374 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import java.util.List; -import java.util.Map; - -/**use this class instead of com.alibaba.fastjson.JSONObject - * @author Lemon - * @see #put - * @see #puts - * @see #putsAll - */ -public class JSONObject extends com.alibaba.fastjson.JSONObject { - private static final long serialVersionUID = 1L; - - private static final String TAG = "JSONObject"; - - - /**ordered - */ - public JSONObject() { - super(true); - } - /**transfer Object to JSONObject - * @param object - * @see {@link #JSONObject(Object, boolean)} - */ - public JSONObject(Object object) { - this(toJSONString(object)); - } - /**parse JSONObject with JSON String - * @param json - * @see {@link #JSONObject(String, boolean)} - */ - public JSONObject(String json) { - this(parseObject(json)); - } - /**transfer com.alibaba.fastjson.JSONObject to JSONObject - * @param object - * @see {@link #putsAll(com.alibaba.fastjson.JSONObject)} - */ - public JSONObject(com.alibaba.fastjson.JSONObject object) { - this(); - putsAll(object); - } - - - - - //judge <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - public static final String KEY_ARRAY = "[]"; - - /**判断是否为Array的key - * @param key - * @return - */ - public static boolean isArrayKey(String key) { - return key != null && key.endsWith(KEY_ARRAY); - } - /**判断是否为对应Table的key - * @param key - * @return - */ - public static boolean isTableKey(String key) { - return StringUtil.isBigName(key); - } - //judge >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //JSONObject内关键词 key <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - - public static final String KEY_ID = "id"; - public static final String KEY_ID_IN = KEY_ID + "{}"; - - /**set "id":id in Table layer - * @param id - * @return - */ - public JSONObject setId(Long id) { - return puts(KEY_ID, id); - } - /**set id{}:[] in Table layer - * @param list - * @return - */ - public JSONObject setIdIn(List list) { - return puts(KEY_ID_IN, list); - } - - - //@key关键字都放这个类 <<<<<<<<<<<<<<<<<<<<<< - public static final String KEY_ROLE = "@role"; //角色,拥有对某些数据的某些操作的权限 - public static final String KEY_CONDITION = "@condition"; //条件 TODO 用 @where& @where| @where! 替代? - public static final String KEY_TRY = "@try"; //尝试,忽略异常 - public static final String KEY_DROP = "@drop"; //丢弃,不返回 - public static final String KEY_CORRECT = "@correct"; //字段校正 - - public static final String KEY_SCHEMA = "@schema"; //数据库,Table在非默认schema内时需要声明 - public static final String KEY_ABOUT = "@about"; //关于,返回数据库表的信息,包括表说明和字段说明 - public static final String KEY_COLUMN = "@column"; //查询的Table字段或SQL函数 - public static final String KEY_GROUP = "@group"; //分组方式 - public static final String KEY_HAVING = "@having"; //聚合函数条件,一般和@group一起用 - public static final String KEY_ORDER = "@order"; //排序方式 - //@key关键字都放这个类 >>>>>>>>>>>>>>>>>>>>>> - - - /**set role of request sender - * @param role - * @return this - */ - public JSONObject setRole(String role) { - return puts(KEY_ROLE, role); - } - - /**set try, ignore exceptions - * @param tri - * @return this - */ - public JSONObject setTry(boolean tri) { - return puts(KEY_TRY, tri); - } - - /**set drop, data dropped will not return - * @param drop - * @return this - */ - public JSONObject setDrop(boolean drop) { - return puts(KEY_DROP, drop); - } - - /**set correct, correct keys to target ones - * @param correct Map{originKey, [posibleKeys]}, posibleKey之间用 , 隔开 - * @return this - */ - public JSONObject setCorrect(Map correct) { - return puts(KEY_CORRECT, correct); - } - - - - /**set schema where table was puts - * @param schema - * @return this - */ - public JSONObject setSchema(String schema) { - return puts(KEY_SCHEMA, schema); - } - - /**set about - * @param about - * @return this - */ - public JSONObject setAbout(boolean about) { - return puts(KEY_ABOUT, about); - } - - /**set keys need to be returned - * @param keys key0, key1, key2 ... - * @return {@link #setColumn(String)} - */ - public JSONObject setColumn(String... keys) { - return setColumn(StringUtil.getString(keys, true)); - } - /**set keys need to be returned - * @param keys "key0,key1,key2..." - * @return - */ - public JSONObject setColumn(String keys) { - return puts(KEY_COLUMN, keys); - } - - /**set keys for group by - * @param keys key0, key1, key2 ... - * @return {@link #setGroup(String)} - */ - public JSONObject setGroup(String... keys) { - return setGroup(StringUtil.getString(keys, true)); - } - /**set keys for group by - * @param keys "key0,key1,key2..." - * @return - */ - public JSONObject setGroup(String keys) { - return puts(KEY_GROUP, keys); - } - - /**set keys for having - * @param keys count(key0) > 1, sum(key1) <= 5, function2(key2) ? value2 ... - * @return {@link #setHaving(String)} - */ - public JSONObject setHaving(String... keys) { - return setHaving(StringUtil.getString(keys, true)); - } - /**set keys for having - * @param keys "key0,key1,key2..." - * @return - */ - public JSONObject setHaving(String keys) { - return puts(KEY_HAVING, keys); - } - - /**set keys for order by - * @param keys key0, key1+, key2- ... - * @return {@link #setOrder(String)} - */ - public JSONObject setOrder(String... keys) { - return setOrder(StringUtil.getString(keys, true)); - } - /**set keys for order by - * @param keys "key0,key1+,key2-..." - * @return - */ - public JSONObject setOrder(String keys) { - return puts(KEY_ORDER, keys); - } - - - //JSONObject内关键词 key >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //Request <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - - /** - * @param key - * @param keys path = keys[0] + "/" + keys[1] + "/" + keys[2] + ... - * @return {@link #puts(String, Object)} - */ - public JSONObject putsPath(String key, String... keys) { - return puts(key+"@", StringUtil.getString(keys, "/")); - } - - /** - * @param key - * @param isNull - * @return {@link #puts(String, Object)} - */ - public JSONObject putsNull(String key, boolean isNull) { - return puts(key+"{}", SQL.isNull(isNull)); - } - /** - * trim = false - * @param key - * @param isEmpty - * @return {@link #putsEmpty(String, boolean, boolean)} - */ - public JSONObject putsEmpty(String key, boolean isEmpty) { - return putsEmpty(key, isEmpty, false); - } - /** - * @param key - * @param isEmpty - * @return {@link #puts(String, Object)} - */ - public JSONObject putsEmpty(String key, boolean isEmpty, boolean trim) { - return puts(key+"{}", SQL.isEmpty(key, isEmpty, trim)); - } - /** - * @param key - * @param compare <=0, >5 ... - * @return {@link #puts(String, Object)} - */ - public JSONObject putsLength(String key, String compare) { - return puts(key+"{}", SQL.length(key) + compare); - } - - /**设置搜索 - * type = SEARCH_TYPE_CONTAIN_FULL - * @param key - * @param value - * @return {@link #putsSearch(String, String, int)} - */ - public JSONObject putsSearch(String key, String value) { - return putsSearch(key, value, SQL.SEARCH_TYPE_CONTAIN_FULL); - } - /**设置搜索 - * @param key - * @param value - * @param type - * @return {@link #puts(String, Object)} - */ - public JSONObject putsSearch(String key, String value, int type) { - return puts(key+"$", SQL.search(value, type)); - } - - //Request >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - /**puts key-value in object into this - * @param object - * @return this - */ - public JSONObject putsAll(Map map) { - putAll(map); - return this; - } - @Override - public void putAll(Map map) { - if (map != null && map.isEmpty() == false) { - super.putAll(map); - } - } - - - - /**put and return this - * @param value must be annotated by {@link MethodAccess} - * @return {@link #puts(String, boolean)} - */ - public JSONObject puts(Object value) { - return puts(null, value); - } - /**put and return this - * @param key - * @param value - * @return this - * @see {@link #put(String, Object)} - */ - public JSONObject puts(String key, Object value) { - put(key, value); - return this; - } - - /**put and return value - * @param value must be annotated by {@link MethodAccess} - * @return {@link #put(String, boolean)} - */ - public Object put(Object value) { - return put(null, value); - } - /**put and return value - * @param key StringUtil.isEmpty(key, true) ? key = value.getClass().getSimpleName(); - * @param value - * @return value - */ - @Override - public Object put(String key, Object value) { - if (value == null) { - Log.e(TAG, "put value == null >> return null;"); - return null; - } - if (StringUtil.isEmpty(key, true)) { - Class clazz = value.getClass(); - if (clazz == null || clazz.getAnnotation(MethodAccess.class) == null) { - throw new IllegalArgumentException("puts StringUtil.isNotEmpty(key, true) == false" + - " && clazz == null || clazz.getAnnotation(MethodAccess.class) == null" + - " \n key为空时仅支持 类型被@MethodAccess注解 的value !!!" + - " \n 如果一定要这么用,请对 " + clazz.getName() + " 注解!" + - " \n 如果是类似 key[]:{} 结构的请求,建议用 putsAll(...) !"); - } - key = value.getClass().getSimpleName(); - } - return super.put(key, value); - } - - - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSONRequest.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSONRequest.java deleted file mode 100644 index 51d064731..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSONRequest.java +++ /dev/null @@ -1,147 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import java.util.Map; - -/**wrapper for request - * @author Lemon - * @see #puts - * @see #toArray - * @use JSONRequest request = new JSONRequest(...); - *
request.puts(...);//not a must - *
request.toArray(...);//not a must - */ -public class JSONRequest extends JSONObject { - private static final long serialVersionUID = 1L; - - public JSONRequest() { - super(); - } - /** - * @param object must be annotated by {@link MethodAccess} - * @see {@link #JSONRequest(String, Object)} - */ - public JSONRequest(Object object) { - this(null, object); - } - /** - * @param name - * @param object - * @see {@link #puts(String, Object)} - */ - public JSONRequest(String name, Object object) { - this(); - puts(name, object); - } - - - - - public static final String KEY_TAG = "tag";//只在最外层,最外层用JSONRequest - public static final String KEY_VERSION = "version";//只在最外层,最外层用JSONRequest - - /**set "tag":tag in outermost layer - * for write operations - * @param tag - * @return - */ - public JSONRequest setTag(String tag) { - return puts(KEY_TAG, tag); - } - /**set "version":version in outermost layer - * for target version of request - * @param version - * @return - */ - public JSONRequest setVersion(String version) { - return puts(KEY_VERSION, version); - } - - - //array object <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - public static final int QUERY_TABLE = 0; - public static final int QUERY_TOTAL = 1; - public static final int QUERY_ALL = 2; - - public static final String KEY_QUERY = "query"; - public static final String KEY_COUNT = "count"; - public static final String KEY_PAGE = "page"; - - /**set what to query in Array layer - * @param query what need to query, Table,total,ALL? - * @return - * @see {@link #QUERY_TABLE} - * @see {@link #QUERY_TOTAL} - * @see {@link #QUERY_ALL} - */ - public JSONRequest setQuery(int query) { - return puts(KEY_QUERY, query); - } - /**set maximum count of Tables to query in Array layer - * @param count <= 0 || >= max ? max : count - * @return - */ - public JSONRequest setCount(int count) { - return puts(KEY_COUNT, count); - } - /**set page of Tables to query in Array layer - * @param page <= 0 ? 0 : page - * @return - */ - public JSONRequest setPage(int page) { - return puts(KEY_PAGE, page); - } - //array object >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - /**create a parent JSONObject named KEY_ARRAY - * @param count - * @param page - * @return {@link #toArray(int, int, boolean)} - */ - public JSONRequest toArray(int count, int page) { - return toArray(count, page, null); - } - /**create a parent JSONObject named name+KEY_ARRAY. - * @param count - * @param page - * @param name - * @return {name+KEY_ARRAY : this}. if needs to be put, use {@link #add(com.alibaba.fastjson.JSONObject)} instead - */ - public JSONRequest toArray(int count, int page, String name) { - return new JSONRequest(StringUtil.getString(name) + KEY_ARRAY, this.setCount(count).setPage(page)); - } - - - @Override - public JSONObject putsAll(Map map) { - super.putsAll(map); - return this; - } - - @Override - public JSONRequest puts(Object value) { - return puts(null, value); - } - @Override - public JSONRequest puts(String key, Object value) { - super.puts(key, value); - return this; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSONResponse.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSONResponse.java deleted file mode 100644 index f9b6d3fc9..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/JSONResponse.java +++ /dev/null @@ -1,400 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import java.util.List; -import java.util.Set; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/**parser for response - * @author Lemon - * @see #getObject - * @see #getList - * @use JSONResponse response = new JSONResponse(json); - *
User user = response.getObject(User.class);//not a must - *
List commenntList = response.getList("Comment[]", Comment.class);//not a must - */ -public class JSONResponse extends zuo.biao.apijson.JSONObject { - private static final long serialVersionUID = 1L; - - private static final String TAG = "JSONResponse"; - - public JSONResponse() { - super(); - } - public JSONResponse(String json) { - this(parseObject(json)); - } - public JSONResponse(JSONObject object) { - super(format(object)); - } - - //状态信息,非GET请求获得的信息<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - public static final int CODE_SUCCESS = 200; //成功 - public static final int CODE_UNSUPPORTED_ENCODING = 400; //编码错误 - public static final int CODE_ILLEGAL_ACCESS = 401; //权限错误 - public static final int CODE_UNSUPPORTED_OPERATION = 403; //禁止操作 - public static final int CODE_NOT_FOUND = 404; //未找到 - public static final int CODE_ILLEGAL_ARGUMENT = 406; //参数错误 - public static final int CODE_NOT_LOGGED_IN = 407; //未登录 - public static final int CODE_TIME_OUT = 408; //超时 - public static final int CODE_CONFLICT = 409; //重复,已存在 - public static final int CODE_CONDITION_ERROR = 412; //条件错误,如密码错误 - public static final int CODE_UNSUPPORTED_TYPE = 415; //类型错误 - public static final int CODE_OUT_OF_RANGE = 416; //超出范围 - public static final int CODE_NULL_POINTER = 417; //对象为空 - public static final int CODE_SERVER_ERROR = 500; //服务器内部错误 - - - public static final String MSG_SUCCEED = "success"; //成功 - public static final String MSG_SERVER_ERROR = "Internal Server Error!"; //服务器内部错误 - - - public static final String KEY_CODE = "code"; - public static final String KEY_MSG = "msg"; - public static final String KEY_ID = "id"; - public static final String KEY_ID_IN = KEY_ID + "{}"; - public static final String KEY_COUNT = "count"; - public static final String KEY_TOTAL = "total"; - - /**获取状态 - * @return - */ - public int getCode() { - try { - return getIntValue(KEY_CODE); - } catch (Exception e) { - //empty - } - return 0; - } - /**获取信息 - * @return - */ - public String getMsg() { - return getString(KEY_MSG); - } - /**获取id - * @return - */ - public long getId() { - try { - return getLongValue(KEY_ID); - } catch (Exception e) { - //empty - } - return 0; - } - /**获取数量 - * @return - */ - public int getCount() { - try { - return getIntValue(KEY_COUNT); - } catch (Exception e) { - //empty - } - return 0; - } - /**获取总数 - * @return - */ - public int getTotal() { - try { - return getIntValue(KEY_TOTAL); - } catch (Exception e) { - //empty - } - return 0; - } - - - /**是否成功 - * @return - */ - public boolean isSuccess() { - return isSuccess(getCode()); - } - /**是否成功 - * @param code - * @return - */ - public static boolean isSuccess(int code) { - return code == CODE_SUCCESS; - } - /**是否成功 - * @param response - * @return - */ - public static boolean isSuccess(JSONResponse response) { - return response != null && response.isSuccess(); - } - - /**校验服务端是否存在table - * @return - */ - public boolean isExist() { - return isExist(getCount()); - } - /**校验服务端是否存在table - * @param count - * @return - */ - public static boolean isExist(int count) { - return count > 0; - } - /**校验服务端是否存在table - * @param response - * @return - */ - public static boolean isExist(JSONResponse response) { - return response != null && response.isExist(); - } - - /**获取内部的JSONResponse - * @param key - * @return - */ - public JSONResponse getJSONResponse(String key) { - return getObject(key, JSONResponse.class); - } - //状态信息,非GET请求获得的信息>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - - - /** - * key = clazz.getSimpleName() - * @param clazz - * @return - */ - public T getObject(Class clazz) { - return getObject(clazz == null ? "" : clazz.getSimpleName(), clazz); - } - /** - * @param key - * @param clazz - * @return - */ - public T getObject(String key, Class clazz) { - return getObject(this, key, clazz); - } - /** - * @param object - * @param key - * @param clazz - * @return - */ - public static T getObject(JSONObject object, String key, Class clazz) { - return toObject(object == null ? null : object.getJSONObject(key), clazz); - } - - /** - * @param clazz - * @return - */ - public T toObject(Class clazz) { - return toObject(this, clazz); - } - /** - * @param object - * @param clazz - * @return - */ - public static T toObject(JSONObject object, Class clazz) { - return JSON.parseObject(JSON.toJSONString(object), clazz); - } - - - - - /** - * key = KEY_ARRAY - * @param clazz - * @return - */ - public List getList(Class clazz) { - return getList(KEY_ARRAY, clazz); - } - /** - * arrayObject = this - * @param key - * @param clazz - * @return - */ - public List getList(String key, Class clazz) { - return getList(this, key, clazz); - } - - /** - * key = KEY_ARRAY - * @param object - * @param clazz - * @return - */ - public static List getList(JSONObject object, Class clazz) { - return getList(object, KEY_ARRAY, clazz); - } - /** - * @param object - * @param key - * @param clazz - * @return - */ - public static List getList(JSONObject object, String key, Class clazz) { - return object == null ? null : JSON.parseArray(object.getString(replaceArray(key)), clazz); - } - - /** - * key = KEY_ARRAY - * @return - */ - public JSONArray getArray() { - return getArray(KEY_ARRAY); - } - /** - * @param key - * @return - */ - public JSONArray getArray(String key) { - return getArray(this, key); - } - /** - * @param object - * @return - */ - public static JSONArray getArray(JSONObject object) { - return getArray(object, KEY_ARRAY); - } - /** - * key = KEY_ARRAY - * @param object - * @param key - * @return - */ - public static JSONArray getArray(JSONObject object, String key) { - return object == null ? null : object.getJSONArray(replaceArray(key)); - } - - - // /** - // * @return - // */ - // public JSONObject format() { - // return format(this); - // } - /**格式化key名称 - * @param object - * @return - */ - public static JSONObject format(final JSONObject object) { - //太长查看不方便,不如debug Log.i(TAG, "format object = \n" + JSON.toJSONString(object)); - if (object == null || object.isEmpty()) { - Log.i(TAG, "format object == null || object.isEmpty() >> return object;"); - return object; - } - JSONObject formatedObject = new JSONObject(true); - - Set set = object.keySet(); - if (set != null) { - - Object value; - for (String key : set) { - value = object.get(key); - - if (value instanceof JSONArray) {//JSONArray,遍历来format内部项 - formatedObject.put(replaceArray(key), format((JSONArray) value)); - } - else if (value instanceof JSONObject) {//JSONObject,往下一级提取 - formatedObject.put(getSimpleName(key), format((JSONObject) value)); - } - else {//其它Object,直接填充 - formatedObject.put(getSimpleName(key), value); - } - } - } - - //太长查看不方便,不如debug Log.i(TAG, "format return formatedObject = " + JSON.toJSONString(formatedObject)); - return formatedObject; - } - - /**格式化key名称 - * @param array - * @return - */ - public static JSONArray format(final JSONArray array) { - //太长查看不方便,不如debug Log.i(TAG, "format array = \n" + JSON.toJSONString(array)); - if (array == null || array.isEmpty()) { - Log.i(TAG, "format array == null || array.isEmpty() >> return array;"); - return array; - } - JSONArray formatedArray = new JSONArray(); - - Object value; - for (int i = 0; i < array.size(); i++) { - value = array.get(i); - if (value instanceof JSONArray) {//JSONArray,遍历来format内部项 - formatedArray.add(format((JSONArray) value)); - } - else if (value instanceof JSONObject) {//JSONObject,往下一级提取 - formatedArray.add(format((JSONObject) value)); - } - else {//其它Object,直接填充 - formatedArray.add(value); - } - } - - //太长查看不方便,不如debug Log.i(TAG, "format return formatedArray = " + JSON.toJSONString(formatedArray)); - return formatedArray; - } - - /**替换key+KEY_ARRAY为keyList - * @param key - * @return getSimpleName(isArrayKey(key) ? getArrayKey(...) : key) {@link #getSimpleName(String)} - */ - public static String replaceArray(String key) { - if (isArrayKey(key)) { - key = getArrayKey(key.substring(0, key.lastIndexOf(KEY_ARRAY))); - } - return getSimpleName(key); - } - /**获取列表变量名 - * @param key => StringUtil.getNoBlankString(key) - * @return empty ? "list" : key + "List" 且首字母小写 - */ - public static String getArrayKey(String key) { - return StringUtil.addSuffix(key, "list"); - } - - /**获取简单名称 - * @param fullName name 或 name:alias - * @return name => name; name:alias => alias - */ - public static String getSimpleName(String fullName) { - //key:alias -> alias; key:alias[] -> alias[] - int index = fullName == null ? -1 : fullName.indexOf(":"); - if (index >= 0) { - fullName = fullName.substring(index + 1); - } - return fullName; - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/Log.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/Log.java deleted file mode 100644 index 4d58c621c..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/Log.java +++ /dev/null @@ -1,74 +0,0 @@ -/*Copyright ©2015 TommyLemon(https://github.com/TommyLemon) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -/**测试用Log - * @modifier Lemon - */ -public class Log { - - private static final boolean DEBUG = true; - - /** - * @param TAG - * @param msg - */ - public static void d(String TAG, String msg) { - if (DEBUG) { - System.err.println(TAG + ".DEBUG: " + msg); - } - } - - /** - * @param TAG - * @param msg - */ - public static void v(String TAG, String msg) { - if (DEBUG) { - System.out.println(TAG + ".VERBOSE: " + msg); - } - } - - /** - * @param TAG - * @param msg - */ - public static void i(String TAG, String msg) { - if (DEBUG) { - System.out.println(TAG + ".INFO: " + msg); - } - } - - /** - * @param TAG - * @param msg - */ - public static void e(String TAG, String msg) { - if (DEBUG) { - System.err.println(TAG + ".ERROR: " + msg); - } - } - - /** - * @param TAG - * @param msg - */ - public static void w(String TAG, String msg) { - if (DEBUG) { - System.err.println(TAG + ".WARN: " + msg); - } - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/MethodAccess.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/MethodAccess.java deleted file mode 100644 index 939571625..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/MethodAccess.java +++ /dev/null @@ -1,73 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.CIRCLE; -import static zuo.biao.apijson.RequestRole.CONTACT; -import static zuo.biao.apijson.RequestRole.LOGIN; -import static zuo.biao.apijson.RequestRole.OWNER; -import static zuo.biao.apijson.RequestRole.UNKNOWN; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/**请求方法权限,只允许某些角色通过对应方法访问 - * @author Lemon - */ -@Documented -@Retention(RUNTIME) -@Target(TYPE) -public @interface MethodAccess { - - /**@see {@link RequestMethod#GET} - * @return 该请求方法允许的角色 default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - */ - RequestRole[] GET() default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - - /**@see {@link RequestMethod#HEAD} - * @return 该请求方法允许的角色 default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - */ - RequestRole[] HEAD() default {UNKNOWN, LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - - /**@see {@link RequestMethod#GETS} - * @return 该请求方法允许的角色 default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - */ - RequestRole[] GETS() default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - - /**@see {@link RequestMethod#HEADS} - * @return 该请求方法允许的角色 default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - */ - RequestRole[] HEADS() default {LOGIN, CONTACT, CIRCLE, OWNER, ADMIN}; - - /**@see {@link RequestMethod#POST} - * @return 该请求方法允许的角色 default {LOGIN, ADMIN}; - */ - RequestRole[] POST() default {LOGIN, ADMIN}; - - /**@see {@link RequestMethod#PUT} - * @return 该请求方法允许的角色 default {OWNER, ADMIN}; - */ - RequestRole[] PUT() default {OWNER, ADMIN}; - - /**@see {@link RequestMethod#DELETE} - * @return 该请求方法允许的角色 default {OWNER, ADMIN}; - */ - RequestRole[] DELETE() default {OWNER, ADMIN}; - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/MethodStructure.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/MethodStructure.java deleted file mode 100644 index 27c30c96d..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/MethodStructure.java +++ /dev/null @@ -1,58 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Documented; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/**对应方法的请求结构。 - * 仅测试和基本的校验用,实际用Request表里的配置 - * @author Lemon - */ -@Documented -@Retention(RUNTIME) -@Target(TYPE) -public @interface MethodStructure { - - /**@see {@link RequestMethod#HEADS} - * @return 该请求方法允许的结构 - */ - String HEADS() default ""; - - /**@see {@link RequestMethod#GETS} - * @return 该请求方法允许的结构 - */ - String GETS() default ""; - - /**@see {@link RequestMethod#POST} - * @return 该请求方法允许的结构 - */ - String POST() default ""; - - /**@see {@link RequestMethod#PUT} - * @return 该请求方法允许的结构 - */ - String PUT() default ""; - - /**@see {@link RequestMethod#DELETE} - * @return 该请求方法允许的结构 - */ - String DELETE() default ""; - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/RequestMethod.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/RequestMethod.java deleted file mode 100644 index a450baad8..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/RequestMethod.java +++ /dev/null @@ -1,94 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -/**请求方法,对应org.springframework.web.bind.annotation.RequestMethod,多出GETS,HEADS方法 - * @author Lemon - */ -public enum RequestMethod { - - /** - * 常规获取数据方式 - */ - GET, - - /** - * 检查,默认是非空检查,返回数据总数 - */ - HEAD, - - /**Safe, Single, Simple - *
限制性GET,通过POST来GET数据,不显示请求内容和返回结果,并且校验请求,一般用于对安全要求比较高的请求 - */ - GETS, - - /**Safe, Single, Simple - *
限制性HEAD,通过POST来HEAD数据,不显示请求内容和返回结果,并且校验请求,一般用于对安全要求比较高的请求 - */ - HEADS, - - /** - * 新增(或者说插入)数据 - */ - POST, - - /** - * 修改数据,只修改传入字段对应的值 - */ - PUT, - - /** - * 删除数据 - */ - DELETE; - - - /**是否为GET请求方法 - * @param method - * @param containPrivate 包含私密(非明文)获取方法GETS - * @return - */ - public static boolean isGetMethod(RequestMethod method, boolean containPrivate) { - boolean is = method == null || method == GET; - return containPrivate == false ? is : is || method == GETS; - } - - /**是否为HEAD请求方法 - * @param method - * @param containPrivate 包含私密(非明文)获取方法HEADS - * @return - */ - public static boolean isHeadMethod(RequestMethod method, boolean containPrivate) { - boolean is = method == HEAD; - return containPrivate == false ? is : is || method == HEADS; - } - - /**是否为查询的请求方法 - * @param method - * @return 读操作(GET型或HEAD型) - true, 写操作(POST,PUT,DELETE) - false - */ - public static boolean isQueryMethod(RequestMethod method) { - return isGetMethod(method, true) || isHeadMethod(method, true); - } - - /**是否为开放(不限制请求的结构或内容;明文,浏览器能直接访问及查看)的请求方法 - * @param method - * @return - */ - public static boolean isPublicMethod(RequestMethod method) { - return method == null || method == GET || method == HEAD; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/RequestRole.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/RequestRole.java deleted file mode 100644 index f3a777d67..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/RequestRole.java +++ /dev/null @@ -1,63 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -/**来访的用户角色 - * @author Lemon - */ -public enum RequestRole { - - /**未登录,不明身份的用户 - */ - UNKNOWN, - - /**已登录的用户 - */ - LOGIN, - - /**联系人,必须已登录 - */ - CONTACT, - - /**圈子成员(CONTACT + OWNER),必须已登录 - */ - CIRCLE, - - /**拥有者,必须已登录 - */ - OWNER, - - /**管理员,必须已登录 - */ - ADMIN; - - //似乎不管怎么做,外部引用后都是空值。并且如果在注解内的位置不是最前的,还会导致被注解的类在其它类中import报错。 - //虽然直接打印显示正常,但被@MethodAccess内RequestRole[] GET()等方法引用后获取的是空值 - // public static final RequestRole[] ALL = {RequestRole.UNKNOWN};//values();//所有 - // public static final RequestRole[] HIGHS;//高级 - // static { - // HIGHS = new RequestRole[] {OWNER, ADMIN}; - // } - - public static RequestRole get(String name) { - try {//Enum.valueOf只要找不到对应的值就会抛异常 - return RequestRole.valueOf(StringUtil.toUpperCase(name)); - } catch (Exception e) { - //empty - } - return null; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/SQL.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/SQL.java deleted file mode 100644 index a9da023e5..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/SQL.java +++ /dev/null @@ -1,389 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -/**SQL语句,函数名尽量和JDK中相同或类似功能的函数的名称一致 - * @author Lemon - */ -public class SQL { - - public static final String OR = " OR "; - public static final String AND = " AND "; - public static final String NOT = " NOT "; - public static final String AS = " AS "; - public static final String IS = " is "; - public static final String NULL = " null "; - - //括号必须紧跟函数名! count (...) 报错! - public static final String COUNT = "count"; - public static final String SUM = "sum"; - public static final String MAX = "max"; - public static final String MIN = "min"; - public static final String AVG = "avg"; - - /** - * isNull = true - * @return {@link #isNull(boolean)} - */ - public static String isNull() { - return isNull(true); - } - /** - * @param isNull - * @return {@link #IS} + (isNull ? "" : {@link #NOT}) + {@link #NULL}; - */ - public static String isNull(boolean isNull) { - return IS + (isNull ? "" : NOT) + NULL; - } - /** - * isNull = true - * @param s - * @return {@link #isNull(String, boolean)} - */ - public static String isNull(String s) { - return isNull(s, true); - } - /** - * @param s - * @param isNull - * @return s + {@link #isNull(boolean)} - */ - public static String isNull(String s, boolean isNull) { - return s + isNull(isNull); - } - - /** - * isEmpty = true - * @param s - * @return {@link #isEmpty(String, boolean)} - */ - public static String isEmpty(String s) { - return isEmpty(s, true); - } - /** - * trim = false - * @param s - * @param isEmpty - * @return {@link #isEmpty(String, boolean, boolean)} - */ - public static String isEmpty(String s, boolean isEmpty) { - return isEmpty(s, isEmpty, false); - } - /** - * nullable = true - * @param s - * @param isEmpty <=0 - * @param trim s = trim(s); - * @return {@link #isEmpty(String, boolean, boolean, boolean)} - */ - public static String isEmpty(String s, boolean isEmpty, boolean trim) { - return isEmpty(s, isEmpty, trim, true); - } - /** - * @param s - * @param isEmpty <=0 - * @param trim s = trim(s); - * @param nullable isNull(s, true) + {@link #OR} + - * @return {@link #lengthCompare(String, String)} - */ - public static String isEmpty(String s, boolean isEmpty, boolean trim, boolean nullable) { - if (trim) { - s = trim(s); - } - return (nullable ? isNull(s, true) + OR : "") + lengthCompare(s, (isEmpty ? "<=" : ">") + "0"); - } - /** - * @param s 因为POWER(x,y)等函数含有不只一个key,所以需要客户端添加进去,服务端检测到条件中有'('和')'时就不转换,直接当SQL语句查询 - * @return {@link #length(String)} + compare - */ - public static String lengthCompare(String s, String compare) { - return length(s) + compare; - } - - - /** - * @param s 因为POWER(x,y)等函数含有不只一个key,所以需要客户端添加进去,服务端检测到条件中有'('和')'时就不转换,直接当SQL语句查询 - * @return "length(" + s + ")" - */ - public static String length(String s) { - return "length(" + s + ")"; - } - /** - * @param s 因为POWER(x,y)等函数含有不只一个key,所以需要客户端添加进去,服务端检测到条件中有'('和')'时就不转换,直接当SQL语句查询 - * @return "char_length(" + s + ")" - */ - public static String charLength(String s) { - return "char_length(" + s + ")"; - } - - /** - * @param s - * @return "trim(" + s + ")" - */ - public static String trim(String s) { - return "trim(" + s + ")"; - } - /** - * @param s - * @return "ltrim(" + s + ")" - */ - public static String trimLeft(String s) { - return "ltrim(" + s + ")"; - } - /** - * @param s - * @return "rtrim(" + s + ")" - */ - public static String trimRight(String s) { - return "rtrim(" + s + ")"; - } - - /** - * @param s - * @param n - * @return "left(" + s + "," + n + ")" - */ - public static String left(String s, int n) { - return "left(" + s + "," + n + ")"; - } - /** - * @param s - * @param n - * @return "right(" + s + "," + n + ")" - */ - public static String right(String s, int n) { - return "right(" + s + "," + n + ")"; - } - - /** - * @param s - * @param start - * @param end - * @return "substring(" + s + "," + start + "," + (end-start) + ")" - */ - public static String subString(String s, int start, int end) { - return "substring(" + s + "," + start + "," + (end-start) + ")"; - } - - /** - * @param s - * @param c -> 'c' - * @return "instr(" + s + ", '" + c + "')" - */ - public static String indexOf(String s, String c) { - return "instr(" + s + ", '" + c + "')"; - } - - /** - * @param s - * @param c1 -> 'c1' - * @param c2 -> 'c2' - * @return "replace(" + s + ", '" + c1 + "', '" + c2 + "')" - */ - public static String replace(String s, String c1, String c2) { - return "replace(" + s + ", '" + c1 + "', '" + c2 + "')"; - } - - /** - * @param s1 - * @param s2 -> 's2' - * @return "strcmp(" + s1 + ", '" + s2 + "')" - */ - public static String equals(String s1, String s2) { - return "strcmp(" + s1 + ", '" + s2 + "')"; - } - - /** - * @param s - * @return "upper(" + s + ")" - */ - public static String toUpperCase(String s) { - return "upper(" + s + ")"; - } - /** - * @param s - * @return "lower(" + s + ")" - */ - public static String toLowerCase(String s) { - return "lower(" + s + ")"; - } - - - - - //column and function<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**字段 - * @param column - * @return column.isEmpty() ? "*" : column; - */ - public static String column(String column) { - column = StringUtil.getTrimedString(column); - return column.isEmpty() ? "*" : column; - } - /**有别名的字段 - * @param column - * @return {@link #count(String)} + {@link #AS}; - */ - public static String columnAs(String column) { - return count(column) + AS; - } - - /**函数 - * @param column if (StringUtil.isEmpty(column, true) || column.contains(",")) -> column = null; - * @return " " + fun + "(" + {@link #column(String)} + ") "; - */ - public static String function(String fun, String column) { - if (StringUtil.isEmpty(column, true) || column.contains(",")) { - column = null; //解决 count(id,name) 这种多个字段导致的SQL异常 - } - return " " + fun + "(" + column(column) + ") "; - } - /**有别名的函数 - * @param column - * @return {@link #function(String, String)} + {@link #AS} + fun; - */ - public static String functionAs(String fun, String column) { - return function(fun, column) + AS + fun + " "; - } - - /**计数 - * column = null - * @return {@link #count(String)} - */ - public static String count() { - return count(null); - } - /**计数 - * fun = {@link #COUNT} - * @param column - * @return {@link #functionAs(String, String)} - */ - public static String count(String column) { - return functionAs(COUNT, column); - } - /**求和 - * fun = {@link #SUM} - * @param column - * @return {@link #functionAs(String, String)} - */ - public static String sum(String column) { - return functionAs(SUM, column); - } - /**最大值 - * fun = {@link #MAX} - * @param column - * @return {@link #functionAs(String, String)} - */ - public static String max(String column) { - return functionAs(MAX, column); - } - /**最小值 - * fun = {@link #MIN} - * @param column - * @return {@link #functionAs(String, String)} - */ - public static String min(String column) { - return functionAs(MIN, column); - } - /**平均值 - * fun = {@link #AVG} - * @param column - * @return {@link #functionAs(String, String)} - */ - public static String avg(String column) { - return functionAs(AVG, column); - } - - //column and function>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //search<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - public static final int SEARCH_TYPE_CONTAIN_FULL = 0; - public static final int SEARCH_TYPE_CONTAIN_ORDER = 1; - public static final int SEARCH_TYPE_CONTAIN_SINGLE = 2; - public static final int SEARCH_TYPE_CONTAIN_ANY = 3; - public static final int SEARCH_TYPE_START = 4; - public static final int SEARCH_TYPE_END = 5; - public static final int SEARCH_TYPE_START_SINGLE = 6; - public static final int SEARCH_TYPE_END_SINGLE = 7; - public static final int SEARCH_TYPE_PART_MATCH = 8; - /**获取搜索值 - * @param s - * @return - */ - public static String search(String s) { - return search(s, SEARCH_TYPE_CONTAIN_FULL); - } - /**获取搜索值 - * @param s - * @param type - * @return - */ - public static String search(String s, int type) { - return search(s, type, true); - } - /**获取搜索值 - * @param s - * @param type - * @param ignoreCase - * @return default SEARCH_TYPE_CONTAIN_FULL - */ - public static String search(String s, int type, boolean ignoreCase) { - if (s == null) { - return null; - } - switch (type) { - case SEARCH_TYPE_CONTAIN_SINGLE: - return "_" + s + "_"; - case SEARCH_TYPE_CONTAIN_ORDER: - char[] cs = s.toCharArray(); - if (cs == null) { - return null; - } - String value = "%"; - for (int i = 0; i < cs.length; i++) { - value += cs[i] + "%"; - } - return value; - case SEARCH_TYPE_START: - return s + "%"; - case SEARCH_TYPE_END: - return "%" + s; - case SEARCH_TYPE_START_SINGLE: - return s + "_"; - case SEARCH_TYPE_END_SINGLE: - return "_" + s; - case SEARCH_TYPE_CONTAIN_ANY: - case SEARCH_TYPE_PART_MATCH: - cs = s.toCharArray(); - if (cs == null) { - return null; - } - value = ""; - for (int i = 0; i < cs.length; i++) { - value += search("" + cs[i], SEARCH_TYPE_CONTAIN_FULL, ignoreCase); - } - return value; - default://SEARCH_TYPE_CONTAIN_FULL - return "%" + s + "%"; - } - } - - //search>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/StringUtil.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/StringUtil.java deleted file mode 100755 index b219b430a..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/StringUtil.java +++ /dev/null @@ -1,842 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson; - -import java.io.File; -import java.math.BigDecimal; -import java.text.DecimalFormat; -import java.util.regex.Pattern; - -/**通用字符串(String)相关类,为null时返回"" - * @author Lemon - * @use StringUtil. - */ -public class StringUtil { - private static final String TAG = "StringUtil"; - - public StringUtil() { - } - - public static final String UTF_8 = "utf-8"; - - public static final String EMPTY = "无"; - public static final String UNKNOWN = "未知"; - public static final String UNLIMITED = "不限"; - - public static final String I = "我"; - public static final String YOU = "你"; - public static final String HE = "他"; - public static final String SHE = "她"; - public static final String IT = "它"; - - public static final String MALE = "男"; - public static final String FEMALE = "女"; - - public static final String TODO = "未完成"; - public static final String DONE = "已完成"; - - public static final String FAIL = "失败"; - public static final String SUCCESS = "成功"; - - public static final String SUNDAY = "日"; - public static final String MONDAY = "一"; - public static final String TUESDAY = "二"; - public static final String WEDNESDAY = "三"; - public static final String THURSDAY = "四"; - public static final String FRIDAY = "五"; - public static final String SATURDAY = "六"; - - public static final String YUAN = "元"; - - - private static String currentString = ""; - /**获取刚传入处理后的string - * @must 上个影响currentString的方法 和 这个方法都应该在同一线程中,否则返回值可能不对 - * @return - */ - public static String getCurrentString() { - return currentString == null ? "" : currentString; - } - - //获取string,为null时返回"" <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**获取string,为null则返回"" - * @param object - * @return - */ - public static String getString(Object object) { - return object == null ? "" : getString(String.valueOf(object)); - } - /**获取string,为null则返回"" - * @param cs - * @return - */ - public static String getString(CharSequence cs) { - return cs == null ? "" : getString(cs.toString()); - } - /**获取string,为null则返回"" - * @param s - * @return - */ - public static String getString(String s) { - return s == null ? "" : s; - } - /**获取string,为null则返回"" - * ignoreEmptyItem = false; - * split = "," - * @param array - * @return {@link #getString(String[], boolean)} - */ - public static String getString(Object[] array) { - return getString(array, false); - } - /**获取string,为null则返回"" - * split = "," - * @param array - * @param ignoreEmptyItem - * @return {@link #getString(String[], String, boolean)} - */ - public static String getString(Object[] array, boolean ignoreEmptyItem) { - return getString(array, null, ignoreEmptyItem); - } - /**获取string,为null则返回"" - * ignoreEmptyItem = false; - * @param array - * @param split - * @return {@link #getString(String[], String, boolean)} - */ - public static String getString(Object[] array, String split) { - return getString(array, split, false); - } - /**获取string,为null则返回"" - * @param array - * @param split - * @param ignoreEmptyItem - * @return - */ - public static String getString(Object[] array, String split, boolean ignoreEmptyItem) { - String s = ""; - if (array != null) { - if (split == null) { - split = ","; - } - for (int i = 0; i < array.length; i++) { - if (ignoreEmptyItem && isEmpty(array[i], true)) { - continue; - } - s += ((i > 0 ? split : "") + array[i]); - } - } - return getString(s); - } - - //获取string,为null时返回"" >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //获取去掉前后空格后的string<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**获取去掉前后空格后的string,为null则返回"" - * @param object - * @return - */ - public static String getTrimedString(Object object) { - return getTrimedString(getString(object)); - } - /**获取去掉前后空格后的string,为null则返回"" - * @param cs - * @return - */ - public static String getTrimedString(CharSequence cs) { - return getTrimedString(getString(cs)); - } - /**获取去掉前后空格后的string,为null则返回"" - * @param s - * @return - */ - public static String getTrimedString(String s) { - return getString(s).trim(); - } - - //获取去掉前后空格后的string>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取去掉所有空格后的string <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**获取去掉所有空格后的string,为null则返回"" - * @param object - * @return - */ - public static String getNoBlankString(Object object) { - return getNoBlankString(getString(object)); - } - /**获取去掉所有空格后的string,为null则返回"" - * @param cs - * @return - */ - public static String getNoBlankString(CharSequence cs) { - return getNoBlankString(getString(cs)); - } - /**获取去掉所有空格后的string,为null则返回"" - * @param s - * @return - */ - public static String getNoBlankString(String s) { - return getString(s).replaceAll("\\s", ""); - } - - //获取去掉所有空格后的string >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //获取string的长度<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**获取string的长度,为null则返回0 - * @param object - * @param trim - * @return - */ - public static int getLength(Object object, boolean trim) { - return getLength(getString(object), trim); - } - /**获取string的长度,为null则返回0 - * @param cs - * @param trim - * @return - */ - public static int getLength(CharSequence cs, boolean trim) { - return getLength(getString(cs), trim); - } - /**获取string的长度,为null则返回0 - * @param s - * @param trim - * @return - */ - public static int getLength(String s, boolean trim) { - s = trim ? getTrimedString(s) : s; - return getString(s).length(); - } - - //获取string的长度>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //判断字符是否为空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**判断字符是否为空 - * @param object - * @param trim - * @return - */ - public static boolean isEmpty(Object object, boolean trim) { - return isEmpty(getString(object), trim); - } - /**判断字符是否为空 - * @param cs - * @param trim - * @return - */ - public static boolean isEmpty(CharSequence cs, boolean trim) { - return isEmpty(getString(cs), trim); - } - /**判断字符是否为空 - * @param s - * @param trim - * @return - */ - public static boolean isEmpty(String s, boolean trim) { - // Log.i(TAG, "getTrimedString s = " + s); - if (s == null) { - return true; - } - if (trim) { - s = s.trim(); - } - if (s.isEmpty()) { - return true; - } - - currentString = s; - - return false; - } - - //判断字符是否为空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //判断字符是否非空 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**判断字符是否非空 - * @param object - * @param trim - * @return - */ - public static boolean isNotEmpty(Object object, boolean trim) { - return isNotEmpty(getString(object), trim); - } - /**判断字符是否非空 - * @param cs - * @param trim - * @return - */ - public static boolean isNotEmpty(CharSequence cs, boolean trim) { - return isNotEmpty(getString(cs), trim); - } - /**判断字符是否非空 - * @param s - * @param trim - * @return - */ - public static boolean isNotEmpty(String s, boolean trim) { - return ! isEmpty(s, trim); - } - - //判断字符是否非空 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //判断字符类型 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - public static final Pattern PATTERN_NUMBER; - public static final Pattern PATTERN_PHONE; - public static final Pattern PATTERN_EMAIL; - public static final Pattern PATTERN_ID_CARD; - public static final Pattern PATTERN_ALPHA; - public static final Pattern PATTERN_PASSWORD; //TODO - public static final Pattern PATTERN_NAME; - public static final Pattern PATTERN_ALPHA_BIG; - public static final Pattern PATTERN_ALPHA_SMALL; - static { - PATTERN_NUMBER = Pattern.compile("^[0-9]+$"); - PATTERN_ALPHA = Pattern.compile("^[a-zA-Z]+$"); - PATTERN_ALPHA_BIG = Pattern.compile("^[A-Z]+$"); - PATTERN_ALPHA_SMALL = Pattern.compile("^[a-z]+$"); - PATTERN_NAME = Pattern.compile("^[0-9a-zA-Z_]+$");//已用55个中英字符测试通过 - PATTERN_PHONE = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(18[0-2,5-9])|(17[0-9]))\\d{8}$"); - PATTERN_EMAIL = Pattern.compile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$"); - PATTERN_ID_CARD = Pattern.compile("(^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{2}$)"); - PATTERN_PASSWORD = Pattern.compile("^[0-9a-zA-Z]+$"); - } - - /**判断手机格式是否正确 - * @param phone - * @return - */ - public static boolean isPhone(String phone) { - if (isNotEmpty(phone, true) == false) { - return false; - } - - currentString = phone; - return PATTERN_PHONE.matcher(phone).matches(); - } - /**判断手机格式是否正确 - * @param s - * @return - */ - public static boolean isPassword(String s) { - return getLength(s, false) >= 6 && PATTERN_PASSWORD.matcher(s).matches(); - } - /**判断是否全是数字密码 - * @param s - * @return - */ - public static boolean isNumberPassword(String s) { - return getLength(s, false) == 6 && isNumer(s); - } - /**判断email格式是否正确 - * @param email - * @return - */ - public static boolean isEmail(String email) { - if (isNotEmpty(email, true) == false) { - return false; - } - - currentString = email; - return PATTERN_EMAIL.matcher(email).matches(); - } - - - /**判断是否全是验证码 - * @param s - * @return - */ - public static boolean isVerify(String s) { - return getLength(s, false) >= 4 && isNumer(s); - } - /**判断是否全是数字 - * @param s - * @return - */ - public static boolean isNumer(String s) { - if (isNotEmpty(s, true) == false) { - return false; - } - - currentString = s; - return PATTERN_NUMBER.matcher(s).matches(); - } - /**判断是否全是字母 - * @param s - * @return - */ - public static boolean isAlpha(String s) { - if (isEmpty(s, true)) { - return false; - } - - currentString = s; - return PATTERN_ALPHA.matcher(s).matches(); - } - /**判断是否全是数字或字母 - * @param s - * @return - */ - public static boolean isNumberOrAlpha(String s) { - return isNumer(s) || isAlpha(s); - } - - /**判断是否为代码名称,只能包含字母,数字或下划线 - * @param s - * @return - */ - public static boolean isName(String s) { - return s != null && PATTERN_NAME.matcher(s).matches(); - } - /**判断是否为首字母大写的代码名称 - * @param key - * @return - */ - public static boolean isBigName(String s) { - s = getString(s); - if (s.isEmpty() || PATTERN_ALPHA_BIG.matcher(s.substring(0, 1)).matches() == false) { - return false; - } - return s.length() <= 1 ? true : isName(s.substring(1)); - } - /**判断是否为首字母小写的代码名称 - * @param key - * @return - */ - public static boolean isSmallName(String s) { - s = getString(s); - if (s.isEmpty() || PATTERN_ALPHA_SMALL.matcher(s.substring(0, 1)).matches() == false) { - return false; - } - return s.length() <= 1 ? true : isName(s.substring(1)); - } - - - /**判断字符类型是否是身份证号 - * @param number - * @return - */ - public static boolean isIDCard(String number) { - if (isNumberOrAlpha(number) == false) { - return false; - } - number = getString(number); - if (number.length() == 15) { - Log.i(TAG, "isIDCard number.length() == 15 old IDCard"); - currentString = number; - return true; - } - if (number.length() == 18) { - currentString = number; - return true; - } - - return false; - } - - public static final String HTTP = "http"; - public static final String URL_PREFIX = "http://"; - public static final String URL_PREFIXs = "https://"; - public static final String URL_STAFFIX = URL_PREFIX; - public static final String URL_STAFFIXs = URL_PREFIXs; - /**判断字符类型是否是网址 - * @param url - * @return - */ - public static boolean isUrl(String url) { - if (isNotEmpty(url, true) == false) { - return false; - } else if (! url.startsWith(URL_PREFIX) && ! url.startsWith(URL_PREFIXs)) { - return false; - } - - currentString = url; - return true; - } - - public static final String FILE_PATH_PREFIX = "file://"; - /**判断文件路径是否存在 - * @param path - * @return - */ - public static boolean isFilePathExist(String path) { - return StringUtil.isFilePath(path) && new File(path).exists(); - } - - public static final String SEPARATOR = "/"; - /**判断是否为路径 - * @param path - * @return - */ - public static boolean isPath(String path) { - return StringUtil.isNotEmpty(path, true) && path.contains(SEPARATOR) - && path.contains(SEPARATOR + SEPARATOR) == false && path.endsWith(SEPARATOR) == false; - } - - /**判断字符类型是否是路径 - * @param path - * @return - */ - public static boolean isFilePath(String path) { - if (isNotEmpty(path, true) == false) { - return false; - } - - if (! path.contains(".") || path.endsWith(".")) { - return false; - } - - currentString = path; - - return true; - } - - //判断字符类型 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //提取特殊字符<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**去掉string内所有非数字类型字符 - * @param object - * @return - */ - public static String getNumber(Object object) { - return getNumber(getString(object)); - } - /**去掉string内所有非数字类型字符 - * @param cs - * @return - */ - public static String getNumber(CharSequence cs) { - return getNumber(getString(cs)); - } - /**去掉string内所有非数字类型字符 - * @param s - * @return - */ - public static String getNumber(String s) { - return getNumber(s, false); - } - /**去掉string内所有非数字类型字符 - * @param s - * @param onlyStart 中间有非数字时只获取前面的数字 - * @return - */ - public static String getNumber(String s, boolean onlyStart) { - if (isNotEmpty(s, true) == false) { - return ""; - } - - String numberString = ""; - String single; - for (int i = 0; i < s.length(); i++) { - single = s.substring(i, i + 1); - if (isNumer(single)) { - numberString += single; - } else { - if (onlyStart) { - return numberString; - } - } - } - - return numberString; - } - - //提取特殊字符>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //校正(自动补全等)字符串<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**获取网址,自动补全 - * @param url - * @return - */ - public static String getCorrectUrl(String url) { - Log.i(TAG, "getCorrectUrl : \n" + url); - if (isNotEmpty(url, true) == false) { - return ""; - } - - // if (! url.endsWith("/") && ! url.endsWith(".html")) { - // url = url + "/"; - // } - - if (isUrl(url) == false) { - return URL_PREFIX + url; - } - return url; - } - - /**获取去掉所有 空格 、"-" 、"+86" 后的phone - * @param phone - * @return - */ - public static String getCorrectPhone(String phone) { - if (isNotEmpty(phone, true) == false) { - return ""; - } - - phone = getNoBlankString(phone); - phone = phone.replaceAll("-", ""); - if (phone.startsWith("+86")) { - phone = phone.substring(3); - } - return phone; - } - - - /**获取邮箱,自动补全 - * @param email - * @return - */ - public static String getCorrectEmail(String email) { - if (isNotEmpty(email, true) == false) { - return ""; - } - - email = getNoBlankString(email); - if (isEmail(email) == false && ! email.endsWith(".com")) { - email += ".com"; - } - - return email; - } - - - public static final int PRICE_FORMAT_DEFAULT = 0; - public static final int PRICE_FORMAT_PREFIX = 1; - public static final int PRICE_FORMAT_SUFFIX = 2; - public static final int PRICE_FORMAT_PREFIX_WITH_BLANK = 3; - public static final int PRICE_FORMAT_SUFFIX_WITH_BLANK = 4; - public static final String[] PRICE_FORMATS = { - "", "¥", "元", "¥ ", " 元" - }; - - /**获取价格,保留两位小数 - * @param price - * @return - */ - public static String getPrice(String price) { - return getPrice(price, PRICE_FORMAT_DEFAULT); - } - /**获取价格,保留两位小数 - * @param price - * @param formatType 添加单位(元) - * @return - */ - public static String getPrice(String price, int formatType) { - if (isNotEmpty(price, true) == false) { - return getPrice(0, formatType); - } - - //单独写到getCorrectPrice? <<<<<<<<<<<<<<<<<<<<<< - String correctPrice = ""; - String s; - for (int i = 0; i < price.length(); i++) { - s = price.substring(i, i + 1); - if (".".equals(s) || isNumer(s)) { - correctPrice += s; - } - } - //单独写到getCorrectPrice? >>>>>>>>>>>>>>>>>>>>>> - - Log.i(TAG, "getPrice <<<<<<<<<<<<<<<<<< correctPrice = " + correctPrice); - if (correctPrice.contains(".")) { - // if (correctPrice.startsWith(".")) { - // correctPrice = 0 + correctPrice; - // } - if (correctPrice.endsWith(".")) { - correctPrice = correctPrice.replaceAll(".", ""); - } - } - - Log.i(TAG, "getPrice correctPrice = " + correctPrice + " >>>>>>>>>>>>>>>>"); - return isNotEmpty(correctPrice, true) ? getPrice(new BigDecimal(0 + correctPrice), formatType) : getPrice(0, formatType); - } - /**获取价格,保留两位小数 - * @param price - * @return - */ - public static String getPrice(BigDecimal price) { - return getPrice(price, PRICE_FORMAT_DEFAULT); - } - /**获取价格,保留两位小数 - * @param price - * @return - */ - public static String getPrice(double price) { - return getPrice(price, PRICE_FORMAT_DEFAULT); - } - /**获取价格,保留两位小数 - * @param price - * @param formatType 添加单位(元) - * @return - */ - public static String getPrice(BigDecimal price, int formatType) { - return getPrice(price == null ? 0 : price.doubleValue(), formatType); - } - /**获取价格,保留两位小数 - * @param price - * @param formatType 添加单位(元) - * @return - */ - public static String getPrice(double price, int formatType) { - String s = new DecimalFormat("#########0.00").format(price); - switch (formatType) { - case PRICE_FORMAT_PREFIX: - return PRICE_FORMATS[PRICE_FORMAT_PREFIX] + s; - case PRICE_FORMAT_SUFFIX: - return s + PRICE_FORMATS[PRICE_FORMAT_SUFFIX]; - case PRICE_FORMAT_PREFIX_WITH_BLANK: - return PRICE_FORMATS[PRICE_FORMAT_PREFIX_WITH_BLANK] + s; - case PRICE_FORMAT_SUFFIX_WITH_BLANK: - return s + PRICE_FORMATS[PRICE_FORMAT_SUFFIX_WITH_BLANK]; - default: - return s; - } - } - - - /**分割路径 - * @param path - * @return - */ - public static String[] splitPath(String path) { - if (StringUtil.isNotEmpty(path, true) == false) { - return null; - } - return isPath(path) ? split(path, SEPARATOR) : new String[] {path}; - } - /**将s分割成String[] - * @param s - * @return - */ - public static String[] split(String s) { - return split(s, null); - } - /**将s用split分割成String[] - * trim = true; - * @param s - * @param split - * @return - */ - public static String[] split(String s, String split) { - return split(s, split, true); - } - /**将s用split分割成String[] - * @param s - * @param split - * @param trim 去掉前后两端的split - * @return - */ - public static String[] split(String s, String split, boolean trim) { - s = getString(s); - if (s.isEmpty()) { - return null; - } - if (isNotEmpty(split, false) == false) { - split = ","; - } - if (trim) { - while (s.startsWith(split)) { - s = s.substring(split.length()); - } - while (s.endsWith(split)) { - s = s.substring(0, s.length() - split.length()); - } - } - return s.contains(split) ? s.split(split) : new String[]{s}; - } - - /** - * @param key - * @param suffix - * @return key + suffix,第一个字母小写 - */ - public static String addSuffix(String key, String suffix) { - key = getNoBlankString(key); - if (key.isEmpty()) { - return firstCase(suffix); - } - return firstCase(key) + firstCase(suffix, true); - } - /** - * @param key - */ - public static String firstCase(String key) { - return firstCase(key, false); - } - /** - * @param key - * @param upper - * @return - */ - public static String firstCase(String key, boolean upper) { - key = getString(key); - if (key.isEmpty()) { - return ""; - } - - String first = key.substring(0, 1); - key = (upper ? first.toUpperCase() : first.toLowerCase()) + key.substring(1, key.length()); - - return key; - } - - /**全部大写 - * @param s - * @return - */ - public static String toUpperCase(String s) { - return toUpperCase(s, false); - } - /**全部大写 - * @param s - * @param trim - * @return - */ - public static String toUpperCase(String s, boolean trim) { - s = trim ? getTrimedString(s) : getString(s); - return s.toUpperCase(); - } - /**全部小写 - * @param s - * @return - */ - public static String toLowerCase(String s) { - return toLowerCase(s, false); - } - /**全部小写 - * @param s - * @return - */ - public static String toLowerCase(String s, boolean trim) { - s = trim ? getTrimedString(s) : getString(s); - return s.toLowerCase(); - } - - //校正(自动补全等)字符串>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Column.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Column.java deleted file mode 100644 index 7e48716b4..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Column.java +++ /dev/null @@ -1,30 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.model; - -import zuo.biao.apijson.MethodAccess; - -/**字段(列名) - * @author Lemon - */ -@MethodAccess( - POST = {}, - PUT = {}, - DELETE = {} - ) -public class Column { - public static final String TAG = "`columns`"; - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Document.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Document.java deleted file mode 100644 index 6846dc847..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Document.java +++ /dev/null @@ -1,30 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.model; - -import static zuo.biao.apijson.RequestRole.ADMIN; -import static zuo.biao.apijson.RequestRole.LOGIN; - -import zuo.biao.apijson.MethodAccess; - -/**测试用例文档类 - * @author Lemon - */ -@MethodAccess( - GET = {LOGIN, ADMIN}, - HEAD = {LOGIN, ADMIN} - ) -public class Document { -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Request.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Request.java deleted file mode 100644 index 09a6d4254..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Request.java +++ /dev/null @@ -1,28 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.model; - -import zuo.biao.apijson.MethodAccess; - -/**请求类 - * @author Lemon - */ -@MethodAccess( - POST = {}, - PUT = {}, - DELETE = {} - ) -public class Request { -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Response.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Response.java deleted file mode 100644 index e46dc8479..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Response.java +++ /dev/null @@ -1,28 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.model; - -import zuo.biao.apijson.MethodAccess; - -/**结果类 - * @author Lemon - */ -@MethodAccess( - POST = {}, - PUT = {}, - DELETE = {} - ) -public class Response { -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Table.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Table.java deleted file mode 100644 index 9346dc805..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Table.java +++ /dev/null @@ -1,30 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.model; - -import zuo.biao.apijson.MethodAccess; - -/**数据库表 - * @author Lemon - */ -@MethodAccess( - POST = {}, - PUT = {}, - DELETE = {} - ) -public class Table { - public static final String TAG = "`tables`"; - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Test.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Test.java deleted file mode 100644 index b090d72a3..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/Test.java +++ /dev/null @@ -1,28 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.model; - -import zuo.biao.apijson.MethodAccess; - -/**输入条件测试类 - * @author Lemon - */ -@MethodAccess( - POST = {}, - PUT = {}, - DELETE = {} - ) -public class Test { -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/package-info.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/package-info.java deleted file mode 100644 index 356cf4e4a..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/model/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * models for special tables - */ -/** - * @author Lemon - * - */ -package zuo.biao.apijson.model; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/package-info.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/package-info.java deleted file mode 100755 index 707b9d11a..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -/** - * the same files for server and client projects - */ -/** - * @author Lemon - * - */ -package zuo.biao.apijson; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Entry.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Entry.java deleted file mode 100644 index 0f6db45ac..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Entry.java +++ /dev/null @@ -1,59 +0,0 @@ -/*Copyright ©2015 TommyLemon(https://github.com/TommyLemon) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -/**自定义Entry - * *java.util.Map.Entry是interface,new Entry(...)不好用,其它的Entry也不好用 - * @author Lemon - * @param key - * @param value - * @use new Entry(...) - * @warn K,V都需要基本类型时不建议使用,判空麻烦,不如新建一个Model - */ -public class Entry { - - public K key; - public V value; - - public Entry() { - //default - } - public Entry(K key) { - this(key, null); - } - public Entry(K key, V value) { - this.key = key; - this.value = value; - } - - - public K getKey() { - return key; - } - public void setKey(K key) { - this.key = key; - } - public V getValue() { - return value; - } - public void setValue(V value) { - this.value = value; - } - - public boolean isEmpty() { - return key == null && value == null; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/JSONRequest.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/JSONRequest.java deleted file mode 100644 index 0a357656c..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/JSONRequest.java +++ /dev/null @@ -1,102 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import java.util.Map; - -import zuo.biao.apijson.JSON; -import zuo.biao.apijson.JSONObject; -import zuo.biao.apijson.StringUtil; - -/**JSONRequest for Server to replace zuo.biao.apijson.JSONRequest, - * put JSON.parseObject(value) and not encode in default cases - * @author Lemon - * @see #put(String, Object, boolean) - */ -public class JSONRequest extends zuo.biao.apijson.JSONRequest { - private static final long serialVersionUID = 1L; - - public JSONRequest() { - super(); - } - /** - * encode = true - * {@link #JSONRequest(String, Object)} - * @param object - */ - public JSONRequest(Object object) { - super(object); - } - /** - * @param name - * @param object - */ - public JSONRequest(String name, Object object) { - super(name, object); - } - - - - @Override - public JSONObject putsAll(Map map) { - super.putsAll(map); - return this; - } - - /** - * @param value - * @return {@link #puts(String, Object)} - */ - @Override - public JSONRequest puts(Object value) { - return puts(null, value); - } - /** - * @param key - * @param value - * @return this - * @see {@link #put(String, Object)} - */ - @Override - public JSONRequest puts(String key, Object value) { - put(key, value); - return this; - } - - /** - * @param value - * @return {@link #put(String, Object)} - */ - @Override - public Object put(Object value) { - return put(null, value); - } - /**自定义类型必须转为JSONObject或JSONArray,否则RequestParser解析不了 - */ - @Override - public Object put(String key, Object value) { - if (value == null) {// || key == null - return null; - } - - com.alibaba.fastjson.JSONObject target = JSON.parseObject(value); - // if (target == null) { // "tag":"User" 报错 - // return null; - // } - return super.put(StringUtil.isNotEmpty(key, true) ? key : value.getClass().getSimpleName() //must handle key here - , target == null ? value : target); - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Logic.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Logic.java deleted file mode 100644 index fc60aaefc..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Logic.java +++ /dev/null @@ -1,145 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import zuo.biao.apijson.StringUtil; - -/**& | !逻辑类 - * @author Lemon - */ -public class Logic { - - public static final int TYPE_OR = 0; - public static final int TYPE_AND = 1; - public static final int TYPE_NOT = 2; - public static final int[] TYPES = {TYPE_OR, TYPE_AND, TYPE_NOT}; - - public static final String CHAR_OR = "|"; - public static final String CHAR_AND = "&"; - public static final String CHAR_NOT = "!"; - public static final String[] CHARS = {CHAR_OR, CHAR_AND, CHAR_NOT}; - - public static final String NAME_OR = "OR"; - public static final String NAME_AND = "AND"; - public static final String NAME_NOT = "NOT"; - public static final String[] NAMES = {NAME_OR, NAME_AND, NAME_NOT}; - - - private int type; - private String key; - - public Logic() { - super(); - } - - public Logic(int type) { - this(); - this.type = type; - } - public Logic(String key) { - key = StringUtil.getString(key); - - int type = getType(key.isEmpty() ? "" : key.substring(key.length() - 1)); - - if (type >= 0 && type <= 2) { - key = key.substring(0, key.length() - 1); - } - if (type < 0) { - type = 0; - } - - - setType(type); - setKey(key); - } - - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public String getKey() { - return key; - } - public void setKey(String key) { - this.key = key; - } - - - public boolean isOr() { - return isOr(type); - } - public static boolean isOr(int type) { - return type == TYPE_OR; - } - public boolean isAnd() { - return isAnd(type); - } - public static boolean isAnd(int type) { - return type == TYPE_AND; - } - public boolean isNot() { - return isNot(type); - } - public static boolean isNot(int type) { - return type == TYPE_NOT; - } - - public boolean isCorrect() { - return isContain(getType()); - } - public static boolean isContain(String s) { - return isContain(getType(s)); - } - public static boolean isContain(int type) { - return type >= TYPE_OR && type <= TYPE_NOT; - } - - public static int getType(char logicChar) { - return getType(String.valueOf(logicChar)); - } - public static int getType(String logicChar) { - int type = -1; - if (logicChar != null && logicChar.length() == 1) { - if ("|".equals(logicChar)) { - type = 0; - } else if ("&".equals(logicChar)) { - type = 1; - } else if ("!".equals(logicChar)) { - type = 2; - } - } - return type; - } - - public String getChar() { - return getChar(type); - } - public static String getChar(int type) { - return type < 0 || type >= CHARS.length ? "" : CHARS[type]; - } - - public String getName() { - return getName(type); - } - public static String getName(int type) { - return type < 0 || type >= NAMES.length ? "" : NAMES[type]; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/ObjectParser.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/ObjectParser.java deleted file mode 100644 index 4f406cbe5..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/ObjectParser.java +++ /dev/null @@ -1,678 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import static zuo.biao.apijson.JSONObject.KEY_CORRECT; -import static zuo.biao.apijson.JSONObject.KEY_DROP; -import static zuo.biao.apijson.JSONObject.KEY_TRY; -import static zuo.biao.apijson.RequestMethod.PUT; -import static zuo.biao.apijson.JSONObject.KEY_CONDITION; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.regex.Pattern; - -import javax.validation.constraints.NotNull; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -import apijson.demo.server.Function; -import apijson.demo.server.model.BaseModel; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.RequestMethod; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.server.exception.ConflictException; -import zuo.biao.apijson.server.exception.NotExistException; -import zuo.biao.apijson.server.sql.SQLConfig; - -/**简化Parser,getObject和getArray(getArrayConfig)都能用 - * @author Lemon - */ -public abstract class ObjectParser implements ParserAdapter { - private static final String TAG = "ObjectParser"; - - - - private ParserAdapter adapter; - public ObjectParser init(ParserAdapter adapter) { - this.adapter = adapter; - return this; - } - public ParserAdapter getAdapter() { - return adapter == null ? this : adapter; - } - - - - public static final int TYPE_CHILD = 0; - public static final int TYPE_ITEM = 1; - public static final int TYPE_ITEM_CHILD_0 = 2; - - - /**for array item - * name = null - * @param parentPath - * @param request - * @throws Exception - */ - public ObjectParser(@NotNull JSONObject request, String parentPath, int type) throws Exception { - this(request, parentPath, type, null); - } - - protected JSONObject request;//不用final是为了recycle - protected String parentPath;//不用final是为了recycle - - protected final boolean isEmpty;//empty有效 User:{} - protected final int type; - protected String path;//不用final是为了recycle - protected String table;//不用final是为了recycle - protected final boolean isTableKey; - - protected final boolean tri; - /** - * TODO Parser内要不因为 非 TYPE_ITEM_CHILD_0 的Table 为空导致后续中断。 - */ - protected final boolean drop; - protected JSONObject correct; - - /**for single object - * @param parentPath - * @param request - * @param name - * @throws Exception - */ - public ObjectParser(@NotNull JSONObject request, String parentPath, int type, String name) throws Exception { - if (request == null) { - throw new IllegalArgumentException(TAG + ".ObjectParser request == null!!!"); - } - this.request = request; - this.parentPath = parentPath; - this.type = type; - - this.path = Parser.getAbsPath(parentPath, name); - this.table = Pair.parseEntry(name, true).getKey(); - this.isTableKey = zuo.biao.apijson.JSONObject.isTableKey(table); - - this.isEmpty = request.isEmpty(); - if (isEmpty) { - this.tri = false; - this.drop = false; - } else { - this.tri = request.getBooleanValue(KEY_TRY); - this.drop = request.getBooleanValue(KEY_DROP); - this.correct = request.getJSONObject(KEY_CORRECT); - - request.remove(KEY_TRY); - request.remove(KEY_DROP); - request.remove(KEY_CORRECT); - - try { - parseCorrect(); - } catch (Exception e) { - if (tri == false) { - throw e; - } - invalidate(); - } - } - - - Log.d(TAG, "ObjectParser table = " + table + "; isTableKey = " + isTableKey); - Log.d(TAG, "ObjectParser isEmpty = " + isEmpty + "; tri = " + tri + "; drop = " + drop); - } - - public static final Map COMPILE_MAP; - static { - COMPILE_MAP = new HashMap(); - COMPILE_MAP.put("phone", StringUtil.PATTERN_PHONE); - COMPILE_MAP.put("email", StringUtil.PATTERN_EMAIL); - COMPILE_MAP.put("idCard", StringUtil.PATTERN_ID_CARD); - } - - protected Map corrected; - /**解析 @correct 校正 - * @throws Exception - */ - protected ObjectParser parseCorrect() throws Exception { - Set set = correct == null ? null : new HashSet<>(correct.keySet()); - - if (set != null && set.isEmpty() == false) {//对每个需要校正的key进行正则表达式匹配校正 - corrected = new HashMap<>();//TODO 返回全部correct内的内容,包括未校正的? correct); - - String value; //13000082001 - String v; // phone,id_number,card_number - String[] posibleKeys; //[phone,email,id_number,card_number] - - for (String k : set) {// k = cert - v = k == null ? null : correct.getString(k); - value = v == null ? null : request.getString(k); - posibleKeys = value == null ? null : StringUtil.split(v); - - if (posibleKeys != null && posibleKeys.length > 0) { - String rk = null; - Pattern p; - for (String pk : posibleKeys) { - p = pk == null ? null : COMPILE_MAP.get(pk); - if (p != null && p.matcher(value).matches()) { - rk = pk; - break; - } - } - - if (rk == null) { - throw new IllegalArgumentException( - "格式错误!找不到 " + k + ":" + value + " 对应[" + v + "]内的任何一项!"); - } - request.put(rk, request.remove(k)); - corrected.put(k, rk); - } - } - } - - return this; - } - - - - private boolean invalidate = false; - public void invalidate() { - invalidate = true; - } - public boolean isInvalidate() { - return invalidate; - } - - private boolean breakParse = false; - public void breakParse() { - breakParse = true; - } - public boolean isBreakParse() { - return breakParse || isInvalidate(); - } - - - protected JSONObject response; - protected JSONObject sqlRequest; - protected JSONObject sqlReponse; - protected Map customMap; - protected Map functionMap; - protected Map childMap; - - /**解析成员 - * response重新赋值 - * @param config 传递给第0个Table - * @return null or this - * @throws Exception - */ - public ObjectParser parse() throws Exception { - if (isInvalidate() == false) { - breakParse = false; - - response = new JSONObject(true);//must init - - sqlRequest = new JSONObject(true);//must init - sqlReponse = null;//must init - customMap = null;//must init - functionMap = null;//must init - childMap = null;//must init - - Set> set = new LinkedHashSet>(request.entrySet()); - if (set != null && set.isEmpty() == false) {//判断换取少几个变量的初始化是否值得? - if (isTableKey) {//非Table下不必分离出去再添加进来 - customMap = new LinkedHashMap(); - childMap = new LinkedHashMap(); - } - functionMap = new LinkedHashMap();//必须执行 - - - //条件<<<<<<<<<<<<<<<<<<< - List conditionList = null; - if (method == PUT) { //这里只有PUTArray需要处理 || method == DELETE) { - String[] conditions = StringUtil.split(request.getString(KEY_CONDITION)); - //Arrays.asList()返回值不支持add方法! - conditionList = new ArrayList(Arrays.asList(conditions != null ? conditions : new String[]{})); - conditionList.add(zuo.biao.apijson.JSONRequest.KEY_ID); - conditionList.add(zuo.biao.apijson.JSONRequest.KEY_ID_IN); - } - //条件>>>>>>>>>>>>>>>>>>> - - String key; - Object value; - for (Entry entry : set) { - if (isBreakParse()) { - break; - } - - value = entry.getValue(); - if (value == null) { - continue; - } - key = entry.getKey(); - - try { - if (value instanceof JSONObject && key.startsWith("@") == false) {//JSONObject,往下一级提取 - putChild(key, (JSON) value); - } - else if (method == PUT && value instanceof JSONArray - && BaseModel.isContain(conditionList, key) == false) {//PUT JSONArray - onPUTArrayParse(key, (JSONArray) value); - } - else {//JSONArray或其它Object,直接填充 - if (onParse(key, value) == false) { - invalidate(); - } - } - } catch (Exception e) { - if (tri == false) { - throw e;//不忽略错误,抛异常 - } - invalidate();//忽略错误,还原request - } - } - } - } - - if (isInvalidate()) { - recycle(); - return null; - } - - return this; - } - - - - /** - * @param key - * @param value 类型不用JSON是因为JSON不能强转为JSONObject - * @throws Exception - */ - protected void putChild(String key, JSON child) throws Exception { - if (child != null) { - if (childMap != null) {//添加到childMap,最后再解析 - childMap.put(key, child); - } else {//直接解析并替换原来的 - response.put(key, onChildParse(key, child)); - } - } - } - - - /** - * @param key - * @param value - * @return - * @throws Exception - */ - protected JSON onChildParse(String key, JSON value) throws Exception { - return getAdapter().parseChild(path, key, value); - } - - /** - * @return - * @throws Exception - */ - protected JSONObject onSQLExecute() throws Exception { - return getAdapter().executeSQL(path, config); - } - - /**解析普通成员 - * @param key - * @param value - * @return whether parse succeed - */ - protected boolean onParse(@NotNull String key, @NotNull Object value) throws Exception { - if (key.endsWith("@")) {//StringUtil.isPath((String) value)) { - if (value instanceof String == false) { - throw new IllegalArgumentException("\"key@\": 后面必须为依赖路径String!"); - } - // System.out.println("getObject key.endsWith(@) >> parseRelation = " + parseRelation); - String replaceKey = key.substring(0, key.length() - 1);//key{}@ getRealKey - String targetPath = Parser.getValuePath(getType() == TYPE_ITEM - ? path : parentPath, new String((String) value)); - - //先尝试获取,尽量保留缺省依赖路径,这样就不需要担心路径改变 - Object target = getAdapter().getTarget(targetPath); - Log.i(TAG, "getObject targetPath = " + targetPath + "; target = " + target); - - if (target == null) {//String#equals(null)会出错 - Log.d(TAG, "getObject target == null >> continue;"); - return true; - } - if (targetPath.equals(target)) {//必须valuePath和保证getValueByPath传进去的一致! - Log.d(TAG, "getObject targetPath.equals(target) >>"); - - //非查询关键词 @key 不影响查询,直接跳过 - if (isTableKey && (key.startsWith("@") == false || SQLConfig.TABLE_KEY_LIST.contains(key))) { - Log.e(TAG, "getObject isTableKey && (key.startsWith(@) == false" - + " || SQLConfig.TABLE_KEY_LIST.contains(key)) >> return null;"); - return false;//获取不到就不用再做无效的query了。不考虑 Table:{Table:{}}嵌套 - } else { - Log.d(TAG, "getObject isTableKey(table) == false >> continue;"); - return true;//舍去,对Table无影响 - } - } - - - //直接替换原来的key@:path为key:target - Log.i(TAG, "getObject >> key = replaceKey; value = target;"); - key = replaceKey; - value = target; - Log.d(TAG, "getObject key = " + key + "; value = " + value); - } - - if (key.endsWith("()")) { - if (value instanceof String == false) { - throw new IllegalArgumentException(path + "/" + key + "():function() 后面必须为函数String!"); - } - functionMap.put(key, (String) value); - } else if (isTableKey && key.startsWith("@") && SQLConfig.TABLE_KEY_LIST.contains(key) == false) { - customMap.put(key, value); - } else { - sqlRequest.put(key, value); - } - - return true; - } - - - //TODO 改用 MySQL json_add,json_remove,json_contains 等函数! - /**PUT key:[] - * @param key - * @param array - * @throws Exception - */ - protected void onPUTArrayParse(@NotNull String key, @NotNull JSONArray array) throws Exception { - if (isTableKey == false || array.isEmpty()) { - Log.e(TAG, "onPUTArray isTableKey == false || array == null || array.isEmpty() >> return;"); - return; - } - - int putType = 0; - if (key.endsWith("+")) {//add - putType = 1; - } else if (key.endsWith("-")) {//remove - putType = 2; - } else {//replace - // throw new IllegalAccessException("PUT " + path + ", PUT Array不允许 " + key + - // " 这种没有 + 或 - 结尾的key!不允许整个替换掉原来的Array!"); - } - String realKey = SQLConfig.getRealKey(method, key, false, false); - - //GET > add all 或 remove all > PUT > remove key - - //GET <<<<<<<<<<<<<<<<<<<<<<<<< - JSONObject rq = new JSONObject(); - rq.put(JSONRequest.KEY_ID, request.get(JSONRequest.KEY_ID)); - rq.put(JSONRequest.KEY_COLUMN, realKey); - JSONObject rp = parseResponse(new JSONRequest(table, rq)); - //GET >>>>>>>>>>>>>>>>>>>>>>>>> - - - //add all 或 remove all <<<<<<<<<<<<<<<<<<<<<<<<< - if (rp != null) { - rp = rp.getJSONObject(table); - } - JSONArray targetArray = rp == null ? null : rp.getJSONArray(realKey); - if (targetArray == null) { - targetArray = new JSONArray(); - } - for (Object obj : array) { - if (obj == null) { - continue; - } - if (putType == 1) { - if (targetArray.contains(obj)) { - throw new ConflictException("PUT " + path + ", " + realKey + ":" + obj + " 已存在!"); - } - targetArray.add(obj); - } else if (putType == 2) { - if (targetArray.contains(obj) == false) { - throw new NullPointerException("PUT " + path + ", " + realKey + ":" + obj + " 不存在!"); - } - targetArray.remove(obj); - } - } - - //add all 或 remove all >>>>>>>>>>>>>>>>>>>>>>>>> - - //PUT <<<<<<<<<<<<<<<<<<<<<<<<< - sqlRequest.put(realKey, targetArray); - //PUT >>>>>>>>>>>>>>>>>>>>>>>>> - - } - - - /**SQL查询,for single object - * @return {@link #executeSQL(int, int, int)} - * @throws Exception - */ - public ObjectParser executeSQL() throws Exception { - return executeSQL(1, 0, 0); - } - - protected SQLConfig config = null;//array item复用 - /**SQL查询,for array item - * @param count - * @param page - * @param position - * @return this - * @throws Exception - */ - public ObjectParser executeSQL(int count, int page, int position) throws Exception { - //执行SQL操作数据库 - if (isTableKey == false) {//提高性能 - sqlReponse = new JSONObject(sqlRequest); - } else { - - try { - if (config == null) { - config = newSQLConfig(); - } - config.setCount(count).setPage(page).setPosition(position); - sqlReponse = onSQLExecute(); - } catch (Exception e) { - Log.e(TAG, "getObject try { response = getSQLObject(config2); } catch (Exception e) {"); - if (e instanceof NotExistException) {//非严重异常,有时候只是数据不存在 - // e.printStackTrace(); - sqlReponse = null;//内部吃掉异常,put到最外层 - // requestObject.put(JSONResponse.KEY_MSG - // , StringUtil.getString(requestObject.get(JSONResponse.KEY_MSG) - // + "; query " + path + " cath NotExistException:" - // + newErrorResult(e).getString(JSONResponse.KEY_MSG))); - } else { - throw e; - } - } - - if (drop) {//丢弃Table,只为了向下提供条件 - sqlReponse = null; - } - } - - return this; - } - - /** - * @return response - * @throws Exception - */ - public JSONObject response() throws Exception { - if (sqlReponse == null || sqlReponse.isEmpty()) { - if (isTableKey) {//Table自身都获取不到值,则里面的Child都无意义,不需要再解析 - return response; - } - } else { - response.putAll(sqlReponse); - } - - - //把已校正的字段键值对corrected添加进来,还是correct直接改? - if (corrected != null) { - response.put(KEY_CORRECT, corrected); - } - - //把isTableKey时取出去的custom重新添加回来 - if (customMap != null) { - response.putAll(customMap); - } - - - - //解析函数function - if (functionMap != null) { - Set> functionSet = functionMap == null ? null : functionMap.entrySet(); - if (functionSet != null && functionSet.isEmpty() == false) { - for (Entry entry : functionSet) { - response.put(SQLConfig.getRealKey(method, entry.getKey(), false, false) - , Function.invoke(response, entry.getValue())); - } - } - } - - //把isTableKey时取出去child解析后重新添加回来 - Set> set = childMap == null ? null : childMap.entrySet(); - if (set != null) { - for (Entry entry : set) { - if (entry != null) { - response.put(entry.getKey(), onChildParse(entry.getKey(), entry.getValue())); - } - } - } - - onComplete(); - - return response; - } - - protected SQLConfig newSQLConfig() throws Exception { - return SQLConfig.newSQLConfig(method, table, sqlRequest); - } - /** - * response has the final value after parse (and query if isTableKey) - */ - protected void onComplete() { - } - - - /**回收内存 - */ - public void recycle() { - //后面还可能用到,要还原 - if (tri) {//避免返回未传的字段 - request.put(KEY_TRY, tri); - } - if (drop) { - request.put(KEY_DROP, drop); - } - if (correct != null) { - request.put(KEY_CORRECT, correct); - } - - - correct = null; - corrected = null; - method = null; - parentPath = null; - path = null; - table = null; - - // if (response != null) { - // response.clear();//有效果? - // response = null; - // } - - request = null; - response = null; - sqlRequest = null; - sqlReponse = null; - - functionMap = null; - customMap = null; - childMap = null; - } - - - - - - - protected RequestMethod method; - public ObjectParser setMethod(RequestMethod method) { - if (this.method != method) { - this.method = method; - config = null; - //TODO ? sqlReponse = null; - } - return this; - } - public RequestMethod getMethod() { - return method; - } - - - - public int getType() { - return type; - } - public String getPath() { - return path; - } - public String getTable() { - return table; - } - public boolean isTableKey() { - return isTableKey; - } - - - - public SQLConfig getConfig() { - return config; - } - - public JSONObject getResponse() { - return response; - } - public JSONObject getSqlRequest() { - return sqlRequest; - } - public JSONObject getSqlReponse() { - return sqlReponse; - } - - - public Map getCustomMap() { - return customMap; - } - public Map getFunctionMap() { - return functionMap; - } - public Map getChildMap() { - return childMap; - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/OnParseCallback.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/OnParseCallback.java deleted file mode 100644 index ba691eefe..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/OnParseCallback.java +++ /dev/null @@ -1,70 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -/** - * @author Lemon - */ -public abstract class OnParseCallback { - - - /** - * @param key - * @param to - * @param ro - * @return false ? continue - * @throws Exception - */ - protected boolean onParse(String key, Object to, Object ro) throws Exception { - return true; - } - - /** - * @param key - * @param to - * @param ro - * @return - * @throws Exception - */ - protected Object onParseObject(String key, Object to, Object ro) throws Exception { - return ro; - } - - /** - * @param key - * @param tobj - * @param robj - * @return - * @throws Exception - */ - protected JSONObject onParseJSONObject(String key, JSONObject tobj, JSONObject robj) throws Exception { - return robj; - } - - /** - * @param key - * @param tarray - * @param rarray - * @return - * @throws Exception - */ - protected JSONArray onParseJSONArray(String key, JSONArray tarray, JSONArray rarray) throws Exception { - return rarray; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Operation.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Operation.java deleted file mode 100644 index b5678a670..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Operation.java +++ /dev/null @@ -1,68 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import zuo.biao.apijson.StringUtil; - -/**对请求JSON的操作 - * @author Lemon - */ -public enum Operation { - - /** - * 不允许传的字段 - */ - DISALLOW, - /** - * 必须传的字段 - */ - NECESSARY, - - /** - * 验证是否符合预设的条件 - */ - VERIFY, - /** - * 验证是否不存在,除了本身的记录 - */ - UNIQUE, - - /** - * 添加,当要被添加的对象不存在时 - */ - ADD, - /** - * 强行放入,不存在时就添加,存在时就修改 - */ - PUT, - /** - * 替换,当要被替换的对象存在时 - */ - REPLACE, - /** - * 移除,当要被移除的对象存在时 - */ - REMOVE; - - public static Operation get(String name) { - try {//Enum.valueOf只要找不到对应的值就会抛异常 - return Operation.valueOf(StringUtil.toUpperCase(name)); - } catch (Exception e) { - //empty - } - return null; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Pair.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Pair.java deleted file mode 100644 index a19c8e447..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Pair.java +++ /dev/null @@ -1,159 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import java.util.Collection; -import java.util.HashMap; -import java.util.Map; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -import zuo.biao.apijson.StringUtil; - -/**key:value - * @author Lemon - */ -public class Pair extends Entry { - - private static final Map> classMap; - static { - classMap = new HashMap>(); - classMap.put(boolean.class.getSimpleName(), boolean.class); - classMap.put(int.class.getSimpleName(), int.class); - classMap.put(long.class.getSimpleName(), long.class); - classMap.put(float.class.getSimpleName(), float.class); - classMap.put(double.class.getSimpleName(), double.class); - classMap.put(Boolean.class.getSimpleName(), Boolean.class); - classMap.put(Integer.class.getSimpleName(), Integer.class); - classMap.put(Long.class.getSimpleName(), Long.class); - classMap.put(Float.class.getSimpleName(), Float.class); - classMap.put(Double.class.getSimpleName(), Double.class); - - classMap.put(Object.class.getSimpleName(), Object.class); - classMap.put(String.class.getSimpleName(), String.class); - classMap.put(Collection.class.getSimpleName(), Collection.class);//不允许指定 - classMap.put(Map.class.getSimpleName(), Map.class);//不允许指定 - classMap.put(JSONObject.class.getSimpleName(), JSONObject.class);//必须有,Map中没有getLongValue等方法 - classMap.put(JSONArray.class.getSimpleName(), JSONArray.class);//必须有,Collection中没有?等方法 - } - - - public Pair() { - super(); - } - - public boolean isEmpty(boolean trim) { - return StringUtil.isNotEmpty(key, trim) == false && StringUtil.isNotEmpty(value, trim) == false; - } - - /** - * @param - * @param pair - * @return - */ - public static boolean isCorrect(Entry pair) { - return pair != null && StringUtil.isNotEmpty(pair.getValue(), true); - } - - /** - * @param pair - * @return - */ - public String toPairString() { - return toPairString(getKey(), getValue()); - } - /** - * @param pair - * @return - */ - public static String toPairString(String typeKey, String valueKey) { - return (typeKey == null ? "" : typeKey + ":") + valueKey; - } - /** - * @param type - * @param value - * @return - */ - public static String toPairString(Class type, Object value) { - return toPairString(type == null ? null : type.getSimpleName(), StringUtil.getString(value)); - } - - /** - * isRightValueDefault = false; - * "key":null不应该出现?因为FastJSON内默认不存null - * @param pair leftKey:rightValue - * @return {@link #parseEntry(String, boolean)} - */ - public static Entry parseEntry(String pair) { - return parseEntry(pair, false); - } - /** - * isRightValueDefault = false; - * "key":null不应该出现?因为FastJSON内默认不存null - * @param pair leftKey:rightValue - * @param isRightValueDefault 右边值缺省,当pair不包含 : 时默认整个pair为leftKey;false-相反 - * @return {@link #parseEntry(String, boolean, String)} - */ - public static Entry parseEntry(String pair, boolean isRightValueDefault) { - return parseEntry(pair, isRightValueDefault, null); - } - /** - * "key":null不应该出现?因为FastJSON内默认不存null - * @param pair leftKey:rightValue - * @param isRightValueDefault 右边值缺省,当pair不包含 : 时默认整个pair为leftKey;false-相反 - * @param defaultValue 缺省值 - * @return @NonNull - */ - public static Entry parseEntry(String pair, boolean isRightValueDefault, String defaultValue) { - pair = StringUtil.getString(pair);//让客户端去掉所有空格 getNoBlankString(pair); - Entry entry = new Entry(); - if (pair.isEmpty() == false) { - int index = pair.indexOf(":"); - if (index < 0) { - entry.setKey(isRightValueDefault ? pair : defaultValue); - entry.setValue(isRightValueDefault ? defaultValue : pair); - } else { - entry.setKey(pair.substring(0, index)); - entry.setValue(pair.substring(index + 1, pair.length())); - } - - } - return entry; - } - /** - * @param pair - * @return - */ - public static Entry parseVariableEntry(String pair) { - return parseEntry(pair, false, Object.class.getSimpleName()); - } - /** - * @param pair - * @param valueMap - * @return - */ - public static Entry, Object> parseVariableEntry(String pair, Map valueMap) { - pair = StringUtil.getString(pair);//让客户端去掉所有空格 getNoBlankString(pair); - Entry, Object> entry = new Entry, Object>(); - if (pair.isEmpty() == false) { - int index = pair.contains(":") ? pair.indexOf(":") : -1; - - entry.setKey(classMap.get(index < 0 ? Object.class.getSimpleName() : pair.substring(0, index))); - entry.setValue(valueMap == null ? null : valueMap.get(pair.substring(index + 1, pair.length()))); - } - return entry; - } -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Parser.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Parser.java deleted file mode 100755 index 707994fe5..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Parser.java +++ /dev/null @@ -1,904 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import static zuo.biao.apijson.RequestMethod.GET; - -import java.io.UnsupportedEncodingException; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.TimeoutException; - -import javax.activation.UnsupportedDataTypeException; -import javax.servlet.http.HttpSession; -import javax.validation.constraints.NotNull; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -import apijson.demo.server.Verifier; -import apijson.demo.server.model.User; -import zuo.biao.apijson.JSON; -import zuo.biao.apijson.JSONResponse; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.RequestMethod; -import zuo.biao.apijson.RequestRole; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.server.exception.ConditionErrorException; -import zuo.biao.apijson.server.exception.ConflictException; -import zuo.biao.apijson.server.exception.NotExistException; -import zuo.biao.apijson.server.exception.NotLoggedInException; -import zuo.biao.apijson.server.exception.OutOfRangeException; -import zuo.biao.apijson.server.sql.SQLConfig; -import zuo.biao.apijson.server.sql.SQLExecutor; - -/**parser for parsing request to JSONObject - * @author Lemon - */ -public class Parser { - private static final String TAG = "Parser"; - - - /** - * GET - */ - public Parser() { - this(null); - } - /** - * @param requestMethod null ? requestMethod = GET - */ - public Parser(RequestMethod method) { - this(method, false); - } - - private final RequestMethod requestMethod; - /** - * @param requestMethod null ? requestMethod = GET - * @param noVerify 仅限于为服务端提供方法免验证特权,普通请求不要设置为true! 如果对应Table有权限也建议用默认值false,保持和客户端权限一致 - */ - public Parser(RequestMethod method, boolean noVerify) { - super(); - this.requestMethod = method == null ? GET : method; - setNoVerifyRequest(noVerify); - setNoVerifyLogin(noVerify); - setNoVerifyRole(noVerify); - } - - private HttpSession session;//可能比较大,占内存。而且不是所有地方都用 - private User visitor;//来访用户 - private long visitorId;//来访用户id - public Parser setSession(@NotNull HttpSession session) { - this.session = session; - this.visitor = Verifier.getUser(session); - this.visitorId = Verifier.getUserId(session); - return this; - } - private RequestRole globleRole;//全局角色,对未指明角色的Table自动加上这个角色 - public Parser setGlobleRole(RequestRole globleRole) { - this.globleRole = globleRole; - return this; - } - - //一定要验证结构!对管理员也要验证! - private boolean noVerifyRequest = false; - private boolean noVerifyLogin = false; - private boolean noVerifyRole = false; - public Parser setNoVerifyRequest(boolean noVerifyRequest) { - this.noVerifyRequest = noVerifyRequest; - return this; - } - public Parser setNoVerifyLogin(boolean noVerifyLogin) { - this.noVerifyLogin = noVerifyLogin; - return this; - } - public Parser setNoVerifyRole(boolean noVerifyRole) { - this.noVerifyRole = noVerifyRole; - return this; - } - - - - - - - private JSONObject requestObject; - private SQLExecutor sqlExecutor; - private Map queryResultMap;//path-result - - - /**解析请求json并获取对应结果 - * @param request - * @return - */ - public String parse(String request) { - return JSON.toJSONString(parseResponse(request)); - } - /**解析请求json并获取对应结果 - * @param request - * @return - */ - @NotNull - public String parse(JSONObject request) { - return JSON.toJSONString(parseResponse(request)); - } - - /**解析请求json并获取对应结果 - * @param request 先parseRequest中URLDecoder.decode(request, UTF_8);再parseResponse(getCorrectRequest(...)) - * @return parseResponse(requestObject); - */ - @NotNull - public JSONObject parseResponse(String request) { - Log.d(TAG, "\n\n\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n" - + requestMethod + "/parseResponse request = \n" + request + "\n\n"); - - try { - requestObject = parseRequest(request, requestMethod); - } catch (Exception e) { - return newErrorResult(e); - } - - return parseResponse(requestObject); - } - - /**解析请求json并获取对应结果 - * @param request - * @return requestObject - */ - @NotNull - public JSONObject parseResponse(JSONObject request) { - long startTime = System.currentTimeMillis(); - Log.d(TAG, "parseResponse startTime = " + startTime - + "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n\n\n "); - - requestObject = request; - if (RequestMethod.isPublicMethod(requestMethod) == false) { - try { - //TODO - // if (noVerifyLogin == false) { - // Verifier.verifyLogin(session); - // } - if (noVerifyRequest == false) { - //补充全局缺省版本号 - if (session != null && requestObject.getIntValue(JSONRequest.KEY_VERSION) <= 0) { - requestObject.put(JSONRequest.KEY_VERSION, session.getAttribute(JSONRequest.KEY_VERSION)); - } - - requestObject = getCorrectRequest(requestMethod, requestObject); - } - } catch (Exception e) { - return Parser.extendErrorResult(requestObject, e); - } - } - - if (noVerifyRole == false && globleRole == null) { - setGlobleRole(RequestRole.get(requestObject.getString(JSONRequest.KEY_ROLE))); - } - - final String requestString = JSON.toJSONString(request);//request传进去解析后已经变了 - - - queryResultMap = new HashMap(); - - Exception error = null; - sqlExecutor = new SQLExecutor(); - try { - requestObject = getObject(null, null, request); - } catch (Exception e) { - e.printStackTrace(); - error = e; - } - sqlExecutor.close(); - sqlExecutor = null; - - - requestObject = Verifier.removeAccessInfo(requestObject); - requestObject = error == null ? extendSuccessResult(requestObject) : extendErrorResult(requestObject, error); - - - queryResultMap.clear(); - - //会不会导致原来的session = null? session = null; - - - Log.d(TAG, "\n\n\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n " - + requestMethod + "/parseResponse request = \n" + requestString + "\n\n"); - - Log.d(TAG, "parse return response = \n" + JSON.toJSONString(requestObject) - + "\n >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> \n\n\n"); - - long endTime = System.currentTimeMillis(); - Log.d(TAG, "parseResponse endTime = " + endTime + "; duration = " + (endTime - startTime) - + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n\n"); - - return requestObject; - } - - /**解析请求JSONObject - * @param request => URLDecoder.decode(request, UTF_8); - * @return - * @throws Exception - */ - @NotNull - public static JSONObject parseRequest(String request, RequestMethod method) throws Exception { - //全走HTTP POST,不用encode和decode - // if (RequestMethod.isPublicMethod(method)) { - // request = URLDecoder.decode(request, UTF_8); - // Log.d(TAG, "\n\n\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n " + method - // + "/parseRequest request = \n" + request + "\n\n"); - // } - if (method == null) { - method = GET; - } - JSONObject obj = JSON.parseObject(request); - if (obj == null) { - throw new UnsupportedEncodingException("JSON格式不合法!"); - } - return obj; - } - - - - - - /**新建带状态内容的JSONObject - * @param code - * @param msg - * @return - */ - public static JSONObject newResult(int code, String msg) { - return extendResult(null, code, msg); - } - /**添加JSONObject的状态内容,一般用于错误提示结果 - * @param object - * @param code - * @param msg - * @return - */ - public static JSONObject extendResult(JSONObject object, int code, String msg) { - if (object == null) { - object = new JSONObject(true); - } - if (object.containsKey(JSONResponse.KEY_CODE) == false) { - object.put(JSONResponse.KEY_CODE, code); - } - String m = StringUtil.getString(object.getString(JSONResponse.KEY_MSG)); - if (m.isEmpty() == false) { - msg = m + " \n " + StringUtil.getString(msg); - } - object.put(JSONResponse.KEY_MSG, msg); - return object; - } - - - /**添加请求成功的状态内容 - * @param object - * @return - */ - public static JSONObject extendSuccessResult(JSONObject object) { - return extendResult(object, JSONResponse.CODE_SUCCESS, JSONResponse.MSG_SUCCEED); - } - /**获取请求成功的状态内容 - * @return - */ - public static JSONObject newSuccessResult() { - return newResult(JSONResponse.CODE_SUCCESS, JSONResponse.MSG_SUCCEED); - } - /**添加请求成功的状态内容 - * @param object - * @return - */ - public static JSONObject extendErrorResult(JSONObject object, Exception e) { - JSONObject error = newErrorResult(e); - return extendResult(object, error.getIntValue(JSONResponse.KEY_CODE), error.getString(JSONResponse.KEY_MSG)); - } - /**新建错误状态内容 - * @param e - * @return - */ - public static JSONObject newErrorResult(Exception e) { - if (e != null) { - e.printStackTrace(); - - int code; - if (e instanceof UnsupportedEncodingException) { - code = JSONResponse.CODE_UNSUPPORTED_ENCODING; - } - else if (e instanceof IllegalAccessException) { - code = JSONResponse.CODE_ILLEGAL_ACCESS; - } - else if (e instanceof UnsupportedOperationException) { - code = JSONResponse.CODE_UNSUPPORTED_OPERATION; - } - else if (e instanceof NotExistException) { - code = JSONResponse.CODE_NOT_FOUND; - } - else if (e instanceof IllegalArgumentException) { - code = JSONResponse.CODE_ILLEGAL_ARGUMENT; - } - else if (e instanceof NotLoggedInException) { - code = JSONResponse.CODE_NOT_LOGGED_IN; - } - else if (e instanceof TimeoutException) { - code = JSONResponse.CODE_TIME_OUT; - } - else if (e instanceof ConflictException) { - code = JSONResponse.CODE_CONFLICT; - } - else if (e instanceof ConditionErrorException) { - code = JSONResponse.CODE_CONDITION_ERROR; - } - else if (e instanceof UnsupportedDataTypeException) { - code = JSONResponse.CODE_UNSUPPORTED_TYPE; - } - else if (e instanceof OutOfRangeException) { - code = JSONResponse.CODE_OUT_OF_RANGE; - } - else if (e instanceof NullPointerException) { - code = JSONResponse.CODE_NULL_POINTER; - } - else { - code = JSONResponse.CODE_SERVER_ERROR; - } - - return newResult(code, e.getMessage()); - } - - return newResult(JSONResponse.CODE_SERVER_ERROR, JSONResponse.MSG_SERVER_ERROR); - } - - - - - //TODO 启动时一次性加载Request所有内容,作为初始化。 - /**获取正确的请求,非GET请求必须是服务器指定的 - * @param method - * @param request - * @return - * @throws Exception - */ - public static JSONObject getCorrectRequest(@NotNull RequestMethod method, JSONObject request) throws Exception { - if (RequestMethod.isPublicMethod(method)) { - return request;//需要指定JSON结构的get请求可以改为post请求。一般只有对安全性要求高的才会指定,而这种情况用明文的GET方式几乎肯定不安全 - } - - String tag = request.getString(JSONRequest.KEY_TAG); - if (StringUtil.isNotEmpty(tag, true) == false) { - throw new IllegalArgumentException("请设置tag!一般是Table名"); - } - int version = request.getIntValue(JSONRequest.KEY_VERSION); - - JSONObject object = null; - String error = ""; - try { - object = getStructure(method, "Request", JSONRequest.KEY_TAG, tag, version); - } catch (Exception e) { - error = e.getMessage(); - } - if (object == null) {//empty表示随意操作 || object.isEmpty()) { - throw new UnsupportedOperationException("非开放请求必须是服务端允许的操作! \n " + error); - } - - JSONObject target = null; - if (zuo.biao.apijson.JSONObject.isTableKey(tag) && object.containsKey(tag) == false) {//tag是table名 - target = new JSONObject(true); - target.put(tag, object); - } else { - target = object; - } - //获取指定的JSON结构 >>>>>>>>>>>>>> - - request.remove(JSONRequest.KEY_TAG); - request.remove(JSONRequest.KEY_VERSION); - return Structure.parseRequest(method, "", (JSONObject) target.clone(), request); - } - - //TODO 优化性能! - /**获取正确的返回结果 - * @param method - * @param response - * @return - * @throws Exception - */ - public static JSONObject getCorrectResponse(@NotNull final RequestMethod method - , String table, JSONObject response) throws Exception { - // Log.d(TAG, "getCorrectResponse method = " + method + "; table = " + table); - // if (response == null || response.isEmpty()) {//避免无效空result:{}添加内容后变有效 - // Log.e(TAG, "getCorrectResponse response == null || response.isEmpty() >> return response;"); - return response; - // } - // - // JSONObject target = zuo.biao.apijson.JSONObject.isTableKey(table) == false - // ? new JSONObject() : getStructure(method, "Response", "model", table); - // - // return MethodStructure.parseResponse(method, table, target, response, new OnParseCallback() { - // - // @Override - // protected JSONObject onParseJSONObject(String key, JSONObject tobj, JSONObject robj) throws Exception { - // return getCorrectResponse(method, key, robj); - // } - // }); - } - - /**获取Request或Response内指定JSON结构 - * @param method - * @param table - * @param key - * @param value - * @param version - * @return - * @throws Exception - */ - public static JSONObject getStructure(@NotNull final RequestMethod method, @NotNull String table, - String key, String value, int version) throws Exception { - //获取指定的JSON结构 <<<<<<<<<<<<<< - SQLConfig config = new SQLConfig(GET, table); - config.setColumn("structure"); - - Map where = new HashMap(); - where.put("method", method.name()); - if (key != null) { - where.put(key, value); - } - if (version > 0) { - where.put(JSONRequest.KEY_VERSION + "{}", ">=" + version); - } - config.setWhere(where); - config.setOrder(JSONRequest.KEY_VERSION + (version > 0 ? "+" : "-")); - config.setCount(1); - - SQLExecutor qh = new SQLExecutor(); - - //too many connections error: 不try-catch,可以让客户端看到是服务器内部异常 - try { - JSONObject result = qh.execute(config.setCacheStatic(true)); - return getJSONObject(result, "structure");//解决返回值套了一层 "structure":{} - } finally { - qh.close(); - } - } - - - /**获取单个对象,该对象处于parentObject内 - * @param parentPath parentObject的路径 - * @param name parentObject的key - * @param request parentObject的value - * @return - * @throws Exception - */ - private JSONObject getObject(String parentPath, String name, JSONObject request) throws Exception { - return getObject(parentPath, name, request, null); - } - - // private SQLConfig itemConfig; - /**获取单个对象,该对象处于parentObject内 - * @param parentPath parentObject的路径 - * @param name parentObject的key - * @param request parentObject的value - * @param config for array item - * @return - * @throws Exception - */ - private JSONObject getObject(String parentPath, String name, final JSONObject request - , final SQLConfig arrayConfig) throws Exception { - Log.i(TAG, "\ngetObject: parentPath = " + parentPath - + ";\n name = " + name + "; request = " + JSON.toJSONString(request)); - if (request == null) {// Moment:{} || request.isEmpty()) {//key-value条件 - return null; - } - - final int type = arrayConfig == null ? 0 : arrayConfig.getType(); - final boolean isArrayItem = type == ObjectParser.TYPE_ITEM; - - ObjectParser op = new ObjectParser(request, parentPath, type, name) { - - @Override - public Object getTarget(@NotNull String path) { - return getValueByPath(path); - } - - @Override - public JSONObject executeSQL(@NotNull String path, @NotNull SQLConfig config) throws Exception { - JSONObject result = getSQLObject(config); - if (result != null) { - putQueryResult(path, result);//解决获取关联数据时requestObject里不存在需要的关联数据 - } - return result; - } - - com.alibaba.fastjson.JSON child; - boolean isFirst = true; - boolean isEmpty; - @Override - public com.alibaba.fastjson.JSON parseChild(@NotNull String path, @NotNull String key - , @NotNull com.alibaba.fastjson.JSON value) throws Exception { - if (zuo.biao.apijson.JSONObject.isArrayKey(key)) {//APIJSON Array - child = getArray(path, key, (JSONObject) value); - isEmpty = child == null || ((JSONArray) child).isEmpty(); - } else {//APIJSON Object - child = getObject(path, key, (JSONObject) value - , isFirst && isArrayItem ? arrayConfig.setType(TYPE_ITEM_CHILD_0) : null); - isEmpty = child == null || ((JSONObject) child).isEmpty(); - if (isFirst && isEmpty) { - invalidate(); - } - - isFirst = false; - } - Log.i(TAG, "getObject ObjectParser.onParse key = " + key + "; child = " + child); - - return isEmpty ? null : child;//只添加! isEmpty的值,可能数据库返回数据不够count - } - - @Override - public JSONObject parseResponse(JSONRequest request) throws Exception { - return new Parser(GET) - .setSession(session) - // .setNoVerifyRequest(noVerifyRequest) - .setNoVerifyLogin(noVerifyLogin) - .setNoVerifyRole(noVerifyRole) - .parseResponse(request); - } - - // @Override - // protected SQLConfig newQueryConfig() { - // if (itemConfig != null) { - // return itemConfig; - // } - // return super.newQueryConfig(); - // } - - //导致最多评论的(Strong 30个)的那个动态详情界面Android(82001)无姓名和头像,即User=null - // @Override - // protected void onComplete() { - // if (response != null) { - // putQueryResult(path, response);//解决获取关联数据时requestObject里不存在需要的关联数据 - // } - // } - - }.setMethod(requestMethod).parse(); - - - - JSONObject response = null; - if (op != null) {//TODO SQL查询结果为空时,functionMap和customMap还有没有意义? - if (arrayConfig == null) {//Common - response = op.executeSQL().response(); - } else {//Array Item Child - int query = arrayConfig.getQuery(); - - //total - if (type == ObjectParser.TYPE_ITEM_CHILD_0 && query != JSONRequest.QUERY_TABLE - && arrayConfig.getPosition() == 0) { - JSONObject rp = op.setMethod(RequestMethod.HEAD).executeSQL().getSqlReponse(); - if (rp != null) { - int index = parentPath.lastIndexOf("]/"); - if (index >= 0) { - int total = rp.getIntValue(JSONResponse.KEY_COUNT); - putQueryResult(parentPath.substring(0, index) + "]/" + JSONResponse.KEY_TOTAL, total); - - if (total <= arrayConfig.getCount()*arrayConfig.getPage()) { - query = JSONRequest.QUERY_TOTAL;//数量不够了,不再往后查询 - } - } - } - - op.setMethod(requestMethod); - } - - //Table - if (query == JSONRequest.QUERY_TOTAL) { - response = null;//不再往后查询 - } else { - response = op.executeSQL( - arrayConfig.getCount(), arrayConfig.getPage(), arrayConfig.getPosition() - ).response(); - // itemConfig = op.getConfig(); - } - } - - op.recycle(); - op = null; - } - - return response; - } - - /**获取对象数组,该对象数组处于parentObject内 - * @param parentPath parentObject的路径 - * @param name parentObject的key - * @param request parentObject的value - * @return - * @throws Exception - */ - private JSONArray getArray(String parentPath, String name, final JSONObject request) throws Exception { - Log.i(TAG, "\n\n\n getArray parentPath = " + parentPath - + "; name = " + name + "; request = " + JSON.toJSONString(request)); - //不能允许GETS,否则会被通过"[]":{"@role":"ADMIN"},"Table":{},"tag":"Table"绕过权限并能批量查询 - if (RequestMethod.isGetMethod(requestMethod, false) == false) { - throw new UnsupportedOperationException("key[]:{}只支持GET方法!不允许传 " + name + ":{} !"); - } - if (request == null || request.isEmpty()) {//jsonKey-jsonValue条件 - return null; - } - String path = getAbsPath(parentPath, name); - - //不能改变,因为后面可能继续用到,导致1以上都改变 []:{0:{Comment[]:{0:{Comment:{}},1:{...},...}},1:{...},...} - final int query = request.getIntValue(JSONRequest.KEY_QUERY); - final int count = request.getIntValue(JSONRequest.KEY_COUNT); - final int page = request.getIntValue(JSONRequest.KEY_PAGE); - request.remove(JSONRequest.KEY_QUERY); - request.remove(JSONRequest.KEY_COUNT); - request.remove(JSONRequest.KEY_PAGE); - Log.d(TAG, "getArray query = " + query + "; count = " + count + "; page = " + page); - - if (request.isEmpty()) {//如果条件成立,说明所有的 parentPath/name:request 中request都无效!!! - Log.e(TAG, "getArray request.isEmpty() >> return null;"); - return null; - } - - - //不用total限制数量了,只用中断机制,total只在query = 1,2的时候才获取 - int size = count <= 0 || count > 100 ? 100 : count;//count为每页数量,size为第page页实际数量,max(size) = count - Log.d(TAG, "getArray size = " + size + "; page = " + page); - - - //key[]:{Table:{}}中key equals Table时 提取Table - int index = name == null ? -1 : name.lastIndexOf("[]"); - String childPath = index <= 0 ? null : Pair.parseEntry(name.substring(0, index), true).getKey(); // Table-key1-key2... - - //判断第一个key,即Table是否存在,如果存在就提取 - String[] childKeys = StringUtil.split(childPath, "-", false); - if (childKeys == null || childKeys.length <= 0 || request.containsKey(childKeys[0]) == false) { - childKeys = null; - } - - - //Table<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - JSONArray response = new JSONArray(); - JSONObject parent; - SQLConfig config = new SQLConfig(requestMethod, size, page).setQuery(query); - //生成size个 - for (int i = 0; i < size; i++) { - parent = getObject(path, "" + i, request, config.setType(ObjectParser.TYPE_ITEM).setPosition(i)); - if (parent == null || parent.isEmpty()) { - break; - } - //key[]:{Table:{}}中key equals Table时 提取Table - response.add(getValue(parent, childKeys)); //null有意义 - } - //Table>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - //后面还可能用到,要还原 - request.put(JSONRequest.KEY_QUERY, query); - request.put(JSONRequest.KEY_COUNT, count); - request.put(JSONRequest.KEY_PAGE, page); - - Log.i(TAG, "getArray return response = \n" + JSON.toJSONString(response) + "\n>>>>>>>>>>>>>>>\n\n\n"); - return response; - } - - - /**根据路径取值 - * @param parent - * @param pathKeys - * @return - */ - private static Object getValue(JSONObject parent, String[] pathKeys) { - if (parent == null || pathKeys == null || pathKeys.length <= 0) { - Log.w(TAG, "getChild parent == null || pathKeys == null || pathKeys.length <= 0 >> return parent;"); - return parent; - } - - //逐层到达child的直接容器JSONObject parent - final int last = pathKeys.length - 1; - for (int i = 0; i < last; i++) {//一步一步到达指定位置 - if (parent == null) {//不存在或路径错误(中间的key对应value不是JSONObject) - break; - } - parent = getJSONObject(parent, pathKeys[i]); - } - - return parent == null ? null : parent.get(pathKeys[last]); - } - - - /**获取被依赖引用的key的路径, 实时替换[] -> []/i - * @param parentPath - * @param valuePath - * @return - */ - public static String getValuePath(String parentPath, String valuePath) { - if (valuePath.startsWith("/")) { - valuePath = getAbsPath(parentPath, valuePath); - } else {//处理[] -> []/i - valuePath = replaceArrayChildPath(parentPath, valuePath); - } - return valuePath; - } - - /**获取绝对路径 - * @param path - * @param name - * @return - */ - public static String getAbsPath(String path, String name) { - Log.i(TAG, "getPath path = " + path + "; name = " + name + " <<<<<<<<<<<<<"); - path = StringUtil.getString(path); - name = StringUtil.getString(name); - if (StringUtil.isNotEmpty(path, false)) { - if (StringUtil.isNotEmpty(name, false)) { - path += ((name.startsWith("/") ? "" : "/") + name); - } - } else { - path = name; - } - if (path.startsWith("/")) { - path = path.substring(1); - } - Log.i(TAG, "getPath return " + path + " >>>>>>>>>>>>>>>>"); - return path; - } - - /**替换[] -> []/i - * 不能写在getAbsPath里,因为name不一定是依赖路径 - * @param parentPath - * @param valuePath - * @return - */ - public static String replaceArrayChildPath(String parentPath, String valuePath) { - String[] ps = StringUtil.split(parentPath, "]/");//"[]/"); - if (ps != null && ps.length > 1) { - String[] vs = StringUtil.split(valuePath, "]/"); - - if (vs != null && vs.length > 0) { - String pos; - for (int i = 0; i < ps.length - 1; i++) { - if (ps[i] == null || ps[i].equals(vs[i]) == false) {//允许""? - break; - } - - pos = ps[i+1].contains("/") == false ? ps[i+1] - : ps[i+1].substring(0, ps[i+1].indexOf("/")); - if ( - //StringUtil.isNumer(pos) && - vs[i+1].startsWith(pos + "/") == false) { - vs[i+1] = pos + "/" + vs[i+1]; - } - } - return StringUtil.getString(vs, "]/"); - } - } - return valuePath; - } - - //依赖引用关系 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - /**将已获取完成的object的内容替换requestObject里对应的值 - * @param path object的路径 - * @param result 需要被关联的object - */ - private synchronized void putQueryResult(String path, Object result) { - Log.i(TAG, "\n putQueryResult valuePath = " + path + "; result = " + result + "\n <<<<<<<<<<<<<<<<<<<<<<<"); - // if (queryResultMap.containsKey(valuePath)) {//只保存被关联的value - Log.d(TAG, "putQueryResult queryResultMap.containsKey(valuePath) >> queryResultMap.put(path, result);"); - queryResultMap.put(path, result); - // } - } - /**根据路径获取值 - * @param valuePath - * @return parent == null ? valuePath : parent.get(keys[keys.length - 1]) - */ - private Object getValueByPath(String valuePath) { - Log.i(TAG, "<<<<<<<<<<<<<<< \n getValueByPath valuePath = " + valuePath + "\n <<<<<<<<<<<<<<<<<<"); - if (StringUtil.isEmpty(valuePath, true)) { - Log.e(TAG, "getValueByPath StringUtil.isNotEmpty(valuePath, true) == false >> return null;"); - return null; - } - Object target = queryResultMap.get(valuePath); - if (target != null) { - return target; - } - - //取出key被valuePath包含的result,再从里面获取key对应的value - Set set = queryResultMap.keySet(); - JSONObject parent = null; - String[] keys = null; - for (String path : set) { - if (valuePath.startsWith(path + "/")) { - try { - parent = (JSONObject) queryResultMap.get(path); - } catch (Exception e) { - Log.e(TAG, "getValueByPath try { parent = (JSONObject) queryResultMap.get(path); } catch { " - + "\n parent not instanceof JSONObject!"); - parent = null; - } - if (parent != null) { - keys = StringUtil.splitPath(valuePath.substring(path.length())); - } - break; - } - } - - //逐层到达targetKey的直接容器JSONObject parent - if (keys != null && keys.length > 1) { - for (int i = 0; i < keys.length - 1; i++) {//一步一步到达指定位置parentPath - if (parent == null) {//不存在或路径错误(中间的key对应value不是JSONObject) - break; - } - parent = getJSONObject(parent, keys[i]); - } - } - - if (parent != null) { - Log.i(TAG, "getValueByPath >> get from queryResultMap >> return parent.get(keys[keys.length - 1]);"); - target = parent.get(keys[keys.length - 1]); //值为null应该报错NotExistExeption,一般都是id关联,不可为null,否则可能绕过安全机制 - if (target != null) { - Log.i(TAG, "getValueByPath >> getValue >> return target = " + target); - return target; - } - } - - - //从requestObject中取值 - target = getValue(requestObject, StringUtil.splitPath(valuePath)); - if (target != null) { - Log.i(TAG, "getValueByPath >> getValue >> return target = " + target); - return target; - } - - Log.i(TAG, "getValueByPath return valuePath;"); - return valuePath; - } - - //依赖引用关系 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - - public static JSONObject getJSONObject(JSONObject object, String key) { - try { - return object.getJSONObject(key); - } catch (Exception e) { - Log.i(TAG, "getJSONObject try { return object.getJSONObject(key);" - + " } catch (Exception e) { \n" + e.getMessage()); - } - return null; - } - - - /**获取数据库返回的String - * @param config - * @return - * @throws Exception - */ - private synchronized JSONObject getSQLObject(SQLConfig config) throws Exception { - Log.i(TAG, "getSQLObject config = " + JSON.toJSONString(config)); - if (noVerifyRole == false) { - if (config.getRole() == null) { - if (globleRole != null) { - config.setRole(globleRole); - } else { - config.setRole(visitorId <= 0 ? RequestRole.UNKNOWN : RequestRole.LOGIN); - } - } - Verifier.verify(config, visitor); - } - return getCorrectResponse(requestMethod, config.getTable(), sqlExecutor.execute(config)); - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/ParserAdapter.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/ParserAdapter.java deleted file mode 100644 index 53cfb0e32..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/ParserAdapter.java +++ /dev/null @@ -1,59 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import javax.validation.constraints.NotNull; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; - -import zuo.biao.apijson.server.sql.SQLConfig; - -/** - * @author Lemon - */ -public interface ParserAdapter { - - /** - * @param path - * @return - */ - Object getTarget(@NotNull String path); - - /** - * @param path - * @param key - * @param value - * @return - * @throws Exception - */ - JSON parseChild(@NotNull String path, @NotNull String key, @NotNull JSON value) throws Exception; - - /** - * @param request - * @return - * @throws Exception - */ - JSONObject parseResponse(@NotNull JSONRequest request) throws Exception; - - /** - * @param path - * @param config - * @return - * @throws Exception - */ - JSONObject executeSQL(@NotNull String path, @NotNull SQLConfig config) throws Exception; - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Structure.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Structure.java deleted file mode 100644 index e5993b9a6..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/Structure.java +++ /dev/null @@ -1,600 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server; - -import static zuo.biao.apijson.JSONRequest.KEY_ID; -import static zuo.biao.apijson.JSONRequest.KEY_ID_IN; -import static zuo.biao.apijson.server.Operation.ADD; -import static zuo.biao.apijson.server.Operation.DISALLOW; -import static zuo.biao.apijson.server.Operation.NECESSARY; -import static zuo.biao.apijson.server.Operation.PUT; -import static zuo.biao.apijson.server.Operation.REMOVE; -import static zuo.biao.apijson.server.Operation.REPLACE; -import static zuo.biao.apijson.server.Operation.UNIQUE; -import static zuo.biao.apijson.server.Operation.VERIFY; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; -import java.util.regex.Pattern; - -import javax.activation.UnsupportedDataTypeException; -import javax.validation.constraints.NotNull; - -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; - -import apijson.demo.server.Verifier; -import apijson.demo.server.model.BaseModel; -import zuo.biao.apijson.JSON; -import zuo.biao.apijson.JSONResponse; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.RequestMethod; -import zuo.biao.apijson.RequestRole; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.model.Test; -import zuo.biao.apijson.server.sql.SQLConfig; -import zuo.biao.apijson.server.sql.SQLExecutor; - -//TODO 放到 zuo.biao.apijson 包内,供Android客户端校验请求结构 -/**结构类 - * 增删改查: OPERATION(ADD,REPLACE,PUT,REMOVE) OPERATION:{key0:value0, key1:value1 ...} - * 对值校验: VERIFY:{key0:value0, key1:value1 ...} (key{}:range,key$:"%m%"等) - * 对值重复性校验: UNIQUE:"key0:, key1 ..." (UNIQUE:"phone,email" 等) - * @author Lemon - */ -public class Structure { - private static final String TAG = "Structure"; - - - - private Structure() {} - - - - static final String requestString = "{\"Comment\":{\"DISALLOW\": \"id\", \"NECESSARY\": \"userId,momentId,content\"}, \"ADD\":{\"Comment:to\":{}}}"; - static final String responseString = "{\"User\":{\"REMOVE\": \"phone\", \"REPLACE\":{\"sex\":2}, \"ADD\":{\"name\":\"api\"}}, \"PUT\":{\"Comment:to\":{}}}"; - /**测试 - * @throws Exception - */ - public static void test() throws Exception { - JSONObject request; - try { - request = JSON.parseObject("{\"Comment\":{\"userId\":0}}"); - Log.d(TAG, "test parseRequest = " + parseRequest(RequestMethod.POST, "", JSON.parseObject(requestString), request)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - request = JSON.parseObject("{\"Comment\":{\"userId\":0, \"momentId\":0, \"content\":\"apijson\"}}"); - Log.d(TAG, "test parseRequest = " + parseRequest(RequestMethod.POST, "", JSON.parseObject(requestString), request)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - request = JSON.parseObject("{\"Comment\":{\"id\":0, \"userId\":0, \"momentId\":0, \"content\":\"apijson\"}}"); - Log.d(TAG, "test parseRequest = " + parseRequest(RequestMethod.POST, "", JSON.parseObject(requestString), request)); - } catch (Exception e) { - e.printStackTrace(); - } - - - JSONObject response; - try { - response = JSON.parseObject("{\"User\":{\"userId\":0}}"); - Log.d(TAG, "test parseResponse = " + parseResponse(RequestMethod.GET, "", JSON.parseObject(responseString), response, null)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - response = JSON.parseObject("{\"User\":{\"userId\":0, \"phone\":\"12345678\"}}"); - Log.d(TAG, "test parseResponse = " + parseResponse(RequestMethod.GET, "", JSON.parseObject(responseString), response, null)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - response = JSON.parseObject("{\"User\":{\"userId\":0, \"phone\":\"12345678\", \"sex\":1}}"); - Log.d(TAG, "test parseResponse = " + parseResponse(RequestMethod.GET, "", JSON.parseObject(responseString), response, null)); - } catch (Exception e) { - e.printStackTrace(); - } - try { - response = JSON.parseObject("{\"User\":{\"id\":0, \"name\":\"tommy\", \"phone\":\"12345678\", \"sex\":1}}"); - Log.d(TAG, "test parseResponse = " + parseResponse(RequestMethod.GET, "", JSON.parseObject(responseString), response, null)); - } catch (Exception e) { - e.printStackTrace(); - } - - } - - - - - - - /**从request提取target指定的内容 - * @param method - * @param name - * @param target - * @param request - * @return - * @throws Exception - */ - public static JSONObject parseRequest(@NotNull final RequestMethod method, final String name - , final JSONObject target, final JSONObject request) throws Exception { - Log.i(TAG, "parseRequest method = " + method + "; name = " + name - + "; target = \n" + JSON.toJSONString(target) - + "\n request = \n" + JSON.toJSONString(request)); - if (target == null || request == null) {// || request.isEmpty()) { - Log.i(TAG, "parseRequest target == null || request == null >> return null;"); - return null; - } - - //TODO globleRole要不要改成@role? 只允许服务端Request表中加上可控的ADMIN角色 - if (RequestRole.get(request.getString(JSONRequest.KEY_ROLE)) == RequestRole.ADMIN) { - throw new IllegalArgumentException("角色设置错误!不允许在写操作Request中传 " + name + - ":{ " + JSONRequest.KEY_ROLE + ":admin } !"); - } - - //解析 - return parse(name, target, request, new OnParseCallback() { - - @Override - public JSONObject onParseJSONObject(String key, JSONObject tobj, JSONObject robj) throws Exception { - // Log.i(TAG, "parseRequest.parse.onParseJSONObject key = " + key + "; robj = " + robj); - if (robj == null) { - if (tobj != null) {//不允许不传Target中指定的Table - throw new IllegalArgumentException(method.name() + "请求,请在 " + name + " 内传 " + key + ":{} !"); - } - } else if (zuo.biao.apijson.JSONObject.isTableKey(key)) { - if (method == RequestMethod.POST) { - if (robj.containsKey(KEY_ID)) { - throw new IllegalArgumentException("POST请求," + name + "/" + key + " 不能传 " + KEY_ID + " !"); - } - } else { - if (RequestMethod.isQueryMethod(method) == false) { - //单个修改或删除 - Object id = robj.get(KEY_ID); //如果必须传 id ,可在Request表中配置necessary - if (id != null) { - if (id instanceof Number == false) { - throw new IllegalArgumentException(method.name() + "请求," + name + "/" + key - + " 里面的 " + KEY_ID_IN + ":value 中value的类型只能是Long!"); - } - } else { - //批量修改或删除 - Object arr = robj.get(KEY_ID_IN); //如果必须传 id{} ,可在Request表中配置necessary - if (arr == null) { - throw new IllegalArgumentException(method.name() + "请求," + name + "/" + key - + " 里面 " + KEY_ID + " 和 " + KEY_ID_IN + " 必须传其中一个!"); - } - if (arr instanceof JSONArray == false) { - throw new IllegalArgumentException(method.name() + "请求," + name + "/" + key - + " 里面的 " + KEY_ID_IN + ":value 中value的类型只能是 [Long] !"); - } - if (((JSONArray)arr).size() > 10) { //不允许一次操作10条以上记录 - throw new IllegalArgumentException(method.name() + "请求," + name + "/" + key - + " 里面的 " + KEY_ID_IN + ":[] 中[]的长度不能超过10!"); - } - } - } - } - } - - return parseRequest(method, key, tobj, robj); - } - }); - - } - - - /**校验并将response转换为指定的内容和结构 - * @param method - * @param name - * @param target - * @param response - * @param callback - * @return - * @throws Exception - */ - public static JSONObject parseResponse(@NotNull final RequestMethod method, final String name - , final JSONObject target, final JSONObject response, OnParseCallback callback) throws Exception { - Log.i(TAG, "parseResponse method = " + method + "; name = " + name - + "; target = \n" + JSON.toJSONString(target) - + "\n response = \n" + JSON.toJSONString(response)); - if (target == null || response == null) {// || target.isEmpty() { - Log.i(TAG, "parseRequest target == null || response == null >> return response;"); - return response; - } - - //解析 - return parse(name, target, response, callback != null ? callback : new OnParseCallback() {}); - } - - - /**对request和response不同的解析用callback返回 - * @param target - * @param request - * @param callback - * @return - * @throws Exception - */ - public static JSONObject parse(String name, JSONObject target, JSONObject real - , @NotNull OnParseCallback callback) throws Exception { - if (target == null) { - return null; - } - - - //获取配置<<<<<<<<<<<<<<<<<<<<<<<<<<<< - JSONObject verify = target.getJSONObject(VERIFY.name()); - JSONObject add = target.getJSONObject(ADD.name()); - JSONObject put = target.getJSONObject(PUT.name()); - JSONObject replace = target.getJSONObject(REPLACE.name()); - - String unique = StringUtil.getNoBlankString(target.getString(UNIQUE.name())); - String remove = StringUtil.getNoBlankString(target.getString(REMOVE.name())); - String necessary = StringUtil.getNoBlankString(target.getString(NECESSARY.name())); - String disallow = StringUtil.getNoBlankString(target.getString(DISALLOW.name())); - - //不还原,传进来的target不应该是原来的 - target.remove(VERIFY.name()); - target.remove(ADD.name()); - target.remove(PUT.name()); - target.remove(REPLACE.name()); - - target.remove(UNIQUE.name()); - target.remove(REMOVE.name()); - target.remove(NECESSARY.name()); - target.remove(DISALLOW.name()); - //获取配置>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //移除字段<<<<<<<<<<<<<<<<<<< - String[] removes = StringUtil.split(remove); - if (removes != null && removes.length > 0) { - for (String r : removes) { - real.remove(r); - } - } - //移除字段>>>>>>>>>>>>>>>>>>> - - //判断必要字段是否都有<<<<<<<<<<<<<<<<<<< - String[] necessarys = StringUtil.split(necessary); - List necessaryList = necessarys == null ? new ArrayList() : Arrays.asList(necessarys); - for (String s : necessaryList) { - if (real.get(s) == null) {//可能传null进来,这里还会通过 real.containsKey(s) == false) { - throw new IllegalArgumentException(name - + " 里面不能缺少 " + s + " 等[" + necessary + "]内的任何字段!"); - } - } - //判断必要字段是否都有>>>>>>>>>>>>>>>>>>> - - - Set objKeySet = new HashSet(); //不能用tableKeySet,仅判断 Table:{} 会导致 key:{ Table:{} } 绕过判断 - - //解析内容<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - - Set> set = new LinkedHashSet<>(target.entrySet()); - if (set.isEmpty() == false) { - - String key; - Object tvalue; - Object rvalue; - for (Entry entry : set) { - key = entry == null ? null : entry.getKey(); - if (key == null) { - continue; - } - tvalue = entry.getValue(); - rvalue = real.get(key); - if (callback.onParse(key, tvalue, rvalue) == false) { - continue; - } - - if (tvalue instanceof JSONObject) {//JSONObject,往下一级提取 - tvalue = callback.onParseJSONObject(key, (JSONObject) tvalue, (JSONObject) rvalue); - - objKeySet.add(key); - } else if (tvalue instanceof JSONArray) {//JSONArray - tvalue = callback.onParseJSONArray(key, (JSONArray) tvalue, (JSONArray) rvalue); - } else {//其它Object - tvalue = callback.onParseObject(key, tvalue, rvalue); - } - - if (tvalue != null) {//可以在target中加上一些不需要客户端传的键值对 - real.put(key, tvalue); - } - } - - } - - //解析内容>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - Set rkset = real.keySet(); //解析内容并没有改变rkset - - //解析不允许的字段<<<<<<<<<<<<<<<<<<< - List disallowList = new ArrayList(); - if ("!".equals(disallow)) {//所有非necessary,改成 !necessary 更好 - for (String key : rkset) {//对@key放行,@role,@column,自定义@position等 - if (key != null && key.startsWith("@") == false - && necessaryList.contains(key) == false && objKeySet.contains(key) == false) { - disallowList.add(key); - } - } - } else { - String[] disallows = StringUtil.split(disallow); - if (disallows != null && disallows.length > 0) { - disallowList.addAll(Arrays.asList(disallows)); - } - } - //解析不允许的字段>>>>>>>>>>>>>>>>>>> - - - //判断不允许传的key<<<<<<<<<<<<<<<<<<<<<<<<< - for (String rk : rkset) { - if (disallowList.contains(rk)) { //不允许的字段 - throw new IllegalArgumentException(name - + " 里面不允许传 " + rk + " 等" + StringUtil.getString(disallowList) + "内的任何字段!"); - } - - if (rk == null) { //无效的key - real.remove(rk); - continue; - } - - //不在target内的 key:{} - if (rk.startsWith("@") == false && objKeySet.contains(rk) == false && real.get(rk) instanceof JSONObject) { - throw new UnsupportedOperationException(name + " 里面不允许传 " + rk + ":{} !"); - } - } - //判断不允许传的key>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //校验与修改Request<<<<<<<<<<<<<<<<< - //在tableKeySet校验后操作,避免 导致put/add进去的Table 被当成原Request的内容 - real = operate(VERIFY, verify, real); - real = operate(ADD, add, real); - real = operate(PUT, put, real); - real = operate(REPLACE, replace, real); - //校验与修改Request>>>>>>>>>>>>>>>>> - - //TODO放在operate前?考虑性能、operate修改后再验证的值是否和原来一样 - //校验重复<<<<<<<<<<<<<<<<<<< - String[] uniques = StringUtil.split(unique); - if (BaseModel.isEmpty(uniques) == false) { - long exceptId = real.getLongValue(KEY_ID); - for (String u : uniques) { - Verifier.verifyRepeat(name, u, real.get(u), exceptId); - } - } - //校验重复>>>>>>>>>>>>>>>>>>> - - Log.i(TAG, "parse return real = " + JSON.toJSONString(real)); - return real; - } - - - - /**执行操作 - * @param opt - * @param targetChild - * @param real - * @return - * @throws Exception - */ - private static JSONObject operate(Operation opt, JSONObject targetChild, JSONObject real) throws Exception { - if (targetChild == null) { - return real; - } - if (real == null) { - throw new IllegalArgumentException("operate real == null!!!"); - } - - - Set> set = new LinkedHashSet<>(targetChild.entrySet()); - String tk; - Object tv; - - for (Entry e : set) { - tk = e == null ? null : e.getKey(); - if (tk == null) { - continue; - } - tv = e.getValue(); - - if (opt == VERIFY) { - verify(tk, tv, real); - } else if (opt == PUT) { - real.put(tk, tv); - } else { - if (real.containsKey(tk)) { - if (opt == REPLACE) { - real.put(tk, tv); - } - } else { - if (opt == ADD) { - real.put(tk, tv); - } - } - } - } - - return real; - } - - - /**验证值 - * @param tk - * @param tv - * @param real - * @throws Exception - */ - private static void verify(@NotNull String tk, @NotNull Object tv, @NotNull JSONObject real) throws Exception { - if (tv == null) { - throw new IllegalArgumentException("operate operate == VERIFY " + tk + ":" + tv + " , >> tv == null!!!"); - } - - String rk; - Object rv; - Logic logic; - if (tk.endsWith("$")) { //搜索 - sqlVerify("$", real, tk, tv); - } - else if (tk.endsWith("?")) { //正则表达式 - logic = new Logic(tk.substring(0, tk.length() - 1)); - rk = logic.getKey(); - rv = real.get(rk); - if (rv == null) { - return; - } - - JSONArray array = SQLConfig.newJSONArray(tv); - - boolean m; - boolean isOr = false; - Pattern reg; - for (Object r : array) { - if (r instanceof String == false) { - throw new UnsupportedDataTypeException(rk + ":" + rv + " 中value只支持 String 或 [String] 类型!"); - } - reg = ObjectParser.COMPILE_MAP.get(r); - if (reg == null) { - reg = Pattern.compile((String) r); - } - m = reg.matcher("" + rv).matches(); - if (m) { - if (logic.isNot()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - if (logic.isOr()) { - isOr = true; - break; - } - } else { - if (logic.isAnd()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - } - } - - if (isOr == false && logic.isOr()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - } - else if (tk.endsWith("{}")) { //rv符合tv条件或在tv内 - if (tv instanceof String) {//TODO >= 0, < 10 - sqlVerify("{}", real, tk, tv); - } - else if (tv instanceof JSONArray) { - logic = new Logic(tk.substring(0, tk.length() - 2)); - rk = logic.getKey(); - rv = real.get(rk); - if (rv == null) { - return; - } - - if (((JSONArray) tv).contains(rv) == logic.isNot()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - } - else { - throw new UnsupportedDataTypeException("服务器Request表verify配置错误!"); - } - } - else if (tk.endsWith("<>")) { //rv包含tv内的值 - logic = new Logic(tk.substring(0, tk.length() - 2)); - rk = logic.getKey(); - rv = real.get(rk); - if (rv == null) { - return; - } - - if (rv instanceof JSONArray == false) { - throw new UnsupportedDataTypeException("服务器Request表verify配置错误!"); - } - - JSONArray array = SQLConfig.newJSONArray(tv); - - boolean isOr = false; - for (Object o : array) { - if (((JSONArray) rv).contains(o)) { - if (logic.isNot()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - if (logic.isOr()) { - isOr = true; - break; - } - } else { - if (logic.isAnd()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - } - } - - if (isOr == false && logic.isOr()) { - throw new IllegalArgumentException(rk + ":value 中value不合法!必须匹配 " + tk + ":" + tv + " !"); - } - } - else { - throw new IllegalArgumentException("服务器Request表verify配置错误!"); - } - } - - /**通过数据库执行SQL语句来验证条件 - * @param funChar - * @param real - * @param tk - * @param tv - * @throws Exception - */ - private static void sqlVerify(@NotNull String funChar, JSONObject real, String tk, Object tv) throws Exception { - //不能用Parser, 0 这种不符合 StringUtil.isName ! - Logic logic = new Logic(tk.substring(0, tk.length() - funChar.length())); - String rk = logic.getKey(); - Object rv = real.get(rk); - if (rv == null) { - return; - } - - SQLConfig config = new SQLConfig(RequestMethod.HEAD, 1, 0); - config.setTable(Test.class.getSimpleName()); - config.setTest(true); - config.addWhere("'" + rv + "'" + logic.getChar() + funChar, tv); - - SQLExecutor executor = new SQLExecutor(); - JSONObject result = null; - try { - result = executor.execute(config); - } catch (Exception e) { - throw e; - } finally { - executor.close(); - } - if (result != null && JSONResponse.isExist(result.getIntValue(JSONResponse.KEY_COUNT)) == false) { - throw new IllegalArgumentException(rk + ":" + rv + "中value不合法!必须匹配 " + logic.getChar() + tv + " !"); - } - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConditionErrorException.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConditionErrorException.java deleted file mode 100644 index 3e7d81b19..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConditionErrorException.java +++ /dev/null @@ -1,33 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.exception; - -/**条件错误 - * @author Lemon - */ -public class ConditionErrorException extends Exception { - private static final long serialVersionUID = 1L; - - public ConditionErrorException(String msg) { - super(msg); - } - public ConditionErrorException(Throwable t) { - super(t); - } - public ConditionErrorException(String msg, Throwable t) { - super(msg, t); - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConflictException.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConflictException.java deleted file mode 100644 index b32e2a7ba..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/ConflictException.java +++ /dev/null @@ -1,33 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.exception; - -/**冲突 - * @author Lemon - */ -public class ConflictException extends Exception { - private static final long serialVersionUID = 1L; - - public ConflictException(String msg) { - super(msg); - } - public ConflictException(Throwable t) { - super(t); - } - public ConflictException(String msg, Throwable t) { - super(msg, t); - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotExistException.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotExistException.java deleted file mode 100644 index ef1e2f3d1..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotExistException.java +++ /dev/null @@ -1,34 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.exception; - -/**不存在,可接受,内部吃掉 - * @author Lemon - */ -public class NotExistException extends Exception { - private static final long serialVersionUID = 1L; - - public NotExistException(String msg) { - super(msg); - } - public NotExistException(Throwable t) { - super(t); - } - public NotExistException(String msg, Throwable t) { - super(msg, t); - } - -} - diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotLoggedInException.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotLoggedInException.java deleted file mode 100644 index 79bc9a8b6..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/NotLoggedInException.java +++ /dev/null @@ -1,33 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.exception; - -/**未登录 - * @author Lemon - */ -public class NotLoggedInException extends Exception { - private static final long serialVersionUID = 1L; - - public NotLoggedInException(String msg, Throwable t) { - super(msg, t); - } - public NotLoggedInException(String msg) { - super(msg); - } - public NotLoggedInException(Throwable t) { - super(t); - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/OutOfRangeException.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/OutOfRangeException.java deleted file mode 100644 index 09d9c5cb8..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/OutOfRangeException.java +++ /dev/null @@ -1,33 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.exception; - -/**超出范围 - * @author Lemon - */ -public class OutOfRangeException extends Exception { - private static final long serialVersionUID = 1L; - - public OutOfRangeException(String msg) { - super(msg); - } - public OutOfRangeException(Throwable t) { - super(t); - } - public OutOfRangeException(String msg, Throwable t) { - super(msg, t); - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/package-info.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/package-info.java deleted file mode 100755 index 06ff39e98..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/exception/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -/** - * exception files package - */ -/** - * @author Lemon - * - */ -package zuo.biao.apijson.server.exception; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/package-info.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/package-info.java deleted file mode 100755 index aadcdd817..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -/** - * server files package - */ -/** - * @author Lemon - * - */ -package zuo.biao.apijson.server; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLConfig.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLConfig.java deleted file mode 100755 index 730d2a3c6..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLConfig.java +++ /dev/null @@ -1,1324 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.sql; - -import static zuo.biao.apijson.JSONObject.KEY_ABOUT; -import static zuo.biao.apijson.JSONObject.KEY_COLUMN; -import static zuo.biao.apijson.JSONObject.KEY_CONDITION; -import static zuo.biao.apijson.JSONObject.KEY_GROUP; -import static zuo.biao.apijson.JSONObject.KEY_HAVING; -import static zuo.biao.apijson.JSONObject.KEY_ID; -import static zuo.biao.apijson.JSONObject.KEY_ID_IN; -import static zuo.biao.apijson.JSONObject.KEY_ORDER; -import static zuo.biao.apijson.JSONObject.KEY_ROLE; -import static zuo.biao.apijson.JSONObject.KEY_SCHEMA; -import static zuo.biao.apijson.JSONRequest.KEY_COUNT; -import static zuo.biao.apijson.JSONRequest.KEY_PAGE; -import static zuo.biao.apijson.JSONRequest.KEY_QUERY; -import static zuo.biao.apijson.RequestMethod.DELETE; -import static zuo.biao.apijson.RequestMethod.GET; -import static zuo.biao.apijson.RequestMethod.POST; -import static zuo.biao.apijson.RequestMethod.PUT; -import static zuo.biao.apijson.SQL.AND; -import static zuo.biao.apijson.SQL.NOT; -import static zuo.biao.apijson.SQL.OR; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.validation.constraints.NotNull; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.alibaba.fastjson.annotation.JSONField; - -import apijson.demo.server.model.BaseModel; -import apijson.demo.server.model.Privacy; -import apijson.demo.server.model.User; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.RequestMethod; -import zuo.biao.apijson.RequestRole; -import zuo.biao.apijson.SQL; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.model.Column; -import zuo.biao.apijson.model.Table; -import zuo.biao.apijson.server.Logic; -import zuo.biao.apijson.server.Pair; -import zuo.biao.apijson.server.exception.NotExistException; - -/**config sql for JSON Request - * @author Lemon - */ -public class SQLConfig { - private static final String TAG = "SQLConfig"; - - - - public static final String SCHEMA_INFORMATION = "`information_schema`"; - public static final String TABLE_SCHEMA = "`table_schema`"; - public static final String TABLE_NAME = "`table_name`"; - - - - - public static final List ARRAY_KEY_LIST; - static { - ARRAY_KEY_LIST = new ArrayList(); - ARRAY_KEY_LIST.add(KEY_QUERY); - ARRAY_KEY_LIST.add(KEY_COUNT); - ARRAY_KEY_LIST.add(KEY_PAGE); - } - public static final List TABLE_KEY_LIST; - static { - TABLE_KEY_LIST = new ArrayList(); - TABLE_KEY_LIST.add(KEY_ROLE); - TABLE_KEY_LIST.add(KEY_CONDITION); - TABLE_KEY_LIST.add(KEY_SCHEMA); - TABLE_KEY_LIST.add(KEY_ABOUT); - TABLE_KEY_LIST.add(KEY_COLUMN); - TABLE_KEY_LIST.add(KEY_GROUP); - TABLE_KEY_LIST.add(KEY_HAVING); - TABLE_KEY_LIST.add(KEY_ORDER); - } - - - - //表名映射,隐藏真实表名,对安全要求很高的表可以这么做 - public static final Map TABLE_KEY_MAP; - static { - TABLE_KEY_MAP = new HashMap(); - TABLE_KEY_MAP.put(Table.class.getSimpleName(), Table.TAG); - TABLE_KEY_MAP.put(Column.class.getSimpleName(), Column.TAG); - - TABLE_KEY_MAP.put(User.class.getSimpleName(), "apijson_user"); - TABLE_KEY_MAP.put(Privacy.class.getSimpleName(), "apijson_privacy"); - } - - - - private long id; //Table的id - private RequestMethod method; //操作方法 - /** - * TODO 被关联的表通过就忽略关联的表?(这个不行 User:{"sex@":"/Comment/toId"}) - */ - private RequestRole role; //发送请求的用户的角色 - private String schema; //Table所在的数据库 - private String table; //Table名 - private boolean about; //关于,返回数据库表的信息,包括表说明和字段说明 - private String group; //分组方式的字符串数组,','分隔 - private String having; //聚合函数的字符串数组,','分隔 - private String order; //排序方式的字符串数组,','分隔 - private String column; //Table内字段名(或函数名,仅查询操作可用)的字符串数组,','分隔 - private String values; //对应Table内字段的值的字符串数组,','分隔 - private Map content; //Request内容,key:value形式,column = content.keySet(),values = content.values() - private Map where; //筛选条件,key:value形式 - - - //array item <<<<<<<<<< - private int count; //Table数量 - private int page; //Table所在页码 - private int position; //Table在[]中的位置 - private int query; //JSONRequest.query - private int type; //ObjectParser.type - //array item >>>>>>>>>> - private boolean test; //测试 - private boolean cacheStatic; //静态缓存 - - public SQLConfig(RequestMethod method) { - setMethod(method); - } - public SQLConfig(RequestMethod method, String table) { - this(method); - setTable(table); - } - public SQLConfig(RequestMethod method, int count, int page) { - this(method); - setCount(count); - setPage(page); - } - - @NotNull - public RequestMethod getMethod() { - if (method == null) { - method = GET; - } - return method; - } - public SQLConfig setMethod(RequestMethod method) { - this.method = method; - return this; - } - - - - public long getId() { - return id; - } - public SQLConfig setId(long id) { - this.id = id; - return this; - } - - public RequestRole getRole() { - //不能 @NotNull , Parser#getSQLObject 内当getRole() == null时填充默认值 - return role; - } - public SQLConfig setRole(String roleName) { - return setRole(RequestRole.get(roleName)); - } - public SQLConfig setRole(RequestRole role) { - this.role = role; - return this; - } - - public String getSchema() { - String sqlTable = getSQLTable(); - if (sqlTable != null && sqlTable.startsWith("`")) { - return SCHEMA_INFORMATION; - } - return getSchema(schema); - } - public static String getSchema(String schema) { - if (StringUtil.isEmpty(schema, true)) { - schema = "sys"; //非默认Schema必须要有 - } - return schema; - } - public SQLConfig setSchema(String schema) { - this.schema = schema; - return this; - } - /**请求传进来的Table名 - * @return - * @see {@link #getSQLTable()} - */ - public String getTable() { - return table; - } - /**数据库里的真实Table名 - * 通过 {@link #TABLE_KEY_MAP} 映射 - * @return - */ - @JSONField(serialize = false) - public String getSQLTable() { - return TABLE_KEY_MAP.containsKey(table) ? TABLE_KEY_MAP.get(table) : table; - } - @JSONField(serialize = false) - public String getTablePath() { - return getSchema() + "." + getSQLTable(); - } - public SQLConfig setTable(String table) { - this.table = table; - return this; - } - - public boolean isAbout() { - return about; - } - public SQLConfig setAbout(boolean about) { - this.about = about; - return this; - } - - public String getGroup() { - return group; - } - public SQLConfig setGroup(String... keys) { - return setGroup(StringUtil.getString(keys)); - } - public SQLConfig setGroup(String group) { - this.group = group; - return this; - } - @JSONField(serialize = false) - public String getGroupString() { - group = StringUtil.getTrimedString(group); - return group.isEmpty() ? "" : " GROUP BY " + group; - } - - public String getHaving() { - return having; - } - public SQLConfig setHaving(String... conditions) { - return setHaving(StringUtil.getString(conditions)); - } - public SQLConfig setHaving(String having) { - this.having = having; - return this; - } - @JSONField(serialize = false) - public String getHavingString() { - having = StringUtil.getTrimedString(having); - return having.isEmpty() ? "" : " HAVING " + having; - } - - public String getOrder() { - return order; - } - public SQLConfig setOrder(String... conditions) { - return setOrder(StringUtil.getString(conditions)); - } - public SQLConfig setOrder(String order) { - this.order = order; - return this; - } - @JSONField(serialize = false) - public String getOrderString() { - order = StringUtil.getTrimedString(order); - if (order.isEmpty()) { - return ""; - } - if (order.contains("+")) {//replace没有包含的replacement会崩溃 - order = order.replaceAll("\\+", " ASC "); - } - if (order.contains("-")) { - order = order.replaceAll("-", " DESC "); - } - return " ORDER BY " + order; - } - - - - public String getColumn() { - return column; - } - public SQLConfig setColumn(String... keys) { - return setColumn(StringUtil.getString(keys)); - } - public SQLConfig setColumn(String column) { - this.column = column; - return this; - } - @JSONField(serialize = false) - public String getColumnString() throws NotExistException { - switch (getMethod()) { - case HEAD: - case HEADS: - return SQL.count(column); - case POST: - if (StringUtil.isEmpty(column, true)) { - throw new NotExistException(TAG + "getColumnString getMethod() = POST" - + " >> StringUtil.isEmpty(column, true)"); - } - return "(" + column + ")"; - default: - column = StringUtil.getString(column); - if (column.isEmpty()) { - return "*"; - } - return column.contains(":") == false ? column : column.replaceAll(":", " AS ");//不能在这里改,后续还要用到: - } - } - - - public String getValues() { - return values; - } - @JSONField(serialize = false) - public String getValuesString() { - return values; - } - public SQLConfig setValues(String[][] valuess) { - String s = ""; - if (BaseModel.isEmpty(valuess) == false) { - String[] items = new String[valuess.length]; - for (int i = 0; i < valuess.length; i++) { - items[i] = "(" + StringUtil.getString(valuess[i]) + ")"; - } - s = StringUtil.getString(items); - } - return setValues(s); - } - public SQLConfig setValues(String values) { - this.values = values; - return this; - } - - public Map getContent() { - return content; - } - public SQLConfig setContent(Map content) { - this.content = content; - return this; - } - - public int getCount() { - return count; - } - public SQLConfig setCount(int count) { - this.count = count; - return this; - } - public int getPage() { - return page; - } - public SQLConfig setPage(int page) { - this.page = page; - return this; - } - public int getPosition() { - return position; - } - public SQLConfig setPosition(int position) { - this.position = position; - return this; - } - - public int getQuery() { - return query; - } - public SQLConfig setQuery(int query) { - this.query = query; - return this; - } - public int getType() { - return type; - } - public SQLConfig setType(int type) { - this.type = type; - return this; - } - - public boolean isTest() { - return test; - } - public SQLConfig setTest(boolean test) { - this.test = test; - return this; - } - public boolean isCacheStatic() { - return cacheStatic; - } - public SQLConfig setCacheStatic(boolean cacheStatic) { - this.cacheStatic = cacheStatic; - return this; - } - - - /**获取初始位置offset - * @return - */ - @JSONField(serialize = false) - public int getOffset() { - return getOffset(getPage(), getCount()); - } - /**获取初始位置offset - * @param page - * @param count - * @return - */ - public static int getOffset(int page, int count) { - return page*count; - } - /**获取限制数量 - * @return - */ - @JSONField(serialize = false) - public String getLimitString() { - return getLimitString(getPage(), getCount());// + 1); - } - /**获取限制数量 - * @param limit - * @return - */ - public static String getLimitString(int page, int count) { - return count <= 0 ? "" : " LIMIT " + getOffset(page, count) + ", " + count; - } - - //WHERE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - public Map getWhere() { - return where; - } - public SQLConfig setWhere(Map where) { - this.where = where; - return this; - } - /** - * noFunctionChar = false - * @param key - * @return - */ - @JSONField(serialize = false) - public Object getWhere(String key) { - return getWhere(key, false); - } - /** - * @param key - * @param exactMatch - * @return - */ - @JSONField(serialize = false) - public Object getWhere(String key, boolean exactMatch) { - if (exactMatch) { - return where == null ? null : where.get(key); - } - - Set set = key == null || where == null ? null : where.keySet(); - if (set != null) { - synchronized (where) { - if (where != null) { - int index; - for (String k : set) { - index = k.indexOf(key); - if (index >= 0 && StringUtil.isName(k.substring(index)) == false) { - return where.get(k); - } - } - } - } - } - return null; - } - public SQLConfig addWhere(String key, Object value) { - if (key != null) { - if (where == null) { - where = new LinkedHashMap(); - } - where.put(key, value); - } - return this; - } - - /**获取WHERE - * @return - * @throws Exception - */ - @JSONField(serialize = false) - public String getWhereString() throws Exception { - return getWhereString(getMethod(), getWhere(), ! isTest()); - } - /**获取WHERE - * @param method - * @param where - * @return - * @throws Exception - */ - public static String getWhereString(RequestMethod method, Map where, boolean verifyName) throws Exception { - Set set = where == null ? null : where.keySet(); - if (BaseModel.isEmpty(set)) { - return ""; - } - String whereString = ""; - boolean isFirst = true; - - String condition; - for (String key : set) { - condition = getWhereItem(key, where.get(key), method, verifyName); - - if (StringUtil.isEmpty(condition, true)) {//避免SQL条件连接错误 - continue; - } - - whereString += (isFirst ? "" : AND) + "(" + condition + ")"; - - isFirst = false; - } - - String s = whereString.isEmpty() ? "" : " WHERE " + whereString; - - if (s.isEmpty() && RequestMethod.isQueryMethod(method) == false) { - throw new UnsupportedOperationException("写操作请求必须带条件!!!"); - } - - return s; - } - - /** - * @param key - * @param value - * @param method - * @param verifyName - * @return - * @throws Exception - */ - private static String getWhereItem(String key, Object value - , RequestMethod method, boolean verifyName) throws Exception { - Log.d(TAG, "getWhereItem key = " + key); - //避免筛选到全部 value = key == null ? null : where.get(key); - if (key == null || value == null || key.startsWith("@") || key.endsWith("()")) {//关键字||方法, +或-直接报错 - Log.d(TAG, "getWhereItem key == null || value == null" - + " || key.startsWith(@) || key.endsWith(()) >> continue;"); - return null; - } - if (key.endsWith("@")) {//引用 - // key = key.substring(0, key.lastIndexOf("@")); - throw new IllegalArgumentException(TAG + ".getWhereItem: 字符 " + key + " 不合法!"); - } - - int keyType; - if (key.endsWith("$")) { - keyType = 1; - } - else if (key.endsWith("?")) { - keyType = 2; - } - else if (key.endsWith("{}")) { - keyType = 3; - } - else if (key.endsWith("<>")) { - keyType = 4; - } - else { //else绝对不能省,避免再次踩坑! keyType = 0; 写在for循环外面都没注意! - keyType = 0; - } - key = getRealKey(method, key, false, true, verifyName); - - switch (keyType) { - case 1: - return getSearchString(key, value); - case 2: - return getRegExpString(key, value); - case 3: - return getRangeString(key, value); - case 4: - return getContainString(key, value); - default: - return (key + "='" + value + "'"); - } - } - - - //$ search <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**search key match value - * @param in - * @return {@link #getSearchString(String, Object[], int)} - * @throws IllegalArgumentException - */ - public static String getSearchString(String key, Object value) throws IllegalArgumentException { - if (value == null) { - return ""; - } - - Logic logic = new Logic(key); - key = logic.getKey(); - Log.i(TAG, "getRangeString key = " + key); - - JSONArray arr = newJSONArray(value); - if (arr.isEmpty()) { - return ""; - } - return getSearchString(key, arr.toArray(), logic.getType()); - } - /**search key match values - * @param in - * @return LOGIC [ key LIKE 'values[i]' ] - * @throws IllegalArgumentException - */ - public static String getSearchString(String key, Object[] values, int type) throws IllegalArgumentException { - if (values == null || values.length <= 0) { - return ""; - } - - String condition = ""; - for (int i = 0; i < values.length; i++) { - if (values[i] instanceof String == false) { - throw new IllegalArgumentException(key + "$\":value 中value只能为String或JSONArray!"); - } - condition += (i <= 0 ? "" : (Logic.isAnd(type) ? AND : OR)) + getLikeString(key, values[i]); - } - - return getCondition(Logic.isNot(type), condition); - } - - /**WHERE key LIKE 'value' - * @param key endsWith("!") ? key = key.substring(0, key.length() - 1) + NOT; - * @param value - * @return key LIKE 'value' - */ - public static String getLikeString(String key, Object value) { - return key + " LIKE '" + value + "'"; - } - //$ search >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //$ search <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**search key match RegExps value - * @param in - * @return {@link #getRegExpString(String, Object[], int)} - * @throws IllegalArgumentException - */ - public static String getRegExpString(String key, Object value) throws IllegalArgumentException { - if (value == null) { - return ""; - } - - Logic logic = new Logic(key); - key = logic.getKey(); - Log.i(TAG, "getRangeString key = " + key); - - JSONArray arr = newJSONArray(value); - if (arr.isEmpty()) { - return ""; - } - return getRegExpString(key, arr.toArray(), logic.getType()); - } - /**search key match RegExp values - * @param in - * @return LOGIC [ key REGEXP 'values[i]' ] - * @throws IllegalArgumentException - */ - public static String getRegExpString(String key, Object[] values, int type) throws IllegalArgumentException { - if (values == null || values.length <= 0) { - return ""; - } - - String condition = ""; - for (int i = 0; i < values.length; i++) { - if (values[i] instanceof String == false) { - throw new IllegalArgumentException(key + "$\":value 中value只能为String或JSONArray!"); - } - condition += (i <= 0 ? "" : (Logic.isAnd(type) ? AND : OR)) + getRegExpString(key, (String) values[i]); - } - - return getCondition(Logic.isNot(type), condition); - } - - /**WHERE key REGEXP 'value' - * @param key - * @param value - * @return key REGEXP 'value' - */ - public static String getRegExpString(String key, String value) { - return key + " REGEXP '" + value + "'"; - } - //$ search >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - - //{} range <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**WHERE key > 'key0' AND key <= 'key1' AND ... - * @param key - * @param range "condition0,condition1..." - * @return key condition0 AND key condition1 AND ... - * @throws Exception - */ - public static String getRangeString(String key, Object range) throws Exception { - Log.i(TAG, "getRangeString key = " + key); - if (range == null) {//依赖的对象都没有给出有效值,这个存在无意义。如果是客户端传的,那就能在客户端确定了。 - throw new NotExistException(TAG + "getRangeString(" + key + ", " + range - + ") range == null"); - } - - Logic logic = new Logic(key); - key = logic.getKey(); - Log.i(TAG, "getRangeString key = " + key); - - if (range instanceof List) { - if (logic.isOr() || logic.isNot()) { - return key + getInString(key, ((List) range).toArray(), logic.isNot()); - } - throw new IllegalArgumentException(key + "{}\":[] 中key末尾的逻辑运算符只能用'|','!'中的一种 !"); - } - if (range instanceof String) {//非Number类型需要客户端拼接成 < 'value0', >= 'value1'这种 - String[] conditions = StringUtil.split((String) range); - String condition = ""; - if (conditions != null) { - int index; - for (int i = 0; i < conditions.length; i++) {//对函数条件length(key)<=5这种不再在开头加key - index = conditions[i] == null ? -1 : conditions[i].indexOf("("); - condition += ((i <= 0 ? "" : (logic.isAnd() ? AND : OR))//连接方式 - + (index >= 0 && index < conditions[i].indexOf(")") ? "" : key + " ")//函数和非函数条件 - + conditions[i]);//单个条件 - } - } - if (condition.isEmpty()) { - return ""; - } - return getCondition(logic.isNot(), condition); - } - - throw new IllegalArgumentException(key + "{}:range 类型为" + range.getClass().getSimpleName() - + "!range只能是 用','分隔条件的字符串 或者 可取选项JSONArray!"); - } - /**WHERE key IN ('key0', 'key1', ... ) - * @param in - * @return IN ('key0', 'key1', ... ) - * @throws NotExistException - */ - public static String getInString(String key, Object[] in, boolean not) throws NotExistException { - String condition = ""; - if (in != null) {//返回 "" 会导致 id:[] 空值时效果和没有筛选id一样! - for (int i = 0; i < in.length; i++) { - condition += ((i > 0 ? "," : "") + "'" + in[i] + "'"); - } - } - if (condition.isEmpty()) {//条件如果存在必须执行,不能忽略。条件为空会导致出错,又很难保证条件不为空(@:条件),所以还是这样好 - throw new NotExistException(TAG + ".getInString(" + key + ", [], " + not - + ") >> condition.isEmpty() >> IN()"); - } - return (not ? NOT : "") + " IN (" + condition + ")"; - } - //{} range >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //<> contain <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**WHERE key contains value - * @param key - * @param value - * @return {@link #getContainString(String, Object[], int)} - * @throws NotExistException - */ - public static String getContainString(String key, Object value) throws NotExistException { - if (value == null) { - return ""; - } - - Logic logic = new Logic(key); - key = logic.getKey(); - Log.i(TAG, "getRangeString key = " + key); - - //TODO 直接调Like性能最好! - return getContainString(key, newJSONArray(value).toArray(), logic.getType()); - } - /**WHERE key contains childs - * @param key - * @param childs null ? "" : (empty ? no child : contains childs) - * @param type |, &, ! - * @return LOGIC [ ( key LIKE '[" + childs[i] + "]' OR key LIKE '[" + childs[i] + ", %' - * OR key LIKE '%, " + childs[i] + ", %' OR key LIKE '%, " + childs[i] + "]' ) ] - * @throws IllegalArgumentException - */ - public static String getContainString(String key, Object[] childs, int type) throws IllegalArgumentException { - String condition = ""; - if (childs != null) { - for (int i = 0; i < childs.length; i++) { - if (childs[i] != null) { - if (childs[i] instanceof JSON) { - throw new IllegalArgumentException(key + "<>\":value 中value类型不能为JSON!"); - } - if (childs[i] instanceof String) { - childs[i] = "\"" + childs[i] + "\""; - } - condition += (i <= 0 ? "" : (Logic.isAnd(type) ? AND : OR)) - + "(" + getSearchString( - key - , new String[]{ - "[" + childs[i] + "]", //全等 - "[" + childs[i] + ", %", //开始 - "%, " + childs[i] + ", %", //中间 - "%, " + childs[i] + "]" //末尾 - } - , Logic.TYPE_OR - ) + ")"; - } - } - if (condition.isEmpty()) { - condition = (SQL.isEmpty(key, true) + OR + getLikeString(key, "[]")); - } - } - if (condition.isEmpty()) { - return ""; - } - return getCondition(Logic.isNot(type), condition); - } - //<> contain >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - /**拼接条件 - * @param not - * @param condition - * @return - */ - private static String getCondition(boolean not, String condition) { - return not ? NOT + "(" + condition + ")" : condition; - } - - - /**转为JSONArray - * @param tv - * @return - */ - @NotNull - public static JSONArray newJSONArray(Object obj) { - JSONArray array = new JSONArray(); - if (obj != null) { - if (obj instanceof Collection) { - array.addAll((Collection) obj); - } else { - array.add(obj); - } - } - return array; - } - - //WHERE >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - //SET <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - /**获取SET - * @return - * @throws Exception - */ - @JSONField(serialize = false) - public String getSetString() throws Exception { - return getSetString(getMethod(), getContent(), ! isTest()); - } - /**获取SET - * @param method - * @param content - * @return - * @throws Exception - */ - public static String getSetString(RequestMethod method, Map content, boolean verifyName) throws Exception { - Set set = content == null ? null : content.keySet(); - if (set != null && set.size() > 0) { - String setString = ""; - boolean isFirst = true; - int keyType = 0;// 0 - =; 1 - +, 2 - - - Object value; - for (String key : set) { - //避免筛选到全部 value = key == null ? null : content.get(key); - if (key == null || KEY_ID.equals(key)) { - continue; - } - - if (key.endsWith("+")) { - keyType = 1; - } else if (key.endsWith("-")) { - keyType = 2; - } - value = content.get(key); - key = getRealKey(method, key, false, true, verifyName); - - setString += (isFirst ? "" : ", ") + (key + "=" + (keyType == 1 ? getAddString(key, value) : (keyType == 2 - ? getRemoveString(key, value) : "'" + value + "'") ) ); - - isFirst = false; - } - if (setString.isEmpty()) { - throw new NotExistException(TAG + "getSetString >> setString.isEmpty()"); - } - return " SET " + setString; - } - return ""; - } - - /**SET key = CONCAT (key, 'value') - * @param key - * @param value - * @return CONCAT (key, 'value') - * @throws IllegalArgumentException - */ - public static String getAddString(String key, Object value) throws IllegalArgumentException { - if (value instanceof Number) { - return key + " + " + value; - } - if (value instanceof String) { - return " CONCAT (" + key + ", '" + value + "') "; - } - throw new IllegalArgumentException(key + "+ 对应的值 " + value + " 不是Number,String,Array中的任何一种!"); - } - /**SET key = replace(key, 'value', '') - * @param key - * @param value - * @return REPLACE (key, 'value', '') - * @throws IllegalArgumentException - */ - public static String getRemoveString(String key, Object value) throws IllegalArgumentException { - if (value instanceof Number) { - return key + " - " + value; - } - if (value instanceof String) { - return SQL.replace(key, (String) value, "");// " replace(" + key + ", '" + value + "', '') "; - } - throw new IllegalArgumentException(key + "- 对应的值 " + value + " 不是Number,String,Array中的任何一种!"); - } - //SET >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - - - /** - * @return - * @throws Exception - */ - @JSONField(serialize = false) - public String getSQL() throws Exception { - return getSQL(this); - } - /** - * @param config - * @return - * @throws Exception - */ - public static String getSQL(SQLConfig config) throws Exception { - String tablePath = config == null ? null : config.getTablePath(); - if (StringUtil.isNotEmpty(tablePath, true) == false) { - Log.i(TAG, "getSQL StringUtil.isNotEmpty(tablePath, true) == false >> return null;"); - return null; - } - - switch (config.getMethod()) { - case POST: - return "INSERT INTO " + tablePath + config.getColumnString() + " VALUES" + config.getValuesString(); - case PUT: - return "UPDATE " + tablePath + config.getSetString() + config.getWhereString(); - case DELETE: - return "DELETE FROM " + tablePath + config.getWhereString(); - default: - String column = config.getColumnString(); - return "SELECT " + column + " FROM " + getConditionString(column, tablePath, config); - } - } - - /**获取条件SQL字符串 - * @param page - * @param column - * @param table - * @param where - * @return - * @throws Exception - */ - private static String getConditionString(String column, String table, SQLConfig config) throws Exception { - String where = config.getWhereString(); - - String condition = table + where + ( - RequestMethod.isGetMethod(config.getMethod(), true) == false ? - "" : config.getGroupString() + config.getHavingString() + config.getOrderString() - ) - ; //+ config.getLimitString(); - - //no need to optimize - // if (config.getPage() <= 0 || ID.equals(column.trim())) { - return condition + config.getLimitString(); - // } - // - // - // //order: id+ -> id >= idOfStartIndex; id- -> id <= idOfStartIndex <<<<<<<<<<<<<<<<<<< - // String order = StringUtil.getNoBlankString(config.getOrder()); - // List orderList = order.isEmpty() ? null : Arrays.asList(StringUtil.split(order)); - // - // int type = 0; - // if (BaseModel.isEmpty(orderList) || BaseModel.isContain(orderList, ID+"+")) { - // type = 1; - // } - // else if (BaseModel.isContain(orderList, ID+"-")) { - // type = 2; - // } - // - // if (type > 0) { - // return condition.replace("WHERE", - // "WHERE id " + (type == 1 ? ">=" : "<=") + " (SELECT id FROM " + table - // + where + " ORDER BY id " + (type == 1 ? "ASC" : "DESC") + " LIMIT " + config.getOffset() + ", 1) AND" - // ) - // + " LIMIT " + config.getCount(); //子查询起始id不一定准确,只能作为最小可能! ;// - // } - // //order: id+ -> id >= idOfStartIndex; id- -> id <= idOfStartIndex >>>>>>>>>>>>>>>>>> - // - // - // //结果错误!SELECT * FROM Test AS t0 INNER JOIN - // (SELECT id FROM Test ORDER BY date ASC LIMIT 20, 10) AS t1 ON t0.id = t1.id - // //common case, inner join - // condition += config.getLimitString(); - // return table + " AS t0 INNER JOIN (SELECT id FROM " + condition + ") AS t1 ON t0.id = t1.id"; - } - - /**获取查询配置 - * @param table - * @param request - * @return - * @throws Exception - */ - public static SQLConfig newSQLConfig(RequestMethod method, String table, JSONObject request) throws Exception { - if (request == null) { // User:{} 这种空内容在查询时也有效 - throw new NullPointerException(TAG + ": newSQLConfig request == null!"); - } - SQLConfig config = new SQLConfig(method, table); - - boolean isEmpty = request.isEmpty(); - if (isEmpty) { // User:{} 这种空内容在查询时也有效 - return config; //request.remove(key); 前都可以直接return,之后必须保证 put 回去 - } - - Object idIn = request.get(KEY_ID_IN); //可能是 id{}:">0" - - if (method == POST) { - if (idIn != null) { //不能在这里确定[]的长度,只能在外面传进来 - if ((idIn instanceof List == false) || ((List)idIn).isEmpty()) { // id{}:[] 表示同时插入多条记录 - throw new IllegalArgumentException("POST请求,生成多条记录请用 id{}:[] ! [] 类型为JSONArray且不能为空!"); - } - } else if (request.get(KEY_ID) == null) { - request.put(KEY_ID, System.currentTimeMillis()); - } - } - - //对id和id{}处理,这两个一定会作为条件 - Long id = request.getLong(KEY_ID); - if (id != null) { //null无效 - if (id <= 0) { //一定没有值 - throw new NotExistException(TAG + ": newSQLConfig " + table + ".id <= 0"); - } - - if (idIn != null && idIn instanceof List) { //共用idArr场景少性能差 - if (idIn != null && ((List) idIn).contains(id) == false) {//empty有效 BaseModel.isEmpty(idArr) == false) { - Log.w(TAG, "newSQLConfig id > 0 >> idInObj != null && idInObj.contains(id) == false >> return null;"); - throw new NotExistException(TAG + ": newSQLConfig idIn != null && ((JSONArray) idIn).contains(id) == false"); - } - } - } - - - String role = request.getString(KEY_ROLE); - String schema = request.getString(KEY_SCHEMA); - boolean about = request.getBooleanValue(KEY_ABOUT); - String condition = request.getString(KEY_CONDITION); - String column = request.getString(KEY_COLUMN); - String group = request.getString(KEY_GROUP); - String having = request.getString(KEY_HAVING); - String order = request.getString(KEY_ORDER); - - //强制作为条件且放在最前面优化性能 - request.remove(KEY_ID); - request.remove(KEY_ID_IN); - //关键词 - request.remove(KEY_ROLE); - request.remove(KEY_SCHEMA); - request.remove(KEY_ABOUT); - request.remove(KEY_CONDITION); - request.remove(KEY_COLUMN); - request.remove(KEY_GROUP); - request.remove(KEY_HAVING); - request.remove(KEY_ORDER); - - - Map tableWhere = new LinkedHashMap();//保证顺序好优化 WHERE id > 1 AND name LIKE... - if (about) { //查询字段属性 - if (RequestMethod.isQueryMethod(method) == false) { - throw new UnsupportedOperationException(config.getTable() - + " 被 " + KEY_ABOUT + " 标注,只能进行 GET,HEAD 等查询操作!"); - } - - tableWhere.put(TABLE_SCHEMA, SQLConfig.getSchema(schema)); - tableWhere.put(TABLE_NAME, config.getSQLTable()); - config.setTable(Column.class.getSimpleName()); - - schema = SCHEMA_INFORMATION; - - column = StringUtil.getString(column); - if (column.isEmpty() && RequestMethod.isHeadMethod(method, true) == false) { - column = "column_name,column_type,column_default,column_comment"; - } - } - - - //已经remove了id和id{},以及@key - Set set = request.keySet(); //前面已经判断request是否为空 - if (method == POST) {//POST操作 - if (BaseModel.isEmpty(set) == false) { //不能直接return,要走完下面的流程 - List idList; - if (id != null) { //单条记录 - if (idIn != null) { - throw new IllegalArgumentException("POST请求中 id 和 id{} 不能同时存在!"); - } - - idList = new ArrayList(1); - idList.add(id); - } else { //多条记录 - idList = new ArrayList((JSONArray) idIn); - } - - //idIn不为空时,valuesString有多条,唯一的区别就是id - String[] columns = set.toArray(new String[]{}); - - Collection valueCollection = request.values(); - Object[] values = valueCollection == null ? null : valueCollection.toArray(); - - if (values == null || values.length != columns.length) { - throw new Exception("服务器内部错误:\n" + TAG - + " newSQLConfig values == null || values.length != columns.length !"); - } - column = KEY_ID + "," + StringUtil.getString(columns); //set已经判断过不为空 - final int size = columns.length + 1; //以key数量为准 - - String[][] valuess = new String[idList.size()][]; // [idList.size()][] - String[] items; //(item0, item1, ...) - for (int i = 0; i < idList.size(); i++) { - items = new String[size]; - items[0] = "'" + idList.get(i) + "'"; //第0个就是id。所有的值都加 '' 避免SQL注入风险 - for (int j = 1; j < size; j++) { - items[j] = "'" + values[j-1] + "'"; //从第1个开始,允许"null" - } - valuess[i] = items; - } - config.setValues(valuess); - } - } - else { //非POST操作 - final boolean isWhere = method != PUT;//除了POST,PUT,其它全是条件!!! - - //条件<<<<<<<<<<<<<<<<<<< - List conditionList = null; - if (isWhere == false) { //减少不必要的步骤 - if (method == PUT || method == DELETE) { - String[] conditions = StringUtil.split(condition); - //Arrays.asList()返回值不支持add方法! - conditionList = BaseModel.isEmpty(conditions) ? null : Arrays.asList(conditions); - } - } - //条件>>>>>>>>>>>>>>>>>>> - - //强制作为条件且放在最前面优化性能 - if (id != null) { - tableWhere.put(KEY_ID, id); - } - if (idIn != null) { - tableWhere.put(KEY_ID_IN, idIn); - } - - Map tableContent = new HashMap(); - Object value; - for (String key : set) { - value = request.get(key); - if (value instanceof JSONObject == false) {//只允许常规Object - //解决AccessVerifier新增userId没有作为条件,而是作为内容,导致PUT,DELETE出错 - if (isWhere || BaseModel.isContain(conditionList, key)) { - tableWhere.put(key, value); - } else { - tableContent.put(key, value);//一样 instanceof JSONArray ? JSON.toJSONString(value) : value); - } - } - } - - config.setContent(tableContent); - } - - - config.setWhere(tableWhere); - - config.setId(BaseModel.value(id)); - //在 tableWhere 第0个 config.setIdIn(idIn); - - config.setRole(role); - //TODO condition组合,优先 | config.setCondition(condition); - config.setSchema(schema); - config.setAbout(about); - config.setColumn(column); - config.setGroup(group); - config.setHaving(having); - config.setOrder(order); - - //后面还可能用到,要还原 - //id或id{}条件 - request.put(KEY_ID, id); - request.put(KEY_ID_IN, idIn); - //关键词 - request.put(KEY_ROLE, role); - request.put(KEY_SCHEMA, schema); - request.put(KEY_ABOUT, about); - request.put(KEY_CONDITION, condition); - request.put(KEY_COLUMN, column); - request.put(KEY_GROUP, group); - request.put(KEY_HAVING, having); - request.put(KEY_ORDER, order); - - - return config; - } - - - - /**获取客户端实际需要的key - * verifyName = true - * @param method - * @param originKey - * @param isTableKey - * @param saveLogic 保留逻辑运算符 & | ! - * @return - */ - public static String getRealKey(RequestMethod method, String originKey - , boolean isTableKey, boolean saveLogic) throws Exception { - return getRealKey(method, originKey, isTableKey, saveLogic, true); - } - /**获取客户端实际需要的key - * @param method - * @param originKey - * @param isTableKey - * @param saveLogic 保留逻辑运算符 & | ! - * @param verifyName 验证key名是否符合代码变量/常量名 - * @return - */ - public static String getRealKey(RequestMethod method, String originKey - , boolean isTableKey, boolean saveLogic, boolean verifyName) throws Exception { - Log.i(TAG, "getRealKey saveLogic = " + saveLogic + "; originKey = " + originKey); - if (originKey == null || originKey.startsWith("`") || zuo.biao.apijson.JSONObject.isArrayKey(originKey)) { - Log.w(TAG, "getRealKey originKey == null || originKey.startsWith(`)" - + " || zuo.biao.apijson.JSONObject.isArrayKey(originKey) >> return originKey;"); - return originKey; - } - - String key = new String(originKey); - if (key.endsWith("$")) {//搜索,查询时处理 - key = key.substring(0, key.length() - 1); - } - else if (key.endsWith("?")) {//匹配正则表达式,查询时处理 - key = key.substring(0, key.length() - 1); - } - else if (key.endsWith("{}")) {//被包含,或者说key对应值处于value的范围内。查询时处理 - key = key.substring(0, key.length() - 2); - } - else if (key.endsWith("<>")) {//包含,或者说value处于key对应值的范围内。查询时处理 - key = key.substring(0, key.length() - 2); - } - else if (key.endsWith("()")) {//方法,查询完后处理,先用一个Map保存? - key = key.substring(0, key.length() - 2); - } - else if (key.endsWith("@")) {//引用,引用对象查询完后处理。fillTarget中暂时不用处理,因为非GET请求都是由给定的id确定,不需要引用 - key = key.substring(0, key.length() - 1); - } - else if (key.endsWith("+")) {//延长,PUT查询时处理 - if (method == PUT) {//不为PUT就抛异常 - key = key.substring(0, key.length() - 1); - } - } - else if (key.endsWith("-")) {//缩减,PUT查询时处理 - if (method == PUT) {//不为PUT就抛异常 - key = key.substring(0, key.length() - 1); - } - } - - String last = null;//不用Logic优化代码,否则 key 可能变为 key| 导致 key=value 变成 key|=value 而出错 - if (RequestMethod.isQueryMethod(method)) {//逻辑运算符仅供GET,HEAD方法使用 - last = key.isEmpty() ? "" : key.substring(key.length() - 1); - if ("&".equals(last) || "|".equals(last) || "!".equals(last)) { - key = key.substring(0, key.length() - 1); - } else { - last = null;//避免key + StringUtil.getString(last)错误延长 - } - } - - //"User:toUser":User转换"toUser":User, User为查询同名Table得到的JSONObject。交给客户端处理更好 - if (isTableKey) {//不允许在column key中使用Type:key形式 - key = Pair.parseEntry(key, true).getKey();//table以左边为准 - } else { - key = Pair.parseEntry(key).getValue();//column以右边为准 - } - - if (verifyName && StringUtil.isName(key.startsWith("@") ? key.substring(1) : key) == false) { - throw new IllegalArgumentException(method + "请求,字符 " + originKey + " 不合法!"); - } - - if (saveLogic && last != null) { - key = key + last; - } - Log.i(TAG, "getRealKey return key = " + key); - return key; - } - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLExecutor.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLExecutor.java deleted file mode 100755 index 67d265fd3..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/sql/SQLExecutor.java +++ /dev/null @@ -1,292 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -package zuo.biao.apijson.server.sql; - -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.Statement; -import java.sql.Timestamp; -import java.util.HashMap; -import java.util.Map; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; - -import zuo.biao.apijson.JSONResponse; -import zuo.biao.apijson.Log; -import zuo.biao.apijson.StringUtil; -import zuo.biao.apijson.server.Parser; - -/**executor for query(read) or update(write) MySQL database - * @author Lemon - */ -public class SQLExecutor { - private static final String TAG = "SQLExecutor"; - - public static final String MYSQL_URI = "jdbc:mysql://localhost:3306";//TODO 改成你自己的 - public static final String MYSQL_ACCOUNT = "root";//TODO 改成你自己的 - public static final String MYSQL_PASSWORD = "apijson";//TODO 改成你自己的 - - //访问一次后丢失,可能因为static导致内存共享,别的地方改变了内部对象的值 - // private static final Map> staticCacheMap; - // static { - // staticCacheMap = new HashMap>(); - // } - - /** - * 缓存map - */ - private Map> cacheMap = new HashMap>(); - static { - try {//调用Class.forName()方法加载驱动程序 - Class.forName("com.mysql.jdbc.Driver"); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } - } - - /**获取连接 - * @return - * @throws Exception - */ - private synchronized Connection getConnection() throws Exception { - Log.i(TAG, "成功加载MySQL驱动!"); - return DriverManager.getConnection(MYSQL_URI + "?useUnicode=true&characterEncoding=UTF-8&user=" - + MYSQL_ACCOUNT + "&password=" + MYSQL_PASSWORD); - } - - /**保存缓存 - * @param sql - * @param map - * @param isStatic - */ - private synchronized void saveCache(String sql, Map map, boolean isStatic) { - if (sql == null || map == null) { //空map有效,说明查询过sql了 || map.isEmpty()) { - Log.i(TAG, "saveList sql == null || map == null >> return;"); - return; - } - // if (isStatic) { - // staticCacheMap.put(sql, map); - // } else { - cacheMap.put(sql, map); - // } - } - /**移除缓存 - * @param sql - * @param isStatic - */ - public synchronized void removeCache(String sql, boolean isStatic) { - if (sql == null) { - Log.i(TAG, "removeList sql == null >> return;"); - return; - } - // if (isStatic) { - // staticCacheMap.remove(sql); - // } else { - cacheMap.remove(sql); - // } - } - - /**获取缓存 - * @param sql - * @param position - * @param isStatic - * @return - */ - public JSONObject getFromCache(String sql, int position, boolean isStatic) { - Map map = /** isStatic ? staticCacheMap.get(sql) : */ cacheMap.get(sql); - //只要map不为null,则如果 map.get(position) == null,则返回 {} ,避免再次SQL查询 - if (map == null) { - return null; - } - JSONObject result = map.get(position); - return result != null ? result : new JSONObject(); - } - - private Connection connection; - private Statement statement; - /**关闭连接,释放资源 - */ - public void close() { - cacheMap.clear(); - try { - if (statement != null && statement.isClosed() == false) { - statement.close(); - } - if (connection != null && connection.isClosed() == false) { - connection.close(); - } - } catch (SQLException e) { - e.printStackTrace(); - } - statement = null; - cacheMap = null; - } - - /**执行SQL - * @param config - * @return - * @throws Exception - */ - public JSONObject execute(SQLConfig config) throws Exception { - - final String sql = SQLConfig.getSQL(config); - if (StringUtil.isNotEmpty(sql, true) == false) { - Log.e(TAG, "select config==null||StringUtil.isNotEmpty(config.getSQLTable(), true)==false>>return null;"); - return null; - } - JSONObject result = null; - - long startTime = System.currentTimeMillis(); - Log.d(TAG, "\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" - + "\n select startTime = " + startTime - + "\n sql = " + sql - + "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"); - - if (connection == null || connection.isClosed()) { - Log.i(TAG, "select connection " + (connection == null ? " = null" : ("isClosed = " + connection.isClosed()))) ; - connection = getConnection(); - statement = connection.createStatement(); //创建Statement对象 - } - Log.i(TAG, "成功连接到数据库!"); - ResultSet rs = null; - switch (config.getMethod()) { - case HEAD: - case HEADS: - rs = statement.executeQuery(sql); - - result = rs.next() ? Parser.newSuccessResult() - : Parser.newErrorResult(new SQLException("数据库错误, rs.next() 失败!")); - result.put(JSONResponse.KEY_COUNT, rs.getLong(1)); - - rs.close(); - return result; - - case POST: - case PUT: - case DELETE: - long updateCount = statement.executeUpdate(sql); - - result = Parser.newResult(updateCount > 0 ? JSONResponse.CODE_SUCCESS : JSONResponse.CODE_NOT_FOUND - , updateCount > 0 ? JSONResponse.MSG_SUCCEED : "可能对象不存在!"); - - //id或id{}一定有,一定会返回,不用抛异常来阻止关联写操作时前面错误导致后面无条件执行! - if (config.getId() > 0) { - result.put(JSONResponse.KEY_ID, config.getId()); - } else { - result.put(JSONResponse.KEY_ID_IN, config.getWhere(JSONResponse.KEY_ID_IN, true)); - } - result.put(JSONResponse.KEY_COUNT, updateCount);//返回修改的记录数 - return result; - - case GET: - case GETS: - break; - - default://OPTIONS, TRACE等 - Log.e(TAG, "select sql = " + sql + " ; method = " + config.getMethod() + " >> return null;"); - return null; - } - - - final int position = config.getPosition(); - result = getFromCache(sql, position, config.isCacheStatic()); - Log.i(TAG, ">>> select result = getFromCache('" + sql + "', " + position + ") = " + result); - if (result != null) { - Log.d(TAG, "\n\n select result != null >> return result;" + "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n"); - return result; - } - - rs = statement.executeQuery(sql); - - // final boolean cache = config.getCount() != 1; - Map resultMap = new HashMap(); - // Log.d(TAG, "select cache = " + cache + "; resultMap" + (resultMap == null ? "=" : "!=") + "null"); - - int index = -1; - - ResultSetMetaData rsmd = rs.getMetaData(); - final int length = rsmd.getColumnCount(); - - while (rs.next()){ - index ++; - Log.d(TAG, "\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n select while (rs.next()){ index = " + index + "\n\n"); - - result = new JSONObject(true); - Object value; - - for (int i = 1; i <= length; i++) { - if (rsmd.getColumnName(i).startsWith("_")) { - Log.i(TAG, "select while (rs.next()){ ..." - + " >> rsmd.getColumnName(i).startsWith(_) >> continue;"); - continue; - } - - value = rs.getObject(i); - // Log.d(TAG, "name:" + rsmd.getColumnName(i)); - // Log.d(TAG, "lable:" + rsmd.getColumnLabel(i)); - // Log.d(TAG, "type:" + rsmd.getColumnType(i)); - // Log.d(TAG, "typeName:" + rsmd.getColumnTypeName(i)); - - // Log.i(TAG, "select while (rs.next()) { >> for (int i = 0; i < length; i++) {" - // + "\n >>> value = " + value); - - if (value != null) { //数据库查出来的null和empty值都有意义,去掉会导致 Moment:{ @column:"content" } 部分无结果及中断数组查询! - if (value instanceof Timestamp) { - value = ((Timestamp) value).toString(); - } - else if (value instanceof String && isJSONType(rsmd, i)) { //json String - value = JSON.parse((String) value); - } - } - - result.put(rsmd.getColumnLabel(i), value); - } - - resultMap.put(index, result); - Log.d(TAG, "\n select while (rs.next()) { resultMap.put( " + index + ", result); " - + "\n >>>>>>>>>>>>>>>>>>>>>>>>>>> \n\n"); - } - - rs.close(); - - saveCache(sql, resultMap, config.isCacheStatic()); - Log.i(TAG, ">>> select saveCache('" + sql + "', resultMap); resultMap.size() = " + resultMap.size()); - - long endTime = System.currentTimeMillis(); - Log.d(TAG, "\n\n select endTime = " + endTime + "; duration = " + (endTime - startTime) - + "\n return resultMap.get(" + position + ");" + "\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n\n"); - return resultMap.get(position); - } - - /**判断是否为JSON类型 - * @param rsmd - * @param position - * @return - */ - private boolean isJSONType(ResultSetMetaData rsmd, int position) { - try { - return rsmd.getColumnType(position) == 1 || rsmd.getColumnTypeName(position).toLowerCase().contains("json"); - } catch (SQLException e) { - e.printStackTrace(); - } - return false; - } - - -} diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/sql/package-info.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/sql/package-info.java deleted file mode 100755 index ce9dee57e..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/java/zuo/biao/apijson/server/sql/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/*Copyright ©2016 TommyLemon(https://github.com/TommyLemon/APIJSON) - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License.*/ - -/** - * package of files for sql - */ -/** - * @author Lemon - * - */ -package zuo.biao.apijson.server.sql; \ No newline at end of file diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/resources/application.properties b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/main/resources/application.properties deleted file mode 100755 index e69de29bb..000000000 diff --git a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/test/java/zuo/biao/apijson/server/ApplicationTests.java b/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/test/java/zuo/biao/apijson/server/ApplicationTests.java deleted file mode 100755 index 6dcfe9e64..000000000 --- a/APIJSON-Java-Server/APIJSON-Idea1.9.0/src/test/java/zuo/biao/apijson/server/ApplicationTests.java +++ /dev/null @@ -1,17 +0,0 @@ -package zuo.biao.apijson.server; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest -public class ApplicationTests { - - @Test - public void contextLoads() { - //TODO Test Case,包括GitHub README介绍和简版demo - } - -}