Browse Source

first commit

张延森 3 years ago
commit
a193a78828
100 changed files with 6427 additions and 0 deletions
  1. 43
    0
      .gitignore
  2. 55
    0
      bin/service.sh
  3. 14
    0
      bin/sgl.service
  4. 7
    0
      deploy/bootstrap
  5. 24
    0
      deploy/template.yml
  6. 0
    0
      deploy/注意修改bootstrap文件中版本号.txt
  7. 310
    0
      mvnw
  8. 182
    0
      mvnw.cmd
  9. 278
    0
      pom.xml
  10. 16
    0
      src/main/java/com/yunzhi/questions/SpringApplication.java
  11. 57
    0
      src/main/java/com/yunzhi/questions/common/BaseController.java
  12. 8
    0
      src/main/java/com/yunzhi/questions/common/Callback.java
  13. 13
    0
      src/main/java/com/yunzhi/questions/common/Constants.java
  14. 25
    0
      src/main/java/com/yunzhi/questions/common/CurrentContext.java
  15. 37
    0
      src/main/java/com/yunzhi/questions/common/DateUtils.java
  16. 17
    0
      src/main/java/com/yunzhi/questions/common/EncryptUtils.java
  17. 27
    0
      src/main/java/com/yunzhi/questions/common/ExcelUtils.java
  18. 107
    0
      src/main/java/com/yunzhi/questions/common/JWTUtils.java
  19. 11
    0
      src/main/java/com/yunzhi/questions/common/MathUtils.java
  20. 166
    0
      src/main/java/com/yunzhi/questions/common/OSSUtils.java
  21. 86
    0
      src/main/java/com/yunzhi/questions/common/ResponseBean.java
  22. 145
    0
      src/main/java/com/yunzhi/questions/common/SMSCaptcha.java
  23. 71
    0
      src/main/java/com/yunzhi/questions/common/SMSUtils.java
  24. 203
    0
      src/main/java/com/yunzhi/questions/common/StringUtils.java
  25. 208
    0
      src/main/java/com/yunzhi/questions/common/WxUtils.java
  26. 53
    0
      src/main/java/com/yunzhi/questions/common/excelConverter/LocalDateTimeConverter.java
  27. 53
    0
      src/main/java/com/yunzhi/questions/common/excelConverter/LocalDayConverter.java
  28. 55
    0
      src/main/java/com/yunzhi/questions/common/excelConverter/MoneyConverter.java
  29. 40
    0
      src/main/java/com/yunzhi/questions/config/AliyunConfig.java
  30. 35
    0
      src/main/java/com/yunzhi/questions/config/BaseConfig.java
  31. 28
    0
      src/main/java/com/yunzhi/questions/config/CorsConfig.java
  32. 32
    0
      src/main/java/com/yunzhi/questions/config/InterceptorConfig.java
  33. 21
    0
      src/main/java/com/yunzhi/questions/config/LoggingFilterConfig.java
  34. 14
    0
      src/main/java/com/yunzhi/questions/config/MybatisPlusConfig.java
  35. 24
    0
      src/main/java/com/yunzhi/questions/config/SwagggerConfig.java
  36. 35
    0
      src/main/java/com/yunzhi/questions/config/WeixinConfig.java
  37. 102
    0
      src/main/java/com/yunzhi/questions/controller/CommController.java
  38. 174
    0
      src/main/java/com/yunzhi/questions/controller/LoginController.java
  39. 119
    0
      src/main/java/com/yunzhi/questions/controller/SysUserController.java
  40. 119
    0
      src/main/java/com/yunzhi/questions/controller/TaAnswerController.java
  41. 119
    0
      src/main/java/com/yunzhi/questions/controller/TaAppController.java
  42. 178
    0
      src/main/java/com/yunzhi/questions/controller/TaCharacterResultController.java
  43. 120
    0
      src/main/java/com/yunzhi/questions/controller/TaGameController.java
  44. 133
    0
      src/main/java/com/yunzhi/questions/controller/TaGameLevelController.java
  45. 130
    0
      src/main/java/com/yunzhi/questions/controller/TaGameLevelQuestionController.java
  46. 119
    0
      src/main/java/com/yunzhi/questions/controller/TaGamePersonAnswerController.java
  47. 119
    0
      src/main/java/com/yunzhi/questions/controller/TaGamePersonController.java
  48. 147
    0
      src/main/java/com/yunzhi/questions/controller/TaGamePersonResultController.java
  49. 119
    0
      src/main/java/com/yunzhi/questions/controller/TaPersonController.java
  50. 158
    0
      src/main/java/com/yunzhi/questions/controller/TaQuestionController.java
  51. 152
    0
      src/main/java/com/yunzhi/questions/controller/TdCharacterLibController.java
  52. 119
    0
      src/main/java/com/yunzhi/questions/controller/TdCharacterWordController.java
  53. 215
    0
      src/main/java/com/yunzhi/questions/controller/WxMpController.java
  54. 52
    0
      src/main/java/com/yunzhi/questions/entity/SysLogin.java
  55. 52
    0
      src/main/java/com/yunzhi/questions/entity/SysUser.java
  56. 53
    0
      src/main/java/com/yunzhi/questions/entity/TaAnswer.java
  57. 46
    0
      src/main/java/com/yunzhi/questions/entity/TaApp.java
  58. 62
    0
      src/main/java/com/yunzhi/questions/entity/TaCharacterResult.java
  59. 45
    0
      src/main/java/com/yunzhi/questions/entity/TaGame.java
  60. 48
    0
      src/main/java/com/yunzhi/questions/entity/TaGameLevel.java
  61. 42
    0
      src/main/java/com/yunzhi/questions/entity/TaGameLevelQuestion.java
  62. 42
    0
      src/main/java/com/yunzhi/questions/entity/TaGamePerson.java
  63. 55
    0
      src/main/java/com/yunzhi/questions/entity/TaGamePersonAnswer.java
  64. 57
    0
      src/main/java/com/yunzhi/questions/entity/TaGamePersonResult.java
  65. 69
    0
      src/main/java/com/yunzhi/questions/entity/TaPerson.java
  66. 49
    0
      src/main/java/com/yunzhi/questions/entity/TaQuestion.java
  67. 76
    0
      src/main/java/com/yunzhi/questions/entity/TaWxConfig.java
  68. 55
    0
      src/main/java/com/yunzhi/questions/entity/TdCharacterLib.java
  69. 43
    0
      src/main/java/com/yunzhi/questions/entity/TdCharacterWord.java
  70. 19
    0
      src/main/java/com/yunzhi/questions/exception/GlobalExceptionHandler.java
  71. 122
    0
      src/main/java/com/yunzhi/questions/interceptor/PermissionInterceptor.java
  72. 79
    0
      src/main/java/com/yunzhi/questions/log/MysqlAppender.java
  73. 18
    0
      src/main/java/com/yunzhi/questions/mapper/SysLoginMapper.java
  74. 18
    0
      src/main/java/com/yunzhi/questions/mapper/SysUserMapper.java
  75. 26
    0
      src/main/java/com/yunzhi/questions/mapper/TaAnswerMapper.java
  76. 18
    0
      src/main/java/com/yunzhi/questions/mapper/TaAppMapper.java
  77. 27
    0
      src/main/java/com/yunzhi/questions/mapper/TaCharacterResultMapper.java
  78. 18
    0
      src/main/java/com/yunzhi/questions/mapper/TaGameLevelMapper.java
  79. 18
    0
      src/main/java/com/yunzhi/questions/mapper/TaGameLevelQuestionMapper.java
  80. 18
    0
      src/main/java/com/yunzhi/questions/mapper/TaGameMapper.java
  81. 18
    0
      src/main/java/com/yunzhi/questions/mapper/TaGamePersonAnswerMapper.java
  82. 18
    0
      src/main/java/com/yunzhi/questions/mapper/TaGamePersonMapper.java
  83. 22
    0
      src/main/java/com/yunzhi/questions/mapper/TaGamePersonResultMapper.java
  84. 20
    0
      src/main/java/com/yunzhi/questions/mapper/TaPersonMapper.java
  85. 24
    0
      src/main/java/com/yunzhi/questions/mapper/TaQuestionMapper.java
  86. 18
    0
      src/main/java/com/yunzhi/questions/mapper/TaWxConfigMapper.java
  87. 22
    0
      src/main/java/com/yunzhi/questions/mapper/TdCharacterLibMapper.java
  88. 28
    0
      src/main/java/com/yunzhi/questions/mapper/TdCharacterWordMapper.java
  89. 14
    0
      src/main/java/com/yunzhi/questions/service/IBaseService.java
  90. 19
    0
      src/main/java/com/yunzhi/questions/service/ISysLoginService.java
  91. 16
    0
      src/main/java/com/yunzhi/questions/service/ISysUserService.java
  92. 22
    0
      src/main/java/com/yunzhi/questions/service/ITaAnswerService.java
  93. 16
    0
      src/main/java/com/yunzhi/questions/service/ITaAppService.java
  94. 20
    0
      src/main/java/com/yunzhi/questions/service/ITaCharacterResultService.java
  95. 16
    0
      src/main/java/com/yunzhi/questions/service/ITaGameLevelQuestionService.java
  96. 16
    0
      src/main/java/com/yunzhi/questions/service/ITaGameLevelService.java
  97. 16
    0
      src/main/java/com/yunzhi/questions/service/ITaGamePersonAnswerService.java
  98. 17
    0
      src/main/java/com/yunzhi/questions/service/ITaGamePersonResultService.java
  99. 16
    0
      src/main/java/com/yunzhi/questions/service/ITaGamePersonService.java
  100. 0
    0
      src/main/java/com/yunzhi/questions/service/ITaGameService.java

+ 43
- 0
.gitignore View File

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

+ 55
- 0
bin/service.sh View File

@@ -0,0 +1,55 @@
1
+#!/bin/sh
2
+#
3
+#
4
+
5
+SERVICE_HOME="/opt/yunzhi/sgl-v2"
6
+LOG="$SERVICE_HOME/logs/nohup.log"
7
+JAR=$(ls -lt ${SERVICE_HOME}/*.jar|head -n1|rev|cut -d" " -f1|rev)
8
+
9
+start() {
10
+    PID=`ps -ef|grep marketing-v|grep -v grep|awk '{print $2}'`
11
+    if [[ "$PID" != "" ]]; then
12
+        echo ""
13
+        echo "Service is running. pid=$PID"
14
+        echo ""
15
+        exit 0
16
+    else
17
+        echo ""
18
+        echo "Start service ..."
19
+        echo "FILE: $JAR"
20
+
21
+        nohup java -jar $JAR > $LOG 2>&1 &
22
+
23
+        echo "Start finished"
24
+        echo "Pls goto $LOG see process status"
25
+        echo ""
26
+    fi
27
+}
28
+
29
+stop() {
30
+    echo ""
31
+    echo "Stoping service ..."
32
+
33
+    PID=`ps -ef|grep shigongli-|grep -v grep|awk '{print $2}'`
34
+    if [[ "$PID" != "" ]]; then
35
+        kill -9 $PID
36
+    fi
37
+
38
+    # 这个延迟不能去掉
39
+    sleep 1s
40
+    echo "Service is stoped"
41
+    echo ""
42
+}
43
+
44
+case $1 in
45
+    "start")
46
+        start ;;
47
+    "stop")
48
+        stop ;;
49
+    "reload"|"restart")
50
+        stop
51
+        start ;;
52
+    *)
53
+        echo "Usage: `basename $0` {start|stop|restart}"
54
+        exit 1
55
+esac

+ 14
- 0
bin/sgl.service View File

@@ -0,0 +1,14 @@
1
+[Unit]
2
+Description=ShiGongli
3
+After=syslog.target
4
+
5
+[Service]
6
+User=root
7
+Type=forking
8
+ExecStart=/opt/yunzhi/sgl-v2/service.sh start
9
+ExecReload=/opt/yunzhi/sgl-v2/service.sh restart
10
+ExecStop=/opt/yunzhi/sgl-v2/service.sh stop
11
+PrivateTmp=true
12
+
13
+[Install]
14
+WantedBy=multi-user.target

+ 7
- 0
deploy/bootstrap View File

@@ -0,0 +1,7 @@
1
+#!/bin/bash
2
+#
3
+#
4
+
5
+appVer="3.0.4"
6
+
7
+java -jar ./shigongli-${appVer}.jar

+ 24
- 0
deploy/template.yml View File

@@ -0,0 +1,24 @@
1
+ROSTemplateFormatVersion: '2015-09-01'
2
+Transform: 'Aliyun::Serverless-2018-04-03'
3
+Resources:
4
+  shigongli:
5
+    Type: 'Aliyun::Serverless::Service'
6
+    Properties:
7
+      InternetAccess: true
8
+      Description: '十公里'
9
+    shigongli-fn:
10
+      Type: 'Aliyun::Serverless::Function'
11
+      Properties:
12
+        Handler: com.yunzhi.shigongli.SpringApplication::main
13
+        Runtime: custom
14
+        CodeUri: 'oss://yz-serverless/shigongli/shigongli-3.0.4.zip'
15
+        MemorySize: 1024
16
+        Timeout: 30
17
+        InitializationTimeout: 30
18
+        CAPort: 8822
19
+      Events:
20
+        http-shigongli:
21
+          Type: HTTP
22
+          Properties:
23
+            AuthType: ANONYMOUS
24
+            Methods: [ 'GET', 'POST', 'PUT', 'DELETE' ]

+ 0
- 0
deploy/注意修改bootstrap文件中版本号.txt View File


+ 310
- 0
mvnw View File

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

+ 182
- 0
mvnw.cmd View File

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

+ 278
- 0
pom.xml View File

@@ -0,0 +1,278 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3
+		 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4
+	<modelVersion>4.0.0</modelVersion>
5
+	<parent>
6
+		<groupId>org.springframework.boot</groupId>
7
+		<artifactId>spring-boot-starter-parent</artifactId>
8
+		<version>2.3.2.RELEASE</version>
9
+		<relativePath/> <!-- lookup parent from repository -->
10
+	</parent>
11
+	<groupId>com.yunzhi</groupId>
12
+	<artifactId>questions</artifactId>
13
+	<version>1.0.0</version>
14
+	<name>questions</name>
15
+	<description>云致-问卷</description>
16
+
17
+	<properties>
18
+		<java.version>1.8</java.version>
19
+	</properties>
20
+
21
+	<dependencies>
22
+		<dependency>
23
+			<groupId>org.springframework.boot</groupId>
24
+			<artifactId>spring-boot-starter-web</artifactId>
25
+		</dependency>
26
+
27
+		<dependency>
28
+			<groupId>org.springframework.boot</groupId>
29
+			<artifactId>spring-boot-configuration-processor</artifactId>
30
+			<optional>true</optional>
31
+		</dependency>
32
+
33
+		<dependency>
34
+			<groupId>org.springframework.boot</groupId>
35
+			<artifactId>spring-boot-starter-test</artifactId>
36
+			<scope>test</scope>
37
+			<exclusions>
38
+				<exclusion>
39
+					<groupId>org.junit.vintage</groupId>
40
+					<artifactId>junit-vintage-engine</artifactId>
41
+				</exclusion>
42
+			</exclusions>
43
+		</dependency>
44
+
45
+		<!--shiro start-->
46
+		<!--		<dependency>-->
47
+		<!--			<groupId>org.apache.shiro</groupId>-->
48
+		<!--			<artifactId>shiro-spring-boot-starter</artifactId>-->
49
+		<!--			<version>1.7.1</version>-->
50
+		<!--		</dependency>-->
51
+		<!--shiro end-->
52
+
53
+		<!--mysql start-->
54
+		<dependency>
55
+			<groupId>mysql</groupId>
56
+			<artifactId>mysql-connector-java</artifactId>
57
+			<scope>runtime</scope>
58
+		</dependency>
59
+		<!--mysql end-->
60
+
61
+		<!--mybatis-plus start-->
62
+		<dependency>
63
+			<groupId>com.baomidou</groupId>
64
+			<artifactId>mybatis-plus-boot-starter</artifactId>
65
+			<version>3.1.1</version>
66
+		</dependency>
67
+		<!--mybatis-plus end-->
68
+
69
+		<!--fastjson start-->
70
+		<dependency>
71
+			<groupId>com.alibaba</groupId>
72
+			<artifactId>fastjson</artifactId>
73
+			<version>1.2.56</version>
74
+		</dependency>
75
+		<!--fastjson end-->
76
+
77
+		<!--jwt start-->
78
+		<dependency>
79
+			<groupId>io.jsonwebtoken</groupId>
80
+			<artifactId>jjwt-api</artifactId>
81
+			<version>0.11.2</version>
82
+		</dependency>
83
+		<dependency>
84
+			<groupId>io.jsonwebtoken</groupId>
85
+			<artifactId>jjwt-impl</artifactId>
86
+			<version>0.11.2</version>
87
+			<scope>runtime</scope>
88
+		</dependency>
89
+		<dependency>
90
+			<groupId>io.jsonwebtoken</groupId>
91
+			<artifactId>jjwt-jackson</artifactId> <!-- or jjwt-gson if Gson is preferred -->
92
+			<version>0.11.2</version>
93
+			<scope>runtime</scope>
94
+		</dependency>
95
+		<!--jwt end-->
96
+
97
+		<!--oss start-->
98
+		<dependency>
99
+			<groupId>com.aliyun.oss</groupId>
100
+			<artifactId>aliyun-sdk-oss</artifactId>
101
+			<version>2.8.3</version>
102
+		</dependency>
103
+		<!--oss end-->
104
+
105
+		<dependency>
106
+			<groupId>com.aliyun</groupId>
107
+			<artifactId>aliyun-java-sdk-core</artifactId>
108
+			<version>[4.4.9,5.0.0)</version>
109
+		</dependency>
110
+
111
+		<!--excel start-->
112
+		<dependency>
113
+			<groupId>com.alibaba</groupId>
114
+			<artifactId>easyexcel</artifactId>
115
+			<version>2.0.4</version>
116
+		</dependency>
117
+		<!--excel end-->
118
+
119
+		<!--weixin-miniapp start-->
120
+		<dependency>
121
+			<groupId>com.github.binarywang</groupId>
122
+			<artifactId>weixin-java-miniapp</artifactId>
123
+			<version>3.8.0</version>
124
+		</dependency>
125
+		<dependency>
126
+			<groupId>com.github.binarywang</groupId>
127
+			<artifactId>weixin-java-mp</artifactId>
128
+			<version>3.8.0</version>
129
+		</dependency>
130
+		<dependency>
131
+			<groupId>com.github.binarywang</groupId>
132
+			<artifactId>weixin-java-pay</artifactId>
133
+			<version>3.8.0</version>
134
+		</dependency>
135
+		<!--weixin-miniapp start-->
136
+
137
+		<!--lombok start-->
138
+		<dependency>
139
+			<groupId>org.projectlombok</groupId>
140
+			<artifactId>lombok</artifactId>
141
+			<optional>true</optional>
142
+		</dependency>
143
+		<!--lombok end-->
144
+
145
+		<!--swagger start-->
146
+		<dependency>
147
+			<groupId>io.springfox</groupId>
148
+			<artifactId>springfox-boot-starter</artifactId>
149
+			<version>3.0.0</version>
150
+		</dependency>
151
+		<!--swagger end-->
152
+	</dependencies>
153
+
154
+	<profiles>
155
+		<profile>
156
+			<id>dev</id>
157
+			<properties>
158
+				<profileActive>dev</profileActive>
159
+			</properties>
160
+			<activation>
161
+				<activeByDefault>true</activeByDefault>
162
+			</activation>
163
+
164
+			<build>
165
+				<plugins>
166
+					<plugin>
167
+						<groupId>org.springframework.boot</groupId>
168
+						<artifactId>spring-boot-maven-plugin</artifactId>
169
+						<configuration>
170
+							<excludes>
171
+								<exclude>
172
+									<groupId>org.springframework.boot</groupId>
173
+									<artifactId>spring-boot-configuration-processor</artifactId>
174
+								</exclude>
175
+							</excludes>
176
+						</configuration>
177
+					</plugin>
178
+
179
+					<!-- 跳过测试 -->
180
+					<plugin>
181
+						<groupId>org.apache.maven.plugins</groupId>
182
+						<artifactId>maven-surefire-plugin</artifactId>
183
+						<configuration>
184
+							<skipTests>true</skipTests>
185
+							<testFailureIgnore>true</testFailureIgnore>
186
+						</configuration>
187
+					</plugin>
188
+					<plugin>
189
+						<groupId>org.apache.maven.plugins</groupId>
190
+						<artifactId>maven-resources-plugin</artifactId>
191
+						<configuration>
192
+							<encoding>UTF-8</encoding>
193
+							<nonFilteredFileExtensions>
194
+								<nonFilteredFileExtension>pem</nonFilteredFileExtension>
195
+								<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
196
+								<nonFilteredFileExtension>p12</nonFilteredFileExtension>
197
+							</nonFilteredFileExtensions>
198
+						</configuration>
199
+					</plugin>
200
+				</plugins>
201
+				<resources>
202
+					<resource>
203
+						<directory>src/main/resources</directory>
204
+						<filtering>true</filtering>
205
+						<includes>
206
+							<include>**/*.xml</include>
207
+							<include>**/*.p12</include>
208
+							<include>application.yml</include>
209
+							<include>application-${profileActive}.yml</include>
210
+						</includes>
211
+					</resource>
212
+				</resources>
213
+			</build>
214
+		</profile>
215
+
216
+		<profile>
217
+			<id>prod</id>
218
+			<properties>
219
+				<profileActive>prod</profileActive>
220
+			</properties>
221
+			<activation>
222
+				<activeByDefault>false</activeByDefault>
223
+			</activation>
224
+
225
+			<build>
226
+				<plugins>
227
+					<plugin>
228
+						<groupId>org.springframework.boot</groupId>
229
+						<artifactId>spring-boot-maven-plugin</artifactId>
230
+						<configuration>
231
+							<excludes>
232
+								<exclude>
233
+									<groupId>org.springframework.boot</groupId>
234
+									<artifactId>spring-boot-configuration-processor</artifactId>
235
+								</exclude>
236
+							</excludes>
237
+						</configuration>
238
+					</plugin>
239
+
240
+					<!-- 跳过测试 -->
241
+					<plugin>
242
+						<groupId>org.apache.maven.plugins</groupId>
243
+						<artifactId>maven-surefire-plugin</artifactId>
244
+						<configuration>
245
+							<skipTests>true</skipTests>
246
+							<testFailureIgnore>true</testFailureIgnore>
247
+						</configuration>
248
+					</plugin>
249
+					<plugin>
250
+						<groupId>org.apache.maven.plugins</groupId>
251
+						<artifactId>maven-resources-plugin</artifactId>
252
+						<configuration>
253
+							<encoding>UTF-8</encoding>
254
+							<nonFilteredFileExtensions>
255
+								<nonFilteredFileExtension>pem</nonFilteredFileExtension>
256
+								<nonFilteredFileExtension>pfx</nonFilteredFileExtension>
257
+								<nonFilteredFileExtension>p12</nonFilteredFileExtension>
258
+							</nonFilteredFileExtensions>
259
+						</configuration>
260
+					</plugin>
261
+				</plugins>
262
+				<resources>
263
+					<resource>
264
+						<directory>src/main/resources</directory>
265
+						<filtering>true</filtering>
266
+						<includes>
267
+							<include>**/*.xml</include>
268
+							<include>**/*.p12</include>
269
+							<include>application.yml</include>
270
+							<include>application-${profileActive}.yml</include>
271
+						</includes>
272
+					</resource>
273
+				</resources>
274
+			</build>
275
+		</profile>
276
+	</profiles>
277
+
278
+</project>

+ 16
- 0
src/main/java/com/yunzhi/questions/SpringApplication.java View File

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

+ 57
- 0
src/main/java/com/yunzhi/questions/common/BaseController.java View File

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

+ 8
- 0
src/main/java/com/yunzhi/questions/common/Callback.java View File

@@ -0,0 +1,8 @@
1
+package com.yunzhi.questions.common;
2
+
3
+/**
4
+ * 实现类似 JS 回调函数的功能
5
+ */
6
+public abstract class Callback {
7
+    public abstract void next() throws Exception;
8
+}

+ 13
- 0
src/main/java/com/yunzhi/questions/common/Constants.java View File

@@ -0,0 +1,13 @@
1
+package com.yunzhi.questions.common;
2
+
3
+public class Constants {
4
+    // 基本状态
5
+    public final static int STATUS_DELETED = -1;
6
+    public final static int STATUS_READY = 0;
7
+    public final static int STATUS_NORMAL = 1;
8
+
9
+    // 游戏结果模型
10
+    public final static String GAME_OF_CHARACTER_MATCHED = "character_matched";
11
+
12
+
13
+}

+ 25
- 0
src/main/java/com/yunzhi/questions/common/CurrentContext.java View File

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

+ 37
- 0
src/main/java/com/yunzhi/questions/common/DateUtils.java View File

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

+ 17
- 0
src/main/java/com/yunzhi/questions/common/EncryptUtils.java View File

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

+ 27
- 0
src/main/java/com/yunzhi/questions/common/ExcelUtils.java View File

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

+ 107
- 0
src/main/java/com/yunzhi/questions/common/JWTUtils.java View File

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

+ 11
- 0
src/main/java/com/yunzhi/questions/common/MathUtils.java View File

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

+ 166
- 0
src/main/java/com/yunzhi/questions/common/OSSUtils.java View File

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

+ 86
- 0
src/main/java/com/yunzhi/questions/common/ResponseBean.java View File

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

+ 145
- 0
src/main/java/com/yunzhi/questions/common/SMSCaptcha.java View File

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

+ 71
- 0
src/main/java/com/yunzhi/questions/common/SMSUtils.java View File

@@ -0,0 +1,71 @@
1
+package com.yunzhi.questions.common;
2
+
3
+import com.aliyuncs.CommonRequest;
4
+import com.aliyuncs.CommonResponse;
5
+import com.aliyuncs.DefaultAcsClient;
6
+import com.aliyuncs.IAcsClient;
7
+import com.aliyuncs.http.MethodType;
8
+import com.aliyuncs.profile.DefaultProfile;
9
+import com.yunzhi.questions.config.AliyunConfig;
10
+import lombok.Data;
11
+import lombok.experimental.Accessors;
12
+import lombok.extern.slf4j.Slf4j;
13
+import org.springframework.beans.factory.InitializingBean;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.stereotype.Component;
16
+
17
+@Slf4j
18
+@Component
19
+public class SMSUtils implements InitializingBean {
20
+
21
+    IAcsClient acsClient;
22
+
23
+    //产品名称:云通信短信API产品,开发者无需替换
24
+    static final String product = "Dysmsapi";
25
+    //产品域名,开发者无需替换
26
+    static final String domain = "dysmsapi.aliyuncs.com";
27
+    //API 的名称,开发者无需替换
28
+    static final String action = "SendSms";
29
+    //API RegionId,开发者无需替换
30
+    static final String regionId = "cn-hangzhou";
31
+    //API 版本,开发者无需替换
32
+    static final String verison = "2017-05-25";
33
+
34
+    @Autowired
35
+    AliyunConfig aliyunConfig;
36
+
37
+    public void sendMessage(Message message) throws Exception {
38
+        request(message);
39
+    }
40
+
41
+    private CommonResponse request(Message message) throws Exception {
42
+        CommonRequest request = new CommonRequest();
43
+        request.setSysMethod(MethodType.POST);
44
+        request.setSysDomain(domain);
45
+        request.setSysVersion(verison);
46
+        request.setSysAction(action);
47
+        request.putQueryParameter("RegionId", regionId);
48
+        request.putQueryParameter("PhoneNumbers", message.getTel());
49
+        request.putQueryParameter("SignName", message.getSign());
50
+        request.putQueryParameter("TemplateCode", message.getCode());
51
+        request.putQueryParameter("TemplateParam", message.getContent());
52
+
53
+        return acsClient.getCommonResponse(request);
54
+    }
55
+
56
+    @Override
57
+    public void afterPropertiesSet() throws Exception {
58
+        AliyunConfig.Sms sms = aliyunConfig.getSms();
59
+        DefaultProfile profile = DefaultProfile.getProfile("cn-hangzhou", aliyunConfig.getAccessKeyId(), aliyunConfig.getAccessKeySecret());
60
+        acsClient = new DefaultAcsClient(profile);
61
+    }
62
+
63
+    @Data
64
+    @Accessors(chain = true)
65
+    public static class Message {
66
+        String code;
67
+        String tel;
68
+        String sign;
69
+        String content;
70
+    }
71
+}

+ 203
- 0
src/main/java/com/yunzhi/questions/common/StringUtils.java View File

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

+ 208
- 0
src/main/java/com/yunzhi/questions/common/WxUtils.java View File

@@ -0,0 +1,208 @@
1
+package com.yunzhi.questions.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.bean.WxMaCodeLineColor;
6
+import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
7
+import cn.binarywang.wx.miniapp.config.WxMaConfig;
8
+import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
9
+import com.github.binarywang.wxpay.config.WxPayConfig;
10
+import com.github.binarywang.wxpay.constant.WxPayConstants;
11
+import com.github.binarywang.wxpay.service.WxPayService;
12
+import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
13
+import com.yunzhi.questions.config.WeixinConfig;
14
+import lombok.Data;
15
+import lombok.extern.slf4j.Slf4j;
16
+import me.chanjar.weixin.common.error.WxErrorException;
17
+import me.chanjar.weixin.mp.api.WxMpService;
18
+import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
19
+import me.chanjar.weixin.mp.bean.template.WxMpTemplateData;
20
+import me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage;
21
+import me.chanjar.weixin.mp.config.WxMpConfigStorage;
22
+import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
23
+import org.springframework.beans.factory.annotation.Autowired;
24
+import org.springframework.scheduling.annotation.Async;
25
+import org.springframework.stereotype.Component;
26
+
27
+import java.io.File;
28
+import java.util.List;
29
+import java.util.Map;
30
+import java.util.concurrent.ConcurrentHashMap;
31
+
32
+@Slf4j
33
+@Component
34
+public class WxUtils {
35
+    // 小程序
36
+    private Map<String, WxMaService> maServiceMap;
37
+    // 公众号
38
+    private Map<String, WxMpService> mpServiceMap;
39
+
40
+    @Autowired
41
+    public WxUtils() {
42
+        maServiceMap = new ConcurrentHashMap<>();
43
+        mpServiceMap = new ConcurrentHashMap<>();
44
+    }
45
+
46
+    /**
47
+     * 生成 公众号 服务
48
+     * @param config
49
+     * @return
50
+     */
51
+    public WxMpService newMpService(WxMpConfigStorage config) {
52
+        WxMpService service = new WxMpServiceImpl();
53
+        service.setWxMpConfigStorage(config);
54
+        return service;
55
+    }
56
+
57
+    /**
58
+     * 添加一个公众号服务到 Map
59
+     * @param appid
60
+     * @param service
61
+     */
62
+    public void addMpService(String appid, WxMpService service) {
63
+        mpServiceMap.put(appid, service);
64
+    }
65
+
66
+    /**
67
+     * 删除一个公众号服务
68
+     * @param appid
69
+     */
70
+    public void removeMpService(String appid) {
71
+        mpServiceMap.remove(appid);
72
+    }
73
+
74
+    /**
75
+     * 生成一个小程序服务
76
+     * @param config
77
+     * @return
78
+     */
79
+    public WxMaService newMaService(WxMaConfig config) {
80
+        WxMaService service = new WxMaServiceImpl();
81
+        service.setWxMaConfig(config);
82
+        return service;
83
+    }
84
+
85
+    /**
86
+     * 添加一个小程序服务到 MAP
87
+     * @param appid
88
+     * @param service
89
+     */
90
+    public void addMaService(String appid, WxMaService service) {
91
+        maServiceMap.put(appid, service);
92
+    }
93
+
94
+    /**
95
+     * 删除一个小程序服务
96
+     * @param appid
97
+     */
98
+    public void removeMaService(String appid) {
99
+        maServiceMap.remove(appid);
100
+    }
101
+
102
+    /**
103
+     * 生成一个小程序二维码
104
+     * @param service
105
+     * @param path
106
+     * @return
107
+     * @throws WxErrorException
108
+     */
109
+    public File createMaQRCode(WxMaService service, String path) throws WxErrorException {
110
+        return service.getQrcodeService().createQrcode(path);
111
+    }
112
+
113
+    /**
114
+     * 获取 appid 对应的小程序服务
115
+     * @param appid
116
+     * @return
117
+     */
118
+    public WxMaService getMaService(String appid) {
119
+        return maServiceMap.get(appid);
120
+    }
121
+
122
+    /**
123
+     * 获取 appid 对应的公众号服务
124
+     * @param appid
125
+     * @return
126
+     */
127
+    public WxMpService getMpService(String appid) {
128
+        return mpServiceMap.get(appid);
129
+    }
130
+
131
+
132
+    @Data
133
+    public static class MAQrCodeParam {
134
+        private String scene;
135
+        private String page;
136
+        private int width;
137
+        private boolean autoColor;
138
+        private WxMaCodeLineColor lineColor;
139
+        private boolean isHyaline;
140
+    }
141
+
142
+    /**
143
+     * 发送小程序订阅消息
144
+     * @param templateId
145
+     * @param openid
146
+     * @param page
147
+     * @param dataList
148
+     * @throws Exception
149
+     */
150
+    @Async
151
+    public void sendMaMessage(WxMaService service, String templateId, String openid, String page, List<WxMaSubscribeMessage.Data> dataList) throws Exception {
152
+        WxMaSubscribeMessage wxMaSubscribeMessage = WxMaSubscribeMessage
153
+                .builder()
154
+                .templateId(templateId)
155
+                .toUser(openid)
156
+                .page(page)
157
+                .data(dataList)
158
+                .build();
159
+
160
+        try {
161
+            service.getMsgService().sendSubscribeMsg(wxMaSubscribeMessage);
162
+        } catch (Exception e) {
163
+            e.printStackTrace();
164
+
165
+            // 再发送一次
166
+            Thread.sleep(1000);
167
+            service.getMsgService().sendSubscribeMsg(wxMaSubscribeMessage);
168
+        }
169
+    }
170
+
171
+    /**
172
+     * 发送公众号模板消息
173
+     * @param toUser
174
+     * @param templateId
175
+     * @param miniAppId
176
+     * @param page
177
+     * @param datas
178
+     * @return
179
+     * @throws WxErrorException
180
+     */
181
+    public void sendMpMessage(WxMpService service, String toUser, String templateId, String miniAppId, String page, String url, List<WxMpTemplateData> datas) throws Exception {
182
+        String pagepath = StringUtils.trim(page, "/");
183
+        WxMpTemplateMessage.MiniProgram miniProgram = null == miniAppId ? null : new WxMpTemplateMessage.MiniProgram(miniAppId, pagepath, false);
184
+
185
+        log.info("模板信息-内容: {}", miniProgram);
186
+
187
+        WxMpTemplateMessage templateMessage = WxMpTemplateMessage.builder()
188
+                .toUser(toUser)
189
+                .miniProgram(miniProgram)
190
+                .templateId(templateId)
191
+                .url(url)
192
+                .build();
193
+
194
+        for (WxMpTemplateData data: datas) {
195
+            templateMessage.addData(data);
196
+        }
197
+
198
+        try {
199
+            service.getTemplateMsgService().sendTemplateMsg(templateMessage);
200
+        } catch (Exception e) {
201
+            e.printStackTrace();
202
+
203
+            // 再发送一次
204
+            Thread.sleep(1000);
205
+            service.getTemplateMsgService().sendTemplateMsg(templateMessage);
206
+        }
207
+    }
208
+}

+ 53
- 0
src/main/java/com/yunzhi/questions/common/excelConverter/LocalDateTimeConverter.java View File

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

+ 53
- 0
src/main/java/com/yunzhi/questions/common/excelConverter/LocalDayConverter.java View File

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

+ 55
- 0
src/main/java/com/yunzhi/questions/common/excelConverter/MoneyConverter.java View File

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

+ 40
- 0
src/main/java/com/yunzhi/questions/config/AliyunConfig.java View File

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

+ 35
- 0
src/main/java/com/yunzhi/questions/config/BaseConfig.java View File

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

+ 28
- 0
src/main/java/com/yunzhi/questions/config/CorsConfig.java View File

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

+ 32
- 0
src/main/java/com/yunzhi/questions/config/InterceptorConfig.java View File

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

+ 21
- 0
src/main/java/com/yunzhi/questions/config/LoggingFilterConfig.java View File

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

+ 14
- 0
src/main/java/com/yunzhi/questions/config/MybatisPlusConfig.java View File

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

+ 24
- 0
src/main/java/com/yunzhi/questions/config/SwagggerConfig.java View File

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

+ 35
- 0
src/main/java/com/yunzhi/questions/config/WeixinConfig.java View File

@@ -0,0 +1,35 @@
1
+package com.yunzhi.questions.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 = "weixin")
10
+public class WeixinConfig {
11
+
12
+    private Miniapp miniapp;
13
+
14
+    private Mp mp;
15
+
16
+    @Data
17
+    public static class Miniapp {
18
+        private String appid;
19
+        private String secret;
20
+        private String token;
21
+        private String aesKey;
22
+        private String msgDataFormat;
23
+    }
24
+
25
+    @Data
26
+    public static class Mp {
27
+        private String appid;
28
+        private String secret;
29
+        private String token;
30
+        private String aesKey;
31
+        private String httpPoxyHost;
32
+        private Integer httpProxyPort;
33
+    }
34
+
35
+}

+ 102
- 0
src/main/java/com/yunzhi/questions/controller/CommController.java View File

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

+ 174
- 0
src/main/java/com/yunzhi/questions/controller/LoginController.java View File

@@ -0,0 +1,174 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.yunzhi.questions.common.*;
4
+import com.yunzhi.questions.entity.SysLogin;
5
+import com.yunzhi.questions.entity.SysUser;
6
+import com.yunzhi.questions.entity.TaApp;
7
+import com.yunzhi.questions.entity.TaPerson;
8
+import com.yunzhi.questions.service.ISysLoginService;
9
+import com.yunzhi.questions.service.ISysUserService;
10
+import com.yunzhi.questions.service.ITaAppService;
11
+import com.yunzhi.questions.service.ITaPersonService;
12
+import com.yunzhi.questions.vo.ChangePassword;
13
+import com.yunzhi.questions.vo.AdminLoginParam;
14
+import com.yunzhi.questions.vo.LoginParam;
15
+import com.yunzhi.questions.vo.TokenParam;
16
+import io.swagger.annotations.Api;
17
+import io.swagger.annotations.ApiOperation;
18
+import io.swagger.annotations.ApiParam;
19
+import org.springframework.beans.factory.annotation.Autowired;
20
+import org.springframework.web.bind.annotation.*;
21
+
22
+import javax.servlet.http.HttpServletRequest;
23
+import java.util.HashMap;
24
+import java.util.Map;
25
+
26
+@Api(tags = "登入/登出")
27
+@RestController
28
+public class LoginController extends BaseController {
29
+
30
+    @Autowired
31
+    SMSCaptcha smsCaptcha;
32
+
33
+    @Autowired
34
+    ISysLoginService iSysLoginService;
35
+
36
+    @Autowired
37
+    ISysUserService iSysUserService;
38
+
39
+    @Autowired
40
+    ITaPersonService iTaPersonService;
41
+
42
+    @Autowired
43
+    ITaAppService iTaAppService;
44
+
45
+    @PostMapping("/admin/login")
46
+    @ApiOperation(value="登录", notes = "登录", httpMethod = "POST", response = ResponseBean.class)
47
+    public ResponseBean login(@ApiParam("登录参数") @RequestBody AdminLoginParam loginParam) throws Exception {
48
+        if (null == loginParam) {
49
+            return ResponseBean.error("账户或密码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
50
+        }
51
+
52
+        String userName = loginParam.getUserName();
53
+        String password = loginParam.getPassword();
54
+
55
+        if (StringUtils.isEmpty(userName) || StringUtils.isEmpty(password)) {
56
+            return ResponseBean.error("账户或密码不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
57
+        }
58
+
59
+        SysLogin sysLogin = iSysLoginService.getByLoginName(userName);
60
+        if (null == sysLogin) {
61
+            return ResponseBean.error("账户或密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
62
+        }
63
+
64
+        SysUser sysUser = iSysUserService.getById(sysLogin.getUserId());
65
+        if (null == sysUser) {
66
+            return ResponseBean.error("账户或密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
67
+        }
68
+
69
+        if (!checkPassword(password, sysLogin.getPassword(), sysLogin.getUserId())) {
70
+            return ResponseBean.error("账户或密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
71
+        }
72
+
73
+        if (Constants.STATUS_NORMAL != sysUser.getStatus()) {
74
+            return ResponseBean.error("用户状态不正确, 请联系管理人员", ResponseBean.ERROR_UNAVAILABLE);
75
+        }
76
+
77
+        // 生成 token
78
+        TokenParam tokenParam = new TokenParam()
79
+                .setUserId(sysUser.getUserId())
80
+                .setOrgId("0");
81
+
82
+        Map<String, Object> tokenMap = tokenParam.toMap();
83
+        String token = JWTUtils.encode(tokenMap);
84
+//        CurrentContext.setTokenParam(tokenMap);
85
+
86
+        Map<String, Object> res = new HashMap<String, Object>() {{
87
+            put("user", sysUser);
88
+            put("token", token);
89
+        }};
90
+        return ResponseBean.success(res);
91
+    }
92
+
93
+
94
+    @PutMapping("/admin/change-password")
95
+    @ApiOperation(value="修改密码", notes = "修改密码", httpMethod = "PUT", response = ResponseBean.class)
96
+    public ResponseBean changePassword(@ApiParam("修改密码参数") @RequestBody ChangePassword param,
97
+                                       HttpServletRequest request) 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 = getCurrentUser(request);
103
+        SysLogin sysLogin = iSysLoginService.getByUser(currentUser.getUserId());
104
+
105
+        if (!checkPassword(param.getOriginPassword(), sysLogin.getPassword(), currentUser.getUserId())) {
106
+            return ResponseBean.error("原始密码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
107
+        }
108
+
109
+        sysLogin.setPassword(EncryptUtils.md5(param.getNewPassword(), currentUser.getUserId()));
110
+        iSysLoginService.updateById(sysLogin);
111
+
112
+        return ResponseBean.success("密码修改成功");
113
+    }
114
+
115
+
116
+    @ApiParam("客户端登录")
117
+    @PostMapping("/{appid}/login")
118
+    public ResponseBean clientLogin(@ApiParam("APPID") @PathVariable String appid,
119
+                                    @ApiParam("登录参数") @RequestBody LoginParam loginParam) throws Exception {
120
+        if (null == loginParam) {
121
+            return ResponseBean.error("登录参数不存在", ResponseBean.ERROR_ILLEGAL_PARAMS);
122
+        }
123
+
124
+        if (StringUtils.isEmpty(loginParam.getName())
125
+            || StringUtils.isEmpty(loginParam.getPhone())
126
+            || StringUtils.isEmpty(loginParam.getCaptcha())) {
127
+            return ResponseBean.error("登录参数不合法", ResponseBean.ERROR_ILLEGAL_PARAMS);
128
+        }
129
+
130
+        boolean isCapatchRight = smsCaptcha.validate(loginParam.getPhone(), loginParam.getCaptcha());
131
+        if (!isCapatchRight) {
132
+            return ResponseBean.error("验证码不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
133
+        }
134
+
135
+        //
136
+        TaApp taApp = iTaAppService.getById(appid);
137
+        if (null == taApp) {
138
+            return ResponseBean.error("APPID不正确", ResponseBean.ERROR_ILLEGAL_PARAMS);
139
+        }
140
+
141
+        TaPerson taPerson = iTaPersonService.getByPhone(loginParam.getPhone());
142
+        if (null != taPerson) {
143
+           return ResponseBean.success(taPerson);
144
+        }
145
+
146
+        taPerson = new TaPerson();
147
+        taPerson.setNickName(loginParam.getName());
148
+        taPerson.setPhone(loginParam.getPhone());
149
+        if (iTaPersonService.save(taPerson)) {
150
+            Map<String, Object> result = new HashMap<>();
151
+            result.put("person", taPerson);
152
+
153
+            return ResponseBean.success(taPerson);
154
+        } else {
155
+            return ResponseBean.error("登录失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
156
+        }
157
+    }
158
+
159
+//    @PutMapping("/admin/reset-password/{userId}")
160
+//    @ApiOperation(value="重置密码", notes = "重置密码", httpMethod = "PUT", response = ResponseBean.class)
161
+//    public ResponseBean resetPassword(@ApiParam("用户ID") @PathVariable String userId) throws Exception {
162
+//        SysLogin sysLogin = iSysLoginService.getByUser(userId);
163
+//
164
+//        String newPassword = EncryptUtils.md5(EncryptUtils.md5(Constants.DEFAULT_PASSWORD), userId);
165
+//        sysLogin.setPassword(newPassword);
166
+//        iSysLoginService.updateById(sysLogin);
167
+//
168
+//        return ResponseBean.success("重置密码成功");
169
+//    }
170
+
171
+    private boolean checkPassword(String src, String targ, String salt) {
172
+        return EncryptUtils.md5(src, salt).equals(targ);
173
+    }
174
+}

+ 119
- 0
src/main/java/com/yunzhi/questions/controller/SysUserController.java View File

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

+ 119
- 0
src/main/java/com/yunzhi/questions/controller/TaAnswerController.java View File

@@ -0,0 +1,119 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.questions.common.BaseController;
7
+import com.yunzhi.questions.common.ResponseBean;
8
+import io.swagger.annotations.Api;
9
+import io.swagger.annotations.ApiOperation;
10
+import io.swagger.annotations.ApiParam;
11
+import org.slf4j.Logger;
12
+import org.slf4j.LoggerFactory;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.web.bind.annotation.PathVariable;
15
+import org.springframework.web.bind.annotation.RequestBody;
16
+import org.springframework.web.bind.annotation.RequestMapping;
17
+import org.springframework.web.bind.annotation.RequestMethod;
18
+import org.springframework.web.bind.annotation.RequestParam;
19
+import com.yunzhi.questions.service.ITaAnswerService;
20
+import com.yunzhi.questions.entity.TaAnswer;
21
+import org.springframework.web.bind.annotation.RestController;
22
+
23
+/**
24
+ * <p>
25
+    * 题库答案 前端控制器
26
+    * </p>
27
+ *
28
+ * @author yansen
29
+ * @since 2021-12-10
30
+ */
31
+
32
+@Api(tags = "题库答案")
33
+@RestController
34
+@RequestMapping("/")
35
+public class TaAnswerController extends BaseController {
36
+
37
+    private final Logger logger = LoggerFactory.getLogger(TaAnswerController.class);
38
+
39
+    @Autowired
40
+    public ITaAnswerService iTaAnswerService;
41
+
42
+
43
+    /**
44
+     * 分页查询列表
45
+     * @param pageNum
46
+     * @param pageSize
47
+     * @return
48
+     */
49
+    @RequestMapping(value="/taAnswer",method= RequestMethod.GET)
50
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
+    public ResponseBean taAnswerList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+
54
+		    IPage<TaAnswer> pg = new Page<>(pageNum, pageSize);
55
+            QueryWrapper<TaAnswer> queryWrapper = new QueryWrapper<>();
56
+            queryWrapper.orderByDesc("create_date");
57
+
58
+            IPage<TaAnswer> result = iTaAnswerService.page(pg, queryWrapper);
59
+            return ResponseBean.success(result);
60
+    }
61
+
62
+    /**
63
+     * 保存对象
64
+     * @param taAnswer 实体对象
65
+     * @return
66
+     */
67
+    @RequestMapping(value="/taAnswer",method= RequestMethod.POST)
68
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
+    public ResponseBean taAnswerAdd(@ApiParam("保存内容") @RequestBody TaAnswer taAnswer) throws Exception{
70
+
71
+        if (iTaAnswerService.save(taAnswer)){
72
+            return ResponseBean.success(taAnswer);
73
+        }else {
74
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
+        }
76
+    }
77
+
78
+    /**
79
+     * 根据id删除对象
80
+     * @param id  实体ID
81
+     */
82
+    @RequestMapping(value="/taAnswer/{id}", method= RequestMethod.DELETE)
83
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
+    public ResponseBean taAnswerDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
+        if(iTaAnswerService.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 taAnswer 实体对象
96
+     * @return
97
+     */
98
+    @RequestMapping(value="/taAnswer/{id}",method= RequestMethod.PUT)
99
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
+    public ResponseBean taAnswerUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
+                                        @ApiParam("更新内容") @RequestBody TaAnswer taAnswer) throws Exception{
102
+
103
+        if (iTaAnswerService.updateById(taAnswer)){
104
+            return ResponseBean.success(iTaAnswerService.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="/taAnswer/{id}",method= RequestMethod.GET)
115
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
+    public ResponseBean taAnswerGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
+        return ResponseBean.success(iTaAnswerService.getById(id));
118
+    }
119
+}

+ 119
- 0
src/main/java/com/yunzhi/questions/controller/TaAppController.java View File

@@ -0,0 +1,119 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.questions.common.BaseController;
7
+import com.yunzhi.questions.common.ResponseBean;
8
+import io.swagger.annotations.Api;
9
+import io.swagger.annotations.ApiOperation;
10
+import io.swagger.annotations.ApiParam;
11
+import org.slf4j.Logger;
12
+import org.slf4j.LoggerFactory;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.web.bind.annotation.PathVariable;
15
+import org.springframework.web.bind.annotation.RequestBody;
16
+import org.springframework.web.bind.annotation.RequestMapping;
17
+import org.springframework.web.bind.annotation.RequestMethod;
18
+import org.springframework.web.bind.annotation.RequestParam;
19
+import com.yunzhi.questions.service.ITaAppService;
20
+import com.yunzhi.questions.entity.TaApp;
21
+import org.springframework.web.bind.annotation.RestController;
22
+
23
+/**
24
+ * <p>
25
+    * 应用表 前端控制器
26
+    * </p>
27
+ *
28
+ * @author yansen
29
+ * @since 2021-12-10
30
+ */
31
+
32
+@Api(tags = "应用表")
33
+@RestController
34
+@RequestMapping("/")
35
+public class TaAppController extends BaseController {
36
+
37
+    private final Logger logger = LoggerFactory.getLogger(TaAppController.class);
38
+
39
+    @Autowired
40
+    public ITaAppService iTaAppService;
41
+
42
+
43
+    /**
44
+     * 分页查询列表
45
+     * @param pageNum
46
+     * @param pageSize
47
+     * @return
48
+     */
49
+    @RequestMapping(value="/taApp",method= RequestMethod.GET)
50
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
+    public ResponseBean taAppList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+
54
+		    IPage<TaApp> pg = new Page<>(pageNum, pageSize);
55
+            QueryWrapper<TaApp> queryWrapper = new QueryWrapper<>();
56
+            queryWrapper.orderByDesc("create_date");
57
+
58
+            IPage<TaApp> result = iTaAppService.page(pg, queryWrapper);
59
+            return ResponseBean.success(result);
60
+    }
61
+
62
+    /**
63
+     * 保存对象
64
+     * @param taApp 实体对象
65
+     * @return
66
+     */
67
+    @RequestMapping(value="/taApp",method= RequestMethod.POST)
68
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
+    public ResponseBean taAppAdd(@ApiParam("保存内容") @RequestBody TaApp taApp) throws Exception{
70
+
71
+        if (iTaAppService.save(taApp)){
72
+            return ResponseBean.success(taApp);
73
+        }else {
74
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
+        }
76
+    }
77
+
78
+    /**
79
+     * 根据id删除对象
80
+     * @param id  实体ID
81
+     */
82
+    @RequestMapping(value="/taApp/{id}", method= RequestMethod.DELETE)
83
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
+    public ResponseBean taAppDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
+        if(iTaAppService.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 taApp 实体对象
96
+     * @return
97
+     */
98
+    @RequestMapping(value="/taApp/{id}",method= RequestMethod.PUT)
99
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
+    public ResponseBean taAppUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
+                                        @ApiParam("更新内容") @RequestBody TaApp taApp) throws Exception{
102
+
103
+        if (iTaAppService.updateById(taApp)){
104
+            return ResponseBean.success(iTaAppService.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="/taApp/{id}",method= RequestMethod.GET)
115
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
+    public ResponseBean taAppGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
+        return ResponseBean.success(iTaAppService.getById(id));
118
+    }
119
+}

+ 178
- 0
src/main/java/com/yunzhi/questions/controller/TaCharacterResultController.java View File

@@ -0,0 +1,178 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.questions.common.BaseController;
7
+import com.yunzhi.questions.common.Constants;
8
+import com.yunzhi.questions.common.ResponseBean;
9
+import com.yunzhi.questions.entity.SysUser;
10
+import com.yunzhi.questions.entity.TdCharacterWord;
11
+import com.yunzhi.questions.service.ITdCharacterLibService;
12
+import com.yunzhi.questions.service.ITdCharacterWordService;
13
+import io.swagger.annotations.Api;
14
+import io.swagger.annotations.ApiOperation;
15
+import io.swagger.annotations.ApiParam;
16
+import org.slf4j.Logger;
17
+import org.slf4j.LoggerFactory;
18
+import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.web.bind.annotation.PathVariable;
20
+import org.springframework.web.bind.annotation.RequestBody;
21
+import org.springframework.web.bind.annotation.RequestMapping;
22
+import org.springframework.web.bind.annotation.RequestMethod;
23
+import org.springframework.web.bind.annotation.RequestParam;
24
+import com.yunzhi.questions.service.ITaCharacterResultService;
25
+import com.yunzhi.questions.entity.TaCharacterResult;
26
+import org.springframework.web.bind.annotation.RestController;
27
+
28
+import javax.servlet.http.HttpServletRequest;
29
+import java.util.List;
30
+
31
+/**
32
+ * <p>
33
+    * 游戏特征实例 前端控制器
34
+    * </p>
35
+ *
36
+ * @author yansen
37
+ * @since 2021-12-15
38
+ */
39
+
40
+@Api(tags = "游戏特征实例")
41
+@RestController
42
+@RequestMapping("/")
43
+public class TaCharacterResultController extends BaseController {
44
+
45
+    private final Logger logger = LoggerFactory.getLogger(TaCharacterResultController.class);
46
+
47
+    @Autowired
48
+    public ITaCharacterResultService iTaCharacterResultService;
49
+
50
+    @Autowired
51
+    public ITdCharacterLibService iTdCharacterLibService;
52
+
53
+    @Autowired
54
+    public ITdCharacterWordService iTdCharacterWordService;
55
+
56
+
57
+    /**
58
+     * 分页查询列表
59
+     * @param pageNum
60
+     * @param pageSize
61
+     * @return
62
+     */
63
+    @RequestMapping(value="/admin/character-result",method= RequestMethod.GET)
64
+    @ApiOperation(value="游戏特征实例列表", notes = "游戏特征实例列表", httpMethod = "GET", response = ResponseBean.class)
65
+    public ResponseBean taCharacterResultList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
66
+                                              @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
67
+
68
+		    IPage<TaCharacterResult> pg = new Page<>(pageNum, pageSize);
69
+            QueryWrapper<TaCharacterResult> queryWrapper = new QueryWrapper<>();
70
+            queryWrapper.orderByDesc("create_date");
71
+
72
+            IPage<TaCharacterResult> result = iTaCharacterResultService.page(pg, queryWrapper);
73
+            return ResponseBean.success(result);
74
+    }
75
+
76
+    /**
77
+     * 保存对象
78
+     * @param taCharacterResult 实体对象
79
+     * @return
80
+     */
81
+    @RequestMapping(value="/admin/character-result",method= RequestMethod.POST)
82
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
83
+    public ResponseBean taCharacterResultAdd(@ApiParam("保存内容") @RequestBody TaCharacterResult taCharacterResult,
84
+                                             HttpServletRequest request) throws Exception{
85
+        SysUser user = getCurrentUser(request);
86
+        int rows = iTdCharacterLibService.getCountOfMapUser(user.getUserId(), taCharacterResult.getLibId());
87
+        if (rows < 1) {
88
+            return ResponseBean.error("没有找到所属特征库, 请重试", ResponseBean.ERROR_UNAVAILABLE);
89
+        }
90
+
91
+        if (iTaCharacterResultService.saveWithWords(user, taCharacterResult)){
92
+            return ResponseBean.success(taCharacterResult);
93
+        }else {
94
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
95
+        }
96
+    }
97
+
98
+    /**
99
+     * 根据id删除对象
100
+     * @param id  实体ID
101
+     */
102
+    @RequestMapping(value="/taCharacterResult/{id}", method= RequestMethod.DELETE)
103
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
104
+    public ResponseBean taCharacterResultDelete(@ApiParam("对象ID") @PathVariable String id,
105
+                                                HttpServletRequest request) throws Exception{
106
+
107
+        TaCharacterResult taCharacterResult = iTaCharacterResultService.getById(id);
108
+        if (null == taCharacterResult || taCharacterResult.getStatus() == Constants.STATUS_DELETED) {
109
+            return ResponseBean.error("没有找到所属特征库, 请重试", ResponseBean.ERROR_UNAVAILABLE);
110
+        }
111
+
112
+        int rows = iTdCharacterLibService.getCountOfMapUser(getCurrentUser(request).getUserId(), taCharacterResult.getLibId());
113
+        if (rows < 1) {
114
+            return ResponseBean.error("没有找到所属特征库, 请重试", ResponseBean.ERROR_UNAVAILABLE);
115
+        }
116
+
117
+        if(iTaCharacterResultService.removeLogicById(id)){
118
+            return ResponseBean.success("success");
119
+        }else {
120
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
121
+        }
122
+    }
123
+
124
+    /**
125
+     * 修改对象
126
+     * @param id  实体ID
127
+     * @param taCharacterResult 实体对象
128
+     * @return
129
+     */
130
+    @RequestMapping(value="/taCharacterResult/{id}",method= RequestMethod.PUT)
131
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
132
+    public ResponseBean taCharacterResultUpdate(@ApiParam("对象ID") @PathVariable String id,
133
+                                                @ApiParam("更新内容") @RequestBody TaCharacterResult taCharacterResult,
134
+                                                HttpServletRequest request) throws Exception{
135
+        TaCharacterResult origin = iTaCharacterResultService.getById(id);
136
+        if (null == origin || origin.getStatus() == Constants.STATUS_DELETED) {
137
+            return ResponseBean.error("没有找到所属特征库, 请重试", ResponseBean.ERROR_UNAVAILABLE);
138
+        }
139
+
140
+        int rows = iTdCharacterLibService.getCountOfMapUser(getCurrentUser(request).getUserId(), origin.getLibId());
141
+        if (rows < 1) {
142
+            return ResponseBean.error("没有找到所属特征库, 请重试", ResponseBean.ERROR_UNAVAILABLE);
143
+        }
144
+
145
+        taCharacterResult.setResultId(id);
146
+        taCharacterResult.setLibId(origin.getLibId());
147
+
148
+        if (iTaCharacterResultService.updateWithWords(taCharacterResult)){
149
+            return ResponseBean.success(iTaCharacterResultService.getById(id));
150
+        }else {
151
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
152
+        }
153
+    }
154
+
155
+    /**
156
+     * 根据id查询对象
157
+     * @param id  实体ID
158
+     */
159
+    @RequestMapping(value="/taCharacterResult/{id}",method= RequestMethod.GET)
160
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
161
+    public ResponseBean taCharacterResultGet(@ApiParam("对象ID") @PathVariable String id,
162
+                                             HttpServletRequest request) throws Exception{
163
+        TaCharacterResult taCharacterResult = iTaCharacterResultService.getById(id);
164
+        if (null == taCharacterResult || taCharacterResult.getStatus() == Constants.STATUS_DELETED) {
165
+            return ResponseBean.error("没有找到所属特征库, 请重试", ResponseBean.ERROR_UNAVAILABLE);
166
+        }
167
+
168
+        int rows = iTdCharacterLibService.getCountOfMapUser(getCurrentUser(request).getUserId(), taCharacterResult.getLibId());
169
+        if (rows < 1) {
170
+            return ResponseBean.error("没有找到所属特征库, 请重试", ResponseBean.ERROR_UNAVAILABLE);
171
+        }
172
+
173
+        List<TdCharacterWord> wordList = iTdCharacterWordService.getListByResultId(id);
174
+        taCharacterResult.setWordList(wordList);
175
+
176
+        return ResponseBean.success(taCharacterResult);
177
+    }
178
+}

+ 120
- 0
src/main/java/com/yunzhi/questions/controller/TaGameController.java View File

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

+ 133
- 0
src/main/java/com/yunzhi/questions/controller/TaGameLevelController.java View File

@@ -0,0 +1,133 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.questions.common.BaseController;
7
+import com.yunzhi.questions.common.Constants;
8
+import com.yunzhi.questions.common.ResponseBean;
9
+import com.yunzhi.questions.common.StringUtils;
10
+import io.swagger.annotations.Api;
11
+import io.swagger.annotations.ApiOperation;
12
+import io.swagger.annotations.ApiParam;
13
+import org.slf4j.Logger;
14
+import org.slf4j.LoggerFactory;
15
+import org.springframework.beans.factory.annotation.Autowired;
16
+import org.springframework.web.bind.annotation.PathVariable;
17
+import org.springframework.web.bind.annotation.RequestBody;
18
+import org.springframework.web.bind.annotation.RequestMapping;
19
+import org.springframework.web.bind.annotation.RequestMethod;
20
+import org.springframework.web.bind.annotation.RequestParam;
21
+import com.yunzhi.questions.service.ITaGameLevelService;
22
+import com.yunzhi.questions.entity.TaGameLevel;
23
+import org.springframework.web.bind.annotation.RestController;
24
+
25
+/**
26
+ * <p>
27
+    * 关卡 前端控制器
28
+    * </p>
29
+ *
30
+ * @author yansen
31
+ * @since 2021-12-10
32
+ */
33
+
34
+@Api(tags = "关卡")
35
+@RestController
36
+@RequestMapping("/")
37
+public class TaGameLevelController extends BaseController {
38
+
39
+    private final Logger logger = LoggerFactory.getLogger(TaGameLevelController.class);
40
+
41
+    @Autowired
42
+    public ITaGameLevelService iTaGameLevelService;
43
+
44
+
45
+    /**
46
+     * 分页查询列表
47
+     * @param pageNum
48
+     * @param pageSize
49
+     * @return
50
+     */
51
+    @RequestMapping(value="/admin/game-level",method= RequestMethod.GET)
52
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
53
+    public ResponseBean taGameLevelList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
54
+                                        @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
55
+
56
+		    IPage<TaGameLevel> pg = new Page<>(pageNum, pageSize);
57
+            QueryWrapper<TaGameLevel> queryWrapper = new QueryWrapper<>();
58
+            queryWrapper.orderByDesc("create_date");
59
+
60
+            IPage<TaGameLevel> result = iTaGameLevelService.page(pg, queryWrapper);
61
+            return ResponseBean.success(result);
62
+    }
63
+
64
+    /**
65
+     * 保存对象
66
+     * @param taGameLevel 实体对象
67
+     * @return
68
+     */
69
+    @RequestMapping(value="/admin/game-level",method= RequestMethod.POST)
70
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
71
+    public ResponseBean taGameLevelAdd(@ApiParam("保存内容") @RequestBody TaGameLevel taGameLevel) throws Exception{
72
+
73
+        if (StringUtils.isEmpty(taGameLevel.getGameId())) {
74
+            return ResponseBean.error("未找到相关联的游戏内容", ResponseBean.ERROR_UNAVAILABLE);
75
+        }
76
+
77
+        taGameLevel.setLevelId(null);
78
+        if (null == taGameLevel.getStatus()) {
79
+            taGameLevel.setStatus(Constants.STATUS_READY);
80
+        }
81
+
82
+        if (iTaGameLevelService.save(taGameLevel)){
83
+            return ResponseBean.success(taGameLevel);
84
+        }else {
85
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
86
+        }
87
+    }
88
+
89
+    /**
90
+     * 根据id删除对象
91
+     * @param id  实体ID
92
+     */
93
+    @RequestMapping(value="/admin/game-level/{id}", method= RequestMethod.DELETE)
94
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
95
+    public ResponseBean taGameLevelDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
96
+        if(iTaGameLevelService.removeLogicById(id)){
97
+            return ResponseBean.success("success");
98
+        }else {
99
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
100
+        }
101
+    }
102
+
103
+    /**
104
+     * 修改对象
105
+     * @param id  实体ID
106
+     * @param taGameLevel 实体对象
107
+     * @return
108
+     */
109
+    @RequestMapping(value="/admin/game-level/{id}",method= RequestMethod.PUT)
110
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
111
+    public ResponseBean taGameLevelUpdate(@ApiParam("对象ID") @PathVariable String id,
112
+                                          @ApiParam("更新内容") @RequestBody TaGameLevel taGameLevel) throws Exception{
113
+        if (StringUtils.isEmpty(taGameLevel.getGameId())) {
114
+            return ResponseBean.error("未找到相关联的游戏内容", ResponseBean.ERROR_UNAVAILABLE);
115
+        }
116
+
117
+        if (iTaGameLevelService.updateById(taGameLevel)){
118
+            return ResponseBean.success(iTaGameLevelService.getById(id));
119
+        }else {
120
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
121
+        }
122
+    }
123
+
124
+    /**
125
+     * 根据id查询对象
126
+     * @param id  实体ID
127
+     */
128
+    @RequestMapping(value="/admin/game-level/{id}",method= RequestMethod.GET)
129
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
130
+    public ResponseBean taGameLevelGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
131
+        return ResponseBean.success(iTaGameLevelService.getById(id));
132
+    }
133
+}

+ 130
- 0
src/main/java/com/yunzhi/questions/controller/TaGameLevelQuestionController.java View File

@@ -0,0 +1,130 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.questions.common.BaseController;
7
+import com.yunzhi.questions.common.ResponseBean;
8
+import com.yunzhi.questions.common.StringUtils;
9
+import io.swagger.annotations.Api;
10
+import io.swagger.annotations.ApiOperation;
11
+import io.swagger.annotations.ApiParam;
12
+import org.slf4j.Logger;
13
+import org.slf4j.LoggerFactory;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.web.bind.annotation.PathVariable;
16
+import org.springframework.web.bind.annotation.RequestBody;
17
+import org.springframework.web.bind.annotation.RequestMapping;
18
+import org.springframework.web.bind.annotation.RequestMethod;
19
+import org.springframework.web.bind.annotation.RequestParam;
20
+import com.yunzhi.questions.service.ITaGameLevelQuestionService;
21
+import com.yunzhi.questions.entity.TaGameLevelQuestion;
22
+import org.springframework.web.bind.annotation.RestController;
23
+
24
+/**
25
+ * <p>
26
+    * 关卡问题 前端控制器
27
+    * </p>
28
+ *
29
+ * @author yansen
30
+ * @since 2021-12-10
31
+ */
32
+
33
+@Api(tags = "关卡问题")
34
+@RestController
35
+@RequestMapping("/")
36
+public class TaGameLevelQuestionController extends BaseController {
37
+
38
+    private final Logger logger = LoggerFactory.getLogger(TaGameLevelQuestionController.class);
39
+
40
+    @Autowired
41
+    public ITaGameLevelQuestionService iTaGameLevelQuestionService;
42
+
43
+
44
+    /**
45
+     * 分页查询列表
46
+     * @param pageNum
47
+     * @param pageSize
48
+     * @return
49
+     */
50
+    @RequestMapping(value="/admin/game-level-question",method= RequestMethod.GET)
51
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
52
+    public ResponseBean taGameLevelQuestionList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
53
+                                                @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
54
+
55
+		    IPage<TaGameLevelQuestion> pg = new Page<>(pageNum, pageSize);
56
+            QueryWrapper<TaGameLevelQuestion> queryWrapper = new QueryWrapper<>();
57
+            queryWrapper.orderByDesc("create_date");
58
+
59
+            IPage<TaGameLevelQuestion> result = iTaGameLevelQuestionService.page(pg, queryWrapper);
60
+            return ResponseBean.success(result);
61
+    }
62
+
63
+    /**
64
+     * 保存关卡游戏内容
65
+     * @param taGameLevelQuestion 实体对象
66
+     * @return
67
+     */
68
+    @RequestMapping(value="/admin/game-level-question",method= RequestMethod.POST)
69
+    @ApiOperation(value="保存关卡游戏内容", notes = "保存关卡游戏内容", httpMethod = "POST", response = ResponseBean.class)
70
+    public ResponseBean taGameLevelQuestionAdd(@ApiParam("保存内容") @RequestBody TaGameLevelQuestion taGameLevelQuestion) throws Exception{
71
+
72
+        if (StringUtils.isEmpty(taGameLevelQuestion.getQuestionId()) || StringUtils.isEmpty(taGameLevelQuestion.getLevelId())) {
73
+            return ResponseBean.error("未找到对应关卡或者问题相关内容", ResponseBean.ERROR_UNAVAILABLE);
74
+        }
75
+
76
+        if (iTaGameLevelQuestionService.save(taGameLevelQuestion)){
77
+            return ResponseBean.success(taGameLevelQuestion);
78
+        }else {
79
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
80
+        }
81
+    }
82
+
83
+    /**
84
+     * 根据id删除对象
85
+     * @param id  实体ID
86
+     */
87
+    @RequestMapping(value="/admin/game-level-question/{id}", method= RequestMethod.DELETE)
88
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
89
+    public ResponseBean taGameLevelQuestionDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
90
+        if(iTaGameLevelQuestionService.removeById(id)){
91
+            return ResponseBean.success("success");
92
+        }else {
93
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
94
+        }
95
+    }
96
+
97
+    /**
98
+     * 修改对象
99
+     * @param id  实体ID
100
+     * @param taGameLevelQuestion 实体对象
101
+     * @return
102
+     */
103
+    @RequestMapping(value="/admin/game-level-question/{id}",method= RequestMethod.PUT)
104
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
105
+    public ResponseBean taGameLevelQuestionUpdate(@ApiParam("对象ID") @PathVariable Integer id,
106
+                                                  @ApiParam("更新内容") @RequestBody TaGameLevelQuestion taGameLevelQuestion) throws Exception{
107
+
108
+        if (StringUtils.isEmpty(taGameLevelQuestion.getQuestionId()) || StringUtils.isEmpty(taGameLevelQuestion.getLevelId())) {
109
+            return ResponseBean.error("未找到对应关卡或者问题相关内容", ResponseBean.ERROR_UNAVAILABLE);
110
+        }
111
+
112
+        taGameLevelQuestion.setSerialNo(id);
113
+
114
+        if (iTaGameLevelQuestionService.updateById(taGameLevelQuestion)){
115
+            return ResponseBean.success(iTaGameLevelQuestionService.getById(id));
116
+        }else {
117
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
118
+        }
119
+    }
120
+
121
+    /**
122
+     * 根据id查询对象
123
+     * @param id  实体ID
124
+     */
125
+    @RequestMapping(value="/admin/game-level-question/{id}",method= RequestMethod.GET)
126
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
127
+    public ResponseBean taGameLevelQuestionGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
128
+        return ResponseBean.success(iTaGameLevelQuestionService.getById(id));
129
+    }
130
+}

+ 119
- 0
src/main/java/com/yunzhi/questions/controller/TaGamePersonAnswerController.java View File

@@ -0,0 +1,119 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.questions.common.BaseController;
7
+import com.yunzhi.questions.common.ResponseBean;
8
+import io.swagger.annotations.Api;
9
+import io.swagger.annotations.ApiOperation;
10
+import io.swagger.annotations.ApiParam;
11
+import org.slf4j.Logger;
12
+import org.slf4j.LoggerFactory;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.web.bind.annotation.PathVariable;
15
+import org.springframework.web.bind.annotation.RequestBody;
16
+import org.springframework.web.bind.annotation.RequestMapping;
17
+import org.springframework.web.bind.annotation.RequestMethod;
18
+import org.springframework.web.bind.annotation.RequestParam;
19
+import com.yunzhi.questions.service.ITaGamePersonAnswerService;
20
+import com.yunzhi.questions.entity.TaGamePersonAnswer;
21
+import org.springframework.web.bind.annotation.RestController;
22
+
23
+/**
24
+ * <p>
25
+    * 问答游戏结果 前端控制器
26
+    * </p>
27
+ *
28
+ * @author yansen
29
+ * @since 2021-12-10
30
+ */
31
+
32
+@Api(tags = "问答游戏结果")
33
+@RestController
34
+@RequestMapping("/")
35
+public class TaGamePersonAnswerController extends BaseController {
36
+
37
+    private final Logger logger = LoggerFactory.getLogger(TaGamePersonAnswerController.class);
38
+
39
+    @Autowired
40
+    public ITaGamePersonAnswerService iTaGamePersonAnswerService;
41
+
42
+
43
+    /**
44
+     * 分页查询列表
45
+     * @param pageNum
46
+     * @param pageSize
47
+     * @return
48
+     */
49
+    @RequestMapping(value="/taGamePersonAnswer",method= RequestMethod.GET)
50
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
+    public ResponseBean taGamePersonAnswerList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+
54
+		    IPage<TaGamePersonAnswer> pg = new Page<>(pageNum, pageSize);
55
+            QueryWrapper<TaGamePersonAnswer> queryWrapper = new QueryWrapper<>();
56
+            queryWrapper.orderByDesc("create_date");
57
+
58
+            IPage<TaGamePersonAnswer> result = iTaGamePersonAnswerService.page(pg, queryWrapper);
59
+            return ResponseBean.success(result);
60
+    }
61
+
62
+    /**
63
+     * 保存对象
64
+     * @param taGamePersonAnswer 实体对象
65
+     * @return
66
+     */
67
+    @RequestMapping(value="/taGamePersonAnswer",method= RequestMethod.POST)
68
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
+    public ResponseBean taGamePersonAnswerAdd(@ApiParam("保存内容") @RequestBody TaGamePersonAnswer taGamePersonAnswer) throws Exception{
70
+
71
+        if (iTaGamePersonAnswerService.save(taGamePersonAnswer)){
72
+            return ResponseBean.success(taGamePersonAnswer);
73
+        }else {
74
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
+        }
76
+    }
77
+
78
+    /**
79
+     * 根据id删除对象
80
+     * @param id  实体ID
81
+     */
82
+    @RequestMapping(value="/taGamePersonAnswer/{id}", method= RequestMethod.DELETE)
83
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
+    public ResponseBean taGamePersonAnswerDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
+        if(iTaGamePersonAnswerService.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 taGamePersonAnswer 实体对象
96
+     * @return
97
+     */
98
+    @RequestMapping(value="/taGamePersonAnswer/{id}",method= RequestMethod.PUT)
99
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
+    public ResponseBean taGamePersonAnswerUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
+                                        @ApiParam("更新内容") @RequestBody TaGamePersonAnswer taGamePersonAnswer) throws Exception{
102
+
103
+        if (iTaGamePersonAnswerService.updateById(taGamePersonAnswer)){
104
+            return ResponseBean.success(iTaGamePersonAnswerService.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="/taGamePersonAnswer/{id}",method= RequestMethod.GET)
115
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
+    public ResponseBean taGamePersonAnswerGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
+        return ResponseBean.success(iTaGamePersonAnswerService.getById(id));
118
+    }
119
+}

+ 119
- 0
src/main/java/com/yunzhi/questions/controller/TaGamePersonController.java View File

@@ -0,0 +1,119 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.questions.common.BaseController;
7
+import com.yunzhi.questions.common.ResponseBean;
8
+import io.swagger.annotations.Api;
9
+import io.swagger.annotations.ApiOperation;
10
+import io.swagger.annotations.ApiParam;
11
+import org.slf4j.Logger;
12
+import org.slf4j.LoggerFactory;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.web.bind.annotation.PathVariable;
15
+import org.springframework.web.bind.annotation.RequestBody;
16
+import org.springframework.web.bind.annotation.RequestMapping;
17
+import org.springframework.web.bind.annotation.RequestMethod;
18
+import org.springframework.web.bind.annotation.RequestParam;
19
+import com.yunzhi.questions.service.ITaGamePersonService;
20
+import com.yunzhi.questions.entity.TaGamePerson;
21
+import org.springframework.web.bind.annotation.RestController;
22
+
23
+/**
24
+ * <p>
25
+    * 参与游戏人员 前端控制器
26
+    * </p>
27
+ *
28
+ * @author yansen
29
+ * @since 2021-12-10
30
+ */
31
+
32
+@Api(tags = "参与游戏人员")
33
+@RestController
34
+@RequestMapping("/")
35
+public class TaGamePersonController extends BaseController {
36
+
37
+    private final Logger logger = LoggerFactory.getLogger(TaGamePersonController.class);
38
+
39
+    @Autowired
40
+    public ITaGamePersonService iTaGamePersonService;
41
+
42
+
43
+    /**
44
+     * 分页查询列表
45
+     * @param pageNum
46
+     * @param pageSize
47
+     * @return
48
+     */
49
+    @RequestMapping(value="/taGamePerson",method= RequestMethod.GET)
50
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
+    public ResponseBean taGamePersonList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+
54
+		    IPage<TaGamePerson> pg = new Page<>(pageNum, pageSize);
55
+            QueryWrapper<TaGamePerson> queryWrapper = new QueryWrapper<>();
56
+            queryWrapper.orderByDesc("create_date");
57
+
58
+            IPage<TaGamePerson> result = iTaGamePersonService.page(pg, queryWrapper);
59
+            return ResponseBean.success(result);
60
+    }
61
+
62
+    /**
63
+     * 保存对象
64
+     * @param taGamePerson 实体对象
65
+     * @return
66
+     */
67
+    @RequestMapping(value="/taGamePerson",method= RequestMethod.POST)
68
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
+    public ResponseBean taGamePersonAdd(@ApiParam("保存内容") @RequestBody TaGamePerson taGamePerson) throws Exception{
70
+
71
+        if (iTaGamePersonService.save(taGamePerson)){
72
+            return ResponseBean.success(taGamePerson);
73
+        }else {
74
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
+        }
76
+    }
77
+
78
+    /**
79
+     * 根据id删除对象
80
+     * @param id  实体ID
81
+     */
82
+    @RequestMapping(value="/taGamePerson/{id}", method= RequestMethod.DELETE)
83
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
+    public ResponseBean taGamePersonDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
+        if(iTaGamePersonService.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 taGamePerson 实体对象
96
+     * @return
97
+     */
98
+    @RequestMapping(value="/taGamePerson/{id}",method= RequestMethod.PUT)
99
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
+    public ResponseBean taGamePersonUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
+                                        @ApiParam("更新内容") @RequestBody TaGamePerson taGamePerson) throws Exception{
102
+
103
+        if (iTaGamePersonService.updateById(taGamePerson)){
104
+            return ResponseBean.success(iTaGamePersonService.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="/taGamePerson/{id}",method= RequestMethod.GET)
115
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
+    public ResponseBean taGamePersonGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
+        return ResponseBean.success(iTaGamePersonService.getById(id));
118
+    }
119
+}

+ 147
- 0
src/main/java/com/yunzhi/questions/controller/TaGamePersonResultController.java View File

@@ -0,0 +1,147 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.yunzhi.questions.common.BaseController;
4
+import com.yunzhi.questions.common.ResponseBean;
5
+import com.yunzhi.questions.common.StringUtils;
6
+import com.yunzhi.questions.entity.TaGamePersonAnswer;
7
+import com.yunzhi.questions.entity.TaPerson;
8
+import com.yunzhi.questions.service.ITaAnswerService;
9
+import com.yunzhi.questions.service.ITaGameService;
10
+import com.yunzhi.questions.service.ITaQuestionService;
11
+import io.swagger.annotations.Api;
12
+import io.swagger.annotations.ApiOperation;
13
+import io.swagger.annotations.ApiParam;
14
+import org.slf4j.Logger;
15
+import org.slf4j.LoggerFactory;
16
+import org.springframework.beans.factory.annotation.Autowired;
17
+import org.springframework.web.bind.annotation.PathVariable;
18
+import org.springframework.web.bind.annotation.RequestBody;
19
+import org.springframework.web.bind.annotation.RequestMapping;
20
+import org.springframework.web.bind.annotation.RequestMethod;
21
+import com.yunzhi.questions.service.ITaGamePersonResultService;
22
+import com.yunzhi.questions.entity.TaGamePersonResult;
23
+import org.springframework.web.bind.annotation.RestController;
24
+
25
+import javax.servlet.http.HttpServletRequest;
26
+import java.util.List;
27
+
28
+/**
29
+ * <p>
30
+    * 问答游戏总结 前端控制器
31
+    * </p>
32
+ *
33
+ * @author yansen
34
+ * @since 2021-12-15
35
+ */
36
+
37
+@Api(tags = "问答游戏总结")
38
+@RestController
39
+@RequestMapping("/")
40
+public class TaGamePersonResultController extends BaseController {
41
+
42
+    private final Logger logger = LoggerFactory.getLogger(TaGamePersonResultController.class);
43
+
44
+    @Autowired
45
+    public ITaGamePersonResultService iTaGamePersonResultService;
46
+
47
+    @Autowired
48
+    public ITaAnswerService iTaAnswerService;
49
+
50
+    @Autowired
51
+    public ITaQuestionService iTaQuestionService;
52
+
53
+
54
+//    /**
55
+//     * 分页查询列表
56
+//     * @param pageNum
57
+//     * @param pageSize
58
+//     * @return
59
+//     */
60
+//    @RequestMapping(value="/taGamePersonResult",method= RequestMethod.GET)
61
+//    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
62
+//    public ResponseBean taGamePersonResultList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
63
+//									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
64
+//
65
+//		    IPage<TaGamePersonResult> pg = new Page<>(pageNum, pageSize);
66
+//            QueryWrapper<TaGamePersonResult> queryWrapper = new QueryWrapper<>();
67
+//            queryWrapper.orderByDesc("create_date");
68
+//
69
+//            IPage<TaGamePersonResult> result = iTaGamePersonResultService.page(pg, queryWrapper);
70
+//            return ResponseBean.success(result);
71
+//    }
72
+
73
+    /**
74
+     * 保存对象
75
+     * @param taGamePersonResult 实体对象
76
+     * @return
77
+     */
78
+    @RequestMapping(value="/game-answer",method= RequestMethod.POST)
79
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
80
+    public ResponseBean taGamePersonResultAdd(@ApiParam("保存内容") @RequestBody TaGamePersonResult taGamePersonResult,
81
+                                              HttpServletRequest request) throws Exception{
82
+        TaPerson taPerson = getCurrentPerson(request);
83
+
84
+        String gameId = taGamePersonResult.getGameId();
85
+        if (StringUtils.isEmpty(gameId)) {
86
+            return ResponseBean.error("请设置问卷ID", ResponseBean.ERROR_UNAVAILABLE);
87
+        }
88
+
89
+        List<TaGamePersonAnswer> answerList = taGamePersonResult.getAnswerList();
90
+        if (null == answerList || answerList.size() < 1) {
91
+            return ResponseBean.error("未找到答题信息", ResponseBean.ERROR_UNAVAILABLE);
92
+        }
93
+
94
+        int totalNum = iTaQuestionService.countByGameId(gameId);
95
+        if (totalNum != answerList.size()) {
96
+            return ResponseBean.error("尚有未作答的题目", ResponseBean.ERROR_UNAVAILABLE);
97
+        }
98
+
99
+        if (iTaGamePersonResultService.makeAnswer(taGamePersonResult)){
100
+            return ResponseBean.success(taGamePersonResult);
101
+        }else {
102
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
103
+        }
104
+    }
105
+
106
+    /**
107
+     * 根据id删除对象
108
+     * @param id  实体ID
109
+     */
110
+    @RequestMapping(value="/taGamePersonResult/{id}", method= RequestMethod.DELETE)
111
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
112
+    public ResponseBean taGamePersonResultDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
113
+        if(iTaGamePersonResultService.removeById(id)){
114
+            return ResponseBean.success("success");
115
+        }else {
116
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
117
+        }
118
+    }
119
+
120
+    /**
121
+     * 修改对象
122
+     * @param id  实体ID
123
+     * @param taGamePersonResult 实体对象
124
+     * @return
125
+     */
126
+    @RequestMapping(value="/taGamePersonResult/{id}",method= RequestMethod.PUT)
127
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
128
+    public ResponseBean taGamePersonResultUpdate(@ApiParam("对象ID") @PathVariable Integer id,
129
+                                        @ApiParam("更新内容") @RequestBody TaGamePersonResult taGamePersonResult) throws Exception{
130
+
131
+        if (iTaGamePersonResultService.updateById(taGamePersonResult)){
132
+            return ResponseBean.success(iTaGamePersonResultService.getById(id));
133
+        }else {
134
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
135
+        }
136
+    }
137
+
138
+    /**
139
+     * 根据id查询对象
140
+     * @param id  实体ID
141
+     */
142
+    @RequestMapping(value="/taGamePersonResult/{id}",method= RequestMethod.GET)
143
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
144
+    public ResponseBean taGamePersonResultGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
145
+        return ResponseBean.success(iTaGamePersonResultService.getById(id));
146
+    }
147
+}

+ 119
- 0
src/main/java/com/yunzhi/questions/controller/TaPersonController.java View File

@@ -0,0 +1,119 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.questions.common.BaseController;
7
+import com.yunzhi.questions.common.ResponseBean;
8
+import io.swagger.annotations.Api;
9
+import io.swagger.annotations.ApiOperation;
10
+import io.swagger.annotations.ApiParam;
11
+import org.slf4j.Logger;
12
+import org.slf4j.LoggerFactory;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.web.bind.annotation.PathVariable;
15
+import org.springframework.web.bind.annotation.RequestBody;
16
+import org.springframework.web.bind.annotation.RequestMapping;
17
+import org.springframework.web.bind.annotation.RequestMethod;
18
+import org.springframework.web.bind.annotation.RequestParam;
19
+import com.yunzhi.questions.service.ITaPersonService;
20
+import com.yunzhi.questions.entity.TaPerson;
21
+import org.springframework.web.bind.annotation.RestController;
22
+
23
+/**
24
+ * <p>
25
+    * 小程序人员表 前端控制器
26
+    * </p>
27
+ *
28
+ * @author yansen
29
+ * @since 2021-12-10
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="/taPerson/{id}",method= RequestMethod.PUT)
99
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
+    public ResponseBean taPersonUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
+                                        @ApiParam("更新内容") @RequestBody TaPerson taPerson) throws Exception{
102
+
103
+        if (iTaPersonService.updateById(taPerson)){
104
+            return ResponseBean.success(iTaPersonService.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="/taPerson/{id}",method= RequestMethod.GET)
115
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
+    public ResponseBean taPersonGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
+        return ResponseBean.success(iTaPersonService.getById(id));
118
+    }
119
+}

+ 158
- 0
src/main/java/com/yunzhi/questions/controller/TaQuestionController.java View File

@@ -0,0 +1,158 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.questions.common.BaseController;
7
+import com.yunzhi.questions.common.Constants;
8
+import com.yunzhi.questions.common.ResponseBean;
9
+import com.yunzhi.questions.entity.TaAnswer;
10
+import com.yunzhi.questions.service.ITaAnswerService;
11
+import com.yunzhi.questions.vo.QuestionVO;
12
+import io.swagger.annotations.Api;
13
+import io.swagger.annotations.ApiOperation;
14
+import io.swagger.annotations.ApiParam;
15
+import org.slf4j.Logger;
16
+import org.slf4j.LoggerFactory;
17
+import org.springframework.beans.BeanUtils;
18
+import org.springframework.beans.factory.annotation.Autowired;
19
+import org.springframework.web.bind.annotation.PathVariable;
20
+import org.springframework.web.bind.annotation.RequestBody;
21
+import org.springframework.web.bind.annotation.RequestMapping;
22
+import org.springframework.web.bind.annotation.RequestMethod;
23
+import org.springframework.web.bind.annotation.RequestParam;
24
+import com.yunzhi.questions.service.ITaQuestionService;
25
+import com.yunzhi.questions.entity.TaQuestion;
26
+import org.springframework.web.bind.annotation.RestController;
27
+
28
+import java.time.LocalDateTime;
29
+import java.util.List;
30
+
31
+/**
32
+ * <p>
33
+    * 题库 前端控制器
34
+    * </p>
35
+ *
36
+ * @author yansen
37
+ * @since 2021-12-10
38
+ */
39
+
40
+@Api(tags = "题库")
41
+@RestController
42
+@RequestMapping("/")
43
+public class TaQuestionController extends BaseController {
44
+
45
+    private final Logger logger = LoggerFactory.getLogger(TaQuestionController.class);
46
+
47
+    @Autowired
48
+    public ITaQuestionService iTaQuestionService;
49
+
50
+    @Autowired
51
+    public ITaAnswerService iTaAnswerService;
52
+
53
+
54
+    /**
55
+     * 分页查询列表
56
+     * @param pageNum
57
+     * @param pageSize
58
+     * @return
59
+     */
60
+    @RequestMapping(value="/admin/question",method= RequestMethod.GET)
61
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
62
+    public ResponseBean taQuestionList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
63
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
64
+
65
+		    IPage<TaQuestion> pg = new Page<>(pageNum, pageSize);
66
+            QueryWrapper<TaQuestion> queryWrapper = new QueryWrapper<>();
67
+            queryWrapper.orderByDesc("create_date");
68
+
69
+            IPage<TaQuestion> result = iTaQuestionService.page(pg, queryWrapper);
70
+            return ResponseBean.success(result);
71
+    }
72
+
73
+    /**
74
+     * 题库保存
75
+     * @param questionVO 实体对象
76
+     * @return
77
+     */
78
+    @RequestMapping(value="/admin/question",method= RequestMethod.POST)
79
+    @ApiOperation(value="题库保存", notes = "题库保存", httpMethod = "POST", response = ResponseBean.class)
80
+    public ResponseBean taQuestionAdd(@ApiParam("保存内容") @RequestBody QuestionVO questionVO) throws Exception{
81
+
82
+        if (null == questionVO) {
83
+            return ResponseBean.error("题库内容不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
84
+        }
85
+
86
+        if (null == questionVO.getAnswerList() || questionVO.getAnswerList().size() == 0) {
87
+            return ResponseBean.error("题库答案列表不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
88
+        }
89
+
90
+        if (iTaQuestionService.saveByVO(questionVO)){
91
+            return ResponseBean.success(questionVO);
92
+        }else {
93
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
94
+        }
95
+    }
96
+
97
+    /**
98
+     * 根据id删除对象
99
+     * @param id  实体ID
100
+     */
101
+    @RequestMapping(value="/admin/question/{id}", method= RequestMethod.DELETE)
102
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
103
+    public ResponseBean taQuestionDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
104
+        if(iTaQuestionService.removeLogicById(id)){
105
+            return ResponseBean.success("success");
106
+        }else {
107
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
108
+        }
109
+    }
110
+
111
+    /**
112
+     * 题库修改
113
+     * @param id  实体ID
114
+     * @param questionVO 实体对象
115
+     * @return
116
+     */
117
+    @RequestMapping(value="/admin/question/{id}",method= RequestMethod.PUT)
118
+    @ApiOperation(value="题库修改", notes = "题库修改", httpMethod = "PUT", response = ResponseBean.class)
119
+    public ResponseBean taQuestionUpdate(@ApiParam("对象ID") @PathVariable String id,
120
+                                         @ApiParam("更新内容") @RequestBody QuestionVO questionVO) throws Exception{
121
+
122
+        TaQuestion taQuestion = iTaQuestionService.getById(id);
123
+        if (null == taQuestion || taQuestion.getStatus() == Constants.STATUS_DELETED) {
124
+            return ResponseBean.error("未找到有效的更新内容", ResponseBean.ERROR_ILLEGAL_PARAMS);
125
+        }
126
+
127
+        questionVO.setQuestionId(id);
128
+
129
+        if (iTaQuestionService.editBy(questionVO)){
130
+            return ResponseBean.success(questionVO);
131
+        }else {
132
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
133
+        }
134
+    }
135
+
136
+    /**
137
+     * 根据id查询对象
138
+     * @param id  实体ID
139
+     */
140
+    @RequestMapping(value="/admin/question/{id}",method= RequestMethod.GET)
141
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
142
+    public ResponseBean taQuestionGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
143
+
144
+        TaQuestion taQuestion = iTaQuestionService.getById(id);
145
+        if (null == taQuestion || taQuestion.getStatus() == Constants.STATUS_DELETED) {
146
+            return ResponseBean.error("未找到题库内容", ResponseBean.ERROR_ILLEGAL_PARAMS);
147
+        }
148
+
149
+        List<TaAnswer> answerList = iTaAnswerService.getByQuestionId(id);
150
+
151
+        QuestionVO questionVO = new QuestionVO();
152
+        BeanUtils.copyProperties(taQuestion, questionVO);
153
+
154
+        questionVO.setAnswerList(answerList);
155
+
156
+        return ResponseBean.success(questionVO);
157
+    }
158
+}

+ 152
- 0
src/main/java/com/yunzhi/questions/controller/TdCharacterLibController.java View File

@@ -0,0 +1,152 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.questions.common.BaseController;
7
+import com.yunzhi.questions.common.Constants;
8
+import com.yunzhi.questions.common.ResponseBean;
9
+import com.yunzhi.questions.entity.SysUser;
10
+import com.yunzhi.questions.entity.TdCharacterWord;
11
+import com.yunzhi.questions.service.ITdCharacterWordService;
12
+import io.swagger.annotations.Api;
13
+import io.swagger.annotations.ApiOperation;
14
+import io.swagger.annotations.ApiParam;
15
+import org.slf4j.Logger;
16
+import org.slf4j.LoggerFactory;
17
+import org.springframework.beans.factory.annotation.Autowired;
18
+import org.springframework.web.bind.annotation.PathVariable;
19
+import org.springframework.web.bind.annotation.RequestBody;
20
+import org.springframework.web.bind.annotation.RequestMapping;
21
+import org.springframework.web.bind.annotation.RequestMethod;
22
+import org.springframework.web.bind.annotation.RequestParam;
23
+import com.yunzhi.questions.service.ITdCharacterLibService;
24
+import com.yunzhi.questions.entity.TdCharacterLib;
25
+import org.springframework.web.bind.annotation.RestController;
26
+
27
+import javax.servlet.http.HttpServletRequest;
28
+import java.util.List;
29
+
30
+/**
31
+ * <p>
32
+    * 特征库 前端控制器
33
+    * </p>
34
+ *
35
+ * @author yansen
36
+ * @since 2021-12-14
37
+ */
38
+
39
+@Api(tags = "特征库")
40
+@RestController
41
+@RequestMapping("/")
42
+public class TdCharacterLibController extends BaseController {
43
+
44
+    private final Logger logger = LoggerFactory.getLogger(TdCharacterLibController.class);
45
+
46
+    @Autowired
47
+    public ITdCharacterLibService iTdCharacterLibService;
48
+
49
+    @Autowired
50
+    public ITdCharacterWordService iTdCharacterWordService;
51
+
52
+
53
+    /**
54
+     * 分页查询列表
55
+     * @param pageNum
56
+     * @param pageSize
57
+     * @return
58
+     */
59
+    @RequestMapping(value="/admin/character-lib",method= RequestMethod.GET)
60
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
61
+    public ResponseBean tdCharacterLibList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
62
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
63
+
64
+		    IPage<TdCharacterLib> pg = new Page<>(pageNum, pageSize);
65
+            QueryWrapper<TdCharacterLib> queryWrapper = new QueryWrapper<>();
66
+            queryWrapper.orderByDesc("create_date");
67
+
68
+            IPage<TdCharacterLib> result = iTdCharacterLibService.page(pg, queryWrapper);
69
+            return ResponseBean.success(result);
70
+    }
71
+
72
+    /**
73
+     * 保存特征库
74
+     * @param tdCharacterLib 实体对象
75
+     * @return
76
+     */
77
+    @RequestMapping(value="/admin/character-lib",method= RequestMethod.POST)
78
+    @ApiOperation(value="保存特征库", notes = "保存特征库", httpMethod = "POST", response = ResponseBean.class)
79
+    public ResponseBean tdCharacterLibAdd(@ApiParam("保存内容") @RequestBody TdCharacterLib tdCharacterLib,
80
+                                          HttpServletRequest request) throws Exception{
81
+
82
+        SysUser user = getCurrentUser(request);
83
+
84
+        if (iTdCharacterLibService.saveWithList(user, tdCharacterLib)){
85
+            return ResponseBean.success(tdCharacterLib);
86
+        } else {
87
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
88
+        }
89
+    }
90
+
91
+    /**
92
+     * 根据id删除对象
93
+     * @param id  实体ID
94
+     */
95
+    @RequestMapping(value="/admin/character-lib/{id}", method= RequestMethod.DELETE)
96
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
97
+    public ResponseBean tdCharacterLibDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
98
+        if(iTdCharacterLibService.removeLogicById(id)){
99
+            return ResponseBean.success("success");
100
+        }else {
101
+            return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
102
+        }
103
+    }
104
+
105
+    /**
106
+     * 修改对象
107
+     * @param id  实体ID
108
+     * @param tdCharacterLib 实体对象
109
+     * @return
110
+     */
111
+    @RequestMapping(value="/admin/character-lib/{id}",method= RequestMethod.PUT)
112
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
113
+    public ResponseBean tdCharacterLibUpdate(@ApiParam("对象ID") @PathVariable String id,
114
+                                             @ApiParam("更新内容") @RequestBody TdCharacterLib tdCharacterLib,
115
+                                             HttpServletRequest request) throws Exception{
116
+        SysUser user = getCurrentUser(request);
117
+        tdCharacterLib.setLibId(id);
118
+
119
+        if (iTdCharacterLibService.updateWithList(user, tdCharacterLib)){
120
+            return ResponseBean.success(iTdCharacterLibService.getById(id));
121
+        } else {
122
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
123
+        }
124
+    }
125
+
126
+    /**
127
+     * 根据id查询对象
128
+     * @param id  实体ID
129
+     */
130
+    @RequestMapping(value="/admin/character-lib/{id}",method= RequestMethod.GET)
131
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
132
+    public ResponseBean tdCharacterLibGet(@ApiParam("对象ID") @PathVariable String id,
133
+                                          HttpServletRequest request) throws Exception{
134
+
135
+        TdCharacterLib tdCharacterLib = iTdCharacterLibService.getById(id);
136
+        if (null == tdCharacterLib || Constants.STATUS_DELETED == tdCharacterLib.getStatus()) {
137
+            ResponseBean.error("未找到对应特征库", ResponseBean.ERROR_UNAVAILABLE);
138
+        }
139
+
140
+        SysUser user = getCurrentUser(request);
141
+        int rows = iTdCharacterLibService.getCountOfMapUser(user.getUserId(), id);
142
+        if (rows < 1) {
143
+            ResponseBean.error("未找到对应特征库", ResponseBean.ERROR_UNAVAILABLE);
144
+        }
145
+
146
+        // 查询明细
147
+        List<TdCharacterWord> wordList = iTdCharacterWordService.getListByLidId(id);
148
+        tdCharacterLib.setWordList(wordList);
149
+
150
+        return ResponseBean.success(tdCharacterLib);
151
+    }
152
+}

+ 119
- 0
src/main/java/com/yunzhi/questions/controller/TdCharacterWordController.java View File

@@ -0,0 +1,119 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.questions.common.BaseController;
7
+import com.yunzhi.questions.common.ResponseBean;
8
+import io.swagger.annotations.Api;
9
+import io.swagger.annotations.ApiOperation;
10
+import io.swagger.annotations.ApiParam;
11
+import org.slf4j.Logger;
12
+import org.slf4j.LoggerFactory;
13
+import org.springframework.beans.factory.annotation.Autowired;
14
+import org.springframework.web.bind.annotation.PathVariable;
15
+import org.springframework.web.bind.annotation.RequestBody;
16
+import org.springframework.web.bind.annotation.RequestMapping;
17
+import org.springframework.web.bind.annotation.RequestMethod;
18
+import org.springframework.web.bind.annotation.RequestParam;
19
+import com.yunzhi.questions.service.ITdCharacterWordService;
20
+import com.yunzhi.questions.entity.TdCharacterWord;
21
+import org.springframework.web.bind.annotation.RestController;
22
+
23
+/**
24
+ * <p>
25
+    * 特征词 前端控制器
26
+    * </p>
27
+ *
28
+ * @author yansen
29
+ * @since 2021-12-14
30
+ */
31
+
32
+@Api(tags = "特征词")
33
+@RestController
34
+@RequestMapping("/")
35
+public class TdCharacterWordController extends BaseController {
36
+
37
+    private final Logger logger = LoggerFactory.getLogger(TdCharacterWordController.class);
38
+
39
+    @Autowired
40
+    public ITdCharacterWordService iTdCharacterWordService;
41
+
42
+
43
+    /**
44
+     * 分页查询列表
45
+     * @param pageNum
46
+     * @param pageSize
47
+     * @return
48
+     */
49
+    @RequestMapping(value="/tdCharacterWord",method= RequestMethod.GET)
50
+    @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
51
+    public ResponseBean tdCharacterWordList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
52
+									 @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
53
+
54
+		    IPage<TdCharacterWord> pg = new Page<>(pageNum, pageSize);
55
+            QueryWrapper<TdCharacterWord> queryWrapper = new QueryWrapper<>();
56
+            queryWrapper.orderByDesc("create_date");
57
+
58
+            IPage<TdCharacterWord> result = iTdCharacterWordService.page(pg, queryWrapper);
59
+            return ResponseBean.success(result);
60
+    }
61
+
62
+    /**
63
+     * 保存对象
64
+     * @param tdCharacterWord 实体对象
65
+     * @return
66
+     */
67
+    @RequestMapping(value="/tdCharacterWord",method= RequestMethod.POST)
68
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
69
+    public ResponseBean tdCharacterWordAdd(@ApiParam("保存内容") @RequestBody TdCharacterWord tdCharacterWord) throws Exception{
70
+
71
+        if (iTdCharacterWordService.save(tdCharacterWord)){
72
+            return ResponseBean.success(tdCharacterWord);
73
+        }else {
74
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
75
+        }
76
+    }
77
+
78
+    /**
79
+     * 根据id删除对象
80
+     * @param id  实体ID
81
+     */
82
+    @RequestMapping(value="/tdCharacterWord/{id}", method= RequestMethod.DELETE)
83
+    @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
84
+    public ResponseBean tdCharacterWordDelete(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
85
+        if(iTdCharacterWordService.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 tdCharacterWord 实体对象
96
+     * @return
97
+     */
98
+    @RequestMapping(value="/tdCharacterWord/{id}",method= RequestMethod.PUT)
99
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
100
+    public ResponseBean tdCharacterWordUpdate(@ApiParam("对象ID") @PathVariable Integer id,
101
+                                        @ApiParam("更新内容") @RequestBody TdCharacterWord tdCharacterWord) throws Exception{
102
+
103
+        if (iTdCharacterWordService.updateById(tdCharacterWord)){
104
+            return ResponseBean.success(iTdCharacterWordService.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="/tdCharacterWord/{id}",method= RequestMethod.GET)
115
+    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
116
+    public ResponseBean tdCharacterWordGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
117
+        return ResponseBean.success(iTdCharacterWordService.getById(id));
118
+    }
119
+}

+ 215
- 0
src/main/java/com/yunzhi/questions/controller/WxMpController.java View File

@@ -0,0 +1,215 @@
1
+package com.yunzhi.questions.controller;
2
+
3
+import com.yunzhi.questions.common.*;
4
+import lombok.extern.slf4j.Slf4j;
5
+import me.chanjar.weixin.common.api.WxConsts;
6
+import me.chanjar.weixin.common.error.WxErrorException;
7
+import me.chanjar.weixin.mp.api.WxMpService;
8
+import me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage;
9
+import me.chanjar.weixin.mp.bean.material.WxMpMaterial;
10
+import me.chanjar.weixin.mp.bean.material.WxMpMaterialUploadResult;
11
+import me.chanjar.weixin.mp.bean.message.WxMpXmlMessage;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.beans.factory.annotation.Value;
14
+import org.springframework.web.bind.annotation.*;
15
+import org.springframework.web.multipart.MultipartFile;
16
+
17
+import javax.servlet.http.HttpServletRequest;
18
+import java.io.File;
19
+import java.io.IOException;
20
+
21
+@Slf4j
22
+@RestController
23
+public class WxMpController extends BaseController {
24
+//
25
+//    @Autowired
26
+//    private ITaMpSettingService iTaMpSettingService;
27
+//
28
+//    @Autowired
29
+//    WxUtils wxUtils;
30
+//
31
+//    @Autowired
32
+//    OSSUtils ossUtils;
33
+//
34
+//    @Value("${sysBiz.miniapp.title}")
35
+//    String miniAppTtitle;
36
+//
37
+//    @Value("${sysBiz.miniapp.indexPage}")
38
+//    String miniAppIndex;
39
+//
40
+//    /**
41
+//     * 微信公众号接入
42
+//     * @param appid
43
+//     * @param signature
44
+//     * @param timestamp
45
+//     * @param nonce
46
+//     * @param echostr
47
+//     * @return
48
+//     */
49
+//    @GetMapping(path = "/mp/portal/{appid}", produces = "text/plain;charset=utf-8")
50
+//    public String authGet(@PathVariable String appid,
51
+//                          @RequestParam(name = "signature", required = false) String signature,
52
+//                          @RequestParam(name = "timestamp", required = false) String timestamp,
53
+//                          @RequestParam(name = "nonce", required = false) String nonce,
54
+//                          @RequestParam(name = "echostr", required = false) String echostr) {
55
+//        return echostr;
56
+//    }
57
+//
58
+//    @PostMapping(path = "/mp/portal/{appid}", produces = "application/xml; charset=UTF-8")
59
+//    public String post(@PathVariable String appid,
60
+//                       @RequestBody String requestBody,
61
+//                       @RequestParam("signature") String signature,
62
+//                       @RequestParam("timestamp") String timestamp,
63
+//                       @RequestParam("nonce") String nonce,
64
+//                       @RequestParam("openid") String openid,
65
+//                       @RequestParam(name = "encrypt_type", required = false) String encType,
66
+//                       @RequestParam(name = "msg_signature", required = false) String msgSignature) {
67
+//
68
+//        log.info("\n接收微信请求:[openid=[{}], [signature=[{}], encType=[{}], msgSignature=[{}],"
69
+//                        + " timestamp=[{}], nonce=[{}], requestBody=[\n{}\n] ",
70
+//                openid, signature, encType, msgSignature, timestamp, nonce, requestBody);
71
+//
72
+//        WxMpService mpService = wxUtils.getMpService();
73
+//        if (null == mpService) {
74
+//            throw new IllegalArgumentException(String.format("未找到对应appid=[%s]的配置,请核实!", appid));
75
+//        }
76
+//
77
+//        if (!mpService.checkSignature(timestamp, nonce, signature)) {
78
+//            throw new IllegalArgumentException("非法请求,可能属于伪造的请求!");
79
+//        }
80
+//
81
+//        WxMpXmlMessage inMessage = null;
82
+//        if (encType == null) {
83
+//            // 明文传输的消息
84
+//            inMessage = WxMpXmlMessage.fromXml(requestBody);
85
+//        } else if ("aes".equalsIgnoreCase(encType)) {
86
+//            // aes加密的消息
87
+//            inMessage = WxMpXmlMessage.fromEncryptedXml(requestBody, mpService.getWxMpConfigStorage(),
88
+//                    timestamp, nonce, msgSignature);
89
+//            log.debug("\n消息解密后内容为:\n{} ", inMessage.toString());
90
+//        }
91
+//
92
+//        // 关注公众号
93
+//        if (inMessage.getMsgType().equals(WxConsts.XmlMsgType.EVENT) && inMessage.getEvent().equals(WxConsts.EventType.SUBSCRIBE)) {
94
+//            // 发送客服消息
95
+//            sendMiniAppKefuMessage(mpService, openid);
96
+//        }
97
+//
98
+//        return "";
99
+//    }
100
+//
101
+//    private void sendMiniAppKefuMessage(WxMpService mpService, String openid) {
102
+//        // 客服消息封面
103
+//        TaMpSetting taMpSetting = iTaMpSettingService.getKFPoster(wxUtils.getMpConf().getAppid());
104
+//        if (null == taMpSetting) {
105
+//            log.error("发送客服消息失败, 暂无小程序封面信息");
106
+//            return;
107
+//        }
108
+//
109
+//        String[] parts = taMpSetting.getSettingValue().split("\\|");
110
+//        if (parts.length != 2) {
111
+//            log.error("发送客服消息失败, 小程序封面信息错误");
112
+//            return;
113
+//        }
114
+//
115
+//        String mediaId = parts[0];
116
+//
117
+//        String miniAppId = wxUtils.getMiniappConf().getAppid();
118
+//        WxMpKefuMessage kefuMessage = WxMpKefuMessage.MINIPROGRAMPAGE().appId(miniAppId)
119
+//                .toUser(openid)
120
+//                .title(miniAppTtitle + "欢迎您!")
121
+//                .pagePath(miniAppIndex + "?mpOpenId=" + openid )
122
+//                .thumbMediaId(mediaId)
123
+//                .build();
124
+//
125
+//        try {
126
+//            mpService.getKefuService().sendKefuMessage(kefuMessage);
127
+//        } catch (WxErrorException e) {
128
+//            e.printStackTrace();
129
+//        }
130
+//    }
131
+//
132
+//    /**
133
+//     * 暂时仅支持 jpg
134
+//     * @param multipartFile
135
+//     * @param request
136
+//     * @return
137
+//     */
138
+//    @PostMapping("/admin/mp/material/miniapp")
139
+//    public ResponseBean postMpMiniappMedia(@RequestParam("file") MultipartFile multipartFile,
140
+//                                           HttpServletRequest request) {
141
+//        if (multipartFile.isEmpty()) {
142
+//            return ResponseBean.error("请选择文件上传", ResponseBean.ERROR_MISSING_PARAMS);
143
+//        }
144
+//
145
+//        try {
146
+//            File tempFile = multipartFileToFile(multipartFile);
147
+//
148
+//            WxMpMaterial wxMaterial = new WxMpMaterial();
149
+//            wxMaterial.setFile(tempFile);
150
+//            wxMaterial.setName("kf-message-poster.jpg");
151
+//
152
+//            WxMpMaterialUploadResult res = wxUtils.getMpService().getMaterialService().materialFileUpload(WxConsts.MaterialType.IMAGE, wxMaterial);
153
+//            String mediaId = res.getMediaId();
154
+//
155
+//            if (StringUtils.isEmpty(mediaId)) {
156
+//                log.error("上传图片到微信失败 [{}]: {}", res.getErrCode(), res.getErrMsg());
157
+//                return ResponseBean.error("上传图片到微信失败: " + res.getErrMsg(), ResponseBean.ERROR_UNAVAILABLE);
158
+//            }
159
+//
160
+//            String imageUrl = ossUtils.putObject(tempFile);
161
+//            String settingValue = String.format("%s|%s", mediaId, imageUrl);
162
+//
163
+//            String mpAppid = wxUtils.getMpConf().getAppid();
164
+//            TaMpSetting taMpSetting = iTaMpSettingService.getKFPoster(mpAppid);
165
+//            if (null == taMpSetting) {
166
+//                taMpSetting = new TaMpSetting();
167
+//                taMpSetting.setAppid(mpAppid);
168
+//                taMpSetting.setSettingCode(Constants.MP_SETTING_MINIAPP_POSTER);
169
+//                taMpSetting.setSettingValue(settingValue);
170
+//                iTaMpSettingService.save(taMpSetting);
171
+//            } else {
172
+//                taMpSetting.setSettingValue(settingValue);
173
+//                iTaMpSettingService.updateById(taMpSetting);
174
+//            }
175
+//
176
+//            // 删除临时文件
177
+//            tempFile.delete();
178
+//
179
+//            return ResponseBean.success(taMpSetting);
180
+//
181
+//        } catch (IOException e) {
182
+//            e.printStackTrace();
183
+//            return ResponseBean.error("接收图片失败: " + e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
184
+//        } catch (WxErrorException e) {
185
+//            e.printStackTrace();
186
+//            return ResponseBean.error("上传图片到微信失败: " + e.getMessage(), ResponseBean.ERROR_UNAVAILABLE);
187
+//        }
188
+//    }
189
+//
190
+//    private File multipartFileToFile(MultipartFile multiFile) throws IOException {
191
+//        // 获取文件名
192
+//        String fileName = multiFile.getOriginalFilename();
193
+//        // sep
194
+//        int pos = fileName.lastIndexOf(".");
195
+//        //
196
+//        String prefix = fileName.substring(0, pos);
197
+//        String suffix = fileName.substring(pos);
198
+//
199
+//        File tempFile = File.createTempFile(prefix, suffix);
200
+//        multiFile.transferTo(tempFile);
201
+//        return tempFile;
202
+//    }
203
+//
204
+//
205
+//    /**
206
+//     * 获取消息封面
207
+//     * @return
208
+//     */
209
+//    @GetMapping("/admin/mp/material/miniapp")
210
+//    public ResponseBean postMpMiniappMedia() {
211
+//        String mpAppid = wxUtils.getMpConf().getAppid();
212
+//        TaMpSetting taMpSetting = iTaMpSettingService.getKFPoster(mpAppid);
213
+//        return ResponseBean.success(taMpSetting);
214
+//    }
215
+}

+ 52
- 0
src/main/java/com/yunzhi/questions/entity/SysLogin.java View File

@@ -0,0 +1,52 @@
1
+package com.yunzhi.questions.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 2021-12-10
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="SysLogin对象", description="登录")
25
+public class SysLogin implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "主键")
30
+    @TableId(value = "login_id", type = IdType.AUTO)
31
+    private Integer loginId;
32
+
33
+    @ApiModelProperty(value = "用户ID")
34
+    private String userId;
35
+
36
+    @ApiModelProperty(value = "登录名")
37
+    private String loginName;
38
+
39
+    @ApiModelProperty(value = "密码")
40
+    private String password;
41
+
42
+    @ApiModelProperty(value = "状态")
43
+    private Integer status;
44
+
45
+    @ApiModelProperty(value = "创建时间")
46
+    private LocalDateTime createDate;
47
+
48
+    @ApiModelProperty(value = "更新时间")
49
+    private LocalDateTime updateDate;
50
+
51
+
52
+}

+ 52
- 0
src/main/java/com/yunzhi/questions/entity/SysUser.java View File

@@ -0,0 +1,52 @@
1
+package com.yunzhi.questions.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 2021-12-10
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 Integer status;
44
+
45
+    @ApiModelProperty(value = "创建时间")
46
+    private LocalDateTime createDate;
47
+
48
+    @ApiModelProperty(value = "更新时间")
49
+    private LocalDateTime updateDate;
50
+
51
+
52
+}

+ 53
- 0
src/main/java/com/yunzhi/questions/entity/TaAnswer.java View File

@@ -0,0 +1,53 @@
1
+package com.yunzhi.questions.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import 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 2021-12-10
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaAnswer对象", description="题库答案")
25
+public class TaAnswer implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "答案ID")
30
+    @TableId(value = "answer_id", type = IdType.UUID)
31
+    private String answerId;
32
+
33
+    @ApiModelProperty(value = "问题ID")
34
+    private String questionId;
35
+
36
+    @ApiModelProperty(value = "选项")
37
+    @TableField("`option`")
38
+    private String option;
39
+
40
+    @ApiModelProperty(value = "选项内容")
41
+    private String content;
42
+
43
+    @ApiModelProperty(value = "内容类型")
44
+    private String contentType;
45
+
46
+    @ApiModelProperty(value = "排序")
47
+    private Integer sortNo;
48
+
49
+    @ApiModelProperty(value = "状态")
50
+    private Integer status;
51
+
52
+
53
+}

+ 46
- 0
src/main/java/com/yunzhi/questions/entity/TaApp.java View File

@@ -0,0 +1,46 @@
1
+package com.yunzhi.questions.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 2021-12-10
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaApp对象", description="应用表")
25
+public class TaApp implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "应用ID")
30
+    @TableId(value = "app_id", type = IdType.INPUT)
31
+    private String appId;
32
+
33
+    @ApiModelProperty(value = "应用名称")
34
+    private String appName;
35
+
36
+    @ApiModelProperty(value = "密钥")
37
+    private String secret;
38
+
39
+    @ApiModelProperty(value = "用户ID")
40
+    private String userId;
41
+
42
+    @ApiModelProperty(value = "创建日期")
43
+    private LocalDateTime createDate;
44
+
45
+
46
+}

+ 62
- 0
src/main/java/com/yunzhi/questions/entity/TaCharacterResult.java View File

@@ -0,0 +1,62 @@
1
+package com.yunzhi.questions.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import java.time.LocalDateTime;
5
+
6
+import com.baomidou.mybatisplus.annotation.TableField;
7
+import com.baomidou.mybatisplus.annotation.TableId;
8
+import java.io.Serializable;
9
+import java.util.List;
10
+
11
+import io.swagger.annotations.ApiModel;
12
+import io.swagger.annotations.ApiModelProperty;
13
+import lombok.Data;
14
+import lombok.EqualsAndHashCode;
15
+import lombok.experimental.Accessors;
16
+
17
+/**
18
+ * <p>
19
+ * 游戏特征实例
20
+ * </p>
21
+ *
22
+ * @author yansen
23
+ * @since 2021-12-15
24
+ */
25
+@Data
26
+@EqualsAndHashCode(callSuper = false)
27
+@Accessors(chain = true)
28
+@ApiModel(value="TaCharacterResult对象", description="游戏特征实例")
29
+public class TaCharacterResult implements Serializable {
30
+
31
+    private static final long serialVersionUID = 1L;
32
+
33
+    @ApiModelProperty(value = "模板ID")
34
+    @TableId(value = "result_id", type = IdType.INPUT)
35
+    private String resultId;
36
+
37
+    @ApiModelProperty(value = "特征库ID")
38
+    private String libId;
39
+
40
+    @ApiModelProperty(value = "实例名称")
41
+    @TableField("`name`")
42
+    private String name;
43
+
44
+    @ApiModelProperty(value = "实例描述")
45
+    @TableField("`desc`")
46
+    private String desc;
47
+
48
+    @ApiModelProperty(value = "图片")
49
+    private String thumb;
50
+
51
+    @ApiModelProperty(value = "状态")
52
+    private Integer status;
53
+
54
+    @ApiModelProperty(value = "创建时间")
55
+    private LocalDateTime createDate;
56
+
57
+
58
+    @ApiModelProperty(value = "特征词")
59
+    @TableField(exist = false)
60
+    private List<TdCharacterWord> wordList;
61
+
62
+}

+ 45
- 0
src/main/java/com/yunzhi/questions/entity/TaGame.java View File

@@ -0,0 +1,45 @@
1
+package com.yunzhi.questions.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 2021-12-10
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@ApiModel(value="TaGame对象", description="问答游戏")
24
+public class TaGame implements Serializable {
25
+
26
+    private static final long serialVersionUID = 1L;
27
+
28
+    @ApiModelProperty(value = "游戏ID")
29
+    @TableId(value = "game_id", type = IdType.UUID)
30
+    private String gameId;
31
+
32
+    @ApiModelProperty(value = "名称")
33
+    private String title;
34
+
35
+    @ApiModelProperty(value = "图片")
36
+    private String gameImage;
37
+
38
+    @ApiModelProperty(value = "结果类型")
39
+    private String resultMode;
40
+
41
+    @ApiModelProperty(value = "状态")
42
+    private Integer status;
43
+
44
+
45
+}

+ 48
- 0
src/main/java/com/yunzhi/questions/entity/TaGameLevel.java View File

@@ -0,0 +1,48 @@
1
+package com.yunzhi.questions.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 2021-12-10
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@ApiModel(value="TaGameLevel对象", description="关卡")
24
+public class TaGameLevel implements Serializable {
25
+
26
+    private static final long serialVersionUID = 1L;
27
+
28
+    @ApiModelProperty(value = "关卡ID")
29
+    @TableId(value = "level_id", type = IdType.UUID)
30
+    private String levelId;
31
+
32
+    @ApiModelProperty(value = "所属游戏")
33
+    private String gameId;
34
+
35
+    @ApiModelProperty(value = "关卡数字")
36
+    private Integer levelNum;
37
+
38
+    @ApiModelProperty(value = "名称")
39
+    private String title;
40
+
41
+    @ApiModelProperty(value = "图片")
42
+    private String levelImage;
43
+
44
+    @ApiModelProperty(value = "状态")
45
+    private Integer status;
46
+
47
+
48
+}

+ 42
- 0
src/main/java/com/yunzhi/questions/entity/TaGameLevelQuestion.java View File

@@ -0,0 +1,42 @@
1
+package com.yunzhi.questions.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 2021-12-10
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@ApiModel(value="TaGameLevelQuestion对象", description="关卡问题")
24
+public class TaGameLevelQuestion implements Serializable {
25
+
26
+    private static final long serialVersionUID = 1L;
27
+
28
+    @ApiModelProperty(value = "主键序号")
29
+    @TableId(value = "serial_no", type = IdType.AUTO)
30
+    private Integer serialNo;
31
+
32
+    @ApiModelProperty(value = "关卡ID")
33
+    private String levelId;
34
+
35
+    @ApiModelProperty(value = "问题ID")
36
+    private String questionId;
37
+
38
+    @ApiModelProperty(value = "序号")
39
+    private Integer sortNo;
40
+
41
+
42
+}

+ 42
- 0
src/main/java/com/yunzhi/questions/entity/TaGamePerson.java View File

@@ -0,0 +1,42 @@
1
+package com.yunzhi.questions.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 2021-12-10
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@ApiModel(value="TaGamePerson对象", description="参与游戏人员")
24
+public class TaGamePerson implements Serializable {
25
+
26
+    private static final long serialVersionUID = 1L;
27
+
28
+    @ApiModelProperty(value = "主键序号")
29
+    @TableId(value = "serial_no", type = IdType.AUTO)
30
+    private Integer serialNo;
31
+
32
+    @ApiModelProperty(value = "人员ID")
33
+    private String personId;
34
+
35
+    @ApiModelProperty(value = "游戏ID")
36
+    private String gameId;
37
+
38
+    @ApiModelProperty(value = "关卡ID")
39
+    private String levelId;
40
+
41
+
42
+}

+ 55
- 0
src/main/java/com/yunzhi/questions/entity/TaGamePersonAnswer.java View File

@@ -0,0 +1,55 @@
1
+package com.yunzhi.questions.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 2021-12-10
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaGamePersonAnswer对象", description="问答游戏结果")
25
+public class TaGamePersonAnswer implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "主键序号")
30
+    @TableId(value = "serial_no", type = IdType.AUTO)
31
+    private Integer serialNo;
32
+
33
+    @ApiModelProperty(value = "人员ID")
34
+    private String personId;
35
+
36
+    @ApiModelProperty(value = "游戏ID")
37
+    private String gameId;
38
+
39
+    @ApiModelProperty(value = "关卡ID")
40
+    private String levelId;
41
+
42
+    @ApiModelProperty(value = "问题ID")
43
+    private String questionId;
44
+
45
+    @ApiModelProperty(value = "回答结果")
46
+    private String answer;
47
+
48
+    @ApiModelProperty(value = "是否正确")
49
+    private Integer isRight;
50
+
51
+    @ApiModelProperty(value = "回答时间")
52
+    private LocalDateTime createDate;
53
+
54
+
55
+}

+ 57
- 0
src/main/java/com/yunzhi/questions/entity/TaGamePersonResult.java View File

@@ -0,0 +1,57 @@
1
+package com.yunzhi.questions.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import java.time.LocalDateTime;
7
+import java.io.Serializable;
8
+import java.util.List;
9
+
10
+import io.swagger.annotations.ApiModel;
11
+import io.swagger.annotations.ApiModelProperty;
12
+import lombok.Data;
13
+import lombok.EqualsAndHashCode;
14
+import lombok.experimental.Accessors;
15
+
16
+/**
17
+ * <p>
18
+ * 问答游戏总结
19
+ * </p>
20
+ *
21
+ * @author yansen
22
+ * @since 2021-12-15
23
+ */
24
+@Data
25
+@EqualsAndHashCode(callSuper = false)
26
+@Accessors(chain = true)
27
+@ApiModel(value="TaGamePersonResult对象", description="问答游戏总结")
28
+public class TaGamePersonResult implements Serializable {
29
+
30
+    private static final long serialVersionUID = 1L;
31
+
32
+    @ApiModelProperty(value = "主键序号")
33
+    @TableId(value = "serial_no", type = IdType.AUTO)
34
+    private Integer serialNo;
35
+
36
+    @ApiModelProperty(value = "人员ID")
37
+    private String personId;
38
+
39
+    @ApiModelProperty(value = "游戏ID")
40
+    private String gameId;
41
+
42
+    @ApiModelProperty(value = "特征实例ID")
43
+    private String resultId;
44
+
45
+    @ApiModelProperty(value = "得分")
46
+    private Integer score;
47
+
48
+    @ApiModelProperty(value = "状态")
49
+    private Integer status;
50
+
51
+    @ApiModelProperty(value = "创建时间")
52
+    private LocalDateTime createDate;
53
+
54
+    @ApiModelProperty(value = "回答列表")
55
+    @TableField(exist = false)
56
+    private List<TaGamePersonAnswer> answerList;
57
+}

+ 69
- 0
src/main/java/com/yunzhi/questions/entity/TaPerson.java View File

@@ -0,0 +1,69 @@
1
+package com.yunzhi.questions.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 2021-12-10
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaPerson对象", description="小程序人员表")
25
+public class TaPerson implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "人员ID")
30
+    @TableId(value = "person_id", type = IdType.UUID)
31
+    private String personId;
32
+
33
+    @ApiModelProperty(value = "小程序或者公众号appid")
34
+    private String appid;
35
+
36
+    @ApiModelProperty(value = "openid")
37
+    private String openid;
38
+
39
+    @ApiModelProperty(value = "unionid")
40
+    private String unionid;
41
+
42
+    @ApiModelProperty(value = "性别")
43
+    private Integer sex;
44
+
45
+    @ApiModelProperty(value = "昵称")
46
+    private String nickName;
47
+
48
+    @ApiModelProperty(value = "头像")
49
+    private String avatar;
50
+
51
+    @ApiModelProperty(value = "手机")
52
+    private String phone;
53
+
54
+    @ApiModelProperty(value = "当前角色")
55
+    private String personRole;
56
+
57
+    @ApiModelProperty(value = "状态")
58
+    private Integer status;
59
+
60
+    @ApiModelProperty(value = "创建时间")
61
+    private LocalDateTime createDate;
62
+
63
+    @ApiModelProperty(value = "来源类型")
64
+    private String fromType;
65
+
66
+    @ApiModelProperty(value = "推广ID")
67
+    private String recommender;
68
+
69
+}

+ 49
- 0
src/main/java/com/yunzhi/questions/entity/TaQuestion.java View File

@@ -0,0 +1,49 @@
1
+package com.yunzhi.questions.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 2021-12-10
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaQuestion对象", description="题库")
25
+public class TaQuestion implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "问题ID")
30
+    @TableId(value = "question_id", type = IdType.UUID)
31
+    private String questionId;
32
+
33
+    @ApiModelProperty(value = "问题名称")
34
+    private String title;
35
+
36
+    @ApiModelProperty(value = "答案类型")
37
+    private String optType;
38
+
39
+    @ApiModelProperty(value = "正确答案")
40
+    private String rightAnswer;
41
+
42
+    @ApiModelProperty(value = "状态")
43
+    private Integer status;
44
+
45
+    @ApiModelProperty(value = "创建时间")
46
+    private LocalDateTime createDate;
47
+
48
+
49
+}

+ 76
- 0
src/main/java/com/yunzhi/questions/entity/TaWxConfig.java View File

@@ -0,0 +1,76 @@
1
+package com.yunzhi.questions.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import io.swagger.annotations.ApiModel;
7
+import io.swagger.annotations.ApiModelProperty;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import lombok.experimental.Accessors;
11
+
12
+import java.io.Serializable;
13
+import java.time.LocalDateTime;
14
+
15
+/**
16
+ * <p>
17
+ * 微信配置
18
+ * </p>
19
+ *
20
+ * @author yansen
21
+ * @since 2021-12-10
22
+ */
23
+@Data
24
+@EqualsAndHashCode(callSuper = false)
25
+@Accessors(chain = true)
26
+@ApiModel(value="TaWxConfig对象", description="微信配置")
27
+public class TaWxConfig implements Serializable {
28
+
29
+    private static final long serialVersionUID = 1L;
30
+
31
+    @ApiModelProperty(value = "配置ID")
32
+    @TableId(value = "config_id", type = IdType.UUID)
33
+    private String configId;
34
+
35
+    @ApiModelProperty(value = "用户ID")
36
+    private String userId;
37
+
38
+    @ApiModelProperty(value = "ma小程序,mp公众号")
39
+    private String appType;
40
+
41
+    @ApiModelProperty(value = "二维码")
42
+    private String qrCode;
43
+
44
+    @ApiModelProperty(value = "AppID")
45
+    private String appid;
46
+
47
+    @ApiModelProperty(value = "Secret")
48
+    private String secret;
49
+
50
+    @ApiModelProperty(value = "Token")
51
+    private String token;
52
+
53
+    @ApiModelProperty(value = "AesKey")
54
+    private String aesKey;
55
+
56
+    @ApiModelProperty(value = "消息格式类型")
57
+    private String msgDataFormat;
58
+
59
+    @ApiModelProperty(value = "接口代理地址")
60
+    private String httpPoxyHost;
61
+
62
+    @ApiModelProperty(value = "接口代理端口")
63
+    private String httpProxyPort;
64
+
65
+    @ApiModelProperty(value = "第三方接口地址")
66
+    @TableField("`api_url`")
67
+    private String apiURL;
68
+
69
+    @ApiModelProperty(value = "状态")
70
+    private Integer status;
71
+
72
+    @ApiModelProperty(value = "创建时间")
73
+    private LocalDateTime createDate;
74
+
75
+
76
+}

+ 55
- 0
src/main/java/com/yunzhi/questions/entity/TdCharacterLib.java View File

@@ -0,0 +1,55 @@
1
+package com.yunzhi.questions.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import java.time.LocalDateTime;
5
+
6
+import com.baomidou.mybatisplus.annotation.TableField;
7
+import com.baomidou.mybatisplus.annotation.TableId;
8
+import java.io.Serializable;
9
+import java.util.List;
10
+
11
+import io.swagger.annotations.ApiModel;
12
+import io.swagger.annotations.ApiModelProperty;
13
+import lombok.Data;
14
+import lombok.EqualsAndHashCode;
15
+import lombok.experimental.Accessors;
16
+
17
+/**
18
+ * <p>
19
+ * 特征库
20
+ * </p>
21
+ *
22
+ * @author yansen
23
+ * @since 2021-12-14
24
+ */
25
+@Data
26
+@EqualsAndHashCode(callSuper = false)
27
+@Accessors(chain = true)
28
+@ApiModel(value="TdCharacterLib对象", description="特征库")
29
+public class TdCharacterLib implements Serializable {
30
+
31
+    private static final long serialVersionUID = 1L;
32
+
33
+    @ApiModelProperty(value = "库ID")
34
+    @TableId(value = "lib_id", type = IdType.UUID)
35
+    private String libId;
36
+
37
+    @ApiModelProperty(value = "特征库名称")
38
+    private String name;
39
+
40
+    @ApiModelProperty(value = "特征库图标")
41
+    private String icon;
42
+
43
+    @ApiModelProperty(value = "特征库说明")
44
+    private String remark;
45
+
46
+    @ApiModelProperty(value = "状态")
47
+    private Integer status;
48
+
49
+    @ApiModelProperty(value = "创建时间")
50
+    private LocalDateTime createDate;
51
+
52
+    @ApiModelProperty(value = "特征词")
53
+    @TableField(exist = false)
54
+    private List<TdCharacterWord> wordList;
55
+}

+ 43
- 0
src/main/java/com/yunzhi/questions/entity/TdCharacterWord.java View File

@@ -0,0 +1,43 @@
1
+package com.yunzhi.questions.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 2021-12-14
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TdCharacterWord对象", description="特征词")
25
+public class TdCharacterWord implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "词ID")
30
+    @TableId(value = "word_id", type = IdType.UUID)
31
+    private String wordId;
32
+
33
+    @ApiModelProperty(value = "特征库ID")
34
+    private String libId;
35
+
36
+    @ApiModelProperty(value = "特征词")
37
+    private String word;
38
+
39
+    @ApiModelProperty(value = "创建时间")
40
+    private LocalDateTime createDate;
41
+
42
+
43
+}

+ 19
- 0
src/main/java/com/yunzhi/questions/exception/GlobalExceptionHandler.java View File

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

+ 122
- 0
src/main/java/com/yunzhi/questions/interceptor/PermissionInterceptor.java View File

@@ -0,0 +1,122 @@
1
+package com.yunzhi.questions.interceptor;
2
+
3
+import com.alibaba.fastjson.JSONObject;
4
+import com.yunzhi.questions.common.*;
5
+import com.yunzhi.questions.entity.TaApp;
6
+import com.yunzhi.questions.entity.TaPerson;
7
+import com.yunzhi.questions.service.ITaAppService;
8
+import com.yunzhi.questions.service.ITaPersonService;
9
+import lombok.extern.slf4j.Slf4j;
10
+import org.springframework.beans.factory.annotation.Autowired;
11
+import org.springframework.stereotype.Component;
12
+import org.springframework.util.DigestUtils;
13
+import org.springframework.web.servlet.HandlerInterceptor;
14
+
15
+import javax.servlet.http.HttpServletRequest;
16
+import javax.servlet.http.HttpServletResponse;
17
+import java.io.IOException;
18
+import java.time.LocalDateTime;
19
+import java.util.Map;
20
+
21
+
22
+@Slf4j
23
+@Component
24
+public class PermissionInterceptor implements HandlerInterceptor {
25
+
26
+    @Autowired
27
+    ITaAppService iTaAppService;
28
+
29
+    @Autowired
30
+    ITaPersonService iTaPersonService;
31
+
32
+    @Override
33
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object obj) throws Exception {
34
+        String uri = request.getRequestURI();
35
+
36
+        if (uri.contains("/admin/")) {
37
+            return validateAdmin(request, response);
38
+        }
39
+
40
+        return validateClient(request, response);
41
+    }
42
+
43
+    private boolean validateClient(HttpServletRequest request, HttpServletResponse response) throws Exception {// JWT
44
+        String appId = request.getHeader("x-appid");
45
+        String personId = request.getHeader("x-personid");
46
+        String timestamp = request.getHeader("x-timestamp");    // 时间 - 毫秒数
47
+        String sign = request.getHeader("x-sign");
48
+
49
+        if (StringUtils.isEmpty(appId)
50
+                || StringUtils.isEmpty(personId)
51
+                || StringUtils.isEmpty(timestamp)
52
+                || StringUtils.isEmpty(sign)) {
53
+            responseTokenError(response, "鉴权失败, 没有相关参数");
54
+            return false;
55
+        }
56
+
57
+        long milliseconds = Long.parseLong(timestamp);
58
+        LocalDateTime dt = DateUtils.getDateTime(milliseconds);
59
+        LocalDateTime now = LocalDateTime.now();
60
+        long diffMin = 5;
61
+
62
+        if (now.minusMinutes(diffMin).isAfter(dt) || now.plusMinutes(diffMin).isBefore(dt)) {
63
+            responseTokenError(response, "鉴权失败, 请求超时");
64
+            return false;
65
+        }
66
+
67
+        TaApp taApp = iTaAppService.getById(appId);
68
+        if (null == taApp) {
69
+            responseTokenError(response, "鉴权失败, 无效的 appid");
70
+            return false;
71
+        }
72
+
73
+        TaPerson taPerson = iTaPersonService.getById(personId);
74
+        if (null == taPerson || Constants.STATUS_DELETED == taPerson.getStatus()) {
75
+            responseTokenError(response, "鉴权失败, 无效的 personId");
76
+            return false;
77
+        }
78
+
79
+        String plainText = appId+personId+taApp.getSecret()+timestamp;
80
+        String validSign = DigestUtils.md5DigestAsHex(plainText.getBytes());
81
+
82
+        if (validSign.equals(sign)) {
83
+            responseTokenError(response, "鉴权失败, sign 校验失败");
84
+            return false;
85
+        }
86
+
87
+        return true;
88
+    }
89
+
90
+    private boolean validateAdmin(HttpServletRequest request, HttpServletResponse response) throws Exception {// JWT
91
+        String jws = JWTUtils.getToken(request);
92
+        String useId = request.getHeader("x-userid");
93
+        if (StringUtils.isEmpty(jws)) {
94
+            responseTokenError(response, "鉴权失败, 请先进行登录操作");
95
+            return false;
96
+        }
97
+
98
+        try {
99
+            Map<String, Object> tokenMap = JWTUtils.decode(jws);
100
+
101
+            Object u = tokenMap.get("userId");
102
+            if (u == null || !u.toString().equals(useId)) {
103
+                responseTokenError(response, "鉴权失败, 请重新登录");
104
+                return false;
105
+            }
106
+        } catch (Exception e) {
107
+            log.error("鉴权失败: {}", e.getMessage());
108
+            responseTokenError(response, "鉴权失败, 请重新登录");
109
+            return false;
110
+        }
111
+
112
+        return true;
113
+    }
114
+
115
+    private void responseTokenError(HttpServletResponse response, String error) throws IOException {
116
+        response.addHeader("Content-type", "application/json");
117
+        response.getOutputStream().write(
118
+                JSONObject.toJSONBytes(
119
+                        ResponseBean.error(error, ResponseBean.ERROR_AUTH_FAIL)
120
+                ));
121
+    }
122
+}

+ 79
- 0
src/main/java/com/yunzhi/questions/log/MysqlAppender.java View File

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

+ 18
- 0
src/main/java/com/yunzhi/questions/mapper/SysLoginMapper.java View File

@@ -0,0 +1,18 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.SysLogin;
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 2021-12-10
14
+ */
15
+@Mapper
16
+public interface SysLoginMapper extends BaseMapper<SysLogin> {
17
+
18
+}

+ 18
- 0
src/main/java/com/yunzhi/questions/mapper/SysUserMapper.java View File

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

+ 26
- 0
src/main/java/com/yunzhi/questions/mapper/TaAnswerMapper.java View File

@@ -0,0 +1,26 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.TaAnswer;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * <p>
12
+ * 题库答案 Mapper 接口
13
+ * </p>
14
+ *
15
+ * @author yansen
16
+ * @since 2021-12-10
17
+ */
18
+@Mapper
19
+public interface TaAnswerMapper extends BaseMapper<TaAnswer> {
20
+
21
+    int deleteByQuestionID(@Param("questionId") String questionId);
22
+
23
+    List<TaAnswer> getByQuestionId(@Param("questionId") String questionId);
24
+
25
+    int countByGameId(@Param("gameId") String gameId);
26
+}

+ 18
- 0
src/main/java/com/yunzhi/questions/mapper/TaAppMapper.java View File

@@ -0,0 +1,18 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.TaApp;
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 2021-12-10
14
+ */
15
+@Mapper
16
+public interface TaAppMapper extends BaseMapper<TaApp> {
17
+
18
+}

+ 27
- 0
src/main/java/com/yunzhi/questions/mapper/TaCharacterResultMapper.java View File

@@ -0,0 +1,27 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.TaCharacterResult;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import com.yunzhi.questions.vo.CharacterInstWithWords;
6
+import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+
9
+import java.util.List;
10
+
11
+/**
12
+ * <p>
13
+ * 游戏特征实例 Mapper 接口
14
+ * </p>
15
+ *
16
+ * @author yansen
17
+ * @since 2021-12-15
18
+ */
19
+@Mapper
20
+public interface TaCharacterResultMapper extends BaseMapper<TaCharacterResult> {
21
+
22
+    int insertWord(@Param("resultId") String resultId, @Param("wordId") String wordId);
23
+
24
+    int removeWords(@Param("resultId") String resultId);
25
+
26
+    List<CharacterInstWithWords> getInstListBy(@Param("gameId") String gameId);
27
+}

+ 18
- 0
src/main/java/com/yunzhi/questions/mapper/TaGameLevelMapper.java View File

@@ -0,0 +1,18 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.TaGameLevel;
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 2021-12-10
14
+ */
15
+@Mapper
16
+public interface TaGameLevelMapper extends BaseMapper<TaGameLevel> {
17
+
18
+}

+ 18
- 0
src/main/java/com/yunzhi/questions/mapper/TaGameLevelQuestionMapper.java View File

@@ -0,0 +1,18 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.TaGameLevelQuestion;
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 2021-12-10
14
+ */
15
+@Mapper
16
+public interface TaGameLevelQuestionMapper extends BaseMapper<TaGameLevelQuestion> {
17
+
18
+}

+ 18
- 0
src/main/java/com/yunzhi/questions/mapper/TaGameMapper.java View File

@@ -0,0 +1,18 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.TaGame;
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 2021-12-10
14
+ */
15
+@Mapper
16
+public interface TaGameMapper extends BaseMapper<TaGame> {
17
+
18
+}

+ 18
- 0
src/main/java/com/yunzhi/questions/mapper/TaGamePersonAnswerMapper.java View File

@@ -0,0 +1,18 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.TaGamePersonAnswer;
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 2021-12-10
14
+ */
15
+@Mapper
16
+public interface TaGamePersonAnswerMapper extends BaseMapper<TaGamePersonAnswer> {
17
+
18
+}

+ 18
- 0
src/main/java/com/yunzhi/questions/mapper/TaGamePersonMapper.java View File

@@ -0,0 +1,18 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.TaGamePerson;
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 2021-12-10
14
+ */
15
+@Mapper
16
+public interface TaGamePersonMapper extends BaseMapper<TaGamePerson> {
17
+
18
+}

+ 22
- 0
src/main/java/com/yunzhi/questions/mapper/TaGamePersonResultMapper.java View File

@@ -0,0 +1,22 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.TaGamePersonResult;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * <p>
12
+ * 问答游戏总结 Mapper 接口
13
+ * </p>
14
+ *
15
+ * @author yansen
16
+ * @since 2021-12-15
17
+ */
18
+@Mapper
19
+public interface TaGamePersonResultMapper extends BaseMapper<TaGamePersonResult> {
20
+
21
+    List<String> getPersonAnswerWordIdList(@Param("gameId") String gameId, @Param("personId") String personId);
22
+}

+ 20
- 0
src/main/java/com/yunzhi/questions/mapper/TaPersonMapper.java View File

@@ -0,0 +1,20 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.TaPerson;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+/**
9
+ * <p>
10
+ * 小程序人员表 Mapper 接口
11
+ * </p>
12
+ *
13
+ * @author yansen
14
+ * @since 2021-12-10
15
+ */
16
+@Mapper
17
+public interface TaPersonMapper extends BaseMapper<TaPerson> {
18
+
19
+    TaPerson getByPhone(@Param("phone") String phone);
20
+}

+ 24
- 0
src/main/java/com/yunzhi/questions/mapper/TaQuestionMapper.java View File

@@ -0,0 +1,24 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.TaQuestion;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * <p>
12
+ * 题库 Mapper 接口
13
+ * </p>
14
+ *
15
+ * @author yansen
16
+ * @since 2021-12-10
17
+ */
18
+@Mapper
19
+public interface TaQuestionMapper extends BaseMapper<TaQuestion> {
20
+
21
+    int countByGameId(@Param("gameId") String gameId);
22
+
23
+    List<TaQuestion> getByGame(String gameId);
24
+}

+ 18
- 0
src/main/java/com/yunzhi/questions/mapper/TaWxConfigMapper.java View File

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

+ 22
- 0
src/main/java/com/yunzhi/questions/mapper/TdCharacterLibMapper.java View File

@@ -0,0 +1,22 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.TdCharacterLib;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+/**
9
+ * <p>
10
+ * 特征库 Mapper 接口
11
+ * </p>
12
+ *
13
+ * @author yansen
14
+ * @since 2021-12-14
15
+ */
16
+@Mapper
17
+public interface TdCharacterLibMapper extends BaseMapper<TdCharacterLib> {
18
+
19
+    int saveUserMapLib(@Param("userId") String userId, @Param("libId") String libId);
20
+
21
+    int getCountOfMapUser(@Param("userId") String userId, @Param("libId") String libId);
22
+}

+ 28
- 0
src/main/java/com/yunzhi/questions/mapper/TdCharacterWordMapper.java View File

@@ -0,0 +1,28 @@
1
+package com.yunzhi.questions.mapper;
2
+
3
+import com.yunzhi.questions.entity.TdCharacterWord;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
9
+
10
+/**
11
+ * <p>
12
+ * 特征词 Mapper 接口
13
+ * </p>
14
+ *
15
+ * @author yansen
16
+ * @since 2021-12-14
17
+ */
18
+@Mapper
19
+public interface TdCharacterWordMapper extends BaseMapper<TdCharacterWord> {
20
+
21
+    int deleteByLibId(@Param("libId") String libId, @Param("wordIdList") List<String> wordIdList);
22
+
23
+    List<TdCharacterWord> getListByLidId(@Param("libId") String libId);
24
+
25
+    int countBy(@Param("libId") String libId, @Param("word") String word);
26
+
27
+    List<TdCharacterWord> getListByResultId(@Param("resultId") String resultId);
28
+}

+ 14
- 0
src/main/java/com/yunzhi/questions/service/IBaseService.java View File

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

+ 19
- 0
src/main/java/com/yunzhi/questions/service/ISysLoginService.java View File

@@ -0,0 +1,19 @@
1
+package com.yunzhi.questions.service;
2
+
3
+import com.yunzhi.questions.entity.SysLogin;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 登录 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2021-12-10
13
+ */
14
+public interface ISysLoginService extends IService<SysLogin> {
15
+
16
+    SysLogin getByLoginName(String userName);
17
+
18
+    SysLogin getByUser(String userId);
19
+}

+ 16
- 0
src/main/java/com/yunzhi/questions/service/ISysUserService.java View File

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

+ 22
- 0
src/main/java/com/yunzhi/questions/service/ITaAnswerService.java View File

@@ -0,0 +1,22 @@
1
+package com.yunzhi.questions.service;
2
+
3
+import com.yunzhi.questions.entity.TaAnswer;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.yunzhi.questions.entity.TaQuestion;
6
+
7
+import java.util.List;
8
+
9
+/**
10
+ * <p>
11
+ * 题库答案 服务类
12
+ * </p>
13
+ *
14
+ * @author yansen
15
+ * @since 2021-12-10
16
+ */
17
+public interface ITaAnswerService extends IService<TaAnswer> {
18
+
19
+    List<TaAnswer> getByQuestionId(String id);
20
+
21
+    int countByGameId(String gameId);
22
+}

+ 16
- 0
src/main/java/com/yunzhi/questions/service/ITaAppService.java View File

@@ -0,0 +1,16 @@
1
+package com.yunzhi.questions.service;
2
+
3
+import com.yunzhi.questions.entity.TaApp;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 应用表 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2021-12-10
13
+ */
14
+public interface ITaAppService extends IService<TaApp> {
15
+
16
+}

+ 20
- 0
src/main/java/com/yunzhi/questions/service/ITaCharacterResultService.java View File

@@ -0,0 +1,20 @@
1
+package com.yunzhi.questions.service;
2
+
3
+import com.yunzhi.questions.entity.SysUser;
4
+import com.yunzhi.questions.entity.TaCharacterResult;
5
+import com.baomidou.mybatisplus.extension.service.IService;
6
+
7
+/**
8
+ * <p>
9
+ * 游戏特征实例 服务类
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2021-12-15
14
+ */
15
+public interface ITaCharacterResultService extends IBaseService<TaCharacterResult> {
16
+
17
+    boolean saveWithWords(SysUser user, TaCharacterResult taCharacterResult) throws Exception;
18
+
19
+    boolean updateWithWords(TaCharacterResult taCharacterResult) throws Exception;
20
+}

+ 16
- 0
src/main/java/com/yunzhi/questions/service/ITaGameLevelQuestionService.java View File

@@ -0,0 +1,16 @@
1
+package com.yunzhi.questions.service;
2
+
3
+import com.yunzhi.questions.entity.TaGameLevelQuestion;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 关卡问题 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2021-12-10
13
+ */
14
+public interface ITaGameLevelQuestionService extends IService<TaGameLevelQuestion> {
15
+
16
+}

+ 16
- 0
src/main/java/com/yunzhi/questions/service/ITaGameLevelService.java View File

@@ -0,0 +1,16 @@
1
+package com.yunzhi.questions.service;
2
+
3
+import com.yunzhi.questions.entity.TaGameLevel;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 关卡 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2021-12-10
13
+ */
14
+public interface ITaGameLevelService extends IBaseService<TaGameLevel> {
15
+
16
+}

+ 16
- 0
src/main/java/com/yunzhi/questions/service/ITaGamePersonAnswerService.java View File

@@ -0,0 +1,16 @@
1
+package com.yunzhi.questions.service;
2
+
3
+import com.yunzhi.questions.entity.TaGamePersonAnswer;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 问答游戏结果 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2021-12-10
13
+ */
14
+public interface ITaGamePersonAnswerService extends IService<TaGamePersonAnswer> {
15
+
16
+}

+ 17
- 0
src/main/java/com/yunzhi/questions/service/ITaGamePersonResultService.java View File

@@ -0,0 +1,17 @@
1
+package com.yunzhi.questions.service;
2
+
3
+import com.yunzhi.questions.entity.TaGamePersonResult;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 问答游戏总结 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2021-12-15
13
+ */
14
+public interface ITaGamePersonResultService extends IService<TaGamePersonResult> {
15
+
16
+    boolean makeAnswer(TaGamePersonResult taGamePersonResult) throws Exception;
17
+}

+ 16
- 0
src/main/java/com/yunzhi/questions/service/ITaGamePersonService.java View File

@@ -0,0 +1,16 @@
1
+package com.yunzhi.questions.service;
2
+
3
+import com.yunzhi.questions.entity.TaGamePerson;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 参与游戏人员 服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2021-12-10
13
+ */
14
+public interface ITaGamePersonService extends IService<TaGamePerson> {
15
+
16
+}

+ 0
- 0
src/main/java/com/yunzhi/questions/service/ITaGameService.java View File


Some files were not shown because too many files changed in this diff