🐛 Fixing a bug. 租户套餐问题

This commit is contained in:
aeizzz committed 2023-01-12 19:29:24 +08:00
1 parent 246fa10785
commit 7f6f5c5c4c
4 files changed
+25 -5

No files matched your search

+3 -3
View File
@@ -10,8 +10,8 @@ CREATE TABLE `sys_tenant_menu` (
`menu_ids` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
`status` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '0' COMMENT '租户菜单,9:冻结,0:正常',
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0',
`create_by` varchar(64) CHARACTER SET utf8bm4 COLLATE utf8bm4_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人',
`update_by` varchar(64) CHARACTER SET utf8bm4 COLLATE utf8bm4_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人',
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT ' ' COMMENT '创建人',
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT ' ' COMMENT '修改人',
`create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) COMMENT '创建',
`update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP(0) ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
PRIMARY KEY (`id`) USING BTREE
@@ -25,7 +25,7 @@ INSERT INTO `sys_tenant_menu` VALUES (1, '套餐1', '1000,1100,1101,1102,1103,11
INSERT INTO `sys_route_conf` VALUES (14, 'APP服务', 'pigx-app-server', '[{\"args\": {\"_genkey_0\": \"/app/**\"}, \"name\": \"Path\"}]', '[]', 'lb://pigx-app-server-biz', 0, '{}', 'admin', ' ', '2022-12-07 10:53:44', NULL, '0');
INSERT INTO `sys_route_conf` VALUES (17, 'APP服务', 'pigx-app-server', '[{\"args\": {\"_genkey_0\": \"/app/**\"}, \"name\": \"Path\"}]', '[]', 'lb://pigx-app-server-biz', 0, '{}', 'admin', ' ', '2022-12-07 10:53:44', NULL, '0');
@@ -17,6 +17,7 @@ import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.event.TransactionalEventListener;
/**
* @author lengleng
@@ -40,7 +41,7 @@ public class ClientDetailsInitRunner implements InitializingBean {
@Async
@Order
@EventListener({ WebServerInitializedEvent.class, ClientDetailsInitEvent.class })
@TransactionalEventListener({ WebServerInitializedEvent.class, ClientDetailsInitEvent.class })
public void initClientDetails() {
log.debug("初始化客户端信息开始 ");
@@ -37,6 +37,7 @@ import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.scheduling.annotation.Async;
import org.springframework.transaction.event.TransactionalEventListener;
import java.net.URI;
import java.util.Map;
@@ -60,7 +61,7 @@ public class DynamicRouteInitRunner implements InitializingBean {
@Async
@Order
@EventListener({ WebServerInitializedEvent.class, DynamicRouteInitEvent.class })
@TransactionalEventListener({ WebServerInitializedEvent.class, DynamicRouteInitEvent.class })
public void initRoute() {
redisTemplate.delete(CacheConstants.ROUTE_KEY);
log.info("开始初始化网关路由");
@@ -1,12 +1,16 @@
package com.pig4cloud.pigx.admin.controller;
import cn.hutool.core.lang.tree.Tree;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pigx.admin.api.entity.SysTenantMenu;
import com.pig4cloud.pigx.admin.service.SysMenuService;
import com.pig4cloud.pigx.admin.service.SysTenantMenuService;
import com.pig4cloud.pigx.common.core.constant.CacheConstants;
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.data.resolver.ParamResolver;
import com.pig4cloud.pigx.common.data.tenant.TenantBroker;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
import com.pig4cloud.pigx.common.security.annotation.Inner;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -17,6 +21,7 @@ import org.springframework.http.HttpHeaders;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
@RestController
@@ -28,6 +33,8 @@ public class SysTenantMenuController {
private final SysTenantMenuService sysTenantMenuService;
private final SysMenuService sysMenuService;
/**
* 分页查询
* @param page 分页对象
@@ -100,4 +107,15 @@ public class SysTenantMenuController {
return R.ok(tenants);
}
@GetMapping(value = "/tree/menu")
public R getTree() {
Long defaultId = ParamResolver.getLong("TENANT_DEFAULT_ID", 1L);
List<Tree<Long>> trees = new ArrayList<>();
TenantBroker.runAs(defaultId, (id) -> {
trees.addAll(sysMenuService.treeMenu(null, null));
});
return R.ok(trees);
}
}