张延森 3 år sedan
incheckning
34f33a8616
39 ändrade filer med 2454 tillägg och 0 borttagningar
  1. 38
    0
      .gitignore
  2. Binär
      .mvn/wrapper/maven-wrapper.jar
  3. 2
    0
      .mvn/wrapper/maven-wrapper.properties
  4. 316
    0
      mvnw
  5. 188
    0
      mvnw.cmd
  6. 140
    0
      pom.xml
  7. 15
    0
      src/main/java/com/yunzhi/roundabout/Application.java
  8. 30
    0
      src/main/java/com/yunzhi/roundabout/common/BaseController.java
  9. 25
    0
      src/main/java/com/yunzhi/roundabout/common/CurrentContext.java
  10. 37
    0
      src/main/java/com/yunzhi/roundabout/common/DateUtils.java
  11. 27
    0
      src/main/java/com/yunzhi/roundabout/common/ExcelUtils.java
  12. 87
    0
      src/main/java/com/yunzhi/roundabout/common/HttpUtils.java
  13. 107
    0
      src/main/java/com/yunzhi/roundabout/common/JWTUtils.java
  14. 11
    0
      src/main/java/com/yunzhi/roundabout/common/MathUtils.java
  15. 80
    0
      src/main/java/com/yunzhi/roundabout/common/ResponseBean.java
  16. 203
    0
      src/main/java/com/yunzhi/roundabout/common/StringUtils.java
  17. 53
    0
      src/main/java/com/yunzhi/roundabout/common/excelConverter/LocalDateTimeConverter.java
  18. 53
    0
      src/main/java/com/yunzhi/roundabout/common/excelConverter/LocalDayConverter.java
  19. 55
    0
      src/main/java/com/yunzhi/roundabout/common/excelConverter/MoneyConverter.java
  20. 36
    0
      src/main/java/com/yunzhi/roundabout/common/excelConverter/SecondConverter.java
  21. 35
    0
      src/main/java/com/yunzhi/roundabout/config/BaseConfig.java
  22. 32
    0
      src/main/java/com/yunzhi/roundabout/config/InterceptorConfig.java
  23. 21
    0
      src/main/java/com/yunzhi/roundabout/config/LoggingFilterConfig.java
  24. 14
    0
      src/main/java/com/yunzhi/roundabout/config/MybatisPlusConfig.java
  25. 20
    0
      src/main/java/com/yunzhi/roundabout/config/SMSConfig.java
  26. 24
    0
      src/main/java/com/yunzhi/roundabout/config/SwagggerConfig.java
  27. 13
    0
      src/main/java/com/yunzhi/roundabout/controller/CommController.java
  28. 141
    0
      src/main/java/com/yunzhi/roundabout/controller/LoginController.java
  29. 261
    0
      src/main/java/com/yunzhi/roundabout/controller/TaPersonController.java
  30. 88
    0
      src/main/java/com/yunzhi/roundabout/entity/TaPerson.java
  31. 19
    0
      src/main/java/com/yunzhi/roundabout/exception/GlobalExceptionHandler.java
  32. 48
    0
      src/main/java/com/yunzhi/roundabout/interceptor/PermissionInterceptor.java
  33. 26
    0
      src/main/java/com/yunzhi/roundabout/mapper/TaPersonMapper.java
  34. 29
    0
      src/main/java/com/yunzhi/roundabout/service/ITaPersonService.java
  35. 73
    0
      src/main/java/com/yunzhi/roundabout/service/impl/TaPersonServiceImpl.java
  36. 16
    0
      src/main/java/com/yunzhi/roundabout/vo/LoginParam.java
  37. 20
    0
      src/main/java/com/yunzhi/roundabout/vo/MPLogin.java
  38. 47
    0
      src/main/resources/application.yml
  39. 24
    0
      src/main/resources/mapper/TaPersonMapper.xml

+ 38
- 0
.gitignore Visa fil

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

Binär
.mvn/wrapper/maven-wrapper.jar Visa fil


+ 2
- 0
.mvn/wrapper/maven-wrapper.properties Visa fil

1
+distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.3/apache-maven-3.8.3-bin.zip
2
+wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar

+ 316
- 0
mvnw Visa fil

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 Visa fil

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%

+ 140
- 0
pom.xml Visa fil

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 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.5.8</version>
9
+		<relativePath/> <!-- lookup parent from repository -->
10
+	</parent>
11
+	<groupId>com.yunzhi</groupId>
12
+	<artifactId>roundabout</artifactId>
13
+	<version>0.0.3</version>
14
+	<name>roundabout</name>
15
+	<description>华侨城-摩天轮</description>
16
+	<properties>
17
+		<java.version>1.8</java.version>
18
+	</properties>
19
+	<dependencies>
20
+		<dependency>
21
+			<groupId>org.springframework.boot</groupId>
22
+			<artifactId>spring-boot-starter-web</artifactId>
23
+		</dependency>
24
+
25
+		<dependency>
26
+			<groupId>mysql</groupId>
27
+			<artifactId>mysql-connector-java</artifactId>
28
+			<scope>runtime</scope>
29
+		</dependency>
30
+		<dependency>
31
+			<groupId>org.projectlombok</groupId>
32
+			<artifactId>lombok</artifactId>
33
+			<optional>true</optional>
34
+		</dependency>
35
+		<dependency>
36
+			<groupId>org.springframework.boot</groupId>
37
+			<artifactId>spring-boot-starter-test</artifactId>
38
+			<scope>test</scope>
39
+		</dependency>
40
+		<!--mybatis-plus start-->
41
+		<dependency>
42
+			<groupId>com.baomidou</groupId>
43
+			<artifactId>mybatis-plus-boot-starter</artifactId>
44
+			<version>3.1.1</version>
45
+		</dependency>
46
+		<!--mybatis-plus end-->
47
+
48
+		<!--fastjson start-->
49
+		<dependency>
50
+			<groupId>com.alibaba</groupId>
51
+			<artifactId>fastjson</artifactId>
52
+			<version>1.2.56</version>
53
+		</dependency>
54
+		<!--fastjson end-->
55
+
56
+		<!--excel start-->
57
+		<dependency>
58
+			<groupId>com.alibaba</groupId>
59
+			<artifactId>easyexcel</artifactId>
60
+			<version>2.0.4</version>
61
+		</dependency>
62
+		<!--excel end-->
63
+<!--		<dependency>-->
64
+<!--			<groupId>com.github.binarywang</groupId>-->
65
+<!--			<artifactId>weixin-java-mp</artifactId>-->
66
+<!--			<version>3.8.0</version>-->
67
+<!--		</dependency>-->
68
+		<!--jwt start-->
69
+		<dependency>
70
+			<groupId>io.jsonwebtoken</groupId>
71
+			<artifactId>jjwt-api</artifactId>
72
+			<version>0.11.2</version>
73
+		</dependency>
74
+		<dependency>
75
+			<groupId>io.jsonwebtoken</groupId>
76
+			<artifactId>jjwt-impl</artifactId>
77
+			<version>0.11.2</version>
78
+			<scope>runtime</scope>
79
+		</dependency>
80
+		<dependency>
81
+			<groupId>io.jsonwebtoken</groupId>
82
+			<artifactId>jjwt-jackson</artifactId> <!-- or jjwt-gson if Gson is preferred -->
83
+			<version>0.11.2</version>
84
+			<scope>runtime</scope>
85
+		</dependency>
86
+		<!--jwt end-->
87
+		<!--swagger start-->
88
+		<dependency>
89
+			<groupId>io.springfox</groupId>
90
+			<artifactId>springfox-boot-starter</artifactId>
91
+			<version>3.0.0</version>
92
+		</dependency>
93
+		<!--swagger end-->
94
+	</dependencies>
95
+
96
+	<build>
97
+		<plugins>
98
+			<plugin>
99
+				<groupId>org.springframework.boot</groupId>
100
+				<artifactId>spring-boot-maven-plugin</artifactId>
101
+				<configuration>
102
+					<excludes>
103
+						<exclude>
104
+							<groupId>org.projectlombok</groupId>
105
+							<artifactId>lombok</artifactId>
106
+						</exclude>
107
+					</excludes>
108
+<!--					<mainClass>com.yunzhi.drawlots.DrawlotsApplication</mainClass>-->
109
+<!--					<layout>ZIP</layout>-->
110
+<!--					<includes>-->
111
+<!--						<include>-->
112
+<!--							<groupId>nothing</groupId>-->
113
+<!--							<artifactId>nothing</artifactId>-->
114
+<!--						</include>-->
115
+<!--					</includes>-->
116
+				</configuration>
117
+			</plugin>
118
+<!--			<plugin>-->
119
+<!--				<groupId>org.apache.maven.plugins</groupId>-->
120
+<!--				<artifactId>maven-dependency-plugin</artifactId>-->
121
+<!--				<executions>-->
122
+<!--					<execution>-->
123
+<!--						<goals>-->
124
+<!--							<goal>copy-dependencies</goal>-->
125
+<!--						</goals>-->
126
+<!--						<configuration>-->
127
+<!--							&lt;!&ndash; ${project.build.directory}是maven变量,内置的,表示target目录,如果不写,将在跟目录下创建/lib &ndash;&gt;-->
128
+<!--							<outputDirectory>${project.build.directory}/lib</outputDirectory>-->
129
+<!--							&lt;!&ndash; excludeTransitive:是否不包含间接依赖包,比如我们依赖A,但是A又依赖了B,我们是否也要把B打进去 默认不打&ndash;&gt;-->
130
+<!--							<excludeTransitive>false</excludeTransitive>-->
131
+<!--							&lt;!&ndash; 复制的jar文件去掉版本信息 true去掉 false 不去&ndash;&gt;-->
132
+<!--							<stripVersion>false</stripVersion>-->
133
+<!--						</configuration>-->
134
+<!--					</execution>-->
135
+<!--				</executions>-->
136
+<!--			</plugin>-->
137
+		</plugins>
138
+	</build>
139
+
140
+</project>

+ 15
- 0
src/main/java/com/yunzhi/roundabout/Application.java Visa fil

1
+package com.yunzhi.roundabout;
2
+
3
+import org.springframework.boot.SpringApplication;
4
+import org.springframework.boot.autoconfigure.SpringBootApplication;
5
+import org.springframework.transaction.annotation.EnableTransactionManagement;
6
+
7
+@EnableTransactionManagement
8
+@SpringBootApplication
9
+public class Application {
10
+
11
+	public static void main(String[] args) {
12
+		SpringApplication.run(Application.class, args);
13
+	}
14
+
15
+}

+ 30
- 0
src/main/java/com/yunzhi/roundabout/common/BaseController.java Visa fil

1
+package com.yunzhi.roundabout.common;
2
+
3
+import com.yunzhi.roundabout.entity.TaPerson;
4
+import com.yunzhi.roundabout.service.ITaPersonService;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.stereotype.Component;
7
+
8
+import javax.servlet.http.HttpServletRequest;
9
+import java.util.Map;
10
+
11
+@Component
12
+public class BaseController {
13
+    @Autowired
14
+    public ITaPersonService iTaPersonService;
15
+
16
+    public TaPerson currentPerson(HttpServletRequest request) throws Exception {
17
+        String token = JWTUtils.getToken(request);
18
+        if (StringUtils.isEmpty(token)) {
19
+            throw new Exception("请先登录系统或刷新重试");
20
+        }
21
+
22
+        Map<String, Object> result = JWTUtils.decode(token);
23
+        String personId = (String) result.get("userId");
24
+        if (StringUtils.isEmpty(personId)) {
25
+            throw new Exception("请先登录系统或刷新重试");
26
+        }
27
+
28
+        return iTaPersonService.getById(personId);
29
+    }
30
+}

+ 25
- 0
src/main/java/com/yunzhi/roundabout/common/CurrentContext.java Visa fil

1
+package com.yunzhi.roundabout.common;
2
+
3
+import java.util.Map;
4
+
5
+public class CurrentContext {
6
+
7
+    /**
8
+     * TokenParam 相关
9
+     */
10
+    private static final ThreadLocal<Map<String, Object>> tokenParamHolder = new ThreadLocal<>();
11
+
12
+    public static void setTokenParam(Map<String, Object> tokenParam) {
13
+        tokenParamHolder.remove();
14
+        tokenParamHolder.set(tokenParam);
15
+    }
16
+
17
+    public static void clear() {
18
+        tokenParamHolder.remove();
19
+    }
20
+
21
+    public static Map<String, Object> getTokenParam() {
22
+        Map<String, Object> params = tokenParamHolder.get();
23
+        return params;
24
+    }
25
+}

+ 37
- 0
src/main/java/com/yunzhi/roundabout/common/DateUtils.java Visa fil

1
+package com.yunzhi.roundabout.common;
2
+
3
+import java.time.*;
4
+import java.time.format.DateTimeFormatter;
5
+
6
+public class DateUtils {
7
+    public static LocalDateTime from(String str, String formater) {
8
+        DateTimeFormatter fmt = DateTimeFormatter.ofPattern(formater);
9
+        return LocalDateTime.parse(str, fmt);
10
+    }
11
+
12
+    public static long daysBetween(LocalDateTime dt1, LocalDateTime dt2) {
13
+        Duration duration = Duration.between(dt1, dt2);
14
+        return duration.toDays();
15
+    }
16
+
17
+    public static String toString(LocalDateTime dt, String formater) {
18
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formater);
19
+        return dt.format(formatter);
20
+    }
21
+
22
+    public static String weekDay(LocalDateTime dt) {
23
+        String[] week = new String[]{"一", "二", "三", "四", "五", "六", "日"};
24
+        DayOfWeek dayOfWeek = dt.getDayOfWeek();
25
+        int inx = dayOfWeek.getValue() - 1;
26
+        return String.format("星期%s", week[inx]);
27
+    }
28
+
29
+    /**
30
+     * 毫秒转 UTC 时间
31
+     * @param milliseconds
32
+     * @return
33
+     */
34
+    public static LocalDateTime getDateTime(long milliseconds) {
35
+        return LocalDateTime.ofInstant(Instant.ofEpochMilli(milliseconds), ZoneOffset.UTC);
36
+    }
37
+}

+ 27
- 0
src/main/java/com/yunzhi/roundabout/common/ExcelUtils.java Visa fil

1
+package com.yunzhi.roundabout.common;
2
+
3
+import com.alibaba.excel.EasyExcel;
4
+
5
+import javax.servlet.http.HttpServletResponse;
6
+import java.io.IOException;
7
+import java.util.List;
8
+
9
+public class ExcelUtils {
10
+
11
+    /**
12
+     * 发送 excel 到客户端
13
+     * 暂时只支持单 sheet 页
14
+     * @param response
15
+     * @param data
16
+     * @param fileName
17
+     * @throws IOException
18
+     */
19
+    public static void flush(HttpServletResponse response, Class dataClass, List data, String fileName) throws IOException {
20
+        response.setContentType("application/vnd.ms-excel");
21
+        response.setCharacterEncoding("utf-8");
22
+        response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
23
+        response.setHeader("Content-Disposition", "attachment;filename="+StringUtils.urlEncode(fileName)+".xlsx");
24
+
25
+        EasyExcel.write(response.getOutputStream(), dataClass).sheet("sheet1").doWrite(data);
26
+    }
27
+}

+ 87
- 0
src/main/java/com/yunzhi/roundabout/common/HttpUtils.java Visa fil

1
+package com.yunzhi.roundabout.common;
2
+
3
+import org.springframework.http.*;
4
+import org.springframework.stereotype.Component;
5
+import org.springframework.web.client.RestTemplate;
6
+
7
+import java.io.UnsupportedEncodingException;
8
+import java.net.URLDecoder;
9
+import java.util.*;
10
+
11
+@Component
12
+public class HttpUtils {
13
+    public String get(String url) throws Exception {
14
+        RestTemplate restTemplate = new RestTemplate();
15
+        HttpHeaders headers = new HttpHeaders();
16
+        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
17
+        HttpEntity<String> entity = new HttpEntity<String>(headers);
18
+
19
+        Map<String, Object> urlAndParams = parseURL(url);
20
+        String formatURL = (String) urlAndParams.get("url");
21
+        Map<String, String> params = (Map<String, String>) urlAndParams.get("params");
22
+
23
+        ResponseEntity<String> resp = restTemplate.exchange(formatURL, HttpMethod.GET, entity, String.class, params);
24
+        return resp.getBody();
25
+    }
26
+
27
+    public String post(String url, Map<String, String> header, String body) throws Exception {
28
+        RestTemplate restTemplate = new RestTemplate();
29
+        HttpHeaders headers = new HttpHeaders();
30
+        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
31
+        headers.setContentType(type);
32
+        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
33
+        headers.setAll(header);
34
+        HttpEntity<String> entity = new HttpEntity<String>(body, headers);
35
+
36
+        Map<String, Object> urlAndParams = parseURL(url);
37
+        String formatURL = (String) urlAndParams.get("url");
38
+        Map<String, String> params = (Map<String, String>) urlAndParams.get("params");
39
+
40
+        ResponseEntity<String> resp = restTemplate.exchange(formatURL, HttpMethod.POST, entity, String.class, params);
41
+        return resp.getBody();
42
+    }
43
+
44
+    // RestTemplate 不能正常的处理 querystring, 必须按照约定的方式处理
45
+    private Map<String, Object> parseURL(String url) {
46
+        Map<String, Object> res = new HashMap<>();
47
+
48
+        String[] parts = url.split("\\?");
49
+        String baseURL = parts[0];
50
+
51
+        if (parts.length < 2) {
52
+            res.put("url", baseURL);
53
+            res.put("params", new HashMap<>());
54
+            return res;
55
+        }
56
+
57
+
58
+        String[] fields = parts[1].split("&");
59
+        Map<String, String> params = new HashMap<>();
60
+        List<String> searchList = new ArrayList<>();
61
+        for (String field : fields) {
62
+            String[] pairs = field.split("=");
63
+            if (2 != pairs.length) {
64
+                continue;
65
+            }
66
+
67
+            try {
68
+                String key = URLDecoder.decode(pairs[0].trim(), "UTF-8");
69
+                String val = URLDecoder.decode(pairs[1].trim(), "UTF-8");
70
+
71
+                // 转化为 "foo={foo}" 这种字符串
72
+                searchList.add(String.format("%s={%s}", key, key));
73
+                // 把 foo 对应的值存储起来
74
+                params.put(key, val);
75
+            } catch (UnsupportedEncodingException e) {
76
+                e.printStackTrace();
77
+            }
78
+        }
79
+
80
+        // url 格式类似 http://foo.org/bar?name={name}
81
+        String formatURL = baseURL + "?" + String.join("&", searchList);
82
+        res.put("url", formatURL);
83
+        res.put("params", params);
84
+
85
+        return res;
86
+    }
87
+}

+ 107
- 0
src/main/java/com/yunzhi/roundabout/common/JWTUtils.java Visa fil

1
+package com.yunzhi.roundabout.common;
2
+
3
+import io.jsonwebtoken.Claims;
4
+import io.jsonwebtoken.Jws;
5
+import io.jsonwebtoken.Jwts;
6
+import io.jsonwebtoken.security.Keys;
7
+import org.slf4j.Logger;
8
+import org.slf4j.LoggerFactory;
9
+
10
+import javax.crypto.SecretKey;
11
+import javax.servlet.http.HttpServletRequest;
12
+import javax.servlet.http.HttpServletResponse;
13
+import java.time.LocalDateTime;
14
+import java.time.ZoneId;
15
+import java.util.Base64;
16
+import java.util.Date;
17
+import java.util.Map;
18
+
19
+/**
20
+ * JWTUtils
21
+ * jwt 辅助类
22
+ * https://github.com/jwtk/jjwt
23
+ */
24
+public class JWTUtils {
25
+    private static final Logger log = LoggerFactory.getLogger(JWTUtils.class);
26
+
27
+    // 过期时间 15 分钟
28
+    public static final long EXPIRE_TIME = 15 * 60 * 24;
29
+
30
+    // 私钥
31
+    static final SecretKey SECRET_KEY = Keys.hmacShaKeyFor(Base64.getEncoder().encode("Yansen is so handsome. He is a good man. Everyone like him !!!".getBytes()));
32
+
33
+    // 请求头
34
+    public static final String AUTH_HEADER = "X-Authorization-JWT";
35
+
36
+    /**
37
+     * 生成 token, claims 里必须要有 userId
38
+     * @param claims
39
+     * @return
40
+     */
41
+    public static String encode(Map<String, Object> claims) {
42
+        Date[] datePair = getDatePair();
43
+        Date iat = datePair[0];
44
+        Date exp = datePair[1];
45
+
46
+        return Jwts.builder().setIssuer(claims.get("userId").toString()).setIssuedAt(iat).setExpiration(exp).addClaims(claims).signWith(SECRET_KEY).compact();
47
+    }
48
+
49
+    public static Map<String, Object> decode(String token) throws Exception {
50
+        return parse(token);
51
+    }
52
+
53
+    public static String refresh(String token) {
54
+        try {
55
+            Claims claims = parse(token);
56
+
57
+            Integer iat = (Integer) claims.get("iat");
58
+            if (null != iat) {
59
+                long currentTime = System.currentTimeMillis() / 1000;
60
+                int oneMinute = 60;
61
+                if (currentTime - iat < oneMinute) {
62
+                    return token;
63
+                }
64
+            }
65
+
66
+            claims.remove("iat");
67
+            claims.remove("exp");
68
+
69
+            return encode(claims);
70
+        } catch (Exception e) {
71
+            log.error("解析 JWT Token 失败: {}", e.getMessage());
72
+        }
73
+        return null;
74
+    }
75
+
76
+    public static void refresh(String jws, HttpServletResponse response) {
77
+        if (!StringUtils.isEmpty(jws)) {
78
+            String token =  refresh(jws);
79
+            response.addHeader(AUTH_HEADER, token);
80
+        }
81
+    }
82
+
83
+    public static String getToken(HttpServletRequest request) {
84
+        return request.getHeader(AUTH_HEADER);
85
+    }
86
+
87
+    public static void verify(String token) throws Exception {
88
+        parse(token);
89
+    }
90
+
91
+    private static Date[] getDatePair() {
92
+        LocalDateTime now = LocalDateTime.now();
93
+        Date iat = Date.from(now.atZone(ZoneId.systemDefault()).toInstant());
94
+        Date exp = Date.from(now.plusSeconds(EXPIRE_TIME).atZone(ZoneId.systemDefault()).toInstant());
95
+        return new Date[]{iat, exp};
96
+    }
97
+
98
+    private static Claims parse(String token) throws Exception {
99
+        if (token == null || "".equals(token)) {
100
+            throw new Exception("Token 不能为空");
101
+        }
102
+
103
+        long skew = 5;
104
+        Jws<Claims> claimsJws = Jwts.parserBuilder().setAllowedClockSkewSeconds(skew).setSigningKey(SECRET_KEY).build().parseClaimsJws(token);
105
+        return claimsJws.getBody();
106
+    }
107
+}

+ 11
- 0
src/main/java/com/yunzhi/roundabout/common/MathUtils.java Visa fil

1
+package com.yunzhi.roundabout.common;
2
+
3
+import java.util.Random;
4
+
5
+public class MathUtils {
6
+
7
+    public static Integer getRand(int min, int max) {
8
+        Random random = new Random();
9
+        return random.nextInt(max) % (max - min + 1) + min;
10
+    }
11
+}

+ 80
- 0
src/main/java/com/yunzhi/roundabout/common/ResponseBean.java Visa fil

1
+package com.yunzhi.roundabout.common;
2
+
3
+import java.io.Serializable;
4
+import java.util.Map;
5
+
6
+/**
7
+ * 接口统一状态返回BEAN.
8
+ */
9
+public class ResponseBean<T> implements Serializable {
10
+
11
+    private static final long serialVersionUID = 3593827217136880822L;
12
+
13
+    public static final int CODE_SUCCESS = 1000;
14
+    public static final int ERROR_AUTH_FAIL = 1001;
15
+    public static final int ERROR_AUTH_EXPIRED = 1002;
16
+    public static final int ERROR_MISSING_PARAMS = 1003;
17
+    public static final int ERROR_ILLEGAL_PARAMS = 1004;
18
+    public static final int ERROR_UNAVAILABLE = 1005;
19
+
20
+    private int code;
21
+    private String message;
22
+    private T data;
23
+    private String token;
24
+
25
+    /**
26
+     * 禁止外部 new
27
+     */
28
+    private ResponseBean() {
29
+        code = ResponseBean.CODE_SUCCESS;
30
+    }
31
+
32
+    public static <T> ResponseBean success(T data, String ...msgs) {
33
+        ResponseBean responseBean = new ResponseBean();
34
+        responseBean.code = ResponseBean.CODE_SUCCESS;
35
+        responseBean.data = data;
36
+
37
+        if (null != msgs && msgs.length > 0) {
38
+            responseBean.message = msgs[0];
39
+        }
40
+
41
+        return responseBean;
42
+    }
43
+
44
+    public static <T> ResponseBean error(String msg, int code, T ...datas) {
45
+        ResponseBean responseBean = new ResponseBean();
46
+        responseBean.code = code;
47
+        responseBean.message = msg;
48
+
49
+        if (null != datas && datas.length > 0) {
50
+            responseBean.data = datas[0];
51
+        }
52
+
53
+        return responseBean;
54
+    }
55
+
56
+    public int getCode() {
57
+        return code;
58
+    }
59
+
60
+    public String getMessage() {
61
+        return message;
62
+    }
63
+
64
+    public T getData() {
65
+        return data;
66
+    }
67
+
68
+    public String getToken() {
69
+        return token;
70
+    }
71
+    
72
+    @Override
73
+    public String toString() {
74
+        return  "{ code: "+code+", message: "+message+", data: <T> }";
75
+    }
76
+
77
+    public String toJSON() {
78
+        return String.format("{ \"code\": %d, \"message\": %s }", code, message);
79
+    }
80
+}

+ 203
- 0
src/main/java/com/yunzhi/roundabout/common/StringUtils.java Visa fil

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

+ 53
- 0
src/main/java/com/yunzhi/roundabout/common/excelConverter/LocalDateTimeConverter.java Visa fil

1
+package com.yunzhi.roundabout.common.excelConverter;
2
+
3
+import com.alibaba.excel.converters.Converter;
4
+import com.alibaba.excel.enums.CellDataTypeEnum;
5
+import com.alibaba.excel.metadata.CellData;
6
+import com.alibaba.excel.metadata.GlobalConfiguration;
7
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
8
+import com.yunzhi.roundabout.common.DateUtils;
9
+
10
+import java.time.LocalDateTime;
11
+
12
+public class LocalDateTimeConverter implements Converter<LocalDateTime> {
13
+    @Override
14
+    public Class supportJavaTypeKey() {
15
+        return LocalDateTime.class;
16
+    }
17
+
18
+    @Override
19
+    public CellDataTypeEnum supportExcelTypeKey() {
20
+        return CellDataTypeEnum.STRING;
21
+    }
22
+
23
+    /**
24
+     * 读 Excel
25
+     * @param cellData
26
+     * @param contentProperty
27
+     * @param globalConfiguration
28
+     * @return
29
+     * @throws Exception
30
+     */
31
+    @Override
32
+    public LocalDateTime convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
33
+        // 暂时没这个业务
34
+        return null;
35
+    }
36
+
37
+    /**
38
+     * 写 Excel
39
+     * @param value
40
+     * @param contentProperty
41
+     * @param globalConfiguration
42
+     * @return
43
+     * @throws Exception
44
+     */
45
+    @Override
46
+    public CellData convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
47
+        if (null == value) return null;
48
+
49
+        String val = DateUtils.toString(value, "yyyy-MM-dd HH:mm:ss");
50
+
51
+        return new CellData(val);
52
+    }
53
+}

+ 53
- 0
src/main/java/com/yunzhi/roundabout/common/excelConverter/LocalDayConverter.java Visa fil

1
+package com.yunzhi.roundabout.common.excelConverter;
2
+
3
+import com.alibaba.excel.converters.Converter;
4
+import com.alibaba.excel.enums.CellDataTypeEnum;
5
+import com.alibaba.excel.metadata.CellData;
6
+import com.alibaba.excel.metadata.GlobalConfiguration;
7
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
8
+import com.yunzhi.roundabout.common.DateUtils;
9
+
10
+import java.time.LocalDateTime;
11
+
12
+public class LocalDayConverter implements Converter<LocalDateTime> {
13
+    @Override
14
+    public Class supportJavaTypeKey() {
15
+        return LocalDateTime.class;
16
+    }
17
+
18
+    @Override
19
+    public CellDataTypeEnum supportExcelTypeKey() {
20
+        return CellDataTypeEnum.STRING;
21
+    }
22
+
23
+    /**
24
+     * 读 Excel
25
+     * @param cellData
26
+     * @param contentProperty
27
+     * @param globalConfiguration
28
+     * @return
29
+     * @throws Exception
30
+     */
31
+    @Override
32
+    public LocalDateTime convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
33
+        // 暂时没这个业务
34
+        return null;
35
+    }
36
+
37
+    /**
38
+     * 写 Excel
39
+     * @param value
40
+     * @param contentProperty
41
+     * @param globalConfiguration
42
+     * @return
43
+     * @throws Exception
44
+     */
45
+    @Override
46
+    public CellData convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
47
+        if (null == value) return null;
48
+
49
+        String val = DateUtils.toString(value, "yyyy-MM-dd");
50
+
51
+        return new CellData(val);
52
+    }
53
+}

+ 55
- 0
src/main/java/com/yunzhi/roundabout/common/excelConverter/MoneyConverter.java Visa fil

1
+package com.yunzhi.roundabout.common.excelConverter;
2
+
3
+import com.alibaba.excel.converters.Converter;
4
+import com.alibaba.excel.enums.CellDataTypeEnum;
5
+import com.alibaba.excel.metadata.CellData;
6
+import com.alibaba.excel.metadata.GlobalConfiguration;
7
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
8
+
9
+import java.math.BigDecimal;
10
+import java.math.RoundingMode;
11
+
12
+public class MoneyConverter implements Converter<Integer> {
13
+    @Override
14
+    public Class supportJavaTypeKey() {
15
+        return Integer.class;
16
+    }
17
+
18
+    @Override
19
+    public CellDataTypeEnum supportExcelTypeKey() {
20
+        return CellDataTypeEnum.NUMBER;
21
+    }
22
+
23
+    /**
24
+     * 读转换
25
+     * @param cellData
26
+     * @param contentProperty
27
+     * @param globalConfiguration
28
+     * @return
29
+     * @throws Exception
30
+     */
31
+    @Override
32
+    public Integer convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
33
+        // 暂时没这业务
34
+        return cellData.getNumberValue().intValue();
35
+    }
36
+
37
+    /**
38
+     * 写转换. 由分写成元
39
+     * @param value
40
+     * @param contentProperty
41
+     * @param globalConfiguration
42
+     * @return
43
+     * @throws Exception
44
+     */
45
+    @Override
46
+    public CellData convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
47
+        if (null == value) return null;
48
+
49
+        float money = Float.valueOf(value) / 100;
50
+        BigDecimal val = new BigDecimal(money);
51
+        val = val.setScale(2, RoundingMode.HALF_UP);    // 保留2位小数
52
+
53
+        return new CellData(val);
54
+    }
55
+}

+ 36
- 0
src/main/java/com/yunzhi/roundabout/common/excelConverter/SecondConverter.java Visa fil

1
+package com.yunzhi.roundabout.common.excelConverter;
2
+
3
+import com.alibaba.excel.converters.Converter;
4
+import com.alibaba.excel.enums.CellDataTypeEnum;
5
+import com.alibaba.excel.metadata.CellData;
6
+import com.alibaba.excel.metadata.GlobalConfiguration;
7
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
8
+
9
+public class SecondConverter implements Converter<Long> {
10
+    @Override
11
+    public Class supportJavaTypeKey() {
12
+        return Long.class;
13
+    }
14
+
15
+    @Override
16
+    public CellDataTypeEnum supportExcelTypeKey() {
17
+        return CellDataTypeEnum.NUMBER;
18
+    }
19
+
20
+    @Override
21
+    public Long convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
22
+        return cellData.getNumberValue().longValue();
23
+    }
24
+
25
+    @Override
26
+    public CellData convertToExcelData(Long value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
27
+        if (null == value) return null;
28
+
29
+        // 整秒
30
+        if (value % 1000 == 0) {
31
+            return new CellData(String.format("%ds", value / 1000));
32
+        } else {
33
+            return new CellData(String.format("%.3fs", value.floatValue() / 1000));
34
+        }
35
+    }
36
+}

+ 35
- 0
src/main/java/com/yunzhi/roundabout/config/BaseConfig.java Visa fil

1
+package com.yunzhi.roundabout.config;
2
+
3
+import com.yunzhi.roundabout.interceptor.PermissionInterceptor;
4
+import lombok.Data;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.context.annotation.Configuration;
7
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
8
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
9
+
10
+import javax.annotation.PostConstruct;
11
+
12
+@Data
13
+@Configuration
14
+public class BaseConfig implements WebMvcConfigurer {
15
+
16
+    @Autowired
17
+    private PermissionInterceptor permissionInterceptor;
18
+
19
+    @Autowired
20
+    private InterceptorConfig interceptorConfig;
21
+
22
+    @PostConstruct
23
+    public void init() {
24
+    }
25
+
26
+    @Override
27
+    public void addInterceptors(InterceptorRegistry registry) {
28
+        // 自定义拦截器,添加拦截路径和排除拦截路径
29
+        if (interceptorConfig.getPermission().isEnable()) {
30
+            registry.addInterceptor(permissionInterceptor)
31
+                    .addPathPatterns(interceptorConfig.getPermission().getIncludePaths())
32
+                    .excludePathPatterns(interceptorConfig.getPermission().getExcludePaths());
33
+        }
34
+    }
35
+}

+ 32
- 0
src/main/java/com/yunzhi/roundabout/config/InterceptorConfig.java Visa fil

1
+package com.yunzhi.roundabout.config;
2
+
3
+import lombok.Data;
4
+import org.springframework.boot.context.properties.ConfigurationProperties;
5
+import org.springframework.stereotype.Component;
6
+
7
+@Data
8
+@Component
9
+@ConfigurationProperties(prefix = "interceptor")
10
+public class InterceptorConfig {
11
+
12
+    private Config permission;
13
+
14
+    @Data
15
+    public static class Config {
16
+
17
+        /**
18
+         * 是否启用
19
+         */
20
+        private boolean enable;
21
+
22
+        /**
23
+         * 包含的路径
24
+         */
25
+        private String[] includePaths = new String[]{};
26
+
27
+        /**
28
+         * 排除路径
29
+         */
30
+        private String[] excludePaths = new String[]{};
31
+    }
32
+}

+ 21
- 0
src/main/java/com/yunzhi/roundabout/config/LoggingFilterConfig.java Visa fil

1
+package com.yunzhi.roundabout.config;
2
+
3
+import lombok.extern.slf4j.Slf4j;
4
+import org.springframework.context.annotation.Configuration;
5
+
6
+import javax.servlet.*;
7
+import javax.servlet.http.HttpServletRequest;
8
+import java.io.IOException;
9
+
10
+@Slf4j
11
+@Configuration
12
+public class LoggingFilterConfig implements Filter {
13
+    @Override
14
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
15
+        HttpServletRequest req = (HttpServletRequest) request;
16
+        log.info("Request URI: [{}] {}", req.getMethod() , req.getRequestURI());
17
+
18
+        // 继续执行
19
+        chain.doFilter(request, response);
20
+    }
21
+}

+ 14
- 0
src/main/java/com/yunzhi/roundabout/config/MybatisPlusConfig.java Visa fil

1
+package com.yunzhi.roundabout.config;
2
+
3
+import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
4
+import org.springframework.context.annotation.Bean;
5
+import org.springframework.context.annotation.Configuration;
6
+
7
+@Configuration
8
+public class MybatisPlusConfig {
9
+
10
+    @Bean
11
+    public PaginationInterceptor paginationInterceptor() {
12
+        return new PaginationInterceptor();
13
+    }
14
+}

+ 20
- 0
src/main/java/com/yunzhi/roundabout/config/SMSConfig.java Visa fil

1
+package com.yunzhi.roundabout.config;
2
+
3
+import lombok.Data;
4
+import org.springframework.boot.context.properties.ConfigurationProperties;
5
+import org.springframework.stereotype.Component;
6
+
7
+@Data
8
+@Component
9
+@ConfigurationProperties(prefix = "sms")
10
+public class SMSConfig {
11
+    private String server;
12
+    private Captcha captcha;
13
+
14
+    @Data
15
+    public static class Captcha {
16
+        private String plat;
17
+        private String template;
18
+        private String sign;
19
+    }
20
+}

+ 24
- 0
src/main/java/com/yunzhi/roundabout/config/SwagggerConfig.java Visa fil

1
+package com.yunzhi.roundabout.config;
2
+
3
+import io.swagger.annotations.Api;
4
+import org.springframework.context.annotation.Bean;
5
+import org.springframework.context.annotation.Configuration;
6
+import springfox.documentation.builders.PathSelectors;
7
+import springfox.documentation.builders.RequestHandlerSelectors;
8
+import springfox.documentation.spi.DocumentationType;
9
+import springfox.documentation.spring.web.plugins.Docket;
10
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
11
+
12
+@Configuration
13
+@EnableSwagger2
14
+public class SwagggerConfig {
15
+    @Bean
16
+    public Docket docket() {
17
+        return new Docket(DocumentationType.SWAGGER_2)
18
+                .select()
19
+                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
20
+                .paths(PathSelectors.any())
21
+                .build();
22
+
23
+    }
24
+}

+ 13
- 0
src/main/java/com/yunzhi/roundabout/controller/CommController.java Visa fil

1
+package com.yunzhi.roundabout.controller;
2
+
3
+import com.yunzhi.roundabout.common.BaseController;
4
+import io.swagger.annotations.Api;
5
+import org.springframework.web.bind.annotation.RequestMapping;
6
+import org.springframework.web.bind.annotation.RestController;
7
+
8
+@Api(tags = "通用")
9
+@RestController
10
+@RequestMapping("/")
11
+public class CommController  extends BaseController {
12
+
13
+}

+ 141
- 0
src/main/java/com/yunzhi/roundabout/controller/LoginController.java Visa fil

1
+package com.yunzhi.roundabout.controller;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.yunzhi.roundabout.common.*;
5
+import com.yunzhi.roundabout.entity.TaPerson;
6
+import com.yunzhi.roundabout.service.ITaPersonService;
7
+import com.yunzhi.roundabout.vo.LoginParam;
8
+import com.yunzhi.roundabout.vo.MPLogin;
9
+import io.swagger.annotations.Api;
10
+import io.swagger.annotations.ApiOperation;
11
+import io.swagger.annotations.ApiParam;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.beans.factory.annotation.Value;
14
+import org.springframework.util.DigestUtils;
15
+import org.springframework.web.bind.annotation.*;
16
+
17
+import java.nio.charset.StandardCharsets;
18
+import java.util.HashMap;
19
+import java.util.Map;
20
+
21
+@Api(tags = "登入/登出")
22
+@RestController
23
+public class LoginController extends BaseController {
24
+
25
+    @Value("${biz.admin.account}")
26
+    String adminAccount;
27
+
28
+    @Value("${biz.admin.password}")
29
+    String adminPassword;
30
+
31
+    @Value("${biz.wxapi}")
32
+    String wxApi;
33
+
34
+    @Autowired
35
+    HttpUtils httpUtils;
36
+
37
+    @Autowired
38
+    ITaPersonService iTaPersonService;
39
+
40
+    @PostMapping("/admin/login")
41
+    @ApiOperation(value="后端登录", notes = "后端登录", httpMethod = "POST", response = ResponseBean.class)
42
+    public ResponseBean login(@ApiParam("登录参数") @RequestBody LoginParam loginParam) throws Exception {
43
+        if (null == loginParam) {
44
+            return ResponseBean.error("账户或密码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
45
+        }
46
+
47
+        String userName = loginParam.getUserName();
48
+        String password = loginParam.getPassword();
49
+
50
+        if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) {
51
+            return ResponseBean.error("账户或密码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
52
+        }
53
+
54
+        if (!adminAccount.equals(userName)) {
55
+            return ResponseBean.error("账户或密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
56
+        }
57
+
58
+        String targetPassword = md5(md5(adminPassword) + adminAccount);
59
+
60
+        if (!checkPassword(password, targetPassword, adminAccount)) {
61
+            return ResponseBean.error("账户或密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
62
+        }
63
+
64
+        // 生成 token
65
+        Map<String, Object> tokenMap = new HashMap<String, Object>() {{
66
+           put("userId", adminAccount);
67
+        }};
68
+        String token = JWTUtils.encode(tokenMap);
69
+
70
+        Map<String, Object> res = new HashMap<String, Object>() {{
71
+//            put("user", sysUser);
72
+            put("token", token);
73
+        }};
74
+        return ResponseBean.success(res);
75
+    }
76
+
77
+    /**
78
+     * 根据id查询对象
79
+     * @param code  登录CODE
80
+     */
81
+    @RequestMapping(value="/wx/login",method= RequestMethod.POST)
82
+    @ApiOperation(value="微信登录", notes = "微信登录", httpMethod = "POST", response = ResponseBean.class)
83
+    public ResponseBean taPersonGet(@ApiParam("对象ID") @RequestParam String code) throws Exception{
84
+        TaPerson taPerson = null;
85
+        if ("123".equals(code)) {
86
+            taPerson = iTaPersonService.getById(code);
87
+        } else {
88
+
89
+            String wxresp = httpUtils.get(wxApi + "/mp/userinfo?code=" + code);
90
+            if (StringUtils.isEmpty(wxresp)) {
91
+                return ResponseBean.error("登录参数不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
92
+            }
93
+
94
+            JSONObject obj = JSONObject.parseObject(wxresp);
95
+            if (ResponseBean.CODE_SUCCESS != (Integer) obj.get("code")) {
96
+                return ResponseBean.error((String) obj.get("message"), ResponseBean.ERROR_ILLEGAL_PARAMS);
97
+            }
98
+
99
+            JSONObject params = obj.getJSONObject("data");
100
+
101
+            String openid = (String) params.get("openid");
102
+            if (StringUtils.isEmpty(openid)) {
103
+                return ResponseBean.error("系统出错, 请退出重试", ResponseBean.ERROR_ILLEGAL_PARAMS);
104
+            }
105
+
106
+            String nickname = (String) params.get("nickname");
107
+            String headimgurl = (String) params.get("headImgUrl");
108
+
109
+            taPerson = iTaPersonService.getByOpenId(openid);
110
+
111
+            // 更新人员信息
112
+            if (StringUtils.isEmpty(taPerson.getName())) {
113
+                taPerson.setName(nickname);
114
+                taPerson.setAvatar(headimgurl);
115
+                iTaPersonService.updateById(taPerson);
116
+            }
117
+        }
118
+
119
+        // 生成 token
120
+        TaPerson finalTaPerson = taPerson;
121
+        Map<String, Object> tokenMap = new HashMap<String, Object>() {{
122
+            put("userId", finalTaPerson.getPersonId());
123
+        }};
124
+        String token = JWTUtils.encode(tokenMap);
125
+
126
+        Map<String, Object> res = new HashMap<String, Object>() {{
127
+            put("user", finalTaPerson);
128
+            put("token", token);
129
+        }};
130
+
131
+        return ResponseBean.success(res);
132
+    }
133
+
134
+    private boolean checkPassword(String src, String targ, String salt) {
135
+        return md5((src+salt)).equals(targ);
136
+    }
137
+
138
+    private String md5(String src) {
139
+        return DigestUtils.md5DigestAsHex(src.getBytes(StandardCharsets.UTF_8));
140
+    }
141
+}

+ 261
- 0
src/main/java/com/yunzhi/roundabout/controller/TaPersonController.java Visa fil

1
+package com.yunzhi.roundabout.controller;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
6
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
+import com.yunzhi.roundabout.common.*;
8
+import io.swagger.annotations.Api;
9
+import io.swagger.annotations.ApiOperation;
10
+import io.swagger.annotations.ApiParam;
11
+import org.slf4j.Logger;
12
+import org.slf4j.LoggerFactory;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.beans.factory.annotation.Value;
15
+import org.springframework.web.bind.annotation.PathVariable;
16
+import org.springframework.web.bind.annotation.RequestMapping;
17
+import org.springframework.web.bind.annotation.RequestMethod;
18
+import org.springframework.web.bind.annotation.RequestParam;
19
+import com.yunzhi.roundabout.service.ITaPersonService;
20
+import com.yunzhi.roundabout.entity.TaPerson;
21
+import org.springframework.web.bind.annotation.RestController;
22
+
23
+import javax.servlet.http.HttpServletRequest;
24
+import javax.servlet.http.HttpServletResponse;
25
+import java.time.LocalDateTime;
26
+import java.util.List;
27
+
28
+/**
29
+ * <p>
30
+    * 用户表 前端控制器
31
+    * </p>
32
+ *
33
+ * @author yansen
34
+ * @since 2022-01-13
35
+ */
36
+
37
+@Api(tags = "用户表")
38
+@RestController
39
+@RequestMapping("/")
40
+public class TaPersonController extends BaseController {
41
+
42
+    private final Logger logger = LoggerFactory.getLogger(TaPersonController.class);
43
+
44
+    @Autowired
45
+    public ITaPersonService iTaPersonService;
46
+
47
+
48
+    @Value("${biz.wxapi}")
49
+    String wxApi;
50
+
51
+    @Autowired
52
+    HttpUtils httpUtils;
53
+
54
+
55
+    /**
56
+     * 分页查询列表
57
+     * @param pageNum
58
+     * @param pageSize
59
+     * @return
60
+     */
61
+    @RequestMapping(value="/taPerson",method= RequestMethod.GET)
62
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
63
+    public ResponseBean taPersonList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
64
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
65
+                                     @ApiParam(value = "开始时间", example = "2021-01-01") @RequestParam(value ="startDate", required = false) String startDate,
66
+                                     @ApiParam(value = "结束时间", example = "2021-10-31") @RequestParam(value ="endDate", required = false) String endDate) throws Exception{
67
+
68
+        LocalDateTime start = null, end = null;
69
+
70
+        if (!StringUtils.isEmpty(startDate)) {
71
+            start = DateUtils.from(startDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
72
+        }
73
+        if (!StringUtils.isEmpty(endDate)) {
74
+            end = DateUtils.from(endDate + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
75
+        }
76
+
77
+        IPage<TaPerson> pg = new Page<>(pageNum, pageSize);
78
+        IPage<TaPerson> result = iTaPersonService.getPageBy(pg, start, end);
79
+        return ResponseBean.success(result);
80
+    }
81
+
82
+    @RequestMapping(value="/taPerson",method= RequestMethod.POST)
83
+    @ApiOperation(value="导出Excel", notes = "导出Excel", httpMethod = "POST", response = ResponseBean.class)
84
+    public void exportXls(@ApiParam(value = "开始时间", example = "2021-01-01") @RequestParam(value ="startDate", required = false) String startDate,
85
+                          @ApiParam(value = "结束时间", example = "2021-10-31") @RequestParam(value ="endDate", required = false) String endDate,
86
+                          HttpServletResponse response) throws Exception {
87
+        LocalDateTime start = null, end = null;
88
+
89
+        if (!StringUtils.isEmpty(startDate)) {
90
+            start = DateUtils.from(startDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
91
+        }
92
+        if (!StringUtils.isEmpty(endDate)) {
93
+            end = DateUtils.from(endDate + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
94
+        }
95
+
96
+        List<TaPerson> result = iTaPersonService.getListBy(start, end);
97
+        ExcelUtils.flush(response, TaPerson.class, result, "参与人员名单");
98
+    }
99
+
100
+
101
+    /**
102
+     * 分页查询列表
103
+     * @return
104
+     */
105
+    @RequestMapping(value="/wx/top",method= RequestMethod.GET)
106
+    @ApiOperation(value="排行榜", notes = "排行榜", httpMethod = "GET", response = ResponseBean.class)
107
+    public ResponseBean top() throws Exception{
108
+
109
+        QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<>();
110
+        queryWrapper.gt("total_millsec", 0);
111
+        queryWrapper.orderByAsc("total_millsec");
112
+        queryWrapper.orderByAsc("join_date");
113
+        queryWrapper.last("limit 100");
114
+
115
+        return ResponseBean.success(iTaPersonService.list(queryWrapper));
116
+    }
117
+
118
+    /**
119
+     * wx-jdk
120
+     */
121
+    @RequestMapping(value="/wx/jssdk",method= RequestMethod.GET)
122
+    @ApiOperation(value="WXJDK", notes = "WXJDK", httpMethod = "GET", response = ResponseBean.class)
123
+    public ResponseBean gameStart(@ApiParam("分享地址") @RequestParam String url) throws Exception{
124
+
125
+        String wxresp = httpUtils.get(wxApi + "/mp/jssdk?url=" + url);
126
+        if (StringUtils.isEmpty(wxresp)) {
127
+            return ResponseBean.error("分享地址不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
128
+        }
129
+
130
+        JSONObject obj = JSONObject.parseObject(wxresp);
131
+        if (ResponseBean.CODE_SUCCESS != (Integer) obj.get("code")) {
132
+            return ResponseBean.error((String) obj.get("message"), ResponseBean.ERROR_ILLEGAL_PARAMS);
133
+        }
134
+
135
+        JSONObject data = obj.getJSONObject("data");
136
+        return ResponseBean.success(data);
137
+    }
138
+
139
+
140
+    /**
141
+     * 游戏开始
142
+     */
143
+    @RequestMapping(value="/wx/game/start",method= RequestMethod.POST)
144
+    @ApiOperation(value="游戏开始", notes = "游戏开始", httpMethod = "POST", response = ResponseBean.class)
145
+    public ResponseBean gameStart(HttpServletRequest request) throws Exception{
146
+        TaPerson taPerson = currentPerson(request);
147
+        long startTime = System.currentTimeMillis();
148
+
149
+        taPerson.setLastStart(String.valueOf(startTime));
150
+        iTaPersonService.updateById(taPerson);
151
+        return ResponseBean.success(null);
152
+    }
153
+
154
+    /**
155
+     * 游戏开始
156
+     */
157
+    @RequestMapping(value="/wx/game/over",method= RequestMethod.POST)
158
+    @ApiOperation(value="游戏结束", notes = "游戏结束", httpMethod = "POST", response = ResponseBean.class)
159
+    public ResponseBean gameOver(HttpServletRequest request) throws Exception{
160
+        TaPerson taPerson = currentPerson(request);
161
+        Long startTime = Long.parseLong(taPerson.getLastStart());
162
+        if (startTime == null) {
163
+            throw new Exception("请刷新重试");
164
+        }
165
+
166
+        long endTime = System.currentTimeMillis();
167
+        long totalMillsec = endTime - startTime;
168
+
169
+        int oneSec = 1000;
170
+        int oneHour = 60 * 60 * 1000;
171
+
172
+        // 防止异常
173
+        if (totalMillsec < oneSec || totalMillsec > oneHour) {
174
+            throw new Exception("请刷新重试");
175
+        }
176
+
177
+        taPerson.setLastEnd(String.valueOf(endTime));
178
+
179
+        // 判断是否之前玩过
180
+        if (taPerson.getTotalMillsec() > 0) {
181
+            // 如果本次时间比上次要少, 则更新本次时间
182
+            if (totalMillsec < taPerson.getTotalMillsec()) {
183
+                taPerson.setStartTime(String.valueOf(startTime));
184
+                taPerson.setEndTime(String.valueOf(endTime));
185
+                taPerson.setTotalMillsec(totalMillsec);
186
+                taPerson.setJoinDate(LocalDateTime.now());
187
+            } else {
188
+                // 否则, 本次游戏不会被算入排行榜
189
+            }
190
+        } else {
191
+            taPerson.setStartTime(String.valueOf(startTime));
192
+            taPerson.setEndTime(String.valueOf(endTime));
193
+            taPerson.setTotalMillsec(totalMillsec);
194
+            taPerson.setJoinDate(LocalDateTime.now());
195
+        }
196
+
197
+        iTaPersonService.updateById(taPerson);
198
+        return ResponseBean.success(null);
199
+    }
200
+
201
+//    /**
202
+//     * 保存对象
203
+//     * @param taPerson 实体对象
204
+//     * @return
205
+//     */
206
+//    @RequestMapping(value="/taPerson",method= RequestMethod.POST)
207
+//    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
208
+//    public ResponseBean taPersonAdd(@ApiParam("保存内容") @RequestBody TaPerson taPerson) throws Exception{
209
+//
210
+//        if (iTaPersonService.save(taPerson)){
211
+//            return ResponseBean.success(taPerson);
212
+//        }else {
213
+//            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
214
+//        }
215
+//    }
216
+//
217
+//    /**
218
+//     * 根据id删除对象
219
+//     * @param id  实体ID
220
+//     */
221
+//    @RequestMapping(value="/taPerson/{id}", method= RequestMethod.DELETE)
222
+//    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
223
+//    public ResponseBean taPersonDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
224
+//        if(iTaPersonService.removeById(id)){
225
+//            return ResponseBean.success("success");
226
+//        }else {
227
+//            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
228
+//        }
229
+//    }
230
+
231
+//    /**
232
+//     * 修改对象
233
+//     * @param id  实体ID
234
+//     * @param taPerson 实体对象
235
+//     * @return
236
+//     */
237
+//    @RequestMapping(value="/wx/taPerson/{id}",method= RequestMethod.PUT)
238
+//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
239
+//    public ResponseBean taPersonUpdate(@ApiParam("对象ID") @PathVariable String id,
240
+//                                        @ApiParam("更新内容") @RequestBody TaPerson taPerson) throws Exception{
241
+//
242
+//        TaPerson origin = iTaPersonService.getByPhone(taPerson.getPhone());
243
+//        if (null != origin && !id.equals(origin.getPersonId())) {
244
+//            return ResponseBean.error("手机号已存在, 请重新填写", ResponseBean.ERROR_UNAVAILABLE);
245
+//        }
246
+//
247
+//        origin = iTaPersonService.getById(id);
248
+//        if (null == origin) {
249
+//            return ResponseBean.error("人员信息校验失败, 请刷新重试", ResponseBean.ERROR_UNAVAILABLE);
250
+//        }
251
+//
252
+//        taPerson.setPersonId(id);
253
+//
254
+//        if (iTaPersonService.updateName(taPerson)){
255
+//            return ResponseBean.success(iTaPersonService.getById(id));
256
+//        }else {
257
+//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
258
+//        }
259
+//    }
260
+
261
+}

+ 88
- 0
src/main/java/com/yunzhi/roundabout/entity/TaPerson.java Visa fil

1
+package com.yunzhi.roundabout.entity;
2
+
3
+import com.alibaba.excel.annotation.ExcelIgnore;
4
+import com.alibaba.excel.annotation.ExcelProperty;
5
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
6
+import com.baomidou.mybatisplus.annotation.IdType;
7
+import java.time.LocalDateTime;
8
+
9
+import com.baomidou.mybatisplus.annotation.TableId;
10
+import java.io.Serializable;
11
+
12
+import com.yunzhi.roundabout.common.excelConverter.LocalDateTimeConverter;
13
+import com.yunzhi.roundabout.common.excelConverter.SecondConverter;
14
+import io.swagger.annotations.ApiModel;
15
+import io.swagger.annotations.ApiModelProperty;
16
+import lombok.Data;
17
+import lombok.EqualsAndHashCode;
18
+import lombok.experimental.Accessors;
19
+
20
+/**
21
+ * <p>
22
+ * 用户表
23
+ * </p>
24
+ *
25
+ * @author yansen
26
+ * @since 2022-01-13
27
+ */
28
+@Data
29
+@EqualsAndHashCode(callSuper = false)
30
+@Accessors(chain = true)
31
+@ApiModel(value="TaPerson对象", description="用户表")
32
+public class TaPerson implements Serializable {
33
+
34
+    @ExcelIgnore
35
+    private static final long serialVersionUID = 1L;
36
+
37
+    @ExcelIgnore
38
+    @ApiModelProperty(value = "用户ID")
39
+    @TableId(value = "person_id", type = IdType.UUID)
40
+    private String personId;
41
+
42
+    @ExcelProperty(value = "中奖人", index = 0)
43
+    @ColumnWidth(40)
44
+    @ApiModelProperty(value = "用户名")
45
+    private String name;
46
+
47
+    @ExcelIgnore
48
+    @ApiModelProperty(value = "头像")
49
+    private String avatar;
50
+
51
+    @ExcelIgnore
52
+    @ApiModelProperty(value = "手机号")
53
+    private String phone;
54
+
55
+    @ExcelIgnore
56
+    @ApiModelProperty(value = "openid")
57
+    private String openid;
58
+
59
+    @ExcelIgnore
60
+    @ApiModelProperty(value = "创建时间")
61
+    private LocalDateTime createDate;
62
+
63
+    @ExcelProperty(value = "参与时间", index = 1, converter = LocalDateTimeConverter.class)
64
+    @ColumnWidth(60)
65
+    @ApiModelProperty(value = "参与时间")
66
+    private LocalDateTime joinDate;
67
+
68
+    @ExcelIgnore
69
+    @ApiModelProperty(value = "开始时间")
70
+    private String startTime;
71
+
72
+    @ExcelIgnore
73
+    @ApiModelProperty(value = "结束时间")
74
+    private String endTime;
75
+
76
+    @ExcelProperty(value = "耗时", index = 2, converter = SecondConverter.class)
77
+    @ColumnWidth(40)
78
+    @ApiModelProperty(value = "耗时时长")
79
+    private Long totalMillsec;
80
+
81
+    @ExcelIgnore
82
+    @ApiModelProperty(value = "最后一次开始时间")
83
+    private String lastStart;
84
+
85
+    @ExcelIgnore
86
+    @ApiModelProperty(value = "最后一次结束时间")
87
+    private String lastEnd;
88
+}

+ 19
- 0
src/main/java/com/yunzhi/roundabout/exception/GlobalExceptionHandler.java Visa fil

1
+package com.yunzhi.roundabout.exception;
2
+
3
+import com.yunzhi.roundabout.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
+        log.error(e.getMessage(),e);
17
+        return ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
18
+    }
19
+}

+ 48
- 0
src/main/java/com/yunzhi/roundabout/interceptor/PermissionInterceptor.java Visa fil

1
+package com.yunzhi.roundabout.interceptor;
2
+
3
+import com.yunzhi.roundabout.common.JWTUtils;
4
+import com.yunzhi.roundabout.common.ResponseBean;
5
+import com.yunzhi.roundabout.common.StringUtils;
6
+import lombok.extern.slf4j.Slf4j;
7
+import org.springframework.stereotype.Component;
8
+import org.springframework.web.servlet.HandlerInterceptor;
9
+
10
+import javax.servlet.http.HttpServletRequest;
11
+import javax.servlet.http.HttpServletResponse;
12
+import java.io.IOException;
13
+import java.nio.charset.StandardCharsets;
14
+import java.util.Map;
15
+
16
+
17
+@Slf4j
18
+@Component
19
+public class PermissionInterceptor implements HandlerInterceptor {
20
+
21
+    @Override
22
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {
23
+//        log.info("Request URI: {}", request.getRequestURI());
24
+
25
+        // JWT
26
+        String jws = JWTUtils.getToken(request);
27
+        if (StringUtils.isEmpty(jws)) {
28
+            responseTokenError(response, "鉴权失败, 请先进行登录操作");
29
+            return false;
30
+        }
31
+
32
+        try {
33
+            Map<String, Object> tokenMap = JWTUtils.decode(jws);
34
+        } catch (Exception e) {
35
+            log.error("鉴权失败: {}", e.getMessage());
36
+            responseTokenError(response, "鉴权失败, 请重新登录");
37
+            return false;
38
+        }
39
+
40
+        return true;
41
+    }
42
+
43
+    private void responseTokenError(HttpServletResponse response, String error) throws IOException {
44
+        response.addHeader("Content-type", "application/json");
45
+        response.getOutputStream().write(
46
+                ResponseBean.error(error, ResponseBean.ERROR_AUTH_FAIL).toJSON().getBytes(StandardCharsets.UTF_8));
47
+    }
48
+}

+ 26
- 0
src/main/java/com/yunzhi/roundabout/mapper/TaPersonMapper.java Visa fil

1
+package com.yunzhi.roundabout.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.roundabout.entity.TaPerson;
5
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.time.LocalDateTime;
10
+import java.util.List;
11
+
12
+/**
13
+ * <p>
14
+ * 用户表 Mapper 接口
15
+ * </p>
16
+ *
17
+ * @author yansen
18
+ * @since 2022-01-13
19
+ */
20
+@Mapper
21
+public interface TaPersonMapper extends BaseMapper<TaPerson> {
22
+
23
+    IPage<TaPerson> getPageBy(IPage<TaPerson> pg, @Param("start") LocalDateTime start, @Param("end")  LocalDateTime end);
24
+
25
+    List<TaPerson> getListBy(@Param("start") LocalDateTime start, @Param("end") LocalDateTime end);
26
+}

+ 29
- 0
src/main/java/com/yunzhi/roundabout/service/ITaPersonService.java Visa fil

1
+package com.yunzhi.roundabout.service;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.roundabout.entity.TaPerson;
5
+import com.baomidou.mybatisplus.extension.service.IService;
6
+
7
+import java.time.LocalDateTime;
8
+import java.util.List;
9
+
10
+/**
11
+ * <p>
12
+ * 用户表 服务类
13
+ * </p>
14
+ *
15
+ * @author yansen
16
+ * @since 2022-01-13
17
+ */
18
+public interface ITaPersonService extends IService<TaPerson> {
19
+
20
+    TaPerson getByOpenId(String openid);
21
+
22
+    boolean updateName(TaPerson taPerson);
23
+
24
+    TaPerson getByPhone(String phone);
25
+
26
+    IPage<TaPerson> getPageBy(IPage<TaPerson> pg, LocalDateTime start, LocalDateTime end);
27
+
28
+    List<TaPerson> getListBy(LocalDateTime start, LocalDateTime end);
29
+}

+ 73
- 0
src/main/java/com/yunzhi/roundabout/service/impl/TaPersonServiceImpl.java Visa fil

1
+package com.yunzhi.roundabout.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.metadata.IPage;
6
+import com.yunzhi.roundabout.entity.TaPerson;
7
+import com.yunzhi.roundabout.mapper.TaPersonMapper;
8
+import com.yunzhi.roundabout.service.ITaPersonService;
9
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
10
+import org.springframework.stereotype.Service;
11
+
12
+import java.time.LocalDateTime;
13
+import java.util.List;
14
+
15
+/**
16
+ * <p>
17
+ * 用户表 服务实现类
18
+ * </p>
19
+ *
20
+ * @author yansen
21
+ * @since 2022-01-13
22
+ */
23
+@Service
24
+public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> implements ITaPersonService {
25
+
26
+    @Override
27
+    public TaPerson getByOpenId(String openid) {
28
+
29
+        QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<>();
30
+        queryWrapper.eq("openid", openid);
31
+        queryWrapper.last("limit 1");
32
+
33
+        TaPerson taPerson = getOne(queryWrapper);
34
+        if (null == taPerson) {
35
+            taPerson = new TaPerson();
36
+            taPerson.setOpenid(openid);
37
+            taPerson.setCreateDate(LocalDateTime.now());
38
+            save(taPerson);
39
+        }
40
+
41
+        return taPerson;
42
+    }
43
+
44
+    @Override
45
+    public boolean updateName(TaPerson taPerson) {
46
+        UpdateWrapper<TaPerson> updateWrapper = new UpdateWrapper<>();
47
+        updateWrapper.set("name", taPerson.getName());
48
+        updateWrapper.set("phone", taPerson.getPhone());
49
+        updateWrapper.eq("person_id", taPerson.getPersonId());
50
+
51
+        return update(updateWrapper);
52
+    }
53
+
54
+    @Override
55
+    public TaPerson getByPhone(String phone) {
56
+
57
+        QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<>();
58
+        queryWrapper.eq("phone", phone);
59
+        queryWrapper.last("limit 1");
60
+
61
+        return getOne(queryWrapper);
62
+    }
63
+
64
+    @Override
65
+    public IPage<TaPerson> getPageBy(IPage<TaPerson> pg, LocalDateTime start, LocalDateTime end) {
66
+        return baseMapper.getPageBy(pg, start, end);
67
+    }
68
+
69
+    @Override
70
+    public List<TaPerson> getListBy(LocalDateTime start, LocalDateTime end) {
71
+        return baseMapper.getListBy(start, end);
72
+    }
73
+}

+ 16
- 0
src/main/java/com/yunzhi/roundabout/vo/LoginParam.java Visa fil

1
+package com.yunzhi.roundabout.vo;
2
+
3
+import io.swagger.annotations.ApiModel;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Data;
6
+
7
+@ApiModel(description = "登录参数")
8
+@Data
9
+public class LoginParam {
10
+
11
+    @ApiModelProperty("用户名")
12
+    String userName;
13
+
14
+    @ApiModelProperty("密码, MD5 加密后数据")
15
+    String password;
16
+}

+ 20
- 0
src/main/java/com/yunzhi/roundabout/vo/MPLogin.java Visa fil

1
+package com.yunzhi.roundabout.vo;
2
+
3
+
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+
8
+@ApiModel(description = "公众号登录")
9
+@Data
10
+public class MPLogin {
11
+
12
+    @ApiModelProperty("OpenID")
13
+    String openid;
14
+
15
+    @ApiModelProperty("昵称")
16
+    String nickname;
17
+
18
+    @ApiModelProperty("头像")
19
+    String headImgUrl;
20
+}

+ 47
- 0
src/main/resources/application.yml Visa fil

1
+###
2
+server:
3
+  port: 9000
4
+  servlet:
5
+    context-path: /api
6
+
7
+###
8
+spring:
9
+  servlet:
10
+    multipart:
11
+      max-file-size: 10MB
12
+      max-request-size: 50MB
13
+  datasource:
14
+#    url: jdbc:mysql://110.40.183.156:3306/hh_draw_lots?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
15
+    url: jdbc:mysql://rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com:3306/hh_roundabout?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
16
+    username: hh_draw_lots
17
+    password: hh_draw_lots@ABC123
18
+
19
+###
20
+mybatis-plus:
21
+  configuration:
22
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
23
+    call-setters-on-nulls: true
24
+  mapper-locations: classpath:mapper/**/*.xml
25
+
26
+
27
+###
28
+interceptor:
29
+  permission:
30
+    enable: true
31
+    include-paths: /**
32
+    exclude-paths:
33
+      - /admin/login
34
+      - /wx/login
35
+      - /wx/jssdk
36
+      - /swagger-ui/**
37
+      - /swagger-resources/**
38
+      - /v2/**
39
+
40
+# 业务
41
+biz:
42
+  wxapi: https://api.h5.njyunzhi.com
43
+  admin:
44
+    # 账户名
45
+    account: admin
46
+    # 密码
47
+    password: 888888

+ 24
- 0
src/main/resources/mapper/TaPersonMapper.xml Visa fil

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.yunzhi.roundabout.mapper.TaPersonMapper">
4
+
5
+    <sql id="listSQL">
6
+        SELECT
7
+            t.*
8
+        FROM
9
+            ta_person t
10
+        WHERE
11
+            t.total_millsec &gt; 0
12
+            <if test="start != null">AND t.join_date &gt;= #{start}</if>
13
+            <if test="end != null">AND t.join_date &lt;= #{end}</if>
14
+        ORDER BY
15
+            t.total_millsec ASC, t.join_date ASC
16
+    </sql>
17
+
18
+    <select id="getPageBy" resultType="com.yunzhi.roundabout.entity.TaPerson">
19
+        <include refid="listSQL"></include>
20
+    </select>
21
+    <select id="getListBy" resultType="com.yunzhi.roundabout.entity.TaPerson">
22
+        <include refid="listSQL"></include>
23
+    </select>
24
+</mapper>