账号切换实现
This commit is contained in:
@@ -67,15 +67,19 @@ public class MyStpLogic {
|
|||||||
public void switchTo(Long id, String account, Long shopId, String shopName, LoginType loginType, boolean isAdmin) {
|
public void switchTo(Long id, String account, Long shopId, String shopName, LoginType loginType, boolean isAdmin) {
|
||||||
StpLogic logic = getLogic();
|
StpLogic logic = getLogic();
|
||||||
long headId = logic.getLoginIdAsLong();
|
long headId = logic.getLoginIdAsLong();
|
||||||
|
|
||||||
|
logic.getSaTokenDao().set(splicingKeyTokenValue(logic.getTokenValue()), id.toString(), logic.getTokenTimeout());
|
||||||
SaSession session = logic.getSession();
|
SaSession session = logic.getSession();
|
||||||
|
if (session == null) {
|
||||||
|
logic.createLoginSession(id);
|
||||||
|
session = logic.getSession();
|
||||||
|
}
|
||||||
Object parentId1 = session.get("headId");
|
Object parentId1 = session.get("headId");
|
||||||
if (parentId1 == null) {
|
if (parentId1 == null) {
|
||||||
session.set("headId", headId);
|
session.set("headId", headId);
|
||||||
}
|
}
|
||||||
session.set("userId", id).set("isAdmin", isAdmin).set("isManager", loginType.equals(LoginType.MANAGER))
|
session.set("userId", id).set("isAdmin", isAdmin).set("isManager", loginType.equals(LoginType.MANAGER))
|
||||||
.set("loginType", loginType).set("account", account).set("shopId", shopId).set("shopName", shopName);
|
.set("loginType", loginType).set("account", account).set("shopId", shopId).set("shopName", shopName);
|
||||||
|
|
||||||
logic.getSaTokenDao().set(splicingKeyTokenValue(logic.getTokenValue()), id.toString(), logic.getTokenTimeout());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -193,7 +193,10 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
|||||||
throw new ApiNotPrintException("店铺信息不存在");
|
throw new ApiNotPrintException("店铺信息不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((headId != null && !shopInfo.getMainId().equals(headId)) || !shopInfo.getMainId().equals(shopId)) {
|
|
||||||
|
// 主店铺切换子店铺
|
||||||
|
if ((headId == null && !shopInfo.getMainId().equals(shopId)) || (!sysUser.getId().equals(headId) && shopInfo.getMainId() == null) ||
|
||||||
|
(headId != null && !sysUserId.equals(headId) && !shopInfo.getMainId().equals(headId))) {
|
||||||
throw new ApiNotPrintException("目标店铺非登录账号所有");
|
throw new ApiNotPrintException("目标店铺非登录账号所有");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user