mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-12 21:02:08 +08:00
Merge remote-tracking branch 'origin/main'
# Conflicts: # cf-module-system/cf-module-system-biz/src/main/java/com/cf/imes/module/system/service/oauth2/OAuth2TokenServiceImpl.java
This commit is contained in:
+3
-5
@@ -1,7 +1,7 @@
|
||||
package com.cf.imes.module.system.dal.mysql.permission;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.cf.imes.framework.common.pojo.PageResult;
|
||||
import com.cf.imes.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.cf.imes.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.security.core.LoginUser;
|
||||
@@ -12,9 +12,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Mapper
|
||||
public interface RoleMapper extends BaseMapperX<RoleDO> {
|
||||
@@ -28,7 +26,7 @@ public interface RoleMapper extends BaseMapperX<RoleDO> {
|
||||
//如果是超级管理员并且未传organId,就查看自己的的
|
||||
lambdaQueryWrapperX.inIfPresent(RoleDO::getOrganId,0L,loginUser.getOrganId());
|
||||
}*/
|
||||
if(isSupAdmin && !Objects.isNull(reqVO.getOrganId())) {
|
||||
if(isSupAdmin && ObjectUtil.isNotNull(reqVO.getOrganId())) {
|
||||
//如果是超级管理员并且传入organId,就查看传入的组织
|
||||
lambdaQueryWrapperX.eqIfPresent(RoleDO::getOrganId, reqVO.getOrganId());
|
||||
} else {
|
||||
@@ -41,7 +39,7 @@ public interface RoleMapper extends BaseMapperX<RoleDO> {
|
||||
.eqIfPresent(RoleDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(RoleDO::getCreateTime, reqVO.getCreateTime())
|
||||
.ne(RoleDO::getId, 1)
|
||||
.orderByDesc(RoleDO::getId);
|
||||
.orderByAsc(RoleDO::getSort);
|
||||
|
||||
return selectPage(reqVO, lambdaQueryWrapperX);
|
||||
}
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.cf.imes.module.system.dal.redis;
|
||||
|
||||
/**
|
||||
* system redis监听刷新通道名称 常量
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/6/13 14:55
|
||||
*/
|
||||
public interface RedisRefreshChannelTopicConstants {
|
||||
|
||||
/**
|
||||
* 刷新权限
|
||||
*/
|
||||
String PREMISSION_REFRESH = "PREMISSION_REFRESH";
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.cf.imes.module.system.dal.redis.listener;
|
||||
|
||||
import com.cf.imes.framework.mq.redis.core.pubsub.AbstractRedisSimpleMessageListener;
|
||||
import com.cf.imes.framework.security.core.service.SecurityFrameworkService;
|
||||
import com.cf.imes.module.system.dal.redis.RedisRefreshChannelTopicConstants;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.listener.ChannelTopic;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* system PREMISSION_REFRESH redis监听器
|
||||
*
|
||||
* @author Gqr
|
||||
* @since 2024/6/13 10:32
|
||||
*/
|
||||
@Component
|
||||
public class SystemPremissionRefreshRedisListener extends AbstractRedisSimpleMessageListener {
|
||||
|
||||
@Autowired
|
||||
private SecurityFrameworkService securityFrameworkService;
|
||||
|
||||
public SystemPremissionRefreshRedisListener() {
|
||||
super.setTopic(new ChannelTopic(RedisRefreshChannelTopicConstants.PREMISSION_REFRESH));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] bytes) {
|
||||
securityFrameworkService.invalidateAll();
|
||||
}
|
||||
}
|
||||
+17
-2
@@ -4,14 +4,12 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.cf.imes.framework.common.enums.CommonStatusEnum;
|
||||
import com.cf.imes.framework.common.util.collection.CollectionUtils;
|
||||
import com.cf.imes.framework.datapermission.core.annotation.DataPermission;
|
||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.cf.imes.framework.organ.core.aop.OrganIgnore;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import com.cf.imes.framework.organ.core.db.OrganBaseDO;
|
||||
import com.cf.imes.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import com.cf.imes.module.system.api.permission.dto.DeptDataPermissionRespDTO;
|
||||
import com.cf.imes.module.system.controller.admin.permission.vo.permission.PermissionAssignUserRoleReqVO;
|
||||
@@ -22,6 +20,7 @@ import com.cf.imes.module.system.dal.dataobject.permission.UserRoleDO;
|
||||
import com.cf.imes.module.system.dal.mysql.permission.RoleMenuMapper;
|
||||
import com.cf.imes.module.system.dal.mysql.permission.UserRoleMapper;
|
||||
import com.cf.imes.module.system.dal.redis.RedisKeyConstants;
|
||||
import com.cf.imes.module.system.dal.redis.RedisRefreshChannelTopicConstants;
|
||||
import com.cf.imes.module.system.enums.permission.DataScopeEnum;
|
||||
import com.cf.imes.module.system.service.dept.DeptService;
|
||||
import com.cf.imes.module.system.service.user.AdminUserService;
|
||||
@@ -30,14 +29,17 @@ import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -72,6 +74,9 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
@Resource
|
||||
private AdminUserService userService;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Override
|
||||
public boolean hasAnyPermissions(Long userId, String... permissions) {
|
||||
// 如果为空,说明已经有权限
|
||||
@@ -179,6 +184,16 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
if (CollUtil.isNotEmpty(deleteMenuIds)) {
|
||||
roleMenuMapper.deleteListByRoleIdAndMenuIds(roleId, deleteMenuIds);
|
||||
}
|
||||
|
||||
// 角色菜单权限发生修改,通知刷新本地缓存
|
||||
if (CollectionUtil.isNotEmpty(createMenuIds) || CollectionUtil.isNotEmpty(deleteMenuIds)) {
|
||||
CompletableFuture.runAsync(() -> {
|
||||
redisTemplate.convertAndSend(RedisRefreshChannelTopicConstants.PREMISSION_REFRESH, "");
|
||||
}).exceptionally(e -> {
|
||||
log.error("redis message发送失败, topic:{}, 异常:{}", RedisRefreshChannelTopicConstants.PREMISSION_REFRESH, e.getMessage());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user