HaniBlindBox/server/HoneyBox/scripts/seed_box_profit_menu.sql
2026-02-04 02:03:25 +08:00

44 lines
1.7 KiB
Transact-SQL
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

-- 盒子利润统计菜单种子数据
-- 执行前请确保统计报表目录菜单已存在
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