Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
rs-cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
周健威
rs-cloud-platform
Commits
a9367c09
Commit
a9367c09
authored
Jul 15, 2021
by
周健威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去除邮件发送通知
parent
86fb39f2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
95 deletions
+0
-95
GlobalExceptionHandler.java
...iaoqi/security/common/handler/GlobalExceptionHandler.java
+0
-46
PlatformExceptionHandler.java
...oqi/security/common/handler/PlatformExceptionHandler.java
+0
-49
No files found.
ace-common/src/main/java/com/github/wxiaoqi/security/common/handler/GlobalExceptionHandler.java
View file @
a9367c09
...
@@ -40,15 +40,6 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
...
@@ -40,15 +40,6 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
private
Logger
logger
=
LoggerFactory
.
getLogger
(
GlobalExceptionHandler
.
class
);
private
Logger
logger
=
LoggerFactory
.
getLogger
(
GlobalExceptionHandler
.
class
);
@Value
(
"${spring.application.name}"
)
@Value
(
"${spring.application.name}"
)
private
String
applicationName
;
private
String
applicationName
;
@Value
(
"${email.log.account}"
)
private
String
emailLogAccount
;
@Value
(
"${email.log.title}"
)
private
String
emailLogTitle
;
@Value
(
"${email.log.host}"
)
private
String
emailLogHost
;
/**
/**
* 在controller里面内容执行之前,校验一些参数不匹配啊,Get post方法不对啊之类的
* 在controller里面内容执行之前,校验一些参数不匹配啊,Get post方法不对啊之类的
*/
*/
...
@@ -94,43 +85,6 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
...
@@ -94,43 +85,6 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
response
.
setStatus
(
500
);
response
.
setStatus
(
500
);
logger
.
error
(
ex
.
getMessage
(),
ex
);
logger
.
error
(
ex
.
getMessage
(),
ex
);
Throwable
cause
=
ex
.
getCause
();
Throwable
cause
=
ex
.
getCause
();
if
(
cause
!=
null
&&
cause
.
toString
().
contains
(
"Exception"
)
&&
!
cause
.
toString
().
contains
(
"UserTokenException"
))
{
StringWriter
stringWriter
=
new
StringWriter
();
cause
.
printStackTrace
(
new
PrintWriter
(
stringWriter
));
logger
.
error
(
cause
.
getMessage
(),
ex
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"toUser"
,
emailLogAccount
);
map
.
put
(
"subject"
,
emailLogTitle
);
map
.
put
(
"content"
,
initCommonLogPrePart
()+
":"
+
stringWriter
.
toString
());
try
{
HttpUtils
.
doPost
(
emailLogHost
,
"/api/universal/mail/app/unauth/send"
,
map
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
}
return
new
BaseResponse
(
5000
,
"Server exception: "
+
ex
.
getMessage
());
}
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"toUser"
,
emailLogAccount
);
map
.
put
(
"subject"
,
emailLogTitle
);
map
.
put
(
"content"
,
initCommonLogPrePart
()+
":"
+
ex
.
toString
()
+
":"
+
ex
.
getMessage
());
try
{
HttpUtils
.
doPost
(
emailLogHost
,
"/api/universal/mail/app/unauth/send"
,
map
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
}
return
new
BaseResponse
(
CommonConstants
.
EX_OTHER_CODE
,
ex
.
getMessage
());
return
new
BaseResponse
(
CommonConstants
.
EX_OTHER_CODE
,
ex
.
getMessage
());
}
}
public
String
initCommonLogPrePart
()
{
ServletRequestAttributes
servletRequestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
HttpServletRequest
request
=
servletRequestAttributes
.
getRequest
();
//获取request
StringBuilder
stringBuilder
=
new
StringBuilder
();
//request 获得头部
stringBuilder
.
append
(
request
.
getHeader
(
"app"
));
LocalDateTime
startTime
=
LocalDateTime
.
now
();
//开始时间
stringBuilder
.
append
(
"》》"
+
startTime
.
toString
());
stringBuilder
.
append
(
"》》"
+
request
.
getServletPath
());
stringBuilder
.
append
(
"》》"
+
applicationName
+
":"
+
request
.
getServletPath
());
return
stringBuilder
.
toString
();
}
}
}
ace-common/src/main/java/com/github/wxiaoqi/security/common/handler/PlatformExceptionHandler.java
View file @
a9367c09
...
@@ -26,15 +26,6 @@ public class PlatformExceptionHandler {
...
@@ -26,15 +26,6 @@ public class PlatformExceptionHandler {
@Value
(
"${spring.application.name}"
)
@Value
(
"${spring.application.name}"
)
private
String
applicationName
;
private
String
applicationName
;
@Value
(
"${email.log.account}"
)
private
String
emailLogAccount
;
@Value
(
"${email.log.title}"
)
private
String
emailLogTitle
;
@Value
(
"${email.log.host}"
)
private
String
emailLogHost
;
@ExceptionHandler
(
value
=
{
BaseException
.
class
})
@ExceptionHandler
(
value
=
{
BaseException
.
class
})
public
BaseResponse
baseExceptionHandler
(
Exception
e
)
{
public
BaseResponse
baseExceptionHandler
(
Exception
e
)
{
if
(
e
instanceof
BaseException
){
if
(
e
instanceof
BaseException
){
...
@@ -47,33 +38,6 @@ public class PlatformExceptionHandler {
...
@@ -47,33 +38,6 @@ public class PlatformExceptionHandler {
//服务器异常
//服务器异常
@ExceptionHandler
(
Exception
.
class
)
@ExceptionHandler
(
Exception
.
class
)
public
ObjectRestResponse
<?>
exceptionHandler
(
Exception
e
){
public
ObjectRestResponse
<?>
exceptionHandler
(
Exception
e
){
Throwable
cause
=
e
.
getCause
();
if
(
cause
!=
null
&&
cause
.
toString
().
contains
(
"Exception"
)
&&
!
cause
.
toString
().
contains
(
"UserTokenException"
))
{
StringWriter
stringWriter
=
new
StringWriter
();
cause
.
printStackTrace
(
new
PrintWriter
(
stringWriter
));
log
.
error
(
cause
.
getMessage
(),
e
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"toUser"
,
emailLogAccount
);
map
.
put
(
"subject"
,
emailLogTitle
);
map
.
put
(
"content"
,
initCommonLogPrePart
()+
":"
+
stringWriter
.
toString
());
try
{
HttpUtils
.
doPost
(
emailLogHost
,
"/api/universal/mail/app/unauth/send"
,
map
);
}
catch
(
Exception
ex
)
{
log
.
error
(
ex
.
getMessage
());
}
return
assembleResult
(
ObjectRestResponse
.
createFailedResult
(
5000
,
"服务器开小差了,请稍后重试!"
),
"Server exception: "
+
e
.
getMessage
());
}
log
.
error
(
"Server exception: "
,
e
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"toUser"
,
emailLogAccount
);
map
.
put
(
"subject"
,
emailLogTitle
);
map
.
put
(
"content"
,
initCommonLogPrePart
()+
":"
+
e
.
toString
()
+
":"
+
e
.
getMessage
());
try
{
HttpUtils
.
doPost
(
emailLogHost
,
"/api/universal/mail/app/unauth/send"
,
map
);
}
catch
(
Exception
ex
)
{
log
.
error
(
ex
.
getMessage
());
}
return
assembleResult
(
ObjectRestResponse
.
createFailedResult
(
5000
,
"服务器开小差了,请稍后重试!"
),
"Server exception: "
+
e
.
getMessage
());
return
assembleResult
(
ObjectRestResponse
.
createFailedResult
(
5000
,
"服务器开小差了,请稍后重试!"
),
"Server exception: "
+
e
.
getMessage
());
}
}
...
@@ -87,17 +51,4 @@ public class PlatformExceptionHandler {
...
@@ -87,17 +51,4 @@ public class PlatformExceptionHandler {
}
}
public
String
initCommonLogPrePart
()
{
ServletRequestAttributes
servletRequestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
HttpServletRequest
request
=
servletRequestAttributes
.
getRequest
();
//获取request
StringBuilder
stringBuilder
=
new
StringBuilder
();
//request 获得头部
LocalDateTime
startTime
=
LocalDateTime
.
now
();
//开始时间
stringBuilder
.
append
(
"》》"
+
startTime
.
toString
());
stringBuilder
.
append
(
"》》"
+
request
.
getServletPath
());
stringBuilder
.
append
(
"》》"
+
applicationName
+
":"
+
request
.
getServletPath
());
return
stringBuilder
.
toString
();
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment