Преглед изворни кода

集团版第一次

release_toaliyun_real
xhxu пре 5 година
родитељ
комит
a96390fee8
4 измењених фајлова са 28 додато и 13 уклоњено
  1. +16
    -9
      mallinkAdmin/src/main/java/com/iformall/controller/base/BaseController.java
  2. +9
    -3
      mallinkAdmin/src/main/java/com/iformall/controller/sys/HomeController.java
  3. +2
    -0
      mallinkAdmin/src/main/java/com/iformall/shiro/UserSession.java
  4. +1
    -1
      mybatis-multi-tenancy/src/main/java/com/iformall/plugin/MultiTenancy.java

+ 16
- 9
mallinkAdmin/src/main/java/com/iformall/controller/base/BaseController.java Прегледај датотеку

@@ -7,8 +7,10 @@ import java.util.Date;

import com.iformall.domain.po.MallUserInfo;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.enums.EnumGroupSupport;
import com.iformall.shiro.UserSession;
import com.iformall.utils.IPUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.springframework.web.bind.WebDataBinder;
@@ -53,24 +55,29 @@ public class BaseController {
return userId;
}
@Deprecated
public String getTenantId(){
String tenantId = (String)SecurityUtils.getSubject().getSession().getAttribute(UserSession.tenantId);
return tenantId;
}
// @Deprecated
// public String getTenantId(){
// String tenantId = (String)SecurityUtils.getSubject().getSession().getAttribute(UserSession.tenantId);
// return tenantId;
// }

/**
* 返回租户信息
* @return
*/
public TenantEntity getTenantInfo(){
TenantEntity tenantEntity = new TenantEntity();
Session session = SecurityUtils.getSubject().getSession();
String isParent = (String)session.getAttribute(UserSession.isParent);
String tenantId = (String)session.getAttribute(UserSession.tenantId);
String parentTenantId = (String)session.getAttribute(UserSession.parentTenantId);
TenantEntity tenantEntity = new TenantEntity(){{
setTenantId(tenantId);
setParentTenantId(parentTenantId);
}};
if(StringUtils.isNotBlank(isParent) && isParent.equalsIgnoreCase(EnumGroupSupport.SUPPORT.getCode().toString())){
tenantEntity.setTenantId(null);
tenantEntity.setParentTenantId(tenantId);
}else{
tenantEntity.setTenantId(tenantId);
tenantEntity.setParentTenantId(parentTenantId);
}
return tenantEntity;
}



+ 9
- 3
mallinkAdmin/src/main/java/com/iformall/controller/sys/HomeController.java Прегледај датотеку

@@ -161,6 +161,10 @@ public class HomeController extends BaseController {
Map map = new HashMap();
if (mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode()) &&
StringUtils.isBlank(info.getParentTenantId())) {

Session session = SecurityUtils.getSubject().getSession();
session.setAttribute(UserSession.isParent, EnumGroupSupport.SUPPORT.getCode());

// 集团用户获取子商场
List<WxMall> mallList = mallService.getSubByParentTenantId(info.getTenantId());
map.put("subMalls", JSON.toJSONString(mallList));
@@ -198,6 +202,7 @@ public class HomeController extends BaseController {
logger.debug(map.toString());

String tenantId = map.get("tenantId");
String subTenantId = map.get("subTenantId");
String parentTenantId = map.get("parentTenantId");

if (StringUtils.isBlank(tenantId)) {
@@ -207,10 +212,11 @@ public class HomeController extends BaseController {
MallUserInfo userInfo = getUser();
if (userInfo.getTenantId().equalsIgnoreCase(tenantId)) {
Session session = SecurityUtils.getSubject().getSession();
session.setAttribute(UserSession.tenantId, tenantId);
if (StringUtils.isNotBlank(parentTenantId)) {
session.setAttribute(UserSession.parentTenantId, parentTenantId);
if (StringUtils.isNotBlank(subTenantId)) {
session.setAttribute(UserSession.tenantId, subTenantId);
session.setAttribute(UserSession.parentTenantId, tenantId);
} else {
session.setAttribute(UserSession.tenantId, tenantId);
session.setAttribute(UserSession.parentTenantId, null);
}
}


+ 2
- 0
mallinkAdmin/src/main/java/com/iformall/shiro/UserSession.java Прегледај датотеку

@@ -10,4 +10,6 @@ public class UserSession {

public static String parentTenantId ="PARENT_TENANT_ID";

public static String isParent ="IS_PARENT";

}

+ 1
- 1
mybatis-multi-tenancy/src/main/java/com/iformall/plugin/MultiTenancy.java Прегледај датотеку

@@ -92,7 +92,7 @@ public class MultiTenancy implements Interceptor {
}

public Object intercept(Invocation invocation) throws Throwable {
if (getTenantInfo().getTenantId() != null) {
if (getTenantInfo().getTenantId() != null || getTenantInfo().getParentTenantId() != null) {
// 能从cookie或者session获取到tenantId
mod(invocation);
}


Loading…
Откажи
Сачувај