commit
f9be7a565e
32 changed files with 1757 additions and 0 deletions
@ -0,0 +1,34 @@ |
|||||||
|
HELP.md |
||||||
|
target/ |
||||||
|
!.mvn/wrapper/maven-wrapper.jar |
||||||
|
!**/src/main/**/target/ |
||||||
|
!**/src/test/**/target/ |
||||||
|
|
||||||
|
### STS ### |
||||||
|
.apt_generated |
||||||
|
.classpath |
||||||
|
.factorypath |
||||||
|
.project |
||||||
|
.settings |
||||||
|
.springBeans |
||||||
|
.sts4-cache |
||||||
|
|
||||||
|
### IntelliJ IDEA ### |
||||||
|
.idea |
||||||
|
*.iws |
||||||
|
*.iml |
||||||
|
*.ipr |
||||||
|
|
||||||
|
### NetBeans ### |
||||||
|
/nbproject/private/ |
||||||
|
/nbbuild/ |
||||||
|
/dist/ |
||||||
|
/nbdist/ |
||||||
|
/.nb-gradle/ |
||||||
|
build/ |
||||||
|
!**/src/main/**/build/ |
||||||
|
!**/src/test/**/build/ |
||||||
|
|
||||||
|
### VS Code ### |
||||||
|
.vscode/ |
||||||
|
/.mvn/ |
@ -0,0 +1,16 @@ |
|||||||
|
# soul2-java-demo-version_1 |
||||||
|
|
||||||
|
处于试验性质的Java模板 |
||||||
|
|
||||||
|
## 开始 |
||||||
|
|
||||||
|
```bash |
||||||
|
git clone http://gitea.soul2.cn/soul2/soul2-java-demo-version_1.git |
||||||
|
``` |
||||||
|
|
||||||
|
## 分支 |
||||||
|
|
||||||
|
- `master`: 上线 |
||||||
|
- `develop`: 最新的开发版 |
||||||
|
|
||||||
|
2022年9月6日 第一版 By soul2 |
@ -0,0 +1,316 @@ |
|||||||
|
#!/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 /usr/local/etc/mavenrc ] ; then |
||||||
|
. /usr/local/etc/mavenrc |
||||||
|
fi |
||||||
|
|
||||||
|
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="`\\unset -f command; \\command -v 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/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" |
||||||
|
else |
||||||
|
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.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" || rm -f "$wrapperJarPath" |
||||||
|
else |
||||||
|
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$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 \ |
||||||
|
$MAVEN_DEBUG_OPTS \ |
||||||
|
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ |
||||||
|
"-Dmaven.home=${M2_HOME}" \ |
||||||
|
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ |
||||||
|
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" |
@ -0,0 +1,188 @@ |
|||||||
|
@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 "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* |
||||||
|
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\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/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar" |
||||||
|
|
||||||
|
FOR /F "usebackq 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%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.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 "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" |
||||||
|
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\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% |
||||||
|
|
||||||
|
cmd /C exit /B %ERROR_CODE% |
@ -0,0 +1,119 @@ |
|||||||
|
<?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.6.10</version> |
||||||
|
<relativePath/> <!-- lookup parent from repository --> |
||||||
|
</parent> |
||||||
|
<groupId>cn.soul2</groupId> |
||||||
|
<artifactId>java-demo</artifactId> |
||||||
|
<version>0.0.1-SNAPSHOT</version> |
||||||
|
<name>java-demo</name> |
||||||
|
<description>java-demo</description> |
||||||
|
<properties> |
||||||
|
<java.version>11</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-devtools</artifactId> |
||||||
|
<scope>runtime</scope> |
||||||
|
<optional>true</optional> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.projectlombok</groupId> |
||||||
|
<artifactId>lombok</artifactId> |
||||||
|
<optional>true</optional> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springframework.boot</groupId> |
||||||
|
<artifactId>spring-boot-starter-test</artifactId> |
||||||
|
<scope>test</scope> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<!--DataSource--> |
||||||
|
<dependency> |
||||||
|
<groupId>com.alibaba</groupId> |
||||||
|
<artifactId>druid-spring-boot-starter</artifactId> |
||||||
|
<version>1.2.6</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>com.baomidou</groupId> |
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId> |
||||||
|
<version>3.5.1</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>com.baomidou</groupId> |
||||||
|
<artifactId>mybatis-plus</artifactId> |
||||||
|
<version>3.5.1</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>com.baomidou</groupId> |
||||||
|
<artifactId>mybatis-plus-generator</artifactId> |
||||||
|
<version>3.5.1</version> |
||||||
|
</dependency> |
||||||
|
<!--freemarker模板--> |
||||||
|
<dependency> |
||||||
|
<groupId>org.freemarker</groupId> |
||||||
|
<artifactId>freemarker</artifactId> |
||||||
|
</dependency> |
||||||
|
<!-- 代码生成器模板,用于生成代码 --> |
||||||
|
<dependency> |
||||||
|
<groupId>org.apache.velocity</groupId> |
||||||
|
<artifactId>velocity-engine-core</artifactId> |
||||||
|
<version>2.3</version> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>ai.houyi</groupId> |
||||||
|
<artifactId>dorado-swagger</artifactId> |
||||||
|
<version>0.0.51</version> |
||||||
|
<type>pom</type> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
<dependency> |
||||||
|
<groupId>mysql</groupId> |
||||||
|
<artifactId>mysql-connector-java</artifactId> |
||||||
|
</dependency> |
||||||
|
<dependency> |
||||||
|
<groupId>org.springframework.boot</groupId> |
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId> |
||||||
|
</dependency> |
||||||
|
|
||||||
|
</dependencies> |
||||||
|
|
||||||
|
<build> |
||||||
|
<plugins> |
||||||
|
<plugin> |
||||||
|
<groupId>org.springframework.boot</groupId> |
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId> |
||||||
|
<configuration> |
||||||
|
<excludes> |
||||||
|
<exclude> |
||||||
|
<groupId>org.projectlombok</groupId> |
||||||
|
<artifactId>lombok</artifactId> |
||||||
|
</exclude> |
||||||
|
</excludes> |
||||||
|
</configuration> |
||||||
|
</plugin> |
||||||
|
</plugins> |
||||||
|
|
||||||
|
<!-- <plugins>--> |
||||||
|
<!-- <plugin>--> |
||||||
|
<!-- <!– springboot打包插件 –>--> |
||||||
|
<!-- <groupId>org.springframework.boot</groupId>--> |
||||||
|
<!-- <artifactId>spring-boot-maven-plugin</artifactId>--> |
||||||
|
<!-- <version>2.1.7.RELEASE</version>--> |
||||||
|
<!-- </plugin>--> |
||||||
|
<!-- </plugins>--> |
||||||
|
|
||||||
|
</build> |
||||||
|
|
||||||
|
</project> |
@ -0,0 +1,13 @@ |
|||||||
|
package cn.soul2.demo; |
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication; |
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||||
|
|
||||||
|
@SpringBootApplication |
||||||
|
public class JavaDemoApplication { |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
SpringApplication.run(JavaDemoApplication.class, args); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,37 @@ |
|||||||
|
package cn.soul2.demo.codemessage; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-08-22 16:40:24 |
||||||
|
*/ |
||||||
|
|
||||||
|
public enum BackCodeMessage { |
||||||
|
/** |
||||||
|
* 0,成功 |
||||||
|
*/ |
||||||
|
SUCCESS("成功", 0), |
||||||
|
/** |
||||||
|
* 2000,错误 |
||||||
|
*/ |
||||||
|
FAIL("错误", 2000), |
||||||
|
/** |
||||||
|
* 40404,参数错误 |
||||||
|
*/ |
||||||
|
PARAM_ERROR("参数错误", 40404); |
||||||
|
private String message; |
||||||
|
private int code; |
||||||
|
|
||||||
|
BackCodeMessage(String message, int code) { |
||||||
|
this.message = message; |
||||||
|
this.code = code; |
||||||
|
} |
||||||
|
|
||||||
|
public String getMessage() { |
||||||
|
return message; |
||||||
|
} |
||||||
|
|
||||||
|
public int getCode() { |
||||||
|
return code; |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,27 @@ |
|||||||
|
package cn.soul2.demo.config; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; |
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; |
||||||
|
import org.springframework.context.annotation.Bean; |
||||||
|
import org.springframework.context.annotation.Configuration; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-08-15 11:57:02 |
||||||
|
* @since 1.0 |
||||||
|
*/ |
||||||
|
|
||||||
|
//@Slf4j
|
||||||
|
@Configuration |
||||||
|
public class BeanConfig { |
||||||
|
|
||||||
|
@Bean |
||||||
|
public MybatisPlusInterceptor mybatisPlusInterceptor() { |
||||||
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); |
||||||
|
// 向Mybatis过滤器链中添加分页拦截器
|
||||||
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor()); |
||||||
|
// 还可以添加其他的拦截器
|
||||||
|
return interceptor; |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -0,0 +1,26 @@ |
|||||||
|
package cn.soul2.demo.config; |
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Value; |
||||||
|
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 { |
||||||
|
|
||||||
|
@Value("${cors.allow-origin}") |
||||||
|
private String allowOrigin; |
||||||
|
|
||||||
|
@Override |
||||||
|
public void addCorsMappings(CorsRegistry registry) { |
||||||
|
//项目中的所有接口都支持跨域
|
||||||
|
registry.addMapping("/**") |
||||||
|
//所有地址都可以访问,也可以配置具体地址
|
||||||
|
.allowedOrigins(allowOrigin) |
||||||
|
.allowCredentials(true) |
||||||
|
//"GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS"
|
||||||
|
.allowedMethods("POST") |
||||||
|
// 跨域允许时间
|
||||||
|
.maxAge(3600); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
package cn.soul2.demo.config; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler; |
||||||
|
import org.apache.ibatis.reflection.MetaObject; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import java.time.LocalDateTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* mybatis-plus自动填充 |
||||||
|
* |
||||||
|
* @author Soul2 |
||||||
|
* @since 2022-08-23 14:49:32 |
||||||
|
*/ |
||||||
|
@Component |
||||||
|
public class MetaObjectHandlerConfig implements MetaObjectHandler { |
||||||
|
@Override |
||||||
|
public void insertFill(MetaObject metaObject) { |
||||||
|
this.strictInsertFill(metaObject, "createdTime", LocalDateTime.class, LocalDateTime.now()); |
||||||
|
this.strictInsertFill(metaObject, "updatedTime", LocalDateTime.class, LocalDateTime.now()); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void updateFill(MetaObject metaObject) { |
||||||
|
this.strictUpdateFill(metaObject, "updatedTime", LocalDateTime.class, LocalDateTime.now()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
package cn.soul2.demo.controller; |
||||||
|
|
||||||
|
import cn.soul2.demo.dto.DemoDTO; |
||||||
|
import cn.soul2.demo.dto.DemoSaveOrUpdateDTO; |
||||||
|
import cn.soul2.demo.service.IDemoService; |
||||||
|
import cn.soul2.demo.vo.DemoVO; |
||||||
|
import cn.soul2.demo.vo.base.Back; |
||||||
|
import cn.soul2.demo.vo.base.VPage; |
||||||
|
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 java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-08-15 |
||||||
|
*/ |
||||||
|
|
||||||
|
//@Slf4j
|
||||||
|
@RestController |
||||||
|
@RequestMapping("/demo") |
||||||
|
public class DemoController { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IDemoService demoService; |
||||||
|
|
||||||
|
@PostMapping("/page") |
||||||
|
public Back<VPage<DemoVO>> page(@RequestBody DemoDTO dto) { |
||||||
|
return demoService.page(dto); |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping("/save") |
||||||
|
public Back<Boolean> save(@RequestBody DemoSaveOrUpdateDTO entity) { |
||||||
|
return demoService.save(entity); |
||||||
|
} |
||||||
|
|
||||||
|
@PostMapping("/remove") |
||||||
|
public Back<Boolean> remove(@RequestBody List<String> ids) { |
||||||
|
return demoService.remove(ids); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,29 @@ |
|||||||
|
package cn.soul2.demo.dto; |
||||||
|
|
||||||
|
import cn.soul2.demo.dto.base.PageParams; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
import java.time.LocalDateTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-08-15 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Data |
||||||
|
@Accessors(chain = true) |
||||||
|
public class DemoDTO extends PageParams { |
||||||
|
|
||||||
|
/** |
||||||
|
* 名字 |
||||||
|
*/ |
||||||
|
private String name; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新时间 |
||||||
|
*/ |
||||||
|
private LocalDateTime startTime; |
||||||
|
private LocalDateTime endTime; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
package cn.soul2.demo.dto; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
import java.time.LocalDateTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-08-23 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Data |
||||||
|
@Accessors(chain = true) |
||||||
|
public class DemoSaveOrUpdateDTO { |
||||||
|
|
||||||
|
/** |
||||||
|
* 主键 |
||||||
|
*/ |
||||||
|
private String id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 名字 |
||||||
|
*/ |
||||||
|
private String name; |
||||||
|
|
||||||
|
/** |
||||||
|
* 属性1 |
||||||
|
*/ |
||||||
|
private String attr1; |
||||||
|
|
||||||
|
/** |
||||||
|
* 属性2 |
||||||
|
*/ |
||||||
|
private String attr2; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新时间 |
||||||
|
*/ |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private LocalDateTime updateTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建时间 |
||||||
|
*/ |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private LocalDateTime createTime; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
package cn.soul2.demo.dto.base; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
/** |
||||||
|
* 分页查询参数 |
||||||
|
* |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-08-15 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Data |
||||||
|
@Accessors(chain = true) |
||||||
|
public class PageParams { |
||||||
|
|
||||||
|
private Integer pageNumber; |
||||||
|
private Integer pageSize; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,77 @@ |
|||||||
|
package cn.soul2.demo.entity; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||||
|
import com.baomidou.mybatisplus.extension.activerecord.Model; |
||||||
|
import lombok.Getter; |
||||||
|
import lombok.Setter; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.time.LocalDateTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* demo表 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author Soul2 |
||||||
|
* @since 2022-08-23 14:32:09 |
||||||
|
*/ |
||||||
|
@Getter |
||||||
|
@Setter |
||||||
|
@Accessors(chain = true) |
||||||
|
@TableName("data_table_demo") |
||||||
|
public class DataTableDemoDO extends Model<DataTableDemoDO> { |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
/** |
||||||
|
* 主键 |
||||||
|
*/ |
||||||
|
@TableId(value = "id", type = IdType.ASSIGN_UUID) |
||||||
|
private String id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 名字 |
||||||
|
*/ |
||||||
|
@TableField("name") |
||||||
|
private String name; |
||||||
|
|
||||||
|
/** |
||||||
|
* 属性1 |
||||||
|
*/ |
||||||
|
@TableField("attr1") |
||||||
|
private String attr1; |
||||||
|
|
||||||
|
/** |
||||||
|
* 属性2 |
||||||
|
*/ |
||||||
|
@TableField("attr2") |
||||||
|
private String attr2; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新时间 |
||||||
|
*/ |
||||||
|
@TableField(value = "updated_time", fill = FieldFill.INSERT_UPDATE) |
||||||
|
private LocalDateTime updatedTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建时间 |
||||||
|
*/ |
||||||
|
@TableField(value = "created_time", fill = FieldFill.INSERT) |
||||||
|
private LocalDateTime createdTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 删除标识: 0-存在; 1-删除 |
||||||
|
*/ |
||||||
|
@TableField("removed") |
||||||
|
@TableLogic |
||||||
|
private Integer removed; |
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public Serializable pkVal() { |
||||||
|
return this.id; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,18 @@ |
|||||||
|
package cn.soul2.demo.mapper; |
||||||
|
|
||||||
|
import cn.soul2.demo.entity.DataTableDemoDO; |
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||||
|
import org.apache.ibatis.annotations.Mapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* demo表 Mapper 接口 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author Soul2 |
||||||
|
* @since 2022-08-15 14:14:23 |
||||||
|
*/ |
||||||
|
@Mapper |
||||||
|
public interface DataTableDemoMapper extends BaseMapper<DataTableDemoDO> { |
||||||
|
|
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
package cn.soul2.demo.repository; |
||||||
|
|
||||||
|
import cn.soul2.demo.dto.DemoDTO; |
||||||
|
import cn.soul2.demo.dto.DemoSaveOrUpdateDTO; |
||||||
|
import cn.soul2.demo.entity.DataTableDemoDO; |
||||||
|
import cn.soul2.demo.vo.base.VPage; |
||||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||||
|
|
||||||
|
import java.util.Collection; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* demo表 服务类 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author Soul2 |
||||||
|
* @since 2022-08-15 14:14:23 |
||||||
|
*/ |
||||||
|
public interface IDataTableDemoRepository extends IService<DataTableDemoDO> { |
||||||
|
|
||||||
|
VPage<DataTableDemoDO> page(DemoDTO dto); |
||||||
|
|
||||||
|
Boolean save(DemoSaveOrUpdateDTO entity); |
||||||
|
|
||||||
|
Boolean remove(Collection<String> ids); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,67 @@ |
|||||||
|
package cn.soul2.demo.repository.impl; |
||||||
|
|
||||||
|
import cn.soul2.demo.dto.DemoDTO; |
||||||
|
import cn.soul2.demo.dto.DemoSaveOrUpdateDTO; |
||||||
|
import cn.soul2.demo.entity.DataTableDemoDO; |
||||||
|
import cn.soul2.demo.mapper.DataTableDemoMapper; |
||||||
|
import cn.soul2.demo.repository.IDataTableDemoRepository; |
||||||
|
import cn.soul2.demo.utils.base.PageUtils; |
||||||
|
import cn.soul2.demo.vo.base.VPage; |
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||||
|
import org.springframework.beans.BeanUtils; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.Collection; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p> |
||||||
|
* demo表 服务实现类 |
||||||
|
* </p> |
||||||
|
* |
||||||
|
* @author Soul2 |
||||||
|
* @since 2022-08-15 14:14:23 |
||||||
|
*/ |
||||||
|
@Service |
||||||
|
public class DataTableDemoRepositoryImpl extends ServiceImpl<DataTableDemoMapper, DataTableDemoDO> implements IDataTableDemoRepository { |
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public IPage<DataTableDemoDO> page(DemoDTO dto) {
|
||||||
|
// LambdaQueryWrapper<DataTableDemoDO> query = Wrappers.lambdaQuery();
|
||||||
|
// query.like(StringUtils.isNotBlank(dto.getName()), DataTableDemoDO::getName, dto.getName());
|
||||||
|
// query.orderByDesc(DataTableDemoDO::getUpdatedTime).orderByDesc(DataTableDemoDO::getCreatedTime).orderByAsc(DataTableDemoDO::getName);
|
||||||
|
// if (dto.getStartTime() != null && dto.getEndTime() != null) {
|
||||||
|
// query.between(DataTableDemoDO::getUpdatedTime, dto.getStartTime(), dto.getEndTime());
|
||||||
|
// }
|
||||||
|
// IPage<DataTableDemoDO> page = new Page<>(dto.getPageNumber(), dto.getPageSize());
|
||||||
|
// return super.page(page, query);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
@Override |
||||||
|
public VPage<DataTableDemoDO> page(DemoDTO dto) { |
||||||
|
LambdaQueryWrapper<DataTableDemoDO> query = Wrappers.lambdaQuery(); |
||||||
|
query.like(StringUtils.isNotBlank(dto.getName()), DataTableDemoDO::getName, dto.getName()); |
||||||
|
query.orderByDesc(DataTableDemoDO::getUpdatedTime).orderByDesc(DataTableDemoDO::getCreatedTime).orderByAsc(DataTableDemoDO::getName); |
||||||
|
if (dto.getStartTime() != null && dto.getEndTime() != null) { |
||||||
|
query.between(DataTableDemoDO::getUpdatedTime, dto.getStartTime(), dto.getEndTime()); |
||||||
|
} |
||||||
|
return PageUtils.to(super.page(PageUtils.build(dto), query)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Boolean save(DemoSaveOrUpdateDTO entity) { |
||||||
|
DataTableDemoDO demoDO = new DataTableDemoDO(); |
||||||
|
BeanUtils.copyProperties(entity, demoDO); |
||||||
|
return super.saveOrUpdate(demoDO); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Boolean remove(Collection<String> ids) { |
||||||
|
LambdaQueryWrapper<DataTableDemoDO> query = Wrappers.lambdaQuery(); |
||||||
|
query.in(DataTableDemoDO::getId, ids); |
||||||
|
return super.remove(query); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
package cn.soul2.demo.service; |
||||||
|
|
||||||
|
import cn.soul2.demo.dto.DemoDTO; |
||||||
|
import cn.soul2.demo.dto.DemoSaveOrUpdateDTO; |
||||||
|
import cn.soul2.demo.vo.DemoVO; |
||||||
|
import cn.soul2.demo.vo.base.Back; |
||||||
|
import cn.soul2.demo.vo.base.VPage; |
||||||
|
|
||||||
|
import java.util.Collection; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-08-22 |
||||||
|
*/ |
||||||
|
|
||||||
|
public interface IDemoService { |
||||||
|
|
||||||
|
Back<VPage<DemoVO>> page(DemoDTO dto); |
||||||
|
|
||||||
|
Back<Boolean> save(DemoSaveOrUpdateDTO entity); |
||||||
|
|
||||||
|
Back<Boolean> remove(Collection<String> ids); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,51 @@ |
|||||||
|
package cn.soul2.demo.service.impl; |
||||||
|
|
||||||
|
import cn.soul2.demo.dto.DemoDTO; |
||||||
|
import cn.soul2.demo.dto.DemoSaveOrUpdateDTO; |
||||||
|
import cn.soul2.demo.entity.DataTableDemoDO; |
||||||
|
import cn.soul2.demo.repository.IDataTableDemoRepository; |
||||||
|
import cn.soul2.demo.service.IDemoService; |
||||||
|
import cn.soul2.demo.utils.base.BackUtils; |
||||||
|
import cn.soul2.demo.utils.base.PageUtils; |
||||||
|
import cn.soul2.demo.vo.DemoVO; |
||||||
|
import cn.soul2.demo.vo.base.Back; |
||||||
|
import cn.soul2.demo.vo.base.VPage; |
||||||
|
import org.springframework.beans.BeanUtils; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.util.Collection; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-08-22 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Service |
||||||
|
public class DemoServiceImpl implements IDemoService { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IDataTableDemoRepository demoRepository; |
||||||
|
|
||||||
|
@Override |
||||||
|
public Back<VPage<DemoVO>> page(DemoDTO dto) { |
||||||
|
VPage<DataTableDemoDO> page = demoRepository.page(dto); |
||||||
|
VPage<DemoVO> toPage = PageUtils.to(page, page.getRows().stream().map(data -> { |
||||||
|
DemoVO vo = new DemoVO(); |
||||||
|
BeanUtils.copyProperties(data, vo); |
||||||
|
return vo; |
||||||
|
}).collect(Collectors.toList())); |
||||||
|
return BackUtils.success(toPage); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Back<Boolean> save(DemoSaveOrUpdateDTO entity) { |
||||||
|
return BackUtils.success(demoRepository.save(entity)); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Back<Boolean> remove(Collection<String> ids) { |
||||||
|
return BackUtils.success(demoRepository.remove(ids)); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,157 @@ |
|||||||
|
package cn.soul2.demo.utils; |
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.FieldFill; |
||||||
|
import com.baomidou.mybatisplus.annotation.IdType; |
||||||
|
import com.baomidou.mybatisplus.generator.FastAutoGenerator; |
||||||
|
import com.baomidou.mybatisplus.generator.config.TemplateType; |
||||||
|
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; |
||||||
|
import com.baomidou.mybatisplus.generator.engine.VelocityTemplateEngine; |
||||||
|
import com.baomidou.mybatisplus.generator.fill.Column; |
||||||
|
import com.baomidou.mybatisplus.generator.fill.Property; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-05-08 11:17:38 |
||||||
|
*/ |
||||||
|
|
||||||
|
public class MybatisFastGenerator { |
||||||
|
|
||||||
|
private static final DatasourceConfig DATASOURCE_CONFIG = new DatasourceConfig( |
||||||
|
"Soul2", |
||||||
|
"jdbc:mysql://next.soul2.cn:3306/cn_soul2?characterEncoding=utf8&serverTimezone=GMT%2B8", |
||||||
|
"buildemo", |
||||||
|
"86ba@qybgz" |
||||||
|
); |
||||||
|
/** |
||||||
|
* 设置需要生成的表名 |
||||||
|
*/ |
||||||
|
private static final String[] TABLE_NAMES = { |
||||||
|
"data_table_demo" |
||||||
|
}; |
||||||
|
/** |
||||||
|
* 模块名称 |
||||||
|
*/ |
||||||
|
private static final String MODULE_NAME = "demo"; |
||||||
|
/** |
||||||
|
* 是否为表更新 |
||||||
|
*/ |
||||||
|
private static final Boolean TABLE_UPDATE = true; |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置过滤表前缀 |
||||||
|
*/ |
||||||
|
private static final String[] TABLE_PREFIX = { |
||||||
|
"b_", "r_" |
||||||
|
}; |
||||||
|
|
||||||
|
private static FastAutoGenerator generator(Boolean update) { |
||||||
|
FastAutoGenerator autoGenerator = FastAutoGenerator.create( |
||||||
|
DATASOURCE_CONFIG.getUrl(), |
||||||
|
DATASOURCE_CONFIG.getUsername(), |
||||||
|
DATASOURCE_CONFIG.getPassword()) |
||||||
|
.globalConfig(builder -> { |
||||||
|
builder.author(DATASOURCE_CONFIG.getAuthor()) // 设置作者
|
||||||
|
// .enableSwagger() // 开启 swagger 模式
|
||||||
|
.fileOverride() // 覆盖已生成文件
|
||||||
|
// 注解日期的格式
|
||||||
|
.commentDate("yyyy-MM-dd HH:mm:ss") |
||||||
|
// 文件输出目录
|
||||||
|
.outputDir(System.getProperty("user.dir") + "\\src\\main\\java") |
||||||
|
// 生成完成后不打开资源管理器(打开会很烦)
|
||||||
|
.disableOpenDir(); |
||||||
|
}) |
||||||
|
.packageConfig(builder -> { |
||||||
|
builder |
||||||
|
// 设置父包名
|
||||||
|
.parent("cn.soul2") |
||||||
|
// 设置父包模块名
|
||||||
|
.moduleName(MODULE_NAME) |
||||||
|
// 设置各类型文件输出的包
|
||||||
|
.mapper("mapper") |
||||||
|
.entity("entity") |
||||||
|
.service("repository") |
||||||
|
.serviceImpl("repository.impl") |
||||||
|
; |
||||||
|
}) |
||||||
|
.strategyConfig(builder -> { |
||||||
|
builder |
||||||
|
// 设置生成的表名
|
||||||
|
.addInclude(TABLE_NAMES) |
||||||
|
// 设置过滤的表前缀
|
||||||
|
.addTablePrefix(TABLE_PREFIX) |
||||||
|
// 实体映射设置
|
||||||
|
.entityBuilder() |
||||||
|
.enableChainModel() |
||||||
|
// id生成策略启用UUID
|
||||||
|
.idType(IdType.ASSIGN_UUID) |
||||||
|
// 启用Lombok
|
||||||
|
.enableLombok() |
||||||
|
// 添加名称后缀
|
||||||
|
.formatFileName("%sDO") |
||||||
|
// 启用链式调用
|
||||||
|
.enableActiveRecord() |
||||||
|
// 启用逻辑删除字段
|
||||||
|
.logicDeleteColumnName("REMOVED") |
||||||
|
// 名称转换,这里是下划线转驼峰
|
||||||
|
.naming(NamingStrategy.underline_to_camel) |
||||||
|
.columnNaming(NamingStrategy.underline_to_camel) |
||||||
|
// 自动填充创建时间
|
||||||
|
.addTableFills(new Column("created_time", FieldFill.INSERT)) |
||||||
|
.addTableFills(new Property("updatedTime", FieldFill.INSERT_UPDATE)) |
||||||
|
// 开启生成实体时生成字段注解
|
||||||
|
.enableTableFieldAnnotation() |
||||||
|
|
||||||
|
.mapperBuilder() |
||||||
|
.enableMapperAnnotation() |
||||||
|
.formatMapperFileName("%sMapper") |
||||||
|
|
||||||
|
.serviceBuilder() |
||||||
|
.formatServiceFileName("I%sRepository") |
||||||
|
.formatServiceImplFileName("%sRepositoryImpl"); |
||||||
|
}) |
||||||
|
// 使用Freemarker引擎模板,默认的是Velocity引擎模板
|
||||||
|
// .templateEngine(new FreemarkerTemplateEngine())
|
||||||
|
// 默认的Velocity引擎模板
|
||||||
|
.templateEngine(new VelocityTemplateEngine()) |
||||||
|
.templateConfig(builder -> { |
||||||
|
builder |
||||||
|
.disable(TemplateType.CONTROLLER) |
||||||
|
.disable(TemplateType.XML); |
||||||
|
}); |
||||||
|
if (update) { |
||||||
|
update(autoGenerator); |
||||||
|
} |
||||||
|
return autoGenerator; |
||||||
|
} |
||||||
|
|
||||||
|
private static FastAutoGenerator update(FastAutoGenerator autoGenerator) { |
||||||
|
return autoGenerator.templateConfig(builder -> { |
||||||
|
builder |
||||||
|
.disable(TemplateType.SERVICE) |
||||||
|
.disable(TemplateType.SERVICEIMPL) |
||||||
|
.disable(TemplateType.MAPPER); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
public static void main(String[] args) { |
||||||
|
generator(TABLE_UPDATE).execute(); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Data |
||||||
|
class DatasourceConfig { |
||||||
|
|
||||||
|
private String author; |
||||||
|
private String url; |
||||||
|
private String username; |
||||||
|
private String password; |
||||||
|
|
||||||
|
public DatasourceConfig(String author, String url, String username, String password) { |
||||||
|
this.author = author; |
||||||
|
this.url = url; |
||||||
|
this.username = username; |
||||||
|
this.password = password; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
package cn.soul2.demo.utils; |
||||||
|
|
||||||
|
import java.time.LocalDate; |
||||||
|
import java.util.UUID; |
||||||
|
|
||||||
|
public class Test { |
||||||
|
public static void main(String[] args) { |
||||||
|
String ddl = "INSERT INTO cn_soul2.data_table_demo " + |
||||||
|
"(id, name, attr1, attr2, update_time, create_time, removed) " + |
||||||
|
"VALUES('%s', '测试%d', '%d', '内容%d', '%s', '%s', 0);"; |
||||||
|
for (int i = 0; i < 30; i++) { |
||||||
|
System.out.printf((ddl) + "%n", UUID.randomUUID().toString().replaceAll("-", ""), i, i, i, LocalDate.now(), LocalDate.now()); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,42 @@ |
|||||||
|
package cn.soul2.demo.utils.base; |
||||||
|
|
||||||
|
import cn.soul2.demo.codemessage.BackCodeMessage; |
||||||
|
import cn.soul2.demo.vo.base.Back; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-08-22 |
||||||
|
*/ |
||||||
|
|
||||||
|
public class BackUtils { |
||||||
|
|
||||||
|
public static <T> Back<T> success() { |
||||||
|
return new Back<>(BackCodeMessage.SUCCESS); |
||||||
|
} |
||||||
|
|
||||||
|
public static <T> Back<T> success(T data) { |
||||||
|
return new Back<>(BackCodeMessage.SUCCESS, data); |
||||||
|
} |
||||||
|
|
||||||
|
public static <T> Back<T> success(T data, String message) { |
||||||
|
return new Back<>(BackCodeMessage.SUCCESS, data).setMessage(message); |
||||||
|
} |
||||||
|
|
||||||
|
public static <T> Back<T> fail() { |
||||||
|
return new Back<>(BackCodeMessage.FAIL); |
||||||
|
} |
||||||
|
|
||||||
|
public static <T> Back<T> fail(String errorMessage) { |
||||||
|
return new Back<T>(BackCodeMessage.FAIL).setErrorMessage(errorMessage); |
||||||
|
} |
||||||
|
|
||||||
|
public static <T> Back<T> fail(BackCodeMessage backCodeMessage) { |
||||||
|
return new Back<>(backCodeMessage); |
||||||
|
} |
||||||
|
|
||||||
|
public static <T> Back<T> fail(BackCodeMessage backCodeMessage, String errorMessage) { |
||||||
|
return new Back<T>(backCodeMessage).setErrorMessage(errorMessage); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,92 @@ |
|||||||
|
package cn.soul2.demo.utils.base; |
||||||
|
|
||||||
|
import cn.soul2.demo.dto.base.PageParams; |
||||||
|
import cn.soul2.demo.vo.base.VPage; |
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-08-22 |
||||||
|
*/ |
||||||
|
|
||||||
|
public class PageUtils { |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据分页参数构造一个mybatis的IPage |
||||||
|
* |
||||||
|
* @param pageParams 分页参数 |
||||||
|
* @return {@code <T> IPage<T>} |
||||||
|
*/ |
||||||
|
public static <T> IPage<T> build(PageParams pageParams) { |
||||||
|
return new com.baomidou.mybatisplus.extension.plugins.pagination.Page<T>(pageParams.getPageNumber(), pageParams.getPageSize()); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 根据分页参数构造一个mybatis的IPage |
||||||
|
* |
||||||
|
* @param pageNumber 页码 |
||||||
|
* @param pageSize 页大小 |
||||||
|
* @return {@code <T> IPage<T>} |
||||||
|
*/ |
||||||
|
public static <T> IPage<T> build(long pageNumber, long pageSize) { |
||||||
|
return new com.baomidou.mybatisplus.extension.plugins.pagination.Page<T>(pageNumber, pageSize); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 生成分页结果 |
||||||
|
* |
||||||
|
* @param page mybatis的分页结果 |
||||||
|
* @return {@code <T> VPage<T>} |
||||||
|
*/ |
||||||
|
public static <T> VPage<T> to(IPage<T> page) { |
||||||
|
VPage<T> toPage = new VPage<>(); |
||||||
|
toPage.setPageNumber(page.getCurrent()) |
||||||
|
.setPageSize(page.getSize()) |
||||||
|
.setTotalPageNumber(page.getPages()) |
||||||
|
.setTotal(page.getTotal()) |
||||||
|
.setHasNext(page.getCurrent() < page.getPages()) |
||||||
|
.setRows(page.getRecords()); |
||||||
|
return toPage; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 转换分页结果 |
||||||
|
* <i>用于处理结果的List数据</i> |
||||||
|
* |
||||||
|
* @param page mybatis的分页结果 |
||||||
|
* @param list 处理后的List |
||||||
|
* @return {@code <T> VPage<T>} |
||||||
|
*/ |
||||||
|
public static <A, B> VPage<B> to(IPage<A> page, List<B> list) { |
||||||
|
VPage<B> toPage = new VPage<>(); |
||||||
|
toPage.setPageNumber(page.getCurrent()) |
||||||
|
.setPageSize(page.getSize()) |
||||||
|
.setTotalPageNumber(page.getPages()) |
||||||
|
.setTotal(page.getTotal()) |
||||||
|
.setHasNext(page.getCurrent() < page.getPages()) |
||||||
|
.setRows(list); |
||||||
|
return toPage; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 转换分页结果 |
||||||
|
* <i>用于处理结果的List数据</i> |
||||||
|
* |
||||||
|
* @param page 分页数据来源 |
||||||
|
* @param list 处理后的List |
||||||
|
* @return {@code <T> VPage<T>} |
||||||
|
*/ |
||||||
|
public static <A, B> VPage<B> to(VPage<A> page, List<B> list) { |
||||||
|
VPage<B> toPage = new VPage<>(); |
||||||
|
toPage.setPageNumber(page.getPageNumber()) |
||||||
|
.setPageSize(page.getPageSize()) |
||||||
|
.setTotalPageNumber(page.getTotalPageNumber()) |
||||||
|
.setTotal(page.getTotal()) |
||||||
|
.setHasNext(page.isHasNext()) |
||||||
|
.setRows(list); |
||||||
|
return toPage; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,50 @@ |
|||||||
|
package cn.soul2.demo.vo; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
import java.time.LocalDateTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-08-15 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Data |
||||||
|
@Accessors(chain = true) |
||||||
|
public class DemoVO { |
||||||
|
|
||||||
|
/** |
||||||
|
* 主键 |
||||||
|
*/ |
||||||
|
private String id; |
||||||
|
|
||||||
|
/** |
||||||
|
* 名字 |
||||||
|
*/ |
||||||
|
private String name; |
||||||
|
|
||||||
|
/** |
||||||
|
* 属性1 |
||||||
|
*/ |
||||||
|
private String attr1; |
||||||
|
|
||||||
|
/** |
||||||
|
* 属性2 |
||||||
|
*/ |
||||||
|
private String attr2; |
||||||
|
|
||||||
|
/** |
||||||
|
* 更新时间 |
||||||
|
*/ |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private LocalDateTime updatedTime; |
||||||
|
|
||||||
|
/** |
||||||
|
* 创建时间 |
||||||
|
*/ |
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||||
|
private LocalDateTime createdTime; |
||||||
|
|
||||||
|
} |
@ -0,0 +1,46 @@ |
|||||||
|
package cn.soul2.demo.vo.base; |
||||||
|
|
||||||
|
import cn.soul2.demo.codemessage.BackCodeMessage; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-08-22 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Data |
||||||
|
@Accessors(chain = true) |
||||||
|
public class Back<T> { |
||||||
|
|
||||||
|
private Integer code; |
||||||
|
private String message; |
||||||
|
private String errorMessage; |
||||||
|
private T data; |
||||||
|
|
||||||
|
public Back() { |
||||||
|
} |
||||||
|
|
||||||
|
public Back(Integer code, String message) { |
||||||
|
this.code = code; |
||||||
|
this.message = message; |
||||||
|
} |
||||||
|
|
||||||
|
public Back(Integer code, String message, T data) { |
||||||
|
this.code = code; |
||||||
|
this.message = message; |
||||||
|
this.data = data; |
||||||
|
} |
||||||
|
|
||||||
|
public Back(BackCodeMessage backCodeMessage) { |
||||||
|
this.code = backCodeMessage.getCode(); |
||||||
|
this.message = backCodeMessage.getMessage(); |
||||||
|
} |
||||||
|
|
||||||
|
public Back(BackCodeMessage backCodeMessage, T data) { |
||||||
|
this.code = backCodeMessage.getCode(); |
||||||
|
this.message = backCodeMessage.getMessage(); |
||||||
|
this.data = data; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,72 @@ |
|||||||
|
package cn.soul2.demo.vo.base; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
import lombok.experimental.Accessors; |
||||||
|
|
||||||
|
import java.util.Collections; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author Soul2 |
||||||
|
* @date 2022-08-22 |
||||||
|
*/ |
||||||
|
|
||||||
|
@Data |
||||||
|
@Accessors(chain = true) |
||||||
|
public class VPage<T> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 默认第一页 |
||||||
|
*/ |
||||||
|
public static final long DEFAULT_PAGE_NUMBER = 1L; |
||||||
|
/** |
||||||
|
* 默认每页的个数 |
||||||
|
*/ |
||||||
|
public static final long DEFAULT_PAGE_SIZE = 10L; |
||||||
|
/** |
||||||
|
* 每页最多的个数 |
||||||
|
*/ |
||||||
|
public static final long MAX_PAGE_SIZE = 200L; |
||||||
|
/** |
||||||
|
* 页码 |
||||||
|
*/ |
||||||
|
private long pageNumber = DEFAULT_PAGE_NUMBER; |
||||||
|
/** |
||||||
|
* 分页大小 |
||||||
|
*/ |
||||||
|
private long pageSize = DEFAULT_PAGE_SIZE; |
||||||
|
/** |
||||||
|
* 总页数 |
||||||
|
*/ |
||||||
|
private long totalPageNumber = 0L; |
||||||
|
/** |
||||||
|
* 总数据量 |
||||||
|
*/ |
||||||
|
private long total = 0L; |
||||||
|
/** |
||||||
|
* 是否有下一页 |
||||||
|
*/ |
||||||
|
private boolean hasNext = Boolean.FALSE; |
||||||
|
/** |
||||||
|
* 当前分页的数据 |
||||||
|
*/ |
||||||
|
private List<T> rows = Collections.emptyList(); |
||||||
|
|
||||||
|
public VPage() { |
||||||
|
} |
||||||
|
|
||||||
|
public VPage(long pageNumber, long pageSize) { |
||||||
|
this.pageNumber = pageNumber; |
||||||
|
this.pageSize = pageSize; |
||||||
|
} |
||||||
|
|
||||||
|
public VPage(long pageNumber, long pageSize, long totalPageNumber, long total, boolean hasNext, List<T> rows) { |
||||||
|
this.pageNumber = pageNumber; |
||||||
|
this.pageSize = pageSize; |
||||||
|
this.totalPageNumber = totalPageNumber; |
||||||
|
this.total = total; |
||||||
|
this.hasNext = hasNext; |
||||||
|
this.rows = rows; |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,19 @@ |
|||||||
|
# 允许跨域的地址 |
||||||
|
|
||||||
|
cors: |
||||||
|
allow-origin: http://localhost |
||||||
|
|
||||||
|
--- |
||||||
|
spring: |
||||||
|
config: |
||||||
|
activate: |
||||||
|
on-profile: dev |
||||||
|
|
||||||
|
cors: |
||||||
|
allow-origin: http://localhost:6901 |
||||||
|
|
||||||
|
--- |
||||||
|
spring: |
||||||
|
config: |
||||||
|
activate: |
||||||
|
on-profile: prod |
@ -0,0 +1,19 @@ |
|||||||
|
spring.datasource.druid: |
||||||
|
# MySQL |
||||||
|
url: jdbc:mysql://next.soul2.cn:3306/cn_soul2?characterEncoding=utf8&serverTimezone=GMT%2B8 |
||||||
|
username: buildemo |
||||||
|
password: 86ba@qybgz |
||||||
|
driver-class-name: com.mysql.cj.jdbc.Driver |
||||||
|
# 连接池配置 |
||||||
|
initial-size: 1 |
||||||
|
max-active: 5 |
||||||
|
max-wait: 60000 |
||||||
|
pool-prepared-statements: true |
||||||
|
max-pool-prepared-statement-per-connection-size: 5 |
||||||
|
max-open-prepared-statements: 5 |
||||||
|
validation-query: select 1 from dual |
||||||
|
validation-query-timeout: 10000 |
||||||
|
test-on-borrow: false |
||||||
|
test-on-return: false |
||||||
|
test-while-idle: true |
||||||
|
time-between-eviction-runs-millis: 60000 |
@ -0,0 +1,5 @@ |
|||||||
|
# mybatis-plus 逻辑删除配置 |
||||||
|
mybatis-plus.global-config.db-config: |
||||||
|
dbType: mysql |
||||||
|
logic-delete-value: 1 |
||||||
|
logic-not-delete-value: 0 |
@ -0,0 +1,16 @@ |
|||||||
|
server: |
||||||
|
#端口 |
||||||
|
port: 7301 |
||||||
|
#上下文 |
||||||
|
servlet.context-path: / |
||||||
|
|
||||||
|
|
||||||
|
spring: |
||||||
|
application.name: java-demo |
||||||
|
profiles.include: datasource,mybatis-plus,cors |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
mybatis-plus: |
||||||
|
configuration: |
||||||
|
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志 |
@ -0,0 +1,13 @@ |
|||||||
|
package cn.soul2.demo; |
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test; |
||||||
|
import org.springframework.boot.test.context.SpringBootTest; |
||||||
|
|
||||||
|
@SpringBootTest |
||||||
|
class JavaDemoApplicationTests { |
||||||
|
|
||||||
|
@Test |
||||||
|
void contextLoads() { |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue