├── .gitignore ├── README.md ├── liberty.sql ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── red │ │ └── fuyun │ │ └── liberty │ │ ├── LibertyApplication.java │ │ ├── advice │ │ ├── ExceptionControllerAdvice.java │ │ └── ResponseResultAdvice.java │ │ ├── annotation │ │ └── RestControllerResult.java │ │ ├── configuration │ │ ├── Config.java │ │ ├── InterceptorConfig.java │ │ └── ProxyeeConfig.java │ │ ├── controller │ │ └── UserController.java │ │ ├── enums │ │ └── ResultStatus.java │ │ ├── interceptors │ │ └── LoginInterceptor.java │ │ ├── mapper │ │ ├── LeaveMapper.java │ │ └── UserMapper.java │ │ ├── pojo │ │ ├── Leave.java │ │ ├── ResultVO.java │ │ └── User.java │ │ ├── proxyee │ │ ├── Auth.java │ │ ├── Cell.java │ │ ├── MapppingMthod.java │ │ ├── MyRequestIntercept.java │ │ └── MyResponseIntercept.java │ │ ├── service │ │ ├── LeaveService.java │ │ └── UserService.java │ │ └── util │ │ ├── ApiException.java │ │ ├── HttpUtil.java │ │ └── JWTUtils.java └── resources │ ├── application.yml │ └── ehcache.xml └── test └── java └── red └── fuyun └── liberty └── HelpcatsApplicationTests.java /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # liberty 2 | 今日校园请假 3 | 真实请假界面,非模拟软件,不限设备 4 | -------------------------------------------------------------------------------- /liberty.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : tom 5 | Source Server Type : MySQL 6 | Source Server Version : 80020 7 | Source Host : 123.56.58.237:3306 8 | Source Schema : liberty 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 80020 12 | File Encoding : 65001 13 | 14 | Date: 14/03/2021 22:21:38 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for leave 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `leave`; 24 | CREATE TABLE `leave` ( 25 | `id` int(0) NOT NULL AUTO_INCREMENT, 26 | `uid` int(0) NULL DEFAULT NULL, 27 | `start_time` timestamp(0) NULL DEFAULT NULL, 28 | `end_time` timestamp(0) NULL DEFAULT NULL, 29 | `leave_reason` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, 30 | `urgency_mobile` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, 31 | PRIMARY KEY (`id`) USING BTREE 32 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; 33 | 34 | -- ---------------------------- 35 | -- Table structure for user 36 | -- ---------------------------- 37 | DROP TABLE IF EXISTS `user`; 38 | CREATE TABLE `user` ( 39 | `id` int(0) NOT NULL AUTO_INCREMENT, 40 | `uname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, 41 | `pwd` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, 42 | `create_time` timestamp(0) NULL DEFAULT NULL, 43 | `last_time` timestamp(0) NULL DEFAULT NULL, 44 | `student_no` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL, 45 | PRIMARY KEY (`id`) USING BTREE 46 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = Dynamic; 47 | 48 | SET FOREIGN_KEY_CHECKS = 1; 49 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.4.3 9 | 10 | 11 | 12 | red.fuyun 13 | liberty 14 | 0.0.1-SNAPSHOT 15 | liberty 16 | liberty 17 | 18 | 1.8 19 | 20 | 21 | 22 | org.springframework.boot 23 | spring-boot-starter-web 24 | 25 | 26 | 27 | org.springframework.boot 28 | spring-boot-starter-validation 29 | 30 | 31 | 32 | org.hibernate.validator 33 | hibernate-validator 34 | 35 | 36 | 37 | org.springframework.boot 38 | spring-boot-starter-test 39 | test 40 | 41 | 42 | 43 | 44 | com.auth0 45 | java-jwt 46 | 3.4.0 47 | 48 | 49 | 50 | com.baomidou 51 | mybatis-plus-boot-starter 52 | 3.4.2 53 | 54 | 55 | 56 | org.projectlombok 57 | lombok 58 | 1.18.0 59 | 60 | 61 | 62 | 63 | 64 | mysql 65 | mysql-connector-java 66 | 8.0.16 67 | 68 | 69 | 70 | 71 | com.alibaba 72 | druid 73 | 1.1.22 74 | 75 | 76 | 77 | 78 | 79 | com.baomidou 80 | mybatis-plus-boot-starter 81 | 3.4.2 82 | 83 | 84 | 85 | 86 | com.squareup.okhttp3 87 | okhttp 88 | 3.10.0 89 | 90 | 91 | 92 | 93 | com.alibaba 94 | fastjson 95 | 1.2.75 96 | 97 | 98 | 99 | net.sf.ehcache 100 | ehcache 101 | 102 | 103 | org.springframework.boot 104 | spring-boot-starter-cache 105 | 106 | 107 | 108 | com.github.monkeywie 109 | proxyee 110 | 1.4.1 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | org.springframework.boot 120 | spring-boot-maven-plugin 121 | 122 | true 123 | -Dfile.encoding=UTF-8 124 | 125 | 126 | 127 | 128 | org.apache.maven.plugins 129 | maven-surefire-plugin 130 | 2.20.1 131 | 132 | true 133 | 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/LibertyApplication.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty; 2 | 3 | import com.github.monkeywie.proxyee.server.HttpProxyServer; 4 | import lombok.extern.slf4j.Slf4j; 5 | 6 | import org.mybatis.spring.annotation.MapperScan; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.boot.ApplicationArguments; 9 | import org.springframework.boot.ApplicationRunner; 10 | import org.springframework.boot.SpringApplication; 11 | import org.springframework.boot.autoconfigure.SpringBootApplication; 12 | import org.springframework.cache.annotation.EnableCaching; 13 | import org.springframework.stereotype.Component; 14 | 15 | import javax.annotation.PostConstruct; 16 | 17 | @SpringBootApplication 18 | @Slf4j 19 | @EnableCaching 20 | @MapperScan(basePackages = {"red.fuyun.liberty.mapper"}) 21 | public class LibertyApplication { 22 | 23 | @Autowired 24 | private HttpProxyServer httpProxyServer; 25 | 26 | @PostConstruct 27 | private void init(){ 28 | System.out.println("服务启动成功..........."); 29 | httpProxyServer.start(6666); 30 | } 31 | 32 | public static void main(String[] args) { 33 | SpringApplication.run(LibertyApplication.class, args); 34 | } 35 | 36 | } 37 | 38 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/advice/ExceptionControllerAdvice.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.advice; 2 | 3 | import red.fuyun.liberty.pojo.ResultVO; 4 | import red.fuyun.liberty.util.ApiException; 5 | import org.springframework.validation.ObjectError; 6 | import org.springframework.web.bind.MethodArgumentNotValidException; 7 | import org.springframework.web.bind.annotation.ExceptionHandler; 8 | import org.springframework.web.bind.annotation.RestControllerAdvice; 9 | 10 | @RestControllerAdvice 11 | public class ExceptionControllerAdvice { 12 | 13 | @ExceptionHandler(MethodArgumentNotValidException.class) 14 | public ResultVO MethodArgumentNotValidExceptionHandler(MethodArgumentNotValidException e) { 15 | // 从异常对象中拿到ObjectError对象 16 | ObjectError objectError = e.getBindingResult().getAllErrors().get(0); 17 | String defaultMessage = objectError.getDefaultMessage(); 18 | 19 | // 然后提取错误提示信息进行返回 20 | return ResultVO.failure(defaultMessage); 21 | } 22 | 23 | @ExceptionHandler(ApiException.class) 24 | public ResultVO APIExceptionHandler(ApiException e) { 25 | return ResultVO.failure(e.getMsg()); 26 | } 27 | 28 | 29 | 30 | @ExceptionHandler(Exception.class) 31 | public ResultVO ExceptionHandler(Exception e) { 32 | return ResultVO.failure(e.getMessage()); 33 | } 34 | 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/advice/ResponseResultAdvice.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.advice; 2 | 3 | import red.fuyun.liberty.pojo.ResultVO; 4 | import red.fuyun.liberty.util.ApiException; 5 | import com.fasterxml.jackson.core.JsonProcessingException; 6 | import com.fasterxml.jackson.databind.ObjectMapper; 7 | import org.springframework.core.MethodParameter; 8 | import org.springframework.http.MediaType; 9 | import org.springframework.http.converter.HttpMessageConverter; 10 | import org.springframework.http.server.ServerHttpRequest; 11 | import org.springframework.http.server.ServerHttpResponse; 12 | import org.springframework.web.bind.annotation.RestControllerAdvice; 13 | import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice; 14 | 15 | @RestControllerAdvice(basePackages = {"com.exmple.helper.controller"}) 16 | public class ResponseResultAdvice implements ResponseBodyAdvice { 17 | 18 | @Override 19 | public boolean supports(MethodParameter returnType, Class> aClass) { 20 | // boolean hasAnnotation = AnnotatedElementUtils.hasAnnotation(methodParameter.getContainingClass(), ResponseResult.class); 21 | // boolean hasMethodAnnotation = methodParameter.hasMethodAnnotation(ResponseResult.class); 22 | return !returnType.getGenericParameterType().equals(ResultVO.class); 23 | } 24 | 25 | @Override 26 | public Object beforeBodyWrite(Object body, MethodParameter returnType, MediaType mediaType, Class> aClass, ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) { 27 | 28 | 29 | // String类型不能直接包装,所以要进行些特别的处理 30 | if (returnType.getGenericParameterType().equals(String.class)) { 31 | ObjectMapper objectMapper = new ObjectMapper(); 32 | try { 33 | // 将数据包装在ResultVO里后,再转换为json字符串响应给前端 34 | return objectMapper.writeValueAsString( ResultVO.success(body)); 35 | } catch (JsonProcessingException e) { 36 | throw new ApiException("返回String类型错误"); 37 | } 38 | } 39 | // 将原本的数据包装在ResultVO里 40 | return ResultVO.success(body); 41 | } 42 | } 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/annotation/RestControllerResult.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.annotation; 2 | 3 | import org.springframework.web.bind.annotation.RestController; 4 | 5 | import java.lang.annotation.*; 6 | 7 | @Retention(RetentionPolicy.RUNTIME) 8 | @Target({ElementType.TYPE, ElementType.METHOD}) 9 | @Documented 10 | @RestController 11 | public @interface RestControllerResult { 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/configuration/Config.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.configuration; 2 | 3 | import okhttp3.OkHttpClient; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | 7 | import java.util.concurrent.TimeUnit; 8 | 9 | @Configuration 10 | public class Config { 11 | 12 | @Bean 13 | public OkHttpClient okHttpClient(){ 14 | OkHttpClient cilent = new OkHttpClient.Builder() 15 | .connectTimeout(2, TimeUnit.SECONDS) 16 | .readTimeout(2, TimeUnit.SECONDS) 17 | .writeTimeout(2, TimeUnit.SECONDS) 18 | .build(); 19 | return cilent; 20 | } 21 | 22 | 23 | 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/configuration/InterceptorConfig.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.configuration; 2 | 3 | import red.fuyun.liberty.interceptors.LoginInterceptor; 4 | import org.springframework.context.annotation.Bean; 5 | import org.springframework.context.annotation.Configuration; 6 | import org.springframework.web.servlet.config.annotation.CorsRegistry; 7 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 8 | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; 9 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 10 | 11 | @Configuration 12 | public class InterceptorConfig implements WebMvcConfigurer { 13 | 14 | 15 | @Bean 16 | public LoginInterceptor loginInterceptor(){ 17 | return new LoginInterceptor(); 18 | } 19 | 20 | @Override 21 | public void addInterceptors(InterceptorRegistry registry) { 22 | registry.addInterceptor(loginInterceptor()) 23 | .addPathPatterns("/**") 24 | .excludePathPatterns("/login","/") 25 | .excludePathPatterns("/static/*"); 26 | } 27 | 28 | @Override 29 | public void addResourceHandlers(ResourceHandlerRegistry registry) { 30 | registry.addResourceHandler("/static/**") 31 | .addResourceLocations("classpath:/static/"); 32 | 33 | } 34 | 35 | @Override 36 | public void addCorsMappings(CorsRegistry registry) { 37 | registry.addMapping("/**") 38 | .allowedOrigins("*"); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/configuration/ProxyeeConfig.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.configuration; 2 | 3 | import com.github.monkeywie.proxyee.intercept.HttpProxyIntercept; 4 | import com.github.monkeywie.proxyee.intercept.HttpProxyInterceptInitializer; 5 | import com.github.monkeywie.proxyee.intercept.HttpProxyInterceptPipeline; 6 | import com.github.monkeywie.proxyee.server.HttpProxyServer; 7 | import com.github.monkeywie.proxyee.server.HttpProxyServerConfig; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.context.annotation.Bean; 10 | import org.springframework.context.annotation.Configuration; 11 | import red.fuyun.liberty.proxyee.Auth; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | @Configuration 17 | public class ProxyeeConfig { 18 | 19 | @Bean 20 | public HttpProxyServerConfig serverConfig(Auth auth){ 21 | HttpProxyServerConfig config = new HttpProxyServerConfig(); 22 | config.setHandleSsl(true); 23 | config.setAuthenticationProvider(auth); 24 | return config; 25 | } 26 | 27 | 28 | @Bean 29 | public HttpProxyServer httpProxyServer( List intercepts,HttpProxyServerConfig serverConfig){ 30 | System.out.println(intercepts.size()); 31 | HttpProxyServer httpProxyServer = new HttpProxyServer() 32 | .serverConfig(serverConfig) 33 | .proxyInterceptInitializer(new HttpProxyInterceptInitializer() { 34 | @Override 35 | public void init(HttpProxyInterceptPipeline pipeline) { 36 | intercepts.forEach(intercept -> { 37 | pipeline.addLast(intercept); 38 | }); 39 | 40 | } 41 | }); 42 | 43 | return httpProxyServer; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/controller/UserController.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.controller; 2 | 3 | 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.web.bind.annotation.PostMapping; 6 | import red.fuyun.liberty.annotation.RestControllerResult; 7 | import red.fuyun.liberty.pojo.User; 8 | import red.fuyun.liberty.service.UserService; 9 | 10 | @RestControllerResult 11 | public class UserController { 12 | @Autowired 13 | UserService userService; 14 | 15 | @PostMapping("/login") 16 | public User user(String uname,String pwd){ 17 | User user = userService.queryUser(uname, pwd); 18 | return null; 19 | } 20 | 21 | @PostMapping("/updatepwd") 22 | public User updatePwd(String pwd){ 23 | return null; 24 | } 25 | 26 | 27 | 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/enums/ResultStatus.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.enums; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Getter; 5 | import lombok.ToString; 6 | 7 | @ToString 8 | @Getter 9 | @AllArgsConstructor 10 | public enum ResultStatus { 11 | 12 | SUCCESS(200,"OK"), 13 | ERROR(400,"error"); 14 | private Integer code; 15 | private String message; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/interceptors/LoginInterceptor.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.interceptors; 2 | 3 | import com.auth0.jwt.interfaces.DecodedJWT; 4 | import org.springframework.web.servlet.HandlerInterceptor; 5 | import red.fuyun.liberty.util.JWTUtils; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | 10 | public class LoginInterceptor implements HandlerInterceptor { 11 | @Override 12 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 13 | String token = request.getHeader("token"); 14 | DecodedJWT verify = JWTUtils.verify(token); 15 | return true; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/mapper/LeaveMapper.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import org.springframework.stereotype.Component; 5 | import red.fuyun.liberty.pojo.Leave; 6 | 7 | @Component 8 | public interface LeaveMapper extends BaseMapper { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.mapper; 2 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; 4 | import org.springframework.stereotype.Component; 5 | import red.fuyun.liberty.pojo.User; 6 | 7 | @Component 8 | public interface UserMapper extends BaseMapper { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/pojo/Leave.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.pojo; 2 | 3 | import com.baomidou.mybatisplus.annotation.TableName; 4 | import lombok.Data; 5 | 6 | import java.sql.Timestamp; 7 | 8 | @Data 9 | @TableName("`leave`") 10 | public class Leave { 11 | private Integer id; 12 | private Integer uid; 13 | private Timestamp startTime; 14 | private Timestamp endTime; 15 | 16 | private String leaveReason; 17 | 18 | private String urgencyMobile; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/pojo/ResultVO.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.pojo; 2 | 3 | import red.fuyun.liberty.enums.ResultStatus; 4 | import lombok.Getter; 5 | import lombok.ToString; 6 | 7 | import java.util.Objects; 8 | 9 | @Getter 10 | @ToString 11 | public class ResultVO{ 12 | private Integer code; 13 | private String message; 14 | private T data; 15 | 16 | ResultVO(ResultStatus status, T data){ 17 | this.code = status.getCode(); 18 | this.message = status.getMessage(); 19 | this.data = data; 20 | } 21 | 22 | public static ResultVO success(){ 23 | return new ResultVO(ResultStatus.SUCCESS,null); 24 | } 25 | 26 | public static ResultVO success(T data){ 27 | return new ResultVO(ResultStatus.SUCCESS,data); 28 | } 29 | 30 | public static ResultVO success(ResultStatus status, T data){ 31 | if (Objects.isNull(status)){ 32 | return success(data); 33 | } 34 | return new ResultVO(status,data); 35 | } 36 | 37 | 38 | 39 | public static ResultVO failure(){ 40 | return new ResultVO(ResultStatus.ERROR,null); 41 | } 42 | 43 | public static ResultVO failure(T data){ 44 | return new ResultVO(ResultStatus.ERROR,data); 45 | } 46 | 47 | public static ResultVO failure(ResultStatus status, T data){ 48 | if (Objects.isNull(status)){ 49 | return success(data); 50 | } 51 | return new ResultVO(status,data); 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/pojo/User.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.pojo; 2 | 3 | 4 | import lombok.Data; 5 | 6 | 7 | import javax.validation.constraints.NotNull; 8 | import java.sql.Timestamp; 9 | 10 | 11 | @Data 12 | public class User { 13 | 14 | private Integer id; 15 | 16 | @NotNull(message = "账号不能为空") 17 | private String uname; 18 | 19 | @NotNull(message = "密码不能为空") 20 | private String pwd; 21 | 22 | 23 | private Timestamp createTime; 24 | 25 | private Timestamp lastTime; 26 | 27 | private String studentNo; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/proxyee/Auth.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.proxyee; 2 | 3 | import com.github.monkeywie.proxyee.server.auth.BasicHttpProxyAuthenticationProvider; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.cache.annotation.Cacheable; 6 | import org.springframework.stereotype.Component; 7 | import red.fuyun.liberty.pojo.User; 8 | import red.fuyun.liberty.service.UserService; 9 | 10 | import java.util.Objects; 11 | 12 | @Component 13 | public class Auth extends BasicHttpProxyAuthenticationProvider { 14 | 15 | @Autowired 16 | UserService userService; 17 | 18 | private Integer count = 0; 19 | @Override 20 | protected boolean authenticate(String uname, String pwd) { 21 | 22 | 23 | return true; 24 | } 25 | 26 | @Cacheable 27 | public User queryUser(String uname,String pwd) { 28 | System.out.println("执行方法了----------"); 29 | User user = userService.queryUser(uname, pwd); 30 | return user; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/proxyee/Cell.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.proxyee; 2 | 3 | 4 | @FunctionalInterface 5 | public interface Cell { 6 | 7 | boolean apply(T t,U u,R r,D d); 8 | 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/proxyee/MapppingMthod.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.proxyee; 2 | 3 | import com.alibaba.fastjson.JSONArray; 4 | import com.alibaba.fastjson.JSONObject; 5 | import com.alibaba.fastjson.parser.Feature; 6 | import com.github.monkeywie.proxyee.intercept.HttpProxyInterceptPipeline; 7 | import io.netty.handler.codec.http.FullHttpResponse; 8 | import io.netty.handler.codec.http.HttpHeaders; 9 | import io.netty.handler.codec.http.HttpRequest; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Component; 12 | import red.fuyun.liberty.mapper.LeaveMapper; 13 | import red.fuyun.liberty.pojo.Leave; 14 | import red.fuyun.liberty.pojo.User; 15 | import red.fuyun.liberty.service.LeaveService; 16 | import red.fuyun.liberty.service.UserService; 17 | import red.fuyun.liberty.util.HttpUtil; 18 | 19 | import javax.annotation.PostConstruct; 20 | import java.io.IOException; 21 | import java.nio.charset.Charset; 22 | import java.time.Duration; 23 | import java.time.LocalDateTime; 24 | import java.time.format.DateTimeFormatter; 25 | import java.util.*; 26 | 27 | @Component 28 | public class MapppingMthod { 29 | @Autowired 30 | HttpUtil httpUtil; 31 | 32 | @Autowired 33 | UserService userService; 34 | 35 | 36 | @Autowired 37 | LeaveService leaveService; 38 | 39 | private Map> map = new HashMap<>(); 40 | // System.out.println("处理假条列表"); 41 | // String content = httpResponse.content().toString(Charset.defaultCharset()); 42 | // String con = "{\"code\":\"0\",\"message\":\"success\",\"datas\":{\"totalSize\":5,\"pageSize\":20,\"pageNumber\":1,\"allowApply\":0,\"allowPcApply\":0,\"rows\":[]}}"; 43 | // JSONObject jsonObject = JSONObject.parseObject(con); 44 | // JSONObject data = jsonObject.getJSONObject("datas"); 45 | // JSONArray rows = data.getJSONArray("rows"); 46 | // JSONObject row = JSONObject.parseObject("{\"id\":\"3659a5b6515f4efbb9c1780777b69668\",\"leaveType\":\"事假\",\"createTime\":\"03-08 15:35\",\"startTime\":\"03-13 00:00\",\"endTime\":\"03-13 22:34\",\"totalDay\":1,\"status\":\"6\",\"expireDay\":null,\"isExtend\":\"0\",\"applyTime\":\"03-08 15:35\",\"out\":\"1\",\"leaveTime\":\"22小时34分钟\",\"startTimePC\":\"03-13 00:00\",\"endTimePC\":\"03-13 22:34\",\"leaveReason\":\"周六教师资格证考试。\",\"shutDown\":false,\"actEndTime\":\"03-13 22:34\",\"actEndTimeDesc\":\"22小时34分钟\",\"actStatus\":\"6\",\"isEarlyEnd\":\"0\"}"); 47 | // rows.add(row); 48 | // LocalDateTime now = LocalDateTime.now(); 49 | // LocalDateTime startTime = now.minusHours(1); 50 | // LocalDateTime endTime = now.plusHours(6); 51 | // DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-dd HH:mm"); 52 | // row.put("startTime",startTime.format(dateTimeFormatter)); 53 | // row.put("endTime",endTime.format(dateTimeFormatter)); 54 | // httpResponse.content().clear(); 55 | // httpResponse.headers().set("Content-Type","application/json;charset=UTF-8"); 56 | // System.out.println(jsonObject.toJSONString()); 57 | // httpResponse.content().writeBytes(jsonObject.toString().getBytes()); 58 | // return true; 59 | // 60 | @PostConstruct 61 | private void init(){ 62 | map.put("/wec-counselor-leave-apps/leave/stu/list", (httpRequest, httpResponse, httpProxyIntercepts,leave) -> { 63 | System.out.println("处理假条列表"); 64 | String content = httpResponse.content().toString(Charset.defaultCharset()); 65 | System.out.println(content); 66 | JSONObject jsonObject = JSONObject.parseObject(content); 67 | JSONObject datas = jsonObject.getJSONObject("datas"); 68 | Integer totalSize = datas.getInteger("totalSize"); 69 | if (totalSize<=0){ 70 | return false; 71 | } 72 | JSONArray rows = datas.getJSONArray("rows"); 73 | JSONObject row = rows.getJSONObject(0); 74 | rows.clear(); 75 | rows.add(row); 76 | LocalDateTime now = LocalDateTime.now(); 77 | LocalDateTime startTime = leave.getStartTime().toLocalDateTime(); 78 | LocalDateTime endTime = leave.getEndTime().toLocalDateTime(); 79 | boolean after = endTime.isAfter(now); 80 | if (!after){ 81 | startTime = LocalDateTime.of(now.toLocalDate(),startTime.toLocalTime()); 82 | endTime = LocalDateTime.of(now.toLocalDate(),endTime.toLocalTime()); 83 | } 84 | 85 | Duration duration = Duration.between(startTime,endTime); 86 | long hours = duration.toHours();//相差的小时数 87 | long minutes = duration.toMinutes()-hours*60;//相差的分钟数 88 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-dd HH:mm"); 89 | row.put("startTime",startTime.format(dateTimeFormatter)); 90 | row.put("endTime",endTime.format(dateTimeFormatter)); 91 | row.put("status",6); 92 | row.put("actStatus",6); 93 | row.put("leaveTime",String.format("%d小时%d分钟",hours,minutes)); 94 | httpResponse.content().clear(); 95 | httpResponse.headers().set("Content-Type","application/json;charset=UTF-8"); 96 | System.out.println(jsonObject.toJSONString()); 97 | httpResponse.content().writeBytes(jsonObject.toString().getBytes()); 98 | return true; 99 | }); 100 | 101 | map.put("/wec-counselor-leave-apps/leave/stu/detail",(httpRequest, httpResponse, httpProxyIntercepts,leave) -> { 102 | 103 | System.out.println("处理假条详情"); 104 | String content = httpResponse.content().toString(Charset.defaultCharset()); 105 | JSONObject jsonObject = JSONObject.parseObject(content, Feature.OrderedField); 106 | JSONObject datas = jsonObject.getJSONObject("datas"); 107 | JSONObject termination = datas.getJSONObject("termination"); 108 | termination.put("terminationObjectName",null); 109 | termination.put("terminationReason",null); 110 | termination.put("terminationDate",null); 111 | 112 | JSONObject condition = datas.getJSONObject("condition"); 113 | condition.put("reportTutorialUrl","http://catqa.cpdaily.com/2018/10/24/如何销假?/"); 114 | condition.put("reportTutorialTitle","如何销假?"); 115 | datas.put("recordStatus",6); 116 | datas.put("isAllowedExtend",true); 117 | datas.put("isReport","1"); 118 | datas.put("isExtend","1"); 119 | 120 | JSONObject detail = datas.getJSONObject("detail"); 121 | LocalDateTime now = LocalDateTime.now(); 122 | LocalDateTime startTime = leave.getStartTime().toLocalDateTime(); 123 | LocalDateTime endTime = leave.getEndTime().toLocalDateTime(); 124 | 125 | boolean after = endTime.isAfter(now); 126 | if (!after){ 127 | startTime = LocalDateTime.of(now.toLocalDate(),startTime.toLocalTime()); 128 | endTime = LocalDateTime.of(now.toLocalDate(),endTime.toLocalTime()); 129 | } 130 | 131 | Random rand = new Random(); 132 | LocalDateTime applyTime = startTime.minusDays(1).plusMinutes(rand.nextInt(25)+1); 133 | 134 | DateTimeFormatter time = DateTimeFormatter.ofPattern("MM-dd HH:mm"); 135 | DateTimeFormatter date = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); 136 | Duration duration = Duration.between(startTime,endTime); 137 | long hours = duration.toHours();//相差的小时数 138 | long minutes = duration.toMinutes()-hours*60;//相差的分钟数 139 | JSONArray approvers = detail.getJSONArray("approvers"); 140 | JSONArray applyAttach = detail.getJSONArray("applyAttach"); 141 | applyAttach.clear(); 142 | Iterator iterator = approvers.iterator(); 143 | 144 | while (iterator.hasNext()){ 145 | JSONObject next = (JSONObject)iterator.next(); 146 | if (next.getInteger("status").equals(5)){ 147 | iterator.remove(); 148 | } 149 | next.put("createTime",applyTime.format(time)); 150 | next.put("approveOption",""); 151 | 152 | applyTime = applyTime.plusHours(rand.nextInt(2)+1).plusMinutes(rand.nextInt(50)+1); 153 | } 154 | 155 | JSONArray logInfos = detail.getJSONArray("logInfos"); 156 | Iterator logit = logInfos.iterator(); 157 | while (logit.hasNext()){ 158 | JSONObject next = (JSONObject)logit.next(); 159 | if (next.getInteger("status").equals(5)){ 160 | logit.remove(); 161 | } 162 | 163 | } 164 | detail.put("startTime",startTime.format(time)); 165 | detail.put("endTime",endTime.format(time)); 166 | detail.put("startDate",startTime.format(date)); 167 | detail.put("endDate",endTime.format(date)); 168 | detail.put("status",2); 169 | detail.put("actStatus",6); 170 | detail.put("dstStatus",6); 171 | detail.put("isEarlyEnd",0); 172 | detail.put("urgencyMobile",leave.getUrgencyMobile()); 173 | detail.put("leaveReason",leave.getLeaveReason()); 174 | detail.put("totalDays",String.format("%d小时%d分钟",hours,minutes)); 175 | datas.put("nowTime",LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); 176 | 177 | httpResponse.content().clear(); 178 | httpResponse.headers().set("Content-Type","application/json;charset=UTF-8"); 179 | System.out.println(jsonObject.toJSONString()); 180 | httpResponse.content().writeBytes(jsonObject.toString().getBytes()); 181 | System.out.println(content); 182 | return true; 183 | }); 184 | 185 | 186 | } 187 | public CellWarpper get(String key){ 188 | Cell cell = map.get(key); 189 | CellWarpper cellWarpper = new CellWarpper(cell); 190 | return cellWarpper; 191 | } 192 | 193 | class CellWarpper { 194 | private Cell cell; 195 | CellWarpper(Cell cell){ 196 | this.cell = cell; 197 | } 198 | 199 | protected Leave before(HttpRequest httpRequest) throws IOException { 200 | HttpHeaders headers = httpRequest.headers(); 201 | String uri = "/wec-counselor-leave-apps/leave/stu/getStuBasicInfo"; 202 | String origin = headers.get("Origin"); 203 | String url = origin+uri; 204 | String cookie = headers.get("Cookie"); 205 | String contentType = headers.get("Content-Type"); 206 | Map map = new HashMap<>(); 207 | map.put("origin",origin); 208 | map.put("cookie",cookie); 209 | JSONObject jsonObject = httpUtil.postJson(url, new JSONObject(), map); 210 | JSONObject datas = jsonObject.getJSONObject("datas"); 211 | String userId = datas.getString("userId"); 212 | User user = userService.queryStudentNo(userId); 213 | if (Objects.isNull(user)){ 214 | return null; 215 | } 216 | Leave leave = leaveService.queryByUId(user.getId()); 217 | 218 | return leave; 219 | } 220 | 221 | protected void after(){ 222 | 223 | } 224 | 225 | public boolean apply(HttpRequest httpRequest, FullHttpResponse fullHttpResponse, HttpProxyInterceptPipeline httpProxyIntercepts) throws IOException { 226 | Leave leave = before(httpRequest); 227 | if (Objects.isNull(leave)){ 228 | return false; 229 | } 230 | return cell.apply(httpRequest, fullHttpResponse, httpProxyIntercepts,leave); 231 | } 232 | 233 | } 234 | 235 | 236 | 237 | public boolean container(String key){ 238 | return map.containsKey(key); 239 | } 240 | // yyyy-MM-dd HH:mm:ss 241 | public static void main(String[] args) { 242 | LocalDateTime now = LocalDateTime.now(); 243 | LocalDateTime startTime = now.minusHours(1); 244 | LocalDateTime endTime = now.plusHours(6); 245 | DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MM-dd HH:mm"); 246 | 247 | System.out.println(now); 248 | System.out.println(startTime.format(dateTimeFormatter)); 249 | System.out.println(endTime.format(dateTimeFormatter)); 250 | 251 | } 252 | } 253 | 254 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/proxyee/MyRequestIntercept.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.proxyee; 2 | 3 | import com.github.monkeywie.proxyee.intercept.HttpProxyInterceptPipeline; 4 | import com.github.monkeywie.proxyee.intercept.common.FullRequestIntercept; 5 | import io.netty.handler.codec.http.FullHttpRequest; 6 | import io.netty.handler.codec.http.HttpRequest; 7 | import org.springframework.stereotype.Component; 8 | 9 | //@Component 10 | public class MyRequestIntercept extends FullRequestIntercept { 11 | @Override 12 | public boolean match(HttpRequest httpRequest, HttpProxyInterceptPipeline pipeline) { 13 | String uri = httpRequest.uri(); 14 | return false; 15 | } 16 | 17 | @Override 18 | public void handleRequest(FullHttpRequest httpRequest, HttpProxyInterceptPipeline pipeline) { 19 | System.out.println("httpRequest"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/proxyee/MyResponseIntercept.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.proxyee; 2 | 3 | import com.github.monkeywie.proxyee.intercept.HttpProxyInterceptPipeline; 4 | import com.github.monkeywie.proxyee.intercept.common.FullResponseIntercept; 5 | import com.github.monkeywie.proxyee.server.auth.BasicHttpProxyAuthenticationProvider; 6 | import io.netty.handler.codec.http.FullHttpRequest; 7 | import io.netty.handler.codec.http.FullHttpResponse; 8 | import io.netty.handler.codec.http.HttpRequest; 9 | import io.netty.handler.codec.http.HttpResponse; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.stereotype.Component; 12 | 13 | import java.io.IOException; 14 | import java.nio.charset.Charset; 15 | import java.util.Map; 16 | import java.util.Objects; 17 | 18 | 19 | @Component 20 | public class MyResponseIntercept extends FullResponseIntercept { 21 | 22 | @Autowired 23 | private MapppingMthod mapppingMthod; 24 | 25 | @Override 26 | public boolean match(HttpRequest httpRequest, HttpResponse httpResponse, HttpProxyInterceptPipeline pipeline) { 27 | String uri = httpRequest.uri(); 28 | return mapppingMthod.container(uri); 29 | } 30 | 31 | @Override 32 | public void handleResponse(HttpRequest httpRequest, FullHttpResponse httpResponse, HttpProxyInterceptPipeline pipeline) { 33 | System.out.println("进入handleResponse"); 34 | try { 35 | process(httpRequest, httpResponse, pipeline); 36 | }catch (Exception e){ 37 | e.printStackTrace(); 38 | } 39 | } 40 | 41 | 42 | public boolean process(HttpRequest httpRequest, FullHttpResponse httpResponse, HttpProxyInterceptPipeline pipeline) throws IOException { 43 | String uri = httpRequest.uri(); 44 | MapppingMthod.CellWarpper cell = mapppingMthod.get(uri); 45 | if (Objects.nonNull(cell)){ 46 | System.out.println(uri); 47 | boolean apply = cell.apply(httpRequest, httpResponse, pipeline); 48 | System.out.println(apply); 49 | return apply; 50 | } 51 | return false; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/service/LeaveService.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.service; 2 | 3 | 4 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | import red.fuyun.liberty.mapper.LeaveMapper; 8 | import red.fuyun.liberty.pojo.Leave; 9 | 10 | @Service 11 | public class LeaveService { 12 | 13 | @Autowired 14 | LeaveMapper leaveMapper; 15 | 16 | public Leave queryByUId(Integer uid){ 17 | QueryWrapper leaveQueryWrapper = new QueryWrapper<>(); 18 | leaveQueryWrapper.eq("uid",uid); 19 | Leave leave = leaveMapper.selectOne(leaveQueryWrapper); 20 | return leave; 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/service/UserService.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.service; 2 | 3 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | import red.fuyun.liberty.mapper.UserMapper; 7 | import red.fuyun.liberty.pojo.User; 8 | 9 | @Service 10 | public class UserService { 11 | 12 | @Autowired 13 | private UserMapper userMapper; 14 | 15 | public User queryUser(String uname,String pwd){ 16 | QueryWrapper userQueryWrapper = new QueryWrapper<>(); 17 | userQueryWrapper.eq("uname",uname); 18 | userQueryWrapper.eq("pwd",pwd); 19 | User user = userMapper.selectOne(userQueryWrapper); 20 | return user; 21 | } 22 | 23 | public User queryStudentNo(String studentNo){ 24 | QueryWrapper queryWrapper = new QueryWrapper(); 25 | queryWrapper.eq("student_no",studentNo); 26 | User user = userMapper.selectOne(queryWrapper); 27 | return user; 28 | } 29 | 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/util/ApiException.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.util; 2 | 3 | import lombok.Getter; 4 | 5 | @Getter 6 | public class ApiException extends RuntimeException { 7 | private int code; 8 | private String msg; 9 | 10 | public ApiException() { 11 | this(1001, "接口错误"); 12 | } 13 | 14 | public ApiException(String msg) { 15 | this(1001, msg); 16 | } 17 | 18 | public ApiException(int code, String msg) { 19 | super(msg); 20 | this.code = code; 21 | this.msg = msg; 22 | } 23 | } -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/util/HttpUtil.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.util; 2 | 3 | import com.alibaba.fastjson.JSONObject; 4 | import okhttp3.*; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.io.IOException; 9 | import java.util.Map; 10 | 11 | @Component 12 | public class HttpUtil { 13 | 14 | @Autowired 15 | OkHttpClient okHttpClient; 16 | 17 | 18 | public JSONObject postJson(String url,JSONObject body, Map headers) throws IOException { 19 | RequestBody requestBody = RequestBody.create(MediaType.parse("application/json;charset=UTF-8"), body.toString()); 20 | 21 | Request request = new Request.Builder(). 22 | url(url) 23 | .post(requestBody) 24 | .headers(Headers.of(headers)) 25 | .build(); 26 | 27 | Call call = okHttpClient.newCall(request); 28 | Response execute = call.execute(); 29 | String respBody = execute.body().string(); 30 | execute.close(); 31 | return JSONObject.parseObject(respBody); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/red/fuyun/liberty/util/JWTUtils.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty.util; 2 | 3 | import com.auth0.jwt.JWT; 4 | import com.auth0.jwt.JWTCreator; 5 | import com.auth0.jwt.algorithms.Algorithm; 6 | import com.auth0.jwt.interfaces.DecodedJWT; 7 | 8 | import java.util.Calendar; 9 | import java.util.Map; 10 | 11 | 12 | public class JWTUtils { 13 | //密钥 14 | private static String SECRET = "@$&$0@@A"; 15 | //token有效期 16 | private static int TIME_OUT = 1; 17 | /** 18 | * 生产token 19 | */ 20 | public static String getToken(Map map) { 21 | JWTCreator.Builder builder = JWT.create(); 22 | 23 | //payload 24 | map.forEach((k, v) -> { 25 | builder.withClaim(k, v); 26 | }); 27 | 28 | Calendar instance = Calendar.getInstance(); 29 | instance.add(Calendar.HOUR, TIME_OUT); //默认1小时过期 30 | 31 | builder.withExpiresAt(instance.getTime());//指定令牌的过期时间 32 | String token = builder.sign(Algorithm.HMAC256(SECRET));//签名 33 | return token; 34 | } 35 | 36 | /** 37 | * 验证token 38 | */ 39 | public static DecodedJWT verify(String token) { 40 | //如果有任何验证异常,此处都会抛出异常 41 | DecodedJWT decodedJWT = JWT.require(Algorithm.HMAC256(SECRET)).build().verify(token); 42 | return decodedJWT; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8889 3 | 4 | mybatis-plus: 5 | configuration: 6 | log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 7 | 8 | spring: 9 | cache: 10 | type: ehcache 11 | ehcache: 12 | config: classpath:ehcache.xml 13 | 14 | datasource: 15 | # 数据源基本配置 16 | username: root 17 | password: ccnl13145 18 | driver-class-name: com.mysql.cj.jdbc.Driver 19 | url: jdbc:mysql://localhost:3306/liberty?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=true 20 | 21 | #自定义数据源,springboot2.0否则默认使用hikari.HikariDataSource 22 | type: com.alibaba.druid.pool.DruidDataSource 23 | 24 | # 数据源其他配置 25 | initialSize: 5 26 | minIdle: 5 27 | maxActive: 20 28 | maxWait: 60000 29 | timeBetweenEvictionRunsMillis: 60000 30 | minEvictableIdleTimeMillis: 300000 31 | validationQuery: SELECT 1 FROM DUAL 32 | testWhileIdle: true 33 | testOnBorrow: false 34 | testOnReturn: false 35 | poolPreparedStatements: true 36 | # 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙 37 | filters: stat,wall,log4j 38 | maxPoolPreparedStatementPerConnectionSize: 20 39 | useGlobalDataSourceStat: true 40 | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500 -------------------------------------------------------------------------------- /src/main/resources/ehcache.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 16 | 27 | 29 | 30 | 32 | 33 | -------------------------------------------------------------------------------- /src/test/java/red/fuyun/liberty/HelpcatsApplicationTests.java: -------------------------------------------------------------------------------- 1 | package red.fuyun.liberty; 2 | 3 | 4 | 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.boot.test.context.SpringBootTest; 8 | 9 | 10 | import red.fuyun.liberty.mapper.UserMapper; 11 | import red.fuyun.liberty.pojo.User; 12 | 13 | import java.util.List; 14 | 15 | @SpringBootTest 16 | class HelpcatsApplicationTests { 17 | 18 | @Autowired 19 | private UserMapper userMapper; 20 | 21 | @Test 22 | void contextLoads() { 23 | System.out.println(("----- selectAll method test ------")); 24 | List userList = userMapper.selectList(null); 25 | 26 | userList.forEach(System.out::println); 27 | } 28 | 29 | } 30 | --------------------------------------------------------------------------------