forked from p4fmevgyr/XYSH
commit
7fc411dd1b
@ -0,0 +1,33 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
@ -0,0 +1,118 @@
|
||||
/*
|
||||
* Copyright 2007-present the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import java.nio.channels.*;
|
||||
import java.util.Properties;
|
||||
|
||||
public class MavenWrapperDownloader {
|
||||
|
||||
private static final String WRAPPER_VERSION = "0.5.6";
|
||||
/**
|
||||
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
|
||||
*/
|
||||
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
|
||||
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
|
||||
|
||||
/**
|
||||
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
|
||||
* use instead of the default one.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
|
||||
".mvn/wrapper/maven-wrapper.properties";
|
||||
|
||||
/**
|
||||
* Path where the maven-wrapper.jar will be saved to.
|
||||
*/
|
||||
private static final String MAVEN_WRAPPER_JAR_PATH =
|
||||
".mvn/wrapper/maven-wrapper.jar";
|
||||
|
||||
/**
|
||||
* Name of the property which should be used to override the default download url for the wrapper.
|
||||
*/
|
||||
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
|
||||
|
||||
public static void main(String args[]) {
|
||||
System.out.println("- Downloader started");
|
||||
File baseDirectory = new File(args[0]);
|
||||
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
|
||||
|
||||
// If the maven-wrapper.properties exists, read it and check if it contains a custom
|
||||
// wrapperUrl parameter.
|
||||
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
|
||||
String url = DEFAULT_DOWNLOAD_URL;
|
||||
if (mavenWrapperPropertyFile.exists()) {
|
||||
FileInputStream mavenWrapperPropertyFileInputStream = null;
|
||||
try {
|
||||
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
|
||||
Properties mavenWrapperProperties = new Properties();
|
||||
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
|
||||
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
|
||||
} catch (IOException e) {
|
||||
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
|
||||
} finally {
|
||||
try {
|
||||
if (mavenWrapperPropertyFileInputStream != null) {
|
||||
mavenWrapperPropertyFileInputStream.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// Ignore ...
|
||||
}
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading from: " + url);
|
||||
|
||||
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
|
||||
if (!outputFile.getParentFile().exists()) {
|
||||
if (!outputFile.getParentFile().mkdirs()) {
|
||||
System.out.println(
|
||||
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
|
||||
}
|
||||
}
|
||||
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
|
||||
try {
|
||||
downloadFileFromURL(url, outputFile);
|
||||
System.out.println("Done");
|
||||
System.exit(0);
|
||||
} catch (Throwable e) {
|
||||
System.out.println("- Error downloading");
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
|
||||
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
|
||||
String username = System.getenv("MVNW_USERNAME");
|
||||
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
|
||||
Authenticator.setDefault(new Authenticator() {
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(username, password);
|
||||
}
|
||||
});
|
||||
}
|
||||
URL website = new URL(urlString);
|
||||
ReadableByteChannel rbc;
|
||||
rbc = Channels.newChannel(website.openStream());
|
||||
FileOutputStream fos = new FileOutputStream(destination);
|
||||
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
|
||||
fos.close();
|
||||
rbc.close();
|
||||
}
|
||||
|
||||
}
|
Binary file not shown.
@ -0,0 +1,2 @@
|
||||
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
|
||||
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
|
@ -0,0 +1,310 @@
|
||||
#!/bin/sh
|
||||
# ----------------------------------------------------------------------------
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Maven Start Up Batch script
|
||||
#
|
||||
# Required ENV vars:
|
||||
# ------------------
|
||||
# JAVA_HOME - location of a JDK home dir
|
||||
#
|
||||
# Optional ENV vars
|
||||
# -----------------
|
||||
# M2_HOME - location of maven2's installed home dir
|
||||
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
# e.g. to debug Maven itself, use
|
||||
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ -z "$MAVEN_SKIP_RC" ] ; then
|
||||
|
||||
if [ -f /etc/mavenrc ] ; then
|
||||
. /etc/mavenrc
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.mavenrc" ] ; then
|
||||
. "$HOME/.mavenrc"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
# OS specific support. $var _must_ be set to either true or false.
|
||||
cygwin=false;
|
||||
darwin=false;
|
||||
mingw=false
|
||||
case "`uname`" in
|
||||
CYGWIN*) cygwin=true ;;
|
||||
MINGW*) mingw=true;;
|
||||
Darwin*) darwin=true
|
||||
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
|
||||
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
if [ -x "/usr/libexec/java_home" ]; then
|
||||
export JAVA_HOME="`/usr/libexec/java_home`"
|
||||
else
|
||||
export JAVA_HOME="/Library/Java/Home"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
if [ -r /etc/gentoo-release ] ; then
|
||||
JAVA_HOME=`java-config --jre-home`
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$M2_HOME" ] ; then
|
||||
## resolve links - $0 may be a link to maven's home
|
||||
PRG="$0"
|
||||
|
||||
# need this for relative symlinks
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG="`dirname "$PRG"`/$link"
|
||||
fi
|
||||
done
|
||||
|
||||
saveddir=`pwd`
|
||||
|
||||
M2_HOME=`dirname "$PRG"`/..
|
||||
|
||||
# make it fully qualified
|
||||
M2_HOME=`cd "$M2_HOME" && pwd`
|
||||
|
||||
cd "$saveddir"
|
||||
# echo Using m2 at $M2_HOME
|
||||
fi
|
||||
|
||||
# For Cygwin, ensure paths are in UNIX format before anything is touched
|
||||
if $cygwin ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --unix "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
|
||||
fi
|
||||
|
||||
# For Mingw, ensure paths are in UNIX format before anything is touched
|
||||
if $mingw ; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME="`(cd "$M2_HOME"; pwd)`"
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ]; then
|
||||
javaExecutable="`which javac`"
|
||||
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
|
||||
# readlink(1) is not available as standard on Solaris 10.
|
||||
readLink=`which readlink`
|
||||
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
|
||||
if $darwin ; then
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
|
||||
else
|
||||
javaExecutable="`readlink -f \"$javaExecutable\"`"
|
||||
fi
|
||||
javaHome="`dirname \"$javaExecutable\"`"
|
||||
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
|
||||
JAVA_HOME="$javaHome"
|
||||
export JAVA_HOME
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$JAVACMD" ] ; then
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
else
|
||||
JAVACMD="`which java`"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
echo "Error: JAVA_HOME is not defined correctly." >&2
|
||||
echo " We cannot execute $JAVACMD" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$JAVA_HOME" ] ; then
|
||||
echo "Warning: JAVA_HOME environment variable is not set."
|
||||
fi
|
||||
|
||||
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
|
||||
|
||||
# traverses directory structure from process work directory to filesystem root
|
||||
# first directory with .mvn subdirectory is considered project base directory
|
||||
find_maven_basedir() {
|
||||
|
||||
if [ -z "$1" ]
|
||||
then
|
||||
echo "Path not specified to find_maven_basedir"
|
||||
return 1
|
||||
fi
|
||||
|
||||
basedir="$1"
|
||||
wdir="$1"
|
||||
while [ "$wdir" != '/' ] ; do
|
||||
if [ -d "$wdir"/.mvn ] ; then
|
||||
basedir=$wdir
|
||||
break
|
||||
fi
|
||||
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
|
||||
if [ -d "${wdir}" ]; then
|
||||
wdir=`cd "$wdir/.."; pwd`
|
||||
fi
|
||||
# end of workaround
|
||||
done
|
||||
echo "${basedir}"
|
||||
}
|
||||
|
||||
# concatenates all lines of a file
|
||||
concat_lines() {
|
||||
if [ -f "$1" ]; then
|
||||
echo "$(tr -s '\n' ' ' < "$1")"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE_DIR=`find_maven_basedir "$(pwd)"`
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
##########################################################################################
|
||||
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
# This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
##########################################################################################
|
||||
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found .mvn/wrapper/maven-wrapper.jar"
|
||||
fi
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
|
||||
fi
|
||||
if [ -n "$MVNW_REPOURL" ]; then
|
||||
jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
else
|
||||
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
fi
|
||||
while IFS="=" read key value; do
|
||||
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
|
||||
esac
|
||||
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Downloading from: $jarUrl"
|
||||
fi
|
||||
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
|
||||
if $cygwin; then
|
||||
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
|
||||
fi
|
||||
|
||||
if command -v wget > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found wget ... using wget"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
wget "$jarUrl" -O "$wrapperJarPath"
|
||||
else
|
||||
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath"
|
||||
fi
|
||||
elif command -v curl > /dev/null; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Found curl ... using curl"
|
||||
fi
|
||||
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
|
||||
curl -o "$wrapperJarPath" "$jarUrl" -f
|
||||
else
|
||||
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
|
||||
fi
|
||||
|
||||
else
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo "Falling back to using Java to download"
|
||||
fi
|
||||
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
|
||||
# For Cygwin, switch paths to Windows format before running javac
|
||||
if $cygwin; then
|
||||
javaClass=`cygpath --path --windows "$javaClass"`
|
||||
fi
|
||||
if [ -e "$javaClass" ]; then
|
||||
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Compiling MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
# Compiling the Java class
|
||||
("$JAVA_HOME/bin/javac" "$javaClass")
|
||||
fi
|
||||
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
|
||||
# Running the downloader
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo " - Running MavenWrapperDownloader.java ..."
|
||||
fi
|
||||
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
##########################################################################################
|
||||
# End of extension
|
||||
##########################################################################################
|
||||
|
||||
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
|
||||
if [ "$MVNW_VERBOSE" = true ]; then
|
||||
echo $MAVEN_PROJECTBASEDIR
|
||||
fi
|
||||
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin; then
|
||||
[ -n "$M2_HOME" ] &&
|
||||
M2_HOME=`cygpath --path --windows "$M2_HOME"`
|
||||
[ -n "$JAVA_HOME" ] &&
|
||||
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
|
||||
[ -n "$CLASSPATH" ] &&
|
||||
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
|
||||
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
|
||||
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
|
||||
fi
|
||||
|
||||
# Provide a "standardized" way to retrieve the CLI args that will
|
||||
# work with both Windows and non-Windows executions.
|
||||
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
|
||||
export MAVEN_CMD_LINE_ARGS
|
||||
|
||||
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
exec "$JAVACMD" \
|
||||
$MAVEN_OPTS \
|
||||
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
|
||||
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
|
@ -0,0 +1,182 @@
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Licensed to the Apache Software Foundation (ASF) under one
|
||||
@REM or more contributor license agreements. See the NOTICE file
|
||||
@REM distributed with this work for additional information
|
||||
@REM regarding copyright ownership. The ASF licenses this file
|
||||
@REM to you under the Apache License, Version 2.0 (the
|
||||
@REM "License"); you may not use this file except in compliance
|
||||
@REM with the License. You may obtain a copy of the License at
|
||||
@REM
|
||||
@REM https://www.apache.org/licenses/LICENSE-2.0
|
||||
@REM
|
||||
@REM Unless required by applicable law or agreed to in writing,
|
||||
@REM software distributed under the License is distributed on an
|
||||
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
@REM KIND, either express or implied. See the License for the
|
||||
@REM specific language governing permissions and limitations
|
||||
@REM under the License.
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM ----------------------------------------------------------------------------
|
||||
@REM Maven Start Up Batch script
|
||||
@REM
|
||||
@REM Required ENV vars:
|
||||
@REM JAVA_HOME - location of a JDK home dir
|
||||
@REM
|
||||
@REM Optional ENV vars
|
||||
@REM M2_HOME - location of maven2's installed home dir
|
||||
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
|
||||
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
|
||||
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
|
||||
@REM e.g. to debug Maven itself, use
|
||||
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
|
||||
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
|
||||
@REM ----------------------------------------------------------------------------
|
||||
|
||||
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
|
||||
@echo off
|
||||
@REM set title of command window
|
||||
title %0
|
||||
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
|
||||
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
|
||||
|
||||
@REM set %HOME% to equivalent of $HOME
|
||||
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
|
||||
|
||||
@REM Execute a user defined script before this one
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
|
||||
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
|
||||
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
|
||||
:skipRcPre
|
||||
|
||||
@setlocal
|
||||
|
||||
set ERROR_CODE=0
|
||||
|
||||
@REM To isolate internal variables from possible post scripts, we use another setlocal
|
||||
@setlocal
|
||||
|
||||
@REM ==== START VALIDATION ====
|
||||
if not "%JAVA_HOME%" == "" goto OkJHome
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME not found in your environment. >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
:OkJHome
|
||||
if exist "%JAVA_HOME%\bin\java.exe" goto init
|
||||
|
||||
echo.
|
||||
echo Error: JAVA_HOME is set to an invalid directory. >&2
|
||||
echo JAVA_HOME = "%JAVA_HOME%" >&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the >&2
|
||||
echo location of your Java installation. >&2
|
||||
echo.
|
||||
goto error
|
||||
|
||||
@REM ==== END VALIDATION ====
|
||||
|
||||
:init
|
||||
|
||||
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
|
||||
@REM Fallback to current working directory if not found.
|
||||
|
||||
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
|
||||
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
|
||||
|
||||
set EXEC_DIR=%CD%
|
||||
set WDIR=%EXEC_DIR%
|
||||
:findBaseDir
|
||||
IF EXIST "%WDIR%"\.mvn goto baseDirFound
|
||||
cd ..
|
||||
IF "%WDIR%"=="%CD%" goto baseDirNotFound
|
||||
set WDIR=%CD%
|
||||
goto findBaseDir
|
||||
|
||||
:baseDirFound
|
||||
set MAVEN_PROJECTBASEDIR=%WDIR%
|
||||
cd "%EXEC_DIR%"
|
||||
goto endDetectBaseDir
|
||||
|
||||
:baseDirNotFound
|
||||
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
|
||||
cd "%EXEC_DIR%"
|
||||
|
||||
:endDetectBaseDir
|
||||
|
||||
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
|
||||
|
||||
@setlocal EnableExtensions EnableDelayedExpansion
|
||||
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
|
||||
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
|
||||
|
||||
:endReadAdditionalConfig
|
||||
|
||||
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
|
||||
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
|
||||
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
|
||||
|
||||
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
|
||||
FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
|
||||
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
|
||||
)
|
||||
|
||||
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
|
||||
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
|
||||
if exist %WRAPPER_JAR% (
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Found %WRAPPER_JAR%
|
||||
)
|
||||
) else (
|
||||
if not "%MVNW_REPOURL%" == "" (
|
||||
SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar"
|
||||
)
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Couldn't find %WRAPPER_JAR%, downloading it ...
|
||||
echo Downloading from: %DOWNLOAD_URL%
|
||||
)
|
||||
|
||||
powershell -Command "&{"^
|
||||
"$webclient = new-object System.Net.WebClient;"^
|
||||
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
|
||||
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
|
||||
"}"^
|
||||
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
|
||||
"}"
|
||||
if "%MVNW_VERBOSE%" == "true" (
|
||||
echo Finished downloading %WRAPPER_JAR%
|
||||
)
|
||||
)
|
||||
@REM End of extension
|
||||
|
||||
@REM Provide a "standardized" way to retrieve the CLI args that will
|
||||
@REM work with both Windows and non-Windows executions.
|
||||
set MAVEN_CMD_LINE_ARGS=%*
|
||||
|
||||
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
:error
|
||||
set ERROR_CODE=1
|
||||
|
||||
:end
|
||||
@endlocal & set ERROR_CODE=%ERROR_CODE%
|
||||
|
||||
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
|
||||
@REM check for post script, once with legacy .bat ending and once with .cmd ending
|
||||
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
|
||||
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
|
||||
:skipRcPost
|
||||
|
||||
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
|
||||
if "%MAVEN_BATCH_PAUSE%" == "on" pause
|
||||
|
||||
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
|
||||
|
||||
exit /B %ERROR_CODE%
|
@ -0,0 +1,126 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.3.4.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com</groupId>
|
||||
<artifactId>forum</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>forum</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<!--redis-->
|
||||
<dependencies>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter-data-redis</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!--导入thymeleaf模板-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--数据库-->
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
#集成Mybatis
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.1.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<scope>runtime</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<!-- 分页插件-->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.2.13</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.atlassian.commonmark</groupId>
|
||||
<artifactId>commonmark-ext-heading-anchor</artifactId>
|
||||
<version>0.10.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.atlassian.commonmark</groupId>
|
||||
<artifactId>commonmark-ext-gfm-tables</artifactId>
|
||||
<version>0.10.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.spotify</groupId>
|
||||
<artifactId>docker-maven-plugin</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<dockerHost>http://ip:2375</dockerHost>
|
||||
<imageName>javaboy/${project.artifactId}</imageName>
|
||||
<imageTags>
|
||||
<imageTag>${project.version}</imageTag>
|
||||
</imageTags>
|
||||
<forceTags>true</forceTags>
|
||||
<dockerDirectory>src/main/docker</dockerDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<targetPath>target</targetPath>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,13 @@
|
||||
package com.forum;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ForumApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ForumApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.forum.config;
|
||||
|
||||
import com.forum.interceptor.LoginInterceptor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/3/24 7:59
|
||||
* 配置拦截器
|
||||
*/
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new LoginInterceptor())
|
||||
.addPathPatterns("/admin/**")
|
||||
.excludePathPatterns("/admin")
|
||||
// 排除登录页面的拦截
|
||||
.excludePathPatterns("/admin/login");
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.forum.controller;
|
||||
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
public class AboutController {
|
||||
|
||||
|
||||
@GetMapping("/about")
|
||||
public String aboutMe(){
|
||||
return "about";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
//package com.forum.controller;
|
||||
//
|
||||
//import com.forum.entity.Forum;
|
||||
//import com.forum.service.ForumService;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Controller;
|
||||
//import org.springframework.ui.Model;
|
||||
//import org.springframework.web.bind.annotation.GetMapping;
|
||||
//
|
||||
//import java.util.List;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//@Controller
|
||||
//public class ArchiveShowController {
|
||||
//
|
||||
// @Autowired
|
||||
// private ForumService forumService;
|
||||
//
|
||||
// @GetMapping("/archives")
|
||||
// public String archives(Model model) {
|
||||
// Map<String, List<Forum>> forums = forumService.archiveForum();
|
||||
// model.addAttribute("archiveMap", forums);
|
||||
// model.addAttribute("forumCount", forumService.countForum());
|
||||
//
|
||||
//
|
||||
// return "archives";
|
||||
// }
|
||||
//}
|
@ -0,0 +1,59 @@
|
||||
package com.forum.controller;
|
||||
|
||||
import com.forum.entity.Comment;
|
||||
import com.forum.entity.User;
|
||||
import com.forum.service.ForumService;
|
||||
import com.forum.service.CommentService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
@Controller
|
||||
public class CommentController {
|
||||
|
||||
@Autowired
|
||||
private CommentService commentService;
|
||||
|
||||
@Autowired
|
||||
private ForumService forumService;
|
||||
|
||||
// @Value("${comment.avatar}")
|
||||
private String avatar;
|
||||
|
||||
@GetMapping("/comments/{forumId}") //展示
|
||||
public String getComments(@PathVariable Long forumId, Model model){
|
||||
model.addAttribute("comments", commentService.getCommentByForumId(forumId));
|
||||
model.addAttribute("forum", forumService.getDetailedForum(forumId));
|
||||
return "forum :: commentList";
|
||||
}
|
||||
|
||||
@PostMapping("/comments") //提交
|
||||
public String postComment(Comment comment, HttpSession session){
|
||||
Long forumId = comment.getForum().getId();
|
||||
comment.setForum(forumService.getDetailedForum(forumId)); //绑定评论
|
||||
comment.setForumId(forumId);
|
||||
User user = (User) session.getAttribute("user");
|
||||
if (user != null){ //用户存在
|
||||
comment.setAvatar(user.getAvatar());
|
||||
comment.setUserComment(true);
|
||||
}else {
|
||||
comment.setAvatar(avatar);
|
||||
}
|
||||
System.out.println(comment);
|
||||
String contents = comment.getContent();
|
||||
String arr[]={"垃圾","滚","混蛋","王八蛋","有病","美白","祛痘","祛斑","纯天然","换肤","去除皱纹","防脱发","生发","无毒","安全","瘦脸","助眠",};
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
contents= contents.replaceAll(arr[i],"*");
|
||||
System.out.println(contents);
|
||||
comment.setContent(contents);
|
||||
|
||||
}
|
||||
commentService.saveComment(comment);
|
||||
return "redirect:/comments/" + forumId;
|
||||
}
|
||||
}
|
@ -0,0 +1,133 @@
|
||||
package com.forum.controller;
|
||||
|
||||
import com.forum.entity.*;
|
||||
import com.forum.service.*;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class IndexController {
|
||||
|
||||
@Autowired
|
||||
private ForumService forumService;
|
||||
|
||||
@Autowired
|
||||
private NoticeService noticeService;
|
||||
|
||||
@Autowired
|
||||
private TagService tagService;
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
|
||||
@Autowired
|
||||
private LinkService linkService;
|
||||
|
||||
private HttpSession session;
|
||||
|
||||
|
||||
|
||||
@GetMapping("/")
|
||||
public String toIndex(@RequestParam(required = false,defaultValue = "1",value = "pageNum")int pagenum, Model model){
|
||||
|
||||
PageHelper.startPage(pagenum,5);
|
||||
//
|
||||
List<Forum> allForum = forumService.getIndexForum();
|
||||
//
|
||||
List<Tag> allTag = tagService.getForumTag(); //获取帖子的标签(联表查询)
|
||||
|
||||
//得到分页结果对象
|
||||
PageInfo pageInfo = new PageInfo(allForum);
|
||||
System.out.println(pageInfo);
|
||||
|
||||
List<RankForum> lankForums=forumService.findForumByLank();
|
||||
List<RankForum> newForum = forumService.getNewForum();
|
||||
|
||||
model.addAttribute("lankForums", lankForums);
|
||||
model.addAttribute("newForum",newForum);
|
||||
model.addAttribute("pageInfo", pageInfo);
|
||||
model.addAttribute("tags", allTag);
|
||||
model.addAttribute("notices",noticeService.findAllNotice());
|
||||
model.addAttribute("messages",messageService.getIndexMessage());
|
||||
|
||||
List<Link> allLink =linkService.getAllLink();
|
||||
//得到分页结果对象
|
||||
|
||||
model.addAttribute("f", allLink);
|
||||
|
||||
|
||||
return "index";
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/search")
|
||||
public String toSearch(@RequestParam(required = false,defaultValue = "1",value = "pagenum")int pagenum,
|
||||
@RequestParam String query, Model model){
|
||||
|
||||
PageHelper.startPage(pagenum, 5);
|
||||
List<Forum> searchForum = forumService.getSearchForum(query);
|
||||
PageInfo pageInfo = new PageInfo(searchForum);
|
||||
model.addAttribute("pageInfo", pageInfo);
|
||||
model.addAttribute("query", query);
|
||||
return "search";
|
||||
}
|
||||
|
||||
@GetMapping("/forum/{id}")
|
||||
public String toDetail(@PathVariable Long id, Model model, HttpSession session){
|
||||
Forum forum = forumService.getDetailedForum(id);
|
||||
forumService.updateView(id);
|
||||
|
||||
|
||||
model.addAttribute("forum", forum);
|
||||
return "forum";
|
||||
}
|
||||
@GetMapping("/forum/like/{id}")
|
||||
public String getLike(@PathVariable Long id, Forum forum,HttpSession session){
|
||||
forumService.addLike(id);
|
||||
User user =(User)session.getAttribute("user");
|
||||
session.setAttribute("user",user);
|
||||
return "redirect:/forum/"+id;
|
||||
}
|
||||
|
||||
public void findAllTag(Model model) {
|
||||
|
||||
model.addAttribute("tags", tagService.getAllTag());
|
||||
}
|
||||
@GetMapping("/publish")
|
||||
public String toPublic(Model model,HttpSession session,RedirectAttributes attributes){
|
||||
model.addAttribute("forum", new Forum()); //返回一个forum对象给前端th:object
|
||||
findAllTag(model);
|
||||
attributes.addFlashAttribute("msg1", "请先登录在发布哦");
|
||||
User user = (User)session.getAttribute("user");
|
||||
if (user==null){
|
||||
return "redirect:/user";
|
||||
}else {
|
||||
return "publish";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/add") //新增
|
||||
public String addForum(@RequestParam(required = false,defaultValue = "1",value = "pageNum")int pagenum,Model model,Forum forum, HttpSession session, RedirectAttributes attributes){
|
||||
//设置user属性
|
||||
forum.setUser((User) session.getAttribute("user"));
|
||||
//设置用户id
|
||||
forum.setUserId(forum.getUser().getId());
|
||||
// //设置forum的type
|
||||
//给forum中的List<Tag>赋值
|
||||
forum.setTags(tagService.getTagByString(forum.getTagIds()));
|
||||
forumService.saveForum(forum);
|
||||
attributes.addFlashAttribute("msg", "发布成功");
|
||||
return "redirect:/";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
package com.forum.controller;
|
||||
|
||||
import com.forum.entity.User;
|
||||
import com.forum.service.UserService;
|
||||
import com.forum.utils.MD5;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/user")
|
||||
public class LoginController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping()
|
||||
public String loginPage(){
|
||||
return "login";
|
||||
}
|
||||
|
||||
@PostMapping("/toLogin")
|
||||
public String frontLogin(@RequestParam String getUserName,
|
||||
@RequestParam String getPassWord,
|
||||
HttpSession session,
|
||||
RedirectAttributes attributes){
|
||||
User user = userService.checkUser(getUserName, getPassWord);
|
||||
if(user != null && user.getType().equals(0)){
|
||||
user.setPassword(null);
|
||||
session.setAttribute("user", user);
|
||||
|
||||
return "redirect:/";
|
||||
}else {
|
||||
attributes.addFlashAttribute("msg", "用户名或密码错误");
|
||||
return "redirect:/user";
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/logout")
|
||||
public String logout(HttpSession session){
|
||||
session.removeAttribute("user");
|
||||
return "redirect:/";
|
||||
}
|
||||
|
||||
//注册
|
||||
@GetMapping("/register")
|
||||
public String frontRegister(Model model){
|
||||
|
||||
return "register";
|
||||
}
|
||||
@PostMapping("/toRegister")
|
||||
public String register(User user, RedirectAttributes attributes){
|
||||
|
||||
System.out.println(user.getUsername());
|
||||
if (user!=null){
|
||||
user.setPassword(MD5.code(user.getPassword()));
|
||||
userService.addUser(user);
|
||||
|
||||
attributes.addFlashAttribute("msg", "恭喜注册成功,快去登录吧!");
|
||||
return "redirect:/user";
|
||||
}else {
|
||||
return "/register";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/toUpdatePage")
|
||||
public String toUpdatePage(){
|
||||
return "update";
|
||||
}
|
||||
@PostMapping ("/toUpdate")
|
||||
public String updatePass(@RequestParam String newPassword,
|
||||
@RequestParam String oldPassword,
|
||||
@RequestParam String username,
|
||||
User user,
|
||||
RedirectAttributes attributes){
|
||||
if (oldPassword!=null&&newPassword!=null){
|
||||
userService.update(MD5.code(newPassword),username);
|
||||
attributes.addFlashAttribute("msg","密码修改成功!");
|
||||
return "redirect:/user";
|
||||
}else {
|
||||
attributes.addFlashAttribute("msg","密码修改失败!");
|
||||
return "update";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.forum.controller;
|
||||
|
||||
import com.forum.entity.Message;
|
||||
import com.forum.entity.Reply;
|
||||
import com.forum.entity.User;
|
||||
import com.forum.service.MessageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/message")
|
||||
public class MessageController {
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
@GetMapping("/allMessage")
|
||||
public String findAllMessage (Model model) {
|
||||
|
||||
List<Message> messages=messageService.findAllMessage();
|
||||
|
||||
model.addAttribute("messages",messages);
|
||||
return "message";
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/save")
|
||||
public String saveMessage(Message message, HttpSession session)
|
||||
{
|
||||
User user= (User) session.getAttribute("user");
|
||||
message.setMsg_avatar(user.getAvatar());
|
||||
message.setName(user.getUsername());
|
||||
messageService.saveMessage(message);
|
||||
return "redirect:/message/allMessage";
|
||||
}
|
||||
|
||||
@PostMapping("/reply/save")
|
||||
public String saveReply(Reply reply, HttpSession session)
|
||||
{
|
||||
User user= (User) session.getAttribute("user");
|
||||
System.out.println(user.getAvatar());
|
||||
reply.setNames(user.getUsername());
|
||||
reply.setAvatar(user.getAvatar());
|
||||
messageService.saveReplyMessage(reply);
|
||||
return "redirect:/message/allMessage";
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
//package com.forum.controller;
|
||||
//
|
||||
//
|
||||
//
|
||||
//import com.forum.service.ForumService;
|
||||
//import com.forum.utils.RedisUtil;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Controller;
|
||||
//import org.springframework.web.bind.annotation.GetMapping;
|
||||
//import org.springframework.web.bind.annotation.ResponseBody;
|
||||
//
|
||||
//
|
||||
//@Controller
|
||||
//public class RedisController {
|
||||
// @Autowired
|
||||
// private RedisUtil redisUtil;
|
||||
// @Autowired
|
||||
// private ForumService forumService;
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// @GetMapping("/redis")
|
||||
// @ResponseBody
|
||||
// private String connection(){
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//// redisUtil.lSet("blogs",rankBlogs,60*60*24);
|
||||
//// List<Object> list=redisUtil.lGetRankBlog("blogs",0,-1);
|
||||
//// List<RankBlog> blogList= (List<RankBlog>) list.get(0);
|
||||
//
|
||||
//
|
||||
// // System.out.println( ":"+redisUtil.getExpire("rank"));
|
||||
// return "success";
|
||||
// }
|
||||
//}
|
@ -0,0 +1,77 @@
|
||||
package com.forum.controller.admin;
|
||||
|
||||
|
||||
import com.forum.entity.User;
|
||||
import com.forum.service.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admin")
|
||||
public class AdminLoginController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private ForumService forumService;
|
||||
@Autowired
|
||||
private TagService tagService;
|
||||
@Autowired
|
||||
private NoticeService noticeService;
|
||||
|
||||
@Autowired
|
||||
private LinkService linkService;
|
||||
|
||||
@GetMapping()
|
||||
public String loginPage() {
|
||||
return "admin/admin-login";
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public String login(@RequestParam String username,
|
||||
@RequestParam String password,
|
||||
HttpSession session,
|
||||
RedirectAttributes attributes, Model model) {
|
||||
User admin = userService.checkUser(username, password);
|
||||
|
||||
if (admin != null && admin.getType() == 1) {
|
||||
session.setAttribute("admin", admin);
|
||||
return "admin/admin-index";
|
||||
} else {
|
||||
attributes.addFlashAttribute("msgs", "用户名或密码错误");
|
||||
return "redirect:/admin";
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/welcome")
|
||||
public String welcome(Model model) {
|
||||
int count = userService.count();
|
||||
int a = forumService.countForum();
|
||||
int b = forumService.countView();
|
||||
int c = tagService.countTag();
|
||||
int d = noticeService.countNotice();
|
||||
int e = linkService.countLink();
|
||||
|
||||
model.addAttribute("userCount", count);
|
||||
model.addAttribute("forumCount", a);
|
||||
model.addAttribute("forumView", b);
|
||||
model.addAttribute("tagCount", c);
|
||||
model.addAttribute("noticeCount", d);
|
||||
model.addAttribute("linkCount", e);
|
||||
return "admin/welcome";
|
||||
}
|
||||
|
||||
@GetMapping("/logout")
|
||||
public String logout(HttpSession session) {
|
||||
session.removeAttribute("admin");
|
||||
return "redirect:/admin";
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.forum.controller.admin;
|
||||
|
||||
import com.forum.entity.Comment;
|
||||
import com.forum.service.CommentService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/4/1 23:39
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin")
|
||||
public class CommentsController {
|
||||
@Autowired
|
||||
CommentService commentService;
|
||||
@GetMapping("/comment")
|
||||
public String findAll(@RequestParam(required = false,defaultValue = "1",value = "pagenum")int pagenum, Model model){
|
||||
List<Comment> allComment = commentService.getAllComment();
|
||||
PageHelper.startPage(pagenum,5);
|
||||
PageInfo<Comment> commentPageInfo = new PageInfo<>(allComment);
|
||||
model.addAttribute("pageInfo",commentPageInfo);
|
||||
model.addAttribute("page",pagenum);
|
||||
return "admin/comment";
|
||||
|
||||
}
|
||||
@GetMapping("/comment/{id}/delete")
|
||||
public String del(@PathVariable Integer id){
|
||||
commentService.delById(id);
|
||||
return "redirect:/admin/comment";
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package com.forum.controller.admin;
|
||||
|
||||
|
||||
import com.forum.entity.Forum;
|
||||
import com.forum.entity.User;
|
||||
import com.forum.service.ForumService;
|
||||
import com.forum.service.TagService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admin")
|
||||
public class ForumController {
|
||||
|
||||
@Autowired
|
||||
private ForumService forumService;
|
||||
|
||||
@Autowired
|
||||
private TagService tagService;
|
||||
|
||||
public void setTypeAndTag(Model model) {
|
||||
|
||||
model.addAttribute("tags", tagService.getAllTag());
|
||||
}
|
||||
|
||||
@GetMapping("/forums") //后台显示帖子列表
|
||||
public String forums(@RequestParam(required = false,defaultValue = "1",value = "pagenum")int pagenum, Model model){
|
||||
PageHelper.startPage(pagenum, 5);
|
||||
List<Forum> allForum = forumService.getAllForum();
|
||||
//得到分页结果对象
|
||||
PageInfo pageInfo = new PageInfo(allForum);
|
||||
model.addAttribute("pageInfo", pageInfo);
|
||||
model.addAttribute("page",pagenum);
|
||||
setTypeAndTag(model); //查询类型和标签
|
||||
return "admin/forums";
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/forums/input") //去新增帖子页面
|
||||
public String toAddForum(Model model){
|
||||
model.addAttribute("forum", new Forum()); //返回一个forum对象给前端th:object
|
||||
setTypeAndTag(model);
|
||||
return "admin/forums-input";
|
||||
}
|
||||
@PostMapping("/forums") //新增
|
||||
public String addForum(Forum forum, HttpSession session, RedirectAttributes attributes){
|
||||
//设置user属性
|
||||
forum.setUser((User) session.getAttribute("admin"));
|
||||
//设置用户id
|
||||
forum.setUserId(forum.getUser().getId());
|
||||
// //设置forum的type
|
||||
//给forum中的List<Tag>赋值
|
||||
forum.setTags(tagService.getTagByString(forum.getTagIds()));
|
||||
forumService.saveForum(forum);
|
||||
attributes.addFlashAttribute("msg", "新增成功");
|
||||
return "redirect:/admin/forums";
|
||||
}
|
||||
|
||||
@GetMapping("/forums/{id}/edit") //去编辑帖子页面
|
||||
public String toEditForum(@PathVariable Long id, Model model){
|
||||
Forum forum = forumService.getForum(id);
|
||||
forum.init(); //将tags集合转换为tagIds字符串
|
||||
model.addAttribute("forum", forum); //返回一个forum对象给前端th:object
|
||||
setTypeAndTag(model);
|
||||
return "admin/forums-edit";
|
||||
}
|
||||
@PostMapping("/forums/edit") //编辑
|
||||
public String editForum(Forum forum, HttpSession session, RedirectAttributes attributes){
|
||||
//设置user属性
|
||||
forum.setUser((User) session.getAttribute("admin"));
|
||||
//设置用户id
|
||||
forum.setUserId(forum.getUser().getId());
|
||||
// //设置forum的type
|
||||
//给forum中的List<Tag>赋值
|
||||
forum.setTags(tagService.getTagByString(forum.getTagIds()));
|
||||
System.out.println(forum);
|
||||
forumService.updateForum(forum);
|
||||
attributes.addFlashAttribute("msg", "编辑成功");
|
||||
return "redirect:/admin/forums";
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/forums/{id}/delete")
|
||||
public String deleteForums(@PathVariable Long id, RedirectAttributes attributes){
|
||||
forumService.deleteForum(id);
|
||||
attributes.addFlashAttribute("msg", "删除成功");
|
||||
return "redirect:/admin/forums";
|
||||
}
|
||||
|
||||
@PostMapping("/forums/search") //按条件查询帖子
|
||||
public String searchForums(Forum forum, @RequestParam(required = false,defaultValue = "1",value = "pagenum")int pagenum, Model model){
|
||||
PageHelper.startPage(pagenum, 5);
|
||||
List<Forum> allForum = forumService.searchAllForum(forum);
|
||||
//得到分页结果对象
|
||||
PageInfo pageInfo = new PageInfo(allForum);
|
||||
model.addAttribute("pageInfo", pageInfo);
|
||||
model.addAttribute("message", "查询成功");
|
||||
setTypeAndTag(model);
|
||||
return "forums";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.forum.controller.admin;
|
||||
|
||||
import com.forum.entity.Link;
|
||||
import com.forum.entity.Message;
|
||||
import com.forum.entity.Notice;
|
||||
import com.forum.entity.Reply;
|
||||
import com.forum.service.MessageService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/4/1 15:25
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin")
|
||||
public class MessagesController {
|
||||
|
||||
@Autowired
|
||||
private MessageService messageService;
|
||||
@GetMapping("/message")
|
||||
public String find (@RequestParam(required = false,defaultValue = "1",value = "pagenum")int pagenum,Model model) {
|
||||
PageHelper.startPage(pagenum, 5);
|
||||
List<Message> messages=messageService.findAll();
|
||||
|
||||
PageInfo<Message> pageInfo = new PageInfo<>(messages);
|
||||
model.addAttribute("pageInfo",pageInfo);
|
||||
model.addAttribute("page",pagenum);
|
||||
|
||||
return "admin/message";
|
||||
}
|
||||
/**
|
||||
* 执行删除
|
||||
* @returnid
|
||||
*/
|
||||
@GetMapping("/message/{id}/delete")
|
||||
public String delete(@PathVariable int id){
|
||||
messageService.deleteById(id);
|
||||
return "redirect:/admin/message";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.forum.controller.admin;
|
||||
|
||||
import com.forum.entity.Message;
|
||||
import com.forum.entity.Reply;
|
||||
import com.forum.service.ReplyService;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/4/1 21:57
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin")
|
||||
public class ReplyController {
|
||||
@Autowired
|
||||
ReplyService replyService;
|
||||
|
||||
@GetMapping("/reply")
|
||||
public String all(@RequestParam(required = false,defaultValue = "1",value = "pagenum")int pagenum, Model model){
|
||||
PageHelper.startPage(pagenum, 5);
|
||||
List<Reply> messages=replyService.findAll();
|
||||
|
||||
PageInfo<Reply> pageInfo = new PageInfo<>(messages);
|
||||
model.addAttribute("pageInfo",pageInfo);
|
||||
model.addAttribute("page",pagenum);
|
||||
return "admin/reply";
|
||||
}
|
||||
@GetMapping("/replyAll/{id}/delete")
|
||||
public String del(@PathVariable Integer id , RedirectAttributes attributes){
|
||||
replyService.del(id);
|
||||
attributes.addFlashAttribute("msg", "删除成功");
|
||||
return "redirect:/admin/reply";
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.forum.controller.admin;
|
||||
|
||||
import com.forum.entity.Tag;
|
||||
import com.forum.entity.User;
|
||||
import com.forum.service.UserService;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/3/30 14:31
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("/admin")
|
||||
public class UserController {
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@GetMapping("/userAll")
|
||||
public String listUser(@RequestParam(required = false,defaultValue = "1",value = "pagenum")int pagenum, Model model){
|
||||
PageHelper.startPage(pagenum, 5);
|
||||
List<User> allUser = userService.getAllUser();
|
||||
//得到分页结果对象
|
||||
PageInfo<User> pageInfo = new PageInfo<>(allUser);
|
||||
model.addAttribute("pageInfo", pageInfo);
|
||||
model.addAttribute("page",pagenum);
|
||||
return "admin/user";
|
||||
}
|
||||
/**
|
||||
* 执行删除
|
||||
* @param id
|
||||
* @param attributes
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/userAll/{id}/delete")
|
||||
public String delete(@PathVariable Integer id, RedirectAttributes attributes){
|
||||
userService.deleteUser(id);
|
||||
attributes.addFlashAttribute("msg", "删除成功");
|
||||
return "redirect:/admin/userAll";
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.forum.dao;
|
||||
|
||||
public interface AboutDao {
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.forum.dao;
|
||||
|
||||
import com.forum.entity.Comment;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface CommentDao {
|
||||
|
||||
//根据创建时间倒序来排
|
||||
List<Comment> findByForumIdAndParentCommentNull(@Param("forumId") Long forumId, @Param("forumParentId") Long forumParentId);
|
||||
|
||||
//查询父级对象
|
||||
Comment findByParentCommentId(@Param("parentCommentId")Long parentcommentid);
|
||||
|
||||
//添加一个评论
|
||||
int saveComment(Comment comment);
|
||||
|
||||
List<Comment> getAllComment();
|
||||
|
||||
void delById(Integer id);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.forum.dao;
|
||||
|
||||
import com.forum.entity.Forum;
|
||||
import com.forum.entity.ForumAndTag;
|
||||
import com.forum.entity.RankForum;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface ForumDao {
|
||||
|
||||
Forum getForum(Long id); //后台展示帖子
|
||||
void updateView(Long id);
|
||||
Forum getDetailedForum(@Param("id") Long id); //帖子详情
|
||||
|
||||
//获取所有帖子
|
||||
List<Forum> getAllForum();
|
||||
|
||||
List<Forum> getByTypeId(Long typeId); //根据类型id获取帖子
|
||||
|
||||
List<Forum> getByTagId(Long tagId); //根据标签id获取帖子
|
||||
|
||||
List<Forum> getIndexForum(); //主页帖子展示
|
||||
|
||||
List<Forum> getAllRecommendForum(); //推荐帖子展示
|
||||
|
||||
List<Forum> getSearchForum(String query); //全局搜索帖子
|
||||
|
||||
List<Forum> searchAllForum(Forum forum); //后台根据标题、分类、推荐搜索帖子
|
||||
|
||||
List<String> findGroupYear(); //查询所有年份,返回一个集合
|
||||
|
||||
List<Forum> getForumTadIds();
|
||||
List<Forum> findForumAndTagsByYear(@Param("year") String year);
|
||||
int saveForum(Forum forum);
|
||||
|
||||
int saveForumAndTag(ForumAndTag forumAndTag);
|
||||
|
||||
int updateForum(Forum forum);
|
||||
|
||||
int deleteForum(Long id);
|
||||
List<RankForum> findForumByRank();
|
||||
List<RankForum> getNewForum();
|
||||
// 点赞相关
|
||||
Long getLike(Long id);
|
||||
// void addLike(Long forumId);
|
||||
// int getLikeByUser(Long userId,Long forumId);
|
||||
// void addForum_Like(Long forumId,Long userId);
|
||||
// void removeForum_Like(Long forumId,Long userId);
|
||||
// void cancelLike(Long forumId);
|
||||
|
||||
|
||||
int countView();
|
||||
|
||||
|
||||
void addLike(Long id);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.forum.dao;
|
||||
|
||||
import com.forum.entity.Link;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/3/30 15:51
|
||||
*/
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface LinkDao {
|
||||
public int deleteLink(Integer id);
|
||||
|
||||
int saveLink(Link link);
|
||||
|
||||
List<Link> getAllLink();
|
||||
|
||||
int countLink();
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.forum.dao;
|
||||
|
||||
|
||||
import com.forum.entity.Message;
|
||||
import com.forum.entity.Reply;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface MessageDao {
|
||||
List<Message> findAllMessage();
|
||||
List<Message> getIndexMessage();
|
||||
void saveMessage(Message message);
|
||||
|
||||
void saveReplyMessage(Reply reply);
|
||||
|
||||
List<Message> findAll();
|
||||
|
||||
void deleteById(int id);
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.forum.dao;
|
||||
|
||||
import com.forum.entity.Notice;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface NoticeDao {
|
||||
public List<Notice> findAllNotice();
|
||||
public void addNotices(Notice notice);
|
||||
public void deleteNotice(int id);
|
||||
|
||||
int countNotice();
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.forum.dao;
|
||||
|
||||
import com.forum.entity.Reply;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/4/1 22:08
|
||||
*/
|
||||
@Repository
|
||||
@Mapper
|
||||
public interface ReplyDao {
|
||||
List<Reply> findAll();
|
||||
|
||||
void del(int id);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.forum.dao;
|
||||
|
||||
import com.forum.entity.Tag;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface TagDao {
|
||||
/**
|
||||
* 执行新增模块
|
||||
* @param tag
|
||||
* @return
|
||||
*/
|
||||
int saveTag(Tag tag);
|
||||
|
||||
Tag getTag(Long id);
|
||||
|
||||
Tag getTagByName(String name);
|
||||
Tag getTagById(int id);
|
||||
|
||||
List<Tag> getAllTag();
|
||||
/**
|
||||
* 查询帖子所有分类
|
||||
* @return
|
||||
*/
|
||||
List<Tag> getForumTag();
|
||||
|
||||
int updateTag(Tag tag);
|
||||
|
||||
int deleteTag(Long id);
|
||||
|
||||
int countTag();
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.forum.dao;
|
||||
|
||||
|
||||
import com.forum.entity.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface UserDao {
|
||||
// @Select("select * from t_user where username=#{username} and password=#{password}")
|
||||
User queryByUsernameAndPassword(@Param("username") String username, @Param("password") String password);
|
||||
|
||||
void addUser(User user);
|
||||
List<User> getAllUser();
|
||||
|
||||
int deleteUser(int id);
|
||||
|
||||
int count();
|
||||
|
||||
void update(String password, String username);
|
||||
|
||||
// User queryByUsernameAndPassword2(@Param("username") String username, @Param("password") String password);
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.forum.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 把博客和标签关系存到数据库中使用的类
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ForumAndTag {
|
||||
|
||||
private Long tagId;
|
||||
private Long forumId;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.forum.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/3/30 15:29
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Link {
|
||||
private Integer id;
|
||||
private String name;
|
||||
private String address;
|
||||
private Date createTime;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.forum.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Message {
|
||||
private int id;
|
||||
private String content;
|
||||
private String name;
|
||||
private String msg_avatar;
|
||||
private Date createTime;
|
||||
List<Reply> replies;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.forum.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Notice {
|
||||
private int id;
|
||||
private String content;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.forum.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
//帖子排行封装
|
||||
public class RankForum {
|
||||
long id;
|
||||
String title;
|
||||
// int lank;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.forum.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Reply {
|
||||
private int id;
|
||||
private String names;
|
||||
private int mes_id;
|
||||
private String avatar;
|
||||
private String content;
|
||||
private Date createTime;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.forum.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Tag {
|
||||
private Long id;
|
||||
private String name;
|
||||
// 标签页的时候可以查找该标签下所有blog
|
||||
private List<Forum> forums = new ArrayList<>();
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.forum.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class User {
|
||||
private Long id;
|
||||
private String username;
|
||||
private String password;
|
||||
private String email;
|
||||
private String avatar;
|
||||
private Integer type;
|
||||
private Date createTime;
|
||||
private Date updateTime;
|
||||
private String school;
|
||||
|
||||
private List<Forum> forums = new ArrayList<>();
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.forum.exception;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/3/24 7:59
|
||||
*拦截所有controller的异常
|
||||
|
||||
*/
|
||||
|
||||
@ControllerAdvice
|
||||
public class ControllerExceptionHandler {
|
||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@ExceptionHandler(Exception.class) //表示该方法可以处理所有类型异常
|
||||
public ModelAndView exceptionHandler(HttpServletRequest request, Exception e) throws Exception {
|
||||
|
||||
//日志打印异常信息,{}占位符
|
||||
logger.error("Request url: {}, Exception: {}", request.getRequestURI(), e);
|
||||
|
||||
//不处理带有ResponseStatus注解的异常
|
||||
if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
//返回异常信息到自定义error页面
|
||||
ModelAndView mv = new ModelAndView();
|
||||
mv.addObject("url", request.getRequestURI());
|
||||
mv.addObject("Exception", e);
|
||||
mv.setViewName("error/error");
|
||||
return mv;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.forum.exception;
|
||||
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/3/24 7:59
|
||||
*配置状态码
|
||||
|
||||
*/
|
||||
@ResponseStatus(HttpStatus.NOT_FOUND) //自定义NotFoundException异常,会跳转到404页面
|
||||
public class NotFoundException extends RuntimeException {
|
||||
public NotFoundException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public NotFoundException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public NotFoundException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.forum.interceptor;
|
||||
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/3/24 7:59
|
||||
* 登录拦截器
|
||||
*/
|
||||
|
||||
public class LoginInterceptor implements HandlerInterceptor {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
if (request.getSession().getAttribute("admin") == null){
|
||||
// 未登录,重定向到登录页面
|
||||
response.sendRedirect("/admin");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.forum.service;
|
||||
|
||||
import com.forum.entity.Comment;
|
||||
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CommentService {
|
||||
|
||||
List<Comment> getCommentByForumId(Long forumId);
|
||||
|
||||
int saveComment(Comment comment);
|
||||
|
||||
List<Comment> getAllComment();
|
||||
|
||||
void delById(Integer id);
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.forum.service;
|
||||
|
||||
import com.forum.entity.Forum;
|
||||
import com.forum.entity.RankForum;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ForumService {
|
||||
void updateView(Long id);
|
||||
|
||||
Forum getForum(Long id); //后台展示论坛
|
||||
|
||||
Forum getDetailedForum(Long id); //前端展示论坛
|
||||
|
||||
List<Forum> getAllForum();
|
||||
|
||||
List<Forum> getByTypeId(Long typeId); //根据类型id获取论坛
|
||||
|
||||
List<Forum> getByTagId(Long tagId); //根据分类id获取论坛
|
||||
|
||||
List<Forum> getIndexForum(); //主页论坛展示
|
||||
|
||||
List<Forum> getAllRecommendForum(); //推荐论坛展示
|
||||
|
||||
List<Forum> getSearchForum(String query); //全局搜索论坛
|
||||
|
||||
Map<String,List<Forum>> archiveForum(); //归档论坛
|
||||
|
||||
int countForum(); //查询论坛条数
|
||||
//新增论坛
|
||||
int saveForum(Forum forum);
|
||||
|
||||
int updateForum(Forum forum);
|
||||
|
||||
int deleteForum(Long id);
|
||||
|
||||
List<Forum> searchAllForum(Forum forum); //后台根据标题、分类、推荐搜索论坛
|
||||
//
|
||||
List<RankForum> findForumByLank();
|
||||
List<RankForum> getNewForum();
|
||||
// Long getLike(Long id);
|
||||
// void addLike(Long forumId,Long userId);
|
||||
// int getLikeByUser(Long userId,Long forumId);
|
||||
//
|
||||
//// void removeForum_Like(Long forumId,Long userId);
|
||||
// void cancelLike(Long forumId,Long userId);
|
||||
|
||||
|
||||
int countView();
|
||||
|
||||
|
||||
void addLike(Long id);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.forum.service;
|
||||
|
||||
import com.forum.entity.Link;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LinkService {
|
||||
int saveLink(Link link);
|
||||
|
||||
List<Link> getAllLink();
|
||||
|
||||
|
||||
int deleteLink(Integer id);
|
||||
|
||||
int countLink();
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.forum.service;
|
||||
|
||||
import com.forum.entity.Message;
|
||||
import com.forum.entity.Reply;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MessageService {
|
||||
List<Message> findAllMessage();
|
||||
List<Message> getIndexMessage();
|
||||
void saveMessage(Message message);
|
||||
void saveReplyMessage(Reply reply);
|
||||
|
||||
List<Message> findAll();
|
||||
|
||||
void deleteById(int id);
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.forum.service;
|
||||
|
||||
import com.forum.entity.Notice;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public interface NoticeService {
|
||||
public List<Notice> findAllNotice();
|
||||
public void addNotices(Notice notice);
|
||||
public void deleteNotice(int id);
|
||||
|
||||
int countNotice();
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.forum.service;
|
||||
|
||||
import com.forum.entity.Reply;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ReplyService {
|
||||
public List<Reply> findAll();
|
||||
|
||||
void del(int id);
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.forum.service;
|
||||
|
||||
import com.forum.entity.Tag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TagService {
|
||||
|
||||
int saveTag(Tag tag);//执行新增模块
|
||||
|
||||
Tag getTag(Long id);
|
||||
|
||||
Tag getTagByName(String name);
|
||||
Tag getTagById(int id);
|
||||
|
||||
List<Tag> getAllTag();
|
||||
|
||||
List<Tag> getForumTag(); //首页展示帖子类型
|
||||
|
||||
List<Tag> getTagByString(String text); //从字符串中获取tag集合
|
||||
|
||||
int updateTag(Tag tag);
|
||||
|
||||
int deleteTag(Long id);
|
||||
|
||||
int countTag();
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.forum.service;
|
||||
|
||||
|
||||
import com.forum.entity.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UserService {
|
||||
|
||||
public User checkUser(String username, String password);
|
||||
void addUser(User user);
|
||||
List<User> getAllUser();
|
||||
int deleteUser(int id);
|
||||
|
||||
int count();
|
||||
|
||||
|
||||
void update(String password, String username);
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
package com.forum.service.impl;
|
||||
|
||||
import com.forum.dao.ForumDao;
|
||||
import com.forum.dao.CommentDao;
|
||||
import com.forum.entity.Comment;
|
||||
import com.forum.service.CommentService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CommentServiceImpl implements CommentService {
|
||||
|
||||
@Autowired
|
||||
private CommentDao commentDao;
|
||||
|
||||
@Autowired
|
||||
private ForumDao forumDao;
|
||||
|
||||
@Override
|
||||
public List<Comment> getCommentByForumId(Long forumId) { //查询父评论
|
||||
//没有父节点的默认为-1
|
||||
List<Comment> comments = commentDao.findByForumIdAndParentCommentNull(forumId, Long.parseLong("-1"));
|
||||
|
||||
return comments;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
//接收回复的表单
|
||||
public int saveComment(Comment comment) {
|
||||
//获得父id
|
||||
Long parentCommentId = comment.getParentComment().getId();
|
||||
System.out.println("是否是父评论"+parentCommentId);
|
||||
comment.setAvatar("https://wallpaperm.cmcm.com/aab1692cf70ed27d9ebcf0ca3e88d61d.jpg");
|
||||
|
||||
//没有父级评论默认是-1
|
||||
if (parentCommentId != -1) {
|
||||
//有父级评论
|
||||
// comment.setParentComment(commentDao.findByParentCommentId(comment.getParentCommentId()));
|
||||
|
||||
comment.setParentCommentId(parentCommentId);
|
||||
} else {
|
||||
//没有父级评论
|
||||
comment.setParentCommentId((long) 0);
|
||||
// comment.setParentComment(null);
|
||||
}
|
||||
comment.setCreateTime(new Date());
|
||||
return commentDao.saveComment(comment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Comment> getAllComment() {
|
||||
return commentDao.getAllComment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delById(Integer id) {
|
||||
commentDao.delById(id);
|
||||
}
|
||||
/**
|
||||
* 循环每个父评论“1”
|
||||
*/
|
||||
// private List<Comment> oneComment(List<Comment> comments){
|
||||
// List<Comment> commentsView = new ArrayList<>();
|
||||
// for (Comment comment : comments) {
|
||||
// Comment comment1 = new Comment();
|
||||
// BeanUtils.copyProperties(comment,comment1);
|
||||
// commentsView.add(comment1);
|
||||
//
|
||||
// }
|
||||
// combineChildren(commentsView);
|
||||
// return commentsView;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 存储帖子为1的对象集合
|
||||
// * @param comments
|
||||
// */
|
||||
// private void combineChildren(List<Comment> comments) {
|
||||
// for (Comment comment : comments) {
|
||||
// List<Comment> replys1 = comment.getReplyComments();
|
||||
// for (Comment reply1 : replys1) {
|
||||
// recursively(reply1);
|
||||
// }
|
||||
// comment.setReplyComments(tempReplys);
|
||||
// tempReplys = new ArrayList<>();
|
||||
// }
|
||||
// }
|
||||
//private List<Comment> tempReplys =new ArrayList<>();
|
||||
//
|
||||
// /**
|
||||
// * 迭代的对象
|
||||
// * @param
|
||||
// */
|
||||
// private void recursively(Comment comment) {
|
||||
// tempReplys.add(comment);
|
||||
// if (comment.getReplyComments().size()>0){
|
||||
// List<Comment> replys = comment.getReplyComments();
|
||||
// for (Comment reply : replys) {
|
||||
// tempReplys.add(reply);
|
||||
// if (reply.getReplyComments().size()>0){
|
||||
// recursively(reply);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
@ -0,0 +1,244 @@
|
||||
package com.forum.service.impl;
|
||||
|
||||
import com.forum.dao.ForumDao;
|
||||
import com.forum.entity.*;
|
||||
import com.forum.exception.NotFoundException;
|
||||
import com.forum.service.ForumService;
|
||||
import com.forum.service.TagService;
|
||||
import com.forum.utils.MarkdownUtils;
|
||||
//import com.forum.utils.RedisUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class ForumServiceImpl implements ForumService {
|
||||
|
||||
@Autowired
|
||||
ForumDao forumDao;
|
||||
@Autowired
|
||||
TagService tagService;
|
||||
// @Autowired
|
||||
// RedisUtil redisUtil;
|
||||
|
||||
private Boolean hasKey = false;
|
||||
|
||||
@Override
|
||||
public void updateView(Long id) {
|
||||
forumDao.updateView(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Forum getForum(Long id) {
|
||||
|
||||
return forumDao.getForum(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Forum getDetailedForum(Long id) {
|
||||
Forum forum = forumDao.getDetailedForum(id);
|
||||
if (forum == null) {
|
||||
throw new NotFoundException("该帖子不存在");
|
||||
}
|
||||
String content = forum.getContent();
|
||||
forum.setContent(MarkdownUtils.markdownToHtmlExtensions(content)); //将Markdown格式转换成html
|
||||
return forum;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Forum> getAllForum() {
|
||||
return forumDao.getAllForum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Forum> getByTypeId(Long typeId) {
|
||||
return forumDao.getByTypeId(typeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Forum> getByTagId(Long tagId) {
|
||||
return forumDao.getByTagId(tagId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Forum> getIndexForum() {
|
||||
List<Forum> forums = forumDao.getIndexForum();
|
||||
// int startPage=(pageNum-1)*5;
|
||||
// List<Forum> forums= forumDao.getForumTadIds();
|
||||
// System.out.println(forums.size());
|
||||
// List<Tag> tags;
|
||||
// for (Forum forum : forums) {
|
||||
// tags=new ArrayList<>();
|
||||
// for (TagIds id : forum.getTagsId()) {
|
||||
// tags.add(tagService.getTagById(id.getTag_id()));
|
||||
// }
|
||||
// forum.setTags(tags);
|
||||
//
|
||||
// }
|
||||
|
||||
return forums;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Forum> getAllRecommendForum() {
|
||||
return forumDao.getAllRecommendForum();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Forum> getSearchForum(String query) {
|
||||
return forumDao.getSearchForum(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<Forum>> archiveForum() {
|
||||
List<String> years;
|
||||
Map<String, List<Forum>> map = new LinkedHashMap<>();
|
||||
years = forumDao.findGroupYear();
|
||||
Set<String> set = new HashSet<>(years); //set去掉重复的年份
|
||||
|
||||
// 转回list进行排序
|
||||
years = new ArrayList<>(set);
|
||||
Collections.sort(years);
|
||||
Collections.reverse(years);
|
||||
// 遍历
|
||||
for (String year : years) {
|
||||
System.out.println(year);
|
||||
map.put(year, findForumAndTagsByYear(year));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
/*
|
||||
根据查找文章的所有
|
||||
*/
|
||||
public List<Forum> findForumAndTagsByYear(String year) {
|
||||
List<Forum> forumAndTagIds = forumDao.findForumAndTagsByYear(year);
|
||||
|
||||
// 将标签的id集合遍历查找出标签
|
||||
List<Tag> tags;
|
||||
for (Forum forumAndTagId : forumAndTagIds) {
|
||||
tags = new ArrayList<>();
|
||||
|
||||
// System.out.println(tags.size());
|
||||
forumAndTagId.setTags(tags);
|
||||
}
|
||||
|
||||
return forumAndTagIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countForum() {
|
||||
return forumDao.getAllForum().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Forum> searchAllForum(Forum forum) {
|
||||
return forumDao.searchAllForum(forum);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 排行榜信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<RankForum> findForumByLank() {
|
||||
|
||||
List<RankForum> rankForums = new ArrayList<>();
|
||||
|
||||
rankForums = forumDao.findForumByRank();
|
||||
|
||||
return rankForums;
|
||||
|
||||
//
|
||||
// }else {
|
||||
// System.out.println("走REDIS---");
|
||||
// return (List<RankForum>) redisUtil.get("rank");
|
||||
//
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RankForum> getNewForum() {
|
||||
return forumDao.getNewForum();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Long getLike(Long id) {
|
||||
// return forumDao.getLike(id);
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public void addLike(Long forumId, Long userId) {
|
||||
//// forumDao.addLike(forumId);
|
||||
//// forumDao.addForum_Like(forumId, userId);
|
||||
// System.out.println("执行插入Like_User");
|
||||
//
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public int getLikeByUser(Long userId, Long forumId) {
|
||||
// return forumDao.getLikeByUser(userId, forumId);
|
||||
// }
|
||||
|
||||
|
||||
// @Override
|
||||
// public void cancelLike(Long forumId, Long userId) {
|
||||
// forumDao.cancelLike(forumId);
|
||||
// forumDao.removeForum_Like(forumId, userId);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int countView() {
|
||||
return forumDao.countView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLike(Long id) {
|
||||
forumDao.addLike(id);
|
||||
}
|
||||
|
||||
|
||||
@Override //新增帖子
|
||||
public int saveForum(Forum forum) {
|
||||
forum.setCreateTime(new Date());
|
||||
forum.setViews(0);
|
||||
// forum.setFlag("原创");
|
||||
//保存帖子
|
||||
forumDao.saveForum(forum);
|
||||
//保存帖子后才能获取自增的id
|
||||
Long id = forum.getId();
|
||||
//将标签的数据存到t_forums_tag表中
|
||||
List<Tag> tags = forum.getTags();
|
||||
ForumAndTag forumAndTag = null;
|
||||
for (Tag tag : tags) {
|
||||
//新增时无法获取自增的id,在mybatis里修改
|
||||
forumAndTag = new ForumAndTag(tag.getId(), id);
|
||||
forumDao.saveForumAndTag(forumAndTag);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override //编辑帖子
|
||||
public int updateForum(Forum forum) {
|
||||
forum.setUpdateTime(new Date());
|
||||
//将标签的数据存到t_forums_tag表中
|
||||
List<Tag> tags = forum.getTags();
|
||||
ForumAndTag forumAndTag = null;
|
||||
for (Tag tag : tags) {
|
||||
forumAndTag = new ForumAndTag(tag.getId(), forum.getId());
|
||||
forumDao.saveForumAndTag(forumAndTag);
|
||||
}
|
||||
return forumDao.updateForum(forum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteForum(Long id) {
|
||||
return forumDao.deleteForum(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.forum.service.impl;
|
||||
|
||||
import com.forum.dao.LinkDao;
|
||||
import com.forum.entity.Link;
|
||||
import com.forum.service.LinkService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/3/30 15:32
|
||||
*/
|
||||
@Service
|
||||
public class LinkServiceImpl implements LinkService
|
||||
{
|
||||
@Autowired
|
||||
private LinkDao linkDao;
|
||||
|
||||
@Override
|
||||
public int saveLink(Link link) {
|
||||
link.setCreateTime(new Date());
|
||||
return linkDao.saveLink(link);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Link> getAllLink() {
|
||||
return linkDao.getAllLink();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteLink(Integer id) {
|
||||
return linkDao.deleteLink(id);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countLink() {
|
||||
return linkDao.countLink();
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.forum.service.impl;
|
||||
|
||||
import com.forum.dao.MessageDao;
|
||||
import com.forum.entity.Message;
|
||||
import com.forum.entity.Reply;
|
||||
import com.forum.service.MessageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class MessageServiceImpl implements MessageService {
|
||||
|
||||
@Autowired
|
||||
MessageDao messageDao;
|
||||
@Override
|
||||
public List<Message> findAllMessage() {
|
||||
return messageDao.findAllMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Message> getIndexMessage() {
|
||||
List<Message> messages=messageDao.getIndexMessage();
|
||||
for (Message message : messages) {
|
||||
if (message.getContent().length()>10)
|
||||
message.setContent(message.getContent().substring(0,10)+"..");
|
||||
}
|
||||
return messages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveMessage(Message message) {
|
||||
|
||||
Date date=new Date();
|
||||
message.setCreateTime(date);
|
||||
messageDao.saveMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveReplyMessage(Reply reply) {
|
||||
Date date=new Date();
|
||||
reply.setCreateTime(date);
|
||||
messageDao.saveReplyMessage(reply);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Message> findAll() {
|
||||
return messageDao.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(int id) {
|
||||
messageDao.deleteById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.forum.service.impl;
|
||||
|
||||
import com.forum.dao.NoticeDao;
|
||||
import com.forum.entity.Notice;
|
||||
import com.forum.service.NoticeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class NoticeServiceImpl implements NoticeService {
|
||||
@Autowired
|
||||
private NoticeDao noticeDao;
|
||||
@Override
|
||||
public List<Notice> findAllNotice() {
|
||||
return noticeDao.findAllNotice();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNotices(Notice notice) {
|
||||
noticeDao.addNotices(notice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteNotice(int id) {
|
||||
noticeDao.deleteNotice(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countNotice() {
|
||||
return noticeDao.countNotice();
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.forum.service.impl;
|
||||
|
||||
import com.forum.dao.ReplyDao;
|
||||
import com.forum.entity.Reply;
|
||||
import com.forum.service.ReplyService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ReplyServicImpl implements ReplyService {
|
||||
@Autowired
|
||||
ReplyDao replyDao;
|
||||
@Override
|
||||
public List<Reply> findAll() {
|
||||
return replyDao.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void del(int id) {
|
||||
replyDao.del(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package com.forum.service.impl;
|
||||
|
||||
import com.forum.dao.UserDao;
|
||||
import com.forum.entity.User;
|
||||
import com.forum.entity.User;
|
||||
import com.forum.service.UserService;
|
||||
import com.forum.utils.MD5;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
|
||||
@Autowired
|
||||
private UserDao userDao;
|
||||
|
||||
@Override
|
||||
public User checkUser(String username, String password) {
|
||||
User user = userDao.queryByUsernameAndPassword(username, MD5.code(password));
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addUser(User user) {
|
||||
user.setCreateTime(new Date());
|
||||
user.setUpdateTime(new Date());
|
||||
user.setType(0);
|
||||
user.setAvatar("https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=3892165108,471848507&fm=26&gp=0.jpg");
|
||||
System.out.println(user);
|
||||
userDao.addUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> getAllUser() {
|
||||
return userDao.getAllUser();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteUser(int id) {
|
||||
return userDao.deleteUser(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int count() {
|
||||
return userDao.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(String password, String username) {
|
||||
userDao.update(password,username);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.forum.utils;
|
||||
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/4/16 20:18
|
||||
*/
|
||||
public class FileUtils {
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.forum.utils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* @author 田勇
|
||||
* @date 2021/3/26 23:35
|
||||
*/
|
||||
public class MD5 {
|
||||
/**
|
||||
* MD5加密类
|
||||
* @param str 要加密的字符串
|
||||
* @return 加密后的字符串
|
||||
*/
|
||||
public static String code(String str){
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
md.update(str.getBytes());
|
||||
byte[]byteDigest = md.digest();
|
||||
int i;
|
||||
StringBuffer buf = new StringBuffer("");
|
||||
for (int offset = 0; offset < byteDigest.length; offset++) {
|
||||
i = byteDigest[offset];
|
||||
if (i < 0)
|
||||
i += 256;
|
||||
if (i < 16)
|
||||
buf.append("0");
|
||||
buf.append(Integer.toHexString(i));
|
||||
}
|
||||
//32位加密
|
||||
return buf.toString();
|
||||
// 16位的加密
|
||||
//return buf.toString().substring(8, 24);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(code("123456"));
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
server:
|
||||
port: 9999
|
||||
|
||||
|
||||
#thymeleaf start
|
||||
spring:
|
||||
thymeleaf:
|
||||
prefix: classpath:/templates/
|
||||
mode: LEGACYHTML5
|
||||
encoding: UTF-8
|
||||
content-type: text/html
|
||||
cache: false
|
||||
suffix: .html
|
||||
|
||||
datasource:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost/forum?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: 13Gmy1848.
|
||||
|
||||
#mapper映射文件
|
||||
mybatis:
|
||||
mapper-locations: classpath:/mapper/*.xml #mapper映射文件路径
|
||||
type-aliases-package: com.forum.entity
|
||||
configuration:
|
||||
map-underscore-to-camel-case: true
|
@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.forum.dao.CommentDao">
|
||||
|
||||
|
||||
<resultMap id="comment" type="Comment">
|
||||
<id property="id" column="cid"/>
|
||||
<result property="username" column="username"/>
|
||||
<result property="email" column="email"/>
|
||||
<result property="content" column="content"/>
|
||||
<result property="userComment" column="usercomment"/>
|
||||
<result property="avatar" column="avatar"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="forumId" column="forum_id"/>
|
||||
<association property="forum" javaType="Forum">
|
||||
<id property="id" column="id"/>
|
||||
</association>
|
||||
</resultMap>
|
||||
<delete id="delById">
|
||||
delete from comment where id=#{id}
|
||||
</delete>
|
||||
|
||||
<select id="findByForumIdAndParentCommentNull" resultMap="comment">
|
||||
select c.id cid,c.username,c.email,c.content,c.avatar,
|
||||
c.create_time,c.forum_id,c.parent_comment_id
|
||||
from comment c, forum b
|
||||
where c.forum_id = b.id and c.forum_id = #{forumId}
|
||||
order by c.create_time desc
|
||||
</select>
|
||||
|
||||
|
||||
<insert id="saveComment" parameterType="Comment">
|
||||
insert into comment (username,email,content,avatar,
|
||||
create_time,forum_id,parent_comment_id, usercomment)
|
||||
values (#{username},#{email},#{content},#{avatar},
|
||||
#{createTime},#{forumId},#{parentCommentId}, #{userComment});
|
||||
</insert>
|
||||
|
||||
|
||||
<select id="findByParentCommentId" resultMap="comment">
|
||||
select c.id cid, c.username, c.email, c.content, c.avatar,
|
||||
c.create_time, c.forum_id, c.parent_comment_id
|
||||
from comment c
|
||||
where c.parent_comment_id = #{parentCommentId}
|
||||
</select>
|
||||
|
||||
<select id="getAllComment" resultType="com.forum.entity.Comment">
|
||||
select id,username,email,content,create_time from comment
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.forum.dao.LinkDao">
|
||||
|
||||
|
||||
|
||||
|
||||
<insert id="saveLink" parameterType="Link">
|
||||
insert into link(name ,address,create_time) values (#{name},#{address},#{createTime});
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
<delete id="deleteLink">
|
||||
delete from link where id = #{id}
|
||||
</delete>
|
||||
<select id="getAllLink" resultType="Link">
|
||||
select id,name,address,create_time from link
|
||||
</select>
|
||||
<select id="countLink" resultType="java.lang.Integer">
|
||||
select count(*) from link
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,66 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.forum.dao.MessageDao">
|
||||
|
||||
|
||||
|
||||
<resultMap id="messages" type="message">
|
||||
<id property="id" column="id"/>
|
||||
<result property="content" column="content"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="msg_avatar" column="msg_avatar"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
|
||||
<collection property="replies" ofType="reply">
|
||||
<id property="id" column="rid"/>
|
||||
<result property="content" column="con"/>
|
||||
<!-- <result property="reply_name" column="reply_name"/>-->
|
||||
<result property="names" column="names"/>
|
||||
<result property="createTime" column="ctime"/>
|
||||
<result property="avatar" column="avatar"/>
|
||||
<result property="mes_id" column="mes_id"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
<delete id="deleteById">
|
||||
delete from message where id=#{id}
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="findAllMessage" resultMap="messages">
|
||||
select m.*,
|
||||
r.id rid,
|
||||
r.content con,
|
||||
r.names names,
|
||||
r.create_time ctime,
|
||||
r.avatar,
|
||||
r.mes_id
|
||||
from message m left join reply r on r.mes_id=m.id
|
||||
order by m.create_time desc
|
||||
</select>
|
||||
<select id="getIndexMessage" resultMap="messages">
|
||||
select m.*
|
||||
from message m
|
||||
order by m.create_time desc
|
||||
limit 0,6
|
||||
|
||||
|
||||
|
||||
|
||||
</select>
|
||||
<select id="findAll" resultType="com.forum.entity.Message">
|
||||
select id,content,name, create_time from message
|
||||
</select>
|
||||
|
||||
<insert id="saveMessage" parameterType="message">
|
||||
insert into message (content,name,create_time,msg_avatar)
|
||||
values (#{content},#{name},#{createTime},#{msg_avatar})
|
||||
</insert>
|
||||
|
||||
<insert id="saveReplyMessage" parameterType="reply">
|
||||
insert into reply (content,names,create_time,mes_id,avatar)
|
||||
values (#{content},#{names},#{createTime},#{mes_id},#{avatar})
|
||||
</insert>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.forum.dao.NoticeDao">
|
||||
<select id="findAllNotice" resultType="notice">
|
||||
select * from notice
|
||||
</select>
|
||||
<select id="countNotice" resultType="java.lang.Integer">
|
||||
select count(*) from notice
|
||||
</select>
|
||||
|
||||
<insert id="addNotices" parameterType="notice">
|
||||
insert into notice(content) values(#{content})
|
||||
</insert>
|
||||
|
||||
<delete id="deleteNotice" parameterType="int">
|
||||
delete from notice where id=#{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.forum.dao.ReplyDao">
|
||||
<delete id="del">
|
||||
delete from reply where id=#{id}
|
||||
</delete>
|
||||
|
||||
|
||||
<select id="findAll" resultType="com.forum.entity.Reply">
|
||||
select id,content,names ,create_time from reply
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.forum.dao.UserDao">
|
||||
<update id="update">
|
||||
update user set password=#{password} where username=#{username}
|
||||
</update>
|
||||
|
||||
<select id="queryByUsernameAndPassword" resultType="com.forum.entity.User">
|
||||
select * from user
|
||||
where username = #{username} and password = #{password};
|
||||
</select>
|
||||
|
||||
<insert id="addUser" parameterType="user">
|
||||
insert into user(username,password,email,create_time,update_time,type,school,avatar)
|
||||
values(#{username},#{password},#{email},#{createTime},#{updateTime},#{type},#{school},#{avatar})
|
||||
</insert>
|
||||
<select id="getAllUser" resultType="com.forum.entity.User">
|
||||
select id,username,password,email,create_time,type from user
|
||||
</select>
|
||||
<delete id="deleteUser" >
|
||||
delete from user where id = #{id}
|
||||
</delete>
|
||||
<select id="count" resultType="Integer" >
|
||||
select count(*) from user where type = 0
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,16 @@
|
||||
@font-face {
|
||||
font-family: 'iconfont';
|
||||
src: url('../fonts/iconfont.eot');
|
||||
src: url('../fonts/iconfont.eot?#iefix') format('embedded-opentype'),
|
||||
url('../fonts/iconfont.woff') format('woff'),
|
||||
url('../fonts/iconfont.ttf') format('truetype'),
|
||||
url('../fonts/iconfont.svg#iconfont') format('svg');
|
||||
}
|
||||
.iconfont{
|
||||
font-family:"iconfont" !important;
|
||||
font-size:16px;font-style:normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-webkit-text-stroke-width: 0.2px;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* @Author: xuebingsi
|
||||
* @Date: 2019-04-01 13:37:17
|
||||
* @Last Modified by: zhibinm
|
||||
* @Last Modified time: 2019-04-01 13:37:19
|
||||
*/
|
||||
.login-bg{
|
||||
/*background: #eeeeee url() 0 0 no-repeat;*/
|
||||
background:url(../images/bg.png) no-repeat center;
|
||||
background-size: cover;
|
||||
overflow: hidden;
|
||||
}
|
||||
.login{
|
||||
margin: 120px auto 0 auto;
|
||||
min-height: 420px;
|
||||
max-width: 420px;
|
||||
padding: 40px;
|
||||
background-color: #ffffff;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
border-radius: 4px;
|
||||
/* overflow-x: hidden; */
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.login a.logo{
|
||||
display: block;
|
||||
height: 58px;
|
||||
width: 167px;
|
||||
margin: 0 auto 30px auto;
|
||||
background-size: 167px 42px;
|
||||
}
|
||||
.login .message {
|
||||
margin: 10px 0 0 -58px;
|
||||
padding: 18px 10px 18px 60px;
|
||||
background: #189F92;
|
||||
position: relative;
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
}
|
||||
.login #darkbannerwrap {
|
||||
background: url(../images/aiwrap.png);
|
||||
width: 18px;
|
||||
height: 10px;
|
||||
margin: 0 0 20px -58px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.login input[type=text],
|
||||
.login input[type=file],
|
||||
.login input[type=password],
|
||||
.login input[type=email], select {
|
||||
border: 1px solid #DCDEE0;
|
||||
vertical-align: middle;
|
||||
border-radius: 3px;
|
||||
height: 50px;
|
||||
padding: 0px 16px;
|
||||
font-size: 14px;
|
||||
color: #555555;
|
||||
outline:none;
|
||||
width:100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.login input[type=text]:focus,
|
||||
.login input[type=file]:focus,
|
||||
.login input[type=password]:focus,
|
||||
.login input[type=email]:focus, select:focus {
|
||||
border: 1px solid #27A9E3;
|
||||
}
|
||||
.login input[type=submit],
|
||||
.login input[type=button]{
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
padding: 12px 24px;
|
||||
margin: 0px;
|
||||
font-size: 18px;
|
||||
line-height: 24px;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
vertical-align: middle;
|
||||
cursor: pointer;
|
||||
color: #ffffff;
|
||||
background-color: #189F92;
|
||||
border-radius: 3px;
|
||||
border: none;
|
||||
-webkit-appearance: none;
|
||||
outline:none;
|
||||
width:100%;
|
||||
}
|
||||
.login hr {
|
||||
background: #fff url("#") 0 0 no-repeat;
|
||||
}
|
||||
.login hr.hr15 {
|
||||
height: 15px;
|
||||
border: none;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
width: 100%;
|
||||
}
|
||||
.login hr.hr20 {
|
||||
height: 20px;
|
||||
border: none;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
width: 100%;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
body{
|
||||
background:#F2F1F2;
|
||||
}
|
||||
.container{
|
||||
background:#1A1B20;
|
||||
}
|
||||
.left-nav{
|
||||
background:#1A1B20;
|
||||
}
|
||||
|
||||
.left-nav a{
|
||||
color:rgba(255,255,255,.7);
|
||||
}
|
||||
.left-nav a.active{
|
||||
background: #009688 !important;
|
||||
color: #fff;
|
||||
}
|
||||
.left-nav a:hover{
|
||||
background: #009688 !important;
|
||||
color: #fff;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
body{
|
||||
background:#EEF5F9;
|
||||
}
|
||||
.container{
|
||||
background:#323640;
|
||||
}
|
||||
.left-nav{
|
||||
background:#fff;
|
||||
}
|
||||
|
||||
.left-nav a{
|
||||
color:#686a76;
|
||||
}
|
||||
.left-nav a.active{
|
||||
background: #786AED !important;
|
||||
color: #fff;
|
||||
}
|
||||
.left-nav a:hover{
|
||||
background: #786AED !important;
|
||||
color: #fff;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
body{
|
||||
background:#E8E8E8;
|
||||
}
|
||||
.container{
|
||||
background:#F34743;
|
||||
}
|
||||
|
||||
.left-nav{
|
||||
background:#F4F4F4;
|
||||
}
|
||||
|
||||
.left-nav a{
|
||||
color:#686a76;
|
||||
}
|
||||
.left-nav a.active{
|
||||
background: #FEFEFE !important;
|
||||
color: #F34743;
|
||||
}
|
||||
.left-nav a:hover{
|
||||
background: #FEFEFE !important;
|
||||
color: #F34743;
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
body{
|
||||
background:#E4E4E4;
|
||||
}
|
||||
.container{
|
||||
background:#019587;
|
||||
}
|
||||
.left-nav{
|
||||
background:#263035;
|
||||
}
|
||||
|
||||
.left-nav a{
|
||||
color:#fff;
|
||||
}
|
||||
.left-nav a.active{
|
||||
background: #212525 !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
.left-nav a:hover{
|
||||
background: #212525 !important;
|
||||
color: #fff !important;
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
body{
|
||||
background:#EEF5F9 !important;
|
||||
}
|
||||
.container{
|
||||
background:linear-gradient(to left, #7b4397, #2196f3);
|
||||
}
|
||||
|
||||
.left-nav{
|
||||
background:#fff !important;
|
||||
}
|
||||
|
||||
.left-nav a{
|
||||
color:#686a76 !important;
|
||||
}
|
||||
.left-nav a.active{
|
||||
background: linear-gradient(to left, #7c8ce4, #2196f3) !important;
|
||||
color: #fff !important;
|
||||
border-color: #7b4397 !important;
|
||||
}
|
||||
.left-nav a:hover{
|
||||
background: linear-gradient(to left, #7c8ce4, #2196f3) !important;
|
||||
color: #fff !important;
|
||||
border-color: #7b4397 !important;
|
||||
}
|
||||
.container .logo a{
|
||||
background: rgba(0,0,0,0) !important;
|
||||
}
|
@ -0,0 +1,534 @@
|
||||
@charset "utf-8";
|
||||
@import url(../layui/css/layui.css);
|
||||
*{
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
}
|
||||
a{
|
||||
text-decoration: none;
|
||||
}
|
||||
html{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow-x:hidden;
|
||||
overflow-y:auto;
|
||||
}
|
||||
body{
|
||||
width: 100%;
|
||||
min-height: 100%;
|
||||
background: #f1f1f1;
|
||||
/*background: #fff;*/
|
||||
}
|
||||
.x-red{
|
||||
color: red;
|
||||
}
|
||||
|
||||
.layui-form-switch{
|
||||
margin-top: 0px;
|
||||
}
|
||||
.layui-input:focus, .layui-textarea:focus {
|
||||
border-color: #189f92!important;
|
||||
}
|
||||
|
||||
.layui-fluid{
|
||||
padding:15px;
|
||||
}
|
||||
.x-nav{
|
||||
padding: 0 20px;
|
||||
position: relative;
|
||||
z-index: 99;
|
||||
border-bottom: 1px solid #e5e5e5;
|
||||
line-height: 39px;
|
||||
height: 39px;
|
||||
overflow: hidden;
|
||||
background: #fff;
|
||||
}
|
||||
.page{
|
||||
text-align: center;
|
||||
|
||||
}
|
||||
.page a{
|
||||
display: inline-block;
|
||||
background: #fff;
|
||||
color: #888;
|
||||
padding: 5px;
|
||||
min-width: 15px;
|
||||
border: 1px solid #E2E2E2;
|
||||
|
||||
}
|
||||
.page span{
|
||||
display: inline-block;
|
||||
padding: 5px;
|
||||
min-width: 15px;
|
||||
border: 1px solid #E2E2E2;
|
||||
}
|
||||
.page span.current{
|
||||
display: inline-block;
|
||||
background: #009688;
|
||||
color: #fff;
|
||||
padding: 5px;
|
||||
min-width: 15px;
|
||||
border: 1px solid #009688;
|
||||
}
|
||||
.page .pagination li{
|
||||
display: inline-block;
|
||||
margin-right: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
.page .pagination li.active span{
|
||||
background: #009688;
|
||||
color: #fff;
|
||||
border: 1px solid #009688;
|
||||
|
||||
}
|
||||
|
||||
/*登录样式*/
|
||||
/*头部*/
|
||||
.container{
|
||||
width: 100%;
|
||||
height: 45px;
|
||||
background-color: #222;
|
||||
}
|
||||
.container a,.layui-nav .layui-nav-item a{
|
||||
color: #fff;
|
||||
}
|
||||
.container .logo a{
|
||||
background-color: rgba(0,0,0,0);
|
||||
}
|
||||
.container .logo a{
|
||||
float: left;
|
||||
font-size: 18px;
|
||||
padding-left: 20px;
|
||||
line-height: 45px;
|
||||
width: 200px;
|
||||
}
|
||||
.container .right{
|
||||
background-color:rgba(0,0,0,0);
|
||||
float: right;
|
||||
|
||||
}
|
||||
.container .left_open{
|
||||
height: 45px;
|
||||
float: left;
|
||||
margin-left: 10px;
|
||||
}
|
||||
.container .left_open i{
|
||||
display: block;
|
||||
background: rgba(255,255,255,0.1);
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
border-radius: 3px;
|
||||
text-align: center;
|
||||
margin-top: 7px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.container .left_open i:hover{
|
||||
background: rgba(255,255,255,0.3);
|
||||
}
|
||||
|
||||
.container .left{
|
||||
background-color:rgba(0,0,0,0);
|
||||
float: left;
|
||||
|
||||
}
|
||||
.container .layui-nav-item{
|
||||
line-height: 45px;
|
||||
}
|
||||
.container .layui-nav-more{
|
||||
top: 20px;
|
||||
}
|
||||
.container .layui-nav-child{
|
||||
top: 50px;
|
||||
}
|
||||
.container .layui-nav-child i{
|
||||
margin-right: 10px;
|
||||
}
|
||||
.layui-nav .layui-nav-item a{
|
||||
cursor: pointer;
|
||||
}
|
||||
.layui-nav .layui-nav-child a{
|
||||
color: #333;
|
||||
cursor: pointer;
|
||||
}
|
||||
.left-nav{
|
||||
position: absolute;
|
||||
top: 45px;
|
||||
bottom: 0px;
|
||||
/*bottom: 42px;*/
|
||||
left: 0;
|
||||
z-index: 2;
|
||||
padding-top: 10px;
|
||||
background-color: #EEEEEE;
|
||||
width: 220px;
|
||||
max-width: 220px;
|
||||
overflow: auto;
|
||||
overflow-x:hidden;
|
||||
overflow: hidden;
|
||||
|
||||
/*width: 0px;*/
|
||||
}
|
||||
#side-nav{
|
||||
width: 220px;
|
||||
}
|
||||
|
||||
.left-nav #nav li:hover > a{
|
||||
/*color: blue;*/
|
||||
}
|
||||
.left-nav #nav .current{
|
||||
background-color: rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
.left-nav #nav li a{
|
||||
font-size: 14px;
|
||||
padding: 10px 15px 10px 15px;
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
border-left: 4px solid transparent;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
.left-nav a:hover{
|
||||
background: #009688 !important;
|
||||
color: #fff;
|
||||
border-color: #04564e !important;
|
||||
}
|
||||
.left-nav a.active{
|
||||
background: #009688 !important;
|
||||
color: #fff;
|
||||
border-color: #04564e !important;
|
||||
}
|
||||
.left-nav #nav li a cite{
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.left-nav #nav li .sub-menu{
|
||||
display: none;
|
||||
}
|
||||
.left-nav #nav li .opened{
|
||||
display: block;
|
||||
}
|
||||
.left-nav #nav li .opened:hover{
|
||||
/*background: #fff ;*/
|
||||
}
|
||||
.left-nav #nav li .opened .current{
|
||||
|
||||
}
|
||||
.left-nav #nav li .sub-menu li:hover{
|
||||
/*color: blue;*/
|
||||
/*background: #fff ;*/
|
||||
}
|
||||
.left-nav #nav li .sub-menu li a{
|
||||
padding: 12px 15px 12px 30px;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.left-nav #nav li .sub-menu li .sub-menu li a{
|
||||
padding-left: 45px;
|
||||
}
|
||||
/*.left-nav #nav li .sub-menu li a:hover{
|
||||
color: #148cf1;
|
||||
}*/
|
||||
.left-nav #nav li .sub-menu li a i{
|
||||
font-size: 12px;
|
||||
}
|
||||
.left-nav #nav li a i{
|
||||
padding-right: 10px;
|
||||
line-height: 14px;
|
||||
}
|
||||
.left-nav #nav li .nav_right{
|
||||
float: right;
|
||||
font-size: 16px;
|
||||
}
|
||||
.x-slide_left {
|
||||
width: 17px;
|
||||
height: 61px;
|
||||
background: url(../images/icon.png) 0 0 no-repeat;
|
||||
position: absolute;
|
||||
top: 200px;
|
||||
left: 220px;
|
||||
cursor: pointer;
|
||||
z-index: 3;
|
||||
}
|
||||
.page-content{
|
||||
position: absolute;
|
||||
top: 45px;
|
||||
right: 0;
|
||||
/*bottom: 42px;*/
|
||||
bottom: 0px;
|
||||
left: 220px;
|
||||
overflow: hidden;
|
||||
z-index: 1;
|
||||
}
|
||||
.page-content-bg{
|
||||
position: absolute;
|
||||
top: 45px;
|
||||
right: 0;
|
||||
/*bottom: 42px;*/
|
||||
bottom: 0px;
|
||||
left: 220px;
|
||||
background: rgba(0,0,0,0.5);
|
||||
overflow: hidden;
|
||||
z-index: 100;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.page-content .tab{
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
/*background: #EFEEF0;*/
|
||||
margin: 0px;
|
||||
}
|
||||
.page-content .layui-tab-title{
|
||||
/*padding-top: 5px;*/
|
||||
height: 35px;
|
||||
background: #EFEEF0 ;
|
||||
position: relative;
|
||||
z-index: 100;
|
||||
}
|
||||
.page-content .layui-tab-title li.home i{
|
||||
padding-right: 5px;
|
||||
}
|
||||
.page-content .layui-tab-title li.home .layui-tab-close{
|
||||
display: none;
|
||||
}
|
||||
.page-content .layui-tab-title li{
|
||||
line-height: 35px;
|
||||
}
|
||||
.page-content .layui-tab-title .layui-this:after{
|
||||
height: 36px;
|
||||
}
|
||||
.page-content .layui-tab-title li .layui-tab-close{
|
||||
border-radius: 50%;
|
||||
}
|
||||
.page-content .layui-tab-title .layui-this{
|
||||
background: #fff ;
|
||||
}
|
||||
.page-content .layui-tab-bar{
|
||||
height:34px;
|
||||
line-height: 35px;
|
||||
}
|
||||
.page-content .layui-tab-content{
|
||||
position: absolute;
|
||||
top: 36px;
|
||||
bottom: 0px;
|
||||
width: 100%;
|
||||
padding: 0px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.page-content .layui-tab-content .layui-tab-item{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
}
|
||||
.page-content .layui-tab-content .layui-tab-item iframe{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
}
|
||||
.x-admin-carousel,.layui-carousel,.x-admin-carousel>[carousel-item]>* {
|
||||
background-color:#fff
|
||||
}
|
||||
|
||||
.x-admin-backlog .x-admin-backlog-body {
|
||||
display:block;
|
||||
padding:10px 15px;
|
||||
background-color:#f8f8f8;
|
||||
color:#999;
|
||||
border-radius:2px;
|
||||
transition:all .3s;
|
||||
-webkit-transition:all .3s
|
||||
}
|
||||
.x-admin-backlog-body h3 {
|
||||
padding-bottom:10px;
|
||||
font-size:12px
|
||||
}
|
||||
.x-admin-backlog-body p cite {
|
||||
font-style:normal;
|
||||
font-size:30px;
|
||||
font-weight:300;
|
||||
color:#009688
|
||||
}
|
||||
.x-admin-backlog-body:hover {
|
||||
background-color:#CFCFCF;
|
||||
color:#888
|
||||
}
|
||||
|
||||
.layui-table td, .layui-table th{
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
table th, table td {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
/*404页面样式*/
|
||||
.fly-panel {
|
||||
margin-bottom: 15px;
|
||||
border-radius: 2px;
|
||||
/*background-color: #fff;*/
|
||||
box-shadow: 0 1px 2px 0 rgba(0,0,0,.05);
|
||||
}
|
||||
.fly-none {
|
||||
min-height: 600px;
|
||||
text-align: center;
|
||||
padding-top: 50px;
|
||||
color: #999;
|
||||
}
|
||||
.fly-none .layui-icon {
|
||||
line-height: 300px;
|
||||
font-size: 300px;
|
||||
color: #393D49;
|
||||
}
|
||||
.fly-none p {
|
||||
margin-top: 50px;
|
||||
padding: 0 15px;
|
||||
font-size: 20px;
|
||||
color: #999;
|
||||
font-weight: 300;
|
||||
}
|
||||
#tab_right{
|
||||
display: none;
|
||||
width: 80px;
|
||||
position: absolute;
|
||||
top: 35px;
|
||||
left: 0px;
|
||||
}
|
||||
#tab_right dl{
|
||||
top: 0px;
|
||||
}
|
||||
#tab_show{
|
||||
position: absolute;
|
||||
top: 36px;
|
||||
bottom: 0px;
|
||||
width: 100%;
|
||||
background:rgb(255, 255, 255,0);
|
||||
padding: 0px;
|
||||
overflow: hidden;
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
@media screen and (max-width: 768px){
|
||||
.fast-add{
|
||||
display: none;
|
||||
}
|
||||
.layui-nav .to-index{
|
||||
display: none;
|
||||
}
|
||||
.container .logo a{
|
||||
width: 140px;
|
||||
}
|
||||
.container .left_open {
|
||||
/*float: right;*/
|
||||
}
|
||||
.left-nav{
|
||||
width: 60px;
|
||||
}
|
||||
.left-nav #nav li a i{
|
||||
font-size: 18px;
|
||||
}
|
||||
.left-nav cite,.left-nav .nav_right{
|
||||
display: none;
|
||||
}
|
||||
.page-content{
|
||||
left: 60px;
|
||||
}
|
||||
.page-content .layui-tab-content .layui-tab-item{
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
.x-so input.layui-input{
|
||||
width: 100%;
|
||||
margin: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
/*精细版样式*/
|
||||
|
||||
.x-admin-sm{
|
||||
font-size: 12px;
|
||||
}
|
||||
.x-admin-sm body{
|
||||
font-size: 12px;
|
||||
}
|
||||
/*登录页面样式*/
|
||||
.x-admin-sm .login input[type=submit],.x-admin-sm .login input[type=button]{
|
||||
font-size: 14px;
|
||||
}
|
||||
.x-admin-sm .login input[type=text],
|
||||
.x-admin-sm .login input[type=file],
|
||||
.x-admin-sm .login input[type=password],
|
||||
.x-admin-sm .login input[type=email], .x-admin-sm select {
|
||||
font-size: 12px;
|
||||
}
|
||||
.x-admin-sm .login .message{
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.x-admin-sm .layui-table td, .x-admin-sm .layui-table th{
|
||||
font-size: 12px;
|
||||
}
|
||||
.x-admin-sm .layui-elem-field legend{
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.x-admin-sm .x-admin-backlog-body p cite{
|
||||
font-size: 24px;
|
||||
}
|
||||
.x-admin-sm .left-nav #nav li a cite{
|
||||
font-size: 12px;
|
||||
}
|
||||
.x-admin-sm .iconfont{
|
||||
font-size: 14px;
|
||||
}
|
||||
.x-admin-sm .layui-tab-title li{
|
||||
font-size: 12px;
|
||||
}
|
||||
.x-admin-sm .layui-icon{
|
||||
font-size: 14px;
|
||||
}
|
||||
.x-admin-sm .layui-nav *{
|
||||
font-size: 12px;
|
||||
}
|
||||
.x-admin-sm .layui-breadcrumb>*{
|
||||
font-size: 12px;
|
||||
}
|
||||
.x-admin-sm .layui-btn,.x-admin-sm .layui-btn-xs,.x-admin-sm .layui-btn-sm{
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.x-admin-sm .layui-laydate{
|
||||
font-size: 12px;
|
||||
}
|
||||
.x-admin-sm .layui-btn{
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 0 10px;
|
||||
}
|
||||
|
||||
.x-admin-sm .layui-btn-lg{
|
||||
height: 38px;
|
||||
line-height: 38px;
|
||||
padding: 0 18px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.x-admin-sm .layui-layer-title,.x-admin-sm .layui-layer-dialog .layui-layer-content{
|
||||
font-size: 12px;
|
||||
}
|
||||
.x-admin-sm .layui-input,.x-admin-sm .layui-select,.x-admin-sm .layui-textarea{
|
||||
height: 30px;
|
||||
}
|
||||
|
||||
.x-admin-sm .layui-form-pane .layui-form-label{
|
||||
height: 30px;
|
||||
line-height: 14px;
|
||||
}
|
||||
.x-admin-sm .layui-form-checkbox span{
|
||||
font-size: 12px;
|
||||
}
|
||||
.x-admin-sm .fly-none .layui-icon {
|
||||
line-height: 300px;
|
||||
font-size: 300px;
|
||||
color: #393D49;
|
||||
}
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 315 KiB |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
After Width: | Height: | Size: 28 KiB |
File diff suppressed because one or more lines are too long
@ -0,0 +1,584 @@
|
||||
;!function (win) {
|
||||
"use strict";
|
||||
var doc = document
|
||||
|
||||
,Xadmin = function(){
|
||||
this.v = '2.2'; //版本号
|
||||
}
|
||||
|
||||
Xadmin.prototype.init = function() {
|
||||
var tab_list = this.get_data();
|
||||
for(var i in tab_list){
|
||||
this.add_lay_tab(tab_list[i].title,tab_list[i].url,i);
|
||||
}
|
||||
element.tabChange('xbs_tab', i);
|
||||
};
|
||||
/**
|
||||
* [end 执行结束要做的]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
Xadmin.prototype.end = function() {
|
||||
|
||||
var cate_list = this.get_cate_data();
|
||||
|
||||
for(var i in cate_list){
|
||||
if(cate_list[i]!=null){
|
||||
$('.left-nav #nav li').eq(cate_list[i]).click();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Xadmin.prototype.add_tab = function (title,url,is_refresh) {
|
||||
var id = md5(url);//md5每个url
|
||||
|
||||
//重复点击
|
||||
for (var i = 0; i <$('.x-iframe').length; i++) {
|
||||
if($('.x-iframe').eq(i).attr('tab-id')==id){
|
||||
element.tabChange('xbs_tab', id);
|
||||
if(is_refresh)
|
||||
$('.x-iframe').eq(i).attr("src",$('.x-iframe').eq(i).attr('src'));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.add_lay_tab(title,url,id);
|
||||
this.set_data(title,url,id);
|
||||
element.tabChange('xbs_tab', id);
|
||||
|
||||
}
|
||||
|
||||
Xadmin.prototype.del_tab = function (id) {
|
||||
|
||||
if(id){
|
||||
console.log(88);
|
||||
}else{
|
||||
var id = $(window.frameElement).attr('tab-id');
|
||||
parent.element.tabDelete('xbs_tab', id);
|
||||
}
|
||||
}
|
||||
|
||||
Xadmin.prototype.add_lay_tab = function(title,url,id) {
|
||||
element.tabAdd('xbs_tab', {
|
||||
title: title
|
||||
,content: '<iframe tab-id="'+id+'" frameborder="0" src="'+url+'" scrolling="yes" class="x-iframe"></iframe>'
|
||||
,id: id
|
||||
})
|
||||
}
|
||||
/**
|
||||
* [open 打开弹出层]
|
||||
* @param {[type]} title [弹出层标题]
|
||||
* @param {[type]} url [弹出层地址]
|
||||
* @param {[type]} w [宽]
|
||||
* @param {[type]} h [高]
|
||||
* @param {Boolean} full [全屏]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
Xadmin.prototype.open = function (title,url,w,h,full) {
|
||||
if (title == null || title == '') {
|
||||
var title=false;
|
||||
};
|
||||
if (url == null || url == '') {
|
||||
var url="404.html";
|
||||
};
|
||||
if (w == null || w == '') {
|
||||
var w=($(window).width()*0.9);
|
||||
};
|
||||
if (h == null || h == '') {
|
||||
var h=($(window).height() - 50);
|
||||
};
|
||||
var index = layer.open({
|
||||
type: 2,
|
||||
area: [w+'px', h +'px'],
|
||||
fix: false, //不固定
|
||||
maxmin: true,
|
||||
shadeClose: true,
|
||||
shade:0.4,
|
||||
title: title,
|
||||
content: url
|
||||
});
|
||||
if(full){
|
||||
layer.full(index);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* [close 关闭弹出层]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
Xadmin.prototype.close = function() {
|
||||
var index = parent.layer.getFrameIndex(window.name);
|
||||
parent.layer.close(index);
|
||||
};
|
||||
/**
|
||||
* [close 关闭弹出层父窗口关闭]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
Xadmin.prototype.father_reload = function() {
|
||||
parent.location.reload();
|
||||
};
|
||||
/**
|
||||
* [get_data 获取所有项]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
Xadmin.prototype.get_data = function () {
|
||||
if(typeof is_remember!="undefined")
|
||||
return false;
|
||||
return layui.data('tab_list')
|
||||
}
|
||||
/**
|
||||
* [set_data 增加某一项]
|
||||
* @param {[type]} id [description]
|
||||
*/
|
||||
Xadmin.prototype.set_data = function(title,url,id) {
|
||||
|
||||
if(typeof is_remember!="undefined")
|
||||
return false;
|
||||
|
||||
layui.data('tab_list', {
|
||||
key: id
|
||||
,value: {title:title,url:url}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* [get_data 获取所有项]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
Xadmin.prototype.get_cate_data = function () {
|
||||
if(typeof is_remember!="undefined")
|
||||
return false;
|
||||
return layui.data('cate')
|
||||
}
|
||||
/**
|
||||
* [set_data 增加某一项]
|
||||
* @param {[type]} id [description]
|
||||
*/
|
||||
Xadmin.prototype.set_cate_data = function(data) {
|
||||
|
||||
if(typeof is_remember!="undefined")
|
||||
return false;
|
||||
|
||||
layui.data('cate', data);
|
||||
};
|
||||
/**
|
||||
* [del_data 删除某一项]
|
||||
* @param {[type]} id [description]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
Xadmin.prototype.del_data = function(id) {
|
||||
if(typeof is_remember!="undefined")
|
||||
return false;
|
||||
if(typeof id!="undefined"){
|
||||
layui.data('tab_list', {
|
||||
key: id
|
||||
,remove: true
|
||||
});
|
||||
}else{
|
||||
layui.data('tab_list',null);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* [del_other_data 删除其它]
|
||||
* @param {[type]} id [description]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
Xadmin.prototype.del_other_data = function(id) {
|
||||
if(typeof is_remember!="undefined")
|
||||
return false;
|
||||
var tab_list = this.get_data();
|
||||
|
||||
layui.data('tab_list',null);
|
||||
|
||||
layui.data('tab_list', {
|
||||
key: id
|
||||
,value: tab_list[id]
|
||||
});
|
||||
};
|
||||
win.xadmin = new Xadmin();
|
||||
|
||||
}(window);
|
||||
|
||||
layui.use(['layer','element','jquery'],function() {
|
||||
layer = layui.layer;
|
||||
element = layui.element;
|
||||
$ = layui.jquery;
|
||||
|
||||
|
||||
// 打开页面初始
|
||||
xadmin.init();
|
||||
|
||||
//关闭tab清除记忆
|
||||
element.on('tabDelete(xbs_tab)', function(data){
|
||||
var id = $(this).parent().attr('lay-id');
|
||||
xadmin.del_data(id);
|
||||
});
|
||||
//左侧菜单
|
||||
$('.left-nav #nav').on('click', 'li', function(event) {
|
||||
|
||||
if($(this).parent().attr('id')=='nav'){
|
||||
xadmin.set_cate_data({key:'f1',value:$('.left-nav #nav li').index($(this))})
|
||||
xadmin.set_cate_data({key:'f2',value:null})
|
||||
xadmin.set_cate_data({key:'f3',value:null})
|
||||
}
|
||||
|
||||
if($(this).parent().parent().parent().attr('id')=='nav'){
|
||||
xadmin.set_cate_data({key:'f2',value:$('.left-nav #nav li').index($(this))})
|
||||
xadmin.set_cate_data({key:'f3',value:null})
|
||||
}
|
||||
|
||||
if($(this).parent().parent().parent().parent().parent().attr('id')=='nav'){
|
||||
xadmin.set_cate_data({key:'f3',value:$('.left-nav #nav li').index($(this))})
|
||||
}
|
||||
|
||||
|
||||
|
||||
if($('.left-nav').css('width')=='60px'){
|
||||
$('.left-nav').animate({width: '220px'}, 100);
|
||||
$('.page-content').animate({left: '220px'}, 100);
|
||||
$('.left-nav i').css('font-size','14px');
|
||||
$('.left-nav cite,.left-nav .nav_right').show();
|
||||
}
|
||||
|
||||
if($(window).width()<768){
|
||||
$('.page-content-bg').show();
|
||||
}
|
||||
|
||||
$('.left-nav').find('a').removeClass('active');
|
||||
$(this).children('a').addClass('active');
|
||||
if($(this).children('.sub-menu').length){
|
||||
if($(this).hasClass('open')){
|
||||
$(this).removeClass('open');
|
||||
$(this).find('.nav_right').html('');
|
||||
$(this).children('.sub-menu').stop(true,true).slideUp();
|
||||
$(this).siblings().children('.sub-menu').slideUp();
|
||||
}else{
|
||||
$(this).addClass('open');
|
||||
$(this).children('a').find('.nav_right').html('');
|
||||
$(this).children('.sub-menu').stop(true,true).slideDown();
|
||||
$(this).siblings().children('.sub-menu').stop(true,true).slideUp();
|
||||
$(this).siblings().find('.nav_right').html('');
|
||||
$(this).siblings().removeClass('open');
|
||||
}
|
||||
}
|
||||
event.stopPropagation();
|
||||
})
|
||||
var left_tips_index = null;
|
||||
$('.left-nav #nav').on('mouseenter', '.left-nav-li', function(event) {
|
||||
if($('.left-nav').css('width')!='220px'){
|
||||
var tips = $(this).attr('lay-tips');
|
||||
left_tips_index = layer.tips(tips, $(this));
|
||||
}
|
||||
})
|
||||
|
||||
$('.left-nav #nav').on('mouseout', '.left-nav-li', function(event) {
|
||||
layer.close(left_tips_index);
|
||||
})
|
||||
// 隐藏左侧
|
||||
$('.container .left_open i').click(function(event) {
|
||||
if($('.left-nav').css('width')=='220px'){
|
||||
$('.left-nav .open').click();
|
||||
$('.left-nav i').css('font-size','18px');
|
||||
$('.left-nav').animate({width: '60px'}, 100);
|
||||
$('.left-nav cite,.left-nav .nav_right').hide();
|
||||
$('.page-content').animate({left: '60px'}, 100);
|
||||
$('.page-content-bg').hide();
|
||||
}else{
|
||||
$('.left-nav').animate({width: '220px'}, 100);
|
||||
$('.page-content').animate({left: '220px'}, 100);
|
||||
$('.left-nav i').css('font-size','14px');
|
||||
$('.left-nav cite,.left-nav .nav_right').show();
|
||||
if($(window).width()<768){
|
||||
$('.page-content-bg').show();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('.page-content-bg').click(function(event) {
|
||||
$('.left-nav .open').click();
|
||||
$('.left-nav i').css('font-size','18px');
|
||||
$('.left-nav').animate({width: '60px'}, 100);
|
||||
$('.left-nav cite,.left-nav .nav_right').hide();
|
||||
$('.page-content').animate({left: '60px'}, 100);
|
||||
$(this).hide();
|
||||
});
|
||||
|
||||
$(".layui-tab-title").on('contextmenu', 'li', function(event) {
|
||||
var tab_left = $(this).position().left;
|
||||
var tab_width = $(this).width();
|
||||
var left = $(this).position().top;
|
||||
var this_index = $(this).attr('lay-id');
|
||||
$('#tab_right').css({'left':tab_left+tab_width/2}).show().attr('lay-id',this_index);
|
||||
$('#tab_show').show();
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#tab_right').on('click', 'dd', function(event) {
|
||||
var data_type = $(this).attr('data-type');
|
||||
var lay_id = $(this).parents('#tab_right').attr('lay-id');
|
||||
if(data_type=='this'){
|
||||
$('.layui-tab-title li[lay-id='+lay_id+']').find('.layui-tab-close').click();
|
||||
}else if(data_type=='other'){
|
||||
$('.layui-tab-title li').eq(0).find('.layui-tab-close').remove();
|
||||
$('.layui-tab-title li[lay-id!='+lay_id+']').find('.layui-tab-close').click();
|
||||
}else if(data_type=='all'){
|
||||
$('.layui-tab-title li[lay-id]').find('.layui-tab-close').click();
|
||||
}
|
||||
$('#tab_right').hide();
|
||||
$('#tab_show').hide();
|
||||
})
|
||||
|
||||
|
||||
$('.page-content,#tab_show,.container,.left-nav').click(function(event) {
|
||||
$('#tab_right').hide();
|
||||
$('#tab_show').hide();
|
||||
});
|
||||
|
||||
// 页面加载完要做的
|
||||
xadmin.end();
|
||||
})
|
||||
// md5-----------------------------------------------------------------------------------
|
||||
/*
|
||||
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
|
||||
* to work around bugs in some JS interpreters.
|
||||
*/
|
||||
function safeAdd (x, y) {
|
||||
var lsw = (x & 0xffff) + (y & 0xffff)
|
||||
var msw = (x >> 16) + (y >> 16) + (lsw >> 16)
|
||||
return (msw << 16) | (lsw & 0xffff)
|
||||
}
|
||||
|
||||
/*
|
||||
* Bitwise rotate a 32-bit number to the left.
|
||||
*/
|
||||
function bitRotateLeft (num, cnt) {
|
||||
return (num << cnt) | (num >>> (32 - cnt))
|
||||
}
|
||||
|
||||
/*
|
||||
* These functions implement the four basic operations the algorithm uses.
|
||||
*/
|
||||
function md5cmn (q, a, b, x, s, t) {
|
||||
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b)
|
||||
}
|
||||
function md5ff (a, b, c, d, x, s, t) {
|
||||
return md5cmn((b & c) | (~b & d), a, b, x, s, t)
|
||||
}
|
||||
function md5gg (a, b, c, d, x, s, t) {
|
||||
return md5cmn((b & d) | (c & ~d), a, b, x, s, t)
|
||||
}
|
||||
function md5hh (a, b, c, d, x, s, t) {
|
||||
return md5cmn(b ^ c ^ d, a, b, x, s, t)
|
||||
}
|
||||
function md5ii (a, b, c, d, x, s, t) {
|
||||
return md5cmn(c ^ (b | ~d), a, b, x, s, t)
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the MD5 of an array of little-endian words, and a bit length.
|
||||
*/
|
||||
function binlMD5 (x, len) {
|
||||
/* append padding */
|
||||
x[len >> 5] |= 0x80 << (len % 32)
|
||||
x[((len + 64) >>> 9 << 4) + 14] = len
|
||||
|
||||
var i
|
||||
var olda
|
||||
var oldb
|
||||
var oldc
|
||||
var oldd
|
||||
var a = 1732584193
|
||||
var b = -271733879
|
||||
var c = -1732584194
|
||||
var d = 271733878
|
||||
|
||||
for (i = 0; i < x.length; i += 16) {
|
||||
olda = a
|
||||
oldb = b
|
||||
oldc = c
|
||||
oldd = d
|
||||
|
||||
a = md5ff(a, b, c, d, x[i], 7, -680876936)
|
||||
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586)
|
||||
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819)
|
||||
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330)
|
||||
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897)
|
||||
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426)
|
||||
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341)
|
||||
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983)
|
||||
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416)
|
||||
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417)
|
||||
c = md5ff(c, d, a, b, x[i + 10], 17, -42063)
|
||||
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162)
|
||||
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682)
|
||||
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101)
|
||||
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290)
|
||||
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329)
|
||||
|
||||
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510)
|
||||
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632)
|
||||
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713)
|
||||
b = md5gg(b, c, d, a, x[i], 20, -373897302)
|
||||
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691)
|
||||
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083)
|
||||
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335)
|
||||
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848)
|
||||
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438)
|
||||
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690)
|
||||
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961)
|
||||
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501)
|
||||
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467)
|
||||
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784)
|
||||
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473)
|
||||
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734)
|
||||
|
||||
a = md5hh(a, b, c, d, x[i + 5], 4, -378558)
|
||||
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463)
|
||||
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562)
|
||||
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556)
|
||||
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060)
|
||||
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353)
|
||||
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632)
|
||||
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640)
|
||||
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174)
|
||||
d = md5hh(d, a, b, c, x[i], 11, -358537222)
|
||||
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979)
|
||||
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189)
|
||||
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487)
|
||||
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835)
|
||||
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520)
|
||||
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651)
|
||||
|
||||
a = md5ii(a, b, c, d, x[i], 6, -198630844)
|
||||
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415)
|
||||
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905)
|
||||
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055)
|
||||
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571)
|
||||
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606)
|
||||
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523)
|
||||
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799)
|
||||
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359)
|
||||
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744)
|
||||
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380)
|
||||
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649)
|
||||
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070)
|
||||
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379)
|
||||
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259)
|
||||
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551)
|
||||
|
||||
a = safeAdd(a, olda)
|
||||
b = safeAdd(b, oldb)
|
||||
c = safeAdd(c, oldc)
|
||||
d = safeAdd(d, oldd)
|
||||
}
|
||||
return [a, b, c, d]
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of little-endian words to a string
|
||||
*/
|
||||
function binl2rstr (input) {
|
||||
var i
|
||||
var output = ''
|
||||
var length32 = input.length * 32
|
||||
for (i = 0; i < length32; i += 8) {
|
||||
output += String.fromCharCode((input[i >> 5] >>> (i % 32)) & 0xff)
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to an array of little-endian words
|
||||
* Characters >255 have their high-byte silently ignored.
|
||||
*/
|
||||
function rstr2binl (input) {
|
||||
var i
|
||||
var output = []
|
||||
output[(input.length >> 2) - 1] = undefined
|
||||
for (i = 0; i < output.length; i += 1) {
|
||||
output[i] = 0
|
||||
}
|
||||
var length8 = input.length * 8
|
||||
for (i = 0; i < length8; i += 8) {
|
||||
output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << (i % 32)
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the MD5 of a raw string
|
||||
*/
|
||||
function rstrMD5 (s) {
|
||||
return binl2rstr(binlMD5(rstr2binl(s), s.length * 8))
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the HMAC-MD5, of a key and some data (raw strings)
|
||||
*/
|
||||
function rstrHMACMD5 (key, data) {
|
||||
var i
|
||||
var bkey = rstr2binl(key)
|
||||
var ipad = []
|
||||
var opad = []
|
||||
var hash
|
||||
ipad[15] = opad[15] = undefined
|
||||
if (bkey.length > 16) {
|
||||
bkey = binlMD5(bkey, key.length * 8)
|
||||
}
|
||||
for (i = 0; i < 16; i += 1) {
|
||||
ipad[i] = bkey[i] ^ 0x36363636
|
||||
opad[i] = bkey[i] ^ 0x5c5c5c5c
|
||||
}
|
||||
hash = binlMD5(ipad.concat(rstr2binl(data)), 512 + data.length * 8)
|
||||
return binl2rstr(binlMD5(opad.concat(hash), 512 + 128))
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to a hex string
|
||||
*/
|
||||
function rstr2hex (input) {
|
||||
var hexTab = '0123456789abcdef'
|
||||
var output = ''
|
||||
var x
|
||||
var i
|
||||
for (i = 0; i < input.length; i += 1) {
|
||||
x = input.charCodeAt(i)
|
||||
output += hexTab.charAt((x >>> 4) & 0x0f) + hexTab.charAt(x & 0x0f)
|
||||
}
|
||||
return output
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode a string as utf-8
|
||||
*/
|
||||
function str2rstrUTF8 (input) {
|
||||
return unescape(encodeURIComponent(input))
|
||||
}
|
||||
|
||||
/*
|
||||
* Take string arguments and return either raw or hex encoded strings
|
||||
*/
|
||||
function rawMD5 (s) {
|
||||
return rstrMD5(str2rstrUTF8(s))
|
||||
}
|
||||
function hexMD5 (s) {
|
||||
return rstr2hex(rawMD5(s))
|
||||
}
|
||||
function rawHMACMD5 (k, d) {
|
||||
return rstrHMACMD5(str2rstrUTF8(k), str2rstrUTF8(d))
|
||||
}
|
||||
function hexHMACMD5 (k, d) {
|
||||
return rstr2hex(rawHMACMD5(k, d))
|
||||
}
|
||||
|
||||
function md5 (string, key, raw) {
|
||||
if (!key) {
|
||||
if (!raw) {
|
||||
return hexMD5(string)
|
||||
}
|
||||
return rawMD5(string)
|
||||
}
|
||||
if (!raw) {
|
||||
return hexHMACMD5(key, string)
|
||||
}
|
||||
return rawHMACMD5(key, string)
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,2 @@
|
||||
/** layui-v2.4.5 MIT License By https://www.layui.com */
|
||||
html #layuicss-skincodecss{display:none;position:absolute;width:1989px}.layui-code-h3,.layui-code-view{position:relative;font-size:12px}.layui-code-view{display:block;margin:10px 0;padding:0;border:1px solid #e2e2e2;border-left-width:6px;background-color:#F2F2F2;color:#333;font-family:Courier New}.layui-code-h3{padding:0 10px;height:32px;line-height:32px;border-bottom:1px solid #e2e2e2}.layui-code-h3 a{position:absolute;right:10px;top:0;color:#999}.layui-code-view .layui-code-ol{position:relative;overflow:auto}.layui-code-view .layui-code-ol li{position:relative;margin-left:45px;line-height:20px;padding:0 5px;border-left:1px solid #e2e2e2;list-style-type:decimal-leading-zero;*list-style-type:decimal;background-color:#fff}.layui-code-view pre{margin:0}.layui-code-notepad{border:1px solid #0C0C0C;border-left-color:#3F3F3F;background-color:#0C0C0C;color:#C2BE9E}.layui-code-notepad .layui-code-h3{border-bottom:none}.layui-code-notepad .layui-code-ol li{background-color:#3F3F3F;border-left:none}
|
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 5.8 KiB |
After Width: | Height: | Size: 11 KiB |
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue