v3.0.6
This commit is contained in:
29
source/xzs/.gitignore
vendored
Normal file
29
source/xzs/.gitignore
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
/target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/build/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
|
||||
### Customer ###
|
||||
/logs/
|
||||
225
source/xzs/mvnw
vendored
Normal file
225
source/xzs/mvnw
vendored
Normal file
@@ -0,0 +1,225 @@
|
||||
#!/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
|
||||
#
|
||||
# http://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.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven2 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 Migwn, 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)`"
|
||||
# TODO classpath?
|
||||
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
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
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
|
||||
|
||||
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 "$@"
|
||||
143
source/xzs/mvnw.cmd
vendored
Normal file
143
source/xzs/mvnw.cmd
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
@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 http://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 Maven2 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 key stroke 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 enable echoing my 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
|
||||
|
||||
%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%
|
||||
184
source/xzs/pom.xml
Normal file
184
source/xzs/pom.xml
Normal file
@@ -0,0 +1,184 @@
|
||||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.mindskip</groupId>
|
||||
<artifactId>xzs</artifactId>
|
||||
<version>3.0.6</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>xzs</name>
|
||||
<description>武汉思维跳跃科技-学之思考试系统</description>
|
||||
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<java.version>1.8</java.version>
|
||||
<mysql.version>8.0.17</mysql.version>
|
||||
<spring.boot.version>2.1.6.RELEASE</spring.boot.version>
|
||||
</properties>
|
||||
|
||||
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.6.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nexus-aliyun</id>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-cache</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-undertow</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.session</groupId>
|
||||
<artifactId>spring-session-data-redis</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.2.12</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>${mysql.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-pool2</artifactId>
|
||||
<version>2.6.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.9</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.modelmapper</groupId>
|
||||
<artifactId>modelmapper</artifactId>
|
||||
<version>2.3.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.8</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.9</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.qiniu</groupId>
|
||||
<artifactId>qiniu-java-sdk</artifactId>
|
||||
<version>7.2.25</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- hot debug -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<configuration>
|
||||
<fork>true</fork>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<skipTests>true</skipTests>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mindskip.xzs;
|
||||
|
||||
import com.mindskip.xzs.configuration.property.SystemConfig;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableTransactionManagement
|
||||
@EnableConfigurationProperties(value = { SystemConfig.class})
|
||||
@EnableCaching
|
||||
public class XzsApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(XzsApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mindskip.xzs.base;
|
||||
|
||||
|
||||
import com.mindskip.xzs.context.WebContext;
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.utility.ModelMapperSingle;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
public class BaseApiController {
|
||||
protected final static String DEFAULT_PAGE_SIZE = "10";
|
||||
protected final static ModelMapper modelMapper = ModelMapperSingle.Instance();
|
||||
@Autowired
|
||||
protected WebContext webContext;
|
||||
|
||||
protected User getCurrentUser() {
|
||||
return webContext.getCurrentUser();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mindskip.xzs.base;
|
||||
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
public abstract class BaseEntity {
|
||||
|
||||
}
|
||||
15
source/xzs/src/main/java/com/mindskip/xzs/base/BasePage.java
Normal file
15
source/xzs/src/main/java/com/mindskip/xzs/base/BasePage.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.mindskip.xzs.base;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class BasePage {
|
||||
private Integer pageIndex;
|
||||
|
||||
private Integer pageSize;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.mindskip.xzs.base;
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
public class RestResponse<T> {
|
||||
private int code;
|
||||
private String message;
|
||||
private T response;
|
||||
|
||||
public RestResponse(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public RestResponse(int code, String message, T response) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public static RestResponse fail(Integer code, String msg) {
|
||||
return new RestResponse<>(code, msg);
|
||||
}
|
||||
|
||||
public static RestResponse ok() {
|
||||
SystemCode systemCode = SystemCode.OK;
|
||||
return new RestResponse<>(systemCode.getCode(), systemCode.getMessage());
|
||||
}
|
||||
|
||||
public static <F> RestResponse<F> ok(F response) {
|
||||
SystemCode systemCode = SystemCode.OK;
|
||||
return new RestResponse<>(systemCode.getCode(), systemCode.getMessage(), response);
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public T getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setResponse(T response) {
|
||||
this.response = response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.mindskip.xzs.base;
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
public enum SystemCode {
|
||||
/**
|
||||
* OK
|
||||
*/
|
||||
OK(1, "成功"),
|
||||
/**
|
||||
* AccessTokenError
|
||||
*/
|
||||
AccessTokenError(400, "用户登录令牌失效"),
|
||||
/**
|
||||
* UNAUTHORIZED
|
||||
*/
|
||||
UNAUTHORIZED(401, "用户未登录"),
|
||||
/**
|
||||
* UNAUTHORIZED
|
||||
*/
|
||||
AuthError(402, "用户名或密码错误"),
|
||||
/**
|
||||
* InnerError
|
||||
*/
|
||||
InnerError(500, "系统内部错误"),
|
||||
/**
|
||||
* ParameterValidError
|
||||
*/
|
||||
ParameterValidError(501, "参数验证错误"),
|
||||
|
||||
/**
|
||||
* AccessDenied
|
||||
*/
|
||||
AccessDenied(502,"用户没有权限访问");
|
||||
|
||||
int code;
|
||||
String message;
|
||||
|
||||
SystemCode(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.mindskip.xzs.configuration.application;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
@Component
|
||||
public class ApplicationContextProvider implements ApplicationContextAware {
|
||||
private static ApplicationContext context;
|
||||
|
||||
private ApplicationContextProvider() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
context = applicationContext;
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> aClass) {
|
||||
return context.getBean(aClass);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getBean(String name) {
|
||||
return (T) context.getBean(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.mindskip.xzs.configuration.property;
|
||||
|
||||
public class CookieConfig {
|
||||
|
||||
public static String getName() {
|
||||
return "exam";
|
||||
}
|
||||
|
||||
public static Integer getInterval() {
|
||||
return 30 * 24 * 60 * 60;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mindskip.xzs.configuration.property;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PasswordKeyConfig {
|
||||
private String publicKey;
|
||||
private String privateKey;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mindskip.xzs.configuration.property;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class QnConfig {
|
||||
private String url;
|
||||
private String bucket;
|
||||
private String accessKey;
|
||||
private String secretKey;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.mindskip.xzs.configuration.property;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "system")
|
||||
@Data
|
||||
public class SystemConfig {
|
||||
private PasswordKeyConfig pwdKey;
|
||||
private List<String> securityIgnoreUrls;
|
||||
private WxConfig wx;
|
||||
private QnConfig qn;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mindskip.xzs.configuration.property;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class WxConfig {
|
||||
private String appid;
|
||||
private String secret;
|
||||
private Duration tokenToLive;
|
||||
private List<String> securityIgnoreUrls;
|
||||
}
|
||||
78
source/xzs/src/main/java/com/mindskip/xzs/configuration/spring/cache/CacheConfig.java
vendored
Normal file
78
source/xzs/src/main/java/com/mindskip/xzs/configuration/spring/cache/CacheConfig.java
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
package com.mindskip.xzs.configuration.spring.cache;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.cache.CacheProperties;
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.interceptor.KeyGenerator;
|
||||
import org.springframework.cache.interceptor.SimpleKey;
|
||||
import org.springframework.cache.interceptor.SimpleKeyGenerator;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.cache.CacheKeyPrefix;
|
||||
import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.serializer.*;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class CacheConfig extends CachingConfigurerSupport {
|
||||
|
||||
/* @Autowired
|
||||
private CacheProperties cacheProperties;*/
|
||||
|
||||
/**
|
||||
* redis序列化修改为ObjectMapper
|
||||
*
|
||||
* @return RedisCacheConfiguration
|
||||
*/
|
||||
/* @Bean
|
||||
public RedisCacheConfiguration redisCacheConfiguration() {
|
||||
Jackson2JsonRedisSerializer<Object> serializer = new Jackson2JsonRedisSerializer<Object>(Object.class);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
|
||||
serializer.setObjectMapper(objectMapper);
|
||||
return RedisCacheConfiguration.defaultCacheConfig().entryTtl(cacheProperties.getRedis().getTimeToLive())
|
||||
.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(serializer));
|
||||
}*/
|
||||
|
||||
|
||||
/**
|
||||
* spring boot redis默认序列化方式
|
||||
*
|
||||
* @return RedisTemplate
|
||||
*/
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> getRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
final RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||
redisTemplate.setKeySerializer(RedisSerializer.string());
|
||||
redisTemplate.setHashKeySerializer(RedisSerializer.string());
|
||||
redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
|
||||
redisTemplate.afterPropertiesSet();
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* spring redis 默认生成key方式,包含::号
|
||||
*
|
||||
* @param prefix
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public String simpleKeyGenerator(String prefix, String key) {
|
||||
return CacheKeyPrefix.simple().compute(prefix) + key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.mindskip.xzs.configuration.spring.exception;
|
||||
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.base.SystemCode;
|
||||
import com.mindskip.xzs.utility.ErrorUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.validation.BindException;
|
||||
import org.springframework.validation.FieldError;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ControllerAdvice
|
||||
public class ExceptionHandle {
|
||||
private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class);
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
@ResponseBody
|
||||
public RestResponse handler(Exception e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
return new RestResponse<>(SystemCode.InnerError.getCode(), SystemCode.InnerError.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
@ResponseBody
|
||||
public RestResponse handler(MethodArgumentNotValidException e) {
|
||||
String errorMsg = e.getBindingResult().getAllErrors().stream().map(file -> {
|
||||
FieldError fieldError = (FieldError) file;
|
||||
return ErrorUtil.parameterErrorFormat(fieldError.getField(), fieldError.getDefaultMessage());
|
||||
}).collect(Collectors.joining());
|
||||
return new RestResponse<>(SystemCode.ParameterValidError.getCode(), errorMsg);
|
||||
}
|
||||
|
||||
@ExceptionHandler(BindException.class)
|
||||
@ResponseBody
|
||||
public RestResponse handler(BindException e) {
|
||||
String errorMsg = e.getBindingResult().getAllErrors().stream().map(file -> {
|
||||
FieldError fieldError = (FieldError) file;
|
||||
return ErrorUtil.parameterErrorFormat(fieldError.getField(), fieldError.getDefaultMessage());
|
||||
}).collect(Collectors.joining());
|
||||
return new RestResponse<>(SystemCode.ParameterValidError.getCode(), errorMsg);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.mindskip.xzs.configuration.spring.mvc;
|
||||
|
||||
import com.mindskip.xzs.configuration.property.SystemConfig;
|
||||
import com.mindskip.xzs.configuration.spring.wx.TokenHandlerInterceptor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
|
||||
@Configuration
|
||||
@AllArgsConstructor
|
||||
public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||
|
||||
private final TokenHandlerInterceptor tokenHandlerInterceptor;
|
||||
private final SystemConfig systemConfig;
|
||||
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
registry.addRedirectViewController("/", "/student/index.html");
|
||||
registry.addRedirectViewController("/student", "/student/index.html");
|
||||
registry.addRedirectViewController("/admin", "/admin/index.html");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("/**")
|
||||
.addResourceLocations("classpath:/static/")
|
||||
.setCachePeriod(31556926);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
List<String> securityIgnoreUrls = systemConfig.getWx().getSecurityIgnoreUrls();
|
||||
String[] ignores = new String[securityIgnoreUrls.size()];
|
||||
registry.addInterceptor(tokenHandlerInterceptor)
|
||||
.addPathPatterns("/api/wx/**")
|
||||
.excludePathPatterns(securityIgnoreUrls.toArray(ignores));
|
||||
super.addInterceptors(registry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**")
|
||||
.allowCredentials(true)
|
||||
.allowedMethods("*")
|
||||
.allowedOrigins("*")
|
||||
.allowedHeaders("*");
|
||||
super.addCorsMappings(registry);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.mindskip.xzs.configuration.spring.security;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class AuthenticationBean {
|
||||
private String userName;
|
||||
private String password;
|
||||
private boolean remember;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mindskip.xzs.configuration.spring.security;
|
||||
|
||||
import com.mindskip.xzs.base.SystemCode;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 未登录
|
||||
* @author alvis
|
||||
*/
|
||||
@Component
|
||||
public final class LoginAuthenticationEntryPoint extends LoginUrlAuthenticationEntryPoint {
|
||||
|
||||
public LoginAuthenticationEntryPoint() {
|
||||
super("/api/user/login");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException authException) throws IOException, ServletException {
|
||||
RestUtil.response(response, SystemCode.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mindskip.xzs.configuration.spring.security;
|
||||
|
||||
import com.mindskip.xzs.base.SystemCode;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.web.access.AccessDeniedHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 没权限
|
||||
*/
|
||||
@Component
|
||||
public class RestAccessDeniedHandler implements AccessDeniedHandler {
|
||||
@Override
|
||||
public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException {
|
||||
RestUtil.response(httpServletResponse, SystemCode.AccessDenied);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mindskip.xzs.configuration.spring.security;
|
||||
|
||||
import com.mindskip.xzs.base.SystemCode;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* 账号验证异常
|
||||
* @author alvis
|
||||
*/
|
||||
@Component
|
||||
public class RestAuthenticationFailureHandler extends SimpleUrlAuthenticationFailureHandler {
|
||||
|
||||
@Override
|
||||
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException exception) throws IOException, ServletException {
|
||||
RestUtil.response(response, SystemCode.AuthError.getCode(), exception.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.mindskip.xzs.configuration.spring.security;
|
||||
|
||||
|
||||
import com.mindskip.xzs.context.WebContext;
|
||||
import com.mindskip.xzs.domain.enums.RoleEnum;
|
||||
import com.mindskip.xzs.domain.enums.UserStatusEnum;
|
||||
import com.mindskip.xzs.service.AuthenticationService;
|
||||
import com.mindskip.xzs.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationProvider;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.LockedException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 登录用户名密码验证
|
||||
*
|
||||
* @author : Alvis
|
||||
* Description : 身份验证
|
||||
* Creation Date: 2018-05-02 5:00 PM
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class RestAuthenticationProvider implements AuthenticationProvider {
|
||||
|
||||
private final AuthenticationService authenticationService;
|
||||
private final UserService userService;
|
||||
private final WebContext webContext;
|
||||
|
||||
@Autowired
|
||||
public RestAuthenticationProvider(AuthenticationService authenticationService, UserService userService, WebContext webContext) {
|
||||
this.authenticationService = authenticationService;
|
||||
this.userService = userService;
|
||||
this.webContext = webContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
||||
String username = authentication.getName();
|
||||
String password = (String) authentication.getCredentials();
|
||||
|
||||
com.mindskip.xzs.domain.User user = userService.getUserByUserName(username);
|
||||
if (user == null) {
|
||||
throw new UsernameNotFoundException("用户名或密码错误");
|
||||
}
|
||||
|
||||
boolean result = authenticationService.authUser(user, username, password);
|
||||
if (!result) {
|
||||
throw new BadCredentialsException("用户名或密码错误");
|
||||
}
|
||||
|
||||
UserStatusEnum userStatusEnum = UserStatusEnum.fromCode(user.getStatus());
|
||||
if (UserStatusEnum.Disable == userStatusEnum) {
|
||||
throw new LockedException("用户被禁用");
|
||||
}
|
||||
|
||||
ArrayList<GrantedAuthority> grantedAuthorities = new ArrayList<>();
|
||||
grantedAuthorities.add(new SimpleGrantedAuthority(RoleEnum.fromCode(user.getRole()).getRoleName()));
|
||||
|
||||
User authUser = new User(user.getUserName(), user.getPassword(), grantedAuthorities);
|
||||
return new UsernamePasswordAuthenticationToken(authUser, authUser.getPassword(), authUser.getAuthorities());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> aClass) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.mindskip.xzs.configuration.spring.security;
|
||||
|
||||
import com.mindskip.xzs.base.SystemCode;
|
||||
import com.mindskip.xzs.domain.UserEventLog;
|
||||
import com.mindskip.xzs.event.UserEvent;
|
||||
import com.mindskip.xzs.service.UserService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 登录成功返回
|
||||
*
|
||||
* @author alvis
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class RestAuthenticationSuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
|
||||
|
||||
private final ApplicationEventPublisher eventPublisher;
|
||||
private final UserService userService;
|
||||
|
||||
@Override
|
||||
public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException, ServletException {
|
||||
User springUser = (User) authentication.getPrincipal();
|
||||
com.mindskip.xzs.domain.User user = userService.getUserByUserName(springUser.getUsername());
|
||||
UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date());
|
||||
userEventLog.setContent(user.getUserName() + " 登录了学之思考试系统");
|
||||
eventPublisher.publishEvent(new UserEvent(userEventLog));
|
||||
com.mindskip.xzs.domain.User newUser = new com.mindskip.xzs.domain.User();
|
||||
newUser.setUserName(user.getUserName());
|
||||
newUser.setImagePath(user.getImagePath());
|
||||
RestUtil.response(response, SystemCode.OK.getCode(), SystemCode.OK.getMessage(), newUser);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.mindskip.xzs.configuration.spring.security;
|
||||
|
||||
import com.mindskip.xzs.domain.enums.RoleEnum;
|
||||
import com.mindskip.xzs.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author : Alvis
|
||||
* Description : 验证通过之后,第二、三...请求,会调用此类
|
||||
* Creation Date: 2018-05-02 4:32 PM
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class RestDetailsServiceImpl implements UserDetailsService {
|
||||
|
||||
private final UserService userService;
|
||||
|
||||
@Autowired
|
||||
public RestDetailsServiceImpl(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
|
||||
com.mindskip.xzs.domain.User user = userService.getUserByUserName(username);
|
||||
|
||||
if (user == null) {
|
||||
throw new UsernameNotFoundException("Username not found.");
|
||||
}
|
||||
|
||||
ArrayList<GrantedAuthority> grantedAuthorities = new ArrayList<>();
|
||||
grantedAuthorities.add(new SimpleGrantedAuthority(RoleEnum.fromCode(user.getRole()).getRoleName()));
|
||||
|
||||
return new User(user.getUserName(), user.getPassword(), grantedAuthorities);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.mindskip.xzs.configuration.spring.security;
|
||||
|
||||
import com.mindskip.xzs.configuration.property.CookieConfig;
|
||||
|
||||
import com.mindskip.xzs.utility.JsonUtil;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
|
||||
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices;
|
||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* 登录参数序列化
|
||||
* @author alvis
|
||||
*/
|
||||
|
||||
public class RestLoginAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
|
||||
private final org.slf4j.Logger logger = LoggerFactory.getLogger(RestLoginAuthenticationFilter.class);
|
||||
|
||||
public RestLoginAuthenticationFilter() {
|
||||
super(new AntPathRequestMatcher("/api/user/login", "POST"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
|
||||
UsernamePasswordAuthenticationToken authRequest;
|
||||
try (InputStream is = request.getInputStream()) {
|
||||
AuthenticationBean authenticationBean = JsonUtil.toJsonObject(is, AuthenticationBean.class);
|
||||
request.setAttribute(TokenBasedRememberMeServices.DEFAULT_PARAMETER, authenticationBean.isRemember());
|
||||
authRequest = new UsernamePasswordAuthenticationToken(authenticationBean.getUserName(), authenticationBean.getPassword());
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
authRequest = new UsernamePasswordAuthenticationToken("", "");
|
||||
}
|
||||
setDetails(request, authRequest);
|
||||
return this.getAuthenticationManager().authenticate(authRequest);
|
||||
|
||||
}
|
||||
|
||||
void setUserDetailsService(UserDetailsService userDetailsService) {
|
||||
RestTokenBasedRememberMeServices tokenBasedRememberMeServices = new RestTokenBasedRememberMeServices(CookieConfig.getName(), userDetailsService);
|
||||
tokenBasedRememberMeServices.setTokenValiditySeconds(CookieConfig.getInterval());
|
||||
setRememberMeServices(tokenBasedRememberMeServices);
|
||||
}
|
||||
|
||||
private void setDetails(HttpServletRequest request, UsernamePasswordAuthenticationToken authRequest) {
|
||||
authRequest.setDetails(authenticationDetailsSource.buildDetails(request));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.mindskip.xzs.configuration.spring.security;
|
||||
|
||||
import com.mindskip.xzs.base.SystemCode;
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.domain.UserEventLog;
|
||||
import com.mindskip.xzs.event.UserEvent;
|
||||
import com.mindskip.xzs.service.UserService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 用户登出
|
||||
*
|
||||
* @author alvis
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class RestLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler {
|
||||
|
||||
private final ApplicationEventPublisher eventPublisher;
|
||||
private final UserService userService;
|
||||
|
||||
@Override
|
||||
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||
org.springframework.security.core.userdetails.User springUser = (org.springframework.security.core.userdetails.User) authentication.getPrincipal();
|
||||
if (null != springUser) {
|
||||
User user = userService.getUserByUserName(springUser.getUsername());
|
||||
UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date());
|
||||
userEventLog.setContent(user.getUserName() + " 登出了学之思考试系统");
|
||||
eventPublisher.publishEvent(new UserEvent(userEventLog));
|
||||
}
|
||||
RestUtil.response(response, SystemCode.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mindskip.xzs.configuration.spring.security;
|
||||
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 记住我,Cookie
|
||||
* @author alvis
|
||||
*/
|
||||
public class RestTokenBasedRememberMeServices extends TokenBasedRememberMeServices {
|
||||
public RestTokenBasedRememberMeServices(String key, UserDetailsService userDetailsService) {
|
||||
super(key, userDetailsService);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean rememberMeRequested(HttpServletRequest request, String parameter) {
|
||||
return (boolean) request.getAttribute(DEFAULT_PARAMETER);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mindskip.xzs.configuration.spring.security;
|
||||
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.base.SystemCode;
|
||||
import com.mindskip.xzs.utility.JsonUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
public class RestUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(RestUtil.class);
|
||||
|
||||
|
||||
public static void response(HttpServletResponse response, SystemCode systemCode) {
|
||||
response(response, systemCode.getCode(), systemCode.getMessage());
|
||||
}
|
||||
|
||||
public static void response(HttpServletResponse response, int systemCode, String msg) {
|
||||
response(response, systemCode, msg, null);
|
||||
}
|
||||
|
||||
|
||||
public static void response(HttpServletResponse response, int systemCode, String msg, Object content) {
|
||||
try {
|
||||
RestResponse res = new RestResponse<>(systemCode, msg, content);
|
||||
String resStr = JsonUtil.toJsonStr(res);
|
||||
response.setContentType("application/json;charset=utf-8");
|
||||
response.getWriter().write(resStr);
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.mindskip.xzs.configuration.spring.security;
|
||||
|
||||
import com.mindskip.xzs.configuration.property.CookieConfig;
|
||||
import com.mindskip.xzs.configuration.property.SystemConfig;
|
||||
import com.mindskip.xzs.domain.enums.RoleEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.CorsConfigurationSource;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class SecurityConfigurer {
|
||||
|
||||
@Configuration
|
||||
@AllArgsConstructor
|
||||
public static class FormLoginWebSecurityConfigurerAdapter extends WebSecurityConfigurerAdapter {
|
||||
|
||||
private final SystemConfig systemConfig;
|
||||
private final LoginAuthenticationEntryPoint restAuthenticationEntryPoint;
|
||||
private final RestAuthenticationProvider restAuthenticationProvider;
|
||||
private final RestDetailsServiceImpl formDetailsService;
|
||||
private final RestAuthenticationSuccessHandler restAuthenticationSuccessHandler;
|
||||
private final RestAuthenticationFailureHandler restAuthenticationFailureHandler;
|
||||
private final RestLogoutSuccessHandler restLogoutSuccessHandler;
|
||||
private final RestAccessDeniedHandler restAccessDeniedHandler;
|
||||
|
||||
/**
|
||||
* @param http http
|
||||
* @throws Exception exception
|
||||
* csrf is the from submit get method
|
||||
*/
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.headers().frameOptions().disable();
|
||||
|
||||
List<String> securityIgnoreUrls = systemConfig.getSecurityIgnoreUrls();
|
||||
String[] ignores = new String[securityIgnoreUrls.size()];
|
||||
http
|
||||
.addFilterAt(authenticationFilter(), UsernamePasswordAuthenticationFilter.class)
|
||||
.exceptionHandling().authenticationEntryPoint(restAuthenticationEntryPoint)
|
||||
.and().authenticationProvider(restAuthenticationProvider)
|
||||
.authorizeRequests()
|
||||
.antMatchers(securityIgnoreUrls.toArray(ignores)).permitAll()
|
||||
.antMatchers("/api/admin/**").hasRole(RoleEnum.ADMIN.getName())
|
||||
.antMatchers("/api/student/**").hasRole(RoleEnum.STUDENT.getName())
|
||||
.anyRequest().permitAll()
|
||||
.and().exceptionHandling().accessDeniedHandler(restAccessDeniedHandler)
|
||||
.and().formLogin().successHandler(restAuthenticationSuccessHandler).failureHandler(restAuthenticationFailureHandler)
|
||||
.and().logout().logoutUrl("/api/user/logout").logoutSuccessHandler(restLogoutSuccessHandler).invalidateHttpSession(true)
|
||||
.and().rememberMe().key(CookieConfig.getName()).tokenValiditySeconds(CookieConfig.getInterval()).userDetailsService(formDetailsService)
|
||||
.and().csrf().disable()
|
||||
.cors();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public CorsConfigurationSource corsConfigurationSource() {
|
||||
final CorsConfiguration configuration = new CorsConfiguration();
|
||||
configuration.setMaxAge(3600L);
|
||||
configuration.setAllowedOrigins(Collections.singletonList("*"));
|
||||
configuration.setAllowedMethods(Collections.singletonList("*"));
|
||||
configuration.setAllowCredentials(true);
|
||||
configuration.setAllowedHeaders(Collections.singletonList("*"));
|
||||
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
source.registerCorsConfiguration("/api/**", configuration);
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public RestLoginAuthenticationFilter authenticationFilter() throws Exception {
|
||||
RestLoginAuthenticationFilter authenticationFilter = new RestLoginAuthenticationFilter();
|
||||
authenticationFilter.setAuthenticationSuccessHandler(restAuthenticationSuccessHandler);
|
||||
authenticationFilter.setAuthenticationFailureHandler(restAuthenticationFailureHandler);
|
||||
authenticationFilter.setAuthenticationManager(authenticationManagerBean());
|
||||
authenticationFilter.setUserDetailsService(formDetailsService);
|
||||
return authenticationFilter;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.mindskip.xzs.configuration.spring.wx;
|
||||
|
||||
import com.mindskip.xzs.base.SystemCode;
|
||||
import com.mindskip.xzs.configuration.spring.security.RestUtil;
|
||||
import com.mindskip.xzs.context.WxContext;
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.domain.UserToken;
|
||||
import com.mindskip.xzs.service.UserService;
|
||||
import com.mindskip.xzs.service.UserTokenService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Date;
|
||||
|
||||
@Component
|
||||
public class TokenHandlerInterceptor implements HandlerInterceptor {
|
||||
|
||||
private final UserTokenService userTokenService;
|
||||
private final UserService userService;
|
||||
private final WxContext wxContext;
|
||||
|
||||
@Autowired
|
||||
public TokenHandlerInterceptor(UserTokenService userTokenService, UserService userService, WxContext wxContext) {
|
||||
this.userTokenService = userTokenService;
|
||||
this.userService = userService;
|
||||
this.wxContext = wxContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
String token = request.getHeader("token");
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
RestUtil.response(response, SystemCode.UNAUTHORIZED);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(token)) {
|
||||
RestUtil.response(response, SystemCode.UNAUTHORIZED);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (token.length() != 36) {
|
||||
RestUtil.response(response, SystemCode.UNAUTHORIZED);
|
||||
return false;
|
||||
}
|
||||
|
||||
UserToken userToken = userTokenService.getToken(token);
|
||||
if (null == userToken) {
|
||||
RestUtil.response(response, SystemCode.UNAUTHORIZED);
|
||||
return false;
|
||||
}
|
||||
|
||||
Date now = new Date();
|
||||
User user = userService.getUserByUserName(userToken.getUserName());
|
||||
if (now.before(userToken.getEndTime())) {
|
||||
wxContext.setContext(user,userToken);
|
||||
return true;
|
||||
} else { //refresh token
|
||||
UserToken refreshToken = userTokenService.insertUserToken(user);
|
||||
RestUtil.response(response, SystemCode.AccessTokenError.getCode(), SystemCode.AccessTokenError.getMessage(), refreshToken.getToken());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mindskip.xzs.context;
|
||||
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.service.UserService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class WebContext {
|
||||
private static final String USER_ATTRIBUTES = "USER_ATTRIBUTES";
|
||||
private final UserService userService;
|
||||
|
||||
|
||||
public void setCurrentUser(User user) {
|
||||
RequestContextHolder.currentRequestAttributes().setAttribute(USER_ATTRIBUTES, user, RequestAttributes.SCOPE_REQUEST);
|
||||
}
|
||||
|
||||
public User getCurrentUser() {
|
||||
User user = (User) RequestContextHolder.currentRequestAttributes().getAttribute(USER_ATTRIBUTES, RequestAttributes.SCOPE_REQUEST);
|
||||
if (null != user) {
|
||||
return user;
|
||||
} else {
|
||||
org.springframework.security.core.userdetails.User springUser = (org.springframework.security.core.userdetails.User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||
if (null == springUser) {
|
||||
return null;
|
||||
}
|
||||
user = userService.getUserByUserName(springUser.getUsername());
|
||||
if (null != user) {
|
||||
setCurrentUser(user);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mindskip.xzs.context;
|
||||
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.domain.UserToken;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
@Component
|
||||
public class WxContext {
|
||||
|
||||
private static final String USER_ATTRIBUTES = "USER_ATTRIBUTES";
|
||||
private static final String USER_TOKEN_ATTRIBUTES = "USER_TOKEN_ATTRIBUTES";
|
||||
|
||||
|
||||
public void setContext(User user, UserToken userToken) {
|
||||
RequestContextHolder.currentRequestAttributes().setAttribute(USER_ATTRIBUTES, user, RequestAttributes.SCOPE_REQUEST);
|
||||
RequestContextHolder.currentRequestAttributes().setAttribute(USER_TOKEN_ATTRIBUTES, userToken, RequestAttributes.SCOPE_REQUEST);
|
||||
}
|
||||
|
||||
public User getCurrentUser() {
|
||||
return (User) RequestContextHolder.currentRequestAttributes().getAttribute(USER_ATTRIBUTES, RequestAttributes.SCOPE_REQUEST);
|
||||
}
|
||||
|
||||
public UserToken getCurrentUserToken() {
|
||||
return (UserToken) RequestContextHolder.currentRequestAttributes().getAttribute(USER_TOKEN_ATTRIBUTES, RequestAttributes.SCOPE_REQUEST);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.mindskip.xzs.controller;
|
||||
|
||||
import com.mindskip.xzs.base.SystemCode;
|
||||
import org.springframework.boot.autoconfigure.web.ErrorProperties;
|
||||
import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController;
|
||||
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
public class ErrorController extends BasicErrorController {
|
||||
|
||||
private static final String PATH = "/error";
|
||||
|
||||
public ErrorController() {
|
||||
super(new DefaultErrorAttributes(), new ErrorProperties());
|
||||
}
|
||||
|
||||
@RequestMapping(produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||
@ResponseBody
|
||||
public ResponseEntity<Map<String, Object>> error(HttpServletRequest request) {
|
||||
Map<String, Object> error = new HashMap<>(2);
|
||||
error.put("code", SystemCode.InnerError.getCode());
|
||||
error.put("message", SystemCode.InnerError.getMessage());
|
||||
return new ResponseEntity<>(error, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorPath() {
|
||||
return PATH;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.mindskip.xzs.controller.admin;
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.service.*;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.viewmodel.admin.dashboard.IndexVM;
|
||||
import com.mindskip.xzs.service.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController("AdminDashboardController")
|
||||
@RequestMapping(value = "/api/admin/dashboard")
|
||||
@AllArgsConstructor
|
||||
public class DashboardController extends BaseApiController {
|
||||
|
||||
|
||||
private final ExamPaperService examPaperService;
|
||||
private final QuestionService questionService;
|
||||
private final ExamPaperAnswerService examPaperAnswerService;
|
||||
private final ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService;
|
||||
private final UserEventLogService userEventLogService;
|
||||
|
||||
@RequestMapping(value = "/index", method = RequestMethod.POST)
|
||||
public RestResponse<IndexVM> Index() {
|
||||
IndexVM vm = new IndexVM();
|
||||
|
||||
Integer examPaperCount = examPaperService.selectAllCount();
|
||||
Integer questionCount = questionService.selectAllCount();
|
||||
Integer doExamPaperCount = examPaperAnswerService.selectAllCount();
|
||||
Integer doQuestionCount = examPaperQuestionCustomerAnswerService.selectAllCount();
|
||||
|
||||
vm.setExamPaperCount(examPaperCount);
|
||||
vm.setQuestionCount(questionCount);
|
||||
vm.setDoExamPaperCount(doExamPaperCount);
|
||||
vm.setDoQuestionCount(doQuestionCount);
|
||||
|
||||
List<Integer> mothDayUserActionValue = userEventLogService.selectMothCount();
|
||||
List<Integer> mothDayDoExamQuestionValue = examPaperQuestionCustomerAnswerService.selectMothCount();
|
||||
vm.setMothDayUserActionValue(mothDayUserActionValue);
|
||||
vm.setMothDayDoExamQuestionValue(mothDayDoExamQuestionValue);
|
||||
|
||||
vm.setMothDayText(DateTimeUtil.MothDay());
|
||||
return RestResponse.ok(vm);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.mindskip.xzs.controller.admin;
|
||||
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.domain.Subject;
|
||||
import com.mindskip.xzs.service.SubjectService;
|
||||
import com.mindskip.xzs.utility.PageInfoHelper;
|
||||
import com.mindskip.xzs.viewmodel.admin.education.SubjectEditRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.admin.education.SubjectPageRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.admin.education.SubjectResponseVM;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController("AdminEducationController")
|
||||
@RequestMapping(value = "/api/admin/education")
|
||||
@AllArgsConstructor
|
||||
public class EducationController extends BaseApiController {
|
||||
|
||||
private final SubjectService subjectService;
|
||||
|
||||
@RequestMapping(value = "/subject/list", method = RequestMethod.POST)
|
||||
public RestResponse<List<Subject>> list() {
|
||||
List<Subject> subjects = subjectService.allSubject();
|
||||
return RestResponse.ok(subjects);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/subject/page", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<SubjectResponseVM>> pageList(@RequestBody SubjectPageRequestVM model) {
|
||||
PageInfo<Subject> pageInfo = subjectService.page(model);
|
||||
PageInfo<SubjectResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> modelMapper.map(e, SubjectResponseVM.class));
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/subject/edit", method = RequestMethod.POST)
|
||||
public RestResponse edit(@RequestBody @Valid SubjectEditRequestVM model) {
|
||||
Subject subject = modelMapper.map(model, Subject.class);
|
||||
if (model.getId() == null) {
|
||||
subject.setDeleted(false);
|
||||
subjectService.insertByFilter(subject);
|
||||
} else {
|
||||
subjectService.updateByIdFilter(subject);
|
||||
}
|
||||
return RestResponse.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/subject/select/{id}", method = RequestMethod.POST)
|
||||
public RestResponse<SubjectEditRequestVM> select(@PathVariable Integer id) {
|
||||
Subject subject = subjectService.selectById(id);
|
||||
SubjectEditRequestVM vm = modelMapper.map(subject, SubjectEditRequestVM.class);
|
||||
return RestResponse.ok(vm);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/subject/delete/{id}", method = RequestMethod.POST)
|
||||
public RestResponse delete(@PathVariable Integer id) {
|
||||
Subject subject = subjectService.selectById(id);
|
||||
subject.setDeleted(true);
|
||||
subjectService.updateByIdFilter(subject);
|
||||
return RestResponse.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.mindskip.xzs.controller.admin;
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.domain.ExamPaper;
|
||||
import com.mindskip.xzs.service.ExamPaperService;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.utility.PageInfoHelper;
|
||||
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperPageRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.admin.exam.ExamResponseVM;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@RestController("AdminExamPaperController")
|
||||
@RequestMapping(value = "/api/admin/exam/paper")
|
||||
@AllArgsConstructor
|
||||
public class ExamPaperController extends BaseApiController {
|
||||
|
||||
private final ExamPaperService examPaperService;
|
||||
|
||||
@RequestMapping(value = "/page", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<ExamResponseVM>> pageList(@RequestBody ExamPaperPageRequestVM model) {
|
||||
PageInfo<ExamPaper> pageInfo = examPaperService.page(model);
|
||||
PageInfo<ExamResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> {
|
||||
ExamResponseVM vm = modelMapper.map(e, ExamResponseVM.class);
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
|
||||
return vm;
|
||||
});
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/taskExamPage", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<ExamResponseVM>> taskExamPageList(@RequestBody ExamPaperPageRequestVM model) {
|
||||
PageInfo<ExamPaper> pageInfo = examPaperService.taskExamPage(model);
|
||||
PageInfo<ExamResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> {
|
||||
ExamResponseVM vm = modelMapper.map(e, ExamResponseVM.class);
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
|
||||
return vm;
|
||||
});
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public RestResponse<ExamPaperEditRequestVM> edit(@RequestBody @Valid ExamPaperEditRequestVM model) {
|
||||
ExamPaper examPaper = examPaperService.savePaperFromVM(model, getCurrentUser());
|
||||
ExamPaperEditRequestVM newVM = examPaperService.examPaperToVM(examPaper.getId());
|
||||
return RestResponse.ok(newVM);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/select/{id}", method = RequestMethod.POST)
|
||||
public RestResponse<ExamPaperEditRequestVM> select(@PathVariable Integer id) {
|
||||
ExamPaperEditRequestVM vm = examPaperService.examPaperToVM(id);
|
||||
return RestResponse.ok(vm);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
|
||||
public RestResponse delete(@PathVariable Integer id) {
|
||||
ExamPaper examPaper = examPaperService.selectById(id);
|
||||
examPaper.setDeleted(true);
|
||||
examPaperService.updateByIdFilter(examPaper);
|
||||
return RestResponse.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.mindskip.xzs.controller.admin;
|
||||
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.domain.Message;
|
||||
import com.mindskip.xzs.domain.MessageUser;
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.service.MessageService;
|
||||
import com.mindskip.xzs.service.UserService;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.utility.PageInfoHelper;
|
||||
import com.mindskip.xzs.viewmodel.admin.message.MessagePageRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.admin.message.MessageResponseVM;
|
||||
import com.mindskip.xzs.viewmodel.admin.message.MessageSendVM;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController("AdminMessageController")
|
||||
@RequestMapping(value = "/api/admin/message")
|
||||
@AllArgsConstructor
|
||||
public class MessageController extends BaseApiController {
|
||||
|
||||
private final MessageService messageService;
|
||||
private final UserService userService;
|
||||
|
||||
@RequestMapping(value = "/page", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<MessageResponseVM>> pageList(@RequestBody MessagePageRequestVM model) {
|
||||
PageInfo<Message> pageInfo = messageService.page(model);
|
||||
List<Integer> ids = pageInfo.getList().stream().map(d -> d.getId()).collect(Collectors.toList());
|
||||
List<MessageUser> messageUsers = ids.size() == 0 ? null : messageService.selectByMessageIds(ids);
|
||||
PageInfo<MessageResponseVM> page = PageInfoHelper.copyMap(pageInfo, m -> {
|
||||
MessageResponseVM vm = modelMapper.map(m, MessageResponseVM.class);
|
||||
String receives = messageUsers.stream().filter(d -> d.getMessageId().equals(m.getId())).map(d -> d.getReceiveUserName())
|
||||
.collect(Collectors.joining(","));
|
||||
vm.setReceives(receives);
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(m.getCreateTime()));
|
||||
return vm;
|
||||
});
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/send", method = RequestMethod.POST)
|
||||
public RestResponse send(@RequestBody @Valid MessageSendVM model) {
|
||||
User user = getCurrentUser();
|
||||
List<User> receiveUser = userService.selectByIds(model.getReceiveUserIds());
|
||||
Date now = new Date();
|
||||
Message message = new Message();
|
||||
message.setTitle(model.getTitle());
|
||||
message.setContent(model.getContent());
|
||||
message.setCreateTime(now);
|
||||
message.setReadCount(0);
|
||||
message.setReceiveUserCount(receiveUser.size());
|
||||
message.setSendUserId(user.getId());
|
||||
message.setSendUserName(user.getUserName());
|
||||
message.setSendRealName(user.getRealName());
|
||||
List<MessageUser> messageUsers = receiveUser.stream().map(d -> {
|
||||
MessageUser messageUser = new MessageUser();
|
||||
messageUser.setCreateTime(now);
|
||||
messageUser.setReaded(false);
|
||||
messageUser.setReceiveRealName(d.getRealName());
|
||||
messageUser.setReceiveUserId(d.getId());
|
||||
messageUser.setReceiveUserName(d.getUserName());
|
||||
return messageUser;
|
||||
}).collect(Collectors.toList());
|
||||
messageService.sendMessage(message, messageUsers);
|
||||
return RestResponse.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.mindskip.xzs.controller.admin;
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.base.SystemCode;
|
||||
import com.mindskip.xzs.domain.Question;
|
||||
import com.mindskip.xzs.domain.TextContent;
|
||||
import com.mindskip.xzs.domain.enums.QuestionTypeEnum;
|
||||
import com.mindskip.xzs.domain.question.QuestionObject;
|
||||
import com.mindskip.xzs.service.QuestionService;
|
||||
import com.mindskip.xzs.service.TextContentService;
|
||||
import com.mindskip.xzs.utility.*;
|
||||
import com.mindskip.xzs.viewmodel.admin.question.QuestionEditRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.admin.question.QuestionPageRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.admin.question.QuestionResponseVM;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mindskip.xzs.utility.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@RestController("AdminQuestionController")
|
||||
@RequestMapping(value = "/api/admin/question")
|
||||
@AllArgsConstructor
|
||||
public class QuestionController extends BaseApiController {
|
||||
|
||||
private final QuestionService questionService;
|
||||
private final TextContentService textContentService;
|
||||
|
||||
@RequestMapping(value = "/page", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<QuestionResponseVM>> pageList(@RequestBody QuestionPageRequestVM model) {
|
||||
PageInfo<Question> pageInfo = questionService.page(model);
|
||||
PageInfo<QuestionResponseVM> page = PageInfoHelper.copyMap(pageInfo, q -> {
|
||||
QuestionResponseVM vm = modelMapper.map(q, QuestionResponseVM.class);
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(q.getCreateTime()));
|
||||
vm.setScore(ExamUtil.scoreToVM(q.getScore()));
|
||||
TextContent textContent = textContentService.selectById(q.getInfoTextContentId());
|
||||
QuestionObject questionObject = JsonUtil.toJsonObject(textContent.getContent(), QuestionObject.class);
|
||||
String clearHtml = HtmlUtil.clear(questionObject.getTitleContent());
|
||||
vm.setShortTitle(clearHtml);
|
||||
return vm;
|
||||
});
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public RestResponse edit(@RequestBody @Valid QuestionEditRequestVM model) {
|
||||
RestResponse validQuestionEditRequestResult = validQuestionEditRequestVM(model);
|
||||
if (validQuestionEditRequestResult.getCode() != SystemCode.OK.getCode()) {
|
||||
return validQuestionEditRequestResult;
|
||||
}
|
||||
|
||||
if (null == model.getId()) {
|
||||
questionService.insertFullQuestion(model, getCurrentUser().getId());
|
||||
} else {
|
||||
questionService.updateFullQuestion(model);
|
||||
}
|
||||
|
||||
return RestResponse.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/select/{id}", method = RequestMethod.POST)
|
||||
public RestResponse<QuestionEditRequestVM> select(@PathVariable Integer id) {
|
||||
QuestionEditRequestVM newVM = questionService.getQuestionEditRequestVM(id);
|
||||
return RestResponse.ok(newVM);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
|
||||
public RestResponse delete(@PathVariable Integer id) {
|
||||
Question question = questionService.selectById(id);
|
||||
question.setDeleted(true);
|
||||
questionService.updateByIdFilter(question);
|
||||
return RestResponse.ok();
|
||||
}
|
||||
|
||||
private RestResponse validQuestionEditRequestVM(QuestionEditRequestVM model) {
|
||||
int qType = model.getQuestionType().intValue();
|
||||
boolean requireCorrect = qType == QuestionTypeEnum.SingleChoice.getCode() || qType == QuestionTypeEnum.TrueFalse.getCode();
|
||||
if (requireCorrect) {
|
||||
if (StringUtils.isBlank(model.getCorrect())) {
|
||||
String errorMsg = ErrorUtil.parameterErrorFormat("correct", "不能为空");
|
||||
return new RestResponse<>(SystemCode.ParameterValidError.getCode(), errorMsg);
|
||||
}
|
||||
}
|
||||
|
||||
if (qType == QuestionTypeEnum.GapFilling.getCode()) {
|
||||
Integer fillSumScore = model.getItems().stream().mapToInt(d -> ExamUtil.scoreFromVM(d.getScore())).sum();
|
||||
Integer questionScore = ExamUtil.scoreFromVM(model.getScore());
|
||||
if (!fillSumScore.equals(questionScore)) {
|
||||
String errorMsg = ErrorUtil.parameterErrorFormat("score", "空分数和与题目总分不相等");
|
||||
return new RestResponse<>(SystemCode.ParameterValidError.getCode(), errorMsg);
|
||||
}
|
||||
}
|
||||
return RestResponse.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.mindskip.xzs.controller.admin;
|
||||
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.domain.TaskExam;
|
||||
import com.mindskip.xzs.service.TaskExamService;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.utility.PageInfoHelper;
|
||||
import com.mindskip.xzs.viewmodel.admin.task.TaskPageRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.admin.task.TaskPageResponseVM;
|
||||
import com.mindskip.xzs.viewmodel.admin.task.TaskRequestVM;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@RestController("AdminTaskController")
|
||||
@RequestMapping(value = "/api/admin/task")
|
||||
@AllArgsConstructor
|
||||
public class TaskController extends BaseApiController {
|
||||
|
||||
private final TaskExamService taskExamService;
|
||||
|
||||
@RequestMapping(value = "/page", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<TaskPageResponseVM>> pageList(@RequestBody TaskPageRequestVM model) {
|
||||
PageInfo<TaskExam> pageInfo = taskExamService.page(model);
|
||||
PageInfo<TaskPageResponseVM> page = PageInfoHelper.copyMap(pageInfo, m -> {
|
||||
TaskPageResponseVM vm = modelMapper.map(m, TaskPageResponseVM.class);
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(m.getCreateTime()));
|
||||
return vm;
|
||||
});
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public RestResponse edit(@RequestBody @Valid TaskRequestVM model) {
|
||||
taskExamService.edit(model, getCurrentUser());
|
||||
TaskRequestVM vm = taskExamService.taskExamToVM(model.getId());
|
||||
return RestResponse.ok(vm);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/select/{id}", method = RequestMethod.POST)
|
||||
public RestResponse<TaskRequestVM> select(@PathVariable Integer id) {
|
||||
TaskRequestVM vm = taskExamService.taskExamToVM(id);
|
||||
return RestResponse.ok(vm);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
|
||||
public RestResponse delete(@PathVariable Integer id) {
|
||||
TaskExam taskExam = taskExamService.selectById(id);
|
||||
taskExam.setDeleted(true);
|
||||
taskExamService.updateByIdFilter(taskExam);
|
||||
return RestResponse.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.mindskip.xzs.controller.admin;
|
||||
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.configuration.property.SystemConfig;
|
||||
import com.mindskip.xzs.service.FileUpload;
|
||||
import com.mindskip.xzs.service.UserService;
|
||||
import com.mindskip.xzs.viewmodel.admin.file.UeditorConfigVM;
|
||||
import com.mindskip.xzs.viewmodel.admin.file.UploadResultVM;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/api/admin/upload")
|
||||
@RestController("AdminUploadController")
|
||||
public class UploadController extends BaseApiController {
|
||||
|
||||
private final FileUpload fileUpload;
|
||||
private final SystemConfig systemConfig;
|
||||
private static final Logger logger = LoggerFactory.getLogger(UploadController.class);
|
||||
private static final String IMAGE_UPLOAD = "imgUpload";
|
||||
private static final String IMAGE_UPLOAD_FILE = "upFile";
|
||||
private final UserService userService;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping("/configAndUpload")
|
||||
public Object upload(HttpServletRequest request, HttpServletResponse response) {
|
||||
String action = request.getParameter("action");
|
||||
if (action.equals(IMAGE_UPLOAD)) {
|
||||
try {
|
||||
MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request;
|
||||
MultipartFile multipartFile = multipartHttpServletRequest.getFile(IMAGE_UPLOAD_FILE);
|
||||
long attachSize = multipartFile.getSize();
|
||||
String imgName = multipartFile.getOriginalFilename();
|
||||
String filePath;
|
||||
try (InputStream inputStream = multipartFile.getInputStream()) {
|
||||
filePath = fileUpload.uploadFile(inputStream, attachSize, imgName);
|
||||
}
|
||||
String imageType = imgName.substring(imgName.lastIndexOf("."));
|
||||
UploadResultVM uploadResultVM = new UploadResultVM();
|
||||
uploadResultVM.setOriginal(imgName);
|
||||
uploadResultVM.setName(imgName);
|
||||
uploadResultVM.setUrl(filePath);
|
||||
uploadResultVM.setSize(multipartFile.getSize());
|
||||
uploadResultVM.setType(imageType);
|
||||
uploadResultVM.setState("SUCCESS");
|
||||
return uploadResultVM;
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
} else {
|
||||
UeditorConfigVM ueditorConfigVM = new UeditorConfigVM();
|
||||
ueditorConfigVM.setImageActionName(IMAGE_UPLOAD);
|
||||
ueditorConfigVM.setImageFieldName(IMAGE_UPLOAD_FILE);
|
||||
ueditorConfigVM.setImageMaxSize(2048000L);
|
||||
ueditorConfigVM.setImageAllowFiles(Arrays.asList(".png", ".jpg", ".jpeg", ".gif", ".bmp"));
|
||||
ueditorConfigVM.setImageCompressEnable(true);
|
||||
ueditorConfigVM.setImageCompressBorder(1600);
|
||||
ueditorConfigVM.setImageInsertAlign("none");
|
||||
ueditorConfigVM.setImageUrlPrefix("");
|
||||
ueditorConfigVM.setImagePathFormat("");
|
||||
return ueditorConfigVM;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/image")
|
||||
@ResponseBody
|
||||
public RestResponse questionUploadAndReadExcel(HttpServletRequest request) {
|
||||
MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request;
|
||||
MultipartFile multipartFile = multipartHttpServletRequest.getFile("file");
|
||||
long attachSize = multipartFile.getSize();
|
||||
String imgName = multipartFile.getOriginalFilename();
|
||||
try (InputStream inputStream = multipartFile.getInputStream()) {
|
||||
String filePath = fileUpload.uploadFile(inputStream, attachSize, imgName);
|
||||
userService.changePicture(getCurrentUser(), filePath);
|
||||
return RestResponse.ok(filePath);
|
||||
} catch (IOException e) {
|
||||
return RestResponse.fail(2, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/auth")
|
||||
@ResponseBody
|
||||
public RestResponse auth() {
|
||||
return RestResponse.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.mindskip.xzs.controller.admin;
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.domain.other.KeyValue;
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.domain.UserEventLog;
|
||||
import com.mindskip.xzs.domain.enums.UserStatusEnum;
|
||||
import com.mindskip.xzs.service.AuthenticationService;
|
||||
import com.mindskip.xzs.service.UserEventLogService;
|
||||
import com.mindskip.xzs.service.UserService;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.viewmodel.admin.user.*;
|
||||
import com.mindskip.xzs.utility.PageInfoHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mindskip.xzs.viewmodel.admin.user.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
@RestController("AdminUserController")
|
||||
@RequestMapping(value = "/api/admin/user")
|
||||
@AllArgsConstructor
|
||||
public class UserController extends BaseApiController {
|
||||
|
||||
private final UserService userService;
|
||||
private final UserEventLogService userEventLogService;
|
||||
private final AuthenticationService authenticationService;
|
||||
|
||||
|
||||
@RequestMapping(value = "/page/list", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<UserResponseVM>> pageList(@RequestBody UserPageRequestVM model) {
|
||||
PageInfo<User> pageInfo = userService.userPage(model);
|
||||
PageInfo<UserResponseVM> page = PageInfoHelper.copyMap(pageInfo, d -> UserResponseVM.from(d));
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/event/page/list", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<UserEventLogVM>> eventPageList(@RequestBody UserEventPageRequestVM model) {
|
||||
PageInfo<UserEventLog> pageInfo = userEventLogService.page(model);
|
||||
PageInfo<UserEventLogVM> page = PageInfoHelper.copyMap(pageInfo, d -> {
|
||||
UserEventLogVM vm = modelMapper.map(d, UserEventLogVM.class);
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(d.getCreateTime()));
|
||||
return vm;
|
||||
});
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/select/{id}", method = RequestMethod.POST)
|
||||
public RestResponse<UserResponseVM> select(@PathVariable Integer id) {
|
||||
User user = userService.getUserById(id);
|
||||
UserResponseVM userVm = UserResponseVM.from(user);
|
||||
return RestResponse.ok(userVm);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/current", method = RequestMethod.POST)
|
||||
public RestResponse<UserResponseVM> current() {
|
||||
User user = getCurrentUser();
|
||||
UserResponseVM userVm = UserResponseVM.from(user);
|
||||
return RestResponse.ok(userVm);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public RestResponse<User> edit(@RequestBody @Valid UserCreateVM model) {
|
||||
if (model.getId() == null) { //create
|
||||
User existUser = userService.getUserByUserName(model.getUserName());
|
||||
if (null != existUser) {
|
||||
return new RestResponse<>(2, "用户已存在");
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(model.getPassword())) {
|
||||
return new RestResponse<>(3, "密码不能为空");
|
||||
}
|
||||
}
|
||||
if (StringUtils.isBlank(model.getBirthDay())) {
|
||||
model.setBirthDay(null);
|
||||
}
|
||||
User user = modelMapper.map(model, User.class);
|
||||
|
||||
if (model.getId() == null) {
|
||||
String encodePwd = authenticationService.pwdEncode(model.getPassword());
|
||||
user.setPassword(encodePwd);
|
||||
user.setUserUuid(UUID.randomUUID().toString());
|
||||
user.setCreateTime(new Date());
|
||||
user.setLastActiveTime(new Date());
|
||||
user.setDeleted(false);
|
||||
userService.insertByFilter(user);
|
||||
} else {
|
||||
if (!StringUtils.isBlank(model.getPassword())) {
|
||||
String encodePwd = authenticationService.pwdEncode(model.getPassword());
|
||||
user.setPassword(encodePwd);
|
||||
}
|
||||
user.setModifyTime(new Date());
|
||||
userService.updateByIdFilter(user);
|
||||
}
|
||||
return RestResponse.ok(user);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
public RestResponse update(@RequestBody @Valid UserUpdateVM model) {
|
||||
User user = userService.selectById(getCurrentUser().getId());
|
||||
modelMapper.map(model, user);
|
||||
user.setModifyTime(new Date());
|
||||
userService.updateByIdFilter(user);
|
||||
return RestResponse.ok();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/changeStatus/{id}", method = RequestMethod.POST)
|
||||
public RestResponse<Integer> changeStatus(@PathVariable Integer id) {
|
||||
User user = userService.getUserById(id);
|
||||
UserStatusEnum userStatusEnum = UserStatusEnum.fromCode(user.getStatus());
|
||||
Integer newStatus = userStatusEnum == UserStatusEnum.Enable ? UserStatusEnum.Disable.getCode() : UserStatusEnum.Enable.getCode();
|
||||
user.setStatus(newStatus);
|
||||
user.setModifyTime(new Date());
|
||||
userService.updateByIdFilter(user);
|
||||
return RestResponse.ok(newStatus);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
|
||||
public RestResponse delete(@PathVariable Integer id) {
|
||||
User user = userService.getUserById(id);
|
||||
user.setDeleted(true);
|
||||
userService.updateByIdFilter(user);
|
||||
return RestResponse.ok();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/selectByUserName", method = RequestMethod.POST)
|
||||
public RestResponse<List<KeyValue>> selectByUserName(@RequestBody String userName) {
|
||||
List<KeyValue> keyValues = userService.selectByUserName(userName);
|
||||
return RestResponse.ok(keyValues);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.mindskip.xzs.controller.student;
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.domain.TaskExam;
|
||||
import com.mindskip.xzs.domain.TaskExamCustomerAnswer;
|
||||
import com.mindskip.xzs.domain.TextContent;
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.domain.enums.ExamPaperTypeEnum;
|
||||
import com.mindskip.xzs.domain.task.TaskItemAnswerObject;
|
||||
import com.mindskip.xzs.domain.task.TaskItemObject;
|
||||
import com.mindskip.xzs.service.*;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.utility.JsonUtil;
|
||||
import com.mindskip.xzs.viewmodel.student.dashboard.*;
|
||||
import com.mindskip.xzs.service.*;
|
||||
import com.mindskip.xzs.viewmodel.student.dashboard.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController("StudentDashboardController")
|
||||
@RequestMapping(value = "/api/student/dashboard")
|
||||
@AllArgsConstructor
|
||||
public class DashboardController extends BaseApiController {
|
||||
|
||||
private final UserService userService;
|
||||
private final ExamPaperService examPaperService;
|
||||
private final QuestionService questionService;
|
||||
private final TaskExamService taskExamService;
|
||||
private final TaskExamCustomerAnswerService taskExamCustomerAnswerService;
|
||||
private final TextContentService textContentService;
|
||||
|
||||
@RequestMapping(value = "/index", method = RequestMethod.POST)
|
||||
public RestResponse<IndexVM> index() {
|
||||
IndexVM indexVM = new IndexVM();
|
||||
User user = getCurrentUser();
|
||||
|
||||
PaperFilter fixedPaperFilter = new PaperFilter();
|
||||
fixedPaperFilter.setGradeLevel(user.getUserLevel());
|
||||
fixedPaperFilter.setExamPaperType(ExamPaperTypeEnum.Fixed.getCode());
|
||||
indexVM.setFixedPaper(examPaperService.indexPaper(fixedPaperFilter));
|
||||
|
||||
PaperFilter timeLimitPaperFilter = new PaperFilter();
|
||||
timeLimitPaperFilter.setDateTime(new Date());
|
||||
timeLimitPaperFilter.setGradeLevel(user.getUserLevel());
|
||||
timeLimitPaperFilter.setExamPaperType(ExamPaperTypeEnum.TimeLimit.getCode());
|
||||
|
||||
List<PaperInfo> limitPaper = examPaperService.indexPaper(timeLimitPaperFilter);
|
||||
List<PaperInfoVM> paperInfoVMS = limitPaper.stream().map(d -> {
|
||||
PaperInfoVM vm = modelMapper.map(d, PaperInfoVM.class);
|
||||
vm.setStartTime(DateTimeUtil.dateFormat(d.getLimitStartTime()));
|
||||
vm.setEndTime(DateTimeUtil.dateFormat(d.getLimitEndTime()));
|
||||
return vm;
|
||||
}).collect(Collectors.toList());
|
||||
indexVM.setTimeLimitPaper(paperInfoVMS);
|
||||
return RestResponse.ok(indexVM);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/task", method = RequestMethod.POST)
|
||||
public RestResponse<List<TaskItemVm>> task() {
|
||||
User user = getCurrentUser();
|
||||
List<TaskExam> taskExams = taskExamService.getByGradeLevel(user.getUserLevel());
|
||||
if (taskExams.size() == 0) {
|
||||
return RestResponse.ok(new ArrayList<>());
|
||||
}
|
||||
List<Integer> tIds = taskExams.stream().map(taskExam -> taskExam.getId()).collect(Collectors.toList());
|
||||
List<TaskExamCustomerAnswer> taskExamCustomerAnswers = taskExamCustomerAnswerService.selectByTUid(tIds, user.getId());
|
||||
List<TaskItemVm> vm = taskExams.stream().map(t -> {
|
||||
TaskItemVm itemVm = new TaskItemVm();
|
||||
itemVm.setId(t.getId());
|
||||
itemVm.setTitle(t.getTitle());
|
||||
TaskExamCustomerAnswer taskExamCustomerAnswer = taskExamCustomerAnswers.stream()
|
||||
.filter(tc -> tc.getTaskExamId().equals(t.getId())).findFirst().orElse(null);
|
||||
List<TaskItemPaperVm> paperItemVMS = getTaskItemPaperVm(t.getFrameTextContentId(), taskExamCustomerAnswer);
|
||||
itemVm.setPaperItems(paperItemVMS);
|
||||
return itemVm;
|
||||
}).collect(Collectors.toList());
|
||||
return RestResponse.ok(vm);
|
||||
}
|
||||
|
||||
|
||||
private List<TaskItemPaperVm> getTaskItemPaperVm(Integer tFrameId, TaskExamCustomerAnswer taskExamCustomerAnswers) {
|
||||
TextContent textContent = textContentService.selectById(tFrameId);
|
||||
List<TaskItemObject> paperItems = JsonUtil.toJsonListObject(textContent.getContent(), TaskItemObject.class);
|
||||
|
||||
List<TaskItemAnswerObject> answerPaperItems = null;
|
||||
if (null != taskExamCustomerAnswers) {
|
||||
TextContent answerTextContent = textContentService.selectById(taskExamCustomerAnswers.getTextContentId());
|
||||
answerPaperItems = JsonUtil.toJsonListObject(answerTextContent.getContent(), TaskItemAnswerObject.class);
|
||||
}
|
||||
|
||||
|
||||
List<TaskItemAnswerObject> finalAnswerPaperItems = answerPaperItems;
|
||||
return paperItems.stream().map(p -> {
|
||||
TaskItemPaperVm ivm = new TaskItemPaperVm();
|
||||
ivm.setExamPaperId(p.getExamPaperId());
|
||||
ivm.setExamPaperName(p.getExamPaperName());
|
||||
if (null != finalAnswerPaperItems) {
|
||||
finalAnswerPaperItems.stream()
|
||||
.filter(a -> a.getExamPaperId().equals(p.getExamPaperId()))
|
||||
.findFirst()
|
||||
.ifPresent(a -> {
|
||||
ivm.setExamPaperAnswerId(a.getExamPaperAnswerId());
|
||||
ivm.setStatus(a.getStatus());
|
||||
});
|
||||
}
|
||||
return ivm;
|
||||
}
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.mindskip.xzs.controller.student;
|
||||
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.domain.Subject;
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.service.SubjectService;
|
||||
import com.mindskip.xzs.viewmodel.student.education.SubjectEditRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.student.education.SubjectVM;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController("StudentEducationController")
|
||||
@RequestMapping(value = "/api/student/education")
|
||||
@AllArgsConstructor
|
||||
public class EducationController extends BaseApiController {
|
||||
|
||||
private final SubjectService subjectService;
|
||||
|
||||
@RequestMapping(value = "/subject/list", method = RequestMethod.POST)
|
||||
public RestResponse<List<SubjectVM>> list() {
|
||||
User user = getCurrentUser();
|
||||
List<Subject> subjects = subjectService.getSubjectByLevel(user.getUserLevel());
|
||||
List<SubjectVM> subjectVMS = subjects.stream().map(d -> {
|
||||
SubjectVM subjectVM = modelMapper.map(d, SubjectVM.class);
|
||||
subjectVM.setId(String.valueOf(d.getId()));
|
||||
return subjectVM;
|
||||
}).collect(Collectors.toList());
|
||||
return RestResponse.ok(subjectVMS);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/subject/select/{id}", method = RequestMethod.POST)
|
||||
public RestResponse<SubjectEditRequestVM> select(@PathVariable Integer id) {
|
||||
Subject subject = subjectService.selectById(id);
|
||||
SubjectEditRequestVM vm = modelMapper.map(subject, SubjectEditRequestVM.class);
|
||||
return RestResponse.ok(vm);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.mindskip.xzs.controller.student;
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.domain.*;
|
||||
import com.mindskip.xzs.domain.enums.ExamPaperAnswerStatusEnum;
|
||||
import com.mindskip.xzs.event.CalculateExamPaperAnswerCompleteEvent;
|
||||
import com.mindskip.xzs.event.UserEvent;
|
||||
import com.mindskip.xzs.service.ExamPaperAnswerService;
|
||||
import com.mindskip.xzs.service.ExamPaperService;
|
||||
import com.mindskip.xzs.service.SubjectService;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.utility.ExamUtil;
|
||||
import com.mindskip.xzs.utility.PageInfoHelper;
|
||||
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperReadVM;
|
||||
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitVM;
|
||||
import com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageResponseVM;
|
||||
import com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageVM;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mindskip.xzs.domain.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Date;
|
||||
|
||||
@RestController("StudentExamPaperAnswerController")
|
||||
@RequestMapping(value = "/api/student/exampaper/answer")
|
||||
@AllArgsConstructor
|
||||
public class ExamPaperAnswerController extends BaseApiController {
|
||||
|
||||
private final ExamPaperAnswerService examPaperAnswerService;
|
||||
private final ExamPaperService examPaperService;
|
||||
private final SubjectService subjectService;
|
||||
private final ApplicationEventPublisher eventPublisher;
|
||||
|
||||
|
||||
@RequestMapping(value = "/pageList", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<ExamPaperAnswerPageResponseVM>> pageList(@RequestBody @Valid ExamPaperAnswerPageVM model) {
|
||||
model.setCreateUser(getCurrentUser().getId());
|
||||
PageInfo<ExamPaperAnswer> pageInfo = examPaperAnswerService.studentPage(model);
|
||||
PageInfo<ExamPaperAnswerPageResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> {
|
||||
ExamPaperAnswerPageResponseVM vm = modelMapper.map(e, ExamPaperAnswerPageResponseVM.class);
|
||||
Subject subject = subjectService.selectById(vm.getSubjectId());
|
||||
vm.setDoTime(ExamUtil.secondToVM(e.getDoTime()));
|
||||
vm.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore()));
|
||||
vm.setUserScore(ExamUtil.scoreToVM(e.getUserScore()));
|
||||
vm.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore()));
|
||||
vm.setSubjectName(subject.getName());
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
|
||||
return vm;
|
||||
});
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/answerSubmit", method = RequestMethod.POST)
|
||||
public RestResponse answerSubmit(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM) {
|
||||
User user = getCurrentUser();
|
||||
ExamPaperAnswerInfo examPaperAnswerInfo = examPaperAnswerService.calculateExamPaperAnswer(examPaperSubmitVM, user);
|
||||
if (null == examPaperAnswerInfo) {
|
||||
return RestResponse.fail(2, "试卷不能重复做");
|
||||
}
|
||||
ExamPaperAnswer examPaperAnswer = examPaperAnswerInfo.getExamPaperAnswer();
|
||||
Integer userScore = examPaperAnswer.getUserScore();
|
||||
String scoreVm = ExamUtil.scoreToVM(userScore);
|
||||
UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date());
|
||||
String content = user.getUserName() + " 提交试卷:" + examPaperAnswerInfo.getExamPaper().getName()
|
||||
+ " 得分:" + scoreVm
|
||||
+ " 耗时:" + ExamUtil.secondToVM(examPaperAnswer.getDoTime());
|
||||
userEventLog.setContent(content);
|
||||
eventPublisher.publishEvent(new CalculateExamPaperAnswerCompleteEvent(examPaperAnswerInfo));
|
||||
eventPublisher.publishEvent(new UserEvent(userEventLog));
|
||||
return RestResponse.ok(scoreVm);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public RestResponse edit(@RequestBody @Valid ExamPaperSubmitVM examPaperSubmitVM) {
|
||||
boolean notJudge = examPaperSubmitVM.getAnswerItems().stream().anyMatch(i -> i.getDoRight() == null && i.getScore() == null);
|
||||
if (notJudge) {
|
||||
return RestResponse.fail(2, "有未批改题目");
|
||||
}
|
||||
|
||||
ExamPaperAnswer examPaperAnswer = examPaperAnswerService.selectById(examPaperSubmitVM.getId());
|
||||
ExamPaperAnswerStatusEnum examPaperAnswerStatusEnum = ExamPaperAnswerStatusEnum.fromCode(examPaperAnswer.getStatus());
|
||||
if (examPaperAnswerStatusEnum == ExamPaperAnswerStatusEnum.Complete) {
|
||||
return RestResponse.fail(3, "试卷已完成");
|
||||
}
|
||||
String score = examPaperAnswerService.judge(examPaperSubmitVM);
|
||||
User user = getCurrentUser();
|
||||
UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date());
|
||||
String content = user.getUserName() + " 批改试卷:" + examPaperAnswer.getPaperName() + " 得分:" + score;
|
||||
userEventLog.setContent(content);
|
||||
eventPublisher.publishEvent(new UserEvent(userEventLog));
|
||||
return RestResponse.ok(score);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/read/{id}", method = RequestMethod.POST)
|
||||
public RestResponse<ExamPaperReadVM> read(@PathVariable Integer id) {
|
||||
ExamPaperAnswer examPaperAnswer = examPaperAnswerService.selectById(id);
|
||||
ExamPaperReadVM vm = new ExamPaperReadVM();
|
||||
ExamPaperEditRequestVM paper = examPaperService.examPaperToVM(examPaperAnswer.getExamPaperId());
|
||||
ExamPaperSubmitVM answer = examPaperAnswerService.examPaperAnswerToVM(examPaperAnswer.getId());
|
||||
vm.setPaper(paper);
|
||||
vm.setAnswer(answer);
|
||||
return RestResponse.ok(vm);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.mindskip.xzs.controller.student;
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.domain.ExamPaper;
|
||||
import com.mindskip.xzs.service.ExamPaperAnswerService;
|
||||
import com.mindskip.xzs.service.ExamPaperService;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.utility.PageInfoHelper;
|
||||
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperPageResponseVM;
|
||||
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperPageVM;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@RestController("StudentExamPaperController")
|
||||
@RequestMapping(value = "/api/student/exam/paper")
|
||||
@AllArgsConstructor
|
||||
public class ExamPaperController extends BaseApiController {
|
||||
|
||||
private final ExamPaperService examPaperService;
|
||||
private final ExamPaperAnswerService examPaperAnswerService;
|
||||
private final ApplicationEventPublisher eventPublisher;
|
||||
|
||||
|
||||
@RequestMapping(value = "/select/{id}", method = RequestMethod.POST)
|
||||
public RestResponse<ExamPaperEditRequestVM> select(@PathVariable Integer id) {
|
||||
ExamPaperEditRequestVM vm = examPaperService.examPaperToVM(id);
|
||||
return RestResponse.ok(vm);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/pageList", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<ExamPaperPageResponseVM>> pageList(@RequestBody @Valid ExamPaperPageVM model) {
|
||||
PageInfo<ExamPaper> pageInfo = examPaperService.studentPage(model);
|
||||
PageInfo<ExamPaperPageResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> {
|
||||
ExamPaperPageResponseVM vm = modelMapper.map(e, ExamPaperPageResponseVM.class);
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
|
||||
return vm;
|
||||
});
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.mindskip.xzs.controller.student;
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.domain.ExamPaperQuestionCustomerAnswer;
|
||||
import com.mindskip.xzs.domain.Subject;
|
||||
import com.mindskip.xzs.domain.TextContent;
|
||||
import com.mindskip.xzs.domain.question.QuestionObject;
|
||||
import com.mindskip.xzs.service.ExamPaperQuestionCustomerAnswerService;
|
||||
import com.mindskip.xzs.service.QuestionService;
|
||||
import com.mindskip.xzs.service.SubjectService;
|
||||
import com.mindskip.xzs.service.TextContentService;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.utility.HtmlUtil;
|
||||
import com.mindskip.xzs.utility.JsonUtil;
|
||||
import com.mindskip.xzs.utility.PageInfoHelper;
|
||||
import com.mindskip.xzs.viewmodel.admin.question.QuestionEditRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitItemVM;
|
||||
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionAnswerVM;
|
||||
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentResponseVM;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController("StudentQuestionAnswerController")
|
||||
@RequestMapping(value = "/api/student/question/answer")
|
||||
@AllArgsConstructor
|
||||
public class QuestionAnswerController extends BaseApiController {
|
||||
|
||||
private final ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService;
|
||||
private final QuestionService questionService;
|
||||
private final TextContentService textContentService;
|
||||
private final SubjectService subjectService;
|
||||
|
||||
@RequestMapping(value = "/page", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<QuestionPageStudentResponseVM>> pageList(@RequestBody QuestionPageStudentRequestVM model) {
|
||||
model.setCreateUser(getCurrentUser().getId());
|
||||
PageInfo<ExamPaperQuestionCustomerAnswer> pageInfo = examPaperQuestionCustomerAnswerService.studentPage(model);
|
||||
PageInfo<QuestionPageStudentResponseVM> page = PageInfoHelper.copyMap(pageInfo, q -> {
|
||||
Subject subject = subjectService.selectById(q.getSubjectId());
|
||||
QuestionPageStudentResponseVM vm = modelMapper.map(q, QuestionPageStudentResponseVM.class);
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(q.getCreateTime()));
|
||||
TextContent textContent = textContentService.selectById(q.getQuestionTextContentId());
|
||||
QuestionObject questionObject = JsonUtil.toJsonObject(textContent.getContent(), QuestionObject.class);
|
||||
String clearHtml = HtmlUtil.clear(questionObject.getTitleContent());
|
||||
vm.setShortTitle(clearHtml);
|
||||
vm.setSubjectName(subject.getName());
|
||||
return vm;
|
||||
});
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/select/{id}", method = RequestMethod.POST)
|
||||
public RestResponse<QuestionAnswerVM> select(@PathVariable Integer id) {
|
||||
QuestionAnswerVM vm = new QuestionAnswerVM();
|
||||
ExamPaperQuestionCustomerAnswer examPaperQuestionCustomerAnswer = examPaperQuestionCustomerAnswerService.selectById(id);
|
||||
ExamPaperSubmitItemVM questionAnswerVM = examPaperQuestionCustomerAnswerService.examPaperQuestionCustomerAnswerToVM(examPaperQuestionCustomerAnswer);
|
||||
QuestionEditRequestVM questionVM = questionService.getQuestionEditRequestVM(examPaperQuestionCustomerAnswer.getQuestionId());
|
||||
vm.setQuestionVM(questionVM);
|
||||
vm.setQuestionAnswerVM(questionAnswerVM);
|
||||
return RestResponse.ok(vm);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mindskip.xzs.controller.student;
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.service.QuestionService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController("StudentQuestionController")
|
||||
@RequestMapping(value = "/api/student/question")
|
||||
@AllArgsConstructor
|
||||
public class QuestionController extends BaseApiController {
|
||||
|
||||
private final QuestionService questionService;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.mindskip.xzs.controller.student;
|
||||
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.service.FileUpload;
|
||||
import com.mindskip.xzs.service.UserService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/api/student/upload")
|
||||
@RestController("StudentUploadController")
|
||||
public class UploadController extends BaseApiController {
|
||||
|
||||
private final FileUpload fileUpload;
|
||||
private final UserService userService;
|
||||
|
||||
|
||||
@RequestMapping("/image")
|
||||
@ResponseBody
|
||||
public RestResponse questionUploadAndReadExcel(HttpServletRequest request) {
|
||||
MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request;
|
||||
MultipartFile multipartFile = multipartHttpServletRequest.getFile("file");
|
||||
long attachSize = multipartFile.getSize();
|
||||
String imgName = multipartFile.getOriginalFilename();
|
||||
try (InputStream inputStream = multipartFile.getInputStream()) {
|
||||
String filePath = fileUpload.uploadFile(inputStream, attachSize, imgName);
|
||||
userService.changePicture(getCurrentUser(), filePath);
|
||||
return RestResponse.ok(filePath);
|
||||
} catch (IOException e) {
|
||||
return RestResponse.fail(2, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.mindskip.xzs.controller.student;
|
||||
|
||||
import com.mindskip.xzs.base.BaseApiController;
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.domain.Message;
|
||||
import com.mindskip.xzs.domain.MessageUser;
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.domain.UserEventLog;
|
||||
import com.mindskip.xzs.domain.enums.RoleEnum;
|
||||
import com.mindskip.xzs.domain.enums.UserStatusEnum;
|
||||
import com.mindskip.xzs.event.UserEvent;
|
||||
import com.mindskip.xzs.service.AuthenticationService;
|
||||
import com.mindskip.xzs.service.MessageService;
|
||||
import com.mindskip.xzs.service.UserEventLogService;
|
||||
import com.mindskip.xzs.service.UserService;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.utility.PageInfoHelper;
|
||||
import com.mindskip.xzs.viewmodel.student.user.*;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mindskip.xzs.viewmodel.student.user.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
@RestController("StudentUserController")
|
||||
@RequestMapping(value = "/api/student/user")
|
||||
@AllArgsConstructor
|
||||
public class UserController extends BaseApiController {
|
||||
|
||||
private final UserService userService;
|
||||
private final UserEventLogService userEventLogService;
|
||||
private final MessageService messageService;
|
||||
private final AuthenticationService authenticationService;
|
||||
private final ApplicationEventPublisher eventPublisher;
|
||||
|
||||
@RequestMapping(value = "/current", method = RequestMethod.POST)
|
||||
public RestResponse<UserResponseVM> current() {
|
||||
User user = getCurrentUser();
|
||||
UserResponseVM userVm = UserResponseVM.from(user);
|
||||
return RestResponse.ok(userVm);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/register", method = RequestMethod.POST)
|
||||
public RestResponse register(@RequestBody @Valid UserRegisterVM model) {
|
||||
User existUser = userService.getUserByUserName(model.getUserName());
|
||||
if (null != existUser) {
|
||||
return new RestResponse<>(2, "用户已存在");
|
||||
}
|
||||
User user = modelMapper.map(model, User.class);
|
||||
String encodePwd = authenticationService.pwdEncode(model.getPassword());
|
||||
user.setUserUuid(UUID.randomUUID().toString());
|
||||
user.setPassword(encodePwd);
|
||||
user.setRole(RoleEnum.STUDENT.getCode());
|
||||
user.setStatus(UserStatusEnum.Enable.getCode());
|
||||
user.setLastActiveTime(new Date());
|
||||
user.setCreateTime(new Date());
|
||||
user.setDeleted(false);
|
||||
userService.insertByFilter(user);
|
||||
UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date());
|
||||
userEventLog.setContent("欢迎 " + user.getUserName() + " 注册来到学之思考试系统");
|
||||
eventPublisher.publishEvent(new UserEvent(userEventLog));
|
||||
return RestResponse.ok();
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
public RestResponse update(@RequestBody @Valid UserUpdateVM model) {
|
||||
if (StringUtils.isBlank(model.getBirthDay())) {
|
||||
model.setBirthDay(null);
|
||||
}
|
||||
User user = userService.selectById(getCurrentUser().getId());
|
||||
modelMapper.map(model, user);
|
||||
user.setModifyTime(new Date());
|
||||
userService.updateByIdFilter(user);
|
||||
UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date());
|
||||
userEventLog.setContent(user.getUserName() + " 更新了个人资料");
|
||||
eventPublisher.publishEvent(new UserEvent(userEventLog));
|
||||
return RestResponse.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/log", method = RequestMethod.POST)
|
||||
public RestResponse<List<UserEventLogVM>> log() {
|
||||
User user = getCurrentUser();
|
||||
List<UserEventLog> userEventLogs = userEventLogService.getUserEventLogByUserId(user.getId());
|
||||
List<UserEventLogVM> userEventLogVMS = userEventLogs.stream().map(d -> {
|
||||
UserEventLogVM vm = modelMapper.map(d, UserEventLogVM.class);
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(d.getCreateTime()));
|
||||
return vm;
|
||||
}).collect(Collectors.toList());
|
||||
return RestResponse.ok(userEventLogVMS);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/message/page", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<MessageResponseVM>> messagePageList(@RequestBody MessageRequestVM messageRequestVM) {
|
||||
messageRequestVM.setReceiveUserId(getCurrentUser().getId());
|
||||
PageInfo<MessageUser> messageUserPageInfo = messageService.studentPage(messageRequestVM);
|
||||
List<Integer> ids = messageUserPageInfo.getList().stream().map(d -> d.getMessageId()).collect(Collectors.toList());
|
||||
List<Message> messages = ids.size() != 0 ? messageService.selectMessageByIds(ids) : null;
|
||||
PageInfo<MessageResponseVM> page = PageInfoHelper.copyMap(messageUserPageInfo, e -> {
|
||||
MessageResponseVM vm = modelMapper.map(e, MessageResponseVM.class);
|
||||
messages.stream().filter(d -> e.getMessageId().equals(d.getId())).findFirst().ifPresent(message -> {
|
||||
vm.setTitle(message.getTitle());
|
||||
vm.setContent(message.getContent());
|
||||
vm.setSendUserName(message.getSendUserName());
|
||||
});
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
|
||||
return vm;
|
||||
});
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/message/unreadCount", method = RequestMethod.POST)
|
||||
public RestResponse unReadCount() {
|
||||
Integer count = messageService.unReadCount(getCurrentUser().getId());
|
||||
return RestResponse.ok(count);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/message/read/{id}", method = RequestMethod.POST)
|
||||
public RestResponse read(@PathVariable Integer id) {
|
||||
messageService.read(id);
|
||||
return RestResponse.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mindskip.xzs.controller.wx;
|
||||
|
||||
import com.mindskip.xzs.context.WxContext;
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.domain.UserToken;
|
||||
import com.mindskip.xzs.utility.ModelMapperSingle;
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
public class BaseWXApiController {
|
||||
protected final static ModelMapper modelMapper = ModelMapperSingle.Instance();
|
||||
@Autowired
|
||||
private WxContext wxContext;
|
||||
|
||||
protected User getCurrentUser() {
|
||||
return wxContext.getCurrentUser();
|
||||
}
|
||||
|
||||
protected UserToken getUserToken() {
|
||||
return wxContext.getCurrentUserToken();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.mindskip.xzs.controller.wx.student;
|
||||
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.configuration.property.SystemConfig;
|
||||
import com.mindskip.xzs.controller.wx.BaseWXApiController;
|
||||
import com.mindskip.xzs.domain.UserToken;
|
||||
import com.mindskip.xzs.domain.enums.UserStatusEnum;
|
||||
import com.mindskip.xzs.service.AuthenticationService;
|
||||
import com.mindskip.xzs.service.UserService;
|
||||
import com.mindskip.xzs.service.UserTokenService;
|
||||
import com.mindskip.xzs.utility.WxUtil;
|
||||
import com.mindskip.xzs.viewmodel.wx.student.user.BindInfo;
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
|
||||
@Controller("WXStudentAuthController")
|
||||
@RequestMapping(value = "/api/wx/student/auth")
|
||||
@AllArgsConstructor
|
||||
@ResponseBody
|
||||
public class AuthController extends BaseWXApiController {
|
||||
|
||||
private final SystemConfig systemConfig;
|
||||
private final AuthenticationService authenticationService;
|
||||
private final UserService userService;
|
||||
private final UserTokenService userTokenService;
|
||||
|
||||
@RequestMapping(value = "/bind", method = RequestMethod.POST)
|
||||
public RestResponse bind(@Valid BindInfo model) {
|
||||
User user = userService.getUserByUserName(model.getUserName());
|
||||
if (user == null) {
|
||||
return RestResponse.fail(2, "用户名或密码错误");
|
||||
}
|
||||
boolean result = authenticationService.authUser(user, model.getUserName(), model.getPassword());
|
||||
if (!result) {
|
||||
return RestResponse.fail(2, "用户名或密码错误");
|
||||
}
|
||||
UserStatusEnum userStatusEnum = UserStatusEnum.fromCode(user.getStatus());
|
||||
if (UserStatusEnum.Disable == userStatusEnum) {
|
||||
return RestResponse.fail(3, "用户被禁用");
|
||||
}
|
||||
String code = model.getCode();
|
||||
String openid = WxUtil.getOpenId(systemConfig.getWx().getAppid(), systemConfig.getWx().getSecret(), code);
|
||||
if (null == openid) {
|
||||
return RestResponse.fail(4, "获取微信OpenId失败");
|
||||
}
|
||||
user.setWxOpenId(openid);
|
||||
UserToken userToken = userTokenService.bind(user);
|
||||
return RestResponse.ok(userToken.getToken());
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/checkBind", method = RequestMethod.POST)
|
||||
public RestResponse checkBind(@Valid @NotBlank String code) {
|
||||
String openid = WxUtil.getOpenId(systemConfig.getWx().getAppid(), systemConfig.getWx().getSecret(), code);
|
||||
if (null == openid) {
|
||||
return RestResponse.fail(3, "获取微信OpenId失败");
|
||||
}
|
||||
UserToken userToken = userTokenService.checkBind(openid);
|
||||
if (null != userToken) {
|
||||
return RestResponse.ok(userToken.getToken());
|
||||
}
|
||||
return RestResponse.fail(2, "用户未绑定");
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/unBind", method = RequestMethod.POST)
|
||||
public RestResponse unBind() {
|
||||
UserToken userToken = getUserToken();
|
||||
userTokenService.unBind(userToken);
|
||||
return RestResponse.ok();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
package com.mindskip.xzs.controller.wx.student;
|
||||
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.controller.wx.BaseWXApiController;
|
||||
import com.mindskip.xzs.domain.TaskExam;
|
||||
import com.mindskip.xzs.domain.TaskExamCustomerAnswer;
|
||||
import com.mindskip.xzs.domain.TextContent;
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.domain.enums.ExamPaperTypeEnum;
|
||||
import com.mindskip.xzs.domain.task.TaskItemAnswerObject;
|
||||
import com.mindskip.xzs.domain.task.TaskItemObject;
|
||||
import com.mindskip.xzs.service.ExamPaperService;
|
||||
import com.mindskip.xzs.service.TaskExamCustomerAnswerService;
|
||||
import com.mindskip.xzs.service.TaskExamService;
|
||||
import com.mindskip.xzs.service.TextContentService;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.utility.JsonUtil;
|
||||
import com.mindskip.xzs.viewmodel.student.dashboard.*;
|
||||
import com.mindskip.xzs.viewmodel.student.dashboard.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Controller("WXStudentDashboardController")
|
||||
@RequestMapping(value = "/api/wx/student/dashboard")
|
||||
@AllArgsConstructor
|
||||
@ResponseBody
|
||||
public class DashboardController extends BaseWXApiController {
|
||||
|
||||
private final ExamPaperService examPaperService;
|
||||
private final TextContentService textContentService;
|
||||
private final TaskExamService taskExamService;
|
||||
private final TaskExamCustomerAnswerService taskExamCustomerAnswerService;
|
||||
|
||||
@RequestMapping(value = "/index", method = RequestMethod.POST)
|
||||
public RestResponse<IndexVM> index() {
|
||||
IndexVM indexVM = new IndexVM();
|
||||
User user = getCurrentUser();
|
||||
|
||||
PaperFilter fixedPaperFilter = new PaperFilter();
|
||||
fixedPaperFilter.setGradeLevel(user.getUserLevel());
|
||||
fixedPaperFilter.setExamPaperType(ExamPaperTypeEnum.Fixed.getCode());
|
||||
indexVM.setFixedPaper(examPaperService.indexPaper(fixedPaperFilter));
|
||||
|
||||
PaperFilter timeLimitPaperFilter = new PaperFilter();
|
||||
timeLimitPaperFilter.setDateTime(new Date());
|
||||
timeLimitPaperFilter.setGradeLevel(user.getUserLevel());
|
||||
timeLimitPaperFilter.setExamPaperType(ExamPaperTypeEnum.TimeLimit.getCode());
|
||||
|
||||
List<PaperInfo> limitPaper = examPaperService.indexPaper(timeLimitPaperFilter);
|
||||
List<PaperInfoVM> paperInfoVMS = limitPaper.stream().map(d -> {
|
||||
PaperInfoVM vm = modelMapper.map(d, PaperInfoVM.class);
|
||||
vm.setStartTime(DateTimeUtil.dateFormat(d.getLimitStartTime()));
|
||||
vm.setEndTime(DateTimeUtil.dateFormat(d.getLimitEndTime()));
|
||||
return vm;
|
||||
}).collect(Collectors.toList());
|
||||
indexVM.setTimeLimitPaper(paperInfoVMS);
|
||||
return RestResponse.ok(indexVM);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/task", method = RequestMethod.POST)
|
||||
public RestResponse<List<TaskItemVm>> task() {
|
||||
User user = getCurrentUser();
|
||||
List<TaskExam> taskExams = taskExamService.getByGradeLevel(user.getUserLevel());
|
||||
if (taskExams.size() == 0) {
|
||||
return RestResponse.ok(new ArrayList<>());
|
||||
}
|
||||
List<Integer> tIds = taskExams.stream().map(taskExam -> taskExam.getId()).collect(Collectors.toList());
|
||||
List<TaskExamCustomerAnswer> taskExamCustomerAnswers = taskExamCustomerAnswerService.selectByTUid(tIds, user.getId());
|
||||
List<TaskItemVm> vm = taskExams.stream().map(t -> {
|
||||
TaskItemVm itemVm = new TaskItemVm();
|
||||
itemVm.setId(t.getId());
|
||||
itemVm.setTitle(t.getTitle());
|
||||
TaskExamCustomerAnswer taskExamCustomerAnswer = taskExamCustomerAnswers.stream()
|
||||
.filter(tc -> tc.getTaskExamId().equals(t.getId())).findFirst().orElse(null);
|
||||
List<TaskItemPaperVm> paperItemVMS = getTaskItemPaperVm(t.getFrameTextContentId(), taskExamCustomerAnswer);
|
||||
itemVm.setPaperItems(paperItemVMS);
|
||||
return itemVm;
|
||||
}).collect(Collectors.toList());
|
||||
return RestResponse.ok(vm);
|
||||
}
|
||||
|
||||
|
||||
private List<TaskItemPaperVm> getTaskItemPaperVm(Integer tFrameId, TaskExamCustomerAnswer taskExamCustomerAnswers) {
|
||||
TextContent textContent = textContentService.selectById(tFrameId);
|
||||
List<TaskItemObject> paperItems = JsonUtil.toJsonListObject(textContent.getContent(), TaskItemObject.class);
|
||||
|
||||
List<TaskItemAnswerObject> answerPaperItems = null;
|
||||
if (null != taskExamCustomerAnswers) {
|
||||
TextContent answerTextContent = textContentService.selectById(taskExamCustomerAnswers.getTextContentId());
|
||||
answerPaperItems = JsonUtil.toJsonListObject(answerTextContent.getContent(), TaskItemAnswerObject.class);
|
||||
}
|
||||
|
||||
|
||||
List<TaskItemAnswerObject> finalAnswerPaperItems = answerPaperItems;
|
||||
return paperItems.stream().map(p -> {
|
||||
TaskItemPaperVm ivm = new TaskItemPaperVm();
|
||||
ivm.setExamPaperId(p.getExamPaperId());
|
||||
ivm.setExamPaperName(p.getExamPaperName());
|
||||
if (null != finalAnswerPaperItems) {
|
||||
finalAnswerPaperItems.stream()
|
||||
.filter(a -> a.getExamPaperId().equals(p.getExamPaperId()))
|
||||
.findFirst()
|
||||
.ifPresent(a -> {
|
||||
ivm.setExamPaperAnswerId(a.getExamPaperAnswerId());
|
||||
ivm.setStatus(a.getStatus());
|
||||
});
|
||||
}
|
||||
return ivm;
|
||||
}
|
||||
).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.mindskip.xzs.controller.wx.student;
|
||||
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.controller.wx.BaseWXApiController;
|
||||
import com.mindskip.xzs.domain.*;
|
||||
import com.mindskip.xzs.domain.enums.QuestionTypeEnum;
|
||||
import com.mindskip.xzs.event.CalculateExamPaperAnswerCompleteEvent;
|
||||
import com.mindskip.xzs.event.UserEvent;
|
||||
import com.mindskip.xzs.service.ExamPaperAnswerService;
|
||||
import com.mindskip.xzs.service.ExamPaperService;
|
||||
import com.mindskip.xzs.service.SubjectService;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.utility.ExamUtil;
|
||||
import com.mindskip.xzs.utility.PageInfoHelper;
|
||||
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.student.exam.*;
|
||||
import com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageResponseVM;
|
||||
import com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageVM;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mindskip.xzs.domain.*;
|
||||
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperReadVM;
|
||||
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitItemVM;
|
||||
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperSubmitVM;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Controller("WXStudentExamPaperAnswerController")
|
||||
@RequestMapping(value = "/api/wx/student/exampaper/answer")
|
||||
@AllArgsConstructor
|
||||
@ResponseBody
|
||||
public class ExamPaperAnswerController extends BaseWXApiController {
|
||||
|
||||
private final ExamPaperAnswerService examPaperAnswerService;
|
||||
private final SubjectService subjectService;
|
||||
private final ApplicationEventPublisher eventPublisher;
|
||||
private final ExamPaperService examPaperService;
|
||||
|
||||
@RequestMapping(value = "/pageList", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<ExamPaperAnswerPageResponseVM>> pageList(@Valid ExamPaperAnswerPageVM model) {
|
||||
model.setCreateUser(getCurrentUser().getId());
|
||||
PageInfo<ExamPaperAnswer> pageInfo = examPaperAnswerService.studentPage(model);
|
||||
PageInfo<ExamPaperAnswerPageResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> {
|
||||
ExamPaperAnswerPageResponseVM vm = modelMapper.map(e, ExamPaperAnswerPageResponseVM.class);
|
||||
Subject subject = subjectService.selectById(vm.getSubjectId());
|
||||
vm.setDoTime(ExamUtil.secondToVM(e.getDoTime()));
|
||||
vm.setSystemScore(ExamUtil.scoreToVM(e.getSystemScore()));
|
||||
vm.setUserScore(ExamUtil.scoreToVM(e.getUserScore()));
|
||||
vm.setPaperScore(ExamUtil.scoreToVM(e.getPaperScore()));
|
||||
vm.setSubjectName(subject.getName());
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
|
||||
return vm;
|
||||
});
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/answerSubmit", method = RequestMethod.POST)
|
||||
public RestResponse answerSubmit(HttpServletRequest request) {
|
||||
ExamPaperSubmitVM examPaperSubmitVM = requestToExamPaperSubmitVM(request);
|
||||
User user = getCurrentUser();
|
||||
ExamPaperAnswerInfo examPaperAnswerInfo = examPaperAnswerService.calculateExamPaperAnswer(examPaperSubmitVM, user);
|
||||
if (null == examPaperAnswerInfo) {
|
||||
return RestResponse.fail(2, "试卷不能重复做");
|
||||
}
|
||||
ExamPaperAnswer examPaperAnswer = examPaperAnswerInfo.getExamPaperAnswer();
|
||||
Integer userScore = examPaperAnswer.getUserScore();
|
||||
String scoreVm = ExamUtil.scoreToVM(userScore);
|
||||
UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date());
|
||||
String content = user.getUserName() + " 提交试卷:" + examPaperAnswerInfo.getExamPaper().getName()
|
||||
+ " 得分:" + scoreVm
|
||||
+ " 耗时:" + ExamUtil.secondToVM(examPaperAnswer.getDoTime());
|
||||
userEventLog.setContent(content);
|
||||
eventPublisher.publishEvent(new CalculateExamPaperAnswerCompleteEvent(examPaperAnswerInfo));
|
||||
eventPublisher.publishEvent(new UserEvent(userEventLog));
|
||||
return RestResponse.ok(scoreVm);
|
||||
}
|
||||
|
||||
private ExamPaperSubmitVM requestToExamPaperSubmitVM(HttpServletRequest request) {
|
||||
ExamPaperSubmitVM examPaperSubmitVM = new ExamPaperSubmitVM();
|
||||
examPaperSubmitVM.setId(Integer.parseInt(request.getParameter("id")));
|
||||
examPaperSubmitVM.setDoTime(Integer.parseInt(request.getParameter("doTime")));
|
||||
List<String> parameterNames = Collections.list(request.getParameterNames()).stream()
|
||||
.filter(n -> n.contains("_"))
|
||||
.collect(Collectors.toList());
|
||||
//题目答案按序号分组
|
||||
Map<String, List<String>> questionGroup = parameterNames.stream().collect(Collectors.groupingBy(p -> p.substring(0, p.indexOf("_"))));
|
||||
List<ExamPaperSubmitItemVM> answerItems = new ArrayList<>();
|
||||
questionGroup.forEach((k, v) -> {
|
||||
ExamPaperSubmitItemVM examPaperSubmitItemVM = new ExamPaperSubmitItemVM();
|
||||
String p = v.get(0);
|
||||
String[] keys = p.split("_");
|
||||
examPaperSubmitItemVM.setQuestionId(Integer.parseInt(keys[1]));
|
||||
examPaperSubmitItemVM.setItemOrder(Integer.parseInt(keys[0]));
|
||||
QuestionTypeEnum typeEnum = QuestionTypeEnum.fromCode(Integer.parseInt(keys[2]));
|
||||
if (v.size() == 1) {
|
||||
String content = request.getParameter(p);
|
||||
examPaperSubmitItemVM.setContent(content);
|
||||
if (typeEnum == QuestionTypeEnum.MultipleChoice) {
|
||||
examPaperSubmitItemVM.setContentArray(Arrays.asList(content.split(",")));
|
||||
}
|
||||
} else { //多个空 填空题
|
||||
List<String> answers = v.stream().sorted(Comparator.comparingInt(ExamUtil::lastNum)).map(inputKey -> request.getParameter(inputKey)).collect(Collectors.toList());
|
||||
examPaperSubmitItemVM.setContentArray(answers);
|
||||
}
|
||||
answerItems.add(examPaperSubmitItemVM);
|
||||
});
|
||||
examPaperSubmitVM.setAnswerItems(answerItems);
|
||||
return examPaperSubmitVM;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/read/{id}")
|
||||
public RestResponse<ExamPaperReadVM> read(@PathVariable Integer id) {
|
||||
ExamPaperReadVM vm = new ExamPaperReadVM();
|
||||
ExamPaperAnswer examPaperAnswer = examPaperAnswerService.selectById(id);
|
||||
ExamPaperEditRequestVM paper = examPaperService.examPaperToVM(examPaperAnswer.getExamPaperId());
|
||||
ExamPaperSubmitVM answer = examPaperAnswerService.examPaperAnswerToVM(examPaperAnswer.getId());
|
||||
vm.setPaper(paper);
|
||||
vm.setAnswer(answer);
|
||||
return RestResponse.ok(vm);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.mindskip.xzs.controller.wx.student;
|
||||
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.controller.wx.BaseWXApiController;
|
||||
import com.mindskip.xzs.domain.ExamPaper;
|
||||
import com.mindskip.xzs.domain.Subject;
|
||||
import com.mindskip.xzs.service.ExamPaperService;
|
||||
import com.mindskip.xzs.service.SubjectService;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.utility.PageInfoHelper;
|
||||
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperEditRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperPageResponseVM;
|
||||
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperPageVM;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
|
||||
@Controller("WXStudentExamController")
|
||||
@RequestMapping(value = "/api/wx/student/exampaper")
|
||||
@AllArgsConstructor
|
||||
@ResponseBody
|
||||
public class ExamPaperController extends BaseWXApiController {
|
||||
|
||||
private final ExamPaperService examPaperService;
|
||||
private final SubjectService subjectService;
|
||||
|
||||
|
||||
@RequestMapping(value = "/select/{id}", method = RequestMethod.POST)
|
||||
public RestResponse<ExamPaperEditRequestVM> select(@PathVariable Integer id) {
|
||||
ExamPaperEditRequestVM vm = examPaperService.examPaperToVM(id);
|
||||
return RestResponse.ok(vm);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/pageList", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<ExamPaperPageResponseVM>> pageList(@Valid ExamPaperPageVM model) {
|
||||
model.setLevelId(getCurrentUser().getUserLevel());
|
||||
PageInfo<ExamPaper> pageInfo = examPaperService.studentPage(model);
|
||||
PageInfo<ExamPaperPageResponseVM> page = PageInfoHelper.copyMap(pageInfo, e -> {
|
||||
ExamPaperPageResponseVM vm = modelMapper.map(e, ExamPaperPageResponseVM.class);
|
||||
Subject subject = subjectService.selectById(vm.getSubjectId());
|
||||
vm.setSubjectName(subject.getName());
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
|
||||
return vm;
|
||||
});
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package com.mindskip.xzs.controller.wx.student;
|
||||
|
||||
import com.mindskip.xzs.base.RestResponse;
|
||||
import com.mindskip.xzs.controller.wx.BaseWXApiController;
|
||||
import com.mindskip.xzs.domain.Message;
|
||||
import com.mindskip.xzs.domain.MessageUser;
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.domain.UserEventLog;
|
||||
import com.mindskip.xzs.domain.enums.RoleEnum;
|
||||
import com.mindskip.xzs.domain.enums.UserStatusEnum;
|
||||
import com.mindskip.xzs.event.UserEvent;
|
||||
import com.mindskip.xzs.service.AuthenticationService;
|
||||
import com.mindskip.xzs.service.MessageService;
|
||||
import com.mindskip.xzs.service.UserEventLogService;
|
||||
import com.mindskip.xzs.service.UserService;
|
||||
import com.mindskip.xzs.utility.DateTimeUtil;
|
||||
import com.mindskip.xzs.utility.PageInfoHelper;
|
||||
import com.mindskip.xzs.viewmodel.student.user.*;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mindskip.xzs.viewmodel.student.user.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
@Controller("WXStudentUserController")
|
||||
@RequestMapping(value = "/api/wx/student/user")
|
||||
@AllArgsConstructor
|
||||
@ResponseBody
|
||||
public class UserController extends BaseWXApiController {
|
||||
|
||||
private final UserService userService;
|
||||
private final UserEventLogService userEventLogService;
|
||||
private final MessageService messageService;
|
||||
private final AuthenticationService authenticationService;
|
||||
private final ApplicationEventPublisher eventPublisher;
|
||||
|
||||
@RequestMapping(value = "/current", method = RequestMethod.POST)
|
||||
public RestResponse<UserResponseVM> current() {
|
||||
User user = getCurrentUser();
|
||||
UserResponseVM userVm = UserResponseVM.from(user);
|
||||
userVm.setBirthDay(DateTimeUtil.dateShortFormat(user.getBirthDay()));
|
||||
return RestResponse.ok(userVm);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/register", method = RequestMethod.POST)
|
||||
public RestResponse register(@Valid UserRegisterVM model) {
|
||||
User existUser = userService.getUserByUserName(model.getUserName());
|
||||
if (null != existUser) {
|
||||
return new RestResponse<>(2, "用户已存在");
|
||||
}
|
||||
User user = modelMapper.map(model, User.class);
|
||||
String encodePwd = authenticationService.pwdEncode(model.getPassword());
|
||||
user.setUserUuid(UUID.randomUUID().toString());
|
||||
user.setPassword(encodePwd);
|
||||
user.setRole(RoleEnum.STUDENT.getCode());
|
||||
user.setStatus(UserStatusEnum.Enable.getCode());
|
||||
user.setLastActiveTime(new Date());
|
||||
user.setCreateTime(new Date());
|
||||
user.setDeleted(false);
|
||||
userService.insertByFilter(user);
|
||||
UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date());
|
||||
userEventLog.setContent("欢迎 " + user.getUserName() + " 注册来到学之思考试系统");
|
||||
eventPublisher.publishEvent(new UserEvent(userEventLog));
|
||||
return RestResponse.ok();
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/update", method = RequestMethod.POST)
|
||||
public RestResponse<UserResponseVM> update(@Valid UserUpdateVM model) {
|
||||
if (StringUtils.isBlank(model.getBirthDay())) {
|
||||
model.setBirthDay(null);
|
||||
}
|
||||
User user = userService.selectById(getCurrentUser().getId());
|
||||
modelMapper.map(model, user);
|
||||
user.setModifyTime(new Date());
|
||||
userService.updateByIdFilter(user);
|
||||
UserEventLog userEventLog = new UserEventLog(user.getId(), user.getUserName(), user.getRealName(), new Date());
|
||||
userEventLog.setContent(user.getUserName() + " 更新了个人资料");
|
||||
eventPublisher.publishEvent(new UserEvent(userEventLog));
|
||||
UserResponseVM userVm = UserResponseVM.from(user);
|
||||
return RestResponse.ok(userVm);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/log", method = RequestMethod.POST)
|
||||
public RestResponse<List<UserEventLogVM>> log() {
|
||||
User user = getCurrentUser();
|
||||
List<UserEventLog> userEventLogs = userEventLogService.getUserEventLogByUserId(user.getId());
|
||||
List<UserEventLogVM> userEventLogVMS = userEventLogs.stream().map(d -> {
|
||||
UserEventLogVM vm = modelMapper.map(d, UserEventLogVM.class);
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(d.getCreateTime()));
|
||||
return vm;
|
||||
}).collect(Collectors.toList());
|
||||
return RestResponse.ok(userEventLogVMS);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/message/page", method = RequestMethod.POST)
|
||||
public RestResponse<PageInfo<MessageResponseVM>> messagePageList(MessageRequestVM messageRequestVM) {
|
||||
messageRequestVM.setReceiveUserId(getCurrentUser().getId());
|
||||
PageInfo<MessageUser> messageUserPageInfo = messageService.studentPage(messageRequestVM);
|
||||
List<Integer> ids = messageUserPageInfo.getList().stream().map(d -> d.getMessageId()).collect(Collectors.toList());
|
||||
List<Message> messages = ids.size() != 0 ? messageService.selectMessageByIds(ids) : null;
|
||||
PageInfo<MessageResponseVM> page = PageInfoHelper.copyMap(messageUserPageInfo, e -> {
|
||||
MessageResponseVM vm = modelMapper.map(e, MessageResponseVM.class);
|
||||
messages.stream().filter(d -> e.getMessageId().equals(d.getId())).findFirst().ifPresent(message -> {
|
||||
vm.setTitle(message.getTitle());
|
||||
vm.setContent(message.getContent());
|
||||
vm.setSendUserName(message.getSendUserName());
|
||||
});
|
||||
vm.setCreateTime(DateTimeUtil.dateFormat(e.getCreateTime()));
|
||||
return vm;
|
||||
});
|
||||
return RestResponse.ok(page);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/message/detail/{id}", method = RequestMethod.POST)
|
||||
public RestResponse messageDetail(@PathVariable Integer id) {
|
||||
Message message = messageService.messageDetail(id);
|
||||
return RestResponse.ok(message);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value = "/message/unreadCount", method = RequestMethod.POST)
|
||||
public RestResponse unReadCount() {
|
||||
Integer count = messageService.unReadCount(getCurrentUser().getId());
|
||||
return RestResponse.ok(count);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/message/read/{id}", method = RequestMethod.POST)
|
||||
public RestResponse read(@PathVariable Integer id) {
|
||||
messageService.read(id);
|
||||
return RestResponse.ok();
|
||||
}
|
||||
|
||||
}
|
||||
159
source/xzs/src/main/java/com/mindskip/xzs/domain/ExamPaper.java
Normal file
159
source/xzs/src/main/java/com/mindskip/xzs/domain/ExamPaper.java
Normal file
@@ -0,0 +1,159 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class ExamPaper implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8509645224550501395L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer subjectId;
|
||||
|
||||
private Integer paperType;
|
||||
|
||||
private Integer gradeLevel;
|
||||
|
||||
private Integer score;
|
||||
|
||||
private Integer questionCount;
|
||||
|
||||
private Integer suggestTime;
|
||||
|
||||
private Date limitStartTime;
|
||||
|
||||
private Date limitEndTime;
|
||||
|
||||
private Integer frameTextContentId;
|
||||
|
||||
private Integer createUser;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Boolean deleted;
|
||||
|
||||
private Integer taskExamId;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name == null ? null : name.trim();
|
||||
}
|
||||
|
||||
public Integer getSubjectId() {
|
||||
return subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectId(Integer subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public Integer getPaperType() {
|
||||
return paperType;
|
||||
}
|
||||
|
||||
public void setPaperType(Integer paperType) {
|
||||
this.paperType = paperType;
|
||||
}
|
||||
|
||||
public Integer getGradeLevel() {
|
||||
return gradeLevel;
|
||||
}
|
||||
|
||||
public void setGradeLevel(Integer gradeLevel) {
|
||||
this.gradeLevel = gradeLevel;
|
||||
}
|
||||
|
||||
public Integer getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(Integer score) {
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public Integer getQuestionCount() {
|
||||
return questionCount;
|
||||
}
|
||||
|
||||
public void setQuestionCount(Integer questionCount) {
|
||||
this.questionCount = questionCount;
|
||||
}
|
||||
|
||||
public Integer getSuggestTime() {
|
||||
return suggestTime;
|
||||
}
|
||||
|
||||
public void setSuggestTime(Integer suggestTime) {
|
||||
this.suggestTime = suggestTime;
|
||||
}
|
||||
|
||||
public Date getLimitStartTime() {
|
||||
return limitStartTime;
|
||||
}
|
||||
|
||||
public void setLimitStartTime(Date limitStartTime) {
|
||||
this.limitStartTime = limitStartTime;
|
||||
}
|
||||
|
||||
public Date getLimitEndTime() {
|
||||
return limitEndTime;
|
||||
}
|
||||
|
||||
public void setLimitEndTime(Date limitEndTime) {
|
||||
this.limitEndTime = limitEndTime;
|
||||
}
|
||||
|
||||
public Integer getFrameTextContentId() {
|
||||
return frameTextContentId;
|
||||
}
|
||||
|
||||
public void setFrameTextContentId(Integer frameTextContentId) {
|
||||
this.frameTextContentId = frameTextContentId;
|
||||
}
|
||||
|
||||
public Integer getCreateUser() {
|
||||
return createUser;
|
||||
}
|
||||
|
||||
public void setCreateUser(Integer createUser) {
|
||||
this.createUser = createUser;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Boolean getDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(Boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public Integer getTaskExamId() {
|
||||
return taskExamId;
|
||||
}
|
||||
|
||||
public void setTaskExamId(Integer taskExamId) {
|
||||
this.taskExamId = taskExamId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class ExamPaperAnswer implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2143539181805283910L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private Integer examPaperId;
|
||||
|
||||
private String paperName;
|
||||
|
||||
private Integer paperType;
|
||||
|
||||
private Integer subjectId;
|
||||
|
||||
private Integer systemScore;
|
||||
|
||||
private Integer userScore;
|
||||
|
||||
private Integer paperScore;
|
||||
|
||||
private Integer questionCorrect;
|
||||
|
||||
private Integer questionCount;
|
||||
|
||||
private Integer doTime;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Integer createUser;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Integer taskExamId;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getExamPaperId() {
|
||||
return examPaperId;
|
||||
}
|
||||
|
||||
public void setExamPaperId(Integer examPaperId) {
|
||||
this.examPaperId = examPaperId;
|
||||
}
|
||||
|
||||
public String getPaperName() {
|
||||
return paperName;
|
||||
}
|
||||
|
||||
public void setPaperName(String paperName) {
|
||||
this.paperName = paperName == null ? null : paperName.trim();
|
||||
}
|
||||
|
||||
public Integer getPaperType() {
|
||||
return paperType;
|
||||
}
|
||||
|
||||
public void setPaperType(Integer paperType) {
|
||||
this.paperType = paperType;
|
||||
}
|
||||
|
||||
public Integer getSubjectId() {
|
||||
return subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectId(Integer subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public Integer getSystemScore() {
|
||||
return systemScore;
|
||||
}
|
||||
|
||||
public void setSystemScore(Integer systemScore) {
|
||||
this.systemScore = systemScore;
|
||||
}
|
||||
|
||||
public Integer getUserScore() {
|
||||
return userScore;
|
||||
}
|
||||
|
||||
public void setUserScore(Integer userScore) {
|
||||
this.userScore = userScore;
|
||||
}
|
||||
|
||||
public Integer getPaperScore() {
|
||||
return paperScore;
|
||||
}
|
||||
|
||||
public void setPaperScore(Integer paperScore) {
|
||||
this.paperScore = paperScore;
|
||||
}
|
||||
|
||||
public Integer getQuestionCorrect() {
|
||||
return questionCorrect;
|
||||
}
|
||||
|
||||
public void setQuestionCorrect(Integer questionCorrect) {
|
||||
this.questionCorrect = questionCorrect;
|
||||
}
|
||||
|
||||
public Integer getQuestionCount() {
|
||||
return questionCount;
|
||||
}
|
||||
|
||||
public void setQuestionCount(Integer questionCount) {
|
||||
this.questionCount = questionCount;
|
||||
}
|
||||
|
||||
public Integer getDoTime() {
|
||||
return doTime;
|
||||
}
|
||||
|
||||
public void setDoTime(Integer doTime) {
|
||||
this.doTime = doTime;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getCreateUser() {
|
||||
return createUser;
|
||||
}
|
||||
|
||||
public void setCreateUser(Integer createUser) {
|
||||
this.createUser = createUser;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Integer getTaskExamId() {
|
||||
return taskExamId;
|
||||
}
|
||||
|
||||
public void setTaskExamId(Integer taskExamId) {
|
||||
this.taskExamId = taskExamId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ExamPaperAnswerInfo {
|
||||
public ExamPaper examPaper;
|
||||
public ExamPaperAnswer examPaperAnswer;
|
||||
public List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers;
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class ExamPaperQuestionCustomerAnswer implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 3389482731220342366L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private Integer questionId;
|
||||
|
||||
private Integer examPaperId;
|
||||
|
||||
private Integer examPaperAnswerId;
|
||||
|
||||
private Integer questionType;
|
||||
|
||||
private Integer subjectId;
|
||||
|
||||
private Integer customerScore;
|
||||
|
||||
private Integer questionScore;
|
||||
|
||||
private Integer questionTextContentId;
|
||||
|
||||
private String answer;
|
||||
|
||||
private Integer textContentId;
|
||||
|
||||
private Boolean doRight;
|
||||
|
||||
private Integer createUser;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Integer itemOrder;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getQuestionId() {
|
||||
return questionId;
|
||||
}
|
||||
|
||||
public void setQuestionId(Integer questionId) {
|
||||
this.questionId = questionId;
|
||||
}
|
||||
|
||||
public Integer getExamPaperId() {
|
||||
return examPaperId;
|
||||
}
|
||||
|
||||
public void setExamPaperId(Integer examPaperId) {
|
||||
this.examPaperId = examPaperId;
|
||||
}
|
||||
|
||||
public Integer getExamPaperAnswerId() {
|
||||
return examPaperAnswerId;
|
||||
}
|
||||
|
||||
public void setExamPaperAnswerId(Integer examPaperAnswerId) {
|
||||
this.examPaperAnswerId = examPaperAnswerId;
|
||||
}
|
||||
|
||||
public Integer getQuestionType() {
|
||||
return questionType;
|
||||
}
|
||||
|
||||
public void setQuestionType(Integer questionType) {
|
||||
this.questionType = questionType;
|
||||
}
|
||||
|
||||
public Integer getSubjectId() {
|
||||
return subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectId(Integer subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public Integer getCustomerScore() {
|
||||
return customerScore;
|
||||
}
|
||||
|
||||
public void setCustomerScore(Integer customerScore) {
|
||||
this.customerScore = customerScore;
|
||||
}
|
||||
|
||||
public Integer getQuestionScore() {
|
||||
return questionScore;
|
||||
}
|
||||
|
||||
public void setQuestionScore(Integer questionScore) {
|
||||
this.questionScore = questionScore;
|
||||
}
|
||||
|
||||
public Integer getQuestionTextContentId() {
|
||||
return questionTextContentId;
|
||||
}
|
||||
|
||||
public void setQuestionTextContentId(Integer questionTextContentId) {
|
||||
this.questionTextContentId = questionTextContentId;
|
||||
}
|
||||
|
||||
public String getAnswer() {
|
||||
return answer;
|
||||
}
|
||||
|
||||
public void setAnswer(String answer) {
|
||||
this.answer = answer == null ? null : answer.trim();
|
||||
}
|
||||
|
||||
public Integer getTextContentId() {
|
||||
return textContentId;
|
||||
}
|
||||
|
||||
public void setTextContentId(Integer textContentId) {
|
||||
this.textContentId = textContentId;
|
||||
}
|
||||
|
||||
public Boolean getDoRight() {
|
||||
return doRight;
|
||||
}
|
||||
|
||||
public void setDoRight(Boolean doRight) {
|
||||
this.doRight = doRight;
|
||||
}
|
||||
|
||||
public Integer getCreateUser() {
|
||||
return createUser;
|
||||
}
|
||||
|
||||
public void setCreateUser(Integer createUser) {
|
||||
this.createUser = createUser;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Integer getItemOrder() {
|
||||
return itemOrder;
|
||||
}
|
||||
|
||||
public void setItemOrder(Integer itemOrder) {
|
||||
this.itemOrder = itemOrder;
|
||||
}
|
||||
}
|
||||
102
source/xzs/src/main/java/com/mindskip/xzs/domain/Message.java
Normal file
102
source/xzs/src/main/java/com/mindskip/xzs/domain/Message.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class Message implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3510265139403747341L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String title;
|
||||
|
||||
private String content;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Integer sendUserId;
|
||||
|
||||
private String sendUserName;
|
||||
|
||||
private String sendRealName;
|
||||
|
||||
private Integer receiveUserCount;
|
||||
|
||||
private Integer readCount;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title == null ? null : title.trim();
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content == null ? null : content.trim();
|
||||
}
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Integer getSendUserId() {
|
||||
return sendUserId;
|
||||
}
|
||||
|
||||
public void setSendUserId(Integer sendUserId) {
|
||||
this.sendUserId = sendUserId;
|
||||
}
|
||||
|
||||
public String getSendUserName() {
|
||||
return sendUserName;
|
||||
}
|
||||
|
||||
public void setSendUserName(String sendUserName) {
|
||||
this.sendUserName = sendUserName == null ? null : sendUserName.trim();
|
||||
}
|
||||
|
||||
public String getSendRealName() {
|
||||
return sendRealName;
|
||||
}
|
||||
|
||||
public void setSendRealName(String sendRealName) {
|
||||
this.sendRealName = sendRealName == null ? null : sendRealName.trim();
|
||||
}
|
||||
|
||||
public Integer getReceiveUserCount() {
|
||||
return receiveUserCount;
|
||||
}
|
||||
|
||||
public void setReceiveUserCount(Integer receiveUserCount) {
|
||||
this.receiveUserCount = receiveUserCount;
|
||||
}
|
||||
|
||||
public Integer getReadCount() {
|
||||
return readCount;
|
||||
}
|
||||
|
||||
public void setReadCount(Integer readCount) {
|
||||
this.readCount = readCount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class MessageUser implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4042932811802896498L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private Integer messageId;
|
||||
|
||||
private Integer receiveUserId;
|
||||
|
||||
private String receiveUserName;
|
||||
|
||||
private String receiveRealName;
|
||||
|
||||
private Boolean readed;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date readTime;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public void setMessageId(Integer messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public Integer getReceiveUserId() {
|
||||
return receiveUserId;
|
||||
}
|
||||
|
||||
public void setReceiveUserId(Integer receiveUserId) {
|
||||
this.receiveUserId = receiveUserId;
|
||||
}
|
||||
|
||||
public String getReceiveUserName() {
|
||||
return receiveUserName;
|
||||
}
|
||||
|
||||
public void setReceiveUserName(String receiveUserName) {
|
||||
this.receiveUserName = receiveUserName == null ? null : receiveUserName.trim();
|
||||
}
|
||||
|
||||
public String getReceiveRealName() {
|
||||
return receiveRealName;
|
||||
}
|
||||
|
||||
public void setReceiveRealName(String receiveRealName) {
|
||||
this.receiveRealName = receiveRealName == null ? null : receiveRealName.trim();
|
||||
}
|
||||
|
||||
public Boolean getReaded() {
|
||||
return readed;
|
||||
}
|
||||
|
||||
public void setReaded(Boolean readed) {
|
||||
this.readed = readed;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getReadTime() {
|
||||
return readTime;
|
||||
}
|
||||
|
||||
public void setReadTime(Date readTime) {
|
||||
this.readTime = readTime;
|
||||
}
|
||||
}
|
||||
144
source/xzs/src/main/java/com/mindskip/xzs/domain/Question.java
Normal file
144
source/xzs/src/main/java/com/mindskip/xzs/domain/Question.java
Normal file
@@ -0,0 +1,144 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import com.mindskip.xzs.domain.enums.QuestionTypeEnum;
|
||||
import com.mindskip.xzs.utility.ExamUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class Question implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8826266720383164363L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private Integer questionType;
|
||||
|
||||
private Integer subjectId;
|
||||
|
||||
private Integer score;
|
||||
|
||||
private Integer gradeLevel;
|
||||
|
||||
private Integer difficult;
|
||||
|
||||
private String correct;
|
||||
|
||||
private Integer infoTextContentId;
|
||||
|
||||
private Integer createUser;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Boolean deleted;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getQuestionType() {
|
||||
return questionType;
|
||||
}
|
||||
|
||||
public void setQuestionType(Integer questionType) {
|
||||
this.questionType = questionType;
|
||||
}
|
||||
|
||||
public Integer getSubjectId() {
|
||||
return subjectId;
|
||||
}
|
||||
|
||||
public void setSubjectId(Integer subjectId) {
|
||||
this.subjectId = subjectId;
|
||||
}
|
||||
|
||||
public Integer getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public void setScore(Integer score) {
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public Integer getGradeLevel() {
|
||||
return gradeLevel;
|
||||
}
|
||||
|
||||
public void setGradeLevel(Integer gradeLevel) {
|
||||
this.gradeLevel = gradeLevel;
|
||||
}
|
||||
|
||||
public Integer getDifficult() {
|
||||
return difficult;
|
||||
}
|
||||
|
||||
public void setDifficult(Integer difficult) {
|
||||
this.difficult = difficult;
|
||||
}
|
||||
|
||||
public String getCorrect() {
|
||||
return correct;
|
||||
}
|
||||
|
||||
public void setCorrect(String correct) {
|
||||
this.correct = correct == null ? null : correct.trim();
|
||||
}
|
||||
|
||||
public Integer getInfoTextContentId() {
|
||||
return infoTextContentId;
|
||||
}
|
||||
|
||||
public void setInfoTextContentId(Integer infoTextContentId) {
|
||||
this.infoTextContentId = infoTextContentId;
|
||||
}
|
||||
|
||||
public Integer getCreateUser() {
|
||||
return createUser;
|
||||
}
|
||||
|
||||
public void setCreateUser(Integer createUser) {
|
||||
this.createUser = createUser;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Boolean getDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(Boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
|
||||
public void setCorrectFromVM(String correct, List<String> correctArray) {
|
||||
int qType = this.getQuestionType();
|
||||
if (qType == QuestionTypeEnum.MultipleChoice.getCode()) {
|
||||
String correctJoin = ExamUtil.contentToString(correctArray);
|
||||
this.setCorrect(correctJoin);
|
||||
} else {
|
||||
this.setCorrect(correct);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class Subject implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8058095034457106501L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer level;
|
||||
|
||||
private String levelName;
|
||||
|
||||
private Integer itemOrder;
|
||||
|
||||
private Boolean deleted;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name == null ? null : name.trim();
|
||||
}
|
||||
|
||||
public Integer getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(Integer level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public String getLevelName() {
|
||||
return levelName;
|
||||
}
|
||||
|
||||
public void setLevelName(String levelName) {
|
||||
this.levelName = levelName == null ? null : levelName.trim();
|
||||
}
|
||||
|
||||
public Integer getItemOrder() {
|
||||
return itemOrder;
|
||||
}
|
||||
|
||||
public void setItemOrder(Integer itemOrder) {
|
||||
this.itemOrder = itemOrder;
|
||||
}
|
||||
|
||||
public Boolean getDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(Boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class TaskExam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7014704644631536195L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String title;
|
||||
|
||||
private Integer gradeLevel;
|
||||
|
||||
private Integer frameTextContentId;
|
||||
|
||||
private Integer createUser;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Boolean deleted;
|
||||
|
||||
private String createUserName;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title == null ? null : title.trim();
|
||||
}
|
||||
|
||||
public Integer getGradeLevel() {
|
||||
return gradeLevel;
|
||||
}
|
||||
|
||||
public void setGradeLevel(Integer gradeLevel) {
|
||||
this.gradeLevel = gradeLevel;
|
||||
}
|
||||
|
||||
public Integer getFrameTextContentId() {
|
||||
return frameTextContentId;
|
||||
}
|
||||
|
||||
public void setFrameTextContentId(Integer frameTextContentId) {
|
||||
this.frameTextContentId = frameTextContentId;
|
||||
}
|
||||
|
||||
public Integer getCreateUser() {
|
||||
return createUser;
|
||||
}
|
||||
|
||||
public void setCreateUser(Integer createUser) {
|
||||
this.createUser = createUser;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Boolean getDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(Boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public String getCreateUserName() {
|
||||
return createUserName;
|
||||
}
|
||||
|
||||
public void setCreateUserName(String createUserName) {
|
||||
this.createUserName = createUserName == null ? null : createUserName.trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class TaskExamCustomerAnswer implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -556842372977600137L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private Integer taskExamId;
|
||||
|
||||
private Integer createUser;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Integer textContentId;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getTaskExamId() {
|
||||
return taskExamId;
|
||||
}
|
||||
|
||||
public void setTaskExamId(Integer taskExamId) {
|
||||
this.taskExamId = taskExamId;
|
||||
}
|
||||
|
||||
public Integer getCreateUser() {
|
||||
return createUser;
|
||||
}
|
||||
|
||||
public void setCreateUser(Integer createUser) {
|
||||
this.createUser = createUser;
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Integer getTextContentId() {
|
||||
return textContentId;
|
||||
}
|
||||
|
||||
public void setTextContentId(Integer textContentId) {
|
||||
this.textContentId = textContentId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class TextContent implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -1279530310964668131L;
|
||||
|
||||
public TextContent(){
|
||||
|
||||
}
|
||||
|
||||
public TextContent(String content, Date createTime) {
|
||||
this.content = content;
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String content;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content == null ? null : content.trim();
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
189
source/xzs/src/main/java/com/mindskip/xzs/domain/User.java
Normal file
189
source/xzs/src/main/java/com/mindskip/xzs/domain/User.java
Normal file
@@ -0,0 +1,189 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class User implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7797183521247423117L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String userUuid;
|
||||
|
||||
private String userName;
|
||||
|
||||
private String password;
|
||||
|
||||
private String realName;
|
||||
|
||||
private Integer age;
|
||||
|
||||
private Integer sex;
|
||||
|
||||
private Date birthDay;
|
||||
|
||||
private Integer userLevel;
|
||||
|
||||
private String phone;
|
||||
|
||||
private Integer role;
|
||||
|
||||
private Integer status;
|
||||
|
||||
private String imagePath;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date modifyTime;
|
||||
|
||||
private Date lastActiveTime;
|
||||
|
||||
private Boolean deleted;
|
||||
|
||||
private String wxOpenId;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUserUuid() {
|
||||
return userUuid;
|
||||
}
|
||||
|
||||
public void setUserUuid(String userUuid) {
|
||||
this.userUuid = userUuid == null ? null : userUuid.trim();
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName == null ? null : userName.trim();
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password == null ? null : password.trim();
|
||||
}
|
||||
|
||||
public String getRealName() {
|
||||
return realName;
|
||||
}
|
||||
|
||||
public void setRealName(String realName) {
|
||||
this.realName = realName == null ? null : realName.trim();
|
||||
}
|
||||
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public Integer getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(Integer sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public Date getBirthDay() {
|
||||
return birthDay;
|
||||
}
|
||||
|
||||
public void setBirthDay(Date birthDay) {
|
||||
this.birthDay = birthDay;
|
||||
}
|
||||
|
||||
public Integer getUserLevel() {
|
||||
return userLevel;
|
||||
}
|
||||
|
||||
public void setUserLevel(Integer userLevel) {
|
||||
this.userLevel = userLevel;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone == null ? null : phone.trim();
|
||||
}
|
||||
|
||||
public Integer getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(Integer role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getImagePath() {
|
||||
return imagePath;
|
||||
}
|
||||
|
||||
public void setImagePath(String imagePath) {
|
||||
this.imagePath = imagePath == null ? null : imagePath.trim();
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getModifyTime() {
|
||||
return modifyTime;
|
||||
}
|
||||
|
||||
public void setModifyTime(Date modifyTime) {
|
||||
this.modifyTime = modifyTime;
|
||||
}
|
||||
|
||||
public Date getLastActiveTime() {
|
||||
return lastActiveTime;
|
||||
}
|
||||
|
||||
public void setLastActiveTime(Date lastActiveTime) {
|
||||
this.lastActiveTime = lastActiveTime;
|
||||
}
|
||||
|
||||
public Boolean getDeleted() {
|
||||
return deleted;
|
||||
}
|
||||
|
||||
public void setDeleted(Boolean deleted) {
|
||||
this.deleted = deleted;
|
||||
}
|
||||
|
||||
public String getWxOpenId() {
|
||||
return wxOpenId;
|
||||
}
|
||||
|
||||
public void setWxOpenId(String wxOpenId) {
|
||||
this.wxOpenId = wxOpenId == null ? null : wxOpenId.trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class UserEventLog implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -3951198127152024633L;
|
||||
|
||||
|
||||
public UserEventLog(){
|
||||
|
||||
}
|
||||
|
||||
public UserEventLog(Integer userId, String userName, String realName, Date createTime) {
|
||||
this.userId = userId;
|
||||
this.userName = userName;
|
||||
this.realName = realName;
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
private Integer id;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private String userName;
|
||||
|
||||
private String realName;
|
||||
|
||||
private String content;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName == null ? null : userName.trim();
|
||||
}
|
||||
|
||||
public String getRealName() {
|
||||
return realName;
|
||||
}
|
||||
|
||||
public void setRealName(String realName) {
|
||||
this.realName = realName == null ? null : realName.trim();
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content == null ? null : content.trim();
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.mindskip.xzs.domain;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
public class UserToken implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2414443061696200360L;
|
||||
|
||||
private Integer id;
|
||||
|
||||
private String token;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private String wxOpenId;
|
||||
|
||||
private Date createTime;
|
||||
|
||||
private Date endTime;
|
||||
|
||||
private String userName;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token == null ? null : token.trim();
|
||||
}
|
||||
|
||||
public Integer getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Integer userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getWxOpenId() {
|
||||
return wxOpenId;
|
||||
}
|
||||
|
||||
public void setWxOpenId(String wxOpenId) {
|
||||
this.wxOpenId = wxOpenId == null ? null : wxOpenId.trim();
|
||||
}
|
||||
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Date endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName == null ? null : userName.trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.mindskip.xzs.domain.enums;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum ExamPaperAnswerStatusEnum {
|
||||
|
||||
WaitJudge(1, "待批改"),
|
||||
Complete(2, "完成");
|
||||
|
||||
int code;
|
||||
String name;
|
||||
|
||||
ExamPaperAnswerStatusEnum(int code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
private static final Map<Integer, ExamPaperAnswerStatusEnum> keyMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (ExamPaperAnswerStatusEnum item : ExamPaperAnswerStatusEnum.values()) {
|
||||
keyMap.put(item.getCode(), item);
|
||||
}
|
||||
}
|
||||
|
||||
public static ExamPaperAnswerStatusEnum fromCode(Integer code) {
|
||||
return keyMap.get(code);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.mindskip.xzs.domain.enums;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum ExamPaperTypeEnum {
|
||||
|
||||
Fixed(1, "固定试卷"),
|
||||
Temp(2, "临时时间"),
|
||||
Classes(3, "班级试卷"),
|
||||
TimeLimit(4, "时段试卷"),
|
||||
Push(5, "推送试卷"),
|
||||
Task(6, "任务试卷");
|
||||
|
||||
int code;
|
||||
String name;
|
||||
|
||||
ExamPaperTypeEnum(int code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
private static final Map<Integer, ExamPaperTypeEnum> keyMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (ExamPaperTypeEnum item : ExamPaperTypeEnum.values()) {
|
||||
keyMap.put(item.getCode(), item);
|
||||
}
|
||||
}
|
||||
|
||||
public static ExamPaperTypeEnum fromCode(Integer code) {
|
||||
return keyMap.get(code);
|
||||
}
|
||||
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.mindskip.xzs.domain.enums;
|
||||
|
||||
public enum QuestionStatusEnum {
|
||||
|
||||
OK(1, "正常"),
|
||||
Publish(2, "发布");
|
||||
|
||||
int code;
|
||||
String name;
|
||||
|
||||
QuestionStatusEnum(int code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.mindskip.xzs.domain.enums;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum QuestionTypeEnum {
|
||||
|
||||
SingleChoice(1, "单选题"),
|
||||
MultipleChoice(2, "多选题"),
|
||||
TrueFalse(3, "判断题"),
|
||||
GapFilling(4, "填空题"),
|
||||
ShortAnswer(5, "简答题");
|
||||
|
||||
int code;
|
||||
String name;
|
||||
|
||||
QuestionTypeEnum(int code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
private static final Map<Integer, QuestionTypeEnum> keyMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (QuestionTypeEnum item : QuestionTypeEnum.values()) {
|
||||
keyMap.put(item.getCode(), item);
|
||||
}
|
||||
}
|
||||
|
||||
public static QuestionTypeEnum fromCode(Integer code) {
|
||||
return keyMap.get(code);
|
||||
}
|
||||
|
||||
public static boolean needSaveTextContent(Integer code) {
|
||||
QuestionTypeEnum questionTypeEnum = QuestionTypeEnum.fromCode(code);
|
||||
switch (questionTypeEnum) {
|
||||
case GapFilling:
|
||||
case ShortAnswer:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.mindskip.xzs.domain.enums;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum RoleEnum {
|
||||
|
||||
STUDENT(1, "STUDENT"),
|
||||
TEACHER(2, "TEACHER"),
|
||||
ADMIN(3, "ADMIN");
|
||||
|
||||
int code;
|
||||
String name;
|
||||
|
||||
RoleEnum(int code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private static final Map<Integer, RoleEnum> keyMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (RoleEnum item : RoleEnum.values()) {
|
||||
keyMap.put(item.getCode(), item);
|
||||
}
|
||||
}
|
||||
|
||||
public static RoleEnum fromCode(Integer code) {
|
||||
return keyMap.get(code);
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getRoleName() {
|
||||
return "ROLE_" + name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.mindskip.xzs.domain.enums;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum UserStatusEnum {
|
||||
|
||||
Enable(1, "启用"),
|
||||
Disable(2, "禁用");
|
||||
|
||||
int code;
|
||||
String name;
|
||||
|
||||
UserStatusEnum(int code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private static final Map<Integer, UserStatusEnum> keyMap = new HashMap<>();
|
||||
|
||||
static {
|
||||
for (UserStatusEnum item : UserStatusEnum.values()) {
|
||||
keyMap.put(item.getCode(), item);
|
||||
}
|
||||
}
|
||||
|
||||
public static UserStatusEnum fromCode(Integer code) {
|
||||
return keyMap.get(code);
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.mindskip.xzs.domain.exam;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ExamPaperQuestionItemObject {
|
||||
private Integer id;
|
||||
private Integer itemOrder;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mindskip.xzs.domain.exam;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ExamPaperTitleItemObject {
|
||||
|
||||
private String name;
|
||||
|
||||
private List<ExamPaperQuestionItemObject> questionItems;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mindskip.xzs.domain.other;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ExamPaperAnswerUpdate {
|
||||
private Integer id;
|
||||
private Integer customerScore;
|
||||
private Boolean doRight;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mindskip.xzs.domain.other;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class KeyValue {
|
||||
|
||||
private String name;
|
||||
private Integer value;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mindskip.xzs.domain.question;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QuestionItemObject {
|
||||
|
||||
private String prefix;
|
||||
|
||||
private String content;
|
||||
|
||||
private Integer score;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mindskip.xzs.domain.question;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class QuestionObject {
|
||||
|
||||
private String titleContent;
|
||||
|
||||
private String analyze;
|
||||
|
||||
private List<QuestionItemObject> questionItemObjects;
|
||||
|
||||
private String correct;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mindskip.xzs.domain.task;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TaskItemAnswerObject {
|
||||
private Integer examPaperId;
|
||||
private Integer examPaperAnswerId;
|
||||
private Integer status;
|
||||
|
||||
public TaskItemAnswerObject(){
|
||||
|
||||
}
|
||||
|
||||
public TaskItemAnswerObject(Integer examPaperId, Integer examPaperAnswerId, Integer status) {
|
||||
this.examPaperId = examPaperId;
|
||||
this.examPaperAnswerId = examPaperAnswerId;
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mindskip.xzs.domain.task;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class TaskItemObject {
|
||||
private Integer examPaperId;
|
||||
private String examPaperName;
|
||||
private Integer itemOrder;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mindskip.xzs.event;
|
||||
|
||||
import com.mindskip.xzs.domain.ExamPaperAnswerInfo;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
public class CalculateExamPaperAnswerCompleteEvent extends ApplicationEvent {
|
||||
|
||||
|
||||
private final ExamPaperAnswerInfo examPaperAnswerInfo;
|
||||
|
||||
|
||||
public CalculateExamPaperAnswerCompleteEvent(final ExamPaperAnswerInfo examPaperAnswerInfo) {
|
||||
super(examPaperAnswerInfo);
|
||||
this.examPaperAnswerInfo = examPaperAnswerInfo;
|
||||
}
|
||||
|
||||
public ExamPaperAnswerInfo getExamPaperAnswerInfo() {
|
||||
return examPaperAnswerInfo;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mindskip.xzs.event;
|
||||
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
public class OnRegistrationCompleteEvent extends ApplicationEvent {
|
||||
|
||||
|
||||
private final User user;
|
||||
|
||||
|
||||
public OnRegistrationCompleteEvent(final User user) {
|
||||
super(user);
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mindskip.xzs.event;
|
||||
|
||||
import com.mindskip.xzs.domain.UserEventLog;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
public class UserEvent extends ApplicationEvent {
|
||||
|
||||
private final UserEventLog userEventLog;
|
||||
|
||||
public UserEvent(final UserEventLog userEventLog) {
|
||||
super(userEventLog);
|
||||
this.userEventLog = userEventLog;
|
||||
}
|
||||
|
||||
public UserEventLog getUserEventLog() {
|
||||
return userEventLog;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.mindskip.xzs.exception;
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
public class BusinessException extends RuntimeException {
|
||||
|
||||
public static final int UNKNOWN_EXCEPTION = 0;
|
||||
|
||||
private int code;
|
||||
|
||||
public BusinessException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public BusinessException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public BusinessException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public BusinessException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public BusinessException(int code) {
|
||||
super();
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public BusinessException(int code, String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public BusinessException(int code, String message) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public BusinessException(int code, Throwable cause) {
|
||||
super(cause);
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public boolean isUnknown() {
|
||||
return code == UNKNOWN_EXCEPTION;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.mindskip.xzs.listener;
|
||||
|
||||
import com.mindskip.xzs.domain.*;
|
||||
import com.mindskip.xzs.domain.*;
|
||||
import com.mindskip.xzs.domain.enums.ExamPaperTypeEnum;
|
||||
import com.mindskip.xzs.domain.enums.QuestionTypeEnum;
|
||||
import com.mindskip.xzs.event.CalculateExamPaperAnswerCompleteEvent;
|
||||
import com.mindskip.xzs.service.ExamPaperAnswerService;
|
||||
import com.mindskip.xzs.service.ExamPaperQuestionCustomerAnswerService;
|
||||
import com.mindskip.xzs.service.TaskExamCustomerAnswerService;
|
||||
import com.mindskip.xzs.service.TextContentService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class CalculateExamPaperAnswerListener implements ApplicationListener<CalculateExamPaperAnswerCompleteEvent> {
|
||||
|
||||
|
||||
private final ExamPaperAnswerService examPaperAnswerService;
|
||||
private final ExamPaperQuestionCustomerAnswerService examPaperQuestionCustomerAnswerService;
|
||||
private final TextContentService textContentService;
|
||||
private final TaskExamCustomerAnswerService examCustomerAnswerService;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void onApplicationEvent(CalculateExamPaperAnswerCompleteEvent calculateExamPaperAnswerCompleteEvent) {
|
||||
Date now = new Date();
|
||||
|
||||
ExamPaperAnswerInfo examPaperAnswerInfo = (ExamPaperAnswerInfo) calculateExamPaperAnswerCompleteEvent.getSource();
|
||||
ExamPaper examPaper = examPaperAnswerInfo.getExamPaper();
|
||||
ExamPaperAnswer examPaperAnswer = examPaperAnswerInfo.getExamPaperAnswer();
|
||||
List<ExamPaperQuestionCustomerAnswer> examPaperQuestionCustomerAnswers = examPaperAnswerInfo.getExamPaperQuestionCustomerAnswers();
|
||||
|
||||
examPaperAnswerService.insertByFilter(examPaperAnswer);
|
||||
examPaperQuestionCustomerAnswers.stream().filter(a -> QuestionTypeEnum.needSaveTextContent(a.getQuestionType())).forEach(d -> {
|
||||
TextContent textContent = new TextContent(d.getAnswer(), now);
|
||||
textContentService.insertByFilter(textContent);
|
||||
d.setTextContentId(textContent.getId());
|
||||
d.setAnswer(null);
|
||||
});
|
||||
examPaperQuestionCustomerAnswers.forEach(d -> {
|
||||
d.setExamPaperAnswerId(examPaperAnswer.getId());
|
||||
});
|
||||
examPaperQuestionCustomerAnswerService.insertList(examPaperQuestionCustomerAnswers);
|
||||
|
||||
switch (ExamPaperTypeEnum.fromCode(examPaper.getPaperType())) {
|
||||
case Task: {
|
||||
examCustomerAnswerService.insertOrUpdate(examPaper, examPaperAnswer, now);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mindskip.xzs.listener;
|
||||
|
||||
import com.mindskip.xzs.domain.User;
|
||||
import com.mindskip.xzs.event.OnRegistrationCompleteEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* @author alvis
|
||||
*/
|
||||
@Component
|
||||
public class EmailSendListener implements ApplicationListener<OnRegistrationCompleteEvent> {
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public void onApplicationEvent(OnRegistrationCompleteEvent event) {
|
||||
User user = event.getUser();
|
||||
System.out.println("User register Email sender :" + user.getUserName());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.mindskip.xzs.listener;
|
||||
|
||||
import com.mindskip.xzs.event.UserEvent;
|
||||
import com.mindskip.xzs.service.UserEventLogService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@AllArgsConstructor
|
||||
public class UserLogListener implements ApplicationListener<UserEvent> {
|
||||
|
||||
private UserEventLogService userEventLogService;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(UserEvent userEvent) {
|
||||
userEventLogService.insertByFilter(userEvent.getUserEventLog());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mindskip.xzs.repository;
|
||||
|
||||
public interface BaseMapper<T> {
|
||||
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(T record);
|
||||
|
||||
int insertSelective(T record);
|
||||
|
||||
T selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(T record);
|
||||
|
||||
int updateByPrimaryKey(T record);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.mindskip.xzs.repository;
|
||||
|
||||
import com.mindskip.xzs.domain.ExamPaperAnswer;
|
||||
import com.mindskip.xzs.domain.other.KeyValue;
|
||||
import com.mindskip.xzs.viewmodel.student.exampaper.ExamPaperAnswerPageVM;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ExamPaperAnswerMapper extends BaseMapper<ExamPaperAnswer> {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(ExamPaperAnswer record);
|
||||
|
||||
int insertSelective(ExamPaperAnswer record);
|
||||
|
||||
ExamPaperAnswer selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(ExamPaperAnswer record);
|
||||
|
||||
int updateByPrimaryKey(ExamPaperAnswer record);
|
||||
|
||||
List<ExamPaperAnswer> studentPage(ExamPaperAnswerPageVM requestVM);
|
||||
|
||||
Integer selectAllCount();
|
||||
|
||||
List<KeyValue> selectCountByDate(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
ExamPaperAnswer getByPidUid(@Param("pid") Integer paperId, @Param("uid") Integer uid);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.mindskip.xzs.repository;
|
||||
|
||||
import com.mindskip.xzs.domain.ExamPaper;
|
||||
import com.mindskip.xzs.domain.other.KeyValue;
|
||||
import com.mindskip.xzs.viewmodel.admin.exam.ExamPaperPageRequestVM;
|
||||
import com.mindskip.xzs.viewmodel.student.dashboard.PaperFilter;
|
||||
import com.mindskip.xzs.viewmodel.student.dashboard.PaperInfo;
|
||||
import com.mindskip.xzs.viewmodel.student.exam.ExamPaperPageVM;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ExamPaperMapper extends BaseMapper<ExamPaper> {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(ExamPaper record);
|
||||
|
||||
int insertSelective(ExamPaper record);
|
||||
|
||||
ExamPaper selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(ExamPaper record);
|
||||
|
||||
int updateByPrimaryKey(ExamPaper record);
|
||||
|
||||
List<ExamPaper> page(ExamPaperPageRequestVM requestVM);
|
||||
|
||||
List<ExamPaper> taskExamPage(ExamPaperPageRequestVM requestVM);
|
||||
|
||||
List<ExamPaper> studentPage(ExamPaperPageVM requestVM);
|
||||
|
||||
List<PaperInfo> indexPaper(PaperFilter paperFilter);
|
||||
|
||||
Integer selectAllCount();
|
||||
|
||||
List<KeyValue> selectCountByDate(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
int updateTaskPaper(@Param("taskId") Integer taskId,@Param("paperIds") List<Integer> paperIds);
|
||||
|
||||
int clearTaskPaper(@Param("paperIds") List<Integer> paperIds);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mindskip.xzs.repository;
|
||||
|
||||
import com.mindskip.xzs.domain.ExamPaperQuestionCustomerAnswer;
|
||||
import com.mindskip.xzs.domain.other.ExamPaperAnswerUpdate;
|
||||
import com.mindskip.xzs.domain.other.KeyValue;
|
||||
import com.mindskip.xzs.viewmodel.student.question.answer.QuestionPageStudentRequestVM;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ExamPaperQuestionCustomerAnswerMapper extends BaseMapper<ExamPaperQuestionCustomerAnswer> {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(ExamPaperQuestionCustomerAnswer record);
|
||||
|
||||
int insertSelective(ExamPaperQuestionCustomerAnswer record);
|
||||
|
||||
ExamPaperQuestionCustomerAnswer selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(ExamPaperQuestionCustomerAnswer record);
|
||||
|
||||
int updateByPrimaryKey(ExamPaperQuestionCustomerAnswer record);
|
||||
|
||||
List<ExamPaperQuestionCustomerAnswer> selectListByPaperAnswerId(Integer id);
|
||||
|
||||
List<ExamPaperQuestionCustomerAnswer> studentPage(QuestionPageStudentRequestVM requestVM);
|
||||
|
||||
int insertList(List<ExamPaperQuestionCustomerAnswer> list);
|
||||
|
||||
Integer selectAllCount();
|
||||
|
||||
List<KeyValue> selectCountByDate(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
|
||||
|
||||
int updateScore(List<ExamPaperAnswerUpdate> examPaperAnswerUpdates);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mindskip.xzs.repository;
|
||||
|
||||
import com.mindskip.xzs.domain.Message;
|
||||
import com.mindskip.xzs.viewmodel.admin.message.MessagePageRequestVM;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface MessageMapper extends BaseMapper<Message> {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(Message record);
|
||||
|
||||
int insertSelective(Message record);
|
||||
|
||||
Message selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(Message record);
|
||||
|
||||
int updateByPrimaryKey(Message record);
|
||||
|
||||
List<Message> page(MessagePageRequestVM requestVM);
|
||||
|
||||
List<Message> selectByIds(List<Integer> ids);
|
||||
|
||||
int readAdd(Integer id);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mindskip.xzs.repository;
|
||||
|
||||
import com.mindskip.xzs.domain.MessageUser;
|
||||
import com.mindskip.xzs.viewmodel.student.user.MessageRequestVM;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface MessageUserMapper extends BaseMapper<MessageUser> {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(MessageUser record);
|
||||
|
||||
int insertSelective(MessageUser record);
|
||||
|
||||
MessageUser selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(MessageUser record);
|
||||
|
||||
int updateByPrimaryKey(MessageUser record);
|
||||
|
||||
List<MessageUser> selectByMessageIds(List<Integer> ids);
|
||||
|
||||
int inserts(List<MessageUser> list);
|
||||
|
||||
List<MessageUser> studentPage(MessageRequestVM requestVM);
|
||||
|
||||
Integer unReadCount(Integer userId);
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.mindskip.xzs.repository;
|
||||
|
||||
import com.mindskip.xzs.domain.other.KeyValue;
|
||||
import com.mindskip.xzs.domain.Question;
|
||||
import com.mindskip.xzs.viewmodel.admin.question.QuestionPageRequestVM;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface QuestionMapper extends BaseMapper<Question> {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(Question record);
|
||||
|
||||
int insertSelective(Question record);
|
||||
|
||||
Question selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(Question record);
|
||||
|
||||
int updateByPrimaryKey(Question record);
|
||||
|
||||
List<Question> page(QuestionPageRequestVM requestVM);
|
||||
|
||||
List<Question> selectByIds(@Param("ids") List<Integer> ids);
|
||||
|
||||
Integer selectAllCount();
|
||||
|
||||
List<KeyValue> selectCountByDate(@Param("startTime") Date startTime,@Param("endTime") Date endTime);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mindskip.xzs.repository;
|
||||
|
||||
import com.mindskip.xzs.domain.Subject;
|
||||
import com.mindskip.xzs.viewmodel.admin.education.SubjectPageRequestVM;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface SubjectMapper extends BaseMapper<Subject> {
|
||||
int deleteByPrimaryKey(Integer id);
|
||||
|
||||
int insert(Subject record);
|
||||
|
||||
int insertSelective(Subject record);
|
||||
|
||||
Subject selectByPrimaryKey(Integer id);
|
||||
|
||||
int updateByPrimaryKeySelective(Subject record);
|
||||
|
||||
int updateByPrimaryKey(Subject record);
|
||||
|
||||
List<Subject> getSubjectByLevel(Integer level);
|
||||
|
||||
List<Subject> allSubject();
|
||||
|
||||
List<Subject> page(SubjectPageRequestVM requestVM);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user