Ver código fonte

first commit

张延森 3 anos atrás
commit
27a974d1fd
93 arquivos alterados com 5244 adições e 0 exclusões
  1. 37
    0
      .gitignore
  2. 5
    0
      deploy/bootstrap
  3. 35
    0
      deploy/s.yml
  4. 316
    0
      mvnw
  5. 188
    0
      mvnw.cmd
  6. 273
    0
      pom.xml
  7. 18
    0
      src/main/java/com/njyunzhi/pet_identity/UbpaApplication.java
  8. 47
    0
      src/main/java/com/njyunzhi/pet_identity/common/BaseController.java
  9. 18
    0
      src/main/java/com/njyunzhi/pet_identity/common/Constants.java
  10. 51
    0
      src/main/java/com/njyunzhi/pet_identity/common/DateUtils.java
  11. 17
    0
      src/main/java/com/njyunzhi/pet_identity/common/EncryptUtils.java
  12. 104
    0
      src/main/java/com/njyunzhi/pet_identity/common/ExcelUtils.java
  13. 87
    0
      src/main/java/com/njyunzhi/pet_identity/common/HttpUtils.java
  14. 191
    0
      src/main/java/com/njyunzhi/pet_identity/common/IpUtil.java
  15. 11
    0
      src/main/java/com/njyunzhi/pet_identity/common/MathUtils.java
  16. 59
    0
      src/main/java/com/njyunzhi/pet_identity/common/MessageUtil.java
  17. 166
    0
      src/main/java/com/njyunzhi/pet_identity/common/OSSUtils.java
  18. 76
    0
      src/main/java/com/njyunzhi/pet_identity/common/ResponseBean.java
  19. 155
    0
      src/main/java/com/njyunzhi/pet_identity/common/SMSCaptcha.java
  20. 58
    0
      src/main/java/com/njyunzhi/pet_identity/common/SMSUtils.java
  21. 125
    0
      src/main/java/com/njyunzhi/pet_identity/common/StringUtils.java
  22. 40
    0
      src/main/java/com/njyunzhi/pet_identity/common/WxUtils.java
  23. 39
    0
      src/main/java/com/njyunzhi/pet_identity/common/excelConverter/LocalDateTimeConverter.java
  24. 49
    0
      src/main/java/com/njyunzhi/pet_identity/common/excelConverter/ResultStatusConverter.java
  25. 40
    0
      src/main/java/com/njyunzhi/pet_identity/config/AliyunConfig.java
  26. 48
    0
      src/main/java/com/njyunzhi/pet_identity/config/CorsConfig.java
  27. 30
    0
      src/main/java/com/njyunzhi/pet_identity/config/DateConverterConfig.java
  28. 70
    0
      src/main/java/com/njyunzhi/pet_identity/config/JacksonConfig.java
  29. 21
    0
      src/main/java/com/njyunzhi/pet_identity/config/LoggingFilterConfig.java
  30. 14
    0
      src/main/java/com/njyunzhi/pet_identity/config/MybatisPlusConfig.java
  31. 45
    0
      src/main/java/com/njyunzhi/pet_identity/config/SaTokenConfigure.java
  32. 24
    0
      src/main/java/com/njyunzhi/pet_identity/config/SwagggerConfig.java
  33. 40
    0
      src/main/java/com/njyunzhi/pet_identity/config/WeixinConfig.java
  34. 104
    0
      src/main/java/com/njyunzhi/pet_identity/controller/CommController.java
  35. 117
    0
      src/main/java/com/njyunzhi/pet_identity/controller/LoginController.java
  36. 119
    0
      src/main/java/com/njyunzhi/pet_identity/controller/SysSettingController.java
  37. 197
    0
      src/main/java/com/njyunzhi/pet_identity/controller/SysUserController.java
  38. 119
    0
      src/main/java/com/njyunzhi/pet_identity/controller/TaApplicationController.java
  39. 139
    0
      src/main/java/com/njyunzhi/pet_identity/controller/TaBannerController.java
  40. 151
    0
      src/main/java/com/njyunzhi/pet_identity/controller/TaNoticeController.java
  41. 119
    0
      src/main/java/com/njyunzhi/pet_identity/controller/TaOrderController.java
  42. 120
    0
      src/main/java/com/njyunzhi/pet_identity/controller/TaPersonController.java
  43. 140
    0
      src/main/java/com/njyunzhi/pet_identity/controller/WxMaController.java
  44. 55
    0
      src/main/java/com/njyunzhi/pet_identity/controller/WxPayController.java
  45. 49
    0
      src/main/java/com/njyunzhi/pet_identity/entity/SysSetting.java
  46. 61
    0
      src/main/java/com/njyunzhi/pet_identity/entity/SysUser.java
  47. 81
    0
      src/main/java/com/njyunzhi/pet_identity/entity/TaApplication.java
  48. 46
    0
      src/main/java/com/njyunzhi/pet_identity/entity/TaBanner.java
  49. 52
    0
      src/main/java/com/njyunzhi/pet_identity/entity/TaNotice.java
  50. 52
    0
      src/main/java/com/njyunzhi/pet_identity/entity/TaOrder.java
  51. 67
    0
      src/main/java/com/njyunzhi/pet_identity/entity/TaPerson.java
  52. 19
    0
      src/main/java/com/njyunzhi/pet_identity/exception/GlobalExceptionHandler.java
  53. 18
    0
      src/main/java/com/njyunzhi/pet_identity/mapper/SysSettingMapper.java
  54. 21
    0
      src/main/java/com/njyunzhi/pet_identity/mapper/SysUserMapper.java
  55. 18
    0
      src/main/java/com/njyunzhi/pet_identity/mapper/TaApplicationMapper.java
  56. 18
    0
      src/main/java/com/njyunzhi/pet_identity/mapper/TaBannerMapper.java
  57. 18
    0
      src/main/java/com/njyunzhi/pet_identity/mapper/TaNoticeMapper.java
  58. 18
    0
      src/main/java/com/njyunzhi/pet_identity/mapper/TaOrderMapper.java
  59. 18
    0
      src/main/java/com/njyunzhi/pet_identity/mapper/TaPersonMapper.java
  60. 33
    0
      src/main/java/com/njyunzhi/pet_identity/service/IBaseService.java
  61. 16
    0
      src/main/java/com/njyunzhi/pet_identity/service/ISysSettingService.java
  62. 18
    0
      src/main/java/com/njyunzhi/pet_identity/service/ISysUserService.java
  63. 16
    0
      src/main/java/com/njyunzhi/pet_identity/service/ITaApplicationService.java
  64. 16
    0
      src/main/java/com/njyunzhi/pet_identity/service/ITaBannerService.java
  65. 16
    0
      src/main/java/com/njyunzhi/pet_identity/service/ITaNoticeService.java
  66. 16
    0
      src/main/java/com/njyunzhi/pet_identity/service/ITaOrderService.java
  67. 16
    0
      src/main/java/com/njyunzhi/pet_identity/service/ITaPersonService.java
  68. 120
    0
      src/main/java/com/njyunzhi/pet_identity/service/impl/BaseServiceImpl.java
  69. 28
    0
      src/main/java/com/njyunzhi/pet_identity/service/impl/ManagerServiceImpl.java
  70. 20
    0
      src/main/java/com/njyunzhi/pet_identity/service/impl/SysSettingServiceImpl.java
  71. 25
    0
      src/main/java/com/njyunzhi/pet_identity/service/impl/SysUserServiceImpl.java
  72. 20
    0
      src/main/java/com/njyunzhi/pet_identity/service/impl/TaApplicationServiceImpl.java
  73. 20
    0
      src/main/java/com/njyunzhi/pet_identity/service/impl/TaBannerServiceImpl.java
  74. 20
    0
      src/main/java/com/njyunzhi/pet_identity/service/impl/TaNoticeServiceImpl.java
  75. 20
    0
      src/main/java/com/njyunzhi/pet_identity/service/impl/TaOrderServiceImpl.java
  76. 20
    0
      src/main/java/com/njyunzhi/pet_identity/service/impl/TaPersonServiceImpl.java
  77. 17
    0
      src/main/java/com/njyunzhi/pet_identity/vo/ChangePassword.java
  78. 55
    0
      src/main/java/com/njyunzhi/pet_identity/vo/FormExport.java
  79. 19
    0
      src/main/java/com/njyunzhi/pet_identity/vo/LoginParam.java
  80. 17
    0
      src/main/java/com/njyunzhi/pet_identity/vo/StatisValue.java
  81. 26
    0
      src/main/java/com/njyunzhi/pet_identity/vo/WxMaAuthParam.java
  82. 32
    0
      src/main/java/com/njyunzhi/pet_identity/vo/WxMaPreload.java
  83. 20
    0
      src/main/resources/application-dev.yml
  84. 17
    0
      src/main/resources/application-prod.yml
  85. 97
    0
      src/main/resources/application.yml
  86. 5
    0
      src/main/resources/mapper/SysSettingMapper.xml
  87. 28
    0
      src/main/resources/mapper/SysUserMapper.xml
  88. 5
    0
      src/main/resources/mapper/TaApplicationMapper.xml
  89. 5
    0
      src/main/resources/mapper/TaBannerMapper.xml
  90. 5
    0
      src/main/resources/mapper/TaNoticeMapper.xml
  91. 5
    0
      src/main/resources/mapper/TaOrderMapper.xml
  92. 5
    0
      src/main/resources/mapper/TaPersonMapper.xml
  93. 13
    0
      src/test/java/com/njyunzhi/pet_identity/UbpaApplicationTests.java

+ 37
- 0
.gitignore Ver arquivo

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

+ 5
- 0
deploy/bootstrap Ver arquivo

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

+ 35
- 0
deploy/s.yml Ver arquivo

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

+ 316
- 0
mvnw Ver arquivo

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

+ 188
- 0
mvnw.cmd Ver arquivo

@@ -0,0 +1,188 @@
1
+@REM ----------------------------------------------------------------------------
2
+@REM Licensed to the Apache Software Foundation (ASF) under one
3
+@REM or more contributor license agreements.  See the NOTICE file
4
+@REM distributed with this work for additional information
5
+@REM regarding copyright ownership.  The ASF licenses this file
6
+@REM to you under the Apache License, Version 2.0 (the
7
+@REM "License"); you may not use this file except in compliance
8
+@REM with the License.  You may obtain a copy of the License at
9
+@REM
10
+@REM    https://www.apache.org/licenses/LICENSE-2.0
11
+@REM
12
+@REM Unless required by applicable law or agreed to in writing,
13
+@REM software distributed under the License is distributed on an
14
+@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+@REM KIND, either express or implied.  See the License for the
16
+@REM specific language governing permissions and limitations
17
+@REM under the License.
18
+@REM ----------------------------------------------------------------------------
19
+
20
+@REM ----------------------------------------------------------------------------
21
+@REM Maven Start Up Batch script
22
+@REM
23
+@REM Required ENV vars:
24
+@REM JAVA_HOME - location of a JDK home dir
25
+@REM
26
+@REM Optional ENV vars
27
+@REM M2_HOME - location of maven2's installed home dir
28
+@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
29
+@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
30
+@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
31
+@REM     e.g. to debug Maven itself, use
32
+@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
33
+@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
34
+@REM ----------------------------------------------------------------------------
35
+
36
+@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
37
+@echo off
38
+@REM set title of command window
39
+title %0
40
+@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
41
+@if "%MAVEN_BATCH_ECHO%" == "on"  echo %MAVEN_BATCH_ECHO%
42
+
43
+@REM set %HOME% to equivalent of $HOME
44
+if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
45
+
46
+@REM Execute a user defined script before this one
47
+if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
48
+@REM check for pre script, once with legacy .bat ending and once with .cmd ending
49
+if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
50
+if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
51
+:skipRcPre
52
+
53
+@setlocal
54
+
55
+set ERROR_CODE=0
56
+
57
+@REM To isolate internal variables from possible post scripts, we use another setlocal
58
+@setlocal
59
+
60
+@REM ==== START VALIDATION ====
61
+if not "%JAVA_HOME%" == "" goto OkJHome
62
+
63
+echo.
64
+echo Error: JAVA_HOME not found in your environment. >&2
65
+echo Please set the JAVA_HOME variable in your environment to match the >&2
66
+echo location of your Java installation. >&2
67
+echo.
68
+goto error
69
+
70
+:OkJHome
71
+if exist "%JAVA_HOME%\bin\java.exe" goto init
72
+
73
+echo.
74
+echo Error: JAVA_HOME is set to an invalid directory. >&2
75
+echo JAVA_HOME = "%JAVA_HOME%" >&2
76
+echo Please set the JAVA_HOME variable in your environment to match the >&2
77
+echo location of your Java installation. >&2
78
+echo.
79
+goto error
80
+
81
+@REM ==== END VALIDATION ====
82
+
83
+:init
84
+
85
+@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
86
+@REM Fallback to current working directory if not found.
87
+
88
+set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
89
+IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
90
+
91
+set EXEC_DIR=%CD%
92
+set WDIR=%EXEC_DIR%
93
+:findBaseDir
94
+IF EXIST "%WDIR%"\.mvn goto baseDirFound
95
+cd ..
96
+IF "%WDIR%"=="%CD%" goto baseDirNotFound
97
+set WDIR=%CD%
98
+goto findBaseDir
99
+
100
+:baseDirFound
101
+set MAVEN_PROJECTBASEDIR=%WDIR%
102
+cd "%EXEC_DIR%"
103
+goto endDetectBaseDir
104
+
105
+:baseDirNotFound
106
+set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
107
+cd "%EXEC_DIR%"
108
+
109
+:endDetectBaseDir
110
+
111
+IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
112
+
113
+@setlocal EnableExtensions EnableDelayedExpansion
114
+for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
115
+@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
116
+
117
+:endReadAdditionalConfig
118
+
119
+SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
120
+set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
121
+set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
122
+
123
+set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
124
+
125
+FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
126
+    IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
127
+)
128
+
129
+@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
130
+@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
131
+if exist %WRAPPER_JAR% (
132
+    if "%MVNW_VERBOSE%" == "true" (
133
+        echo Found %WRAPPER_JAR%
134
+    )
135
+) else (
136
+    if not "%MVNW_REPOURL%" == "" (
137
+        SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
138
+    )
139
+    if "%MVNW_VERBOSE%" == "true" (
140
+        echo Couldn't find %WRAPPER_JAR%, downloading it ...
141
+        echo Downloading from: %DOWNLOAD_URL%
142
+    )
143
+
144
+    powershell -Command "&{"^
145
+		"$webclient = new-object System.Net.WebClient;"^
146
+		"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
147
+		"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
148
+		"}"^
149
+		"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
150
+		"}"
151
+    if "%MVNW_VERBOSE%" == "true" (
152
+        echo Finished downloading %WRAPPER_JAR%
153
+    )
154
+)
155
+@REM End of extension
156
+
157
+@REM Provide a "standardized" way to retrieve the CLI args that will
158
+@REM work with both Windows and non-Windows executions.
159
+set MAVEN_CMD_LINE_ARGS=%*
160
+
161
+%MAVEN_JAVA_EXE% ^
162
+  %JVM_CONFIG_MAVEN_PROPS% ^
163
+  %MAVEN_OPTS% ^
164
+  %MAVEN_DEBUG_OPTS% ^
165
+  -classpath %WRAPPER_JAR% ^
166
+  "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
167
+  %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
168
+if ERRORLEVEL 1 goto error
169
+goto end
170
+
171
+:error
172
+set ERROR_CODE=1
173
+
174
+:end
175
+@endlocal & set ERROR_CODE=%ERROR_CODE%
176
+
177
+if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
178
+@REM check for post script, once with legacy .bat ending and once with .cmd ending
179
+if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
180
+if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
181
+:skipRcPost
182
+
183
+@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
184
+if "%MAVEN_BATCH_PAUSE%"=="on" pause
185
+
186
+if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
187
+
188
+cmd /C exit /B %ERROR_CODE%

+ 273
- 0
pom.xml Ver arquivo

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

+ 18
- 0
src/main/java/com/njyunzhi/pet_identity/UbpaApplication.java Ver arquivo

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

+ 47
- 0
src/main/java/com/njyunzhi/pet_identity/common/BaseController.java Ver arquivo

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

+ 18
- 0
src/main/java/com/njyunzhi/pet_identity/common/Constants.java Ver arquivo

@@ -0,0 +1,18 @@
1
+package com.njyunzhi.pet_identity.common;
2
+
3
+public class Constants {
4
+    public final static int STATUS_DELETE = -1;
5
+    public final static int STATUS_READY = 0;
6
+    public final static int STATUS_NORMAL = 1;
7
+
8
+    public final static String SETTING_REPORT_URL = "report_url";
9
+
10
+    //
11
+    public final static String LOGIN_TYPE_ADMIN = "admin";
12
+    public final static String LOGIN_TYPE_MINIAPP = "miniapp";
13
+
14
+    //
15
+    public final static String USER_ADMIN = "admin";
16
+    public final static String USER_AUDITOR = "auditor";
17
+    public final static String USER_MAKER = "maker";
18
+}

+ 51
- 0
src/main/java/com/njyunzhi/pet_identity/common/DateUtils.java Ver arquivo

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

+ 17
- 0
src/main/java/com/njyunzhi/pet_identity/common/EncryptUtils.java Ver arquivo

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

+ 104
- 0
src/main/java/com/njyunzhi/pet_identity/common/ExcelUtils.java Ver arquivo

@@ -0,0 +1,104 @@
1
+package com.njyunzhi.pet_identity.common;
2
+
3
+import com.alibaba.excel.EasyExcel;
4
+import com.alibaba.excel.write.builder.ExcelWriterBuilder;
5
+import com.alibaba.excel.write.metadata.style.WriteCellStyle;
6
+import com.alibaba.excel.write.metadata.style.WriteFont;
7
+import com.alibaba.excel.write.style.HorizontalCellStyleStrategy;
8
+import com.alibaba.fastjson.JSON;
9
+import org.apache.poi.ss.usermodel.BorderStyle;
10
+import org.apache.poi.ss.usermodel.FillPatternType;
11
+import org.apache.poi.ss.usermodel.IndexedColors;
12
+import org.apache.poi.ss.usermodel.VerticalAlignment;
13
+import org.apache.poi.xssf.usermodel.DefaultIndexedColorMap;
14
+import org.apache.poi.xssf.usermodel.XSSFColor;
15
+
16
+import javax.servlet.http.HttpServletResponse;
17
+import java.io.IOException;
18
+import java.util.List;
19
+
20
+public class ExcelUtils {
21
+
22
+//    public static void fill(HttpServletResponse response, String tpl, List data, Map<String, Object> otherData, String fileName) throws IOException {
23
+//        response.setContentType("application/vnd.ms-excel");
24
+//        response.setCharacterEncoding("utf-8");
25
+//        response.setHeader("Content-disposition", "attachment;filename="+StringUtils.urlEncode(fileName)+".xlsx");
26
+//
27
+//        ClassPathResource classPathResource = new ClassPathResource(tpl);
28
+//        InputStream tplStream =classPathResource.getInputStream();
29
+//
30
+//        ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream()).withTemplate(tplStream).build();
31
+//        WriteSheet writeSheet = EasyExcel.writerSheet().build();
32
+//        // 写入内容部分
33
+//        for(Object it: data) {
34
+//            excelWriter.fill(it, writeSheet);
35
+//        }
36
+//        // 写入其余部分
37
+//        excelWriter.fill(otherData, writeSheet);
38
+//        excelWriter.finish();
39
+//    }
40
+
41
+    public static XSSFColor color(int r, int g, int b) {
42
+        return new XSSFColor(new java.awt.Color(r, g, b), new DefaultIndexedColorMap());
43
+    }
44
+
45
+    public static HorizontalCellStyleStrategy defaultStyle() {
46
+        // 头的策略
47
+        WriteCellStyle headWriteCellStyle = new WriteCellStyle();
48
+        // 背景
49
+        headWriteCellStyle.setFillForegroundColor(IndexedColors.LIGHT_GREEN.getIndex());
50
+        WriteFont headWriteFont = new WriteFont();
51
+        headWriteFont.setFontName("微软雅黑");
52
+        headWriteFont.setFontHeightInPoints((short)14);
53
+        headWriteCellStyle.setWriteFont(headWriteFont);
54
+        headWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
55
+        // 内容的策略
56
+        WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
57
+        // 这里需要指定 FillPatternType 为FillPatternType.SOLID_FOREGROUND 不然无法显示背景颜色.头默认了 FillPatternType所以可以不指定
58
+        contentWriteCellStyle.setFillPatternType(FillPatternType.SOLID_FOREGROUND);
59
+        // 背景
60
+        contentWriteCellStyle.setFillForegroundColor(IndexedColors.WHITE.getIndex());
61
+        WriteFont contentWriteFont = new WriteFont();
62
+        contentWriteFont.setFontName("微软雅黑");
63
+        contentWriteFont.setFontHeightInPoints((short)12);
64
+        contentWriteCellStyle.setWriteFont(contentWriteFont);
65
+        contentWriteCellStyle.setBorderBottom(BorderStyle.THIN);   // 下边框
66
+        contentWriteCellStyle.setBorderLeft(BorderStyle.THIN);     // 左边框
67
+        contentWriteCellStyle.setBorderTop(BorderStyle.THIN);      // 上边框
68
+        contentWriteCellStyle.setBorderRight(BorderStyle.THIN);    // 右边框
69
+        contentWriteCellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
70
+        return new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
71
+    }
72
+
73
+    /**
74
+     * 发送 excel 到客户端
75
+     * 暂时只支持单 sheet 页
76
+     * @param response
77
+     * @param data
78
+     * @param fileName
79
+     * @throws IOException
80
+     */
81
+    public static void flush(HttpServletResponse response, Class dataClass, List data, String fileName, HorizontalCellStyleStrategy style) throws IOException {
82
+        try {
83
+            response.setContentType("application/vnd.ms-excel");
84
+            response.setCharacterEncoding("utf-8");
85
+            response.setHeader("Content-disposition", "attachment;filename="+StringUtils.urlEncode(fileName)+".xlsx");
86
+            ExcelWriterBuilder builder = EasyExcel.write(response.getOutputStream(), dataClass);
87
+            if (null == style) {
88
+                style = defaultStyle();
89
+                builder.registerWriteHandler(style);
90
+            }
91
+            builder.autoCloseStream(Boolean.FALSE).sheet("sheet1").doWrite(data);
92
+        } catch (Exception e) {
93
+            e.printStackTrace();
94
+
95
+            // 重置response
96
+            response.reset();
97
+            response.setContentType("application/json");
98
+            response.setCharacterEncoding("utf-8");
99
+            ResponseBean res = ResponseBean.error(e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
100
+            response.getWriter().println(JSON.toJSONString(res));
101
+        }
102
+
103
+    }
104
+}

+ 87
- 0
src/main/java/com/njyunzhi/pet_identity/common/HttpUtils.java Ver arquivo

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

+ 191
- 0
src/main/java/com/njyunzhi/pet_identity/common/IpUtil.java Ver arquivo

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

+ 11
- 0
src/main/java/com/njyunzhi/pet_identity/common/MathUtils.java Ver arquivo

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

+ 59
- 0
src/main/java/com/njyunzhi/pet_identity/common/MessageUtil.java Ver arquivo

@@ -0,0 +1,59 @@
1
+package com.njyunzhi.pet_identity.common;
2
+
3
+import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
4
+import com.alibaba.fastjson.JSONArray;
5
+import com.alibaba.fastjson.JSONObject;
6
+import lombok.Data;
7
+
8
+import java.util.Formatter;
9
+import java.util.List;
10
+
11
+public class MessageUtil {
12
+
13
+    public static List<WxMaSubscribeMessage.MsgData> getWxMessageData(String jsonStr, Object ...values) {
14
+        String str = new Formatter().format(jsonStr, values).toString();
15
+
16
+        return JSONArray.parseArray(str, WxMaSubscribeMessage.MsgData.class);
17
+    }
18
+
19
+//    public static WxMaSubscribeMessage getWxMaSubscribeMessage(TaMessageTemplate taMessageTemplate) {
20
+//        if (null == taMessageTemplate) return null;
21
+//
22
+//        WxMaSubscribeMessage message = new WxMaSubscribeMessage();
23
+//        message.setTemplateId(taMessageTemplate.getAppTplId());
24
+//
25
+//        return message;
26
+//    }
27
+//
28
+//    public static SMSUtils.Message getSmsMessage(TaMessageTemplate taMessageTemplate) {
29
+//        if (null == taMessageTemplate) return null;
30
+//
31
+//        SMSUtils.Message message = new SMSUtils.Message();
32
+//        message.setCode(taMessageTemplate.getAppTplId());
33
+//        message.setSign(taMessageTemplate.getAppTplSign());
34
+//
35
+//        return message;
36
+//    }
37
+
38
+    @Data
39
+    public static class NaviPage {
40
+        private String page;
41
+        private String query;
42
+
43
+        NaviPage() {}
44
+        public static NaviPage fromJSON(String jsonStr) {
45
+            JSONObject jsonObject = JSONObject.parseObject(jsonStr);
46
+            NaviPage naviPage = new NaviPage();
47
+            naviPage.page = (String) jsonObject.get("page");
48
+            naviPage.query = (String) jsonObject.get("query");
49
+            return naviPage;
50
+        }
51
+
52
+        public String toURL(Object ...values) {
53
+            String queryString = new Formatter().format(this.query, values).toString();
54
+            return this.page + "?" + queryString;
55
+        }
56
+
57
+    }
58
+
59
+}

+ 166
- 0
src/main/java/com/njyunzhi/pet_identity/common/OSSUtils.java Ver arquivo

@@ -0,0 +1,166 @@
1
+package com.njyunzhi.pet_identity.common;
2
+
3
+import com.aliyun.oss.OSSClient;
4
+import com.aliyuncs.DefaultAcsClient;
5
+import com.aliyuncs.auth.sts.AssumeRoleRequest;
6
+import com.aliyuncs.auth.sts.AssumeRoleResponse;
7
+import com.aliyuncs.exceptions.ClientException;
8
+import com.aliyuncs.http.MethodType;
9
+import com.aliyuncs.profile.DefaultProfile;
10
+import com.aliyuncs.profile.IClientProfile;
11
+import com.njyunzhi.pet_identity.config.AliyunConfig;
12
+import lombok.extern.slf4j.Slf4j;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.stereotype.Component;
15
+import org.springframework.web.multipart.MultipartFile;
16
+
17
+import java.io.*;
18
+import java.time.LocalDateTime;
19
+import java.time.format.DateTimeFormatter;
20
+import java.util.Base64;
21
+import java.util.HashMap;
22
+import java.util.Map;
23
+
24
+@Slf4j
25
+@Component
26
+public class OSSUtils {
27
+
28
+    private final static String STS_ENDPOINT = "sts.aliyuncs.com";
29
+
30
+    @Autowired
31
+    AliyunConfig aliyunConfig;
32
+
33
+    private String getMonth() {
34
+        return DateTimeFormatter.ofPattern("yyyyMM").format(LocalDateTime.now());
35
+    }
36
+
37
+    private String getUploadPath(String[] toDirs) {
38
+        String path = toDirs.length > 0 ? toDirs[0] : "/";
39
+        if (!path.endsWith("/")) {
40
+            path += "/";
41
+        }
42
+
43
+        return path + getMonth() + "/";
44
+    }
45
+
46
+    /**
47
+     * 上传 base64
48
+     * @param base64Str
49
+     * @param toDirs
50
+     * @return
51
+     * @throws IOException
52
+     */
53
+    public String putObject(String base64Str, String ...toDirs) throws IOException {
54
+        int index = base64Str.indexOf("base64,");
55
+
56
+        if (index > -1) {
57
+            index += 7;
58
+        } else {
59
+            index = 0;
60
+        }
61
+
62
+        String dataStr = base64Str.substring(index);
63
+        byte[] data = Base64.getDecoder().decode(dataStr);
64
+        ByteArrayInputStream inputStream = new ByteArrayInputStream(data);
65
+        String toDir = getUploadPath(toDirs);
66
+        String nwFName = toDir + System.currentTimeMillis() + ".png";
67
+        nwFName = StringUtils.trim(nwFName,"/");
68
+        return putFile(nwFName, inputStream);
69
+    }
70
+
71
+    /**
72
+     * 上传文件
73
+     * @param mf 上传的文件
74
+     * @param toDirs 上传到的目录
75
+     * @return
76
+     */
77
+    public String putObject(MultipartFile mf, String ... toDirs) throws IOException {
78
+        String fName = formatFileName(mf.getOriginalFilename());
79
+        String preFix = String.valueOf(System.currentTimeMillis());
80
+        String toDir = getUploadPath(toDirs);
81
+        String nwFName = toDir + preFix + "-" + fName;
82
+        nwFName = StringUtils.trim(nwFName,"/");
83
+
84
+        return putFile(nwFName, new ByteArrayInputStream(mf.getBytes()));
85
+    }
86
+
87
+    public String putObject(File f, String ... toDirs) throws FileNotFoundException {
88
+        String fName = formatFileName(f.getName());
89
+        String preFix = String.valueOf(System.currentTimeMillis());
90
+        String toDir = getUploadPath(toDirs);
91
+        String nwFName = toDir + preFix + "-" + fName;
92
+        nwFName = StringUtils.trim(nwFName,"/");
93
+
94
+        InputStream inputStream = new FileInputStream(f);
95
+        return putFile(nwFName, inputStream);
96
+    }
97
+
98
+    public String putObject(InputStream inputStream, String fName, String ... toDirs) {
99
+        String toDir = getUploadPath(toDirs);
100
+        String nwFName = toDir + fName;
101
+        nwFName = StringUtils.trim(nwFName,"/");
102
+        return putFile(nwFName, inputStream);
103
+    }
104
+
105
+    private String formatFileName(String fName) {
106
+        return StringUtils.ifNull(fName, StringUtils.random(16) + ".png");
107
+    }
108
+
109
+    private String putFile(String fname, InputStream input) {
110
+        OSSClient ossClient = new OSSClient(aliyunConfig.getOss().getEndpoint(), aliyunConfig.getAccessKeyId(), aliyunConfig.getAccessKeySecret());
111
+        ossClient.putObject(aliyunConfig.getOss().getBucketName(), fname, input);
112
+        ossClient.shutdown();
113
+
114
+        // String url = ossClient.generatePresignedUrl(AliOSSUtils.oss.getBucketName(), fname, expiration).toString();
115
+
116
+        String preURL = aliyunConfig.getOss().getBucketURL();
117
+        if (!preURL.endsWith("/")) {
118
+            preURL += "/";
119
+        }
120
+
121
+        return preURL + fname.replaceAll("\\ ", "%20").replaceAll("\\'", "%27");
122
+    }
123
+
124
+    /**
125
+     * 获取上传凭证
126
+     * @return
127
+     * @throws Exception
128
+     */
129
+    public Map<String, Object> getSTSAKToken() throws Exception {
130
+        AliyunConfig.Oss oss = aliyunConfig.getOss();
131
+
132
+        try {
133
+            // 添加endpoint(直接使用STS endpoint,无需添加region ID)
134
+            DefaultProfile.addEndpoint("", "Sts", STS_ENDPOINT);
135
+            // 构造default profile(参数留空,无需添加region ID)
136
+            IClientProfile profile = DefaultProfile.getProfile("", oss.getAccessKeyId(), oss.getAccessKeySecret());
137
+
138
+            // 用profile构造client
139
+            DefaultAcsClient client = new DefaultAcsClient(profile);
140
+            final AssumeRoleRequest request = new AssumeRoleRequest();
141
+            request.setSysMethod(MethodType.POST);
142
+            request.setRoleArn(oss.getArn());
143
+            request.setRoleSessionName(oss.getRoleSessionName());
144
+            request.setPolicy(null); // 若policy为空,则用户将获得该角色下所有权限
145
+            request.setDurationSeconds(30 * 60L); // 设置凭证有效时间 1800 秒 = 30 分钟
146
+            final AssumeRoleResponse response = client.getAcsResponse(request);
147
+
148
+            AssumeRoleResponse.Credentials credentials = response.getCredentials();
149
+
150
+            Map<String, Object> res = new HashMap<>();
151
+            res.put("stsToken", credentials.getSecurityToken());
152
+            res.put("accessKeySecret", credentials.getAccessKeySecret());
153
+            res.put("accessKeyId", credentials.getAccessKeyId());
154
+            res.put("expiration", credentials.getExpiration());
155
+
156
+            return res;
157
+        } catch (ClientException e) {
158
+            e.printStackTrace();
159
+            log.error("Error code: " + e.getErrCode());
160
+            log.error("Error message: " + e.getErrMsg());
161
+            log.error("RequestId: " + e.getRequestId());
162
+            throw new Exception(e.getMessage());
163
+        }
164
+    }
165
+
166
+}

+ 76
- 0
src/main/java/com/njyunzhi/pet_identity/common/ResponseBean.java Ver arquivo

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

+ 155
- 0
src/main/java/com/njyunzhi/pet_identity/common/SMSCaptcha.java Ver arquivo

@@ -0,0 +1,155 @@
1
+package com.njyunzhi.pet_identity.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/njyunzhi/pet_identity/common/SMSUtils.java Ver arquivo

@@ -0,0 +1,58 @@
1
+package com.njyunzhi.pet_identity.common;
2
+
3
+import com.alibaba.fastjson.JSONObject;
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, JSONObject.toJSONString(body, false));
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
+}

+ 125
- 0
src/main/java/com/njyunzhi/pet_identity/common/StringUtils.java Ver arquivo

@@ -0,0 +1,125 @@
1
+package com.njyunzhi.pet_identity.common;
2
+
3
+import java.io.UnsupportedEncodingException;
4
+import java.net.URLEncoder;
5
+import java.util.Random;
6
+import java.util.UUID;
7
+import java.util.regex.Matcher;
8
+import java.util.regex.Pattern;
9
+
10
+public class StringUtils {
11
+    private static Pattern humpPattern = Pattern.compile("[A-Z]");
12
+
13
+    public static boolean isEmpty(String str) {
14
+        return null == str || "".equals(str.trim()) || "null".equals(str) || "undefined".equals(str);
15
+    }
16
+
17
+    public static String trim(String src, String...st) {
18
+        if (null == src) return src;
19
+        if (null == st || st.length == 0) return src.trim();
20
+
21
+        String start = st[0];
22
+        if (!src.startsWith(start)) {
23
+            return src;
24
+        }
25
+
26
+        return src.substring(start.length());
27
+    }
28
+
29
+    public static String trimEnd(String src, String str) {
30
+        if (null == src || null == str) {
31
+            return src;
32
+        }
33
+
34
+        if (src.endsWith(str)) {
35
+            return src.substring(0, src.length() - str.length());
36
+        }
37
+
38
+        return src;
39
+    }
40
+
41
+    public static String ifNull(String src, String defaultVal) {
42
+        return isEmpty(src) ? defaultVal : src;
43
+    }
44
+
45
+    public static String random(int length) {
46
+        String str="abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
47
+        Random random = new Random();
48
+        StringBuffer sb = new StringBuffer();
49
+        for(int i=0;i<length;i++){
50
+            int number=random.nextInt(62);
51
+            sb.append(str.charAt(number));
52
+        }
53
+        return sb.toString();
54
+    }
55
+
56
+    public static String uuid() {
57
+        return UUID.randomUUID().toString().replaceAll("-", "");
58
+    }
59
+
60
+    public static String urlEncode(String str) {
61
+        try {
62
+            return URLEncoder.encode(str, "UTF-8");
63
+        } catch (UnsupportedEncodingException e) {
64
+            e.printStackTrace();
65
+            return str;
66
+        }
67
+    }
68
+
69
+    public static String humpToLine(String str) {
70
+        if (null == str || "".equals(str)) return "";
71
+
72
+        Matcher matcher = humpPattern.matcher(str);
73
+        StringBuffer sb = new StringBuffer();
74
+        while (matcher.find()) {
75
+            matcher.appendReplacement(sb, "_" + matcher.group(0).toLowerCase());
76
+        }
77
+        matcher.appendTail(sb);
78
+        return sb.toString();
79
+    }
80
+
81
+    public static String strToUnicode(String str) {
82
+        char[] chars = str.toCharArray();
83
+        String returnStr = "";
84
+        for (int i = 0; i < chars.length; i++) {
85
+            returnStr += "\\u" + Integer.toString(chars[i], 16);
86
+        }
87
+        return returnStr;
88
+    }
89
+
90
+    public static String repeat(String src, int len) {
91
+        if (null == src) {
92
+            return null;
93
+        }
94
+
95
+        if (len <= 0) {
96
+            return src;
97
+        }
98
+
99
+        String res = "";
100
+        for (int i = 0; i < len; i ++) {
101
+            res += src;
102
+        }
103
+
104
+        return res;
105
+    }
106
+
107
+    public static String lpad(String src, String padStr, int len) {
108
+        if (null == src) {
109
+            return null;
110
+        }
111
+
112
+        if (len <= 0 || src.length() >= len) {
113
+            return src;
114
+        }
115
+
116
+        if (null == padStr) {
117
+            padStr = "";
118
+        }
119
+
120
+        int padLen = len - src.length();
121
+        String prefix = repeat(padStr, padLen);
122
+        prefix = prefix.substring(0, padLen);
123
+        return prefix + src;
124
+    }
125
+}

+ 40
- 0
src/main/java/com/njyunzhi/pet_identity/common/WxUtils.java Ver arquivo

@@ -0,0 +1,40 @@
1
+package com.njyunzhi.pet_identity.common;
2
+
3
+import cn.binarywang.wx.miniapp.api.WxMaService;
4
+import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
5
+import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
6
+import com.njyunzhi.pet_identity.config.WeixinConfig;
7
+import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.stereotype.Component;
9
+
10
+@Component
11
+public class WxUtils {
12
+    //
13
+    private final WeixinConfig config;
14
+    //
15
+    private static WxMaService maService;
16
+
17
+    @Autowired
18
+    public WxUtils(WeixinConfig config) {
19
+        this.config = config;
20
+        this.maService = initMaService(config);
21
+    }
22
+
23
+    public WxMaService getMaService() throws Exception {
24
+        return maService;
25
+    }
26
+
27
+    private WxMaService initMaService(WeixinConfig config) {
28
+        WxMaDefaultConfigImpl conf = new WxMaDefaultConfigImpl();
29
+        WeixinConfig.Miniapp miniapp = config.getMiniapp();
30
+        conf.setAppid(miniapp.getAppid());
31
+        conf.setSecret(miniapp.getSecret());
32
+        conf.setToken(miniapp.getToken());
33
+        conf.setAesKey(miniapp.getAesKey());
34
+        conf.setMsgDataFormat("JSON");
35
+
36
+        WxMaService service = new WxMaServiceImpl();
37
+        service.setWxMaConfig(conf);
38
+        return service;
39
+    }
40
+}

+ 39
- 0
src/main/java/com/njyunzhi/pet_identity/common/excelConverter/LocalDateTimeConverter.java Ver arquivo

@@ -0,0 +1,39 @@
1
+package com.njyunzhi.pet_identity.common.excelConverter;
2
+
3
+import com.alibaba.excel.converters.Converter;
4
+import com.alibaba.excel.enums.CellDataTypeEnum;
5
+import com.alibaba.excel.metadata.GlobalConfiguration;
6
+import com.alibaba.excel.metadata.data.WriteCellData;
7
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
8
+import com.njyunzhi.pet_identity.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 value
26
+     * @param contentProperty
27
+     * @param globalConfiguration
28
+     * @return
29
+     * @throws Exception
30
+     */
31
+    @Override
32
+    public WriteCellData<?> convertToExcelData(LocalDateTime value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
33
+        if (null == value) return null;
34
+
35
+        String val = DateUtils.toString(value, "yyyy-MM-dd HH:mm:ss");
36
+
37
+        return new WriteCellData(val);
38
+    }
39
+}

+ 49
- 0
src/main/java/com/njyunzhi/pet_identity/common/excelConverter/ResultStatusConverter.java Ver arquivo

@@ -0,0 +1,49 @@
1
+package com.njyunzhi.pet_identity.common.excelConverter;
2
+
3
+import com.alibaba.excel.converters.Converter;
4
+import com.alibaba.excel.enums.CellDataTypeEnum;
5
+import com.alibaba.excel.metadata.GlobalConfiguration;
6
+import com.alibaba.excel.metadata.data.WriteCellData;
7
+import com.alibaba.excel.metadata.property.ExcelContentProperty;
8
+
9
+public class ResultStatusConverter implements Converter<Integer> {
10
+    @Override
11
+    public Class supportJavaTypeKey() {
12
+        return Integer.class;
13
+    }
14
+
15
+    @Override
16
+    public CellDataTypeEnum supportExcelTypeKey() {
17
+        return CellDataTypeEnum.STRING;
18
+    }
19
+
20
+    /**
21
+     * 写 excel
22
+     * @param value
23
+     * @param contentProperty
24
+     * @param globalConfiguration
25
+     * @return
26
+     * @throws Exception
27
+     */
28
+    @Override
29
+    public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
30
+        String result = null;
31
+        if (null == value) return null;
32
+
33
+        final int on = 1;
34
+        final int off = 0;
35
+
36
+        switch (value) {
37
+            case on:
38
+                result = "正常";
39
+                break;
40
+            case off:
41
+                result = "异常";
42
+                break;
43
+            default:
44
+                break;
45
+        }
46
+
47
+        return new WriteCellData(result);
48
+    }
49
+}

+ 40
- 0
src/main/java/com/njyunzhi/pet_identity/config/AliyunConfig.java Ver arquivo

@@ -0,0 +1,40 @@
1
+package com.njyunzhi.pet_identity.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 = "aliyun")
10
+public class AliyunConfig {
11
+    private String accessKeyId;
12
+    private String accessKeySecret;
13
+
14
+    private Oss oss;
15
+
16
+//    private Sms sms;
17
+
18
+    @Data
19
+    public  static class Oss {
20
+        private String roleSessionName;
21
+        private String accessKeyId;
22
+        private String accessKeySecret;
23
+        private String arn;
24
+        private String region;
25
+        private String endpoint;
26
+        private String bucketName;
27
+        private String bucketURL;
28
+    }
29
+
30
+//    @Data
31
+//    public static class Sms {
32
+//        private Captcha captcha;
33
+//    }
34
+//
35
+//    @Data
36
+//    public static class Captcha {
37
+//        private String code;
38
+//        private String sign;
39
+//    }
40
+}

+ 48
- 0
src/main/java/com/njyunzhi/pet_identity/config/CorsConfig.java Ver arquivo

@@ -0,0 +1,48 @@
1
+package com.njyunzhi.pet_identity.config;
2
+
3
+import org.springframework.beans.factory.annotation.Value;
4
+import org.springframework.context.annotation.Configuration;
5
+import org.springframework.web.servlet.config.annotation.CorsRegistration;
6
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
7
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
8
+
9
+// TODO
10
+// 这个配置实际上不生效,不知道为什么
11
+
12
+@Configuration
13
+public class CorsConfig implements WebMvcConfigurer {
14
+
15
+    @Value("${yz.cros}")
16
+    Boolean useCROS;
17
+
18
+    @Value("${yz.mode}")
19
+    String mode;
20
+
21
+    @Override
22
+    public void addCorsMappings(CorsRegistry registry) {
23
+        if (!useCROS) return;
24
+
25
+//        //添加映射路径
26
+        CorsRegistration registration = registry.addMapping("/**")
27
+                //是否发送Cookie
28
+                .allowCredentials(true);
29
+
30
+        //设置放行哪些原始域
31
+        if ("prod".equals(mode)) {
32
+            registration.allowedOrigins("http://resumework.njyunzhi.com", "https://resumework.njyunzhi.com");
33
+        } else {
34
+            registration.allowedOrigins("http://localhost:8000", "http://localhost:3000");
35
+        }
36
+
37
+        //放行哪些请求方式
38
+        registration.allowedMethods("GET", "POST", "PUT", "DELETE")
39
+                //.allowedMethods("*") //或者放行全部
40
+                //放行哪些原始请求头部信息
41
+                .allowedHeaders("*")
42
+                //暴露哪些原始请求头部信息
43
+                .exposedHeaders("Authorization", "Content-Disposition");
44
+    }
45
+}
46
+
47
+
48
+//public class CorsConfig {}

+ 30
- 0
src/main/java/com/njyunzhi/pet_identity/config/DateConverterConfig.java Ver arquivo

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

+ 70
- 0
src/main/java/com/njyunzhi/pet_identity/config/JacksonConfig.java Ver arquivo

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

+ 21
- 0
src/main/java/com/njyunzhi/pet_identity/config/LoggingFilterConfig.java Ver arquivo

@@ -0,0 +1,21 @@
1
+package com.njyunzhi.pet_identity.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/njyunzhi/pet_identity/config/MybatisPlusConfig.java Ver arquivo

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

+ 45
- 0
src/main/java/com/njyunzhi/pet_identity/config/SaTokenConfigure.java Ver arquivo

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

+ 24
- 0
src/main/java/com/njyunzhi/pet_identity/config/SwagggerConfig.java Ver arquivo

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

+ 40
- 0
src/main/java/com/njyunzhi/pet_identity/config/WeixinConfig.java Ver arquivo

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

+ 104
- 0
src/main/java/com/njyunzhi/pet_identity/controller/CommController.java Ver arquivo

@@ -0,0 +1,104 @@
1
+package com.njyunzhi.pet_identity.controller;
2
+
3
+import com.njyunzhi.pet_identity.common.*;
4
+import com.njyunzhi.pet_identity.config.AliyunConfig;
5
+import io.swagger.annotations.Api;
6
+import io.swagger.annotations.ApiOperation;
7
+import io.swagger.annotations.ApiParam;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.web.bind.annotation.*;
10
+import org.springframework.web.multipart.MultipartFile;
11
+
12
+import java.io.IOException;
13
+import java.time.LocalDateTime;
14
+import java.time.format.DateTimeFormatter;
15
+import java.util.Map;
16
+
17
+@Api(tags = "通用")
18
+@RestController
19
+@RequestMapping("/{client}")
20
+public class CommController extends BaseController {
21
+
22
+    @Autowired
23
+    OSSUtils ossUtils;
24
+
25
+    @Autowired
26
+    AliyunConfig aliyunConfig;
27
+
28
+    @Autowired
29
+    SMSCaptcha smsCaptcha;
30
+
31
+    @Autowired
32
+    HttpUtils httpUtils;
33
+
34
+    /**
35
+     * 图片
36
+     * @param multipartFile
37
+     * @return
38
+     */
39
+    @ApiOperation(value = "图片上传", notes = "图片上传")
40
+    @PostMapping("/image")
41
+    public ResponseBean uploadImage(@ApiParam("客户端") @PathVariable String client,
42
+                                    @RequestParam("file") MultipartFile multipartFile) {
43
+        try {
44
+            String img = ossUtils.putObject(multipartFile);
45
+            return ResponseBean.success(img);
46
+        } catch (IOException e) {
47
+            return ResponseBean.error("上传图片失败: " + e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
48
+        }
49
+    }
50
+
51
+    /**
52
+     * base64 图片上传
53
+     * @param data
54
+     * @return
55
+     */
56
+    @ApiOperation(value = "base64 图片上传", notes = "base64 图片上传")
57
+    @PostMapping("/image/base64")
58
+    public ResponseBean uploadBase64Image(@ApiParam("客户端") @PathVariable String client,
59
+                                          @RequestBody Map<String, String> data) {
60
+        try {
61
+            String base64Str = data.get("base64");
62
+            String img = ossUtils.putObject(base64Str);
63
+            return ResponseBean.success(img);
64
+        } catch (IOException e) {
65
+            return ResponseBean.error("上传图片失败: " + e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
66
+        }
67
+    }
68
+
69
+    @ApiOperation(value = "发送手机验证码", notes = "发送手机验证码")
70
+    @PostMapping("/sms-captcha")
71
+    public ResponseBean sendCaptcha(@ApiParam("客户端") @PathVariable String client,
72
+                                    @ApiParam("手机号") @RequestParam String phone) throws Exception {
73
+        smsCaptcha.send(phone, smsCaptcha.randCaptcha(6));
74
+        return ResponseBean.success("发送成功");
75
+    }
76
+
77
+    /**
78
+     * 获取文件上传凭证
79
+     * @return
80
+     */
81
+    @ApiOperation(value = "获取文件上传凭证", notes = "获取文件上传凭证")
82
+    @GetMapping("/oss-sts")
83
+    public ResponseBean getOSSSTS(@ApiParam("客户端") @PathVariable String client) {
84
+        AliyunConfig.Oss oss = aliyunConfig.getOss();
85
+
86
+        try {
87
+            Map<String, Object> res = ossUtils.getSTSAKToken();
88
+            res.put("endpoint", oss.getEndpoint());
89
+            res.put("bucket", oss.getBucketName());
90
+            res.put("bucketURL", oss.getBucketURL());
91
+            res.put("region", oss.getRegion());
92
+            res.put("path", getMonth());
93
+
94
+            return ResponseBean.success(res);
95
+        } catch (Exception e) {
96
+            return ResponseBean.error("获取上传凭证失败! ", ResponseBean.ERROR_UNAVAILABLE);
97
+        }
98
+    }
99
+
100
+    private String getMonth() {
101
+        return DateTimeFormatter.ofPattern("yyyy-MM").format(LocalDateTime.now());
102
+    }
103
+
104
+}

+ 117
- 0
src/main/java/com/njyunzhi/pet_identity/controller/LoginController.java Ver arquivo

@@ -0,0 +1,117 @@
1
+package com.njyunzhi.pet_identity.controller;
2
+
3
+import cn.dev33.satoken.stp.StpUtil;
4
+import com.njyunzhi.pet_identity.common.*;
5
+import com.njyunzhi.pet_identity.entity.SysUser;
6
+import com.njyunzhi.pet_identity.service.ISysSettingService;
7
+import com.njyunzhi.pet_identity.vo.ChangePassword;
8
+import com.njyunzhi.pet_identity.vo.LoginParam;
9
+import io.swagger.annotations.Api;
10
+import io.swagger.annotations.ApiOperation;
11
+import io.swagger.annotations.ApiParam;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.web.bind.annotation.*;
14
+
15
+import java.util.HashMap;
16
+import java.util.Map;
17
+
18
+
19
+@Api(tags = "登入/登出")
20
+@RestController
21
+public class LoginController extends BaseController {
22
+
23
+    @Autowired
24
+    ISysSettingService iSysSettingService;
25
+
26
+    @PostMapping("/admin/login")
27
+    @ApiOperation(value="登录", notes = "登录", httpMethod = "POST", response = ResponseBean.class)
28
+    public ResponseBean login(@ApiParam("登录参数") @RequestBody LoginParam loginParam) throws Exception {
29
+        if (null == loginParam) {
30
+            return ResponseBean.error("账户或密码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
31
+        }
32
+
33
+        String userName = loginParam.getUserName();
34
+        String password = loginParam.getPassword();
35
+
36
+        if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) {
37
+            return ResponseBean.error("账户或密码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
38
+        }
39
+
40
+        SysUser sysUser = iSysUserService.getExistBy("login_name", userName, false, true);
41
+        if (null == sysUser) {
42
+            return ResponseBean.error("账户或密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
43
+        }
44
+
45
+        if (sysUser.getStatus() != Constants.STATUS_NORMAL) {
46
+            return ResponseBean.error("账户异常", ResponseBean.ERROR_ILLEGAL_PARAMS);
47
+        }
48
+
49
+        if (!checkPassword(password, sysUser.getPassword(), sysUser.getUserId())) {
50
+            return ResponseBean.error("账户或密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
51
+        }
52
+
53
+        sysUser.setPassword(null);
54
+
55
+        Map<String, Object> res = new HashMap<>();
56
+        res.put("user", sysUser);
57
+
58
+        // 生成 token
59
+        StpUtil.login(sysUser.getUserId(), Constants.LOGIN_TYPE_ADMIN);
60
+        res.put("token", StpUtil.getTokenValue());
61
+
62
+        return ResponseBean.success(res);
63
+    }
64
+
65
+    @GetMapping("/admin/currentUser")
66
+    @ApiOperation(value="当前用户", notes = "当前用户", httpMethod = "GET", response = ResponseBean.class)
67
+    public ResponseBean getCurrentUser() throws Exception {
68
+        Map<String, Object> res = new HashMap<>();
69
+
70
+        SysUser sysUser = currentUser();
71
+
72
+        if (sysUser.getStatus() != Constants.STATUS_NORMAL) {
73
+            return ResponseBean.error("账户异常", ResponseBean.ERROR_ILLEGAL_PARAMS);
74
+        }
75
+
76
+        sysUser.setPassword(null);
77
+        res.put("user", sysUser);
78
+
79
+        return ResponseBean.success(res);
80
+    }
81
+
82
+    @PostMapping("/admin/logout")
83
+    @ApiOperation(value="登出", notes = "登出", httpMethod = "POST", response = ResponseBean.class)
84
+    public ResponseBean logout() throws Exception {
85
+        StpUtil.logout();
86
+        return ResponseBean.success("success");
87
+    }
88
+
89
+    @GetMapping("/401")
90
+    @ApiOperation(value="401无权限", notes = "401无权限", httpMethod = "GET", response = ResponseBean.class)
91
+    public ResponseBean unAuth(@RequestParam(value = "msg", defaultValue = "未登录或暂无权限") String msg) throws Exception {
92
+        return ResponseBean.error(msg, ResponseBean.ERROR_AUTH_FAIL);
93
+    }
94
+
95
+    @PutMapping("/admin/change-password")
96
+    @ApiOperation(value="修改密码", notes = "修改密码", httpMethod = "PUT", response = ResponseBean.class)
97
+    public ResponseBean changePassword(@ApiParam("修改密码参数") @RequestBody ChangePassword param) throws Exception {
98
+        if (StringUtils.isEmpty(param.getOriginPassword()) || StringUtils.isEmpty(param.getNewPassword())) {
99
+            return ResponseBean.error("原始密码或新密码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
100
+        }
101
+
102
+        SysUser currentUser = currentUser();
103
+
104
+        if (!checkPassword(param.getOriginPassword(), currentUser.getPassword(), currentUser.getUserId())) {
105
+            return ResponseBean.error("原始密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
106
+        }
107
+
108
+        currentUser.setPassword(EncryptUtils.md5(param.getNewPassword(), currentUser.getUserId()));
109
+        iSysUserService.updateById(currentUser);
110
+
111
+        return ResponseBean.success("密码修改成功");
112
+    }
113
+
114
+    private boolean checkPassword(String src, String targ, String salt) {
115
+        return EncryptUtils.md5(src, salt).equals(targ);
116
+    }
117
+}

+ 119
- 0
src/main/java/com/njyunzhi/pet_identity/controller/SysSettingController.java Ver arquivo

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

+ 197
- 0
src/main/java/com/njyunzhi/pet_identity/controller/SysUserController.java Ver arquivo

@@ -0,0 +1,197 @@
1
+package com.njyunzhi.pet_identity.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.njyunzhi.pet_identity.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.njyunzhi.pet_identity.service.ISysUserService;
19
+import com.njyunzhi.pet_identity.entity.SysUser;
20
+import org.springframework.web.bind.annotation.RestController;
21
+
22
+/**
23
+ * <p>
24
+    * 用户 前端控制器
25
+    * </p>
26
+ *
27
+ * @author yansen
28
+ * @since 2022-05-24
29
+ */
30
+
31
+@Api(tags = "用户")
32
+@RestController
33
+@RequestMapping("/admin")
34
+public class SysUserController extends BaseController {
35
+
36
+    private final Logger logger = LoggerFactory.getLogger(SysUserController.class);
37
+
38
+    @Autowired
39
+    public ISysUserService iSysUserService;
40
+
41
+
42
+    /**
43
+     * 分页查询列表
44
+     * @param pageNum
45
+     * @param pageSize
46
+     * @return
47
+     */
48
+    @RequestMapping(value="/user",method= RequestMethod.GET)
49
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
50
+    public ResponseBean sysUserList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
51
+                                    @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
52
+                                    @ApiParam("用户名") @RequestParam(value ="userName", required = false) String userName) throws Exception{
53
+
54
+        IPage<SysUser> pg = new Page<>(pageNum, pageSize);
55
+
56
+        IPage<SysUser> result = iSysUserService.getPagedBy(pg, userName);
57
+        return ResponseBean.success(result);
58
+    }
59
+
60
+    /**
61
+     * 保存对象
62
+     * @param sysUser 实体对象
63
+     * @return
64
+     */
65
+    @RequestMapping(value="/user",method= RequestMethod.POST)
66
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
67
+    public ResponseBean sysUserAdd(@ApiParam("保存内容") @RequestBody SysUser sysUser) throws Exception{
68
+
69
+        SysUser exists = null;
70
+        sysUser.setUserId(StringUtils.uuid());
71
+
72
+        if (StringUtils.isEmpty(sysUser.getUserName())) {
73
+            return ResponseBean.error("用户姓名不能为空");
74
+        }
75
+        if (StringUtils.isEmpty(sysUser.getPhone())) {
76
+            return ResponseBean.error("用户手机不能为空");
77
+        } else {
78
+            exists = iSysUserService.getExistBy("phone", sysUser.getPhone(), false, true);
79
+            if (exists != null) {
80
+                return ResponseBean.error("用户手机号重复");
81
+            }
82
+        }
83
+        if (StringUtils.isEmpty(sysUser.getRoleName())) {
84
+            return ResponseBean.error("用户角色不能为空");
85
+        }
86
+
87
+        if (!StringUtils.isEmpty(sysUser.getLoginName())) {
88
+            exists = iSysUserService.getExistBy("login_name", sysUser.getLoginName(), false, true);
89
+            if (exists != null) {
90
+                return ResponseBean.error("用户登录名重复");
91
+            }
92
+
93
+            if (StringUtils.isEmpty(sysUser.getPassword())) {
94
+                return ResponseBean.error("登录密码不能为空");
95
+            } else {
96
+                sysUser.setPassword(EncryptUtils.md5(sysUser.getPassword(), sysUser.getUserId()));
97
+            }
98
+        }
99
+
100
+        if (iSysUserService.save(sysUser)){
101
+            sysUser.setPassword(null);
102
+            return ResponseBean.success(sysUser);
103
+        } else {
104
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
105
+        }
106
+    }
107
+
108
+    /**
109
+     * 根据id删除对象
110
+     * @param id  实体ID
111
+     */
112
+    @RequestMapping(value="/user/{id}", method= RequestMethod.DELETE)
113
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
114
+    public ResponseBean sysUserDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
115
+        SysUser sysUser = iSysUserService.getById(id);
116
+        if (null == sysUser || Constants.STATUS_DELETE == sysUser.getStatus()) {
117
+            return ResponseBean.error("未找到用户");
118
+        }
119
+
120
+        if (Constants.USER_ADMIN.equals(sysUser.getRoleName())) {
121
+            return ResponseBean.error("暂无权限");
122
+        }
123
+
124
+        if(iSysUserService.removeLogicById(id)){
125
+            return ResponseBean.success("success");
126
+        }else {
127
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
128
+        }
129
+    }
130
+
131
+    /**
132
+     * 修改对象
133
+     * @param id  实体ID
134
+     * @param sysUser 实体对象
135
+     * @return
136
+     */
137
+    @RequestMapping(value="/user/{id}",method= RequestMethod.PUT)
138
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
139
+    public ResponseBean sysUserUpdate(@ApiParam("对象ID") @PathVariable String id,
140
+                                        @ApiParam("更新内容") @RequestBody SysUser sysUser) throws Exception{
141
+        SysUser origin = iSysUserService.getById(id);
142
+        if (null == origin || Constants.STATUS_DELETE == origin.getStatus()) {
143
+            return ResponseBean.error("未找到用户");
144
+        }
145
+
146
+        SysUser exists = null;
147
+        sysUser.setUserId(id);
148
+        if (StringUtils.isEmpty(sysUser.getUserName())) {
149
+            return ResponseBean.error("用户姓名不能为空");
150
+        }
151
+        if (StringUtils.isEmpty(sysUser.getPhone())) {
152
+            return ResponseBean.error("用户手机不能为空");
153
+        } else {
154
+            exists = iSysUserService.getExistBy("phone", sysUser.getPhone(), false, true);
155
+            if (exists != null && !id.equals(exists.getUserId())) {
156
+                return ResponseBean.error("用户手机号重复");
157
+            }
158
+        }
159
+        if (StringUtils.isEmpty(sysUser.getRoleName())) {
160
+            return ResponseBean.error("用户角色不能为空");
161
+        }
162
+
163
+        if (!StringUtils.isEmpty(sysUser.getLoginName())) {
164
+            exists = iSysUserService.getExistBy("login_name", sysUser.getLoginName(), false, true);
165
+            if (exists != null && !id.equals(exists.getUserId())) {
166
+                return ResponseBean.error("用户登录名重复");
167
+            }
168
+
169
+            if (!StringUtils.isEmpty(sysUser.getPassword())) {
170
+                sysUser.setPassword(EncryptUtils.md5(sysUser.getPassword(), sysUser.getUserId()));
171
+            }
172
+        }
173
+
174
+        if (iSysUserService.updateById(sysUser)){
175
+            sysUser.setPassword(null);
176
+            return ResponseBean.success(sysUser);
177
+        }else {
178
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
179
+        }
180
+    }
181
+
182
+    /**
183
+     * 根据id查询对象
184
+     * @param id  实体ID
185
+     */
186
+    @RequestMapping(value="/user/{id}",method= RequestMethod.GET)
187
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
188
+    public ResponseBean sysUserGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
189
+        SysUser origin = iSysUserService.getById(id);
190
+        if (null == origin || Constants.STATUS_DELETE == origin.getStatus()) {
191
+            return ResponseBean.error("未找到用户");
192
+        }
193
+
194
+        origin.setPassword(null);
195
+        return ResponseBean.success(origin);
196
+    }
197
+}

+ 119
- 0
src/main/java/com/njyunzhi/pet_identity/controller/TaApplicationController.java Ver arquivo

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

+ 139
- 0
src/main/java/com/njyunzhi/pet_identity/controller/TaBannerController.java Ver arquivo

@@ -0,0 +1,139 @@
1
+package com.njyunzhi.pet_identity.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.njyunzhi.pet_identity.common.BaseController;
7
+import com.njyunzhi.pet_identity.common.Constants;
8
+import com.njyunzhi.pet_identity.common.ResponseBean;
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.njyunzhi.pet_identity.service.ITaBannerService;
21
+import com.njyunzhi.pet_identity.entity.TaBanner;
22
+import org.springframework.web.bind.annotation.RestController;
23
+
24
+import java.util.List;
25
+
26
+/**
27
+ * <p>
28
+    * banner 前端控制器
29
+    * </p>
30
+ *
31
+ * @author yansen
32
+ * @since 2022-05-24
33
+ */
34
+
35
+@Api(tags = "banner")
36
+@RestController
37
+@RequestMapping("/")
38
+public class TaBannerController extends BaseController {
39
+
40
+    private final Logger logger = LoggerFactory.getLogger(TaBannerController.class);
41
+
42
+    @Autowired
43
+    public ITaBannerService iTaBannerService;
44
+
45
+
46
+    /**
47
+     * 分页查询列表
48
+     * @param pageNum
49
+     * @param pageSize
50
+     * @return
51
+     */
52
+    @RequestMapping(value="/admin/banner",method= RequestMethod.GET)
53
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
54
+    public ResponseBean taBannerList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
55
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
56
+
57
+        IPage<TaBanner> pg = new Page<>(pageNum, pageSize);
58
+        QueryWrapper<TaBanner> queryWrapper = new QueryWrapper<>();
59
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
60
+        queryWrapper.orderByDesc("create_date");
61
+
62
+        IPage<TaBanner> result = iTaBannerService.page(pg, queryWrapper);
63
+        return ResponseBean.success(result);
64
+    }
65
+
66
+    /**
67
+     * 分页查询列表
68
+     * @return
69
+     */
70
+    @RequestMapping(value="/wx/{clientId}/banner",method= RequestMethod.GET)
71
+    @ApiOperation(value="微信列表", notes = "微信列表", httpMethod = "GET", response = ResponseBean.class)
72
+    public ResponseBean wxList() throws Exception{
73
+
74
+        QueryWrapper<TaBanner> queryWrapper = new QueryWrapper<>();
75
+        queryWrapper.eq("status", Constants.STATUS_NORMAL);
76
+        queryWrapper.orderByDesc("sort_no");
77
+
78
+        List<TaBanner> result = iTaBannerService.list(queryWrapper);
79
+        return ResponseBean.success(result);
80
+    }
81
+
82
+    /**
83
+     * 保存对象
84
+     * @param taBanner 实体对象
85
+     * @return
86
+     */
87
+    @RequestMapping(value="/admin/banner",method= RequestMethod.POST)
88
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
89
+    public ResponseBean taBannerAdd(@ApiParam("保存内容") @RequestBody TaBanner taBanner) throws Exception{
90
+
91
+        if (iTaBannerService.save(taBanner)){
92
+            return ResponseBean.success(taBanner);
93
+        } else {
94
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
95
+        }
96
+    }
97
+
98
+    /**
99
+     * 根据id删除对象
100
+     * @param id  实体ID
101
+     */
102
+    @RequestMapping(value="/admin/banner/{id}", method= RequestMethod.DELETE)
103
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
104
+    public ResponseBean taBannerDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
105
+        if(iTaBannerService.removeLogicById(id)){
106
+            return ResponseBean.success("success");
107
+        }else {
108
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
109
+        }
110
+    }
111
+
112
+    /**
113
+     * 修改对象
114
+     * @param id  实体ID
115
+     * @param taBanner 实体对象
116
+     * @return
117
+     */
118
+    @RequestMapping(value="/admin/banner/{id}",method= RequestMethod.PUT)
119
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
120
+    public ResponseBean taBannerUpdate(@ApiParam("对象ID") @PathVariable Integer id,
121
+                                        @ApiParam("更新内容") @RequestBody TaBanner taBanner) throws Exception{
122
+
123
+        if (iTaBannerService.updateById(taBanner)){
124
+            return ResponseBean.success(iTaBannerService.getById(id));
125
+        }else {
126
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
127
+        }
128
+    }
129
+
130
+    /**
131
+     * 根据id查询对象
132
+     * @param id  实体ID
133
+     */
134
+    @RequestMapping(value="/admin/banner/{id}",method= RequestMethod.GET)
135
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
136
+    public ResponseBean taBannerGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
137
+        return ResponseBean.success(iTaBannerService.getById(id));
138
+    }
139
+}

+ 151
- 0
src/main/java/com/njyunzhi/pet_identity/controller/TaNoticeController.java Ver arquivo

@@ -0,0 +1,151 @@
1
+package com.njyunzhi.pet_identity.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.njyunzhi.pet_identity.common.BaseController;
7
+import com.njyunzhi.pet_identity.common.Constants;
8
+import com.njyunzhi.pet_identity.common.ResponseBean;
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.njyunzhi.pet_identity.service.ITaNoticeService;
21
+import com.njyunzhi.pet_identity.entity.TaNotice;
22
+import org.springframework.web.bind.annotation.RestController;
23
+
24
+/**
25
+ * <p>
26
+    * 消息通知 前端控制器
27
+    * </p>
28
+ *
29
+ * @author yansen
30
+ * @since 2022-05-24
31
+ */
32
+
33
+@Api(tags = "消息通知")
34
+@RestController
35
+@RequestMapping("/")
36
+public class TaNoticeController extends BaseController {
37
+
38
+    private final Logger logger = LoggerFactory.getLogger(TaNoticeController.class);
39
+
40
+    @Autowired
41
+    public ITaNoticeService iTaNoticeService;
42
+
43
+
44
+    /**
45
+     * 分页查询列表
46
+     * @param pageNum
47
+     * @param pageSize
48
+     * @return
49
+     */
50
+    @RequestMapping(value="/admin/notice",method= RequestMethod.GET)
51
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
52
+    public ResponseBean taNoticeList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
53
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
54
+
55
+        IPage<TaNotice> pg = new Page<>(pageNum, pageSize);
56
+        QueryWrapper<TaNotice> queryWrapper = new QueryWrapper<>();
57
+        queryWrapper.gt("status", Constants.STATUS_DELETE);
58
+        queryWrapper.orderByDesc("create_date");
59
+
60
+        IPage<TaNotice> result = iTaNoticeService.page(pg, queryWrapper);
61
+        return ResponseBean.success(result);
62
+    }
63
+
64
+    /**
65
+     * 分页查询列表
66
+     * @param pageNum
67
+     * @param pageSize
68
+     * @return
69
+     */
70
+    @RequestMapping(value="/wx/{clientId}/notice",method= RequestMethod.GET)
71
+    @ApiOperation(value="微信列表", notes = "微信列表", httpMethod = "GET", response = ResponseBean.class)
72
+    public ResponseBean wxList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
73
+                               @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
74
+
75
+        IPage<TaNotice> pg = new Page<>(pageNum, pageSize);
76
+        QueryWrapper<TaNotice> queryWrapper = new QueryWrapper<>();
77
+        queryWrapper.eq("status", Constants.STATUS_NORMAL);
78
+        queryWrapper.orderByDesc("weight");
79
+
80
+        IPage<TaNotice> result = iTaNoticeService.page(pg, queryWrapper);
81
+        return ResponseBean.success(result);
82
+    }
83
+
84
+    /**
85
+     * 保存对象
86
+     * @param taNotice 实体对象
87
+     * @return
88
+     */
89
+    @RequestMapping(value="/admin/notice",method= RequestMethod.POST)
90
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
91
+    public ResponseBean taNoticeAdd(@ApiParam("保存内容") @RequestBody TaNotice taNotice) throws Exception{
92
+
93
+        if (iTaNoticeService.save(taNotice)){
94
+            return ResponseBean.success(taNotice);
95
+        }else {
96
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
97
+        }
98
+    }
99
+
100
+    /**
101
+     * 根据id删除对象
102
+     * @param id  实体ID
103
+     */
104
+    @RequestMapping(value="/admin/notice/{id}", method= RequestMethod.DELETE)
105
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
106
+    public ResponseBean taNoticeDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
107
+        if(iTaNoticeService.removeById(id)){
108
+            return ResponseBean.success("success");
109
+        } else {
110
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
111
+        }
112
+    }
113
+
114
+    /**
115
+     * 修改对象
116
+     * @param id  实体ID
117
+     * @param taNotice 实体对象
118
+     * @return
119
+     */
120
+    @RequestMapping(value="/admin/notice/{id}",method= RequestMethod.PUT)
121
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
122
+    public ResponseBean taNoticeUpdate(@ApiParam("对象ID") @PathVariable Integer id,
123
+                                        @ApiParam("更新内容") @RequestBody TaNotice taNotice) throws Exception{
124
+
125
+        if (iTaNoticeService.updateById(taNotice)){
126
+            return ResponseBean.success(iTaNoticeService.getById(id));
127
+        }else {
128
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
129
+        }
130
+    }
131
+
132
+    /**
133
+     * 根据id查询对象
134
+     * @param id  实体ID
135
+     */
136
+    @RequestMapping(value="/admin/notice/{id}",method= RequestMethod.GET)
137
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
138
+    public ResponseBean taNoticeGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
139
+        return ResponseBean.success(iTaNoticeService.getById(id));
140
+    }
141
+
142
+    /**
143
+     * 根据id查询对象
144
+     * @param id  实体ID
145
+     */
146
+    @RequestMapping(value="/wx/{clientId}/notice/{id}",method= RequestMethod.GET)
147
+    @ApiOperation(value="微信详情", notes = "微信详情", httpMethod = "GET", response = ResponseBean.class)
148
+    public ResponseBean wxDetail(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
149
+        return ResponseBean.success(iTaNoticeService.getById(id));
150
+    }
151
+}

+ 119
- 0
src/main/java/com/njyunzhi/pet_identity/controller/TaOrderController.java Ver arquivo

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

+ 120
- 0
src/main/java/com/njyunzhi/pet_identity/controller/TaPersonController.java Ver arquivo

@@ -0,0 +1,120 @@
1
+package com.njyunzhi.pet_identity.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.njyunzhi.pet_identity.common.BaseController;
7
+import com.njyunzhi.pet_identity.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.njyunzhi.pet_identity.service.ITaPersonService;
20
+import com.njyunzhi.pet_identity.entity.TaPerson;
21
+import org.springframework.web.bind.annotation.RestController;
22
+
23
+/**
24
+ * <p>
25
+    * 人员表 前端控制器
26
+    * </p>
27
+ *
28
+ * @author yansen
29
+ * @since 2022-05-24
30
+ */
31
+
32
+@Api(tags = "人员表")
33
+@RestController
34
+@RequestMapping("/")
35
+public class TaPersonController extends BaseController {
36
+
37
+    private final Logger logger = LoggerFactory.getLogger(TaPersonController.class);
38
+
39
+    @Autowired
40
+    public ITaPersonService iTaPersonService;
41
+
42
+
43
+//    /**
44
+//     * 分页查询列表
45
+//     * @param pageNum
46
+//     * @param pageSize
47
+//     * @return
48
+//     */
49
+//    @RequestMapping(value="/taPerson",method= RequestMethod.GET)
50
+//    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
+//    public ResponseBean taPersonList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
+//									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+//
54
+//        IPage<TaPerson> pg = new Page<>(pageNum, pageSize);
55
+//        QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<>();
56
+//        queryWrapper.orderByDesc("create_date");
57
+//
58
+//        IPage<TaPerson> result = iTaPersonService.page(pg, queryWrapper);
59
+//        return ResponseBean.success(result);
60
+//    }
61
+
62
+//    /**
63
+//     * 保存对象
64
+//     * @param taPerson 实体对象
65
+//     * @return
66
+//     */
67
+//    @RequestMapping(value="/taPerson",method= RequestMethod.POST)
68
+//    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
+//    public ResponseBean taPersonAdd(@ApiParam("保存内容") @RequestBody TaPerson taPerson) throws Exception{
70
+//
71
+//        if (iTaPersonService.save(taPerson)){
72
+//            return ResponseBean.success(taPerson);
73
+//        }else {
74
+//            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
+//        }
76
+//    }
77
+
78
+//    /**
79
+//     * 根据id删除对象
80
+//     * @param id  实体ID
81
+//     */
82
+//    @RequestMapping(value="/taPerson/{id}", method= RequestMethod.DELETE)
83
+//    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
+//    public ResponseBean taPersonDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
+//        if(iTaPersonService.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 taPerson 实体对象
96
+     * @return
97
+     */
98
+    @RequestMapping(value="/wx/{clientId}/person",method= RequestMethod.PUT)
99
+    @ApiOperation(value="微信更新信息", notes = "微信更新信息", httpMethod = "PUT", response = ResponseBean.class)
100
+    public ResponseBean taPersonUpdate(@ApiParam("更新内容") @RequestBody TaPerson taPerson) throws Exception{
101
+        TaPerson origin = currentPerson();
102
+        taPerson.setPersonId(origin.getPersonId());
103
+
104
+        if (iTaPersonService.updateById(taPerson)){
105
+            return ResponseBean.success(taPerson);
106
+        }else {
107
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
108
+        }
109
+    }
110
+
111
+//    /**
112
+//     * 根据id查询对象
113
+//     * @param id  实体ID
114
+//     */
115
+//    @RequestMapping(value="/taPerson/{id}",method= RequestMethod.GET)
116
+//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
117
+//    public ResponseBean taPersonGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
118
+//        return ResponseBean.success(iTaPersonService.getById(id));
119
+//    }
120
+}

+ 140
- 0
src/main/java/com/njyunzhi/pet_identity/controller/WxMaController.java Ver arquivo

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

+ 55
- 0
src/main/java/com/njyunzhi/pet_identity/controller/WxPayController.java Ver arquivo

@@ -0,0 +1,55 @@
1
+package com.njyunzhi.pet_identity.controller;
2
+
3
+import com.njyunzhi.pet_identity.common.BaseController;
4
+import io.swagger.annotations.Api;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.web.bind.annotation.RequestBody;
7
+import org.springframework.web.bind.annotation.RequestMapping;
8
+import org.springframework.web.bind.annotation.ResponseBody;
9
+import org.springframework.web.bind.annotation.RestController;
10
+
11
+@Api(tags = "微信小程序")
12
+@RestController
13
+@RequestMapping("/wxpay")
14
+public class WxPayController extends BaseController {
15
+
16
+//    @Autowired
17
+//    WxUtils wxUtils;
18
+//
19
+//    @Autowired
20
+//    ITaPayService orderPayService;
21
+//
22
+//    @ResponseBody
23
+//    @RequestMapping("/notify/order")
24
+//    public String payNotify(@RequestBody String jsonData) {
25
+//        WxPayService payService = wxUtils.getPayService();
26
+//        WxPayOrderNotifyV3Result result = null;
27
+//        try {
28
+//            result = payService.parseOrderNotifyV3Result(jsonData, null);
29
+//            orderPayService.notifyOrder(result.getResult());
30
+//            return WxPayNotifyResponse.success("OK");
31
+//        } catch (Exception e) {
32
+//            e.printStackTrace();
33
+//            return WxPayNotifyResponse.fail(e.getMessage());
34
+//        }
35
+//
36
+//
37
+//    }
38
+//
39
+//    @ResponseBody
40
+//    @RequestMapping("/notify/refund")
41
+//    public String refundNotify(@RequestBody String jsonData) {
42
+//        WxPayService payService = wxUtils.getPayService();
43
+//        WxPayRefundNotifyV3Result result = null;
44
+//        try {
45
+//            result = payService.parseRefundNotifyV3Result(jsonData, null);
46
+//            orderPayService.refundNotifyOrder(result.getResult());
47
+//            return WxPayNotifyResponse.success("OK");
48
+//        } catch (Exception e) {
49
+//            e.printStackTrace();
50
+//            return WxPayNotifyResponse.fail(e.getMessage());
51
+//        }
52
+//
53
+//    }
54
+
55
+}

+ 49
- 0
src/main/java/com/njyunzhi/pet_identity/entity/SysSetting.java Ver arquivo

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

+ 61
- 0
src/main/java/com/njyunzhi/pet_identity/entity/SysUser.java Ver arquivo

@@ -0,0 +1,61 @@
1
+package com.njyunzhi.pet_identity.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import java.time.LocalDateTime;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import java.io.Serializable;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+import lombok.EqualsAndHashCode;
11
+import lombok.experimental.Accessors;
12
+
13
+/**
14
+ * <p>
15
+ * 用户
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2022-05-24
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 userName;
35
+
36
+    @ApiModelProperty(value = "头像")
37
+    private String avatar;
38
+
39
+    @ApiModelProperty(value = "手机号")
40
+    private String phone;
41
+
42
+    @ApiModelProperty(value = "登录账户")
43
+    private String loginName;
44
+
45
+    @ApiModelProperty(value = "登录密码")
46
+    private String password;
47
+
48
+    @ApiModelProperty(value = "所属企业")
49
+    private String orgId;
50
+
51
+    @ApiModelProperty(value = "角色;admin 管理员, auditor 审核员, maker 制证员")
52
+    private String roleName;
53
+
54
+    @ApiModelProperty(value = "状态")
55
+    private Integer status;
56
+
57
+    @ApiModelProperty(value = "创建时间")
58
+    private LocalDateTime createDate;
59
+
60
+
61
+}

+ 81
- 0
src/main/java/com/njyunzhi/pet_identity/entity/TaApplication.java Ver arquivo

@@ -0,0 +1,81 @@
1
+package com.njyunzhi.pet_identity.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-05-24
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@ApiModel(value="TaApplication对象", description="我的申请")
24
+public class TaApplication implements Serializable {
25
+
26
+    private static final long serialVersionUID = 1L;
27
+
28
+    @ApiModelProperty(value = "申请ID")
29
+    @TableId(value = "apply_id", type = IdType.AUTO)
30
+    private Integer applyId;
31
+
32
+    @ApiModelProperty(value = "申请人")
33
+    private String personId;
34
+
35
+    @ApiModelProperty(value = "宠物名称")
36
+    private String petName;
37
+
38
+    @ApiModelProperty(value = "性别")
39
+    private String petSex;
40
+
41
+    @ApiModelProperty(value = "生日")
42
+    private String petBirthday;
43
+
44
+    @ApiModelProperty(value = "类别")
45
+    private String petType;
46
+
47
+    @ApiModelProperty(value = "毛色")
48
+    private String petColor;
49
+
50
+    @ApiModelProperty(value = "免疫证明")
51
+    private String immunization;
52
+
53
+    @ApiModelProperty(value = "宠养区域")
54
+    private String areaCode;
55
+
56
+    @ApiModelProperty(value = "详细地址")
57
+    private String address;
58
+
59
+    @ApiModelProperty(value = "宠物照片")
60
+    private String img1;
61
+
62
+    @ApiModelProperty(value = "图片2")
63
+    private String img2;
64
+
65
+    @ApiModelProperty(value = "状态")
66
+    private String status;
67
+
68
+    @ApiModelProperty(value = "申请时间")
69
+    private String createDate;
70
+
71
+    @ApiModelProperty(value = "申请状态")
72
+    private String verifyStatus;
73
+
74
+    @ApiModelProperty(value = "是否通过")
75
+    private String isAgree;
76
+
77
+    @ApiModelProperty(value = "驳回原因")
78
+    private String rejectReason;
79
+
80
+
81
+}

+ 46
- 0
src/main/java/com/njyunzhi/pet_identity/entity/TaBanner.java Ver arquivo

@@ -0,0 +1,46 @@
1
+package com.njyunzhi.pet_identity.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
+ * banner
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2022-05-24
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaBanner对象", description="banner")
25
+public class TaBanner implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "id")
30
+    @TableId(value = "banner_id", type = IdType.AUTO)
31
+    private Integer bannerId;
32
+
33
+    @ApiModelProperty(value = "图片")
34
+    private String image;
35
+
36
+    @ApiModelProperty(value = "状态")
37
+    private Integer status;
38
+
39
+    @ApiModelProperty(value = "创建日期")
40
+    private LocalDateTime createDate;
41
+
42
+    @ApiModelProperty(value = "排序")
43
+    private Integer sortNo;
44
+
45
+
46
+}

+ 52
- 0
src/main/java/com/njyunzhi/pet_identity/entity/TaNotice.java Ver arquivo

@@ -0,0 +1,52 @@
1
+package com.njyunzhi.pet_identity.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-05-24
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaNotice对象", description="消息通知")
25
+public class TaNotice implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "通知ID")
30
+    @TableId(value = "notice_id", type = IdType.AUTO)
31
+    private Integer noticeId;
32
+
33
+    @ApiModelProperty(value = "通知标题")
34
+    private String title;
35
+
36
+    @ApiModelProperty(value = "图片")
37
+    private String thumb;
38
+
39
+    @ApiModelProperty(value = "正文")
40
+    private String content;
41
+
42
+    @ApiModelProperty(value = "状态")
43
+    private Integer status;
44
+
45
+    @ApiModelProperty(value = "权重")
46
+    private Integer weight;
47
+
48
+    @ApiModelProperty(value = "创建日期")
49
+    private LocalDateTime createDate;
50
+
51
+
52
+}

+ 52
- 0
src/main/java/com/njyunzhi/pet_identity/entity/TaOrder.java Ver arquivo

@@ -0,0 +1,52 @@
1
+package com.njyunzhi.pet_identity.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import java.time.LocalDateTime;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import java.io.Serializable;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+import lombok.EqualsAndHashCode;
11
+import lombok.experimental.Accessors;
12
+
13
+/**
14
+ * <p>
15
+ * 订单表
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2022-05-24
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaOrder对象", description="订单表")
25
+public class TaOrder implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "订单ID")
30
+    @TableId(value = "order_id", type = IdType.INPUT)
31
+    private String orderId;
32
+
33
+    @ApiModelProperty(value = "申请ID")
34
+    private String applyId;
35
+
36
+    @ApiModelProperty(value = "支付金额;单位分")
37
+    private Integer charges;
38
+
39
+    @ApiModelProperty(value = "工本费;单位分")
40
+    private Integer productionCost;
41
+
42
+    @ApiModelProperty(value = "快递费;单位分")
43
+    private Integer expressFee;
44
+
45
+    @ApiModelProperty(value = "状态;0未支付, 1支付成功, 2支付失败")
46
+    private Integer status;
47
+
48
+    @ApiModelProperty(value = "创建日期")
49
+    private LocalDateTime createDate;
50
+
51
+
52
+}

+ 67
- 0
src/main/java/com/njyunzhi/pet_identity/entity/TaPerson.java Ver arquivo

@@ -0,0 +1,67 @@
1
+package com.njyunzhi.pet_identity.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import java.time.LocalDateTime;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import java.io.Serializable;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+import lombok.EqualsAndHashCode;
11
+import lombok.experimental.Accessors;
12
+
13
+/**
14
+ * <p>
15
+ * 人员表
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2022-05-24
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaPerson对象", description="人员表")
25
+public class TaPerson implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "用户ID")
30
+    @TableId(value = "person_id", type = IdType.INPUT)
31
+    private String personId;
32
+
33
+    @ApiModelProperty(value = "小程序APPID")
34
+    private String appId;
35
+
36
+    @ApiModelProperty(value = "openid")
37
+    private String openid;
38
+
39
+    @ApiModelProperty(value = "名称")
40
+    private String nickName;
41
+
42
+    @ApiModelProperty(value = "头像")
43
+    private String avatar;
44
+
45
+    @ApiModelProperty(value = "性别")
46
+    private Integer sex;
47
+
48
+    @ApiModelProperty(value = "手机号")
49
+    private String phone;
50
+
51
+    @ApiModelProperty(value = "身份证号码")
52
+    private String idCard;
53
+
54
+    @ApiModelProperty(value = "身份证正面")
55
+    private String cardImg1;
56
+
57
+    @ApiModelProperty(value = "身份证反面")
58
+    private String cardImg2;
59
+
60
+    @ApiModelProperty(value = "状态")
61
+    private Integer status;
62
+
63
+    @ApiModelProperty(value = "创建时间")
64
+    private LocalDateTime createDate;
65
+
66
+
67
+}

+ 19
- 0
src/main/java/com/njyunzhi/pet_identity/exception/GlobalExceptionHandler.java Ver arquivo

@@ -0,0 +1,19 @@
1
+package com.njyunzhi.pet_identity.exception;
2
+
3
+import com.njyunzhi.pet_identity.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
+}

+ 18
- 0
src/main/java/com/njyunzhi/pet_identity/mapper/SysSettingMapper.java Ver arquivo

@@ -0,0 +1,18 @@
1
+package com.njyunzhi.pet_identity.mapper;
2
+
3
+import com.njyunzhi.pet_identity.entity.SysSetting;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 系统配置 Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2022-05-24
14
+ */
15
+@Mapper
16
+public interface SysSettingMapper extends BaseMapper<SysSetting> {
17
+
18
+}

+ 21
- 0
src/main/java/com/njyunzhi/pet_identity/mapper/SysUserMapper.java Ver arquivo

@@ -0,0 +1,21 @@
1
+package com.njyunzhi.pet_identity.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.njyunzhi.pet_identity.entity.SysUser;
5
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6
+import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+/**
10
+ * <p>
11
+ * 用户 Mapper 接口
12
+ * </p>
13
+ *
14
+ * @author yansen
15
+ * @since 2022-05-24
16
+ */
17
+@Mapper
18
+public interface SysUserMapper extends BaseMapper<SysUser> {
19
+
20
+    IPage<SysUser> getPagedBy(IPage<SysUser> pg, @Param("userName") String userName);
21
+}

+ 18
- 0
src/main/java/com/njyunzhi/pet_identity/mapper/TaApplicationMapper.java Ver arquivo

@@ -0,0 +1,18 @@
1
+package com.njyunzhi.pet_identity.mapper;
2
+
3
+import com.njyunzhi.pet_identity.entity.TaApplication;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 我的申请 Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2022-05-24
14
+ */
15
+@Mapper
16
+public interface TaApplicationMapper extends BaseMapper<TaApplication> {
17
+
18
+}

+ 18
- 0
src/main/java/com/njyunzhi/pet_identity/mapper/TaBannerMapper.java Ver arquivo

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

+ 18
- 0
src/main/java/com/njyunzhi/pet_identity/mapper/TaNoticeMapper.java Ver arquivo

@@ -0,0 +1,18 @@
1
+package com.njyunzhi.pet_identity.mapper;
2
+
3
+import com.njyunzhi.pet_identity.entity.TaNotice;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 消息通知 Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2022-05-24
14
+ */
15
+@Mapper
16
+public interface TaNoticeMapper extends BaseMapper<TaNotice> {
17
+
18
+}

+ 18
- 0
src/main/java/com/njyunzhi/pet_identity/mapper/TaOrderMapper.java Ver arquivo

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

+ 18
- 0
src/main/java/com/njyunzhi/pet_identity/mapper/TaPersonMapper.java Ver arquivo

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

+ 33
- 0
src/main/java/com/njyunzhi/pet_identity/service/IBaseService.java Ver arquivo

@@ -0,0 +1,33 @@
1
+package com.njyunzhi.pet_identity.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
+    /**
16
+     * 逻辑删除
17
+     * @param id
18
+     * @return
19
+     */
20
+    boolean removeLogicByUser(Serializable id, String userId, String userType);
21
+
22
+    boolean removeBy(String column, Object value, boolean notDelete);
23
+
24
+    boolean canAccessData(Serializable id, String userId);
25
+
26
+    boolean remvoeWithDataScope(Serializable id, String userId);
27
+
28
+    int countBy(String column, Object value, boolean notDelete);
29
+
30
+    T getByButNot(String column, Object value, String col, Object val, boolean notDelete);
31
+
32
+    T getExistBy(String column, Object value, boolean normal, boolean notDelete);
33
+}

+ 16
- 0
src/main/java/com/njyunzhi/pet_identity/service/ISysSettingService.java Ver arquivo

@@ -0,0 +1,16 @@
1
+package com.njyunzhi.pet_identity.service;
2
+
3
+import com.njyunzhi.pet_identity.entity.SysSetting;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 系统配置 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2022-05-24
13
+ */
14
+public interface ISysSettingService extends IService<SysSetting> {
15
+
16
+}

+ 18
- 0
src/main/java/com/njyunzhi/pet_identity/service/ISysUserService.java Ver arquivo

@@ -0,0 +1,18 @@
1
+package com.njyunzhi.pet_identity.service;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.njyunzhi.pet_identity.entity.SysUser;
5
+import com.baomidou.mybatisplus.extension.service.IService;
6
+
7
+/**
8
+ * <p>
9
+ * 用户 服务类
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2022-05-24
14
+ */
15
+public interface ISysUserService extends IBaseService<SysUser> {
16
+
17
+    IPage<SysUser> getPagedBy(IPage<SysUser> pg, String userName);
18
+}

+ 16
- 0
src/main/java/com/njyunzhi/pet_identity/service/ITaApplicationService.java Ver arquivo

@@ -0,0 +1,16 @@
1
+package com.njyunzhi.pet_identity.service;
2
+
3
+import com.njyunzhi.pet_identity.entity.TaApplication;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 我的申请 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2022-05-24
13
+ */
14
+public interface ITaApplicationService extends IService<TaApplication> {
15
+
16
+}

+ 16
- 0
src/main/java/com/njyunzhi/pet_identity/service/ITaBannerService.java Ver arquivo

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

+ 16
- 0
src/main/java/com/njyunzhi/pet_identity/service/ITaNoticeService.java Ver arquivo

@@ -0,0 +1,16 @@
1
+package com.njyunzhi.pet_identity.service;
2
+
3
+import com.njyunzhi.pet_identity.entity.TaNotice;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 消息通知 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2022-05-24
13
+ */
14
+public interface ITaNoticeService extends IService<TaNotice> {
15
+
16
+}

+ 16
- 0
src/main/java/com/njyunzhi/pet_identity/service/ITaOrderService.java Ver arquivo

@@ -0,0 +1,16 @@
1
+package com.njyunzhi.pet_identity.service;
2
+
3
+import com.njyunzhi.pet_identity.entity.TaOrder;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 订单表 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2022-05-24
13
+ */
14
+public interface ITaOrderService extends IService<TaOrder> {
15
+
16
+}

+ 16
- 0
src/main/java/com/njyunzhi/pet_identity/service/ITaPersonService.java Ver arquivo

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

+ 120
- 0
src/main/java/com/njyunzhi/pet_identity/service/impl/BaseServiceImpl.java Ver arquivo

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

+ 28
- 0
src/main/java/com/njyunzhi/pet_identity/service/impl/ManagerServiceImpl.java Ver arquivo

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

+ 20
- 0
src/main/java/com/njyunzhi/pet_identity/service/impl/SysSettingServiceImpl.java Ver arquivo

@@ -0,0 +1,20 @@
1
+package com.njyunzhi.pet_identity.service.impl;
2
+
3
+import com.njyunzhi.pet_identity.entity.SysSetting;
4
+import com.njyunzhi.pet_identity.mapper.SysSettingMapper;
5
+import com.njyunzhi.pet_identity.service.ISysSettingService;
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-05-24
16
+ */
17
+@Service
18
+public class SysSettingServiceImpl extends ServiceImpl<SysSettingMapper, SysSetting> implements ISysSettingService {
19
+
20
+}

+ 25
- 0
src/main/java/com/njyunzhi/pet_identity/service/impl/SysUserServiceImpl.java Ver arquivo

@@ -0,0 +1,25 @@
1
+package com.njyunzhi.pet_identity.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
+import com.njyunzhi.pet_identity.entity.SysUser;
5
+import com.njyunzhi.pet_identity.mapper.SysUserMapper;
6
+import com.njyunzhi.pet_identity.service.ISysUserService;
7
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
+import org.springframework.stereotype.Service;
9
+
10
+/**
11
+ * <p>
12
+ * 用户 服务实现类
13
+ * </p>
14
+ *
15
+ * @author yansen
16
+ * @since 2022-05-24
17
+ */
18
+@Service
19
+public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
20
+
21
+    @Override
22
+    public IPage<SysUser> getPagedBy(IPage<SysUser> pg, String userName) {
23
+        return baseMapper.getPagedBy(pg, userName);
24
+    }
25
+}

+ 20
- 0
src/main/java/com/njyunzhi/pet_identity/service/impl/TaApplicationServiceImpl.java Ver arquivo

@@ -0,0 +1,20 @@
1
+package com.njyunzhi.pet_identity.service.impl;
2
+
3
+import com.njyunzhi.pet_identity.entity.TaApplication;
4
+import com.njyunzhi.pet_identity.mapper.TaApplicationMapper;
5
+import com.njyunzhi.pet_identity.service.ITaApplicationService;
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-05-24
16
+ */
17
+@Service
18
+public class TaApplicationServiceImpl extends ServiceImpl<TaApplicationMapper, TaApplication> implements ITaApplicationService {
19
+
20
+}

+ 20
- 0
src/main/java/com/njyunzhi/pet_identity/service/impl/TaBannerServiceImpl.java Ver arquivo

@@ -0,0 +1,20 @@
1
+package com.njyunzhi.pet_identity.service.impl;
2
+
3
+import com.njyunzhi.pet_identity.entity.TaBanner;
4
+import com.njyunzhi.pet_identity.mapper.TaBannerMapper;
5
+import com.njyunzhi.pet_identity.service.ITaBannerService;
6
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import org.springframework.stereotype.Service;
8
+
9
+/**
10
+ * <p>
11
+ * banner 服务实现类
12
+ * </p>
13
+ *
14
+ * @author yansen
15
+ * @since 2022-05-24
16
+ */
17
+@Service
18
+public class TaBannerServiceImpl extends BaseServiceImpl<TaBannerMapper, TaBanner> implements ITaBannerService {
19
+
20
+}

+ 20
- 0
src/main/java/com/njyunzhi/pet_identity/service/impl/TaNoticeServiceImpl.java Ver arquivo

@@ -0,0 +1,20 @@
1
+package com.njyunzhi.pet_identity.service.impl;
2
+
3
+import com.njyunzhi.pet_identity.entity.TaNotice;
4
+import com.njyunzhi.pet_identity.mapper.TaNoticeMapper;
5
+import com.njyunzhi.pet_identity.service.ITaNoticeService;
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-05-24
16
+ */
17
+@Service
18
+public class TaNoticeServiceImpl extends ServiceImpl<TaNoticeMapper, TaNotice> implements ITaNoticeService {
19
+
20
+}

+ 20
- 0
src/main/java/com/njyunzhi/pet_identity/service/impl/TaOrderServiceImpl.java Ver arquivo

@@ -0,0 +1,20 @@
1
+package com.njyunzhi.pet_identity.service.impl;
2
+
3
+import com.njyunzhi.pet_identity.entity.TaOrder;
4
+import com.njyunzhi.pet_identity.mapper.TaOrderMapper;
5
+import com.njyunzhi.pet_identity.service.ITaOrderService;
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-05-24
16
+ */
17
+@Service
18
+public class TaOrderServiceImpl extends ServiceImpl<TaOrderMapper, TaOrder> implements ITaOrderService {
19
+
20
+}

+ 20
- 0
src/main/java/com/njyunzhi/pet_identity/service/impl/TaPersonServiceImpl.java Ver arquivo

@@ -0,0 +1,20 @@
1
+package com.njyunzhi.pet_identity.service.impl;
2
+
3
+import com.njyunzhi.pet_identity.entity.TaPerson;
4
+import com.njyunzhi.pet_identity.mapper.TaPersonMapper;
5
+import com.njyunzhi.pet_identity.service.ITaPersonService;
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-05-24
16
+ */
17
+@Service
18
+public class TaPersonServiceImpl extends BaseServiceImpl<TaPersonMapper, TaPerson> implements ITaPersonService {
19
+
20
+}

+ 17
- 0
src/main/java/com/njyunzhi/pet_identity/vo/ChangePassword.java Ver arquivo

@@ -0,0 +1,17 @@
1
+package com.njyunzhi.pet_identity.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 ChangePassword {
11
+
12
+    @ApiModelProperty("原始密码")
13
+    String originPassword;
14
+
15
+    @ApiModelProperty("新密码")
16
+    String newPassword;
17
+}

+ 55
- 0
src/main/java/com/njyunzhi/pet_identity/vo/FormExport.java Ver arquivo

@@ -0,0 +1,55 @@
1
+package com.njyunzhi.pet_identity.vo;
2
+
3
+
4
+import com.alibaba.excel.annotation.ExcelIgnore;
5
+import com.alibaba.excel.annotation.ExcelProperty;
6
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
7
+import com.alibaba.excel.annotation.write.style.ContentRowHeight;
8
+import com.alibaba.excel.annotation.write.style.HeadRowHeight;
9
+import com.njyunzhi.pet_identity.common.excelConverter.ResultStatusConverter;
10
+import lombok.Data;
11
+import lombok.EqualsAndHashCode;
12
+import lombok.experimental.Accessors;
13
+
14
+import java.net.URL;
15
+import java.time.LocalDateTime;
16
+
17
+@Data
18
+@ContentRowHeight(60)
19
+@HeadRowHeight(30)
20
+@ColumnWidth(25)
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+public class FormExport {
24
+
25
+    @ColumnWidth(15)
26
+    @ExcelProperty(value = "序号")
27
+    private String index;
28
+
29
+    @ExcelProperty(value = "企业名称")
30
+    private String orgName;
31
+
32
+    @ExcelProperty(value = "申请人名称")
33
+    private String userName;
34
+
35
+    @ExcelIgnore
36
+    private String antigenImage;
37
+
38
+    @ExcelProperty(value = "抗原截图")
39
+    private URL antigenImageURL;
40
+
41
+    @ExcelProperty(value = "抗原是否正常", converter = ResultStatusConverter.class)
42
+    private Integer antigenIsNormal;
43
+
44
+    @ExcelIgnore
45
+    private String nucleicImage;
46
+
47
+    @ExcelProperty(value = "核酸截图")
48
+    private URL nucleicImageURL;
49
+
50
+    @ExcelProperty(value = "核酸是否正常", converter = ResultStatusConverter.class)
51
+    private Integer nucleicIsNormal;
52
+
53
+    @ExcelProperty(value = "申请时间")
54
+    private LocalDateTime createDate;
55
+}

+ 19
- 0
src/main/java/com/njyunzhi/pet_identity/vo/LoginParam.java Ver arquivo

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

+ 17
- 0
src/main/java/com/njyunzhi/pet_identity/vo/StatisValue.java Ver arquivo

@@ -0,0 +1,17 @@
1
+package com.njyunzhi.pet_identity.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 StatisValue {
11
+
12
+    @ApiModelProperty("指标名称")
13
+    String name;
14
+
15
+    @ApiModelProperty("指标值")
16
+    String value;
17
+}

+ 26
- 0
src/main/java/com/njyunzhi/pet_identity/vo/WxMaAuthParam.java Ver arquivo

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

+ 32
- 0
src/main/java/com/njyunzhi/pet_identity/vo/WxMaPreload.java Ver arquivo

@@ -0,0 +1,32 @@
1
+package com.njyunzhi.pet_identity.vo;
2
+
3
+
4
+import io.swagger.annotations.ApiModel;
5
+import io.swagger.annotations.ApiModelProperty;
6
+import lombok.Data;
7
+
8
+@ApiModel(description = "小程序预加载参数")
9
+@Data
10
+public class WxMaPreload {
11
+
12
+    @ApiModelProperty("小程序标识")
13
+    String appid;
14
+
15
+    @ApiModelProperty("用户设置的 TOKEN")
16
+    String token;
17
+
18
+    @ApiModelProperty("用户登录凭证")
19
+    String code;
20
+
21
+    @ApiModelProperty("时间戳,微信客户端发起请求的时间")
22
+    Integer timestamp;
23
+
24
+    @ApiModelProperty("打开小程序的路径")
25
+    String path;
26
+
27
+    @ApiModelProperty("打开小程序的query")
28
+    String query;
29
+
30
+    @ApiModelProperty("打开小程序的场景值")
31
+    Integer scene;
32
+}

+ 20
- 0
src/main/resources/application-dev.yml Ver arquivo

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

+ 17
- 0
src/main/resources/application-prod.yml Ver arquivo

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

+ 97
- 0
src/main/resources/application.yml Ver arquivo

@@ -0,0 +1,97 @@
1
+###
2
+server:
3
+  port: 9002
4
+  servlet:
5
+    context-path: /api
6
+
7
+# Sa-Token配置
8
+sa-token:
9
+  # jwt秘钥
10
+  jwt-secret-key: Q920tdPkkDxnSv4dd6cqE6jNDT2OKT7L
11
+  # token名称 (同时也是cookie名称)
12
+  token-name: Authorization
13
+  # 禁用 cookie
14
+  is-read-cookie: false
15
+  # token有效期,单位s 默认30天, -1代表永不过期
16
+  timeout: 2592000
17
+  # token临时有效期 (指定时间内无操作就视为token过期) 单位: 秒
18
+  activity-timeout: -1
19
+  # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
20
+  is-concurrent: true
21
+  # 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
22
+  is-share: false
23
+  # token风格
24
+  token-style: uuid
25
+  # 是否输出操作日志
26
+  is-log: false
27
+
28
+###
29
+mybatis-plus:
30
+  configuration:
31
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
32
+    call-setters-on-nulls: true
33
+  mapper-locations: classpath:mapper/**/*.xml
34
+
35
+###
36
+sms:
37
+  captcha:
38
+    code: SMS_207555188
39
+    sign: 云致科技
40
+
41
+###
42
+yz:
43
+  sms:
44
+    ## ??????
45
+    appid: ubpa
46
+    api: http://sms.njyunzhi.com/sms
47
+    ## ????
48
+    help: http://sms.njyunzhi.com/help
49
+
50
+###
51
+aliyun:
52
+  accessKeyId: LTAI5tGjnZY6k799BHxhmqcm
53
+  accessKeySecret: eU1DmULbgHe2dnIg3P93634PO2vEh5
54
+  oss:
55
+    roleSessionName: shigongli
56
+    accessKeyId: LTAI4G9zCefU1m7sKmmBnzTc
57
+    accessKeySecret: Vaax5O7wTL0KZdSgd8L9cGBf8AgUqJ
58
+    arn: acs:ram::1636896505560465:role/ramosssts
59
+    region: oss-cn-shanghai
60
+    endpoint: oss-cn-shanghai.aliyuncs.com
61
+    bucketName: yz-ubpa-image
62
+    bucketURL: https://yz-ubpa-image.oss-cn-shanghai.aliyuncs.com
63
+
64
+
65
+###
66
+weixin:
67
+  miniapp:
68
+    appid: wxd6f47a9bb3052175
69
+    secret: 28f33b6bbc0f778c11a0bb234a7d6d4e
70
+    token:
71
+    aesKey:
72
+    msgDataFormat: JSON
73
+  pay:
74
+    appId: wx94f23e5b285c046d
75
+    mchId: 1621038483
76
+    mchKey: #????
77
+    subAppId: #??????????????ID
78
+    subMchId: #???????????
79
+    apiV3Key: bRygxYHU7hTzNPixgnKbElhmYQDw1C7r
80
+    keyPath:
81
+    privateKeyPath: classpath:cert/apiclient_key.pem
82
+    privateCertPath: classpath:cert/apiclient_cert.pem
83
+
84
+###
85
+spring:
86
+  mvc:
87
+    pathmatch:
88
+      matching-strategy: ANT_PATH_MATCHER
89
+  application:
90
+    name: pet_identity
91
+  #  jackson:
92
+  #    date-format: yyyy-MM-dd HH:mm:ss
93
+  #    time-zone: GMT+8
94
+  profiles:
95
+    active: @profileActive@
96
+
97
+

+ 5
- 0
src/main/resources/mapper/SysSettingMapper.xml Ver arquivo

@@ -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.njyunzhi.pet_identity.mapper.SysSettingMapper">
4
+
5
+</mapper>

+ 28
- 0
src/main/resources/mapper/SysUserMapper.xml Ver arquivo

@@ -0,0 +1,28 @@
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.njyunzhi.pet_identity.mapper.SysUserMapper">
4
+
5
+    <select id="getPagedBy" resultType="com.njyunzhi.pet_identity.entity.SysUser">
6
+        SELECT
7
+            t.user_id,
8
+            t.user_name,
9
+            t.avatar,
10
+            t.phone,
11
+            t.login_name,
12
+            NULL AS `password`,
13
+            t.org_id,
14
+            t.role_name,
15
+            t.`status`,
16
+            t.create_date
17
+        FROM
18
+            sys_user t
19
+        WHERE
20
+            t.`status` > - 1
21
+          AND t.role_name != 'admin'
22
+          <if test="userName != null and userName != ''">
23
+              AND t.user_name LIKE CONCAT( '%', #{userName}, '%' )
24
+          </if>
25
+        ORDER BY
26
+            t.create_date DESC
27
+    </select>
28
+</mapper>

+ 5
- 0
src/main/resources/mapper/TaApplicationMapper.xml Ver arquivo

@@ -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.njyunzhi.pet_identity.mapper.TaApplicationMapper">
4
+
5
+</mapper>

+ 5
- 0
src/main/resources/mapper/TaBannerMapper.xml Ver arquivo

@@ -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.njyunzhi.pet_identity.mapper.TaBannerMapper">
4
+
5
+</mapper>

+ 5
- 0
src/main/resources/mapper/TaNoticeMapper.xml Ver arquivo

@@ -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.njyunzhi.pet_identity.mapper.TaNoticeMapper">
4
+
5
+</mapper>

+ 5
- 0
src/main/resources/mapper/TaOrderMapper.xml Ver arquivo

@@ -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.njyunzhi.pet_identity.mapper.TaOrderMapper">
4
+
5
+</mapper>

+ 5
- 0
src/main/resources/mapper/TaPersonMapper.xml Ver arquivo

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

+ 13
- 0
src/test/java/com/njyunzhi/pet_identity/UbpaApplicationTests.java Ver arquivo

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