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
a8221d51
Commit
a8221d51
authored
Apr 15, 2025
by
xuepeng.chang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
小程序 解绑 清除 小程序的登录状态
parent
782f6d1b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
AppletServiceImpl.java
...b/service/middleoffice/applet/impl/AppletServiceImpl.java
+18
-9
SessionServiceImpl.java
...ntgroup/xyqb/service/session/impl/SessionServiceImpl.java
+2
-2
No files found.
src/main/java/cn/quantgroup/xyqb/service/middleoffice/applet/impl/AppletServiceImpl.java
View file @
a8221d51
...
@@ -22,6 +22,7 @@ import cn.quantgroup.xyqb.service.session.impl.SessionServiceImpl;
...
@@ -22,6 +22,7 @@ import cn.quantgroup.xyqb.service.session.impl.SessionServiceImpl;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.util.StringUtils
;
import
cn.quantgroup.xyqb.util.StringUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.qiniu.util.Json
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -189,6 +190,7 @@ public class AppletServiceImpl implements IAppletService {
...
@@ -189,6 +190,7 @@ public class AppletServiceImpl implements IAppletService {
@Override
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
unbind
(
UnbindParam
unbindParam
)
{
public
boolean
unbind
(
UnbindParam
unbindParam
)
{
log
.
info
(
"微信解绑,unbindParam:{} "
,
JSON
.
toJSONString
(
unbindParam
));
// 获取当前用户绑定了对应的微信小程序
// 获取当前用户绑定了对应的微信小程序
List
<
WechatUserInfo
>
wechatUserInfoList
=
iWeChatUserRepository
.
findByUserIdAndAppNameAndAppIdAndTenantId
(
unbindParam
.
getUserId
(),
unbindParam
.
getAppName
(),
List
<
WechatUserInfo
>
wechatUserInfoList
=
iWeChatUserRepository
.
findByUserIdAndAppNameAndAppIdAndTenantId
(
unbindParam
.
getUserId
(),
unbindParam
.
getAppName
(),
unbindParam
.
getAppId
(),
unbindParam
.
getTenantId
());
unbindParam
.
getAppId
(),
unbindParam
.
getTenantId
());
...
@@ -205,15 +207,22 @@ public class AppletServiceImpl implements IAppletService {
...
@@ -205,15 +207,22 @@ public class AppletServiceImpl implements IAppletService {
wechatBindLogRepository
.
save
(
wechatBindLog
);
wechatBindLogRepository
.
save
(
wechatBindLog
);
}
}
// 删除微信关联记录后,清除微信渠道的登陆token
// 删除微信关联记录后,清除微信渠道的登陆token
if
(
org
.
apache
.
commons
.
lang3
.
StringUtils
.
isNotEmpty
(
unbindParam
.
getWechatChannelId
())){
// if(org.apache.commons.lang3.StringUtils.isNotEmpty(unbindParam.getWechatChannelId())){
List
<
String
>
wechatChannelIds
=
Arrays
.
stream
(
unbindParam
.
getWechatChannelId
().
split
(
","
)).
collect
(
Collectors
.
toList
());
// List<String> wechatChannelIds = Arrays.stream(unbindParam.getWechatChannelId().split(",")).collect(Collectors.toList());
for
(
String
wechatChannelId
:
wechatChannelIds
)
{
// for (String wechatChannelId : wechatChannelIds) {
LoginProperties
loginProperties
=
new
LoginProperties
(
1
,
Long
.
valueOf
(
wechatChannelId
),
unbindParam
.
getTenantId
());
// LoginProperties loginProperties = new LoginProperties(1, Long.valueOf(wechatChannelId), unbindParam.getTenantId());
sessionService
.
deleteWechatSession
(
unbindParam
.
getUserId
(),
loginProperties
,
unbindParam
.
getTenantId
());
// sessionService.deleteWechatSession(unbindParam.getUserId(),loginProperties,unbindParam.getTenantId());
log
.
info
(
"微信解绑成功,清除微信的登陆token,userId:{},wechatChannelId:{}"
,
unbindParam
.
getUserId
(),
wechatChannelId
);
// log.info("微信解绑成功,清除微信的登陆token,userId:{},wechatChannelId:{}", unbindParam.getUserId(),wechatChannelId);
}
// }
}
// }
log
.
info
(
"微信解绑成功,unbindParam:{} "
,
JSON
.
toJSONString
(
unbindParam
));
User
user
=
userService
.
findById
(
unbindParam
.
getUserId
(),
unbindParam
.
getTenantId
());
// 老的微信登录的时候用的是下边的方式,删除的时候也只能这么删
LoginProperties
loginProperties
=
LoginProperties
.
builder
()
.
createdFrom
(
user
.
getRegisteredFrom
())
.
tenantId
(
unbindParam
.
getTenantId
())
.
build
();
sessionService
.
deleteWechatSession
(
unbindParam
.
getUserId
(),
loginProperties
,
unbindParam
.
getTenantId
());
log
.
info
(
"微信解绑成功,清除微信的登陆token,userId:{},loginProperties:{}"
,
unbindParam
.
getUserId
(),
JSON
.
toJSONString
(
loginProperties
));
return
true
;
return
true
;
}
}
...
...
src/main/java/cn/quantgroup/xyqb/service/session/impl/SessionServiceImpl.java
View file @
a8221d51
...
@@ -435,8 +435,8 @@ public class SessionServiceImpl implements ISessionService {
...
@@ -435,8 +435,8 @@ public class SessionServiceImpl implements ISessionService {
public
void
deleteWechatSession
(
Long
userId
,
LoginProperties
loginProperties
,
Integer
tenantId
)
{
public
void
deleteWechatSession
(
Long
userId
,
LoginProperties
loginProperties
,
Integer
tenantId
)
{
String
key
=
generateLoginPropertiesKey
(
userId
,
loginProperties
,
tenantId
);
String
key
=
generateLoginPropertiesKey
(
userId
,
loginProperties
,
tenantId
);
String
token
=
stringRedisTemplate
.
opsForValue
().
get
(
key
);
String
token
=
stringRedisTemplate
.
opsForValue
().
get
(
key
);
log
.
info
(
"deleteWechatSession,通过用户获取token结果,token:{} , userId: {},loginProperties:{},tenantId:{}"
,
log
.
info
(
"deleteWechatSession,通过用户获取token结果,
key :{},
token:{} , userId: {},loginProperties:{},tenantId:{}"
,
token
,
userId
,
JSON
.
toJSONString
(
loginProperties
),
tenantId
);
key
,
token
,
userId
,
JSON
.
toJSONString
(
loginProperties
),
tenantId
);
deleteSession
(
token
,
tenantId
);
deleteSession
(
token
,
tenantId
);
}
}
...
...
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