解决权限配置过滤的bug
This commit is contained in:
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.jsh.erp.constants.ExceptionConstants;
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.datasource.entities.App;
|
import com.jsh.erp.datasource.entities.App;
|
||||||
|
import com.jsh.erp.datasource.entities.User;
|
||||||
import com.jsh.erp.datasource.entities.UserBusiness;
|
import com.jsh.erp.datasource.entities.UserBusiness;
|
||||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||||
import com.jsh.erp.service.app.AppService;
|
import com.jsh.erp.service.app.AppService;
|
||||||
@@ -12,12 +13,14 @@ import com.jsh.erp.utils.BaseResponseInfo;
|
|||||||
import com.jsh.erp.utils.FileUtils;
|
import com.jsh.erp.utils.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
@@ -29,6 +32,9 @@ import java.util.Properties;
|
|||||||
public class AppController {
|
public class AppController {
|
||||||
private Logger logger = LoggerFactory.getLogger(AppController.class);
|
private Logger logger = LoggerFactory.getLogger(AppController.class);
|
||||||
|
|
||||||
|
@Value("${mybatis-plus.status}")
|
||||||
|
private String mybatisPlusStatus;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private AppService appService;
|
private AppService appService;
|
||||||
|
|
||||||
@@ -157,7 +163,7 @@ public class AppController {
|
|||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
JSONArray arr = new JSONArray();
|
JSONArray arr = new JSONArray();
|
||||||
try {
|
try {
|
||||||
List<App> dataList = appService.findRoleAPP();
|
List<App> dataListApp = appService.findRoleAPP();
|
||||||
//开始拼接json数据
|
//开始拼接json数据
|
||||||
JSONObject outer = new JSONObject();
|
JSONObject outer = new JSONObject();
|
||||||
outer.put("id", 1);
|
outer.put("id", 1);
|
||||||
@@ -165,26 +171,48 @@ public class AppController {
|
|||||||
outer.put("state", "open");
|
outer.put("state", "open");
|
||||||
//存放数据json数组
|
//存放数据json数组
|
||||||
JSONArray dataArray = new JSONArray();
|
JSONArray dataArray = new JSONArray();
|
||||||
if (null != dataList) {
|
if (null != dataListApp) {
|
||||||
for (App app : dataList) {
|
//根据条件从列表里面移除"系统管理"
|
||||||
if(!("系统管理").equals(app.getName())) {
|
List<App> dataList = new ArrayList<App>();
|
||||||
JSONObject item = new JSONObject();
|
for (App appOne : dataListApp) {
|
||||||
item.put("id", app.getId());
|
if(("open").equals(mybatisPlusStatus)){
|
||||||
item.put("text", app.getName());
|
//从session中获取租户id
|
||||||
//勾选判断1
|
String loginName = null;
|
||||||
Boolean flag = false;
|
Object userInfo = request.getSession().getAttribute("user");
|
||||||
try {
|
if(userInfo != null) {
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + app.getId().toString() + "]");
|
User user = (User) userInfo;
|
||||||
} catch (Exception e) {
|
loginName = user.getLoginame();
|
||||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的应用:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
|
||||||
}
|
}
|
||||||
if (flag == true) {
|
if(("admin").equals(loginName)) {
|
||||||
item.put("checked", true);
|
dataList.add(appOne);
|
||||||
|
} else {
|
||||||
|
if(!("系统管理").equals(appOne.getName())) {
|
||||||
|
dataList.add(appOne);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//结束
|
} else {
|
||||||
dataArray.add(item);
|
dataList.add(appOne);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//筛选应用列表
|
||||||
|
for (App app : dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
item.put("id", app.getId());
|
||||||
|
item.put("text", app.getName());
|
||||||
|
//勾选判断1
|
||||||
|
Boolean flag = false;
|
||||||
|
try {
|
||||||
|
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + app.getId().toString() + "]");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的应用:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||||
|
}
|
||||||
|
if (flag == true) {
|
||||||
|
item.put("checked", true);
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
outer.put("children", dataArray);
|
outer.put("children", dataArray);
|
||||||
arr.add(outer);
|
arr.add(outer);
|
||||||
|
|||||||
@@ -4,18 +4,21 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.jsh.erp.constants.ExceptionConstants;
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.datasource.entities.Functions;
|
import com.jsh.erp.datasource.entities.Functions;
|
||||||
|
import com.jsh.erp.datasource.entities.User;
|
||||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||||
import com.jsh.erp.service.functions.FunctionsService;
|
import com.jsh.erp.service.functions.FunctionsService;
|
||||||
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
import com.jsh.erp.service.userBusiness.UserBusinessService;
|
||||||
import com.jsh.erp.utils.BaseResponseInfo;
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,6 +29,9 @@ import java.util.List;
|
|||||||
public class FunctionsController {
|
public class FunctionsController {
|
||||||
private Logger logger = LoggerFactory.getLogger(FunctionsController.class);
|
private Logger logger = LoggerFactory.getLogger(FunctionsController.class);
|
||||||
|
|
||||||
|
@Value("${mybatis-plus.status}")
|
||||||
|
private String mybatisPlusStatus;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private FunctionsService functionsService;
|
private FunctionsService functionsService;
|
||||||
|
|
||||||
@@ -121,7 +127,7 @@ public class FunctionsController {
|
|||||||
HttpServletRequest request) {
|
HttpServletRequest request) {
|
||||||
JSONArray arr = new JSONArray();
|
JSONArray arr = new JSONArray();
|
||||||
try {
|
try {
|
||||||
List<Functions> dataList = functionsService.findRoleFunctions("0");
|
List<Functions> dataListFun = functionsService.findRoleFunctions("0");
|
||||||
//开始拼接json数据
|
//开始拼接json数据
|
||||||
JSONObject outer = new JSONObject();
|
JSONObject outer = new JSONObject();
|
||||||
outer.put("id", 1);
|
outer.put("id", 1);
|
||||||
@@ -129,108 +135,130 @@ public class FunctionsController {
|
|||||||
outer.put("state", "open");
|
outer.put("state", "open");
|
||||||
//存放数据json数组
|
//存放数据json数组
|
||||||
JSONArray dataArray = new JSONArray();
|
JSONArray dataArray = new JSONArray();
|
||||||
if (null != dataList) {
|
if (null != dataListFun) {
|
||||||
|
//根据条件从列表里面移除"系统管理"
|
||||||
|
List<Functions> dataList = new ArrayList<Functions>();
|
||||||
|
for (Functions fun : dataListFun) {
|
||||||
|
if(("open").equals(mybatisPlusStatus)){
|
||||||
|
//从session中获取租户id
|
||||||
|
String loginName = null;
|
||||||
|
Object userInfo = request.getSession().getAttribute("user");
|
||||||
|
if(userInfo != null) {
|
||||||
|
User user = (User) userInfo;
|
||||||
|
loginName = user.getLoginame();
|
||||||
|
}
|
||||||
|
if(("admin").equals(loginName)) {
|
||||||
|
dataList.add(fun);
|
||||||
|
} else {
|
||||||
|
if(!("系统管理").equals(fun.getName())) {
|
||||||
|
dataList.add(fun);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dataList.add(fun);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//筛选功能列表
|
||||||
for (Functions functions : dataList) {
|
for (Functions functions : dataList) {
|
||||||
if(!("系统管理").equals(functions.getName())) {
|
JSONObject item = new JSONObject();
|
||||||
JSONObject item = new JSONObject();
|
item.put("id", functions.getId());
|
||||||
item.put("id", functions.getId());
|
item.put("text", functions.getName());
|
||||||
item.put("text", functions.getName());
|
|
||||||
|
|
||||||
//勾选判断1
|
//勾选判断1
|
||||||
Boolean flag = false;
|
Boolean flag = false;
|
||||||
try {
|
try {
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions.getId().toString() + "]");
|
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions.getId().toString() + "]");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||||
}
|
}
|
||||||
if (flag == true) {
|
if (flag == true) {
|
||||||
item.put("checked", true);
|
item.put("checked", true);
|
||||||
}
|
}
|
||||||
//结束
|
//结束
|
||||||
|
|
||||||
List<Functions> dataList1 = functionsService.findRoleFunctions(functions.getNumber());
|
List<Functions> dataList1 = functionsService.findRoleFunctions(functions.getNumber());
|
||||||
JSONArray dataArray1 = new JSONArray();
|
JSONArray dataArray1 = new JSONArray();
|
||||||
if (null != dataList1) {
|
if (null != dataList1) {
|
||||||
|
|
||||||
for (Functions functions1 : dataList1) {
|
for (Functions functions1 : dataList1) {
|
||||||
item.put("state", "open"); //如果不为空,节点不展开
|
item.put("state", "open"); //如果不为空,节点不展开
|
||||||
JSONObject item1 = new JSONObject();
|
JSONObject item1 = new JSONObject();
|
||||||
item1.put("id", functions1.getId());
|
item1.put("id", functions1.getId());
|
||||||
item1.put("text", functions1.getName());
|
item1.put("text", functions1.getName());
|
||||||
|
|
||||||
//勾选判断2
|
//勾选判断2
|
||||||
//Boolean flag = false;
|
//Boolean flag = false;
|
||||||
try {
|
try {
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions1.getId().toString() + "]");
|
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions1.getId().toString() + "]");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||||
}
|
}
|
||||||
if (flag == true) {
|
if (flag == true) {
|
||||||
item1.put("checked", true);
|
item1.put("checked", true);
|
||||||
}
|
}
|
||||||
//结束
|
//结束
|
||||||
|
|
||||||
List<Functions> dataList2 = functionsService.findRoleFunctions(functions1.getNumber());
|
List<Functions> dataList2 = functionsService.findRoleFunctions(functions1.getNumber());
|
||||||
JSONArray dataArray2 = new JSONArray();
|
JSONArray dataArray2 = new JSONArray();
|
||||||
if (null != dataList2) {
|
if (null != dataList2) {
|
||||||
|
|
||||||
for (Functions functions2 : dataList2) {
|
for (Functions functions2 : dataList2) {
|
||||||
item1.put("state", "closed"); //如果不为空,节点不展开
|
item1.put("state", "closed"); //如果不为空,节点不展开
|
||||||
JSONObject item2 = new JSONObject();
|
JSONObject item2 = new JSONObject();
|
||||||
item2.put("id", functions2.getId());
|
item2.put("id", functions2.getId());
|
||||||
item2.put("text", functions2.getName());
|
item2.put("text", functions2.getName());
|
||||||
|
|
||||||
//勾选判断3
|
//勾选判断3
|
||||||
//Boolean flag = false;
|
//Boolean flag = false;
|
||||||
try {
|
try {
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions2.getId().toString() + "]");
|
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions2.getId().toString() + "]");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item2.put("checked", true);
|
|
||||||
}
|
|
||||||
//结束
|
|
||||||
|
|
||||||
List<Functions> dataList3 = functionsService.findRoleFunctions(functions2.getNumber());
|
|
||||||
JSONArray dataArray3 = new JSONArray();
|
|
||||||
if (null != dataList3) {
|
|
||||||
|
|
||||||
for (Functions functions3 : dataList3) {
|
|
||||||
item2.put("state", "closed"); //如果不为空,节点不展开
|
|
||||||
JSONObject item3 = new JSONObject();
|
|
||||||
item3.put("id", functions3.getId());
|
|
||||||
item3.put("text", functions3.getName());
|
|
||||||
|
|
||||||
//勾选判断4
|
|
||||||
//Boolean flag = false;
|
|
||||||
try {
|
|
||||||
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions3.getId().toString() + "]");
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
|
||||||
}
|
|
||||||
if (flag == true) {
|
|
||||||
item3.put("checked", true);
|
|
||||||
}
|
|
||||||
//结束
|
|
||||||
|
|
||||||
dataArray3.add(item3);
|
|
||||||
item2.put("children", dataArray3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dataArray2.add(item2);
|
|
||||||
item1.put("children", dataArray2);
|
|
||||||
}
|
}
|
||||||
}
|
if (flag == true) {
|
||||||
|
item2.put("checked", true);
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
|
||||||
dataArray1.add(item1);
|
List<Functions> dataList3 = functionsService.findRoleFunctions(functions2.getNumber());
|
||||||
item.put("children", dataArray1);
|
JSONArray dataArray3 = new JSONArray();
|
||||||
|
if (null != dataList3) {
|
||||||
|
|
||||||
|
for (Functions functions3 : dataList3) {
|
||||||
|
item2.put("state", "closed"); //如果不为空,节点不展开
|
||||||
|
JSONObject item3 = new JSONObject();
|
||||||
|
item3.put("id", functions3.getId());
|
||||||
|
item3.put("text", functions3.getName());
|
||||||
|
|
||||||
|
//勾选判断4
|
||||||
|
//Boolean flag = false;
|
||||||
|
try {
|
||||||
|
flag = userBusinessService.checkIsUserBusinessExist(type, keyId, "[" + functions3.getId().toString() + "]");
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error(">>>>>>>>>>>>>>>>>设置角色对应的功能:类型" + type + " KeyId为: " + keyId + " 存在异常!");
|
||||||
|
}
|
||||||
|
if (flag == true) {
|
||||||
|
item3.put("checked", true);
|
||||||
|
}
|
||||||
|
//结束
|
||||||
|
|
||||||
|
dataArray3.add(item3);
|
||||||
|
item2.put("children", dataArray3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dataArray2.add(item2);
|
||||||
|
item1.put("children", dataArray2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dataArray1.add(item1);
|
||||||
|
item.put("children", dataArray1);
|
||||||
}
|
}
|
||||||
dataArray.add(item);
|
|
||||||
}
|
}
|
||||||
|
dataArray.add(item);
|
||||||
}
|
}
|
||||||
outer.put("children", dataArray);
|
outer.put("children", dataArray);
|
||||||
arr.add(outer);
|
arr.add(outer);
|
||||||
|
|||||||
Reference in New Issue
Block a user