mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-08 12:57:13 +08:00
fix: 修复租户套餐更新时租户权限未更新问题、租户操作日志未记录问题、租户角色管理模块菜单过滤、删除租户时菜单被删除问题
This commit is contained in:
@@ -17,10 +17,13 @@
|
||||
package top.continew.admin.system.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import top.continew.admin.common.constant.CacheConstants;
|
||||
@@ -36,8 +39,10 @@ import top.continew.starter.core.util.validation.ValidationUtils;
|
||||
import top.continew.starter.extension.crud.annotation.CrudApi;
|
||||
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
|
||||
import top.continew.starter.extension.crud.enums.Api;
|
||||
import top.continew.starter.extension.crud.model.query.SortQuery;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单管理 API
|
||||
@@ -47,9 +52,12 @@ import java.lang.reflect.Method;
|
||||
*/
|
||||
@Tag(name = "菜单管理 API")
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@CrudRequestMapping(value = "/system/menu", api = {Api.TREE, Api.GET, Api.CREATE, Api.UPDATE, Api.BATCH_DELETE})
|
||||
public class MenuController extends BaseController<MenuService, MenuResp, MenuResp, MenuQuery, MenuReq> {
|
||||
|
||||
private final MenuService menuService;
|
||||
|
||||
@Operation(summary = "清除缓存", description = "清除缓存")
|
||||
@SaCheckPermission("system:menu:clearCache")
|
||||
@DeleteMapping("/cache")
|
||||
@@ -77,4 +85,11 @@ public class MenuController extends BaseController<MenuService, MenuResp, MenuRe
|
||||
req.setComponent(StrUtil.removePrefix(req.getComponent(), StringConstants.SLASH));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Tree<Long>> tree(@Valid MenuQuery query, @Valid SortQuery sortQuery) {
|
||||
query.setExcludeMenuIdList(menuService.listExcludeTenantMenu());
|
||||
return super.tree(query, sortQuery);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -64,4 +64,9 @@ public interface MenuService extends BaseService<MenuResp, MenuResp, MenuQuery,
|
||||
* @param parentMenu 父菜单
|
||||
*/
|
||||
void addTenantMenu(MenuDO menu, MenuDO parentMenu);
|
||||
|
||||
/**
|
||||
* 查询租户排除的菜单
|
||||
*/
|
||||
List<Long> listExcludeTenantMenu();
|
||||
}
|
||||
|
@@ -18,6 +18,7 @@ package top.continew.admin.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alicp.jetcache.anno.Cached;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@@ -163,6 +164,18 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, MenuDO, MenuRes
|
||||
RedisUtils.deleteByPattern(CacheConstants.ROLE_MENU_KEY_PREFIX + StringConstants.ASTERISK);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> listExcludeTenantMenu() {
|
||||
RoleDO role = roleMapper.selectOne(Wrappers.lambdaQuery(RoleDO.class)
|
||||
.eq(RoleDO::getCode, SysConstants.TENANT_ADMIN_ROLE_CODE));
|
||||
if (role == null) {
|
||||
return ListUtil.of();
|
||||
}
|
||||
List<Long> allMenuList = list().stream().map(MenuDO::getId).toList();
|
||||
List<Long> menuList = baseMapper.selectListByRoleId(role.getId()).stream().map(MenuDO::getId).toList();
|
||||
return CollUtil.disjunction(allMenuList, menuList).stream().toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查标题是否重复
|
||||
*
|
||||
|
Reference in New Issue
Block a user