|
@@ -5,15 +5,18 @@ import cn.hutool.core.collection.CollectionUtil;
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
|
+import com.citu.framework.common.enums.CommonStatusEnum;
|
|
import com.citu.framework.common.util.collection.CollectionUtils;
|
|
import com.citu.framework.common.util.collection.CollectionUtils;
|
|
import com.citu.framework.datapermission.core.annotation.DataPermission;
|
|
import com.citu.framework.datapermission.core.annotation.DataPermission;
|
|
import com.citu.module.menduner.system.dal.dataobject.enterprise.EnterpriseUserBindDO;
|
|
import com.citu.module.menduner.system.dal.dataobject.enterprise.EnterpriseUserBindDO;
|
|
|
|
+import com.citu.module.menduner.system.dal.dataobject.permission.MdeMenuDO;
|
|
import com.citu.module.menduner.system.dal.dataobject.permission.MdeRoleDO;
|
|
import com.citu.module.menduner.system.dal.dataobject.permission.MdeRoleDO;
|
|
|
|
+import com.citu.module.menduner.system.dal.dataobject.permission.MdeRoleMenuDO;
|
|
import com.citu.module.menduner.system.dal.dataobject.permission.MdeUserRoleDO;
|
|
import com.citu.module.menduner.system.dal.dataobject.permission.MdeUserRoleDO;
|
|
import com.citu.module.menduner.system.dal.dataobject.user.MdeUserDO;
|
|
import com.citu.module.menduner.system.dal.dataobject.user.MdeUserDO;
|
|
|
|
+import com.citu.module.menduner.system.dal.mysql.permission.MdeRoleMenuMapper;
|
|
import com.citu.module.menduner.system.dal.mysql.permission.MdeUserRoleMapper;
|
|
import com.citu.module.menduner.system.dal.mysql.permission.MdeUserRoleMapper;
|
|
import com.citu.module.menduner.system.dal.redis.RedisKeyConstants;
|
|
import com.citu.module.menduner.system.dal.redis.RedisKeyConstants;
|
|
-import com.citu.module.menduner.system.enums.MendunerStatusEnum;
|
|
|
|
import com.citu.module.menduner.system.enums.permission.MdeDefaultRoleEnum;
|
|
import com.citu.module.menduner.system.enums.permission.MdeDefaultRoleEnum;
|
|
import com.citu.module.menduner.system.service.enterprise.EnterpriseService;
|
|
import com.citu.module.menduner.system.service.enterprise.EnterpriseService;
|
|
import com.citu.module.menduner.system.service.enterprise.bind.EnterpriseUserBindService;
|
|
import com.citu.module.menduner.system.service.enterprise.bind.EnterpriseUserBindService;
|
|
@@ -28,12 +31,10 @@ import org.springframework.cache.annotation.Cacheable;
|
|
import org.springframework.cache.annotation.Caching;
|
|
import org.springframework.cache.annotation.Caching;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
-import java.util.Collection;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Objects;
|
|
|
|
-import java.util.Set;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
import static com.citu.framework.common.util.collection.CollectionUtils.convertSet;
|
|
import static com.citu.framework.common.util.collection.CollectionUtils.convertSet;
|
|
import static com.citu.framework.common.util.json.JsonUtils.toJsonString;
|
|
import static com.citu.framework.common.util.json.JsonUtils.toJsonString;
|
|
@@ -48,11 +49,18 @@ import static com.citu.framework.common.util.json.JsonUtils.toJsonString;
|
|
public class MdePermissionServiceImpl implements MdePermissionService {
|
|
public class MdePermissionServiceImpl implements MdePermissionService {
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
- private MdeUserRoleMapper mdeUserRoleMapper;
|
|
|
|
|
|
+ private MdeRoleMenuMapper roleMenuMapper;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ private MdeUserRoleMapper userRoleMapper;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
@Lazy
|
|
@Lazy
|
|
- private MdeRoleService mdeRoleService;
|
|
|
|
|
|
+ private MdeRoleService roleService;
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ @Lazy
|
|
|
|
+ private MdeMenuService menuService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
@Lazy
|
|
@Lazy
|
|
@@ -79,35 +87,42 @@ public class MdePermissionServiceImpl implements MdePermissionService {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 情况一:遍历判断每个权限,如果有一满足,说明有权限
|
|
|
|
+ for (String permission : permissions) {
|
|
|
|
+ if (hasAnyPermission(roles, permission)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
// 情况二:如果是超管,也说明有权限
|
|
// 情况二:如果是超管,也说明有权限
|
|
- return mdeRoleService.hasAnySuperAdmin(convertSet(roles, MdeRoleDO::getId));
|
|
|
|
|
|
+ return roleService.hasAnySuperAdmin(convertSet(roles, MdeRoleDO::getId));
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
- * 获得自身的代理对象,解决 AOP 生效问题
|
|
|
|
|
|
+ * 判断指定角色,是否拥有该 permission 权限
|
|
*
|
|
*
|
|
- * @return 自己
|
|
|
|
|
|
+ * @param roles 指定角色数组
|
|
|
|
+ * @param permission 权限标识
|
|
|
|
+ * @return 是否拥有
|
|
*/
|
|
*/
|
|
- private MdePermissionServiceImpl getSelf() {
|
|
|
|
- return SpringUtil.getBean(getClass());
|
|
|
|
- }
|
|
|
|
|
|
+ private boolean hasAnyPermission(List<MdeRoleDO> roles, String permission) {
|
|
|
|
+ List<Long> menuIds = menuService.getMenuIdListByPermissionFromCache(permission);
|
|
|
|
+ // 采用严格模式,如果权限找不到对应的 Menu 的话,也认为没有权限
|
|
|
|
+ if (CollUtil.isEmpty(menuIds)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
|
- * 获得用户拥有的角色,并且这些角色是开启状态的
|
|
|
|
- *
|
|
|
|
- * @param userId 用户编号
|
|
|
|
- * @return 用户拥有的角色
|
|
|
|
- */
|
|
|
|
- @VisibleForTesting
|
|
|
|
- List<MdeRoleDO> getEnableUserRoleListByUserIdFromCache(Long userId) {
|
|
|
|
- // 获得用户拥有的角色编号
|
|
|
|
- Set<Long> roleIds = getSelf().getUserRoleIdListByUserIdFromCache(userId);
|
|
|
|
- // 获得角色数组,并移除被禁用的
|
|
|
|
- List<MdeRoleDO> roles = mdeRoleService.getRoleListFromCache(roleIds);
|
|
|
|
- roles.removeIf(role -> !MendunerStatusEnum.ENABLE.getStatus().equals(role.getStatus()));
|
|
|
|
- return roles;
|
|
|
|
|
|
+ // 判断是否有权限
|
|
|
|
+ Set<Long> roleIds = convertSet(roles, MdeRoleDO::getId);
|
|
|
|
+ for (Long menuId : menuIds) {
|
|
|
|
+ // 获得拥有该菜单的角色编号集合
|
|
|
|
+ Set<Long> menuRoleIds = getSelf().getMenuRoleIdListByMenuIdFromCache(menuId);
|
|
|
|
+ // 如果有交集,说明有权限
|
|
|
|
+ if (CollUtil.containsAny(menuRoleIds, roleIds)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -128,12 +143,86 @@ public class MdePermissionServiceImpl implements MdePermissionService {
|
|
return CollUtil.containsAny(userRoles, Sets.newHashSet(roles));
|
|
return CollUtil.containsAny(userRoles, Sets.newHashSet(roles));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // ========== 角色-菜单的相关方法 ==========
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
|
|
|
+ @Caching(evict = {
|
|
|
|
+ @CacheEvict(value = RedisKeyConstants.MDE_MENU_ROLE_ID_LIST,
|
|
|
|
+ allEntries = true),
|
|
|
|
+ @CacheEvict(value = RedisKeyConstants.MDE_PERMISSION_MENU_ID_LIST,
|
|
|
|
+ allEntries = true) // allEntries 清空所有缓存,主要一次更新涉及到的 menuIds 较多,反倒批量会更快
|
|
|
|
+ })
|
|
|
|
+ public void assignRoleMenu(Long roleId, Set<Long> menuIds) {
|
|
|
|
+ // 获得角色拥有菜单编号
|
|
|
|
+ Set<Long> dbMenuIds = convertSet(roleMenuMapper.selectListByRoleId(roleId), MdeRoleMenuDO::getMenuId);
|
|
|
|
+ // 计算新增和删除的菜单编号
|
|
|
|
+ Set<Long> menuIdList = CollUtil.emptyIfNull(menuIds);
|
|
|
|
+ Collection<Long> createMenuIds = CollUtil.subtract(menuIdList, dbMenuIds);
|
|
|
|
+ Collection<Long> deleteMenuIds = CollUtil.subtract(dbMenuIds, menuIdList);
|
|
|
|
+ // 执行新增和删除。对于已经授权的菜单,不用做任何处理
|
|
|
|
+ if (CollUtil.isNotEmpty(createMenuIds)) {
|
|
|
|
+ roleMenuMapper.insertBatch(CollectionUtils.convertList(createMenuIds, menuId -> {
|
|
|
|
+ MdeRoleMenuDO entity = new MdeRoleMenuDO();
|
|
|
|
+ entity.setRoleId(roleId);
|
|
|
|
+ entity.setMenuId(menuId);
|
|
|
|
+ return entity;
|
|
|
|
+ }));
|
|
|
|
+ }
|
|
|
|
+ if (CollUtil.isNotEmpty(deleteMenuIds)) {
|
|
|
|
+ roleMenuMapper.deleteListByRoleIdAndMenuIds(roleId, deleteMenuIds);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Caching(evict = {
|
|
|
|
+ @CacheEvict(value = RedisKeyConstants.MDE_MENU_ROLE_ID_LIST,
|
|
|
|
+ allEntries = true), // allEntries 清空所有缓存,此处无法方便获得 roleId 对应的 menu 缓存们
|
|
|
|
+ @CacheEvict(value = RedisKeyConstants.MDE_USER_ROLE_IDS,
|
|
|
|
+ allEntries = true) // allEntries 清空所有缓存,此处无法方便获得 roleId 对应的 user 缓存们
|
|
|
|
+ })
|
|
|
|
+ public void processRoleDeleted(Long roleId) {
|
|
|
|
+ // 标记删除 UserRole
|
|
|
|
+ userRoleMapper.deleteListByRoleId(roleId);
|
|
|
|
+ // 标记删除 RoleMenu
|
|
|
|
+ roleMenuMapper.deleteListByRoleId(roleId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @CacheEvict(value = RedisKeyConstants.MDE_MENU_ROLE_ID_LIST, key = "#menuId")
|
|
|
|
+ public void processMenuDeleted(Long menuId) {
|
|
|
|
+ roleMenuMapper.deleteListByMenuId(menuId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Set<Long> getRoleMenuListByRoleId(Collection<Long> roleIds) {
|
|
|
|
+ if (CollUtil.isEmpty(roleIds)) {
|
|
|
|
+ return Collections.emptySet();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 如果是管理员的情况下,获取全部菜单编号
|
|
|
|
+ if (roleService.hasAnySuperAdmin(roleIds)) {
|
|
|
|
+ return convertSet(menuService.getMenuList(), MdeMenuDO::getId);
|
|
|
|
+ }
|
|
|
|
+ // 如果是非管理员的情况下,获得拥有的菜单编号
|
|
|
|
+ return convertSet(roleMenuMapper.selectListByRoleId(roleIds), MdeRoleMenuDO::getMenuId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ @Cacheable(value = RedisKeyConstants.MDE_MENU_ROLE_ID_LIST, key = "#menuId")
|
|
|
|
+ public Set<Long> getMenuRoleIdListByMenuIdFromCache(Long menuId) {
|
|
|
|
+ return convertSet(roleMenuMapper.selectListByMenuId(menuId), MdeRoleMenuDO::getRoleId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // ========== 用户-角色的相关方法 ==========
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
|
@DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
|
@CacheEvict(value = RedisKeyConstants.MDE_USER_ROLE_IDS, key = "#userId")
|
|
@CacheEvict(value = RedisKeyConstants.MDE_USER_ROLE_IDS, key = "#userId")
|
|
public void assignUserRole(Long userId, Set<Long> roleIds) {
|
|
public void assignUserRole(Long userId, Set<Long> roleIds) {
|
|
// 获得角色拥有角色编号
|
|
// 获得角色拥有角色编号
|
|
- Set<Long> dbRoleIds = convertSet(mdeUserRoleMapper.selectListByUserId(userId),
|
|
|
|
|
|
+ Set<Long> dbRoleIds = convertSet(userRoleMapper.selectListByUserId(userId),
|
|
MdeUserRoleDO::getRoleId);
|
|
MdeUserRoleDO::getRoleId);
|
|
// 计算新增和删除的角色编号
|
|
// 计算新增和删除的角色编号
|
|
Set<Long> roleIdList = CollUtil.emptyIfNull(roleIds);
|
|
Set<Long> roleIdList = CollUtil.emptyIfNull(roleIds);
|
|
@@ -141,7 +230,7 @@ public class MdePermissionServiceImpl implements MdePermissionService {
|
|
Collection<Long> deleteMenuIds = CollUtil.subtract(dbRoleIds, roleIdList);
|
|
Collection<Long> deleteMenuIds = CollUtil.subtract(dbRoleIds, roleIdList);
|
|
// 执行新增和删除。对于已经授权的角色,不用做任何处理
|
|
// 执行新增和删除。对于已经授权的角色,不用做任何处理
|
|
if (!CollectionUtil.isEmpty(createRoleIds)) {
|
|
if (!CollectionUtil.isEmpty(createRoleIds)) {
|
|
- mdeUserRoleMapper.insertBatch(CollectionUtils.convertList(createRoleIds, roleId -> {
|
|
|
|
|
|
+ userRoleMapper.insertBatch(CollectionUtils.convertList(createRoleIds, roleId -> {
|
|
MdeUserRoleDO entity = new MdeUserRoleDO();
|
|
MdeUserRoleDO entity = new MdeUserRoleDO();
|
|
entity.setUserId(userId);
|
|
entity.setUserId(userId);
|
|
entity.setRoleId(roleId);
|
|
entity.setRoleId(roleId);
|
|
@@ -149,49 +238,31 @@ public class MdePermissionServiceImpl implements MdePermissionService {
|
|
}));
|
|
}));
|
|
}
|
|
}
|
|
if (!CollectionUtil.isEmpty(deleteMenuIds)) {
|
|
if (!CollectionUtil.isEmpty(deleteMenuIds)) {
|
|
- mdeUserRoleMapper.deleteListByUserIdAndRoleIdIds(userId, deleteMenuIds);
|
|
|
|
|
|
+ userRoleMapper.deleteListByUserIdAndRoleIdIds(userId, deleteMenuIds);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- @DSTransactional // 单机+多数据源方案,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
|
|
|
public void assignUserRoleByDefault(Long userId, MdeDefaultRoleEnum roleEnum) {
|
|
public void assignUserRoleByDefault(Long userId, MdeDefaultRoleEnum roleEnum) {
|
|
// 获得默认角色信息
|
|
// 获得默认角色信息
|
|
- MdeRoleDO role = mdeRoleService.getRoleByDefault(roleEnum);
|
|
|
|
|
|
+ MdeRoleDO role = roleService.getRoleByDefault(roleEnum);
|
|
MdeUserRoleDO entity = new MdeUserRoleDO();
|
|
MdeUserRoleDO entity = new MdeUserRoleDO();
|
|
entity.setUserId(userId);
|
|
entity.setUserId(userId);
|
|
entity.setRoleId(role.getId());
|
|
entity.setRoleId(role.getId());
|
|
- mdeUserRoleMapper.insert(entity);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- @DSTransactional // 单机+多数据源方案,使用 @DSTransactional 保证本地事务,以及数据源的切换
|
|
|
|
- @Caching(evict = {
|
|
|
|
- @CacheEvict(value = RedisKeyConstants.MDE_USER_ROLE_IDS,
|
|
|
|
- allEntries = true) // allEntries 清空所有缓存,此处无法方便获得 roleId 对应的 user 缓存们
|
|
|
|
- })
|
|
|
|
- public void processRoleDeleted(Long roleId) {
|
|
|
|
- // 标记删除 MdeUserRole
|
|
|
|
- mdeUserRoleMapper.deleteListByRoleId(roleId);
|
|
|
|
|
|
+ userRoleMapper.insert(entity);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@CacheEvict(value = RedisKeyConstants.MDE_USER_ROLE_IDS, key = "#userId")
|
|
@CacheEvict(value = RedisKeyConstants.MDE_USER_ROLE_IDS, key = "#userId")
|
|
public void processUserDeleted(Long userId) {
|
|
public void processUserDeleted(Long userId) {
|
|
- mdeUserRoleMapper.deleteListByUserId(userId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Set<Long> getUserRoleIdListByRoleId(Collection<Long> roleIds) {
|
|
|
|
- return convertSet(mdeUserRoleMapper.selectListByRoleIds(roleIds), MdeUserRoleDO::getUserId);
|
|
|
|
|
|
+ userRoleMapper.deleteListByUserId(userId);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Set<Long> getUserRoleIdListByUserId(Long userId) {
|
|
public Set<Long> getUserRoleIdListByUserId(Long userId) {
|
|
- return convertSet(mdeUserRoleMapper.selectListByUserId(userId), MdeUserRoleDO::getRoleId);
|
|
|
|
|
|
+ return convertSet(userRoleMapper.selectListByUserId(userId), MdeUserRoleDO::getRoleId);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
@Override
|
|
@Override
|
|
@Cacheable(value = RedisKeyConstants.MDE_USER_ROLE_IDS, key = "#userId")
|
|
@Cacheable(value = RedisKeyConstants.MDE_USER_ROLE_IDS, key = "#userId")
|
|
public Set<Long> getUserRoleIdListByUserIdFromCache(Long userId) {
|
|
public Set<Long> getUserRoleIdListByUserIdFromCache(Long userId) {
|
|
@@ -199,14 +270,31 @@ public class MdePermissionServiceImpl implements MdePermissionService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void assignRoleDataScope(Long roleId, Integer dataScope, Set<Long> dataScopeDataIds) {
|
|
|
|
- mdeRoleService.updateRoleDataScope(roleId, dataScope, dataScopeDataIds);
|
|
|
|
|
|
+ public Set<Long> getUserRoleIdListByRoleId(Collection<Long> roleIds) {
|
|
|
|
+ return convertSet(userRoleMapper.selectListByRoleIds(roleIds), MdeUserRoleDO::getUserId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获得用户拥有的角色,并且这些角色是开启状态的
|
|
|
|
+ *
|
|
|
|
+ * @param userId 用户编号
|
|
|
|
+ * @return 用户拥有的角色
|
|
|
|
+ */
|
|
|
|
+ @VisibleForTesting
|
|
|
|
+ List<MdeRoleDO> getEnableUserRoleListByUserIdFromCache(Long userId) {
|
|
|
|
+ // 获得用户拥有的角色编号
|
|
|
|
+ Set<Long> roleIds = getSelf().getUserRoleIdListByUserIdFromCache(userId);
|
|
|
|
+ // 获得角色数组,并移除被禁用的
|
|
|
|
+ List<MdeRoleDO> roles = roleService.getRoleListFromCache(roleIds);
|
|
|
|
+ roles.removeIf(role -> !CommonStatusEnum.ENABLE.getStatus().equals(role.getStatus()));
|
|
|
|
+ return roles;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // ========== 用户-部门的相关方法 ==========
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
- @DataPermission(enable = false) // 关闭数据权限,不然就会出现递归获取数据权限的问题
|
|
|
|
- public DataPermissionRespDTO getDataPermission(Long userId) {
|
|
|
|
- return getDataPermission(userId, null);
|
|
|
|
|
|
+ public void assignRoleDataScope(Long roleId, Integer dataScope, Set<Long> dataScopeDataIds) {
|
|
|
|
+ roleService.updateRoleDataScope(roleId, dataScope, dataScopeDataIds);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -247,7 +335,7 @@ public class MdePermissionServiceImpl implements MdePermissionService {
|
|
}
|
|
}
|
|
// 情况二,DEPT_CUSTOM 自定义
|
|
// 情况二,DEPT_CUSTOM 自定义
|
|
if (Objects.equals(role.getDataScope(), DataScopeEnum.DEPT_CUSTOM.getScope())) {
|
|
if (Objects.equals(role.getDataScope(), DataScopeEnum.DEPT_CUSTOM.getScope())) {
|
|
- CollUtil.addAll(result.getDataIds(), role.getDataScopeDeptIds());
|
|
|
|
|
|
+ CollUtil.addAll(result.getDataIds(), role.getDataScopeEnterpriseIds());
|
|
// 自定义可见部门时,保证可以看到自己所在的部门。否则,一些场景下可能会有问题。
|
|
// 自定义可见部门时,保证可以看到自己所在的部门。否则,一些场景下可能会有问题。
|
|
// 例如说,登录时,基于 t_user 的 username 查询会可能被 dept_id 过滤掉
|
|
// 例如说,登录时,基于 t_user 的 username 查询会可能被 dept_id 过滤掉
|
|
CollUtil.addAll(result.getDataIds(), enterpriseUserBind.getEnterpriseId());
|
|
CollUtil.addAll(result.getDataIds(), enterpriseUserBind.getEnterpriseId());
|
|
@@ -283,4 +371,14 @@ public class MdePermissionServiceImpl implements MdePermissionService {
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获得自身的代理对象,解决 AOP 生效问题
|
|
|
|
+ *
|
|
|
|
+ * @return 自己
|
|
|
|
+ */
|
|
|
|
+ private MdePermissionServiceImpl getSelf() {
|
|
|
|
+ return SpringUtil.getBean(getClass());
|
|
|
|
+ }
|
|
}
|
|
}
|