Commit 911b105e authored by 廖旭伟's avatar 廖旭伟

修改admin账号登陆时不在加载站点列表

parent 5473825a
...@@ -262,23 +262,14 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic ...@@ -262,23 +262,14 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
String busiDesc = "查询" + this.getModuleDesc(); String busiDesc = "查询" + this.getModuleDesc();
int code = 1; int code = 1;
try { try {
if(this.getCurUser().getId()==1){ if (CollectionUtils.isNotEmpty(query.getAreaCodeList())) {
List<SiteEntity> siteEntityList = new ArrayList<>(); List<SiteEntity> siteEntityList = query.getAreaCodeList().parallelStream().flatMap(areaId ->
SiteEntity siteEntity = new SiteEntity(); this.service.getFlatSitesByAreaCode(areaId, getContext()).stream()
siteEntity.setId(0l); ).distinct().collect(Collectors.toList());
siteEntity.setSiteName("无站点");
siteEntityList.add(siteEntity);
model.put("data", siteEntityList); model.put("data", siteEntityList);
}else { } else {
if (CollectionUtils.isNotEmpty(query.getAreaCodeList())) { List<SiteEntity> result = this.getService().find(query, context);
List<SiteEntity> siteEntityList = query.getAreaCodeList().parallelStream().flatMap(areaId -> model.put("data", result);
this.service.getFlatSitesByAreaCode(areaId, getContext()).stream()
).distinct().collect(Collectors.toList());
model.put("data", siteEntityList);
} else {
List<SiteEntity> result = this.getService().find(query, context);
model.put("data", result);
}
} }
model.put("message_info", busiDesc + "成功"); model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】"); this.recordSysLog(this.request, busiDesc + " 【成功】");
......
...@@ -2,6 +2,7 @@ package com.mortals.xhx.base.login.web; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.base.login.web;
import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.service.IAuthTokenService; import com.mortals.framework.service.IAuthTokenService;
...@@ -21,6 +22,7 @@ import com.mortals.xhx.module.menu.service.MenuService; ...@@ -21,6 +22,7 @@ import com.mortals.xhx.module.menu.service.MenuService;
import com.mortals.xhx.module.user.model.UserEntity; import com.mortals.xhx.module.user.model.UserEntity;
import com.mortals.xhx.module.user.service.UserService; import com.mortals.xhx.module.user.service.UserService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.ArrayStack;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
...@@ -72,24 +74,32 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi ...@@ -72,24 +74,32 @@ public class LoginController extends BaseCRUDJsonBodyMappingController<UserServi
List<MenuEntity> menuList = menuService.findTreeMenuByUser(userEntity); List<MenuEntity> menuList = menuService.findTreeMenuByUser(userEntity);
userEntity.setMenuList(menuList); userEntity.setMenuList(menuList);
data.put("user", userEntity); data.put("user", userEntity);
if(StringUtils.isNotEmpty(userEntity.getAreaCodes())){ if(this.getCurUser().getId()==1){
SitePdu sitePdu = new SitePdu(); JSONArray siteList = new JSONArray();
List<String> areaCodeList = Arrays.asList(userEntity.getAreaCodes().split(",")); JSONObject siteObject = new JSONObject();
sitePdu.setAreaCodeList(areaCodeList); siteObject.put("id",0);
String resp = apiModelFeign.getSitesByQuery(sitePdu); siteObject.put("siteName","无站点");
ApiResp<JSONObject> apiResp = JSON.parseObject(resp, ApiResp.class); siteList.add(siteObject);
if (apiResp.getCode() != YesNoEnum.YES.getValue()) { data.put("siteList", siteList);
throw new AppException("获取用户站点列表树数据失败:" + apiResp.getMsg()); }else {
} if(StringUtils.isNotEmpty(userEntity.getAreaCodes())){
if(apiResp.getData().get("data")!=null) { SitePdu sitePdu = new SitePdu();
data.put("siteList", apiResp.getData().get("data")); List<String> areaCodeList = Arrays.asList(userEntity.getAreaCodes().split(","));
sitePdu.setAreaCodeList(areaCodeList);
String resp = apiModelFeign.getSitesByQuery(sitePdu);
ApiResp<JSONObject> apiResp = JSON.parseObject(resp, ApiResp.class);
if (apiResp.getCode() != YesNoEnum.YES.getValue()) {
throw new AppException("获取用户站点列表树数据失败:" + apiResp.getMsg());
}
if(apiResp.getData().get("data")!=null) {
data.put("siteList", apiResp.getData().get("data"));
}else {
data.put("siteList", Collections.emptyList());
}
}else { }else {
data.put("siteList", Collections.emptyList()); data.put("siteList", Collections.emptyList());
} }
}else {
data.put("siteList", Collections.emptyList());
} }
recordSysLog(request, userEntity, "用户登录系统成功!"); recordSysLog(request, userEntity, "用户登录系统成功!");
ret.put(KEY_RESULT_DATA, data); ret.put(KEY_RESULT_DATA, data);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); ret.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment