parent
70a9370c90
commit
6e8deddaf3
@ -1,2 +1,8 @@
|
||||
# market
|
||||
# 线上营销管理平台——说明
|
||||
|
||||
|
||||
|
||||
```
|
||||
获取代码后,将数据库指向自己团队的数据库。
|
||||
12312311
|
||||
```
|
@ -0,0 +1,31 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**
|
||||
!**/src/test/**
|
||||
|
||||
### 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/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
@ -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,198 @@
|
||||
<?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.2.2.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.universe</groupId>
|
||||
<artifactId>marketing-mgt</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>marketing</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<java.version>1.8</java.version>
|
||||
<fastjson.version>1.2.70</fastjson.version>
|
||||
<consul.version>2.2.0.RELEASE</consul.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!--分页插件-->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
<version>5.1.10</version>
|
||||
</dependency>
|
||||
<!--redis-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.4</version>
|
||||
</dependency>
|
||||
<!--可执行的Springboot Web 应用-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!--引入AOP依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<!--token-->
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-core</artifactId>
|
||||
<version>1.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.1</version>
|
||||
</dependency>
|
||||
<!--MP-plus-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-extension</artifactId>
|
||||
<version>3.4.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.0.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<version>${postgresql.version}</version>
|
||||
</dependency>
|
||||
<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>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.junit.vintage</groupId>
|
||||
<artifactId>junit-vintage-engine</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
|
||||
<dependency>
|
||||
<groupId>com.thoughtworks.xstream</groupId>
|
||||
<artifactId>xstream</artifactId>
|
||||
<version>1.4.10</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.dom4j/dom4j -->
|
||||
<dependency>
|
||||
<groupId>org.dom4j</groupId>
|
||||
<artifactId>dom4j</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<!--hutool工具-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.7.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.persistence</groupId>
|
||||
<artifactId>persistence-api</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/tk.mybatis/mapper -->
|
||||
<!-- <dependency>
|
||||
<groupId>tk.mybatis</groupId>
|
||||
<artifactId>mapper</artifactId>
|
||||
<version>4.1.5</version>
|
||||
</dependency>
|
||||
|
||||
<!– https://mvnrepository.com/artifact/tk.mybatis/mapper-spring-boot-starter –>
|
||||
<dependency>
|
||||
<groupId>tk.mybatis</groupId>
|
||||
<artifactId>mapper-spring-boot-starter</artifactId>
|
||||
<version>2.1.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.2.12</version>
|
||||
</dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/java</directory>
|
||||
<includes>
|
||||
<include>**/*.xml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,16 @@
|
||||
package com.universe;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
|
||||
@SpringBootApplication//(scanBasePackages = {"com.universe"})
|
||||
@MapperScan("com.universe.marketing.*.mapper")
|
||||
public class MarketingMgtApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MarketingMgtApplication.class, args);
|
||||
}
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.universe.aop;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author yuanjs
|
||||
* @description:
|
||||
* @date 2020-04-08 11:30
|
||||
*/
|
||||
@Slf4j
|
||||
@Aspect
|
||||
@Component
|
||||
public class LogAspect {
|
||||
|
||||
|
||||
|
||||
@Pointcut("@annotation(io.swagger.annotations.ApiOperation)")
|
||||
public void pointCut() {
|
||||
//定义切点
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 发送日志
|
||||
// * @param logStr
|
||||
// */
|
||||
// private void sendLog(String cookies,String logStr) {
|
||||
// new Thread(() -> {
|
||||
// try {
|
||||
// Map<String,String> ck=HttpUtil.cookieToMap(cookies);
|
||||
// HashMap<String, String> hash = new HashMap<>();
|
||||
// hash.put("userName", hash.get("username"));
|
||||
// hash.put("projectId", hash.get("projectid"));
|
||||
// hash.put("content", logStr);
|
||||
// HttpUtil.sendPostRequest(url, hash);
|
||||
// } catch (Exception ex) {
|
||||
// log.error("LogAspect中向远程发送日志失败");
|
||||
// }
|
||||
// }).start();
|
||||
// }
|
||||
|
||||
|
||||
@Before("pointCut()")
|
||||
public void before(JoinPoint joinPoint) {
|
||||
try {
|
||||
|
||||
RequestAttributes ra = RequestContextHolder.getRequestAttributes();
|
||||
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
HttpServletRequest request = (HttpServletRequest) ra.resolveReference(RequestAttributes.REFERENCE_REQUEST);
|
||||
String cookiesStr = request.getHeader("Cookie");
|
||||
if (!StringUtils.isEmpty(cookiesStr)) {
|
||||
log.info(cookiesStr);
|
||||
}
|
||||
//处理cookies
|
||||
|
||||
Api api = method.getDeclaringClass().getAnnotation(Api.class);
|
||||
String apiValue = "", operationValue = "";
|
||||
if (api != null) {
|
||||
apiValue = api.value();
|
||||
}
|
||||
ApiOperation operation = method.getAnnotation(ApiOperation.class);
|
||||
if (operation != null) {
|
||||
operationValue = operation.value();
|
||||
}
|
||||
|
||||
String logContent = String.format("%s-%s", apiValue, operationValue);
|
||||
log.info(logContent);
|
||||
|
||||
} catch (Exception ex) {
|
||||
log.error("LogAspect采集日志发生错误");
|
||||
log.error(ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.universe.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author yuanjs
|
||||
* @description:
|
||||
* @date 2020-06-22 8:04
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@Order(value = 1)
|
||||
public class DirtyDataRunnerImpl implements CommandLineRunner {
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
log.debug("SpringBoot启动后执行……");
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.universe.config;
|
||||
|
||||
import com.universe.config.Login.LoginInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* 登录拦截器
|
||||
*/
|
||||
@Configuration
|
||||
public class InterceptorConfig implements WebMvcConfigurer {
|
||||
// @Override
|
||||
// public void addInterceptors(InterceptorRegistry registry) {
|
||||
// registry.addInterceptor(LoginInterceptor())
|
||||
// .addPathPatterns("/**")
|
||||
// .excludePathPatterns("/login");
|
||||
// }
|
||||
@Bean
|
||||
public LoginInterceptor LoginInterceptor(){
|
||||
return new LoginInterceptor();
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.universe.config.Login;
|
||||
|
||||
|
||||
import com.universe.marketing.users.entity.Users;
|
||||
import com.universe.marketing.users.mapper.UsersMapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
public class LoginInterceptor implements HandlerInterceptor {
|
||||
@Autowired
|
||||
private UsersMapper usersMapper;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
String name = request.getHeader("name");
|
||||
if (StringUtils.isBlank(name)) {
|
||||
return false;
|
||||
}
|
||||
Users users = usersMapper.selectByUsername(name);
|
||||
if (users == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.universe.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
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;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class MPConfig implements WebMvcConfigurer {
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor(){
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.POSTGRE_SQL));
|
||||
return interceptor;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.universe.handler;
|
||||
|
||||
/**
|
||||
* @author yuanjs
|
||||
* @description:
|
||||
* @date 2019-11-23 20:14
|
||||
*/
|
||||
public class BusinessException extends RuntimeException {
|
||||
|
||||
public BusinessException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.universe.handler;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author yuanjs
|
||||
* @description:
|
||||
* @date 2019-11-23 20:13
|
||||
*/
|
||||
@Data
|
||||
public class ErrorInfo<T> {
|
||||
|
||||
public static final Integer OK = 0;
|
||||
public static final Integer ERROR = 500;
|
||||
private String errorType;
|
||||
private Integer code;
|
||||
private String message;
|
||||
private String url;
|
||||
private T exception;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.universe.handler;
|
||||
|
||||
import com.universe.marketing.users.entity.Utils.R;
|
||||
import org.springframework.web.bind.annotation.ControllerAdvice;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
@ControllerAdvice
|
||||
public class GlobalExceptionHandler {
|
||||
@ExceptionHandler(BusinessException.class)
|
||||
@ResponseBody
|
||||
public R handle(BusinessException be){
|
||||
return R.fail(be.getMessage());
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.universe.marketing.client.controller;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.universe.marketing.client.pojo.dto.ClientDto;
|
||||
import com.universe.marketing.client.pojo.entity.ClientEntity;
|
||||
import com.universe.marketing.client.pojo.vo.Result;
|
||||
import com.universe.marketing.client.service.ClientService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
@Api(value = "客户信息管理",tags = {"客户信息管理"})
|
||||
@RestController
|
||||
@RequestMapping("/client")
|
||||
public class ClientController {
|
||||
@Autowired
|
||||
private ClientService clientService;
|
||||
@ApiOperation(value = "分页查询客户信息")
|
||||
@PostMapping("/select")
|
||||
public PageInfo<ClientDto> query(
|
||||
@RequestParam(defaultValue = "1") int pageNum,
|
||||
@RequestParam(defaultValue = "#{T(java.lang.Integer).MAX_VALUE}") int pageSize) {
|
||||
return clientService.query(pageNum, pageSize);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加客户信息")
|
||||
@PostMapping("/add")
|
||||
public Result insertClient(ClientDto clientDto){
|
||||
return clientService.insertClient(clientDto);
|
||||
}
|
||||
@ApiOperation(value = "修改客户信息")
|
||||
@PostMapping("/update")
|
||||
public Result updateClient(ClientDto clientDto){
|
||||
Result flag = clientService.updateClient(clientDto);
|
||||
return flag;
|
||||
}
|
||||
@ApiOperation(value = "删除客户信息")
|
||||
@PostMapping("/delete")
|
||||
public Result deleteClient(String clientId){
|
||||
Result flag = clientService.deleteClient(clientId);
|
||||
return flag;
|
||||
}
|
||||
@ApiOperation(value = "查询客户信息")
|
||||
@GetMapping("/query")
|
||||
public ClientEntity selectClient(String clientId){
|
||||
return clientService.selectClient(clientId);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.universe.marketing.client.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.universe.marketing.client.pojo.entity.ClientEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
|
||||
@Repository
|
||||
|
||||
public interface ClientMapper extends BaseMapper<ClientEntity> {
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.universe.marketing.client.pojo.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 数据传输对象
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ClientDto {
|
||||
private String clientId;
|
||||
private String clientName;
|
||||
private String clientPhone;
|
||||
private String clientAddress;
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.universe.marketing.client.pojo.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 实体类
|
||||
*/
|
||||
@Data
|
||||
@TableName("client_manage")
|
||||
public class ClientEntity {
|
||||
@TableId
|
||||
private String clientId;
|
||||
private String clientName;
|
||||
private String clientPhone;
|
||||
private String clientAddress;
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.universe.marketing.client.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 视图对象
|
||||
*/
|
||||
@Data
|
||||
public class ClientVo {
|
||||
private String clientId;
|
||||
private String clientName;
|
||||
private String clientPhone;
|
||||
private String clientAddress;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.universe.marketing.client.service;
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.universe.marketing.client.pojo.dto.ClientDto;
|
||||
import com.universe.marketing.client.pojo.entity.ClientEntity;
|
||||
import com.universe.marketing.client.pojo.vo.Result;
|
||||
|
||||
|
||||
public interface ClientService {
|
||||
//添加客户信息
|
||||
Result insertClient(ClientDto clientDto);
|
||||
//删除客户信息
|
||||
Result deleteClient(String clientId);
|
||||
//修改客户信息
|
||||
Result updateClient(ClientDto clientDto);
|
||||
//分页查询
|
||||
PageInfo<ClientDto> query(int pageNum, int pageSize);
|
||||
//查询客户信息
|
||||
ClientEntity selectClient(String clientId);
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.universe.marketing.client.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.universe.marketing.client.mapper.ClientMapper;
|
||||
import com.universe.marketing.client.pojo.dto.ClientDto;
|
||||
import com.universe.marketing.client.pojo.entity.ClientEntity;
|
||||
import com.universe.marketing.client.pojo.vo.Result;
|
||||
import com.universe.marketing.client.service.ClientService;
|
||||
import com.universe.utils.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ClientServiceImpl implements ClientService {
|
||||
@Autowired
|
||||
private ClientMapper clientMapper;
|
||||
|
||||
@Override
|
||||
public Result insertClient(ClientDto clientDto) {
|
||||
ClientEntity clientEntity = new ClientEntity();
|
||||
BeanUtils.copyProperties(clientDto,clientEntity);
|
||||
clientEntity.setClientId(UUIDUtils.generateId());
|
||||
if(clientMapper.insert(clientEntity)>0){
|
||||
return Result.success("客户信息添加成功");
|
||||
}return Result.fail("客户信息添加失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteClient(String clientId) {
|
||||
LambdaQueryWrapper<ClientEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ClientEntity::getClientId,clientId);
|
||||
int id = clientMapper.delete(wrapper);
|
||||
if(id>0){
|
||||
return Result.success("客户信息删除成功");
|
||||
}return Result.fail("客户信息删除失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateClient(ClientDto clientDto) {
|
||||
|
||||
String id = clientDto.getClientId();
|
||||
ClientEntity client = new ClientEntity();
|
||||
client.setClientId(id);
|
||||
BeanUtils.copyProperties(clientDto,client);
|
||||
LambdaQueryWrapper<ClientEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ClientEntity::getClientId, id);
|
||||
|
||||
if(clientMapper.update(client, wrapper)>0){
|
||||
return Result.success("客户信息修改成功");
|
||||
}return Result.fail("客户信息修改失败");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PageInfo<ClientDto> query(int pageNum, int pageSize) {
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
return new PageInfo(clientMapper.selectList(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientEntity selectClient(String clientId) {
|
||||
LambdaQueryWrapper<ClientEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ClientEntity::getClientId,clientId);
|
||||
return clientMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.universe.marketing.login.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.universe.marketing.login.pojo.po.User;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.universe.marketing.login.pojo.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LoginDto {
|
||||
private String username;
|
||||
private String password;
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.universe.marketing.login.pojo.dto;
|
||||
|
||||
public class RegisterDto {
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.universe.marketing.login.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@TableName("users")
|
||||
public class User {
|
||||
private String id;
|
||||
private String enabled;
|
||||
private String name;
|
||||
private String password;
|
||||
private long telNumber;
|
||||
private String realName;
|
||||
private String roleName;
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package com.universe.marketing.login.service.Impl;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.universe.marketing.login.mapper.UserMapper;
|
||||
import com.universe.marketing.login.pojo.dto.LoginDto;
|
||||
import com.universe.marketing.login.pojo.po.User;
|
||||
import com.universe.marketing.login.service.LoginService;
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
import com.universe.utils.ChUtils.JWTUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@Transactional //事务回滚 理应加载接口类上 这里只有一个实现类
|
||||
public class LoginServiceImpl implements LoginService {
|
||||
@Autowired
|
||||
UserMapper userMapper;
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
private static final String slat = "chh!@#";
|
||||
|
||||
@Override
|
||||
public Result login(LoginDto loginDto) {
|
||||
if(StringUtils.isBlank(loginDto.getUsername()) || StringUtils.isBlank(loginDto.getUsername())){
|
||||
return Result.fail("用户名或密码为空");
|
||||
}
|
||||
//String password = DigestUtils.md5Hex(loginDto.getPassword() + slat);
|
||||
User existUser = isExistUser(loginDto.getUsername(), loginDto.getPassword());
|
||||
if(existUser==null) {
|
||||
return new Result().fail("用户名或密码错误");
|
||||
}
|
||||
String token = JWTUtils.createToken(existUser.getId());
|
||||
redisTemplate.opsForValue().set("TOKEN_" + token, JSON.toJSONString(existUser), 1, TimeUnit.DAYS);
|
||||
return Result.succ("登录成功!", token);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检擦用户名密码是否正确
|
||||
* @param username
|
||||
* @param password
|
||||
* @return
|
||||
*/
|
||||
private User isExistUser(String username, String password) {
|
||||
LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(User::getName, username);
|
||||
wrapper.eq(User::getPassword, password);
|
||||
return userMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result loginOut(String token) {
|
||||
redisTemplate.delete("TOKEN_" + token);
|
||||
return Result.succ("成功退出!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result findUserByToken(String token) {
|
||||
User user = checkToken(token);
|
||||
if(user!=null){
|
||||
return Result.succ(user);
|
||||
}
|
||||
return Result.fail();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查token是否正确
|
||||
* @param token
|
||||
* @return
|
||||
*/
|
||||
public User checkToken(String token) {
|
||||
//验证Token
|
||||
if(StringUtils.isBlank(token)){//是否为空
|
||||
return null;
|
||||
}
|
||||
Map<String, Object> stringObjectMap = JWTUtils.checkToken(token);
|
||||
if(stringObjectMap == null){
|
||||
return null;
|
||||
}
|
||||
String userJson = redisTemplate.opsForValue().get("TOKEN_" + token);
|
||||
if(StringUtils.isBlank(userJson)){
|
||||
return null;
|
||||
}
|
||||
User user = JSON.parseObject(userJson, User.class);
|
||||
return user;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.universe.marketing.login.service;
|
||||
|
||||
import com.universe.marketing.login.pojo.dto.LoginDto;
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
|
||||
public interface LoginService {
|
||||
Result login(LoginDto loginDto);
|
||||
Result loginOut(String token);
|
||||
Result findUserByToken(String token);
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.universe.marketing.product.controller;
|
||||
|
||||
import com.universe.marketing.product.mapper.ProductMapper;
|
||||
import com.universe.marketing.product.pojo.dto.PageParamDto;
|
||||
import com.universe.marketing.product.pojo.dto.ProductDto;
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
import com.universe.marketing.product.service.Impl.ProductServiceImpl;
|
||||
import com.universe.marketing.product.service.ProductService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/product")
|
||||
@Api(value = "产品管理",tags = {"产品管理"})
|
||||
public class ProductController {
|
||||
@Autowired
|
||||
private ProductService productService;
|
||||
|
||||
@ApiOperation(value = "添加产品")
|
||||
@PostMapping("/add")
|
||||
public Result addProduct(@RequestBody ProductDto productDto){
|
||||
return productService.addProduct(productDto);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改产品信息")
|
||||
@PostMapping("/update")
|
||||
public Result updateProduct(@RequestBody ProductDto productDto){
|
||||
return productService.updateProduct(productDto);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除产品信息")
|
||||
@PostMapping("/del/{productId}")
|
||||
public Result delProduct(@PathVariable("productId") String productId){
|
||||
return productService.delProductById(productId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询产品名称和种类列表")
|
||||
@GetMapping("/list")
|
||||
public Result queryList(){
|
||||
return Result.succ(productService.queryProductList());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "分页查询产品列表")
|
||||
@PostMapping("/query/page")
|
||||
public Result queryPageProductList(@RequestBody PageParamDto pageParamDto){
|
||||
return productService.queryPageProduceList(pageParamDto);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.universe.marketing.product.controller;
|
||||
|
||||
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
import com.universe.marketing.product.service.SortService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("sort")
|
||||
@Api(value = "分类管理",tags = {"分类管理"})
|
||||
public class SortController {
|
||||
|
||||
@Autowired
|
||||
private SortService sortService;
|
||||
|
||||
@ApiOperation(value = "添加分类")
|
||||
@PostMapping("add")
|
||||
public Result addSort(@RequestParam String sortName){
|
||||
return sortService.addSort(sortName);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除分类")
|
||||
@PostMapping("del/{sortId}")
|
||||
public Result delSort(@PathVariable("sortId") String sortId){
|
||||
return sortService.delSort(sortId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询分类列表")
|
||||
@GetMapping("list")
|
||||
public Result allSort(){
|
||||
return sortService.queryAllSort();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.universe.marketing.product.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.universe.marketing.product.pojo.po.Product;
|
||||
import com.universe.marketing.product.pojo.vo.ProductShowListVo;
|
||||
import com.universe.marketing.product.pojo.vo.ProductSortListVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductMapper extends BaseMapper<Product> {
|
||||
//查询商品的基础信息列表
|
||||
List<ProductSortListVo> queryProductList();
|
||||
//根据商品名称分页模糊查询商品列表
|
||||
List<ProductShowListVo> queryPageProductList(int pageSize, int pageNum, String query);
|
||||
//获取模糊查询的条数 total
|
||||
int queryPageProductCount(String query);
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.universe.marketing.product.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.universe.marketing.product.pojo.po.Sort;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface SortMapper extends BaseMapper<Sort> {
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.universe.marketing.product.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PageParamDto {
|
||||
private int pageSize = 1;//每页显示条数
|
||||
private int pageNum = 10;//每页个数
|
||||
private String query;
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.universe.marketing.product.pojo.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 接受上传的商品信息
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ProductDto {
|
||||
private String productId;
|
||||
private String productName ;
|
||||
private String productDescribe;
|
||||
private Double productPricePurchase;
|
||||
private Double productPriceShipment;
|
||||
private Double productPriceSuggest;
|
||||
private String productFormat;
|
||||
private Integer state;
|
||||
private String personId;
|
||||
private String sortId;
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package com.universe.marketing.product.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName(value = "product_manage")
|
||||
public class Product {
|
||||
@TableId(type = IdType.ASSIGN_UUID)
|
||||
@TableField("product_id")
|
||||
private String productId;
|
||||
|
||||
@TableField("product_name")
|
||||
private String productName;
|
||||
|
||||
@TableField("product_describe")
|
||||
private String productDescribe;
|
||||
|
||||
@TableField("product_price_purchase")
|
||||
private Double productPricePurchase; //进价
|
||||
|
||||
@TableField("product_price_shipment")
|
||||
private Double productPriceShipment;//出货价
|
||||
|
||||
@TableField("product_price_suggest")
|
||||
private Double productPriceSuggest;//建议零售价
|
||||
|
||||
@TableField("product_format")
|
||||
private String productFormat;
|
||||
|
||||
@TableField("state")
|
||||
private Integer state;
|
||||
|
||||
@TableField("create_datetime")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createDatetime;
|
||||
|
||||
@TableField("update_datetime")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateDatetime;
|
||||
|
||||
@TableField("person_id")
|
||||
private String personId;
|
||||
|
||||
@TableField("sort_id")
|
||||
private String sortId;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.universe.marketing.product.pojo.po;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("product_sort")
|
||||
public class Sort {
|
||||
@TableId()
|
||||
private String sortId;
|
||||
private String sortName;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.universe.marketing.product.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ProductListVo {
|
||||
private String productId;
|
||||
private String productName;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.universe.marketing.product.pojo.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ProductPageListVo {
|
||||
private Integer total;
|
||||
private List<ProductShowListVo> productShowList;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.universe.marketing.product.pojo.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ProductShowListVo {
|
||||
private String productId;
|
||||
private String productName;
|
||||
private String productDescribe;
|
||||
private Double productPricePurchase; //进价
|
||||
private Double productPriceShipment;//出货价
|
||||
private Double productPriceSuggest;//建议零售价
|
||||
private String productFormat;
|
||||
private Integer state;
|
||||
private Date createDatetime;
|
||||
private Date updateDatetime;
|
||||
private String name;
|
||||
private String sortName;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.universe.marketing.product.pojo.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class ProductSortListVo {
|
||||
private String productName;
|
||||
private Double productPricePurchase;
|
||||
private String sortName;
|
||||
private String productId;
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.universe.marketing.product.service.Impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.universe.marketing.product.mapper.ProductMapper;
|
||||
import com.universe.marketing.product.pojo.dto.ProductDto;
|
||||
import com.universe.marketing.product.pojo.dto.PageParamDto;
|
||||
import com.universe.marketing.product.pojo.po.Product;
|
||||
import com.universe.marketing.product.pojo.vo.ProductPageListVo;
|
||||
import com.universe.marketing.product.pojo.vo.ProductShowListVo;
|
||||
import com.universe.marketing.product.pojo.vo.ProductSortListVo;
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
import com.universe.marketing.product.service.ProductService;
|
||||
import com.universe.utils.UuidUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ProductServiceImpl implements ProductService {
|
||||
@Autowired
|
||||
private ProductMapper productMapper;
|
||||
|
||||
@Override
|
||||
public Result addProduct(ProductDto productDto) {
|
||||
Product product = new Product();
|
||||
BeanUtils.copyProperties(productDto, product);
|
||||
product.setProductId(UuidUtil.getUuid());
|
||||
//添加
|
||||
if(productMapper.insert(product)>0){
|
||||
return Result.succ("商品添加成功!");
|
||||
}
|
||||
return Result.fail("商品添加失败!请检查参数");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result delProductById(String productId) {
|
||||
LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Product::getProductId, productId);
|
||||
//删除
|
||||
if(productMapper.delete(wrapper)>0){
|
||||
return Result.succ("删除成功!");
|
||||
}
|
||||
return Result.fail("删除失败!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateProduct(ProductDto productDto) {
|
||||
LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Product::getProductId, productDto.getProductId());
|
||||
Product product = new Product();
|
||||
BeanUtils.copyProperties(productDto, product);
|
||||
product.setUpdateDatetime(new Date());
|
||||
//修改
|
||||
if(productMapper.update(product, wrapper)>0){
|
||||
return Result.succ("商品修改成功!");
|
||||
}
|
||||
return Result.fail("商品修改失败!请检查参数");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result queryPageProduceList(PageParamDto pageParamDto) {
|
||||
//查询total
|
||||
int total = productMapper.queryPageProductCount(pageParamDto.getQuery());
|
||||
//获取符合条件的商品列表
|
||||
List<ProductShowListVo> list = productMapper.queryPageProductList(pageParamDto.getPageNum()*(pageParamDto.getPageSize()-1),
|
||||
pageParamDto.getPageNum(),
|
||||
pageParamDto.getQuery());
|
||||
return Result.succ(new ProductPageListVo(total, list));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result queryProductList() {
|
||||
List<ProductSortListVo> list = productMapper.queryProductList();
|
||||
return Result.succ(list);
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package com.universe.marketing.product.service.Impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.universe.marketing.product.mapper.SortMapper;
|
||||
import com.universe.marketing.product.pojo.po.Sort;
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
import com.universe.marketing.product.service.SortService;
|
||||
import com.universe.utils.UuidUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service
|
||||
public class SortServiceImpl implements SortService {
|
||||
|
||||
@Autowired
|
||||
private SortMapper sortMapper;
|
||||
|
||||
@Override
|
||||
public Result addSort(String sortName) {
|
||||
|
||||
Sort sort = new Sort(UuidUtil.getUuid(), sortName);
|
||||
System.out.println(sort);
|
||||
if(sortMapper.insert(sort)>0){
|
||||
return Result.succ("添加分类成功!");
|
||||
}
|
||||
return Result.fail("添加分类失败!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result delSort(String sortId) {
|
||||
LambdaQueryWrapper<Sort> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(Sort::getSortId, sortId);
|
||||
if(sortMapper.delete(wrapper)>0){
|
||||
return Result.succ("删除分类成功!");
|
||||
}
|
||||
return Result.fail("删除分类失败!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result queryAllSort() {
|
||||
return Result.succ(sortMapper.selectList(null));
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.universe.marketing.product.service;
|
||||
|
||||
import com.universe.marketing.product.pojo.dto.ProductDto;
|
||||
import com.universe.marketing.product.pojo.dto.PageParamDto;
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
|
||||
public interface ProductService {
|
||||
//添加商品
|
||||
Result addProduct(ProductDto productDto);
|
||||
//删除商品
|
||||
Result delProductById(String productId);
|
||||
//更新商品
|
||||
Result updateProduct(ProductDto productDto);
|
||||
//分页查询商品
|
||||
Result queryPageProduceList(PageParamDto pageParamDto);
|
||||
//查询商品的名称喝种类名称
|
||||
Result queryProductList();
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.universe.marketing.product.service;
|
||||
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
|
||||
public interface SortService {
|
||||
//添加分类
|
||||
Result addSort(String sortName);
|
||||
//删除分类
|
||||
Result delSort(String sortId);
|
||||
//查询分类列表
|
||||
Result queryAllSort();
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.universe.marketing.purchase.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
import com.universe.marketing.purchase.mapper.PurchaseMapper;
|
||||
import com.universe.marketing.purchase.pojo.dto.PurchaseDto;
|
||||
import com.universe.marketing.purchase.pojo.dto.PurchaseSonDto;
|
||||
import com.universe.marketing.purchase.pojo.dto.QueryPurchasePageDto;
|
||||
import com.universe.marketing.purchase.pojo.dto.QueryPurchaseSonListDto;
|
||||
import com.universe.marketing.purchase.pojo.po.Purchase;
|
||||
import com.universe.marketing.purchase.service.PurchaseService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/purchase")
|
||||
@Api(value = "进货管理",tags = {"进货管理"})
|
||||
public class PurchaseController {
|
||||
|
||||
@Autowired
|
||||
PurchaseService purchaseService;
|
||||
|
||||
@PostMapping("/son/add")
|
||||
@ApiOperation(value = "添加进货分表信息")
|
||||
public Result addPurchaseSon(@RequestBody PurchaseSonDto purchaseSonDto){
|
||||
return purchaseService.insertPurchaseSonMsg(purchaseSonDto);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation(value = "添加进货总表信息")
|
||||
public Result addPurchase(@RequestBody PurchaseDto purchaseDto){
|
||||
return purchaseService.insertPurchaseMsg(purchaseDto);
|
||||
}
|
||||
|
||||
@PostMapping("/son/list")
|
||||
@ApiOperation(value = "根据进货总表Id查询对应信息")
|
||||
public Result queryPurchaseSonList(@RequestBody QueryPurchaseSonListDto queryDto){
|
||||
return purchaseService.queryPurchaseSonById(queryDto);
|
||||
}
|
||||
|
||||
@PostMapping("/page/list")
|
||||
@ApiOperation(value = "分页模糊查询进货总表信息")
|
||||
public Result queryPurchasePageList(@RequestBody QueryPurchasePageDto queryDto) throws ParseException {
|
||||
return purchaseService.queryPurchasePage(queryDto);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.universe.marketing.purchase.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.universe.marketing.purchase.pojo.po.Purchase;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PurchaseMapper extends BaseMapper<Purchase> {
|
||||
//分页模糊查询进货表的列表(根据开始时间和负责人 选填)
|
||||
List<Purchase> queryPageList(int pageNum, int pageSize, String person, String beginTime);
|
||||
//查询符合条件的列表个数 total
|
||||
int queryPageListCount(String person, String beginTime);
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.universe.marketing.purchase.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.universe.marketing.purchase.pojo.po.PurchaseSon;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PurchaseSonMapper extends BaseMapper<PurchaseSon> {
|
||||
//查询当前进货分表的列表
|
||||
List<PurchaseSon> queryNowPurchaseSonList(List<String> list);
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.universe.marketing.purchase.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.universe.marketing.purchase.pojo.po.PurchaseSwap;
|
||||
import com.universe.marketing.purchase.pojo.vo.PurchaseSonVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PurchaseSwapMapper extends BaseMapper<PurchaseSwap> {
|
||||
//绑定进货表和进货分表
|
||||
int insertSwap(@Param("purchaseId")String purchaseId, List<String> list);
|
||||
//通过进货表来查询进货分表的列表信息
|
||||
List<PurchaseSonVo> queryPurchaseSonById(String purchaseId, List<String> list, int pageNum, int pageSize);
|
||||
//查询符合条件的进货子表数目
|
||||
int queryPurchaseSonCount(List<String> purchaseIds);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.universe.marketing.purchase.pojo.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PurchaseDto {
|
||||
private String msg;
|
||||
private String purchaseChargePersonId;
|
||||
private List<String> purchaseSonList;
|
||||
private Double totalPrice;
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.universe.marketing.purchase.pojo.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PurchaseSonDto {
|
||||
private String sort_id;
|
||||
private String productId;
|
||||
private Integer purchaseCount;
|
||||
private String productName;
|
||||
private String msg;
|
||||
private Double totalPrice;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.universe.marketing.purchase.pojo.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class QueryPurchasePageDto {
|
||||
private int pageSize = 1;//每页显示条数
|
||||
private int pageNum = 10;//每页个数
|
||||
private String person;
|
||||
private String beginTime;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package com.universe.marketing.purchase.pojo.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class QueryPurchaseSonListDto {
|
||||
private int pageSize = 1;//每页显示条数
|
||||
private int pageNum = 10;//每页个数
|
||||
private String purchaseId;
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.universe.marketing.purchase.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("purchase")
|
||||
public class Purchase {
|
||||
@TableId
|
||||
@TableField("purchase_id")
|
||||
private String purchaseId;
|
||||
@TableField("create_datetime")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createDatetime;
|
||||
@TableField("purchase_charge_person_id")
|
||||
private String purchaseChargePersonId;
|
||||
@TableField("purchase_state")
|
||||
private Integer purchaseState;
|
||||
@TableField("msg")
|
||||
private String msg;
|
||||
@TableField("total_price")
|
||||
private Double totalPrice;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.universe.marketing.purchase.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("purchase_sort")
|
||||
public class PurchaseSon {
|
||||
@TableId
|
||||
@TableField("id")
|
||||
private String id;
|
||||
@TableField("sort_id")
|
||||
private String sort_id;
|
||||
@TableField("purchase_count")
|
||||
Integer purchaseCount;
|
||||
@TableField("purchase_state")
|
||||
private Integer purchaseState;
|
||||
@TableField("manage_datetime")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date manageDatetime;
|
||||
@TableField("msg")
|
||||
private String msg;
|
||||
@TableField("total_price")
|
||||
private double totalPrice;
|
||||
@TableField("purchase_name")
|
||||
private String purchaseName;
|
||||
@TableField("product_id")
|
||||
private String productId;
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.universe.marketing.purchase.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("purchase_swap")
|
||||
public class PurchaseSwap {
|
||||
@TableId
|
||||
@TableField("id")
|
||||
private String id;
|
||||
@TableField("purchase_id")
|
||||
private String purchaseId;
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.universe.marketing.purchase.pojo.vo;
|
||||
|
||||
import com.universe.marketing.purchase.pojo.po.Purchase;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class PurchaseListVo {
|
||||
private Integer total;
|
||||
private List<Purchase> pageList;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.universe.marketing.purchase.pojo.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PurchasePageListVo {
|
||||
private String purchaseId;
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createDatetime;
|
||||
private String name;
|
||||
private Integer purchaseState;
|
||||
private String msg;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.universe.marketing.purchase.pojo.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PurchaseSonPageVo {
|
||||
private Integer total;
|
||||
List<PurchaseSonVo> purchaseSonList;
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.universe.marketing.purchase.pojo.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class PurchaseSonVo {
|
||||
private String id;
|
||||
private String sortName;
|
||||
private Integer purchaseCount;
|
||||
private Integer purchaseState;
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date manageDatetime;
|
||||
private String msg;
|
||||
private String purchaseName;
|
||||
private double totalPrice;
|
||||
|
||||
}
|
@ -0,0 +1,134 @@
|
||||
package com.universe.marketing.purchase.service.Impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
import com.universe.marketing.purchase.mapper.PurchaseMapper;
|
||||
import com.universe.marketing.purchase.mapper.PurchaseSonMapper;
|
||||
import com.universe.marketing.purchase.mapper.PurchaseSwapMapper;
|
||||
import com.universe.marketing.purchase.pojo.dto.PurchaseDto;
|
||||
import com.universe.marketing.purchase.pojo.dto.PurchaseSonDto;
|
||||
import com.universe.marketing.purchase.pojo.dto.QueryPurchasePageDto;
|
||||
import com.universe.marketing.purchase.pojo.dto.QueryPurchaseSonListDto;
|
||||
import com.universe.marketing.purchase.pojo.po.Purchase;
|
||||
import com.universe.marketing.purchase.pojo.po.PurchaseSon;
|
||||
import com.universe.marketing.purchase.pojo.po.PurchaseSwap;
|
||||
import com.universe.marketing.purchase.pojo.vo.PurchaseListVo;
|
||||
import com.universe.marketing.purchase.pojo.vo.PurchaseSonPageVo;
|
||||
import com.universe.marketing.purchase.pojo.vo.PurchaseSonVo;
|
||||
import com.universe.marketing.purchase.service.PurchaseService;
|
||||
import com.universe.marketing.store.mapper.ProductStoreMapper;
|
||||
import com.universe.utils.BeanUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class PurchaseServiceImpl implements PurchaseService {
|
||||
|
||||
@Autowired
|
||||
PurchaseMapper purchaseMapper;
|
||||
@Autowired
|
||||
PurchaseSonMapper purchaseSonMapper;
|
||||
@Autowired
|
||||
PurchaseSwapMapper purchaseSwapMapper;
|
||||
@Autowired
|
||||
ProductStoreMapper productStoreMapper;
|
||||
@Override
|
||||
public Result insertPurchaseSonMsg(PurchaseSonDto purchaseSonDto) {
|
||||
PurchaseSon purchaseSon = new PurchaseSon();
|
||||
BeanUtil.copyNotNullBean(purchaseSonDto, purchaseSon);
|
||||
purchaseSon.setId(UUID.randomUUID().toString());
|
||||
purchaseSon.setPurchaseName(purchaseSonDto.getProductName());
|
||||
if(purchaseSonMapper.insert(purchaseSon)>0){
|
||||
return Result.succ("进货分表添加成功!", purchaseSon.getId());
|
||||
}
|
||||
return Result.fail("进货分表添加失败!");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public Result insertPurchaseMsg(PurchaseDto purchaseDto) {
|
||||
double total = 0;
|
||||
Purchase purchase = new Purchase();
|
||||
BeanUtil.copyNotNullBean(purchaseDto, purchase);
|
||||
purchase.setPurchaseId(UUID.randomUUID().toString());
|
||||
//获取子项的id列表
|
||||
List<String> purchaseSonList = purchaseDto.getPurchaseSonList();
|
||||
|
||||
|
||||
//取得当前上传中的进货子项列表product_id, purchase_count, total_price
|
||||
List<PurchaseSon> list = purchaseSonMapper.queryNowPurchaseSonList(purchaseSonList);
|
||||
|
||||
|
||||
//将其加入库存中,修改库存
|
||||
for(PurchaseSon data:list){
|
||||
total+=data.getTotalPrice();
|
||||
//获取当前库存product_id, purchase_count
|
||||
int count = productStoreMapper.queryStoreCount(data.getProductId());
|
||||
if(productStoreMapper.updateStoreByPurchaseSon(data.getProductId(), data.getPurchaseCount()+count)<1){
|
||||
return Result.fail("修改库存失败!");
|
||||
}
|
||||
}
|
||||
//添加总表价格
|
||||
purchase.setTotalPrice(total);
|
||||
if(purchaseMapper.insert(purchase)==0){
|
||||
return Result.fail("插入进货主表失败!");
|
||||
}
|
||||
if(insertPurchaseSwap(purchase.getPurchaseId(), purchaseDto.getPurchaseSonList())==0){
|
||||
return Result.fail("绑定进货主分表信息失败!");
|
||||
}
|
||||
return Result.succ("添加进货成功!");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertPurchaseSwap(String purchaseId, List<String> purchaseSonList) {
|
||||
return purchaseSwapMapper.insertSwap(purchaseId, purchaseSonList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result queryPurchaseSonById(QueryPurchaseSonListDto queryDto) {
|
||||
List<String> purchaseIds = new ArrayList<>();
|
||||
//查询该主表下分表的id列表
|
||||
LambdaQueryWrapper<PurchaseSwap> swapWrapper = new LambdaQueryWrapper<>();
|
||||
swapWrapper.select(PurchaseSwap::getId);
|
||||
swapWrapper.eq(PurchaseSwap::getPurchaseId, queryDto.getPurchaseId());
|
||||
List<PurchaseSwap> purchaseSwaps = purchaseSwapMapper.selectList(swapWrapper);
|
||||
//取出分表id列表
|
||||
for(PurchaseSwap data:purchaseSwaps){
|
||||
purchaseIds.add(data.getId().trim());
|
||||
}
|
||||
//根据分表id查询数据
|
||||
List<PurchaseSonVo> list = purchaseSwapMapper.queryPurchaseSonById(queryDto.getPurchaseId(),
|
||||
purchaseIds,
|
||||
queryDto.getPageNum(),
|
||||
queryDto.getPageNum()*(queryDto.getPageSize()-1));
|
||||
|
||||
int total = purchaseSwapMapper.queryPurchaseSonCount(purchaseIds);
|
||||
return Result.succ(new PurchaseSonPageVo(total, list));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result queryPurchasePage(QueryPurchasePageDto queryDto) throws ParseException {
|
||||
String time1 = queryDto.getBeginTime();
|
||||
/*String time="";
|
||||
Long time1=null;
|
||||
if(!"".equals(queryDto.getBeginTime())){
|
||||
time = queryDto.getBeginTime();
|
||||
Date parse = new SimpleDateFormat("yyyy-MM-dd").parse(time);
|
||||
time1 = parse.getTime();
|
||||
}*/
|
||||
System.out.println(time1);
|
||||
List<Purchase> list = purchaseMapper.queryPageList(queryDto.getPageNum(),
|
||||
queryDto.getPageNum()*(queryDto.getPageSize()-1), queryDto.getPerson(), time1);
|
||||
int total = purchaseMapper.queryPageListCount(queryDto.getPerson(), time1);
|
||||
return Result.succ(new PurchaseListVo(total, list));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.universe.marketing.purchase.service;
|
||||
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
import com.universe.marketing.purchase.pojo.dto.PurchaseDto;
|
||||
import com.universe.marketing.purchase.pojo.dto.PurchaseSonDto;
|
||||
import com.universe.marketing.purchase.pojo.dto.QueryPurchasePageDto;
|
||||
import com.universe.marketing.purchase.pojo.dto.QueryPurchaseSonListDto;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
public interface PurchaseService {
|
||||
//上传进货分表数据
|
||||
Result insertPurchaseSonMsg(PurchaseSonDto purchaseSonDto);
|
||||
//上传整体进货表的数据
|
||||
Result insertPurchaseMsg(PurchaseDto purchaseDto);
|
||||
//添加进货主表和分表的关联信息
|
||||
int insertPurchaseSwap(String purchaseId, List<String>purchaseSonList);
|
||||
//根据主表查询对应子表的信息
|
||||
Result queryPurchaseSonById(QueryPurchaseSonListDto queryDto);
|
||||
//分页查询进货总表的列表信息(根据负责人和生成时间)
|
||||
Result queryPurchasePage(QueryPurchasePageDto queryDto) throws ParseException;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.universe.marketing.store.controller;
|
||||
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
import com.universe.marketing.store.mapper.ProductStoreMapper;
|
||||
import com.universe.marketing.store.pojo.dto.PageParamDto;
|
||||
import com.universe.marketing.store.pojo.dto.UpdateStoreDto;
|
||||
import com.universe.marketing.store.service.Impl.StoreServiceImpl;
|
||||
import com.universe.marketing.store.service.StoreService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/store")
|
||||
@Api(value = "库存管理",tags = {"库存管理"})
|
||||
public class StoreController {
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
@Autowired
|
||||
private ProductStoreMapper storeMapper;
|
||||
|
||||
@PostMapping("page/list")
|
||||
@ApiOperation(value = "分页模糊查询库存列表")
|
||||
public Result queryPageLikeList(@RequestBody PageParamDto pageParamDto){
|
||||
return storeService.queryPageStoreMSG(pageParamDto);
|
||||
}
|
||||
|
||||
@PostMapping("update")
|
||||
@ApiOperation(value = "修改库存信息")
|
||||
public Result updateStore(@RequestBody UpdateStoreDto updateStoreDto){
|
||||
return storeService.updateStoreMSG(updateStoreDto);
|
||||
}
|
||||
|
||||
@GetMapping("all")
|
||||
@ApiOperation(value = "查询全部数据")
|
||||
public Result queryAll(){
|
||||
return Result.succ(storeMapper.queryStoreMsg());
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.universe.marketing.store.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.universe.marketing.purchase.pojo.po.PurchaseSon;
|
||||
import com.universe.marketing.store.pojo.po.ProductStore;
|
||||
import com.universe.marketing.store.pojo.vo.StoreVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductStoreMapper extends BaseMapper<ProductStore> {
|
||||
List<StoreVo> queryPageStoreMSG(int pageSize, int pageNum);
|
||||
//分页模糊查询库存的信息列表
|
||||
List<StoreVo> queryPageLikeStoreMSG(String query, int pageSize, int pageNum);
|
||||
//查询所有
|
||||
List<StoreVo> queryStoreMsg();
|
||||
//查询total总数
|
||||
int queryTotalStore(String query);
|
||||
//更新库存的数量
|
||||
int updateStoreByPurchaseSon(String pId, Integer count);
|
||||
//查询商品总数
|
||||
int queryStoreCount(String productId);
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.universe.marketing.store.pojo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PageParamDto {
|
||||
private int pageSize = 10;//每页显示条数
|
||||
private int pageNum = 0;//每页个数
|
||||
private String query;
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.universe.marketing.store.pojo.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UpdateStoreDto {
|
||||
private String storeId;
|
||||
private String productId;
|
||||
private String productName;
|
||||
private Integer total;
|
||||
private Integer state;
|
||||
private String sortId;
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.universe.marketing.store.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("product_store")
|
||||
public class ProductStore {
|
||||
@TableId
|
||||
@TableField("store_id")
|
||||
private String storeId;
|
||||
@TableField("product_id")
|
||||
String productId;
|
||||
@TableField("product_name")
|
||||
private String productName;
|
||||
@TableField("total")
|
||||
Integer total;
|
||||
@TableField("update_datetime")
|
||||
private Date updateDatetime;
|
||||
@TableField("state")
|
||||
private Integer state;
|
||||
@TableField("create_datetime")
|
||||
private Date create_datetime;
|
||||
@TableField("sort_id")
|
||||
private String sortId;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.universe.marketing.store.pojo.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class StoreAllVo {
|
||||
private int total;
|
||||
private List<StoreVo> list;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.universe.marketing.store.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class StoreVo {
|
||||
private String sortName;
|
||||
private String productId;
|
||||
private String productName;
|
||||
private Integer total;
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateDatetime;
|
||||
private Integer state;
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createDatetime;
|
||||
private String sortId;
|
||||
private String storeId;
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.universe.marketing.store.service.Impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
import com.universe.marketing.store.mapper.ProductStoreMapper;
|
||||
import com.universe.marketing.store.pojo.dto.PageParamDto;
|
||||
import com.universe.marketing.store.pojo.dto.UpdateStoreDto;
|
||||
import com.universe.marketing.store.pojo.po.ProductStore;
|
||||
import com.universe.marketing.store.pojo.vo.StoreAllVo;
|
||||
import com.universe.marketing.store.service.StoreService;
|
||||
import com.universe.utils.BeanUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
@Service
|
||||
public class StoreServiceImpl implements StoreService {
|
||||
|
||||
@Autowired
|
||||
ProductStoreMapper storeMapper;
|
||||
|
||||
@Override
|
||||
public Result queryPageStoreMSG(PageParamDto pageParamDto) {
|
||||
StoreAllVo res = new StoreAllVo();
|
||||
//获取返回的列表
|
||||
res.setList(storeMapper.queryPageLikeStoreMSG(pageParamDto.getQuery(),
|
||||
(pageParamDto.getPageSize()-1)*pageParamDto.getPageNum(), pageParamDto.getPageNum()));
|
||||
//获取分页查询的total
|
||||
res.setTotal(storeMapper.queryTotalStore(pageParamDto.getQuery()));
|
||||
return Result.succ(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateStoreMSG(UpdateStoreDto updateStoreDto) {
|
||||
ProductStore productStore = new ProductStore();
|
||||
BeanUtil.copyNotNullBean(updateStoreDto, productStore);
|
||||
//添加修改时间属性
|
||||
productStore.setUpdateDatetime(new Date());
|
||||
LambdaQueryWrapper<ProductStore> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(ProductStore::getStoreId, updateStoreDto.getStoreId());
|
||||
//修改
|
||||
if(storeMapper.update(productStore, wrapper)>0){
|
||||
return Result.succ("修改库存成功!");
|
||||
}
|
||||
return Result.fail("修改库存失败!");
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.universe.marketing.store.service;
|
||||
|
||||
import com.universe.marketing.product.pojo.vo.Result;
|
||||
import com.universe.marketing.store.pojo.dto.PageParamDto;
|
||||
import com.universe.marketing.store.pojo.dto.UpdateStoreDto;
|
||||
|
||||
public interface StoreService {
|
||||
//分页模糊查询库存信息
|
||||
Result queryPageStoreMSG(PageParamDto pageParamDto);
|
||||
//修改库存信息
|
||||
Result updateStoreMSG(UpdateStoreDto updateStoreDto);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.universe.marketing.users.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@TableName("menu")
|
||||
public class Menu {
|
||||
@TableId(value = "id",type = IdType.INPUT)
|
||||
private String id;
|
||||
//子Id
|
||||
private String pid;
|
||||
private String name;
|
||||
private String path;
|
||||
@TableField(exist = false)
|
||||
private List<Menu> children;
|
||||
private String description;
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.universe.marketing.users.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("role_menu")
|
||||
public class RoleMenu {
|
||||
private String roleId;
|
||||
private String menuId;
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.universe.marketing.users.entity;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@TableName("roles")
|
||||
public class Roles {
|
||||
|
||||
@TableId(value = "id",type = IdType.INPUT)
|
||||
private String id;
|
||||
private String name;
|
||||
private String keyname;
|
||||
private String description;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.universe.marketing.users.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
@TableName("users")
|
||||
public class Users {
|
||||
|
||||
@TableId(value = "id",type = IdType.INPUT)
|
||||
private String id;
|
||||
private String name;
|
||||
@JsonIgnore
|
||||
private String password;
|
||||
private String realName;
|
||||
private String telNumber;
|
||||
private Integer enabled;
|
||||
private String roleName;
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.universe.marketing.users.entity.Utils;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class R {
|
||||
private Integer code;
|
||||
private Object data;
|
||||
private String msg;
|
||||
|
||||
|
||||
public R(Integer code, Object data) {
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
public R(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public R(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public static R ok() {
|
||||
return new R(200, null, null);
|
||||
}
|
||||
|
||||
public static R ok(Object data) {
|
||||
return new R(200, data, null);
|
||||
}
|
||||
|
||||
public static R ok(String msg) {
|
||||
return new R(200, null, msg);
|
||||
}
|
||||
public static R ok(Object data,String msg) {
|
||||
return new R(200, data, msg);
|
||||
}
|
||||
public static R fail(String errorMsg) {
|
||||
return new R(400, null, errorMsg);
|
||||
}
|
||||
|
||||
public static R error(Integer code, String msg) {
|
||||
return new R(code, msg);
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.universe.marketing.users.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.universe.marketing.users.entity.Menu;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface MenuMapper extends BaseMapper<Menu> {
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.universe.marketing.users.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.universe.marketing.users.entity.RoleMenu;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface RoleMenuMapper extends BaseMapper<RoleMenu> {
|
||||
@Select("select menu_id from role_menu where role_id = #{roleId}")
|
||||
List<String> selectByRoleId(@Param("roleId") String roleId);
|
||||
|
||||
@Delete("delete from role_menu where role_id=#{roleId}")
|
||||
int deleteByRoleId(@Param("roleId") String roleId);
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.universe.marketing.users.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.universe.marketing.users.entity.Roles;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yuanjs
|
||||
* @description:
|
||||
* @date 2020-04-02 19:19
|
||||
*/
|
||||
@Mapper
|
||||
public interface RolesMapper extends BaseMapper<Roles> {
|
||||
@Select("select id from roles where keyname = #{keyname}")
|
||||
String selectByRoleName(@Param("keyname") String role);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.universe.marketing.users.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.universe.marketing.users.entity.Users;
|
||||
import com.universe.marketing.users.vo.UsersParams;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UsersMapper extends BaseMapper<Users> {
|
||||
|
||||
|
||||
|
||||
@Select("update users set password= #{password,jdbcType=VARCHAR} where name= #{name,jdbcType=VARCHAR}")
|
||||
void updatepwd(@Param("name") String name, @Param("password") String pwd);
|
||||
|
||||
@Select("select * from users where name = #{name}")
|
||||
Users selectByUsername(@Param("name") String name);
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.universe.marketing.users.service.Impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.universe.marketing.users.entity.Menu;
|
||||
|
||||
public interface MenuServiceImpl extends IService<Menu> {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.universe.marketing.users.service.Impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.universe.marketing.users.entity.RoleMenu;
|
||||
|
||||
public interface RoleMenuServiceImpl extends IService<RoleMenu> {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.universe.marketing.users.service.Impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.universe.marketing.users.entity.Roles;
|
||||
|
||||
public interface RoleServiceImpl extends IService<Roles> {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.universe.marketing.users.service.Impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.universe.marketing.users.entity.Users;
|
||||
|
||||
public interface UserServiceImpl extends IService<Users> {
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package com.universe.marketing.users.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.universe.marketing.users.entity.Menu;
|
||||
import com.universe.marketing.users.entity.Roles;
|
||||
import com.universe.marketing.users.mapper.MenuMapper;
|
||||
import com.universe.marketing.users.service.Impl.MenuServiceImpl;
|
||||
import com.universe.utils.UUIDUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class MenuService extends ServiceImpl<MenuMapper,Menu> implements MenuServiceImpl {
|
||||
@Resource
|
||||
private MenuService menuService;
|
||||
@Resource
|
||||
MenuMapper menuMapper;
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean save(Menu menu) {
|
||||
if (StringUtils.isEmpty(menu.getId())) {
|
||||
menu.setId(UUIDUtils.generateId());
|
||||
menuMapper.insert(menu);
|
||||
return true;
|
||||
} else {
|
||||
menuMapper.updateById(menu);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<Menu> findMeus(String name) {
|
||||
QueryWrapper<Menu> queryWrapper = new QueryWrapper<>();
|
||||
if(StringUtils.isNotBlank(name)){
|
||||
queryWrapper.like("name",name);
|
||||
}
|
||||
|
||||
List<Menu> list = list(queryWrapper);
|
||||
//找出pid一级菜单
|
||||
|
||||
List<Menu> parentNodes = list.stream().filter(menu -> menu.getPid() == null).collect(Collectors.toList());
|
||||
//一级菜单的子菜单
|
||||
for(Menu menu : parentNodes){
|
||||
menu.setChildren(list.stream().filter(m -> menu.getId().equals(m.getPid())).collect(Collectors.toList()));
|
||||
}
|
||||
return parentNodes;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.universe.marketing.users.service;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.universe.marketing.users.entity.Menu;
|
||||
import com.universe.marketing.users.entity.RoleMenu;
|
||||
import com.universe.marketing.users.mapper.MenuMapper;
|
||||
import com.universe.marketing.users.mapper.RoleMenuMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RoleMenuService {
|
||||
@Resource
|
||||
RoleMenuMapper roleMenuMapper;
|
||||
@Resource
|
||||
MenuMapper menuMapper;
|
||||
|
||||
|
||||
@Transactional
|
||||
public boolean setRoleMenu(String roleId, List<String> menuIds) {
|
||||
roleMenuMapper.deleteByRoleId(roleId);
|
||||
List<String> menuIdsCopy = CollUtil.newArrayList(menuIds);
|
||||
for(String menuId : menuIds){
|
||||
Menu menu = menuMapper.selectById(menuId);
|
||||
if(menu.getPid()!=null&&!menuIdsCopy.contains(menu.getPid())){
|
||||
RoleMenu roleMenu = new RoleMenu();
|
||||
roleMenu.setRoleId(roleId);
|
||||
//要传menu的子ID 不能传主键
|
||||
roleMenu.setMenuId(menu.getPid());
|
||||
roleMenuMapper.insert(roleMenu);
|
||||
menuIdsCopy.add(menu.getPid());
|
||||
}
|
||||
RoleMenu roleMenu = new RoleMenu();
|
||||
roleMenu.setRoleId(roleId);
|
||||
roleMenu.setMenuId(menuId);
|
||||
roleMenuMapper.insert(roleMenu);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<String> getRoleMenu(String roleId) {
|
||||
return roleMenuMapper.selectByRoleId(roleId);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.universe.marketing.users.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
|
||||
import com.universe.marketing.users.entity.Menu;
|
||||
import com.universe.marketing.users.entity.Roles;
|
||||
|
||||
import com.universe.marketing.users.mapper.MenuMapper;
|
||||
import com.universe.marketing.users.mapper.RoleMenuMapper;
|
||||
import com.universe.marketing.users.mapper.RolesMapper;
|
||||
import com.universe.marketing.users.service.Impl.RoleServiceImpl;
|
||||
import com.universe.utils.UUIDUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class RolesService extends ServiceImpl<RolesMapper,Roles> implements RoleServiceImpl {
|
||||
|
||||
@Autowired
|
||||
RolesMapper rolesMapper;
|
||||
@Resource
|
||||
private RoleMenuMapper roleMenuMapper;
|
||||
@Resource
|
||||
private MenuService menuService;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean save(Roles roles) {
|
||||
if (StringUtils.isEmpty(roles.getId())) {
|
||||
roles.setId(UUIDUtils.generateId());
|
||||
rolesMapper.insert(roles);
|
||||
return true;
|
||||
} else {
|
||||
rolesMapper.updateById(roles);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取当前菜单列表
|
||||
* @param keyname 角色唯一标识
|
||||
*
|
||||
*/
|
||||
public List<Menu> getRoleMenu(String keyname){
|
||||
String roleId = rolesMapper.selectByRoleName(keyname);
|
||||
// 当前角色的所有菜单id集合
|
||||
List<String> menuIds = roleMenuMapper.selectByRoleId(roleId);
|
||||
|
||||
// 查出系统所有的菜单(树形)
|
||||
List<Menu> menus = menuService.findMeus("");
|
||||
// new一个最后筛选完成之后的list
|
||||
List<Menu> roleMenus = new ArrayList<>();
|
||||
// 筛选当前用户角色的菜单
|
||||
for (Menu menu : menus) {
|
||||
if (menuIds.contains(menu.getId())) {
|
||||
roleMenus.add(menu);
|
||||
}
|
||||
List<Menu> children = menu.getChildren();
|
||||
// removeIf() 移除 children 里面不在 menuIds集合中的 元素
|
||||
children.removeIf(child -> !menuIds.contains(child.getId()));
|
||||
}
|
||||
return roleMenus;
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package com.universe.marketing.users.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.universe.handler.BusinessException;
|
||||
import com.universe.marketing.users.entity.Menu;
|
||||
import com.universe.marketing.users.entity.Users;
|
||||
import com.universe.marketing.users.mapper.RoleMenuMapper;
|
||||
import com.universe.marketing.users.mapper.RolesMapper;
|
||||
import com.universe.marketing.users.mapper.UsersMapper;
|
||||
import com.universe.marketing.users.service.Impl.UserServiceImpl;
|
||||
import com.universe.utils.UUIDUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yuanjs
|
||||
* @description:
|
||||
* @date 2020-02-05 7:23
|
||||
*/
|
||||
@Service
|
||||
public class UsersService extends ServiceImpl<UsersMapper,Users> implements UserServiceImpl {
|
||||
@Autowired
|
||||
UsersMapper usersMapper;
|
||||
@Resource
|
||||
RolesService rolesService;
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean save(Users users) {
|
||||
Users old = usersMapper.selectByUsername(users.getName());
|
||||
if(old!=null){
|
||||
if(!old.getId().equals(users.getId())){
|
||||
throw new BusinessException("用户名已被占用");
|
||||
}
|
||||
}
|
||||
if (StrUtil.isEmpty(users.getId())) {
|
||||
users.setId(UUIDUtils.generateId());
|
||||
usersMapper.insert(users);
|
||||
} else {
|
||||
users.setPassword(old.getPassword());
|
||||
usersMapper.updateById(users);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public String resetPwd(String userId){
|
||||
Users user = usersMapper.selectById(userId);
|
||||
|
||||
Integer integer=(int) (Math.random()*899999+100000);
|
||||
String password=integer.toString();
|
||||
user.setPassword(password);
|
||||
usersMapper.updatepwd(user.getName(),password);
|
||||
return password;
|
||||
}
|
||||
//获取用户菜单
|
||||
public List<Menu> getUserMenu(String roleName) {
|
||||
return rolesService.getRoleMenu(roleName);
|
||||
}
|
||||
|
||||
|
||||
//更改密码
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean setPwd(String userId, String password) {
|
||||
Users user = usersMapper.selectById(userId);
|
||||
if (user != null) {
|
||||
usersMapper.updatepwd(user.getName(),password);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// public UserRequest login(UserRequest userRequest) {
|
||||
// QueryWrapper<Users> queryWrapper = new QueryWrapper<>();
|
||||
// queryWrapper.eq("name",userRequest.getName());
|
||||
// queryWrapper.eq("password",userRequest.getPassword());
|
||||
// try{
|
||||
// Users a = getOne(queryWrapper);
|
||||
// if(a!=null){
|
||||
// BeanUtil.copyProperties(a,userRequest,true);
|
||||
// String token = UUIDUtils.generateId();
|
||||
// userRequest.setToken(token);
|
||||
// //获取role的字符串
|
||||
// String role = a.getRoleName();
|
||||
// //设置菜单列表
|
||||
// List<Menu> roleMenu = getRoleMenu(role);
|
||||
// userRequest.setMenus(roleMenu);
|
||||
// return userRequest;
|
||||
// }
|
||||
// else{
|
||||
// throw new BusinessException("用户名或密码错误");
|
||||
// }
|
||||
// }catch (Exception e){
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.universe.marketing.users.vo;
|
||||
|
||||
import com.universe.marketing.users.entity.Menu;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 登录接收信息
|
||||
*/
|
||||
@Data
|
||||
public class UserRequest {
|
||||
private String id;
|
||||
private String name;
|
||||
private String password;
|
||||
private String roleName;
|
||||
private String token;
|
||||
private List<Menu> menus;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.universe.marketing.users.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author yuanjs
|
||||
* @description:
|
||||
* @date 2020-04-05 11:16
|
||||
*/
|
||||
@Data
|
||||
public class UsersParams {
|
||||
private String queryKey;
|
||||
private Integer enabled;
|
||||
private String projectId;
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.universe.marketing.users.web;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import com.universe.marketing.users.entity.Menu;
|
||||
|
||||
import com.universe.marketing.users.entity.Utils.R;
|
||||
import com.universe.marketing.users.service.MenuService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
@Api(value = "菜单管理", tags = {"菜单管理"})
|
||||
@RestController
|
||||
@RequestMapping("/menu")
|
||||
public class MenuController {
|
||||
@Resource
|
||||
MenuService menuService;
|
||||
|
||||
/* @ApiOperation(value = "获取父子信息")
|
||||
@GetMapping("/list")
|
||||
public R list(@RequestParam(defaultValue = "") String name){
|
||||
return R.ok(menuService.findMeus(name));
|
||||
}*/
|
||||
@ApiOperation(value = "获取角色的全部菜单ID")
|
||||
@GetMapping("/ids")
|
||||
public R MenuIds() {
|
||||
return R.ok(menuService.list().stream().map(Menu::getId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "保存菜单")
|
||||
@PostMapping("/save")
|
||||
public R save(@RequestBody Menu menu) {
|
||||
boolean flag = menuService.save(menu);
|
||||
if (flag) {
|
||||
return R.ok("添加成功");
|
||||
} else {
|
||||
return R.fail("添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新菜单")
|
||||
@PutMapping("/update")
|
||||
public R update(@RequestBody Menu menu) {
|
||||
boolean flag = menuService.updateById(menu);
|
||||
if (flag) {
|
||||
return R.ok("更新成功");
|
||||
} else {
|
||||
return R.fail("更新失败");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除菜单")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public R delete(@PathVariable String id) {
|
||||
boolean flag = menuService.removeById(id);
|
||||
if (flag) {
|
||||
return R.ok("删除成功");
|
||||
} else {
|
||||
return R.fail("删除失败");
|
||||
}
|
||||
}
|
||||
/* @GetMapping("/lists")
|
||||
public R List() {
|
||||
return R.ok(menuService.list(null));
|
||||
}*/
|
||||
@ApiOperation(value = "分页查询菜单接口")
|
||||
@GetMapping("/query")
|
||||
public IPage<Menu> find(
|
||||
@RequestParam Integer pageNum,
|
||||
@RequestParam Integer pageSize,
|
||||
@RequestParam(defaultValue = "") String name
|
||||
){
|
||||
IPage<Menu> page = new Page<>(pageNum,pageSize);
|
||||
QueryWrapper<Menu> queryWrapper = new QueryWrapper<>();
|
||||
if(!"".equals(name)){
|
||||
queryWrapper.like("name",name);
|
||||
}
|
||||
return menuService.page(page, queryWrapper);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package com.universe.marketing.users.web;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.universe.marketing.users.entity.Roles;
|
||||
import com.universe.marketing.users.entity.Users;
|
||||
import com.universe.marketing.users.entity.Utils.R;
|
||||
import com.universe.marketing.users.service.RoleMenuService;
|
||||
import com.universe.marketing.users.service.RolesService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "角色管理", tags = {"角色权限"})
|
||||
@RestController
|
||||
@RequestMapping("/roles")
|
||||
public class RolesController {
|
||||
|
||||
@Resource
|
||||
RolesService rolesService;
|
||||
@Resource
|
||||
private RoleMenuService roleMenuService;
|
||||
|
||||
@ApiOperation(value = "分页查询角色")
|
||||
@GetMapping("/query")
|
||||
public IPage<Roles> find(
|
||||
@RequestParam Integer pageNum,
|
||||
@RequestParam Integer pageSize
|
||||
) {
|
||||
IPage<Roles> page = new Page<>(pageNum, pageSize);
|
||||
return rolesService.page(page);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "保存角色")
|
||||
@PostMapping("/save")
|
||||
public R save(@RequestBody Roles roles) {
|
||||
boolean flag = rolesService.save(roles);
|
||||
if (flag) {
|
||||
return R.ok("添加成功");
|
||||
} else {
|
||||
return R.fail("添加失败");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除角色")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public R delete(@PathVariable String id) {
|
||||
boolean flag = rolesService.removeById(id);
|
||||
if (flag) {
|
||||
return R.ok("删除成功");
|
||||
} else {
|
||||
return R.fail("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取角色菜单ID")
|
||||
@GetMapping("/roleMenu/{roleId}")
|
||||
public R getRoleMenu(@PathVariable String roleId) {
|
||||
List<String> list = roleMenuService.getRoleMenu(roleId);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新角色")
|
||||
@PutMapping("/update")
|
||||
public R update(@RequestBody Roles role) {
|
||||
boolean flag = rolesService.updateById(role);
|
||||
if (flag) {
|
||||
return R.ok("更新成功");
|
||||
} else {
|
||||
return R.fail("更新失败");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "设置角色菜单ID")
|
||||
@PutMapping("/roleMenu/{roleId}")
|
||||
public R roleMenu(@PathVariable String roleId, @RequestBody List<String> menuIds) {
|
||||
boolean flag = roleMenuService.setRoleMenu(roleId, menuIds);
|
||||
if (flag) {
|
||||
return R.ok("设置成功");
|
||||
} else {
|
||||
return R.fail("设置失败");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量删除菜单")
|
||||
@PostMapping("/delbatch")
|
||||
public R delete(@RequestBody List<String> ids) {
|
||||
boolean flag = rolesService.removeByIds(ids);
|
||||
if (flag) {
|
||||
return R.ok("批量删除成功");
|
||||
} else {
|
||||
return R.fail("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,156 @@
|
||||
package com.universe.marketing.users.web;
|
||||
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.universe.marketing.users.entity.Users;
|
||||
import com.universe.marketing.users.entity.Utils.R;
|
||||
import com.universe.marketing.users.service.UsersService;
|
||||
import com.universe.marketing.users.vo.UserRequest;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Api(value = "用户管理", tags = {"用户管理"})
|
||||
@RestController
|
||||
@RequestMapping("/users")
|
||||
public class UsersController {
|
||||
|
||||
@Autowired
|
||||
UsersService usersService;
|
||||
|
||||
@ApiOperation(value = "保存用户")
|
||||
@PostMapping("/save")
|
||||
public R save(@RequestBody Users users) {
|
||||
if (StringUtils.isEmpty(users.getId())) {
|
||||
Integer integer = (int) (Math.random() * 899999 + 100000);
|
||||
String password = integer.toString();
|
||||
users.setPassword(password);
|
||||
boolean flag = usersService.save(users);
|
||||
if (flag) {
|
||||
password = users.getPassword();
|
||||
String msg = "这是你的账号:" + users.getName() + "! 密码:" + users.getPassword();
|
||||
return R.ok(password, msg);
|
||||
} else {
|
||||
return R.fail("保存失败");
|
||||
}
|
||||
} else {
|
||||
usersService.save(users);
|
||||
return R.ok("账户已保存");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取对应角色的用户")
|
||||
@GetMapping("/{role}")
|
||||
public R list_role(@PathVariable String role) {
|
||||
QueryWrapper<Users> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("role_name", role);
|
||||
return R.ok(usersService.list(queryWrapper));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取该用户的菜单集合")
|
||||
@GetMapping("/getmenu")
|
||||
public R getUserMenu(@RequestBody UserRequest userRequest) {
|
||||
String roleName = userRequest.getRoleName();
|
||||
return R.ok(usersService.getUserMenu(roleName));
|
||||
}
|
||||
|
||||
// @ApiOperation(value = "登录")
|
||||
// @PostMapping("/login")
|
||||
// public R login(@RequestBody UserRequest userRequest) {
|
||||
// String name = userRequest.getName();
|
||||
// String password = userRequest.getPassword();
|
||||
// if (StrUtil.isBlank(name) || StrUtil.isBlank(password)) {
|
||||
// throw new BusinessException("用户名或密码为空");
|
||||
// }
|
||||
// if(usersService.login(userRequest)!=null){
|
||||
// return R.ok(usersService.login(userRequest));
|
||||
// }else{
|
||||
// throw new BusinessException("用户名或密码错误");
|
||||
// }
|
||||
// }
|
||||
@ApiOperation(value = "重置密码")
|
||||
@PutMapping("/reset/{userId}")
|
||||
public R resetPwd(@PathVariable String userId) {
|
||||
return R.ok(usersService.resetPwd(userId), "重置后的密码");
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "更改密码")
|
||||
@PutMapping("/set/{userId}")
|
||||
public R setPwd(@PathVariable String userId,@RequestParam String password) {
|
||||
boolean flag = usersService.setPwd(userId,password);
|
||||
if (flag) {
|
||||
return R.ok("更改成功");
|
||||
} else {
|
||||
return R.fail("更改失败");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除用户")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public R delete(@PathVariable String id) {
|
||||
boolean flag = usersService.removeById(id);
|
||||
if (flag) {
|
||||
return R.ok("删除成功");
|
||||
} else {
|
||||
return R.fail("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "批量删除用户")
|
||||
@PostMapping("/delbatch")
|
||||
public R delete(@RequestBody List<String> ids) {
|
||||
boolean flag = usersService.removeByIds(ids);
|
||||
if (flag) {
|
||||
return R.ok("批量删除成功");
|
||||
} else {
|
||||
return R.fail("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "分页查询用户")
|
||||
@GetMapping("/query")
|
||||
//条件查询
|
||||
public IPage<Users> find(
|
||||
@RequestParam Integer pageNum,
|
||||
@RequestParam Integer pageSize,
|
||||
@RequestParam(defaultValue = "") String roleName,
|
||||
@RequestParam(defaultValue = "") String telnumber,
|
||||
@RequestParam(defaultValue = "") String realname) {
|
||||
IPage<Users> page = new Page<>(pageNum, pageSize);
|
||||
QueryWrapper<Users> queryWrapper = new QueryWrapper<>();
|
||||
if (!"".equals(roleName)) {
|
||||
queryWrapper.like("role_name", roleName);
|
||||
}
|
||||
if (!"".equals(realname)) {
|
||||
queryWrapper.like("real_name", realname);
|
||||
}
|
||||
if (!"".equals(telnumber)) {
|
||||
queryWrapper.like("tel_number", telnumber);
|
||||
}
|
||||
return usersService.page(page, queryWrapper);
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "更新用户")
|
||||
@PutMapping("/update")
|
||||
public R update(@RequestBody Users user) {
|
||||
boolean flag = usersService.updateById(user);
|
||||
if (flag) {
|
||||
return R.ok("更新成功");
|
||||
} else {
|
||||
return R.fail("更新失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.universe.utils;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
|
||||
/**
|
||||
* @author zhuxiaomeng
|
||||
* @date 2018/1/5.
|
||||
* @email lenospmiller@gmail.com
|
||||
*/
|
||||
public class ApplicationContextUtil implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext applicationContext;
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
ApplicationContextUtil.applicationContext=applicationContext;
|
||||
}
|
||||
|
||||
public static ApplicationContext getContext(){
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
public static Object getBean(String arg){
|
||||
return applicationContext.getBean(arg);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue