|
@@ -0,0 +1,33 @@
|
|
|
+package com.fjhx.common.utils;
|
|
|
+
|
|
|
+import com.ruoyi.common.core.domain.BasePo;
|
|
|
+import com.ruoyi.common.utils.SecurityUtils;
|
|
|
+import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
|
+import com.ruoyi.system.utils.UserUtil;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.function.Function;
|
|
|
+
|
|
|
+public class AuthorityUtils {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * OA相关模块财务特殊权限
|
|
|
+ */
|
|
|
+ public static <V> void cofAuthority(String alias, Function<V, Long> getCompanyIdFun, IWrapper<V> wrapper) {
|
|
|
+ //权限过滤 财务看全部
|
|
|
+ List<String> userRoleKeys = UserUtil.getUserRoleKeys(SecurityUtils.getUserId());
|
|
|
+ if (!userRoleKeys.contains("cfo")) {
|
|
|
+ //非财务 看本公司
|
|
|
+ wrapper.in(alias, getCompanyIdFun, SecurityUtils.getCompanyIds());
|
|
|
+ //且 自己以及下级角色用户的数据
|
|
|
+ List<Long> uidList = new ArrayList<>();
|
|
|
+ //自己的数据
|
|
|
+ uidList.add(SecurityUtils.getUserId());
|
|
|
+ //下级角色用户数据
|
|
|
+ uidList.addAll(UserUtil.getUserIdsByRoleKeys(UserUtil.getUserRoleAndChildRoleKeys(SecurityUtils.getUserId()), SecurityUtils.getCompanyId()));
|
|
|
+
|
|
|
+ wrapper.in(alias, BasePo::getCreateUser, uidList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|