Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
data-server
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
licc
data-server
Commits
39d5bad9
Commit
39d5bad9
authored
Mar 16, 2021
by
m1991
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
登录模块——用户退出功能修复
parent
fcd5b3de
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
22 deletions
+22
-22
Constants.java
...on/src/main/java/cn/wisenergy/common/utils/Constants.java
+1
-1
RedisKeyUtils.java
...rc/main/java/cn/wisenergy/common/utils/RedisKeyUtils.java
+2
-2
UserServiceImpl.java
...n/java/cn/wisenergy/service/app/impl/UserServiceImpl.java
+3
-3
LoginController.java
...n/wisenergy/web/admin/controller/app/LoginController.java
+16
-16
No files found.
wisenergy-common/src/main/java/cn/wisenergy/common/utils/Constants.java
View file @
39d5bad9
...
...
@@ -109,7 +109,7 @@ public class Constants {
/**
* token相关
*/
public
final
static
String
PREFIX_TOKEN
=
"token
:
"
;
public
final
static
String
PREFIX_TOKEN
=
"token"
;
}
}
wisenergy-common/src/main/java/cn/wisenergy/common/utils/RedisKeyUtils.java
View file @
39d5bad9
...
...
@@ -27,9 +27,9 @@ public class RedisKeyUtils {
*/
public
static
String
formatKeyWithPrefix
(
String
...
args
){
if
(
args
!=
null
&&
args
.
length
>
0
){
StringBuilder
key
=
new
StringBuilder
(
Constants
.
Redis
.
PREFIX
).
append
(
Constants
.
Connnector
.
UNDERLINE
);
StringBuilder
key
=
new
StringBuilder
(
Constants
.
Redis
.
PREFIX
).
append
(
Constants
.
Connnector
.
COLON
);
for
(
String
s:
args
){
key
.
append
(
s
).
append
(
Constants
.
Connnector
.
UNDERLINE
);
key
.
append
(
s
).
append
(
Constants
.
Connnector
.
COLON
);
}
return
key
.
toString
();
}
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/UserServiceImpl.java
View file @
39d5bad9
...
...
@@ -331,9 +331,9 @@ public class UserServiceImpl extends ServiceImpl<UsersMapper, User> implements U
@Override
public
int
logout
(
String
token
)
{
int
succ
=
0
;
String
key
=
RedisKeyUtils
.
formatKeyWithPrefix
(
token
);
redisUtils
.
delete
(
key
);
if
(
redisUtils
.
getValue
(
key
)
==
null
){
//
String key = RedisKeyUtils.formatKeyWithPrefix(token);
redisUtils
.
delete
(
token
);
if
(
redisUtils
.
getValue
(
token
)
==
null
){
succ
=
1
;
}
return
succ
;
...
...
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/LoginController.java
View file @
39d5bad9
...
...
@@ -193,28 +193,28 @@ public class LoginController {
/**
* 退出登录
*
* @param token
* @param
* @return
*/
@ApiOperation
(
value
=
"退出登录"
,
produces
=
"application/json"
,
notes
=
"退出登录"
)
@ApiImplicitParam
(
paramType
=
"header"
,
name
=
"token"
,
value
=
"用户token"
,
required
=
true
,
dataType
=
"String"
)
@PostMapping
(
"/logout"
)
public
Result
logout
(
String
token
)
{
log
.
info
(
"退出登录"
);
Result
result
=
ResultUtils
.
returnFail
();
// String token = request.getHeader("token");HttpServletRequest request
String
key
=
RedisKeyUtils
.
formatKeyWithPrefix
(
token
);
if
(
redisUtils
.
getValue
(
key
)
==
null
)
{
log
.
info
(
"要退出登录的用户未登录"
);
return
ResultUtils
.
returnResult
(
ResultEnum
.
FILE_NOT_LOGIN
);
}
int
succ
=
usersService
.
logout
(
token
);
if
(
succ
>
0
)
{
result
=
ResultUtils
.
returnSuccess
();
public
Result
logout
(
HttpServletRequest
request
)
{
log
.
info
(
"退出登录"
);
Result
result
=
ResultUtils
.
returnFail
();
String
token
=
request
.
getHeader
(
"token"
);
String
key
=
RedisKeyUtils
.
formatKeyWithPrefix
(
Constants
.
Redis
.
PREFIX_TOKEN
,
token
);
if
(
redisUtils
.
getValue
(
key
)
==
null
){
log
.
info
(
"要退出登录的用户未登录"
);
return
ResultUtils
.
returnResult
(
ResultEnum
.
FILE_NOT_LOGIN
);
}
int
succ
=
usersService
.
logout
(
token
);
if
(
succ
>
0
)
{
result
=
ResultUtils
.
returnSuccess
();
}
return
result
;
}
return
result
;
}
}
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