数据权限新增 API 方式实现(适应 Cloud 环境,基础用户表与业务数据表跨库的情况)
This commit is contained in:
@@ -71,6 +71,8 @@ import com.jeesite.common.utils.excel.fieldtype.OfficeType;
|
|||||||
@Column(name="area_type", label="区域类型"),
|
@Column(name="area_type", label="区域类型"),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
// extFromKeys="dsfOfficeFrom, dsfCompanyFrom",
|
||||||
|
// extWhereKeys="dsfOfficeWhere, dsfCompanyWhere",
|
||||||
extWhereKeys="dsfOffice, dsfCompany",
|
extWhereKeys="dsfOffice, dsfCompany",
|
||||||
orderBy="a.user_weight DESC, a.update_date DESC"
|
orderBy="a.user_weight DESC, a.update_date DESC"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -4,8 +4,10 @@
|
|||||||
package com.jeesite.modules.sys.utils;
|
package com.jeesite.modules.sys.utils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.jeesite.common.collect.ListUtils;
|
import com.jeesite.common.collect.ListUtils;
|
||||||
|
import com.jeesite.common.collect.SetUtils;
|
||||||
import com.jeesite.common.lang.StringUtils;
|
import com.jeesite.common.lang.StringUtils;
|
||||||
import com.jeesite.common.utils.SpringUtils;
|
import com.jeesite.common.utils.SpringUtils;
|
||||||
import com.jeesite.modules.sys.entity.Company;
|
import com.jeesite.modules.sys.entity.Company;
|
||||||
@@ -155,6 +157,33 @@ public class EmpUtils {
|
|||||||
return list.toArray(new String[list.size()]);
|
return list.toArray(new String[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前员工所有机构编码,包括附属机构以及子机构(数据权限用)
|
||||||
|
* @author ThinkGem
|
||||||
|
*/
|
||||||
|
public static String[] getOfficeCodesAndChildren(){
|
||||||
|
Set<String> list = SetUtils.newLinkedHashSet();
|
||||||
|
Set<String> parentCodess = SetUtils.newHashSet();
|
||||||
|
Office currentOffice = getOffice();
|
||||||
|
list.add(currentOffice.getOfficeCode());
|
||||||
|
parentCodess.add(currentOffice.getParentCodes() + currentOffice.getOfficeCode() + ",");
|
||||||
|
// 添加附属机构
|
||||||
|
getEmployeeOfficeList().forEach(e -> {
|
||||||
|
list.add(e.getOfficeCode());
|
||||||
|
parentCodess.add(e.getParentCodes() + e.getOfficeCode() + ",");
|
||||||
|
});
|
||||||
|
// 查找并添加子机构
|
||||||
|
getOfficeAllList().forEach(e -> {
|
||||||
|
for (String parentCodes : parentCodess) {
|
||||||
|
if (e.getParentCodes().startsWith(parentCodes)) {
|
||||||
|
list.add(e.getOfficeCode());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return list.toArray(new String[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据机构类型,获取当前员工所有机构编码,包括附属机构(数据权限用)
|
* 根据机构类型,获取当前员工所有机构编码,包括附属机构(数据权限用)
|
||||||
* @author ThinkGem
|
* @author ThinkGem
|
||||||
@@ -265,6 +294,28 @@ public class EmpUtils {
|
|||||||
return companyList;
|
return companyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前员工所有公司编码,包括子公司(数据权限用)
|
||||||
|
* @author ThinkGem
|
||||||
|
*/
|
||||||
|
public static String[] getCompanyCodesAndChildren(){
|
||||||
|
Set<String> list = SetUtils.newLinkedHashSet();
|
||||||
|
Set<String> parentCodess = SetUtils.newHashSet();
|
||||||
|
Company currentCompany = getCompany();
|
||||||
|
list.add(currentCompany.getCompanyCode());
|
||||||
|
parentCodess.add(currentCompany.getParentCodes() + currentCompany.getCompanyCode() + ",");
|
||||||
|
// 查找并添加子公司
|
||||||
|
getCompanyAllList().forEach(e -> {
|
||||||
|
for (String parentCodes : parentCodess) {
|
||||||
|
if (e.getParentCodes().startsWith(parentCodes)) {
|
||||||
|
list.add(e.getCompanyCode());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return list.toArray(new String[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除指定用户缓存,不包括改用的SESSION缓存
|
* 清除指定用户缓存,不包括改用的SESSION缓存
|
||||||
* @author ThinkGem
|
* @author ThinkGem
|
||||||
|
|||||||
@@ -167,6 +167,12 @@ user:
|
|||||||
remarks: ""
|
remarks: ""
|
||||||
}]
|
}]
|
||||||
|
|
||||||
|
# 数据权限调试模式(会输出一些日志)
|
||||||
|
dataScopeDebug: false
|
||||||
|
|
||||||
|
# 数据权限使用 API 方式实现(适应 Cloud 环境,基础用户表与业务数据表跨库的情况)
|
||||||
|
dataScopeApiMode: false
|
||||||
|
|
||||||
# 管理功能的控制权限类型(1拥有的权限 2管理的权限)(v4.1.5+)
|
# 管理功能的控制权限类型(1拥有的权限 2管理的权限)(v4.1.5+)
|
||||||
adminCtrlPermi: 2
|
adminCtrlPermi: 2
|
||||||
|
|
||||||
@@ -188,9 +194,9 @@ role:
|
|||||||
#控制数据的类名: "指定一个静态类名,方便 ctrlDataAttrName 得到权限数据,如:当前机构编码、当前公司编码、当前行业编码等",
|
#控制数据的类名: "指定一个静态类名,方便 ctrlDataAttrName 得到权限数据,如:当前机构编码、当前公司编码、当前行业编码等",
|
||||||
ctrlDataClass: "com.jeesite.modules.sys.utils.EmpUtils",
|
ctrlDataClass: "com.jeesite.modules.sys.utils.EmpUtils",
|
||||||
#控制数据的类名下的属性名 : "可看做 ctrlDataClass 下的 get 方法,如:EmpUtils.getOfficeCodes(),支持返回字符串或字符串数组类型",
|
#控制数据的类名下的属性名 : "可看做 ctrlDataClass 下的 get 方法,如:EmpUtils.getOfficeCodes(),支持返回字符串或字符串数组类型",
|
||||||
ctrlDataAttrName: "officeCodes",
|
ctrlDataAttrName: "officeCodesAndChildren",
|
||||||
#控制数据的所有上级编码 : "用于控制数据为树表的情况,为数组时,必须与 ctrlDataAttrName 返回的长度相同,不是树表设置为空",
|
#控制数据的所有上级编码 : "用于控制数据为树表的情况,为数组时,必须与 ctrlDataAttrName 返回的长度相同,不是树表设置为空",
|
||||||
ctrlDataParentCodesAttrName: "officeParentCodess"
|
ctrlDataParentCodesAttrName: ""
|
||||||
},
|
},
|
||||||
Company: {
|
Company: {
|
||||||
ctrlTypeClass: "NONE"
|
ctrlTypeClass: "NONE"
|
||||||
|
|||||||
Reference in New Issue
Block a user