@@ -1,23 +1,31 @@ | |||
# Compiled class file | |||
*.class | |||
HELP.md | |||
target/ | |||
!.mvn/wrapper/maven-wrapper.jar | |||
!**/src/main/** | |||
!**/src/test/** | |||
# Log file | |||
*.log | |||
### STS ### | |||
.apt_generated | |||
.classpath | |||
.factorypath | |||
.project | |||
.settings | |||
.springBeans | |||
.sts4-cache | |||
# BlueJ files | |||
*.ctxt | |||
### IntelliJ IDEA ### | |||
.idea | |||
*.iws | |||
*.iml | |||
*.ipr | |||
# Mobile Tools for Java (J2ME) | |||
.mtj.tmp/ | |||
### NetBeans ### | |||
/nbproject/private/ | |||
/nbbuild/ | |||
/dist/ | |||
/nbdist/ | |||
/.nb-gradle/ | |||
build/ | |||
# Package Files # | |||
*.jar | |||
*.war | |||
*.nar | |||
*.ear | |||
*.zip | |||
*.tar.gz | |||
*.rar | |||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | |||
hs_err_pid* | |||
### 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(); | |||
} | |||
} |
@@ -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,202 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
<modelVersion>4.0.0</modelVersion> | |||
<parent> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-parent</artifactId> | |||
<version>2.1.2.RELEASE</version> | |||
</parent> | |||
<groupId>com.xdf</groupId> | |||
<artifactId>creative</artifactId> | |||
<version>0.0.1-SNAPSHOT</version> | |||
<name>creative</name> | |||
<description>wenchuangban project for Spring Boot</description> | |||
<properties> | |||
<java.version>1.8</java.version> | |||
</properties> | |||
<dependencies> | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-web</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-test</artifactId> | |||
<scope>test</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-aop</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-tomcat</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-jdbc</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-json</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-validation</artifactId> | |||
</dependency> | |||
<!-- 获取配置文件内容 注入实体get方法--> | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-configuration-processor</artifactId> | |||
<optional>true</optional> | |||
</dependency> | |||
<!-- alibaba start --> | |||
<dependency> | |||
<groupId>com.alibaba</groupId> | |||
<artifactId>druid-spring-boot-starter</artifactId> | |||
<version>1.1.20</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.alibaba</groupId> | |||
<artifactId>fastjson</artifactId> | |||
<version>1.2.62</version> | |||
</dependency> | |||
<!-- swagger start 可通过注解生成接口文档,包括接口名、请求方法、参数、返回信息等等--> | |||
<dependency> | |||
<groupId>io.springfox</groupId> | |||
<artifactId>springfox-swagger2</artifactId> | |||
<version>2.9.2</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>io.springfox</groupId> | |||
<artifactId>springfox-swagger-ui</artifactId> | |||
<version>2.9.2</version> | |||
</dependency> | |||
<!-- apache commons start --> | |||
<dependency> | |||
<groupId>org.apache.commons</groupId> | |||
<artifactId>commons-lang3</artifactId> | |||
<version>3.9</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.commons</groupId> | |||
<artifactId>commons-collections4</artifactId> | |||
<version>4.4</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-net</groupId> | |||
<artifactId>commons-net</artifactId> | |||
<version>3.6</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.commons</groupId> | |||
<artifactId>commons-pool2</artifactId> | |||
<version>2.7.0</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>commons-io</groupId> | |||
<artifactId>commons-io</artifactId> | |||
<version>2.6</version> | |||
</dependency> | |||
<!-- JWT+SHIRO--> | |||
<dependency> | |||
<groupId>com.auth0</groupId> | |||
<artifactId>java-jwt</artifactId> | |||
<version>3.8.3</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.shiro</groupId> | |||
<artifactId>shiro-spring</artifactId> | |||
<version>1.4.0</version> | |||
</dependency> | |||
<!-- mybatis-plus begin --> | |||
<dependency> | |||
<groupId>com.baomidou</groupId> | |||
<artifactId>mybatis-plus-boot-starter</artifactId> | |||
<version>3.1.0</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.apache.velocity</groupId> | |||
<artifactId>velocity</artifactId> | |||
<version>1.7</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>mysql</groupId> | |||
<artifactId>mysql-connector-java</artifactId> | |||
<version>5.1.47</version> | |||
</dependency> | |||
<!-- 对象属性复制 --> | |||
<dependency> | |||
<groupId>org.mapstruct</groupId> | |||
<artifactId>mapstruct</artifactId> | |||
<version>1.3.0.Final</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.mapstruct</groupId> | |||
<artifactId>mapstruct-processor</artifactId> | |||
<version>1.3.0.Final</version> | |||
<scope>provided</scope> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.projectlombok</groupId> | |||
<artifactId>lombok</artifactId> | |||
<optional>true</optional> | |||
</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> | |||
<dependency> | |||
<groupId>junit</groupId> | |||
<artifactId>junit</artifactId> | |||
<version>4.12</version> | |||
<scope>test</scope> | |||
</dependency> | |||
<!-- 分页支持pageHelper --> | |||
</dependencies> | |||
<build> | |||
<finalName>cultural_creative_server</finalName> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-maven-plugin</artifactId> | |||
</plugin> | |||
<plugin> | |||
<groupId>org.apache.maven.plugins</groupId> | |||
<artifactId>maven-resources-plugin</artifactId> | |||
<version>3.0.2</version> | |||
<configuration> | |||
<encoding>UTF-8</encoding> | |||
</configuration> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
</project> |
@@ -0,0 +1,26 @@ | |||
package com.xdf.creative; | |||
import org.mybatis.spring.annotation.MapperScan; | |||
import org.springframework.boot.SpringApplication; | |||
import org.springframework.boot.autoconfigure.SpringBootApplication; | |||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | |||
import org.springframework.boot.web.servlet.ServletComponentScan; | |||
import org.springframework.context.annotation.ComponentScan; | |||
import org.springframework.transaction.annotation.EnableTransactionManagement; | |||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
@EnableConfigurationProperties | |||
@EnableSwagger2 | |||
@ComponentScan(value = "com.xdf.**.**") | |||
@MapperScan({"com.xdf.creative.**.mapper"}) | |||
@ServletComponentScan | |||
@EnableTransactionManagement | |||
@SpringBootApplication | |||
public class CreativeApplication { | |||
public static void main(String[] args) { | |||
SpringApplication.run(CreativeApplication.class, args); | |||
} | |||
} |
@@ -0,0 +1,37 @@ | |||
package com.xdf.creative.base.controller; | |||
import com.baomidou.mybatisplus.extension.api.ApiController; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.web.context.request.RequestContextHolder; | |||
import org.springframework.web.context.request.ServletRequestAttributes; | |||
import javax.servlet.http.HttpServletRequest; | |||
import javax.servlet.http.HttpServletResponse; | |||
/** | |||
* @author DeanYe | |||
* @date 2018-11-08 | |||
*/ | |||
@Slf4j | |||
public abstract class BaseController extends ApiController { | |||
/** | |||
* 获取当前请求 | |||
* | |||
* @return request | |||
*/ | |||
public HttpServletRequest getRequest() { | |||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
} | |||
/** | |||
* 获取当前请求 | |||
* | |||
* @return response | |||
*/ | |||
public HttpServletResponse getResponse() { | |||
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse(); | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
package com.xdf.creative.base.entity; | |||
import io.swagger.annotations.ApiModel; | |||
import java.io.Serializable; | |||
/** | |||
* 实体父类 | |||
* | |||
* @author DeanYe | |||
* @date 2018-11-08 | |||
*/ | |||
@ApiModel("BaseEntity") | |||
public abstract class BaseEntity implements Serializable { | |||
} |
@@ -0,0 +1,20 @@ | |||
package com.xdf.creative.base.params; | |||
import io.swagger.annotations.ApiModel; | |||
import lombok.Data; | |||
import javax.validation.constraints.NotNull; | |||
import java.io.Serializable; | |||
/** | |||
* @author DeanYe | |||
* @date 2018-11-08 | |||
*/ | |||
@Data | |||
@ApiModel("ID参数") | |||
public class IdParam implements Serializable { | |||
private static final long serialVersionUID = -5353973980674510450L; | |||
@NotNull(message = "ID不能为空") | |||
private Long id; | |||
} |
@@ -0,0 +1,32 @@ | |||
package com.xdf.creative.base.params; | |||
import com.xdf.creative.constant.CommonConstant; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import java.io.Serializable; | |||
/** | |||
* 查询参数 | |||
*/ | |||
@Data | |||
@ApiModel("查询参数对象") | |||
public abstract class QueryParam implements Serializable { | |||
private static final long serialVersionUID = -3263921252635611410L; | |||
@ApiModelProperty(value = "页码,默认为1") | |||
private Integer pageNum = CommonConstant.DEFAULT_PAGE_INDEX; | |||
@ApiModelProperty(value = "页大小,默认为10") | |||
private Integer pageSize = CommonConstant.DEFAULT_PAGE_SIZE; | |||
// @ApiModelProperty(value = "排序字段") | |||
// private String[] order = {"create_time"}; | |||
// @ApiModelProperty(value = "排序类型默认降序 DESC/ASC") | |||
// private boolean[] doAsc = {CommonConstant.DEFAULT_PAGE_ORDER_TYPE}; | |||
@ApiModelProperty(value = "排序字段") | |||
private String[] order = {}; | |||
@ApiModelProperty(value = "排序类型默认降序 DESC/ASC") | |||
private boolean[] doAsc = {}; | |||
} |
@@ -0,0 +1,58 @@ | |||
package com.xdf.creative.base.params.creative; | |||
import com.baomidou.mybatisplus.annotation.IdType; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.xdf.creative.base.params.QueryParam; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import javax.validation.constraints.NotNull; | |||
import java.util.Date; | |||
/** | |||
* <p> | |||
* 操作日志 查询参数对象 | |||
* </p> | |||
* | |||
* @author lgw | |||
* @date 2020-03-02 | |||
*/ | |||
@Data | |||
@Accessors(chain = true) | |||
@EqualsAndHashCode(callSuper = true) | |||
@ApiModel(value = "SysOperationLogQueryParam对象", description = "操作日志查询参数") | |||
public class SysOperationLogQueryParam extends QueryParam { | |||
private static final long serialVersionUID = 1L; | |||
@ApiModelProperty(value = "用户操作日志主键") | |||
@TableId(value = "id", type = IdType.AUTO) | |||
@NotNull(message = "用户操作日志主键不能为空") | |||
private Long id; | |||
@ApiModelProperty(value = "日志名称") | |||
private String logName; | |||
@ApiModelProperty(value = "用户id") | |||
private Long userId; | |||
@ApiModelProperty(value = "api名称") | |||
private String api; | |||
@ApiModelProperty(value = "方法名称") | |||
private String method; | |||
@ApiModelProperty(value = "创建时间") | |||
private Date createTime; | |||
@ApiModelProperty(value = "是否执行成功(0失败1成功)") | |||
private Integer succeed; | |||
@ApiModelProperty(value = "具体消息备注") | |||
private String detail; | |||
} |
@@ -0,0 +1,47 @@ | |||
package com.xdf.creative.base.params.creative; | |||
import com.baomidou.mybatisplus.annotation.IdType; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.xdf.creative.base.params.QueryParam; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
/** | |||
* <p> | |||
* 全国行政区域[sys_region] 查询参数对象 | |||
* </p> | |||
* | |||
* @author DeanYe | |||
* @date 2019-11-06 | |||
*/ | |||
@Data | |||
@Accessors(chain = true) | |||
@EqualsAndHashCode(callSuper = true) | |||
@ApiModel(value = "SysRegionQueryParam对象", description = "全国行政区域[sys_region]查询参数") | |||
public class SysRegionQueryParam extends QueryParam { | |||
private static final long serialVersionUID = 1L; | |||
@ApiModelProperty(value = "主键ID") | |||
@TableId(value = "id", type = IdType.AUTO) | |||
private Long id; | |||
@ApiModelProperty(value = "行政区代码") | |||
private String regionId; | |||
@ApiModelProperty(value = "行政区域名称") | |||
private String regionName; | |||
@ApiModelProperty(value = "上级行政区域") | |||
private String parRegionId; | |||
@ApiModelProperty(value = "值:0、草稿 1、提交") | |||
private Integer state; | |||
private String descript; | |||
} |
@@ -0,0 +1,23 @@ | |||
package com.xdf.creative.base.service; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
/** | |||
* | |||
* @param <T> | |||
*/ | |||
public interface BaseService<T> extends IService<T> { | |||
// Long getUserId(); | |||
// | |||
// Long getOrganizeId(); | |||
// | |||
// Integer getOrganizeType(); | |||
// | |||
// String getRegionId(); | |||
// | |||
// boolean verifyUserPermission(Long userId); | |||
// | |||
// boolean verifyOrganizePermission(Long organizeId); | |||
} |
@@ -0,0 +1,109 @@ | |||
package com.xdf.creative.base.service.impl; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.xdf.creative.base.params.QueryParam; | |||
import com.xdf.creative.base.service.BaseService; | |||
import com.xdf.creative.util.CollectionTools; | |||
/** | |||
* | |||
* @param <M> | |||
* @param <T> | |||
*/ | |||
public abstract class BaseServiceImpl<M extends BaseMapper<T>, T> extends ServiceImpl<M, T> implements BaseService<T> { | |||
// @Autowired | |||
// private JwtTokenUtil jwtTokenUtil; | |||
// @Autowired | |||
// private JwtUtil jwtUtil; | |||
/** | |||
* 分页排序设置 | |||
* 默认按创建时间Desc降序排列 | |||
* | |||
* @param queryParam | |||
* @return | |||
*/ | |||
protected Page setPageParam(QueryParam queryParam) { | |||
Page page = new Page(); | |||
page.setCurrent(queryParam.getPageNum()); | |||
page.setSize(queryParam.getPageSize()); | |||
if (CollectionTools.isNoEmptyArr(queryParam.getOrder())) { | |||
String[] ascArray = new String[queryParam.getOrder().length]; | |||
String[] descArray = new String[queryParam.getOrder().length]; | |||
int ascIndex = 0; | |||
int descIndex = 0; | |||
for (int i = 0; i < queryParam.getOrder().length; i++) { | |||
boolean asc = false; | |||
if (queryParam.getOrder().length == queryParam.getDoAsc().length) { | |||
asc = queryParam.getDoAsc()[i]; | |||
} else if (1 == queryParam.getDoAsc().length) { | |||
asc = queryParam.getDoAsc()[0]; | |||
} | |||
if (asc) { | |||
ascArray[ascIndex] = queryParam.getOrder()[i]; | |||
ascIndex++; | |||
} else { | |||
descArray[descIndex] = queryParam.getOrder()[i]; | |||
descIndex++; | |||
} | |||
} | |||
if (descArray.length > 0) { | |||
page.setDesc(descArray); | |||
} | |||
if (ascArray.length > 0) { | |||
page.setAsc(ascArray); | |||
} | |||
} | |||
return page; | |||
} | |||
protected Page setPage(QueryParam queryParam) { | |||
Page page = new Page<>(queryParam.getPageNum(), queryParam.getPageSize(), true); | |||
return page; | |||
} | |||
// @Override | |||
// public Long getUserId() { | |||
// String token = jwtTokenUtil.getToken(); | |||
// return jwtUtil.getUserId(token); | |||
// } | |||
// | |||
// @Override | |||
// public Integer getOrganizeType() { | |||
// String token = jwtTokenUtil.getToken(); | |||
// return jwtUtil.getOrganizeType(token); | |||
// } | |||
// | |||
// @Override | |||
// public Long getOrganizeId() { | |||
// String token = jwtTokenUtil.getToken(); | |||
// return jwtUtil.getOrganizeId(token); | |||
// } | |||
// | |||
// @Override | |||
// public String getRegionId() { | |||
// String token = jwtTokenUtil.getToken(); | |||
// return jwtUtil.getRegionId(token); | |||
// } | |||
// | |||
// @Override | |||
// public boolean verifyUserPermission(Long userId) { | |||
// boolean passageFlag = false; | |||
// if (getUserId() == userId || (getUserId() == 1 && getOrganizeId() == 1)) { | |||
// passageFlag = true; | |||
// } | |||
// return passageFlag; | |||
// } | |||
// | |||
// @Override | |||
// public boolean verifyOrganizePermission(Long organizeId) { | |||
// boolean passageFlag = false; | |||
// if (getOrganizeId() == organizeId || (getUserId() == 1 && getOrganizeId() == 1)) { | |||
// passageFlag = true; | |||
// } | |||
// return passageFlag; | |||
// } | |||
} |
@@ -0,0 +1,26 @@ | |||
package com.xdf.creative.base.vo; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
/** | |||
* <p> | |||
* 公共ID-NAME-VO对象 | |||
* </p> | |||
* | |||
* @author DeanYe | |||
* @since 2018-11-08 | |||
*/ | |||
@ApiModel("ID-NAME-VO") | |||
@Data | |||
public class CommonIdName { | |||
@ApiModelProperty("id") | |||
private String id; | |||
@ApiModelProperty("名称") | |||
private String name; | |||
} |
@@ -0,0 +1,49 @@ | |||
package com.xdf.creative.base.vo.creative; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import lombok.experimental.Accessors; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* <p> | |||
* 操作日志 查询结果对象 | |||
* </p> | |||
* | |||
* @author lgw | |||
* @date 2020-03-02 | |||
*/ | |||
@Data | |||
@Accessors(chain = true) | |||
@ApiModel(value = "SysOperationLogQueryVo对象", description = "操作日志查询参数") | |||
public class SysOperationLogQueryVo implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
@ApiModelProperty(value = "用户操作日志主键") | |||
private Long id; | |||
@ApiModelProperty(value = "日志名称") | |||
private String logName; | |||
@ApiModelProperty(value = "用户id") | |||
private Long userId; | |||
@ApiModelProperty(value = "api名称") | |||
private String api; | |||
@ApiModelProperty(value = "方法名称") | |||
private String method; | |||
@ApiModelProperty(value = "创建时间") | |||
private Date createTime; | |||
@ApiModelProperty(value = "是否执行成功(0失败1成功)") | |||
private Integer succeed; | |||
@ApiModelProperty(value = "具体消息备注") | |||
private String detail; | |||
} |
@@ -0,0 +1,41 @@ | |||
package com.xdf.creative.base.vo.creative; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import lombok.experimental.Accessors; | |||
import java.io.Serializable; | |||
/** | |||
* <p> | |||
* 全国行政区域[sys_region] 查询结果对象 | |||
* </p> | |||
* | |||
* @author DeanYe | |||
* @date 2019-11-06 | |||
*/ | |||
@Data | |||
@Accessors(chain = true) | |||
@ApiModel(value = "SysRegionQueryVo对象", description = "全国行政区域[sys_region]查询参数") | |||
public class SysRegionQueryVo implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
@ApiModelProperty(value = "主键ID") | |||
private Long id; | |||
@ApiModelProperty(value = "行政区代码") | |||
private String regionId; | |||
@ApiModelProperty(value = "行政区域名称") | |||
private String regionName; | |||
@ApiModelProperty(value = "上级行政区域") | |||
private String parRegionId; | |||
@ApiModelProperty(value = "值:0、草稿 1、提交") | |||
private Integer state; | |||
private String descript; | |||
} |
@@ -0,0 +1,19 @@ | |||
package com.xdf.creative.config; | |||
import org.springframework.context.annotation.Configuration; | |||
import org.springframework.web.servlet.config.annotation.CorsRegistry; | |||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | |||
@Configuration | |||
public class CorsConfig implements WebMvcConfigurer { | |||
@Override | |||
public void addCorsMappings(CorsRegistry registry) { | |||
registry.addMapping("/**") | |||
.allowedOrigins("*") | |||
.allowCredentials(true) | |||
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS") | |||
.maxAge(3600); | |||
} | |||
} |
@@ -0,0 +1,25 @@ | |||
package com.xdf.creative.config; | |||
import com.baomidou.mybatisplus.core.injector.ISqlInjector; | |||
import com.baomidou.mybatisplus.extension.injector.LogicSqlInjector; | |||
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor; | |||
import org.springframework.context.annotation.Bean; | |||
import org.springframework.context.annotation.Configuration; | |||
@Configuration | |||
public class MybatisPlusConfig { | |||
/** | |||
* 配置分页 | |||
*/ | |||
@Bean | |||
public PaginationInterceptor paginationInterceptor() { | |||
return new PaginationInterceptor(); | |||
} | |||
@Bean | |||
public ISqlInjector sqlInjector() { | |||
return new LogicSqlInjector(); | |||
} | |||
} |
@@ -0,0 +1,108 @@ | |||
package com.xdf.creative.constant; | |||
/** | |||
* 常量 | |||
* | |||
*/ | |||
public interface CommonConstant { | |||
/** | |||
* 默认页码为1 | |||
*/ | |||
Integer DEFAULT_PAGE_INDEX = 1; | |||
/** | |||
* 默认页大小为10 | |||
*/ | |||
Integer DEFAULT_PAGE_SIZE = 10; | |||
/** | |||
* 默认降序排序 | |||
*/ | |||
boolean DEFAULT_PAGE_ORDER_TYPE = false; | |||
/** | |||
* 登录用户 | |||
*/ | |||
String LOGIN_SYS_USER = "loginSysUser"; | |||
/** | |||
* JWT用户名 | |||
*/ | |||
String JWT_USERID = "userId"; | |||
/** | |||
* 登录类型 | |||
*/ | |||
String JWT_LOGINTYPE = "loginType"; | |||
/** | |||
* 登录组织id | |||
*/ | |||
String JWT_ORGANIZE = "organizeId"; | |||
/** | |||
* 登录组织辖区id | |||
*/ | |||
String JWT_REGIONID = "regionId"; | |||
/** | |||
* 登录组织类型 0 普通用户 1、企业 2、金融机构 3、投资机构 4、服务机构 5、园区 6、协(商会) 7、项目管理公司 8 区文创办 9 市文创办 99 公司后台管理 | |||
*/ | |||
String JWT_ORGANIZETYPE = "organizeType"; | |||
/** | |||
* JWT用户名 | |||
*/ | |||
String JWT_USERNAME = "username"; | |||
/** | |||
* JWT刷新新token响应状态码 | |||
*/ | |||
int JWT_REFRESH_TOKEN_CODE = 4460; | |||
/** | |||
* JWT刷新新token响应状态码, | |||
* Redis中不存在,但jwt未过期,不生成新的token,返回4461状态码 | |||
*/ | |||
int JWT_INVALID_TOKEN_CODE = 4461; | |||
/** | |||
* 初始密码 | |||
*/ | |||
String INIT_PWD = "123456"; | |||
/** | |||
* 默认头像 | |||
*/ | |||
String DEFAULT_HEAD_URL = ""; | |||
/** | |||
* 管理员角色名称 | |||
*/ | |||
String ADMIN_ROLE_NAME = "管理员"; | |||
String ADMIN_LOGIN = "adminLogin"; | |||
/** | |||
* 验证码token | |||
*/ | |||
String VERIFY_TOKEN = "verifyToken"; | |||
/** | |||
* 图片 | |||
*/ | |||
String IMAGE = "image"; | |||
/** | |||
* JPEG | |||
*/ | |||
String JPEG = "JPEG"; | |||
/** | |||
* base64前缀 | |||
*/ | |||
String BASE64_PREFIX = "data:image/png;base64,"; | |||
} |
@@ -0,0 +1,79 @@ | |||
package com.xdf.creative.enums; | |||
/** | |||
* <p> | |||
* REST API 响应码 | |||
* </p> | |||
* | |||
* @author DeanYe | |||
* @since 2018-11-08 | |||
*/ | |||
public enum ApiCode { | |||
SUCCESS(200, "操作成功"), | |||
TOKEN_IS_EMPTY(4400, "TOKEN不能为空"), | |||
UNAUTHORIZED(4401, "非法访问"), | |||
NOT_PERMISSION(4403, "没有权限"), | |||
NOT_FOUND(4404, "你请求的资源不存在"), | |||
USERNAME_ERROR(4405, "用户名不正确"), | |||
PASSWORD_ERROR(4406, "密码不正确"), | |||
USER_DISABLE(4407, "用户不可用"), | |||
VERIFICATION_CODE_ERROR(4408, "验证码不正确"), | |||
TOKEN_INVALID(4409, "无效令牌"), | |||
REFRESH_TOKEN_ERROR(4410, "刷新令牌异常"), | |||
FAIL(5500, "操作失败"), | |||
LOGIN_EXCEPTION(4000, "登陆失败"), | |||
SYSTEM_EXCEPTION(5000, "系统异常!"), | |||
PARAMETER_EXCEPTION(5001, "请求参数校验异常"), | |||
PARAMETER_PARSE_EXCEPTION(5002, "请求参数解析异常"), | |||
HTTP_MEDIA_TYPE_EXCEPTION(5003, "HTTP Media 类型异常"), | |||
SERVICE_EXCEPTION(5004, "RPC下游服务异常"), | |||
; | |||
private final int code; | |||
private final String msg; | |||
ApiCode(final int code, final String msg) { | |||
this.code = code; | |||
this.msg = msg; | |||
} | |||
public static ApiCode getApiCode(int code) { | |||
ApiCode[] ecs = ApiCode.values(); | |||
for (ApiCode ec : ecs) { | |||
if (ec.getCode() == code) { | |||
return ec; | |||
} | |||
} | |||
return SUCCESS; | |||
} | |||
public int getCode() { | |||
return code; | |||
} | |||
public String getMsg() { | |||
return msg; | |||
} | |||
} |
@@ -0,0 +1,56 @@ | |||
package com.xdf.creative.enums; | |||
/** | |||
* 命名表名+功能 | |||
* <p> | |||
* 六位代码 1、admin后台管理 2、文促会官网 3、业务服务bus 4、投融资 5、 | |||
* 末位已数据库表排序 | |||
*/ | |||
public enum StatusCode { | |||
//修改数据 传入主键查不到数据 | |||
FORM_SUBMIT_UPDATE_VERIFY(000001, "当前数据不存在或已删除,请刷新后再试!"), | |||
//修改数据未传主键id | |||
FORM_SUBMIT_ID_VERIFY(000002, "未知数据标识,请重新选择!"), | |||
AUTH_UPDATE_VERIFY_ERROR(000003, "存在非法访问,请刷新后再试!"), | |||
FORM_AUDIT_STATE_VERIFY(000004, "只能操作待审核的数据!"), | |||
FORM_UPDATE_STATE_VERIFY(000005, "只能操作草稿状态的数据!"), | |||
FORM_AUTH_UPDATE_VERIFY_ERROR(000006, "存在非法更新!"), | |||
SMS_SEND_VERIFICATION_CODE_SUCCESS(20000, "短信发送成功"), | |||
SMS_SEND_VERIFICATION_CODE_FAIL(20001, "短信发送失败"), | |||
SMS_MESSAGE_VERIFICATION_CODE_VERIFY(20002, "验证码已过期!"), | |||
SMS_MESSAGE_VERIFICATION_CODE_ERROR(20003, "验证码错误!"), | |||
; | |||
private int status; | |||
private String msg; | |||
StatusCode(int status, String msg) { | |||
this.status = status; | |||
this.msg = msg; | |||
} | |||
public boolean isSuccess() { | |||
return getStatus() == 10000; | |||
} | |||
public int getStatus() { | |||
return status; | |||
} | |||
public String getCode() { | |||
return name(); | |||
} | |||
public String getMsg() { | |||
return String.format(msg, ""); | |||
} | |||
public String getMsg(Object... format) { | |||
if (format == null) { | |||
return getMsg(); | |||
} | |||
return String.format(msg, format); | |||
} | |||
} |
@@ -0,0 +1,90 @@ | |||
package com.xdf.creative.module.controller; | |||
import com.xdf.creative.base.controller.BaseController; | |||
import com.xdf.creative.base.params.IdParam; | |||
import com.xdf.creative.base.params.creative.SysOperationLogQueryParam; | |||
import com.xdf.creative.base.vo.creative.SysOperationLogQueryVo; | |||
import com.xdf.creative.module.entity.SysOperationLog; | |||
import com.xdf.creative.module.service.SysOperationLogService; | |||
import com.xdf.creative.util.page.ApiResult; | |||
import com.xdf.creative.util.page.PageTool; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import javax.validation.Valid; | |||
/** | |||
* <p> | |||
* 操作日志 前端控制器 | |||
* </p> | |||
* | |||
* @author lgw | |||
* @since 2020-03-02 | |||
*/ | |||
@Slf4j | |||
@RestController | |||
@RequestMapping("/sysOperationLog") | |||
@Api("操作日志 API") | |||
public class SysOperationLogController extends BaseController { | |||
@Autowired | |||
private SysOperationLogService sysOperationLogService; | |||
/** | |||
* 添加操作日志 | |||
*/ | |||
@PostMapping("/add") | |||
@ApiOperation(value = "添加SysOperationLog对象", notes = "添加操作日志", response = ApiResult.class) | |||
public ApiResult<Boolean> addSysOperationLog(@Valid @RequestBody SysOperationLog sysOperationLog) throws Exception { | |||
boolean flag = sysOperationLogService.save(sysOperationLog); | |||
return ApiResult.result(flag); | |||
} | |||
/** | |||
* 修改操作日志 | |||
*/ | |||
@PostMapping("/update") | |||
@ApiOperation(value = "修改SysOperationLog对象", notes = "修改操作日志", response = ApiResult.class) | |||
public ApiResult<Boolean> updateSysOperationLog(@Valid @RequestBody SysOperationLog sysOperationLog) throws Exception { | |||
boolean flag = sysOperationLogService.updateById(sysOperationLog); | |||
return ApiResult.result(flag); | |||
} | |||
/** | |||
* 删除操作日志 | |||
*/ | |||
@PostMapping("/delete") | |||
@ApiOperation(value = "删除SysOperationLog对象", notes = "删除操作日志", response = ApiResult.class) | |||
public ApiResult<Boolean> deleteSysOperationLog(@Valid @RequestBody IdParam idParam) throws Exception { | |||
boolean flag = sysOperationLogService.removeById(idParam.getId()); | |||
return ApiResult.result(flag); | |||
} | |||
/** | |||
* 获取操作日志 | |||
*/ | |||
@PostMapping("/info") | |||
@ApiOperation(value = "获取SysOperationLog对象详情", notes = "查看操作日志", response = SysOperationLogQueryVo.class) | |||
public ApiResult<SysOperationLogQueryVo> getSysOperationLog(@Valid @RequestBody IdParam idParam) throws Exception { | |||
SysOperationLogQueryVo sysOperationLogQueryVo = sysOperationLogService.getSysOperationLogById(idParam.getId()); | |||
return ApiResult.ok(sysOperationLogQueryVo); | |||
} | |||
/** | |||
* 操作日志分页列表 | |||
*/ | |||
@PostMapping("/getPageList") | |||
@ApiOperation(value = "获取SysOperationLog分页列表", notes = "操作日志分页列表", response = SysOperationLogQueryVo.class) | |||
public ApiResult<PageTool<SysOperationLogQueryVo>> getSysOperationLogPageList(@Valid @RequestBody SysOperationLogQueryParam sysOperationLogQueryParam) throws Exception { | |||
PageTool<SysOperationLogQueryVo> pageList = sysOperationLogService.getSysOperationLogPageList(sysOperationLogQueryParam); | |||
return ApiResult.ok(pageList); | |||
} | |||
} | |||
@@ -0,0 +1,104 @@ | |||
package com.xdf.creative.module.controller; | |||
import com.xdf.creative.base.controller.BaseController; | |||
import com.xdf.creative.base.params.IdParam; | |||
import com.xdf.creative.base.params.creative.SysRegionQueryParam; | |||
import com.xdf.creative.base.vo.creative.SysRegionQueryVo; | |||
import com.xdf.creative.module.entity.SysRegion; | |||
import com.xdf.creative.module.service.SysRegionService; | |||
import com.xdf.creative.support.aop.OperationLogger; | |||
import com.xdf.creative.util.page.ApiResult; | |||
import com.xdf.creative.util.page.PageTool; | |||
import io.swagger.annotations.Api; | |||
import io.swagger.annotations.ApiOperation; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.*; | |||
import javax.validation.Valid; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 全国行政区域[sys_region] 前端控制器 | |||
* </p> | |||
* | |||
* @author DeanYe | |||
* @since 2019-11-06 | |||
*/ | |||
@Slf4j | |||
@RestController | |||
@RequestMapping("/sysRegion") | |||
@Api("全国行政区域[sys_region] API") | |||
public class SysRegionController extends BaseController { | |||
@Autowired | |||
private SysRegionService sysRegionService; | |||
/** | |||
* 添加全国行政区域[sys_region] | |||
* | |||
* @param sysRegion | |||
* @return | |||
* @throws Exception | |||
*/ | |||
@PostMapping("/add") | |||
@ApiOperation(value = "添加SysRegion对象", notes = "添加全国行政区域[sys_region]", response = ApiResult.class) | |||
public ApiResult<Boolean> addSysRegion(@Valid @RequestBody SysRegion sysRegion) throws Exception { | |||
boolean flag = sysRegionService.save(sysRegion); | |||
return ApiResult.result(flag); | |||
} | |||
/** | |||
* 修改全国行政区域[sys_region] | |||
*/ | |||
@PostMapping("/update") | |||
@ApiOperation(value = "修改SysRegion对象", notes = "修改全国行政区域[sys_region]", response = ApiResult.class) | |||
public ApiResult<Boolean> updateSysRegion(@Valid @RequestBody SysRegion sysRegion) throws Exception { | |||
boolean flag = sysRegionService.updateById(sysRegion); | |||
return ApiResult.result(flag); | |||
} | |||
/** | |||
* 删除全国行政区域[sys_region] | |||
*/ | |||
@PostMapping("/delete") | |||
@ApiOperation(value = "删除SysRegion对象", notes = "删除全国行政区域[sys_region]", response = ApiResult.class) | |||
public ApiResult<Boolean> deleteSysRegion(@Valid @RequestBody IdParam idParam) throws Exception { | |||
boolean flag = sysRegionService.removeById(idParam.getId()); | |||
return ApiResult.result(flag); | |||
} | |||
/** | |||
* 获取全国行政区域[sys_region] | |||
*/ | |||
@PostMapping("/info") | |||
@ApiOperation(value = "获取SysRegion对象详情", notes = "查看全国行政区域[sys_region]", response = SysRegionQueryVo.class) | |||
public ApiResult<SysRegionQueryVo> getSysRegion(@Valid @RequestBody IdParam idParam) throws Exception { | |||
SysRegionQueryVo sysRegionQueryVo = sysRegionService.getSysRegionById(idParam.getId()); | |||
return ApiResult.ok(sysRegionQueryVo); | |||
} | |||
/** | |||
* 全国行政区域[sys_region]分页列表 | |||
*/ | |||
@GetMapping("/getPageList") | |||
@ApiOperation(value = "获取SysRegion分页列表", notes = "全国行政区域[sys_region]分页列表", response = SysRegionQueryVo.class) | |||
public ApiResult<PageTool<SysRegionQueryVo>> getSysRegionPageList(@Valid @RequestBody SysRegionQueryParam sysRegionQueryParam) throws Exception { | |||
PageTool<SysRegionQueryVo> pageList = sysRegionService.getSysRegionPageList(sysRegionQueryParam); | |||
return ApiResult.ok(pageList); | |||
} | |||
/** | |||
* 全国行政区域[sys_region]分页列表 | |||
*/ | |||
@OperationLogger(value = "获取SysRegion列表") //这里添加了AOP的自定义注解 | |||
@PostMapping("/getRegionList") | |||
@ApiOperation(value = "获取SysRegion列表", notes = "全国行政区域[sys_region]分页列表", response = SysRegionQueryVo.class) | |||
public ApiResult<List<SysRegionQueryVo>> getSysRegionList(@Valid @RequestBody SysRegionQueryParam sysRegionQueryParam) throws Exception { | |||
return ApiResult.ok(sysRegionService.getSysRegionList(sysRegionQueryParam)); | |||
} | |||
} | |||
@@ -0,0 +1,55 @@ | |||
package com.xdf.creative.module.entity; | |||
import com.baomidou.mybatisplus.annotation.IdType; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.xdf.creative.base.entity.BaseEntity; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import java.util.Date; | |||
/** | |||
* <p> | |||
* 操作日志 | |||
* </p> | |||
* | |||
* @author lgw | |||
* @since 2020-03-02 | |||
*/ | |||
@Data | |||
@Accessors(chain = true) | |||
@EqualsAndHashCode(callSuper = true) | |||
@ApiModel(value = "SysOperationLog对象", description = "操作日志") | |||
public class SysOperationLog extends BaseEntity { | |||
private static final long serialVersionUID = 1L; | |||
@ApiModelProperty(value = "用户操作日志主键") | |||
@TableId(value = "id", type = IdType.AUTO) | |||
private Long id; | |||
@ApiModelProperty(value = "日志名称") | |||
private String logName; | |||
@ApiModelProperty(value = "用户id") | |||
private Long userId; | |||
@ApiModelProperty(value = "api名称") | |||
private String api; | |||
@ApiModelProperty(value = "方法名称") | |||
private String method; | |||
@ApiModelProperty(value = "创建时间") | |||
private Date createTime; | |||
@ApiModelProperty(value = "是否执行成功(0失败1成功)") | |||
private Integer succeed; | |||
@ApiModelProperty(value = "具体消息备注") | |||
private String detail; | |||
} |
@@ -0,0 +1,41 @@ | |||
package com.xdf.creative.module.entity; | |||
import com.baomidou.mybatisplus.annotation.IdType; | |||
import com.baomidou.mybatisplus.annotation.TableId; | |||
import com.xdf.creative.base.entity.BaseEntity; | |||
import io.swagger.annotations.ApiModel; | |||
import io.swagger.annotations.ApiModelProperty; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
/** | |||
* 全国行政区域[sys_region] | |||
*/ | |||
@Data | |||
@Accessors(chain = true) | |||
@EqualsAndHashCode(callSuper = true) | |||
@ApiModel(value = "SysRegion对象", description = "全国行政区域[sys_region]") | |||
public class SysRegion extends BaseEntity { | |||
private static final long serialVersionUID = 1L; | |||
@ApiModelProperty(value = "主键ID") | |||
@TableId(value = "id", type = IdType.AUTO) | |||
private Long id; | |||
@ApiModelProperty(value = "行政区代码") | |||
private String regionId; | |||
@ApiModelProperty(value = "行政区域名称") | |||
private String regionName; | |||
@ApiModelProperty(value = "上级行政区域") | |||
private String parRegionId; | |||
@ApiModelProperty(value = "值:0、草稿 1、提交") | |||
private Integer state; | |||
private String descript; | |||
} |
@@ -0,0 +1,42 @@ | |||
package com.xdf.creative.module.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.xdf.creative.base.params.creative.SysOperationLogQueryParam; | |||
import com.xdf.creative.base.vo.creative.SysOperationLogQueryVo; | |||
import com.xdf.creative.module.entity.SysOperationLog; | |||
import org.apache.ibatis.annotations.Param; | |||
import org.springframework.stereotype.Repository; | |||
import java.io.Serializable; | |||
/** | |||
* <p> | |||
* 操作日志 Mapper 接口 | |||
* </p> | |||
* | |||
* @author lgw | |||
* @since 2020-03-02 | |||
*/ | |||
@Repository | |||
public interface SysOperationLogMapper extends BaseMapper<SysOperationLog> { | |||
/** | |||
* 根据ID获取查询对象 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
SysOperationLogQueryVo getSysOperationLogById(Serializable id); | |||
/** | |||
* 获取分页对象 | |||
* | |||
* @param page | |||
* @param sysOperationLogQueryParam | |||
* @return | |||
*/ | |||
IPage<SysOperationLogQueryVo> getSysOperationLogPageList(@Param("page") Page page, @Param("param") SysOperationLogQueryParam sysOperationLogQueryParam); | |||
} |
@@ -0,0 +1,51 @@ | |||
package com.xdf.creative.module.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.xdf.creative.base.params.creative.SysRegionQueryParam; | |||
import com.xdf.creative.base.vo.creative.SysRegionQueryVo; | |||
import com.xdf.creative.module.entity.SysRegion; | |||
import org.apache.ibatis.annotations.Param; | |||
import org.springframework.stereotype.Repository; | |||
import java.io.Serializable; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 全国行政区域[sys_region] Mapper 接口 | |||
* </p> | |||
* | |||
* @author DeanYe | |||
* @since 2019-11-06 | |||
*/ | |||
@Repository | |||
public interface SysRegionMapper extends BaseMapper<SysRegion> { | |||
/** | |||
* 根据ID获取查询对象 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
SysRegionQueryVo getSysRegionById(Serializable id); | |||
/** | |||
* 获取分页对象 | |||
* | |||
* @param page | |||
* @param sysRegionQueryParam | |||
* @return | |||
*/ | |||
IPage<SysRegionQueryVo> getSysRegionPageList(@Param("page") Page page, @Param("param") SysRegionQueryParam sysRegionQueryParam); | |||
/** | |||
* 不分页查询 | |||
* | |||
* @param sysRegionQueryParam | |||
* @return | |||
*/ | |||
List<SysRegionQueryVo> getSysRegionList(@Param("param") SysRegionQueryParam sysRegionQueryParam); | |||
} |
@@ -0,0 +1,37 @@ | |||
package com.xdf.creative.module.service; | |||
import com.xdf.creative.base.params.creative.SysOperationLogQueryParam; | |||
import com.xdf.creative.base.service.BaseService; | |||
import com.xdf.creative.base.vo.creative.SysOperationLogQueryVo; | |||
import com.xdf.creative.module.entity.SysOperationLog; | |||
import com.xdf.creative.util.page.PageTool; | |||
import java.io.Serializable; | |||
/** | |||
* <p> | |||
* 操作日志 服务类 | |||
* </p> | |||
* | |||
* @author lgw | |||
* @since 2020-03-02 | |||
*/ | |||
public interface SysOperationLogService extends BaseService<SysOperationLog> { | |||
/** | |||
* 根据ID获取查询对象 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
SysOperationLogQueryVo getSysOperationLogById(Serializable id) throws Exception; | |||
/** | |||
* 获取分页对象 | |||
* | |||
* @param sysOperationLogQueryParam | |||
* @return | |||
*/ | |||
PageTool<SysOperationLogQueryVo> getSysOperationLogPageList(SysOperationLogQueryParam sysOperationLogQueryParam) throws Exception; | |||
} |
@@ -0,0 +1,46 @@ | |||
package com.xdf.creative.module.service; | |||
import com.xdf.creative.base.params.creative.SysRegionQueryParam; | |||
import com.xdf.creative.base.service.BaseService; | |||
import com.xdf.creative.base.vo.creative.SysRegionQueryVo; | |||
import com.xdf.creative.module.entity.SysRegion; | |||
import com.xdf.creative.util.page.PageTool; | |||
import java.io.Serializable; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 全国行政区域[sys_region] 服务类 | |||
* </p> | |||
* | |||
* @author DeanYe | |||
* @since 2019-11-06 | |||
*/ | |||
public interface SysRegionService extends BaseService<SysRegion> { | |||
/** | |||
* 根据ID获取查询对象 | |||
* | |||
* @param id | |||
* @return | |||
*/ | |||
SysRegionQueryVo getSysRegionById(Serializable id) throws Exception; | |||
/** | |||
* 获取分页对象 | |||
* | |||
* @param sysRegionQueryParam | |||
* @return | |||
*/ | |||
PageTool<SysRegionQueryVo> getSysRegionPageList(SysRegionQueryParam sysRegionQueryParam) throws Exception; | |||
/** | |||
* 不分页查询 | |||
* | |||
* @param sysRegionQueryParam | |||
* @return | |||
*/ | |||
List<SysRegionQueryVo> getSysRegionList(SysRegionQueryParam sysRegionQueryParam); | |||
} |
@@ -0,0 +1,48 @@ | |||
package com.xdf.creative.module.service.impl; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.xdf.creative.base.params.creative.SysOperationLogQueryParam; | |||
import com.xdf.creative.base.service.impl.BaseServiceImpl; | |||
import com.xdf.creative.base.vo.creative.SysOperationLogQueryVo; | |||
import com.xdf.creative.module.entity.SysOperationLog; | |||
import com.xdf.creative.module.mapper.SysOperationLogMapper; | |||
import com.xdf.creative.module.service.SysOperationLogService; | |||
import com.xdf.creative.util.page.PageTool; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.io.Serializable; | |||
/** | |||
* <p> | |||
* 操作日志 服务实现类 | |||
* </p> | |||
* | |||
* @author lgw | |||
* @since 2020-03-02 | |||
*/ | |||
@Slf4j | |||
@Service | |||
@Transactional(rollbackFor = Exception.class) | |||
public class SysOperationLogServiceImpl extends BaseServiceImpl<SysOperationLogMapper, SysOperationLog> implements SysOperationLogService { | |||
@Autowired | |||
private SysOperationLogMapper sysOperationLogMapper; | |||
@Override | |||
public SysOperationLogQueryVo getSysOperationLogById(Serializable id) throws Exception { | |||
return sysOperationLogMapper.getSysOperationLogById(id); | |||
} | |||
@Override | |||
public PageTool<SysOperationLogQueryVo> getSysOperationLogPageList(SysOperationLogQueryParam sysOperationLogQueryParam) throws Exception { | |||
Page page = setPageParam(sysOperationLogQueryParam); | |||
IPage<SysOperationLogQueryVo> iPage = sysOperationLogMapper.getSysOperationLogPageList(page, sysOperationLogQueryParam); | |||
return new PageTool(iPage); | |||
} | |||
} |
@@ -0,0 +1,58 @@ | |||
package com.xdf.creative.module.service.impl; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.xdf.creative.base.params.creative.SysRegionQueryParam; | |||
import com.xdf.creative.base.service.impl.BaseServiceImpl; | |||
import com.xdf.creative.base.vo.creative.SysRegionQueryVo; | |||
import com.xdf.creative.module.entity.SysRegion; | |||
import com.xdf.creative.module.mapper.SysRegionMapper; | |||
import com.xdf.creative.module.service.SysRegionService; | |||
import com.xdf.creative.util.page.PageTool; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import java.io.Serializable; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 全国行政区域[sys_region] 服务实现类 | |||
* </p> | |||
* | |||
* @author DeanYe | |||
* @since 2019-11-06 | |||
*/ | |||
@Slf4j | |||
@Service | |||
@Transactional(rollbackFor = Exception.class) | |||
public class SysRegionServiceImpl extends BaseServiceImpl<SysRegionMapper, SysRegion> implements SysRegionService { | |||
@Autowired | |||
private SysRegionMapper sysRegionMapper; | |||
@Override | |||
public SysRegionQueryVo getSysRegionById(Serializable id) throws Exception { | |||
return sysRegionMapper.getSysRegionById(id); | |||
} | |||
/** | |||
* 不分页查询 | |||
* | |||
* @param sysRegionQueryParam | |||
* @return | |||
* @throws Exception | |||
*/ | |||
@Override | |||
public List<SysRegionQueryVo> getSysRegionList(SysRegionQueryParam sysRegionQueryParam) { | |||
return sysRegionMapper.getSysRegionList(sysRegionQueryParam); | |||
} | |||
@Override | |||
public PageTool<SysRegionQueryVo> getSysRegionPageList(SysRegionQueryParam sysRegionQueryParam) throws Exception { | |||
Page page = setPageParam(sysRegionQueryParam); | |||
IPage<SysRegionQueryVo> iPage = sysRegionMapper.getSysRegionPageList(page, sysRegionQueryParam); | |||
return new PageTool(iPage); | |||
} | |||
} |
@@ -0,0 +1,4 @@ | |||
package com.xdf.creative.module; | |||
public class test { | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.xdf.creative.support.aop; | |||
import java.lang.annotation.ElementType; | |||
import java.lang.annotation.Retention; | |||
import java.lang.annotation.RetentionPolicy; | |||
import java.lang.annotation.Target; | |||
/** | |||
* @author : lgw | |||
* @date : 17:55 2020/3/2 | |||
*/ | |||
@Retention(RetentionPolicy.RUNTIME)//注解会在class中存在,运行时可通过反射获取 | |||
@Target(ElementType.METHOD)//目标是方法 | |||
public @interface OperationLogger { | |||
String value() default ""; | |||
} |
@@ -0,0 +1,78 @@ | |||
package com.xdf.creative.support.aop; | |||
import com.alibaba.fastjson.JSON; | |||
import com.xdf.creative.module.entity.SysOperationLog; | |||
import com.xdf.creative.module.service.SysOperationLogService; | |||
import com.xdf.creative.util.IpUtil; | |||
import org.aspectj.lang.JoinPoint; | |||
import org.aspectj.lang.annotation.AfterReturning; | |||
import org.aspectj.lang.annotation.Aspect; | |||
import org.aspectj.lang.annotation.Pointcut; | |||
import org.aspectj.lang.reflect.MethodSignature; | |||
import org.slf4j.Logger; | |||
import org.slf4j.LoggerFactory; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Component; | |||
import javax.servlet.http.HttpServletRequest; | |||
import java.lang.reflect.Method; | |||
import java.util.Date; | |||
/** | |||
* @author : lgw | |||
* @date : 17:57 2020/3/2 | |||
*/ | |||
@Aspect | |||
@Component | |||
public class SysOperationLogAspect { | |||
@Autowired | |||
private SysOperationLogService sysOperationLogService; | |||
private static final Logger logger = LoggerFactory.getLogger(SysOperationLogAspect.class); | |||
//定义切点 @Pointcut | |||
//在注解的位置切入代码 | |||
@Pointcut("@annotation( com.xdf.creative.support.aop.OperationLogger)") | |||
public void logPoinCut() { | |||
} | |||
//切面 配置通知 | |||
@AfterReturning("logPoinCut()") | |||
public void saveSysLog(JoinPoint joinPoint) { | |||
System.out.println("切面。。。。。"); | |||
//保存日志 | |||
SysOperationLog sysOperationLog = new SysOperationLog(); | |||
//从切面织入点处通过反射机制获取织入点处的方法 | |||
MethodSignature signature = (MethodSignature) joinPoint.getSignature(); | |||
//获取切入点所在的方法 | |||
Method method = signature.getMethod(); | |||
//获取操作 | |||
OperationLogger operationLogger = method.getAnnotation(OperationLogger.class); | |||
if (operationLogger != null) { | |||
String value = operationLogger.value(); | |||
sysOperationLog.setDetail(value);//保存获取的操作 | |||
} | |||
//获取请求的类名 | |||
String className = joinPoint.getTarget().getClass().getName(); | |||
//获取请求的方法名 | |||
String methodName = method.getName(); | |||
sysOperationLog.setMethod(className + "." + methodName); | |||
//请求的参数 | |||
Object[] args = joinPoint.getArgs(); | |||
//将参数所在的数组转换成json | |||
// String params = JSON.toJSONString(args); | |||
// sysOperationLog.setParams(params); | |||
sysOperationLog.setCreateTime(new Date()); | |||
//获取用户名 | |||
// sysOperationLog.setUserId(ShiroUtils.getUserEntity().getUsername()); | |||
sysOperationLog.setUserId((long)1); | |||
//获取用户ip地址 | |||
sysOperationLog.setApi(IpUtil.getRequestIp()); | |||
//调用service保存SysLog实体类到数据库 | |||
sysOperationLogService.save(sysOperationLog); | |||
} | |||
} |
@@ -0,0 +1,17 @@ | |||
package com.xdf.creative.util; | |||
public class CollectionTools { | |||
public static boolean isEmptyArr(String[] arr) { | |||
if (arr == null || arr.length == 0) { | |||
return true; | |||
} | |||
return false; | |||
} | |||
public static boolean isNoEmptyArr(String[] arr) { | |||
if (arr != null && arr.length != 0) { | |||
return true; | |||
} | |||
return false; | |||
} | |||
} |
@@ -0,0 +1,148 @@ | |||
package com.xdf.creative.util; | |||
import org.springframework.web.context.request.RequestContextHolder; | |||
import org.springframework.web.context.request.ServletRequestAttributes; | |||
import javax.servlet.http.HttpServletRequest; | |||
/** | |||
* IP地址工具类 | |||
* @author xudongdong | |||
* | |||
*/ | |||
public class IpUtil { | |||
/** | |||
* 私有化构造器 | |||
*/ | |||
private IpUtil() { | |||
} | |||
/** | |||
* 获取请求用户的IP地址 | |||
* | |||
* @return | |||
*/ | |||
public static String getRequestIp() { | |||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); | |||
HttpServletRequest request = attributes.getRequest(); | |||
return getRequestIp(request); | |||
} | |||
/** | |||
* 获取真实IP地址 | |||
* <p>使用getRealIP代替该方法</p> | |||
* @param request req | |||
* @return ip | |||
*/ | |||
@Deprecated | |||
public static String getRequestIp(HttpServletRequest request) { | |||
// 获取客户端ip地址 | |||
String clientIp = request.getHeader("x-forwarded-for"); | |||
if (clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) { | |||
clientIp = request.getHeader("Proxy-Client-IP"); | |||
} | |||
if (clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) { | |||
clientIp = request.getHeader("WL-Proxy-Client-IP"); | |||
} | |||
if (clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) { | |||
clientIp = request.getRemoteAddr(); | |||
} | |||
/* | |||
* 对于获取到多ip的情况下,找到公网ip. | |||
*/ | |||
String sIP = null; | |||
if (clientIp != null && !clientIp.contains("unknown") && clientIp.indexOf(",") > 0) { | |||
String[] ipsz = clientIp.split(","); | |||
for (String anIpsz : ipsz) { | |||
if (!isInnerIP(anIpsz.trim())) { | |||
sIP = anIpsz.trim(); | |||
break; | |||
} | |||
} | |||
/* | |||
* 如果多ip都是内网ip,则取第一个ip. | |||
*/ | |||
if (null == sIP) { | |||
sIP = ipsz[0].trim(); | |||
} | |||
clientIp = sIP; | |||
} | |||
if (clientIp != null && clientIp.contains("unknown")){ | |||
clientIp =clientIp.replaceAll("unknown,", ""); | |||
clientIp = clientIp.trim(); | |||
} | |||
if ("".equals(clientIp) || null == clientIp){ | |||
clientIp = "127.0.0.1"; | |||
} | |||
return clientIp; | |||
} | |||
/** | |||
* 判断IP是否是内网地址 | |||
* @param ipAddress ip地址 | |||
* @return 是否是内网地址 | |||
*/ | |||
public static boolean isInnerIP(String ipAddress) { | |||
boolean isInnerIp; | |||
long ipNum = getIpNum(ipAddress); | |||
/** | |||
私有IP:A类 10.0.0.0-10.255.255.255 | |||
B类 172.16.0.0-172.31.255.255 | |||
C类 192.168.0.0-192.168.255.255 | |||
当然,还有127这个网段是环回地址 | |||
**/ | |||
long aBegin = getIpNum("10.0.0.0"); | |||
long aEnd = getIpNum("10.255.255.255"); | |||
long bBegin = getIpNum("172.16.0.0"); | |||
long bEnd = getIpNum("172.31.255.255"); | |||
long cBegin = getIpNum("192.168.0.0"); | |||
long cEnd = getIpNum("192.168.255.255"); | |||
isInnerIp = isInner(ipNum, aBegin, aEnd) || isInner(ipNum, bBegin, bEnd) || isInner(ipNum, cBegin, cEnd) | |||
|| ipAddress.equals("127.0.0.1"); | |||
return isInnerIp; | |||
} | |||
private static long getIpNum(String ipAddress) { | |||
String[] ip = ipAddress.split("\\."); | |||
long a = Integer.parseInt(ip[0]); | |||
long b = Integer.parseInt(ip[1]); | |||
long c = Integer.parseInt(ip[2]); | |||
long d = Integer.parseInt(ip[3]); | |||
return a * 256 * 256 * 256 + b * 256 * 256 + c * 256 + d; | |||
} | |||
private static boolean isInner(long userIp, long begin, long end) { | |||
return (userIp >= begin) && (userIp <= end); | |||
} | |||
public static String getRealIP(HttpServletRequest request){ | |||
// 获取客户端ip地址 | |||
String clientIp = request.getHeader("x-forwarded-for"); | |||
if (clientIp == null || clientIp.length() == 0 || "unknown".equalsIgnoreCase(clientIp)) { | |||
clientIp = request.getRemoteAddr(); | |||
} | |||
String[] clientIps = clientIp.split(","); | |||
if(clientIps.length <= 1) return clientIp.trim(); | |||
// 判断是否来自CDN | |||
if(isComefromCDN(request)){ | |||
if(clientIps.length>=2) return clientIps[clientIps.length-2].trim(); | |||
} | |||
return clientIps[clientIps.length-1].trim(); | |||
} | |||
private static boolean isComefromCDN(HttpServletRequest request) { | |||
String host = request.getHeader("host"); | |||
return host.contains("www.189.cn") ||host.contains("shouji.189.cn") || host.contains( | |||
"image2.chinatelecom-ec.com") || host.contains( | |||
"image1.chinatelecom-ec.com"); | |||
} | |||
} |
@@ -0,0 +1,44 @@ | |||
package com.xdf.creative.util; | |||
public class StringUtil { | |||
public static String replaceSpecialCharacter(String str) { | |||
String newStr = str.trim(); | |||
for (; ; ) { | |||
if (newStr.contains("\\\\")) { | |||
newStr = newStr.replaceAll("\\\\", ""); | |||
} else if (newStr.contains("r")) { | |||
newStr = newStr.replaceAll("r", ""); | |||
} else if (newStr.contains("n")) { | |||
newStr = newStr.replaceAll("n", ""); | |||
} else { | |||
return newStr; | |||
} | |||
} | |||
} | |||
/** | |||
* 判断是否空字符串 | |||
* | |||
* @param str | |||
* @return | |||
*/ | |||
public static boolean isEmpty(String str) { | |||
return ((str == null) || (str.trim().equals(""))); | |||
} | |||
/** | |||
* 判断是否非空字符串 | |||
* | |||
* @param str | |||
* @return | |||
*/ | |||
public static boolean isNotEmpty(String str) { | |||
return !((str == null) || (str.trim().equals(""))); | |||
} | |||
public static boolean longIsNotEmpty(Long val) { | |||
return !((val == null) || (val == 0)); | |||
} | |||
} |
@@ -0,0 +1,131 @@ | |||
package com.xdf.creative.util.page; | |||
import com.alibaba.fastjson.annotation.JSONField; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.xdf.creative.enums.ApiCode; | |||
import com.xdf.creative.enums.StatusCode; | |||
import com.xdf.creative.util.StringUtil; | |||
import lombok.AllArgsConstructor; | |||
import lombok.Builder; | |||
import lombok.Data; | |||
import lombok.experimental.Accessors; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
/** | |||
* <p> | |||
* REST API 返回结果 | |||
* </p> | |||
* | |||
* @author DeanYe | |||
* @since 2018-11-08 | |||
*/ | |||
@Data | |||
@Accessors(chain = true) | |||
@Builder | |||
@AllArgsConstructor | |||
public class ApiResult<T> implements Serializable { | |||
private int code; | |||
private T data; | |||
private String msg; | |||
@JSONField(format = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
private Date time; | |||
public ApiResult() { | |||
} | |||
public static ApiResult result(boolean flag) { | |||
if (flag) { | |||
return ok(); | |||
} | |||
return fail(""); | |||
} | |||
public static ApiResult result(ApiCode apiCode) { | |||
return result(apiCode, null); | |||
} | |||
public static ApiResult result(ApiCode apiCode, Object data) { | |||
return result(apiCode, null, data); | |||
} | |||
public static ApiResult error(StatusCode statusCode) { | |||
ApiResult r = new ApiResult(); | |||
r.setCode(statusCode.getStatus()); | |||
r.setMsg(statusCode.getMsg()); | |||
r.setTime(new Date()); | |||
return r; | |||
} | |||
public static ApiResult result(ApiCode apiCode, String msg, Object data) { | |||
String message = apiCode.getMsg(); | |||
if (StringUtil.isNotEmpty(msg)) { | |||
message = msg; | |||
} | |||
return ApiResult.builder() | |||
.code(apiCode.getCode()) | |||
.msg(message) | |||
.data(data) | |||
.time(new Date()) | |||
.build(); | |||
} | |||
public static ApiResult ok() { | |||
return ok(null); | |||
} | |||
public static ApiResult ok(Object data) { | |||
return result(ApiCode.SUCCESS, data); | |||
} | |||
public static ApiResult ok(Object data, String msg) { | |||
return result(ApiCode.SUCCESS, msg, data); | |||
} | |||
public static ApiResult okMap(String key, Object value) { | |||
Map<String, Object> map = new HashMap<>(); | |||
map.put(key, value); | |||
return ok(map); | |||
} | |||
public static ApiResult fail(ApiCode apiCode) { | |||
return result(apiCode, null); | |||
} | |||
public static ApiResult fail(ApiCode code, String msg) { | |||
return result(code, msg, null); | |||
} | |||
public static ApiResult fail(String msg) { | |||
return result(ApiCode.FAIL, msg, null); | |||
} | |||
public static ApiResult fail(ApiCode apiCode, Object data) { | |||
if (ApiCode.SUCCESS == apiCode) { | |||
throw new RuntimeException("失败结果状态码不能为" + ApiCode.SUCCESS.getCode()); | |||
} | |||
return result(apiCode, data); | |||
} | |||
public static ApiResult fail(String key, Object value) { | |||
Map<String, Object> map = new HashMap<>(); | |||
map.put(key, value); | |||
return result(ApiCode.FAIL, map); | |||
} | |||
public static ApiResult fail() { | |||
return fail(ApiCode.FAIL); | |||
} | |||
} |
@@ -0,0 +1,62 @@ | |||
package com.xdf.creative.util.page; | |||
import com.alibaba.fastjson.annotation.JSONField; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.fasterxml.jackson.annotation.JsonProperty; | |||
import java.io.Serializable; | |||
import java.util.Collections; | |||
import java.util.List; | |||
/** | |||
* @author DeanYe | |||
* @date 2018-11-08 | |||
*/ | |||
public class PageTool<T> implements Serializable { | |||
private static final long serialVersionUID = -1683800405530086022L; | |||
@JSONField(name = "total") | |||
@JsonProperty("total") | |||
private long total = 0; | |||
@JSONField(name = "records") | |||
@JsonProperty("records") | |||
private List<T> records = Collections.emptyList(); | |||
public PageTool() { | |||
} | |||
public PageTool(IPage<T> iPage) { | |||
this.total = iPage.getTotal(); | |||
this.records = iPage.getRecords(); | |||
} | |||
public PageTool(List<T> list, long total) { | |||
this.total = total; | |||
this.records = list; | |||
} | |||
public long getTotal() { | |||
return total; | |||
} | |||
public void setTotal(long total) { | |||
this.total = total; | |||
} | |||
public List<T> getRecords() { | |||
return records; | |||
} | |||
public void setRecords(List<T> records) { | |||
this.records = records; | |||
} | |||
@Override | |||
public String toString() { | |||
return "Paging{" + | |||
"total=" + total + | |||
", records=" + records + | |||
'}'; | |||
} | |||
} |
@@ -0,0 +1,2 @@ | |||
############################# 恵諒揃抄、極笥tomcat start ############################# | |||
@@ -0,0 +1,88 @@ | |||
############################# 访问路径、端口tomcat start ############################# | |||
server: | |||
address: | |||
port: 8999 | |||
servlet: | |||
context-path: / | |||
tomcat: | |||
max-threads: 1000 | |||
min-spare-threads: 30 | |||
uri-encoding: utf-8 | |||
spring: | |||
application: | |||
name: creative-service | |||
http: | |||
encoding: | |||
charset: UTF-8 | |||
enabled: true | |||
force: true | |||
jackson: | |||
date-format: yyy-MM-dd HH:mm:ss | |||
time-zone: GMT+8 | |||
banner: | |||
charset: UTF-8 | |||
location: classpath:banner.txt | |||
profiles: | |||
active: dev | |||
datasource: | |||
driver-class-name: com.mysql.jdbc.Driver | |||
platform: mysql | |||
type: com.alibaba.druid.pool.DruidDataSource | |||
url: jdbc:mysql://192.168.1.101:3306/creative_db?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true | |||
username: root | |||
password: 123456 | |||
druid: | |||
filter: | |||
slf4j: | |||
enabled: true | |||
stat: | |||
log-slow-sql: true | |||
merge-sql: true | |||
slow-sql-millis: 3000 | |||
wall: | |||
config: | |||
delete-allow: true | |||
drop-table-allow: false | |||
enabled: true | |||
filters: stat,wall,slf4j | |||
initial-size: 10 | |||
max-active: 100 | |||
max-pool-prepared-statement-per-connection-size: 20 | |||
max-wait: 60000 | |||
min-evictable-idle-time-millis: 300000 | |||
min-idle: 10 | |||
pool-prepared-statements: true | |||
stat-view-servlet: | |||
enabled: true | |||
login-password: druid123 | |||
login-username: druid | |||
url-pattern: /druid/* | |||
test-on-borrow: false | |||
test-on-return: false | |||
test-while-idle: true | |||
time-between-eviction-runs-millis: 60000 | |||
validation-query: SELECT 1 | |||
validation-query-timeout: 60000 | |||
############################### mybatis-plus start ################################# | |||
mybatis-plus: | |||
check-config-location: true | |||
configuration: | |||
map-underscore-to-camel-case: true | |||
global-config: | |||
db-config: | |||
id-type: id_worker | |||
logic-delete-value: 0 | |||
logic-not-delete-value: 1 | |||
mapper-locations: classpath*:mapper/*Mapper.xml | |||
type-aliases-package: com.xdf.creative.module.entity | |||
################################ mybatis-plus end ################################## | |||
@@ -0,0 +1,153 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<configuration scan="true"> | |||
<!-- 日志输出上下文名称 --> | |||
<contextName>creative</contextName> | |||
<!-- 输出日志到控制台 ConsoleAppender --> | |||
<appender name="ConsoleAppender" class="ch.qos.logback.core.ConsoleAppender"> | |||
<encoder> | |||
<!--<pattern>%d %p (%file:%line\)- %m%n</pattern>--> | |||
<!--格式化输出:%d:表示日期 %thread:表示线程名 %-5level:级别从左显示5个字符宽度 %msg:日志消息 %n:是换行符--> | |||
<pattern>1-%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger - %msg%n</pattern> | |||
<charset>UTF-8</charset> | |||
</encoder> | |||
</appender> | |||
<!-- 输出日志到文件 每天一个文件 --> | |||
<!--输出每天的运行日志到文件SystemOut.log--> | |||
<appender name="SystemOutFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||
<!-- 正在记录的日志文件的路径及文件名 --> | |||
<file>/logs/creative/SystemOut.log</file> | |||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> | |||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||
<!-- 归档的日志文件的路径。%d{yyyy-MM-dd}指定日期格式,%i指定索引 --> | |||
<fileNamePattern>/logs/creative/sys_bak/SystemOut-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | |||
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始 --> | |||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | |||
<maxFileSize>2MB</maxFileSize> | |||
</timeBasedFileNamingAndTriggeringPolicy> | |||
</rollingPolicy> | |||
<!-- 追加方式记录日志 --> | |||
<append>true</append> | |||
<!-- 日志文件的格式 --> | |||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | |||
<pattern>===%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n</pattern> | |||
<charset>utf-8</charset> | |||
</encoder> | |||
<!-- 此日志文件记录debug及以上级别的 --> | |||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||
<level>debug</level> | |||
<onMatch>ACCEPT</onMatch> | |||
<onMismatch>DENY</onMismatch> | |||
</filter> | |||
</appender> | |||
<!-- 输出日志到文件 每天一个文件 --> | |||
<!--输出每天的运行日志到文件SystemErrOut.log--> | |||
<appender name="ErrOutFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||
<!-- 正在记录的日志文件的路径及文件名 --> | |||
<file>/logs/creative/SystemErrOut.log</file> | |||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> | |||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||
<!-- 归档的日志文件的路径。%d{yyyy-MM-dd}指定日期格式,%i指定索引 --> | |||
<fileNamePattern>/logs/creative/err_bak/SystemErrOut-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | |||
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始 --> | |||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | |||
<maxFileSize>2MB</maxFileSize> | |||
</timeBasedFileNamingAndTriggeringPolicy> | |||
</rollingPolicy> | |||
<!-- 追加方式记录日志 --> | |||
<append>true</append> | |||
<!-- 日志文件的格式 --> | |||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | |||
<pattern>===%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n</pattern> | |||
<charset>utf-8</charset> | |||
</encoder> | |||
<!-- 此日志文件记录error及以上级别的 --> | |||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||
<level>error</level> | |||
<onMatch>ACCEPT</onMatch> | |||
<onMismatch>DENY</onMismatch> | |||
</filter> | |||
</appender> | |||
<!-- 输出日志到文件 文件大小到达指定尺寸的时候文件会自动回滚 --> | |||
<!-- 输出运行的SQL语句日志到文件SqlOut.log --> | |||
<appender name="SqlOutFileAppender" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||
<!-- 正在记录的日志文件的路径及文件名 --> | |||
<file>/logs/creative/SystemSqlOut.log</file> | |||
<!-- 日志记录器的滚动策略,按日期,按大小记录 --> | |||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||
<!-- 归档的日志文件的路径。%d{yyyy-MM-dd}指定日期格式,%i指定索引 --> | |||
<fileNamePattern>/logs/creative/sql_bak/SystemSqlOut-%d{yyyy-MM-dd}.%i.log</fileNamePattern> | |||
<!-- 除按日志记录之外,还配置了日志文件不能超过2M,若超过2M,日志文件会以索引0开始 --> | |||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP"> | |||
<maxFileSize>2MB</maxFileSize> | |||
</timeBasedFileNamingAndTriggeringPolicy> | |||
</rollingPolicy> | |||
<!-- 追加方式记录日志 --> | |||
<append>true</append> | |||
<!-- 日志文件的格式 --> | |||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder"> | |||
<pattern>===%d{yyyy-MM-dd HH:mm:ss.SSS} %-5level %logger Line:%-3L - %msg%n</pattern> | |||
<charset>utf-8</charset> | |||
</encoder> | |||
<!-- 此日志文件记录sql trace --> | |||
<filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||
<level>debug</level> | |||
<onMatch>ACCEPT</onMatch> | |||
<onMismatch>DENY</onMismatch> | |||
</filter> | |||
</appender> | |||
<!--这个logger的设置是:举例在org.springframework包下面的所有输出日志必须级别level在info及以上级别才会被输出!--> | |||
<!--这样可以避免输出一些spring框架的许多常见debug信息!--> | |||
<logger name="org.springframework" level="info"/> | |||
<logger name="org.json" level="error"/> | |||
<logger name="io.netty" level="info"/> | |||
<logger name="org.slf4j" level="info"/> | |||
<logger name="ch.qos.logback" level="info"/> | |||
<!-- 生产环境配置文件 --> | |||
<springProfile name="prod"> | |||
<!-- 下面是打印 mybatis sql语句日志的配置 --> | |||
<logger name="com.xdf.creative.module.mapper"> | |||
<level value="debug"/> | |||
<appender-ref ref="SqlOutFileAppender"/> | |||
</logger> | |||
<root level="DEBUG"> | |||
<appender-ref ref="ErrOutFileAppender"/> | |||
<appender-ref ref="SystemOutFileAppender"/> | |||
<appender-ref ref="ConsoleAppender"/> | |||
</root> | |||
</springProfile> | |||
<!-- 测试环境配置文件 --> | |||
<springProfile name="test"> | |||
<!-- 下面是打印 mybatis sql语句日志的配置 --> | |||
<logger name="com.xdf.creative.module.mapper"> | |||
<level value="debug"/> | |||
<appender-ref ref="SqlOutFileAppender"/> | |||
</logger> | |||
<root level="DEBUG"> | |||
<appender-ref ref="ErrOutFileAppender"/> | |||
<appender-ref ref="SystemOutFileAppender"/> | |||
<appender-ref ref="ConsoleAppender"/> | |||
</root> | |||
</springProfile> | |||
<!--开发环境配置文件--> | |||
<springProfile name="dev"> | |||
<root level="DEBUG"> | |||
<appender-ref ref="ConsoleAppender"/> | |||
</root> | |||
</springProfile> | |||
</configuration> |
@@ -0,0 +1,58 @@ | |||
<?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.xdf.creative.module.mapper.SysOperationLogMapper"> | |||
<!-- 通用查询结果列 --> | |||
<sql id="Base_Column_List"> | |||
id, log_name, user_id, api, method, create_time, succeed, detail | |||
</sql> | |||
<sql id="Base_If_Condition"> | |||
<where> | |||
<if test="param.id !=null and param.id!=''"> | |||
and id=#{param.id} | |||
</if> | |||
<if test="param.logName !=null and param.logName!=''"> | |||
and log_name=#{param.logName} | |||
</if> | |||
<if test="param.userId !=null and param.userId!=''"> | |||
and user_id=#{param.userId} | |||
</if> | |||
<if test="param.api !=null and param.api!=''"> | |||
and api=#{param.api} | |||
</if> | |||
<if test="param.method !=null and param.method!=''"> | |||
and method=#{param.method} | |||
</if> | |||
<if test="param.createTime !=null and param.createTime!=''"> | |||
and create_time=#{param.createTime} | |||
</if> | |||
<if test="param.succeed !=null and param.succeed!=''"> | |||
and succeed=#{param.succeed} | |||
</if> | |||
<if test="param.detail !=null and param.detail!=''"> | |||
and detail=#{param.detail} | |||
</if> | |||
</where> | |||
</sql> | |||
<!--根据ID查询--> | |||
<select id="getSysOperationLogById" resultType="com.xdf.creative.base.vo.creative.SysOperationLogQueryVo"> | |||
select | |||
<include refid="Base_Column_List"/> | |||
from sys_operation_log where id = #{id} | |||
</select> | |||
<!--分页查询--> | |||
<select id="getSysOperationLogPageList" | |||
resultType="com.xdf.creative.base.vo.creative.SysOperationLogQueryVo" | |||
parameterType="com.xdf.creative.base.params.creative.SysOperationLogQueryParam"> | |||
select | |||
<include refid="Base_Column_List"/> | |||
from sys_operation_log | |||
<include refid="Base_If_Condition"/> | |||
</select> | |||
</mapper> |
@@ -0,0 +1,64 @@ | |||
<?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.xdf.creative.module.mapper.SysRegionMapper"> | |||
<!-- 通用查询结果列 --> | |||
<sql id="Base_Column_List"> | |||
id, region_id, region_name, par_region_id, state, descript | |||
</sql> | |||
<sql id="Base_If_Condition"> | |||
<where> | |||
<if test="param.id !=null and param.id!=''"> | |||
and id=#{param.id} | |||
</if> | |||
<if test="param.regionId !=null and param.regionId!=''"> | |||
and region_id like CONCAT('',#{param.regionId},'%') | |||
</if> | |||
<if test="param.regionName !=null and param.regionName!=''"> | |||
and region_name=#{param.regionName} | |||
</if> | |||
<if test="param.parRegionId !=null and param.parRegionId!=''"> | |||
and par_region_id like CONCAT('',#{param.parRegionId},'%') | |||
</if> | |||
<if test="param.state !=null and param.state!=''"> | |||
and state=#{param.state} | |||
</if> | |||
<if test="param.descript !=null and param.descript!=''"> | |||
and descript=#{param.descript} | |||
</if> | |||
</where> | |||
</sql> | |||
<!--根据ID查询--> | |||
<select id="getSysRegionById" resultType="com.xdf.creative.base.vo.creative.SysRegionQueryVo"> | |||
select | |||
<include refid="Base_Column_List"/> | |||
from sys_region where id = #{id} | |||
</select> | |||
<!--不分页查询--> | |||
<select id="getSysRegionList" | |||
resultType="com.xdf.creative.base.vo.creative.SysRegionQueryVo" | |||
parameterType="com.xdf.creative.base.params.creative.SysRegionQueryParam"> | |||
select | |||
<include refid="Base_Column_List"/> | |||
from sys_region | |||
<include refid="Base_If_Condition"/> | |||
</select> | |||
<!--分页查询--> | |||
<select id="getSysRegionPageList" | |||
resultType="com.xdf.creative.base.vo.creative.SysRegionQueryVo" | |||
parameterType="com.xdf.creative.base.params.creative.SysRegionQueryParam"> | |||
select | |||
<include refid="Base_Column_List"/> | |||
from sys_region | |||
<include refid="Base_If_Condition"/> | |||
</select> | |||
</mapper> |
@@ -0,0 +1,12 @@ | |||
package com.xdf.creative; | |||
import org.junit.Test; | |||
import org.springframework.boot.test.context.SpringBootTest; | |||
@SpringBootTest | |||
class CreativeApplicationTests { | |||
@Test | |||
void contextLoads() { | |||
} | |||
} |