张延森 3 年前
当前提交
c102c1aee9
共有 61 个文件被更改,包括 3255 次插入0 次删除
  1. 43
    0
      .gitignore
  2. 310
    0
      mvnw
  3. 182
    0
      mvnw.cmd
  4. 231
    0
      pom.xml
  5. 16
    0
      src/main/java/com/yunzhi/gnyy/SpringApplication.java
  6. 52
    0
      src/main/java/com/yunzhi/gnyy/common/BaseController.java
  7. 14
    0
      src/main/java/com/yunzhi/gnyy/common/Constants.java
  8. 51
    0
      src/main/java/com/yunzhi/gnyy/common/DateUtils.java
  9. 17
    0
      src/main/java/com/yunzhi/gnyy/common/EncryptUtils.java
  10. 87
    0
      src/main/java/com/yunzhi/gnyy/common/HttpUtils.java
  11. 191
    0
      src/main/java/com/yunzhi/gnyy/common/IpUtil.java
  12. 11
    0
      src/main/java/com/yunzhi/gnyy/common/MathUtils.java
  13. 76
    0
      src/main/java/com/yunzhi/gnyy/common/ResponseBean.java
  14. 125
    0
      src/main/java/com/yunzhi/gnyy/common/StringUtils.java
  15. 58
    0
      src/main/java/com/yunzhi/gnyy/common/WxUtils.java
  16. 28
    0
      src/main/java/com/yunzhi/gnyy/config/CorsConfig.java
  17. 30
    0
      src/main/java/com/yunzhi/gnyy/config/DateConverterConfig.java
  18. 70
    0
      src/main/java/com/yunzhi/gnyy/config/JacksonConfig.java
  19. 21
    0
      src/main/java/com/yunzhi/gnyy/config/LoggingFilterConfig.java
  20. 14
    0
      src/main/java/com/yunzhi/gnyy/config/MybatisPlusConfig.java
  21. 42
    0
      src/main/java/com/yunzhi/gnyy/config/SaTokenConfigure.java
  22. 24
    0
      src/main/java/com/yunzhi/gnyy/config/SwagggerConfig.java
  23. 40
    0
      src/main/java/com/yunzhi/gnyy/config/WeixinConfig.java
  24. 128
    0
      src/main/java/com/yunzhi/gnyy/controller/BdsOrganizationController.java
  25. 139
    0
      src/main/java/com/yunzhi/gnyy/controller/TaPersonController.java
  26. 152
    0
      src/main/java/com/yunzhi/gnyy/controller/WxMaController.java
  27. 119
    0
      src/main/java/com/yunzhi/gnyy/controller/WxUserController.java
  28. 143
    0
      src/main/java/com/yunzhi/gnyy/entity/BdsOrganization.java
  29. 42
    0
      src/main/java/com/yunzhi/gnyy/entity/SysSetting.java
  30. 52
    0
      src/main/java/com/yunzhi/gnyy/entity/TaPerson.java
  31. 58
    0
      src/main/java/com/yunzhi/gnyy/entity/WxUser.java
  32. 30
    0
      src/main/java/com/yunzhi/gnyy/exception/GlobalExceptionHandler.java
  33. 80
    0
      src/main/java/com/yunzhi/gnyy/log/MysqlAppender.java
  34. 18
    0
      src/main/java/com/yunzhi/gnyy/mapper/BdsOrganizationMapper.java
  35. 9
    0
      src/main/java/com/yunzhi/gnyy/mapper/SysSettingMapper.java
  36. 18
    0
      src/main/java/com/yunzhi/gnyy/mapper/TaPersonMapper.java
  37. 18
    0
      src/main/java/com/yunzhi/gnyy/mapper/WxUserMapper.java
  38. 26
    0
      src/main/java/com/yunzhi/gnyy/service/IBaseService.java
  39. 15
    0
      src/main/java/com/yunzhi/gnyy/service/IBdsOrganizationService.java
  40. 6
    0
      src/main/java/com/yunzhi/gnyy/service/ISysSettingService.java
  41. 15
    0
      src/main/java/com/yunzhi/gnyy/service/ITaPersonService.java
  42. 15
    0
      src/main/java/com/yunzhi/gnyy/service/IWxUserService.java
  43. 109
    0
      src/main/java/com/yunzhi/gnyy/service/impl/BaseServiceImpl.java
  44. 19
    0
      src/main/java/com/yunzhi/gnyy/service/impl/BdsOrganizationServiceImpl.java
  45. 23
    0
      src/main/java/com/yunzhi/gnyy/service/impl/ManagerServiceImpl.java
  46. 10
    0
      src/main/java/com/yunzhi/gnyy/service/impl/SysSettingServiceImpl.java
  47. 19
    0
      src/main/java/com/yunzhi/gnyy/service/impl/TaPersonServiceImpl.java
  48. 19
    0
      src/main/java/com/yunzhi/gnyy/service/impl/WxUserServiceImpl.java
  49. 22
    0
      src/main/java/com/yunzhi/gnyy/vo/LoginParam.java
  50. 17
    0
      src/main/java/com/yunzhi/gnyy/vo/PhoneParam.java
  51. 26
    0
      src/main/java/com/yunzhi/gnyy/vo/WxMaAuthParam.java
  52. 32
    0
      src/main/java/com/yunzhi/gnyy/vo/WxMaPreload.java
  53. 16
    0
      src/main/resources/application-dev.yml
  54. 11
    0
      src/main/resources/application-prod.yml
  55. 52
    0
      src/main/resources/application.yml
  56. 31
    0
      src/main/resources/logback.xml.bak
  57. 5
    0
      src/main/resources/mapper/BdsOrganizationMapper.xml
  58. 5
    0
      src/main/resources/mapper/SysSettingMapper.xml
  59. 5
    0
      src/main/resources/mapper/TaPersonMapper.xml
  60. 5
    0
      src/main/resources/mapper/WxUserMapper.xml
  61. 13
    0
      src/test/java/com/yunzhi/demo/SpringApplicationTests.java

+ 43
- 0
.gitignore 查看文件

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

+ 310
- 0
mvnw 查看文件

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

+ 182
- 0
mvnw.cmd 查看文件

@@ -0,0 +1,182 @@
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 "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
50
+if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\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/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
124
+
125
+FOR /F "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%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.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% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
162
+if ERRORLEVEL 1 goto error
163
+goto end
164
+
165
+:error
166
+set ERROR_CODE=1
167
+
168
+:end
169
+@endlocal & set ERROR_CODE=%ERROR_CODE%
170
+
171
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
172
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
173
+if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
174
+if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
175
+:skipRcPost
176
+
177
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
178
+if "%MAVEN_BATCH_PAUSE%" == "on" pause
179
+
180
+if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
181
+
182
+exit /B %ERROR_CODE%

+ 231
- 0
pom.xml 查看文件

@@ -0,0 +1,231 @@
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.3.2.RELEASE</version>
9
+		<relativePath/> <!-- lookup parent from repository -->
10
+	</parent>
11
+	<groupId>com.yunzhi</groupId>
12
+	<artifactId>gnyy</artifactId>
13
+	<version>0.0.1</version>
14
+	<name>qrcode</name>
15
+	<description>Demo project for Spring Boot</description>
16
+
17
+	<properties>
18
+		<java.version>1.8</java.version>
19
+		<log4j.version>2.17.0</log4j.version>
20
+	</properties>
21
+
22
+	<dependencies>
23
+		<dependency>
24
+			<groupId>org.springframework.boot</groupId>
25
+			<artifactId>spring-boot-starter-web</artifactId>
26
+		</dependency>
27
+
28
+		<dependency>
29
+			<groupId>org.springframework.boot</groupId>
30
+			<artifactId>spring-boot-configuration-processor</artifactId>
31
+			<optional>true</optional>
32
+		</dependency>
33
+
34
+		<dependency>
35
+			<groupId>org.springframework.boot</groupId>
36
+			<artifactId>spring-boot-starter-test</artifactId>
37
+			<scope>test</scope>
38
+			<exclusions>
39
+				<exclusion>
40
+					<groupId>org.junit.vintage</groupId>
41
+					<artifactId>junit-vintage-engine</artifactId>
42
+				</exclusion>
43
+			</exclusions>
44
+		</dependency>
45
+
46
+		<!--mysql start-->
47
+		<dependency>
48
+			<groupId>mysql</groupId>
49
+			<artifactId>mysql-connector-java</artifactId>
50
+			<scope>runtime</scope>
51
+		</dependency>
52
+		<!--mysql end-->
53
+
54
+		<!--mybatis-plus start-->
55
+		<dependency>
56
+			<groupId>com.baomidou</groupId>
57
+			<artifactId>mybatis-plus-boot-starter</artifactId>
58
+			<version>3.1.1</version>
59
+		</dependency>
60
+		<!--mybatis-plus end-->
61
+
62
+		<!--fastjson start-->
63
+		<dependency>
64
+			<groupId>com.alibaba</groupId>
65
+			<artifactId>fastjson</artifactId>
66
+			<version>1.2.56</version>
67
+		</dependency>
68
+		<!--fastjson end-->
69
+
70
+		<!--weixin-miniapp start-->
71
+		<dependency>
72
+			<groupId>com.github.binarywang</groupId>
73
+			<artifactId>weixin-java-miniapp</artifactId>
74
+			<version>4.2.0</version>
75
+		</dependency>
76
+		<!--weixin-miniapp start-->
77
+
78
+		<!--lombok start-->
79
+		<dependency>
80
+			<groupId>org.projectlombok</groupId>
81
+			<artifactId>lombok</artifactId>
82
+			<optional>true</optional>
83
+		</dependency>
84
+		<!--lombok end-->
85
+
86
+		<!--swagger start-->
87
+		<dependency>
88
+			<groupId>io.springfox</groupId>
89
+			<artifactId>springfox-boot-starter</artifactId>
90
+			<version>3.0.0</version>
91
+		</dependency>
92
+		<!--swagger end-->
93
+
94
+		<!-- Sa-Token 权限认证, 在线文档:http://sa-token.dev33.cn/ -->
95
+		<dependency>
96
+			<groupId>cn.dev33</groupId>
97
+			<artifactId>sa-token-spring-boot-starter</artifactId>
98
+			<version>1.29.0</version>
99
+		</dependency>
100
+
101
+		<!-- Sa-Token 整合 jwt -->
102
+		<dependency>
103
+			<groupId>cn.dev33</groupId>
104
+			<artifactId>sa-token-jwt</artifactId>
105
+			<version>1.29.0</version>
106
+		</dependency>
107
+
108
+	</dependencies>
109
+
110
+	<profiles>
111
+		<profile>
112
+			<id>dev</id>
113
+			<properties>
114
+				<profileActive>dev</profileActive>
115
+			</properties>
116
+			<activation>
117
+				<activeByDefault>true</activeByDefault>
118
+			</activation>
119
+
120
+			<build>
121
+				<plugins>
122
+					<plugin>
123
+						<groupId>org.springframework.boot</groupId>
124
+						<artifactId>spring-boot-maven-plugin</artifactId>
125
+						<configuration>
126
+							<includeSystemScope>true</includeSystemScope>
127
+							<excludes>
128
+								<exclude>
129
+									<groupId>org.springframework.boot</groupId>
130
+									<artifactId>spring-boot-configuration-processor</artifactId>
131
+								</exclude>
132
+							</excludes>
133
+						</configuration>
134
+					</plugin>
135
+					<plugin>
136
+						<groupId>org.apache.maven.plugins</groupId>
137
+						<artifactId>maven-resources-plugin</artifactId>
138
+						<configuration>
139
+							<encoding>UTF-8</encoding>
140
+							<nonFilteredFileExtensions>
141
+								<nonFilteredFileExtension>pem</nonFilteredFileExtension>
142
+								<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
143
+								<nonFilteredFileExtension>p12</nonFilteredFileExtension>
144
+							</nonFilteredFileExtensions>
145
+						</configuration>
146
+					</plugin>
147
+				</plugins>
148
+				<resources>
149
+					<resource>
150
+						<directory>src/main/resources</directory>
151
+						<filtering>true</filtering>
152
+						<includes>
153
+							<include>**/*.xml</include>
154
+							<include>**/*.p12</include>
155
+							<include>**/*.pem</include>
156
+							<include>application.yml</include>
157
+							<include>application-${profileActive}.yml</include>
158
+						</includes>
159
+					</resource>
160
+				</resources>
161
+			</build>
162
+		</profile>
163
+
164
+		<profile>
165
+			<id>prod</id>
166
+			<properties>
167
+				<profileActive>prod</profileActive>
168
+			</properties>
169
+			<activation>
170
+				<activeByDefault>false</activeByDefault>
171
+			</activation>
172
+
173
+			<build>
174
+				<plugins>
175
+					<plugin>
176
+						<groupId>org.springframework.boot</groupId>
177
+						<artifactId>spring-boot-maven-plugin</artifactId>
178
+						<configuration>
179
+							<includeSystemScope>true</includeSystemScope>
180
+						</configuration>
181
+					</plugin>
182
+
183
+					<!-- 跳过测试 -->
184
+					<plugin>
185
+						<groupId>org.apache.maven.plugins</groupId>
186
+						<artifactId>maven-surefire-plugin</artifactId>
187
+						<configuration>
188
+							<skipTests>true</skipTests>
189
+							<testFailureIgnore>true</testFailureIgnore>
190
+						</configuration>
191
+					</plugin>
192
+					<plugin>
193
+						<groupId>org.apache.maven.plugins</groupId>
194
+						<artifactId>maven-resources-plugin</artifactId>
195
+						<configuration>
196
+							<encoding>UTF-8</encoding>
197
+							<nonFilteredFileExtensions>
198
+								<nonFilteredFileExtension>pem</nonFilteredFileExtension>
199
+								<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
200
+								<nonFilteredFileExtension>p12</nonFilteredFileExtension>
201
+							</nonFilteredFileExtensions>
202
+						</configuration>
203
+					</plugin>
204
+				</plugins>
205
+				<resources>
206
+					<resource>
207
+						<directory>src/main/resources</directory>
208
+						<filtering>true</filtering>
209
+						<excludes>
210
+							<exclude>application.yml</exclude>
211
+							<exclude>application-*.yml</exclude>
212
+						</excludes>
213
+					</resource>
214
+					<resource>
215
+						<directory>src/main/resources</directory>
216
+						<filtering>true</filtering>
217
+						<includes>
218
+							<include>**/*.xml</include>
219
+							<include>**/*.p12</include>
220
+							<include>**/*.pem</include>
221
+							<include>application.yml</include>
222
+							<include>application-${profileActive}.yml</include>
223
+						</includes>
224
+						<targetPath>${project.build.directory}/config</targetPath>
225
+					</resource>
226
+				</resources>
227
+			</build>
228
+		</profile>
229
+	</profiles>
230
+
231
+</project>

+ 16
- 0
src/main/java/com/yunzhi/gnyy/SpringApplication.java 查看文件

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

+ 52
- 0
src/main/java/com/yunzhi/gnyy/common/BaseController.java 查看文件

@@ -0,0 +1,52 @@
1
+package com.yunzhi.gnyy.common;
2
+
3
+import cn.dev33.satoken.stp.StpUtil;
4
+import com.yunzhi.gnyy.entity.TaPerson;
5
+import com.yunzhi.gnyy.entity.WxUser;
6
+import com.yunzhi.gnyy.service.ITaPersonService;
7
+import com.yunzhi.gnyy.service.IWxUserService;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.stereotype.Component;
10
+
11
+@Component
12
+public class BaseController {
13
+
14
+    @Autowired
15
+    IWxUserService iWxUserService;
16
+
17
+    @Autowired
18
+    ITaPersonService iTaPersonService;
19
+
20
+    public String getLoginId() {
21
+        return StpUtil.getLoginIdAsString();
22
+    }
23
+
24
+    public WxUser currentWxUser() throws Exception {
25
+        String loginId = getLoginId();
26
+        if (StringUtils.isEmpty(loginId)) {
27
+            throw new Exception("请先登录");
28
+        }
29
+
30
+        WxUser user = iWxUserService.getById(loginId);
31
+        if (user == null || user.getStatus() == Constants.STATUS_DELETE) {
32
+            throw new Exception("微信用户不存在");
33
+        }
34
+
35
+        return user;
36
+    }
37
+
38
+    public TaPerson currentPerson() throws Exception {
39
+        WxUser user = currentWxUser();
40
+        if (StringUtils.isEmpty(user.getPersonId())) {
41
+            throw new Exception("未维护人员信息");
42
+        }
43
+
44
+        TaPerson taPerson = iTaPersonService.getById(user.getPersonId());
45
+        if (taPerson == null || taPerson.getStatus() == Constants.STATUS_DELETE) {
46
+            throw new Exception("人员不存在");
47
+        }
48
+
49
+        return taPerson;
50
+    }
51
+
52
+}

+ 14
- 0
src/main/java/com/yunzhi/gnyy/common/Constants.java 查看文件

@@ -0,0 +1,14 @@
1
+package com.yunzhi.gnyy.common;
2
+
3
+public class Constants {
4
+    public final static int STATUS_DELETE = -1;
5
+    public final static int STATUS_READY = 0;
6
+    public final static int STATUS_NORMAL = 1;
7
+
8
+    // 条码接口地址
9
+    public final static String SETTING_BARCODE_URL = "BARCODE_URL";
10
+    // 院区编码
11
+    public final static String SETTING_CAMPUS_CODE = "CAMPUS_CODE";
12
+    // 院区根ID
13
+    public final static String SETTING_CAMPUS_ROOT = "CAMPUS_ROOT";
14
+}

+ 51
- 0
src/main/java/com/yunzhi/gnyy/common/DateUtils.java 查看文件

@@ -0,0 +1,51 @@
1
+package com.yunzhi.gnyy.common;
2
+
3
+import java.time.*;
4
+import java.time.format.DateTimeFormatter;
5
+
6
+public class DateUtils {
7
+    public static LocalDateTime from(String str, DateTimeFormatter fmt) {
8
+        return LocalDateTime.parse(str, fmt);
9
+    }
10
+
11
+    public static LocalDateTime from(String str, String formater) {
12
+        DateTimeFormatter fmt = DateTimeFormatter.ofPattern(formater);
13
+        return LocalDateTime.parse(str, fmt);
14
+    }
15
+
16
+    public static long daysBetween(LocalDateTime dt1, LocalDateTime dt2) {
17
+        Duration duration = Duration.between(dt1, dt2);
18
+        return duration.toDays();
19
+    }
20
+
21
+    public static String toString(LocalDateTime dt, String formater) {
22
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(formater);
23
+        return dt.format(formatter);
24
+    }
25
+
26
+    public static String weekDay(LocalDateTime dt) {
27
+        String[] week = new String[]{"一", "二", "三", "四", "五", "六", "日"};
28
+        DayOfWeek dayOfWeek = dt.getDayOfWeek();
29
+        int inx = dayOfWeek.getValue() - 1;
30
+        return String.format("星期%s", week[inx]);
31
+    }
32
+
33
+    /**
34
+     * 毫秒转 UTC 时间
35
+     * @param milliseconds
36
+     * @return
37
+     */
38
+    public static LocalDateTime getDateTime(long milliseconds) {
39
+        return LocalDateTime.ofInstant(Instant.ofEpochMilli(milliseconds), ZoneOffset.UTC);
40
+    }
41
+
42
+    public static LocalDateTime getDayStart(String dt) {
43
+        if (dt == null || dt.equals("")) return null;
44
+        return from(dt + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
45
+    }
46
+
47
+    public static LocalDateTime getDayEnd(String dt) {
48
+        if (dt == null || dt.equals("")) return null;
49
+        return from(dt + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
50
+    }
51
+}

+ 17
- 0
src/main/java/com/yunzhi/gnyy/common/EncryptUtils.java 查看文件

@@ -0,0 +1,17 @@
1
+package com.yunzhi.gnyy.common;
2
+
3
+import org.springframework.util.DigestUtils;
4
+
5
+public class EncryptUtils {
6
+
7
+    public static String md5(String str, String ...slats) {
8
+        String slat = "";
9
+        if (null != slats && slats.length > 0) {
10
+            slat = slats[0];
11
+        }
12
+
13
+        String base = str + slat;
14
+        String md5 = DigestUtils.md5DigestAsHex(base.getBytes());
15
+        return md5;
16
+    }
17
+}

+ 87
- 0
src/main/java/com/yunzhi/gnyy/common/HttpUtils.java 查看文件

@@ -0,0 +1,87 @@
1
+package com.yunzhi.gnyy.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
+}

+ 191
- 0
src/main/java/com/yunzhi/gnyy/common/IpUtil.java 查看文件

@@ -0,0 +1,191 @@
1
+package com.yunzhi.gnyy.common;
2
+
3
+import lombok.extern.slf4j.Slf4j;
4
+
5
+import javax.servlet.http.HttpServletRequest;
6
+import java.net.*;
7
+import java.util.Enumeration;
8
+
9
+@Slf4j
10
+public class IpUtil {
11
+    private static final String LOCAL_IP = "127.0.0.1";
12
+    /**
13
+     * 获取IP地址
14
+     *
15
+     * 使用Nginx等反向代理软件, 则不能通过request.getRemoteAddr()获取IP地址
16
+     * 如果使用了多级反向代理的话,X-Forwarded-For的值并不止一个,而是一串IP地址,X-Forwarded-For中第一个非unknown的有效IP字符串,则为真实IP地址
17
+     */
18
+    public static String getIpAddr(HttpServletRequest request) {
19
+        if (request == null) {
20
+            return "unknown";
21
+        }
22
+        String ip = request.getHeader("x-forwarded-for");
23
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
24
+            ip = request.getHeader("Proxy-Client-IP");
25
+        }
26
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
27
+            ip = request.getHeader("X-Forwarded-For");
28
+        }
29
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
30
+            ip = request.getHeader("WL-Proxy-Client-IP");
31
+        }
32
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
33
+            ip = request.getHeader("X-Real-IP");
34
+        }
35
+
36
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
37
+            ip = request.getRemoteAddr();
38
+        }
39
+
40
+        return "0:0:0:0:0:0:0:1".equals(ip) ? LOCAL_IP : ip;
41
+    }
42
+
43
+    public static boolean internalIp(String ip) {
44
+        boolean res = false;
45
+        byte[] addr = textToNumericFormatV4(ip);
46
+        if (addr != null && ip != null) {
47
+            res = internalIp(addr) || LOCAL_IP.equals(ip);
48
+        }
49
+        return res;
50
+    }
51
+
52
+    private static boolean internalIp(byte[] addr) {
53
+        final byte b0 = addr[0];
54
+        final byte b1 = addr[1];
55
+        // 10.x.x.x/8
56
+        final byte SECTION_1 = 0x0A;
57
+        // 172.16.x.x/12
58
+        final byte SECTION_2 = (byte) 0xAC;
59
+        final byte SECTION_3 = (byte) 0x10;
60
+        final byte SECTION_4 = (byte) 0x1F;
61
+        // 192.168.x.x/16
62
+        final byte SECTION_5 = (byte) 0xC0;
63
+        final byte SECTION_6 = (byte) 0xA8;
64
+        boolean flag = false;
65
+        switch (b0) {
66
+            case SECTION_1:
67
+                flag = true;
68
+                break;
69
+            case SECTION_2:
70
+                if (b1 >= SECTION_3 && b1 <= SECTION_4) {
71
+                    flag = true;
72
+                }
73
+                break;
74
+            case SECTION_5:
75
+                if (b1 == SECTION_6) {
76
+                    flag = true;
77
+                }
78
+                break;
79
+            default:
80
+                break;
81
+        }
82
+        return flag;
83
+    }
84
+
85
+    /**
86
+     * 将IPv4地址转换成字节
87
+     *IPv4地址
88
+     * @param text
89
+     * @return byte 字节
90
+     */
91
+    public static byte[] textToNumericFormatV4(String text) {
92
+        if (text.length() == 0) {
93
+            return null;
94
+        }
95
+
96
+        byte[] bytes = new byte[4];
97
+        String[] elements = text.split("\\.", -1);
98
+        try {
99
+            long l;
100
+            int i;
101
+            switch (elements.length) {
102
+                case 1:
103
+                    l = Long.parseLong(elements[0]);
104
+                    if ((l < 0L) || (l > 4294967295L))
105
+                        return null;
106
+                    bytes[0] = (byte) (int) (l >> 24 & 0xFF);
107
+                    bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF);
108
+                    bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
109
+                    bytes[3] = (byte) (int) (l & 0xFF);
110
+                    break;
111
+                case 2:
112
+                    l = Integer.parseInt(elements[0]);
113
+                    if ((l < 0L) || (l > 255L))
114
+                        return null;
115
+                    bytes[0] = (byte) (int) (l & 0xFF);
116
+                    l = Integer.parseInt(elements[1]);
117
+                    if ((l < 0L) || (l > 16777215L))
118
+                        return null;
119
+                    bytes[1] = (byte) (int) (l >> 16 & 0xFF);
120
+                    bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF);
121
+                    bytes[3] = (byte) (int) (l & 0xFF);
122
+                    break;
123
+                case 3:
124
+                    for (i = 0; i < 2; ++i) {
125
+                        l = Integer.parseInt(elements[i]);
126
+                        if ((l < 0L) || (l > 255L))
127
+                            return null;
128
+                        bytes[i] = (byte) (int) (l & 0xFF);
129
+                    }
130
+                    l = Integer.parseInt(elements[2]);
131
+                    if ((l < 0L) || (l > 65535L))
132
+                        return null;
133
+                    bytes[2] = (byte) (int) (l >> 8 & 0xFF);
134
+                    bytes[3] = (byte) (int) (l & 0xFF);
135
+                    break;
136
+                case 4:
137
+                    for (i = 0; i < 4; ++i) {
138
+                        l = Integer.parseInt(elements[i]);
139
+                        if ((l < 0L) || (l > 255L))
140
+                            return null;
141
+                        bytes[i] = (byte) (int) (l & 0xFF);
142
+                    }
143
+                    break;
144
+                default:
145
+                    return null;
146
+            }
147
+        } catch (NumberFormatException e) {
148
+            log.error("数字格式化异常",e);
149
+            return null;
150
+        }
151
+        return bytes;
152
+    }
153
+
154
+    public static String getLocalIP() {
155
+        String ip = "";
156
+        if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
157
+            InetAddress addr;
158
+            try {
159
+                addr = InetAddress.getLocalHost();
160
+                ip = addr.getHostAddress();
161
+            } catch (UnknownHostException e) {
162
+                log.error("获取失败",e);
163
+            }
164
+            return ip;
165
+        } else {
166
+            try {
167
+                Enumeration<?> e1 = (Enumeration<?>) NetworkInterface
168
+                        .getNetworkInterfaces();
169
+                while (e1.hasMoreElements()) {
170
+                    NetworkInterface ni = (NetworkInterface) e1.nextElement();
171
+                    if (!ni.getName().equals("eth0")) {
172
+                        continue;
173
+                    } else {
174
+                        Enumeration<?> e2 = ni.getInetAddresses();
175
+                        while (e2.hasMoreElements()) {
176
+                            InetAddress ia = (InetAddress) e2.nextElement();
177
+                            if (ia instanceof Inet6Address)
178
+                                continue;
179
+                            ip = ia.getHostAddress();
180
+                            return ip;
181
+                        }
182
+                        break;
183
+                    }
184
+                }
185
+            } catch (SocketException e) {
186
+                log.error("获取失败",e);
187
+            }
188
+        }
189
+        return "";
190
+    }
191
+}

+ 11
- 0
src/main/java/com/yunzhi/gnyy/common/MathUtils.java 查看文件

@@ -0,0 +1,11 @@
1
+package com.yunzhi.gnyy.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
+}

+ 76
- 0
src/main/java/com/yunzhi/gnyy/common/ResponseBean.java 查看文件

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

+ 125
- 0
src/main/java/com/yunzhi/gnyy/common/StringUtils.java 查看文件

@@ -0,0 +1,125 @@
1
+package com.yunzhi.gnyy.common;
2
+
3
+import java.io.UnsupportedEncodingException;
4
+import java.net.URLEncoder;
5
+import java.util.Random;
6
+import java.util.UUID;
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 uuid() {
57
+        return UUID.randomUUID().toString().replaceAll("-", "");
58
+    }
59
+
60
+    public static String urlEncode(String str) {
61
+        try {
62
+            return URLEncoder.encode(str, "UTF-8");
63
+        } catch (UnsupportedEncodingException e) {
64
+            e.printStackTrace();
65
+            return str;
66
+        }
67
+    }
68
+
69
+    public static String humpToLine(String str) {
70
+        if (null == str || "".equals(str)) return "";
71
+
72
+        Matcher matcher = humpPattern.matcher(str);
73
+        StringBuffer sb = new StringBuffer();
74
+        while (matcher.find()) {
75
+            matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
76
+        }
77
+        matcher.appendTail(sb);
78
+        return sb.toString();
79
+    }
80
+
81
+    public static String strToUnicode(String str) {
82
+        char[] chars = str.toCharArray();
83
+        String returnStr = "";
84
+        for (int i = 0; i < chars.length; i++) {
85
+            returnStr += "\\u" + Integer.toString(chars[i], 16);
86
+        }
87
+        return returnStr;
88
+    }
89
+
90
+    public static String repeat(String src, int len) {
91
+        if (null == src) {
92
+            return null;
93
+        }
94
+
95
+        if (len <= 0) {
96
+            return src;
97
+        }
98
+
99
+        String res = "";
100
+        for (int i = 0; i < len; i ++) {
101
+            res += src;
102
+        }
103
+
104
+        return res;
105
+    }
106
+
107
+    public static String lpad(String src, String padStr, int len) {
108
+        if (null == src) {
109
+            return null;
110
+        }
111
+
112
+        if (len <= 0 || src.length() >= len) {
113
+            return src;
114
+        }
115
+
116
+        if (null == padStr) {
117
+            padStr = "";
118
+        }
119
+
120
+        int padLen = len - src.length();
121
+        String prefix = repeat(padStr, padLen);
122
+        prefix = prefix.substring(0, padLen);
123
+        return prefix + src;
124
+    }
125
+}

+ 58
- 0
src/main/java/com/yunzhi/gnyy/common/WxUtils.java 查看文件

@@ -0,0 +1,58 @@
1
+package com.yunzhi.gnyy.common;
2
+
3
+import cn.binarywang.wx.miniapp.api.WxMaService;
4
+import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
5
+import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
6
+import com.yunzhi.gnyy.config.WeixinConfig;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.stereotype.Component;
9
+
10
+@Component
11
+public class WxUtils {
12
+    //
13
+    private final WeixinConfig config;
14
+    // 小程序
15
+    private static WxMaService maService;
16
+
17
+    @Autowired
18
+    public WxUtils(WeixinConfig config) {
19
+        this.config = config;
20
+
21
+        try {
22
+            setMaService(initMaService());
23
+        } catch (Exception e) {
24
+            e.printStackTrace();
25
+        }
26
+    }
27
+
28
+    public String getAppId() {
29
+        return this.config.getMiniapp().getAppid();
30
+    }
31
+
32
+    public WxMaService getMaService() throws Exception {
33
+        if (maService == null) {
34
+            setMaService(initMaService());
35
+        }
36
+
37
+        return maService;
38
+    }
39
+
40
+    private void setMaService(WxMaService maService) throws Exception {
41
+        this.maService = maService;
42
+    }
43
+
44
+    private WxMaService initMaService() {
45
+        WxMaDefaultConfigImpl conf = new WxMaDefaultConfigImpl();
46
+        WeixinConfig.Miniapp miniapp = config.getMiniapp();
47
+        conf.setAppid(miniapp.getAppid());
48
+        conf.setSecret(miniapp.getSecret());
49
+        conf.setToken(miniapp.getToken());
50
+        conf.setAesKey(miniapp.getAesKey());
51
+        conf.setMsgDataFormat("JSON");
52
+
53
+        WxMaService service = new WxMaServiceImpl();
54
+        service.setWxMaConfig(conf);
55
+        return service;
56
+    }
57
+
58
+}

+ 28
- 0
src/main/java/com/yunzhi/gnyy/config/CorsConfig.java 查看文件

@@ -0,0 +1,28 @@
1
+package com.yunzhi.gnyy.config;
2
+
3
+import org.springframework.boot.SpringBootConfiguration;
4
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
5
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
6
+
7
+@SpringBootConfiguration
8
+public class CorsConfig implements WebMvcConfigurer {
9
+    @Override
10
+    public void addCorsMappings(CorsRegistry registry) {
11
+//        //添加映射路径
12
+//        registry.addMapping("/**")
13
+//                //是否发送Cookie
14
+//                .allowCredentials(true)
15
+//                //设置放行哪些原始域
16
+//                .allowedOrigins("*")
17
+//                //放行哪些请求方式
18
+//                .allowedMethods("GET", "POST", "PUT", "DELETE")
19
+//                //.allowedMethods("*") //或者放行全部
20
+//                //放行哪些原始请求头部信息
21
+//                .allowedHeaders("*")
22
+//                //暴露哪些原始请求头部信息
23
+//                .exposedHeaders("X-Authorization-JWT");
24
+    }
25
+}
26
+
27
+
28
+//public class CorsConfig {}

+ 30
- 0
src/main/java/com/yunzhi/gnyy/config/DateConverterConfig.java 查看文件

@@ -0,0 +1,30 @@
1
+package com.yunzhi.gnyy.config;
2
+
3
+import org.springframework.context.annotation.Bean;
4
+import org.springframework.context.annotation.Configuration;
5
+import org.springframework.core.convert.converter.Converter;
6
+
7
+import java.time.LocalDateTime;
8
+import java.time.format.DateTimeFormatter;
9
+
10
+/**
11
+ * 处理 ResquestParam 中的日期格式
12
+ */
13
+
14
+@Configuration
15
+public class DateConverterConfig {
16
+    @Bean
17
+    public Converter<String, LocalDateTime> localDateTimeConverter() {
18
+        return new Converter<String, LocalDateTime>() {
19
+            @Override
20
+            public LocalDateTime convert(String source) {
21
+                if ("".equals(source)) {
22
+                    return null;
23
+                }
24
+
25
+                String dt = source + "+0800";
26
+                return LocalDateTime.parse(dt, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ssZ"));
27
+            }
28
+        };
29
+    }
30
+}

+ 70
- 0
src/main/java/com/yunzhi/gnyy/config/JacksonConfig.java 查看文件

@@ -0,0 +1,70 @@
1
+package com.yunzhi.gnyy.config;
2
+
3
+import com.fasterxml.jackson.databind.DeserializationFeature;
4
+import com.fasterxml.jackson.databind.ObjectMapper;
5
+import com.fasterxml.jackson.databind.SerializationFeature;
6
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
7
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
8
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
9
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalTimeDeserializer;
10
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
11
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
12
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
13
+import org.springframework.context.annotation.Bean;
14
+import org.springframework.context.annotation.Configuration;
15
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
16
+
17
+import java.text.SimpleDateFormat;
18
+import java.time.LocalDate;
19
+import java.time.LocalDateTime;
20
+import java.time.LocalTime;
21
+import java.time.format.DateTimeFormatter;
22
+import java.util.TimeZone;
23
+
24
+/**
25
+ * 处理 RequestBody 中的日期
26
+ */
27
+
28
+@Configuration
29
+public class JacksonConfig {
30
+
31
+    /** 默认日期时间格式 */
32
+    public static final String DEFAULT_DATE_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
33
+    /** 默认日期格式 */
34
+    public static final String DEFAULT_DATE_FORMAT = "yyyy-MM-dd";
35
+    /** 默认时间格式 */
36
+    public static final String DEFAULT_TIME_FORMAT = "HH:mm:ss";
37
+
38
+    @Bean
39
+    public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
40
+        MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
41
+        ObjectMapper objectMapper = new ObjectMapper();
42
+
43
+        // 忽略json字符串中不识别的属性
44
+        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
45
+        // 忽略无法转换的对象
46
+        objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
47
+        // PrettyPrinter 格式化输出
48
+        objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
49
+        // NULL不参与序列化
50
+//        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
51
+
52
+        // 指定时区
53
+        objectMapper.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
54
+        // 日期类型字符串处理
55
+        objectMapper.setDateFormat(new SimpleDateFormat(DEFAULT_DATE_TIME_FORMAT));
56
+
57
+        // java8日期日期处理
58
+        JavaTimeModule javaTimeModule = new JavaTimeModule();
59
+        javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)));
60
+        javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)));
61
+        javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));
62
+        javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_TIME_FORMAT)));
63
+        javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ofPattern(DEFAULT_DATE_FORMAT)));
64
+        javaTimeModule.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ofPattern(DEFAULT_TIME_FORMAT)));
65
+        objectMapper.registerModule(javaTimeModule);
66
+
67
+        converter.setObjectMapper(objectMapper);
68
+        return converter;
69
+    }
70
+}

+ 21
- 0
src/main/java/com/yunzhi/gnyy/config/LoggingFilterConfig.java 查看文件

@@ -0,0 +1,21 @@
1
+package com.yunzhi.gnyy.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/gnyy/config/MybatisPlusConfig.java 查看文件

@@ -0,0 +1,14 @@
1
+package com.yunzhi.gnyy.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
+}

+ 42
- 0
src/main/java/com/yunzhi/gnyy/config/SaTokenConfigure.java 查看文件

@@ -0,0 +1,42 @@
1
+package com.yunzhi.gnyy.config;
2
+
3
+import cn.dev33.satoken.interceptor.SaRouteInterceptor;
4
+import cn.dev33.satoken.jwt.StpLogicJwtForStateless;
5
+import cn.dev33.satoken.stp.StpLogic;
6
+import org.springframework.context.annotation.Bean;
7
+import org.springframework.context.annotation.Configuration;
8
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
9
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
10
+
11
+import java.util.ArrayList;
12
+import java.util.List;
13
+
14
+@Configuration
15
+public class SaTokenConfigure implements WebMvcConfigurer {
16
+    // 注册拦截器
17
+    @Override
18
+    public void addInterceptors(InterceptorRegistry registry) {
19
+
20
+        List<String> anonList = new ArrayList<>();
21
+        anonList.add("/wxpay/notify/**");
22
+        anonList.add("/**/sms-captcha");
23
+        anonList.add("/**/**/sms-captcha");
24
+        anonList.add("/**/preload");
25
+        anonList.add("/**/login");
26
+        anonList.add("/**/**/login");
27
+        anonList.add("/**/**/login");
28
+
29
+        // 注册Sa-Token的路由拦截器
30
+        registry.addInterceptor(new SaRouteInterceptor())
31
+                .addPathPatterns("/**")
32
+                .excludePathPatterns(anonList.toArray(new String[0]));
33
+    }
34
+
35
+
36
+
37
+    // Sa-Token 整合 jwt (Style模式)
38
+    @Bean
39
+    public StpLogic getStpLogicJwt() {
40
+        return new StpLogicJwtForStateless();
41
+    }
42
+}

+ 24
- 0
src/main/java/com/yunzhi/gnyy/config/SwagggerConfig.java 查看文件

@@ -0,0 +1,24 @@
1
+package com.yunzhi.gnyy.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
+}

+ 40
- 0
src/main/java/com/yunzhi/gnyy/config/WeixinConfig.java 查看文件

@@ -0,0 +1,40 @@
1
+package com.yunzhi.gnyy.config;
2
+
3
+import lombok.Data;
4
+import org.springframework.boot.context.properties.ConfigurationProperties;
5
+import org.springframework.boot.context.properties.NestedConfigurationProperty;
6
+import org.springframework.stereotype.Component;
7
+
8
+@Data
9
+@Component
10
+@ConfigurationProperties(prefix = "weixin")
11
+public class WeixinConfig {
12
+
13
+    @NestedConfigurationProperty
14
+    private Miniapp miniapp = new Miniapp();
15
+
16
+//    @NestedConfigurationProperty
17
+//    private Pay pay = new Pay();
18
+
19
+    @Data
20
+    public static class Miniapp {
21
+        private String appid;
22
+        private String secret;
23
+        private String token;
24
+        private String aesKey;
25
+        private String msgDataFormat;
26
+    }
27
+
28
+//    @Data
29
+//    public static class Pay {
30
+//        private String appId;
31
+//        private String mchId;
32
+//        private String mchKey;
33
+//        private String subAppId;
34
+//        private String subMchId;
35
+//        private String apiV3Key;
36
+//        private String keyPath;
37
+//        private String privateKeyPath;
38
+//        private String privateCertPath;
39
+//    }
40
+}

+ 128
- 0
src/main/java/com/yunzhi/gnyy/controller/BdsOrganizationController.java 查看文件

@@ -0,0 +1,128 @@
1
+package com.yunzhi.gnyy.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.gnyy.common.BaseController;
7
+import com.yunzhi.gnyy.common.Constants;
8
+import com.yunzhi.gnyy.common.ResponseBean;
9
+import com.yunzhi.gnyy.entity.SysSetting;
10
+import com.yunzhi.gnyy.service.ISysSettingService;
11
+import io.swagger.annotations.Api;
12
+import io.swagger.annotations.ApiOperation;
13
+import io.swagger.annotations.ApiParam;
14
+import org.slf4j.Logger;
15
+import org.slf4j.LoggerFactory;
16
+import org.springframework.beans.factory.annotation.Autowired;
17
+import org.springframework.web.bind.annotation.PathVariable;
18
+import org.springframework.web.bind.annotation.RequestBody;
19
+import org.springframework.web.bind.annotation.RequestMapping;
20
+import org.springframework.web.bind.annotation.RequestMethod;
21
+import org.springframework.web.bind.annotation.RequestParam;
22
+import com.yunzhi.gnyy.service.IBdsOrganizationService;
23
+import com.yunzhi.gnyy.entity.BdsOrganization;
24
+import org.springframework.web.bind.annotation.RestController;
25
+
26
+import java.util.List;
27
+
28
+/**
29
+ * <p>
30
+    * 组织机构 前端控制器
31
+    * </p>
32
+ *
33
+ * @author yansen
34
+ * @since 2022-05-06
35
+ */
36
+
37
+@Api(tags = "组织机构")
38
+@RestController
39
+@RequestMapping("/")
40
+public class BdsOrganizationController extends BaseController {
41
+
42
+    private final Logger logger = LoggerFactory.getLogger(BdsOrganizationController.class);
43
+
44
+    @Autowired
45
+    public IBdsOrganizationService iBdsOrganizationService;
46
+
47
+    @Autowired
48
+    public ISysSettingService iSysSettingService;
49
+
50
+
51
+    /**
52
+     * 分页查询列表
53
+     * @return
54
+     */
55
+    @RequestMapping(value="/wx/{clientId}/bds-org",method= RequestMethod.GET)
56
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
57
+    public ResponseBean bdsOrganizationList() throws Exception{
58
+
59
+        SysSetting setting1 = iSysSettingService.getById(Constants.SETTING_CAMPUS_CODE);
60
+        SysSetting setting2 = iSysSettingService.getById(Constants.SETTING_CAMPUS_ROOT);
61
+
62
+        QueryWrapper<BdsOrganization> queryWrapper = new QueryWrapper<>();
63
+        queryWrapper.eq("PROPERTY1", setting1.getContent());
64
+        queryWrapper.gt("ID", setting2.getContent());
65
+        queryWrapper.orderByAsc("ID");
66
+
67
+        List<BdsOrganization> result = iBdsOrganizationService.list(queryWrapper);
68
+        return ResponseBean.success(result);
69
+    }
70
+
71
+//    /**
72
+//     * 保存对象
73
+//     * @param bdsOrganization 实体对象
74
+//     * @return
75
+//     */
76
+//    @RequestMapping(value="/bdsOrganization",method= RequestMethod.POST)
77
+//    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
78
+//    public ResponseBean bdsOrganizationAdd(@ApiParam("保存内容") @RequestBody BdsOrganization bdsOrganization) throws Exception{
79
+//
80
+//        if (iBdsOrganizationService.save(bdsOrganization)){
81
+//            return ResponseBean.success(bdsOrganization);
82
+//        }else {
83
+//            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
84
+//        }
85
+//    }
86
+//
87
+//    /**
88
+//     * 根据id删除对象
89
+//     * @param id  实体ID
90
+//     */
91
+//    @RequestMapping(value="/bdsOrganization/{id}", method= RequestMethod.DELETE)
92
+//    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
93
+//    public ResponseBean bdsOrganizationDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
94
+//        if(iBdsOrganizationService.removeById(id)){
95
+//            return ResponseBean.success("success");
96
+//        }else {
97
+//            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
98
+//        }
99
+//    }
100
+//
101
+//    /**
102
+//     * 修改对象
103
+//     * @param id  实体ID
104
+//     * @param bdsOrganization 实体对象
105
+//     * @return
106
+//     */
107
+//    @RequestMapping(value="/bdsOrganization/{id}",method= RequestMethod.PUT)
108
+//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
109
+//    public ResponseBean bdsOrganizationUpdate(@ApiParam("对象ID") @PathVariable Integer id,
110
+//                                        @ApiParam("更新内容") @RequestBody BdsOrganization bdsOrganization) throws Exception{
111
+//
112
+//        if (iBdsOrganizationService.updateById(bdsOrganization)){
113
+//            return ResponseBean.success(iBdsOrganizationService.getById(id));
114
+//        }else {
115
+//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
116
+//        }
117
+//    }
118
+//
119
+//    /**
120
+//     * 根据id查询对象
121
+//     * @param id  实体ID
122
+//     */
123
+//    @RequestMapping(value="/bdsOrganization/{id}",method= RequestMethod.GET)
124
+//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
125
+//    public ResponseBean bdsOrganizationGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
126
+//        return ResponseBean.success(iBdsOrganizationService.getById(id));
127
+//    }
128
+}

+ 139
- 0
src/main/java/com/yunzhi/gnyy/controller/TaPersonController.java 查看文件

@@ -0,0 +1,139 @@
1
+package com.yunzhi.gnyy.controller;
2
+
3
+import com.yunzhi.gnyy.common.BaseController;
4
+import com.yunzhi.gnyy.common.Constants;
5
+import com.yunzhi.gnyy.common.ResponseBean;
6
+import com.yunzhi.gnyy.common.StringUtils;
7
+import com.yunzhi.gnyy.entity.SysSetting;
8
+import com.yunzhi.gnyy.entity.TaPerson;
9
+import com.yunzhi.gnyy.service.ISysSettingService;
10
+import io.swagger.annotations.Api;
11
+import io.swagger.annotations.ApiOperation;
12
+import io.swagger.annotations.ApiParam;
13
+import org.slf4j.Logger;
14
+import org.slf4j.LoggerFactory;
15
+import org.springframework.beans.factory.annotation.Autowired;
16
+import org.springframework.web.bind.annotation.PathVariable;
17
+import org.springframework.web.bind.annotation.RequestMapping;
18
+import org.springframework.web.bind.annotation.RequestMethod;
19
+import com.yunzhi.gnyy.service.ITaPersonService;
20
+import org.springframework.web.bind.annotation.RestController;
21
+
22
+/**
23
+ * <p>
24
+    * 人员表 前端控制器
25
+    * </p>
26
+ *
27
+ * @author yansen
28
+ * @since 2022-05-06
29
+ */
30
+
31
+@Api(tags = "人员表")
32
+@RestController
33
+@RequestMapping("/")
34
+public class TaPersonController extends BaseController {
35
+
36
+    private final Logger logger = LoggerFactory.getLogger(TaPersonController.class);
37
+
38
+    @Autowired
39
+    public ITaPersonService iTaPersonService;
40
+
41
+    @Autowired
42
+    public ISysSettingService iSysSettingService;
43
+
44
+
45
+//    /**
46
+//     * 分页查询列表
47
+//     * @param pageNum
48
+//     * @param pageSize
49
+//     * @return
50
+//     */
51
+//    @RequestMapping(value="/taPerson",method= RequestMethod.GET)
52
+//    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
53
+//    public ResponseBean taPersonList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
54
+//									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
55
+//
56
+//		    IPage<TaPerson> pg = new Page<>(pageNum, pageSize);
57
+//            QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<>();
58
+//            queryWrapper.orderByDesc("create_date");
59
+//
60
+//            IPage<TaPerson> result = iTaPersonService.page(pg, queryWrapper);
61
+//            return ResponseBean.success(result);
62
+//    }
63
+//
64
+//    /**
65
+//     * 保存对象
66
+//     * @param taPerson 实体对象
67
+//     * @return
68
+//     */
69
+//    @RequestMapping(value="/taPerson",method= RequestMethod.POST)
70
+//    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
71
+//    public ResponseBean taPersonAdd(@ApiParam("保存内容") @RequestBody TaPerson taPerson) throws Exception{
72
+//
73
+//        if (iTaPersonService.save(taPerson)){
74
+//            return ResponseBean.success(taPerson);
75
+//        }else {
76
+//            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
77
+//        }
78
+//    }
79
+//
80
+//    /**
81
+//     * 根据id删除对象
82
+//     * @param id  实体ID
83
+//     */
84
+//    @RequestMapping(value="/taPerson/{id}", method= RequestMethod.DELETE)
85
+//    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
86
+//    public ResponseBean taPersonDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
87
+//        if(iTaPersonService.removeById(id)){
88
+//            return ResponseBean.success("success");
89
+//        }else {
90
+//            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
91
+//        }
92
+//    }
93
+//
94
+//    /**
95
+//     * 修改对象
96
+//     * @param id  实体ID
97
+//     * @param taPerson 实体对象
98
+//     * @return
99
+//     */
100
+//    @RequestMapping(value="/taPerson/{id}",method= RequestMethod.PUT)
101
+//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
102
+//    public ResponseBean taPersonUpdate(@ApiParam("对象ID") @PathVariable Integer id,
103
+//                                        @ApiParam("更新内容") @RequestBody TaPerson taPerson) throws Exception{
104
+//
105
+//        if (iTaPersonService.updateById(taPerson)){
106
+//            return ResponseBean.success(iTaPersonService.getById(id));
107
+//        }else {
108
+//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
109
+//        }
110
+//    }
111
+//
112
+//    /**
113
+//     * 根据id查询对象
114
+//     * @param id  实体ID
115
+//     */
116
+//    @RequestMapping(value="/taPerson/{id}",method= RequestMethod.GET)
117
+//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
118
+//    public ResponseBean taPersonGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
119
+//        return ResponseBean.success(iTaPersonService.getById(id));
120
+//    }
121
+
122
+    /**
123
+     * 获取条码
124
+     * @param id  实体ID
125
+     */
126
+    @RequestMapping(value="/wx/{clientId}/person/{id}/barcode",method= RequestMethod.GET)
127
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
128
+    public ResponseBean getBarCode(@ApiParam("对象ID") @PathVariable String id) throws Exception{
129
+        TaPerson taPerson = iTaPersonService.getById(id);
130
+        if (null == taPerson || taPerson.getStatus() == Constants.STATUS_DELETE) {
131
+            return ResponseBean.error("人员不存在");
132
+        }
133
+
134
+        SysSetting sysSetting = iSysSettingService.getById(Constants.SETTING_BARCODE_URL);
135
+        String url = sysSetting.getContent() + "?id_no=" + StringUtils.urlEncode(taPerson.getIdNo());
136
+
137
+        return ResponseBean.success(iTaPersonService.getById(id));
138
+    }
139
+}

+ 152
- 0
src/main/java/com/yunzhi/gnyy/controller/WxMaController.java 查看文件

@@ -0,0 +1,152 @@
1
+package com.yunzhi.gnyy.controller;
2
+
3
+import cn.binarywang.wx.miniapp.api.WxMaService;
4
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
5
+import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
6
+import cn.binarywang.wx.miniapp.bean.WxMaUserInfo;
7
+import cn.dev33.satoken.stp.StpUtil;
8
+import com.yunzhi.gnyy.common.*;
9
+import com.yunzhi.gnyy.entity.TaPerson;
10
+import com.yunzhi.gnyy.entity.WxUser;
11
+import com.yunzhi.gnyy.service.ITaPersonService;
12
+import com.yunzhi.gnyy.service.IWxUserService;
13
+import com.yunzhi.gnyy.vo.LoginParam;
14
+import com.yunzhi.gnyy.vo.WxMaAuthParam;
15
+import com.yunzhi.gnyy.vo.WxMaPreload;
16
+import io.swagger.annotations.Api;
17
+import io.swagger.annotations.ApiOperation;
18
+import io.swagger.annotations.ApiParam;
19
+import org.springframework.beans.factory.annotation.Autowired;
20
+import org.springframework.web.bind.annotation.*;
21
+
22
+import java.util.HashMap;
23
+import java.util.Map;
24
+
25
+@Api(tags = "小程序登入/登出")
26
+@RestController
27
+@RequestMapping("/wx/{clientId}")
28
+public class WxMaController extends BaseController {
29
+
30
+    @Autowired
31
+    ITaPersonService iTaPersonService;
32
+
33
+    @Autowired
34
+    IWxUserService iWxUserService;
35
+
36
+    @Autowired
37
+    WxUtils wxUtils;
38
+
39
+    private boolean checkLoginParam(LoginParam loginParam) {
40
+        return !StringUtils.isEmpty(loginParam.getCode())
41
+                && !StringUtils.isEmpty(loginParam.getUserName())
42
+                && !StringUtils.isEmpty(loginParam.getPassword());
43
+    }
44
+
45
+    @GetMapping("/preload")
46
+    @ApiOperation(value="小程序登录", notes = "小程序登录", httpMethod = "POST", response = ResponseBean.class)
47
+    public ResponseBean preload(@ApiParam("客户端ID") @PathVariable String clientId,
48
+                                @ApiParam("小程序预加载参数") @RequestParam(required = false) WxMaPreload wxMaPreload) throws Exception {
49
+
50
+
51
+        return ResponseBean.success(null);
52
+    }
53
+
54
+    /**
55
+     * 小程序
56
+     * @param loginParam
57
+     * @return
58
+     * @throws Exception
59
+     */
60
+    @PostMapping("/login")
61
+    @ApiOperation(value="小程序登录", notes = "小程序登录", httpMethod = "POST", response = ResponseBean.class)
62
+    public ResponseBean appLogin(@ApiParam("客户端ID") @PathVariable String clientId,
63
+                                 @ApiParam("登录参数") @RequestBody LoginParam loginParam) throws Exception {
64
+
65
+        if (StringUtils.isEmpty(loginParam.getCode())) {
66
+            return ResponseBean.error("CODE 不能为空");
67
+        }
68
+
69
+        WxMaService service = wxUtils.getMaService();
70
+
71
+        WxMaJscode2SessionResult sessionInfo = service.getUserService().getSessionInfo(loginParam.getCode());
72
+        String openid = sessionInfo.getOpenid();
73
+        String sessionKey = sessionInfo.getSessionKey();
74
+
75
+        WxUser wxUser = iWxUserService.getExistBy("openid", openid, false, true);
76
+        if (wxUser == null) {
77
+            wxUser = new WxUser();
78
+            wxUser.setAppId(wxUtils.getAppId());
79
+            wxUser.setOpenid(openid);
80
+            iWxUserService.save(wxUser);
81
+        }
82
+
83
+        TaPerson taPerson = null;
84
+        if (!StringUtils.isEmpty(wxUser.getPersonId())) {
85
+            taPerson = iTaPersonService.getExistBy("person_id", wxUser.getPersonId(), false, true);
86
+        }
87
+
88
+        StpUtil.login(wxUser.getUserId(), "wx");
89
+        Map<String, Object> res = new HashMap<>();
90
+        res.put("user", wxUser);
91
+        res.put("person", taPerson);
92
+        res.put("token", StpUtil.getTokenValue());
93
+        res.put("sessionKey", sessionKey);
94
+
95
+        return ResponseBean.success(res);
96
+    }
97
+
98
+
99
+    @PutMapping("/auth-user")
100
+    @ApiOperation(value="授权头像", notes = "授权头像", httpMethod = "PUT", response = TaPerson.class)
101
+    public ResponseBean updateUserInfo(@ApiParam("客户端ID") @PathVariable String clientId,
102
+                                       @ApiParam("授权头像的参数") @RequestBody WxMaAuthParam params) throws Exception {
103
+        WxMaService service = wxUtils.getMaService();
104
+        checkAuthParams(service, params);
105
+
106
+        // 解密用户信息
107
+        WxMaUserInfo userInfo = service.getUserService().getUserInfo(params.getSessionKey(), params.getEncryptedData(), params.getIv());
108
+
109
+        WxUser wxUser = currentWxUser();
110
+        if (null == wxUser) {
111
+            throw new Exception("校验当前人员失败, 请重试");
112
+        }
113
+
114
+        wxUser.setAvatar(userInfo.getAvatarUrl());
115
+        wxUser.setNickName(userInfo.getNickName());
116
+
117
+        iWxUserService.updateById(wxUser);
118
+
119
+        return ResponseBean.success(wxUser);
120
+    }
121
+
122
+    @ApiOperation(value="授权手机", notes = "授权手机", httpMethod = "PUT", response = TaPerson.class)
123
+    @PutMapping("/auth-phone")
124
+    public ResponseBean updateUserPhone(@ApiParam("客户端ID") @PathVariable String clientId,
125
+                                        @ApiParam("授权手机的参数") @RequestBody WxMaAuthParam params) throws Exception {
126
+
127
+        WxMaService service = wxUtils.getMaService();
128
+
129
+        // 解密
130
+        WxMaPhoneNumberInfo phoneNoInfo = service.getUserService().getPhoneNoInfo(params.getSessionKey(), params.getEncryptedData(), params.getIv());
131
+
132
+        return ResponseBean.success(phoneNoInfo);
133
+    }
134
+
135
+
136
+    private void checkAuthParams(WxMaService service, WxMaAuthParam params) throws Exception {
137
+        String signature = params.getSignature();
138
+        String rawData = params.getRawData();
139
+        String encryptedData = params.getEncryptedData();
140
+        String iv = params.getIv();
141
+        String sessionKey = params.getSessionKey();
142
+
143
+        if (StringUtils.isEmpty(signature) || StringUtils.isEmpty(rawData) || StringUtils.isEmpty(encryptedData) || StringUtils.isEmpty(iv) || StringUtils.isEmpty(sessionKey)) {
144
+            throw new Exception("缺失授权参数");
145
+        }
146
+
147
+        boolean isValid = service.getUserService().checkUserInfo(sessionKey, rawData, signature);
148
+        if (!isValid) {
149
+            throw new Exception("校验授权参数失败, 请重试");
150
+        }
151
+    }
152
+}

+ 119
- 0
src/main/java/com/yunzhi/gnyy/controller/WxUserController.java 查看文件

@@ -0,0 +1,119 @@
1
+package com.yunzhi.gnyy.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.gnyy.common.BaseController;
7
+import com.yunzhi.gnyy.common.ResponseBean;
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.web.bind.annotation.PathVariable;
15
+import org.springframework.web.bind.annotation.RequestBody;
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.gnyy.service.IWxUserService;
20
+import com.yunzhi.gnyy.entity.WxUser;
21
+import org.springframework.web.bind.annotation.RestController;
22
+
23
+/**
24
+ * <p>
25
+    * 微信用户 前端控制器
26
+    * </p>
27
+ *
28
+ * @author yansen
29
+ * @since 2022-05-06
30
+ */
31
+
32
+@Api(tags = "微信用户")
33
+@RestController
34
+@RequestMapping("/")
35
+public class WxUserController extends BaseController {
36
+
37
+    private final Logger logger = LoggerFactory.getLogger(WxUserController.class);
38
+
39
+    @Autowired
40
+    public IWxUserService iWxUserService;
41
+
42
+//
43
+//    /**
44
+//     * 分页查询列表
45
+//     * @param pageNum
46
+//     * @param pageSize
47
+//     * @return
48
+//     */
49
+//    @RequestMapping(value="/wxUser",method= RequestMethod.GET)
50
+//    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
+//    public ResponseBean wxUserList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
+//									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+//
54
+//		    IPage<WxUser> pg = new Page<>(pageNum, pageSize);
55
+//            QueryWrapper<WxUser> queryWrapper = new QueryWrapper<>();
56
+//            queryWrapper.orderByDesc("create_date");
57
+//
58
+//            IPage<WxUser> result = iWxUserService.page(pg, queryWrapper);
59
+//            return ResponseBean.success(result);
60
+//    }
61
+//
62
+//    /**
63
+//     * 保存对象
64
+//     * @param wxUser 实体对象
65
+//     * @return
66
+//     */
67
+//    @RequestMapping(value="/wxUser",method= RequestMethod.POST)
68
+//    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
+//    public ResponseBean wxUserAdd(@ApiParam("保存内容") @RequestBody WxUser wxUser) throws Exception{
70
+//
71
+//        if (iWxUserService.save(wxUser)){
72
+//            return ResponseBean.success(wxUser);
73
+//        }else {
74
+//            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
+//        }
76
+//    }
77
+//
78
+//    /**
79
+//     * 根据id删除对象
80
+//     * @param id  实体ID
81
+//     */
82
+//    @RequestMapping(value="/wxUser/{id}", method= RequestMethod.DELETE)
83
+//    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
+//    public ResponseBean wxUserDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
+//        if(iWxUserService.removeById(id)){
86
+//            return ResponseBean.success("success");
87
+//        }else {
88
+//            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
89
+//        }
90
+//    }
91
+//
92
+//    /**
93
+//     * 修改对象
94
+//     * @param id  实体ID
95
+//     * @param wxUser 实体对象
96
+//     * @return
97
+//     */
98
+//    @RequestMapping(value="/wxUser/{id}",method= RequestMethod.PUT)
99
+//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
+//    public ResponseBean wxUserUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
+//                                        @ApiParam("更新内容") @RequestBody WxUser wxUser) throws Exception{
102
+//
103
+//        if (iWxUserService.updateById(wxUser)){
104
+//            return ResponseBean.success(iWxUserService.getById(id));
105
+//        }else {
106
+//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
107
+//        }
108
+//    }
109
+//
110
+//    /**
111
+//     * 根据id查询对象
112
+//     * @param id  实体ID
113
+//     */
114
+//    @RequestMapping(value="/wxUser/{id}",method= RequestMethod.GET)
115
+//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
+//    public ResponseBean wxUserGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
+//        return ResponseBean.success(iWxUserService.getById(id));
118
+//    }
119
+}

+ 143
- 0
src/main/java/com/yunzhi/gnyy/entity/BdsOrganization.java 查看文件

@@ -0,0 +1,143 @@
1
+package com.yunzhi.gnyy.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableName;
4
+import com.baomidou.mybatisplus.annotation.IdType;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import com.baomidou.mybatisplus.annotation.TableField;
7
+import java.io.Serializable;
8
+import io.swagger.annotations.ApiModel;
9
+import io.swagger.annotations.ApiModelProperty;
10
+import lombok.Data;
11
+import lombok.EqualsAndHashCode;
12
+import lombok.experimental.Accessors;
13
+
14
+/**
15
+ * <p>
16
+ * 组织机构
17
+ * </p>
18
+ *
19
+ * @author yansen
20
+ * @since 2022-05-06
21
+ */
22
+@Data
23
+@EqualsAndHashCode(callSuper = false)
24
+@Accessors(chain = true)
25
+@TableName("BDS_ORGANIZATION")
26
+@ApiModel(value="BdsOrganization对象", description="组织机构")
27
+public class BdsOrganization implements Serializable {
28
+
29
+    private static final long serialVersionUID = 1L;
30
+
31
+    @ApiModelProperty(value = "ID")
32
+    @TableId(value = "ID", type = IdType.INPUT)
33
+    private Integer id;
34
+
35
+    @ApiModelProperty(value = "父ID")
36
+    @TableField("PARENT_ID")
37
+    private Integer parentId;
38
+
39
+    @ApiModelProperty(value = "组织名称")
40
+    @TableField("NAME")
41
+    private String name;
42
+
43
+    @TableField("NAME_ALIAS")
44
+    private String nameAlias;
45
+
46
+    @ApiModelProperty(value = "编码")
47
+    @TableField("CODE")
48
+    private String code;
49
+
50
+    @ApiModelProperty(value = "类型编码:临床,医技,护理,机关等")
51
+    @TableField("ORGANIZATIONTYPE_CODE")
52
+    private String organizationtypeCode;
53
+
54
+    @ApiModelProperty(value = "门诊住院类型")
55
+    @TableField("PAT_SERVICE_TYPE_CODE")
56
+    private String patServiceTypeCode;
57
+
58
+    @ApiModelProperty(value = "医务类型")
59
+    @TableField("MEDICAL_TYPE_CODE")
60
+    private String medicalTypeCode;
61
+
62
+    @ApiModelProperty(value = "财务类型")
63
+    @TableField("FINANCE_TYPE_CODE")
64
+    private String financeTypeCode;
65
+
66
+    @ApiModelProperty(value = "是否启用")
67
+    @TableField("ENABLE")
68
+    private Boolean enable;
69
+
70
+    @ApiModelProperty(value = "地址、位置")
71
+    @TableField("ADDRESS")
72
+    private String address;
73
+
74
+    @ApiModelProperty(value = "联系电话")
75
+    @TableField("PHONE")
76
+    private String phone;
77
+
78
+    @ApiModelProperty(value = "拼音码")
79
+    @TableField("PINYIN_CODE")
80
+    private String pinyinCode;
81
+
82
+    @ApiModelProperty(value = "五笔码")
83
+    @TableField("WUBI_CODE")
84
+    private String wubiCode;
85
+
86
+    @ApiModelProperty(value = "负责人")
87
+    @TableField("SUPERVISOR")
88
+    private String supervisor;
89
+
90
+    @ApiModelProperty(value = "排序")
91
+    @TableField("SORT_NUM")
92
+    private Integer sortNum;
93
+
94
+    @ApiModelProperty(value = "原机构编码")
95
+    @TableField("OLD_CODE")
96
+    private String oldCode;
97
+
98
+    @ApiModelProperty(value = "备注")
99
+    @TableField("DESCN")
100
+    private String descn;
101
+
102
+    @ApiModelProperty(value = "院区编码")
103
+    @TableField("PROPERTY1")
104
+    private String property1;
105
+
106
+    @ApiModelProperty(value = "医疗分类:1医疗执行 2医疗管理")
107
+    @TableField("PROPERTY2")
108
+    private String property2;
109
+
110
+    @ApiModelProperty(value = "细分类别:0其他 1临床专科 2病区 3门诊 4医技 51药库 52药房 6手术 7护理单元 8门诊诊区 9预约小组 10教学单元")
111
+    @TableField("PROPERTY3")
112
+    private String property3;
113
+
114
+    @ApiModelProperty(value = "核算单元编码")
115
+    @TableField("PROPERTY4")
116
+    private String property4;
117
+
118
+    @ApiModelProperty(value = "核算单元名称")
119
+    @TableField("PROPERTY5")
120
+    private String property5;
121
+
122
+    @ApiModelProperty(value = "虚拟病区、虚拟护理单元标识(1表示为虚拟,否则为空)")
123
+    @TableField("PROPERTY6")
124
+    private String property6;
125
+
126
+    @ApiModelProperty(value = "会诊科室标志")
127
+    @TableField("PROPERTY7")
128
+    private String property7;
129
+
130
+    @TableField("PROPERTY8")
131
+    private String property8;
132
+
133
+    @TableField("PROPERTY9")
134
+    private String property9;
135
+
136
+    @TableField("PROPERTY10")
137
+    private String property10;
138
+
139
+    @TableField("PROPERTY11")
140
+    private String property11;
141
+
142
+
143
+}

+ 42
- 0
src/main/java/com/yunzhi/gnyy/entity/SysSetting.java 查看文件

@@ -0,0 +1,42 @@
1
+package com.yunzhi.gnyy.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import lombok.experimental.Accessors;
11
+
12
+import java.io.Serializable;
13
+import java.time.LocalDateTime;
14
+
15
+@Data
16
+@EqualsAndHashCode(callSuper = false)
17
+@Accessors(chain = true)
18
+@ApiModel(value="SysSetting对象", description="系统配置")
19
+public class SysSetting implements Serializable {
20
+
21
+    private static final long serialVersionUID = 1L;
22
+
23
+    @ApiModelProperty(value = "设置ID")
24
+    @TableId(value = "setting_id", type = IdType.INPUT)
25
+    private String settingId;
26
+
27
+    @ApiModelProperty(value = "配置标题")
28
+    private String title;
29
+
30
+    @TableField("`desc`")
31
+    @ApiModelProperty(value = "详细说明")
32
+    private String desc;
33
+
34
+    @ApiModelProperty(value = "配置内容")
35
+    private String content;
36
+
37
+    @ApiModelProperty(value = "状态")
38
+    private Integer status;
39
+
40
+    @ApiModelProperty(value = "创建时间")
41
+    private LocalDateTime createDate;
42
+}

+ 52
- 0
src/main/java/com/yunzhi/gnyy/entity/TaPerson.java 查看文件

@@ -0,0 +1,52 @@
1
+package com.yunzhi.gnyy.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import java.time.LocalDateTime;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import java.io.Serializable;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+import lombok.EqualsAndHashCode;
11
+import lombok.experimental.Accessors;
12
+
13
+/**
14
+ * <p>
15
+ * 人员表
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2022-05-06
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaPerson对象", description="人员表")
25
+public class TaPerson implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "用户ID")
30
+    @TableId(value = "person_id", type = IdType.UUID)
31
+    private String personId;
32
+
33
+    @ApiModelProperty(value = "用户名")
34
+    private String personName;
35
+
36
+    @ApiModelProperty(value = "手机号")
37
+    private String phone;
38
+
39
+    @ApiModelProperty(value = "身份证号码")
40
+    private String idNo;
41
+
42
+    @ApiModelProperty(value = "科室名称")
43
+    private String deptName;
44
+
45
+    @ApiModelProperty(value = "状态")
46
+    private Integer status;
47
+
48
+    @ApiModelProperty(value = "创建时间")
49
+    private LocalDateTime createDate;
50
+
51
+
52
+}

+ 58
- 0
src/main/java/com/yunzhi/gnyy/entity/WxUser.java 查看文件

@@ -0,0 +1,58 @@
1
+package com.yunzhi.gnyy.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import java.time.LocalDateTime;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import java.io.Serializable;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+import lombok.EqualsAndHashCode;
11
+import lombok.experimental.Accessors;
12
+
13
+/**
14
+ * <p>
15
+ * 微信用户
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2022-05-06
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="WxUser对象", description="微信用户")
25
+public class WxUser implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "用户ID")
30
+    @TableId(value = "user_id", type = IdType.UUID)
31
+    private String userId;
32
+
33
+    @ApiModelProperty(value = "APPID")
34
+    private String appId;
35
+
36
+    @ApiModelProperty(value = "openid")
37
+    private String openid;
38
+
39
+    @ApiModelProperty(value = "昵称")
40
+    private String nickName;
41
+
42
+    @ApiModelProperty(value = "头像")
43
+    private String avatar;
44
+
45
+    @ApiModelProperty(value = "手机号")
46
+    private String phone;
47
+
48
+    @ApiModelProperty(value = "关联人员")
49
+    private String personId;
50
+
51
+    @ApiModelProperty(value = "状态")
52
+    private Integer status;
53
+
54
+    @ApiModelProperty(value = "创建时间")
55
+    private LocalDateTime createDate;
56
+
57
+
58
+}

+ 30
- 0
src/main/java/com/yunzhi/gnyy/exception/GlobalExceptionHandler.java 查看文件

@@ -0,0 +1,30 @@
1
+package com.yunzhi.gnyy.exception;
2
+
3
+import cn.dev33.satoken.exception.SaTokenException;
4
+import com.yunzhi.gnyy.common.ResponseBean;
5
+import lombok.extern.slf4j.Slf4j;
6
+import org.springframework.web.bind.annotation.ExceptionHandler;
7
+import org.springframework.web.bind.annotation.ResponseBody;
8
+import org.springframework.web.bind.annotation.RestControllerAdvice;
9
+
10
+@Slf4j
11
+@RestControllerAdvice
12
+public class GlobalExceptionHandler {
13
+
14
+    @ResponseBody
15
+    @ExceptionHandler(Exception.class)
16
+    public ResponseBean handleException(Exception e){
17
+        e.printStackTrace();
18
+
19
+        if (e instanceof SaTokenException) {
20
+            return ResponseBean.error("无权或者未登录", ResponseBean.ERROR_UNAUTHORIZED);
21
+        }
22
+
23
+        String err = e.getMessage();
24
+        if (err.contains("java")) {
25
+            err = "系统内部异常";
26
+        }
27
+
28
+        return ResponseBean.error(err, ResponseBean.ERROR_UNAVAILABLE);
29
+    }
30
+}

+ 80
- 0
src/main/java/com/yunzhi/gnyy/log/MysqlAppender.java 查看文件

@@ -0,0 +1,80 @@
1
+package com.yunzhi.gnyy.log;
2
+
3
+import ch.qos.logback.core.UnsynchronizedAppenderBase;
4
+import ch.qos.logback.core.db.ConnectionSource;
5
+import ch.qos.logback.core.encoder.Encoder;
6
+
7
+import java.sql.Connection;
8
+import java.sql.PreparedStatement;
9
+import java.util.Arrays;
10
+
11
+import static ch.qos.logback.core.db.DBHelper.closeStatement;
12
+
13
+public class MysqlAppender<E> extends UnsynchronizedAppenderBase<E> {
14
+    protected ConnectionSource connectionSource;
15
+    protected Encoder<E> encoder;
16
+    protected String app = "shigongli";
17
+
18
+    @Override
19
+    public void start() {
20
+        if (connectionSource == null) {
21
+            throw new IllegalStateException("MysqlAppender cannot function without a connection source");
22
+        }
23
+
24
+        super.start();
25
+    }
26
+
27
+    public ConnectionSource getConnectionSource() {
28
+        return connectionSource;
29
+    }
30
+
31
+    public void setConnectionSource(ConnectionSource connectionSource) {
32
+        this.connectionSource = connectionSource;
33
+    }
34
+
35
+    @Override
36
+    protected void append(E event) {
37
+        Connection connection = null;
38
+        PreparedStatement insertStatement = null;
39
+
40
+        try {
41
+            connection = connectionSource.getConnection();
42
+            connection.setAutoCommit(false);
43
+            insertStatement = connection.prepareStatement(getInsertSQL());
44
+
45
+            synchronized (this) {
46
+                byte[] logContent = this.encoder.encode(event);
47
+                insertStatement.setBytes(1, logContent);
48
+                insertStatement.execute();
49
+                closeStatement(insertStatement);
50
+            }
51
+
52
+            connection.commit();
53
+        } catch (Throwable sqle) {
54
+            addError("problem appending event", sqle);
55
+        }
56
+
57
+    }
58
+
59
+    public Encoder<E> getEncoder() {
60
+        return encoder;
61
+    }
62
+
63
+    public void setEncoder(Encoder<E> encoder) {
64
+        this.encoder = encoder;
65
+    }
66
+
67
+    @Override
68
+    public void stop() {
69
+        super.stop();
70
+    }
71
+
72
+    private String getInsertSQL() {
73
+        String tableName = "ta_"+app;
74
+        String[] columns = {"log"};
75
+        String[] signs = Arrays.stream(columns).map(x -> "?").toArray(String[]::new);
76
+        String sql = String.format("INSERT INTO %s (%s) values (%s)", tableName, String.join(",", columns), String.join(",", signs));
77
+//        System.out.println(sql);
78
+        return sql;
79
+    }
80
+}

+ 18
- 0
src/main/java/com/yunzhi/gnyy/mapper/BdsOrganizationMapper.java 查看文件

@@ -0,0 +1,18 @@
1
+package com.yunzhi.gnyy.mapper;
2
+
3
+import com.yunzhi.gnyy.entity.BdsOrganization;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 组织机构 Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2022-05-06
14
+ */
15
+@Mapper
16
+public interface BdsOrganizationMapper extends BaseMapper<BdsOrganization> {
17
+
18
+}

+ 9
- 0
src/main/java/com/yunzhi/gnyy/mapper/SysSettingMapper.java 查看文件

@@ -0,0 +1,9 @@
1
+package com.yunzhi.gnyy.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.yunzhi.gnyy.entity.SysSetting;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+@Mapper
8
+public interface SysSettingMapper extends BaseMapper<SysSetting> {
9
+}

+ 18
- 0
src/main/java/com/yunzhi/gnyy/mapper/TaPersonMapper.java 查看文件

@@ -0,0 +1,18 @@
1
+package com.yunzhi.gnyy.mapper;
2
+
3
+import com.yunzhi.gnyy.entity.TaPerson;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 人员表 Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2022-05-06
14
+ */
15
+@Mapper
16
+public interface TaPersonMapper extends BaseMapper<TaPerson> {
17
+
18
+}

+ 18
- 0
src/main/java/com/yunzhi/gnyy/mapper/WxUserMapper.java 查看文件

@@ -0,0 +1,18 @@
1
+package com.yunzhi.gnyy.mapper;
2
+
3
+import com.yunzhi.gnyy.entity.WxUser;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 微信用户 Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2022-05-06
14
+ */
15
+@Mapper
16
+public interface WxUserMapper extends BaseMapper<WxUser> {
17
+
18
+}

+ 26
- 0
src/main/java/com/yunzhi/gnyy/service/IBaseService.java 查看文件

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

+ 15
- 0
src/main/java/com/yunzhi/gnyy/service/IBdsOrganizationService.java 查看文件

@@ -0,0 +1,15 @@
1
+package com.yunzhi.gnyy.service;
2
+
3
+import com.yunzhi.gnyy.entity.BdsOrganization;
4
+
5
+/**
6
+ * <p>
7
+ * 组织机构 服务类
8
+ * </p>
9
+ *
10
+ * @author yansen
11
+ * @since 2022-05-06
12
+ */
13
+public interface IBdsOrganizationService extends IBaseService<BdsOrganization> {
14
+
15
+}

+ 6
- 0
src/main/java/com/yunzhi/gnyy/service/ISysSettingService.java 查看文件

@@ -0,0 +1,6 @@
1
+package com.yunzhi.gnyy.service;
2
+
3
+import com.yunzhi.gnyy.entity.SysSetting;
4
+
5
+public interface ISysSettingService extends IBaseService<SysSetting> {
6
+}

+ 15
- 0
src/main/java/com/yunzhi/gnyy/service/ITaPersonService.java 查看文件

@@ -0,0 +1,15 @@
1
+package com.yunzhi.gnyy.service;
2
+
3
+import com.yunzhi.gnyy.entity.TaPerson;
4
+
5
+/**
6
+ * <p>
7
+ * 人员表 服务类
8
+ * </p>
9
+ *
10
+ * @author yansen
11
+ * @since 2022-05-06
12
+ */
13
+public interface ITaPersonService extends IBaseService<TaPerson> {
14
+
15
+}

+ 15
- 0
src/main/java/com/yunzhi/gnyy/service/IWxUserService.java 查看文件

@@ -0,0 +1,15 @@
1
+package com.yunzhi.gnyy.service;
2
+
3
+import com.yunzhi.gnyy.entity.WxUser;
4
+
5
+/**
6
+ * <p>
7
+ * 微信用户 服务类
8
+ * </p>
9
+ *
10
+ * @author yansen
11
+ * @since 2022-05-06
12
+ */
13
+public interface IWxUserService extends IBaseService<WxUser> {
14
+
15
+}

+ 109
- 0
src/main/java/com/yunzhi/gnyy/service/impl/BaseServiceImpl.java 查看文件

@@ -0,0 +1,109 @@
1
+package com.yunzhi.gnyy.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import com.baomidou.mybatisplus.core.metadata.TableInfo;
7
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
+import com.baomidou.mybatisplus.extension.toolkit.SqlHelper;
9
+import com.yunzhi.gnyy.common.Constants;
10
+import com.yunzhi.gnyy.service.IBaseService;
11
+
12
+import java.io.Serializable;
13
+
14
+public class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements IBaseService<T> {
15
+    @Override
16
+    public boolean removeLogicById(Serializable id) {
17
+
18
+        TableInfo tableInfo = SqlHelper.table(currentModelClass());
19
+        UpdateWrapper<T> updateWrapper = new UpdateWrapper<>();
20
+        updateWrapper.set("status", -1)
21
+                .eq(tableInfo.getKeyColumn(), id);
22
+
23
+        return update(updateWrapper);
24
+    }
25
+
26
+    @Override
27
+    public boolean removeBy(String column, Object value, boolean notDelete) {
28
+        if (notDelete) {
29
+            UpdateWrapper<T> updateWrapper = new UpdateWrapper<>();
30
+            updateWrapper.set("status", -1);
31
+            updateWrapper.eq(column, value);
32
+            return update(updateWrapper);
33
+        } else {
34
+            QueryWrapper<T> queryWrapper = new QueryWrapper<>();
35
+            queryWrapper.eq(column, value);
36
+            return remove(queryWrapper);
37
+        }
38
+    }
39
+
40
+    @Override
41
+    public boolean canAccessData(Serializable id, String userId) {
42
+//        if (Constants.ADMIN_ID.equals(userId)) return true;
43
+//
44
+//        TableInfo tableInfo = SqlHelper.table(currentModelClass());
45
+//
46
+//        String t = tableInfo.getTableName();
47
+////        String k = tableInfo.getKeyColumn();
48
+//        String kAlias = t + ".org_id";
49
+//
50
+//        String joinSQL = "INNER JOIN sys_user_data_scope s ON ( "+ kAlias +" = s.org_id OR "+t+".create_user = s.user_id )";
51
+//        String whereSQL = "WHERE " + kAlias + " = '"+ id +"' AND s.user_id = '" + userId + "'";
52
+//
53
+//        String sql = joinSQL + " " + whereSQL;
54
+//
55
+//        QueryWrapper<T> wrapper = new QueryWrapper<>();
56
+//        wrapper.last(sql);
57
+//        return count(wrapper) > 0;
58
+        return true;
59
+    }
60
+
61
+    @Override
62
+    public boolean remvoeWithDataScope(Serializable id, String userId) {
63
+        TableInfo tableInfo = SqlHelper.table(currentModelClass());
64
+
65
+        String t = tableInfo.getTableName();
66
+        String k = tableInfo.getKeyColumn();
67
+        String kAlias = t + "." + k;
68
+
69
+        String joinSQL = "INNER JOIN sys_user_data_scope s ON ( "+ kAlias +" = s.org_id OR "+t+".create_user = s.user_id )";
70
+        String setSQL = "SET status = -1";
71
+        String whereSQL = "WHERE " + kAlias + " = '"+ id +"' AND s.user_id = '" + userId + "'";
72
+
73
+        String sql = joinSQL + " " + setSQL + " " + whereSQL;
74
+
75
+        UpdateWrapper<T> wrapper = new UpdateWrapper<>();
76
+        wrapper.last(sql);
77
+        return update(wrapper);
78
+    }
79
+
80
+    @Override
81
+    public int countBy(String column, Object value, boolean notDelete) {
82
+        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
83
+        queryWrapper.eq(column, value);
84
+        queryWrapper.gt(notDelete, "status", -1);
85
+
86
+        return count(queryWrapper);
87
+    }
88
+
89
+    @Override
90
+    public T getByButNot(String column, Object value, String col, Object val, boolean notDelete) {
91
+        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
92
+        queryWrapper.eq(column, value);
93
+        queryWrapper.ne(col, val);
94
+        queryWrapper.gt(notDelete, "status", -1);
95
+        queryWrapper.last("limit 1");
96
+
97
+        return getOne(queryWrapper);
98
+    }
99
+
100
+    @Override
101
+    public T getExistBy(String column, Object value, boolean normal, boolean notDelete) {
102
+        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
103
+        queryWrapper.eq(column, value);
104
+        queryWrapper.eq(normal, "status", 1);
105
+        queryWrapper.gt(notDelete, "status", -1);
106
+        queryWrapper.last("limit 1");
107
+        return getOne(queryWrapper);
108
+    }
109
+}

+ 19
- 0
src/main/java/com/yunzhi/gnyy/service/impl/BdsOrganizationServiceImpl.java 查看文件

@@ -0,0 +1,19 @@
1
+package com.yunzhi.gnyy.service.impl;
2
+
3
+import com.yunzhi.gnyy.entity.BdsOrganization;
4
+import com.yunzhi.gnyy.mapper.BdsOrganizationMapper;
5
+import com.yunzhi.gnyy.service.IBdsOrganizationService;
6
+import org.springframework.stereotype.Service;
7
+
8
+/**
9
+ * <p>
10
+ * 组织机构 服务实现类
11
+ * </p>
12
+ *
13
+ * @author yansen
14
+ * @since 2022-05-06
15
+ */
16
+@Service
17
+public class BdsOrganizationServiceImpl extends BaseServiceImpl<BdsOrganizationMapper, BdsOrganization> implements IBdsOrganizationService {
18
+
19
+}

+ 23
- 0
src/main/java/com/yunzhi/gnyy/service/impl/ManagerServiceImpl.java 查看文件

@@ -0,0 +1,23 @@
1
+package com.yunzhi.gnyy.service.impl;
2
+
3
+import cn.dev33.satoken.stp.StpInterface;
4
+import org.springframework.stereotype.Service;
5
+
6
+import java.util.ArrayList;
7
+import java.util.List;
8
+
9
+@Service
10
+public class ManagerServiceImpl implements StpInterface {
11
+
12
+
13
+    @Override
14
+    public List<String> getRoleList(Object loginId, String loginType) {
15
+        return new ArrayList<>();
16
+    }
17
+
18
+    @Override
19
+    public List<String> getPermissionList(Object loginId, String loginType) {
20
+        return new ArrayList<>();
21
+    }
22
+
23
+}

+ 10
- 0
src/main/java/com/yunzhi/gnyy/service/impl/SysSettingServiceImpl.java 查看文件

@@ -0,0 +1,10 @@
1
+package com.yunzhi.gnyy.service.impl;
2
+
3
+import com.yunzhi.gnyy.entity.SysSetting;
4
+import com.yunzhi.gnyy.mapper.SysSettingMapper;
5
+import com.yunzhi.gnyy.service.ISysSettingService;
6
+import org.springframework.stereotype.Service;
7
+
8
+@Service
9
+public class SysSettingServiceImpl extends BaseServiceImpl<SysSettingMapper, SysSetting> implements ISysSettingService {
10
+}

+ 19
- 0
src/main/java/com/yunzhi/gnyy/service/impl/TaPersonServiceImpl.java 查看文件

@@ -0,0 +1,19 @@
1
+package com.yunzhi.gnyy.service.impl;
2
+
3
+import com.yunzhi.gnyy.entity.TaPerson;
4
+import com.yunzhi.gnyy.mapper.TaPersonMapper;
5
+import com.yunzhi.gnyy.service.ITaPersonService;
6
+import org.springframework.stereotype.Service;
7
+
8
+/**
9
+ * <p>
10
+ * 人员表 服务实现类
11
+ * </p>
12
+ *
13
+ * @author yansen
14
+ * @since 2022-05-06
15
+ */
16
+@Service
17
+public class TaPersonServiceImpl extends BaseServiceImpl<TaPersonMapper, TaPerson> implements ITaPersonService {
18
+
19
+}

+ 19
- 0
src/main/java/com/yunzhi/gnyy/service/impl/WxUserServiceImpl.java 查看文件

@@ -0,0 +1,19 @@
1
+package com.yunzhi.gnyy.service.impl;
2
+
3
+import com.yunzhi.gnyy.entity.WxUser;
4
+import com.yunzhi.gnyy.mapper.WxUserMapper;
5
+import com.yunzhi.gnyy.service.IWxUserService;
6
+import org.springframework.stereotype.Service;
7
+
8
+/**
9
+ * <p>
10
+ * 微信用户 服务实现类
11
+ * </p>
12
+ *
13
+ * @author yansen
14
+ * @since 2022-05-06
15
+ */
16
+@Service
17
+public class WxUserServiceImpl extends BaseServiceImpl<WxUserMapper, WxUser> implements IWxUserService {
18
+
19
+}

+ 22
- 0
src/main/java/com/yunzhi/gnyy/vo/LoginParam.java 查看文件

@@ -0,0 +1,22 @@
1
+package com.yunzhi.gnyy.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 loginType;
13
+
14
+    @ApiModelProperty("code")
15
+    String code;
16
+
17
+    @ApiModelProperty("用户名")
18
+    String userName;
19
+
20
+    @ApiModelProperty("密码, MD5 加密后数据")
21
+    String password;
22
+}

+ 17
- 0
src/main/java/com/yunzhi/gnyy/vo/PhoneParam.java 查看文件

@@ -0,0 +1,17 @@
1
+package com.yunzhi.gnyy.vo;
2
+
3
+
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+
8
+@ApiModel(value = "手机号信息", description = "手机号信息")
9
+@Data
10
+public class PhoneParam {
11
+
12
+    @ApiModelProperty("手机号")
13
+    private String phone;
14
+
15
+    @ApiModelProperty("验证码")
16
+    private String captcha;
17
+}

+ 26
- 0
src/main/java/com/yunzhi/gnyy/vo/WxMaAuthParam.java 查看文件

@@ -0,0 +1,26 @@
1
+package com.yunzhi.gnyy.vo;
2
+
3
+
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+
8
+@ApiModel(value = "微信小程序授权", description = "微信小程序授权参数")
9
+@Data
10
+public class WxMaAuthParam {
11
+
12
+    @ApiModelProperty("signature")
13
+    String signature;
14
+
15
+    @ApiModelProperty("rawData")
16
+    String rawData;
17
+
18
+    @ApiModelProperty("encryptedData")
19
+    String encryptedData;
20
+
21
+    @ApiModelProperty("iv")
22
+    String iv;
23
+
24
+    @ApiModelProperty("sessionKey")
25
+    String sessionKey;
26
+}

+ 32
- 0
src/main/java/com/yunzhi/gnyy/vo/WxMaPreload.java 查看文件

@@ -0,0 +1,32 @@
1
+package com.yunzhi.gnyy.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 WxMaPreload {
11
+
12
+    @ApiModelProperty("小程序标识")
13
+    String appid;
14
+
15
+    @ApiModelProperty("用户设置的 TOKEN")
16
+    String token;
17
+
18
+    @ApiModelProperty("用户登录凭证")
19
+    String code;
20
+
21
+    @ApiModelProperty("时间戳,微信客户端发起请求的时间")
22
+    Integer timestamp;
23
+
24
+    @ApiModelProperty("打开小程序的路径")
25
+    String path;
26
+
27
+    @ApiModelProperty("打开小程序的query")
28
+    String query;
29
+
30
+    @ApiModelProperty("打开小程序的场景值")
31
+    Integer scene;
32
+}

+ 16
- 0
src/main/resources/application-dev.yml 查看文件

@@ -0,0 +1,16 @@
1
+###
2
+spring:
3
+  servlet:
4
+    multipart:
5
+      max-file-size: 10MB
6
+      max-request-size: 50MB
7
+  datasource:
8
+    url: jdbc:mysql://110.40.183.156:3306/lyg_gnyy?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
9
+    username: lyg_gnyy
10
+    password: gnyy@ABCD1234
11
+
12
+###
13
+logging:
14
+  level:
15
+    root: info
16
+    springfox: info

+ 11
- 0
src/main/resources/application-prod.yml 查看文件

@@ -0,0 +1,11 @@
1
+###
2
+spring:
3
+  servlet:
4
+    multipart:
5
+      max-file-size: 10MB
6
+      max-request-size: 50MB
7
+  datasource:
8
+    url: jdbc:mysql://110.40.183.156:3306/lyg_gnyy?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
9
+    username: lyg_gnyy
10
+    password: gnyy@ABCD1234
11
+

+ 52
- 0
src/main/resources/application.yml 查看文件

@@ -0,0 +1,52 @@
1
+###
2
+server:
3
+  port: 9000
4
+  servlet:
5
+    context-path: /api
6
+
7
+# Sa-Token配置
8
+sa-token:
9
+  # jwt秘钥
10
+  jwt-secret-key: Q920tdPkkDxnSv4dd6cqE6jNDT2OKT7L
11
+  # token名称 (同时也是cookie名称)
12
+  token-name: Authorization
13
+  # token有效期,单位s 默认30天, -1代表永不过期
14
+  timeout: 2592000
15
+  # token临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
16
+  activity-timeout: -1
17
+  # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
18
+  is-concurrent: true
19
+  # 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
20
+  is-share: false
21
+  # token风格
22
+  token-style: uuid
23
+  # 是否输出操作日志
24
+  is-log: false
25
+
26
+###
27
+mybatis-plus:
28
+  configuration:
29
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
30
+    call-setters-on-nulls: true
31
+  mapper-locations: classpath:mapper/**/*.xml
32
+
33
+###
34
+weixin:
35
+  miniapp:
36
+    appid: wxd6f47a9bb3052175
37
+    secret: 28f33b6bbc0f778c11a0bb234a7d6d4e
38
+    token:
39
+    aesKey:
40
+    msgDataFormat: JSON
41
+
42
+###
43
+spring:
44
+  application:
45
+    name: demo
46
+#  jackson:
47
+#    date-format: yyyy-MM-dd HH:mm:ss
48
+#    time-zone: GMT+8
49
+  profiles:
50
+    active: @profileActive@
51
+
52
+

+ 31
- 0
src/main/resources/logback.xml.bak 查看文件

@@ -0,0 +1,31 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<configuration>
3
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
4
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
5
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
6
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
7
+        </encoder>
8
+    </appender>
9
+    <appender name="LOGDB" class="com.yunzhi.dianyang.log.MysqlAppender">
10
+        <connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">
11
+            <driverClass>com.mysql.cj.jdbc.Driver</driverClass>
12
+            <url>jdbc:mysql://rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com:3306/yz_questions</url>
13
+            <user>yz_questions</user>
14
+            <password>questions@1234</password>
15
+        </connectionSource>
16
+        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
17
+            <!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
18
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
19
+        </encoder>
20
+    </appender>
21
+
22
+    <logger name="com.apache.ibatis" level="TRACE"/>
23
+    <logger name="java.sql.Connection" level="DEBUG"/>
24
+    <logger name="java.sql.Statement" level="DEBUG"/>
25
+    <logger name="java.sql.PreparedStatement" level="DEBUG"/>
26
+
27
+    <root level="INFO">
28
+        <appender-ref ref="STDOUT" />
29
+        <appender-ref ref="LOGDB" />
30
+    </root>
31
+</configuration>

+ 5
- 0
src/main/resources/mapper/BdsOrganizationMapper.xml 查看文件

@@ -0,0 +1,5 @@
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.gnyy.mapper.BdsOrganizationMapper">
4
+
5
+</mapper>

+ 5
- 0
src/main/resources/mapper/SysSettingMapper.xml 查看文件

@@ -0,0 +1,5 @@
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.gnyy.mapper.SysSettingMapper">
4
+
5
+</mapper>

+ 5
- 0
src/main/resources/mapper/TaPersonMapper.xml 查看文件

@@ -0,0 +1,5 @@
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.gnyy.mapper.TaPersonMapper">
4
+
5
+</mapper>

+ 5
- 0
src/main/resources/mapper/WxUserMapper.xml 查看文件

@@ -0,0 +1,5 @@
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.gnyy.mapper.WxUserMapper">
4
+
5
+</mapper>

+ 13
- 0
src/test/java/com/yunzhi/demo/SpringApplicationTests.java 查看文件

@@ -0,0 +1,13 @@
1
+package com.yunzhi.demo;
2
+
3
+import org.junit.jupiter.api.Test;
4
+import org.springframework.boot.test.context.SpringBootTest;
5
+
6
+@SpringBootTest
7
+class SpringApplicationTests {
8
+
9
+	@Test
10
+	void contextLoads() {
11
+	}
12
+
13
+}