Commit 489cb811 by 涂亚平

start...

1 parent 58955cd3
Showing with 4334 additions and 0 deletions
2024-07-23 13:57:02,964 [main] INFO org.springframework.data.repository.config.RepositoryConfigurationDelegate:244 - Multiple Spring Data modules found, entering strict repository configuration mode!
2024-07-23 13:57:02,972 [main] INFO org.springframework.data.repository.config.RepositoryConfigurationDelegate:126 - Bootstrapping Spring Data repositories in DEFAULT mode.
2024-07-23 13:57:03,011 [main] INFO org.springframework.data.repository.config.RepositoryConfigurationDelegate:182 - Finished Spring Data repository scanning in 24ms. Found 0 repository interfaces.
2024-07-23 13:57:03,347 [main] INFO org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker:330 - Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$8be5f5a8] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-07-23 13:57:03,432 [main] INFO org.springframework.context.support.PostProcessorRegistrationDelegate$BeanPostProcessorChecker:330 - Bean 'redisConfig' of type [com.subsidy.common.configure.RedisConfig$$EnhancerBySpringCGLIB$$8bae00af] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2024-07-23 13:57:03,775 [main] INFO org.springframework.boot.web.embedded.tomcat.TomcatWebServer:90 - Tomcat initialized with port(s): 23507 (http)
2024-07-23 13:57:03,788 [main] INFO org.apache.coyote.http11.Http11NioProtocol:173 - Initializing ProtocolHandler ["http-nio-23507"]
2024-07-23 13:57:03,794 [main] INFO org.apache.catalina.core.StandardService:173 - Starting service [Tomcat]
2024-07-23 13:57:03,794 [main] INFO org.apache.catalina.core.StandardEngine:173 - Starting Servlet engine: [Apache Tomcat/9.0.22]
2024-07-23 13:57:03,800 [main] INFO org.apache.catalina.core.AprLifecycleListener:173 - Loaded APR based Apache Tomcat Native library [1.2.37] using APR version [1.7.4].
2024-07-23 13:57:03,801 [main] INFO org.apache.catalina.core.AprLifecycleListener:173 - APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2024-07-23 13:57:03,801 [main] INFO org.apache.catalina.core.AprLifecycleListener:173 - APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2024-07-23 13:57:03,812 [main] INFO org.apache.catalina.core.AprLifecycleListener:173 - OpenSSL successfully initialized [OpenSSL 1.1.1u 30 May 2023]
2024-07-23 13:57:03,918 [main] INFO org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/]:173 - Initializing Spring embedded WebApplicationContext
2024-07-23 13:57:03,919 [main] INFO org.springframework.web.context.ContextLoader:284 - Root WebApplicationContext: initialization completed in 1842 ms
2024-07-23 13:57:04,015 [main] INFO com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure:56 - Init DruidDataSource
2024-07-23 13:57:05,131 [main] INFO com.alibaba.druid.pool.DruidDataSource:994 - {dataSource-1} inited
2024-07-23 13:57:05,829 [main] INFO org.quartz.impl.StdSchedulerFactory:1208 - Using default implementation for ThreadExecutor
2024-07-23 13:57:05,838 [main] INFO org.quartz.core.SchedulerSignalerImpl:61 - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl
2024-07-23 13:57:05,838 [main] INFO org.quartz.core.QuartzScheduler:229 - Quartz Scheduler v.2.3.1 created.
2024-07-23 13:57:05,842 [main] INFO org.springframework.scheduling.quartz.LocalDataSourceJobStore:672 - Using db table-based data access locking (synchronization).
2024-07-23 13:57:05,843 [main] INFO org.springframework.scheduling.quartz.LocalDataSourceJobStore:145 - JobStoreCMT initialized.
2024-07-23 13:57:05,844 [main] INFO org.quartz.core.QuartzScheduler:294 - Scheduler meta-data: Quartz Scheduler (v2.3.1) 'schedulerFactoryBean' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
Using job-store 'org.springframework.scheduling.quartz.LocalDataSourceJobStore' - which supports persistence. and is not clustered.
2024-07-23 13:57:05,844 [main] INFO org.quartz.impl.StdSchedulerFactory:1362 - Quartz scheduler 'schedulerFactoryBean' initialized from an externally provided properties instance.
2024-07-23 13:57:05,844 [main] INFO org.quartz.impl.StdSchedulerFactory:1366 - Quartz scheduler version: 2.3.1
2024-07-23 13:57:05,845 [main] INFO org.quartz.core.QuartzScheduler:2293 - JobFactory set to: com.subsidy.common.configure.JobFactory@2c668c2a
2024-07-23 13:57:06,480 [main] INFO springfox.documentation.spring.web.PropertySourcedRequestMappingHandlerMapping:69 - Mapped URL path [/v2/api-docs] onto method [public org.springframework.http.ResponseEntity<springfox.documentation.spring.web.json.Json> springfox.documentation.swagger2.web.Swagger2Controller.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest)]
2024-07-23 13:57:06,663 [main] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor:171 - Initializing ExecutorService 'applicationTaskExecutor'
2024-07-23 13:57:07,209 [main] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler:171 - Initializing ExecutorService 'taskScheduler'
2024-07-23 13:57:07,267 [main] INFO springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper:160 - Context refreshed
2024-07-23 13:57:07,284 [main] INFO springfox.documentation.spring.web.plugins.DocumentationPluginsBootstrapper:163 - Found 1 custom documentation plugin(s)
2024-07-23 13:57:07,456 [main] INFO springfox.documentation.spring.web.scanners.ApiListingReferenceScanner:41 - Scanning for api listing references
2024-07-23 13:57:07,586 [main] INFO org.springframework.scheduling.quartz.SchedulerFactoryBean:731 - Will start Quartz Scheduler [schedulerFactoryBean] in 1 seconds
2024-07-23 13:57:07,596 [main] INFO org.apache.coyote.http11.Http11NioProtocol:173 - Starting ProtocolHandler ["http-nio-23507"]
2024-07-23 13:57:07,615 [main] INFO org.springframework.boot.web.embedded.tomcat.TomcatWebServer:202 - Tomcat started on port(s): 23507 (http) with context path ''
2024-07-23 13:57:08,600 [Quartz Scheduler [schedulerFactoryBean]] INFO org.springframework.scheduling.quartz.SchedulerFactoryBean:747 - Starting Quartz Scheduler now, after delay of 1 seconds
2024-07-23 13:58:55,730 [Thread-15] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler:208 - Shutting down ExecutorService 'taskScheduler'
2024-07-23 13:58:55,735 [Thread-15] INFO org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor:208 - Shutting down ExecutorService 'applicationTaskExecutor'
2024-07-23 13:58:55,749 [Thread-15] INFO org.quartz.core.QuartzScheduler:666 - Scheduler schedulerFactoryBean_$_NON_CLUSTERED shutting down.
2024-07-23 13:58:55,749 [Thread-15] INFO org.quartz.core.QuartzScheduler:585 - Scheduler schedulerFactoryBean_$_NON_CLUSTERED paused.
2024-07-23 13:58:55,749 [Thread-15] INFO org.quartz.core.QuartzScheduler:740 - Scheduler schedulerFactoryBean_$_NON_CLUSTERED shutdown complete.
2024-07-23 13:58:55,749 [Thread-15] INFO org.springframework.scheduling.quartz.SchedulerFactoryBean:844 - Shutting down Quartz Scheduler
2024-07-23 13:58:55,750 [Thread-15] INFO com.alibaba.druid.pool.DruidDataSource:2029 - {dataSource-1} closing ...
2024-07-23 13:58:55,751 [Thread-15] INFO com.alibaba.druid.pool.DruidDataSource:2101 - {dataSource-1} closed
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.subsidy</groupId>
<artifactId>subsidy</artifactId>
<version>0.0.1</version>
<name>subsidy</name>
<description>Demo project for Spring Boot</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<java.version>1.8</java.version>
<mybatis-plus.version>3.3.0</mybatis-plus.version>
<generator.version>3.3.2</generator.version>
<swagger2.version>2.9.2</swagger2.version>
<fastjson.version>1.2.58</fastjson.version>
<jhash.version>2.0.0</jhash.version>
<poi-ooxml.version>3.13</poi-ooxml.version>
<dysmsapi.version>1.1.0</dysmsapi.version>
<sdk-core.version>4.4.6</sdk-core.version>
<lang3.version>3.9</lang3.version>
<druid.version>1.1.22</druid.version>
<itext-asian.version>5.2.0</itext-asian.version>
<itextpdf.version>5.4.1</itextpdf.version>
<java-jwt.version>3.10.3</java-jwt.version>
<jedis.version>3.3.0</jedis.version>
<collections.version>3.2.2</collections.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>com.belerweb</groupId>
<artifactId>pinyin4j</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>com.tencentcloudapi</groupId>
<artifactId>tencentcloud-sdk-java</artifactId>
<version>3.1.322</version>
</dependency>
<dependency>
<groupId>com.qcloud</groupId>
<artifactId>vod_api</artifactId>
<version>2.1.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<!-- <optional>true</optional>-->
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>${generator.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger2.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.amdelamar</groupId>-->
<!-- <artifactId>jhash</artifactId>-->
<!-- <version>${jhash.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi-ooxml.version}</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-dysmsapi</artifactId>
<version>${dysmsapi.version}</version>
</dependency>
<dependency>
<groupId>com.aliyun</groupId>
<artifactId>aliyun-java-sdk-core</artifactId>
<version>${sdk-core.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${lang3.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-asian</artifactId>
<version>${itext-asian.version}</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>${itextpdf.version}</version>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>${java-jwt.version}</version>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.scilab.forge</groupId>
<artifactId>jlatexmath</artifactId>
<version>1.0.7</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>${jedis.version}</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${collections.version}</version>
</dependency>
<!--webSocket-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.5.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<dependency>
<groupId>net.polyv</groupId>
<artifactId>polyv-java-live-sdk</artifactId>
<version>2.0.4</version>
</dependency>
<!-- 阿里云 对象存储oss -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.15.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.10.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>1.13.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
</dependencies>
<build>
<finalName>subsidy-interShip</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.2.6.RELEASE</version>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
package com.subsidy;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication
@MapperScan(basePackages = {"com.subsidy.mapper"})
@EnableScheduling
//@EnableCaching
@EnableAsync
@EnableTransactionManagement
public class MeishuApplication {
public static void main(String[] args) {
SpringApplication.run(MeishuApplication.class, args);
}
//@Bean
//public ServletRegistrationBean druidStatViewServlet() {
// //先配置管理后台的servLet,访问的入口为/druid/
// ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(
// new StatViewServlet(), "/druid/*");
// // IP白名单 (没有配置或者为空,则允许所有访问)
// servletRegistrationBean.addInitParameter("allow", "127.0.0.1");
// // IP黑名单 (存在共同时,deny优先于allow)
// servletRegistrationBean.addInitParameter("deny", "");
// servletRegistrationBean.addInitParameter("loginUsername", "admin");
// servletRegistrationBean.addInitParameter("loginPassword", "yhkl1234");
// servletRegistrationBean.addInitParameter("resetEnable", "false");
// return servletRegistrationBean;
//}
}
package com.subsidy.common;
public class RedisPrefixConstant {
/**
* subsidyAdminister_accountName:AdministerDO 老师账号密码
*/
public static final String SUBSIDY_ADMINISTER_PREFIX = "subsidyAdminister:";
/**
* subsidyMember_companyId_accountName:MemberDO 学员账号密码
*/
public static final String SUBSIDY_COMPANY_MEMBER_PREFIX = "subsidyMember:";
///**
// *subsidy_memberLogin_memberId_userName_companyName_now : 学员端审计记录
// */
//public static final String SUBSIDY_MEMBER_LOGIN_PREFIX = "subsidy:memberLogin:";
/**
* subsidySmsCode_telephone:code 手机验证码
*/
public static final String SUBSIDY_TELEPHONE_PREFIX = "subsidySmsCode:";
/**
* subsidySettings:companyId:ClassHourDictDO 公司操作设置
*/
public static final String SUBSIDY_SETTINGS_PREFIX = "subsidySettings:";
/**
* subsidySignInfo:memberId:1:classId:12:20211223:long,do 学生签到数据
*/
public static final String SUBSIDY_SIGN_INFO_PREFIX = "subsidySignInfo:memberId:";
}
package com.subsidy.common;
import com.subsidy.common.configure.RemoteProperties;
import lombok.Data;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
/**
* 返回数据
*
* @author DengMin
* @date 2019/08/27 13:57
**/
@Data
@EnableConfigurationProperties(RemoteProperties.class)
public class ResponseData {
public static <T> ResponseVO<T> generateCreatedResponse(int code) {
return (ResponseVO<T>) ResponseVO.builder()
.code(code)
.message(RemoteProperties.getMessage(code))
.build();
}
public static <T> ResponseVO<T> generateCreatedResponse(int code, String message) {
return (ResponseVO<T>) ResponseVO.builder()
.code(code)
.message(message)
.build();
}
public static <T> ResponseVO<T> generateCreatedResponse(int code, T data) {
return (ResponseVO<T>) ResponseVO.builder()
.code(code)
.message(RemoteProperties.getMessage(code))
.data(data)
.build();
}
public static <T> ResponseVO<T> generateCreatedResponse(int code, String message, T data) {
return (ResponseVO<T>) ResponseVO.builder()
.code(code)
.message(message)
.data(data)
.build();
}
public static <T> ResponseVO<T> generateCreatedResponse(int code, String message, String path) {
return (ResponseVO<T>) ResponseVO.builder()
.code(code)
.message(message)
.path(path)
.build();
}
}
\ No newline at end of file
package com.subsidy.common;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class ResponseVO<T> {
private Integer code;
private String message;
private T data;
private String path;
}
\ No newline at end of file
package com.subsidy.common.configure;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties(prefix = "sms")
public class AliyunSmsProperties {
private String product;
private String domain;
private String accessKeyId;
private String accessKeySecret;
}
package com.subsidy.common.configure;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.scheduling.quartz.AdaptableJobFactory;
import org.springframework.stereotype.Component;
/**
* <p>
* JobFactory实例
* </p>
*
* @author DengMin
* @since 2020/12/9
*/
@Component
public class JobFactory extends AdaptableJobFactory {
private AutowireCapableBeanFactory factory;
public JobFactory(AutowireCapableBeanFactory factory) {
this.factory = factory;
}
@Override
protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
Object job = super.createJobInstance(bundle);
factory.autowireBean(job);
return job;
}
}
package com.subsidy.common.configure;
import org.apache.catalina.connector.Connector;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.servlet.MultipartConfigElement;
@Configuration
public class MyTomcat {
@Value("${spring.server.port}")
private String port;
@Value("${spring.server.acceptorThreadCount}")
private String acceptorThreadCount;
@Value("${spring.server.minSpareThreads}")
private String minSpareThreads;
@Value("${spring.server.maxSpareThreads}")
private String maxSpareThreads;
@Value("${spring.server.maxThreads}")
private String maxThreads;
@Value("${spring.server.maxConnections}")
private String maxConnections;
@Value("${spring.server.protocol}")
private String protocol;
@Value("${spring.server.redirectPort}")
private String redirectPort;
@Value("${spring.server.compression}")
private String compression;
@Value("${spring.server.connectionTimeout}")
private String connectionTimeout;
@Value("${spring.server.MaxFileSize}")
private String MaxFileSize;
@Value("${spring.server.MaxRequestSize}")
private String MaxRequestSize;
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory();
tomcat.addConnectorCustomizers(new GwsTomcatConnectionCustomizer());
return tomcat;
}
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
// 单个数据大小
factory.setMaxFileSize(MaxFileSize); // KB,MB
/// 总上传数据大小
factory.setMaxRequestSize(MaxRequestSize);
return factory.createMultipartConfig();
}
/**
*
* 默认http连接
*
* @version
* @author liuyi 2016年7月20日 下午7:59:41
*
*/
public class GwsTomcatConnectionCustomizer implements TomcatConnectorCustomizer {
public GwsTomcatConnectionCustomizer() {
}
@Override
public void customize(Connector connector) {
connector.setPort(Integer.valueOf(port));
connector.setAttribute("connectionTimeout", connectionTimeout);
connector.setAttribute("acceptorThreadCount", acceptorThreadCount);
connector.setAttribute("minSpareThreads", minSpareThreads);
connector.setAttribute("maxSpareThreads", maxSpareThreads);
connector.setAttribute("maxThreads", maxThreads);
connector.setAttribute("maxConnections", maxConnections);
connector.setAttribute("protocol", protocol);
connector.setAttribute("redirectPort", "redirectPort");
connector.setAttribute("compression", "compression");
}
}
}
package com.subsidy.common.configure;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.subsidy.common.handler.MetaHandler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author: tuyp
* @create: 2020-08-12 12:01
*/
@Configuration
@ConditionalOnClass(value = {PaginationInterceptor.class})
public class MybatisPlusConfig {
/**
* 分页
* @return
*/
@Bean
public PaginationInterceptor paginationInterceptor(){
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
paginationInterceptor.setDialectType(DbType.MYSQL.getDb());
return paginationInterceptor;
}
//
// /**
// * 打印 sql
// */
// @Bean
// public PerformanceInterceptor performanceInterceptor() {
// PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
// //格式化sql语句
// Properties properties = new Properties();
// properties.setProperty("format", "false");
// performanceInterceptor.setProperties(properties);
// return performanceInterceptor;
// }
/**
* 自动填充功能
* @return
*/
@Bean
public GlobalConfig globalConfig() {
GlobalConfig globalConfig = new GlobalConfig();
globalConfig.setMetaObjectHandler(new MetaHandler());
return globalConfig;
}
}
package com.subsidy.common.configure;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@Data
@ConfigurationProperties(prefix = "polyv")
public class PolyvConfig {
private String userId;
private String appId;
private String appSecret;
private String secretKey;
}
package com.subsidy.common.configure;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "qxueyou")
public class QXueYouConfig {
private String appId;
private String securityKey;
private String url;
}
package com.subsidy.common.configure;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import javax.sql.DataSource;
/**
* <p>
* Quartz配置
* </p>
*
* @author DengMin
* @since 2020/12/8
*/
@Configuration
public class QuartzConfig {
@Autowired
private JobFactory jobFactory;
@Autowired
private DataSource dataSource;
@Bean
public SchedulerFactoryBean schedulerFactoryBean() {
SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
schedulerFactoryBean.setOverwriteExistingJobs(true);
schedulerFactoryBean.setStartupDelay(60);
schedulerFactoryBean.setJobFactory(jobFactory);
schedulerFactoryBean.setOverwriteExistingJobs(true);
schedulerFactoryBean.setStartupDelay(1);
schedulerFactoryBean.setDataSource(dataSource);
schedulerFactoryBean.setConfigLocation(new ClassPathResource("/application-quartz.properties"));
return schedulerFactoryBean;
}
@Bean
public Scheduler scheduler() {
return schedulerFactoryBean().getScheduler();
}
}
package com.subsidy.common.configure;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.cache.annotation.CachingConfigurerSupport;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.ListOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.SetOperations;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.data.redis.core.ZSetOperations;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
@EnableCaching
/**
* <p>
* Redis
* </p>
*
* @author DengMin
* @since 2020/12/14
*/
@Configuration
public class RedisConfig extends CachingConfigurerSupport {
/**
* retemplate相关配置
* @param factory
* @return
*/
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
// 配置连接工厂
template.setConnectionFactory(factory);
//使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
Jackson2JsonRedisSerializer jacksonSeial = new Jackson2JsonRedisSerializer(Object.class);
ObjectMapper om = new ObjectMapper();
// 指定要序列化的域,field,get和set,以及修饰符范围,ANY是都有包括private和public
om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
// 指定序列化输入的类型,类必须是非final修饰的,final修饰的类,比如String,Integer等会跑出异常
om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
jacksonSeial.setObjectMapper(om);
// 值采用json序列化
template.setValueSerializer(jacksonSeial);
//使用StringRedisSerializer来序列化和反序列化redis的key值
template.setKeySerializer(new StringRedisSerializer());
// 设置hash key 和value序列化模式
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(jacksonSeial);
template.afterPropertiesSet();
return template;
}
/**
* 对hash类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public HashOperations<String, String, Object> hashOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForHash();
}
/**
* 对redis字符串类型数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ValueOperations<String, Object> valueOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForValue();
}
/**
* 对链表类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ListOperations<String, Object> listOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForList();
}
/**
* 对无序集合类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public SetOperations<String, Object> setOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForSet();
}
/**
* 对有序集合类型的数据操作
*
* @param redisTemplate
* @return
*/
@Bean
public ZSetOperations<String, Object> zSetOperations(RedisTemplate<String, Object> redisTemplate) {
return redisTemplate.opsForZSet();
}
}
\ No newline at end of file
package com.subsidy.common.configure;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* <p>
* 读取状态码
* </p>
*
* @author DengMin
* @date Created in 2020/08/24
*/
@Component
@ConfigurationProperties(prefix = "meishu")
@PropertySource(value = "classpath:code.properties", encoding = "UTF-8")
public class RemoteProperties {
private static Map<Integer, String> codeMessage = new HashMap<>();
public static String getMessage(Integer code) {
return codeMessage.get(code);
}
public Map<Integer, String> getCodeMessage() {
return codeMessage;
}
public void setCodeMessage(Map<Integer, String> codeMessage) {
RemoteProperties.codeMessage = codeMessage;
}
}
\ No newline at end of file
package com.subsidy.common.configure;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Component
@Data
@ConfigurationProperties(prefix = "renshe")
public class RenSheConfig {
//接口地址
private String url;
//私钥
private String secretKey;
//普陀 正式接口
private String putuo;
}
package com.subsidy.common.configure;
import org.springframework.context.annotation.Bean;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import java.util.ArrayList;
import java.util.List;
@Component
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.getMessageConverters().add(new WxMappingJackson2HttpMessageConverter());
return restTemplate;
}
public class WxMappingJackson2HttpMessageConverter extends MappingJackson2HttpMessageConverter {
public WxMappingJackson2HttpMessageConverter(){
List<MediaType> mediaTypes = new ArrayList<>();
mediaTypes.add(MediaType.TEXT_PLAIN);
mediaTypes.add(MediaType.TEXT_HTML);
setSupportedMediaTypes(mediaTypes);
}
}
}
package com.subsidy.common.configure;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "subsidy")
public class SubsidyConfig {
private String appId;
private String securityKey;
private String url;
}
package com.subsidy.common.configure;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.pathMapping("/")
.select()
.apis(RequestHandlerSelectors.basePackage("com.subsidy"))
.paths(PathSelectors.any())
.build().apiInfo(new ApiInfoBuilder()
.title("顶岗实习端")
.description("接口文档规范")
.version("1.0")
// .contact(new Contact("啊啊啊啊","www.youkehulian.com","tcp@meishu.com"))
// .license("The Apache License")
// .licenseUrl("http://www.baidu.com")
.build());
}
}
package com.subsidy.common.configure;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @author: tuyp
* @create: 2020-06-01 16:46
*/
@Component
@Data
@ConfigurationProperties(prefix = "vod")
public class VODConfig {
private String appId;
private String secretId;
private String secretKey;
private String api;
private String region;
private Integer classId;
}
package com.subsidy.common.configure;
import com.subsidy.common.interceptor.AuthenticationInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author DengMin
* @date 2020/07/06
**/
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Autowired
private AuthenticationInterceptor authenticationInterceptor;
/**
* 跨域支持
*
* @param registry
*/
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
// .allowCredentials(true)
.allowedOrigins("*")
.allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("*")
.maxAge(3600);
}
/**
* Swagger
*
* @param registry
*/
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
/**
* 鉴权
*
* @param registry
*/
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(authenticationInterceptor)
.excludePathPatterns("/static/*")
.addPathPatterns("/**");
}
@Bean
public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
config.setMaxAge(3600L);
config.addAllowedOrigin("*");
config.addAllowedMethod("*");
config.addAllowedHeader("*");
UrlBasedCorsConfigurationSource configSource = new UrlBasedCorsConfigurationSource();
configSource.registerCorsConfiguration("/**", config);
return new CorsFilter(configSource);
}
}
\ No newline at end of file
package com.subsidy.common.configure;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
@Aspect
@Component
@Order(1)
public class WebLogAspect {
private final Logger logger = LoggerFactory.getLogger(WebLogAspect.class);
@Pointcut("execution(public * com.subsidy.controller.*.*(..))")//切入点描述 这个是controller包的切入点
public void controllerLog(){}//签名,可以理解成这个切入点的一个名称
@Pointcut("execution(public * com.subsidy.controller.*.*(..))")
public void serviceImplLog(){}
@Before("controllerLog()") //在切入点的方法run之前要干的
public void logBeforeController(JoinPoint joinPoint) {
// RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
//这个RequestContextHolder是Springmvc提供来获得请求的东西
// HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest();
// 记录下请求内容
// logger.info("####requestUrl : " + request.getRequestURL().toString());
// logger.info("####requestParam : " + Arrays.toString(joinPoint.getArgs()));
}
// @Around("serviceImplLog()")
// public Object afterController(ProceedingJoinPoint proceedingJoinPoint) {
//
// Object result = null;
//
// try{
// result = proceedingJoinPoint.proceed();
// logger.info("====reulst"+result);
// }catch (Throwable e){
// MyException myException =(MyException)e;
// throw myException;
// }
// return result;
// }
}
\ No newline at end of file
package com.subsidy.common.configure;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "wechat")
public class WechatConfig {
private String appId;
private String appSecret;
//private String msgUrl;
//
//private String templateId;
//
//private String agentId;
}
package com.subsidy.common.constant;
public class AttendanceConstant {
/**
* 创建预约api
*/
public static final String CREATE_TOPIC_URL = "https://open.api.roomis.com.cn/api/my/booking/spaces/{spaceId}/events";
/**
* 考勤api
*/
public static final String GET_ATTENDANCE_URL = "https://open.api.roomis.com.cn/api/attendance/{id}";
/**
* 创建人ID
*/
public static Long organizerId = 200000222L;
/**
* 开始时间
*/
public static String startTime = "07:00:00";
/**
* 结束时间
*/
public static String endTime = "21:00:00";
}
package com.subsidy.common.constant;
import lombok.Getter;
@Getter
public enum Code {
USERNAMENOTFOUND(1001, "用户不存在"),
BADCREDENTIALS(1002,"账户或者密码错误"),
ACCOUNTEXPIRED(1003,"账户过期"),
LOCKEDEXCEPTION(1004, "账户已锁定"),
DISABLEDEXCEPTION(1005,"账户已禁用"),
ACCESSDENIED(1006,"无权限访问"),
AUTHENTICATION(1007,"身份验证异常"),
NOHANDLERFOUND(1008,"找不到相应的视图处理器"),
PARAM_INVALID(1009, "参数不合法"),
TOKEN_EXCEPTION(1010, "无效的令牌"),
TOKEN_EXPIRED(1011, "当前账户已在其他设备登录"),
TOKEN_VERIFICATION_FAILED(1013, "令牌验证失败"),
OSS_ERROR(1012, "OSS文件上传异常"),
Network_ERROR(9000, "网络请求失败"),
SERVER_INTERNAL_ERROR(99999, "服务器内部错误"),
;
private Integer code;
private String message;
Code(Integer code, String message) {
this.code = code;
this.message = message;
}
}
package com.subsidy.common.constant;
public class CourseNotification {
public static final String UNSENT = "待发送";
public static final String SENT = "已发送";
}
package com.subsidy.common.constant;
import lombok.Getter;
@Getter
public enum SmsCode {
SIGN_IN("SMS_234409992", "签到通知"),
TEST("SMS_234414789", "测试通知"),
CLASS_START("SMS_228137810", "开课通知"),
ALL("SMS_228137810", "全部成员"),
NOT_SIGNED_IN("SMS_234409992","未签到成员"),
UNFINISHED("SMS_234414789","未完课成员");
private String type;
private String code;
SmsCode(String code, String type) {
this.code = code;
this.type = type;
}
}
package com.subsidy.common.constant;
import lombok.Getter;
@Getter
public class VodConstant {
/* 流量 */
public final static String FLUX = "Flux";
/* 带宽 */
public final static String BANDWIDTH = "Bandwidth";
/* 请求数 */
public final static String REQUESTS = "Requests";
/* 请求命中率 */
public final static String HITRATE = "Hitrate";
/* IP访问次数 */
public final static String IP_VISITS = "Ip_visits";
/* 带宽缓存key */
public final static String BANDWIDTH_CACHE_KEY = "CDNStatBandwidthCache";
/* 流量缓存key */
public final static String FLUX_CACHE_KEY = "CDNStatFluxCache";
/* 自定义缓存名称(ehcache.xml中的自定义规则名称) */
public final static String CDN_STAT_DETAILS_CACHE_NAME = "CDNStatDetails";
}
package com.subsidy.common.constant;
public class WxConstant {
/**
* app id
*/
public static final String APPID = "wx75ec06e9ce50ef73";
/**
* 秘钥
*/
public static final String SECRENT = "c039d32804278503474dfcf7cb3944b9";
/**
* 获取访问用户身份
*/
public static final String GETUSERINFO = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token={access_token}&code={code}";
/**
* 读取成员
*/
public static final String GET = "https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token={access_token}&userid={userid}";
/**
* 获取access_token
*/
public static final String GET_SUITE_TOKEN = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={appid}&secret={secret}";
/**
* 扫码登陆回调地址
*/
public static final String QR_REDIRECT_URL = "http://massadmin.youkehulian.com";
}
package com.subsidy.common.exception;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO;
import com.subsidy.common.configure.RemoteProperties;
import com.subsidy.common.constant.Code;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.validation.BindException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.NoHandlerFoundException;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
/**
* 异常处理
* @author DengMin
* @date 2020/07/14
**/
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {
/**
* 自定义异常
* @param e
* @return
*/
@ExceptionHandler(value = HttpException.class)
public ResponseVO<T> handlerException(HttpServletRequest request, HttpException e) {
String message = RemoteProperties.getMessage(e.getCode());
if(StringUtils.isBlank(message)) {
message = e.getMessage();
}
String url = request.getRequestURI();
return ResponseData.generateCreatedResponse(e.getCode(), message, url);
}
/**
* 404
* @param request
* @return
*/
@ExceptionHandler(value = NoHandlerFoundException.class)
public ResponseVO<T> NoHandlerFoundException(HttpServletRequest request) {
String url = request.getRequestURI();
return ResponseData.generateCreatedResponse(Code.NOHANDLERFOUND.getCode(), Code.NOHANDLERFOUND.getMessage(), url);
}
/**
* 请求方式错误
* @param request
* @return
*/
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.class)
public ResponseVO<T> HttpRequestMethodNotSupportedException(HttpServletRequest request) {
String url = request.getRequestURI();
return ResponseData.generateCreatedResponse(Code.NOHANDLERFOUND.getCode(), Code.NOHANDLERFOUND.getMessage(), url);
}
/**
* 参数不合法
* @param e
* @return
*/
@ExceptionHandler(MethodArgumentNotValidException.class)
public ResponseVO<T> validateException(MethodArgumentNotValidException e){
final List<String> errList = new ArrayList<>();
e.getBindingResult().getAllErrors().stream().forEach(x -> {
errList.add(x.getDefaultMessage());
});
return ResponseData.generateCreatedResponse(Code.PARAM_INVALID.getCode(), Code.PARAM_INVALID.getMessage(), errList.toString());
}
/**
* JSON 序列化异常
* @param e
* @return
*/
@ExceptionHandler(HttpMessageNotReadableException.class)
public ResponseVO<T> exceptionHandler(HttpMessageNotReadableException e) {
log.error(e.getMessage());
return ResponseData.generateCreatedResponse(Code.PARAM_INVALID.getCode(), Code.PARAM_INVALID.getMessage()+":{"+e.getMessage()+"}");
}
/**
* 校验异常
* @param e
* @return
*/
@ExceptionHandler(BindException.class)
public ResponseVO<T> BindException(BindException e){
final List<String> errList = new ArrayList<>();
e.getBindingResult().getAllErrors().stream().forEach(x -> {
errList.add(x.getDefaultMessage());
});
return ResponseData.generateCreatedResponse(Code.PARAM_INVALID.getCode(), Code.PARAM_INVALID.getMessage(), errList.toString());
}
/**
* 服务器内部错误
* @return
*/
@ExceptionHandler(value = Exception.class)
public ResponseVO<T> serverInternalError(Exception e, HttpServletRequest request) {
String url = request.getRequestURI();
// log.error("path:"+url);
// log.error("---- error message: ---"+e.toString());
e.printStackTrace();
return ResponseData.generateCreatedResponse(Code.SERVER_INTERNAL_ERROR.getCode(), Code.SERVER_INTERNAL_ERROR.getMessage(), url);
}
}
\ No newline at end of file
package com.subsidy.common.exception;
import com.subsidy.common.configure.RemoteProperties;
/**
* 异常处理
* @author DengMin
* @date 2020/08/12
**/
public class HttpException extends RuntimeException{
private Integer code;
private String message;
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
@Override
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public HttpException(Integer code) {
super(RemoteProperties.getMessage(code));
String message = RemoteProperties.getMessage(code);
this.message = message;
this.code = code;
}
public HttpException(Integer code, String message) {
this.message = message;
this.code = code;
}
}
package com.subsidy.common.handler;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
/**
* 填充配置
* @author DengMin
* @date 2020/07/21
**/
@Component
public class MetaHandler implements MetaObjectHandler {
@Override
public void insertFill(MetaObject metaObject) {
this.setFieldValByName("createDate", LocalDateTime.now(), metaObject);
}
@Override
public void updateFill(MetaObject metaObject) {
this.setFieldValByName("updateDate", LocalDateTime.now(), metaObject);
}
}
package com.subsidy.common.interceptor;
import com.auth0.jwt.interfaces.Claim;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.subsidy.common.exception.HttpException;
import com.subsidy.mapper.AdministerMapper;
import com.subsidy.model.AdministerDO;
import com.subsidy.util.ConstantUtils;
import com.subsidy.util.JwtUtil;
import com.subsidy.util.Localstorage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.Calendar;
import java.util.Map;
/**
* <p>
* 鉴权拦截器
* </p>
*
* @author DengMin
* @since 2021/4/14
*/
@Component
public class AuthenticationInterceptor implements HandlerInterceptor {
@Autowired
private AdministerMapper administerMapper;
@Override
@CrossOrigin()
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
// 不需要进行拦截
if (!(handler instanceof HandlerMethod)) {
return true;
}
HandlerMethod handlerMethod = (HandlerMethod) handler;
Method method = handlerMethod.getMethod();
TimeRequired timeRequired = method.getAnnotation(TimeRequired.class);
if (timeRequired != null) {
Calendar calendar = Calendar.getInstance();
int hour = calendar.get(Calendar.HOUR_OF_DAY);
if (hour < 6 || hour >= 23 ) {
throw new HttpException(17001);
}
}
LoginRequired methodAnnotation = method.getAnnotation(LoginRequired.class);
if (methodAnnotation != null) {
String authorization = request.getHeader("Authorization");
if (!StringUtils.isBlank(authorization)) {
String token = authorization;
if (authorization.startsWith("Bearer")) {
token = authorization.replace("Bearer ", "");
}
/*Token不存在*/
if (token == null || !JwtUtil.verifyToken(token)) {
throw new HttpException(1010);
}
Map<String, Claim> claimMap = JwtUtil.getClaims(token);
if (claimMap != null) {
//String[] role = methodAnnotation.value();
String type = claimMap.get("type").asString();
if (ConstantUtils.ADMINISTER_TERMINATE.equals(type)) {
AdministerDO administerDO = administerMapper.selectById(claimMap.get("id").asLong());
if (administerDO != null) {
Localstorage.setUser(administerDO);
return true;
}
} else if (ConstantUtils.MOBILE_TERMINATE.equals(type)) {
/**
* 学生端设置单设备登录
*/
/* String tk = (String) redisUtil.get(ConstantUtils.MOBILE_TERMINATE+"_"+claimMap.get("id").asLong());
if(StringUtils.isNotBlank(tk)) {
if(tk.equals(token)) {
return true;
}
throw new HttpException(1011);
} else {
throw new HttpException(1010);
}*/
} else {
throw new HttpException(1010);
}
}
}
throw new HttpException(1010);
}
return true;
}
}
package com.subsidy.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/**
* <p>
* 管理平台用户 前端控制器
* </p>
*
* @author Tuyp
* @since 2024-07-18
*/
@RestController
@Api(tags = "管理平台用户")
@RequestMapping("/administer-do")
public class AdministerController {
}
package com.subsidy.controller;
import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO;
import com.subsidy.dto.administer.VerifyCodeDTO;
import com.subsidy.dto.labor.SalaryListSumDTO;
import com.subsidy.dto.labor.UpdateTelephoneDTO;
import com.subsidy.model.MemberDO;
import com.subsidy.service.ProjectService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
/**
* <p>
* 项目表 前端控制器
* </p>
*
* @author Tuyp
* @since 2024-07-18
*/
@RestController
@Api(tags = "项目表")
@RequestMapping("/project")
public class ProjectController {
@Autowired
private ProjectService projectService;
@PostMapping("sendSms")
@ApiOperation("发送验证码 telephone ")
public ResponseVO sendSms(@RequestBody MemberDO memberDO){
return ResponseData.generateCreatedResponse(0,projectService.sendSms(memberDO));
}
@PostMapping("login")
@ApiOperation("登录 telephone verifyCode")
public ResponseVO login(@RequestBody VerifyCodeDTO verifyCodeDTO){
return ResponseData.generateCreatedResponse(0,projectService.login(verifyCodeDTO));
}
@PostMapping("currentProject")
@ApiOperation("当前所在项目 id 人才id")
public ResponseVO currentProject(@RequestBody MemberDO memberDO){
return ResponseData.generateCreatedResponse(0,projectService.currentProject(memberDO));
}
@PostMapping("historyProjects")
@ApiOperation("历史所有职位 id 人才id")
public ResponseVO historyProjects(@RequestBody MemberDO memberDO){
return ResponseData.generateCreatedResponse(0,projectService.historyProjects(memberDO));
}
@PostMapping("verify")
@ApiOperation("变更绑定手机--验证验证码 verifyCode")
public ResponseVO verify(@RequestBody VerifyCodeDTO verifyCodeDTO){
return ResponseData.generateCreatedResponse(0,projectService.verify(verifyCodeDTO));
}
@PostMapping("updateTelephone")
@ApiOperation("更新手机号 id telephone verifyCode ")
public ResponseVO updateTelephone(@RequestBody UpdateTelephoneDTO updateTelephoneDTO){
return ResponseData.generateCreatedResponse(0,projectService.updateTelephone(updateTelephoneDTO));
}
@PostMapping("idCardInfo")
@ApiOperation("身份证信息 id")
public ResponseVO idCardInfo(@RequestBody MemberDO memberDO){
return ResponseData.generateCreatedResponse(0,projectService.idCardInfo(memberDO));
}
@PostMapping("bankInfo")
@ApiOperation("银行卡信息 id")
public ResponseVO bankInfo(@RequestBody MemberDO memberDO){
return ResponseData.generateCreatedResponse(0,projectService.bankInfo(memberDO));
}
@PostMapping("salaryListSum")
@ApiOperation("工资单--笔数+总计 memberId 人才id projectId 项目id ")
public ResponseVO salaryListSum(@RequestBody SalaryListSumDTO salaryListSumDTO){
return ResponseData.generateCreatedResponse(0,projectService.salaryListSum(salaryListSumDTO));
}
@PostMapping("salaryList")
@ApiOperation("工资单明细 memberId 人才id projectId 项目id pageSize pageNum ")
public ResponseVO salaryList(@RequestBody SalaryListSumDTO salaryListSumDTO){
return ResponseData.generateCreatedResponse(0,projectService.salaryList(salaryListSumDTO));
}
}
package com.subsidy.dto.administer;
import lombok.Data;
@Data
public class VerifyCodeDTO {
private String telephone;
private String verifyCode;
}
package com.subsidy.dto.labor;
import lombok.Data;
@Data
public class SalaryListSumDTO {
private Long memberId;
private Long projectId;
private Integer pageSize;
private Integer pageNum;
}
package com.subsidy.dto.labor;
import lombok.Data;
@Data
public class UpdateTelephoneDTO {
private Long id;
private String telephone;
private String verifyCode;
}
package com.subsidy.mapper;
import com.subsidy.model.ProjectMemberMappingDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.vo.labor.CurrentProjectVO;
import com.subsidy.vo.labor.HistoryProjectsVO;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* <p>
* 项目人员映射表 Mapper 接口
* </p>
*
* @author Tuyp
* @since 2024-07-18
*/
@Repository
public interface ProjectMemberMappingMapper extends BaseMapper<ProjectMemberMappingDO> {
/**
* 查看某人当前所在项目
*/
CurrentProjectVO currentProject(Long memberId);
/**
* 某人的历史职位
*/
List<HistoryProjectsVO> historyProjects(Long memberId);
}
package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.model.ProjectSalaryHistoryDO;
import com.subsidy.vo.labor.SalaryListSumVO;
import com.subsidy.vo.labor.SalaryListVO;
import org.springframework.stereotype.Repository;
/**
* <p>
* 工资单历史表 Mapper 接口
* </p>
*
* @author Tuyp
* @since 2024-07-11
*/
@Repository
public interface ProjectSalaryHistoryMapper extends BaseMapper<ProjectSalaryHistoryDO> {
SalaryListSumVO salaryCount(Long project, Long memberId);
IPage<SalaryListVO> salaryList(IPage page, Long projectId, Long memberId);
}
package com.subsidy.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.subsidy.model.SmsVerifyCodeDO;
import org.springframework.stereotype.Repository;
/**
* <p>
* 短信验证码记录表 Mapper 接口
* </p>
*
* @author DengMin
* @since 2021-10-14
*/
@Repository
public interface SmsVerifyCodeMapper extends BaseMapper<SmsVerifyCodeDO> {
}
package com.subsidy.model;
import com.subsidy.util.BaseModel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 管理平台用户
* </p>
*
* @author Tuyp
* @since 2024-07-18
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("administer")
public class AdministerDO extends BaseModel {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 手机号
*/
private String telephone;
/**
* 账号
*/
private String accountName;
/**
* 密码
*/
private String password;
/**
* 公司id
*/
private Long companyId;
/**
* 成员名称
*/
private String userName;
/**
* 头像
*/
private String img;
/**
* 1:启用 0:禁用
*/
private String status;
/**
* 角色 0:应用 1:企业关联客户 2:中心 3:企业唯一账号,4:院校唯一账号 5:院校关联账号 6:伙伴唯一账号 7:伙伴关联账号
*/
private Integer role;
/**
* 备注
*/
private String remark;
}
package com.subsidy.model;
import com.subsidy.util.BaseModel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 管理员-项目映射表
* </p>
*
* @author Tuyp
* @since 2024-07-18
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("administer_project_mapping")
public class AdministerProjectMappingDO extends BaseModel {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
private Long administerId;
private Long projectId;
}
package com.subsidy.model;
import com.subsidy.util.BaseModel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
*
* </p>
*
* @author Tuyp
* @since 2024-07-18
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("member")
public class MemberDO extends BaseModel {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 院校id
*/
private Long academyId;
/**
* 公司名 弃用
*/
private Long companyId;
/**
* 姓名
*/
private String userName;
/**
* 账号
*/
private String accountName;
/**
* 英文名
*/
private String accountNameEn;
/**
* 邮箱
*/
private String email;
/**
* 工号
*/
private String workNo;
/**
* 入职时间
*/
private String inductionDate;
/**
* 手机号
*/
private String telephone;
/**
* 密码
*/
private String password;
/**
* 性别
*/
private String gender;
/**
* 头像
*/
private String image;
/**
* 人脸核验--照片
*/
private String checkImage;
/**
* 采集时间
*/
private LocalDateTime checkTime;
/**
* 身份证号
*/
private String idCard;
/**
* 身份证照片
*/
private String idCardPhoto;
/**
* 启用/冻结
*/
private String status;
/**
* 是否登陆过 1 是 0 不是
*/
private Integer firstLogin;
/**
* QQ号
*/
private String qqNo;
/**
* 微信账号
*/
private String wechat;
/**
* 实习状态
*/
private String practiceStatus;
/**
* 学院id
*/
private Long collegeId;
/**
* 专业id
*/
private String major;
/**
* 入学年份
*/
private String enrollmentYear;
/**
* 工资账户
*/
private String payrollAccount;
/**
* 开户行
*/
private String bank;
/**
* 0:学生 2:职工 3:人才
*/
private Integer memberType;
/**
* 微信的openId
*/
private String openId;
}
package com.subsidy.model;
import com.subsidy.util.BaseModel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 项目表
* </p>
*
* @author Tuyp
* @since 2024-07-18
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("project")
public class ProjectDO extends BaseModel {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 项目名称
*/
private String projectName;
/**
* 关联企业
*/
private Long companyId;
/**
* 伙伴id
*/
private Long laborServiceId;
/**
* 薪资发放日
*/
private String salaryDate;
/**
* 开始时间
*/
private String startDate;
/**
* 结束时间
*/
private String endDate;
}
package com.subsidy.model;
import com.subsidy.util.BaseModel;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 项目人员映射表
* </p>
*
* @author Tuyp
* @since 2024-07-18
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("project_member_mapping")
public class ProjectMemberMappingDO extends BaseModel {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 人员id
*/
private Long memberId;
/**
* 项目id
*/
private Long projectId;
/**
* 职位名称
*/
private String jobName;
/**
* 排序
*/
private Integer orderNo;
/**
* 1:在职 0 已离职
*/
private Integer status;
}
package com.subsidy.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.subsidy.util.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 工资单历史表
* </p>
*
* @author Tuyp
* @since 2024-07-11
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("project_salary_history")
public class ProjectSalaryHistoryDO extends BaseModel {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 人员id
*/
private Long memberId;
/**
* 项目id
*/
private Long projectId;
/**
* 工资
*/
private String salary;
/**
* 备注
*/
private String salaryMark;
/**
* 开户行
*/
private String bank;
/**
* 账户
*/
private String payrollAccount;
}
package com.subsidy.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.subsidy.util.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 短信验证码记录表
* </p>
*
* @author DengMin
* @since 2021-10-14
*/
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sms_verify_code")
public class SmsVerifyCodeDO extends BaseModel {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 手机号
*/
private String telephone;
/**
* 验证码
*/
private String verifyCode;
}
package com.subsidy.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.subsidy.dto.administer.VerifyCodeDTO;
import com.subsidy.dto.labor.SalaryListSumDTO;
import com.subsidy.dto.labor.UpdateTelephoneDTO;
import com.subsidy.model.MemberDO;
import com.subsidy.model.ProjectDO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.subsidy.vo.administer.UserRoleVO;
import com.subsidy.vo.labor.*;
import java.util.List;
/**
* <p>
* 项目表 服务类
* </p>
*
* @author Tuyp
* @since 2024-07-18
*/
public interface ProjectService extends IService<ProjectDO> {
String sendSms(MemberDO memberDO);
UserRoleVO login(VerifyCodeDTO verifyCodeDTO);
CurrentProjectVO currentProject(MemberDO memberDO);
List<HistoryProjectsVO> historyProjects(MemberDO memberDO);
String verify(VerifyCodeDTO verifyCodeDTO);
String updateTelephone(UpdateTelephoneDTO updateTelephoneDTO);
IdCardInfoVO idCardInfo(MemberDO memberDO);
BankInfoVO bankInfo(MemberDO memberDO);
SalaryListSumVO salaryListSum(SalaryListSumDTO salaryListSumDTO);
IPage<SalaryListVO> salaryList(SalaryListSumDTO salaryListSumDTO);
}
package com.subsidy.service.impl;
import com.subsidy.model.AdministerDO;
import com.subsidy.mapper.AdministerMapper;
import com.subsidy.service.AdministerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 管理平台用户 服务实现类
* </p>
*
* @author Tuyp
* @since 2024-07-18
*/
@Service
public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, AdministerDO> implements AdministerService {
}
package com.subsidy.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.subsidy.common.exception.HttpException;
import com.subsidy.dto.administer.VerifyCodeDTO;
import com.subsidy.dto.labor.SalaryListSumDTO;
import com.subsidy.dto.labor.UpdateTelephoneDTO;
import com.subsidy.mapper.*;
import com.subsidy.model.MemberDO;
import com.subsidy.model.ProjectDO;
import com.subsidy.model.SmsVerifyCodeDO;
import com.subsidy.service.ProjectService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.subsidy.util.*;
import com.subsidy.vo.administer.UserRoleVO;
import com.subsidy.vo.labor.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
* 项目表 服务实现类
* </p>
*
* @author Tuyp
* @since 2024-07-18
*/
@Service
public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, ProjectDO> implements ProjectService {
@Autowired
private MemberMapper memberMapper;
@Autowired
private SMSUtils smsUtils;
@Autowired
private SmsVerifyCodeMapper smsVerifyCodeMapper;
@Autowired
private ProjectMemberMappingMapper projectMemberMappingMapper;
@Autowired
private ProjectSalaryHistoryMapper projectSalaryHistoryMapper;
public String sendSms(MemberDO memberDO) {
int count = memberMapper.selectCount(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getTelephone, memberDO.getTelephone())
.eq(MemberDO::getMemberType, 3));
if (count == 0) {
throw new HttpException(10011);
}
String code = RandomUtil.getRandomCode(6);
smsUtils.send(memberDO.getTelephone(), code);
smsVerifyCodeMapper.delete(new QueryWrapper<SmsVerifyCodeDO>()
.lambda()
.eq(SmsVerifyCodeDO::getTelephone, memberDO.getTelephone()));
SmsVerifyCodeDO smsCodeDO = new SmsVerifyCodeDO();
smsCodeDO.setVerifyCode(code);
smsCodeDO.setTelephone(memberDO.getTelephone());
smsVerifyCodeMapper.insert(smsCodeDO);
return ConstantUtils.SUCCESS_SEND_OUT;
}
public UserRoleVO login(VerifyCodeDTO verifyCodeDTO) {
UserRoleVO userRoleVO = new UserRoleVO();
MemberDO memberDO = memberMapper.selectOne(new QueryWrapper<MemberDO>()
.lambda()
.eq(MemberDO::getTelephone, verifyCodeDTO.getTelephone())
.eq(MemberDO::getMemberType, 3));
if (null == memberDO) {
throw new HttpException(10011);
}
SmsVerifyCodeDO smsCodeDO = smsVerifyCodeMapper.selectOne(new QueryWrapper<SmsVerifyCodeDO>()
.lambda()
.eq(SmsVerifyCodeDO::getTelephone, verifyCodeDTO.getTelephone())
.eq(SmsVerifyCodeDO::getVerifyCode, verifyCodeDTO.getVerifyCode())
.gt(SmsVerifyCodeDO::getCreateDate, LocalDateTime.now().minusMinutes(30L)));
if (null == smsCodeDO || !verifyCodeDTO.getVerifyCode().equals(smsCodeDO.getVerifyCode())) {
throw new HttpException(70010);
}
String token = JwtUtil.generateToken(memberDO.getId(), ConstantUtils.MOBILE_TERMINATE);
Localstorage.setUser(memberDO);
userRoleVO.setToken(token);
BeanUtils.copyProperties(memberDO, userRoleVO);
return userRoleVO;
}
public CurrentProjectVO currentProject(MemberDO memberDO) {
return projectMemberMappingMapper.currentProject(memberDO.getId());
}
public List<HistoryProjectsVO> historyProjects(MemberDO memberDO) {
return projectMemberMappingMapper.historyProjects(memberDO.getId());
}
public String verify(VerifyCodeDTO verifyCodeDTO) {
SmsVerifyCodeDO smsCodeDO = smsVerifyCodeMapper.selectOne(new QueryWrapper<SmsVerifyCodeDO>()
.lambda()
.eq(SmsVerifyCodeDO::getTelephone, verifyCodeDTO.getTelephone())
.eq(SmsVerifyCodeDO::getVerifyCode, verifyCodeDTO.getVerifyCode())
.gt(SmsVerifyCodeDO::getCreateDate, LocalDateTime.now().minusMinutes(30L)));
if (null == smsCodeDO || !verifyCodeDTO.getVerifyCode().equals(smsCodeDO.getVerifyCode())) {
throw new HttpException(70010);
}
return ConstantUtils.SUCCESS_VERIFY;
}
public String updateTelephone(UpdateTelephoneDTO updateTelephoneDTO) {
SmsVerifyCodeDO smsCodeDO = smsVerifyCodeMapper.selectOne(new QueryWrapper<SmsVerifyCodeDO>()
.lambda()
.eq(SmsVerifyCodeDO::getTelephone, updateTelephoneDTO.getTelephone())
.eq(SmsVerifyCodeDO::getVerifyCode, updateTelephoneDTO.getVerifyCode())
.gt(SmsVerifyCodeDO::getCreateDate, LocalDateTime.now().minusMinutes(30L)));
if (null == smsCodeDO || !updateTelephoneDTO.getVerifyCode().equals(smsCodeDO.getVerifyCode())) {
throw new HttpException(70010);
}
MemberDO memberDO = memberMapper.selectById(updateTelephoneDTO.getId());
memberDO.setTelephone(updateTelephoneDTO.getTelephone());
memberMapper.updateById(memberDO);
return ConstantUtils.SUCCESS_UPDATE;
}
public IdCardInfoVO idCardInfo(MemberDO memberDO) {
IdCardInfoVO idCardInfoVO = new IdCardInfoVO();
MemberDO memberDO1 = memberMapper.selectById(memberDO.getId());
idCardInfoVO.setIdCard(memberDO1.getIdCard());
idCardInfoVO.setUserName(memberDO1.getUserName());
return idCardInfoVO;
}
public BankInfoVO bankInfo(MemberDO memberDO) {
BankInfoVO bankInfoVO = new BankInfoVO();
MemberDO memberDO1 = memberMapper.selectById(memberDO.getId());
bankInfoVO.setPayrollAccount(memberDO1.getPayrollAccount());
bankInfoVO.setUserName(memberDO1.getUserName());
bankInfoVO.setBank(memberDO1.getBank());
return bankInfoVO;
}
public SalaryListSumVO salaryListSum(SalaryListSumDTO salaryListSumDTO) {
return projectSalaryHistoryMapper.salaryCount(salaryListSumDTO.getProjectId(), salaryListSumDTO.getMemberId());
}
public IPage<SalaryListVO> salaryList(SalaryListSumDTO salaryListSumDTO) {
Page page = new Page(salaryListSumDTO.getPageNum(), salaryListSumDTO.getPageSize());
return projectSalaryHistoryMapper.salaryList(page, salaryListSumDTO.getProjectId(), salaryListSumDTO.getMemberId());
}
}
package com.subsidy.util;
import com.tencentcloudapi.captcha.v20190722.CaptchaClient;
import com.tencentcloudapi.captcha.v20190722.models.DescribeCaptchaResultRequest;
import com.tencentcloudapi.captcha.v20190722.models.DescribeCaptchaResultResponse;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import javax.servlet.http.HttpServletRequest;
public class ActivityDetectionUtils {
/**
* 活跃度检测工具类
*
* @throws Exception
*/
public static DescribeCaptchaResultResponse activityDetection(HttpServletRequest request, String ticket, String randstr) {
try {
// 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
// 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
Credential cred = new Credential(ConstantUtils.SECRET_ID, ConstantUtils.SECRET_KEY);
// 实例化一个http选项,可选的,没有特殊需求可以跳过
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("captcha.tencentcloudapi.com");
// 实例化一个client选项,可选的,没有特殊需求可以跳过
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
// 实例化要请求产品的client对象,clientProfile是可选的
CaptchaClient client = new CaptchaClient(cred, "", clientProfile);
// 实例化一个请求对象,每个接口都会对应一个request对象
DescribeCaptchaResultRequest req = new DescribeCaptchaResultRequest();
req.setCaptchaType(9L);
String ip = IpAddressUtil.getIpAddress(request);
req.setUserIp(ip);
req.setRandstr(randstr);
req.setCaptchaAppId(ConstantUtils.CAPTCHAAPP_ID);
req.setAppSecretKey(ConstantUtils.APP_SECRET_KEY);
req.setBusinessId(ConstantUtils.BUSINESS_ID);
req.setTicket(ticket);
// 返回的resp是一个DescribeCaptchaResultResponse的实例,与请求对象对应
return client.DescribeCaptchaResult(req);
} catch (Exception e) {
}
return null;
}
}
package com.subsidy.util;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
import javax.imageio.stream.FileImageInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class Base64Util {
/**
* 字符串转图片
* @param base64Str
* @return
*/
public static byte[] decode(String base64Str){
byte[] b = null;
BASE64Decoder decoder = new BASE64Decoder();
try {
b = decoder.decodeBuffer(replaceEnter(base64Str));
} catch (IOException e) {
e.printStackTrace();
}
return b;
}
/**
* 图片转字符串
* @param image
* @return
*/
public static String encode(byte[] image){
BASE64Encoder decoder = new BASE64Encoder();
return replaceEnter(decoder.encode(image));
}
public static void main(String[] args) {
System.out.println(encode("http://ykhl-bigger.oss-cn-beijing.aliyuncs.com/2023-02-1618cb936b-4825-429c-9fdd-dd9d0de97ed7.jpg?x-oss-process=image/auto-orient,1/resize,m_pad,w_500,h_500/quality,Q_100/format,jpg"));
}
public static String encode(String uri){
BASE64Encoder encoder = new BASE64Encoder();
return replaceEnter(encoder.encode(uri.getBytes()));
}
/**
*
* @path 图片路径
* @return
*/
public static byte[] imageTobyte(String path){
byte[] data = null;
FileImageInputStream input = null;
try {
input = new FileImageInputStream(new File(path));
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int numBytesRead = 0;
while((numBytesRead = input.read(buf)) != -1){
output.write(buf, 0, numBytesRead);
}
data = output.toByteArray();
output.close();
input.close();
} catch (Exception e) {
e.printStackTrace();
}
return data;
}
public static String replaceEnter(String str){
String reg ="[\n-\r]";
Pattern p = Pattern.compile(reg);
Matcher m = p.matcher(str);
return m.replaceAll("");
}
}
\ No newline at end of file
package com.subsidy.util;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.time.LocalDateTime;
@Data
public abstract class BaseModel {
/**
* 创建时间
*/
@JsonIgnore
@TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER, value = "create_date", fill = FieldFill.INSERT)
private LocalDateTime createDate;
/**
* 更新时间
*/
@JsonIgnore
@TableField(insertStrategy = FieldStrategy.NEVER, updateStrategy = FieldStrategy.NEVER, value = "update_date", fill = FieldFill.UPDATE)
private LocalDateTime updateDate;
/**
* 删除时间
*/
@JsonIgnore
@TableLogic
private LocalDateTime deleteDate;
}
package com.subsidy.util;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.InjectionConfig;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.FileOutConfig;
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
import com.baomidou.mybatisplus.generator.config.PackageConfig;
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
import com.baomidou.mybatisplus.generator.config.TemplateConfig;
import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import java.util.ArrayList;
import java.util.List;
import java.util.ResourceBundle;
import java.util.Scanner;
/**
* Mybatis-Plus CodeGenerator
*
* @author DengMin
* @date 2020/07/02
**/
public class CodeGenerator {
public static String scanner(String tip) {
StringBuilder help = new StringBuilder();
help.append("1.生成全部表 2.输入需要生成表名");
System.out.println(help.toString());
Scanner scanner = new Scanner(System.in);
Integer ipt = Integer.valueOf(scanner.next());
if(ipt == 1) {
return "";
} else if(ipt == 2) {
StringBuilder help1 = new StringBuilder();
help1.append("请输入" + tip + ":");
System.out.println(help1.toString());
Scanner scanner1 = new Scanner(System.in);
if (scanner1.hasNext()) {
String name = scanner1.next();
if (StringUtils.isNotEmpty(name)) {
return name;
}
}
throw new MybatisPlusException("请输入正确的" + tip + "!");
}
return scanner(tip);
}
public static void main(String[] args) {
final ResourceBundle rb = ResourceBundle.getBundle("mybatis-plus");
// 代码生成器
AutoGenerator mpg = new AutoGenerator();
// 全局配置
GlobalConfig gc = new GlobalConfig();
gc.setOutputDir(System.getProperty("user.dir") + rb.getString("outputDir"));
gc.setOpen(false);
gc.setBaseResultMap(true);
gc.setBaseColumnList(true);
gc.setAuthor(rb.getString("author"));
gc.setMapperName("%sMapper");
gc.setEntityName("%sDO");
gc.setServiceName("%sService");
gc.setServiceImplName("%sServiceImpl");
gc.setControllerName("%sController");
mpg.setGlobalConfig(gc);
// 数据源配置
DataSourceConfig dsc = new DataSourceConfig();
dsc.setDbType(DbType.MYSQL);
dsc.setUrl(rb.getString("url"));
dsc.setDriverName(rb.getString("driverName"));
dsc.setUsername(rb.getString("userName"));
dsc.setPassword(rb.getString("password"));
mpg.setDataSource(dsc);
// 包配置
PackageConfig pc = new PackageConfig();
pc.setParent(rb.getString("setParent"));
pc.setController("controller");
pc.setService("service");
pc.setServiceImpl("service.impl");
pc.setEntity("model");
pc.setMapper("mapper");
mpg.setPackageInfo(pc);
// 自定义配置
InjectionConfig cfg = new InjectionConfig() {
@Override
public void initMap() {
// to do nothing
}
};
List<FileOutConfig> focList = new ArrayList<>();
focList.add(new FileOutConfig("/templates/mapper.xml.ftl") {
@Override
public String outputFile(TableInfo tableInfo) {
// 自定义输入文件名称
return System.getProperty("user.dir")+ rb.getString("mapperPath") + tableInfo.getMapperName() + StringPool.DOT_XML;
}
});
cfg.setFileOutConfigList(focList);
mpg.setCfg(cfg);
mpg.setTemplate(new TemplateConfig().setXml(null));
// 策略配置
StrategyConfig strategy = new StrategyConfig();
strategy.setNaming(NamingStrategy.underline_to_camel);
strategy.setColumnNaming(NamingStrategy.underline_to_camel);
strategy.setSuperEntityClass(BaseModel.class);
strategy.setEntityLombokModel(true);
strategy.setRestControllerStyle(true);
String [] tables = scanner("表名,多个英文逗号分割").split(",");
if(StringUtils.isNotBlank(tables[0])) {
strategy.setInclude(tables);
}
strategy.setControllerMappingHyphenStyle(true);
mpg.setStrategy(strategy);
mpg.setTemplateEngine(new FreemarkerTemplateEngine());
mpg.execute();
}
}
\ No newline at end of file
package com.subsidy.util;
/**
* 枚举类
*/
public class ConstantUtils {
public static final String DELETE_SUCCESS = "删除成功";
public static final String UPLOAD_FAIL = "上传失败";
public static final String ADD_SUCCESS = "新增成功";
public static final String COMMIT_SUCCESS = "提交成功";
public static final String SUCCESS_SEND_OUT = "发送成功";
public static final String FAIL_SEND_OUT = "发送失败";
public static final String SAVE_SUCCESS = "保存成功";
public static final String SHARE_SUCCESS = "共享成功";
public static final String SUBMIT_SUCCESS = "提交成功";
public static final String SUCCESS_UPDATE = "更新成功";
public static final String FAIL_UPDATE = "更新失败";
public static final String SET_SUCCESS = "设置成功";
public static final String SUCCESS_VERIFY = "验证成功";
public static final String FAIL_VERIFY = "验证失败";
public static final String COMPANY_NAME = "TeachAI";
public static final String ALREADY_DONE = "已完成";
public static final String ALREADY_RECOMMEND = "已推荐";
public static final String VERIFY_NAME = "有课互联";
public static final String NOTICE_NAME = "有课进度通知";
public static final String TECH_NAME = "有课互联学习平台";
public static final String PUBLISH_SUCCESS = "发布成功";
public static final String COMPRESS_SUCCESS = "压缩成功";
public static final String CHECK_STATUS = "审核通过";
/**
* 短信模板---验证模板
*/
public static final String TEMPLATE_CODE = "SMS_190945394";
/**
* 短信 地域ID
*/
public static final String REGION_ID = "cn-hangzhou";
/**
* 短信 RAM账号AccessKey ID
*/
public static final String ACCESS_KEY_ID = "LTAI5tPAH7P7WQVeowo517BE";
/**
* 短信 RAM账号AccessKey Secret
*/
public static final String SECRET = "0ueqhIfdAZyw5lWlBVSLpAxTtx37RY";
/**
* 腾讯云点播视频转码模板
*/
public static final Long TEMPLATE_VOD = 100030L;
/**
* 手机端token
*/
public static final String MOBILE_TERMINATE = "mobile";
public static final String ADMINISTER_TERMINATE = "administer";
/**
* API密钥--微信参数
*/
public static final String SECRET_ID = "AKIDOcePHvZ2C5VeYHQGSO5aqtlNxJQLqfz2";
public static final String SECRET_KEY = "vjHYRmrfDbw0rWxA7oFcj7F8lDPKCm8E";
/**
* 图形验证码
*/
public static final Long CAPTCHAAPP_ID = 2013197365L;
public static final String APP_SECRET_KEY = "04ABoF0ZVuMje8NP84DE5Sg**";
public static final Long BUSINESS_ID = 1L;
public static final String UTF8 = "UTF-8";
/**
* 保利威视
*/
public static final String POLYV_VIEWLOG_2 = "http://api.polyv.net/live/v1/statistics/{channelId}/viewlog";
/**
* 推送人社局图片格式
*/
public static final String IMAGE_FORMAT = "?x-oss-process=image/auto-orient,1/resize,m_pad,w_500,h_500/quality,Q_100/format,jpg";
}
package com.subsidy.util;
import java.awt.SystemTray;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.util.Date;
/**
* 处理时间工具
*
* @author DengMin
* @date 2019/08/27 13:56
**/
public class DateFormatUtil {
public final static String YEAR = "yyyy";
public final static String FMT_sdf14_L = "yyyy-MM-dd HH:mm:ss";
public final static String FMT_sdf_yMd = "yyyy-MM-dd";
public final static String FMT_sdf_yM = "yyyy-M";
public final static String FMT_sdf_yMM = "yyyy-MM";
public final static String FMT_sdf_Hm = "H:mm";
public final static String FMT_sdf_HHmm = "HH:mm";
public final static String cron = "s m H d M ? yyyy";
/**
* Date转String,自定义格式
* @param date
* @param pattern
* @return
*/
public static String format(Date date, String pattern) {
try {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(date);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* LocalDateTime转String,自定义格式
* @param localDateTime
* @param pattern
* @return
*/
public static String format(LocalDateTime localDateTime, String pattern) {
try {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(localDateTime);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* String转Date,自定义格式
* @param date
* @param pattern
* @return
*/
public static Date parse(String date, String pattern) {
try {
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.parse(date);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/**
* 比较两个时间
* .after 大于
* .before 小于
* @param d1
* @param d2
* @return
*/
public static boolean compare(Date d1, Date d2 ) {
return !d1.after(d2);
}
/**
* Data转Cron
* @param date
* @return
*/
public static String getCron(Date date) {
SimpleDateFormat sdf = new SimpleDateFormat("s m H d M ? yyyy");
return sdf.format(date);
}
public static Date localDateTimeToDate(LocalDateTime dateTime) {
if(dateTime == null) {
return null;
}
ZoneId zoneId = ZoneId.systemDefault();
ZonedDateTime zdt = dateTime.atZone(zoneId);
return Date.from(zdt.toInstant());
}
public static LocalDateTime secondToLocalDateTime(Long second) {
if(second != null) {
return LocalDateTime.ofEpochSecond(second, 0, ZoneOffset.ofHours(8));
}
return LocalDateTime.now();
}
public static Long LocalDateTimeToSecond(LocalDateTime localDateTime) {
if(localDateTime != null) {
return localDateTime.atZone(ZoneOffset.ofHours(8)).toInstant().toEpochMilli();
}
return System.currentTimeMillis();
}
}
package com.subsidy.util;
public class DudaoConstant {
/**
* POST-1:班级基本信息信息采集接口
*/
public static final String POST_1 = "DUDAO_POST_1_insertClassBasicInformation";
/**
* POST-2:学时信息采集接口
*/
public static final String POST_2 = "DUDAO_POST_2_insertLearnDuration";
/**
* POST-3:考试信息采集接口
*/
public static final String POST_3 = "DUDAO_POST_3_insertExamInformation";
/**
* POST-4:答疑辅导采集接口
*/
public static final String POST_4 = "DUDAO_POST_4_insertAnswerTutor";
/**
* POST-5 上下游班级数据绑定接口
*/
public static final String POST_5 = "DUDAO_POST_5_insertBindClass";
/**
* 调取失败
*/
public static final String API_ERROR = "调取失败";
/**
* 当天没数据
*/
public static final String NO_DATA = "NO_DATA";
/**
* 推送失败
*/
public static final String PUSH_FAIL = "推送失败";
/**
* 推送成功
*/
public static final String PUSH_SUCCESS = "推送成功";
}
package com.subsidy.util;
import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
import org.springframework.util.ClassUtils;
/**
* <p>
* Ehcache
* </p>
*
* @author DengMin
* @since 2022/8/1
*/
public class EhCacheUtil {
static CacheManager cacheManager = CacheManager.newInstance(ClassUtils.getDefaultClassLoader().getResource("").getPath()+"ehcache.xml");
/**
* 添加缓存
* @param cacheName
* @param key
* @param value
*/
public static void putEhCache(String cacheName, String key, Object value) {
Cache cache = cacheManager.getCache(cacheName);
Element element = new Element(key, value);
cache.put(element);
}
/**
* 获取缓存数据
* @param cacheName
* @param key
* @return
*/
public static Object getEhCache(String cacheName, String key) {
Cache cache = cacheManager.getCache(cacheName);
Element element = cache.get(key);
return element == null ? null : element.getObjectValue();
}
/**
* 删除缓存
* @param cacheName
* @param key
*/
public static void deleteEhCache(String cacheName, String key) {
Cache cache = cacheManager.getCache(cacheName);
cache.remove(key);
}
}
//package com.subsidy.util;
//
//import com.amdelamar.jhash.Hash;
//import com.amdelamar.jhash.algorithms.Type;
//import com.amdelamar.jhash.exception.InvalidHashException;
//
//public class EncryptUtil {
//
// /**
// * 设置密文密码
// *
// * @param password 原始密码
// * @return 加密密码
// */
// public static String encrypt(String password) {
// char[] chars = password.toCharArray();
// return Hash.password(chars).algorithm(Type.PBKDF2_SHA256).create();
// }
//
// /**
// * 验证加密密码
// *
// * @param encryptedPassword 密文密码
// * @param plainPassword 明文密码
// * @return 验证是否成功
// */
// public static boolean verify(String encryptedPassword, String plainPassword) {
// char[] chars = plainPassword.toCharArray();
// try {
// return Hash.password(chars).algorithm(Type.PBKDF2_SHA256).verify(encryptedPassword);
// } catch (InvalidHashException e) {
// return false;
// }
// }
//}
package com.subsidy.util;
import java.util.Arrays;
import java.util.List;
public class ExcelFormatUtils {
public static final List<String> memberList = Arrays.asList("序号", "成员名称","身份证号码", "性别", "账号", "联系方式", "签到次数", "课程进度", "学习时长(小时)","学习时长(分钟)","累计有效学习时长", "答疑数", "测试成绩", "总评价");
public static final List<String> signList = Arrays.asList("序号", "成员名称", "身份证号", "联系方式", "签到次数", "签到时间","最近签到ip地址","最近签到设备型号");
public static final List<String> scoreList = Arrays.asList("序号", "成员名称", "身份证号码", "联系方式", "测试成绩", "测试次数","开始时间","结束时间","测评时间", "总评价");
public static final List<String> answersList = Arrays.asList("序号", "提问", "答疑", "提问时间", "提问成员", "答疑时间");
public static final List<String> studyLogList = Arrays.asList("开始时间","结束时间","课程","类型","学习时长","累计有效时长");
}
package com.subsidy.util;
import com.google.common.hash.Hashing;
import org.apache.commons.codec.Charsets;
import java.util.Collections;
import java.util.List;
/**
* 人脸识别工具类
*/
public class ImageCheckUtil {
/**
* 签名方法
* @param values
* @param ticket
* @return
*/
public static String sign(List<String> values, String ticket) { //values传ticket外的其他参数
if (values == null) {
throw new NullPointerException("values is null");
}
values.removeAll(Collections.singleton(null));// remove null
values.add(ticket); java.util.Collections.sort(values);
StringBuilder sb = new StringBuilder();
for (String s : values) { sb.append(s);
}
return Hashing.sha1().hashString(sb,
Charsets.UTF_8).toString().toUpperCase();
}
}
package com.subsidy.util;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
import java.net.UnknownHostException;
public class IpAddressUtil {
/**
* 返回客户端ip
*/
public static String getIpAddress(HttpServletRequest request) {
String ipAddress = request.getHeader("x-forwarded-for");
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getHeader("Proxy-Client-IP");
}
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getHeader("WL-Proxy-Client-IP");
}
if (ipAddress == null || ipAddress.length() == 0 || "unknown".equalsIgnoreCase(ipAddress)) {
ipAddress = request.getRemoteAddr();
if (ipAddress.equals("127.0.0.1") || ipAddress.equals("0:0:0:0:0:0:0:1")) {
InetAddress inet = null;
try {
inet = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
ipAddress = inet.getHostAddress();
}
}
if (ipAddress != null && ipAddress.length() > 15) {
if (ipAddress.indexOf(",") > 0) {
ipAddress = ipAddress.substring(0, ipAddress.indexOf(","));
}
}
return ipAddress;
}
/**
* @Description:获取客户端外网ip
* @Author:zrt
* @Date:2019/6/13 11:23
**/
public static String getPublicIp() {
try {
String path = "http://subsidy.youkehulian.cn/";// 要获得html页面内容的地址
URL url = new URL(path);// 创建url对象
HttpURLConnection conn = (HttpURLConnection) url.openConnection();// 打开连接
conn.setRequestProperty("contentType", "GBK"); // 设置url中文参数编码
conn.setConnectTimeout(5 * 1000);// 请求的时间
conn.setRequestMethod("GET");// 请求方式
InputStream inStream = conn.getInputStream();
// readLesoSysXML(inStream);
BufferedReader in = new BufferedReader(new InputStreamReader(
inStream, "GBK"));
StringBuffer buffer = new StringBuffer();
String line = "";
// 读取获取到内容的最后一行,写入
while ((line = in.readLine()) != null) {
buffer.append(line);
}
String str = buffer.toString();
String ipString1 = str.substring(str.indexOf("["));
// 获取你的IP是中间的[182.149.82.50]内容
String ipsString2 = ipString1.substring(ipString1.indexOf("[") + 1,
ipString1.lastIndexOf("]"));
//获取当前IP地址所在地址
/* String ipsString3=ipString1.substring(ipString1.indexOf(": "),ipString1.lastIndexOf("</center>"));
System.err.println(ipsString3);*/
// 返回公网IP值
return ipsString2;
} catch (Exception e) {
System.out.println("获取公网IP连接超时");
return "连接超时";
}
}
}
package com.subsidy.util;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.Claim;
import java.util.Date;
import java.util.Map;
/**
* <p>
* Token工具
* </p>
*
* @author DengMin
* @since 2021/4/14
*/
public class JwtUtil {
private static Long EXPIRE_TIME = 24 * 60 * 60 * 1000L;
private static String SECRET = "PBKDF2SHA256:64000:18:24:N:GFHZ6Y0PTEUDYCJI3K6SOOXWYEKPOZED:WBWFJMX5DF252E0HR3BF3P/D";
/**
* 生成Token
* @param id
* @return
*/
public static String generateToken(Long id, String type) {
Date expireDate = new Date(System.currentTimeMillis() + EXPIRE_TIME);
return JWT.create()
.withClaim("id", id)
.withClaim("type", type)
.withAudience()
.withExpiresAt(expireDate)
.withIssuedAt(new Date())
.sign(Algorithm.HMAC256(SECRET));
}
/**
* 检验token是否正确
* @param token
* @return
*/
public static boolean verifyToken(String token) {
try {
Algorithm algorithm = Algorithm.HMAC256(SECRET);
JWTVerifier verifier = JWT.require(algorithm).build();
verifier.verify(token);
return true;
} catch (Exception e) {
return false;
}
}
/**
* 获取用户自定义Claim集合
* @param token
* @return
*/
public static Map<String, Claim> getClaims(String token) {
Algorithm algorithm = Algorithm.HMAC256(SECRET);
JWTVerifier verifier = JWT.require(algorithm).build();
Map<String, Claim> claims = verifier.verify(token).getClaims();
return claims;
}
/**
* 获取过期时间
* @param token
* @return
*/
public static Date getExpiresAt(String token) {
Algorithm algorithm = Algorithm.HMAC256(SECRET);
return JWT
.require(algorithm)
.build()
.verify(token)
.getExpiresAt();
}
/**
* 验证token是否失效
* @param token
* @return true: 过期, false: 没过期
*/
public static boolean isExpired(String token) {
try {
final Date expiration = getExpiresAt(token);
return expiration.before(new Date());
} catch (Exception e) {
return true;
}
}
}
package com.subsidy.util;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class Localstorage {
private static final ThreadLocal<Object> local = ThreadLocal.withInitial(() -> null);
public static void setUser(Object admin) {
Localstorage.local.set(admin);
}
public static Object getUser() {
return Localstorage.local.get();
}
public static void remove() {
Localstorage.local.remove();
}
}
package com.subsidy.util;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Random;
public class MathUtil {
public static String getRandomCode(int randomLength) {
StringBuilder str = new StringBuilder();
Random random = new Random();
for (int i = 0; i < randomLength; i++) {
str.append(random.nextInt(10));
}
return str.toString();
}
public static String getRandomString(int length) {
StringBuilder val = new StringBuilder();
Random random = new Random();
for (int i = 0; i < length; ++i) {
String charOrNum = random.nextInt(3) % 3 == 0 ? "num" : "char";
if ("char".equalsIgnoreCase(charOrNum)) {
int temp = random.nextInt(2) % 2 == 0 ? 65 : 97;
val.append((char) (random.nextInt(26) + temp));
} else {
val.append(random.nextInt(10));
}
}
return val.toString();
}
//习题/视频 ==> 秒钟向上取整
public static String ceilSecond(int length) {
return String.valueOf((int) Math.ceil((double) length / 60));
}
//习题/视频 ==> 秒钟向下取整
public static String floorSecond(int length) {
return String.valueOf((int) Math.floor((double) length / 60));
}
//视频秒数处理
public static String vodLength(int i) {
if (i > 60) {
if (i % 60 >= 10) {
return i / 60 + ":" + i % 60;
} else {
return i / 60 + ":0" + i % 60;
}
} else {
if (i % 60 >= 10) {
return "00:" + i;
} else {
return "00:0" + i;
}
}
}
//文件大小处理
public static String fileUnit(int i) {
if (i / 1024 > 1024) {
return String.format("%.2f", (double) i / 1024 / 1024) + "M";
} else {
return String.format("%.2f", (double) i / 1024) + "K";
}
}
//单个题目秒数处理
public static String exerciseLength(int i) {
if (i >= 60 * 60) {
return i / 60 / 60 + "时" + (i - 60 * 60) / 60 + "分" + i % 60 + "秒";
} else if (i >= 60) {
return i / 60 + "分" + i % 60 + "秒";
} else {
return i % 60 + "秒";
}
}
// 除法取整
public static String getAvgIndex(BigDecimal counts, BigDecimal total) {
if (BigDecimal.ZERO.equals(total)) {
return "0";
} else {
return counts.divide(total, RoundingMode.CEILING).stripTrailingZeros().toPlainString();
}
}
//百分比 取整 返回字符串
public static String getPercentAvgIndex(BigDecimal counts, BigDecimal total) {
if (BigDecimal.ZERO.equals(total) || BigDecimal.ZERO.equals(counts)) {
return "0%";
} else {
return counts.multiply(new BigDecimal(100)).divide(total, RoundingMode.CEILING).stripTrailingZeros().toPlainString() + "%";
}
}
//百分比 不带%输出
public static String getPercentAvgIndexWithPercent(BigDecimal counts, BigDecimal total) {
if (BigDecimal.ZERO.equals(total) || BigDecimal.ZERO.equals(counts)) {
return "0";
} else {
return counts.multiply(new BigDecimal(100)).divide(total, 2, BigDecimal.ROUND_HALF_UP).stripTrailingZeros().toPlainString();
}
}
//百分比 不带%输出
public static String getPercentAvgIndexCeil(BigDecimal counts, BigDecimal total) {
if (BigDecimal.ZERO.equals(total) || BigDecimal.ZERO.equals(counts)) {
return "0";
} else {
return counts.multiply(new BigDecimal(100)).divide(total, 2, BigDecimal.ROUND_CEILING).stripTrailingZeros().toPlainString();
}
}
//习题序号生成规则 sid 从数据取出某科目某知识点的最大的序号
public static String getExeCode(String sid) {
Integer integer = Integer.valueOf(sid.substring(9));
return sid.substring(0, 9) + (++integer);
}
// 整型a 整型b a/b 向上取整
public static Integer intDivCeil(long a, int b) {
return (int) Math.ceil((double) a / b);
}
// 整型a 整型b a/b 向下取整
public static Integer intDivFloorPercent(long a, int b) {
return (int) Math.floor((double) a * 100 / b);
}
public static Integer getRandomNum(Integer i) {
Random random = new Random();
return random.nextInt(i);
}
// public static void main(String[] args) {
// for (int i= 1;i<100;i++){
// System.out.println(getRandomNum(2));
// }
// }
public static String secToTime(int time) {
String timeStr ;
int hour;
int minute;
int second;
if (time <= 0) {
return "00:00:00";
} else {
minute = time / 60;
if (minute < 60) {
second = time % 60;
timeStr = "00:"+unitFormat(minute) + ":" + unitFormat(second);
} else {
hour = minute / 60;
minute = minute % 60;
second = time - hour * 3600 - minute * 60;
timeStr = unitFormat(hour) + ":" + unitFormat(minute) + ":" + unitFormat(second);
}
}
return timeStr;
}
public static String unitFormat(int i) {
String retStr = null;
if (i >= 0 && i < 10) {
retStr = "0" + i;
} else {
retStr = "" + i;
}
return retStr;
}
}
//package com.subsidy.util;
//
//import lombok.Data;
//import org.springframework.stereotype.Component;
//
//import java.util.List;
//import java.util.regex.Pattern;
//
//@Data
//@Component
//public class MongoUtil<T> {
// public Integer pageSize;
// private Integer currentPage;
//
//
// public void start(Integer currentPage, Integer pageSize, Query query) {
// pageSize = pageSize == 0 ? 10 : pageSize;
// query.limit(pageSize);
// query.skip((currentPage - 1) * pageSize);
// this.pageSize = pageSize;
// this.currentPage = currentPage;
// }
//
// public PageHelper pageHelper(long total, List<T> list) {
// return new PageHelper(this.currentPage, total, this.pageSize, list);
// }
//
// public PageHelper pageHelper(List<T> list) {
// return new PageHelper(this.currentPage, this.pageSize, list);
// }
//
// public PageHelper pageHelper(long currentPage, long total, long pageSize, List<T> list) {
// return new PageHelper(currentPage, total, pageSize, list);
// }
//
// public PageHelper pageHelper(long currentPage, long pageSize, List<T> list) {
// return new PageHelper(currentPage, pageSize, list);
// }
//
//
// /**
// * 用于模糊查询忽略大小写
// *
// * @param string
// * @return
// */
// public Pattern getPattern(String string) {
// Pattern pattern = Pattern.compile("^.*" + string + ".*$", Pattern.CASE_INSENSITIVE);
// return pattern;
// }
//
//}
package com.subsidy.util;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import java.beans.PropertyDescriptor;
import java.util.HashSet;
import java.util.Set;
public class MyBeanUtils {
public static String[] getNullPropertyNames (Object source) {
final BeanWrapper src = new BeanWrapperImpl(source);
PropertyDescriptor[] pds = src.getPropertyDescriptors();
Set<String> emptyNames = new HashSet<>();
for(PropertyDescriptor pd : pds) {
Object srcValue = src.getPropertyValue(pd.getName());
// 此处判断可根据需求修改
if (srcValue == null) {
emptyNames.add(pd.getName());
}
}
String[] result = new String[emptyNames.size()];
return emptyNames.toArray(result);
}
}
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
This file is too large to display.
No preview for this file type
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!