Compare commits

..

No commits in common. "master" and "v3.1" have entirely different histories.
master ... v3.1

440 changed files with 13276 additions and 29329 deletions

1
.github/FUNDING.yml vendored
View File

@ -1 +0,0 @@
custom: http://doc.ruoyi.vip/ruoyi-vue/other/donate.html

3
.gitignore vendored
View File

@ -25,9 +25,6 @@ target/
*.iml *.iml
*.ipr *.ipr
### JRebel ###
rebel.xml
### NetBeans ### ### NetBeans ###
nbproject/private/ nbproject/private/
build/* build/*

View File

@ -1,29 +1,14 @@
<p align="center">
<img alt="logo" src="https://oscimg.oschina.net/oscnet/up-d3d0a9303e11d522a06cd263f3079027715.png">
</p>
<h1 align="center" style="margin: 30px 0 30px; font-weight: bold;">RuoYi v3.8.2</h1>
<h4 align="center">基于SpringBoot+Vue前后端分离的Java快速开发框架</h4>
<p align="center">
<a href="https://gitee.com/y_project/RuoYi-Vue/stargazers"><img src="https://gitee.com/y_project/RuoYi-Vue/badge/star.svg?theme=dark"></a>
<a href="https://gitee.com/y_project/RuoYi-Vue"><img src="https://img.shields.io/badge/RuoYi-v3.8.2-brightgreen.svg"></a>
<a href="https://gitee.com/y_project/RuoYi-Vue/blob/master/LICENSE"><img src="https://img.shields.io/github/license/mashape/apistatus.svg"></a>
</p>
## 平台简介 ## 平台简介
若依是一套全部开源的快速开发平台,毫无保留给个人及企业免费使用。
* 前端采用Vue、Element UI。 * 前端采用Vue、Element UI。
* 后端采用Spring Boot、Spring Security、Redis & Jwt。 * 后端采用Spring Boot、Spring Security、Redis & Jwt。
* 权限认证使用Jwt支持多终端认证系统。 * 权限认证使用Jwt支持多终端认证系统。
* 支持加载动态权限菜单,多方式轻松权限控制。 * 支持加载动态权限菜单,多方式轻松权限控制。
* 高效率开发,使用代码生成器可以一键生成前后端代码。 * 高效率开发,使用代码生成器可以一键生成前后端代码。
* 提供了技术栈([Vue3](https://v3.cn.vuejs.org) [Element Plus](https://element-plus.org/zh-CN) [Vite](https://cn.vitejs.dev))版本[RuoYi-Vue3](https://github.com/yangzongzhuan/RuoYi-Vue3),保持同步更新。 * 提供了一个Oracle版本[RuoYi-Vue-Oracle](https://github.com/yangzongzhuan/RuoYi-Vue-Oracle),保持同步更新。
* 提供了单应用版本[RuoYi-Vue-fast](https://github.com/yangzongzhuan/RuoYi-Vue-fast)Oracle版本[RuoYi-Vue-Oracle](https://github.com/yangzongzhuan/RuoYi-Vue-Oracle),保持同步更新。
* 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi),微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud) * 不分离版本,请移步[RuoYi](https://gitee.com/y_project/RuoYi),微服务版本,请移步[RuoYi-Cloud](https://gitee.com/y_project/RuoYi-Cloud)
* 特别鸣谢:[element](https://github.com/ElemeFE/element)[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)[eladmin-web](https://github.com/elunez/eladmin-web)。 * 感谢[Vue-Element-Admin](https://github.com/PanJiaChen/vue-element-admin)[eladmin-web](https://gitee.com/elunez/eladmin-web?_from=gitee_search)。
* 阿里云折扣场:[点我进入](http://aly.ruoyi.vip),腾讯云秒杀场:[点我进入](http://txy.ruoyi.vip)&nbsp;&nbsp; * 阿里云优惠券:[点我进入](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link),腾讯云优惠券:[点我领取](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console)&nbsp;&nbsp;
* 阿里云优惠券:[点我领取](https://www.aliyun.com/minisite/goods?userCode=brki8iof&share_source=copy_link),腾讯云优惠券:[点我领取](https://cloud.tencent.com/redirect.php?redirect=1025&cps_key=198c8df2ed259157187173bc7f4f32fd&from=console)&nbsp;&nbsp;
## 内置功能 ## 内置功能
@ -42,9 +27,8 @@
13. 代码生成前后端代码的生成java、html、xml、sql支持CRUD下载 。 13. 代码生成前后端代码的生成java、html、xml、sql支持CRUD下载 。
14. 系统接口根据业务代码自动生成相关的api接口文档。 14. 系统接口根据业务代码自动生成相关的api接口文档。
15. 服务监控监视当前系统CPU、内存、磁盘、堆栈等相关信息。 15. 服务监控监视当前系统CPU、内存、磁盘、堆栈等相关信息。
16. 缓存监控:对系统的缓存信息查询,命令统计等。 16. 在线构建器拖动表单元素生成相应的HTML代码。
17. 在线构建器拖动表单元素生成相应的HTML代码。 17. 连接池监视监视当前系统数据库连接池状态可进行分析SQL找出系统性能瓶颈。
18. 连接池监视监视当前系统数据库连接池状态可进行分析SQL找出系统性能瓶颈。
## 在线体验 ## 在线体验
@ -87,11 +71,11 @@
</tr> </tr>
<tr> <tr>
<td><img src="https://oscimg.oschina.net/oscnet/b6115bc8c31de52951982e509930b20684a.jpg"/></td> <td><img src="https://oscimg.oschina.net/oscnet/b6115bc8c31de52951982e509930b20684a.jpg"/></td>
<td><img src="https://oscimg.oschina.net/oscnet/up-5e4daac0bb59612c5038448acbcef235e3a.png"/></td> <td><img src="https://oscimg.oschina.net/oscnet/up-6d73c2140ce694e3de4c05035fdc1868d4c.png"/></td>
</tr> </tr>
</table> </table>
## 若依前后端分离交流群 ## 若依前后端分离交流群
QQ群 [![加入QQ群](https://img.shields.io/badge/已满-937441-blue.svg)](https://jq.qq.com/?_wv=1027&k=5bVB1og) [![加入QQ群](https://img.shields.io/badge/已满-887144332-blue.svg)](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [![加入QQ群](https://img.shields.io/badge/已满-180251782-blue.svg)](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [![加入QQ群](https://img.shields.io/badge/已满-104180207-blue.svg)](https://jq.qq.com/?_wv=1027&k=51G72yr) [![加入QQ群](https://img.shields.io/badge/已满-186866453-blue.svg)](https://jq.qq.com/?_wv=1027&k=VvjN2nvu) [![加入QQ群](https://img.shields.io/badge/已满-201396349-blue.svg)](https://jq.qq.com/?_wv=1027&k=5vYAqA05) [![加入QQ群](https://img.shields.io/badge/已满-101456076-blue.svg)](https://jq.qq.com/?_wv=1027&k=kOIINEb5) [![加入QQ群](https://img.shields.io/badge/已满-101539465-blue.svg)](https://jq.qq.com/?_wv=1027&k=UKtX5jhs) [![加入QQ群](https://img.shields.io/badge/已满-264312783-blue.svg)](https://jq.qq.com/?_wv=1027&k=EI9an8lJ) [![加入QQ群](https://img.shields.io/badge/167385320-blue.svg)](https://jq.qq.com/?_wv=1027&k=SWCtLnMz) 点击按钮入群。 QQ群 [![加入QQ群](https://img.shields.io/badge/已满-937441-blue.svg)](https://jq.qq.com/?_wv=1027&k=5bVB1og) [![加入QQ群](https://img.shields.io/badge/已满-887144332-blue.svg)](https://jq.qq.com/?_wv=1027&k=5eiA4DH) [![加入QQ群](https://img.shields.io/badge/已满-180251782-blue.svg)](https://jq.qq.com/?_wv=1027&k=5AxMKlC) [![加入QQ群](https://img.shields.io/badge/104180207-blue.svg)](https://jq.qq.com/?_wv=1027&k=51G72yr) 点击按钮入群。

View File

@ -1,6 +1,6 @@
@echo off @echo off
echo. echo.
echo [信息] 清理工程target生成路径。 echo [信息] 清理生成路径。
echo. echo.
%~d0 %~d0

View File

@ -1,6 +1,6 @@
@echo off @echo off
echo. echo.
echo [信息] 使用Jar命令运行Web工程。 echo [信息] 运行Web工程。
echo. echo.
cd %~dp0 cd %~dp0

33
demo/.gitignore vendored
View File

@ -1,33 +0,0 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

Binary file not shown.

View File

@ -1,2 +0,0 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar

316
demo/mvnw vendored
View File

@ -1,316 +0,0 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /usr/local/etc/mavenrc ] ; then
. /usr/local/etc/mavenrc
fi
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`\\unset -f command; \\command -v java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

188
demo/mvnw.cmd vendored
View File

@ -1,188 +0,0 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%

View File

@ -1,41 +0,0 @@
<?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.7.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,13 +0,0 @@
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}

View File

@ -1,13 +0,0 @@
package com.example.demo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class DemoApplicationTests {
@Test
void contextLoads() {
}
}

81
pom.xml
View File

@ -6,32 +6,30 @@
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<artifactId>ruoyi</artifactId> <artifactId>ruoyi</artifactId>
<version>3.8.2</version> <version>3.1.0</version>
<name>ruoyi</name> <name>ruoyi</name>
<url>http://www.ruoyi.vip</url> <url>http://www.ruoyi.vip</url>
<description>若依管理系统</description> <description>若依管理系统</description>
<properties> <properties>
<ruoyi.version>3.8.2</ruoyi.version> <ruoyi.version>3.1.0</ruoyi.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>11</java.version> <java.version>1.8</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version> <mybatis.boot.version>1.3.2</mybatis.boot.version>
<druid.version>1.2.11</druid.version> <druid.version>1.1.14</druid.version>
<bitwalker.version>1.21</bitwalker.version> <bitwalker.version>1.19</bitwalker.version>
<swagger.version>3.0.0</swagger.version> <swagger.version>2.9.2</swagger.version>
<kaptcha.version>2.3.2</kaptcha.version> <kaptcha.version>2.3.2</kaptcha.version>
<mybatis-spring-boot.version>2.2.2</mybatis-spring-boot.version> <pagehelper.boot.version>1.2.5</pagehelper.boot.version>
<pagehelper.boot.version>1.4.2</pagehelper.boot.version> <fastjson.version>1.2.70</fastjson.version>
<fastjson.version>1.2.83</fastjson.version> <oshi.version>3.9.1</oshi.version>
<oshi.version>6.1.6</oshi.version> <commons.io.version>2.5</commons.io.version>
<commons.io.version>2.11.0</commons.io.version> <commons.fileupload.version>1.3.3</commons.fileupload.version>
<commons.fileupload.version>1.4</commons.fileupload.version> <poi.version>3.17</poi.version>
<commons.collections.version>3.2.2</commons.collections.version> <velocity.version>1.7</velocity.version>
<poi.version>4.1.2</poi.version> <jwt.version>0.9.0</jwt.version>
<velocity.version>2.3</velocity.version>
<jwt.version>0.9.1</jwt.version>
</properties> </properties>
<!-- 依赖声明 --> <!-- 依赖声明 -->
@ -42,12 +40,12 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId> <artifactId>spring-boot-dependencies</artifactId>
<version>2.5.14</version> <version>2.1.1.RELEASE</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
<!-- 阿里数据库连接池 --> <!--阿里数据库连接池 -->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId> <artifactId>druid-spring-boot-starter</artifactId>
@ -61,13 +59,6 @@
<version>${bitwalker.version}</version> <version>${bitwalker.version}</version>
</dependency> </dependency>
<!-- SpringBoot集成mybatis框架 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-spring-boot.version}</version>
</dependency>
<!-- pagehelper 分页插件 --> <!-- pagehelper 分页插件 -->
<dependency> <dependency>
<groupId>com.github.pagehelper</groupId> <groupId>com.github.pagehelper</groupId>
@ -82,12 +73,16 @@
<version>${oshi.version}</version> <version>${oshi.version}</version>
</dependency> </dependency>
<!-- Swagger3依赖 --> <!-- swagger2-->
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId> <artifactId>springfox-swagger2</artifactId>
<version>${swagger.version}</version> <version>${swagger.version}</version>
<exclusions> <exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
<exclusion> <exclusion>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId> <artifactId>swagger-models</artifactId>
@ -95,14 +90,21 @@
</exclusions> </exclusions>
</dependency> </dependency>
<!-- io常用工具类 --> <!-- swagger2-UI-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger.version}</version>
</dependency>
<!--io常用工具类 -->
<dependency> <dependency>
<groupId>commons-io</groupId> <groupId>commons-io</groupId>
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>${commons.io.version}</version> <version>${commons.io.version}</version>
</dependency> </dependency>
<!-- 文件上传工具类 --> <!--文件上传工具类 -->
<dependency> <dependency>
<groupId>commons-fileupload</groupId> <groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId> <artifactId>commons-fileupload</artifactId>
@ -116,20 +118,13 @@
<version>${poi.version}</version> <version>${poi.version}</version>
</dependency> </dependency>
<!-- velocity代码生成使用模板 --> <!--velocity代码生成使用模板 -->
<dependency> <dependency>
<groupId>org.apache.velocity</groupId> <groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId> <artifactId>velocity</artifactId>
<version>${velocity.version}</version> <version>${velocity.version}</version>
</dependency> </dependency>
<!-- collections工具类 -->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>${commons.collections.version}</version>
</dependency>
<!-- 阿里JSON解析器 --> <!-- 阿里JSON解析器 -->
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
@ -137,14 +132,14 @@
<version>${fastjson.version}</version> <version>${fastjson.version}</version>
</dependency> </dependency>
<!-- Token生成与解析--> <!--Token生成与解析-->
<dependency> <dependency>
<groupId>io.jsonwebtoken</groupId> <groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId> <artifactId>jjwt</artifactId>
<version>${jwt.version}</version> <version>${jwt.version}</version>
</dependency> </dependency>
<!-- 验证码 --> <!--验证码 -->
<dependency> <dependency>
<groupId>com.github.penggle</groupId> <groupId>com.github.penggle</groupId>
<artifactId>kaptcha</artifactId> <artifactId>kaptcha</artifactId>
@ -223,7 +218,7 @@
<repository> <repository>
<id>public</id> <id>public</id>
<name>aliyun nexus</name> <name>aliyun nexus</name>
<url>https://maven.aliyun.com/repository/public</url> <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases> <releases>
<enabled>true</enabled> <enabled>true</enabled>
</releases> </releases>
@ -234,7 +229,7 @@
<pluginRepository> <pluginRepository>
<id>public</id> <id>public</id>
<name>aliyun nexus</name> <name>aliyun nexus</name>
<url>https://maven.aliyun.com/repository/public</url> <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases> <releases>
<enabled>true</enabled> <enabled>true</enabled>
</releases> </releases>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ruoyi</artifactId> <artifactId>ruoyi</artifactId>
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<version>3.8.2</version> <version>3.1.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging> <packaging>jar</packaging>
@ -17,56 +17,36 @@
<dependencies> <dependencies>
<dependency> <!-- spring-boot-devtools -->
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId> <artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 表示依赖不会传递 --> <optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency> </dependency>
<!-- swagger3--> <!-- swagger2-->
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId> <artifactId>springfox-swagger2</artifactId>
</dependency>
<!--防止进入swagger页面报类型转换错误排除2.9.2中的引用手动增加1.5.21版本-->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.5.21</version>
</dependency> </dependency>
<!-- 防止进入swagger页面报类型转换错误排除3.0.0中的引用手动增加1.6.2版本 -->
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId> <artifactId>swagger-models</artifactId>
<version>1.6.6</version> <version>1.5.21</version>
</dependency> </dependency>
<!-- knife4j -->
<!-- swagger2-UI-->
<dependency> <dependency>
<groupId>com.github.xiaoymin</groupId> <groupId>io.springfox</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId> <artifactId>springfox-swagger-ui</artifactId>
<version>3.0.3</version>
</dependency>
<!-- postgresql驱动包-->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.2.20</version>
</dependency> </dependency>
<!-- Mysql驱动包 --> <!-- Mysql驱动包 -->

View File

@ -1,6 +1,5 @@
package com.ruoyi; package com.ruoyi;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
@ -11,25 +10,21 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
* @author ruoyi * @author ruoyi
*/ */
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class }) @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@MapperScan("com.ruoyi.system.mapper_yada")
public class RuoYiApplication public class RuoYiApplication
{ {
public static void main(String[] args) public static void main(String[] args)
{ {
// System.setProperty("spring.devtools.restart.enabled", "false"); // System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(RuoYiApplication.class, args); SpringApplication.run(RuoYiApplication.class, args);
System.out.println(); System.out.println("(♥◠‿◠)ノ゙ 若依启动成功 ლ(´ڡ`ლ)゙ \n" +
System.out.println(" --->>>启动成功!<<<---"); " .-------. ____ __ \n" +
// System.out.println("(♥◠‿◠)ノ゙ ლ(´ڡ`ლ)゙ \n" + " | _ _ \\ \\ \\ / / \n" +
// " .-------. ____ __ \n" + " | ( ' ) | \\ _. / ' \n" +
// " | _ _ \\ \\ \\ / / \n" + " |(_ o _) / _( )_ .' \n" +
// " | ( ' ) | \\ _. / ' \n" + " | (_,_).' __ ___(_ o _)' \n" +
// " |(_ o _) / _( )_ .' \n" + " | |\\ \\ | || |(_,_)' \n" +
// " | (_,_).' __ ___(_ o _)' \n" + " | | \\ `' /| `-' / \n" +
// " | |\\ \\ | || |(_,_)' \n" + " | | \\ / \\ / \n" +
// " | | \\ `' /| `-' / \n" + " ''-' `'-' `-..-' ");
// " | | \\ / \\ / \n" +
// " ''-' `'-' `-..-' ");
} }
} }

View File

@ -0,0 +1,86 @@
package com.ruoyi.web.controller.common;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.FastByteArrayOutputStream;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.google.code.kaptcha.Producer;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.sign.Base64;
import com.ruoyi.common.utils.uuid.IdUtils;
/**
* 验证码操作处理
*
* @author ruoyi
*/
@RestController
public class CaptchaController
{
@Resource(name = "captchaProducer")
private Producer captchaProducer;
@Resource(name = "captchaProducerMath")
private Producer captchaProducerMath;
@Autowired
private RedisCache redisCache;
// 验证码类型
@Value("${ruoyi.captchaType}")
private String captchaType;
/**
* 生成验证码
*/
@GetMapping("/captchaImage")
public AjaxResult getCode(HttpServletResponse response) throws IOException
{
// 保存验证码信息
String uuid = IdUtils.simpleUUID();
String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
String capStr = null, code = null;
BufferedImage image = null;
// 生成验证码
if ("math".equals(captchaType))
{
String capText = captchaProducerMath.createText();
capStr = capText.substring(0, capText.lastIndexOf("@"));
code = capText.substring(capText.lastIndexOf("@") + 1);
image = captchaProducerMath.createImage(capStr);
}
else if ("char".equals(captchaType))
{
capStr = code = captchaProducer.createText();
image = captchaProducer.createImage(capStr);
}
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
// 转换流信息写出
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
try
{
ImageIO.write(image, "jpg", os);
}
catch (IOException e)
{
return AjaxResult.error(e.getMessage());
}
AjaxResult ajax = AjaxResult.success();
ajax.put("uuid", uuid);
ajax.put("img", Base64.encode(os.toByteArray()));
return ajax;
}
}

View File

@ -1,16 +1,12 @@
package com.ruoyi.web.controller.common; package com.ruoyi.web.controller.common;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.config.RuoYiConfig;
@ -27,7 +23,6 @@ import com.ruoyi.framework.config.ServerConfig;
* @author ruoyi * @author ruoyi
*/ */
@RestController @RestController
@RequestMapping("/common")
public class CommonController public class CommonController
{ {
private static final Logger log = LoggerFactory.getLogger(CommonController.class); private static final Logger log = LoggerFactory.getLogger(CommonController.class);
@ -35,28 +30,28 @@ public class CommonController
@Autowired @Autowired
private ServerConfig serverConfig; private ServerConfig serverConfig;
private static final String FILE_DELIMETER = ",";
/** /**
* 通用下载请求 * 通用下载请求
* *
* @param fileName 文件名称 * @param fileName 文件名称
* @param delete 是否删除 * @param delete 是否删除
*/ */
@GetMapping("/download") @GetMapping("common/download")
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
{ {
try try
{ {
if (!FileUtils.checkAllowDownload(fileName)) if (!FileUtils.isValidFilename(fileName))
{ {
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName)); throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
} }
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1); String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
String filePath = RuoYiConfig.getDownloadPath() + fileName; String filePath = RuoYiConfig.getDownloadPath() + fileName;
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); response.setCharacterEncoding("utf-8");
FileUtils.setAttachmentResponseHeader(response, realFileName); response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition",
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName));
FileUtils.writeBytes(filePath, response.getOutputStream()); FileUtils.writeBytes(filePath, response.getOutputStream());
if (delete) if (delete)
{ {
@ -70,9 +65,9 @@ public class CommonController
} }
/** /**
* 通用上传请求单个 * 通用上传请求
*/ */
@PostMapping("/upload") @PostMapping("/common/upload")
public AjaxResult uploadFile(MultipartFile file) throws Exception public AjaxResult uploadFile(MultipartFile file) throws Exception
{ {
try try
@ -83,47 +78,8 @@ public class CommonController
String fileName = FileUploadUtils.upload(filePath, file); String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName; String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("url", url);
ajax.put("fileName", fileName); ajax.put("fileName", fileName);
ajax.put("newFileName", FileUtils.getName(fileName)); ajax.put("url", url);
ajax.put("originalFilename", file.getOriginalFilename());
return ajax;
}
catch (Exception e)
{
return AjaxResult.error(e.getMessage());
}
}
/**
* 通用上传请求多个
*/
@PostMapping("/uploads")
public AjaxResult uploadFiles(List<MultipartFile> files) throws Exception
{
try
{
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
List<String> urls = new ArrayList<String>();
List<String> fileNames = new ArrayList<String>();
List<String> newFileNames = new ArrayList<String>();
List<String> originalFilenames = new ArrayList<String>();
for (MultipartFile file : files)
{
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
urls.add(url);
fileNames.add(fileName);
newFileNames.add(FileUtils.getName(fileName));
originalFilenames.add(file.getOriginalFilename());
}
AjaxResult ajax = AjaxResult.success();
ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
return ajax; return ajax;
} }
catch (Exception e) catch (Exception e)
@ -135,29 +91,19 @@ public class CommonController
/** /**
* 本地资源通用下载 * 本地资源通用下载
*/ */
@GetMapping("/download/resource") @GetMapping("/common/download/resource")
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response) public void resourceDownload(String name, HttpServletRequest request, HttpServletResponse response) throws Exception
throws Exception
{ {
try
{
if (!FileUtils.checkAllowDownload(resource))
{
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
}
// 本地资源路径 // 本地资源路径
String localPath = RuoYiConfig.getProfile(); String localPath = RuoYiConfig.getProfile();
// 数据库资源地址 // 数据库资源地址
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX); String downloadPath = localPath + StringUtils.substringAfter(name, Constants.RESOURCE_PREFIX);
// 下载名称 // 下载名称
String downloadName = StringUtils.substringAfterLast(downloadPath, "/"); String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE); response.setCharacterEncoding("utf-8");
FileUtils.setAttachmentResponseHeader(response, downloadName); response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition",
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName));
FileUtils.writeBytes(downloadPath, response.getOutputStream()); FileUtils.writeBytes(downloadPath, response.getOutputStream());
} }
catch (Exception e)
{
log.error("下载文件失败", e);
}
}
} }

View File

@ -1,53 +0,0 @@
package com.ruoyi.web.controller.monitor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils;
/**
* 缓存监控
*
* @author ruoyi
*/
@RestController
@RequestMapping("/monitor/cache")
public class CacheController
{
@Autowired
private RedisTemplate<String, String> redisTemplate;
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping()
public AjaxResult getInfo() throws Exception
{
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
Map<String, Object> result = new HashMap<>(3);
result.put("info", info);
result.put("dbSize", dbSize);
List<Map<String, String>> pieList = new ArrayList<>();
commandStats.stringPropertyNames().forEach(key -> {
Map<String, String> data = new HashMap<>(2);
String property = commandStats.getProperty(key);
data.put("name", StringUtils.removeStart(key, "cmdstat_"));
data.put("value", StringUtils.substringBetween(property, "calls=", ",usec"));
pieList.add(data);
});
result.put("commandStats", pieList);
return AjaxResult.success(result);
}
}

View File

@ -4,6 +4,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.framework.web.domain.Server; import com.ruoyi.framework.web.domain.Server;
@ -14,7 +15,7 @@ import com.ruoyi.framework.web.domain.Server;
*/ */
@RestController @RestController
@RequestMapping("/monitor/server") @RequestMapping("/monitor/server")
public class ServerController public class ServerController extends BaseController
{ {
@PreAuthorize("@ss.hasPermi('monitor:server:list')") @PreAuthorize("@ss.hasPermi('monitor:server:list')")
@GetMapping() @GetMapping()

View File

@ -1,13 +1,11 @@
package com.ruoyi.web.controller.monitor; package com.ruoyi.web.controller.monitor;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
@ -40,18 +38,18 @@ public class SysLogininforController extends BaseController
return getDataTable(list); return getDataTable(list);
} }
@Log(title = "日志", businessType = BusinessType.EXPORT) @Log(title = "日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')") @PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
@PostMapping("/export") @GetMapping("/export")
public void export(HttpServletResponse response, SysLogininfor logininfor) public AjaxResult export(SysLogininfor logininfor)
{ {
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class); ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
util.exportExcel(response, list, "登录日志"); return util.exportExcel(list, "登陆日志");
} }
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
@Log(title = "日志", businessType = BusinessType.DELETE) @Log(title = "日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{infoIds}") @DeleteMapping("/{infoIds}")
public AjaxResult remove(@PathVariable Long[] infoIds) public AjaxResult remove(@PathVariable Long[] infoIds)
{ {
@ -59,7 +57,7 @@ public class SysLogininforController extends BaseController
} }
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')") @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
@Log(title = "日志", businessType = BusinessType.CLEAN) @Log(title = "日志", businessType = BusinessType.CLEAN)
@DeleteMapping("/clean") @DeleteMapping("/clean")
public AjaxResult clean() public AjaxResult clean()
{ {

View File

@ -1,13 +1,11 @@
package com.ruoyi.web.controller.monitor; package com.ruoyi.web.controller.monitor;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
@ -42,15 +40,14 @@ public class SysOperlogController extends BaseController
@Log(title = "操作日志", businessType = BusinessType.EXPORT) @Log(title = "操作日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')") @PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
@PostMapping("/export") @GetMapping("/export")
public void export(HttpServletResponse response, SysOperLog operLog) public AjaxResult export(SysOperLog operLog)
{ {
List<SysOperLog> list = operLogService.selectOperLogList(operLog); List<SysOperLog> list = operLogService.selectOperLogList(operLog);
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class); ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
util.exportExcel(response, list, "操作日志"); return util.exportExcel(list, "操作日志");
} }
@Log(title = "操作日志", businessType = BusinessType.DELETE)
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')") @PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
@DeleteMapping("/{operIds}") @DeleteMapping("/{operIds}")
public AjaxResult remove(@PathVariable Long[] operIds) public AjaxResult remove(@PathVariable Long[] operIds)

View File

@ -1,7 +1,6 @@
package com.ruoyi.web.controller.system; package com.ruoyi.web.controller.system;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -14,11 +13,13 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysConfig; import com.ruoyi.system.domain.SysConfig;
import com.ruoyi.system.service.ISysConfigService; import com.ruoyi.system.service.ISysConfigService;
@ -49,12 +50,12 @@ public class SysConfigController extends BaseController
@Log(title = "参数管理", businessType = BusinessType.EXPORT) @Log(title = "参数管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:config:export')") @PreAuthorize("@ss.hasPermi('system:config:export')")
@PostMapping("/export") @GetMapping("/export")
public void export(HttpServletResponse response, SysConfig config) public AjaxResult export(SysConfig config)
{ {
List<SysConfig> list = configService.selectConfigList(config); List<SysConfig> list = configService.selectConfigList(config);
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class); ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
util.exportExcel(response, list, "参数数据"); return util.exportExcel(list, "参数数据");
} }
/** /**
@ -82,13 +83,14 @@ public class SysConfigController extends BaseController
@PreAuthorize("@ss.hasPermi('system:config:add')") @PreAuthorize("@ss.hasPermi('system:config:add')")
@Log(title = "参数管理", businessType = BusinessType.INSERT) @Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
@RepeatSubmit
public AjaxResult add(@Validated @RequestBody SysConfig config) public AjaxResult add(@Validated @RequestBody SysConfig config)
{ {
if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config)))
{ {
return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在"); return AjaxResult.error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
} }
config.setCreateBy(getUsername()); config.setCreateBy(SecurityUtils.getUsername());
return toAjax(configService.insertConfig(config)); return toAjax(configService.insertConfig(config));
} }
@ -104,7 +106,7 @@ public class SysConfigController extends BaseController
{ {
return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在"); return AjaxResult.error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
} }
config.setUpdateBy(getUsername()); config.setUpdateBy(SecurityUtils.getUsername());
return toAjax(configService.updateConfig(config)); return toAjax(configService.updateConfig(config));
} }
@ -116,19 +118,18 @@ public class SysConfigController extends BaseController
@DeleteMapping("/{configIds}") @DeleteMapping("/{configIds}")
public AjaxResult remove(@PathVariable Long[] configIds) public AjaxResult remove(@PathVariable Long[] configIds)
{ {
configService.deleteConfigByIds(configIds); return toAjax(configService.deleteConfigByIds(configIds));
return success();
} }
/** /**
* 刷新参数缓存 * 清空缓存
*/ */
@PreAuthorize("@ss.hasPermi('system:config:remove')") @PreAuthorize("@ss.hasPermi('system:config:remove')")
@Log(title = "参数管理", businessType = BusinessType.CLEAN) @Log(title = "参数管理", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache") @DeleteMapping("/clearCache")
public AjaxResult refreshCache() public AjaxResult clearCache()
{ {
configService.resetConfigCache(); configService.clearCache();
return AjaxResult.success(); return AjaxResult.success();
} }
} }

View File

@ -20,6 +20,7 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysDeptService;
@ -74,7 +75,6 @@ public class SysDeptController extends BaseController
@GetMapping(value = "/{deptId}") @GetMapping(value = "/{deptId}")
public AjaxResult getInfo(@PathVariable Long deptId) public AjaxResult getInfo(@PathVariable Long deptId)
{ {
deptService.checkDeptDataScope(deptId);
return AjaxResult.success(deptService.selectDeptById(deptId)); return AjaxResult.success(deptService.selectDeptById(deptId));
} }
@ -113,7 +113,7 @@ public class SysDeptController extends BaseController
{ {
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
} }
dept.setCreateBy(getUsername()); dept.setCreateBy(SecurityUtils.getUsername());
return toAjax(deptService.insertDept(dept)); return toAjax(deptService.insertDept(dept));
} }
@ -125,21 +125,20 @@ public class SysDeptController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@Validated @RequestBody SysDept dept) public AjaxResult edit(@Validated @RequestBody SysDept dept)
{ {
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId);
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{ {
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
} }
else if (dept.getParentId().equals(deptId)) else if (dept.getParentId().equals(dept.getDeptId()))
{ {
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己"); return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
} }
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus())
&& deptService.selectNormalChildrenDeptById(dept.getDeptId()) > 0)
{ {
return AjaxResult.error("该部门包含未停用的子部门!"); return AjaxResult.error("该部门包含未停用的子部门!");
} }
dept.setUpdateBy(getUsername()); dept.setUpdateBy(SecurityUtils.getUsername());
return toAjax(deptService.updateDept(dept)); return toAjax(deptService.updateDept(dept));
} }
@ -159,7 +158,6 @@ public class SysDeptController extends BaseController
{ {
return AjaxResult.error("部门存在用户,不允许删除"); return AjaxResult.error("部门存在用户,不允许删除");
} }
deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(deptId)); return toAjax(deptService.deleteDeptById(deptId));
} }
} }

View File

@ -1,8 +1,6 @@
package com.ruoyi.web.controller.system; package com.ruoyi.web.controller.system;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -20,7 +18,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.core.domain.entity.SysDictData;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDictDataService; import com.ruoyi.system.service.ISysDictDataService;
import com.ruoyi.system.service.ISysDictTypeService; import com.ruoyi.system.service.ISysDictTypeService;
@ -51,12 +49,12 @@ public class SysDictDataController extends BaseController
@Log(title = "字典数据", businessType = BusinessType.EXPORT) @Log(title = "字典数据", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')") @PreAuthorize("@ss.hasPermi('system:dict:export')")
@PostMapping("/export") @GetMapping("/export")
public void export(HttpServletResponse response, SysDictData dictData) public AjaxResult export(SysDictData dictData)
{ {
List<SysDictData> list = dictDataService.selectDictDataList(dictData); List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class); ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
util.exportExcel(response, list, "字典数据"); return util.exportExcel(list, "字典数据");
} }
/** /**
@ -75,12 +73,7 @@ public class SysDictDataController extends BaseController
@GetMapping(value = "/type/{dictType}") @GetMapping(value = "/type/{dictType}")
public AjaxResult dictType(@PathVariable String dictType) public AjaxResult dictType(@PathVariable String dictType)
{ {
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType); return AjaxResult.success(dictTypeService.selectDictDataByType(dictType));
if (StringUtils.isNull(data))
{
data = new ArrayList<SysDictData>();
}
return AjaxResult.success(data);
} }
/** /**
@ -91,7 +84,7 @@ public class SysDictDataController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@Validated @RequestBody SysDictData dict) public AjaxResult add(@Validated @RequestBody SysDictData dict)
{ {
dict.setCreateBy(getUsername()); dict.setCreateBy(SecurityUtils.getUsername());
return toAjax(dictDataService.insertDictData(dict)); return toAjax(dictDataService.insertDictData(dict));
} }
@ -103,7 +96,7 @@ public class SysDictDataController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@Validated @RequestBody SysDictData dict) public AjaxResult edit(@Validated @RequestBody SysDictData dict)
{ {
dict.setUpdateBy(getUsername()); dict.setUpdateBy(SecurityUtils.getUsername());
return toAjax(dictDataService.updateDictData(dict)); return toAjax(dictDataService.updateDictData(dict));
} }
@ -115,7 +108,6 @@ public class SysDictDataController extends BaseController
@DeleteMapping("/{dictCodes}") @DeleteMapping("/{dictCodes}")
public AjaxResult remove(@PathVariable Long[] dictCodes) public AjaxResult remove(@PathVariable Long[] dictCodes)
{ {
dictDataService.deleteDictDataByIds(dictCodes); return toAjax(dictDataService.deleteDictDataByIds(dictCodes));
return success();
} }
} }

View File

@ -1,7 +1,6 @@
package com.ruoyi.web.controller.system; package com.ruoyi.web.controller.system;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -20,6 +19,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysDictType; import com.ruoyi.common.core.domain.entity.SysDictType;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.service.ISysDictTypeService; import com.ruoyi.system.service.ISysDictTypeService;
@ -46,12 +46,12 @@ public class SysDictTypeController extends BaseController
@Log(title = "字典类型", businessType = BusinessType.EXPORT) @Log(title = "字典类型", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')") @PreAuthorize("@ss.hasPermi('system:dict:export')")
@PostMapping("/export") @GetMapping("/export")
public void export(HttpServletResponse response, SysDictType dictType) public AjaxResult export(SysDictType dictType)
{ {
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType); List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class); ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
util.exportExcel(response, list, "字典类型"); return util.exportExcel(list, "字典类型");
} }
/** /**
@ -76,7 +76,7 @@ public class SysDictTypeController extends BaseController
{ {
return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在"); return AjaxResult.error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
} }
dict.setCreateBy(getUsername()); dict.setCreateBy(SecurityUtils.getUsername());
return toAjax(dictTypeService.insertDictType(dict)); return toAjax(dictTypeService.insertDictType(dict));
} }
@ -92,7 +92,7 @@ public class SysDictTypeController extends BaseController
{ {
return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在"); return AjaxResult.error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
} }
dict.setUpdateBy(getUsername()); dict.setUpdateBy(SecurityUtils.getUsername());
return toAjax(dictTypeService.updateDictType(dict)); return toAjax(dictTypeService.updateDictType(dict));
} }
@ -104,19 +104,18 @@ public class SysDictTypeController extends BaseController
@DeleteMapping("/{dictIds}") @DeleteMapping("/{dictIds}")
public AjaxResult remove(@PathVariable Long[] dictIds) public AjaxResult remove(@PathVariable Long[] dictIds)
{ {
dictTypeService.deleteDictTypeByIds(dictIds); return toAjax(dictTypeService.deleteDictTypeByIds(dictIds));
return success();
} }
/** /**
* 刷新字典缓存 * 清空缓存
*/ */
@PreAuthorize("@ss.hasPermi('system:dict:remove')") @PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.CLEAN) @Log(title = "字典类型", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache") @DeleteMapping("/clearCache")
public AjaxResult refreshCache() public AjaxResult clearCache()
{ {
dictTypeService.resetDictCache(); dictTypeService.clearCache();
return AjaxResult.success(); return AjaxResult.success();
} }

View File

@ -1,29 +0,0 @@
package com.ruoyi.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.utils.StringUtils;
/**
* 首页
*
* @author ruoyi
*/
@RestController
public class SysIndexController
{
/** 系统基础配置 */
@Autowired
private RuoYiConfig ruoyiConfig;
/**
* 访问首页提示语
*/
@RequestMapping("/")
public String index()
{
return StringUtils.format("欢迎使用{}后台管理框架当前版本v{},请通过前端地址访问。", ruoyiConfig.getName(), ruoyiConfig.getVersion());
}
}

View File

@ -50,7 +50,8 @@ public class SysLoginController
{ {
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
// 生成令牌 // 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode()); String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
ajax.put(Constants.TOKEN, token); ajax.put(Constants.TOKEN, token);
return ajax; return ajax;
} }

View File

@ -13,12 +13,17 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysMenu; import com.ruoyi.common.core.domain.entity.SysMenu;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.service.ISysMenuService; import com.ruoyi.system.service.ISysMenuService;
/** /**
@ -33,6 +38,9 @@ public class SysMenuController extends BaseController
@Autowired @Autowired
private ISysMenuService menuService; private ISysMenuService menuService;
@Autowired
private TokenService tokenService;
/** /**
* 获取菜单列表 * 获取菜单列表
*/ */
@ -40,7 +48,9 @@ public class SysMenuController extends BaseController
@GetMapping("/list") @GetMapping("/list")
public AjaxResult list(SysMenu menu) public AjaxResult list(SysMenu menu)
{ {
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
Long userId = loginUser.getUser().getUserId();
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
return AjaxResult.success(menus); return AjaxResult.success(menus);
} }
@ -60,7 +70,9 @@ public class SysMenuController extends BaseController
@GetMapping("/treeselect") @GetMapping("/treeselect")
public AjaxResult treeselect(SysMenu menu) public AjaxResult treeselect(SysMenu menu)
{ {
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId()); LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
Long userId = loginUser.getUser().getUserId();
List<SysMenu> menus = menuService.selectMenuList(menu, userId);
return AjaxResult.success(menuService.buildMenuTreeSelect(menus)); return AjaxResult.success(menuService.buildMenuTreeSelect(menus));
} }
@ -70,7 +82,8 @@ public class SysMenuController extends BaseController
@GetMapping(value = "/roleMenuTreeselect/{roleId}") @GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId) public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
{ {
List<SysMenu> menus = menuService.selectMenuList(getUserId()); LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
List<SysMenu> menus = menuService.selectMenuList(loginUser.getUser().getUserId());
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId)); ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
ajax.put("menus", menuService.buildMenuTreeSelect(menus)); ajax.put("menus", menuService.buildMenuTreeSelect(menus));
@ -89,11 +102,12 @@ public class SysMenuController extends BaseController
{ {
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} }
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
{ {
return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头"); return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");
} }
menu.setCreateBy(getUsername()); menu.setCreateBy(SecurityUtils.getUsername());
return toAjax(menuService.insertMenu(menu)); return toAjax(menuService.insertMenu(menu));
} }
@ -109,15 +123,16 @@ public class SysMenuController extends BaseController
{ {
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在"); return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
} }
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath())) else if (UserConstants.YES_FRAME.equals(menu.getIsFrame())
&& !StringUtils.startsWithAny(menu.getPath(), Constants.HTTP, Constants.HTTPS))
{ {
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头"); return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");
} }
else if (menu.getMenuId().equals(menu.getParentId())) else if (menu.getMenuId().equals(menu.getParentId()))
{ {
return AjaxResult.error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己"); return AjaxResult.error("新增菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
} }
menu.setUpdateBy(getUsername()); menu.setUpdateBy(SecurityUtils.getUsername());
return toAjax(menuService.updateMenu(menu)); return toAjax(menuService.updateMenu(menu));
} }

View File

@ -17,6 +17,7 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.SysNotice; import com.ruoyi.system.domain.SysNotice;
import com.ruoyi.system.service.ISysNoticeService; import com.ruoyi.system.service.ISysNoticeService;
@ -62,7 +63,7 @@ public class SysNoticeController extends BaseController
@PostMapping @PostMapping
public AjaxResult add(@Validated @RequestBody SysNotice notice) public AjaxResult add(@Validated @RequestBody SysNotice notice)
{ {
notice.setCreateBy(getUsername()); notice.setCreateBy(SecurityUtils.getUsername());
return toAjax(noticeService.insertNotice(notice)); return toAjax(noticeService.insertNotice(notice));
} }
@ -74,7 +75,7 @@ public class SysNoticeController extends BaseController
@PutMapping @PutMapping
public AjaxResult edit(@Validated @RequestBody SysNotice notice) public AjaxResult edit(@Validated @RequestBody SysNotice notice)
{ {
notice.setUpdateBy(getUsername()); notice.setUpdateBy(SecurityUtils.getUsername());
return toAjax(noticeService.updateNotice(notice)); return toAjax(noticeService.updateNotice(notice));
} }

View File

@ -1,7 +1,6 @@
package com.ruoyi.web.controller.system; package com.ruoyi.web.controller.system;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -19,6 +18,7 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.domain.SysPost;
import com.ruoyi.system.service.ISysPostService; import com.ruoyi.system.service.ISysPostService;
@ -49,12 +49,12 @@ public class SysPostController extends BaseController
@Log(title = "岗位管理", businessType = BusinessType.EXPORT) @Log(title = "岗位管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:post:export')") @PreAuthorize("@ss.hasPermi('system:post:export')")
@PostMapping("/export") @GetMapping("/export")
public void export(HttpServletResponse response, SysPost post) public AjaxResult export(SysPost post)
{ {
List<SysPost> list = postService.selectPostList(post); List<SysPost> list = postService.selectPostList(post);
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class); ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
util.exportExcel(response, list, "岗位数据"); return util.exportExcel(list, "岗位数据");
} }
/** /**
@ -83,7 +83,7 @@ public class SysPostController extends BaseController
{ {
return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在"); return AjaxResult.error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
} }
post.setCreateBy(getUsername()); post.setCreateBy(SecurityUtils.getUsername());
return toAjax(postService.insertPost(post)); return toAjax(postService.insertPost(post));
} }
@ -103,7 +103,7 @@ public class SysPostController extends BaseController
{ {
return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在"); return AjaxResult.error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
} }
post.setUpdateBy(getUsername()); post.setUpdateBy(SecurityUtils.getUsername());
return toAjax(postService.updatePost(post)); return toAjax(postService.updatePost(post));
} }

View File

@ -12,14 +12,13 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
@ -45,7 +44,7 @@ public class SysProfileController extends BaseController
@GetMapping @GetMapping
public AjaxResult profile() public AjaxResult profile()
{ {
LoginUser loginUser = getLoginUser(); LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
SysUser user = loginUser.getUser(); SysUser user = loginUser.getUser();
AjaxResult ajax = AjaxResult.success(user); AjaxResult ajax = AjaxResult.success(user);
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername())); ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
@ -60,28 +59,14 @@ public class SysProfileController extends BaseController
@PutMapping @PutMapping
public AjaxResult updateProfile(@RequestBody SysUser user) public AjaxResult updateProfile(@RequestBody SysUser user)
{ {
LoginUser loginUser = getLoginUser();
SysUser sysUser = loginUser.getUser();
user.setUserName(sysUser.getUserName());
if (StringUtils.isNotEmpty(user.getPhonenumber())
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
}
if (StringUtils.isNotEmpty(user.getEmail())
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUserId(sysUser.getUserId());
user.setPassword(null);
if (userService.updateUserProfile(user) > 0) if (userService.updateUserProfile(user) > 0)
{ {
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
// 更新缓存用户信息 // 更新缓存用户信息
sysUser.setNickName(user.getNickName()); loginUser.getUser().setNickName(user.getNickName());
sysUser.setPhonenumber(user.getPhonenumber()); loginUser.getUser().setPhonenumber(user.getPhonenumber());
sysUser.setEmail(user.getEmail()); loginUser.getUser().setEmail(user.getEmail());
sysUser.setSex(user.getSex()); loginUser.getUser().setSex(user.getSex());
tokenService.setLoginUser(loginUser); tokenService.setLoginUser(loginUser);
return AjaxResult.success(); return AjaxResult.success();
} }
@ -95,7 +80,7 @@ public class SysProfileController extends BaseController
@PutMapping("/updatePwd") @PutMapping("/updatePwd")
public AjaxResult updatePwd(String oldPassword, String newPassword) public AjaxResult updatePwd(String oldPassword, String newPassword)
{ {
LoginUser loginUser = getLoginUser(); LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
String userName = loginUser.getUsername(); String userName = loginUser.getUsername();
String password = loginUser.getPassword(); String password = loginUser.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password)) if (!SecurityUtils.matchesPassword(oldPassword, password))
@ -125,7 +110,7 @@ public class SysProfileController extends BaseController
{ {
if (!file.isEmpty()) if (!file.isEmpty())
{ {
LoginUser loginUser = getLoginUser(); LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file); String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
if (userService.updateUserAvatar(loginUser.getUsername(), avatar)) if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
{ {

View File

@ -1,38 +0,0 @@
package com.ruoyi.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.RegisterBody;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.service.SysRegisterService;
import com.ruoyi.system.service.ISysConfigService;
/**
* 注册验证
*
* @author ruoyi
*/
@RestController
public class SysRegisterController extends BaseController
{
@Autowired
private SysRegisterService registerService;
@Autowired
private ISysConfigService configService;
@PostMapping("/register")
public AjaxResult register(@RequestBody RegisterBody user)
{
// if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
// {
// return error("当前系统没有开启注册功能!");
// }
String msg = registerService.register(user);
return StringUtils.isEmpty(msg) ? success() : error(msg);
}
}

View File

@ -1,7 +1,6 @@
package com.ruoyi.web.controller.system; package com.ruoyi.web.controller.system;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -18,15 +17,15 @@ import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.service.SysPermissionService; import com.ruoyi.framework.web.service.SysPermissionService;
import com.ruoyi.framework.web.service.TokenService; import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
@ -62,12 +61,12 @@ public class SysRoleController extends BaseController
@Log(title = "角色管理", businessType = BusinessType.EXPORT) @Log(title = "角色管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:role:export')") @PreAuthorize("@ss.hasPermi('system:role:export')")
@PostMapping("/export") @GetMapping("/export")
public void export(HttpServletResponse response, SysRole role) public AjaxResult export(SysRole role)
{ {
List<SysRole> list = roleService.selectRoleList(role); List<SysRole> list = roleService.selectRoleList(role);
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class); ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
util.exportExcel(response, list, "角色数据"); return util.exportExcel(list, "角色数据");
} }
/** /**
@ -77,7 +76,6 @@ public class SysRoleController extends BaseController
@GetMapping(value = "/{roleId}") @GetMapping(value = "/{roleId}")
public AjaxResult getInfo(@PathVariable Long roleId) public AjaxResult getInfo(@PathVariable Long roleId)
{ {
roleService.checkRoleDataScope(roleId);
return AjaxResult.success(roleService.selectRoleById(roleId)); return AjaxResult.success(roleService.selectRoleById(roleId));
} }
@ -97,7 +95,7 @@ public class SysRoleController extends BaseController
{ {
return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在"); return AjaxResult.error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
} }
role.setCreateBy(getUsername()); role.setCreateBy(SecurityUtils.getUsername());
return toAjax(roleService.insertRole(role)); return toAjax(roleService.insertRole(role));
} }
@ -111,7 +109,6 @@ public class SysRoleController extends BaseController
public AjaxResult edit(@Validated @RequestBody SysRole role) public AjaxResult edit(@Validated @RequestBody SysRole role)
{ {
roleService.checkRoleAllowed(role); roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role))) if (UserConstants.NOT_UNIQUE.equals(roleService.checkRoleNameUnique(role)))
{ {
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在"); return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
@ -120,12 +117,12 @@ public class SysRoleController extends BaseController
{ {
return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在"); return AjaxResult.error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
} }
role.setUpdateBy(getUsername()); role.setUpdateBy(SecurityUtils.getUsername());
if (roleService.updateRole(role) > 0) if (roleService.updateRole(role) > 0)
{ {
// 更新缓存用户权限 // 更新缓存用户权限
LoginUser loginUser = getLoginUser(); LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin()) if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
{ {
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser())); loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
@ -146,7 +143,6 @@ public class SysRoleController extends BaseController
public AjaxResult dataScope(@RequestBody SysRole role) public AjaxResult dataScope(@RequestBody SysRole role)
{ {
roleService.checkRoleAllowed(role); roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
return toAjax(roleService.authDataScope(role)); return toAjax(roleService.authDataScope(role));
} }
@ -159,8 +155,7 @@ public class SysRoleController extends BaseController
public AjaxResult changeStatus(@RequestBody SysRole role) public AjaxResult changeStatus(@RequestBody SysRole role)
{ {
roleService.checkRoleAllowed(role); roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId()); role.setUpdateBy(SecurityUtils.getUsername());
role.setUpdateBy(getUsername());
return toAjax(roleService.updateRoleStatus(role)); return toAjax(roleService.updateRoleStatus(role));
} }
@ -184,62 +179,4 @@ public class SysRoleController extends BaseController
{ {
return AjaxResult.success(roleService.selectRoleAll()); return AjaxResult.success(roleService.selectRoleAll());
} }
/**
* 查询已分配用户角色列表
*/
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/allocatedList")
public TableDataInfo allocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list);
}
/**
* 查询未分配用户角色列表
*/
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/unallocatedList")
public TableDataInfo unallocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list);
}
/**
* 取消授权用户
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancel")
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole)
{
return toAjax(roleService.deleteAuthUser(userRole));
}
/**
* 批量取消授权用户
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancelAll")
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds)
{
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
}
/**
* 批量选择用户授权
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/selectAll")
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
{
roleService.checkRoleDataScope(roleId);
return toAjax(roleService.insertAuthUsers(roleId, userIds));
}
} }

View File

@ -2,8 +2,6 @@ package com.ruoyi.web.controller.system;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -22,11 +20,14 @@ import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.service.ISysPostService; import com.ruoyi.system.service.ISysPostService;
import com.ruoyi.system.service.ISysRoleService; import com.ruoyi.system.service.ISysRoleService;
import com.ruoyi.system.service.ISysUserService; import com.ruoyi.system.service.ISysUserService;
@ -49,6 +50,9 @@ public class SysUserController extends BaseController
@Autowired @Autowired
private ISysPostService postService; private ISysPostService postService;
@Autowired
private TokenService tokenService;
/** /**
* 获取用户列表 * 获取用户列表
*/ */
@ -63,12 +67,12 @@ public class SysUserController extends BaseController
@Log(title = "用户管理", businessType = BusinessType.EXPORT) @Log(title = "用户管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:user:export')") @PreAuthorize("@ss.hasPermi('system:user:export')")
@PostMapping("/export") @GetMapping("/export")
public void export(HttpServletResponse response, SysUser user) public AjaxResult export(SysUser user)
{ {
List<SysUser> list = userService.selectUserList(user); List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.exportExcel(response, list, "用户数据"); return util.exportExcel(list, "用户数据");
} }
@Log(title = "用户管理", businessType = BusinessType.IMPORT) @Log(title = "用户管理", businessType = BusinessType.IMPORT)
@ -78,16 +82,17 @@ public class SysUserController extends BaseController
{ {
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUser> userList = util.importExcel(file.getInputStream()); List<SysUser> userList = util.importExcel(file.getInputStream());
String operName = getUsername(); LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
String operName = loginUser.getUsername();
String message = userService.importUser(userList, updateSupport, operName); String message = userService.importUser(userList, updateSupport, operName);
return AjaxResult.success(message); return AjaxResult.success(message);
} }
@PostMapping("/importTemplate") @GetMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) public AjaxResult importTemplate()
{ {
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class); ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.importTemplateExcel(response, "用户数据"); return util.importTemplateExcel("用户数据");
} }
/** /**
@ -97,17 +102,15 @@ public class SysUserController extends BaseController
@GetMapping(value = { "/", "/{userId}" }) @GetMapping(value = { "/", "/{userId}" })
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId)
{ {
userService.checkUserDataScope(userId);
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
List<SysRole> roles = roleService.selectRoleAll(); List<SysRole> roles = roleService.selectRoleAll();
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList())); ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
ajax.put("posts", postService.selectPostAll()); ajax.put("posts", postService.selectPostAll());
if (StringUtils.isNotNull(userId)) if (StringUtils.isNotNull(userId))
{ {
SysUser sysUser = userService.selectUserById(userId); ajax.put(AjaxResult.DATA_TAG, userService.selectUserById(userId));
ajax.put(AjaxResult.DATA_TAG, sysUser);
ajax.put("postIds", postService.selectPostListByUserId(userId)); ajax.put("postIds", postService.selectPostListByUserId(userId));
ajax.put("roleIds", sysUser.getRoles().stream().map(SysRole::getRoleId).collect(Collectors.toList())); ajax.put("roleIds", roleService.selectRoleListByUserId(userId));
} }
return ajax; return ajax;
} }
@ -124,17 +127,15 @@ public class SysUserController extends BaseController
{ {
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在"); return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
} }
else if (StringUtils.isNotEmpty(user.getPhonenumber()) else if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{ {
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
} }
else if (StringUtils.isNotEmpty(user.getEmail()) else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{ {
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在"); return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
} }
user.setCreateBy(getUsername()); user.setCreateBy(SecurityUtils.getUsername());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
return toAjax(userService.insertUser(user)); return toAjax(userService.insertUser(user));
} }
@ -148,18 +149,15 @@ public class SysUserController extends BaseController
public AjaxResult edit(@Validated @RequestBody SysUser user) public AjaxResult edit(@Validated @RequestBody SysUser user)
{ {
userService.checkUserAllowed(user); userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId()); if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
if (StringUtils.isNotEmpty(user.getPhonenumber())
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user)))
{ {
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
} }
else if (StringUtils.isNotEmpty(user.getEmail()) else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user)))
{ {
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在"); return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
} }
user.setUpdateBy(getUsername()); user.setUpdateBy(SecurityUtils.getUsername());
return toAjax(userService.updateUser(user)); return toAjax(userService.updateUser(user));
} }
@ -171,25 +169,20 @@ public class SysUserController extends BaseController
@DeleteMapping("/{userIds}") @DeleteMapping("/{userIds}")
public AjaxResult remove(@PathVariable Long[] userIds) public AjaxResult remove(@PathVariable Long[] userIds)
{ {
if (ArrayUtils.contains(userIds, getUserId()))
{
return error("当前用户不能删除");
}
return toAjax(userService.deleteUserByIds(userIds)); return toAjax(userService.deleteUserByIds(userIds));
} }
/** /**
* 重置密码 * 重置密码
*/ */
@PreAuthorize("@ss.hasPermi('system:user:resetPwd')") @PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE) @Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/resetPwd") @PutMapping("/resetPwd")
public AjaxResult resetPwd(@RequestBody SysUser user) public AjaxResult resetPwd(@RequestBody SysUser user)
{ {
userService.checkUserAllowed(user); userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
user.setUpdateBy(getUsername()); user.setUpdateBy(SecurityUtils.getUsername());
return toAjax(userService.resetPwd(user)); return toAjax(userService.resetPwd(user));
} }
@ -202,36 +195,7 @@ public class SysUserController extends BaseController
public AjaxResult changeStatus(@RequestBody SysUser user) public AjaxResult changeStatus(@RequestBody SysUser user)
{ {
userService.checkUserAllowed(user); userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId()); user.setUpdateBy(SecurityUtils.getUsername());
user.setUpdateBy(getUsername());
return toAjax(userService.updateUserStatus(user)); return toAjax(userService.updateUserStatus(user));
} }
/**
* 根据用户编号获取授权角色
*/
@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping("/authRole/{userId}")
public AjaxResult authRole(@PathVariable("userId") Long userId)
{
AjaxResult ajax = AjaxResult.success();
SysUser user = userService.selectUserById(userId);
List<SysRole> roles = roleService.selectRolesByUserId(userId);
ajax.put("user", user);
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
return ajax;
}
/**
* 用户授权角色
*/
@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.GRANT)
@PutMapping("/authRole")
public AjaxResult insertAuthRole(Long userId, Long[] roleIds)
{
userService.checkUserDataScope(userId);
userService.insertUserAuth(userId, roleIds);
return success();
}
} }

View File

@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
@ -17,7 +16,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -47,7 +45,7 @@ public class TestController extends BaseController
} }
@ApiOperation("获取用户详细") @ApiOperation("获取用户详细")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class) @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
@GetMapping("/{userId}") @GetMapping("/{userId}")
public AjaxResult getUser(@PathVariable Integer userId) public AjaxResult getUser(@PathVariable Integer userId)
{ {
@ -57,61 +55,57 @@ public class TestController extends BaseController
} }
else else
{ {
return error("用户不存在"); return AjaxResult.error("用户不存在");
} }
} }
@ApiOperation("新增用户") @ApiOperation("新增用户")
@ApiImplicitParams({ @ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "username", value = "用户名称", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
})
@PostMapping("/save") @PostMapping("/save")
public AjaxResult save(UserEntity user) public AjaxResult save(UserEntity user)
{ {
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{ {
return error("用户ID不能为空"); return AjaxResult.error("用户ID不能为空");
} }
return AjaxResult.success(users.put(user.getUserId(), user)); return AjaxResult.success(users.put(user.getUserId(), user));
} }
@ApiOperation("更新用户") @ApiOperation("更新用户")
@ApiImplicitParam(name = "userEntity", value = "新增用户信息", dataType = "UserEntity")
@PutMapping("/update") @PutMapping("/update")
public AjaxResult update(@RequestBody UserEntity user) public AjaxResult update(UserEntity user)
{ {
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId())) if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{ {
return error("用户ID不能为空"); return AjaxResult.error("用户ID不能为空");
} }
if (users.isEmpty() || !users.containsKey(user.getUserId())) if (users.isEmpty() || !users.containsKey(user.getUserId()))
{ {
return error("用户不存在"); return AjaxResult.error("用户不存在");
} }
users.remove(user.getUserId()); users.remove(user.getUserId());
return AjaxResult.success(users.put(user.getUserId(), user)); return AjaxResult.success(users.put(user.getUserId(), user));
} }
@ApiOperation("删除用户信息") @ApiOperation("删除用户信息")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class) @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path")
@DeleteMapping("/{userId}") @DeleteMapping("/{userId}")
public AjaxResult delete(@PathVariable Integer userId) public AjaxResult delete(@PathVariable Integer userId)
{ {
if (!users.isEmpty() && users.containsKey(userId)) if (!users.isEmpty() && users.containsKey(userId))
{ {
users.remove(userId); users.remove(userId);
return success(); return AjaxResult.success();
} }
else else
{ {
return error("用户不存在"); return AjaxResult.error("用户不存在");
} }
} }
} }
@ApiModel(value = "UserEntity", description = "用户实体") @ApiModel("用户实体")
class UserEntity class UserEntity
{ {
@ApiModelProperty("用户ID") @ApiModelProperty("用户ID")

View File

@ -1,172 +0,0 @@
package com.ruoyi.web.controller.yada;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.system.domain_yada.*;
import com.ruoyi.system.service_yada.IAorestCoverageService;
import com.ruoyi.system.service_yada.IAustraliaMiddleEastService;
import com.ruoyi.system.service_yada.ThematicMapService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.crypto.Data;
import java.io.InputStream;
import java.security.Guard;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.List;
/**
* 森林覆盖率
*/
@RestController
@RequestMapping(value = "/business-service/api/Aorest", produces = "application/json;charset=UTF-8")
@Api(tags = "森林覆盖率")
public class AorestCoverageController {
@Resource
private IAorestCoverageService service;
@Resource
private ThematicMapService thematicMapService;
/**
* 查询方法
* 需要查询的字段参数
* @return 参数类
*/
@RequestMapping(value = "/selectAorestCoverage",method = {RequestMethod.GET})
@ApiOperation(value = "查询方法",httpMethod = "GET")
public AjaxResult selectAorestCoverage()
{
List<AorestCoverageVO> eastVOSList= service.selectAorestCoverage();
return AjaxResult.success(eastVOSList);
}
/**
* 删除方法
* @param ID id
* @return 状态码
*/
@RequestMapping(value = "/DelAorestCoverage",method = {RequestMethod.DELETE})
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@ApiOperation(value = "删除方法",httpMethod = "DELETE")
public AjaxResult DelAorestCoverage(@Param("ID") String ID)
{
int NUM = service.DelAorestCoverage(ID);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
/**
* 新增方法
* @param eastVOS 新增实体类
* @return 状态码
*/
@RequestMapping(value = "/IntoAorestCoverage",method = {RequestMethod.POST})
@ApiOperation(value = "新增方法",httpMethod = "POST")
public AjaxResult IntoAorestCoverage(@RequestBody AorestCoverageVO eastVOS)
{
try {
eastVOS.setCreateTime(LocalDateTime.now());
int NUM = service.IntoAorestCoverage(eastVOS);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
catch (Exception E){
E.getMessage();
return AjaxResult.error();
}
}
/**
* 上传文件
* @return 状态码
*/
@RequestMapping(value = "/IntoUpLoad",method = {RequestMethod.POST})
@ApiOperation(value = "上传文件",httpMethod = "POST")
public AjaxResult IntoUpload(@RequestBody MultipartFile file)
{
UploadFile upload=new UploadFile();
ThematicMapDomain domain=new ThematicMapDomain();
UploadFile value= null;
try {
value = uploadFile(file,upload);
} catch (Exception e) {
e.printStackTrace();
}
int NUM = service.IntoUpload(value);
domain.setPictureCode(value.getFileId());
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
/**
* 文件查询
* @param response
* @param request 客户端请求
* @return
*/
@RequestMapping(value = "/selectUpload",method = {RequestMethod.GET})
@ApiOperation(value = "文件查询",httpMethod = "GET")
public AjaxResult selectUpload(HttpServletResponse response, HttpServletRequest request,@RequestBody UploadFile upload)
{
List<UploadFile> eastVOSList= service.selectUpload(upload.getFileId(),upload.getFileName());
return AjaxResult.success(eastVOSList);
}
public UploadFile uploadFile(MultipartFile file,UploadFile upload) throws Exception
{
// 上传文件路径
String filePath = RuoYiConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
upload.setFileId(String.valueOf(System.currentTimeMillis()));
upload.setFileName(file.getOriginalFilename());
upload.setFilePath(fileName);
upload.setFileSize(String.valueOf(file.getSize()));
upload.setCreateTime(LocalDateTime.now());
return upload;
}
@RequestMapping(value = "/Dictionary")
@ApiOperation(value = "字典查询",httpMethod = "POST")
public AjaxResult Dictionary(@RequestBody Dictionary dic)
{
List<Dictionary> diclist=service.selectDic(dic.getCodingType(),dic.getCodingType1(), dic.getCodingType2());
return AjaxResult.success(diclist);
}
}

View File

@ -1,81 +0,0 @@
package com.ruoyi.web.controller.yada;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service_yada.IAustraliaMiddleEastService;
import com.ruoyi.system.domain_yada.AustraliaMiddleEastVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;
/**
* 澳大利亚中东部地区
*/
@RestController
@RequestMapping(value = "/business-service/api/Australia", produces = "application/json;charset=UTF-8")
@Api(tags = "澳大利亚中东部地区")
public class AustraliaMiddleEastController
{
@Resource
private IAustraliaMiddleEastService australiaMiddleEastService;
/**
* 查询方法
* @return 实体类
*/
@ApiOperation(value = "查询方法",httpMethod = "GET")
@RequestMapping(value = "/SelectAustralia",method = {RequestMethod.GET})
public AjaxResult SelectAustralia(@RequestBody AustraliaMiddleEastVO eastVO )
{
List<AustraliaMiddleEastVO> eastVOSList= australiaMiddleEastService.selectAustralia(eastVO.getYearMonth(),eastVO.getMonth());
return AjaxResult.success(eastVOSList);
}
/**
* 删除方法
* @param ID id
* @return 状态码
*/
@RequestMapping(value = "/DelAustralia",method = {RequestMethod.DELETE})
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@ApiOperation(value = "删除方法",httpMethod = "DELETE")
public AjaxResult DelAustralia(@Param("ID") String ID)
{
int NUM = australiaMiddleEastService.DelAustralia(ID);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
/**
* 新增方法
* @param eastVOS 新增实体类
* @return 状态码
*/
@RequestMapping(value = "/IntoAustralia",method = {RequestMethod.POST})
@ApiOperation(value = "新增方法",httpMethod = "POST")
public AjaxResult IntoAustralia(@RequestBody AustraliaMiddleEastVO eastVOS)
{
eastVOS.setCreateTime(LocalDateTime.now());
int NUM = australiaMiddleEastService.IntoAustralia(eastVOS);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
}

View File

@ -1,85 +0,0 @@
package com.ruoyi.web.controller.yada;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain_yada.AustraliaMiddleEastVO;
import com.ruoyi.system.domain_yada.GlobalTypeVO;
import com.ruoyi.system.service_yada.IAustraliaMiddleEastService;
import com.ruoyi.system.service_yada.IGlobalTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;
/**
*全球各类型占比
*/
@RestController
@RequestMapping("/monitor/clobal")
@Api(tags = "全球各类型占比")
public class GlobalTypeController {
@Resource
private IGlobalTypeService typeService;
/**
* 查询方法
* @param response 响应头
* @param request 客户端请求
* @return 参数类
*/
@RequestMapping(value = "/selectGlobalType",method = {RequestMethod.POST})
@ApiOperation(value = "查询方法",httpMethod = "POST")
public AjaxResult selectGlobalType(HttpServletResponse response, HttpServletRequest request,@RequestBody GlobalTypeVO TypeVO)
{
List<GlobalTypeVO> eastVOSList= typeService.selectGlobalType(TypeVO.getTypeName(),TypeVO.getParticularYear());
return AjaxResult.success(eastVOSList);
}
/**
* 删除方法
* @param ID id
* @return 状态码
*/
@RequestMapping(value = "/DelGlobalType",method = {RequestMethod.DELETE})
@ApiOperation(value = "删除方法",httpMethod = "DELETE")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
public AjaxResult DelGlobalType(@Param("ID") String ID)
{
int NUM = typeService.DelGlobalType(ID);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
/**
* 新增方法
* @param eastVOS 新增实体类
* @return 状态码
*/
@ApiOperation(value = "新增方法",httpMethod = "POST")
@RequestMapping(value = "/IntoGlobalType",method = {RequestMethod.POST})
public AjaxResult IntoGlobalType(@RequestBody GlobalTypeVO eastVOS)
{
eastVOS.setCreateTime(LocalDateTime.now());
int NUM = typeService.IntoGlobalType(eastVOS);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
}

View File

@ -1,83 +0,0 @@
package com.ruoyi.web.controller.yada;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain_yada.AustraliaMiddleEastVO;
import com.ruoyi.system.domain_yada.OceanTemperatureVO;
import com.ruoyi.system.service_yada.IAustraliaMiddleEastService;
import com.ruoyi.system.service_yada.IOceanTemperatureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;
/**
* 海洋表面温度监测
*/
@Api(tags = "海洋表面温度监测")
@RestController
@RequestMapping(value = "/business-service/api/Ocean", produces = "application/json;charset=UTF-8")
public class OceanTemperatureController {
@Resource
private IOceanTemperatureService temperatureService;
/**
* 查询方法
* @return 参数类
*/
@RequestMapping(value = "/selectOcean",method = {RequestMethod.GET})
@ApiOperation(value = "查询方法",httpMethod = "GET")
public AjaxResult selectOcean(@RequestBody OceanTemperatureVO temperatureVO)
{
List<OceanTemperatureVO> eastVOSList= temperatureService.selectOcean(temperatureVO.getStartDate());
return AjaxResult.success(eastVOSList);
}
/**
* 删除方法
* @param ID id
* @return 状态码
*/
@RequestMapping(value = "/DelOcean",method = {RequestMethod.DELETE})
@ApiOperation(value = "删除方法",httpMethod = "DELETE")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
public AjaxResult DelOcean(@Param("ID") String ID)
{
int NUM = temperatureService.DelOcean(ID);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
/**
* 新增方法
* @param eastVOS 新增实体类
* @return 状态码
*/
@ApiOperation(value = "新增方法",httpMethod = "POST")
@RequestMapping(value = "/IntoAustralia",method = {RequestMethod.POST})
public AjaxResult IntoOcean(@RequestBody OceanTemperatureVO eastVOS)
{
eastVOS.setCreateTime(LocalDateTime.now());
int NUM = temperatureService.IntoOcean(eastVOS);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
}

View File

@ -1,81 +0,0 @@
package com.ruoyi.web.controller.yada;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service_yada.IRegionVGIService;
import com.ruoyi.system.domain_yada.RegionVGIVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;
/**
* 各区域VGI
*/
@Api(tags = "各区域VGI")
@RestController
@RequestMapping(value = "/business-service/api/orderMng", produces = "application/json;charset=UTF-8")
public class RegionVGIController
{
@Resource
private IRegionVGIService regionVGIService;
/**
* 查询方法
* @return 参数类
*/
@RequestMapping(value = "/SelectRegion",method = {RequestMethod.GET})
@ApiOperation(value = "查询方法",httpMethod = "GET")
public AjaxResult SelectRegion()
{
List<RegionVGIVO> vgivost= regionVGIService.selectRegion();
return AjaxResult.success(vgivost);
}
/**
* 删除方法
* @param ID id
* @return 状态码
*/
@RequestMapping(value = "/DelRegion",method = {RequestMethod.DELETE})
@ApiOperation(value = "删除方法",httpMethod = "DELETE")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
public AjaxResult DelRegion(@Param("ID") String ID)
{
int NUM = regionVGIService.DelRegion(ID);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
/**
* 新增方法
* @param vgivo 新增实体类
* @return 状态码
*/
@ApiOperation(value = "新增方法",httpMethod = "POST")
@RequestMapping(value = "/IntoRegion",method = {RequestMethod.POST})
public AjaxResult IntoRegion(@RequestBody RegionVGIVO vgivo)
{
vgivo.setCreatedTime(LocalDateTime.now());
int NUM = regionVGIService.IntoRegion(vgivo);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
}

View File

@ -1,76 +0,0 @@
package com.ruoyi.web.controller.yada;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain_yada.AustraliaMiddleEastVO;
import com.ruoyi.system.domain_yada.RegionVGIVO;
import com.ruoyi.system.domain_yada.RegionalSystemVO;
import com.ruoyi.system.service_yada.IAustraliaMiddleEastService;
import com.ruoyi.system.service_yada.IRegionalSystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
/**
* 区域生态系统
*/
@Api(tags = "区域生态系统")
@RestController
@RequestMapping(value = "/business-service/api/Regional", produces = "application/json;charset=UTF-8")
public class RegionalSystemController {
@Resource
private IRegionalSystemService systemService;
/**
* 查询方法
* @return 参数类
*/
@RequestMapping(value = "/selectRegional",method = {RequestMethod.GET})
@ApiOperation(value = "查询方法",httpMethod = "GET")
public AjaxResult selectRegional(@RequestParam("region") String region)
{
List<RegionalSystemVO> eastVOSList= systemService.selectRegional(region);
return AjaxResult.success(eastVOSList);
}
/**
* 删除方法
* @param ID id
* @return 状态码
*/
@RequestMapping(value = "/DelRegional",method = {RequestMethod.DELETE})
@ApiOperation(value = "删除方法",httpMethod = "DELETE")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
public AjaxResult DelRegional(@RequestParam("ID") String ID)
{
int NUM = systemService.DelRegional(ID);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
/**
* 新增方法
* @param eastVOS 新增实体类
* @return 状态码
*/
@ApiOperation(value = "新增方法",httpMethod = "POST")
@RequestMapping(value = "/IntoRegional",method = {RequestMethod.POST})
public AjaxResult IntoRegional(@RequestBody RegionalSystemVO eastVOS)
{
eastVOS.setCreateTime(LocalDateTime.now());
int NUM = systemService.IntoRegional(eastVOS);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
}

View File

@ -1,330 +0,0 @@
package com.ruoyi.web.controller.yada;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.file.WeatherUtils;
import com.ruoyi.system.domain_yada.*;
import com.ruoyi.system.service_yada.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jdk.jfr.Frequency;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.spring.web.json.Json;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.net.http.HttpRequest;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value = "/Special")
@Api(tags = "模板导入")
public class SpecialController {
@Resource
private IRegionVGIService regionVGIService;
@Resource
private IAustraliaMiddleEastService australiaMiddleEastService;
@Resource
private IAorestCoverageService service;
@Resource
private IVegetationCoverageService coverageService;
@Resource
private IRegionalSystemService systemService;
/**
*/
@RequestMapping(value = "/helpSaveExcel")
private AjaxResult helpSaveExcel(@RequestBody MultipartFile file) {
List<RegionVGIVO> value = saveExcel(file);
return IntoRegion(value);
}
@RequestMapping(value = "/helpWeatherClass",method = {RequestMethod.GET})
public AjaxResult helpWeatherClass(String city,String type)
{
String url="https://restapi.amap.com/v3/weather/weatherInfo";
Map<String,String> map=new HashMap<>();
map.put("key","37087f0a3007dc67d37859553cd02d33");
map.put("city",city);
if (type!=null){ map.put("extensions",type);}
map.put("output","json");
String value= WeatherUtils.httpRequest(url,map);
WeatherUtilsVO vo = JSON.parseObject(value,WeatherUtilsVO.class);
// String value2=vo.getForecasts().substring(1,vo.getForecasts().length()-1);
// System.out.println(value2);
// vo.setForecast(JSON.parseObject(value2,ForecastVo.class));
// JSONObject userJson=JSONObject.parseObject(value);
// WeatherUtilsVO utilsValue= JSON.toJavaObject(userJson,WeatherUtilsVO.class);
return AjaxResult.success(vo);
} /**
* 森林覆盖率模板导入
*/
@RequestMapping(value = "/helpExcelAorest")
private AjaxResult helpExcelAorest(@RequestBody MultipartFile file) {
List<AorestCoverageVO> value = saveExcelAorest(file);
return IntoAorestCoverage(value);
}
/**
*平均植被覆盖度和净初级生产力
*/
@RequestMapping(value = "/helpExcelnpp")
private AjaxResult helpExcelnpp(@RequestBody MultipartFile file) {
List<VegetationCoverageVO> value = saveExcelnpp(file);
return IntoVegetation(value);
}
/**
* 澳大利亚中部地区模板导入
*/
@RequestMapping(value = "/helpExcelAus")
private AjaxResult helpExcelAus(@RequestBody MultipartFile file) {
List<AustraliaMiddleEastVO> value = saveExcelAus(file);
return IntoAustralia(value);
}
/**
* 区域生态系统类型转移
*/
@RequestMapping(value = "/helpExcelRegion")
private AjaxResult helpExcelRegion(@RequestBody MultipartFile file) {
List<RegionalSystemVO> value = saveExcelRegion(file);
return IntoRegional(value);
}
public AjaxResult IntoRegional(List<RegionalSystemVO> eastVOS)
{
try {
for (int i = 0; i < eastVOS.size(); i++) {
eastVOS.get(i).setCreateTime(LocalDateTime.now());
systemService.IntoRegional(eastVOS.get(i));
}
return AjaxResult.success();
}
catch (Exception E){
E.getMessage();
return AjaxResult.error(E.getMessage());
}
}
public AjaxResult IntoAustralia(List<AustraliaMiddleEastVO> eastVOS) {
for (int i = 0; i < eastVOS.size(); i++) {
eastVOS.get(i).setCreateTime(LocalDateTime.now());
australiaMiddleEastService.IntoAustralia(eastVOS.get(i));
}
return AjaxResult.success();
}
public AjaxResult IntoRegion(List<RegionVGIVO> vgivo) {
for (int i = 0; i < vgivo.size(); i++) {
vgivo.get(i).setCreatedTime(LocalDateTime.now());
regionVGIService.IntoRegion(vgivo.get(i));
}
return AjaxResult.success();
}
public AjaxResult IntoAorestCoverage(List<AorestCoverageVO> eastVOS)
{
try {
for (int i = 0; i < eastVOS.size(); i++) {
eastVOS.get(i).setCreateTime(LocalDateTime.now());
service.IntoAorestCoverage(eastVOS.get(i));
}
return AjaxResult.success();
}
catch (Exception E){
E.getMessage();
return AjaxResult.error(E.getMessage());
}
}
public AjaxResult IntoVegetation(List<VegetationCoverageVO> eastVOS)
{
try {
for (int i = 0; i < eastVOS.size(); i++) {
eastVOS.get(i).setCreateTime(LocalDateTime.now());
coverageService.IntoVegetation(eastVOS.get(i));
}
return AjaxResult.success();
}
catch (Exception E){
E.getMessage();
return AjaxResult.error(E.getMessage());
}
}
private List<RegionVGIVO> saveExcel(MultipartFile file) {
try {
List<RegionVGIVO> Value = new ArrayList<>();
InputStream inputStream = file.getInputStream();
Workbook book;
Sheet sheet;
book = new XSSFWorkbook(inputStream);
sheet = book.getSheetAt(0);
for (int i = 1; i < sheet.getLastRowNum() + 1; i++) {
RegionVGIVO value = new RegionVGIVO();
Row row = sheet.getRow(i);
value.setCreatedTime(LocalDateTime.now());
value.setRegion(row.getCell(0).toString());
value.setRegionEn(row.getCell(1).toString());
value.setForest(Double.parseDouble(row.getCell(2).toString()));
value.setGrassland(Double.parseDouble(row.getCell(3).toString()));
value.setParticularYear(row.getCell(4).toString());
Value.add(value);
}
return Value;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
private List<AustraliaMiddleEastVO> saveExcelAus(MultipartFile file) {
try {
List<AustraliaMiddleEastVO> Value = new ArrayList<>();
InputStream inputStream = file.getInputStream();
Workbook book;
Sheet sheet;
book = new XSSFWorkbook(inputStream);
sheet = book.getSheetAt(0);
for (int i = 1; i < sheet.getLastRowNum() + 1; i++) {
AustraliaMiddleEastVO value = new AustraliaMiddleEastVO();
Row row = sheet.getRow(i);
value.setYearMonth(row.getCell(0).toString());
value.setMonth(row.getCell(1).toString());
value.setSstAnomalyIndex(Double.parseDouble(row.getCell(2).toString()));
value.setTemperatureAnomolies(Double.parseDouble(row.getCell(3).toString()));
value.setPrecipitationAnomolies(Double.parseDouble(row.getCell(4).toString()));
value.setVaiAnomolies(Double.parseDouble(row.getCell(5).toString()));
Value.add(value);
}
return Value;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
private List<AorestCoverageVO> saveExcelAorest(MultipartFile file) {
try {
List<AorestCoverageVO> Value = new ArrayList<>();
InputStream inputStream = file.getInputStream();
Workbook book;
Sheet sheet;
book = new XSSFWorkbook(inputStream);
sheet = book.getSheetAt(0);
for (int i = 1; i < sheet.getLastRowNum() + 1; i++) {
AorestCoverageVO value = new AorestCoverageVO();
Row row = sheet.getRow(i);
value.setRegion(row.getCell(0).toString());
value.setRegionEn(row.getCell(1).toString());
value.setProtectedLands(Double.parseDouble(row.getCell(2).toString()));
value.setNonProtectedLands(Double.parseDouble(row.getCell(3).toString()));
value.setMountain(Double.parseDouble(row.getCell(4).toString()));
value.setNonMountain(Double.parseDouble(row.getCell(5).toString()));
value.setCreateTime(LocalDateTime.now());
Value.add(value);
}
return Value;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
private List<VegetationCoverageVO> saveExcelnpp(MultipartFile file) {
try {
List<VegetationCoverageVO> Value = new ArrayList<>();
InputStream inputStream = file.getInputStream();
Workbook book;
Sheet sheet;
book = new XSSFWorkbook(inputStream);
sheet = book.getSheetAt(0);
for (int i = 1; i < sheet.getLastRowNum() + 1; i++) {
VegetationCoverageVO value = new VegetationCoverageVO();
Row row = sheet.getRow(i);
value.setRegion(row.getCell(0).toString());
value.setRegionEn(row.getCell(1).toString());
value.setProtectedLands(Double.parseDouble(row.getCell(4).toString()));
value.setNonProtectedLands(Double.parseDouble(row.getCell(5).toString()));
value.setMountain(Double.parseDouble(row.getCell(2).toString()));
value.setNonMountain(Double.parseDouble(row.getCell(3).toString()));
value.setCreateTime(LocalDateTime.now());
Value.add(value);
}
return Value;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
private List<RegionalSystemVO> saveExcelRegion(MultipartFile file) {
try {
List<RegionalSystemVO> Value = new ArrayList<>();
InputStream inputStream = file.getInputStream();
Workbook book;
Sheet sheet;
book = new XSSFWorkbook(inputStream);
sheet = book.getSheetAt(0);
for (int i = 1; i < sheet.getLastRowNum() + 1; i++) {
RegionalSystemVO value = new RegionalSystemVO();
Row row = sheet.getRow(i);
value.setRegion(row.getCell(0).toString());
value.setRegionEn(row.getCell(1).toString());
value.setTypeConversion(row.getCell(2).toString());
value.setTypeconversionEn(row.getCell(3).toString());
value.setProportionOfChangedAreas(Double.parseDouble(row.getCell(4).toString()));
value.setCreateTime(LocalDateTime.now());
Value.add(value);
}
return Value;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
}

View File

@ -1,92 +0,0 @@
package com.ruoyi.web.controller.yada;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.system.domain_yada.ThematicMapDomain;
import com.ruoyi.system.service_yada.ThematicMapService;
import io.swagger.annotations.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;
/**
* 专题图模块
* @author taco chen
*/
@RestController
@RequestMapping(value = "/thematic-map")
@Api(tags = "专题图模块")
public class ThematicMapController {
@Resource
private ThematicMapService thematicMapService;
/**
* 查询方法
* @param response 响应头
* @return 参数类
*/
@ApiOperation("获取所有专题图")
@ApiImplicitParams({})
@ApiResponses({
@ApiResponse(code =200,message = "请求成功"),
@ApiResponse(code =401,message = "没有认证"),
@ApiResponse(code =403,message = "权限不足"),
@ApiResponse(code =404,message = "未找到")
})
@RequestMapping(value = "/get/all",method = {RequestMethod.POST})
public AjaxResult selectAllThematicMap(HttpServletResponse response,@RequestBody ThematicMapDomain thematicMapDomain)
{
List<ThematicMapDomain> res= thematicMapService.selectAll(thematicMapDomain.getPictureType(),
thematicMapDomain.getPictureTypeOne(),thematicMapDomain.getPictureTypeTwo());
return AjaxResult.success(res);
}
/**
* 删除方法
* @param id id
* @return 状态码
*/
@RequestMapping(value = "/delete",method = {RequestMethod.DELETE})
@ApiOperation(value = "删除方法",httpMethod = "DELETE")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "long", paramType = "path", dataTypeClass = long.class)
public AjaxResult deleteThematicMap(@Param("id") Long id)
{
int num = thematicMapService.deleteById(id);
if (num>0) {
return AjaxResult.success();
}
return AjaxResult.error();
}
/**
* 新增方法
* @param thematicMapDomain 新增实体类
* @return 状态码
*/
@ApiOperation(value = "新增方法",httpMethod = "POST")
@RequestMapping(value = "/add",method = {RequestMethod.POST})
public AjaxResult saveThematicMap(@RequestBody ThematicMapDomain thematicMapDomain)
{
thematicMapDomain.setCreatedTime(LocalDateTime.now());
int num = thematicMapService.save(thematicMapDomain);
if (num>0) {
return AjaxResult.success();
}
return AjaxResult.error();
}
}

View File

@ -1,84 +0,0 @@
package com.ruoyi.web.controller.yada;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain_yada.AustraliaMiddleEastVO;
import com.ruoyi.system.domain_yada.UrbanVO;
import com.ruoyi.system.service_yada.IAustraliaMiddleEastService;
import com.ruoyi.system.service_yada.IUrbanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;
/**
* 中国城市监测
*/
@Api(tags = "中国城市监测")
@RestController
@RequestMapping(value = "/business-service/api/Urban", produces = "application/json;charset=UTF-8")
public class UrbanController {
@Resource
private IUrbanService urbanService;
/**
* 查询方法
* @param response 响应头
* @param request 客户端请求
* @return 参数类
*/
@RequestMapping(value = "/selectUrban",method = {RequestMethod.GET})
@ApiOperation(value = "查询方法",httpMethod = "GET")
public AjaxResult selectUrban(HttpServletResponse response, HttpServletRequest request,@RequestBody UrbanVO urbanVO)
{
List<UrbanVO> eastVOSList= urbanService.selectUrban(urbanVO.getName(),urbanVO.getParticularYear());
return AjaxResult.success(eastVOSList);
}
/**
* 删除方法
* @param ID id
* @return 状态码
*/
@RequestMapping(value = "/DelUrban",method = {RequestMethod.DELETE})
@ApiOperation(value = "删除方法",httpMethod = "DELETE")
public AjaxResult DelUrban(@Param("ID") String ID)
{
int NUM = urbanService.DelUrban(ID);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
/**
* 新增方法
* @param eastVOS 新增实体类
* @return 状态码
*/
@ApiOperation(value = "新增方法",httpMethod = "POST")
@RequestMapping(value = "/IntoUrban",method = {RequestMethod.POST})
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "long", paramType = "path", dataTypeClass = long.class)
public AjaxResult IntoUrban(@RequestBody UrbanVO eastVOS)
{
eastVOS.setCreateTime(LocalDateTime.now());
int NUM = urbanService.IntoUrban(eastVOS);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
}

View File

@ -1,82 +0,0 @@
package com.ruoyi.web.controller.yada;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain_yada.AustraliaMiddleEastVO;
import com.ruoyi.system.domain_yada.VegetationCoverageVO;
import com.ruoyi.system.service_yada.IAustraliaMiddleEastService;
import com.ruoyi.system.service_yada.IVegetationCoverageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;
/**
* 平均植被覆盖度和净初级生产力
*/
@Api(tags = "平均植被覆盖度和净初级生产力")
@RestController
@RequestMapping(value = "/business-service/api/Vegetation", produces = "application/json;charset=UTF-8")
public class VegetationCoverageController {
@Resource
private IVegetationCoverageService coverageService;
/**
* 查询方法
* @return 参数类
*/
@RequestMapping(value = "/selectVegetation",method = {RequestMethod.GET})
@ApiOperation(value = "查询方法",httpMethod = "GET")
public AjaxResult selectVegetation()
{
List<VegetationCoverageVO> eastVOSList= coverageService.selectVegetation();
return AjaxResult.success(eastVOSList);
}
/**
* 删除方法
* @param ID id
* @return 状态码
*/
@RequestMapping(value = "/DelVegetation",method = {RequestMethod.DELETE})
@ApiOperation(value = "删除方法",httpMethod = "DELETE")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "long", paramType = "path", dataTypeClass = long.class)
public AjaxResult DelVegetation(@Param("ID") String ID)
{
int NUM = coverageService.DelVegetation(ID);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
/**
* 新增方法
* @param eastVOS 新增实体类
* @return 状态码
*/
@ApiOperation(value = "新增方法",httpMethod = "POST")
@RequestMapping(value = "/IntoVegetation",method = {RequestMethod.POST})
public AjaxResult IntoVegetation(@RequestBody VegetationCoverageVO eastVOS)
{
eastVOS.setCreateTime(LocalDateTime.now());
int NUM = coverageService.IntoVegetation(eastVOS);
if (NUM>0)
{
return AjaxResult.success();
}
return AjaxResult.error();
}
}

View File

@ -8,7 +8,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.config.RuoYiConfig;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.builders.RequestHandlerSelectors;
@ -17,10 +16,10 @@ import springfox.documentation.service.ApiKey;
import springfox.documentation.service.AuthorizationScope; import springfox.documentation.service.AuthorizationScope;
import springfox.documentation.service.Contact; import springfox.documentation.service.Contact;
import springfox.documentation.service.SecurityReference; import springfox.documentation.service.SecurityReference;
import springfox.documentation.service.SecurityScheme;
import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext; import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/** /**
* Swagger2的接口配置 * Swagger2的接口配置
@ -28,6 +27,7 @@ import springfox.documentation.spring.web.plugins.Docket;
* @author ruoyi * @author ruoyi
*/ */
@Configuration @Configuration
@EnableSwagger2
public class SwaggerConfig public class SwaggerConfig
{ {
/** 系统基础配置 */ /** 系统基础配置 */
@ -48,7 +48,7 @@ public class SwaggerConfig
@Bean @Bean
public Docket createRestApi() public Docket createRestApi()
{ {
return new Docket(DocumentationType.OAS_30) return new Docket(DocumentationType.SWAGGER_2)
// 是否启用Swagger // 是否启用Swagger
.enable(enabled) .enable(enabled)
// 用来创建该API的基本信息展示在文档的页面中自定义展示的信息 // 用来创建该API的基本信息展示在文档的页面中自定义展示的信息
@ -71,10 +71,10 @@ public class SwaggerConfig
/** /**
* 安全模式这里指定token通过Authorization头请求头传递 * 安全模式这里指定token通过Authorization头请求头传递
*/ */
private List<SecurityScheme> securitySchemes() private List<ApiKey> securitySchemes()
{ {
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>(); List<ApiKey> apiKeyList = new ArrayList<ApiKey>();
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue())); apiKeyList.add(new ApiKey("Authorization", "Authorization", "header"));
return apiKeyList; return apiKeyList;
} }
@ -87,7 +87,7 @@ public class SwaggerConfig
securityContexts.add( securityContexts.add(
SecurityContext.builder() SecurityContext.builder()
.securityReferences(defaultAuth()) .securityReferences(defaultAuth())
.operationSelector(o -> o.requestMappingPattern().matches("/.*")) .forPaths(PathSelectors.regex("^(?!auth).*$"))
.build()); .build());
return securityContexts; return securityContexts;
} }

View File

@ -1 +0,0 @@
com.ruoyi.framework.web.service.CaptchaRedisService

View File

@ -2,17 +2,13 @@
spring: spring:
datasource: datasource:
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
# driverClassName: com.mysql.cj.jdbc.Driver driverClassName: com.mysql.cj.jdbc.Driver
driver-class-name: org.postgresql.Driver
druid: druid:
# 主库数据源
master: master:
#url: jdbc:postgresql://47.243.79.66:5432/yada?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
#url: jdbc:postgresql://192.168.2.9:5432/yada?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&serverTimezone=Asia/Shanghai username: root
# username: postgres password: password
# password: postgres
url: jdbc:postgresql://118.195.242.28:5432/yada?AllowPublicKeyRetrieval=True&useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai
username: gty
password: 308525
# 从库数据源 # 从库数据源
slave: slave:
# 从数据源开关/默认关闭 # 从数据源开关/默认关闭
@ -34,9 +30,8 @@ spring:
minEvictableIdleTimeMillis: 300000 minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒 # 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000 maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效select * from pg_stat_activity # 配置检测连接是否有效
# validationQuery: SELECT 1 FROM DUAL validationQuery: SELECT 1 FROM DUAL
validationQuery: SELECT version()
testWhileIdle: true testWhileIdle: true
testOnBorrow: false testOnBorrow: false
testOnReturn: false testOnReturn: false
@ -48,8 +43,8 @@ spring:
allow: allow:
url-pattern: /druid/* url-pattern: /druid/*
# 控制台管理用户名和密码 # 控制台管理用户名和密码
login-username: ruoyi login-username:
login-password: 123456 login-password:
filter: filter:
stat: stat:
enabled: true enabled: true

View File

@ -3,13 +3,13 @@ ruoyi:
# 名称 # 名称
name: RuoYi name: RuoYi
# 版本 # 版本
version: 3.4.0 version: 3.1.0
# 版权年份 # 版权年份
copyrightYear: 2021 copyrightYear: 2019
# 实例演示开关 # 实例演示开关
demoEnabled: true demoEnabled: true
# 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath # 文件路径 示例( Windows配置D:/ruoyi/uploadPathLinux配置 /home/ruoyi/uploadPath
profile: /home/gty/ruoyi/uploadPath profile: D:/ruoyi/uploadPath
# 获取ip地址开关 # 获取ip地址开关
addressEnabled: false addressEnabled: false
# 验证码类型 math 数组计算 char 字符验证 # 验证码类型 math 数组计算 char 字符验证
@ -19,7 +19,6 @@ ruoyi:
server: server:
# 服务器的HTTP端口默认为8080 # 服务器的HTTP端口默认为8080
port: 8080 port: 8080
#port: 6061
servlet: servlet:
# 应用的访问路径 # 应用的访问路径
context-path: / context-path: /
@ -63,10 +62,8 @@ spring:
host: localhost host: localhost
# 端口默认为6379 # 端口默认为6379
port: 6379 port: 6379
# 数据库索引
database: 0
# 密码 # 密码
password: '*&jkjusWETO(^ses%i' password:
# 连接超时时间 # 连接超时时间
timeout: 10s timeout: 10s
lettuce: lettuce:
@ -87,7 +84,7 @@ token:
# 令牌密钥 # 令牌密钥
secret: abcdefghijklmnopqrstuvwxyz secret: abcdefghijklmnopqrstuvwxyz
# 令牌有效期默认30分钟 # 令牌有效期默认30分钟
expireTime: 300 expireTime: 30
# MyBatis配置 # MyBatis配置
mybatis: mybatis:
@ -112,21 +109,6 @@ swagger:
# 请求前缀 # 请求前缀
pathMapping: /dev-api pathMapping: /dev-api
# 滑块验证码
aj:
captcha:
cache-type: redis
# blockPuzzle 滑块 clickWord 文字点选 default默认两者都实例化
type: blockPuzzle
# 右下角显示字
water-mark: ruoyi.vip
# 校验滑动拼图允许误差偏移量(默认5像素)
slip-offset: 5
# aes加密坐标开启或者禁用(true|false)
aes-status: true
# 滑动干扰项(0/1/2)
interference-options: 2
# 防止XSS攻击 # 防止XSS攻击
xss: xss:
# 过滤开关 # 过滤开关
@ -135,4 +117,3 @@ xss:
excludes: /system/notice/* excludes: /system/notice/*
# 匹配链接 # 匹配链接
urlPatterns: /system/*,/monitor/*,/tool/* urlPatterns: /system/*,/monitor/*,/tool/*

View File

@ -1,6 +1,24 @@
_ Application Version: ${ruoyi.version}
( ) Spring Boot Version: ${spring-boot.version}
| |/') _ __ ___ ////////////////////////////////////////////////////////////////////
(`\/')| , < ( '__)/',__) // _ooOoo_ //
> < | |\`\ | | \__, \ // o8888888o //
(_/\_)(_) (_)(_) (____/ // 88" . "88 //
// (| ^_^ |) //
// O\ = /O //
// ____/`---'\____ //
// .' \\| |// `. //
// / \\||| : |||// \ //
// / _||||| -:- |||||- \ //
// | | \\\ - /// | | //
// | \_| ''\---/'' | | //
// \ .-\__ `-` ___/-. / //
// ___`. .' /--.--\ `. . ___ //
// ."" '< `.___\_<|>_/___.' >'"". //
// | | : `- \`.;`\ _ /`;.`/ - ` : | | //
// \ \ `-. \_ __\ /__ _/ .-` / / //
// ========`-.____`-.___\_____/___.-`____.-'======== //
// `=---=' //
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ //
// 佛祖保佑 永不宕机 永无BUG //
////////////////////////////////////////////////////////////////////

View File

@ -19,7 +19,6 @@ user.password.not.valid=* 5-50个字符
user.email.not.valid=邮箱格式错误 user.email.not.valid=邮箱格式错误
user.mobile.phone.number.not.valid=手机号格式错误 user.mobile.phone.number.not.valid=手机号格式错误
user.login.success=登录成功 user.login.success=登录成功
user.register.success=注册成功
user.notfound=请重新登录 user.notfound=请重新登录
user.forcelogout=管理员强制退出,请重新登录 user.forcelogout=管理员强制退出,请重新登录
user.unknown.error=未知错误,请重新登录 user.unknown.error=未知错误,请重新登录

View File

@ -3,18 +3,13 @@
PUBLIC "-//mybatis.org//DTD Config 3.0//EN" PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd"> "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration> <configuration>
<!-- 全局参数 -->
<settings> <settings>
<!-- 使全局的映射器启用或禁用缓存 --> <setting name="cacheEnabled" value="true" /> <!-- 全局映射器启用缓存 -->
<setting name="cacheEnabled" value="true" /> <setting name="useGeneratedKeys" value="true" /> <!-- 允许 JDBC 支持自动生成主键 -->
<!-- 允许JDBC 支持自动生成主键 --> <setting name="defaultExecutorType" value="REUSE" /> <!-- 配置默认的执行器 -->
<setting name="useGeneratedKeys" value="true" /> <setting name="logImpl" value="SLF4J" /> <!-- 指定 MyBatis 所用日志的具体实现 -->
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 --> <!-- <setting name="mapUnderscoreToCamelCase" value="true"/> 驼峰式命名 -->
<setting name="defaultExecutorType" value="SIMPLE" />
<!-- 指定 MyBatis 所用日志的具体实现 -->
<setting name="logImpl" value="SLF4J" />
<!-- 使用驼峰命名法转换字段 -->
<!-- <setting name="mapUnderscoreToCamelCase" value="true"/> -->
</settings> </settings>
</configuration> </configuration>

View File

@ -5,7 +5,7 @@
<parent> <parent>
<artifactId>ruoyi</artifactId> <artifactId>ruoyi</artifactId>
<groupId>com.ruoyi</groupId> <groupId>com.ruoyi</groupId>
<version>3.8.2</version> <version>3.1.0</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
@ -43,8 +43,8 @@
<!-- 自定义验证注解 --> <!-- 自定义验证注解 -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>javax.validation</groupId>
<artifactId>spring-boot-starter-validation</artifactId> <artifactId>validation-api</artifactId>
</dependency> </dependency>
<!--常用工具类 --> <!--常用工具类 -->
@ -89,18 +89,12 @@
<artifactId>snakeyaml</artifactId> <artifactId>snakeyaml</artifactId>
</dependency> </dependency>
<!-- Token生成与解析--> <!--Token生成与解析-->
<dependency> <dependency>
<groupId>io.jsonwebtoken</groupId> <groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId> <artifactId>jjwt</artifactId>
</dependency> </dependency>
<!-- Jaxb -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<!-- redis 缓存操作 --> <!-- redis 缓存操作 -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>

View File

@ -4,10 +4,6 @@ import java.lang.annotation.ElementType;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import java.math.BigDecimal;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.IndexedColors;
import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
/** /**
* 自定义导出Excel数据注解 * 自定义导出Excel数据注解
@ -34,7 +30,7 @@ public @interface Excel
public String dateFormat() default ""; public String dateFormat() default "";
/** /**
* 如果是字典类型请设置字典的type值 (: sys_user_sex) * 如果是字典类型请设置字典的type值
*/ */
public String dictType() default ""; public String dictType() default "";
@ -49,14 +45,9 @@ public @interface Excel
public String separator() default ","; public String separator() default ",";
/** /**
* BigDecimal 精度 默认:-1(默认不开启BigDecimal格式化) * 导出类型0数字 1字符串
*/ */
public int scale() default -1; public ColumnType cellType() default ColumnType.STRING;
/**
* BigDecimal 舍入规则 默认:BigDecimal.ROUND_HALF_EVEN
*/
public int roundingMode() default BigDecimal.ROUND_HALF_EVEN;
/** /**
* 导出时在excel中每个列的高度 单位为字符 * 导出时在excel中每个列的高度 单位为字符
@ -98,52 +89,6 @@ public @interface Excel
*/ */
public String targetAttr() default ""; public String targetAttr() default "";
/**
* 是否自动统计数据,在最后追加一行统计数据总和
*/
public boolean isStatistics() default false;
/**
* 导出类型0数字 1字符串
*/
public ColumnType cellType() default ColumnType.STRING;
/**
* 导出字体颜色
*/
public IndexedColors color() default IndexedColors.BLACK;
/**
* 导出字段对齐方式
*/
public HorizontalAlignment align() default HorizontalAlignment.CENTER;
/**
* 自定义数据处理器
*/
public Class<?> handler() default ExcelHandlerAdapter.class;
/**
* 自定义数据处理器参数
*/
public String[] args() default {};
public enum Align
{
AUTO(0), LEFT(1), CENTER(2), RIGHT(3);
private final int value;
Align(int value)
{
this.value = value;
}
public int value()
{
return this.value;
}
}
/** /**
* 字段类型0导出导入1仅导出2仅导入 * 字段类型0导出导入1仅导出2仅导入
*/ */
@ -167,7 +112,7 @@ public @interface Excel
public enum ColumnType public enum ColumnType
{ {
NUMERIC(0), STRING(1), IMAGE(2); NUMERIC(0), STRING(1);
private final int value; private final int value;
ColumnType(int value) ColumnType(int value)

View File

@ -14,5 +14,5 @@ import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface Excels public @interface Excels
{ {
public Excel[] value(); Excel[] value();
} }

View File

@ -38,9 +38,4 @@ public @interface Log
* 是否保存请求的参数 * 是否保存请求的参数
*/ */
public boolean isSaveRequestData() default true; public boolean isSaveRequestData() default true;
/**
* 是否保存响应的参数
*/
public boolean isSaveResponseData() default true;
} }

View File

@ -1,40 +0,0 @@
package com.ruoyi.common.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.enums.LimitType;
/**
* 限流注解
*
* @author ruoyi
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RateLimiter
{
/**
* 限流key
*/
public String key() default Constants.RATE_LIMIT_KEY;
/**
* 限流时间,单位秒
*/
public int time() default 60;
/**
* 限流次数
*/
public int count() default 100;
/**
* 限流类型
*/
public LimitType limitType() default LimitType.DEFAULT;
}

View File

@ -19,13 +19,5 @@ import java.lang.annotation.Target;
@Documented @Documented
public @interface RepeatSubmit public @interface RepeatSubmit
{ {
/**
* 间隔时间(ms)小于此时间视为重复提交
*/
public int interval() default 5000;
/**
* 提示消息
*/
public String message() default "不允许重复提交,请稍候再试";
} }

View File

@ -30,9 +30,6 @@ public class RuoYiConfig
/** 获取地址开关 */ /** 获取地址开关 */
private static boolean addressEnabled; private static boolean addressEnabled;
/** 验证码类型 */
private static String captchaType;
public String getName() public String getName()
{ {
return name; return name;
@ -93,22 +90,6 @@ public class RuoYiConfig
RuoYiConfig.addressEnabled = addressEnabled; RuoYiConfig.addressEnabled = addressEnabled;
} }
public static String getCaptchaType() {
return captchaType;
}
public void setCaptchaType(String captchaType) {
RuoYiConfig.captchaType = captchaType;
}
/**
* 获取导入上传路径
*/
public static String getImportPath()
{
return getProfile() + "/import";
}
/** /**
* 获取头像上传路径 * 获取头像上传路径
*/ */

View File

@ -1,7 +1,5 @@
package com.ruoyi.common.constant; package com.ruoyi.common.constant;
import io.jsonwebtoken.Claims;
/** /**
* 通用常量信息 * 通用常量信息
* *
@ -49,11 +47,6 @@ public class Constants
*/ */
public static final String LOGOUT = "Logout"; public static final String LOGOUT = "Logout";
/**
* 注册
*/
public static final String REGISTER = "Register";
/** /**
* 登录失败 * 登录失败
*/ */
@ -74,11 +67,6 @@ public class Constants
*/ */
public static final String REPEAT_SUBMIT_KEY = "repeat_submit:"; public static final String REPEAT_SUBMIT_KEY = "repeat_submit:";
/**
* 限流 redis key
*/
public static final String RATE_LIMIT_KEY = "rate_limit:";
/** /**
* 验证码有效期分钟 * 验证码有效期分钟
*/ */
@ -107,7 +95,7 @@ public class Constants
/** /**
* 用户名称 * 用户名称
*/ */
public static final String JWT_USERNAME = Claims.SUBJECT; public static final String JWT_USERNAME = "sub";
/** /**
* 用户头像 * 用户头像
@ -138,30 +126,4 @@ public class Constants
* 资源映射路径 前缀 * 资源映射路径 前缀
*/ */
public static final String RESOURCE_PREFIX = "/profile"; public static final String RESOURCE_PREFIX = "/profile";
/**
* RMI 远程方法调用
*/
public static final String LOOKUP_RMI = "rmi:";
/**
* LDAP 远程方法调用
*/
public static final String LOOKUP_LDAP = "ldap:";
/**
* LDAPS 远程方法调用
*/
public static final String LOOKUP_LDAPS = "ldaps:";
/**
* 定时任务白名单配置仅允许访问的包名如其他需要可以自行添加
*/
public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" };
/**
* 定时任务违规的字符
*/
public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
"org.springframework", "org.apache", "com.ruoyi.common.utils.file" };
} }

View File

@ -13,9 +13,6 @@ public class GenConstants
/** 树表(增删改查) */ /** 树表(增删改查) */
public static final String TPL_TREE = "tree"; public static final String TPL_TREE = "tree";
/** 主子表(增删改查) */
public static final String TPL_SUB = "sub";
/** 树编码字段 */ /** 树编码字段 */
public static final String TREE_CODE = "treeCode"; public static final String TREE_CODE = "treeCode";
@ -32,17 +29,15 @@ public class GenConstants
public static final String PARENT_MENU_NAME = "parentMenuName"; public static final String PARENT_MENU_NAME = "parentMenuName";
/** 数据库字符串类型 */ /** 数据库字符串类型 */
public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" }; public static final String[] COLUMNTYPE_STR = { "char", "varchar", "narchar", "varchar2", "tinytext", "text",
"mediumtext", "longtext" };
/** 数据库文本类型 */
public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
/** 数据库时间类型 */ /** 数据库时间类型 */
public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" }; public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
/** 数据库数字类型 */ /** 数据库数字类型 */
public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer", public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
"bit", "bigint", "float", "double", "decimal" }; "bigint", "float", "float", "double", "decimal" };
/** 页面不需要编辑字段 */ /** 页面不需要编辑字段 */
public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" }; public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
@ -79,15 +74,6 @@ public class GenConstants
/** 日期控件 */ /** 日期控件 */
public static final String HTML_DATETIME = "datetime"; public static final String HTML_DATETIME = "datetime";
/** 图片上传控件 */
public static final String HTML_IMAGE_UPLOAD = "imageUpload";
/** 文件上传控件 */
public static final String HTML_FILE_UPLOAD = "fileUpload";
/** 富文本控件 */
public static final String HTML_EDITOR = "editor";
/** 字符串类型 */ /** 字符串类型 */
public static final String TYPE_STRING = "String"; public static final String TYPE_STRING = "String";
@ -109,9 +95,6 @@ public class GenConstants
/** 模糊查询 */ /** 模糊查询 */
public static final String QUERY_LIKE = "LIKE"; public static final String QUERY_LIKE = "LIKE";
/** 相等查询 */
public static final String QUERY_EQ = "EQ";
/** 需要 */ /** 需要 */
public static final String REQUIRE = "1"; public static final String REQUIRE = "1";
} }

View File

@ -54,25 +54,7 @@ public class UserConstants
/** Layout组件标识 */ /** Layout组件标识 */
public final static String LAYOUT = "Layout"; public final static String LAYOUT = "Layout";
/** ParentView组件标识 */
public final static String PARENT_VIEW = "ParentView";
/** InnerLink组件标识 */
public final static String INNER_LINK = "InnerLink";
/** 校验返回结果码 */ /** 校验返回结果码 */
public final static String UNIQUE = "0"; public final static String UNIQUE = "0";
public final static String NOT_UNIQUE = "1"; public final static String NOT_UNIQUE = "1";
/**
* 用户名长度限制
*/
public static final int USERNAME_MIN_LENGTH = 2;
public static final int USERNAME_MAX_LENGTH = 20;
/**
* 密码长度限制
*/
public static final int PASSWORD_MIN_LENGTH = 5;
public static final int PASSWORD_MAX_LENGTH = 20;
} }

View File

@ -11,13 +11,10 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.page.PageDomain; import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.page.TableSupport; import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.sql.SqlUtil; import com.ruoyi.common.utils.sql.SqlUtil;
@ -28,7 +25,7 @@ import com.ruoyi.common.utils.sql.SqlUtil;
*/ */
public class BaseController public class BaseController
{ {
protected final Logger logger = LoggerFactory.getLogger(this.getClass()); protected final Logger logger = LoggerFactory.getLogger(BaseController.class);
/** /**
* 将前台传递过来的日期格式的字符串自动转化为Date类型 * 将前台传递过来的日期格式的字符串自动转化为Date类型
@ -51,31 +48,17 @@ public class BaseController
* 设置请求分页数据 * 设置请求分页数据
*/ */
protected void startPage() protected void startPage()
{
PageUtils.startPage();
}
/**
* 设置请求排序数据
*/
protected void startOrderBy()
{ {
PageDomain pageDomain = TableSupport.buildPageRequest(); PageDomain pageDomain = TableSupport.buildPageRequest();
if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize))
{ {
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy()); String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
PageHelper.orderBy(orderBy); PageHelper.startPage(pageNum, pageSize, orderBy);
} }
} }
/**
* 清理分页的线程变量
*/
protected void clearPage()
{
PageUtils.clearPage();
}
/** /**
* 响应请求分页数据 * 响应请求分页数据
*/ */
@ -90,38 +73,6 @@ public class BaseController
return rspData; return rspData;
} }
/**
* 返回成功
*/
public AjaxResult success()
{
return AjaxResult.success();
}
/**
* 返回失败消息
*/
public AjaxResult error()
{
return AjaxResult.error();
}
/**
* 返回成功消息
*/
public AjaxResult success(String message)
{
return AjaxResult.success(message);
}
/**
* 返回失败消息
*/
public AjaxResult error(String message)
{
return AjaxResult.error(message);
}
/** /**
* 响应返回结果 * 响应返回结果
* *
@ -133,17 +84,6 @@ public class BaseController
return rows > 0 ? AjaxResult.success() : AjaxResult.error(); return rows > 0 ? AjaxResult.success() : AjaxResult.error();
} }
/**
* 响应返回结果
*
* @param result 结果
* @return 操作结果
*/
protected AjaxResult toAjax(boolean result)
{
return result ? success() : error();
}
/** /**
* 页面跳转 * 页面跳转
*/ */
@ -151,36 +91,4 @@ public class BaseController
{ {
return StringUtils.format("redirect:{}", url); return StringUtils.format("redirect:{}", url);
} }
/**
* 获取用户缓存信息
*/
public LoginUser getLoginUser()
{
return SecurityUtils.getLoginUser();
}
/**
* 获取登录用户id
*/
public Long getUserId()
{
return getLoginUser().getUserId();
}
/**
* 获取登录部门id
*/
public Long getDeptId()
{
return getLoginUser().getDeptId();
}
/**
* 获取登录用户名
*/
public String getUsername()
{
return getLoginUser().getUsername();
}
} }

View File

@ -145,18 +145,4 @@ public class AjaxResult extends HashMap<String, Object>
{ {
return new AjaxResult(code, msg, null); return new AjaxResult(code, msg, null);
} }
/**
* 方便链式调用
*
* @param key
* @param value
* @return 数据对象
*/
@Override
public AjaxResult put(String key, Object value)
{
super.put(key, value);
return this;
}
} }

View File

@ -5,6 +5,7 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
/** /**
* Entity基类 * Entity基类
@ -35,6 +36,14 @@ public class BaseEntity implements Serializable
/** 备注 */ /** 备注 */
private String remark; private String remark;
/** 开始时间 */
@JsonIgnore
private String beginTime;
/** 结束时间 */
@JsonIgnore
private String endTime;
/** 请求参数 */ /** 请求参数 */
private Map<String, Object> params; private Map<String, Object> params;
@ -98,6 +107,26 @@ public class BaseEntity implements Serializable
this.remark = remark; this.remark = remark;
} }
public String getBeginTime()
{
return beginTime;
}
public void setBeginTime(String beginTime)
{
this.beginTime = beginTime;
}
public String getEndTime()
{
return endTime;
}
public void setEndTime(String endTime)
{
this.endTime = endTime;
}
public Map<String, Object> getParams() public Map<String, Object> getParams()
{ {
if (params == null) if (params == null)

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.validation.constraints.Email; import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
@ -32,7 +31,7 @@ public class SysDept extends BaseEntity
private String deptName; private String deptName;
/** 显示顺序 */ /** 显示顺序 */
private Integer orderNum; private String orderNum;
/** 负责人 */ /** 负责人 */
private String leader; private String leader;
@ -97,13 +96,13 @@ public class SysDept extends BaseEntity
this.deptName = deptName; this.deptName = deptName;
} }
@NotNull(message = "显示顺序不能为空") @NotBlank(message = "显示顺序不能为空")
public Integer getOrderNum() public String getOrderNum()
{ {
return orderNum; return orderNum;
} }
public void setOrderNum(Integer orderNum) public void setOrderNum(String orderNum)
{ {
this.orderNum = orderNum; this.orderNum = orderNum;
} }

View File

@ -1,7 +1,6 @@
package com.ruoyi.common.core.domain.entity; package com.ruoyi.common.core.domain.entity;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
@ -58,7 +57,6 @@ public class SysDictType extends BaseEntity
@NotBlank(message = "字典类型不能为空") @NotBlank(message = "字典类型不能为空")
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符") @Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
@Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)")
public String getDictType() public String getDictType()
{ {
return dictType; return dictType;

View File

@ -3,7 +3,6 @@ package com.ruoyi.common.core.domain.entity;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
@ -31,7 +30,7 @@ public class SysMenu extends BaseEntity
private Long parentId; private Long parentId;
/** 显示顺序 */ /** 显示顺序 */
private Integer orderNum; private String orderNum;
/** 路由地址 */ /** 路由地址 */
private String path; private String path;
@ -39,15 +38,9 @@ public class SysMenu extends BaseEntity
/** 组件路径 */ /** 组件路径 */
private String component; private String component;
/** 路由参数 */
private String query;
/** 是否为外链0是 1否 */ /** 是否为外链0是 1否 */
private String isFrame; private String isFrame;
/** 是否缓存0缓存 1不缓存 */
private String isCache;
/** 类型M目录 C菜单 F按钮 */ /** 类型M目录 C菜单 F按钮 */
private String menuType; private String menuType;
@ -108,13 +101,13 @@ public class SysMenu extends BaseEntity
this.parentId = parentId; this.parentId = parentId;
} }
@NotNull(message = "显示顺序不能为空") @NotBlank(message = "显示顺序不能为空")
public Integer getOrderNum() public String getOrderNum()
{ {
return orderNum; return orderNum;
} }
public void setOrderNum(Integer orderNum) public void setOrderNum(String orderNum)
{ {
this.orderNum = orderNum; this.orderNum = orderNum;
} }
@ -141,16 +134,6 @@ public class SysMenu extends BaseEntity
this.component = component; this.component = component;
} }
public String getQuery()
{
return query;
}
public void setQuery(String query)
{
this.query = query;
}
public String getIsFrame() public String getIsFrame()
{ {
return isFrame; return isFrame;
@ -161,16 +144,6 @@ public class SysMenu extends BaseEntity
this.isFrame = isFrame; this.isFrame = isFrame;
} }
public String getIsCache()
{
return isCache;
}
public void setIsCache(String isCache)
{
this.isCache = isCache;
}
@NotBlank(message = "菜单类型不能为空") @NotBlank(message = "菜单类型不能为空")
public String getMenuType() public String getMenuType()
{ {
@ -243,7 +216,6 @@ public class SysMenu extends BaseEntity
.append("path", getPath()) .append("path", getPath())
.append("component", getComponent()) .append("component", getComponent())
.append("isFrame", getIsFrame()) .append("isFrame", getIsFrame())
.append("IsCache", getIsCache())
.append("menuType", getMenuType()) .append("menuType", getMenuType())
.append("visible", getVisible()) .append("visible", getVisible())
.append("status ", getStatus()) .append("status ", getStatus())

View File

@ -33,16 +33,10 @@ public class SysRole extends BaseEntity
@Excel(name = "角色排序") @Excel(name = "角色排序")
private String roleSort; private String roleSort;
/** 数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限5仅本人数据权限 */ /** 数据范围1所有数据权限2自定义数据权限3本部门数据权限4本部门及以下数据权限 */
@Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限")
private String dataScope; private String dataScope;
/** 菜单树选择项是否关联显示( 0父子不互相关联显示 1父子互相关联显示 */
private boolean menuCheckStrictly;
/** 部门树选择项是否关联显示0父子不互相关联显示 1父子互相关联显示 */
private boolean deptCheckStrictly;
/** 角色状态0正常 1停用 */ /** 角色状态0正常 1停用 */
@Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用")
private String status; private String status;
@ -134,26 +128,6 @@ public class SysRole extends BaseEntity
this.dataScope = dataScope; this.dataScope = dataScope;
} }
public boolean isMenuCheckStrictly()
{
return menuCheckStrictly;
}
public void setMenuCheckStrictly(boolean menuCheckStrictly)
{
this.menuCheckStrictly = menuCheckStrictly;
}
public boolean isDeptCheckStrictly()
{
return deptCheckStrictly;
}
public void setDeptCheckStrictly(boolean deptCheckStrictly)
{
this.deptCheckStrictly = deptCheckStrictly;
}
public String getStatus() public String getStatus()
{ {
return status; return status;
@ -212,8 +186,6 @@ public class SysRole extends BaseEntity
.append("roleKey", getRoleKey()) .append("roleKey", getRoleKey())
.append("roleSort", getRoleSort()) .append("roleSort", getRoleSort())
.append("dataScope", getDataScope()) .append("dataScope", getDataScope())
.append("menuCheckStrictly", isMenuCheckStrictly())
.append("deptCheckStrictly", isDeptCheckStrictly())
.append("status", getStatus()) .append("status", getStatus())
.append("delFlag", getDelFlag()) .append("delFlag", getDelFlag())
.append("createBy", getCreateBy()) .append("createBy", getCreateBy())

View File

@ -2,7 +2,9 @@ package com.ruoyi.common.core.domain.entity;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import javax.validation.constraints.*; import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
@ -12,7 +14,6 @@ import com.ruoyi.common.annotation.Excel.ColumnType;
import com.ruoyi.common.annotation.Excel.Type; import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.annotation.Excels; import com.ruoyi.common.annotation.Excels;
import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.xss.Xss;
/** /**
* 用户对象 sys_user * 用户对象 sys_user
@ -67,12 +68,12 @@ public class SysUser extends BaseEntity
/** 删除标志0代表存在 2代表删除 */ /** 删除标志0代表存在 2代表删除 */
private String delFlag; private String delFlag;
/** 最后登IP */ /** 最后登IP */
@Excel(name = "最后登IP", type = Type.EXPORT) @Excel(name = "最后登IP", type = Type.EXPORT)
private String loginIp; private String loginIp;
/** 最后登时间 */ /** 最后登时间 */
@Excel(name = "最后登时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT) @Excel(name = "最后登时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
private Date loginDate; private Date loginDate;
/** 部门对象 */ /** 部门对象 */
@ -91,9 +92,6 @@ public class SysUser extends BaseEntity
/** 岗位组 */ /** 岗位组 */
private Long[] postIds; private Long[] postIds;
/** 角色ID */
private Long roleId;
public SysUser() public SysUser()
{ {
@ -134,7 +132,6 @@ public class SysUser extends BaseEntity
this.deptId = deptId; this.deptId = deptId;
} }
@Xss(message = "用户昵称不能包含脚本字符")
@Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符") @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
public String getNickName() public String getNickName()
{ {
@ -146,7 +143,6 @@ public class SysUser extends BaseEntity
this.nickName = nickName; this.nickName = nickName;
} }
@Xss(message = "用户账号不能包含脚本字符")
@NotBlank(message = "用户账号不能为空") @NotBlank(message = "用户账号不能为空")
@Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符") @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
public String getUserName() public String getUserName()
@ -304,16 +300,6 @@ public class SysUser extends BaseEntity
this.postIds = postIds; this.postIds = postIds;
} }
public Long getRoleId()
{
return roleId;
}
public void setRoleId(Long roleId)
{
this.roleId = roleId;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

View File

@ -25,7 +25,7 @@ public class LoginBody
/** /**
* 唯一标识 * 唯一标识
*/ */
private String uuid; private String uuid = "";
public String getUsername() public String getUsername()
{ {

View File

@ -4,7 +4,7 @@ import java.util.Collection;
import java.util.Set; import java.util.Set;
import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetails;
import com.alibaba.fastjson.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.core.domain.entity.SysUser;
/** /**
@ -16,23 +16,13 @@ public class LoginUser implements UserDetails
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
* 用户ID
*/
private Long userId;
/**
* 部门ID
*/
private Long deptId;
/** /**
* 用户唯一标识 * 用户唯一标识
*/ */
private String token; private String token;
/** /**
* 时间 * 登陆时间
*/ */
private Long loginTime; private Long loginTime;
@ -71,26 +61,6 @@ public class LoginUser implements UserDetails
*/ */
private SysUser user; private SysUser user;
public Long getUserId()
{
return userId;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getDeptId()
{
return deptId;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public String getToken() public String getToken()
{ {
return token; return token;
@ -111,15 +81,7 @@ public class LoginUser implements UserDetails
this.permissions = permissions; this.permissions = permissions;
} }
public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions) @JsonIgnore
{
this.userId = userId;
this.deptId = deptId;
this.user = user;
this.permissions = permissions;
}
@JSONField(serialize = false)
@Override @Override
public String getPassword() public String getPassword()
{ {
@ -135,7 +97,7 @@ public class LoginUser implements UserDetails
/** /**
* 账户是否未过期,过期无法验证 * 账户是否未过期,过期无法验证
*/ */
@JSONField(serialize = false) @JsonIgnore
@Override @Override
public boolean isAccountNonExpired() public boolean isAccountNonExpired()
{ {
@ -147,7 +109,7 @@ public class LoginUser implements UserDetails
* *
* @return * @return
*/ */
@JSONField(serialize = false) @JsonIgnore
@Override @Override
public boolean isAccountNonLocked() public boolean isAccountNonLocked()
{ {
@ -159,7 +121,7 @@ public class LoginUser implements UserDetails
* *
* @return * @return
*/ */
@JSONField(serialize = false) @JsonIgnore
@Override @Override
public boolean isCredentialsNonExpired() public boolean isCredentialsNonExpired()
{ {
@ -171,7 +133,7 @@ public class LoginUser implements UserDetails
* *
* @return * @return
*/ */
@JSONField(serialize = false) @JsonIgnore
@Override @Override
public boolean isEnabled() public boolean isEnabled()
{ {

View File

@ -1,11 +0,0 @@
package com.ruoyi.common.core.domain.model;
/**
* 用户注册对象
*
* @author ruoyi
*/
public class RegisterBody extends LoginBody
{
}

View File

@ -18,11 +18,8 @@ public class PageDomain
/** 排序列 */ /** 排序列 */
private String orderByColumn; private String orderByColumn;
/** 排序的方向desc或者asc */ /** 排序的方向 "desc" 或者 "asc". */
private String isAsc = "asc"; private String isAsc;
/** 分页参数合理化 */
private Boolean reasonable = true;
public String getOrderBy() public String getOrderBy()
{ {
@ -70,32 +67,6 @@ public class PageDomain
public void setIsAsc(String isAsc) public void setIsAsc(String isAsc)
{ {
if (StringUtils.isNotEmpty(isAsc))
{
// 兼容前端排序类型
if ("ascending".equals(isAsc))
{
isAsc = "asc";
}
else if ("descending".equals(isAsc))
{
isAsc = "desc";
}
this.isAsc = isAsc; this.isAsc = isAsc;
} }
}
public Boolean getReasonable()
{
if (StringUtils.isNull(reasonable))
{
return Boolean.TRUE;
}
return reasonable;
}
public void setReasonable(Boolean reasonable)
{
this.reasonable = reasonable;
}
} }

View File

@ -1,6 +1,5 @@
package com.ruoyi.common.core.page; package com.ruoyi.common.core.page;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.ServletUtils;
/** /**
@ -30,22 +29,16 @@ public class TableSupport
*/ */
public static final String IS_ASC = "isAsc"; public static final String IS_ASC = "isAsc";
/**
* 分页参数合理化
*/
public static final String REASONABLE = "reasonable";
/** /**
* 封装分页对象 * 封装分页对象
*/ */
public static PageDomain getPageDomain() public static PageDomain getPageDomain()
{ {
PageDomain pageDomain = new PageDomain(); PageDomain pageDomain = new PageDomain();
pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1)); pageDomain.setPageNum(ServletUtils.getParameterToInt(PAGE_NUM));
pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10)); pageDomain.setPageSize(ServletUtils.getParameterToInt(PAGE_SIZE));
pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN)); pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN));
pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC)); pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC));
pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE));
return pageDomain; return pageDomain;
} }

View File

@ -1,13 +1,11 @@
package com.ruoyi.common.core.redis; package com.ruoyi.common.core.redis;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundSetOperations;
import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;
@ -138,15 +136,10 @@ public class RedisCache
* @param dataSet 缓存的数据 * @param dataSet 缓存的数据
* @return 缓存数据的对象 * @return 缓存数据的对象
*/ */
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) public <T> long setCacheSet(final String key, final Set<T> dataSet)
{ {
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key); Long count = redisTemplate.opsForSet().add(key, dataSet);
Iterator<T> it = dataSet.iterator(); return count == null ? 0 : count;
while (it.hasNext())
{
setOperation.add(it.next());
}
return setOperation;
} }
/** /**
@ -209,18 +202,6 @@ public class RedisCache
return opsForHash.get(key, hKey); return opsForHash.get(key, hKey);
} }
/**
* 删除Hash中的数据
*
* @param key
* @param hKey
*/
public void delCacheMapValue(final String key, final String hKey)
{
HashOperations hashOperations = redisTemplate.opsForHash();
hashOperations.delete(key, hKey);
}
/** /**
* 获取多个Hash中的数据 * 获取多个Hash中的数据
* *

View File

@ -66,7 +66,7 @@ public class CharsetKit
if (null == destCharset) if (null == destCharset)
{ {
destCharset = StandardCharsets.UTF_8; srcCharset = StandardCharsets.UTF_8;
} }
if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))

View File

@ -7,7 +7,6 @@ import java.nio.charset.Charset;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.Set; import java.util.Set;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import org.apache.commons.lang3.ArrayUtils;
/** /**
* 类型转换器 * 类型转换器
@ -796,14 +795,9 @@ public class Convert
{ {
return (String) obj; return (String) obj;
} }
else if (obj instanceof byte[]) else if (obj instanceof byte[] || obj instanceof Byte[])
{ {
return str((byte[]) obj, charset); return str((Byte[]) obj, charset);
}
else if (obj instanceof Byte[])
{
byte[] bytes = ArrayUtils.toPrimitive((Byte[]) obj);
return str(bytes, charset);
} }
else if (obj instanceof ByteBuffer) else if (obj instanceof ByteBuffer)
{ {

View File

@ -1,20 +0,0 @@
package com.ruoyi.common.enums;
/**
* 限流类型
*
* @author ruoyi
*/
public enum LimitType
{
/**
* 默认策略全局限流
*/
DEFAULT,
/**
* 根据请求者IP进行限流
*/
IP
}

View File

@ -1,4 +1,4 @@
package com.ruoyi.common.exception.base; package com.ruoyi.common.exception;
import com.ruoyi.common.utils.MessageUtils; import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;

View File

@ -0,0 +1,43 @@
package com.ruoyi.common.exception;
/**
* 自定义异常
*
* @author ruoyi
*/
public class CustomException extends RuntimeException
{
private static final long serialVersionUID = 1L;
private Integer code;
private String message;
public CustomException(String message)
{
this.message = message;
}
public CustomException(String message, Integer code)
{
this.message = message;
this.code = code;
}
public CustomException(String message, Throwable e)
{
super(message, e);
this.message = message;
}
@Override
public String getMessage()
{
return message;
}
public Integer getCode()
{
return code;
}
}

View File

@ -1,58 +0,0 @@
package com.ruoyi.common.exception;
/**
* 全局异常
*
* @author ruoyi
*/
public class GlobalException extends RuntimeException
{
private static final long serialVersionUID = 1L;
/**
* 错误提示
*/
private String message;
/**
* 错误明细内部调试错误
*
* {@link CommonResult#getDetailMessage()} 一致的设计
*/
private String detailMessage;
/**
* 空构造方法避免反序列化问题
*/
public GlobalException()
{
}
public GlobalException(String message)
{
this.message = message;
}
public String getDetailMessage()
{
return detailMessage;
}
public GlobalException setDetailMessage(String detailMessage)
{
this.detailMessage = detailMessage;
return this;
}
public String getMessage()
{
return message;
}
public GlobalException setMessage(String message)
{
this.message = message;
return this;
}
}

View File

@ -1,73 +0,0 @@
package com.ruoyi.common.exception;
/**
* 业务异常
*
* @author ruoyi
*/
public final class ServiceException extends RuntimeException
{
private static final long serialVersionUID = 1L;
/**
* 错误码
*/
private Integer code;
/**
* 错误提示
*/
private String message;
/**
* 错误明细内部调试错误
*
* {@link CommonResult#getDetailMessage()} 一致的设计
*/
private String detailMessage;
/**
* 空构造方法避免反序列化问题
*/
public ServiceException()
{
}
public ServiceException(String message)
{
this.message = message;
}
public ServiceException(String message, Integer code)
{
this.message = message;
this.code = code;
}
public String getDetailMessage()
{
return detailMessage;
}
public String getMessage()
{
return message;
}
public Integer getCode()
{
return code;
}
public ServiceException setMessage(String message)
{
this.message = message;
return this;
}
public ServiceException setDetailMessage(String detailMessage)
{
this.detailMessage = detailMessage;
return this;
}
}

View File

@ -1,6 +1,6 @@
package com.ruoyi.common.exception.file; package com.ruoyi.common.exception.file;
import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.common.exception.BaseException;
/** /**
* 文件信息异常类 * 文件信息异常类

View File

@ -68,14 +68,4 @@ public class InvalidExtensionException extends FileUploadException
super(allowedExtension, extension, filename); super(allowedExtension, extension, filename);
} }
} }
public static class InvalidVideoExtensionException extends InvalidExtensionException
{
private static final long serialVersionUID = 1L;
public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename)
{
super(allowedExtension, extension, filename);
}
}
} }

View File

@ -1,6 +1,6 @@
package com.ruoyi.common.exception.user; package com.ruoyi.common.exception.user;
import com.ruoyi.common.exception.base.BaseException; import com.ruoyi.common.exception.BaseException;
/** /**
* 用户信息异常类 * 用户信息异常类

View File

@ -29,8 +29,8 @@ public class RepeatableFilter implements Filter
throws IOException, ServletException throws IOException, ServletException
{ {
ServletRequest requestWrapper = null; ServletRequest requestWrapper = null;
if (request instanceof HttpServletRequest if (request instanceof HttpServletRequest && StringUtils.equalsAnyIgnoreCase(request.getContentType(),
&& StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE))
{ {
requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response); requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
} }

View File

@ -38,21 +38,18 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper
@Override @Override
public ServletInputStream getInputStream() throws IOException public ServletInputStream getInputStream() throws IOException
{ {
final ByteArrayInputStream bais = new ByteArrayInputStream(body); final ByteArrayInputStream bais = new ByteArrayInputStream(body);
return new ServletInputStream() return new ServletInputStream()
{ {
@Override @Override
public int read() throws IOException public int read() throws IOException
{ {
return bais.read(); return bais.read();
} }
@Override
public int available() throws IOException
{
return body.length;
}
@Override @Override
public boolean isFinished() public boolean isFinished()
{ {

View File

@ -3,6 +3,8 @@ package com.ruoyi.common.filter;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.servlet.Filter; import javax.servlet.Filter;
import javax.servlet.FilterChain; import javax.servlet.FilterChain;
import javax.servlet.FilterConfig; import javax.servlet.FilterConfig;
@ -25,10 +27,16 @@ public class XssFilter implements Filter
*/ */
public List<String> excludes = new ArrayList<>(); public List<String> excludes = new ArrayList<>();
/**
* xss过滤开关
*/
public boolean enabled = false;
@Override @Override
public void init(FilterConfig filterConfig) throws ServletException public void init(FilterConfig filterConfig) throws ServletException
{ {
String tempExcludes = filterConfig.getInitParameter("excludes"); String tempExcludes = filterConfig.getInitParameter("excludes");
String tempEnabled = filterConfig.getInitParameter("enabled");
if (StringUtils.isNotEmpty(tempExcludes)) if (StringUtils.isNotEmpty(tempExcludes))
{ {
String[] url = tempExcludes.split(","); String[] url = tempExcludes.split(",");
@ -37,6 +45,10 @@ public class XssFilter implements Filter
excludes.add(url[i]); excludes.add(url[i]);
} }
} }
if (StringUtils.isNotEmpty(tempEnabled))
{
enabled = Boolean.valueOf(tempEnabled);
}
} }
@Override @Override
@ -56,14 +68,25 @@ public class XssFilter implements Filter
private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response)
{ {
String url = request.getServletPath(); if (!enabled)
String method = request.getMethod();
// GET DELETE 不过滤
if (method == null || method.matches("GET") || method.matches("DELETE"))
{ {
return true; return true;
} }
return StringUtils.matches(url, excludes); if (excludes == null || excludes.isEmpty())
{
return false;
}
String url = request.getServletPath();
for (String pattern : excludes)
{
Pattern p = Pattern.compile("^" + pattern);
Matcher m = p.matcher(url);
if (m.find())
{
return true;
}
}
return false;
} }
@Override @Override

View File

@ -63,8 +63,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
// xss过滤 // xss过滤
json = EscapeUtil.clean(json).trim(); json = EscapeUtil.clean(json).trim();
byte[] jsonBytes = json.getBytes("utf-8"); final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8"));
final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes);
return new ServletInputStream() return new ServletInputStream()
{ {
@Override @Override
@ -79,12 +78,6 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
return true; return true;
} }
@Override
public int available() throws IOException
{
return jsonBytes.length;
}
@Override @Override
public void setReadListener(ReadListener readListener) public void setReadListener(ReadListener readListener)
{ {
@ -106,6 +99,7 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
public boolean isJsonRequest() public boolean isJsonRequest()
{ {
String header = super.getHeader(HttpHeaders.CONTENT_TYPE); String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE); return MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(header)
|| MediaType.APPLICATION_JSON_UTF8_VALUE.equalsIgnoreCase(header);
} }
} }

View File

@ -108,7 +108,7 @@ public class Arith
"The scale must be a positive integer or zero"); "The scale must be a positive integer or zero");
} }
BigDecimal b = new BigDecimal(Double.toString(v)); BigDecimal b = new BigDecimal(Double.toString(v));
BigDecimal one = BigDecimal.ONE; BigDecimal one = new BigDecimal("1");
return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue(); return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue();
} }
} }

View File

@ -3,11 +3,6 @@ package com.ruoyi.common.utils;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date; import java.util.Date;
import org.apache.commons.lang3.time.DateFormatUtils; import org.apache.commons.lang3.time.DateFormatUtils;
@ -136,14 +131,6 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
return new Date(time); return new Date(time);
} }
/**
* 计算相差天数
*/
public static int differentDaysByMillisecond(Date date1, Date date2)
{
return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
}
/** /**
* 计算两个时间差 * 计算两个时间差
*/ */
@ -165,23 +152,4 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
// long sec = diff % nd % nh % nm / ns; // long sec = diff % nd % nh % nm / ns;
return day + "" + hour + "小时" + min + "分钟"; return day + "" + hour + "小时" + min + "分钟";
} }
/**
* 增加 LocalDateTime ==> Date
*/
public static Date toDate(LocalDateTime temporalAccessor)
{
ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
return Date.from(zdt.toInstant());
}
/**
* 增加 LocalDate ==> Date
*/
public static Date toDate(LocalDate temporalAccessor)
{
LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
return Date.from(zdt.toInstant());
}
} }

View File

@ -41,7 +41,8 @@ public class DictUtils
Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key)); Object cacheObj = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
if (StringUtils.isNotNull(cacheObj)) if (StringUtils.isNotNull(cacheObj))
{ {
return StringUtils.cast(cacheObj); List<SysDictData> dictDatas = StringUtils.cast(cacheObj);
return dictDatas;
} }
return null; return null;
} }
@ -91,7 +92,7 @@ public class DictUtils
{ {
if (value.equals(dict.getDictValue())) if (value.equals(dict.getDictValue()))
{ {
propertyString.append(dict.getDictLabel()).append(separator); propertyString.append(dict.getDictLabel() + separator);
break; break;
} }
} }
@ -131,7 +132,7 @@ public class DictUtils
{ {
if (label.equals(dict.getDictLabel())) if (label.equals(dict.getDictLabel()))
{ {
propertyString.append(dict.getDictValue()).append(separator); propertyString.append(dict.getDictValue() + separator);
break; break;
} }
} }
@ -150,16 +151,6 @@ public class DictUtils
return StringUtils.stripEnd(propertyString.toString(), separator); return StringUtils.stripEnd(propertyString.toString(), separator);
} }
/**
* 删除指定字典缓存
*
* @param key 字典键
*/
public static void removeDictCache(String key)
{
SpringUtils.getBean(RedisCache.class).deleteObject(getCacheKey(key));
}
/** /**
* 清空字典缓存 * 清空字典缓存
*/ */

View File

@ -18,10 +18,11 @@ public class ExceptionUtil
{ {
StringWriter sw = new StringWriter(); StringWriter sw = new StringWriter();
e.printStackTrace(new PrintWriter(sw, true)); e.printStackTrace(new PrintWriter(sw, true));
return sw.toString(); String str = sw.toString();
return str;
} }
public static String getRootErrorMessage(Exception e) public static String getRootErrorMseeage(Exception e)
{ {
Throwable root = ExceptionUtils.getRootCause(e); Throwable root = ExceptionUtils.getRootCause(e);
root = (root == null ? e : root); root = (root == null ? e : root);

View File

@ -1,36 +0,0 @@
package com.ruoyi.common.utils;
import com.github.pagehelper.PageHelper;
import com.ruoyi.common.core.page.PageDomain;
import com.ruoyi.common.core.page.TableSupport;
import com.ruoyi.common.utils.sql.SqlUtil;
/**
* 分页工具类
*
* @author ruoyi
*/
public class PageUtils extends PageHelper
{
/**
* 设置请求分页数据
*/
public static void
startPage()
{
PageDomain pageDomain = TableSupport.buildPageRequest();
Integer pageNum = pageDomain.getPageNum();
Integer pageSize = pageDomain.getPageSize();
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
Boolean reasonable = pageDomain.getReasonable();
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
}
/**
* 清理分页的线程变量
*/
public static void clearPage()
{
PageHelper.clearPage();
}
}

View File

@ -5,7 +5,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import com.ruoyi.common.constant.HttpStatus; import com.ruoyi.common.constant.HttpStatus;
import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.CustomException;
/** /**
* 安全服务工具类 * 安全服务工具类
@ -14,36 +14,6 @@ import com.ruoyi.common.exception.ServiceException;
*/ */
public class SecurityUtils public class SecurityUtils
{ {
/**
* 用户ID
**/
public static Long getUserId()
{
try
{
return getLoginUser().getUserId();
}
catch (Exception e)
{
throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED);
}
}
/**
* 获取部门ID
**/
public static Long getDeptId()
{
try
{
return getLoginUser().getDeptId();
}
catch (Exception e)
{
throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED);
}
}
/** /**
* 获取用户账户 * 获取用户账户
**/ **/
@ -55,7 +25,7 @@ public class SecurityUtils
} }
catch (Exception e) catch (Exception e)
{ {
throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED); throw new CustomException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
} }
} }
@ -70,7 +40,7 @@ public class SecurityUtils
} }
catch (Exception e) catch (Exception e)
{ {
throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED); throw new CustomException("获取用户信息异常", HttpStatus.UNAUTHORIZED);
} }
} }

View File

@ -48,22 +48,6 @@ public class ServletUtils
return Convert.toInt(getRequest().getParameter(name), defaultValue); return Convert.toInt(getRequest().getParameter(name), defaultValue);
} }
/**
* 获取Boolean参数
*/
public static Boolean getParameterToBool(String name)
{
return Convert.toBool(getRequest().getParameter(name));
}
/**
* 获取Boolean参数
*/
public static Boolean getParameterToBool(String name, Boolean defaultValue)
{
return Convert.toBool(getRequest().getParameter(name), defaultValue);
}
/** /**
* 获取request * 获取request
*/ */
@ -99,8 +83,9 @@ public class ServletUtils
* *
* @param response 渲染对象 * @param response 渲染对象
* @param string 待渲染的字符串 * @param string 待渲染的字符串
* @return null
*/ */
public static void renderString(HttpServletResponse response, String string) public static String renderString(HttpServletResponse response, String string)
{ {
try try
{ {
@ -113,6 +98,7 @@ public class ServletUtils
{ {
e.printStackTrace(); e.printStackTrace();
} }
return null;
} }
/** /**
@ -123,13 +109,13 @@ public class ServletUtils
public static boolean isAjaxRequest(HttpServletRequest request) public static boolean isAjaxRequest(HttpServletRequest request)
{ {
String accept = request.getHeader("accept"); String accept = request.getHeader("accept");
if (accept != null && accept.contains("application/json")) if (accept != null && accept.indexOf("application/json") != -1)
{ {
return true; return true;
} }
String xRequestedWith = request.getHeader("X-Requested-With"); String xRequestedWith = request.getHeader("X-Requested-With");
if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest")) if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1)
{ {
return true; return true;
} }
@ -141,6 +127,10 @@ public class ServletUtils
} }
String ajax = request.getParameter("__ajax"); String ajax = request.getParameter("__ajax");
return StringUtils.inStringIgnoreCase(ajax, "json", "xml"); if (StringUtils.inStringIgnoreCase(ajax, "json", "xml"))
{
return true;
}
return false;
} }
} }

View File

@ -6,8 +6,6 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.springframework.util.AntPathMatcher;
import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.text.StrFormatter; import com.ruoyi.common.core.text.StrFormatter;
/** /**
@ -262,17 +260,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
return StrFormatter.format(template, params); return StrFormatter.format(template, params);
} }
/**
* 是否为http(s)://开头
*
* @param link 链接
* @return 结果
*/
public static boolean ishttp(String link)
{
return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS);
}
/** /**
* 字符串转set * 字符串转set
* *
@ -325,30 +312,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
} }
/** /**
* 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写 * 下划线转驼峰命名
*
* @param cs 指定字符串
* @param searchCharSequences 需要检查的字符串数组
* @return 是否包含任意一个字符串
*/
public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences)
{
if (isEmpty(cs) || isEmpty(searchCharSequences))
{
return false;
}
for (CharSequence testStr : searchCharSequences)
{
if (containsIgnoreCase(cs, testStr))
{
return true;
}
}
return false;
}
/**
* 驼峰转下划线命名
*/ */
public static String toUnderScoreCase(String str) public static String toUnderScoreCase(String str)
{ {
@ -487,97 +451,9 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
return sb.toString(); return sb.toString();
} }
/**
* 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
*
* @param str 指定字符串
* @param strs 需要检查的字符串数组
* @return 是否匹配
*/
public static boolean matches(String str, List<String> strs)
{
if (isEmpty(str) || isEmpty(strs))
{
return false;
}
for (String pattern : strs)
{
if (isMatch(pattern, str))
{
return true;
}
}
return false;
}
/**
* 判断url是否与规则配置:
* ? 表示单个字符;
* * 表示一层路径内的任意字符串不可跨层级;
* ** 表示任意层路径;
*
* @param pattern 匹配规则
* @param url 需要匹配的url
* @return
*/
public static boolean isMatch(String pattern, String url)
{
AntPathMatcher matcher = new AntPathMatcher();
return matcher.match(pattern, url);
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <T> T cast(Object obj) public static <T> T cast(Object obj)
{ {
return (T) obj; return (T) obj;
} }
/**
* 数字左边补齐0使之达到指定长度注意如果数字转换为字符串后长度大于size则只保留 最后size个字符
*
* @param num 数字对象
* @param size 字符串指定长度
* @return 返回数字的字符串格式该字符串为指定长度
*/
public static final String padl(final Number num, final int size)
{
return padl(num.toString(), size, '0');
}
/**
* 字符串左补齐如果原始字符串s长度大于size则只保留最后size个字符
*
* @param s 原始字符串
* @param size 字符串指定长度
* @param c 用于补齐的字符
* @return 返回指定长度的字符串由原字符串左补齐或截取得到
*/
public static final String padl(final String s, final int size, final char c)
{
final StringBuilder sb = new StringBuilder(size);
if (s != null)
{
final int len = s.length();
if (s.length() <= size)
{
for (int i = size - len; i > 0; i--)
{
sb.append(c);
}
sb.append(s);
}
else
{
return s.substring(len - size, len);
}
}
else
{
for (int i = size; i > 0; i--)
{
sb.append(c);
}
}
return sb.toString();
}
} }

Some files were not shown because too many files have changed in this diff Show More