Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
b1829ee8
Commit
b1829ee8
authored
Jan 06, 2022
by
李健华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改交换token验证
parent
3a676134
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
12 deletions
+23
-12
UserController.java
...n/quantgroup/xyqb/controller/external/UserController.java
+18
-11
SessionServiceImpl.java
...ntgroup/xyqb/service/session/impl/SessionServiceImpl.java
+5
-1
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/UserController.java
View file @
b1829ee8
...
...
@@ -550,21 +550,28 @@ public class UserController implements IBaseController {
headers
.
put
(
"qg-tenant-id"
,
tenantId
.
toString
());
parameters
.
put
(
"token"
,
token
);
String
resultStr
=
httpService
.
post
(
userHost
+
"/api/finance-gateway/finance-user/finance/tokenExchange"
,
headers
,
parameters
);
// 如果有返回值
if
(
resultStr
!=
null
)
{
try
{
String
resultStr
=
httpService
.
post
(
userHost
+
"/api/finance-gateway/finance-user/shop/tokenExchange"
,
headers
,
parameters
);
JsonResult
<
TokenExchange
>
tokenExchangeResult
=
JSONObject
.
parseObject
(
resultStr
,
new
TypeReference
<
JsonResult
<
TokenExchange
>>(){});
// 如果有返回值
TokenExchange
tokenExchange
=
tokenExchangeResult
.
getData
();
if
(
tokenExchange
!=
null
)
{
SessionValue
sessionValue
=
new
SessionValue
();
User
user
=
userService
.
findById
(
tokenExchange
.
getUserId
());
if
(
user
!=
null
)
{
LoginProperties
loginProperties
=
JSONObject
.
parseObject
(
tokenExchange
.
getLoginProperties
(),
LoginProperties
.
class
);
// 根据返回值生成token, 返回值包含user:session:token的值
sessionValue
.
setUser
(
user
);
sessionValue
.
setLoginProperties
(
loginProperties
);
sessionService
.
persistSessionExchange
(
token
,
sessionValue
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"请求金融卡包网关出错--{}"
,
e
.
getMessage
());
}
}
/**
...
...
src/main/java/cn/quantgroup/xyqb/service/session/impl/SessionServiceImpl.java
View file @
b1829ee8
...
...
@@ -14,6 +14,7 @@ import cn.quantgroup.xyqb.util.TenantUtil;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Caching
;
import
org.springframework.data.redis.core.RedisTemplate
;
...
...
@@ -37,6 +38,9 @@ public class SessionServiceImpl implements ISessionService {
@Resource
private
RedisTemplate
<
String
,
String
>
stringRedisTemplate
;
@Value
(
"${token.prefix}"
)
private
String
prefix
;
/**
* 更新session
* 用户信息存在,更新session中的最后访问时间,重新写入缓存.
...
...
@@ -123,7 +127,7 @@ public class SessionServiceImpl implements ISessionService {
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
SessionStruct
sessionStruct
=
new
SessionStruct
();
SessionValue
sessionValue
=
new
SessionValue
();
sessionStruct
.
setSid
(
"yxm-"
+
UUID
.
randomUUID
().
toString
());
sessionStruct
.
setSid
(
prefix
+
UUID
.
randomUUID
().
toString
());
sessionValue
.
setCreatedAt
(
now
);
sessionValue
.
setLastAccessTime
(
now
);
sessionValue
.
setUser
(
user
);
...
...
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