-- 盒子利润统计菜单种子数据 -- 执行前请确保统计报表目录菜单已存在 USE honey_box_admin; GO -- 查找统计报表目录的ID DECLARE @statisticsMenuId BIGINT; SELECT @statisticsMenuId = Id FROM menus WHERE Path = '/business/statistics' AND MenuType = 1; -- 如果统计报表目录不存在,先创建它 IF @statisticsMenuId IS NULL BEGIN DECLARE @businessMenuId BIGINT; SELECT @businessMenuId = Id FROM menus WHERE Path = '/business' AND MenuType = 1; INSERT INTO menus (Name, Path, Component, Icon, SortOrder, MenuType, Status, ParentId, Permission, CreatedAt, UpdatedAt, IsExternal, IsCache) VALUES (N'统计报表', '/business/statistics', NULL, 'DataAnalysis', 80, 1, 1, @businessMenuId, NULL, GETDATE(), GETDATE(), 0, 0); SET @statisticsMenuId = SCOPE_IDENTITY(); PRINT N'创建统计报表目录菜单,ID: ' + CAST(@statisticsMenuId AS NVARCHAR(10)); END -- 检查盒子利润统计菜单是否已存在 IF NOT EXISTS (SELECT 1 FROM menus WHERE Path = '/business/statistics/box-profit') BEGIN INSERT INTO menus (Name, Path, Component, Icon, SortOrder, MenuType, Status, ParentId, Permission, CreatedAt, UpdatedAt, IsExternal, IsCache) VALUES (N'盒子利润统计', '/business/statistics/box-profit', 'business/statistics/box-profit', 'TrendCharts', 2, 2, 1, @statisticsMenuId, 'statistics:box-profit', GETDATE(), GETDATE(), 0, 1); PRINT N'创建盒子利润统计菜单成功'; END ELSE BEGIN PRINT N'盒子利润统计菜单已存在,跳过创建'; END -- 查看结果 SELECT Id, Name, Path, Component, Permission, ParentId, SortOrder, MenuType, Status FROM menus WHERE Path LIKE '/business/statistics%' ORDER BY ParentId, SortOrder; GO