店铺切换
This commit is contained in:
@@ -35,7 +35,6 @@ public class MyStpLogic {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public enum LoginType {
|
||||
MANAGER, USER, STAFF
|
||||
}
|
||||
@@ -71,26 +70,29 @@ public class MyStpLogic {
|
||||
*/
|
||||
public void switchTo(boolean isMain, Long id, String account, Long shopId, String shopName, LoginType loginType, boolean isAdmin) {
|
||||
StpLogic logic = getLogic();
|
||||
long headId = logic.getLoginIdAsLong();
|
||||
// 设置主店id
|
||||
Object mainShopId = logic.getSession().get("mainShopId");
|
||||
SaSession session = logic.getSession();
|
||||
Object parentId1 = session.get("headShopId");
|
||||
logic.getSaTokenDao().set(splicingKeyTokenValue(logic.getTokenValue()), id.toString(), logic.getTokenTimeout());
|
||||
session = logic.getSession();
|
||||
if (session == null) {
|
||||
logic.createLoginSession(id);
|
||||
session = logic.getSession();
|
||||
}
|
||||
// 主店没有headShopId
|
||||
if (!isMain && parentId1 == null) {
|
||||
session.set("headId", headId);
|
||||
}
|
||||
|
||||
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("isMainShop", isMain)
|
||||
.set("mainShopId", mainShopId);
|
||||
session.set("shopId", shopId).set("shopName", shopName);
|
||||
|
||||
// long headId = logic.getLoginIdAsLong();
|
||||
// // 设置主店id
|
||||
// Object mainShopId = logic.getSession().get("mainShopId");
|
||||
//
|
||||
// Object parentId1 = session.get("headShopId");
|
||||
// logic.getSaTokenDao().set(splicingKeyTokenValue(logic.getTokenValue()), id.toString(), logic.getTokenTimeout());
|
||||
// session = logic.getSession();
|
||||
// if (session == null) {
|
||||
// logic.createLoginSession(id);
|
||||
// session = logic.getSession();
|
||||
// }
|
||||
// // 主店没有headShopId
|
||||
// if (!isMain && parentId1 == null) {
|
||||
// session.set("headId", headId);
|
||||
// }
|
||||
//
|
||||
// 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("isMainShop", isMain)
|
||||
// .set("mainShopId", mainShopId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,10 +76,6 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
||||
return Map.of("code", captcha.toBase64(), "uuid", captchaKey);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(DateUtil.format(DateUtil.date(), "HHmm"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoginVO login(SysLoginDTO loginDTO, String platType) {
|
||||
Object code = redisService.get(RedisCst.LOGIN_CODE + loginDTO.uuid());
|
||||
@@ -208,8 +204,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
||||
Long headId = StpKit.USER.getHeadId();
|
||||
long shopId = StpKit.USER.getLoginIdAsLong();
|
||||
ShopInfo currentInfo = shopInfoService.getById(shopId);
|
||||
// if (headId != null && currentInfo.getIsHeadShop() != YesNoEnum.YES.value()) {
|
||||
if (currentInfo.getIsHeadShop() != YesNoEnum.YES.value()) {
|
||||
if (headId != null && currentInfo.getIsHeadShop() != YesNoEnum.YES.value()) {
|
||||
throw new CzgException("登录账号无权限切换");
|
||||
}
|
||||
|
||||
@@ -224,7 +219,7 @@ public class AuthorizationServiceImpl implements AuthorizationService {
|
||||
}
|
||||
|
||||
// 主店铺切换子店铺
|
||||
if (headId != null && !shopInfo.getMainId().equals(shopId)) {
|
||||
if (!shopInfo.getMainId().equals(shopId)) {
|
||||
throw new CzgException("目标店铺非登录账号所有");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user