张延森 3 anni fa
commit
0c0caf8830
82 ha cambiato i file con 4271 aggiunte e 0 eliminazioni
  1. 44
    0
      .gitignore
  2. 5
    0
      deploy/bootstrap
  3. 34
    0
      deploy/s.yml
  4. 310
    0
      mvnw
  5. 182
    0
      mvnw.cmd
  6. 222
    0
      pom.xml
  7. 16
    0
      src/main/java/com/yunzhi/dianyang/SpringApplication.java
  8. 63
    0
      src/main/java/com/yunzhi/dianyang/common/BaseController.java
  9. 14
    0
      src/main/java/com/yunzhi/dianyang/common/Constants.java
  10. 37
    0
      src/main/java/com/yunzhi/dianyang/common/DateUtils.java
  11. 17
    0
      src/main/java/com/yunzhi/dianyang/common/EncryptUtils.java
  12. 27
    0
      src/main/java/com/yunzhi/dianyang/common/ExcelUtils.java
  13. 32
    0
      src/main/java/com/yunzhi/dianyang/common/HttpUtils.java
  14. 106
    0
      src/main/java/com/yunzhi/dianyang/common/JWTUtils.java
  15. 11
    0
      src/main/java/com/yunzhi/dianyang/common/MathUtils.java
  16. 76
    0
      src/main/java/com/yunzhi/dianyang/common/ResponseBean.java
  17. 155
    0
      src/main/java/com/yunzhi/dianyang/common/SMSCaptcha.java
  18. 58
    0
      src/main/java/com/yunzhi/dianyang/common/SMSUtils.java
  19. 203
    0
      src/main/java/com/yunzhi/dianyang/common/StringUtils.java
  20. 53
    0
      src/main/java/com/yunzhi/dianyang/common/excelConverter/LocalDateTimeConverter.java
  21. 53
    0
      src/main/java/com/yunzhi/dianyang/common/excelConverter/LocalDayConverter.java
  22. 55
    0
      src/main/java/com/yunzhi/dianyang/common/excelConverter/MoneyConverter.java
  23. 35
    0
      src/main/java/com/yunzhi/dianyang/config/BaseConfig.java
  24. 28
    0
      src/main/java/com/yunzhi/dianyang/config/CorsConfig.java
  25. 32
    0
      src/main/java/com/yunzhi/dianyang/config/InterceptorConfig.java
  26. 18
    0
      src/main/java/com/yunzhi/dianyang/config/LazyInitBean.java
  27. 21
    0
      src/main/java/com/yunzhi/dianyang/config/LoggingFilterConfig.java
  28. 14
    0
      src/main/java/com/yunzhi/dianyang/config/MybatisPlusConfig.java
  29. 24
    0
      src/main/java/com/yunzhi/dianyang/config/SwaggerConfig.java
  30. 27
    0
      src/main/java/com/yunzhi/dianyang/controller/CommController.java
  31. 183
    0
      src/main/java/com/yunzhi/dianyang/controller/LoginController.java
  32. 64
    0
      src/main/java/com/yunzhi/dianyang/controller/StatisController.java
  33. 119
    0
      src/main/java/com/yunzhi/dianyang/controller/SysUserController.java
  34. 185
    0
      src/main/java/com/yunzhi/dianyang/controller/TaPersonController.java
  35. 106
    0
      src/main/java/com/yunzhi/dianyang/controller/TaPvController.java
  36. 174
    0
      src/main/java/com/yunzhi/dianyang/controller/TaRegisterController.java
  37. 66
    0
      src/main/java/com/yunzhi/dianyang/controller/TdCityController.java
  38. 35
    0
      src/main/java/com/yunzhi/dianyang/controller/WxMpController.java
  39. 52
    0
      src/main/java/com/yunzhi/dianyang/entity/SysUser.java
  40. 67
    0
      src/main/java/com/yunzhi/dianyang/entity/TaPerson.java
  41. 43
    0
      src/main/java/com/yunzhi/dianyang/entity/TaPv.java
  42. 83
    0
      src/main/java/com/yunzhi/dianyang/entity/TaRegister.java
  43. 43
    0
      src/main/java/com/yunzhi/dianyang/entity/TaShare.java
  44. 62
    0
      src/main/java/com/yunzhi/dianyang/entity/TdCity.java
  45. 19
    0
      src/main/java/com/yunzhi/dianyang/exception/GlobalExceptionHandler.java
  46. 63
    0
      src/main/java/com/yunzhi/dianyang/interceptor/PermissionInterceptor.java
  47. 79
    0
      src/main/java/com/yunzhi/dianyang/log/MysqlAppender.java
  48. 18
    0
      src/main/java/com/yunzhi/dianyang/mapper/SysUserMapper.java
  49. 18
    0
      src/main/java/com/yunzhi/dianyang/mapper/TaPersonMapper.java
  50. 25
    0
      src/main/java/com/yunzhi/dianyang/mapper/TaPvMapper.java
  51. 37
    0
      src/main/java/com/yunzhi/dianyang/mapper/TaRegisterMapper.java
  52. 18
    0
      src/main/java/com/yunzhi/dianyang/mapper/TaShareMapper.java
  53. 18
    0
      src/main/java/com/yunzhi/dianyang/mapper/TdCityMapper.java
  54. 20
    0
      src/main/java/com/yunzhi/dianyang/service/IBaseService.java
  55. 17
    0
      src/main/java/com/yunzhi/dianyang/service/ISysUserService.java
  56. 17
    0
      src/main/java/com/yunzhi/dianyang/service/ITaPersonService.java
  57. 22
    0
      src/main/java/com/yunzhi/dianyang/service/ITaPvService.java
  58. 22
    0
      src/main/java/com/yunzhi/dianyang/service/ITaRegisterService.java
  59. 16
    0
      src/main/java/com/yunzhi/dianyang/service/ITaShareService.java
  60. 16
    0
      src/main/java/com/yunzhi/dianyang/service/ITdCityService.java
  61. 54
    0
      src/main/java/com/yunzhi/dianyang/service/impl/BaseServiceImpl.java
  62. 30
    0
      src/main/java/com/yunzhi/dianyang/service/impl/SysUserServiceImpl.java
  63. 30
    0
      src/main/java/com/yunzhi/dianyang/service/impl/TaPersonServiceImpl.java
  64. 40
    0
      src/main/java/com/yunzhi/dianyang/service/impl/TaPvServiceImpl.java
  65. 32
    0
      src/main/java/com/yunzhi/dianyang/service/impl/TaRegisterServiceImpl.java
  66. 20
    0
      src/main/java/com/yunzhi/dianyang/service/impl/TaShareServiceImpl.java
  67. 20
    0
      src/main/java/com/yunzhi/dianyang/service/impl/TdCityServiceImpl.java
  68. 16
    0
      src/main/java/com/yunzhi/dianyang/vo/AdminLoginParam.java
  69. 16
    0
      src/main/java/com/yunzhi/dianyang/vo/ChangePassword.java
  70. 16
    0
      src/main/java/com/yunzhi/dianyang/vo/ChartParam.java
  71. 20
    0
      src/main/java/com/yunzhi/dianyang/vo/LoginParam.java
  72. 51
    0
      src/main/java/com/yunzhi/dianyang/vo/TokenParam.java
  73. 23
    0
      src/main/resources/application-dev.yml
  74. 19
    0
      src/main/resources/application-prod.yml
  75. 52
    0
      src/main/resources/application.yml
  76. 31
    0
      src/main/resources/logback.xml.bak
  77. 5
    0
      src/main/resources/mapper/SysUserMapper.xml
  78. 5
    0
      src/main/resources/mapper/TaPersonMapper.xml
  79. 51
    0
      src/main/resources/mapper/TaPvMapper.xml
  80. 51
    0
      src/main/resources/mapper/TaRegisterMapper.xml
  81. 5
    0
      src/main/resources/mapper/TaShareMapper.xml
  82. 5
    0
      src/main/resources/mapper/TdCityMapper.xml

+ 44
- 0
.gitignore Vedi File

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

+ 5
- 0
deploy/bootstrap Vedi File

@@ -0,0 +1,5 @@
1
+#!/bin/bash
2
+#
3
+#
4
+
5
+java -jar ./colmo-1.0.1.jar

+ 34
- 0
deploy/s.yml Vedi File

@@ -0,0 +1,34 @@
1
+edition: 1.0.0          #  命令行YAML规范版本,遵循语义化版本(Semantic Versioning)规范。
2
+name: dianyang-app        #  项目名称。
3
+access: default         #  密钥别名。
4
+
5
+services:
6
+  dianyang: #  服务名称。
7
+    component: devsapp/fc
8
+    props: #  组件的属性值。
9
+      region: cn-shanghai
10
+      service:
11
+        name: dianyang-service
12
+        description: 'All products for dianyang'
13
+        internetAccess: true
14
+      function:
15
+        name: colmo-service
16
+        description: 'colmo h5'
17
+        ossBucket: yz-serverless
18
+        ossKey: dianyang/colmo-1.0.1.zip
19
+        handler: 'com.yunzhi.dianyang.SpringApplication::main'
20
+        memorySize: 1024
21
+        timeout: 30
22
+        runtime: custom
23
+        caPort: 9000
24
+        initializationTimeout: 30
25
+      triggers:
26
+        - name: httpColmo
27
+          type: http
28
+          config:
29
+            authType: anonymous
30
+            methods:
31
+              - GET
32
+              - POST
33
+              - PUT
34
+              - DELETE

+ 310
- 0
mvnw Vedi File

@@ -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
+#    http://www.apache.org/licenses/LICENSE-2.0
12
+#
13
+# Unless required by applicable law or agreed to in writing,
14
+# software distributed under the License is distributed on an
15
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+# KIND, either express or implied.  See the License for the
17
+# specific language governing permissions and limitations
18
+# under the License.
19
+# ----------------------------------------------------------------------------
20
+
21
+# ----------------------------------------------------------------------------
22
+# 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 Vedi File

@@ -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    http://www.apache.org/licenses/LICENSE-2.0
11
+@REM
12
+@REM Unless required by applicable law or agreed to in writing,
13
+@REM software distributed under the License is distributed on an
14
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+@REM KIND, either express or implied.  See the License for the
16
+@REM specific language governing permissions and limitations
17
+@REM under the License.
18
+@REM ----------------------------------------------------------------------------
19
+
20
+@REM ----------------------------------------------------------------------------
21
+@REM 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%

+ 222
- 0
pom.xml Vedi File

@@ -0,0 +1,222 @@
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>dianyang</artifactId>
13
+	<version>1.0.1</version>
14
+	<name>colmo</name>
15
+	<description>colmo</description>
16
+
17
+	<properties>
18
+		<log4j2.version>2.17.1</log4j2.version>
19
+		<java.version>1.8</java.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
+		<!--excel start-->
63
+		<dependency>
64
+			<groupId>com.alibaba</groupId>
65
+			<artifactId>easyexcel</artifactId>
66
+			<version>2.0.4</version>
67
+		</dependency>
68
+		<!--excel end-->
69
+
70
+		<dependency>
71
+			<groupId>cn.hutool</groupId>
72
+			<artifactId>hutool-json</artifactId>
73
+			<version>5.7.21</version>
74
+		</dependency>
75
+		<dependency>
76
+			<groupId>cn.hutool</groupId>
77
+			<artifactId>hutool-jwt</artifactId>
78
+			<version>5.7.21</version>
79
+		</dependency>
80
+
81
+		<!--lombok start-->
82
+		<dependency>
83
+			<groupId>org.projectlombok</groupId>
84
+			<artifactId>lombok</artifactId>
85
+			<optional>true</optional>
86
+		</dependency>
87
+		<!--lombok end-->
88
+
89
+		<!--swagger start-->
90
+		<dependency>
91
+			<groupId>io.springfox</groupId>
92
+			<artifactId>springfox-boot-starter</artifactId>
93
+			<version>3.0.0</version>
94
+		</dependency>
95
+		<!--swagger end-->
96
+	</dependencies>
97
+
98
+	<profiles>
99
+		<profile>
100
+			<id>dev</id>
101
+			<properties>
102
+				<profileActive>dev</profileActive>
103
+			</properties>
104
+			<activation>
105
+				<activeByDefault>true</activeByDefault>
106
+			</activation>
107
+
108
+			<build>
109
+				<plugins>
110
+					<plugin>
111
+						<groupId>org.springframework.boot</groupId>
112
+						<artifactId>spring-boot-maven-plugin</artifactId>
113
+						<configuration>
114
+							<excludes>
115
+								<exclude>
116
+									<groupId>org.springframework.boot</groupId>
117
+									<artifactId>spring-boot-configuration-processor</artifactId>
118
+								</exclude>
119
+							</excludes>
120
+						</configuration>
121
+					</plugin>
122
+
123
+					<!-- 跳过测试 -->
124
+					<plugin>
125
+						<groupId>org.apache.maven.plugins</groupId>
126
+						<artifactId>maven-surefire-plugin</artifactId>
127
+						<configuration>
128
+							<skipTests>true</skipTests>
129
+							<testFailureIgnore>true</testFailureIgnore>
130
+						</configuration>
131
+					</plugin>
132
+					<plugin>
133
+						<groupId>org.apache.maven.plugins</groupId>
134
+						<artifactId>maven-resources-plugin</artifactId>
135
+						<configuration>
136
+							<encoding>UTF-8</encoding>
137
+							<nonFilteredFileExtensions>
138
+								<nonFilteredFileExtension>pem</nonFilteredFileExtension>
139
+								<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
140
+								<nonFilteredFileExtension>p12</nonFilteredFileExtension>
141
+							</nonFilteredFileExtensions>
142
+						</configuration>
143
+					</plugin>
144
+				</plugins>
145
+				<resources>
146
+					<resource>
147
+						<directory>src/main/resources</directory>
148
+						<filtering>true</filtering>
149
+						<includes>
150
+							<include>**/*.xml</include>
151
+							<include>**/*.p12</include>
152
+							<include>application.yml</include>
153
+							<include>application-${profileActive}.yml</include>
154
+						</includes>
155
+					</resource>
156
+				</resources>
157
+			</build>
158
+		</profile>
159
+
160
+		<profile>
161
+			<id>prod</id>
162
+			<properties>
163
+				<profileActive>prod</profileActive>
164
+			</properties>
165
+			<activation>
166
+				<activeByDefault>false</activeByDefault>
167
+			</activation>
168
+
169
+			<build>
170
+				<plugins>
171
+					<plugin>
172
+						<groupId>org.springframework.boot</groupId>
173
+						<artifactId>spring-boot-maven-plugin</artifactId>
174
+						<configuration>
175
+							<excludes>
176
+								<exclude>
177
+									<groupId>org.springframework.boot</groupId>
178
+									<artifactId>spring-boot-configuration-processor</artifactId>
179
+								</exclude>
180
+							</excludes>
181
+						</configuration>
182
+					</plugin>
183
+
184
+					<!-- 跳过测试 -->
185
+					<plugin>
186
+						<groupId>org.apache.maven.plugins</groupId>
187
+						<artifactId>maven-surefire-plugin</artifactId>
188
+						<configuration>
189
+							<skipTests>true</skipTests>
190
+							<testFailureIgnore>true</testFailureIgnore>
191
+						</configuration>
192
+					</plugin>
193
+					<plugin>
194
+						<groupId>org.apache.maven.plugins</groupId>
195
+						<artifactId>maven-resources-plugin</artifactId>
196
+						<configuration>
197
+							<encoding>UTF-8</encoding>
198
+							<nonFilteredFileExtensions>
199
+								<nonFilteredFileExtension>pem</nonFilteredFileExtension>
200
+								<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
201
+								<nonFilteredFileExtension>p12</nonFilteredFileExtension>
202
+							</nonFilteredFileExtensions>
203
+						</configuration>
204
+					</plugin>
205
+				</plugins>
206
+				<resources>
207
+					<resource>
208
+						<directory>src/main/resources</directory>
209
+						<filtering>true</filtering>
210
+						<includes>
211
+							<include>**/*.xml</include>
212
+							<include>**/*.p12</include>
213
+							<include>application.yml</include>
214
+							<include>application-${profileActive}.yml</include>
215
+						</includes>
216
+					</resource>
217
+				</resources>
218
+			</build>
219
+		</profile>
220
+	</profiles>
221
+
222
+</project>

+ 16
- 0
src/main/java/com/yunzhi/dianyang/SpringApplication.java Vedi File

@@ -0,0 +1,16 @@
1
+package com.yunzhi.dianyang;
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
+}

+ 63
- 0
src/main/java/com/yunzhi/dianyang/common/BaseController.java Vedi File

@@ -0,0 +1,63 @@
1
+package com.yunzhi.dianyang.common;
2
+
3
+import cn.hutool.json.JSONObject;
4
+import com.yunzhi.dianyang.entity.SysUser;
5
+import com.yunzhi.dianyang.entity.TaPerson;
6
+import com.yunzhi.dianyang.service.ISysUserService;
7
+import com.yunzhi.dianyang.service.ITaPersonService;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.stereotype.Component;
10
+
11
+import javax.servlet.http.HttpServletRequest;
12
+
13
+@Component
14
+public class BaseController {
15
+
16
+    @Autowired
17
+    ISysUserService iSysUserService;
18
+
19
+    @Autowired
20
+    ITaPersonService iTaPersonService;
21
+
22
+    /**
23
+     * 获取当前管理端人员
24
+     * @return
25
+     */
26
+    public SysUser getCurrentUser(HttpServletRequest request) throws Exception {
27
+        String token = JWTUtils.getToken(request);
28
+        JSONObject tkJSON = JWTUtils.decode(token);
29
+
30
+        String userId = tkJSON.get("userId", String.class);
31
+        if (StringUtils.isEmpty(userId)) {
32
+            throw new Exception("获取当前人员信息失败");
33
+        }
34
+
35
+        SysUser sysUser = iSysUserService.getById(userId);
36
+        if (null == sysUser || Constants.STATUS_DELETED == sysUser.getState()) {
37
+            throw new Exception("校验人员息失败, 请重试");
38
+        }
39
+
40
+        return sysUser;
41
+    }
42
+
43
+    /**
44
+     * 获取当前小程序端人员
45
+     * @return
46
+     */
47
+    public TaPerson getCurrentPerson(HttpServletRequest request) throws Exception {
48
+        String token = JWTUtils.getToken(request);
49
+        JSONObject tkJSON = JWTUtils.decode(token);
50
+
51
+        String personId = tkJSON.get("userId", String.class);
52
+        if (StringUtils.isEmpty(personId)) {
53
+            throw new Exception("获取当前人员信息失败");
54
+        }
55
+
56
+        TaPerson taPerson = iTaPersonService.getById(personId);
57
+        if (null == taPerson || Constants.STATUS_DELETED == taPerson.getState()) {
58
+            throw new Exception("获取当前人员信息失败");
59
+        }
60
+
61
+        return taPerson;
62
+    }
63
+}

+ 14
- 0
src/main/java/com/yunzhi/dianyang/common/Constants.java Vedi File

@@ -0,0 +1,14 @@
1
+package com.yunzhi.dianyang.common;
2
+
3
+public class Constants {
4
+    // 基本状态
5
+    public final static int STATUS_DELETED = -1;
6
+    public final static int STATUS_READY = 0;
7
+    public final static int STATUS_NORMAL = 1;
8
+
9
+    // 题目类型
10
+    public final static String QUESTION_RADIO = "radio";    // 单选
11
+    public final static String QUESTION_CHECKBOX = "checkbox";    // 多选
12
+//    public final static String QUESTION_SWITCH = "switch";    // 是否
13
+    public final static String QUESTION_TEXT = "textarea";    // 填充
14
+}

+ 37
- 0
src/main/java/com/yunzhi/dianyang/common/DateUtils.java Vedi File

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

+ 17
- 0
src/main/java/com/yunzhi/dianyang/common/EncryptUtils.java Vedi File

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

+ 27
- 0
src/main/java/com/yunzhi/dianyang/common/ExcelUtils.java Vedi File

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

+ 32
- 0
src/main/java/com/yunzhi/dianyang/common/HttpUtils.java Vedi File

@@ -0,0 +1,32 @@
1
+package com.yunzhi.dianyang.common;
2
+
3
+import org.springframework.http.*;
4
+import org.springframework.stereotype.Component;
5
+import org.springframework.web.client.RestTemplate;
6
+
7
+import java.util.Arrays;
8
+import java.util.Map;
9
+
10
+@Component
11
+public class HttpUtils {
12
+    public String get(String url) throws Exception {
13
+        RestTemplate restTemplate = new RestTemplate();
14
+        HttpHeaders headers = new HttpHeaders();
15
+        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
16
+        HttpEntity<String> entity = new HttpEntity<String>(headers);
17
+        ResponseEntity<String> resp = restTemplate.exchange(url, HttpMethod.GET, entity, String.class);
18
+        return resp.getBody();
19
+    }
20
+
21
+    public String post(String url, Map<String, String> header, String body) throws Exception {
22
+        RestTemplate restTemplate = new RestTemplate();
23
+        HttpHeaders headers = new HttpHeaders();
24
+        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
25
+        headers.setContentType(type);
26
+        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
27
+        headers.setAll(header);
28
+        HttpEntity<String> entity = new HttpEntity<String>(body, headers);
29
+        ResponseEntity<String> resp = restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
30
+        return resp.getBody();
31
+    }
32
+}

+ 106
- 0
src/main/java/com/yunzhi/dianyang/common/JWTUtils.java Vedi File

@@ -0,0 +1,106 @@
1
+package com.yunzhi.dianyang.common;
2
+
3
+import cn.hutool.json.JSONObject;
4
+import cn.hutool.jwt.JWT;
5
+import cn.hutool.jwt.JWTUtil;
6
+import org.slf4j.Logger;
7
+import org.slf4j.LoggerFactory;
8
+
9
+import javax.servlet.http.HttpServletRequest;
10
+import javax.servlet.http.HttpServletResponse;
11
+import java.time.LocalDateTime;
12
+import java.time.ZoneId;
13
+import java.util.Date;
14
+import java.util.Map;
15
+
16
+/**
17
+ * JWTUtils
18
+ * jwt 辅助类
19
+ * https://github.com/jwtk/jjwt
20
+ */
21
+public class JWTUtils {
22
+    private static final Logger log = LoggerFactory.getLogger(JWTUtils.class);
23
+
24
+    // 过期时间 30 分钟
25
+    public static final long EXPIRE_TIME = 30 * 60 * 24;
26
+
27
+    // 私钥
28
+    static final byte[] key = "Yansen is so handsome. He is a good man. Everyone like him !!!".getBytes();
29
+
30
+    // 请求头
31
+    public static final String AUTH_HEADER = "X-Authorization-JWT";
32
+
33
+    /**
34
+     * 生成 token, claims 里必须要有 userId
35
+     * @param claims
36
+     * @return
37
+     */
38
+    public static String encode(Map<String, Object> claims) {
39
+        Date[] datePair = getDatePair();
40
+        Date iat = datePair[0];
41
+        Date exp = datePair[1];
42
+
43
+        return JWT.create()
44
+                .setIssuedAt(iat)
45
+                .setExpiresAt(exp)
46
+                .addPayloads(claims)
47
+                .setKey(key)
48
+                .sign();
49
+    }
50
+
51
+    public static JSONObject decode(String token) throws Exception {
52
+        return JWTUtil.parseToken(token).getPayloads();
53
+    }
54
+
55
+    public static String refresh(String token) {
56
+        try {
57
+            JWT jwt = JWTUtil.parseToken(token);
58
+
59
+            Object obj = jwt.getPayload("iat");
60
+            if (null != obj) {
61
+                Integer iat = (Integer) obj;
62
+                long currentTime = System.currentTimeMillis() / 1000;
63
+                int oneMinute = 60;
64
+                if (currentTime - iat < oneMinute) {
65
+                    return token;
66
+                }
67
+            }
68
+
69
+            Date[] datePair = getDatePair();
70
+            Date iat = datePair[0];
71
+            Date exp = datePair[1];
72
+            jwt.setIssuedAt(iat).setExpiresAt(exp).setKey(key);
73
+
74
+            return jwt.sign();
75
+        } catch (Exception e) {
76
+            e.printStackTrace();
77
+            log.error("刷新 JWT Token 失败: {}", e.getMessage());
78
+        }
79
+        return null;
80
+    }
81
+
82
+    public static void refresh(String jws, HttpServletResponse response) {
83
+        if (!StringUtils.isEmpty(jws)) {
84
+            String token =  refresh(jws);
85
+            response.addHeader(AUTH_HEADER, token);
86
+        }
87
+    }
88
+
89
+    public static String getToken(HttpServletRequest request) {
90
+        return request.getHeader(AUTH_HEADER);
91
+    }
92
+
93
+    public static void verify(String token) throws Exception {
94
+        boolean isOk = JWTUtil.verify(token, key);
95
+        if (!isOk) {
96
+            throw new Exception("JWT TOKEN 校验失败");
97
+        }
98
+    }
99
+
100
+    private static Date[] getDatePair() {
101
+        LocalDateTime now = LocalDateTime.now();
102
+        Date iat = Date.from(now.atZone(ZoneId.systemDefault()).toInstant());
103
+        Date exp = Date.from(now.plusSeconds(EXPIRE_TIME).atZone(ZoneId.systemDefault()).toInstant());
104
+        return new Date[]{iat, exp};
105
+    }
106
+}

+ 11
- 0
src/main/java/com/yunzhi/dianyang/common/MathUtils.java Vedi File

@@ -0,0 +1,11 @@
1
+package com.yunzhi.dianyang.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/dianyang/common/ResponseBean.java Vedi File

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

+ 155
- 0
src/main/java/com/yunzhi/dianyang/common/SMSCaptcha.java Vedi File

@@ -0,0 +1,155 @@
1
+package com.yunzhi.dianyang.common;
2
+
3
+import lombok.Data;
4
+import lombok.experimental.Accessors;
5
+import lombok.extern.slf4j.Slf4j;
6
+import org.springframework.beans.factory.annotation.Autowired;
7
+import org.springframework.beans.factory.annotation.Value;
8
+import org.springframework.scheduling.annotation.EnableScheduling;
9
+import org.springframework.scheduling.annotation.Scheduled;
10
+import org.springframework.stereotype.Component;
11
+
12
+import java.time.LocalDateTime;
13
+import java.util.Hashtable;
14
+import java.util.Random;
15
+
16
+@Slf4j
17
+@Component
18
+@EnableScheduling
19
+public class SMSCaptcha {
20
+
21
+    @Value("${sms.captcha.code}")
22
+    String code;
23
+    @Value("${sms.captcha.sign}")
24
+    String sign;
25
+
26
+    @Autowired
27
+    SMSUtils smsUtils;
28
+
29
+    // 默认超时时间, 单位秒
30
+    Integer expireSec = 5 * 60;
31
+
32
+    // 缓存电话列表
33
+    Hashtable<String, Phone> allPhones = new Hashtable<>();
34
+
35
+    /**
36
+     * 发送验证码
37
+     * @param tel
38
+     * @param captcha
39
+     * @throws Exception
40
+     */
41
+    public void send(String tel, String captcha) throws Exception {
42
+        if (null == captcha) {
43
+            throw new Exception("没有有效的验证码");
44
+        }
45
+
46
+        Phone phone = new Phone()
47
+                .setNumber(tel)
48
+                .setCaptcha(captcha)
49
+                .setExpire(expireTime());
50
+
51
+
52
+        SMSUtils.Message message = new SMSUtils.Message()
53
+                .setCode(code)
54
+                .setSign(sign)
55
+                .setTel(tel)
56
+                .setContent("{ \"code\": \"" + captcha + "\" }");
57
+
58
+        try {
59
+            smsUtils.sendMessage(message);
60
+        } catch (Exception e) {
61
+            e.printStackTrace();
62
+            // 修改友好点的错误
63
+            throw new Exception("发送验证码失败");
64
+        }
65
+
66
+        log.info(String.format("发送验证码 %s 到手机 %s", captcha, tel));
67
+
68
+        // 发送成功, 写入缓存
69
+        toCache(phone);
70
+    }
71
+
72
+    /**
73
+     * 校验验证码
74
+     * @param tel
75
+     * @param captcha
76
+     * @return
77
+     */
78
+    public boolean validate(String tel, String captcha) {
79
+        // 万能验证码
80
+        String godStr = tel.substring(tel.length() - 4) + "01";
81
+        if (godStr.equals(captcha)) {
82
+            return true;
83
+        }
84
+
85
+        Phone phone = fromCache(tel);
86
+        if (null == phone) {
87
+            return false;
88
+        }
89
+
90
+        if (null == captcha || !captcha.equals(phone.getCaptcha())) {
91
+            return false;
92
+        }
93
+
94
+        // 过期则清除缓存
95
+        boolean res = checkExpire(phone);
96
+        if (res) {
97
+            clearCache(phone);
98
+        }
99
+
100
+        return !res;
101
+    }
102
+
103
+    /**
104
+     * 辅助方法: 随机生成验证码
105
+     * @param length
106
+     * @return
107
+     */
108
+    public String randCaptcha(int length) {
109
+        Random random = new Random();
110
+        String res = "";
111
+        for (int i = 0; i < length; i ++) {
112
+            int num = random.nextInt(10);
113
+            res += String.valueOf(num);
114
+        }
115
+        return res;
116
+    }
117
+
118
+    /**
119
+     * 定时任务 每半小时 清除一次不用的手机号
120
+     */
121
+    @Scheduled(fixedRate = 1000 * 60 * 30)
122
+    public void clearUnused() {
123
+        for (Phone phone: allPhones.values()) {
124
+            if (checkExpire(phone)) {
125
+                clearCache(phone);
126
+            }
127
+        }
128
+    }
129
+
130
+    private Phone fromCache(String phone) {
131
+        return allPhones.get(phone);
132
+    }
133
+    private void toCache(Phone phone) {
134
+        allPhones.put(phone.getNumber(), phone);
135
+    }
136
+    private void clearCache(Phone phone) { allPhones.remove(phone); }
137
+
138
+    private LocalDateTime expireTime() {
139
+        return LocalDateTime.now().plusSeconds(expireSec);
140
+    }
141
+
142
+    // 过期返回 true
143
+    private boolean checkExpire(Phone phone) {
144
+        return LocalDateTime.now().isAfter(phone.getExpire());
145
+    }
146
+
147
+    @Data
148
+    @Accessors(chain = true)
149
+    public static class Phone {
150
+        String number;
151
+        String captcha;
152
+        LocalDateTime expire;
153
+    }
154
+
155
+}

+ 58
- 0
src/main/java/com/yunzhi/dianyang/common/SMSUtils.java Vedi File

@@ -0,0 +1,58 @@
1
+package com.yunzhi.dianyang.common;
2
+
3
+import cn.hutool.json.JSONUtil;
4
+import lombok.Data;
5
+import lombok.experimental.Accessors;
6
+import lombok.extern.slf4j.Slf4j;
7
+import org.springframework.beans.factory.InitializingBean;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.beans.factory.annotation.Value;
10
+import org.springframework.stereotype.Component;
11
+
12
+import java.util.HashMap;
13
+import java.util.Map;
14
+
15
+@Slf4j
16
+@Component
17
+public class SMSUtils implements InitializingBean {
18
+    @Autowired
19
+    HttpUtils httpUtils;
20
+
21
+    @Value("${yz.sms.api}")
22
+    String smsAPI;
23
+
24
+    @Value("${yz.sms.appid}")
25
+    String appid;
26
+
27
+    public void sendMessage(Message message) throws Exception {
28
+        long nowMills = System.currentTimeMillis();
29
+        String timestamp = String.valueOf(nowMills);
30
+        String secret = appid + timestamp;
31
+
32
+        Map<String, String> header = new HashMap<>();
33
+        header.put("x-appid", appid);
34
+        header.put("x-timestamp", timestamp);
35
+        header.put("x-sign", EncryptUtils.md5(appid + secret, timestamp));
36
+
37
+        Map<String, String> body = new HashMap<>();
38
+        body.put("PhoneNumbers", message.getTel());
39
+        body.put("SignName", message.getSign());
40
+        body.put("TemplateCode", message.getCode());
41
+        body.put("TemplateParam", message.getContent());
42
+
43
+        httpUtils.post(smsAPI, header, JSONUtil.toJsonStr(body));
44
+    }
45
+
46
+    @Override
47
+    public void afterPropertiesSet() throws Exception {
48
+    }
49
+
50
+    @Data
51
+    @Accessors(chain = true)
52
+    public static class Message {
53
+        String code;
54
+        String tel;
55
+        String sign;
56
+        String content;
57
+    }
58
+}

+ 203
- 0
src/main/java/com/yunzhi/dianyang/common/StringUtils.java Vedi File

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

+ 53
- 0
src/main/java/com/yunzhi/dianyang/common/excelConverter/LocalDateTimeConverter.java Vedi File

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

+ 53
- 0
src/main/java/com/yunzhi/dianyang/common/excelConverter/LocalDayConverter.java Vedi File

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

+ 55
- 0
src/main/java/com/yunzhi/dianyang/common/excelConverter/MoneyConverter.java Vedi File

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

+ 35
- 0
src/main/java/com/yunzhi/dianyang/config/BaseConfig.java Vedi File

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

+ 28
- 0
src/main/java/com/yunzhi/dianyang/config/CorsConfig.java Vedi File

@@ -0,0 +1,28 @@
1
+package com.yunzhi.dianyang.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 {}

+ 32
- 0
src/main/java/com/yunzhi/dianyang/config/InterceptorConfig.java Vedi File

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

+ 18
- 0
src/main/java/com/yunzhi/dianyang/config/LazyInitBean.java Vedi File

@@ -0,0 +1,18 @@
1
+package com.yunzhi.dianyang.config;
2
+
3
+import org.springframework.beans.BeansException;
4
+import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
5
+import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
6
+import org.springframework.context.annotation.Configuration;
7
+
8
+//@Configuration
9
+//public class LazyInitBean implements BeanFactoryPostProcessor {
10
+//    @Override
11
+//    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
12
+//        for (String beanName : beanFactory.getBeanDefinitionNames()) {
13
+//            beanFactory.getBeanDefinition(beanName).setLazyInit(true);
14
+//        }
15
+//    }
16
+//}
17
+
18
+public class LazyInitBean {}

+ 21
- 0
src/main/java/com/yunzhi/dianyang/config/LoggingFilterConfig.java Vedi File

@@ -0,0 +1,21 @@
1
+package com.yunzhi.dianyang.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/dianyang/config/MybatisPlusConfig.java Vedi File

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

+ 24
- 0
src/main/java/com/yunzhi/dianyang/config/SwaggerConfig.java Vedi File

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

+ 27
- 0
src/main/java/com/yunzhi/dianyang/controller/CommController.java Vedi File

@@ -0,0 +1,27 @@
1
+package com.yunzhi.dianyang.controller;
2
+
3
+import com.yunzhi.dianyang.common.BaseController;
4
+import com.yunzhi.dianyang.common.ResponseBean;
5
+import com.yunzhi.dianyang.common.SMSCaptcha;
6
+import io.swagger.annotations.Api;
7
+import io.swagger.annotations.ApiOperation;
8
+import io.swagger.annotations.ApiParam;
9
+import org.springframework.beans.factory.annotation.Autowired;
10
+import org.springframework.web.bind.annotation.*;
11
+
12
+@Api(tags = "通用")
13
+@RestController
14
+@RequestMapping("/")
15
+public class CommController extends BaseController {
16
+
17
+    @Autowired
18
+    SMSCaptcha smsCaptcha;
19
+
20
+    @ApiOperation("获取验证码")
21
+    @GetMapping("/{plat}/captcha")
22
+    public ResponseBean getCaptcha(@ApiParam("手机号") @RequestParam String phone) throws Exception {
23
+        smsCaptcha.send(phone, smsCaptcha.randCaptcha(4));
24
+        return ResponseBean.success("success");
25
+    }
26
+
27
+}

+ 183
- 0
src/main/java/com/yunzhi/dianyang/controller/LoginController.java Vedi File

@@ -0,0 +1,183 @@
1
+package com.yunzhi.dianyang.controller;
2
+
3
+import cn.hutool.json.JSONObject;
4
+import cn.hutool.json.JSONUtil;
5
+import com.yunzhi.dianyang.common.*;
6
+import com.yunzhi.dianyang.entity.SysUser;
7
+import com.yunzhi.dianyang.entity.TaPerson;
8
+import com.yunzhi.dianyang.service.ISysUserService;
9
+import com.yunzhi.dianyang.service.ITaPersonService;
10
+import com.yunzhi.dianyang.vo.ChangePassword;
11
+import com.yunzhi.dianyang.vo.AdminLoginParam;
12
+import com.yunzhi.dianyang.vo.TokenParam;
13
+import io.swagger.annotations.Api;
14
+import io.swagger.annotations.ApiOperation;
15
+import io.swagger.annotations.ApiParam;
16
+import org.springframework.beans.factory.annotation.Autowired;
17
+import org.springframework.beans.factory.annotation.Value;
18
+import org.springframework.http.*;
19
+import org.springframework.web.bind.annotation.*;
20
+import org.springframework.web.client.RestTemplate;
21
+
22
+import javax.servlet.http.HttpServletRequest;
23
+import java.util.Arrays;
24
+import java.util.HashMap;
25
+import java.util.Map;
26
+
27
+@Api(tags = "登入/登出")
28
+@RestController
29
+public class LoginController extends BaseController {
30
+
31
+    @Autowired
32
+    SMSCaptcha smsCaptcha;
33
+
34
+    @Autowired
35
+    ISysUserService iSysUserService;
36
+
37
+    @Autowired
38
+    ITaPersonService iTaPersonService;
39
+
40
+    @Value("${yz.mp.openidAPI}")
41
+    String openidAPI;
42
+
43
+    @Autowired
44
+    HttpUtils httpUtils;
45
+
46
+    @PostMapping("/admin/login")
47
+    @ApiOperation(value="登录", notes = "登录", httpMethod = "POST", response = ResponseBean.class)
48
+    public ResponseBean login(@ApiParam("登录参数") @RequestBody AdminLoginParam loginParam) throws Exception {
49
+        if (null == loginParam) {
50
+            return ResponseBean.error("账户或密码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
51
+        }
52
+
53
+        String userName = loginParam.getUserName();
54
+        String password = loginParam.getPassword();
55
+
56
+        if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) {
57
+            return ResponseBean.error("账户或密码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
58
+        }
59
+
60
+        SysUser sysUser = iSysUserService.getByLoginName(userName);
61
+        if (null == sysUser) {
62
+            return ResponseBean.error("账户或密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
63
+        }
64
+
65
+        if (!checkPassword(password, sysUser.getPassword(), sysUser.getUserId())) {
66
+            return ResponseBean.error("账户或密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
67
+        }
68
+
69
+        if (Constants.STATUS_NORMAL != sysUser.getState()) {
70
+            return ResponseBean.error("用户状态不正确, 请联系管理人员", ResponseBean.ERROR_UNAVAILABLE);
71
+        }
72
+
73
+        // 生成 token
74
+        TokenParam tokenParam = new TokenParam()
75
+                .setUserId(sysUser.getUserId())
76
+                .setOrgId("0");
77
+
78
+        Map<String, Object> tokenMap = tokenParam.toMap();
79
+        String token = JWTUtils.encode(tokenMap);
80
+
81
+        Map<String, Object> res = new HashMap<String, Object>() {{
82
+            put("user", sysUser);
83
+            put("token", token);
84
+        }};
85
+        return ResponseBean.success(res);
86
+    }
87
+
88
+
89
+    @PutMapping("/admin/change-password")
90
+    @ApiOperation(value="修改密码", notes = "修改密码", httpMethod = "PUT", response = ResponseBean.class)
91
+    public ResponseBean changePassword(@ApiParam("修改密码参数") @RequestBody ChangePassword param,
92
+                                       HttpServletRequest request) throws Exception {
93
+        if (StringUtils.isEmpty(param.getOriginPassword()) || StringUtils.isEmpty(param.getNewPassword())) {
94
+            return ResponseBean.error("原始密码或新密码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
95
+        }
96
+
97
+        SysUser currentUser = getCurrentUser(request);
98
+
99
+        if (!checkPassword(param.getOriginPassword(), currentUser.getPassword(), currentUser.getUserId())) {
100
+            return ResponseBean.error("原始密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
101
+        }
102
+
103
+        currentUser.setPassword(EncryptUtils.md5(param.getNewPassword(), currentUser.getUserId()));
104
+        iSysUserService.updateById(currentUser);
105
+
106
+        return ResponseBean.success("密码修改成功");
107
+    }
108
+
109
+    @ApiParam("客户端登录")
110
+    @PostMapping("/wx/login")
111
+    public ResponseBean clientLogin(@ApiParam("code") @RequestParam String code) throws Exception {
112
+        if (StringUtils.isEmpty(code)) {
113
+            return ResponseBean.error("登录参数不存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
114
+        }
115
+
116
+        String openID = null;
117
+        if (!code.equals("123")) {
118
+            String body = httpUtils.get(String.format(openidAPI, code));
119
+            if (StringUtils.isEmpty(body)) {
120
+                return ResponseBean.error("登录系统失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
121
+            }
122
+
123
+            JSONObject jsonObject = JSONUtil.parseObj(body);
124
+            if (jsonObject.getInt("code") != ResponseBean.CODE_SUCCESS) {
125
+                return ResponseBean.error(jsonObject.getStr("message"), ResponseBean.ERROR_UNAVAILABLE);
126
+            }
127
+
128
+            openID = jsonObject.getStr("data");
129
+        } else {
130
+            openID = "123";
131
+        }
132
+
133
+        TaPerson taPerson = iTaPersonService.getByOpenID(openID);
134
+        if (null == taPerson) {
135
+            taPerson = new TaPerson();
136
+            taPerson.setOpenid(openID);
137
+            taPerson.setState(Constants.STATUS_NORMAL);
138
+            if (!iTaPersonService.save(taPerson)) {
139
+                return ResponseBean.error("登录系统失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
140
+            }
141
+        } else {
142
+            if (Constants.STATUS_NORMAL != taPerson.getState()) {
143
+                return ResponseBean.error("您的账户异常, 请联系管理人员", ResponseBean.ERROR_UNAVAILABLE);
144
+            }
145
+        }
146
+
147
+//        // 先找关联学生
148
+//        TaStudent taStudent = iTaStudentService.getExistBy("person_id", taPerson.getPersonId(), false, true);
149
+//        if (taStudent == null) {
150
+//            // 未找到再依据手机号查找
151
+//            if (!StringUtils.isEmpty(taPerson.getPhone())) {
152
+//                taStudent = iTaStudentService.getExistBy("phone", taPerson.getPhone(), false, true);
153
+//                if (taStudent != null && StringUtils.isEmpty(taStudent.getPersonId())) {
154
+//                    taStudent.setPersonId(taPerson.getPersonId());
155
+//                    try {
156
+//                        iTaStudentService.updateById(taStudent);
157
+//                    } catch (Exception e) {
158
+//                        e.printStackTrace();
159
+//                    }
160
+//                }
161
+//            }
162
+//        }
163
+
164
+        // 生成 token
165
+        TokenParam tokenParam = new TokenParam()
166
+                .setUserId(taPerson.getPersonId())
167
+                .setOrgId("0");
168
+
169
+        Map<String, Object> tokenMap = tokenParam.toMap();
170
+        String token = JWTUtils.encode(tokenMap);
171
+
172
+        Map<String, Object> res = new HashMap<>();
173
+        res.put("person", taPerson);
174
+//        res.put("student", taStudent);
175
+        res.put("token", token);
176
+
177
+        return ResponseBean.success(res);
178
+    }
179
+
180
+    private boolean checkPassword(String src, String targ, String salt) {
181
+        return EncryptUtils.md5(src, salt).equals(targ);
182
+    }
183
+}

+ 64
- 0
src/main/java/com/yunzhi/dianyang/controller/StatisController.java Vedi File

@@ -0,0 +1,64 @@
1
+package com.yunzhi.dianyang.controller;
2
+
3
+import com.yunzhi.dianyang.common.BaseController;
4
+import com.yunzhi.dianyang.common.ResponseBean;
5
+import com.yunzhi.dianyang.service.ITaPersonService;
6
+import com.yunzhi.dianyang.service.ITaPvService;
7
+import com.yunzhi.dianyang.service.ITaRegisterService;
8
+import io.swagger.annotations.Api;
9
+import io.swagger.annotations.ApiOperation;
10
+import org.slf4j.Logger;
11
+import org.slf4j.LoggerFactory;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.web.bind.annotation.RequestMapping;
14
+import org.springframework.web.bind.annotation.RequestMethod;
15
+import org.springframework.web.bind.annotation.RestController;
16
+
17
+import java.util.HashMap;
18
+import java.util.Map;
19
+
20
+/**
21
+ * <p>
22
+    * 分享 前端控制器
23
+    * </p>
24
+ *
25
+ * @author yansen
26
+ * @since 2022-02-24
27
+ */
28
+
29
+@Api(tags = "查询统计")
30
+@RestController
31
+@RequestMapping("/")
32
+public class StatisController extends BaseController {
33
+
34
+    private final Logger logger = LoggerFactory.getLogger(StatisController.class);
35
+
36
+    @Autowired
37
+    ITaRegisterService iTaRegisterService;
38
+
39
+    @Autowired
40
+    ITaPvService iTaPvService;
41
+
42
+    @Autowired
43
+    ITaPersonService iTaPersonService;
44
+
45
+
46
+    @RequestMapping(value="/admin/stat-total",method= RequestMethod.GET)
47
+    @ApiOperation(value="总数统计", notes = "总数统计", httpMethod = "GET", response = ResponseBean.class)
48
+    public ResponseBean statTotal() throws Exception {
49
+        // 总报名数
50
+        long totalReg = iTaRegisterService.count();
51
+        // 总 PV
52
+        long totalPV = iTaPvService.count();
53
+        // 总 UV
54
+        long totalUV = iTaPersonService.count();
55
+
56
+        Map<String, Object> res = new HashMap<>();
57
+        res.put("reg", totalReg);
58
+        res.put("pv", totalPV);
59
+        res.put("uv", totalUV);
60
+
61
+        return ResponseBean.success(res);
62
+    }
63
+
64
+}

+ 119
- 0
src/main/java/com/yunzhi/dianyang/controller/SysUserController.java Vedi File

@@ -0,0 +1,119 @@
1
+package com.yunzhi.dianyang.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.dianyang.common.BaseController;
7
+import com.yunzhi.dianyang.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.dianyang.service.ISysUserService;
20
+import com.yunzhi.dianyang.entity.SysUser;
21
+import org.springframework.web.bind.annotation.RestController;
22
+
23
+/**
24
+ * <p>
25
+    * 用户表 前端控制器
26
+    * </p>
27
+ *
28
+ * @author yansen
29
+ * @since 2022-02-18
30
+ */
31
+
32
+@Api(tags = "用户表")
33
+@RestController
34
+@RequestMapping("/")
35
+public class SysUserController extends BaseController {
36
+
37
+    private final Logger logger = LoggerFactory.getLogger(SysUserController.class);
38
+
39
+    @Autowired
40
+    public ISysUserService iSysUserService;
41
+
42
+
43
+    /**
44
+     * 分页查询列表
45
+     * @param pageNum
46
+     * @param pageSize
47
+     * @return
48
+     */
49
+    @RequestMapping(value="/sysUser",method= RequestMethod.GET)
50
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
+    public ResponseBean sysUserList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+
54
+		    IPage<SysUser> pg = new Page<>(pageNum, pageSize);
55
+            QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
56
+            queryWrapper.orderByDesc("create_date");
57
+
58
+            IPage<SysUser> result = iSysUserService.page(pg, queryWrapper);
59
+            return ResponseBean.success(result);
60
+    }
61
+
62
+    /**
63
+     * 保存对象
64
+     * @param sysUser 实体对象
65
+     * @return
66
+     */
67
+    @RequestMapping(value="/sysUser",method= RequestMethod.POST)
68
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
+    public ResponseBean sysUserAdd(@ApiParam("保存内容") @RequestBody SysUser sysUser) throws Exception{
70
+
71
+        if (iSysUserService.save(sysUser)){
72
+            return ResponseBean.success(sysUser);
73
+        }else {
74
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
+        }
76
+    }
77
+
78
+    /**
79
+     * 根据id删除对象
80
+     * @param id  实体ID
81
+     */
82
+    @RequestMapping(value="/sysUser/{id}", method= RequestMethod.DELETE)
83
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
+    public ResponseBean sysUserDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
+        if(iSysUserService.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 sysUser 实体对象
96
+     * @return
97
+     */
98
+    @RequestMapping(value="/sysUser/{id}",method= RequestMethod.PUT)
99
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
+    public ResponseBean sysUserUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
+                                        @ApiParam("更新内容") @RequestBody SysUser sysUser) throws Exception{
102
+
103
+        if (iSysUserService.updateById(sysUser)){
104
+            return ResponseBean.success(iSysUserService.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="/sysUser/{id}",method= RequestMethod.GET)
115
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
+    public ResponseBean sysUserGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
+        return ResponseBean.success(iSysUserService.getById(id));
118
+    }
119
+}

+ 185
- 0
src/main/java/com/yunzhi/dianyang/controller/TaPersonController.java Vedi File

@@ -0,0 +1,185 @@
1
+package com.yunzhi.dianyang.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.dianyang.common.BaseController;
7
+import com.yunzhi.dianyang.common.ResponseBean;
8
+import com.yunzhi.dianyang.common.SMSCaptcha;
9
+import io.swagger.annotations.Api;
10
+import io.swagger.annotations.ApiOperation;
11
+import io.swagger.annotations.ApiParam;
12
+import org.slf4j.Logger;
13
+import org.slf4j.LoggerFactory;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.web.bind.annotation.RequestMapping;
16
+import org.springframework.web.bind.annotation.RequestMethod;
17
+import org.springframework.web.bind.annotation.RequestParam;
18
+import com.yunzhi.dianyang.service.ITaPersonService;
19
+import com.yunzhi.dianyang.entity.TaPerson;
20
+import org.springframework.web.bind.annotation.RestController;
21
+
22
+import javax.servlet.http.HttpServletRequest;
23
+
24
+/**
25
+ * <p>
26
+    * 人员表 前端控制器
27
+    * </p>
28
+ *
29
+ * @author yansen
30
+ * @since 2022-02-21
31
+ */
32
+
33
+@Api(tags = "人员表")
34
+@RestController
35
+@RequestMapping("/")
36
+public class TaPersonController extends BaseController {
37
+
38
+    private final Logger logger = LoggerFactory.getLogger(TaPersonController.class);
39
+
40
+    @Autowired
41
+    public ITaPersonService iTaPersonService;
42
+
43
+    @Autowired
44
+    public SMSCaptcha smsCaptcha;
45
+
46
+    /**
47
+     * 分页查询列表
48
+     * @param pageNum
49
+     * @param pageSize
50
+     * @return
51
+     */
52
+    @RequestMapping(value="/taPerson",method= RequestMethod.GET)
53
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
54
+    public ResponseBean taPersonList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
55
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
56
+
57
+        IPage<TaPerson> pg = new Page<>(pageNum, pageSize);
58
+        QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<>();
59
+        queryWrapper.orderByDesc("create_date");
60
+
61
+        IPage<TaPerson> result = iTaPersonService.page(pg, queryWrapper);
62
+        return ResponseBean.success(result);
63
+    }
64
+
65
+//    /**
66
+//     * 保存对象
67
+//     * @param taPerson 实体对象
68
+//     * @return
69
+//     */
70
+//    @RequestMapping(value="/wx/person",method= RequestMethod.POST)
71
+//    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
72
+//    public ResponseBean taPersonAdd(@ApiParam("保存内容") @RequestBody TaPerson taPerson) throws Exception{
73
+//
74
+//        if (iTaPersonService.save(taPerson)){
75
+//            return ResponseBean.success(taPerson);
76
+//        }else {
77
+//            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
78
+//        }
79
+//    }
80
+
81
+//    /**
82
+//     * 根据id删除对象
83
+//     * @param id  实体ID
84
+//     */
85
+//    @RequestMapping(value="/taPerson/{id}", method= RequestMethod.DELETE)
86
+//    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
87
+//    public ResponseBean taPersonDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
88
+//        if(iTaPersonService.removeById(id)){
89
+//            return ResponseBean.success("success");
90
+//        }else {
91
+//            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
92
+//        }
93
+//    }
94
+
95
+//    /**
96
+//     * 修改对象
97
+//     * @param id  实体ID
98
+//     * @param taPerson 实体对象
99
+//     * @return
100
+//     */
101
+//    @RequestMapping(value="/wx/person/{id}",method= RequestMethod.PUT)
102
+//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
103
+//    public ResponseBean taPersonUpdate(@ApiParam("对象ID") @PathVariable String id,
104
+//                                        @ApiParam("更新内容") @RequestBody TaPerson taPerson) throws Exception{
105
+//
106
+//        if (StringUtils.isEmpty(taPerson.getPhone())) {
107
+//            return ResponseBean.error("手机号不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
108
+//        }
109
+//
110
+//        if ((!StringUtils.isEmpty(taPerson.getTermId()) && StringUtils.isEmpty(taPerson.getClassId()))
111
+//            || (StringUtils.isEmpty(taPerson.getTermId()) && !StringUtils.isEmpty(taPerson.getClassId()))) {
112
+//            return ResponseBean.error("请正确的设置学期与班级", ResponseBean.ERROR_ILLEGAL_PARAMS);
113
+//        }
114
+//
115
+//        if (!StringUtils.isEmpty(taPerson.getTermId())) {
116
+//            taPerson.setPersonType("student");
117
+//        } else {
118
+//            taPerson.setPersonType("");
119
+//        }
120
+//
121
+//        // 找对应的学生信息
122
+//        TaStudent taStudent = getStudent(taPerson);
123
+//        if (taStudent != null && (StringUtils.isEmpty(taStudent.getPersonId()) || taStudent.getPersonId().equals(taPerson.getPersonId()))) {
124
+//            // 映射信息
125
+//            taStudent.setPersonId(taPerson.getPersonId());
126
+//            taStudent.setName(taPerson.getName());
127
+//            taStudent.setSex(taPerson.getSex());
128
+//            taStudent.setPhone(taPerson.getPhone());
129
+//
130
+//            if (!StringUtils.isEmpty(taPerson.getTermId())) {
131
+//                taStudent.setTermId(taPerson.getTermId());
132
+//                taStudent.setClassId(taPerson.getClassId());
133
+//            }
134
+//
135
+//            try {
136
+//                iTaStudentService.updateById(taStudent);
137
+//            } catch (Exception e) {
138
+//                e.printStackTrace();
139
+//            }
140
+//        }
141
+//
142
+//        // 如果没有映射学生, 但是当前人员是学生身份, 则建立关系
143
+//        if (taStudent == null && !StringUtils.isEmpty(taPerson.getTermId())) {
144
+//            taStudent = new TaStudent();
145
+//            taStudent.setPersonId(taPerson.getPersonId());
146
+//            taStudent.setName(taPerson.getName());
147
+//            taStudent.setSex(taPerson.getSex());
148
+//            taStudent.setPhone(taPerson.getPhone());
149
+//            taStudent.setTermId(taPerson.getTermId());
150
+//            taStudent.setClassId(taPerson.getClassId());
151
+//
152
+//            if (!iTaStudentService.save(taStudent)) {
153
+//                return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
154
+//            }
155
+//        }
156
+//
157
+//        if (iTaPersonService.updateById(taPerson)){
158
+//            return ResponseBean.success(iTaPersonService.getById(id));
159
+//        }else {
160
+//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
161
+//        }
162
+//    }
163
+
164
+    /**
165
+     * 根据id查询对象
166
+     */
167
+    @RequestMapping(value="/wx/person/current",method= RequestMethod.GET)
168
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
169
+    public ResponseBean taPersonGet(HttpServletRequest request) throws Exception{
170
+        return ResponseBean.success(getCurrentPerson(request));
171
+    }
172
+
173
+//    public TaStudent getStudent(TaPerson taPerson) {
174
+//        // 先找关联学生
175
+//        TaStudent taStudent = iTaStudentService.getExistBy("person_id", taPerson.getPersonId(), false, true);
176
+//        if (taStudent == null) {
177
+//            // 未找到再依据手机号查找
178
+//            if (!StringUtils.isEmpty(taPerson.getPhone())) {
179
+//                taStudent = iTaStudentService.getExistBy("phone", taPerson.getPhone(), false, true);
180
+//            }
181
+//        }
182
+//
183
+//        return taStudent;
184
+//    }
185
+}

+ 106
- 0
src/main/java/com/yunzhi/dianyang/controller/TaPvController.java Vedi File

@@ -0,0 +1,106 @@
1
+package com.yunzhi.dianyang.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.dianyang.common.BaseController;
7
+import com.yunzhi.dianyang.common.ResponseBean;
8
+import com.yunzhi.dianyang.common.StringUtils;
9
+import com.yunzhi.dianyang.entity.TaPerson;
10
+import com.yunzhi.dianyang.vo.ChartParam;
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.dianyang.service.ITaPvService;
23
+import com.yunzhi.dianyang.entity.TaPv;
24
+import org.springframework.web.bind.annotation.RestController;
25
+
26
+import javax.servlet.http.HttpServletRequest;
27
+import java.time.LocalDateTime;
28
+import java.util.List;
29
+
30
+/**
31
+ * <p>
32
+    * pv 前端控制器
33
+    * </p>
34
+ *
35
+ * @author yansen
36
+ * @since 2022-02-24
37
+ */
38
+
39
+@Api(tags = "pv")
40
+@RestController
41
+@RequestMapping("/")
42
+public class TaPvController extends BaseController {
43
+
44
+    private final Logger logger = LoggerFactory.getLogger(TaPvController.class);
45
+
46
+    @Autowired
47
+    public ITaPvService iTaPvService;
48
+
49
+
50
+    /**
51
+     * 分页查询列表
52
+     * @param startDate
53
+     * @param days
54
+     * @return
55
+     */
56
+    @RequestMapping(value="/admin/pv",method= RequestMethod.GET)
57
+    @ApiOperation(value="PV日统计", notes = "PV日统计", httpMethod = "GET", response = ResponseBean.class)
58
+    public ResponseBean taPvList(@ApiParam(value = "开始日期", example = "2022-02-20") @RequestParam(value ="startDate") String startDate,
59
+                                 @ApiParam("统计天数") @RequestParam(value ="days", defaultValue = "7") Integer days) throws Exception{
60
+
61
+        List<ChartParam> result = iTaPvService.statisPVDaily(startDate, days);
62
+        return ResponseBean.success(result);
63
+    }
64
+
65
+    /**
66
+     * 分页查询列表
67
+     * @param startDate
68
+     * @param days
69
+     * @return
70
+     */
71
+    @RequestMapping(value="/admin/uv",method= RequestMethod.GET)
72
+    @ApiOperation(value="UV日统计", notes = "UV日统计", httpMethod = "GET", response = ResponseBean.class)
73
+    public ResponseBean getUV(@ApiParam(value = "开始日期", example = "2022-02-20") @RequestParam(value ="startDate") String startDate,
74
+                              @ApiParam("统计天数") @RequestParam(value ="days", defaultValue = "7") Integer days) throws Exception{
75
+
76
+        List<ChartParam> result = iTaPvService.statisUVDaily(startDate, days);
77
+        return ResponseBean.success(result);
78
+    }
79
+
80
+    /**
81
+     * 保存对象
82
+     * @param taPv 实体对象
83
+     * @return
84
+     */
85
+    @RequestMapping(value="/wx/pv",method= RequestMethod.POST)
86
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
87
+    public ResponseBean taPvAdd(@ApiParam("保存内容") @RequestBody TaPv taPv,
88
+                                HttpServletRequest request) throws Exception{
89
+
90
+        if (StringUtils.isEmpty(taPv.getAddr())) {
91
+            return ResponseBean.error("没有埋点数据", ResponseBean.ERROR_UNAVAILABLE);
92
+        }
93
+
94
+        TaPerson taPerson = getCurrentPerson(request);
95
+        taPv.setSerailNo(null);
96
+        taPv.setPersonId(taPerson.getPersonId());
97
+        taPv.setCreateDate(LocalDateTime.now());
98
+
99
+        if (iTaPvService.save(taPv)){
100
+            return ResponseBean.success(taPv);
101
+        }else {
102
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
103
+        }
104
+    }
105
+
106
+}

+ 174
- 0
src/main/java/com/yunzhi/dianyang/controller/TaRegisterController.java Vedi File

@@ -0,0 +1,174 @@
1
+package com.yunzhi.dianyang.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.dianyang.common.*;
7
+import io.swagger.annotations.Api;
8
+import io.swagger.annotations.ApiOperation;
9
+import io.swagger.annotations.ApiParam;
10
+import org.slf4j.Logger;
11
+import org.slf4j.LoggerFactory;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.web.bind.annotation.PathVariable;
14
+import org.springframework.web.bind.annotation.RequestBody;
15
+import org.springframework.web.bind.annotation.RequestMapping;
16
+import org.springframework.web.bind.annotation.RequestMethod;
17
+import org.springframework.web.bind.annotation.RequestParam;
18
+import com.yunzhi.dianyang.service.ITaRegisterService;
19
+import com.yunzhi.dianyang.entity.TaRegister;
20
+import org.springframework.web.bind.annotation.RestController;
21
+
22
+import javax.servlet.http.HttpServletResponse;
23
+import java.time.LocalDateTime;
24
+import java.util.List;
25
+
26
+/**
27
+ * <p>
28
+    * 报名表 前端控制器
29
+    * </p>
30
+ *
31
+ * @author yansen
32
+ * @since 2022-02-24
33
+ */
34
+
35
+@Api(tags = "报名表")
36
+@RestController
37
+@RequestMapping("/")
38
+public class TaRegisterController extends BaseController {
39
+
40
+    private final Logger logger = LoggerFactory.getLogger(TaRegisterController.class);
41
+
42
+    @Autowired
43
+    public ITaRegisterService iTaRegisterService;
44
+
45
+
46
+    /**
47
+     * 分页查询列表
48
+     * @param pageNum
49
+     * @param pageSize
50
+     * @return
51
+     */
52
+    @RequestMapping(value="/admin/register",method= RequestMethod.GET)
53
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
54
+    public ResponseBean taRegisterList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
55
+                                       @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
56
+                                       @ApiParam("名称") @RequestParam(value ="name", required = false) String name,
57
+                                       @ApiParam("手机号") @RequestParam(value ="phone", required = false) String phone,
58
+                                       @ApiParam("手机号") @RequestParam(value ="personType", required = false) String personType,
59
+                                       @ApiParam("所属地区") @RequestParam(value ="area", required = false) String area,
60
+                                       @ApiParam(value = "开始时间", example = "2022-02-21") @RequestParam(value ="startDate", required = false) String startDate,
61
+                                       @ApiParam(value = "结束时间", example = "2022-02-28") @RequestParam(value ="endDate", required = false) String endDate) throws Exception{
62
+
63
+        LocalDateTime start = null;
64
+        LocalDateTime end = null;
65
+        if ((StringUtils.isEmpty(startDate) && !StringUtils.isEmpty(endDate)) || (!StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate))) {
66
+            return ResponseBean.error("请选择完整的开始结束时间", ResponseBean.ERROR_ILLEGAL_PARAMS);
67
+        }
68
+
69
+        if (!StringUtils.isEmpty(startDate)) {
70
+            start = DateUtils.from(startDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
71
+            end = DateUtils.from(endDate + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
72
+        }
73
+
74
+        IPage<TaRegister> pg = new Page<>(pageNum, pageSize);
75
+
76
+        IPage<TaRegister> result = iTaRegisterService.getPageBy(pg, name, phone, personType, area, start, end);
77
+        return ResponseBean.success(result);
78
+    }
79
+
80
+
81
+    @RequestMapping(value="/admin/register/export",method= RequestMethod.GET)
82
+    @ApiOperation(value="导出", notes = "导出", httpMethod = "GET", response = ResponseBean.class)
83
+    public void export(@ApiParam("名称") @RequestParam(value ="name", required = false) String name,
84
+                       @ApiParam("手机号") @RequestParam(value ="phone", required = false) String phone,
85
+                       @ApiParam("所属地区") @RequestParam(value ="area", required = false) String area,
86
+                       @ApiParam("手机号") @RequestParam(value ="personType", required = false) String personType,
87
+                       @ApiParam(value = "开始时间", example = "2022-02-21") @RequestParam(value ="startDate", required = false) String startDate,
88
+                       @ApiParam(value = "结束时间", example = "2022-02-28") @RequestParam(value ="endDate", required = false) String endDate,
89
+                       HttpServletResponse response) throws Exception {
90
+
91
+        LocalDateTime start = null;
92
+        LocalDateTime end = null;
93
+        if ((StringUtils.isEmpty(startDate) && !StringUtils.isEmpty(endDate)) || (!StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate))) {
94
+            throw new Exception("请选择完整的开始结束时间");
95
+        }
96
+
97
+        if (!StringUtils.isEmpty(startDate)) {
98
+            start = DateUtils.from(startDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
99
+            end = DateUtils.from(endDate + " 23:59:59", "yyyy-MM-dd HH:mm:ss");
100
+        }
101
+
102
+        List<TaRegister> list = iTaRegisterService.getListBy(name, phone, personType, area, start, end);
103
+        ExcelUtils.flush(response, TaRegister.class, list, "报名人员名单.xlsx");
104
+    }
105
+
106
+    /**
107
+     * 保存对象
108
+     * @param taRegister 实体对象
109
+     * @return
110
+     */
111
+    @RequestMapping(value="/wx/register",method= RequestMethod.POST)
112
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
113
+    public ResponseBean taRegisterAdd(@ApiParam("保存内容") @RequestBody TaRegister taRegister) throws Exception{
114
+
115
+        if (StringUtils.isEmpty(taRegister.getPhone()) || StringUtils.isEmpty(taRegister.getName())) {
116
+            return ResponseBean.error("报名必填内容不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
117
+        }
118
+
119
+        TaRegister exsit = iTaRegisterService.getExistBy("phone", taRegister.getPhone(), true, true);
120
+        if (exsit != null) {
121
+            return ResponseBean.error("当前手机号已经报名", ResponseBean.ERROR_ILLEGAL_PARAMS);
122
+        }
123
+
124
+        taRegister.setRegId(null);
125
+
126
+        if (iTaRegisterService.save(taRegister)){
127
+            return ResponseBean.success(taRegister);
128
+        } else {
129
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
130
+        }
131
+    }
132
+//
133
+//    /**
134
+//     * 根据id删除对象
135
+//     * @param id  实体ID
136
+//     */
137
+//    @RequestMapping(value="/taRegister/{id}", method= RequestMethod.DELETE)
138
+//    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
139
+//    public ResponseBean taRegisterDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
140
+//        if(iTaRegisterService.removeById(id)){
141
+//            return ResponseBean.success("success");
142
+//        }else {
143
+//            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
144
+//        }
145
+//    }
146
+//
147
+//    /**
148
+//     * 修改对象
149
+//     * @param id  实体ID
150
+//     * @param taRegister 实体对象
151
+//     * @return
152
+//     */
153
+//    @RequestMapping(value="/taRegister/{id}",method= RequestMethod.PUT)
154
+//    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
155
+//    public ResponseBean taRegisterUpdate(@ApiParam("对象ID") @PathVariable Integer id,
156
+//                                        @ApiParam("更新内容") @RequestBody TaRegister taRegister) throws Exception{
157
+//
158
+//        if (iTaRegisterService.updateById(taRegister)){
159
+//            return ResponseBean.success(iTaRegisterService.getById(id));
160
+//        }else {
161
+//            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
162
+//        }
163
+//    }
164
+
165
+    /**
166
+     * 根据id查询对象
167
+     * @param id  实体ID
168
+     */
169
+    @RequestMapping(value="/admin/register/{id}",method= RequestMethod.GET)
170
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
171
+    public ResponseBean taRegisterGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
172
+        return ResponseBean.success(iTaRegisterService.getById(id));
173
+    }
174
+}

+ 66
- 0
src/main/java/com/yunzhi/dianyang/controller/TdCityController.java Vedi File

@@ -0,0 +1,66 @@
1
+package com.yunzhi.dianyang.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.dianyang.common.BaseController;
7
+import com.yunzhi.dianyang.common.ResponseBean;
8
+import com.yunzhi.dianyang.common.StringUtils;
9
+import io.swagger.annotations.Api;
10
+import io.swagger.annotations.ApiOperation;
11
+import io.swagger.annotations.ApiParam;
12
+import org.slf4j.Logger;
13
+import org.slf4j.LoggerFactory;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.web.bind.annotation.PathVariable;
16
+import org.springframework.web.bind.annotation.RequestBody;
17
+import org.springframework.web.bind.annotation.RequestMapping;
18
+import org.springframework.web.bind.annotation.RequestMethod;
19
+import org.springframework.web.bind.annotation.RequestParam;
20
+import com.yunzhi.dianyang.service.ITdCityService;
21
+import com.yunzhi.dianyang.entity.TdCity;
22
+import org.springframework.web.bind.annotation.RestController;
23
+
24
+import java.util.List;
25
+
26
+/**
27
+ * <p>
28
+    *  前端控制器
29
+    * </p>
30
+ *
31
+ * @author yansen
32
+ * @since 2022-02-24
33
+ */
34
+
35
+@Api(tags = "")
36
+@RestController
37
+@RequestMapping("/")
38
+public class TdCityController extends BaseController {
39
+
40
+    private final Logger logger = LoggerFactory.getLogger(TdCityController.class);
41
+
42
+    @Autowired
43
+    public ITdCityService iTdCityService;
44
+
45
+
46
+    /**
47
+     * 分页查询列表
48
+     * @param pageNum
49
+     * @param pageSize
50
+     * @return
51
+     */
52
+    @RequestMapping(value="/{client}/city",method= RequestMethod.GET)
53
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
54
+    public ResponseBean tdCityList(@ApiParam("级别, 1省份, 2城市, 3区县") @RequestParam(value ="level",defaultValue = "1") Integer level,
55
+                                   @ApiParam("父级") @RequestParam(value ="parent", required = false) String parent) throws Exception{
56
+
57
+        QueryWrapper<TdCity> queryWrapper = new QueryWrapper<>();
58
+        queryWrapper.eq("leveltype", level);
59
+        queryWrapper.eq(!StringUtils.isEmpty(parent), "parentid", parent);
60
+        queryWrapper.orderByAsc("id");
61
+
62
+        List<TdCity> result = iTdCityService.list(queryWrapper);
63
+        return ResponseBean.success(result);
64
+    }
65
+
66
+}

+ 35
- 0
src/main/java/com/yunzhi/dianyang/controller/WxMpController.java Vedi File

@@ -0,0 +1,35 @@
1
+package com.yunzhi.dianyang.controller;
2
+
3
+import cn.hutool.json.JSONObject;
4
+import cn.hutool.json.JSONUtil;
5
+import com.yunzhi.dianyang.common.*;
6
+import io.swagger.annotations.ApiOperation;
7
+import lombok.extern.slf4j.Slf4j;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.beans.factory.annotation.Value;
10
+import org.springframework.web.bind.annotation.*;
11
+
12
+@Slf4j
13
+@RestController
14
+public class WxMpController extends BaseController {
15
+
16
+    @Value("${yz.mp.jssdk}")
17
+    public String jssdkAPI;
18
+
19
+    @Autowired
20
+    HttpUtils httpUtils;
21
+
22
+    @ApiOperation("获取JSSDK相关")
23
+    @GetMapping("/wx/jssdk")
24
+    public ResponseBean jssdk(@RequestParam("url") String url) throws Exception {
25
+        String json = httpUtils.get(String.format(jssdkAPI, url));
26
+        JSONObject jsonObject = JSONUtil.parseObj(json);
27
+
28
+        if (jsonObject.getInt("code") == ResponseBean.CODE_SUCCESS) {
29
+            return ResponseBean.success(jsonObject.get("data"));
30
+        } else {
31
+            return ResponseBean.error(jsonObject.getStr("message"), ResponseBean.ERROR_UNAVAILABLE);
32
+        }
33
+
34
+    }
35
+}

+ 52
- 0
src/main/java/com/yunzhi/dianyang/entity/SysUser.java Vedi File

@@ -0,0 +1,52 @@
1
+package com.yunzhi.dianyang.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-02-18
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="SysUser对象", description="用户表")
25
+public class SysUser implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "用户ID")
30
+    @TableId(value = "user_id", type = IdType.INPUT)
31
+    private String userId;
32
+
33
+    @ApiModelProperty(value = "用户名")
34
+    private String name;
35
+
36
+    @ApiModelProperty(value = "登录名")
37
+    private String loginName;
38
+
39
+    @ApiModelProperty(value = "密码")
40
+    private String password;
41
+
42
+    @ApiModelProperty(value = "手机号")
43
+    private String phone;
44
+
45
+    @ApiModelProperty(value = "状态")
46
+    private Integer state;
47
+
48
+    @ApiModelProperty(value = "创建时间")
49
+    private LocalDateTime createDate;
50
+
51
+
52
+}

+ 67
- 0
src/main/java/com/yunzhi/dianyang/entity/TaPerson.java Vedi File

@@ -0,0 +1,67 @@
1
+package com.yunzhi.dianyang.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import java.time.LocalDateTime;
5
+
6
+import com.baomidou.mybatisplus.annotation.TableField;
7
+import com.baomidou.mybatisplus.annotation.TableId;
8
+import java.io.Serializable;
9
+import io.swagger.annotations.ApiModel;
10
+import io.swagger.annotations.ApiModelProperty;
11
+import lombok.Data;
12
+import lombok.EqualsAndHashCode;
13
+import lombok.experimental.Accessors;
14
+
15
+/**
16
+ * <p>
17
+ * 人员表
18
+ * </p>
19
+ *
20
+ * @author yansen
21
+ * @since 2022-02-21
22
+ */
23
+@Data
24
+@EqualsAndHashCode(callSuper = false)
25
+@Accessors(chain = true)
26
+@ApiModel(value="TaPerson对象", description="人员表")
27
+public class TaPerson implements Serializable {
28
+
29
+    private static final long serialVersionUID = 1L;
30
+
31
+    @ApiModelProperty(value = "人员ID")
32
+    @TableId(value = "person_id", type = IdType.UUID)
33
+    private String personId;
34
+
35
+    @ApiModelProperty(value = "openid")
36
+    private String openid;
37
+
38
+    @ApiModelProperty(value = "名称")
39
+    private String name;
40
+
41
+    @ApiModelProperty(value = "性别")
42
+    private Integer sex;
43
+
44
+    @ApiModelProperty(value = "手机号")
45
+    private String phone;
46
+
47
+    @ApiModelProperty(value = "身份")
48
+    private String personType;
49
+
50
+    @ApiModelProperty(value = "状态")
51
+    private Integer state;
52
+
53
+    @ApiModelProperty(value = "创建时间")
54
+    private LocalDateTime createDate;
55
+
56
+    @TableField(exist = false)
57
+    @ApiModelProperty(value = "所属学期")
58
+    private String termId;
59
+
60
+    @TableField(exist = false)
61
+    @ApiModelProperty(value = "班级ID")
62
+    private String classId;
63
+
64
+    @TableField(exist = false)
65
+    @ApiModelProperty(value = "验证码")
66
+    private String captcha;
67
+}

+ 43
- 0
src/main/java/com/yunzhi/dianyang/entity/TaPv.java Vedi File

@@ -0,0 +1,43 @@
1
+package com.yunzhi.dianyang.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import java.time.LocalDateTime;
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
+ * pv
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2022-02-24
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaPv对象", description="pv")
25
+public class TaPv implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "序号")
30
+    @TableId(value = "serail_no", type = IdType.AUTO)
31
+    private Integer serailNo;
32
+
33
+    @ApiModelProperty(value = "人员ID")
34
+    private String personId;
35
+
36
+    @ApiModelProperty(value = "访问地址")
37
+    private String addr;
38
+
39
+    @ApiModelProperty(value = "创建时间")
40
+    private LocalDateTime createDate;
41
+
42
+
43
+}

+ 83
- 0
src/main/java/com/yunzhi/dianyang/entity/TaRegister.java Vedi File

@@ -0,0 +1,83 @@
1
+package com.yunzhi.dianyang.entity;
2
+
3
+import com.alibaba.excel.annotation.ExcelIgnore;
4
+import com.alibaba.excel.annotation.ExcelProperty;
5
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
6
+import com.baomidou.mybatisplus.annotation.IdType;
7
+import java.time.LocalDateTime;
8
+import com.baomidou.mybatisplus.annotation.TableId;
9
+import java.io.Serializable;
10
+
11
+import com.yunzhi.dianyang.common.excelConverter.LocalDateTimeConverter;
12
+import io.swagger.annotations.ApiModel;
13
+import io.swagger.annotations.ApiModelProperty;
14
+import lombok.Data;
15
+import lombok.EqualsAndHashCode;
16
+import lombok.experimental.Accessors;
17
+
18
+/**
19
+ * <p>
20
+ * 报名表
21
+ * </p>
22
+ *
23
+ * @author yansen
24
+ * @since 2022-02-24
25
+ */
26
+@Data
27
+@EqualsAndHashCode(callSuper = false)
28
+@Accessors(chain = true)
29
+@ApiModel(value="TaRegister对象", description="报名表")
30
+public class TaRegister implements Serializable {
31
+
32
+    @ExcelIgnore
33
+    private static final long serialVersionUID = 1L;
34
+
35
+    @ExcelIgnore
36
+    @ApiModelProperty(value = "报名ID")
37
+    @TableId(value = "reg_id", type = IdType.UUID)
38
+    private String regId;
39
+
40
+    @ColumnWidth(20)
41
+    @ExcelProperty(value = "姓名", index = 1)
42
+    @ApiModelProperty(value = "名称")
43
+    private String name;
44
+
45
+    @ExcelIgnore
46
+    @ApiModelProperty(value = "性别")
47
+    private Integer sex;
48
+
49
+    @ColumnWidth(30)
50
+    @ExcelProperty(value = "手机号", index = 2)
51
+    @ApiModelProperty(value = "手机号")
52
+    private String phone;
53
+
54
+    @ColumnWidth(20)
55
+    @ExcelProperty(value = "身份", index = 3)
56
+    @ApiModelProperty(value = "身份")
57
+    private String personType;
58
+
59
+    @ColumnWidth(50)
60
+    @ExcelProperty(value = "意向产品", index = 5)
61
+    @ApiModelProperty(value = "意向产品")
62
+    private String interestTo;
63
+
64
+    @ExcelIgnore
65
+    @ApiModelProperty(value = "地区编码")
66
+    private String areaCode;
67
+
68
+    @ColumnWidth(30)
69
+    @ExcelProperty(value = "所在地", index = 4)
70
+    @ApiModelProperty(value = "地区名称")
71
+    private String areaName;
72
+
73
+    @ExcelIgnore
74
+    @ApiModelProperty(value = "状态")
75
+    private Integer state;
76
+
77
+    @ColumnWidth(50)
78
+    @ExcelProperty(value = "报名时间", index = 6, converter = LocalDateTimeConverter.class)
79
+    @ApiModelProperty(value = "创建时间")
80
+    private LocalDateTime createDate;
81
+
82
+
83
+}

+ 43
- 0
src/main/java/com/yunzhi/dianyang/entity/TaShare.java Vedi File

@@ -0,0 +1,43 @@
1
+package com.yunzhi.dianyang.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import java.time.LocalDateTime;
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-02-24
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaShare对象", description="分享")
25
+public class TaShare implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "序号")
30
+    @TableId(value = "serail_no", type = IdType.AUTO)
31
+    private Integer serailNo;
32
+
33
+    @ApiModelProperty(value = "人员ID")
34
+    private String personId;
35
+
36
+    @ApiModelProperty(value = "分享地址")
37
+    private String addr;
38
+
39
+    @ApiModelProperty(value = "创建时间")
40
+    private LocalDateTime createDate;
41
+
42
+
43
+}

+ 62
- 0
src/main/java/com/yunzhi/dianyang/entity/TdCity.java Vedi File

@@ -0,0 +1,62 @@
1
+package com.yunzhi.dianyang.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import java.io.Serializable;
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
+/**
13
+ * <p>
14
+ * 
15
+ * </p>
16
+ *
17
+ * @author yansen
18
+ * @since 2022-02-24
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@ApiModel(value="TdCity对象", description="")
24
+public class TdCity implements Serializable {
25
+
26
+    private static final long serialVersionUID = 1L;
27
+
28
+    @ApiModelProperty(value = "ID")
29
+    @TableId(value = "id", type = IdType.AUTO)
30
+    private Integer id;
31
+
32
+    @ApiModelProperty(value = "省市区名称")
33
+    private String name;
34
+
35
+    @ApiModelProperty(value = "上级ID")
36
+    private Integer parentid;
37
+
38
+    @ApiModelProperty(value = "简称")
39
+    private String shortname;
40
+
41
+    @ApiModelProperty(value = "级别:0,中国;1,省分;2,市;3,区、县")
42
+    private Integer leveltype;
43
+
44
+    @ApiModelProperty(value = "城市代码")
45
+    private String citycode;
46
+
47
+    @ApiModelProperty(value = "邮编")
48
+    private String zipcode;
49
+
50
+    @ApiModelProperty(value = "经度")
51
+    private String lng;
52
+
53
+    @ApiModelProperty(value = "纬度")
54
+    private String lat;
55
+
56
+    @ApiModelProperty(value = "拼音")
57
+    private String pinyin;
58
+
59
+    private Integer status;
60
+
61
+
62
+}

+ 19
- 0
src/main/java/com/yunzhi/dianyang/exception/GlobalExceptionHandler.java Vedi File

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

+ 63
- 0
src/main/java/com/yunzhi/dianyang/interceptor/PermissionInterceptor.java Vedi File

@@ -0,0 +1,63 @@
1
+package com.yunzhi.dianyang.interceptor;
2
+
3
+import cn.hutool.json.JSONUtil;
4
+import com.yunzhi.dianyang.common.*;
5
+import lombok.extern.slf4j.Slf4j;
6
+import org.springframework.stereotype.Component;
7
+import org.springframework.web.servlet.HandlerInterceptor;
8
+import org.springframework.web.servlet.ModelAndView;
9
+
10
+import javax.servlet.http.HttpServletRequest;
11
+import javax.servlet.http.HttpServletResponse;
12
+import java.io.IOException;
13
+import java.nio.charset.StandardCharsets;
14
+
15
+@Slf4j
16
+@Component
17
+public class PermissionInterceptor implements HandlerInterceptor {
18
+
19
+    @Override
20
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {
21
+        // 请求地址
22
+        String uri = request.getRequestURI();
23
+//        if (uri.contains("/wx/")) {
24
+//            boolean isWx = checkWx(request);
25
+//            if (!isWx) {
26
+//                responseTokenError(response, "请使用微信客户端访问");
27
+//                return false;
28
+//            }
29
+//        }
30
+
31
+        String token = JWTUtils.getToken(request);
32
+
33
+        try {
34
+            JWTUtils.verify(token);
35
+        } catch (Exception e) {
36
+            e.printStackTrace();
37
+            log.error("鉴权失败: {}", e.getMessage());
38
+            responseTokenError(response, "鉴权失败, 请重新登录");
39
+            return false;
40
+        }
41
+
42
+        return true;
43
+    }
44
+
45
+    @Override
46
+    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
47
+        // 刷新 TOKEN
48
+        String jws = JWTUtils.getToken(request);
49
+        JWTUtils.refresh(jws, response);
50
+    }
51
+
52
+    private void responseTokenError(HttpServletResponse response, String error) throws IOException {
53
+        response.addHeader("Content-type", "application/json");
54
+        byte[] data = JSONUtil.toJsonStr(ResponseBean.error(error, ResponseBean.ERROR_AUTH_FAIL)).getBytes(StandardCharsets.UTF_8);
55
+        response.getOutputStream().write(data);
56
+
57
+    }
58
+
59
+    private boolean checkWx(HttpServletRequest request) {
60
+        String ua = request.getHeader("user-agent");
61
+        return ua.toLowerCase().contains("micromessenger");
62
+    }
63
+}

+ 79
- 0
src/main/java/com/yunzhi/dianyang/log/MysqlAppender.java Vedi File

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

+ 18
- 0
src/main/java/com/yunzhi/dianyang/mapper/SysUserMapper.java Vedi File

@@ -0,0 +1,18 @@
1
+package com.yunzhi.dianyang.mapper;
2
+
3
+import com.yunzhi.dianyang.entity.SysUser;
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-02-18
14
+ */
15
+@Mapper
16
+public interface SysUserMapper extends BaseMapper<SysUser> {
17
+
18
+}

+ 18
- 0
src/main/java/com/yunzhi/dianyang/mapper/TaPersonMapper.java Vedi File

@@ -0,0 +1,18 @@
1
+package com.yunzhi.dianyang.mapper;
2
+
3
+import com.yunzhi.dianyang.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-02-21
14
+ */
15
+@Mapper
16
+public interface TaPersonMapper extends BaseMapper<TaPerson> {
17
+
18
+}

+ 25
- 0
src/main/java/com/yunzhi/dianyang/mapper/TaPvMapper.java Vedi File

@@ -0,0 +1,25 @@
1
+package com.yunzhi.dianyang.mapper;
2
+
3
+import com.yunzhi.dianyang.entity.TaPv;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import com.yunzhi.dianyang.vo.ChartParam;
6
+import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.util.List;
10
+
11
+/**
12
+ * <p>
13
+ * pv Mapper 接口
14
+ * </p>
15
+ *
16
+ * @author yansen
17
+ * @since 2022-02-24
18
+ */
19
+@Mapper
20
+public interface TaPvMapper extends BaseMapper<TaPv> {
21
+
22
+    List<ChartParam> statisPVDaily(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("days") Integer days);
23
+
24
+    List<ChartParam> statisUVDaily(@Param("startDate") String startDate, @Param("endDate") String toString, @Param("days") Integer days);
25
+}

+ 37
- 0
src/main/java/com/yunzhi/dianyang/mapper/TaRegisterMapper.java Vedi File

@@ -0,0 +1,37 @@
1
+package com.yunzhi.dianyang.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.dianyang.entity.TaRegister;
5
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.time.LocalDateTime;
10
+import java.util.List;
11
+
12
+/**
13
+ * <p>
14
+ * 报名表 Mapper 接口
15
+ * </p>
16
+ *
17
+ * @author yansen
18
+ * @since 2022-02-24
19
+ */
20
+@Mapper
21
+public interface TaRegisterMapper extends BaseMapper<TaRegister> {
22
+
23
+    IPage<TaRegister> getPageBy(IPage<TaRegister> pg,
24
+                                @Param("name") String name,
25
+                                @Param("phone") String phone,
26
+                                @Param("personType") String personType,
27
+                                @Param("area") String area,
28
+                                @Param("start") LocalDateTime start,
29
+                                @Param("end") LocalDateTime end);
30
+
31
+    List<TaRegister> getListBy(@Param("name") String name,
32
+                               @Param("phone") String phone,
33
+                               @Param("personType") String personType,
34
+                               @Param("area") String area,
35
+                               @Param("start") LocalDateTime start,
36
+                               @Param("end") LocalDateTime end);
37
+}

+ 18
- 0
src/main/java/com/yunzhi/dianyang/mapper/TaShareMapper.java Vedi File

@@ -0,0 +1,18 @@
1
+package com.yunzhi.dianyang.mapper;
2
+
3
+import com.yunzhi.dianyang.entity.TaShare;
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-02-24
14
+ */
15
+@Mapper
16
+public interface TaShareMapper extends BaseMapper<TaShare> {
17
+
18
+}

+ 18
- 0
src/main/java/com/yunzhi/dianyang/mapper/TdCityMapper.java Vedi File

@@ -0,0 +1,18 @@
1
+package com.yunzhi.dianyang.mapper;
2
+
3
+import com.yunzhi.dianyang.entity.TdCity;
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-02-24
14
+ */
15
+@Mapper
16
+public interface TdCityMapper extends BaseMapper<TdCity> {
17
+
18
+}

+ 20
- 0
src/main/java/com/yunzhi/dianyang/service/IBaseService.java Vedi File

@@ -0,0 +1,20 @@
1
+package com.yunzhi.dianyang.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
+    int countBy(String column, Object value, boolean notDelete);
16
+
17
+    T getByButNot(String column, Object value, String col, Object val, boolean notDelete);
18
+
19
+    T getExistBy(String column, Object value, boolean normal, boolean notDelete);
20
+}

+ 17
- 0
src/main/java/com/yunzhi/dianyang/service/ISysUserService.java Vedi File

@@ -0,0 +1,17 @@
1
+package com.yunzhi.dianyang.service;
2
+
3
+import com.yunzhi.dianyang.entity.SysUser;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 用户表 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2022-02-18
13
+ */
14
+public interface ISysUserService extends IService<SysUser> {
15
+
16
+    SysUser getByLoginName(String userName);
17
+}

+ 17
- 0
src/main/java/com/yunzhi/dianyang/service/ITaPersonService.java Vedi File

@@ -0,0 +1,17 @@
1
+package com.yunzhi.dianyang.service;
2
+
3
+import com.yunzhi.dianyang.entity.TaPerson;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 人员表 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2022-02-21
13
+ */
14
+public interface ITaPersonService extends IService<TaPerson> {
15
+
16
+    TaPerson getByOpenID(String openID);
17
+}

+ 22
- 0
src/main/java/com/yunzhi/dianyang/service/ITaPvService.java Vedi File

@@ -0,0 +1,22 @@
1
+package com.yunzhi.dianyang.service;
2
+
3
+import com.yunzhi.dianyang.entity.TaPv;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.yunzhi.dianyang.vo.ChartParam;
6
+
7
+import java.util.List;
8
+
9
+/**
10
+ * <p>
11
+ * pv 服务类
12
+ * </p>
13
+ *
14
+ * @author yansen
15
+ * @since 2022-02-24
16
+ */
17
+public interface ITaPvService extends IService<TaPv> {
18
+
19
+    List<ChartParam> statisPVDaily(String startDate, Integer days);
20
+
21
+    List<ChartParam> statisUVDaily(String startDate, Integer days);
22
+}

+ 22
- 0
src/main/java/com/yunzhi/dianyang/service/ITaRegisterService.java Vedi File

@@ -0,0 +1,22 @@
1
+package com.yunzhi.dianyang.service;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.dianyang.entity.TaRegister;
5
+
6
+import java.time.LocalDateTime;
7
+import java.util.List;
8
+
9
+/**
10
+ * <p>
11
+ * 报名表 服务类
12
+ * </p>
13
+ *
14
+ * @author yansen
15
+ * @since 2022-02-24
16
+ */
17
+public interface ITaRegisterService extends IBaseService<TaRegister> {
18
+
19
+    IPage<TaRegister> getPageBy(IPage<TaRegister> pg, String name, String phone, String personType, String area, LocalDateTime start, LocalDateTime end);
20
+
21
+    List<TaRegister> getListBy(String name, String phone, String personType, String area, LocalDateTime start, LocalDateTime end);
22
+}

+ 16
- 0
src/main/java/com/yunzhi/dianyang/service/ITaShareService.java Vedi File

@@ -0,0 +1,16 @@
1
+package com.yunzhi.dianyang.service;
2
+
3
+import com.yunzhi.dianyang.entity.TaShare;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 分享 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2022-02-24
13
+ */
14
+public interface ITaShareService extends IService<TaShare> {
15
+
16
+}

+ 16
- 0
src/main/java/com/yunzhi/dianyang/service/ITdCityService.java Vedi File

@@ -0,0 +1,16 @@
1
+package com.yunzhi.dianyang.service;
2
+
3
+import com.yunzhi.dianyang.entity.TdCity;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ *  服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2022-02-24
13
+ */
14
+public interface ITdCityService extends IService<TdCity> {
15
+
16
+}

+ 54
- 0
src/main/java/com/yunzhi/dianyang/service/impl/BaseServiceImpl.java Vedi File

@@ -0,0 +1,54 @@
1
+package com.yunzhi.dianyang.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.dianyang.service.IBaseService;
10
+
11
+import java.io.Serializable;
12
+
13
+public class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements IBaseService<T> {
14
+    @Override
15
+    public boolean removeLogicById(Serializable id) {
16
+
17
+        TableInfo tableInfo = SqlHelper.table(currentModelClass());
18
+        UpdateWrapper<T> updateWrapper = new UpdateWrapper<>();
19
+        updateWrapper.set("state", -1)
20
+                .eq(tableInfo.getKeyColumn(), id);
21
+
22
+        return update(updateWrapper);
23
+    }
24
+
25
+    @Override
26
+    public int countBy(String column, Object value, boolean notDelete) {
27
+        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
28
+        queryWrapper.eq(column, value);
29
+        queryWrapper.gt(notDelete, "state", -1);
30
+
31
+        return count(queryWrapper);
32
+    }
33
+
34
+    @Override
35
+    public T getByButNot(String column, Object value, String col, Object val, boolean notDelete) {
36
+        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
37
+        queryWrapper.eq(column, value);
38
+        queryWrapper.ne(col, val);
39
+        queryWrapper.gt(notDelete, "state", -1);
40
+        queryWrapper.last("limit 1");
41
+
42
+        return getOne(queryWrapper);
43
+    }
44
+
45
+    @Override
46
+    public T getExistBy(String column, Object value, boolean normal, boolean notDelete) {
47
+        QueryWrapper<T> queryWrapper = new QueryWrapper<>();
48
+        queryWrapper.eq(column, value);
49
+        queryWrapper.eq(normal, "state", 1);
50
+        queryWrapper.gt(notDelete, "state", -1);
51
+        queryWrapper.last("limit 1");
52
+        return getOne(queryWrapper);
53
+    }
54
+}

+ 30
- 0
src/main/java/com/yunzhi/dianyang/service/impl/SysUserServiceImpl.java Vedi File

@@ -0,0 +1,30 @@
1
+package com.yunzhi.dianyang.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.yunzhi.dianyang.common.Constants;
5
+import com.yunzhi.dianyang.entity.SysUser;
6
+import com.yunzhi.dianyang.mapper.SysUserMapper;
7
+import com.yunzhi.dianyang.service.ISysUserService;
8
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import org.springframework.stereotype.Service;
10
+
11
+/**
12
+ * <p>
13
+ * 用户表 服务实现类
14
+ * </p>
15
+ *
16
+ * @author yansen
17
+ * @since 2022-02-18
18
+ */
19
+@Service
20
+public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
21
+
22
+    @Override
23
+    public SysUser getByLoginName(String userName) {
24
+        QueryWrapper<SysUser> queryWrapper = new QueryWrapper<>();
25
+        queryWrapper.eq("login_name", userName);
26
+        queryWrapper.gt("state", Constants.STATUS_DELETED);
27
+
28
+        return getOne(queryWrapper);
29
+    }
30
+}

+ 30
- 0
src/main/java/com/yunzhi/dianyang/service/impl/TaPersonServiceImpl.java Vedi File

@@ -0,0 +1,30 @@
1
+package com.yunzhi.dianyang.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.yunzhi.dianyang.common.Constants;
5
+import com.yunzhi.dianyang.entity.TaPerson;
6
+import com.yunzhi.dianyang.mapper.TaPersonMapper;
7
+import com.yunzhi.dianyang.service.ITaPersonService;
8
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import org.springframework.stereotype.Service;
10
+
11
+/**
12
+ * <p>
13
+ * 人员表 服务实现类
14
+ * </p>
15
+ *
16
+ * @author yansen
17
+ * @since 2022-02-21
18
+ */
19
+@Service
20
+public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> implements ITaPersonService {
21
+
22
+    @Override
23
+    public TaPerson getByOpenID(String openID) {
24
+        QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<>();
25
+        queryWrapper.eq("openid", openID);
26
+        queryWrapper.gt("state", Constants.STATUS_DELETED);
27
+
28
+        return getOne(queryWrapper);
29
+    }
30
+}

+ 40
- 0
src/main/java/com/yunzhi/dianyang/service/impl/TaPvServiceImpl.java Vedi File

@@ -0,0 +1,40 @@
1
+package com.yunzhi.dianyang.service.impl;
2
+
3
+import com.yunzhi.dianyang.common.DateUtils;
4
+import com.yunzhi.dianyang.entity.TaPv;
5
+import com.yunzhi.dianyang.mapper.TaPvMapper;
6
+import com.yunzhi.dianyang.service.ITaPvService;
7
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
+import com.yunzhi.dianyang.vo.ChartParam;
9
+import org.springframework.stereotype.Service;
10
+
11
+import java.time.LocalDateTime;
12
+import java.util.List;
13
+
14
+/**
15
+ * <p>
16
+ * pv 服务实现类
17
+ * </p>
18
+ *
19
+ * @author yansen
20
+ * @since 2022-02-24
21
+ */
22
+@Service
23
+public class TaPvServiceImpl extends ServiceImpl<TaPvMapper, TaPv> implements ITaPvService {
24
+
25
+    @Override
26
+    public List<ChartParam> statisPVDaily(String startDate, Integer days) {
27
+        LocalDateTime start = DateUtils.from(startDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
28
+        LocalDateTime endDate = start.plusDays(days);
29
+
30
+        return baseMapper.statisPVDaily(startDate, DateUtils.toString(endDate, "yyyy-MM-dd"), days);
31
+    }
32
+
33
+    @Override
34
+    public List<ChartParam> statisUVDaily(String startDate, Integer days) {
35
+        LocalDateTime start = DateUtils.from(startDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss");
36
+        LocalDateTime endDate = start.plusDays(days);
37
+
38
+        return baseMapper.statisUVDaily(startDate, DateUtils.toString(endDate, "yyyy-MM-dd"), days);
39
+    }
40
+}

+ 32
- 0
src/main/java/com/yunzhi/dianyang/service/impl/TaRegisterServiceImpl.java Vedi File

@@ -0,0 +1,32 @@
1
+package com.yunzhi.dianyang.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.yunzhi.dianyang.entity.TaRegister;
5
+import com.yunzhi.dianyang.mapper.TaRegisterMapper;
6
+import com.yunzhi.dianyang.service.ITaRegisterService;
7
+import org.springframework.stereotype.Service;
8
+
9
+import java.time.LocalDateTime;
10
+import java.util.List;
11
+
12
+/**
13
+ * <p>
14
+ * 报名表 服务实现类
15
+ * </p>
16
+ *
17
+ * @author yansen
18
+ * @since 2022-02-24
19
+ */
20
+@Service
21
+public class TaRegisterServiceImpl extends BaseServiceImpl<TaRegisterMapper, TaRegister> implements ITaRegisterService {
22
+
23
+    @Override
24
+    public IPage<TaRegister> getPageBy(IPage<TaRegister> pg, String name, String phone, String personType, String area, LocalDateTime start, LocalDateTime end) {
25
+        return baseMapper.getPageBy(pg, name, phone, personType, area, start, end);
26
+    }
27
+
28
+    @Override
29
+    public List<TaRegister> getListBy(String name, String phone, String personType, String area, LocalDateTime start, LocalDateTime end) {
30
+        return baseMapper.getListBy(name, phone, personType, area, start, end);
31
+    }
32
+}

+ 20
- 0
src/main/java/com/yunzhi/dianyang/service/impl/TaShareServiceImpl.java Vedi File

@@ -0,0 +1,20 @@
1
+package com.yunzhi.dianyang.service.impl;
2
+
3
+import com.yunzhi.dianyang.entity.TaShare;
4
+import com.yunzhi.dianyang.mapper.TaShareMapper;
5
+import com.yunzhi.dianyang.service.ITaShareService;
6
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import org.springframework.stereotype.Service;
8
+
9
+/**
10
+ * <p>
11
+ * 分享 服务实现类
12
+ * </p>
13
+ *
14
+ * @author yansen
15
+ * @since 2022-02-24
16
+ */
17
+@Service
18
+public class TaShareServiceImpl extends ServiceImpl<TaShareMapper, TaShare> implements ITaShareService {
19
+
20
+}

+ 20
- 0
src/main/java/com/yunzhi/dianyang/service/impl/TdCityServiceImpl.java Vedi File

@@ -0,0 +1,20 @@
1
+package com.yunzhi.dianyang.service.impl;
2
+
3
+import com.yunzhi.dianyang.entity.TdCity;
4
+import com.yunzhi.dianyang.mapper.TdCityMapper;
5
+import com.yunzhi.dianyang.service.ITdCityService;
6
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import org.springframework.stereotype.Service;
8
+
9
+/**
10
+ * <p>
11
+ *  服务实现类
12
+ * </p>
13
+ *
14
+ * @author yansen
15
+ * @since 2022-02-24
16
+ */
17
+@Service
18
+public class TdCityServiceImpl extends ServiceImpl<TdCityMapper, TdCity> implements ITdCityService {
19
+
20
+}

+ 16
- 0
src/main/java/com/yunzhi/dianyang/vo/AdminLoginParam.java Vedi File

@@ -0,0 +1,16 @@
1
+package com.yunzhi.dianyang.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 AdminLoginParam {
10
+
11
+    @ApiModelProperty("用户名")
12
+    String userName;
13
+
14
+    @ApiModelProperty("密码, MD5 加密后数据")
15
+    String password;
16
+}

+ 16
- 0
src/main/java/com/yunzhi/dianyang/vo/ChangePassword.java Vedi File

@@ -0,0 +1,16 @@
1
+package com.yunzhi.dianyang.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 ChangePassword {
10
+
11
+    @ApiModelProperty("原始密码, MD5 加密后数据")
12
+    String originPassword;
13
+
14
+    @ApiModelProperty("新密码, MD5 加密后数据")
15
+    String newPassword;
16
+}

+ 16
- 0
src/main/java/com/yunzhi/dianyang/vo/ChartParam.java Vedi File

@@ -0,0 +1,16 @@
1
+package com.yunzhi.dianyang.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 ChartParam {
10
+
11
+    @ApiModelProperty("维度")
12
+    String key;
13
+
14
+    @ApiModelProperty("值")
15
+    String value;
16
+}

+ 20
- 0
src/main/java/com/yunzhi/dianyang/vo/LoginParam.java Vedi File

@@ -0,0 +1,20 @@
1
+package com.yunzhi.dianyang.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 LoginParam {
11
+
12
+    @ApiModelProperty("用户名")
13
+    private String name;
14
+
15
+    @ApiModelProperty("手机号")
16
+    private String phone;
17
+
18
+    @ApiModelProperty("验证码")
19
+    private String captcha;
20
+}

+ 51
- 0
src/main/java/com/yunzhi/dianyang/vo/TokenParam.java Vedi File

@@ -0,0 +1,51 @@
1
+package com.yunzhi.dianyang.vo;
2
+
3
+import io.swagger.annotations.ApiModel;
4
+import io.swagger.annotations.ApiModelProperty;
5
+import lombok.Data;
6
+import lombok.experimental.Accessors;
7
+
8
+import java.lang.reflect.Field;
9
+import java.util.Date;
10
+import java.util.HashMap;
11
+import java.util.Map;
12
+
13
+@ApiModel(description = "Token参数")
14
+@Data
15
+@Accessors(chain = true)
16
+public class TokenParam {
17
+    @ApiModelProperty("用户ID")
18
+    String userId;
19
+
20
+    @ApiModelProperty("机构ID")
21
+    String orgId;
22
+
23
+    @ApiModelProperty("原始值")
24
+    String raw;
25
+
26
+    public static TokenParam fromMap(Map<String, Object> mapParams) {
27
+        TokenParam tokenParam = new TokenParam();
28
+
29
+        // 没有使用反射, 懒
30
+        Object u = mapParams.get("userId");
31
+        Object o = mapParams.get("orgId");
32
+        Object r = mapParams.get("raw");
33
+        tokenParam.setUserId(null == u ? null : u.toString());
34
+        tokenParam.setOrgId(null == o ? null : o.toString());
35
+        tokenParam.setRaw(null == r ? null : r.toString());
36
+
37
+        return tokenParam;
38
+    }
39
+
40
+    public Map<String, Object> toMap() throws IllegalAccessException {
41
+        Map<String, Object> rtn = new HashMap<>();
42
+
43
+        Class<?> cls = getClass();
44
+        for (Field field: cls.getDeclaredFields()) {
45
+            field.setAccessible(true);
46
+            rtn.put(field.getName(), field.get(this));
47
+        }
48
+
49
+        return rtn;
50
+    }
51
+}

+ 23
- 0
src/main/resources/application-dev.yml Vedi File

@@ -0,0 +1,23 @@
1
+###
2
+spring:
3
+  main:
4
+    lazy-initialization: false
5
+  servlet:
6
+    multipart:
7
+      max-file-size: 10MB
8
+      max-request-size: 50MB
9
+  datasource:
10
+    url: jdbc:mysql://rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com:3306/dianyang_colmo?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
11
+    username: dianyang_colmo
12
+    password: dianyang_colmo@ABC123
13
+
14
+###
15
+logging:
16
+  level:
17
+    root: info
18
+    springfox: info
19
+
20
+### swagger
21
+springfox:
22
+  documentation:
23
+    auto-startup: true

+ 19
- 0
src/main/resources/application-prod.yml Vedi File

@@ -0,0 +1,19 @@
1
+server:
2
+  port: 9000
3
+###
4
+spring:
5
+  servlet:
6
+    multipart:
7
+      max-file-size: 10MB
8
+      max-request-size: 50MB
9
+  datasource:
10
+    url: jdbc:mysql://rm-uf6z3z6jq11x653d77o.mysql.rds.aliyuncs.com:3306/dianyang_colmo?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
11
+    username: dianyang_colmo
12
+    password: dianyang_colmo@ABC123
13
+
14
+
15
+
16
+##
17
+springfox:
18
+  documentation:
19
+    auto-startup: false

+ 52
- 0
src/main/resources/application.yml Vedi File

@@ -0,0 +1,52 @@
1
+###
2
+server:
3
+  port: 8081
4
+  servlet:
5
+    context-path: /api
6
+
7
+###
8
+interceptor:
9
+  permission:
10
+    enable: true
11
+    include-paths: /**
12
+    exclude-paths:
13
+      - /**/login
14
+      - /**/captcha
15
+      - /swagger-ui/**
16
+      - /swagger-resources/**
17
+      - /**/api-docs
18
+      - /test-weather
19
+
20
+###
21
+mybatis-plus:
22
+  configuration:
23
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
24
+    call-setters-on-nulls: true
25
+  mapper-locations: classpath:mapper/**/*.xml
26
+
27
+###
28
+sms:
29
+  captcha:
30
+    code: SMS_207555188
31
+    sign: 云致科技
32
+
33
+###
34
+yz:
35
+  sms:
36
+    ## 可以任意名称
37
+    appid: state-grid-training
38
+    api: http://sms.njyunzhi.com/sms
39
+    ## 帮助文档
40
+    help: http://sms.njyunzhi.com/help
41
+  mp:
42
+    openidAPI: https://api.h5.njyunzhi.com/mp/openid?code=%s
43
+    jssdk: https://api.h5.njyunzhi.com/mp/jssdk?url=%s
44
+
45
+###
46
+spring:
47
+  main:
48
+    lazy-initialization: true
49
+  application:
50
+    name: questions
51
+  profiles:
52
+    active: @profileActive@

+ 31
- 0
src/main/resources/logback.xml.bak Vedi File

@@ -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/SysUserMapper.xml Vedi File

@@ -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.dianyang.mapper.SysUserMapper">
4
+
5
+</mapper>

+ 5
- 0
src/main/resources/mapper/TaPersonMapper.xml Vedi File

@@ -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.dianyang.mapper.TaPersonMapper">
4
+
5
+</mapper>

+ 51
- 0
src/main/resources/mapper/TaPvMapper.xml Vedi File

@@ -0,0 +1,51 @@
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.dianyang.mapper.TaPvMapper">
4
+
5
+    <select id="statisPVDaily" resultType="com.yunzhi.dianyang.vo.ChartParam">
6
+        SELECT
7
+            DATE_ADD( #{startDate}, INTERVAL t.rownum DAY ) AS `key`,
8
+            IFNULL( s.cnt, 0 ) AS `value`
9
+        FROM
10
+        sequence t
11
+            LEFT JOIN (
12
+            SELECT
13
+                DATE_FORMAT( a.create_date, '%Y-%m-%d' ) AS rq,
14
+                COUNT( 1 ) AS cnt
15
+            FROM
16
+                `ta_pv` a
17
+            WHERE
18
+                DATE_FORMAT( a.create_date, '%Y-%m-%d' ) &gt;= #{startDate}
19
+                AND DATE_FORMAT( a.create_date, '%Y-%m-%d' ) &lt; #{endDate}
20
+                GROUP BY
21
+                DATE_FORMAT( a.create_date, '%Y-%m-%d' )
22
+            ) s ON DATE_ADD( #{startDate}, INTERVAL t.rownum DAY ) = s.rq
23
+        WHERE
24
+            t.rownum &lt; #{days}
25
+        ORDER BY
26
+            t.rownum ASC
27
+    </select>
28
+    <select id="statisUVDaily" resultType="com.yunzhi.dianyang.vo.ChartParam">
29
+        SELECT
30
+            DATE_ADD( #{startDate}, INTERVAL t.rownum DAY ) AS `key`,
31
+            IFNULL( s.cnt, 0 ) AS `value`
32
+        FROM
33
+            sequence t
34
+                LEFT JOIN (
35
+                SELECT
36
+                    DATE_FORMAT( a.create_date, '%Y-%m-%d' ) AS rq,
37
+                    COUNT( DISTINCT a.person_id ) AS cnt
38
+                FROM
39
+                    `ta_pv` a
40
+                WHERE
41
+                    DATE_FORMAT( a.create_date, '%Y-%m-%d' ) &gt;= #{startDate}
42
+                  AND DATE_FORMAT( a.create_date, '%Y-%m-%d' ) &lt; #{endDate}
43
+                GROUP BY
44
+                    DATE_FORMAT( a.create_date, '%Y-%m-%d' )
45
+            ) s ON DATE_ADD( #{startDate}, INTERVAL t.rownum DAY ) = s.rq
46
+        WHERE
47
+            t.rownum &lt; #{days}
48
+        ORDER BY
49
+            t.rownum ASC
50
+    </select>
51
+</mapper>

+ 51
- 0
src/main/resources/mapper/TaRegisterMapper.xml Vedi File

@@ -0,0 +1,51 @@
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.dianyang.mapper.TaRegisterMapper">
4
+
5
+    <sql id="queryList">
6
+        SELECT
7
+        t.reg_id,
8
+        t.`name`,
9
+        t.sex,
10
+        t.phone,
11
+        t.person_type,
12
+        t.state,
13
+        t.create_date,
14
+        t.area_code,
15
+        t.interest_to,
16
+        IF ( n.id IS NULL, t.area_name, CONCAT( n.`name`, '/', m.`name` ) ) AS area_name
17
+        FROM
18
+        ta_register t
19
+        LEFT JOIN td_city m ON t.area_code = m.id
20
+        LEFT JOIN td_city n ON m.parentid = n.id
21
+        WHERE
22
+        t.state = 1
23
+        <if test="name != null and name != ''">
24
+            AND t.`name` LIKE concat( '%', #{name}, '%' )
25
+        </if>
26
+        <if test="phone != null and phone != ''">
27
+            AND t.phone LIKE concat( '%', #{phone}, '%' )
28
+        </if>
29
+        <if test="area != null and area != ''">
30
+            AND ( m.id = #{area} OR m.parentid = #{area} )
31
+        </if>
32
+        <if test="personType != null and personType != ''">
33
+            AND t.person_type = #{personType}
34
+        </if>
35
+        <if test="start != null">
36
+            AND t.create_date &gt;= #{start}
37
+        </if>
38
+        <if test="end != null">
39
+            AND t.create_date &lt;= #{end}
40
+        </if>
41
+        ORDER BY
42
+        t.create_date DESC
43
+    </sql>
44
+
45
+    <select id="getPageBy" resultType="com.yunzhi.dianyang.entity.TaRegister">
46
+        <include refid="queryList"></include>
47
+    </select>
48
+    <select id="getListBy" resultType="com.yunzhi.dianyang.entity.TaRegister">
49
+        <include refid="queryList"></include>
50
+    </select>
51
+</mapper>

+ 5
- 0
src/main/resources/mapper/TaShareMapper.xml Vedi File

@@ -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.dianyang.mapper.TaShareMapper">
4
+
5
+</mapper>

+ 5
- 0
src/main/resources/mapper/TdCityMapper.xml Vedi File

@@ -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.dianyang.mapper.TdCityMapper">
4
+
5
+</mapper>