mirror of
https://gitee.com/qqtt-ah/ai-crm.git
synced 2026-11-24 07:09:20 +08:00
sql: 精简 sys_seed,移除电商/渠道/BI 菜单权限仅保留基础模块
This commit is contained in:
@@ -0,0 +1,135 @@
|
||||
-- ========================================
|
||||
-- 一次性清理:已灌库环境上的电商/渠道/BI/openapi/data 菜单与权限
|
||||
-- 空库请直接依赖精简后的 sql/init/sys_seed.sql,无需执行本脚本
|
||||
-- 执行前请备份;按公司菜单/岗位菜单外键顺序删除
|
||||
-- ========================================
|
||||
|
||||
-- 1) 关联表:菜单权限、公司菜单、职位菜单
|
||||
DELETE mp FROM `sys_menu_permission` mp
|
||||
INNER JOIN `sys_menu` m ON m.id = mp.menu_id
|
||||
WHERE m.path LIKE '%/bi/%'
|
||||
OR m.path LIKE '%/ec/%'
|
||||
OR m.path LIKE '%/channel/%'
|
||||
OR m.path LIKE '/pdd%'
|
||||
OR m.path IN ('/product', '/bi', '/ec', '/channel', '/config')
|
||||
OR m.component LIKE '%/bi/%'
|
||||
OR m.component LIKE '%/ec/%'
|
||||
OR m.component LIKE '%/channel/%'
|
||||
OR m.route_name LIKE 'Bi%'
|
||||
OR m.route_name LIKE 'Ec%'
|
||||
OR m.route_name LIKE 'Channel%'
|
||||
OR m.route_name LIKE 'Pdd%'
|
||||
OR m.route_name IN (
|
||||
'ShopCatalog', 'ProductCatalog', 'TaobaoChannel', 'PddChannel',
|
||||
'Workbench', 'OrderManagement', 'ProductManagement', 'ShopManagement',
|
||||
'ConfigManagement', 'AdFeeManagement', 'BrushOrderManagement',
|
||||
'ShopMonthlyTargetManagement', 'OpTeamManagement', 'CategoryConfig',
|
||||
'ShopOverview', 'ProductOverview', 'PlatformOverview', 'CategoryOverview',
|
||||
'SkuOverview', 'ShopDetails', 'PddGoodsPublishDesk', 'PddGoodsPublishDeskEdit',
|
||||
'PddOrderManagement', 'PddShopManagement', 'PddGoodsManagement',
|
||||
'PddCatManagement', 'PddGoodsAdFeeManagement'
|
||||
);
|
||||
|
||||
DELETE cm FROM `org_company_menu` cm
|
||||
INNER JOIN `sys_menu` m ON m.id = cm.menu_id
|
||||
WHERE m.path LIKE '%/bi/%'
|
||||
OR m.path LIKE '%/ec/%'
|
||||
OR m.path LIKE '%/channel/%'
|
||||
OR m.path LIKE '/pdd%'
|
||||
OR m.path IN ('/product', '/bi', '/ec', '/channel', '/config')
|
||||
OR m.route_name LIKE 'Pdd%'
|
||||
OR m.route_name IN (
|
||||
'ShopCatalog', 'ProductCatalog', 'TaobaoChannel', 'PddChannel',
|
||||
'Workbench', 'OrderManagement', 'ProductManagement', 'ShopManagement',
|
||||
'ConfigManagement', 'AdFeeManagement', 'BrushOrderManagement',
|
||||
'ShopMonthlyTargetManagement', 'OpTeamManagement', 'CategoryConfig',
|
||||
'ShopOverview', 'ProductOverview', 'PlatformOverview', 'CategoryOverview',
|
||||
'SkuOverview', 'ShopDetails', 'PddGoodsPublishDesk', 'PddGoodsPublishDeskEdit',
|
||||
'PddOrderManagement', 'PddShopManagement', 'PddGoodsManagement',
|
||||
'PddCatManagement', 'PddGoodsAdFeeManagement', 'EcPages'
|
||||
);
|
||||
|
||||
DELETE pm FROM `org_position_menu` pm
|
||||
INNER JOIN `sys_menu` m ON m.id = pm.menu_id
|
||||
WHERE m.path LIKE '%/bi/%'
|
||||
OR m.path LIKE '%/ec/%'
|
||||
OR m.path LIKE '%/channel/%'
|
||||
OR m.path LIKE '/pdd%'
|
||||
OR m.path IN ('/product', '/bi', '/ec', '/channel', '/config')
|
||||
OR m.route_name LIKE 'Pdd%'
|
||||
OR m.route_name IN (
|
||||
'ShopCatalog', 'ProductCatalog', 'TaobaoChannel', 'PddChannel',
|
||||
'Workbench', 'OrderManagement', 'ProductManagement', 'ShopManagement',
|
||||
'ConfigManagement', 'AdFeeManagement', 'BrushOrderManagement',
|
||||
'ShopMonthlyTargetManagement', 'OpTeamManagement', 'CategoryConfig',
|
||||
'ShopOverview', 'ProductOverview', 'PlatformOverview', 'CategoryOverview',
|
||||
'SkuOverview', 'ShopDetails', 'PddGoodsPublishDesk', 'PddGoodsPublishDeskEdit',
|
||||
'PddOrderManagement', 'PddShopManagement', 'PddGoodsManagement',
|
||||
'PddCatManagement', 'PddGoodsAdFeeManagement', 'EcPages'
|
||||
);
|
||||
|
||||
-- 2) 菜单本身(先子后父:无 parent 约束时也可一次删)
|
||||
DELETE FROM `sys_menu`
|
||||
WHERE path LIKE '%/bi/%'
|
||||
OR path LIKE '%/ec/%'
|
||||
OR path LIKE '%/channel/%'
|
||||
OR path LIKE '/pdd%'
|
||||
OR path IN ('/product', '/bi', '/ec', '/channel', '/config')
|
||||
OR component LIKE '%/bi/%'
|
||||
OR component LIKE '%/ec/%'
|
||||
OR component LIKE '%/channel/%'
|
||||
OR route_name LIKE 'Bi%'
|
||||
OR route_name LIKE 'Ec%'
|
||||
OR route_name LIKE 'Channel%'
|
||||
OR route_name LIKE 'Pdd%'
|
||||
OR route_name IN (
|
||||
'ShopCatalog', 'ProductCatalog', 'TaobaoChannel', 'PddChannel',
|
||||
'Workbench', 'OrderManagement', 'ProductManagement', 'ShopManagement',
|
||||
'ConfigManagement', 'AdFeeManagement', 'BrushOrderManagement',
|
||||
'ShopMonthlyTargetManagement', 'OpTeamManagement', 'CategoryConfig',
|
||||
'ShopOverview', 'ProductOverview', 'PlatformOverview', 'CategoryOverview',
|
||||
'SkuOverview', 'ShopDetails', 'PddGoodsPublishDesk', 'PddGoodsPublishDeskEdit',
|
||||
'PddOrderManagement', 'PddShopManagement', 'PddGoodsManagement',
|
||||
'PddCatManagement', 'PddGoodsAdFeeManagement', 'EcPages'
|
||||
);
|
||||
|
||||
-- 3) 公司/职位权限关联
|
||||
DELETE cp FROM `org_company_permission` cp
|
||||
INNER JOIN `sys_permission` p ON p.id = cp.permission_id
|
||||
WHERE p.code = 'ec' OR p.code LIKE 'ec:%'
|
||||
OR p.code = 'channel' OR p.code LIKE 'channel:%'
|
||||
OR p.code = 'bi' OR p.code LIKE 'bi:%'
|
||||
OR p.code = 'data' OR p.code LIKE 'data:%'
|
||||
OR p.code = 'openapi' OR p.code LIKE 'openapi:%';
|
||||
|
||||
DELETE pp FROM `org_position_permission` pp
|
||||
INNER JOIN `sys_permission` p ON p.id = pp.permission_id
|
||||
WHERE p.code = 'ec' OR p.code LIKE 'ec:%'
|
||||
OR p.code = 'channel' OR p.code LIKE 'channel:%'
|
||||
OR p.code = 'bi' OR p.code LIKE 'bi:%'
|
||||
OR p.code = 'data' OR p.code LIKE 'data:%'
|
||||
OR p.code = 'openapi' OR p.code LIKE 'openapi:%';
|
||||
|
||||
DELETE mp FROM `sys_menu_permission` mp
|
||||
INNER JOIN `sys_permission` p ON p.id = mp.permission_id
|
||||
WHERE p.code = 'ec' OR p.code LIKE 'ec:%'
|
||||
OR p.code = 'channel' OR p.code LIKE 'channel:%'
|
||||
OR p.code = 'bi' OR p.code LIKE 'bi:%'
|
||||
OR p.code = 'data' OR p.code LIKE 'data:%'
|
||||
OR p.code = 'openapi' OR p.code LIKE 'openapi:%';
|
||||
|
||||
-- 4) 权限树(叶子 → 父;多轮删子节点)
|
||||
DELETE FROM `sys_permission`
|
||||
WHERE code LIKE 'ec:%'
|
||||
OR code LIKE 'channel:%'
|
||||
OR code LIKE 'bi:%'
|
||||
OR code LIKE 'data:%'
|
||||
OR code LIKE 'openapi:%'
|
||||
OR code IN ('ec', 'channel', 'bi', 'data', 'openapi');
|
||||
|
||||
-- 5) 若历史 agent 挂在 data 下且 id 为 4800 段:把根域纠正为独立 agent(幂等)
|
||||
UPDATE `sys_permission`
|
||||
SET `parent_id` = NULL,
|
||||
`remark` = 'Agent 对话与模型配置',
|
||||
`sort_order` = 60
|
||||
WHERE `code` = 'agent' AND (`parent_id` IS NOT NULL OR `id` = 4800);
|
||||
Reference in New Issue
Block a user