Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
cocktail-party-server
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
cocktail-party
cocktail-party-server
Commits
03cf98d3
提交
03cf98d3
authored
8月 16, 2021
作者:
RuoYi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化异常信息
上级
6f51f729
隐藏空白字符变更
内嵌
并排
正在显示
18 个修改的文件
包含
180 行增加
和
93 行删除
+180
-93
GlobalException.java
...main/java/com/ruoyi/common/exception/GlobalException.java
+59
-0
ServiceException.java
...ain/java/com/ruoyi/common/exception/ServiceException.java
+40
-9
BaseException.java
...n/java/com/ruoyi/common/exception/base/BaseException.java
+1
-1
FileException.java
...n/java/com/ruoyi/common/exception/file/FileException.java
+1
-1
UserException.java
...n/java/com/ruoyi/common/exception/user/UserException.java
+1
-1
SecurityUtils.java
...n/src/main/java/com/ruoyi/common/utils/SecurityUtils.java
+5
-5
ExcelUtil.java
...n/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
+2
-2
SqlUtil.java
...mon/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java
+2
-2
GlobalExceptionHandler.java
...ruoyi/framework/web/exception/GlobalExceptionHandler.java
+39
-42
SysLoginService.java
...java/com/ruoyi/framework/web/service/SysLoginService.java
+2
-2
UserDetailsServiceImpl.java
...m/ruoyi/framework/web/service/UserDetailsServiceImpl.java
+4
-4
GenTableServiceImpl.java
...java/com/ruoyi/generator/service/GenTableServiceImpl.java
+9
-9
SysConfigServiceImpl.java
...a/com/ruoyi/system/service/impl/SysConfigServiceImpl.java
+2
-2
SysDeptServiceImpl.java
...ava/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
+2
-2
SysDictTypeServiceImpl.java
...com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java
+2
-2
SysPostServiceImpl.java
...ava/com/ruoyi/system/service/impl/SysPostServiceImpl.java
+2
-2
SysRoleServiceImpl.java
...ava/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
+3
-3
SysUserServiceImpl.java
...ava/com/ruoyi/system/service/impl/SysUserServiceImpl.java
+4
-4
没有找到文件。
ruoyi-common/src/main/java/com/ruoyi/common/exception/GlobalException.java
0 → 100644
浏览文件 @
03cf98d3
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
;
}
}
\ No newline at end of file
ruoyi-common/src/main/java/com/ruoyi/common/exception/
Custom
Exception.java
→
ruoyi-common/src/main/java/com/ruoyi/common/exception/
Service
Exception.java
浏览文件 @
03cf98d3
package
com
.
ruoyi
.
common
.
exception
;
package
com
.
ruoyi
.
common
.
exception
;
/**
/**
*
自定义
异常
*
业务
异常
*
*
* @author ruoyi
* @author ruoyi
*/
*/
public
class
Custom
Exception
extends
RuntimeException
public
final
class
Service
Exception
extends
RuntimeException
{
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
/**
* 错误码
*/
private
Integer
code
;
private
Integer
code
;
/**
* 错误提示
*/
private
String
message
;
private
String
message
;
public
CustomException
(
String
message
)
/**
* 错误明细,内部调试错误
*
* 和 {@link CommonResult#getDetailMessage()} 一致的设计
*/
private
String
detailMessage
;
/**
* 空构造方法,避免反序列化问题
*/
public
ServiceException
()
{
}
public
ServiceException
(
String
message
)
{
{
this
.
message
=
message
;
this
.
message
=
message
;
}
}
public
Custom
Exception
(
String
message
,
Integer
code
)
public
Service
Exception
(
String
message
,
Integer
code
)
{
{
this
.
message
=
message
;
this
.
message
=
message
;
this
.
code
=
code
;
this
.
code
=
code
;
}
}
public
CustomException
(
String
message
,
Throwable
e
)
public
String
getDetailMessage
(
)
{
{
super
(
message
,
e
);
return
detailMessage
;
this
.
message
=
message
;
}
}
@Override
public
String
getMessage
()
public
String
getMessage
()
{
{
return
message
;
return
message
;
...
@@ -40,4 +58,16 @@ public class CustomException extends RuntimeException
...
@@ -40,4 +58,16 @@ public class CustomException extends RuntimeException
{
{
return
code
;
return
code
;
}
}
}
public
ServiceException
setMessage
(
String
message
)
{
this
.
message
=
message
;
return
this
;
}
public
ServiceException
setDetailMessage
(
String
detailMessage
)
{
this
.
detailMessage
=
detailMessage
;
return
this
;
}
}
\ No newline at end of file
ruoyi-common/src/main/java/com/ruoyi/common/exception/BaseException.java
→
ruoyi-common/src/main/java/com/ruoyi/common/exception/
base/
BaseException.java
浏览文件 @
03cf98d3
package
com
.
ruoyi
.
common
.
exception
;
package
com
.
ruoyi
.
common
.
exception
.
base
;
import
com.ruoyi.common.utils.MessageUtils
;
import
com.ruoyi.common.utils.MessageUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
...
...
ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileException.java
浏览文件 @
03cf98d3
package
com
.
ruoyi
.
common
.
exception
.
file
;
package
com
.
ruoyi
.
common
.
exception
.
file
;
import
com.ruoyi.common.exception.BaseException
;
import
com.ruoyi.common.exception.
base.
BaseException
;
/**
/**
* 文件信息异常类
* 文件信息异常类
...
...
ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java
浏览文件 @
03cf98d3
package
com
.
ruoyi
.
common
.
exception
.
user
;
package
com
.
ruoyi
.
common
.
exception
.
user
;
import
com.ruoyi.common.exception.BaseException
;
import
com.ruoyi.common.exception.
base.
BaseException
;
/**
/**
* 用户信息异常类
* 用户信息异常类
...
...
ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java
浏览文件 @
03cf98d3
...
@@ -5,7 +5,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
...
@@ -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.
Custom
Exception
;
import
com.ruoyi.common.exception.
Service
Exception
;
/**
/**
* 安全服务工具类
* 安全服务工具类
...
@@ -25,7 +25,7 @@ public class SecurityUtils
...
@@ -25,7 +25,7 @@ public class SecurityUtils
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
throw
new
Custom
Exception
(
"获取用户ID异常"
,
HttpStatus
.
UNAUTHORIZED
);
throw
new
Service
Exception
(
"获取用户ID异常"
,
HttpStatus
.
UNAUTHORIZED
);
}
}
}
}
...
@@ -40,7 +40,7 @@ public class SecurityUtils
...
@@ -40,7 +40,7 @@ public class SecurityUtils
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
throw
new
Custom
Exception
(
"获取部门ID异常"
,
HttpStatus
.
UNAUTHORIZED
);
throw
new
Service
Exception
(
"获取部门ID异常"
,
HttpStatus
.
UNAUTHORIZED
);
}
}
}
}
...
@@ -55,7 +55,7 @@ public class SecurityUtils
...
@@ -55,7 +55,7 @@ public class SecurityUtils
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
throw
new
Custom
Exception
(
"获取用户账户异常"
,
HttpStatus
.
UNAUTHORIZED
);
throw
new
Service
Exception
(
"获取用户账户异常"
,
HttpStatus
.
UNAUTHORIZED
);
}
}
}
}
...
@@ -70,7 +70,7 @@ public class SecurityUtils
...
@@ -70,7 +70,7 @@ public class SecurityUtils
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
throw
new
Custom
Exception
(
"获取用户信息异常"
,
HttpStatus
.
UNAUTHORIZED
);
throw
new
Service
Exception
(
"获取用户信息异常"
,
HttpStatus
.
UNAUTHORIZED
);
}
}
}
}
...
...
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
浏览文件 @
03cf98d3
...
@@ -66,7 +66,7 @@ import com.ruoyi.common.annotation.Excels;
...
@@ -66,7 +66,7 @@ import com.ruoyi.common.annotation.Excels;
import
com.ruoyi.common.config.RuoYiConfig
;
import
com.ruoyi.common.config.RuoYiConfig
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.text.Convert
;
import
com.ruoyi.common.core.text.Convert
;
import
com.ruoyi.common.exception.
Custom
Exception
;
import
com.ruoyi.common.exception.
Util
Exception
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.DictUtils
;
import
com.ruoyi.common.utils.DictUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
...
@@ -450,7 +450,7 @@ public class ExcelUtil<T>
...
@@ -450,7 +450,7 @@ public class ExcelUtil<T>
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
log
.
error
(
"导出Excel异常{}"
,
e
.
getMessage
());
log
.
error
(
"导出Excel异常{}"
,
e
.
getMessage
());
throw
new
Custom
Exception
(
"导出Excel失败,请联系网站管理员!"
);
throw
new
Util
Exception
(
"导出Excel失败,请联系网站管理员!"
);
}
}
finally
finally
{
{
...
...
ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java
浏览文件 @
03cf98d3
package
com
.
ruoyi
.
common
.
utils
.
sql
;
package
com
.
ruoyi
.
common
.
utils
.
sql
;
import
com.ruoyi.common.exception.
Base
Exception
;
import
com.ruoyi.common.exception.
Util
Exception
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
/**
/**
...
@@ -22,7 +22,7 @@ public class SqlUtil
...
@@ -22,7 +22,7 @@ public class SqlUtil
{
{
if
(
StringUtils
.
isNotEmpty
(
value
)
&&
!
isValidOrderBySql
(
value
))
if
(
StringUtils
.
isNotEmpty
(
value
)
&&
!
isValidOrderBySql
(
value
))
{
{
throw
new
Base
Exception
(
"参数不符合规范,不能进行查询"
);
throw
new
Util
Exception
(
"参数不符合规范,不能进行查询"
);
}
}
return
value
;
return
value
;
}
}
...
...
ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java
浏览文件 @
03cf98d3
package
com
.
ruoyi
.
framework
.
web
.
exception
;
package
com
.
ruoyi
.
framework
.
web
.
exception
;
import
javax.servlet.http.HttpServletRequest
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.security.authentication.AccountExpiredException
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.validation.BindException
;
import
org.springframework.validation.BindException
;
import
org.springframework.web.HttpRequestMethodNotSupportedException
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.MethodArgumentNotValidException
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
org.springframework.web.servlet.NoHandlerFoundException
;
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.exception.BaseException
;
import
com.ruoyi.common.exception.CustomException
;
import
com.ruoyi.common.exception.DemoModeException
;
import
com.ruoyi.common.exception.DemoModeException
;
import
com.ruoyi.common.exception.ServiceException
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
/**
/**
...
@@ -28,59 +26,58 @@ public class GlobalExceptionHandler
...
@@ -28,59 +26,58 @@ public class GlobalExceptionHandler
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
GlobalExceptionHandler
.
class
);
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
GlobalExceptionHandler
.
class
);
/**
/**
*
基础
异常
*
权限校验
异常
*/
*/
@ExceptionHandler
(
Base
Exception
.
class
)
@ExceptionHandler
(
AccessDenied
Exception
.
class
)
public
AjaxResult
baseException
(
BaseException
e
)
public
AjaxResult
handleAccessDeniedException
(
AccessDeniedException
e
,
HttpServletRequest
request
)
{
{
return
AjaxResult
.
error
(
e
.
getMessage
());
String
requestURI
=
request
.
getRequestURI
();
log
.
error
(
"请求地址'{}',权限校验失败'{}'"
,
requestURI
,
e
.
getMessage
());
return
AjaxResult
.
error
(
HttpStatus
.
FORBIDDEN
,
"没有权限,请联系管理员授权"
);
}
}
/**
/**
*
业务异常
*
请求方式不支持
*/
*/
@ExceptionHandler
(
CustomException
.
class
)
@ExceptionHandler
(
HttpRequestMethodNotSupportedException
.
class
)
public
AjaxResult
businessException
(
CustomException
e
)
public
AjaxResult
handleHttpRequestMethodNotSupported
(
HttpRequestMethodNotSupportedException
e
,
{
HttpServletRequest
request
)
if
(
StringUtils
.
isNull
(
e
.
getCode
()))
{
return
AjaxResult
.
error
(
e
.
getMessage
());
}
return
AjaxResult
.
error
(
e
.
getCode
(),
e
.
getMessage
());
}
@ExceptionHandler
(
NoHandlerFoundException
.
class
)
public
AjaxResult
handlerNoFoundException
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
return
AjaxResult
.
error
(
HttpStatus
.
NOT_FOUND
,
"路径不存在,请检查路径是否正确"
);
}
@ExceptionHandler
(
AccessDeniedException
.
class
)
public
AjaxResult
handleAuthorizationException
(
AccessDeniedException
e
)
{
{
log
.
error
(
e
.
getMessage
());
String
requestURI
=
request
.
getRequestURI
();
return
AjaxResult
.
error
(
HttpStatus
.
FORBIDDEN
,
"没有权限,请联系管理员授权"
);
log
.
error
(
"请求地址'{}',不支持'{}'请求"
,
requestURI
,
e
.
getMethod
());
return
AjaxResult
.
error
(
e
.
getMessage
());
}
}
@ExceptionHandler
(
AccountExpiredException
.
class
)
/**
public
AjaxResult
handleAccountExpiredException
(
AccountExpiredException
e
)
* 业务异常
*/
@ExceptionHandler
(
ServiceException
.
class
)
public
AjaxResult
handleServiceException
(
ServiceException
e
,
HttpServletRequest
request
)
{
{
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
e
.
getMessage
(),
e
);
return
AjaxResult
.
error
(
e
.
getMessage
());
Integer
code
=
e
.
getCode
();
return
StringUtils
.
isNotNull
(
code
)
?
AjaxResult
.
error
(
code
,
e
.
getMessage
())
:
AjaxResult
.
error
(
e
.
getMessage
());
}
}
@ExceptionHandler
(
UsernameNotFoundException
.
class
)
/**
public
AjaxResult
handleUsernameNotFoundException
(
UsernameNotFoundException
e
)
* 拦截未知的运行时异常
*/
@ExceptionHandler
(
RuntimeException
.
class
)
public
AjaxResult
handleRuntimeException
(
RuntimeException
e
,
HttpServletRequest
request
)
{
{
log
.
error
(
e
.
getMessage
(),
e
);
String
requestURI
=
request
.
getRequestURI
();
log
.
error
(
"请求地址'{}',发生未知异常."
,
requestURI
,
e
);
return
AjaxResult
.
error
(
e
.
getMessage
());
return
AjaxResult
.
error
(
e
.
getMessage
());
}
}
/**
* 系统异常
*/
@ExceptionHandler
(
Exception
.
class
)
@ExceptionHandler
(
Exception
.
class
)
public
AjaxResult
handleException
(
Exception
e
)
public
AjaxResult
handleException
(
Exception
e
,
HttpServletRequest
request
)
{
{
log
.
error
(
e
.
getMessage
(),
e
);
String
requestURI
=
request
.
getRequestURI
();
log
.
error
(
"请求地址'{}',发生系统异常."
,
requestURI
,
e
);
return
AjaxResult
.
error
(
e
.
getMessage
());
return
AjaxResult
.
error
(
e
.
getMessage
());
}
}
...
@@ -88,7 +85,7 @@ public class GlobalExceptionHandler
...
@@ -88,7 +85,7 @@ public class GlobalExceptionHandler
* 自定义验证异常
* 自定义验证异常
*/
*/
@ExceptionHandler
(
BindException
.
class
)
@ExceptionHandler
(
BindException
.
class
)
public
AjaxResult
validated
BindException
(
BindException
e
)
public
AjaxResult
handle
BindException
(
BindException
e
)
{
{
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
e
.
getMessage
(),
e
);
String
message
=
e
.
getAllErrors
().
get
(
0
).
getDefaultMessage
();
String
message
=
e
.
getAllErrors
().
get
(
0
).
getDefaultMessage
();
...
@@ -99,7 +96,7 @@ public class GlobalExceptionHandler
...
@@ -99,7 +96,7 @@ public class GlobalExceptionHandler
* 自定义验证异常
* 自定义验证异常
*/
*/
@ExceptionHandler
(
MethodArgumentNotValidException
.
class
)
@ExceptionHandler
(
MethodArgumentNotValidException
.
class
)
public
Object
validExceptionHandler
(
MethodArgumentNotValidException
e
)
public
Object
handleMethodArgumentNotValidException
(
MethodArgumentNotValidException
e
)
{
{
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
e
.
getMessage
(),
e
);
String
message
=
e
.
getBindingResult
().
getFieldError
().
getDefaultMessage
();
String
message
=
e
.
getBindingResult
().
getFieldError
().
getDefaultMessage
();
...
@@ -110,7 +107,7 @@ public class GlobalExceptionHandler
...
@@ -110,7 +107,7 @@ public class GlobalExceptionHandler
* 演示模式异常
* 演示模式异常
*/
*/
@ExceptionHandler
(
DemoModeException
.
class
)
@ExceptionHandler
(
DemoModeException
.
class
)
public
AjaxResult
d
emoModeException
(
DemoModeException
e
)
public
AjaxResult
handleD
emoModeException
(
DemoModeException
e
)
{
{
return
AjaxResult
.
error
(
"演示模式,不允许操作"
);
return
AjaxResult
.
error
(
"演示模式,不允许操作"
);
}
}
...
...
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
浏览文件 @
03cf98d3
...
@@ -11,7 +11,7 @@ import com.ruoyi.common.constant.Constants;
...
@@ -11,7 +11,7 @@ import com.ruoyi.common.constant.Constants;
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.core.redis.RedisCache
;
import
com.ruoyi.common.core.redis.RedisCache
;
import
com.ruoyi.common.exception.
Custom
Exception
;
import
com.ruoyi.common.exception.
Service
Exception
;
import
com.ruoyi.common.exception.user.CaptchaException
;
import
com.ruoyi.common.exception.user.CaptchaException
;
import
com.ruoyi.common.exception.user.CaptchaExpireException
;
import
com.ruoyi.common.exception.user.CaptchaExpireException
;
import
com.ruoyi.common.exception.user.UserPasswordNotMatchException
;
import
com.ruoyi.common.exception.user.UserPasswordNotMatchException
;
...
@@ -82,7 +82,7 @@ public class SysLoginService
...
@@ -82,7 +82,7 @@ public class SysLoginService
else
else
{
{
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordLogininfor
(
username
,
Constants
.
LOGIN_FAIL
,
e
.
getMessage
()));
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordLogininfor
(
username
,
Constants
.
LOGIN_FAIL
,
e
.
getMessage
()));
throw
new
Custom
Exception
(
e
.
getMessage
());
throw
new
Service
Exception
(
e
.
getMessage
());
}
}
}
}
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordLogininfor
(
username
,
Constants
.
LOGIN_SUCCESS
,
MessageUtils
.
message
(
"user.login.success"
)));
AsyncManager
.
me
().
execute
(
AsyncFactory
.
recordLogininfor
(
username
,
Constants
.
LOGIN_SUCCESS
,
MessageUtils
.
message
(
"user.login.success"
)));
...
...
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java
浏览文件 @
03cf98d3
...
@@ -10,7 +10,7 @@ import org.springframework.stereotype.Service;
...
@@ -10,7 +10,7 @@ import org.springframework.stereotype.Service;
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.UserStatus
;
import
com.ruoyi.common.enums.UserStatus
;
import
com.ruoyi.common.exception.
Bas
eException
;
import
com.ruoyi.common.exception.
Servic
eException
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.system.service.ISysUserService
;
import
com.ruoyi.system.service.ISysUserService
;
...
@@ -37,17 +37,17 @@ public class UserDetailsServiceImpl implements UserDetailsService
...
@@ -37,17 +37,17 @@ public class UserDetailsServiceImpl implements UserDetailsService
if
(
StringUtils
.
isNull
(
user
))
if
(
StringUtils
.
isNull
(
user
))
{
{
log
.
info
(
"登录用户:{} 不存在."
,
username
);
log
.
info
(
"登录用户:{} 不存在."
,
username
);
throw
new
UsernameNotFound
Exception
(
"登录用户:"
+
username
+
" 不存在"
);
throw
new
Service
Exception
(
"登录用户:"
+
username
+
" 不存在"
);
}
}
else
if
(
UserStatus
.
DELETED
.
getCode
().
equals
(
user
.
getDelFlag
()))
else
if
(
UserStatus
.
DELETED
.
getCode
().
equals
(
user
.
getDelFlag
()))
{
{
log
.
info
(
"登录用户:{} 已被删除."
,
username
);
log
.
info
(
"登录用户:{} 已被删除."
,
username
);
throw
new
Bas
eException
(
"对不起,您的账号:"
+
username
+
" 已被删除"
);
throw
new
Servic
eException
(
"对不起,您的账号:"
+
username
+
" 已被删除"
);
}
}
else
if
(
UserStatus
.
DISABLE
.
getCode
().
equals
(
user
.
getStatus
()))
else
if
(
UserStatus
.
DISABLE
.
getCode
().
equals
(
user
.
getStatus
()))
{
{
log
.
info
(
"登录用户:{} 已被停用."
,
username
);
log
.
info
(
"登录用户:{} 已被停用."
,
username
);
throw
new
Bas
eException
(
"对不起,您的账号:"
+
username
+
" 已停用"
);
throw
new
Servic
eException
(
"对不起,您的账号:"
+
username
+
" 已停用"
);
}
}
return
createLoginUser
(
user
);
return
createLoginUser
(
user
);
...
...
ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
浏览文件 @
03cf98d3
...
@@ -25,7 +25,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -25,7 +25,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.constant.Constants
;
import
com.ruoyi.common.constant.GenConstants
;
import
com.ruoyi.common.constant.GenConstants
;
import
com.ruoyi.common.core.text.CharsetKit
;
import
com.ruoyi.common.core.text.CharsetKit
;
import
com.ruoyi.common.exception.
Custom
Exception
;
import
com.ruoyi.common.exception.
Service
Exception
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.generator.domain.GenTable
;
import
com.ruoyi.generator.domain.GenTable
;
...
@@ -180,7 +180,7 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -180,7 +180,7 @@ public class GenTableServiceImpl implements IGenTableService
}
}
catch
(
Exception
e
)
catch
(
Exception
e
)
{
{
throw
new
Custom
Exception
(
"导入失败:"
+
e
.
getMessage
());
throw
new
Service
Exception
(
"导入失败:"
+
e
.
getMessage
());
}
}
}
}
...
@@ -269,7 +269,7 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -269,7 +269,7 @@ public class GenTableServiceImpl implements IGenTableService
}
}
catch
(
IOException
e
)
catch
(
IOException
e
)
{
{
throw
new
Custom
Exception
(
"渲染模板失败,表名:"
+
table
.
getTableName
());
throw
new
Service
Exception
(
"渲染模板失败,表名:"
+
table
.
getTableName
());
}
}
}
}
}
}
...
@@ -291,7 +291,7 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -291,7 +291,7 @@ public class GenTableServiceImpl implements IGenTableService
List
<
GenTableColumn
>
dbTableColumns
=
genTableColumnMapper
.
selectDbTableColumnsByName
(
tableName
);
List
<
GenTableColumn
>
dbTableColumns
=
genTableColumnMapper
.
selectDbTableColumnsByName
(
tableName
);
if
(
StringUtils
.
isEmpty
(
dbTableColumns
))
if
(
StringUtils
.
isEmpty
(
dbTableColumns
))
{
{
throw
new
Custom
Exception
(
"同步数据失败,原表结构不存在"
);
throw
new
Service
Exception
(
"同步数据失败,原表结构不存在"
);
}
}
List
<
String
>
dbTableColumnNames
=
dbTableColumns
.
stream
().
map
(
GenTableColumn:
:
getColumnName
).
collect
(
Collectors
.
toList
());
List
<
String
>
dbTableColumnNames
=
dbTableColumns
.
stream
().
map
(
GenTableColumn:
:
getColumnName
).
collect
(
Collectors
.
toList
());
...
@@ -383,25 +383,25 @@ public class GenTableServiceImpl implements IGenTableService
...
@@ -383,25 +383,25 @@ public class GenTableServiceImpl implements IGenTableService
JSONObject
paramsObj
=
JSONObject
.
parseObject
(
options
);
JSONObject
paramsObj
=
JSONObject
.
parseObject
(
options
);
if
(
StringUtils
.
isEmpty
(
paramsObj
.
getString
(
GenConstants
.
TREE_CODE
)))
if
(
StringUtils
.
isEmpty
(
paramsObj
.
getString
(
GenConstants
.
TREE_CODE
)))
{
{
throw
new
Custom
Exception
(
"树编码字段不能为空"
);
throw
new
Service
Exception
(
"树编码字段不能为空"
);
}
}
else
if
(
StringUtils
.
isEmpty
(
paramsObj
.
getString
(
GenConstants
.
TREE_PARENT_CODE
)))
else
if
(
StringUtils
.
isEmpty
(
paramsObj
.
getString
(
GenConstants
.
TREE_PARENT_CODE
)))
{
{
throw
new
Custom
Exception
(
"树父编码字段不能为空"
);
throw
new
Service
Exception
(
"树父编码字段不能为空"
);
}
}
else
if
(
StringUtils
.
isEmpty
(
paramsObj
.
getString
(
GenConstants
.
TREE_NAME
)))
else
if
(
StringUtils
.
isEmpty
(
paramsObj
.
getString
(
GenConstants
.
TREE_NAME
)))
{
{
throw
new
Custom
Exception
(
"树名称字段不能为空"
);
throw
new
Service
Exception
(
"树名称字段不能为空"
);
}
}
else
if
(
GenConstants
.
TPL_SUB
.
equals
(
genTable
.
getTplCategory
()))
else
if
(
GenConstants
.
TPL_SUB
.
equals
(
genTable
.
getTplCategory
()))
{
{
if
(
StringUtils
.
isEmpty
(
genTable
.
getSubTableName
()))
if
(
StringUtils
.
isEmpty
(
genTable
.
getSubTableName
()))
{
{
throw
new
Custom
Exception
(
"关联子表的表名不能为空"
);
throw
new
Service
Exception
(
"关联子表的表名不能为空"
);
}
}
else
if
(
StringUtils
.
isEmpty
(
genTable
.
getSubTableFkName
()))
else
if
(
StringUtils
.
isEmpty
(
genTable
.
getSubTableFkName
()))
{
{
throw
new
Custom
Exception
(
"子表关联的外键名不能为空"
);
throw
new
Service
Exception
(
"子表关联的外键名不能为空"
);
}
}
}
}
}
}
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java
浏览文件 @
03cf98d3
...
@@ -6,7 +6,7 @@ import com.ruoyi.common.constant.UserConstants;
...
@@ -6,7 +6,7 @@ import com.ruoyi.common.constant.UserConstants;
import
com.ruoyi.common.core.redis.RedisCache
;
import
com.ruoyi.common.core.redis.RedisCache
;
import
com.ruoyi.common.core.text.Convert
;
import
com.ruoyi.common.core.text.Convert
;
import
com.ruoyi.common.enums.DataSourceType
;
import
com.ruoyi.common.enums.DataSourceType
;
import
com.ruoyi.common.exception.
Custom
Exception
;
import
com.ruoyi.common.exception.
Service
Exception
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.system.domain.SysConfig
;
import
com.ruoyi.system.domain.SysConfig
;
import
com.ruoyi.system.mapper.SysConfigMapper
;
import
com.ruoyi.system.mapper.SysConfigMapper
;
...
@@ -156,7 +156,7 @@ public class SysConfigServiceImpl implements ISysConfigService
...
@@ -156,7 +156,7 @@ public class SysConfigServiceImpl implements ISysConfigService
SysConfig
config
=
selectConfigById
(
configId
);
SysConfig
config
=
selectConfigById
(
configId
);
if
(
StringUtils
.
equals
(
UserConstants
.
YES
,
config
.
getConfigType
()))
if
(
StringUtils
.
equals
(
UserConstants
.
YES
,
config
.
getConfigType
()))
{
{
throw
new
Custom
Exception
(
String
.
format
(
"内置参数【%1$s】不能删除 "
,
config
.
getConfigKey
()));
throw
new
Service
Exception
(
String
.
format
(
"内置参数【%1$s】不能删除 "
,
config
.
getConfigKey
()));
}
}
configMapper
.
deleteConfigById
(
configId
);
configMapper
.
deleteConfigById
(
configId
);
redisCache
.
deleteObject
(
getCacheKey
(
config
.
getConfigKey
()));
redisCache
.
deleteObject
(
getCacheKey
(
config
.
getConfigKey
()));
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java
浏览文件 @
03cf98d3
...
@@ -12,7 +12,7 @@ import com.ruoyi.common.core.domain.TreeSelect;
...
@@ -12,7 +12,7 @@ import com.ruoyi.common.core.domain.TreeSelect;
import
com.ruoyi.common.core.domain.entity.SysDept
;
import
com.ruoyi.common.core.domain.entity.SysDept
;
import
com.ruoyi.common.core.domain.entity.SysRole
;
import
com.ruoyi.common.core.domain.entity.SysRole
;
import
com.ruoyi.common.core.text.Convert
;
import
com.ruoyi.common.core.text.Convert
;
import
com.ruoyi.common.exception.
Custom
Exception
;
import
com.ruoyi.common.exception.
Service
Exception
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.system.mapper.SysDeptMapper
;
import
com.ruoyi.system.mapper.SysDeptMapper
;
import
com.ruoyi.system.mapper.SysRoleMapper
;
import
com.ruoyi.system.mapper.SysRoleMapper
;
...
@@ -184,7 +184,7 @@ public class SysDeptServiceImpl implements ISysDeptService
...
@@ -184,7 +184,7 @@ public class SysDeptServiceImpl implements ISysDeptService
// 如果父节点不为正常状态,则不允许新增子节点
// 如果父节点不为正常状态,则不允许新增子节点
if
(!
UserConstants
.
DEPT_NORMAL
.
equals
(
info
.
getStatus
()))
if
(!
UserConstants
.
DEPT_NORMAL
.
equals
(
info
.
getStatus
()))
{
{
throw
new
Custom
Exception
(
"部门停用,不允许新增"
);
throw
new
Service
Exception
(
"部门停用,不允许新增"
);
}
}
dept
.
setAncestors
(
info
.
getAncestors
()
+
","
+
dept
.
getParentId
());
dept
.
setAncestors
(
info
.
getAncestors
()
+
","
+
dept
.
getParentId
());
return
deptMapper
.
insertDept
(
dept
);
return
deptMapper
.
insertDept
(
dept
);
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java
浏览文件 @
03cf98d3
...
@@ -3,7 +3,7 @@ package com.ruoyi.system.service.impl;
...
@@ -3,7 +3,7 @@ package com.ruoyi.system.service.impl;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.core.domain.entity.SysDictData
;
import
com.ruoyi.common.core.domain.entity.SysDictData
;
import
com.ruoyi.common.core.domain.entity.SysDictType
;
import
com.ruoyi.common.core.domain.entity.SysDictType
;
import
com.ruoyi.common.exception.
Custom
Exception
;
import
com.ruoyi.common.exception.
Service
Exception
;
import
com.ruoyi.common.utils.DictUtils
;
import
com.ruoyi.common.utils.DictUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.system.mapper.SysDictDataMapper
;
import
com.ruoyi.system.mapper.SysDictDataMapper
;
...
@@ -122,7 +122,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
...
@@ -122,7 +122,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
SysDictType
dictType
=
selectDictTypeById
(
dictId
);
SysDictType
dictType
=
selectDictTypeById
(
dictId
);
if
(
dictDataMapper
.
countDictDataByType
(
dictType
.
getDictType
())
>
0
)
if
(
dictDataMapper
.
countDictDataByType
(
dictType
.
getDictType
())
>
0
)
{
{
throw
new
Custom
Exception
(
String
.
format
(
"%1$s已分配,不能删除"
,
dictType
.
getDictName
()));
throw
new
Service
Exception
(
String
.
format
(
"%1$s已分配,不能删除"
,
dictType
.
getDictName
()));
}
}
dictTypeMapper
.
deleteDictTypeById
(
dictId
);
dictTypeMapper
.
deleteDictTypeById
(
dictId
);
DictUtils
.
removeDictCache
(
dictType
.
getDictType
());
DictUtils
.
removeDictCache
(
dictType
.
getDictType
());
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java
浏览文件 @
03cf98d3
...
@@ -4,7 +4,7 @@ import java.util.List;
...
@@ -4,7 +4,7 @@ import java.util.List;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.exception.
Custom
Exception
;
import
com.ruoyi.common.exception.
Service
Exception
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.system.domain.SysPost
;
import
com.ruoyi.system.domain.SysPost
;
import
com.ruoyi.system.mapper.SysPostMapper
;
import
com.ruoyi.system.mapper.SysPostMapper
;
...
@@ -147,7 +147,7 @@ public class SysPostServiceImpl implements ISysPostService
...
@@ -147,7 +147,7 @@ public class SysPostServiceImpl implements ISysPostService
SysPost
post
=
selectPostById
(
postId
);
SysPost
post
=
selectPostById
(
postId
);
if
(
countUserPostById
(
postId
)
>
0
)
if
(
countUserPostById
(
postId
)
>
0
)
{
{
throw
new
Custom
Exception
(
String
.
format
(
"%1$s已分配,不能删除"
,
post
.
getPostName
()));
throw
new
Service
Exception
(
String
.
format
(
"%1$s已分配,不能删除"
,
post
.
getPostName
()));
}
}
}
}
return
postMapper
.
deletePostByIds
(
postIds
);
return
postMapper
.
deletePostByIds
(
postIds
);
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java
浏览文件 @
03cf98d3
...
@@ -11,7 +11,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -11,7 +11,7 @@ import org.springframework.transaction.annotation.Transactional;
import
com.ruoyi.common.annotation.DataScope
;
import
com.ruoyi.common.annotation.DataScope
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.core.domain.entity.SysRole
;
import
com.ruoyi.common.core.domain.entity.SysRole
;
import
com.ruoyi.common.exception.
Custom
Exception
;
import
com.ruoyi.common.exception.
Service
Exception
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
com.ruoyi.system.domain.SysRoleDept
;
import
com.ruoyi.system.domain.SysRoleDept
;
...
@@ -183,7 +183,7 @@ public class SysRoleServiceImpl implements ISysRoleService
...
@@ -183,7 +183,7 @@ public class SysRoleServiceImpl implements ISysRoleService
{
{
if
(
StringUtils
.
isNotNull
(
role
.
getRoleId
())
&&
role
.
isAdmin
())
if
(
StringUtils
.
isNotNull
(
role
.
getRoleId
())
&&
role
.
isAdmin
())
{
{
throw
new
Custom
Exception
(
"不允许操作超级管理员角色"
);
throw
new
Service
Exception
(
"不允许操作超级管理员角色"
);
}
}
}
}
...
@@ -342,7 +342,7 @@ public class SysRoleServiceImpl implements ISysRoleService
...
@@ -342,7 +342,7 @@ public class SysRoleServiceImpl implements ISysRoleService
SysRole
role
=
selectRoleById
(
roleId
);
SysRole
role
=
selectRoleById
(
roleId
);
if
(
countUserRoleByRoleId
(
roleId
)
>
0
)
if
(
countUserRoleByRoleId
(
roleId
)
>
0
)
{
{
throw
new
Custom
Exception
(
String
.
format
(
"%1$s已分配,不能删除"
,
role
.
getRoleName
()));
throw
new
Service
Exception
(
String
.
format
(
"%1$s已分配,不能删除"
,
role
.
getRoleName
()));
}
}
}
}
// 删除角色与菜单关联
// 删除角色与菜单关联
...
...
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java
浏览文件 @
03cf98d3
...
@@ -11,7 +11,7 @@ import com.ruoyi.common.annotation.DataScope;
...
@@ -11,7 +11,7 @@ import com.ruoyi.common.annotation.DataScope;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.constant.UserConstants
;
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.exception.
Custom
Exception
;
import
com.ruoyi.common.exception.
Service
Exception
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.SecurityUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.system.domain.SysPost
;
import
com.ruoyi.system.domain.SysPost
;
...
@@ -223,7 +223,7 @@ public class SysUserServiceImpl implements ISysUserService
...
@@ -223,7 +223,7 @@ public class SysUserServiceImpl implements ISysUserService
{
{
if
(
StringUtils
.
isNotNull
(
user
.
getUserId
())
&&
user
.
isAdmin
())
if
(
StringUtils
.
isNotNull
(
user
.
getUserId
())
&&
user
.
isAdmin
())
{
{
throw
new
Custom
Exception
(
"不允许操作超级管理员用户"
);
throw
new
Service
Exception
(
"不允许操作超级管理员用户"
);
}
}
}
}
...
@@ -485,7 +485,7 @@ public class SysUserServiceImpl implements ISysUserService
...
@@ -485,7 +485,7 @@ public class SysUserServiceImpl implements ISysUserService
{
{
if
(
StringUtils
.
isNull
(
userList
)
||
userList
.
size
()
==
0
)
if
(
StringUtils
.
isNull
(
userList
)
||
userList
.
size
()
==
0
)
{
{
throw
new
Custom
Exception
(
"导入用户数据不能为空!"
);
throw
new
Service
Exception
(
"导入用户数据不能为空!"
);
}
}
int
successNum
=
0
;
int
successNum
=
0
;
int
failureNum
=
0
;
int
failureNum
=
0
;
...
@@ -530,7 +530,7 @@ public class SysUserServiceImpl implements ISysUserService
...
@@ -530,7 +530,7 @@ public class SysUserServiceImpl implements ISysUserService
if
(
failureNum
>
0
)
if
(
failureNum
>
0
)
{
{
failureMsg
.
insert
(
0
,
"很抱歉,导入失败!共 "
+
failureNum
+
" 条数据格式不正确,错误如下:"
);
failureMsg
.
insert
(
0
,
"很抱歉,导入失败!共 "
+
failureNum
+
" 条数据格式不正确,错误如下:"
);
throw
new
Custom
Exception
(
failureMsg
.
toString
());
throw
new
Service
Exception
(
failureMsg
.
toString
());
}
}
else
else
{
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论