Files
FruitServer/sql/migrate-k91-watch-history-menu.sql
T

35 lines
1.6 KiB
SQL

-- Author: fruit.com.cn
-- K91 后台观看记录独立菜单与权限点(幂等,仅提交文件,由发布流程执行)
INSERT INTO sys_permission (id, code, name, group_name, type, sort) VALUES
(1105, 'watch-history:list', '查看观看记录', '用户管理', 'BUTTON', 105)
ON CONFLICT (code) DO NOTHING;
INSERT INTO sys_role_permission (id, role_id, permission_id)
SELECT r.id * 1000000 + p.id, r.id, p.id
FROM sys_role r
CROSS JOIN sys_permission p
WHERE r.code = 'super_admin' AND p.code = 'watch-history:list'
ON CONFLICT DO NOTHING;
-- 任务书建议使用菜单 id 26,但现有“创作者中心”已使用 26,27-30 为其子菜单。
-- 为避免覆盖已有菜单树,这里使用下一个空闲 id 34。
INSERT INTO sys_menu (id, parent_id, title, route_path, route_name, component, redirect, icon,
permission_code, type, always_show, affix, sort) VALUES
(34, 15, '观看记录', 'watch-history', 'watch-history',
'views/userManagement/WatchHistoryView', '', '',
'watch-history:list', 'MENU', 0, 0, 2)
ON CONFLICT (id) DO UPDATE SET parent_id = EXCLUDED.parent_id, title = EXCLUDED.title,
route_path = EXCLUDED.route_path, route_name = EXCLUDED.route_name,
component = EXCLUDED.component, redirect = EXCLUDED.redirect, icon = EXCLUDED.icon,
permission_code = EXCLUDED.permission_code, type = EXCLUDED.type,
always_show = EXCLUDED.always_show, affix = EXCLUDED.affix, sort = EXCLUDED.sort;
INSERT INTO sys_role_menu (id, role_id, menu_id)
SELECT r.id * 1000000 + m.id, r.id, m.id
FROM sys_role r
CROSS JOIN sys_menu m
WHERE r.code = 'super_admin' AND m.id = 34
ON CONFLICT DO NOTHING;