Files
yunzerwebsiteallinone/go/docs/sql/fix_module_platforms.sql
T

68 lines
3.1 KiB
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.
-- =============================================================
-- 修复:模块「展示端(platforms)」误配置导致菜单整块消失
--
-- 背景:
-- yz_system_modules.platforms 是与 status/is_show、菜单 views、角色 rights
-- 并列的第四个维度,决定模块/菜单出现在 Web 端还是移动端:
-- ["web"] 仅 Web 端(租户管理后台 PC)
-- ["app"] 仅移动端(APP / 微信小程序)
-- ["web","app"] 两端都显示
-- '' / NULL 全端显示(默认)
--
-- 菜单自身未配置 platforms 时,按 path 前缀继承所属模块的 platforms
-- (services.MenuVisibleOn)。所以模块一旦配错,其下整棵菜单都会被
-- 某一端整体剔除——而后台的「模块管理 / 菜单管理 / 角色管理」里
-- 所有开关都是正常的,界面上完全看不出原因。
--
-- 事故原因:
-- add_module_platforms.sql 里的「使用示例」第 1、2 条是演示语句,
-- 却被原样执行到了正式库:
-- 例1 UPDATE yz_system_modules SET platforms = JSON_ARRAY('web') WHERE code = 'crm';
-- 例2 UPDATE yz_system_modules SET platforms = JSON_ARRAY('app') WHERE code = 'bianjiegongju';
--
-- 后果:
-- 例2 → 租户后台(Web)左侧菜单里 /tools(便捷工具)整块消失:
-- 记事本、日程提醒、账号管理全部不显示。
-- 例1 → 移动端工作台没有「客户关系」模块卡片,/apps/crm 下 29 条菜单全部不显示。
--
-- 修复:两个模块都恢复为两端可见。
-- 依据:
-- · 便捷工具:backend/src/views/tools/ 有记事本/日程/密码库完整页面;
-- uniapp/pages/toolbox/ 有 home/functions/mine/todo;
-- 菜单 views 含 2;全部租户套餐都含 bianjiegongju。
-- · 客户关系:backend/src/views/apps/crm/ 与 uniapp/pages/crm/ 均已完整实现;
-- SUBSYSTEMS 已注册 crm;菜单 views 全为 2(租户端两端共用)。
--
-- 回滚:
-- UPDATE yz_system_modules SET platforms = JSON_ARRAY('app')
-- WHERE code = 'bianjiegongju';
-- UPDATE yz_system_modules SET platforms = JSON_ARRAY('web')
-- WHERE code = 'crm';
-- =============================================================
-- ---------- 修复前先看一眼现状 ----------
SELECT id, name, code, path, type, status, is_show, platforms
FROM yz_system_modules
WHERE code IN ('bianjiegongju', 'crm');
-- ---------- 恢复为两端可见 ----------
UPDATE yz_system_modules
SET platforms = JSON_ARRAY('web', 'app'),
update_time = NOW()
WHERE code IN ('bianjiegongju', 'crm')
AND delete_time IS NULL;
-- ---------- 校验 ----------
SELECT id, name, code, path, type, status, is_show, platforms
FROM yz_system_modules
WHERE code IN ('bianjiegongju', 'crm');
-- ---------- 顺带体检:其余模块不应残留单端配置 ----------
-- 除本次修复的两个模块外,其余模块 platforms 应为 NULL(全端)。
SELECT id, name, code, path, platforms
FROM yz_system_modules
WHERE delete_time IS NULL
AND platforms IS NOT NULL
AND platforms <> ''
AND code NOT IN ('bianjiegongju', 'crm');