Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gs1-office-web-sit
Overview
Overview
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
吴迪
gs1-office-web-sit
Commits
aaff4e73
Commit
aaff4e73
authored
Dec 13, 2021
by
吴迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【新增】区分前后端token
parent
491e730e
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
2 deletions
+41
-2
LogLoginServiceImpl.java
...fice/modules/manage/service/impl/LogLoginServiceImpl.java
+1
-1
SysUserTokenService.java
...va/io/office/modules/sys/service/SysUserTokenService.java
+4
-0
SysUserTokenServiceImpl.java
...ice/modules/sys/service/impl/SysUserTokenServiceImpl.java
+36
-1
No files found.
src/main/java/io/office/modules/manage/service/impl/LogLoginServiceImpl.java
View file @
aaff4e73
...
@@ -124,7 +124,7 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
...
@@ -124,7 +124,7 @@ public class LogLoginServiceImpl extends ServiceImpl<LogLoginDao, LogLoginEntity
jsonObject
.
put
(
"isQY"
,
isQY
);
jsonObject
.
put
(
"isQY"
,
isQY
);
jsonObject
.
put
(
"isXT"
,
isXT
);
jsonObject
.
put
(
"isXT"
,
isXT
);
jsonObject
.
put
(
"id"
,
id
);
jsonObject
.
put
(
"id"
,
id
);
R
token
=
sysUserTokenService
.
createToken
(
id
);
//将token信息存入 数据库
R
token
=
sysUserTokenService
.
createToken
(
"qianduan_"
,
id
);
//将token信息存入 数据库
Object
token1
=
token
.
get
(
"token"
);
Object
token1
=
token
.
get
(
"token"
);
jsonObject
.
put
(
"token"
,
token1
);
jsonObject
.
put
(
"token"
,
token1
);
return
jsonObject
;
return
jsonObject
;
...
...
src/main/java/io/office/modules/sys/service/SysUserTokenService.java
View file @
aaff4e73
...
@@ -25,6 +25,10 @@ public interface SysUserTokenService extends IService<SysUserTokenEntity> {
...
@@ -25,6 +25,10 @@ public interface SysUserTokenService extends IService<SysUserTokenEntity> {
*/
*/
R
createToken
(
long
userId
);
R
createToken
(
long
userId
);
R
createToken
(
String
flag
,
long
userId
);
/**
/**
* 退出,修改token值
* 退出,修改token值
* @param userId 用户ID
* @param userId 用户ID
...
...
src/main/java/io/office/modules/sys/service/impl/SysUserTokenServiceImpl.java
View file @
aaff4e73
...
@@ -28,7 +28,42 @@ public class SysUserTokenServiceImpl extends ServiceImpl<SysUserTokenDao, SysUse
...
@@ -28,7 +28,42 @@ public class SysUserTokenServiceImpl extends ServiceImpl<SysUserTokenDao, SysUse
@Override
@Override
public
R
createToken
(
long
userId
)
{
public
R
createToken
(
long
userId
)
{
//生成一个token
//生成一个token
String
token
=
"qianduan_"
+
TokenGenerator
.
generateValue
();
String
token
=
TokenGenerator
.
generateValue
();
//当前时间
Date
now
=
new
Date
();
//过期时间
Date
expireTime
=
new
Date
(
now
.
getTime
()
+
EXPIRE
*
1000
);
//判断是否生成过token
SysUserTokenEntity
tokenEntity
=
this
.
getById
(
userId
);
if
(
tokenEntity
==
null
){
tokenEntity
=
new
SysUserTokenEntity
();
tokenEntity
.
setUserId
(
userId
);
tokenEntity
.
setToken
(
token
);
tokenEntity
.
setUpdateTime
(
now
);
tokenEntity
.
setExpireTime
(
expireTime
);
//保存token
this
.
save
(
tokenEntity
);
}
else
{
tokenEntity
.
setToken
(
token
);
tokenEntity
.
setUpdateTime
(
now
);
tokenEntity
.
setExpireTime
(
expireTime
);
//更新token
this
.
updateById
(
tokenEntity
);
}
R
r
=
R
.
ok
().
put
(
"token"
,
token
).
put
(
"expire"
,
EXPIRE
);
return
r
;
}
@Override
public
R
createToken
(
String
flag
,
long
userId
)
{
//生成一个token
String
token
=
flag
+
TokenGenerator
.
generateValue
();
//当前时间
//当前时间
Date
now
=
new
Date
();
Date
now
=
new
Date
();
...
...
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