Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dinky
Project
Project
Details
Activity
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
wangpeng
dinky
Commits
7b38967f
Unverified
Commit
7b38967f
authored
Aug 11, 2023
by
ZackYoung
Committed by
GitHub
Aug 11, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Optimize]optimize_some_code (#2198)
* optimize_some_code * optimize_some_code * optimize_some_code
parent
6fdf8577
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
17 deletions
+17
-17
WebExceptionHandler.java
...dmin/src/main/java/org/dinky/aop/WebExceptionHandler.java
+17
-17
No files found.
dinky-admin/src/main/java/org/dinky/aop/WebExceptionHandler.java
View file @
7b38967f
...
...
@@ -28,6 +28,7 @@ import org.dinky.utils.I18nMsgUtils;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.List
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -46,6 +47,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
cn.dev33.satoken.exception.NotLoginException
;
import
cn.hutool.core.map.MapUtil
;
import
cn.hutool.core.util.StrUtil
;
/**
...
...
@@ -67,6 +69,17 @@ public class WebExceptionHandler {
return
Result
.
failed
(
e
.
getMsg
());
}
private
static
final
Map
<
String
,
Status
>
ERR_CODE_MAPPING
=
MapUtil
.<
String
,
Status
>
builder
()
.
put
(
NotLoginException
.
NOT_TOKEN
,
Status
.
NOT_TOKEN
)
.
put
(
NotLoginException
.
INVALID_TOKEN
,
Status
.
INVALID_TOKEN
)
.
put
(
NotLoginException
.
TOKEN_TIMEOUT
,
Status
.
EXPIRED_TOKEN
)
.
put
(
NotLoginException
.
BE_REPLACED
,
Status
.
BE_REPLACED
)
.
put
(
NotLoginException
.
KICK_OUT
,
Status
.
KICK_OUT
)
.
put
(
NotLoginException
.
TOKEN_FREEZE
,
Status
.
TOKEN_FREEZED
)
.
put
(
NotLoginException
.
NO_PREFIX
,
Status
.
NO_PREFIX
)
.
build
();
@ExceptionHandler
public
Result
<
Void
>
notLoginException
(
NotLoginException
notLoginException
)
{
ServletRequestAttributes
servletRequestAttributes
=
...
...
@@ -75,23 +88,10 @@ public class WebExceptionHandler {
if
(
response
!=
null
)
{
response
.
setStatus
(
CodeEnum
.
NOTLOGIN
.
getCode
());
}
if
(
notLoginException
.
getType
().
equals
(
NotLoginException
.
NOT_TOKEN
))
{
return
Result
.
failed
(
Status
.
NOT_TOKEN
);
}
else
if
(
notLoginException
.
getType
().
equals
(
NotLoginException
.
INVALID_TOKEN
))
{
return
Result
.
failed
(
Status
.
INVALID_TOKEN
);
}
else
if
(
notLoginException
.
getType
().
equals
(
NotLoginException
.
TOKEN_TIMEOUT
))
{
return
Result
.
failed
(
Status
.
EXPIRED_TOKEN
);
}
else
if
(
notLoginException
.
getType
().
equals
(
NotLoginException
.
BE_REPLACED
))
{
return
Result
.
failed
(
Status
.
BE_REPLACED
);
}
else
if
(
notLoginException
.
getType
().
equals
(
NotLoginException
.
KICK_OUT
))
{
return
Result
.
failed
(
Status
.
KICK_OUT
);
}
else
if
(
notLoginException
.
getType
().
equals
(
NotLoginException
.
TOKEN_FREEZE
))
{
return
Result
.
failed
(
Status
.
TOKEN_FREEZED
);
}
else
if
(
notLoginException
.
getType
().
equals
(
NotLoginException
.
NO_PREFIX
))
{
return
Result
.
failed
(
Status
.
NO_PREFIX
);
}
else
{
return
Result
.
failed
(
Status
.
USER_NOT_LOGIN
);
}
String
type
=
notLoginException
.
getType
();
Status
status
=
ERR_CODE_MAPPING
.
getOrDefault
(
type
,
Status
.
NOT_TOKEN
);
return
Result
.
failed
(
status
);
}
/**
...
...
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