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 5fd4d5023..000000000
Binary files a/APIJSON-Java-Server/APIJSON-Eclipse1.9.0/.mvn/wrapper/maven-wrapper.jar and /dev/null differ
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