no message
0 parents
Showing
70 changed files
with
3089 additions
and
0 deletions
kmr_dp_HDP/.classpath
0 → 100644
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <classpath> | ||
3 | <classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
4 | <attributes> | ||
5 | <attribute name="optional" value="true"/> | ||
6 | <attribute name="maven.pomderived" value="true"/> | ||
7 | </attributes> | ||
8 | </classpathentry> | ||
9 | <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
10 | <attributes> | ||
11 | <attribute name="maven.pomderived" value="true"/> | ||
12 | </attributes> | ||
13 | </classpathentry> | ||
14 | <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
15 | <attributes> | ||
16 | <attribute name="optional" value="true"/> | ||
17 | <attribute name="maven.pomderived" value="true"/> | ||
18 | </attributes> | ||
19 | </classpathentry> | ||
20 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> | ||
21 | <attributes> | ||
22 | <attribute name="maven.pomderived" value="true"/> | ||
23 | </attributes> | ||
24 | </classpathentry> | ||
25 | <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
26 | <attributes> | ||
27 | <attribute name="maven.pomderived" value="true"/> | ||
28 | </attributes> | ||
29 | </classpathentry> | ||
30 | <classpathentry kind="output" path="target/classes"/> | ||
31 | </classpath> |
kmr_dp_HDP/.mvn/wrapper/maven-wrapper.jar
0 → 100644
No preview for this file type
1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.3/apache-maven-3.3.3-bin.zip | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
kmr_dp_HDP/.project
0 → 100644
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <projectDescription> | ||
3 | <name>demo</name> | ||
4 | <comment></comment> | ||
5 | <projects> | ||
6 | </projects> | ||
7 | <buildSpec> | ||
8 | <buildCommand> | ||
9 | <name>org.eclipse.wst.common.project.facet.core.builder</name> | ||
10 | <arguments> | ||
11 | </arguments> | ||
12 | </buildCommand> | ||
13 | <buildCommand> | ||
14 | <name>org.eclipse.jdt.core.javabuilder</name> | ||
15 | <arguments> | ||
16 | </arguments> | ||
17 | </buildCommand> | ||
18 | <buildCommand> | ||
19 | <name>org.springframework.ide.eclipse.core.springbuilder</name> | ||
20 | <arguments> | ||
21 | </arguments> | ||
22 | </buildCommand> | ||
23 | <buildCommand> | ||
24 | <name>org.eclipse.m2e.core.maven2Builder</name> | ||
25 | <arguments> | ||
26 | </arguments> | ||
27 | </buildCommand> | ||
28 | </buildSpec> | ||
29 | <natures> | ||
30 | <nature>org.springframework.ide.eclipse.core.springnature</nature> | ||
31 | <nature>org.eclipse.jdt.core.javanature</nature> | ||
32 | <nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
33 | <nature>org.eclipse.wst.common.project.facet.core.nature</nature> | ||
34 | </natures> | ||
35 | </projectDescription> |
kmr_dp_HDP/kmr_dp_HDP.iml
0 → 100644
This diff is collapsed.
Click to expand it.
kmr_dp_HDP/logs/catalina-2017-07-03.0.log
0 → 100644
This diff could not be displayed because it is too large.
kmr_dp_HDP/logs/catalina-2017-07-04.0.log
0 → 100644
This diff could not be displayed because it is too large.
kmr_dp_HDP/logs/catalina-2017-07-13.0.log
0 → 100644
This diff is collapsed.
Click to expand it.
kmr_dp_HDP/logs/catalina-2017-07-17.0.log
0 → 100644
This diff could not be displayed because it is too large.
kmr_dp_HDP/logs/catalina-2017-07-18.0.log
0 → 100644
This diff could not be displayed because it is too large.
kmr_dp_HDP/logs/catalina-2017-07-25.0.log
0 → 100644
This diff is collapsed.
Click to expand it.
kmr_dp_HDP/logs/catalina-2017-07-26.0.log
0 → 100644
This diff is collapsed.
Click to expand it.
kmr_dp_HDP/logs/catalina-2017-08-03.0.log
0 → 100644
This diff is collapsed.
Click to expand it.
kmr_dp_HDP/logs/catalina-2017-08-04.0.log
0 → 100644
This diff is collapsed.
Click to expand it.
kmr_dp_HDP/logs/catalina-2017-08-09.0.log
0 → 100644
This diff is collapsed.
Click to expand it.
kmr_dp_HDP/logs/catalina-2017-08-10.0.log
0 → 100644
This diff is collapsed.
Click to expand it.
kmr_dp_HDP/logs/catalina-2017-08-16.0.log
0 → 100644
This diff is collapsed.
Click to expand it.
kmr_dp_HDP/logs/catalina-2017-09-21.0.log
0 → 100644
This diff is collapsed.
Click to expand it.
kmr_dp_HDP/logs/catalina-2017-10-13.0.log
0 → 100644
This diff is collapsed.
Click to expand it.
kmr_dp_HDP/logs/catalina-2017-11-23.0.log
0 → 100644
This diff is collapsed.
Click to expand it.
kmr_dp_HDP/logs/catalina-2017-11-29.0.log
0 → 100644
This diff is collapsed.
Click to expand it.
kmr_dp_HDP/mvnw
0 → 100755
1 | #!/bin/sh | ||
2 | # ---------------------------------------------------------------------------- | ||
3 | # Licensed to the Apache Software Foundation (ASF) under one | ||
4 | # or more contributor license agreements. See the NOTICE file | ||
5 | # distributed with this work for additional information | ||
6 | # regarding copyright ownership. The ASF licenses this file | ||
7 | # to you under the Apache License, Version 2.0 (the | ||
8 | # "License"); you may not use this file except in compliance | ||
9 | # with the License. You may obtain a copy of the License at | ||
10 | # | ||
11 | # http://www.apache.org/licenses/LICENSE-2.0 | ||
12 | # | ||
13 | # Unless required by applicable law or agreed to in writing, | ||
14 | # software distributed under the License is distributed on an | ||
15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
16 | # KIND, either express or implied. See the License for the | ||
17 | # specific language governing permissions and limitations | ||
18 | # under the License. | ||
19 | # ---------------------------------------------------------------------------- | ||
20 | |||
21 | # ---------------------------------------------------------------------------- | ||
22 | # Maven2 Start Up Batch script | ||
23 | # | ||
24 | # Required ENV vars: | ||
25 | # ------------------ | ||
26 | # JAVA_HOME - location of a JDK home dir | ||
27 | # | ||
28 | # Optional ENV vars | ||
29 | # ----------------- | ||
30 | # M2_HOME - location of maven2's installed home dir | ||
31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven | ||
32 | # e.g. to debug Maven itself, use | ||
33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 | ||
34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files | ||
35 | # ---------------------------------------------------------------------------- | ||
36 | |||
37 | if [ -z "$MAVEN_SKIP_RC" ] ; then | ||
38 | |||
39 | if [ -f /etc/mavenrc ] ; then | ||
40 | . /etc/mavenrc | ||
41 | fi | ||
42 | |||
43 | if [ -f "$HOME/.mavenrc" ] ; then | ||
44 | . "$HOME/.mavenrc" | ||
45 | fi | ||
46 | |||
47 | fi | ||
48 | |||
49 | # OS specific support. $var _must_ be set to either true or false. | ||
50 | cygwin=false; | ||
51 | darwin=false; | ||
52 | mingw=false | ||
53 | case "`uname`" in | ||
54 | CYGWIN*) cygwin=true ;; | ||
55 | MINGW*) mingw=true;; | ||
56 | Darwin*) darwin=true | ||
57 | # | ||
58 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look | ||
59 | # for the new JDKs provided by Oracle. | ||
60 | # | ||
61 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then | ||
62 | # | ||
63 | # Apple JDKs | ||
64 | # | ||
65 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home | ||
66 | fi | ||
67 | |||
68 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then | ||
69 | # | ||
70 | # Apple JDKs | ||
71 | # | ||
72 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home | ||
73 | fi | ||
74 | |||
75 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then | ||
76 | # | ||
77 | # Oracle JDKs | ||
78 | # | ||
79 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home | ||
80 | fi | ||
81 | |||
82 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then | ||
83 | # | ||
84 | # Apple JDKs | ||
85 | # | ||
86 | export JAVA_HOME=`/usr/libexec/java_home` | ||
87 | fi | ||
88 | ;; | ||
89 | esac | ||
90 | |||
91 | if [ -z "$JAVA_HOME" ] ; then | ||
92 | if [ -r /etc/gentoo-release ] ; then | ||
93 | JAVA_HOME=`java-config --jre-home` | ||
94 | fi | ||
95 | fi | ||
96 | |||
97 | if [ -z "$M2_HOME" ] ; then | ||
98 | ## resolve links - $0 may be a link to maven's home | ||
99 | PRG="$0" | ||
100 | |||
101 | # need this for relative symlinks | ||
102 | while [ -h "$PRG" ] ; do | ||
103 | ls=`ls -ld "$PRG"` | ||
104 | link=`expr "$ls" : '.*-> \(.*\)$'` | ||
105 | if expr "$link" : '/.*' > /dev/null; then | ||
106 | PRG="$link" | ||
107 | else | ||
108 | PRG="`dirname "$PRG"`/$link" | ||
109 | fi | ||
110 | done | ||
111 | |||
112 | saveddir=`pwd` | ||
113 | |||
114 | M2_HOME=`dirname "$PRG"`/.. | ||
115 | |||
116 | # make it fully qualified | ||
117 | M2_HOME=`cd "$M2_HOME" && pwd` | ||
118 | |||
119 | cd "$saveddir" | ||
120 | # echo Using m2 at $M2_HOME | ||
121 | fi | ||
122 | |||
123 | # For Cygwin, ensure paths are in UNIX format before anything is touched | ||
124 | if $cygwin ; then | ||
125 | [ -n "$M2_HOME" ] && | ||
126 | M2_HOME=`cygpath --unix "$M2_HOME"` | ||
127 | [ -n "$JAVA_HOME" ] && | ||
128 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` | ||
129 | [ -n "$CLASSPATH" ] && | ||
130 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` | ||
131 | fi | ||
132 | |||
133 | # For Migwn, ensure paths are in UNIX format before anything is touched | ||
134 | if $mingw ; then | ||
135 | [ -n "$M2_HOME" ] && | ||
136 | M2_HOME="`(cd "$M2_HOME"; pwd)`" | ||
137 | [ -n "$JAVA_HOME" ] && | ||
138 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" | ||
139 | # TODO classpath? | ||
140 | fi | ||
141 | |||
142 | if [ -z "$JAVA_HOME" ]; then | ||
143 | javaExecutable="`which javac`" | ||
144 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then | ||
145 | # readlink(1) is not available as standard on Solaris 10. | ||
146 | readLink=`which readlink` | ||
147 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then | ||
148 | if $darwin ; then | ||
149 | javaHome="`dirname \"$javaExecutable\"`" | ||
150 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" | ||
151 | else | ||
152 | javaExecutable="`readlink -f \"$javaExecutable\"`" | ||
153 | fi | ||
154 | javaHome="`dirname \"$javaExecutable\"`" | ||
155 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` | ||
156 | JAVA_HOME="$javaHome" | ||
157 | export JAVA_HOME | ||
158 | fi | ||
159 | fi | ||
160 | fi | ||
161 | |||
162 | if [ -z "$JAVACMD" ] ; then | ||
163 | if [ -n "$JAVA_HOME" ] ; then | ||
164 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
165 | # IBM's JDK on AIX uses strange locations for the executables | ||
166 | JAVACMD="$JAVA_HOME/jre/sh/java" | ||
167 | else | ||
168 | JAVACMD="$JAVA_HOME/bin/java" | ||
169 | fi | ||
170 | else | ||
171 | JAVACMD="`which java`" | ||
172 | fi | ||
173 | fi | ||
174 | |||
175 | if [ ! -x "$JAVACMD" ] ; then | ||
176 | echo "Error: JAVA_HOME is not defined correctly." >&2 | ||
177 | echo " We cannot execute $JAVACMD" >&2 | ||
178 | exit 1 | ||
179 | fi | ||
180 | |||
181 | if [ -z "$JAVA_HOME" ] ; then | ||
182 | echo "Warning: JAVA_HOME environment variable is not set." | ||
183 | fi | ||
184 | |||
185 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher | ||
186 | |||
187 | # For Cygwin, switch paths to Windows format before running java | ||
188 | if $cygwin; then | ||
189 | [ -n "$M2_HOME" ] && | ||
190 | M2_HOME=`cygpath --path --windows "$M2_HOME"` | ||
191 | [ -n "$JAVA_HOME" ] && | ||
192 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` | ||
193 | [ -n "$CLASSPATH" ] && | ||
194 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` | ||
195 | fi | ||
196 | |||
197 | # traverses directory structure from process work directory to filesystem root | ||
198 | # first directory with .mvn subdirectory is considered project base directory | ||
199 | find_maven_basedir() { | ||
200 | local basedir=$(pwd) | ||
201 | local wdir=$(pwd) | ||
202 | while [ "$wdir" != '/' ] ; do | ||
203 | if [ -d "$wdir"/.mvn ] ; then | ||
204 | basedir=$wdir | ||
205 | break | ||
206 | fi | ||
207 | wdir=$(cd "$wdir/.."; pwd) | ||
208 | done | ||
209 | echo "${basedir}" | ||
210 | } | ||
211 | |||
212 | # concatenates all lines of a file | ||
213 | concat_lines() { | ||
214 | if [ -f "$1" ]; then | ||
215 | echo "$(tr -s '\n' ' ' < "$1")" | ||
216 | fi | ||
217 | } | ||
218 | |||
219 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} | ||
220 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" | ||
221 | |||
222 | # Provide a "standardized" way to retrieve the CLI args that will | ||
223 | # work with both Windows and non-Windows executions. | ||
224 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" | ||
225 | export MAVEN_CMD_LINE_ARGS | ||
226 | |||
227 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain | ||
228 | |||
229 | exec "$JAVACMD" \ | ||
230 | $MAVEN_OPTS \ | ||
231 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ | ||
232 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ | ||
233 | ${WRAPPER_LAUNCHER} "$@" |
kmr_dp_HDP/mvnw.cmd
0 → 100644
1 | @REM ---------------------------------------------------------------------------- | ||
2 | @REM Licensed to the Apache Software Foundation (ASF) under one | ||
3 | @REM or more contributor license agreements. See the NOTICE file | ||
4 | @REM distributed with this work for additional information | ||
5 | @REM regarding copyright ownership. The ASF licenses this file | ||
6 | @REM to you under the Apache License, Version 2.0 (the | ||
7 | @REM "License"); you may not use this file except in compliance | ||
8 | @REM with the License. You may obtain a copy of the License at | ||
9 | @REM | ||
10 | @REM http://www.apache.org/licenses/LICENSE-2.0 | ||
11 | @REM | ||
12 | @REM Unless required by applicable law or agreed to in writing, | ||
13 | @REM software distributed under the License is distributed on an | ||
14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
15 | @REM KIND, either express or implied. See the License for the | ||
16 | @REM specific language governing permissions and limitations | ||
17 | @REM under the License. | ||
18 | @REM ---------------------------------------------------------------------------- | ||
19 | |||
20 | @REM ---------------------------------------------------------------------------- | ||
21 | @REM Maven2 Start Up Batch script | ||
22 | @REM | ||
23 | @REM Required ENV vars: | ||
24 | @REM JAVA_HOME - location of a JDK home dir | ||
25 | @REM | ||
26 | @REM Optional ENV vars | ||
27 | @REM M2_HOME - location of maven2's installed home dir | ||
28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands | ||
29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending | ||
30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven | ||
31 | @REM e.g. to debug Maven itself, use | ||
32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 | ||
33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files | ||
34 | @REM ---------------------------------------------------------------------------- | ||
35 | |||
36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' | ||
37 | @echo off | ||
38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' | ||
39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% | ||
40 | |||
41 | @REM set %HOME% to equivalent of $HOME | ||
42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") | ||
43 | |||
44 | @REM Execute a user defined script before this one | ||
45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre | ||
46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending | ||
47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" | ||
48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" | ||
49 | :skipRcPre | ||
50 | |||
51 | @setlocal | ||
52 | |||
53 | set ERROR_CODE=0 | ||
54 | |||
55 | @REM To isolate internal variables from possible post scripts, we use another setlocal | ||
56 | @setlocal | ||
57 | |||
58 | @REM ==== START VALIDATION ==== | ||
59 | if not "%JAVA_HOME%" == "" goto OkJHome | ||
60 | |||
61 | echo. | ||
62 | echo Error: JAVA_HOME not found in your environment. >&2 | ||
63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 | ||
64 | echo location of your Java installation. >&2 | ||
65 | echo. | ||
66 | goto error | ||
67 | |||
68 | :OkJHome | ||
69 | if exist "%JAVA_HOME%\bin\java.exe" goto init | ||
70 | |||
71 | echo. | ||
72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 | ||
73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 | ||
74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 | ||
75 | echo location of your Java installation. >&2 | ||
76 | echo. | ||
77 | goto error | ||
78 | |||
79 | @REM ==== END VALIDATION ==== | ||
80 | |||
81 | :init | ||
82 | |||
83 | set MAVEN_CMD_LINE_ARGS=%* | ||
84 | |||
85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". | ||
86 | @REM Fallback to current working directory if not found. | ||
87 | |||
88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% | ||
89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir | ||
90 | |||
91 | set EXEC_DIR=%CD% | ||
92 | set WDIR=%EXEC_DIR% | ||
93 | :findBaseDir | ||
94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound | ||
95 | cd .. | ||
96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound | ||
97 | set WDIR=%CD% | ||
98 | goto findBaseDir | ||
99 | |||
100 | :baseDirFound | ||
101 | set MAVEN_PROJECTBASEDIR=%WDIR% | ||
102 | cd "%EXEC_DIR%" | ||
103 | goto endDetectBaseDir | ||
104 | |||
105 | :baseDirNotFound | ||
106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% | ||
107 | cd "%EXEC_DIR%" | ||
108 | |||
109 | :endDetectBaseDir | ||
110 | |||
111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig | ||
112 | |||
113 | @setlocal EnableExtensions EnableDelayedExpansion | ||
114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a | ||
115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% | ||
116 | |||
117 | :endReadAdditionalConfig | ||
118 | |||
119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" | ||
120 | |||
121 | set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" | ||
122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain | ||
123 | |||
124 | %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% | ||
125 | if ERRORLEVEL 1 goto error | ||
126 | goto end | ||
127 | |||
128 | :error | ||
129 | set ERROR_CODE=1 | ||
130 | |||
131 | :end | ||
132 | @endlocal & set ERROR_CODE=%ERROR_CODE% | ||
133 | |||
134 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost | ||
135 | @REM check for post script, once with legacy .bat ending and once with .cmd ending | ||
136 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" | ||
137 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" | ||
138 | :skipRcPost | ||
139 | |||
140 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' | ||
141 | if "%MAVEN_BATCH_PAUSE%" == "on" pause | ||
142 | |||
143 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% | ||
144 | |||
145 | exit /B %ERROR_CODE% | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
kmr_dp_HDP/pom.xml
0 → 100644
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
4 | <modelVersion>4.0.0</modelVersion> | ||
5 | |||
6 | <groupId>com.example</groupId> | ||
7 | <artifactId>kmr_dp_HDP</artifactId> | ||
8 | <version>0.0.1-SNAPSHOT</version> | ||
9 | <packaging>jar</packaging> | ||
10 | |||
11 | <name>kmr_dp_HDP</name> | ||
12 | <description>Demo project for Spring Boot</description> | ||
13 | |||
14 | <parent> | ||
15 | <groupId>org.springframework.boot</groupId> | ||
16 | <artifactId>spring-boot-starter-parent</artifactId> | ||
17 | <version>1.3.3.RELEASE</version> | ||
18 | <relativePath/> <!-- lookup parent from repository --> | ||
19 | </parent> | ||
20 | |||
21 | <properties> | ||
22 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
23 | <java.version>1.7</java.version> | ||
24 | </properties> | ||
25 | |||
26 | <dependencies> | ||
27 | <dependency> | ||
28 | <groupId>org.springframework.boot</groupId> | ||
29 | <artifactId>spring-boot-starter-data-mongodb</artifactId> | ||
30 | </dependency> | ||
31 | <dependency> | ||
32 | <groupId>org.springframework.boot</groupId> | ||
33 | <artifactId>spring-boot-starter-redis</artifactId> | ||
34 | </dependency> | ||
35 | <dependency> | ||
36 | <groupId>org.springframework.boot</groupId> | ||
37 | <artifactId>spring-boot-starter-web</artifactId> | ||
38 | </dependency> | ||
39 | |||
40 | <dependency> | ||
41 | <groupId>commons-httpclient</groupId> | ||
42 | <artifactId>commons-httpclient</artifactId> | ||
43 | <version>3.1</version> | ||
44 | </dependency> | ||
45 | |||
46 | |||
47 | <dependency> | ||
48 | <groupId>mysql</groupId> | ||
49 | <artifactId>mysql-connector-java</artifactId> | ||
50 | <scope>runtime</scope> | ||
51 | </dependency> | ||
52 | <dependency> | ||
53 | <groupId>org.springframework.boot</groupId> | ||
54 | <artifactId>spring-boot-starter-test</artifactId> | ||
55 | <scope>test</scope> | ||
56 | </dependency> | ||
57 | |||
58 | <dependency> | ||
59 | <groupId>org.json</groupId> | ||
60 | <artifactId>json</artifactId> | ||
61 | <version>20140107</version> | ||
62 | </dependency> | ||
63 | |||
64 | <!-- https://mvnrepository.com/artifact/wsdl4j/wsdl4j --> | ||
65 | <dependency> | ||
66 | <groupId>wsdl4j</groupId> | ||
67 | <artifactId>wsdl4j</artifactId> | ||
68 | <version>1.6.3</version> | ||
69 | </dependency> | ||
70 | |||
71 | |||
72 | <dependency> | ||
73 | <groupId>org.apache.tomcat.embed</groupId> | ||
74 | <artifactId>tomcat-embed-jasper</artifactId> | ||
75 | <scope>provided</scope> | ||
76 | </dependency> | ||
77 | <dependency> | ||
78 | <groupId>javax.servlet</groupId> | ||
79 | <artifactId>jstl</artifactId> | ||
80 | </dependency> | ||
81 | |||
82 | |||
83 | <dependency> | ||
84 | <groupId>org.mybatis.spring.boot</groupId> | ||
85 | <artifactId>mybatis-spring-boot-starter</artifactId> | ||
86 | <version>1.0.0</version> | ||
87 | </dependency> | ||
88 | |||
89 | <dependency> | ||
90 | <groupId>org.springframework.data</groupId> | ||
91 | <artifactId>spring-data-redis</artifactId> | ||
92 | <version>1.5.0.RELEASE</version> | ||
93 | </dependency> | ||
94 | |||
95 | <dependency> | ||
96 | <groupId>org.springframework</groupId> | ||
97 | <artifactId>spring-webmvc-portlet</artifactId> | ||
98 | </dependency> | ||
99 | |||
100 | <dependency> | ||
101 | <groupId>org.tuckey</groupId> | ||
102 | <artifactId>urlrewritefilter</artifactId> | ||
103 | <version>4.0.3</version> | ||
104 | </dependency> | ||
105 | |||
106 | <!--通用Mapper插件--> | ||
107 | <dependency> | ||
108 | <groupId>tk.mybatis</groupId> | ||
109 | <artifactId>mapper</artifactId> | ||
110 | <version>3.3.4</version> | ||
111 | </dependency> | ||
112 | |||
113 | <dependency> | ||
114 | <groupId>org.apache.commons</groupId> | ||
115 | <artifactId>commons-lang3</artifactId> | ||
116 | <version>3.3.2</version> | ||
117 | </dependency> | ||
118 | |||
119 | <dependency> | ||
120 | <groupId>commons-io</groupId> | ||
121 | <artifactId>commons-io</artifactId> | ||
122 | <version>2.1</version> | ||
123 | </dependency> | ||
124 | |||
125 | <dependency> | ||
126 | <groupId>org.apache.wink</groupId> | ||
127 | <artifactId>wink-client</artifactId> | ||
128 | <version>1.3.0</version> | ||
129 | </dependency> | ||
130 | |||
131 | <!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> | ||
132 | <dependency> | ||
133 | <groupId>org.apache.poi</groupId> | ||
134 | <artifactId>poi</artifactId> | ||
135 | <version>3.15</version> | ||
136 | </dependency> | ||
137 | |||
138 | |||
139 | <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --> | ||
140 | <dependency> | ||
141 | <groupId>org.apache.poi</groupId> | ||
142 | <artifactId>poi-ooxml</artifactId> | ||
143 | <version>3.15</version> | ||
144 | </dependency> | ||
145 | |||
146 | |||
147 | <dependency> | ||
148 | <groupId>dom4j</groupId> | ||
149 | <artifactId>dom4j</artifactId> | ||
150 | <version>1.6.1</version> | ||
151 | </dependency> | ||
152 | |||
153 | |||
154 | <dependency> | ||
155 | <groupId>commons-codec</groupId> | ||
156 | <artifactId>commons-codec</artifactId> | ||
157 | <version>1.9</version> | ||
158 | </dependency> | ||
159 | |||
160 | <dependency> | ||
161 | <groupId>commons-fileupload</groupId> | ||
162 | <artifactId>commons-fileupload</artifactId> | ||
163 | <version>1.2.2</version> | ||
164 | </dependency> | ||
165 | |||
166 | <dependency> | ||
167 | <groupId>javax.mail</groupId> | ||
168 | <artifactId>mail</artifactId> | ||
169 | <version>1.4.1</version> | ||
170 | </dependency> | ||
171 | |||
172 | |||
173 | <dependency> | ||
174 | <groupId>org.springframework.boot</groupId> | ||
175 | <artifactId>spring-boot-starter-jetty</artifactId> | ||
176 | </dependency> | ||
177 | |||
178 | <dependency> | ||
179 | <groupId>org.apache.httpcomponents</groupId> | ||
180 | <artifactId>httpclient</artifactId> | ||
181 | <version>4.4.1</version> | ||
182 | </dependency> | ||
183 | |||
184 | <dependency> | ||
185 | <groupId>net.sf.json-lib</groupId> | ||
186 | <artifactId>json-lib</artifactId> | ||
187 | <version>2.2.3</version> | ||
188 | <classifier>jdk15</classifier> | ||
189 | </dependency> | ||
190 | |||
191 | |||
192 | </dependencies> | ||
193 | |||
194 | <build> | ||
195 | <plugins> | ||
196 | <plugin> | ||
197 | <groupId>org.springframework.boot</groupId> | ||
198 | <artifactId>spring-boot-maven-plugin</artifactId> | ||
199 | </plugin> | ||
200 | </plugins> | ||
201 | </build> | ||
202 | |||
203 | |||
204 | </project> |
1 | Manifest-Version: 1.0 | ||
2 | Class-Path: spring-tx-4.2.5.RELEASE.jar websocket-api-9.2.15.v20160210 | ||
3 | .jar spring-boot-starter-1.3.3.RELEASE.jar urlrewritefilter-4.0.3.jar | ||
4 | mybatis-spring-boot-starter-1.0.0.jar spring-boot-starter-jdbc-1.3.3 | ||
5 | .RELEASE.jar tomcat-jdbc-8.0.32.jar javax.websocket-api-1.0.jar valid | ||
6 | ation-api-1.1.0.Final.jar aopalliance-1.0.jar xml-apis-1.0.b2.jar asm | ||
7 | -commons-5.0.1.jar jaxb-impl-2.2.1.1.jar jetty-servlet-9.2.15.v201602 | ||
8 | 10.jar spring-data-mongodb-1.8.4.RELEASE.jar websocket-client-9.2.15. | ||
9 | v20160210.jar jetty-server-9.2.15.v20160210.jar jetty-xml-9.2.15.v201 | ||
10 | 60210.jar javax-websocket-server-impl-9.2.15.v20160210.jar jackson-an | ||
11 | notations-2.6.5.jar commons-codec-1.9.jar mysql-connector-java-5.1.38 | ||
12 | .jar dom4j-1.6.1.jar jetty-util-9.2.15.v20160210.jar commons-pool2-2. | ||
13 | 4.2.jar mongo-java-driver-2.13.3.jar jboss-logging-3.3.0.Final.jar co | ||
14 | mmons-logging-1.0.4.jar h2-1.4.191.jar mybatis-spring-1.2.3.jar jaxb- | ||
15 | api-2.2.jar jetty-jndi-9.2.15.v20160210.jar wink-client-1.3.0.jar hib | ||
16 | ernate-validator-5.2.4.Final.jar websocket-server-9.2.15.v20160210.ja | ||
17 | r log4j-over-slf4j-1.7.16.jar mapper-3.3.4.jar json-20140107.jar tomc | ||
18 | at-embed-core-8.0.32.jar asm-tree-5.0.1.jar spring-context-4.2.5.RELE | ||
19 | ASE.jar jsr311-api-1.1.1.jar spring-aop-4.2.5.RELEASE.jar snakeyaml-1 | ||
20 | .16.jar javax.annotation-api-1.2.jar wink-common-1.3.0.jar commons-io | ||
21 | -2.1.jar jetty-security-9.2.15.v20160210.jar asm-5.0.1.jar logback-cl | ||
22 | assic-1.1.5.jar tomcat-juli-8.0.32.jar classmate-1.1.0.jar jstl-1.2.j | ||
23 | ar spring-boot-starter-data-mongodb-1.3.3.RELEASE.jar spring-beans-4. | ||
24 | 2.5.RELEASE.jar spring-boot-autoconfigure-1.3.3.RELEASE.jar logback-c | ||
25 | ore-1.1.5.jar spring-jdbc-4.2.5.RELEASE.jar slf4j-api-1.7.16.jar comm | ||
26 | ons-lang3-3.3.2.jar jetty-http-9.2.15.v20160210.jar geronimo-annotati | ||
27 | on_1.1_spec-1.0.jar jedis-2.7.3.jar spring-core-4.2.5.RELEASE.jar jet | ||
28 | ty-io-9.2.15.v20160210.jar stax-api-1.0-2.jar spring-boot-starter-web | ||
29 | -1.3.3.RELEASE.jar spring-boot-starter-tomcat-1.3.3.RELEASE.jar jacks | ||
30 | on-databind-2.6.5.jar mybatis-3.3.0.jar commons-httpclient-3.1.jar je | ||
31 | tty-servlets-9.2.15.v20160210.jar jul-to-slf4j-1.7.16.jar javax.servl | ||
32 | et-api-3.1.0.jar jetty-annotations-9.2.15.v20160210.jar jcl-over-slf4 | ||
33 | j-1.7.16.jar activation-1.1.jar jetty-webapp-9.2.15.v20160210.jar spr | ||
34 | ing-boot-starter-validation-1.3.3.RELEASE.jar spring-boot-1.3.3.RELEA | ||
35 | SE.jar jackson-core-2.6.5.jar tomcat-embed-websocket-8.0.32.jar sprin | ||
36 | g-boot-starter-jetty-1.3.3.RELEASE.jar spring-context-support-4.2.5.R | ||
37 | ELEASE.jar spring-webmvc-4.2.5.RELEASE.jar spring-boot-starter-loggin | ||
38 | g-1.3.3.RELEASE.jar tomcat-embed-el-8.0.32.jar commons-fileupload-1.2 | ||
39 | .2.jar jetty-continuation-9.2.15.v20160210.jar spring-webmvc-portlet- | ||
40 | 4.2.5.RELEASE.jar spring-web-4.2.5.RELEASE.jar javax-websocket-client | ||
41 | -impl-9.2.15.v20160210.jar spring-boot-starter-redis-1.3.3.RELEASE.ja | ||
42 | r websocket-servlet-9.2.15.v20160210.jar persistence-api-1.0.jar tomc | ||
43 | at-embed-logging-juli-8.0.32.jar jetty-plus-9.2.15.v20160210.jar spri | ||
44 | ng-data-commons-1.11.4.RELEASE.jar spring-data-redis-1.5.0.RELEASE.ja | ||
45 | r spring-expression-4.2.5.RELEASE.jar websocket-common-9.2.15.v201602 | ||
46 | 10.jar mybatis-spring-boot-autoconfigure-1.0.0.jar | ||
47 | Main-Class: com.example.DemoApplication | ||
48 |
1 | package com.example; | ||
2 | |||
3 | import com.example.filter.CORSFilter; | ||
4 | import org.mybatis.spring.annotation.MapperScan; | ||
5 | import org.springframework.boot.SpringApplication; | ||
6 | import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
7 | import org.springframework.boot.context.embedded.MultipartConfigFactory; | ||
8 | import org.springframework.context.annotation.Bean; | ||
9 | import org.springframework.context.annotation.Configuration; | ||
10 | import org.springframework.web.bind.annotation.RequestMapping; | ||
11 | import org.springframework.web.bind.annotation.RestController; | ||
12 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | ||
13 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||
14 | |||
15 | import javax.servlet.MultipartConfigElement; | ||
16 | |||
17 | @MapperScan(basePackages = {"com.example.mapper"}) | ||
18 | @SpringBootApplication | ||
19 | public class DemoApplication extends WebMvcConfigurerAdapter{ | ||
20 | |||
21 | |||
22 | public static void main(String[] args) { | ||
23 | |||
24 | SpringApplication.run(DemoApplication.class, args); | ||
25 | } | ||
26 | |||
27 | @Override | ||
28 | public void addInterceptors(InterceptorRegistry registry) { | ||
29 | |||
30 | registry.addInterceptor(new CORSFilter()).addPathPatterns("/**"); | ||
31 | } | ||
32 | |||
33 | |||
34 | } |
1 | package com.example.controller; | ||
2 | |||
3 | import com.example.models.ImgInfo; | ||
4 | import com.example.service.ImgInfoService; | ||
5 | import com.example.support.model.MessageEntity; | ||
6 | import com.example.utils.file.DefaultFileUpload; | ||
7 | import com.example.utils.file.FileUploadInfo; | ||
8 | import com.example.utils.md5.MD5Utils; | ||
9 | import com.fasterxml.jackson.databind.ObjectMapper; | ||
10 | import org.apache.commons.lang3.StringUtils; | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | ||
12 | import org.springframework.web.bind.annotation.*; | ||
13 | import org.springframework.web.multipart.MultipartFile; | ||
14 | |||
15 | import javax.servlet.http.HttpServletRequest; | ||
16 | import java.io.IOException; | ||
17 | import java.net.URLDecoder; | ||
18 | import java.util.Map; | ||
19 | |||
20 | /** | ||
21 | * Created by JA on 17/7/3. | ||
22 | */ | ||
23 | @RequestMapping("/kmr/img") | ||
24 | @RestController | ||
25 | public class ImgInfoController { | ||
26 | |||
27 | @Autowired | ||
28 | private ImgInfoService imgInfoService; | ||
29 | |||
30 | @RequestMapping(value = "/upload", method = RequestMethod.POST) | ||
31 | public MessageEntity upload(HttpServletRequest request,@RequestPart final MultipartFile file,@ModelAttribute ImgInfo imgInfo, | ||
32 | String access_token, String state, String timestamp, String rands, String jsondata, String checksum, String secret) { | ||
33 | MessageEntity.Builder builder = new MessageEntity.Builder(request); | ||
34 | String code = "9000"; | ||
35 | String openid = imgInfo.getOpenid(); | ||
36 | boolean flag = false; | ||
37 | if(StringUtils.isNotBlank(jsondata)){ | ||
38 | jsondata = URLDecoder.decode(jsondata); | ||
39 | ObjectMapper objectMapper = new ObjectMapper(); | ||
40 | Map map = null; | ||
41 | try { | ||
42 | map = objectMapper.readValue(jsondata, Map.class); | ||
43 | } catch (IOException e) { | ||
44 | e.printStackTrace(); | ||
45 | } | ||
46 | if(map != null && map.containsKey("gtmc_code") && map.get("gtmc_code").toString().equals("200")){ | ||
47 | String checksum1 = MD5Utils.hash(access_token + openid + state + timestamp + rands + jsondata + secret); | ||
48 | if(checksum1.equals(checksum)){ | ||
49 | imgInfo.setGtmcUid(map.get("gtmc_uid").toString()); | ||
50 | imgInfo.setGtmcDepartment(map.get("gtmc_department").toString()); | ||
51 | imgInfo.setGtmcName(map.get("gtmc_name").toString()); | ||
52 | FileUploadInfo info = new DefaultFileUpload().upload("/Users/JA/Documents/img", file); | ||
53 | String url = info.getUrl(); | ||
54 | imgInfo.setImgUrl(url); | ||
55 | boolean b = this.imgInfoService.create(imgInfo); | ||
56 | if(b){ | ||
57 | code = "2000"; | ||
58 | flag = true; | ||
59 | } | ||
60 | } | ||
61 | } | ||
62 | } | ||
63 | |||
64 | return builder.success(flag).content(imgInfo).code(code).create(); | ||
65 | } | ||
66 | |||
67 | @RequestMapping("/getbyopenid") | ||
68 | public MessageEntity getbyopenid(HttpServletRequest request, @RequestParam String openid) { | ||
69 | MessageEntity.Builder builder = new MessageEntity.Builder(request); | ||
70 | ImgInfo imgInfo = this.imgInfoService.getNewByOpenid(openid); | ||
71 | return builder.success(true).code("2000").content(imgInfo).create(); | ||
72 | } | ||
73 | |||
74 | } |
1 | package com.example.controller; | ||
2 | |||
3 | import com.example.mapper.ConfigInfoMapper; | ||
4 | import com.example.models.ConfigInfo; | ||
5 | import com.example.models.ScoreLogInfo; | ||
6 | import com.example.service.ScoreLogInfoService; | ||
7 | import com.example.support.model.MessageEntity; | ||
8 | import com.example.utils.md5.MD5Utils; | ||
9 | import com.fasterxml.jackson.databind.ObjectMapper; | ||
10 | import org.apache.commons.lang3.StringUtils; | ||
11 | import org.springframework.beans.factory.annotation.Autowired; | ||
12 | import org.springframework.web.bind.annotation.ModelAttribute; | ||
13 | import org.springframework.web.bind.annotation.RequestMapping; | ||
14 | import org.springframework.web.bind.annotation.RequestParam; | ||
15 | import org.springframework.web.bind.annotation.RestController; | ||
16 | |||
17 | import javax.servlet.http.HttpServletRequest; | ||
18 | import java.io.IOException; | ||
19 | import java.net.URLDecoder; | ||
20 | import java.net.URLEncoder; | ||
21 | import java.text.SimpleDateFormat; | ||
22 | import java.util.HashMap; | ||
23 | import java.util.List; | ||
24 | import java.util.Map; | ||
25 | |||
26 | /** | ||
27 | * Created by JA on 17/7/3. | ||
28 | */ | ||
29 | @RequestMapping("/kmr/rank") | ||
30 | @RestController | ||
31 | public class ScoreLogInfoController { | ||
32 | |||
33 | private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | ||
34 | |||
35 | @Autowired | ||
36 | private ScoreLogInfoService scoreLogInfoService; | ||
37 | |||
38 | @Autowired | ||
39 | private ConfigInfoMapper configInfoMapper; | ||
40 | |||
41 | @RequestMapping("/save") | ||
42 | public MessageEntity save(HttpServletRequest request, @ModelAttribute ScoreLogInfo scoreLogInfo, | ||
43 | String access_token, String state, String timestamp, String rands, String jsondata, String checksum, String secret) { | ||
44 | MessageEntity.Builder builder = new MessageEntity.Builder(request); | ||
45 | boolean flag = false; | ||
46 | String code = "9000"; | ||
47 | String openid = scoreLogInfo.getOpenid(); | ||
48 | if(StringUtils.isNotBlank(jsondata)){ | ||
49 | jsondata = URLDecoder.decode(jsondata); | ||
50 | ObjectMapper objectMapper = new ObjectMapper(); | ||
51 | Map map = null; | ||
52 | try { | ||
53 | map = objectMapper.readValue(jsondata, Map.class); | ||
54 | } catch (IOException e) { | ||
55 | e.printStackTrace(); | ||
56 | } | ||
57 | if(map != null && map.containsKey("gtmc_code") && map.get("gtmc_code").toString().equals("200")){ | ||
58 | String checksum1 = MD5Utils.hash(access_token +openid +state +timestamp +rands +jsondata +secret); | ||
59 | if(checksum1.equals(checksum)){ | ||
60 | scoreLogInfo.setGtmcUid(map.get("gtmc_uid").toString()); | ||
61 | scoreLogInfo.setGtmcDepartment(map.get("gtmc_department").toString()); | ||
62 | scoreLogInfo.setGtmcName(map.get("gtmc_name").toString()); | ||
63 | code = this.scoreLogInfoService.save(scoreLogInfo); | ||
64 | if(code.equals("2000")){ | ||
65 | flag = true; | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | return builder.success(flag).code(code).create(); | ||
71 | } | ||
72 | |||
73 | @RequestMapping("/ranking") | ||
74 | public MessageEntity ranking(HttpServletRequest request, @RequestParam String openid,@RequestParam(defaultValue = "10") Long limit) { | ||
75 | MessageEntity.Builder builder = new MessageEntity.Builder(request); | ||
76 | Map<String,Object> map = new HashMap<>(); | ||
77 | List<Map<String, Object>> rankingList = this.scoreLogInfoService.getRankingList(limit); | ||
78 | Map<String, Object> myRanking = this.scoreLogInfoService.getMyRanking(openid); | ||
79 | map.put("rankingList",rankingList); | ||
80 | map.put("myRanking",myRanking); | ||
81 | return builder.success(true).code("2000").content(map).create(); | ||
82 | } | ||
83 | |||
84 | @RequestMapping("/counttoday") | ||
85 | public MessageEntity counttoday(HttpServletRequest request, @RequestParam String openid) { | ||
86 | MessageEntity.Builder builder = new MessageEntity.Builder(request); | ||
87 | long l = this.scoreLogInfoService.countToDay(openid); | ||
88 | ConfigInfo configInfo = configInfoMapper.get(); | ||
89 | Long maxTime = configInfo.getMaxTime(); | ||
90 | long lastTime = maxTime - l; | ||
91 | return builder.success(true).code("2000").content(lastTime).create(); | ||
92 | } | ||
93 | |||
94 | @RequestMapping("/sum") | ||
95 | public MessageEntity sum(HttpServletRequest request, @RequestParam String openid) { | ||
96 | MessageEntity.Builder builder = new MessageEntity.Builder(request); | ||
97 | long l = this.scoreLogInfoService.countSum(openid); | ||
98 | return builder.success(true).code("2000").content(l).create(); | ||
99 | } | ||
100 | |||
101 | |||
102 | // public static void main(String[] args) { | ||
103 | // String access_token="4_ei8KYHlVKGE8zLguYGl7iHLEBf28u4nAzxocOMXGvzKoPxpU3Dxr_kq8cQlfDD34qFiJWgQpYxj3k3gobg0hyA"; | ||
104 | // String openid="oUmdXt90H2A784gfU7ChtsBsxU48"; | ||
105 | // String state="xxxx"; | ||
106 | // String timestamp="1511923072"; | ||
107 | // String rands="KeXxdzc7gQxkw6sE"; | ||
108 | // String jsondata="%7B%22gtmc_code%22%3A404%7D"; | ||
109 | // jsondata = URLDecoder.decode(jsondata); | ||
110 | // System.out.println(jsondata); | ||
111 | // String checksum="5d179dbfdb49cafd3f27100df12d3b99"; | ||
112 | // String secret="digi-campaign-2015"; | ||
113 | // System.out.println(URLEncoder.encode("{\"gtmc_code\":404,\"gtmc_uid\":\"gtmc_uid\",\"gtmc_department\":\"gtmc_department\",\"gtmc_name\":\"gtmc_name\"}")); | ||
114 | // String checksum1 = MD5Utils.hash(access_token +openid +state +timestamp +rands +jsondata +secret); | ||
115 | // System.out.println(checksum); | ||
116 | // System.out.println(checksum1); | ||
117 | // } | ||
118 | |||
119 | |||
120 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | package com.example.controller; | ||
2 | |||
3 | import com.example.models.ImgInfo; | ||
4 | import com.example.service.ImgInfoService; | ||
5 | import com.example.service.http.ClientConfigService; | ||
6 | import com.example.service.http.ClientConfigServiceImpl; | ||
7 | import com.example.service.http.HttpPostService; | ||
8 | import com.example.support.model.MessageEntity; | ||
9 | import com.example.utils.file.DefaultFileUpload; | ||
10 | import com.example.utils.file.FileUploadInfo; | ||
11 | import com.fasterxml.jackson.databind.ObjectMapper; | ||
12 | import org.apache.wink.client.ClientResponse; | ||
13 | import org.apache.wink.client.Resource; | ||
14 | import org.apache.wink.client.RestClient; | ||
15 | import org.springframework.beans.factory.annotation.Autowired; | ||
16 | import org.springframework.web.bind.annotation.*; | ||
17 | import org.springframework.web.multipart.MultipartFile; | ||
18 | import sun.misc.BASE64Decoder; | ||
19 | import sun.misc.BASE64Encoder; | ||
20 | |||
21 | import javax.servlet.http.HttpServletRequest; | ||
22 | import java.io.IOException; | ||
23 | import java.io.UnsupportedEncodingException; | ||
24 | import java.util.Map; | ||
25 | |||
26 | /** | ||
27 | * Created by JA on 17/7/3. | ||
28 | */ | ||
29 | @RequestMapping("/kmr/wx") | ||
30 | @RestController | ||
31 | public class WxController { | ||
32 | |||
33 | // String jssdkurl = "http://gfwp.gac-toyota.com.cn/GTMCfamily/index.php/campaign/api2/getjssdk"; | ||
34 | // | ||
35 | // String getopenidurl = "http://gfwp.gac-toyota.com.cn/GTMCfamily/index.php/campaign/api2/getjssdk"; | ||
36 | // | ||
37 | // @Autowired | ||
38 | // private HttpPostService httpPostService; | ||
39 | // | ||
40 | // | ||
41 | // @RequestMapping("/getjssdk") | ||
42 | // public MessageEntity getjssdk(HttpServletRequest request, @RequestParam String url) { | ||
43 | // MessageEntity.Builder builder = new MessageEntity.Builder(request); | ||
44 | // String newUrl = jssdkurl + "?url="+ url; | ||
45 | // Map<String, Object> map = null; | ||
46 | // try { | ||
47 | // map = httpPostService.httpPost(newUrl, null); | ||
48 | // } catch (IOException e) { | ||
49 | // e.printStackTrace(); | ||
50 | // } | ||
51 | // return builder.success(true).code("2000").content(map).create(); | ||
52 | // } | ||
53 | |||
54 | |||
55 | @RequestMapping("/getUser") | ||
56 | public MessageEntity oauth(HttpServletRequest request, @RequestParam String accessToken, String openid) { | ||
57 | MessageEntity.Builder builder = new MessageEntity.Builder(request); | ||
58 | ClientConfigService configService = new ClientConfigServiceImpl(); | ||
59 | RestClient restClient = new RestClient(configService.getClientConfig()); | ||
60 | Resource resource = restClient.resource("https://api.weixin.qq.com/sns/userinfo"); | ||
61 | resource.queryParam("access_token", accessToken); | ||
62 | resource.queryParam("openid", openid); | ||
63 | resource.queryParam("lang", "zh_CN"); | ||
64 | ClientResponse response = resource.get(); | ||
65 | String responseEntity = response.getEntity(String.class); | ||
66 | Map readValue = null; | ||
67 | // System.out.println("responseEntity:::"+responseEntity); | ||
68 | ObjectMapper mapper = new ObjectMapper(); | ||
69 | try { | ||
70 | readValue = mapper.readValue(responseEntity, Map.class); | ||
71 | if (null != readValue.get("errcode")) { | ||
72 | return null; | ||
73 | } | ||
74 | } catch (IOException e) { | ||
75 | e.printStackTrace();; | ||
76 | } | ||
77 | return builder.success(true).code("2000").content(readValue).create(); | ||
78 | } | ||
79 | |||
80 | |||
81 | } |
1 | package com.example.filter; | ||
2 | |||
3 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | ||
4 | |||
5 | import javax.servlet.*; | ||
6 | import javax.servlet.http.HttpServletRequest; | ||
7 | import javax.servlet.http.HttpServletResponse; | ||
8 | import java.io.IOException; | ||
9 | |||
10 | /** | ||
11 | * Created by caobug on 15/7/29. | ||
12 | */ | ||
13 | public class CORSFilter extends HandlerInterceptorAdapter { | ||
14 | |||
15 | |||
16 | @Override | ||
17 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) | ||
18 | throws Exception { | ||
19 | response.setHeader("Access-Control-Allow-Origin", "*"); | ||
20 | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEAD"); | ||
21 | response.setHeader("Access-Control-Max-Age", "3600"); | ||
22 | response.setHeader("Access-Control-Allow-Headers", "Content-Type,X-Requested-With,accept," + | ||
23 | "Origin,Access-Control-Request-Method,Access-Control-Request-Headers,hdp-application-id," + | ||
24 | "hdp-rest-api-key,hdp_wx_user_info_json,wxu_session"); | ||
25 | |||
26 | return super.preHandle(request, response, handler); | ||
27 | } | ||
28 | |||
29 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | package com.example.mapper; | ||
2 | |||
3 | import com.example.models.ImgInfo; | ||
4 | import org.apache.ibatis.annotations.Param; | ||
5 | |||
6 | /** | ||
7 | * Created by JA on 17/7/17. | ||
8 | */ | ||
9 | public interface ImgInfoMapper { | ||
10 | |||
11 | boolean create(ImgInfo imgInfo); | ||
12 | |||
13 | ImgInfo getNewByOpenid(@Param("openid") String openid); | ||
14 | |||
15 | } |
1 | package com.example.mapper; | ||
2 | |||
3 | import com.example.models.ScoreLogInfo; | ||
4 | import org.apache.ibatis.annotations.Param; | ||
5 | |||
6 | import java.util.List; | ||
7 | import java.util.Map; | ||
8 | |||
9 | /** | ||
10 | * Created by JA on 17/7/17. | ||
11 | */ | ||
12 | public interface ScoreLogInfoMapper { | ||
13 | |||
14 | boolean create(ScoreLogInfo scoreLogInfo); | ||
15 | |||
16 | List<Map<String,Object>> getRankingList(@Param("limit") Long limit); | ||
17 | |||
18 | Map<String,Object> getMyRanking(@Param("openid") String openid); | ||
19 | |||
20 | long countByDay(@Param("openid") String openid,@Param("startDate") String startDate,@Param("endDate") String endDate); | ||
21 | |||
22 | long countSum(@Param("openid") String openid); | ||
23 | } |
1 | package com.example.models; | ||
2 | |||
3 | import java.util.Date; | ||
4 | |||
5 | /** | ||
6 | * Created by JA on 17/7/17. | ||
7 | */ | ||
8 | public class ConfigInfo { | ||
9 | |||
10 | private Date offTime; | ||
11 | private Double minScore; | ||
12 | private Long maxTime; | ||
13 | |||
14 | public Date getOffTime() { | ||
15 | return offTime; | ||
16 | } | ||
17 | |||
18 | public void setOffTime(Date offTime) { | ||
19 | this.offTime = offTime; | ||
20 | } | ||
21 | |||
22 | public Double getMinScore() { | ||
23 | return minScore; | ||
24 | } | ||
25 | |||
26 | public void setMinScore(Double minScore) { | ||
27 | this.minScore = minScore; | ||
28 | } | ||
29 | |||
30 | public Long getMaxTime() { | ||
31 | return maxTime; | ||
32 | } | ||
33 | |||
34 | public void setMaxTime(Long maxTime) { | ||
35 | this.maxTime = maxTime; | ||
36 | } | ||
37 | } |
1 | package com.example.models; | ||
2 | |||
3 | import java.util.Date; | ||
4 | |||
5 | /** | ||
6 | * Created by JA on 17/7/17. | ||
7 | */ | ||
8 | public class ImgInfo { | ||
9 | |||
10 | Long id; | ||
11 | String openid; | ||
12 | String nickname; | ||
13 | String headimgurl; | ||
14 | String imgUrl; | ||
15 | String blessingWords; | ||
16 | String sharingDescribe; | ||
17 | |||
18 | String gtmcUid; | ||
19 | String gtmcName; | ||
20 | String gtmcDepartment; | ||
21 | Date createAt; | ||
22 | Date updateAt; | ||
23 | Integer status; | ||
24 | |||
25 | public Long getId() { | ||
26 | return id; | ||
27 | } | ||
28 | |||
29 | public void setId(Long id) { | ||
30 | this.id = id; | ||
31 | } | ||
32 | |||
33 | public String getOpenid() { | ||
34 | return openid; | ||
35 | } | ||
36 | |||
37 | public void setOpenid(String openid) { | ||
38 | this.openid = openid; | ||
39 | } | ||
40 | |||
41 | public String getNickname() { | ||
42 | return nickname; | ||
43 | } | ||
44 | |||
45 | public void setNickname(String nickname) { | ||
46 | this.nickname = nickname; | ||
47 | } | ||
48 | |||
49 | public String getHeadimgurl() { | ||
50 | return headimgurl; | ||
51 | } | ||
52 | |||
53 | public void setHeadimgurl(String headimgurl) { | ||
54 | this.headimgurl = headimgurl; | ||
55 | } | ||
56 | |||
57 | public String getImgUrl() { | ||
58 | return imgUrl; | ||
59 | } | ||
60 | |||
61 | public void setImgUrl(String imgUrl) { | ||
62 | this.imgUrl = imgUrl; | ||
63 | } | ||
64 | |||
65 | public Date getCreateAt() { | ||
66 | return createAt; | ||
67 | } | ||
68 | |||
69 | public void setCreateAt(Date createAt) { | ||
70 | this.createAt = createAt; | ||
71 | } | ||
72 | |||
73 | public Date getUpdateAt() { | ||
74 | return updateAt; | ||
75 | } | ||
76 | |||
77 | public void setUpdateAt(Date updateAt) { | ||
78 | this.updateAt = updateAt; | ||
79 | } | ||
80 | |||
81 | public Integer getStatus() { | ||
82 | return status; | ||
83 | } | ||
84 | |||
85 | public void setStatus(Integer status) { | ||
86 | this.status = status; | ||
87 | } | ||
88 | |||
89 | public String getBlessingWords() { | ||
90 | return blessingWords; | ||
91 | } | ||
92 | |||
93 | public void setBlessingWords(String blessingWords) { | ||
94 | this.blessingWords = blessingWords; | ||
95 | } | ||
96 | |||
97 | public String getSharingDescribe() { | ||
98 | return sharingDescribe; | ||
99 | } | ||
100 | |||
101 | public void setSharingDescribe(String sharingDescribe) { | ||
102 | this.sharingDescribe = sharingDescribe; | ||
103 | } | ||
104 | |||
105 | public String getGtmcUid() { | ||
106 | return gtmcUid; | ||
107 | } | ||
108 | |||
109 | public void setGtmcUid(String gtmcUid) { | ||
110 | this.gtmcUid = gtmcUid; | ||
111 | } | ||
112 | |||
113 | public String getGtmcName() { | ||
114 | return gtmcName; | ||
115 | } | ||
116 | |||
117 | public void setGtmcName(String gtmcName) { | ||
118 | this.gtmcName = gtmcName; | ||
119 | } | ||
120 | |||
121 | public String getGtmcDepartment() { | ||
122 | return gtmcDepartment; | ||
123 | } | ||
124 | |||
125 | public void setGtmcDepartment(String gtmcDepartment) { | ||
126 | this.gtmcDepartment = gtmcDepartment; | ||
127 | } | ||
128 | } |
1 | package com.example.models; | ||
2 | |||
3 | import java.util.Date; | ||
4 | |||
5 | /** | ||
6 | * Created by JA on 17/7/17. | ||
7 | */ | ||
8 | public class ScoreLogInfo { | ||
9 | |||
10 | private Long id; | ||
11 | private String openid; | ||
12 | private String nickname; | ||
13 | private String headimgurl; | ||
14 | String gtmcUid; | ||
15 | String gtmcName; | ||
16 | String gtmcDepartment; | ||
17 | private Double score; | ||
18 | private Date createAt; | ||
19 | private Integer status; | ||
20 | |||
21 | public Long getId() { | ||
22 | return id; | ||
23 | } | ||
24 | |||
25 | public void setId(Long id) { | ||
26 | this.id = id; | ||
27 | } | ||
28 | |||
29 | public String getOpenid() { | ||
30 | return openid; | ||
31 | } | ||
32 | |||
33 | public void setOpenid(String openid) { | ||
34 | this.openid = openid; | ||
35 | } | ||
36 | |||
37 | public String getNickname() { | ||
38 | return nickname; | ||
39 | } | ||
40 | |||
41 | public void setNickname(String nickname) { | ||
42 | this.nickname = nickname; | ||
43 | } | ||
44 | |||
45 | public String getHeadimgurl() { | ||
46 | return headimgurl; | ||
47 | } | ||
48 | |||
49 | public void setHeadimgurl(String headimgurl) { | ||
50 | this.headimgurl = headimgurl; | ||
51 | } | ||
52 | |||
53 | public Double getScore() { | ||
54 | return score; | ||
55 | } | ||
56 | |||
57 | public void setScore(Double score) { | ||
58 | this.score = score; | ||
59 | } | ||
60 | |||
61 | public Date getCreateAt() { | ||
62 | return createAt; | ||
63 | } | ||
64 | |||
65 | public void setCreateAt(Date createAt) { | ||
66 | this.createAt = createAt; | ||
67 | } | ||
68 | |||
69 | public Integer getStatus() { | ||
70 | return status; | ||
71 | } | ||
72 | |||
73 | public void setStatus(Integer status) { | ||
74 | this.status = status; | ||
75 | } | ||
76 | |||
77 | public String getGtmcUid() { | ||
78 | return gtmcUid; | ||
79 | } | ||
80 | |||
81 | public void setGtmcUid(String gtmcUid) { | ||
82 | this.gtmcUid = gtmcUid; | ||
83 | } | ||
84 | |||
85 | public String getGtmcName() { | ||
86 | return gtmcName; | ||
87 | } | ||
88 | |||
89 | public void setGtmcName(String gtmcName) { | ||
90 | this.gtmcName = gtmcName; | ||
91 | } | ||
92 | |||
93 | public String getGtmcDepartment() { | ||
94 | return gtmcDepartment; | ||
95 | } | ||
96 | |||
97 | public void setGtmcDepartment(String gtmcDepartment) { | ||
98 | this.gtmcDepartment = gtmcDepartment; | ||
99 | } | ||
100 | } |
1 | package com.example.service; | ||
2 | |||
3 | import com.example.mapper.ImgInfoMapper; | ||
4 | import com.example.models.ImgInfo; | ||
5 | import org.springframework.beans.factory.annotation.Autowired; | ||
6 | import org.springframework.stereotype.Service; | ||
7 | |||
8 | import java.util.Date; | ||
9 | |||
10 | /** | ||
11 | * Created by JA on 17/11/22. | ||
12 | */ | ||
13 | @Service | ||
14 | public class ImgInfoServiceImpl implements ImgInfoService { | ||
15 | |||
16 | @Autowired | ||
17 | private ImgInfoMapper imgInfoMapper; | ||
18 | |||
19 | @Override | ||
20 | public boolean create(ImgInfo imgInfo) { | ||
21 | imgInfo.setStatus(1); | ||
22 | imgInfo.setCreateAt(new Date()); | ||
23 | imgInfo.setUpdateAt(new Date()); | ||
24 | return this.imgInfoMapper.create(imgInfo); | ||
25 | } | ||
26 | |||
27 | @Override | ||
28 | public ImgInfo getNewByOpenid(String openid) { | ||
29 | return this.imgInfoMapper.getNewByOpenid(openid); | ||
30 | } | ||
31 | } |
1 | package com.example.service; | ||
2 | |||
3 | import com.example.models.ScoreLogInfo; | ||
4 | |||
5 | import java.util.List; | ||
6 | import java.util.Map; | ||
7 | |||
8 | /** | ||
9 | * Created by JA on 17/11/21. | ||
10 | */ | ||
11 | public interface ScoreLogInfoService { | ||
12 | String save(ScoreLogInfo scoreLogInfo); | ||
13 | |||
14 | List<Map<String,Object>> getRankingList(Long limit); | ||
15 | |||
16 | Map<String,Object> getMyRanking(String openid); | ||
17 | |||
18 | long countToDay(String openid); | ||
19 | |||
20 | long countSum(String openid); | ||
21 | } |
1 | package com.example.service; | ||
2 | |||
3 | import com.example.mapper.ConfigInfoMapper; | ||
4 | import com.example.mapper.ScoreLogInfoMapper; | ||
5 | import com.example.models.ConfigInfo; | ||
6 | import com.example.models.ScoreLogInfo; | ||
7 | import org.springframework.beans.factory.annotation.Autowired; | ||
8 | import org.springframework.stereotype.Service; | ||
9 | |||
10 | import java.text.SimpleDateFormat; | ||
11 | import java.util.Date; | ||
12 | import java.util.List; | ||
13 | import java.util.Map; | ||
14 | |||
15 | /** | ||
16 | * Created by JA on 17/11/22. | ||
17 | */ | ||
18 | @Service | ||
19 | public class ScoreLogInfoServiceImpl implements ScoreLogInfoService { | ||
20 | |||
21 | private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); | ||
22 | |||
23 | @Autowired | ||
24 | private ScoreLogInfoMapper scoreLogInfoMapper; | ||
25 | |||
26 | @Autowired | ||
27 | private ConfigInfoMapper configInfoMapper; | ||
28 | |||
29 | @Override | ||
30 | public String save(ScoreLogInfo scoreLogInfo) { | ||
31 | String code = "2000"; | ||
32 | ConfigInfo configInfo = configInfoMapper.get(); | ||
33 | Date offTime = configInfo.getOffTime(); | ||
34 | Long maxTime = configInfo.getMaxTime(); | ||
35 | Double minScore = configInfo.getMinScore(); | ||
36 | Date now = new Date(); | ||
37 | long nowTime = now.getTime(); | ||
38 | long offTimeTime = offTime.getTime(); | ||
39 | |||
40 | if(nowTime > offTimeTime){ | ||
41 | code = "9901"; | ||
42 | }else{ | ||
43 | long count = this.countToDay(scoreLogInfo.getOpenid()); | ||
44 | if(count >= maxTime){ | ||
45 | code = "9902"; | ||
46 | }else{ | ||
47 | Double score = scoreLogInfo.getScore(); | ||
48 | if(minScore > score){ | ||
49 | code = "9903"; | ||
50 | }else{ | ||
51 | scoreLogInfo.setCreateAt(new Date()); | ||
52 | scoreLogInfo.setStatus(1); | ||
53 | boolean b = this.scoreLogInfoMapper.create(scoreLogInfo); | ||
54 | if(!b){ | ||
55 | code = "9904"; | ||
56 | } | ||
57 | } | ||
58 | } | ||
59 | } | ||
60 | return code; | ||
61 | } | ||
62 | |||
63 | @Override | ||
64 | public List<Map<String, Object>> getRankingList(Long limit) { | ||
65 | return this.scoreLogInfoMapper.getRankingList(limit); | ||
66 | } | ||
67 | |||
68 | @Override | ||
69 | public Map<String, Object> getMyRanking(String openid) { | ||
70 | return this.scoreLogInfoMapper.getMyRanking(openid); | ||
71 | } | ||
72 | |||
73 | @Override | ||
74 | public long countToDay(String openid) { | ||
75 | Date date = new Date(); | ||
76 | String format = sdf.format(date); | ||
77 | String startDate = format + " 00:00:00"; | ||
78 | String endDate = format + " 23:59:59"; | ||
79 | return this.scoreLogInfoMapper.countByDay(openid,startDate,endDate); | ||
80 | } | ||
81 | |||
82 | @Override | ||
83 | public long countSum(String openid) { | ||
84 | return this.scoreLogInfoMapper.countSum(openid); | ||
85 | } | ||
86 | |||
87 | |||
88 | } |
1 | package com.example.service.http; | ||
2 | |||
3 | import org.apache.wink.client.ClientConfig; | ||
4 | |||
5 | import javax.net.ssl.HttpsURLConnection; | ||
6 | import javax.net.ssl.SSLContext; | ||
7 | import javax.net.ssl.TrustManager; | ||
8 | import javax.net.ssl.X509TrustManager; | ||
9 | import java.security.KeyManagementException; | ||
10 | import java.security.NoSuchAlgorithmException; | ||
11 | |||
12 | /** | ||
13 | * Created by caobug on 15/5/12. | ||
14 | */ | ||
15 | public class ClientConfigServiceImpl implements ClientConfigService { | ||
16 | |||
17 | |||
18 | public ClientConfig getClientConfig() { | ||
19 | ClientConfig myConfig = new ClientConfig(); | ||
20 | SSLContext sc; | ||
21 | try { | ||
22 | sc = SSLContext.getInstance("SSL"); | ||
23 | sc.init(null, getTrustManager(), new java.security.SecureRandom()); | ||
24 | } catch (NoSuchAlgorithmException | KeyManagementException e) { | ||
25 | return null; | ||
26 | } | ||
27 | HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); | ||
28 | myConfig.setBypassHostnameVerification(true); | ||
29 | myConfig.connectTimeout(100000); | ||
30 | myConfig.readTimeout(100000); | ||
31 | myConfig.followRedirects(false); | ||
32 | return myConfig; | ||
33 | } | ||
34 | |||
35 | private TrustManager[] getTrustManager() { | ||
36 | return new TrustManager[]{new X509TrustManager() { | ||
37 | @Override | ||
38 | public java.security.cert.X509Certificate[] getAcceptedIssuers() { | ||
39 | return null; | ||
40 | } | ||
41 | |||
42 | @Override | ||
43 | public void checkClientTrusted( | ||
44 | java.security.cert.X509Certificate[] certs, String authType) { | ||
45 | } | ||
46 | |||
47 | @Override | ||
48 | public void checkServerTrusted( | ||
49 | java.security.cert.X509Certificate[] certs, String authType) { | ||
50 | } | ||
51 | }}; | ||
52 | } | ||
53 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | package com.example.service.http; | ||
2 | |||
3 | import com.fasterxml.jackson.core.JsonProcessingException; | ||
4 | |||
5 | import java.io.IOException; | ||
6 | import java.util.List; | ||
7 | import java.util.Map; | ||
8 | |||
9 | /** | ||
10 | * Created by Administrator on 2015/10/10-16:56. | ||
11 | * | ||
12 | * 派加积分HTTP POST接口 | ||
13 | */ | ||
14 | public interface HttpPostService { | ||
15 | |||
16 | void httpPostAsync(String url, Map<String, Object> postData); | ||
17 | |||
18 | Map<String, Object> httpPost(String url, Map<String, Object> postData) throws JsonProcessingException, IOException; | ||
19 | |||
20 | Map<String, Object> httpPostList(String url, List<Map<String, Object>> postData) throws JsonProcessingException, IOException; | ||
21 | |||
22 | String httpPostString(String url, Map<String, Object> postData); | ||
23 | |||
24 | List<Map<String, Object>> httpPostXml(String url, String postData); | ||
25 | |||
26 | } |
1 | package com.example.service.http; | ||
2 | |||
3 | import com.fasterxml.jackson.core.JsonProcessingException; | ||
4 | import com.fasterxml.jackson.core.type.TypeReference; | ||
5 | import com.fasterxml.jackson.databind.ObjectMapper; | ||
6 | import org.apache.wink.client.*; | ||
7 | import org.dom4j.Document; | ||
8 | import org.dom4j.DocumentException; | ||
9 | import org.dom4j.Element; | ||
10 | import org.dom4j.io.SAXReader; | ||
11 | import org.springframework.scheduling.annotation.Async; | ||
12 | import org.springframework.stereotype.Service; | ||
13 | |||
14 | import java.io.ByteArrayInputStream; | ||
15 | import java.io.IOException; | ||
16 | import java.io.UnsupportedEncodingException; | ||
17 | import java.util.ArrayList; | ||
18 | import java.util.HashMap; | ||
19 | import java.util.List; | ||
20 | import java.util.Map; | ||
21 | |||
22 | /** | ||
23 | * Created by Administrator on 2015/10/10-17:00. | ||
24 | */ | ||
25 | @Service("HttpPostService") | ||
26 | public class HttpPostServiceImpl implements HttpPostService { | ||
27 | |||
28 | |||
29 | private final ClientConfig CONFIG = new ClientConfigServiceImpl().getClientConfig(); | ||
30 | |||
31 | private final ClientConfig ASYNC_CONFIG = new ClientConfigServiceImpl().getClientConfig(); | ||
32 | |||
33 | @Override | ||
34 | @Async | ||
35 | public void httpPostAsync(String url, Map<String, Object> postData) { | ||
36 | // logger.debug("http post start [url:{}] [param:{}]", url, postData); | ||
37 | // logger.debug("http post postData:{}", postData); | ||
38 | |||
39 | ObjectMapper objectMapper = new ObjectMapper(); | ||
40 | try { | ||
41 | String postDataString = objectMapper.writeValueAsString(postData); | ||
42 | String responseEntity = post(url, postDataString, ASYNC_CONFIG); | ||
43 | } catch (JsonProcessingException e) { | ||
44 | } catch (ClientRuntimeException e) { | ||
45 | } | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * | ||
50 | * | ||
51 | * | ||
52 | * @param url 请求的url | ||
53 | * @param postData post的数据 | ||
54 | * @return 请求响应内容(解析后的结果) | ||
55 | */ | ||
56 | @Override | ||
57 | public Map<String, Object> httpPost(String url, Map<String, Object> postData) { | ||
58 | // logger.debug("http post start url:{}", url); | ||
59 | // logger.debug("http post postData:{}", postData); | ||
60 | ObjectMapper objectMapper = new ObjectMapper(); | ||
61 | Map<String, Object> readValue = null; | ||
62 | try { | ||
63 | String postDataString = objectMapper.writeValueAsString(postData); | ||
64 | String responseEntity = post(url, postDataString, CONFIG); | ||
65 | readValue = objectMapper.readValue(responseEntity, new TypeReference<Map<String, Object>>() { | ||
66 | }); | ||
67 | } catch (JsonProcessingException e) { | ||
68 | } catch (IOException e) { | ||
69 | } catch (ClientRuntimeException e) { | ||
70 | } | ||
71 | |||
72 | return readValue; | ||
73 | } | ||
74 | |||
75 | |||
76 | /** | ||
77 | * | ||
78 | * | ||
79 | * | ||
80 | * @param url 请求的url | ||
81 | * @param postData post的数据 | ||
82 | * @return 请求响应内容(解析后的结果) | ||
83 | */ | ||
84 | @Override | ||
85 | public String httpPostString(String url, Map<String, Object> postData) { | ||
86 | String responseEntity = null; | ||
87 | try { | ||
88 | responseEntity = postString(url, postData, CONFIG); | ||
89 | } catch (Exception e){ | ||
90 | e.printStackTrace(); | ||
91 | } | ||
92 | |||
93 | return responseEntity; | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * | ||
98 | * | ||
99 | * | ||
100 | * @param url 请求的url | ||
101 | * @param postData post的数据 | ||
102 | * @return 请求响应内容(解析后的结果) | ||
103 | */ | ||
104 | @Override | ||
105 | public Map<String, Object> httpPostList(String url, List<Map<String, Object>> postData) { | ||
106 | // logger.debug("http post start url:{}", url); | ||
107 | // logger.debug("http post postData:{}", postData); | ||
108 | |||
109 | ObjectMapper objectMapper = new ObjectMapper(); | ||
110 | Map<String, Object> readValue = null; | ||
111 | try { | ||
112 | String postDataString = objectMapper.writeValueAsString(postData); | ||
113 | String responseEntity = post(url, postDataString, CONFIG); | ||
114 | readValue = objectMapper.readValue(responseEntity, new TypeReference<Map<String, Object>>() { | ||
115 | }); | ||
116 | } catch (JsonProcessingException e) { | ||
117 | } catch (IOException e) { | ||
118 | } catch (ClientRuntimeException e) { | ||
119 | } | ||
120 | |||
121 | return readValue; | ||
122 | } | ||
123 | |||
124 | private String post(String url, String postParams, ClientConfig config) { | ||
125 | //创建http访问 | ||
126 | Resource resource = new RestClient(config).resource(url); | ||
127 | resource.contentType("application/json;charset=UTF-8"); | ||
128 | ClientResponse response = resource.post(postParams); | ||
129 | String responseEntity = response.getEntity(String.class); | ||
130 | return responseEntity; | ||
131 | } | ||
132 | |||
133 | /** | ||
134 | * | ||
135 | * | ||
136 | * | ||
137 | * @param url 请求的url | ||
138 | * @param postData post的数据 | ||
139 | * @return 请求响应内容(解析后的结果) | ||
140 | */ | ||
141 | @Override | ||
142 | public List<Map<String, Object>> httpPostXml(String url, String postData) { | ||
143 | // logger.debug("http post start url:{}", url); | ||
144 | // logger.debug("http post postData:{}", postData); | ||
145 | List<Map<String, Object>> list = null; | ||
146 | try { | ||
147 | String responseEntity = post(url, postData, CONFIG); | ||
148 | System.out.println(responseEntity); | ||
149 | list = resolveXml(responseEntity); | ||
150 | } catch (Exception e) { | ||
151 | } | ||
152 | |||
153 | return list; | ||
154 | } | ||
155 | |||
156 | @SuppressWarnings("unchecked") | ||
157 | public static List<Map<String, Object>> resolveXml(String xmlString) { | ||
158 | List<Map<String, Object>> result = new ArrayList<>(); | ||
159 | try { | ||
160 | SAXReader saxReader = new SAXReader(); | ||
161 | Document document = saxReader.read(new ByteArrayInputStream(xmlString.getBytes("UTF-8"))); | ||
162 | Element rootElement = document.getRootElement(); | ||
163 | re(result,rootElement); | ||
164 | } catch (DocumentException | UnsupportedEncodingException e) { | ||
165 | e.printStackTrace(); | ||
166 | } | ||
167 | return result; | ||
168 | } | ||
169 | |||
170 | @SuppressWarnings("unchecked") | ||
171 | private static List<Map<String, Object>> re(List<Map<String, Object>> pMap,Element rootElement){ | ||
172 | List<Map<String, Object>> result = new ArrayList<>(); | ||
173 | Map<String, Object> m = new HashMap<>(); | ||
174 | for (Element element : (Iterable<Element>) rootElement.elements()) { | ||
175 | |||
176 | |||
177 | if(element.elements() != null && element.elements().size() != 0){ | ||
178 | re(result,element); | ||
179 | m.put(element.getName(),result); | ||
180 | }else{ | ||
181 | m.put(element.getName(), element.getStringValue()); | ||
182 | } | ||
183 | |||
184 | } | ||
185 | pMap.add(m); | ||
186 | return pMap; | ||
187 | } | ||
188 | |||
189 | private String postXml(String url, String postParams, ClientConfig config) { | ||
190 | //创建http访问 | ||
191 | Resource resource = new RestClient(config).resource(url); | ||
192 | resource.contentType("application/xml;charset=UTF-8"); | ||
193 | ClientResponse response = resource.post(postParams); | ||
194 | String responseEntity = response.getEntity(String.class); | ||
195 | return responseEntity; | ||
196 | } | ||
197 | |||
198 | |||
199 | private String postString(String url, Map<String,Object> postParams, ClientConfig config) { | ||
200 | //创建http访问 | ||
201 | Resource resource = new RestClient(config).resource(url); | ||
202 | if(postParams != null){ | ||
203 | for(String key:postParams.keySet()){ | ||
204 | resource.queryParam(key,postParams.get(key)); | ||
205 | } | ||
206 | } | ||
207 | ClientResponse response = resource.post(null); | ||
208 | String responseEntity = response.getEntity(String.class); | ||
209 | return responseEntity; | ||
210 | } | ||
211 | |||
212 | } |
1 | package com.example.support.model; | ||
2 | |||
3 | import org.apache.commons.lang3.RandomStringUtils; | ||
4 | |||
5 | import javax.servlet.http.HttpServletRequest; | ||
6 | import java.io.Serializable; | ||
7 | |||
8 | /** | ||
9 | * 响应的消息实体,使用例子如下: | ||
10 | * | ||
11 | * @FormToken(produce = true) | ||
12 | * @ResponseBody | ||
13 | * @RequestMapping(value = "/create/test", method = RequestMethod.GET) | ||
14 | * public Object test(HttpServletRequest request) throws JsonProcessingException { | ||
15 | * Object map = new HashMap<>(); | ||
16 | * map.put("redirect", "http://www.baidu.com/"); | ||
17 | * return new MessageEntity.Builder(request).code(MessageCodeEnum.ALREADY_EXISTS). | ||
18 | * msg("账户已存在").content(map).success(false).create(); | ||
19 | * } | ||
20 | * <p/> | ||
21 | * 构造对此对象时,消息不传时会默认初始化一些值。以下键值对左边表示属性,右边表示默认值:requestId=null, msg=null, seccuess=false | ||
22 | * , code=0, content=null,而resubmitToken已内置在构造器中,无需担忧默认为空。通常该值是从 SESSION 中取,为了防止TOKEN 重复提交功能生效, | ||
23 | * 请勿自定义resubmitToken值。正确的做法是传入request | ||
24 | */ | ||
25 | public class MessageEntity implements Serializable { | ||
26 | |||
27 | private static final long serialVersionUID = 5165069341805388402L; | ||
28 | |||
29 | private final String msg; // 消息 | ||
30 | private final boolean success; // 操作成功与否 | ||
31 | private final String resubmitToken; // post token | ||
32 | private final String code; // 状态码 | ||
33 | private final Object content; // 内容主体 | ||
34 | |||
35 | /** | ||
36 | * 请选构造 MessageEntity.Builder 对象 | ||
37 | * | ||
38 | * @param builder | ||
39 | */ | ||
40 | public MessageEntity(Builder builder) { | ||
41 | this.msg = builder.msg; | ||
42 | this.success = builder.success; | ||
43 | this.resubmitToken = builder.resubmitToken; | ||
44 | this.code = builder.code; | ||
45 | this.content = builder.content; | ||
46 | } | ||
47 | |||
48 | public String getMsg() { | ||
49 | return msg; | ||
50 | } | ||
51 | |||
52 | public boolean isSuccess() { | ||
53 | return success; | ||
54 | } | ||
55 | |||
56 | public String getResubmitToken() { | ||
57 | return resubmitToken; | ||
58 | } | ||
59 | |||
60 | public String getCode() { | ||
61 | return code; | ||
62 | } | ||
63 | |||
64 | public Object getContent() { | ||
65 | return content; | ||
66 | } | ||
67 | |||
68 | @Override | ||
69 | public String toString() { | ||
70 | return "MessageEntity{" + | ||
71 | ", msg='" + msg + '\'' + | ||
72 | ", success=" + success + | ||
73 | ", resubmitToken='" + resubmitToken + '\'' + | ||
74 | ", code=" + code + | ||
75 | ", content=" + content + | ||
76 | '}'; | ||
77 | } | ||
78 | |||
79 | public static class Builder { | ||
80 | private final String resubmitToken; // post token | ||
81 | private String msg; // 消息 | ||
82 | private boolean success; // 操作成功与否 | ||
83 | private String code; // 状态码 | ||
84 | private Object content; // 内容主体 | ||
85 | |||
86 | /** | ||
87 | * 新 token | ||
88 | * | ||
89 | * @param request | ||
90 | */ | ||
91 | public Builder(HttpServletRequest request) { | ||
92 | if (null != request) { | ||
93 | this.resubmitToken = getToken(); | ||
94 | // request.getSession().setAttribute(FormTokenInterceptor.TOKEN_NAME, this.resubmitToken); | ||
95 | } else { | ||
96 | this.resubmitToken = null; | ||
97 | } | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * 消息,需要解决国际化问题 | ||
102 | * | ||
103 | * @param msg | ||
104 | * @return | ||
105 | */ | ||
106 | public Builder msg(String msg) { | ||
107 | this.msg = msg; | ||
108 | return this; | ||
109 | } | ||
110 | |||
111 | /** | ||
112 | * 是否成功 | ||
113 | * | ||
114 | * @param success | ||
115 | * @return | ||
116 | */ | ||
117 | public Builder success(boolean success) { | ||
118 | this.success = success; | ||
119 | return this; | ||
120 | } | ||
121 | |||
122 | public Builder code(String code) { | ||
123 | this.code = code; | ||
124 | return this; | ||
125 | } | ||
126 | |||
127 | /** | ||
128 | * 消息主体,根据前端需求构造 | ||
129 | * | ||
130 | * @param content | ||
131 | * @return | ||
132 | */ | ||
133 | public Builder content(Object content) { | ||
134 | this.content = content; | ||
135 | return this; | ||
136 | } | ||
137 | |||
138 | public MessageEntity create() { | ||
139 | return new MessageEntity(this); | ||
140 | } | ||
141 | |||
142 | public String getToken() { | ||
143 | return RandomStringUtils.random(32, 'a', 'b', 'c', 'd', 'e', 'f', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); | ||
144 | } | ||
145 | } | ||
146 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | package com.example.utils; | ||
2 | |||
3 | import java.util.UUID; | ||
4 | |||
5 | /** | ||
6 | * RandomStringUtils | ||
7 | * <p/> | ||
8 | * Created by caobug on 15/6/23. | ||
9 | */ | ||
10 | public class RandomStringUtils extends org.apache.commons.lang3.RandomStringUtils { | ||
11 | |||
12 | public static final String ARTICLE_KEY_ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | ||
13 | |||
14 | public static String getString() { | ||
15 | return UUID.randomUUID().toString().replace("-", ""); | ||
16 | } | ||
17 | |||
18 | /** | ||
19 | * 根据字母表生成指定位数随机字符串 | ||
20 | * | ||
21 | * @param length 随机长度 | ||
22 | * @return 随机字符串 | ||
23 | */ | ||
24 | public static String getString(int length) { | ||
25 | return random(length, ARTICLE_KEY_ALPHABET); | ||
26 | } | ||
27 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | package com.example.utils.check; | ||
2 | |||
3 | import javax.servlet.http.HttpServletRequest; | ||
4 | |||
5 | /** | ||
6 | * Created by Administrator on 2017/4/1. | ||
7 | */ | ||
8 | public class CheckRefererUtils { | ||
9 | |||
10 | public static boolean checkReferer(HttpServletRequest request){ | ||
11 | return true; | ||
12 | |||
13 | // String referer = request.getHeader("REFERER"); | ||
14 | // String host = "lucky.csair.com"; | ||
15 | // | ||
16 | // System.out.println("开始校验 referer:"+referer); | ||
17 | // if(referer == null || referer.indexOf(host) < 0){ | ||
18 | // System.out.println("referer错误 referer:"+referer); | ||
19 | // return false; | ||
20 | // } | ||
21 | // return true; | ||
22 | } | ||
23 | |||
24 | } |
1 | package com.example.utils.file; | ||
2 | |||
3 | import org.springframework.web.multipart.MultipartFile; | ||
4 | import sun.misc.BASE64Decoder; | ||
5 | |||
6 | import java.io.*; | ||
7 | import java.text.SimpleDateFormat; | ||
8 | import java.util.Date; | ||
9 | import java.util.UUID; | ||
10 | |||
11 | /** | ||
12 | * Created by JA on 17/7/3. | ||
13 | */ | ||
14 | |||
15 | public class DefaultFileUpload { | ||
16 | |||
17 | |||
18 | |||
19 | /** | ||
20 | * 快速上传,等同于调用另外一个uplaod方法 | ||
21 | * | ||
22 | * @param file MultipartFile 对象,不能为空 | ||
23 | * @return FileUploadInfo | ||
24 | */ | ||
25 | public static FileUploadInfo directUpload(String home, MultipartFile file) { | ||
26 | return new DefaultFileUpload().upload(home,file); | ||
27 | } | ||
28 | |||
29 | |||
30 | public FileUploadInfo upload(String home,MultipartFile file) { | ||
31 | try { | ||
32 | InputStream inputStream = file.getInputStream(); | ||
33 | String savePath = home; | ||
34 | String originFileName = file.getOriginalFilename(); | ||
35 | String suffix = FileType.getSuffixByFilename(originFileName); | ||
36 | String url = savePath + "/" + getRandomString() + suffix; | ||
37 | File filePath = new File(url); | ||
38 | |||
39 | File parentFile = filePath.getParentFile(); | ||
40 | if (!parentFile.exists()) { | ||
41 | parentFile.mkdirs(); // create dirs | ||
42 | } | ||
43 | // filePath.createNewFile(); | ||
44 | inputstreamtofile(inputStream,filePath); | ||
45 | // file.transferTo(filePath); | ||
46 | return new FileUploadInfo(true, originFileName, file.getSize(), url.replace(home, ""), suffix); | ||
47 | } catch (IOException e) { | ||
48 | e.printStackTrace(); | ||
49 | // logger.error("file upload fail!", e); | ||
50 | FileUploadInfo fileUploadInfo = new FileUploadInfo(false, null, 0, null, null); | ||
51 | fileUploadInfo.setStateMsg(e.getMessage()); | ||
52 | return fileUploadInfo; | ||
53 | } | ||
54 | } | ||
55 | |||
56 | public FileUploadInfo uploadBase64(String home,String base64) { | ||
57 | try { | ||
58 | BASE64Decoder decoder = new BASE64Decoder(); | ||
59 | String savePath = home; | ||
60 | String suffix = base64.substring(base64.indexOf('/') + 1, base64.indexOf(';')); | ||
61 | String str1 = base64.split(",")[1]; | ||
62 | base64 = str1; | ||
63 | String url = savePath + "/" + getRandomString()+"." + suffix; | ||
64 | // File filePath = new File(url); | ||
65 | // filePath.createNewFile(); | ||
66 | //对字节数组字符串进行Base64解码并生成图片 | ||
67 | if (base64 == null){ | ||
68 | FileUploadInfo fileUploadInfo = new FileUploadInfo(false, null, 0, null, null); | ||
69 | fileUploadInfo.setStateMsg(""); | ||
70 | return fileUploadInfo; | ||
71 | } | ||
72 | //Base64解码 | ||
73 | byte[] bytes = decoder.decodeBuffer(base64); | ||
74 | OutputStream out = new FileOutputStream(url); | ||
75 | out.write(bytes); | ||
76 | out.flush(); | ||
77 | out.close(); | ||
78 | // file.transferTo(filePath); | ||
79 | return new FileUploadInfo(true, "", 0, url.replace(home, ""), suffix); | ||
80 | } catch (Exception e) { | ||
81 | e.printStackTrace(); | ||
82 | // logger.error("file upload fail!", e); | ||
83 | FileUploadInfo fileUploadInfo = new FileUploadInfo(false, null, 0, null, null); | ||
84 | fileUploadInfo.setStateMsg(e.getMessage()); | ||
85 | return fileUploadInfo; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | public static void inputstreamtofile(InputStream ins,File file) { | ||
90 | try { | ||
91 | OutputStream os = new FileOutputStream(file); | ||
92 | int bytesRead = 0; | ||
93 | byte[] buffer = new byte[8192]; | ||
94 | while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { | ||
95 | os.write(buffer, 0, bytesRead); | ||
96 | } | ||
97 | os.close(); | ||
98 | ins.close(); | ||
99 | } catch (Exception e) { | ||
100 | e.printStackTrace(); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | private String getDateTime(String format) { | ||
105 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat(format); | ||
106 | return simpleDateFormat.format(new Date()); | ||
107 | } | ||
108 | |||
109 | private String getRandomString() { | ||
110 | return UUID.randomUUID().toString().replace("-", ""); | ||
111 | } | ||
112 | |||
113 | |||
114 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | package com.example.utils.file; | ||
2 | |||
3 | import java.util.HashMap; | ||
4 | import java.util.Map; | ||
5 | |||
6 | /** | ||
7 | * Created by caobug on 15/5/22. | ||
8 | */ | ||
9 | public class FileType { | ||
10 | |||
11 | public static final String JPG = "JPG"; | ||
12 | |||
13 | private static final Map<String, String> types = new HashMap<String, String>() {{ | ||
14 | put(FileType.JPG, ".jpg"); | ||
15 | }}; | ||
16 | |||
17 | public static String getSuffix(String key) { | ||
18 | return FileType.types.get(key); | ||
19 | } | ||
20 | |||
21 | /** | ||
22 | * 根据给定的文件名,获取其后缀信息 | ||
23 | * | ||
24 | * @param filename | ||
25 | * @return | ||
26 | */ | ||
27 | public static String getSuffixByFilename(String filename) { | ||
28 | return filename.substring(filename.lastIndexOf(".")).toLowerCase(); | ||
29 | } | ||
30 | |||
31 | /** | ||
32 | * 根据给定的文件名,获取文件类型 | ||
33 | * | ||
34 | * @param filename | ||
35 | * @return | ||
36 | */ | ||
37 | public static String getFileType(String filename) { | ||
38 | return filename.substring(filename.lastIndexOf(".") + 1).toLowerCase(); | ||
39 | } | ||
40 | } |
1 | package com.example.utils.file; | ||
2 | |||
3 | /** | ||
4 | * Created by JA on 17/7/3. | ||
5 | */ | ||
6 | |||
7 | /** | ||
8 | * 文件上传信息 | ||
9 | * <p/> | ||
10 | * Created by caobug on 15/5/22. | ||
11 | */ | ||
12 | public class FileUploadInfo { | ||
13 | |||
14 | private boolean state; // 上传状态 | ||
15 | private String stateMsg;// 状态消息 | ||
16 | private String originalName; // 原始文件名 | ||
17 | private long size; // 文件大小 | ||
18 | private String url; // 文件保存路径 | ||
19 | private String suffix; // 后缀 | ||
20 | |||
21 | public FileUploadInfo(boolean state, String originalName, long size, String url, String suffix) { | ||
22 | this.state = state; | ||
23 | this.originalName = originalName; | ||
24 | this.size = size; | ||
25 | this.url = url; | ||
26 | this.suffix = suffix; | ||
27 | } | ||
28 | |||
29 | public boolean isState() { | ||
30 | return state; | ||
31 | } | ||
32 | |||
33 | public void setState(boolean state) { | ||
34 | this.state = state; | ||
35 | } | ||
36 | |||
37 | public String getOriginalName() { | ||
38 | return originalName; | ||
39 | } | ||
40 | |||
41 | public void setOriginalName(String originalName) { | ||
42 | this.originalName = originalName; | ||
43 | } | ||
44 | |||
45 | public long getSize() { | ||
46 | return size; | ||
47 | } | ||
48 | |||
49 | public void setSize(long size) { | ||
50 | this.size = size; | ||
51 | } | ||
52 | |||
53 | public String getUrl() { | ||
54 | return url; | ||
55 | } | ||
56 | |||
57 | public void setUrl(String url) { | ||
58 | this.url = url; | ||
59 | } | ||
60 | |||
61 | public String getSuffix() { | ||
62 | return suffix; | ||
63 | } | ||
64 | |||
65 | public void setSuffix(String suffix) { | ||
66 | this.suffix = suffix; | ||
67 | } | ||
68 | |||
69 | public String getStateMsg() { | ||
70 | return stateMsg; | ||
71 | } | ||
72 | |||
73 | public void setStateMsg(String stateMsg) { | ||
74 | this.stateMsg = stateMsg; | ||
75 | } | ||
76 | } |
1 | package com.example.utils.md5; | ||
2 | |||
3 | import java.io.File; | ||
4 | import java.io.FileInputStream; | ||
5 | import java.io.FileNotFoundException; | ||
6 | import java.io.IOException; | ||
7 | import java.math.BigInteger; | ||
8 | import java.nio.MappedByteBuffer; | ||
9 | import java.nio.channels.FileChannel; | ||
10 | import java.security.MessageDigest; | ||
11 | |||
12 | |||
13 | |||
14 | /** | ||
15 | * Created by caobug on 14/11/20. | ||
16 | */ | ||
17 | public class MD5Utils { | ||
18 | |||
19 | public static String hash(String str) { | ||
20 | try { | ||
21 | java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); | ||
22 | byte[] array = md.digest(str.getBytes()); | ||
23 | StringBuilder sb = new StringBuilder(); | ||
24 | for (byte anArray : array) { | ||
25 | sb.append(Integer.toHexString((anArray & 0xFF) | 0x100).substring(1, 3)); | ||
26 | } | ||
27 | return sb.toString(); | ||
28 | } catch (java.security.NoSuchAlgorithmException ignored) { | ||
29 | } | ||
30 | return ""; | ||
31 | } | ||
32 | |||
33 | private static String byteArrayToHexString(byte b[]) { | ||
34 | StringBuffer resultSb = new StringBuffer(); | ||
35 | for (int i = 0; i < b.length; i++) | ||
36 | resultSb.append(byteToHexString(b[i])); | ||
37 | |||
38 | return resultSb.toString(); | ||
39 | } | ||
40 | |||
41 | private static String byteToHexString(byte b) { | ||
42 | int n = b; | ||
43 | if (n < 0) | ||
44 | n += 256; | ||
45 | int d1 = n / 16; | ||
46 | int d2 = n % 16; | ||
47 | return hexDigits[d1] + hexDigits[d2]; | ||
48 | } | ||
49 | |||
50 | public static String MD5Encode(String origin, String charsetname) { | ||
51 | String resultString = null; | ||
52 | try { | ||
53 | resultString = new String(origin); | ||
54 | MessageDigest md = MessageDigest.getInstance("MD5"); | ||
55 | if (charsetname == null || "".equals(charsetname)) | ||
56 | resultString = byteArrayToHexString(md.digest(resultString | ||
57 | .getBytes())); | ||
58 | else | ||
59 | resultString = byteArrayToHexString(md.digest(resultString | ||
60 | .getBytes(charsetname))); | ||
61 | } catch (Exception exception) { | ||
62 | } | ||
63 | return resultString; | ||
64 | } | ||
65 | |||
66 | public static String getMd5ByFile(File file) throws FileNotFoundException { | ||
67 | String value = null; | ||
68 | FileInputStream in = new FileInputStream(file); | ||
69 | try { | ||
70 | MappedByteBuffer byteBuffer = in.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, file.length()); | ||
71 | MessageDigest md5 = MessageDigest.getInstance("MD5"); | ||
72 | md5.update(byteBuffer); | ||
73 | BigInteger bi = new BigInteger(1, md5.digest()); | ||
74 | value = bi.toString(16); | ||
75 | } catch (Exception e) { | ||
76 | e.printStackTrace(); | ||
77 | } finally { | ||
78 | if(null != in) { | ||
79 | try { | ||
80 | in.close(); | ||
81 | } catch (IOException e) { | ||
82 | e.printStackTrace(); | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | return value; | ||
87 | } | ||
88 | |||
89 | private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5", | ||
90 | "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" }; | ||
91 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | package com.example.utils.mybatis; | ||
2 | |||
3 | import com.example.utils.mybatis.pageable.MybatisPageableInterceptor; | ||
4 | import org.apache.ibatis.plugin.Interceptor; | ||
5 | import org.apache.ibatis.session.SqlSessionFactory; | ||
6 | import org.mybatis.spring.SqlSessionFactoryBean; | ||
7 | import org.mybatis.spring.SqlSessionTemplate; | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | ||
9 | import org.springframework.beans.factory.annotation.Value; | ||
10 | import org.springframework.context.annotation.Bean; | ||
11 | import org.springframework.context.annotation.Configuration; | ||
12 | import org.springframework.core.io.support.PathMatchingResourcePatternResolver; | ||
13 | import org.springframework.core.io.support.ResourcePatternResolver; | ||
14 | import org.springframework.jdbc.datasource.DataSourceTransactionManager; | ||
15 | import org.springframework.transaction.PlatformTransactionManager; | ||
16 | import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
17 | import org.springframework.transaction.annotation.TransactionManagementConfigurer; | ||
18 | |||
19 | import javax.sql.DataSource; | ||
20 | |||
21 | @Configuration | ||
22 | @EnableTransactionManagement | ||
23 | public class MyBatisConfig implements TransactionManagementConfigurer { | ||
24 | |||
25 | @Autowired | ||
26 | DataSource dataSource; | ||
27 | |||
28 | @Value("${mybatis.mapperLocations}") | ||
29 | private String mybatismapperLocations; | ||
30 | |||
31 | @Autowired | ||
32 | MybatisPageableInterceptor mybatisPageableInterceptor; | ||
33 | |||
34 | @Bean(name = "sqlSessionFactory") | ||
35 | public SqlSessionFactory sqlSessionFactoryBean() { | ||
36 | System.out.println("sqlSessionFactory============="); | ||
37 | System.out.println("sqlSessionFactory============="); | ||
38 | System.out.println("sqlSessionFactory============="); | ||
39 | System.out.println("sqlSessionFactory============="); | ||
40 | System.out.println("sqlSessionFactory============="); | ||
41 | SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); | ||
42 | bean.setDataSource(dataSource); | ||
43 | //添加分页插件 | ||
44 | bean.setPlugins(new Interceptor[]{mybatisPageableInterceptor}); | ||
45 | |||
46 | //添加XML目录 | ||
47 | ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); | ||
48 | try { | ||
49 | // SqlSessionFactory sqlSessionFactory = bean.getObject(); | ||
50 | // org.apache.ibatis.session.Configuration configuration = sqlSessionFactory.getConfiguration(); | ||
51 | // //支持驼峰 | ||
52 | // configuration.setMapUnderscoreToCamelCase(true); | ||
53 | bean.setMapperLocations(resolver.getResources(mybatismapperLocations)); | ||
54 | SqlSessionFactory sqlSessionFactory = bean.getObject(); | ||
55 | sqlSessionFactory.getConfiguration().setMapUnderscoreToCamelCase(true);// 开启驼峰映射 | ||
56 | return sqlSessionFactory; | ||
57 | } catch (Exception e) { | ||
58 | e.printStackTrace(); | ||
59 | throw new RuntimeException(e); | ||
60 | } | ||
61 | } | ||
62 | |||
63 | @Bean | ||
64 | public SqlSessionTemplate sqlSessionTemplate(SqlSessionFactory sqlSessionFactory) { | ||
65 | return new SqlSessionTemplate(sqlSessionFactory); | ||
66 | } | ||
67 | |||
68 | @Bean | ||
69 | @Override | ||
70 | public PlatformTransactionManager annotationDrivenTransactionManager() { | ||
71 | return new DataSourceTransactionManager(dataSource); | ||
72 | } | ||
73 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | package com.example.utils.mybatis.pageable; | ||
2 | |||
3 | public class Dialect { | ||
4 | public boolean supportsLimit() { | ||
5 | return false; | ||
6 | } | ||
7 | |||
8 | public boolean supportsLimitOffset() { | ||
9 | return supportsLimit(); | ||
10 | } | ||
11 | |||
12 | /** | ||
13 | * 将sql变成分页sql语句,直接使用offset,limit的值作为占位符.</br> 源代码为: | ||
14 | * getLimitString(sql,offset | ||
15 | * ,String.valueOf(offset),limit,String.valueOf(limit)) | ||
16 | */ | ||
17 | public String getLimitString(String sql, int offset, int limit) { | ||
18 | return getLimitString(sql, offset, Integer.toString(offset), limit, | ||
19 | Integer.toString(limit)); | ||
20 | } | ||
21 | |||
22 | /** | ||
23 | * 将sql变成分页sql语句,提供将offset及limit使用占位符(placeholder)替换. | ||
24 | * <p/> | ||
25 | * <pre> | ||
26 | * 如mysql | ||
27 | * dialect.getLimitString("select * from user", 12, ":offset",0,":limit") 将返回 | ||
28 | * select * from user limit :offset,:limit | ||
29 | * </pre> | ||
30 | * | ||
31 | * @return 包含占位符的分页sql | ||
32 | */ | ||
33 | public String getLimitString(String sql, int offset, | ||
34 | String offsetPlaceholder, int limit, String limitPlaceholder) { | ||
35 | throw new UnsupportedOperationException("paged queries not supported"); | ||
36 | } | ||
37 | |||
38 | /** | ||
39 | * 将sql转换为总记录数SQL | ||
40 | * | ||
41 | * @param sql SQL语句 | ||
42 | * @return 总记录数的sql | ||
43 | */ | ||
44 | public String getCountString(String sql) { | ||
45 | return "select count(1) from (" + sql + ") tmp_count"; | ||
46 | } | ||
47 | |||
48 | /** | ||
49 | * 将sql转换为带排序的SQL | ||
50 | * | ||
51 | * @param sql | ||
52 | * SQL语句 | ||
53 | * @return 总记录数的sql | ||
54 | */ | ||
55 | // public String getSortString(String sql, List<Order> orders) { | ||
56 | // if (orders == null || orders.isEmpty()) { | ||
57 | // return sql; | ||
58 | // } | ||
59 | // | ||
60 | // StringBuffer buffer = new StringBuffer("select * from (").append(sql) | ||
61 | // .append(") temp_order order by "); | ||
62 | // for (Order order : orders) { | ||
63 | // if (order != null) { | ||
64 | // buffer.append(order.toString()).append(", "); | ||
65 | // } | ||
66 | // | ||
67 | // } | ||
68 | // buffer.delete(buffer.length() - 2, buffer.length()); | ||
69 | // return buffer.toString(); | ||
70 | // } | ||
71 | } |
1 | package com.example.utils.mybatis.pageable; | ||
2 | |||
3 | public class MySQLDialect extends Dialect { | ||
4 | |||
5 | public boolean supportsLimitOffset() { | ||
6 | return true; | ||
7 | } | ||
8 | |||
9 | public boolean supportsLimit() { | ||
10 | return true; | ||
11 | } | ||
12 | |||
13 | public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder) { | ||
14 | if (offset > 0) { | ||
15 | return sql + " limit " + offsetPlaceholder + "," + limitPlaceholder; | ||
16 | } else { | ||
17 | return sql + " limit " + limitPlaceholder; | ||
18 | } | ||
19 | } | ||
20 | } | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
kmr_dp_HDP/src/main/java/com/example/utils/mybatis/pageable/MybatisPageableInterceptor.java
0 → 100755
This diff is collapsed.
Click to expand it.
1 | package com.example.utils.mybatis.pageable; | ||
2 | |||
3 | public class OracleDialect extends Dialect { | ||
4 | |||
5 | public boolean supportsLimit() { | ||
6 | return true; | ||
7 | } | ||
8 | |||
9 | public boolean supportsLimitOffset() { | ||
10 | return true; | ||
11 | } | ||
12 | |||
13 | public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder) { | ||
14 | sql = sql.trim(); | ||
15 | boolean isForUpdate = false; | ||
16 | if (sql.toLowerCase().endsWith(" for update")) { | ||
17 | sql = sql.substring(0, sql.length() - 11); | ||
18 | isForUpdate = true; | ||
19 | } | ||
20 | |||
21 | StringBuffer pagingSelect = new StringBuffer(sql.length() + 100); | ||
22 | if (offset > 0) { | ||
23 | pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( "); | ||
24 | } else { | ||
25 | pagingSelect.append("select * from ( "); | ||
26 | } | ||
27 | pagingSelect.append(sql); | ||
28 | if (offset > 0) { | ||
29 | // int end = offset+limit; | ||
30 | String endString = offsetPlaceholder + "+" + limitPlaceholder; | ||
31 | pagingSelect.append(" ) row_ ) where rownum_ <= " + endString + " and rownum_ > " + offsetPlaceholder); | ||
32 | } else { | ||
33 | pagingSelect.append(" ) where rownum <= " + limitPlaceholder); | ||
34 | } | ||
35 | |||
36 | if (isForUpdate) { | ||
37 | pagingSelect.append(" for update"); | ||
38 | } | ||
39 | |||
40 | return pagingSelect.toString(); | ||
41 | } | ||
42 | |||
43 | } | ||
44 |
1 | package com.example.utils.mybatis.pageable; | ||
2 | |||
3 | import java.util.ArrayList; | ||
4 | import java.util.Collections; | ||
5 | import java.util.Iterator; | ||
6 | import java.util.List; | ||
7 | |||
8 | /** | ||
9 | * 分页对象, 存放单页数据 | ||
10 | */ | ||
11 | public class Page<T> { | ||
12 | private static final long serialVersionUID = 867755909294344406L; | ||
13 | |||
14 | private final List<T> content = new ArrayList<T>(); | ||
15 | private final Pageable pageable; | ||
16 | private final long total; | ||
17 | |||
18 | public Page(List<T> content, Pageable pageable, long total) { | ||
19 | |||
20 | if (null == content) { | ||
21 | throw new IllegalArgumentException("Content must not be null!"); | ||
22 | } | ||
23 | |||
24 | this.content.addAll(content); | ||
25 | this.total = total; | ||
26 | this.pageable = pageable; | ||
27 | } | ||
28 | |||
29 | public Page(List<T> content) { | ||
30 | this(content, null, null == content ? 0 : content.size()); | ||
31 | } | ||
32 | |||
33 | /** | ||
34 | * 请求页面 | ||
35 | * | ||
36 | * @return | ||
37 | */ | ||
38 | public int getNumber() { | ||
39 | return pageable == null ? 0 : pageable.getPageNumber(); | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * page size | ||
44 | * | ||
45 | * @return | ||
46 | */ | ||
47 | public int getSize() { | ||
48 | return pageable == null ? 0 : pageable.getPageSize(); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * 总页数 | ||
53 | * | ||
54 | * @return | ||
55 | */ | ||
56 | public int getTotalPages() { | ||
57 | return getSize() == 0 ? 1 : (int) Math.ceil((double) total / (double) getSize()); | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * 当前页记录条数 | ||
62 | * | ||
63 | * @return | ||
64 | */ | ||
65 | public int getNumberOfElements() { | ||
66 | return content.size(); | ||
67 | } | ||
68 | |||
69 | /** | ||
70 | * 总记录条数 | ||
71 | * | ||
72 | * @return | ||
73 | */ | ||
74 | public long getTotalElements() { | ||
75 | return total; | ||
76 | } | ||
77 | |||
78 | /** | ||
79 | * 是否有上一页 | ||
80 | * | ||
81 | * @return | ||
82 | */ | ||
83 | public boolean hasPreviousPage() { | ||
84 | return getNumber() > 0; | ||
85 | } | ||
86 | |||
87 | /** | ||
88 | * 是否首页 | ||
89 | * | ||
90 | * @return | ||
91 | */ | ||
92 | public boolean isFirstPage() { | ||
93 | return !hasPreviousPage(); | ||
94 | } | ||
95 | |||
96 | /** | ||
97 | * 是否有下一页 | ||
98 | * | ||
99 | * @return | ||
100 | */ | ||
101 | public boolean hasNextPage() { | ||
102 | return getNumber() + 1 < getTotalPages(); | ||
103 | } | ||
104 | |||
105 | /** | ||
106 | * 是否末页 | ||
107 | * | ||
108 | * @return | ||
109 | */ | ||
110 | public boolean isLastPage() { | ||
111 | return !hasNextPage(); | ||
112 | } | ||
113 | |||
114 | /** | ||
115 | * 下一页请求对象 | ||
116 | * | ||
117 | * @return | ||
118 | */ | ||
119 | public Pageable nextPageable() { | ||
120 | return hasNextPage() ? pageable.next() : null; | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * 上一页请求对象 | ||
125 | * | ||
126 | * @return | ||
127 | */ | ||
128 | public Pageable previousPageable() { | ||
129 | |||
130 | if (hasPreviousPage()) { | ||
131 | return pageable.previousOrFirst(); | ||
132 | } | ||
133 | |||
134 | return null; | ||
135 | } | ||
136 | |||
137 | /** | ||
138 | * 迭代器 | ||
139 | * | ||
140 | * @return | ||
141 | */ | ||
142 | public Iterator<T> iterator() { | ||
143 | return content.iterator(); | ||
144 | } | ||
145 | |||
146 | /** | ||
147 | * 当前页元素列表 | ||
148 | * | ||
149 | * @return | ||
150 | */ | ||
151 | public List<T> getContent() { | ||
152 | return Collections.unmodifiableList(content); | ||
153 | } | ||
154 | |||
155 | /** | ||
156 | * 当前页是否有元素 | ||
157 | * | ||
158 | * @return | ||
159 | */ | ||
160 | public boolean hasContent() { | ||
161 | return !content.isEmpty(); | ||
162 | } | ||
163 | |||
164 | |||
165 | /* | ||
166 | * (non-Javadoc) | ||
167 | * @see java.lang.Object#toString() | ||
168 | */ | ||
169 | @Override | ||
170 | public String toString() { | ||
171 | |||
172 | String contentType = "UNKNOWN"; | ||
173 | |||
174 | if (content.size() > 0) { | ||
175 | contentType = content.get(0).getClass().getName(); | ||
176 | } | ||
177 | |||
178 | return String.format("Page %s of %d containing %s instances", getNumber(), getTotalPages(), contentType); | ||
179 | } | ||
180 | |||
181 | } |
1 | package com.example.utils.mybatis.pageable; | ||
2 | |||
3 | /** | ||
4 | * 分页请求对象 | ||
5 | */ | ||
6 | public class Pageable { | ||
7 | private static final long serialVersionUID = 7280485938848398236L; | ||
8 | |||
9 | private final int page; | ||
10 | private final int size; | ||
11 | |||
12 | /** | ||
13 | * 是否查询总记录数 | ||
14 | */ | ||
15 | private final boolean countable; | ||
16 | |||
17 | /** | ||
18 | * @param page the page no you want to request, start from 0 | ||
19 | * @param size page size | ||
20 | */ | ||
21 | public Pageable(int page, int size) { | ||
22 | |||
23 | this(page, size, true); | ||
24 | } | ||
25 | |||
26 | /** | ||
27 | * @param page the page no you want to request, start from 0 | ||
28 | * @param size page size | ||
29 | * @param countable whether count total numbers | ||
30 | */ | ||
31 | public Pageable(int page, int size, boolean countable) { | ||
32 | |||
33 | if (page < 0) { | ||
34 | throw new IllegalArgumentException("Page index must not be less than zero!"); | ||
35 | } | ||
36 | |||
37 | if (size < 0) { | ||
38 | throw new IllegalArgumentException("Page size must not be less than zero!"); | ||
39 | } | ||
40 | |||
41 | this.page = page; | ||
42 | this.size = size; | ||
43 | |||
44 | this.countable = countable; | ||
45 | } | ||
46 | |||
47 | public boolean getCountable() { | ||
48 | return countable; | ||
49 | } | ||
50 | |||
51 | public int getPageSize() { | ||
52 | |||
53 | return size; | ||
54 | } | ||
55 | |||
56 | public int getPageNumber() { | ||
57 | return page; | ||
58 | } | ||
59 | |||
60 | public int getOffset() { | ||
61 | return page * size - size; | ||
62 | } | ||
63 | |||
64 | public boolean hasPrevious() { | ||
65 | return page > 0; | ||
66 | } | ||
67 | |||
68 | public Pageable next() { | ||
69 | return new Pageable(page + 1, size); | ||
70 | } | ||
71 | |||
72 | public Pageable previousOrFirst() { | ||
73 | return hasPrevious() ? new Pageable(page - 1, size) : this; | ||
74 | } | ||
75 | |||
76 | public Pageable first() { | ||
77 | return new Pageable(0, size); | ||
78 | } | ||
79 | |||
80 | /* | ||
81 | * (non-Javadoc) | ||
82 | * @see java.lang.Object#toString() | ||
83 | */ | ||
84 | @Override | ||
85 | public String toString() { | ||
86 | return String.format("Page request [number: %d, size %d, sort: %s]", page, size); | ||
87 | } | ||
88 | } |
1 | |||
2 | |||
3 | #data source | ||
4 | spring.datasource.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf8 | ||
5 | spring.datasource.username=root | ||
6 | spring.datasource.password= | ||
7 | spring.datasource.driver-class-name=com.mysql.jdbc.Driver | ||
8 | spring.datasource.max-idle=10 | ||
9 | spring.datasource.max-wait=10000 | ||
10 | spring.datasource.min-idle=5 | ||
11 | spring.datasource.initial-size=5 | ||
12 | spring.datasource.validation-query=SELECT 1 | ||
13 | spring.datasource.test-on-borrow=false | ||
14 | spring.datasource.test-while-idle=true | ||
15 | spring.datasource.time-between-eviction-runs-millis=18800 | ||
16 | spring.datasource.jdbc-interceptors=ConnectionState;SlowQueryReport(threshold=0) | ||
17 | |||
18 | #mybatis | ||
19 | mybatis.mapperLocations=classpath*:mappers/*.xml | ||
20 | mybatis.configLocation=classpath:/mybatis-config.xml | ||
21 | |||
22 | #port | ||
23 | server.port=9092 | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
kmr_dp_HDP/src/main/resources/logback.xml
0 → 100644
1 | <!-- Logback configuration. See http://logback.qos.ch/manual/index.html --> | ||
2 | <configuration scan="true" scanPeriod="10 seconds"> | ||
3 | |||
4 | <!-- Simple file output --> | ||
5 | <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
6 | <!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder --> | ||
7 | <encoder> | ||
8 | <pattern> | ||
9 | [ %-5level] [%date{yyyy-MM-dd HH:mm:ss}] %logger{96} [%line] - %msg%n | ||
10 | </pattern> | ||
11 | <charset>UTF-8</charset> <!-- 此处设置字符集 --> | ||
12 | </encoder> | ||
13 | |||
14 | <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | ||
15 | <!-- rollover daily 配置日志所生成的目录以及生成文件名的规则 --> | ||
16 | <fileNamePattern>logs/catalina-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | ||
17 | <timeBasedFileNamingAndTriggeringPolicy | ||
18 | class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | ||
19 | <!-- or whenever the file size reaches 64 MB --> | ||
20 | <maxFileSize>64 MB</maxFileSize> | ||
21 | </timeBasedFileNamingAndTriggeringPolicy> | ||
22 | </rollingPolicy> | ||
23 | |||
24 | |||
25 | <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
26 | <level>DEBUG</level> | ||
27 | </filter> | ||
28 | <!-- Safely log to the same file from multiple JVMs. Degrades performance! --> | ||
29 | <prudent>true</prudent> | ||
30 | </appender> | ||
31 | |||
32 | |||
33 | <!-- Console output --> | ||
34 | <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
35 | <!-- encoder defaults to ch.qos.logback.classic.encoder.PatternLayoutEncoder --> | ||
36 | <encoder> | ||
37 | <pattern> | ||
38 | [ %-5level] [%date{yyyy-MM-dd HH:mm:ss}] %logger{96} [%line] - %msg%n | ||
39 | </pattern> | ||
40 | <charset>UTF-8</charset> <!-- 此处设置字符集 --> | ||
41 | </encoder> | ||
42 | <!-- Only log level WARN and above --> | ||
43 | <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
44 | <level>INFO</level> | ||
45 | </filter> | ||
46 | </appender> | ||
47 | |||
48 | |||
49 | <!-- Enable FILE and STDOUT appenders for all log messages. | ||
50 | By default, only log at level INFO and above. --> | ||
51 | <root level="INFO"> | ||
52 | <appender-ref ref="FILE" /> | ||
53 | <appender-ref ref="STDOUT" /> | ||
54 | </root> | ||
55 | |||
56 | <!-- For loggers in the these namespaces, log at all levels. --> | ||
57 | <logger name="pedestal" level="ALL" /> | ||
58 | <logger name="hammock-cafe" level="ALL" /> | ||
59 | <logger name="user" level="ALL" /> | ||
60 | </configuration> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | <mapper namespace="com.example.mapper.ConfigInfoMapper"> | ||
4 | |||
5 | <select id="get" resultType="com.example.models.ConfigInfo"> | ||
6 | select * from t_kmr_config_info limit 1; | ||
7 | </select> | ||
8 | |||
9 | </mapper> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | <mapper namespace="com.example.mapper.ImgInfoMapper"> | ||
4 | |||
5 | <select id="getNewByOpenid" resultType="com.example.models.ImgInfo"> | ||
6 | select * from t_kmr_img_info where openid = #{openid} and status = 1 order by id desc limit 1; | ||
7 | </select> | ||
8 | |||
9 | <insert id="create"> | ||
10 | insert into `t_kmr_img_info` ( | ||
11 | `openid`, | ||
12 | `nickname`, | ||
13 | `headimgurl`, | ||
14 | `img_url`, | ||
15 | blessing_words, | ||
16 | sharing_describe, | ||
17 | gtmc_uid, | ||
18 | gtmc_name, | ||
19 | gtmc_department, | ||
20 | `create_at`, | ||
21 | `update_at`, | ||
22 | `status` | ||
23 | ) | ||
24 | values( | ||
25 | #{openid}, | ||
26 | #{nickname}, | ||
27 | #{headimgurl}, | ||
28 | #{imgUrl}, | ||
29 | #{blessingWords}, | ||
30 | #{sharingDescribe}, | ||
31 | #{gtmcUid}, | ||
32 | #{gtmcName}, | ||
33 | #{gtmcDepartment}, | ||
34 | #{createAt}, | ||
35 | #{updateAt}, | ||
36 | #{status} | ||
37 | ); | ||
38 | </insert> | ||
39 | |||
40 | </mapper> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | <?xml version="1.0" encoding="UTF-8" ?> | ||
2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | <mapper namespace="com.example.mapper.ScoreLogInfoMapper"> | ||
4 | |||
5 | <insert id="create"> | ||
6 | insert into `t_kmr_score_log_info` ( | ||
7 | `openid`, | ||
8 | `nickname`, | ||
9 | `headimgurl`, | ||
10 | gtmc_uid, | ||
11 | gtmc_name, | ||
12 | gtmc_department, | ||
13 | `score`, | ||
14 | `create_at`, | ||
15 | `status` | ||
16 | ) | ||
17 | values( | ||
18 | #{openid}, | ||
19 | #{nickname}, | ||
20 | #{headimgurl}, | ||
21 | #{gtmcUid}, | ||
22 | #{gtmcName}, | ||
23 | #{gtmcDepartment}, | ||
24 | #{score}, | ||
25 | #{createAt}, | ||
26 | #{status} | ||
27 | ); | ||
28 | </insert> | ||
29 | |||
30 | <select id="getRankingList" resultType="map"> | ||
31 | select(@i:= @i+ 1) r, | ||
32 | a.* | ||
33 | from( | ||
34 | select openid, min(score) score, nickname, headimgurl | ||
35 | from t_kmr_score_log_info | ||
36 | where status= 1 | ||
37 | GROUP BY openid) a, | ||
38 | ( | ||
39 | select @i:= 0) t2 | ||
40 | order by a.score | ||
41 | limit #{limit}; | ||
42 | </select> | ||
43 | |||
44 | <select id="getMyRanking" resultType="map"> | ||
45 | select b.* | ||
46 | from( | ||
47 | select(@i:= @i+ 1) r, a.* | ||
48 | from( | ||
49 | select openid, min(score) score, nickname, headimgurl | ||
50 | from t_kmr_score_log_info | ||
51 | where status= 1 | ||
52 | GROUP BY openid) a,( | ||
53 | select @i:= 0) t2 | ||
54 | order by a.score) b | ||
55 | where b.openid= #{openid} | ||
56 | </select> | ||
57 | |||
58 | <select id="countByDay" resultType="long"> | ||
59 | select count(*) c | ||
60 | from `t_kmr_score_log_info` | ||
61 | where create_at BETWEEN #{startDate} and #{endDate} | ||
62 | and openid= #{openid}; | ||
63 | </select> | ||
64 | |||
65 | <select id="countSum" resultType="long"> | ||
66 | select count(*) c | ||
67 | from `t_kmr_score_log_info` | ||
68 | where openid= #{openid}; | ||
69 | </select> | ||
70 | |||
71 | |||
72 | |||
73 | </mapper> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"> | ||
3 | <configuration> | ||
4 | |||
5 | <settings> | ||
6 | <!--该配置影响的所有映射器中配置的二级缓存的全局开关。--> | ||
7 | <setting name="cacheEnabled" value="false"/> | ||
8 | <!--延迟加载的全局开关。当开启时,所有关联对象都会延迟加载。特定关联关系中可通过设置fetchType属性来覆盖该项的开关状态。--> | ||
9 | <setting name="lazyLoadingEnabled" value="true"/> | ||
10 | <!--是否允许单一语句返回多结果集(需要兼容驱动)。--> | ||
11 | <setting name="multipleResultSetsEnabled" value="true"/> | ||
12 | <!--使用列标签代替列名。不同的驱动在这方面会有不同的表现,具体可参考相关驱动文档或通过测试这两种不同的模式来观察所用驱动的结果。--> | ||
13 | <setting name="useColumnLabel" value="true"/> | ||
14 | <!--允许 JDBC 支持自动生成主键,需要驱动兼容。如果设置为 true 则这个设置强制使用自动生成主键,尽管一些驱动不能兼容但仍可正常工作(比如 Derby)。--> | ||
15 | <setting name="useGeneratedKeys" value="false"/> | ||
16 | <!--指定 MyBatis 是否以及如何自动映射指定的列到字段或属性。NONE 表示取消自动映射;PARTIAL 只会自动映射没有定义嵌套结果集映射的结果集。FULL 会自动映射任意复杂的结果集(包括嵌套和其他情况)。--> | ||
17 | <setting name="autoMappingBehavior" value="PARTIAL"/> | ||
18 | <!--配置默认的执行器。SIMPLE 就是普通的执行器;REUSE 执行器会重用预处理语句(prepared statements);BATCH 执行器将重用语句并执行批量更新。--> | ||
19 | <setting name="defaultExecutorType" value="SIMPLE"/> | ||
20 | <!--设置超时时间,它决定驱动等待数据库响应的秒数。--> | ||
21 | <setting name="defaultStatementTimeout" value="25"/> | ||
22 | <!--允许在嵌套语句中使用行分界(RowBounds)。--> | ||
23 | <setting name="safeRowBoundsEnabled" value="false"/> | ||
24 | <!--是否开启自动驼峰命名规则(camel case)映射,即从经典数据库列名 A_COLUMN 到经典 Java 属性名 aColumn 的类似映射。--> | ||
25 | <setting name="mapUnderscoreToCamelCase" value="true"/> | ||
26 | <!--MyBatis 利用本地缓存机制(Local Cache)防止循环引用(circular references)和加速重复嵌套查询。默认值为 SESSION,这种情况下会缓存一个会话中执行的所有查询。若设置值为 STATEMENT,本地会话仅用在语句执行上,对相同 SqlSession 的不同调用将不会共享数据。--> | ||
27 | <setting name="localCacheScope" value="SESSION"/> | ||
28 | <!--当没有为参数提供特定的 JDBC 类型时,为空值指定 JDBC 类型。某些驱动需要指定列的 JDBC 类型,多数情况直接用一般类型即可,比如 NULL、VARCHAR 或 OTHER。--> | ||
29 | <setting name="jdbcTypeForNull" value="OTHER"/> | ||
30 | <!--指定哪个对象的方法触发一次延迟加载。--> | ||
31 | <setting name="lazyLoadTriggerMethods" value="equals,clone,hashCode,toString"/> | ||
32 | </settings> | ||
33 | <plugins> | ||
34 | <!-- 分页 --> | ||
35 | <plugin interceptor="com.example.utils.pageable.MybatisPageableInterceptor"> | ||
36 | <property name="dialectClass" value="com.example.utils.pageable.MySQLDialect"/> | ||
37 | </plugin> | ||
38 | <!-- / 分页 --> | ||
39 | </plugins> | ||
40 | </configuration> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
kmr_dp_HDP/src/main/resources/urlrewrite.xml
0 → 100644
1 | package com.example; | ||
2 | |||
3 | import org.junit.Test; | ||
4 | import org.junit.runner.RunWith; | ||
5 | import org.springframework.test.context.web.WebAppConfiguration; | ||
6 | import org.springframework.boot.test.SpringApplicationConfiguration; | ||
7 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
8 | |||
9 | @RunWith(SpringJUnit4ClassRunner.class) | ||
10 | @SpringApplicationConfiguration(classes = DemoApplication.class) | ||
11 | @WebAppConfiguration | ||
12 | public class DemoApplicationTests { | ||
13 | |||
14 | @Test | ||
15 | public void contextLoads() { | ||
16 | } | ||
17 | |||
18 | } |
-
Please register or sign in to post a comment