张涛 1 gadu atpakaļ
revīzija
c75f784830

+ 33
- 0
.gitignore Parādīt failu

@@ -0,0 +1,33 @@
1
+HELP.md
2
+target/
3
+!.mvn/wrapper/maven-wrapper.jar
4
+!**/src/main/**/target/
5
+!**/src/test/**/target/
6
+
7
+### STS ###
8
+.apt_generated
9
+.classpath
10
+.factorypath
11
+.project
12
+.settings
13
+.springBeans
14
+.sts4-cache
15
+
16
+### IntelliJ IDEA ###
17
+.idea
18
+*.iws
19
+*.iml
20
+*.ipr
21
+
22
+### NetBeans ###
23
+/nbproject/private/
24
+/nbbuild/
25
+/dist/
26
+/nbdist/
27
+/.nb-gradle/
28
+build/
29
+!**/src/main/**/build/
30
+!**/src/test/**/build/
31
+
32
+### VS Code ###
33
+.vscode/

+ 316
- 0
mvnw Parādīt failu

@@ -0,0 +1,316 @@
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
+#    https://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
+# Maven 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 /usr/local/etc/mavenrc ] ; then
40
+    . /usr/local/etc/mavenrc
41
+  fi
42
+
43
+  if [ -f /etc/mavenrc ] ; then
44
+    . /etc/mavenrc
45
+  fi
46
+
47
+  if [ -f "$HOME/.mavenrc" ] ; then
48
+    . "$HOME/.mavenrc"
49
+  fi
50
+
51
+fi
52
+
53
+# OS specific support.  $var _must_ be set to either true or false.
54
+cygwin=false;
55
+darwin=false;
56
+mingw=false
57
+case "`uname`" in
58
+  CYGWIN*) cygwin=true ;;
59
+  MINGW*) mingw=true;;
60
+  Darwin*) darwin=true
61
+    # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
62
+    # See https://developer.apple.com/library/mac/qa/qa1170/_index.html
63
+    if [ -z "$JAVA_HOME" ]; then
64
+      if [ -x "/usr/libexec/java_home" ]; then
65
+        export JAVA_HOME="`/usr/libexec/java_home`"
66
+      else
67
+        export JAVA_HOME="/Library/Java/Home"
68
+      fi
69
+    fi
70
+    ;;
71
+esac
72
+
73
+if [ -z "$JAVA_HOME" ] ; then
74
+  if [ -r /etc/gentoo-release ] ; then
75
+    JAVA_HOME=`java-config --jre-home`
76
+  fi
77
+fi
78
+
79
+if [ -z "$M2_HOME" ] ; then
80
+  ## resolve links - $0 may be a link to maven's home
81
+  PRG="$0"
82
+
83
+  # need this for relative symlinks
84
+  while [ -h "$PRG" ] ; do
85
+    ls=`ls -ld "$PRG"`
86
+    link=`expr "$ls" : '.*-> \(.*\)$'`
87
+    if expr "$link" : '/.*' > /dev/null; then
88
+      PRG="$link"
89
+    else
90
+      PRG="`dirname "$PRG"`/$link"
91
+    fi
92
+  done
93
+
94
+  saveddir=`pwd`
95
+
96
+  M2_HOME=`dirname "$PRG"`/..
97
+
98
+  # make it fully qualified
99
+  M2_HOME=`cd "$M2_HOME" && pwd`
100
+
101
+  cd "$saveddir"
102
+  # echo Using m2 at $M2_HOME
103
+fi
104
+
105
+# For Cygwin, ensure paths are in UNIX format before anything is touched
106
+if $cygwin ; then
107
+  [ -n "$M2_HOME" ] &&
108
+    M2_HOME=`cygpath --unix "$M2_HOME"`
109
+  [ -n "$JAVA_HOME" ] &&
110
+    JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
111
+  [ -n "$CLASSPATH" ] &&
112
+    CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
113
+fi
114
+
115
+# For Mingw, ensure paths are in UNIX format before anything is touched
116
+if $mingw ; then
117
+  [ -n "$M2_HOME" ] &&
118
+    M2_HOME="`(cd "$M2_HOME"; pwd)`"
119
+  [ -n "$JAVA_HOME" ] &&
120
+    JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
121
+fi
122
+
123
+if [ -z "$JAVA_HOME" ]; then
124
+  javaExecutable="`which javac`"
125
+  if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
126
+    # readlink(1) is not available as standard on Solaris 10.
127
+    readLink=`which readlink`
128
+    if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
129
+      if $darwin ; then
130
+        javaHome="`dirname \"$javaExecutable\"`"
131
+        javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
132
+      else
133
+        javaExecutable="`readlink -f \"$javaExecutable\"`"
134
+      fi
135
+      javaHome="`dirname \"$javaExecutable\"`"
136
+      javaHome=`expr "$javaHome" : '\(.*\)/bin'`
137
+      JAVA_HOME="$javaHome"
138
+      export JAVA_HOME
139
+    fi
140
+  fi
141
+fi
142
+
143
+if [ -z "$JAVACMD" ] ; then
144
+  if [ -n "$JAVA_HOME"  ] ; then
145
+    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
146
+      # IBM's JDK on AIX uses strange locations for the executables
147
+      JAVACMD="$JAVA_HOME/jre/sh/java"
148
+    else
149
+      JAVACMD="$JAVA_HOME/bin/java"
150
+    fi
151
+  else
152
+    JAVACMD="`\\unset -f command; \\command -v java`"
153
+  fi
154
+fi
155
+
156
+if [ ! -x "$JAVACMD" ] ; then
157
+  echo "Error: JAVA_HOME is not defined correctly." >&2
158
+  echo "  We cannot execute $JAVACMD" >&2
159
+  exit 1
160
+fi
161
+
162
+if [ -z "$JAVA_HOME" ] ; then
163
+  echo "Warning: JAVA_HOME environment variable is not set."
164
+fi
165
+
166
+CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
167
+
168
+# traverses directory structure from process work directory to filesystem root
169
+# first directory with .mvn subdirectory is considered project base directory
170
+find_maven_basedir() {
171
+
172
+  if [ -z "$1" ]
173
+  then
174
+    echo "Path not specified to find_maven_basedir"
175
+    return 1
176
+  fi
177
+
178
+  basedir="$1"
179
+  wdir="$1"
180
+  while [ "$wdir" != '/' ] ; do
181
+    if [ -d "$wdir"/.mvn ] ; then
182
+      basedir=$wdir
183
+      break
184
+    fi
185
+    # workaround for JBEAP-8937 (on Solaris 10/Sparc)
186
+    if [ -d "${wdir}" ]; then
187
+      wdir=`cd "$wdir/.."; pwd`
188
+    fi
189
+    # end of workaround
190
+  done
191
+  echo "${basedir}"
192
+}
193
+
194
+# concatenates all lines of a file
195
+concat_lines() {
196
+  if [ -f "$1" ]; then
197
+    echo "$(tr -s '\n' ' ' < "$1")"
198
+  fi
199
+}
200
+
201
+BASE_DIR=`find_maven_basedir "$(pwd)"`
202
+if [ -z "$BASE_DIR" ]; then
203
+  exit 1;
204
+fi
205
+
206
+##########################################################################################
207
+# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
208
+# This allows using the maven wrapper in projects that prohibit checking in binary data.
209
+##########################################################################################
210
+if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
211
+    if [ "$MVNW_VERBOSE" = true ]; then
212
+      echo "Found .mvn/wrapper/maven-wrapper.jar"
213
+    fi
214
+else
215
+    if [ "$MVNW_VERBOSE" = true ]; then
216
+      echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
217
+    fi
218
+    if [ -n "$MVNW_REPOURL" ]; then
219
+      jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
220
+    else
221
+      jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
222
+    fi
223
+    while IFS="=" read key value; do
224
+      case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
225
+      esac
226
+    done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
227
+    if [ "$MVNW_VERBOSE" = true ]; then
228
+      echo "Downloading from: $jarUrl"
229
+    fi
230
+    wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
231
+    if $cygwin; then
232
+      wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
233
+    fi
234
+
235
+    if command -v wget > /dev/null; then
236
+        if [ "$MVNW_VERBOSE" = true ]; then
237
+          echo "Found wget ... using wget"
238
+        fi
239
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
240
+            wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
241
+        else
242
+            wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
243
+        fi
244
+    elif command -v curl > /dev/null; then
245
+        if [ "$MVNW_VERBOSE" = true ]; then
246
+          echo "Found curl ... using curl"
247
+        fi
248
+        if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
249
+            curl -o "$wrapperJarPath" "$jarUrl" -f
250
+        else
251
+            curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
252
+        fi
253
+
254
+    else
255
+        if [ "$MVNW_VERBOSE" = true ]; then
256
+          echo "Falling back to using Java to download"
257
+        fi
258
+        javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
259
+        # For Cygwin, switch paths to Windows format before running javac
260
+        if $cygwin; then
261
+          javaClass=`cygpath --path --windows "$javaClass"`
262
+        fi
263
+        if [ -e "$javaClass" ]; then
264
+            if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
265
+                if [ "$MVNW_VERBOSE" = true ]; then
266
+                  echo " - Compiling MavenWrapperDownloader.java ..."
267
+                fi
268
+                # Compiling the Java class
269
+                ("$JAVA_HOME/bin/javac" "$javaClass")
270
+            fi
271
+            if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
272
+                # Running the downloader
273
+                if [ "$MVNW_VERBOSE" = true ]; then
274
+                  echo " - Running MavenWrapperDownloader.java ..."
275
+                fi
276
+                ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
277
+            fi
278
+        fi
279
+    fi
280
+fi
281
+##########################################################################################
282
+# End of extension
283
+##########################################################################################
284
+
285
+export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
286
+if [ "$MVNW_VERBOSE" = true ]; then
287
+  echo $MAVEN_PROJECTBASEDIR
288
+fi
289
+MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
290
+
291
+# For Cygwin, switch paths to Windows format before running java
292
+if $cygwin; then
293
+  [ -n "$M2_HOME" ] &&
294
+    M2_HOME=`cygpath --path --windows "$M2_HOME"`
295
+  [ -n "$JAVA_HOME" ] &&
296
+    JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
297
+  [ -n "$CLASSPATH" ] &&
298
+    CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
299
+  [ -n "$MAVEN_PROJECTBASEDIR" ] &&
300
+    MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
301
+fi
302
+
303
+# Provide a "standardized" way to retrieve the CLI args that will
304
+# work with both Windows and non-Windows executions.
305
+MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
306
+export MAVEN_CMD_LINE_ARGS
307
+
308
+WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
309
+
310
+exec "$JAVACMD" \
311
+  $MAVEN_OPTS \
312
+  $MAVEN_DEBUG_OPTS \
313
+  -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
314
+  "-Dmaven.home=${M2_HOME}" \
315
+  "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
316
+  ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

+ 188
- 0
mvnw.cmd Parādīt failu

@@ -0,0 +1,188 @@
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    https://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 Maven 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 keystroke 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 set title of command window
39
+title %0
40
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41
+@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
42
+
43
+@REM set %HOME% to equivalent of $HOME
44
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45
+
46
+@REM Execute a user defined script before this one
47
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
49
+if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
50
+if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
51
+:skipRcPre
52
+
53
+@setlocal
54
+
55
+set ERROR_CODE=0
56
+
57
+@REM To isolate internal variables from possible post scripts, we use another setlocal
58
+@setlocal
59
+
60
+@REM ==== START VALIDATION ====
61
+if not "%JAVA_HOME%" == "" goto OkJHome
62
+
63
+echo.
64
+echo Error: JAVA_HOME not found in your environment. >&2
65
+echo Please set the JAVA_HOME variable in your environment to match the >&2
66
+echo location of your Java installation. >&2
67
+echo.
68
+goto error
69
+
70
+:OkJHome
71
+if exist "%JAVA_HOME%\bin\java.exe" goto init
72
+
73
+echo.
74
+echo Error: JAVA_HOME is set to an invalid directory. >&2
75
+echo JAVA_HOME = "%JAVA_HOME%" >&2
76
+echo Please set the JAVA_HOME variable in your environment to match the >&2
77
+echo location of your Java installation. >&2
78
+echo.
79
+goto error
80
+
81
+@REM ==== END VALIDATION ====
82
+
83
+:init
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
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122
+
123
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
124
+
125
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126
+    IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127
+)
128
+
129
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131
+if exist %WRAPPER_JAR% (
132
+    if "%MVNW_VERBOSE%" == "true" (
133
+        echo Found %WRAPPER_JAR%
134
+    )
135
+) else (
136
+    if not "%MVNW_REPOURL%" == "" (
137
+        SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
138
+    )
139
+    if "%MVNW_VERBOSE%" == "true" (
140
+        echo Couldn't find %WRAPPER_JAR%, downloading it ...
141
+        echo Downloading from: %DOWNLOAD_URL%
142
+    )
143
+
144
+    powershell -Command "&{"^
145
+		"$webclient = new-object System.Net.WebClient;"^
146
+		"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147
+		"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148
+		"}"^
149
+		"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150
+		"}"
151
+    if "%MVNW_VERBOSE%" == "true" (
152
+        echo Finished downloading %WRAPPER_JAR%
153
+    )
154
+)
155
+@REM End of extension
156
+
157
+@REM Provide a "standardized" way to retrieve the CLI args that will
158
+@REM work with both Windows and non-Windows executions.
159
+set MAVEN_CMD_LINE_ARGS=%*
160
+
161
+%MAVEN_JAVA_EXE% ^
162
+  %JVM_CONFIG_MAVEN_PROPS% ^
163
+  %MAVEN_OPTS% ^
164
+  %MAVEN_DEBUG_OPTS% ^
165
+  -classpath %WRAPPER_JAR% ^
166
+  "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
167
+  %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
168
+if ERRORLEVEL 1 goto error
169
+goto end
170
+
171
+:error
172
+set ERROR_CODE=1
173
+
174
+:end
175
+@endlocal & set ERROR_CODE=%ERROR_CODE%
176
+
177
+if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
178
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
179
+if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
180
+if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
181
+:skipRcPost
182
+
183
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
184
+if "%MAVEN_BATCH_PAUSE%"=="on" pause
185
+
186
+if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
187
+
188
+cmd /C exit /B %ERROR_CODE%

+ 165
- 0
pom.xml Parādīt failu

@@ -0,0 +1,165 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+    <modelVersion>4.0.0</modelVersion>
5
+    <parent>
6
+        <groupId>org.springframework.boot</groupId>
7
+        <artifactId>spring-boot-starter-parent</artifactId>
8
+        <version>2.7.17</version>
9
+        <relativePath/> <!-- lookup parent from repository -->
10
+    </parent>
11
+    <groupId>com.lyg</groupId>
12
+    <artifactId>tools</artifactId>
13
+    <version>0.0.1-SNAPSHOT</version>
14
+    <name>tools</name>
15
+    <description>Demo project for Spring Boot</description>
16
+    <properties>
17
+        <java.version>1.8</java.version>
18
+        <swagger.version>3.0.0</swagger.version>
19
+        <wx.version>4.4.0</wx.version>
20
+        <lombok.version>1.18.22</lombok.version>
21
+        <mybatis-plus.version>3.5.1</mybatis-plus.version>
22
+        <dynamic-datasource.version>3.5.1</dynamic-datasource.version>
23
+    </properties>
24
+    <dependencies>
25
+        <!--web依赖-->
26
+<!--        <dependency>-->
27
+<!--            <groupId>org.springframework.boot</groupId>-->
28
+<!--            <artifactId>spring-boot-starter-validation</artifactId>-->
29
+<!--        </dependency>-->
30
+        <dependency>
31
+            <groupId>org.springframework.boot</groupId>
32
+            <artifactId>spring-boot-starter-web</artifactId>
33
+        </dependency>
34
+        <!--swagger start-->
35
+        <dependency>
36
+            <groupId>io.springfox</groupId>
37
+            <artifactId>springfox-boot-starter</artifactId>
38
+            <version>3.0.0</version>
39
+        </dependency>
40
+        <!--swagger end-->
41
+        <!-- 企业号/企业微信 -->
42
+        <dependency>
43
+            <groupId>com.github.binarywang</groupId>
44
+            <artifactId>weixin-java-cp</artifactId>
45
+            <version>${wx.version}</version>
46
+        </dependency>
47
+
48
+        <dependency>
49
+            <groupId>org.projectlombok</groupId>
50
+            <artifactId>lombok</artifactId>
51
+            <version>${lombok.version}</version>
52
+        </dependency>
53
+
54
+        <!--mybatis-plus-->
55
+        <dependency>
56
+            <groupId>com.baomidou</groupId>
57
+            <artifactId>mybatis-plus-boot-starter</artifactId>
58
+            <version>${mybatis-plus.version}</version>
59
+        </dependency>
60
+        <!-- oracle -->
61
+        <dependency>
62
+            <groupId>com.oracle.database.jdbc</groupId>
63
+            <artifactId>ojdbc8</artifactId>
64
+            <scope>runtime</scope>
65
+        </dependency>
66
+
67
+        <!-- mysql -->
68
+        <dependency>
69
+            <groupId>com.mysql</groupId>
70
+            <artifactId>mysql-connector-j</artifactId>
71
+            <scope>runtime</scope>
72
+        </dependency>
73
+
74
+        <!-- 多数据源 -->
75
+        <dependency>
76
+            <groupId>com.baomidou</groupId>
77
+            <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
78
+            <version>${dynamic-datasource.version}</version>
79
+        </dependency>
80
+    </dependencies>
81
+
82
+    <build>
83
+        <plugins>
84
+
85
+            <plugin>
86
+                <groupId>org.springframework.boot</groupId>
87
+                <artifactId>spring-boot-maven-plugin</artifactId>
88
+                <configuration>
89
+                    <layout>ZIP</layout>
90
+                    <includeSystemScope>true</includeSystemScope>
91
+                    <mainClass>com.lyg.tools.ToolsApplication</mainClass>
92
+                    <includes>
93
+                        <include>
94
+                            <groupId>com.lyg</groupId>
95
+                            <artifactId>tools</artifactId>
96
+                        </include>
97
+                    </includes>
98
+                    <excludes>
99
+                        <exclude>
100
+                            <groupId>org.projectlombok</groupId>
101
+                            <artifactId>lombok</artifactId>
102
+                        </exclude>
103
+                    </excludes>
104
+                </configuration>
105
+                <executions>
106
+                    <execution>
107
+                        <goals>
108
+                            <goal>repackage</goal>
109
+                        </goals>
110
+                    </execution>
111
+                </executions>
112
+            </plugin>
113
+
114
+
115
+            <!-- 第三方依赖包单独打包 -->
116
+            <plugin>
117
+                <groupId>org.apache.maven.plugins</groupId>
118
+                <artifactId>maven-dependency-plugin</artifactId>
119
+                <executions>
120
+                    <execution>
121
+                        <id>copy-dependencies</id>
122
+                        <phase>package</phase>
123
+                        <goals>
124
+                            <goal>copy-dependencies</goal>
125
+                        </goals>
126
+                        <configuration>
127
+                            <outputDirectory>target/lib</outputDirectory>
128
+                            <stripVersion>false</stripVersion>
129
+                            <!-- 不包含哪些jar包 -->
130
+                            <excludeGroupIds>
131
+                                <!-- 只排除业务模块相关的jar包,多个用英文逗号分割-->
132
+                                com.lyg
133
+                            </excludeGroupIds>
134
+                        </configuration>
135
+                    </execution>
136
+                </executions>
137
+            </plugin>
138
+
139
+            <!-- 把配置文件单独拷贝出来 -->
140
+            <plugin>
141
+                <groupId>org.apache.maven.plugins</groupId>
142
+                <artifactId>maven-resources-plugin</artifactId>
143
+                <executions>
144
+                    <execution>
145
+                        <id>copy-resources</id>
146
+                        <phase>package</phase>
147
+                        <goals>
148
+                            <goal>copy-resources</goal>
149
+                        </goals>
150
+                        <configuration>
151
+                            <outputDirectory>target/config</outputDirectory>
152
+                            <resources>
153
+                                <resource>
154
+                                    <directory>./src/main/resources</directory>
155
+                                </resource>
156
+                            </resources>
157
+                        </configuration>
158
+                    </execution>
159
+                </executions>
160
+            </plugin>
161
+        </plugins>
162
+
163
+    </build>
164
+
165
+</project>

+ 20
- 0
src/main/java/com/lyg/tools/GlobalExceptionHandler.java Parādīt failu

@@ -0,0 +1,20 @@
1
+package com.lyg.tools;
2
+
3
+import com.lyg.tools.common.ResponseBean;
4
+import lombok.extern.slf4j.Slf4j;
5
+import org.springframework.web.bind.annotation.ExceptionHandler;
6
+import org.springframework.web.bind.annotation.ResponseBody;
7
+import org.springframework.web.bind.annotation.RestControllerAdvice;
8
+
9
+@Slf4j
10
+@RestControllerAdvice
11
+public class GlobalExceptionHandler {
12
+
13
+    @ResponseBody
14
+    @ExceptionHandler(Exception.class)
15
+    public ResponseBean handleException(Exception e) {
16
+        e.printStackTrace();
17
+        return ResponseBean.error(e.getMessage());
18
+    }
19
+
20
+}

+ 27
- 0
src/main/java/com/lyg/tools/ToolsApplication.java Parādīt failu

@@ -0,0 +1,27 @@
1
+package com.lyg.tools;
2
+
3
+import org.mybatis.spring.annotation.MapperScan;
4
+import org.springframework.boot.SpringApplication;
5
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
6
+import org.springframework.boot.autoconfigure.SpringBootApplication;
7
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
8
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
9
+import org.springframework.scheduling.annotation.EnableAsync;
10
+import org.springframework.scheduling.annotation.EnableScheduling;
11
+import org.springframework.transaction.annotation.EnableTransactionManagement;
12
+
13
+
14
+@EnableAsync
15
+@EnableScheduling
16
+@EnableTransactionManagement
17
+@EnableConfigurationProperties
18
+@MapperScan({"com.lyg.**.mapper"})
19
+@SpringBootApplication(scanBasePackages = {"com.lyg"})
20
+//@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
21
+
22
+public class ToolsApplication {
23
+    public static void main(String[] args) {
24
+        SpringApplication.run(ToolsApplication.class, args);
25
+    }
26
+
27
+}

+ 85
- 0
src/main/java/com/lyg/tools/common/FileUtil.java Parādīt failu

@@ -0,0 +1,85 @@
1
+package com.lyg.tools.common;
2
+
3
+import org.springframework.beans.factory.annotation.Value;
4
+import org.springframework.stereotype.Component;
5
+import org.springframework.web.multipart.MultipartFile;
6
+
7
+import java.io.File;
8
+import java.io.FileOutputStream;
9
+import java.io.IOException;
10
+import java.io.OutputStream;
11
+import java.time.LocalDateTime;
12
+import java.time.format.DateTimeFormatter;
13
+
14
+@Component
15
+public class FileUtil {
16
+
17
+    @Value("${yz.upload.path}")
18
+    String uploadPath;
19
+
20
+    private void checkUploadPath(String path) throws Exception {
21
+        File tmp = new File(path);
22
+        if (!tmp.exists()) {
23
+            boolean isOk = tmp.mkdirs();
24
+            if (!isOk) {
25
+                throw new Exception("保存路径创建失败");
26
+            }
27
+        }
28
+    }
29
+
30
+    private String getMonth() {
31
+        LocalDateTime now = LocalDateTime.now();
32
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
33
+        return now.format(formatter);
34
+    }
35
+
36
+    private String[] getFilePaths(String appid, String fileName) throws Exception {
37
+        String monthStr = getMonth();
38
+        String newFileName = String.format("%d-%s", System.currentTimeMillis(), fileName);
39
+        checkUploadPath(String.format("%s/%s/%s", uploadPath, appid, monthStr));
40
+
41
+        // 绝对路径
42
+        String filePath = String.format("%s/%s/%s/%s", uploadPath, appid, monthStr, newFileName);
43
+        // 相对路径 - 不包含 uploadPath
44
+        String url = String.format("%s/%s/%s", appid, monthStr, newFileName);
45
+
46
+        return new String[] { filePath, url };
47
+    }
48
+
49
+    // 上传目录
50
+    public String saveFile(MultipartFile multipartFile, String appid) throws Exception {
51
+        //获取文件名
52
+        String fileName = multipartFile.getOriginalFilename();
53
+
54
+        String[] filePaths = getFilePaths(appid, fileName);
55
+        File upFile = new File(filePaths[0]);
56
+        multipartFile.transferTo(upFile);
57
+
58
+        // 返回值 去掉根目录
59
+        return filePaths[1];
60
+    }
61
+
62
+    // 保存文件
63
+    public String saveFile(File file, String fileName, String appid) throws Exception {
64
+
65
+        String[] filePaths = getFilePaths(appid, fileName);
66
+        if (!file.renameTo(new File(filePaths[0]))) {
67
+            throw new Exception("保存文件失败");
68
+        }
69
+
70
+        return filePaths[1];
71
+    }
72
+
73
+
74
+    // 保存文件
75
+    public String saveFile(byte[] bytes, String fileName, String appid) throws Exception {
76
+
77
+        String[] filePaths = getFilePaths(appid, fileName);
78
+        File file = new File(filePaths[0]);
79
+        OutputStream outputStream = new FileOutputStream(file);
80
+        outputStream.write(bytes);
81
+        outputStream.close();
82
+
83
+        return filePaths[1];
84
+    }
85
+}

+ 85
- 0
src/main/java/com/lyg/tools/common/ResponseBean.java Parādīt failu

@@ -0,0 +1,85 @@
1
+package com.lyg.tools.common;
2
+
3
+import java.io.Serializable;
4
+
5
+/**
6
+ * 接口统一状态返回BEAN.
7
+ */
8
+public class ResponseBean<T> implements Serializable {
9
+
10
+    private static final long serialVersionUID = 3593827217136880822L;
11
+
12
+    public static final int CODE_SUCCESS = 200;
13
+    public static final int ERROR_AUTH_FAIL = 401;
14
+    public static final int ERROR_UNAUTHORIZED = 401;
15
+    public static final int ERROR_MISSING_PARAMS = 501;
16
+    public static final int ERROR_ILLEGAL_PARAMS = 503;
17
+    public static final int ERROR_UNAVAILABLE = 500;
18
+
19
+    private int code;
20
+    private String message;
21
+    private T data;
22
+
23
+    public ResponseBean() {
24
+        code = ResponseBean.CODE_SUCCESS;
25
+    }
26
+
27
+    public static <T> ResponseBean success(T data, String ...msgs) {
28
+        ResponseBean responseBean = new ResponseBean();
29
+        responseBean.code = ResponseBean.CODE_SUCCESS;
30
+        responseBean.data = data;
31
+
32
+        if (null != msgs && msgs.length > 0) {
33
+            responseBean.message = msgs[0];
34
+        }
35
+
36
+        return responseBean;
37
+    }
38
+
39
+
40
+    public static <T> ResponseBean error(String msg) {
41
+        ResponseBean responseBean = new ResponseBean();
42
+        responseBean.code = ERROR_UNAVAILABLE;
43
+        responseBean.message = msg;
44
+
45
+        return responseBean;
46
+    }
47
+
48
+    public static <T> ResponseBean error(String msg, int code, T ...datas) {
49
+        ResponseBean responseBean = new ResponseBean();
50
+        responseBean.code = code;
51
+        responseBean.message = msg;
52
+
53
+        if (null != datas && datas.length > 0) {
54
+            responseBean.data = datas[0];
55
+        }
56
+
57
+        return responseBean;
58
+    }
59
+
60
+    public int getCode() {
61
+        return code;
62
+    }
63
+    public void setCode(int code) {
64
+        this.code = code;
65
+    }
66
+
67
+    public String getMessage() {
68
+        return message;
69
+    }
70
+    public void setMessage(String message) {
71
+        this.message = message;
72
+    }
73
+
74
+    public T getData() {
75
+        return data;
76
+    }
77
+    public void setData(T data) {
78
+        this.data = data;
79
+    }
80
+    
81
+    @Override
82
+    public String toString() {
83
+        return  "{ code: "+code+", message: "+message+", data: <T> }";
84
+    }
85
+}

+ 229
- 0
src/main/java/com/lyg/tools/common/StringUtil.java Parādīt failu

@@ -0,0 +1,229 @@
1
+package com.lyg.tools.common;
2
+
3
+import java.io.File;
4
+import java.io.UnsupportedEncodingException;
5
+import java.net.URLDecoder;
6
+import java.net.URLEncoder;
7
+import java.util.*;
8
+import java.util.regex.Matcher;
9
+import java.util.regex.Pattern;
10
+
11
+public class StringUtil {
12
+    private static Pattern humpPattern = Pattern.compile("[A-Z]");
13
+
14
+    public static boolean isEmpty(String str) {
15
+        return null == str || "".equals(str.trim()) || "null".equals(str) || "undefined".equals(str);
16
+    }
17
+    public static boolean isNotEmpty(String str) {
18
+        return !isEmpty(str);
19
+    }
20
+
21
+    public static String trim(String src, String...st) {
22
+        if (null == src) return src;
23
+        if (null == st || st.length == 0) return src.trim();
24
+
25
+        String start = st[0];
26
+        if (!src.startsWith(start)) {
27
+            return src;
28
+        }
29
+
30
+        return src.substring(start.length());
31
+    }
32
+
33
+    public static String trimEnd(String src, String str) {
34
+        if (null == src || null == str) {
35
+            return src;
36
+        }
37
+
38
+        if (src.endsWith(str)) {
39
+            return src.substring(0, src.length() - str.length());
40
+        }
41
+
42
+        return src;
43
+    }
44
+
45
+    public static String ifNull(String src, String defaultVal) {
46
+        return isEmpty(src) ? defaultVal : src;
47
+    }
48
+
49
+    public static String random(int length) {
50
+        String str="abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
51
+        Random random = new Random();
52
+        StringBuffer sb = new StringBuffer();
53
+        for(int i=0;i<length;i++){
54
+            int number=random.nextInt(62);
55
+            sb.append(str.charAt(number));
56
+        }
57
+        return sb.toString();
58
+    }
59
+
60
+    public static String uuid() {
61
+        return UUID.randomUUID().toString().replaceAll("-", "");
62
+    }
63
+
64
+    public static String urlEncode(String str) {
65
+        if (isEmpty(str)) return str;
66
+
67
+        try {
68
+            return URLEncoder.encode(str, "UTF-8");
69
+        } catch (UnsupportedEncodingException e) {
70
+            e.printStackTrace();
71
+            return str;
72
+        }
73
+    }
74
+
75
+    public static String urlDecode(String str) {
76
+        if (isEmpty(str)) return str;
77
+
78
+        try {
79
+            return URLDecoder.decode(str, "UTF-8");
80
+        } catch (UnsupportedEncodingException e) {
81
+            e.printStackTrace();
82
+            return str;
83
+        }
84
+    }
85
+
86
+    public static String encodeURIComponent(String str) {
87
+        String result = urlEncode(str);
88
+
89
+        return result.replaceAll("\\+", "%20")
90
+                .replaceAll("\\%21", "!")
91
+                .replaceAll("\\%27", "'")
92
+                .replaceAll("\\%28", "(")
93
+                .replaceAll("\\%29", ")")
94
+                .replaceAll("\\%7E", "~");
95
+    }
96
+
97
+    public static String humpToLine(String str) {
98
+        if (null == str || "".equals(str)) return "";
99
+
100
+        Matcher matcher = humpPattern.matcher(str);
101
+        StringBuffer sb = new StringBuffer();
102
+        while (matcher.find()) {
103
+            matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
104
+        }
105
+        matcher.appendTail(sb);
106
+        return sb.toString();
107
+    }
108
+
109
+    public static String strToUnicode(String str) {
110
+        char[] chars = str.toCharArray();
111
+        String returnStr = "";
112
+        for (int i = 0; i < chars.length; i++) {
113
+            returnStr += "\\u" + Integer.toString(chars[i], 16);
114
+        }
115
+        return returnStr;
116
+    }
117
+
118
+    public static String repeat(String src, int len) {
119
+        if (null == src) {
120
+            return null;
121
+        }
122
+
123
+        if (len <= 0) {
124
+            return src;
125
+        }
126
+
127
+        String res = "";
128
+        for (int i = 0; i < len; i ++) {
129
+            res += src;
130
+        }
131
+
132
+        return res;
133
+    }
134
+
135
+    public static String lpad(String src, String padStr, int len) {
136
+        if (null == src) {
137
+            return null;
138
+        }
139
+
140
+        if (len <= 0 || src.length() >= len) {
141
+            return src;
142
+        }
143
+
144
+        if (null == padStr) {
145
+            padStr = "";
146
+        }
147
+
148
+        int padLen = len - src.length();
149
+        String prefix = repeat(padStr, padLen);
150
+        prefix = prefix.substring(0, padLen);
151
+        return prefix + src;
152
+    }
153
+
154
+    /**
155
+     * 解析 QueryString
156
+     * @param queryStr
157
+     * @return
158
+     */
159
+    public static Map<String, String> parseQueryString(String queryStr) {
160
+        if (isEmpty(queryStr)) {
161
+            return null;
162
+        }
163
+        Map<String, String> result = new HashMap<String, String>();
164
+
165
+        String[] fields = queryStr.split("&");
166
+        for (String field : fields) {
167
+            String[] pairs = field.split("=");
168
+            if (2 != pairs.length) {
169
+                continue;
170
+            }
171
+
172
+            try {
173
+                String key = URLDecoder.decode(pairs[0].trim(), "UTF-8");
174
+                String val = URLDecoder.decode(pairs[1].trim(), "UTF-8");
175
+
176
+                result.put(key, val);
177
+            } catch (UnsupportedEncodingException e) {
178
+                e.printStackTrace();
179
+            }
180
+        }
181
+
182
+        return result;
183
+    }
184
+
185
+    /**
186
+     * Map 转 QueryString
187
+     * @param params
188
+     * @return
189
+     */
190
+    public static String buildQueryString(Map<String, Object> params) {
191
+        if (null == params) {
192
+            return null;
193
+        }
194
+
195
+        List<String> lst = new ArrayList<>();
196
+        for (Map.Entry<String, Object> entry : params.entrySet()) {
197
+            String key = urlEncode(entry.getKey());
198
+            Object o = entry.getValue();
199
+            if (null == o) {
200
+                continue;
201
+            }
202
+            String val = o.toString();
203
+            if (isEmpty(val)) {
204
+                continue;
205
+            }
206
+            String queryStr = key + "=" + urlEncode(val);
207
+            lst.add(queryStr);
208
+        }
209
+        return String.join("&", lst);
210
+    }
211
+
212
+    public static byte[] base64ToBytes(String base64Str) {
213
+        if (isEmpty(base64Str)) return null;
214
+
215
+        // H5端图片的 base64 格式类似 data:image/png;base64,...
216
+        // 需要去掉前面的部分
217
+        int pos = base64Str.indexOf("base64,");
218
+        String str = null;
219
+        if (pos > -1) {
220
+            pos += "base64,".length();
221
+            str = base64Str.substring(pos);
222
+        } else {
223
+            str = base64Str;
224
+        }
225
+
226
+        byte[] bytes = Base64.getDecoder().decode(str);
227
+        return bytes;
228
+    }
229
+}

+ 41
- 0
src/main/java/com/lyg/tools/common/SwaggerConfig.java Parādīt failu

@@ -0,0 +1,41 @@
1
+package com.lyg.tools.common;
2
+
3
+
4
+import io.swagger.annotations.Api;
5
+import org.springframework.context.annotation.Bean;
6
+import org.springframework.context.annotation.Configuration;
7
+import org.springframework.core.env.Environment;
8
+import org.springframework.util.StringUtils;
9
+import org.springframework.web.servlet.config.annotation.EnableWebMvc;
10
+import springfox.documentation.builders.ApiInfoBuilder;
11
+import springfox.documentation.builders.PathSelectors;
12
+import springfox.documentation.builders.RequestHandlerSelectors;
13
+import springfox.documentation.service.*;
14
+import springfox.documentation.spi.DocumentationType;
15
+import springfox.documentation.spi.service.contexts.SecurityContext;
16
+import springfox.documentation.spring.web.plugins.Docket;
17
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
18
+
19
+import java.util.*;
20
+
21
+@EnableWebMvc
22
+@EnableSwagger2
23
+@Configuration
24
+public class SwaggerConfig {
25
+    @Bean
26
+    public Docket docket() {
27
+        return new Docket(DocumentationType.SWAGGER_2)
28
+                .apiInfo(apiInfo())
29
+                .select()
30
+                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
31
+                .paths(PathSelectors.any())
32
+                .build();
33
+
34
+    }
35
+    private ApiInfo apiInfo() {
36
+        return new ApiInfoBuilder()
37
+                .description("upload服务")
38
+                .title("upload_server").build();
39
+    }
40
+
41
+}

+ 58
- 0
src/main/java/com/lyg/tools/config/cors/CorsFilter.java Parādīt failu

@@ -0,0 +1,58 @@
1
+package com.lyg.tools.config.cors;
2
+
3
+import lombok.Data;
4
+import org.springframework.beans.factory.annotation.Value;
5
+import org.springframework.boot.context.properties.ConfigurationProperties;
6
+import org.springframework.context.annotation.Configuration;
7
+import org.springframework.http.HttpMethod;
8
+import org.springframework.http.HttpStatus;
9
+
10
+import javax.servlet.*;
11
+import javax.servlet.annotation.WebFilter;
12
+import javax.servlet.http.HttpServletRequest;
13
+import javax.servlet.http.HttpServletResponse;
14
+import java.io.IOException;
15
+import java.util.List;
16
+
17
+@Data
18
+@WebFilter(filterName = "CorsFilter ")
19
+@Configuration
20
+@ConfigurationProperties(prefix = "cors")
21
+public class CorsFilter implements Filter {
22
+
23
+    Boolean enabled;
24
+    List<String> methods;
25
+    List<String> headers;
26
+
27
+    // 必须要带有 return
28
+    // 不然返回数据会变多
29
+    @Override
30
+    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
31
+        if (null == enabled || !enabled) {
32
+            chain.doFilter(req, res);
33
+            return;
34
+        }
35
+
36
+        HttpServletResponse response = (HttpServletResponse) res;
37
+        HttpServletRequest request = (HttpServletRequest) req;
38
+
39
+        String reqHeaders = request.getHeader("Access-Control-Request-Headers");
40
+        if (null == reqHeaders || "".equals(reqHeaders.trim())) {
41
+            reqHeaders = String.join(",", headers);
42
+        }
43
+
44
+        response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
45
+        response.setHeader("Access-Control-Allow-Methods", String.join(",", methods));
46
+        response.setHeader("Access-Control-Allow-Headers", reqHeaders);
47
+        response.setHeader("Access-Control-Allow-Credentials", "true");
48
+        response.setHeader("Access-Control-Max-Age", "3600");
49
+
50
+        // 如果是OPTIONS则结束请求
51
+        if (HttpMethod.OPTIONS.toString().equals(request.getMethod())) {
52
+            response.setStatus(HttpStatus.NO_CONTENT.value());
53
+        }
54
+
55
+        chain.doFilter(req, res);
56
+        return;
57
+    }
58
+}

+ 89
- 0
src/main/java/com/lyg/tools/controller/UploadController.java Parādīt failu

@@ -0,0 +1,89 @@
1
+package com.lyg.tools.controller;
2
+
3
+import com.lyg.tools.common.FileUtil;
4
+import com.lyg.tools.common.ResponseBean;
5
+import com.lyg.tools.common.StringUtil;
6
+import com.lyg.tools.hangxin.WxUtil;
7
+import io.swagger.annotations.Api;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.web.bind.annotation.*;
10
+import org.springframework.web.multipart.MultipartFile;
11
+
12
+import java.io.File;
13
+import java.util.HashMap;
14
+import java.util.Map;
15
+
16
+@Api(tags = "文件上传")
17
+@RestController
18
+@RequestMapping("/")
19
+public class UploadController {
20
+
21
+    @Autowired
22
+    WxUtil wxUtil;
23
+
24
+    @Autowired
25
+    FileUtil fileUtil;
26
+
27
+    /**
28
+     * 通用端上传文件
29
+     *
30
+     * @param appid 应用Id
31
+     * @return
32
+     * @throws Exception
33
+     */
34
+    @PostMapping("/upload/admin/{appid}")
35
+    public ResponseBean uploadAdmin(@RequestParam(value = "file") MultipartFile multipartFile,
36
+                               @PathVariable(value = "appid") String appid
37
+    ) throws Exception {
38
+
39
+        Map<String, Object> res = new HashMap<>();
40
+        String path = fileUtil.saveFile(multipartFile,  appid);
41
+        res.put("url", path);
42
+
43
+        return ResponseBean.success(res);
44
+    }
45
+
46
+    /**
47
+     * 通过 Base64 上传文件
48
+     *
49
+     * @param appid 应用Id
50
+     * @return
51
+     * @throws Exception
52
+     */
53
+    @PostMapping("/upload/base64/{appid}")
54
+    public ResponseBean uploadBase64(@PathVariable(value = "appid") String appid,
55
+                                 @RequestParam(value = "base64") String base64,
56
+                                 @RequestParam(value = "fileName", defaultValue = "unknown.jpg") String fileName
57
+    ) throws Exception {
58
+
59
+        Map<String, Object> res = new HashMap<>();
60
+        byte[] bytes = StringUtil.base64ToBytes(base64);
61
+
62
+        String path = fileUtil.saveFile(bytes, fileName, appid);
63
+        res.put("url", path);
64
+
65
+        return ResponseBean.success(res);
66
+    }
67
+
68
+    /**
69
+     * 企业微信上传文件
70
+     *
71
+     * @param appid 应用Id
72
+     * @return
73
+     * @throws Exception
74
+     */
75
+    @PostMapping("/upload/h5/{appid}")
76
+    public ResponseBean uploadH5(@PathVariable(value = "appid") String appid,
77
+                               @RequestParam(value = "mediaId") String mediaId,
78
+                               @RequestParam(value = "fileName", defaultValue = "unknown.jpg") String fileName
79
+    ) throws Exception {
80
+
81
+        Map<String, Object> res = new HashMap<>();
82
+        File file = wxUtil.downloadMedia(mediaId);
83
+        String path = fileUtil.saveFile(file, fileName, appid);
84
+        res.put("url", path);
85
+
86
+        return ResponseBean.success(res);
87
+    }
88
+
89
+}

+ 42
- 0
src/main/java/com/lyg/tools/controller/WxCpController.java Parādīt failu

@@ -0,0 +1,42 @@
1
+package com.lyg.tools.controller;
2
+
3
+import com.lyg.tools.common.FileUtil;
4
+import com.lyg.tools.common.ResponseBean;
5
+import com.lyg.tools.hangxin.WxUtil;
6
+//import io.swagger.annotations.Api;
7
+//import io.swagger.annotations.ApiOperation;
8
+import io.swagger.annotations.Api;
9
+import io.swagger.annotations.ApiOperation;
10
+import io.swagger.annotations.ApiParam;
11
+import me.chanjar.weixin.common.bean.WxJsapiSignature;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.beans.factory.annotation.Value;
14
+import org.springframework.web.bind.annotation.*;
15
+import org.springframework.web.multipart.MultipartFile;
16
+
17
+import java.io.File;
18
+import java.util.HashMap;
19
+import java.util.Map;
20
+
21
+
22
+@Api(tags = "企业微信")
23
+@RestController
24
+@RequestMapping("/")
25
+public class WxCpController {
26
+
27
+    @Autowired
28
+    WxUtil wxUtil;
29
+
30
+    @Autowired
31
+    FileUtil fileUtil;
32
+
33
+    @Value("${yz.env}")
34
+    String env;
35
+
36
+    @ApiOperation("获取 JS-SDK config")
37
+    @GetMapping("/h5/jsconfig")
38
+    public ResponseBean getJsConfig(@ApiParam("页面路径") @RequestParam("url") String url) throws Exception {
39
+        WxJsapiSignature jsconfig = wxUtil.jsconfig(url);
40
+        return ResponseBean.success(jsconfig);
41
+    }
42
+}

+ 52
- 0
src/main/java/com/lyg/tools/entity/MessageSmBox.java Parādīt failu

@@ -0,0 +1,52 @@
1
+package com.lyg.tools.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.baomidou.mybatisplus.annotation.TableName;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import lombok.experimental.Accessors;
11
+
12
+import java.io.Serializable;
13
+import java.time.LocalDateTime;
14
+
15
+/**
16
+* 消息表-mysql;
17
+* @author : http://www.chiner.pro
18
+* @date : 2023-2-7
19
+*/
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@ApiModel(value = "消息表-mysql",description = "")
24
+@TableName("Message_sm_box")
25
+public class MessageSmBox implements Serializable,Cloneable{
26
+   /** 消息id */
27
+   @ApiModelProperty(name = "消息id",notes = "")
28
+   @TableId(value = "id", type = IdType.AUTO)
29
+   private Integer id ;
30
+   /** 消息内容 */
31
+   @ApiModelProperty(name = "消息内容",notes = "")
32
+   private String message ;
33
+   /** 手机号 */
34
+   @ApiModelProperty(name = "手机号",notes = "")
35
+   private String phone ;
36
+   /** 应用id;用于记录是哪个应用使用的短信 */
37
+   @ApiModelProperty(name = "应用id",notes = "用于记录是哪个应用使用的短信")
38
+   private String appid ;
39
+   /** 渠道标识;1、联通短信 ;2、行信;4、移动;3、行信和联通 */
40
+   @ApiModelProperty(name = "渠道标识",notes = "1、联通短信 ;2、行信;4、移动;3、行信和联通")
41
+   private Integer chn ;
42
+   /** 员工EHR号 */
43
+   @ApiModelProperty(name = "员工EHR号",notes = "")
44
+   private String user ;
45
+   /** 创建时间 */
46
+   @ApiModelProperty(name = "创建时间",notes = "")
47
+   private LocalDateTime dataDate ;
48
+   /** 备注 */
49
+   @ApiModelProperty(name = "备注",notes = "")
50
+   private String remark ;
51
+
52
+}

+ 13
- 0
src/main/java/com/lyg/tools/hangxin/CpConfig.java Parādīt failu

@@ -0,0 +1,13 @@
1
+package com.lyg.tools.hangxin;
2
+
3
+
4
+import lombok.Data;
5
+import me.chanjar.weixin.cp.config.impl.WxCpDefaultConfigImpl;
6
+import org.springframework.boot.context.properties.ConfigurationProperties;
7
+import org.springframework.stereotype.Component;
8
+
9
+@Data
10
+@Component
11
+@ConfigurationProperties(prefix = "wx.cp")
12
+public class CpConfig extends WxCpDefaultConfigImpl {
13
+}

+ 37
- 0
src/main/java/com/lyg/tools/hangxin/WxUtil.java Parādīt failu

@@ -0,0 +1,37 @@
1
+package com.lyg.tools.hangxin;
2
+
3
+
4
+import me.chanjar.weixin.common.bean.WxJsapiSignature;
5
+import me.chanjar.weixin.common.error.WxErrorException;
6
+import me.chanjar.weixin.cp.api.impl.WxCpServiceImpl;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.stereotype.Component;
9
+
10
+import java.io.File;
11
+
12
+@Component
13
+public class WxUtil {
14
+
15
+    CpConfig cpConfig;
16
+    WxCpServiceImpl wxCpService = new WxCpServiceImpl();
17
+
18
+    @Autowired
19
+    public WxUtil(CpConfig cpConfig) {
20
+        this.cpConfig = cpConfig;
21
+
22
+        initCpService(cpConfig);
23
+    }
24
+
25
+    void initCpService(CpConfig cpConfig) {
26
+        wxCpService.setWxCpConfigStorage(cpConfig);
27
+    }
28
+
29
+    public File downloadMedia(String mediaId) throws WxErrorException {
30
+        return wxCpService.getMediaService().download(mediaId);
31
+    }
32
+
33
+    public WxJsapiSignature jsconfig(String url) throws WxErrorException {
34
+        WxJsapiSignature jsapiSignature = wxCpService.createJsapiSignature(url);
35
+        return jsapiSignature;
36
+    }
37
+}

+ 15
- 0
src/main/java/com/lyg/tools/mapper/MessageSmBoxMapper.java Parādīt failu

@@ -0,0 +1,15 @@
1
+package com.lyg.tools.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.lyg.tools.entity.MessageSmBox;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+* 消息表-mysql;(Message_sm_box)表数据库访问层
9
+* @author : http://njyunzhi.com
10
+* @date : 2023-2-7
11
+*/
12
+@Mapper
13
+public interface MessageSmBoxMapper extends BaseMapper<MessageSmBox>{
14
+
15
+}

+ 20
- 0
src/main/java/com/lyg/tools/service/IBaseService.java Parādīt failu

@@ -0,0 +1,20 @@
1
+package com.lyg.tools.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+
5
+import java.io.Serializable;
6
+
7
+public interface IBaseService<T> extends IService<T> {
8
+    /**
9
+     * 逻辑删除
10
+     * @param id
11
+     * @return
12
+     */
13
+    boolean removeLogicById(Serializable id);
14
+
15
+    long countBy(String column, Object value, boolean notDelete);
16
+
17
+    T getByButNot(String column, Object value, String col, Object val, boolean notDelete);
18
+
19
+    T getExistBy(String column, Object value, boolean normal, boolean notDelete);
20
+}

+ 16
- 0
src/main/java/com/lyg/tools/service/MessageSmBoxService.java Parādīt failu

@@ -0,0 +1,16 @@
1
+package com.lyg.tools.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.lyg.tools.entity.MessageSmBox;
5
+
6
+/**
7
+ * 消息表-mysql;(Message_sm_box)表服务接口
8
+ *
9
+ * @author : http://njyunzhi.com
10
+ * @date : 2023-2-7
11
+ */
12
+
13
+public interface MessageSmBoxService extends IService<MessageSmBox> {
14
+
15
+//    void warning(List<SysUser> list, TaTask taTask);
16
+}

+ 54
- 0
src/main/java/com/lyg/tools/service/impl/BaseServiceImpl.java Parādīt failu

@@ -0,0 +1,54 @@
1
+package com.lyg.tools.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import com.baomidou.mybatisplus.core.metadata.TableInfo;
7
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
+import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
9
+import com.lyg.tools.service.IBaseService;
10
+
11
+import java.io.Serializable;
12
+
13
+public class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements IBaseService<T> {
14
+    @Override
15
+    public boolean removeLogicById(Serializable id) {
16
+
17
+        TableInfo tableInfo = SqlHelper.table(currentModelClass());
18
+        UpdateWrapper<T> updateWrapper = new UpdateWrapper<>();
19
+        updateWrapper.set("status", -1)
20
+                .eq(tableInfo.getKeyColumn(), id);
21
+
22
+        return update(updateWrapper);
23
+    }
24
+
25
+    @Override
26
+    public long countBy(String column, Object value, boolean notDelete) {
27
+        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
28
+        queryWrapper.eq(column, value);
29
+        queryWrapper.gt(notDelete, "status", -1);
30
+
31
+        return count(queryWrapper);
32
+    }
33
+
34
+    @Override
35
+    public T getByButNot(String column, Object value, String col, Object val, boolean notDelete) {
36
+        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
37
+        queryWrapper.eq(column, value);
38
+        queryWrapper.ne(col, val);
39
+        queryWrapper.gt(notDelete, "status", -1);
40
+        queryWrapper.last("AND ROWNUM = 1");
41
+
42
+        return getOne(queryWrapper);
43
+    }
44
+
45
+    @Override
46
+    public T getExistBy(String column, Object value, boolean normal, boolean notDelete) {
47
+        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
48
+        queryWrapper.eq(column, value);
49
+        queryWrapper.eq(normal, "status", 1);
50
+        queryWrapper.gt(notDelete, "status", -1);
51
+        queryWrapper.last("AND ROWNUM = 1");
52
+        return getOne(queryWrapper);
53
+    }
54
+}

+ 54
- 0
src/main/java/com/lyg/tools/service/impl/MessageSmBoxServiceImpl.java Parādīt failu

@@ -0,0 +1,54 @@
1
+package com.lyg.tools.service.impl;
2
+
3
+import com.baomidou.dynamic.datasource.annotation.DS;
4
+import com.lyg.tools.entity.MessageSmBox;
5
+import com.lyg.tools.mapper.MessageSmBoxMapper;
6
+import com.lyg.tools.service.MessageSmBoxService;
7
+import org.springframework.beans.factory.annotation.Value;
8
+import org.springframework.stereotype.Service;
9
+
10
+/**
11
+ * 消息表-mysql;(Message_sm_box)表服务实现类
12
+ *
13
+ * @author : http://www.chiner.pro
14
+ * @date : 2023-2-7
15
+ */
16
+@Service
17
+@DS("mysql")
18
+public class MessageSmBoxServiceImpl extends BaseServiceImpl<MessageSmBoxMapper, MessageSmBox> implements MessageSmBoxService {
19
+
20
+    public static final int CHN_HX = 2;
21
+    @Value("${yz.task.message.appid}")
22
+    String appid;
23
+    @Value("${yz.task.message.template}")
24
+    String template;
25
+
26
+//    @Async
27
+//    @Override
28
+//    public void warning(List<SysUser> list, TaTask taTask) {
29
+//        if (null == list || list.size() == 0) {
30
+//            return;
31
+//        }
32
+//
33
+//        LocalDateTime now = LocalDateTime.now();
34
+//
35
+//        List<MessageSmBox> messageList = new ArrayList<>();
36
+//        for (SysUser user : list) {
37
+//            MessageSmBox message = new MessageSmBox();
38
+//
39
+//            String name = user.getName();
40
+//            String taskTitle = taTask.getTitle();
41
+//            String msg = template.replace("{name}", name).replace("{taskTitle}", taskTitle);
42
+//            message.setMessage(msg);
43
+//            message.setPhone(user.getPhone());
44
+//            message.setAppid(appid);
45
+//            message.setChn(CHN_HX);
46
+//            message.setUser(user.getHxId());
47
+//            message.setDataDate(now);
48
+//            message.setRemark(null);
49
+//            messageList.add(message);
50
+//        }
51
+//
52
+//        saveBatch(messageList);
53
+//    }
54
+}

+ 112
- 0
src/resources/application.yml Parādīt failu

@@ -0,0 +1,112 @@
1
+server:
2
+  port: 7200
3
+  servlet:
4
+    context-path: /api
5
+
6
+spring:
7
+  mvc:
8
+    pathmatch:
9
+      matching-strategy: ANT_PATH_MATCHER
10
+  servlet:
11
+    multipart:
12
+      max-file-size: 1024MB
13
+      max-request-size: 1024MB
14
+  datasource:
15
+    dynamic:
16
+      primary: oracle
17
+      datasource:
18
+        oracle:
19
+          url: jdbc:oracle:thin:@192.168.89.147:1521:orcl
20
+          username: schedule_task
21
+          password: schedule_task@ABCD123
22
+          driver-class-name: oracle.jdbc.OracleDriver
23
+        mysql:
24
+          url: jdbc:mysql://192.168.89.10:3306/civilizedcity?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&autoReconnect=true
25
+          username: civilizedcity
26
+          password: civilizedcity@ABCD1234
27
+          driver-class-name: com.mysql.cj.jdbc.Driver
28
+
29
+      hikari:
30
+        max-pool-size: 3  # 最大连接池数
31
+
32
+
33
+  # 配置 Redis 连接
34
+  redis:
35
+    # Redis数据库索引
36
+    database: 3
37
+    # Redis服务器地址
38
+    host: 192.168.89.10
39
+    # Redis服务器连接端口
40
+    port: 6379
41
+    # Redis服务器连接密码(默认为空)
42
+    password: yansen@123
43
+    # 连接超时时间
44
+    timeout: 10s
45
+    lettuce:
46
+      pool:
47
+        # 连接池最大连接数
48
+        max-active: 200
49
+        # 连接池最大阻塞等待时间(使用负值表示没有限制)
50
+        max-wait: -1ms
51
+        # 连接池中的最大空闲连接
52
+        max-idle: 10
53
+        # 连接池中的最小空闲连接
54
+        min-idle: 0
55
+
56
+
57
+###
58
+mybatis-plus:
59
+  configuration:
60
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
61
+    call-setters-on-nulls: true
62
+  mapper-locations: classpath*:mapper/**/*.xml,classpath*:mysql-mapper/**/*.xml
63
+  type-aliases-package: com.lyg.*.entity
64
+
65
+logging:
66
+  level:
67
+    root: info
68
+    org.springframework.web: debug # 更具体的日志级别设置
69
+
70
+wx:
71
+  cp:
72
+    baseApiUrl: http://baidu.com
73
+    # 微信企业号的appid
74
+    corpId: 123
75
+    # 微信企业号的app corpSecret
76
+    corpSecret: 123
77
+    # 微信企业号应用ID
78
+    agentId: 123
79
+    # 微信企业号应用的token
80
+    token: 123
81
+    # 微信企业号应用的EncodingAESKey
82
+    aesKey: 123
83
+
84
+
85
+
86
+yz:
87
+  env: dev
88
+  upload:
89
+    path: E:\work\public-upload
90
+  task:
91
+    cron:
92
+      # 班前, 每天 9:45
93
+      before-work: "0 45 9 * * ?"
94
+      # 班中
95
+      in-working: "0 45 14 * * ?"
96
+      # 班后
97
+      after-work: "0 45 16 * * ?"
98
+      # 其余, 每天 9:45
99
+      common: "0 45 9 * * ?"
100
+    message:
101
+      appid: task
102
+      template: "{name} 您好, 请及时完成您的 {taskTitle} 任务。"
103
+cors:
104
+  enabled: true
105
+  methods:
106
+    - "OPTIONS"
107
+    - "GET"
108
+    - "POST"
109
+    - "PUT"
110
+    - "DELETE"
111
+  headers:
112
+    - "*"

+ 6
- 0
src/resources/mapper/MessageSmBoxMapper.xml Parādīt failu

@@ -0,0 +1,6 @@
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
+
4
+<mapper namespace="com.lyg.tools.mapper.MessageSmBoxMapper">
5
+
6
+</mapper>