-- 页面菜单缺失清单 SQL
-- 用途：
-- 1. 检查前端当前已接入的页面路由，哪些还没有对应的 sys_menu 页面菜单
-- 2. 只查询，不做插入
--
-- 说明：
-- 1. 这里按前端当前实际路由整理了一份页面菜单基线
-- 2. 仅检查 menu_type in ('M','C') 的目录/页面菜单
-- 3. 管理员无需在角色管理中额外勾选页面；前端当前已按 admin 角色默认放行

DROP TEMPORARY TABLE IF EXISTS tmp_page_menu_specs;
CREATE TEMPORARY TABLE tmp_page_menu_specs (
  path VARCHAR(128) NOT NULL,
  component_like VARCHAR(255) NULL,
  menu_name VARCHAR(128) NOT NULL,
  remark VARCHAR(255) NULL
);

INSERT INTO tmp_page_menu_specs (path, component_like, menu_name, remark) VALUES
('index', '%worklog%', '工作日志', 'WorkLogPage 首页'),
('dashboard/project-execution', '%dashboard/project-execution%', '项目进度', 'ProjectExecutionPage'),
('projectBank/projectProgress', '%dashboard/project-execution%', '项目进度(兼容)', 'ProjectExecutionPage 别名路由'),
('projectBank/projectUser', '%projectBank/projectUser%', '项目成员', 'ProjectUserPage'),
('projectBank/userProject', '%projectBank/userProject%', '人员项目', 'UserProjectPage'),
('projectBank/userScore', '%projectBank/userScore%', '我的绩效', 'UserScorePage'),
('projectBank/userScoreDetail', '%projectBank/userScoreDetail%', '绩效详情', 'UserScoreDetailPage'),
('user/profile', '%Profile%', '个人中心', 'ProfilePage'),
('monitor/cache', '%monitor/cache%', '缓存监控', 'CacheMonitorPage'),
('monitor/job', '%monitor/job%', '定时任务', 'JobMonitorPage'),
('monitor/logininfor', '%monitor/login%', '登录日志', 'LoginLogPage'),
('monitor/online', '%monitor/online%', '在线用户', 'OnlineUserPage'),
('monitor/operlog', '%monitor/operation%', '操作日志', 'OperationLogPage'),
('monitor/server', '%monitor/server%', '服务监控', 'ServerMonitorPage'),
('monitor/cacheList', '%monitor/cache-list%', '缓存列表', 'CacheListPage'),
('system/user', '%system/user%', '用户管理', 'UserPage'),
('system/role', '%system/role%', '角色管理', 'RolePage'),
('system/menu', '%system/menu%', '菜单管理', 'MenuPage'),
('system/dept', '%system/dept%', '部门管理', 'DeptPage'),
('system/dict', '%system/dict%', '字典管理', 'DictPage'),
('system/config', '%system/config%', '参数配置', 'ConfigPage'),
('project', '%project/list%', '项目管理', 'ProjectPage 后端标准路径'),
('project/list', '%project/list%', '项目管理', 'ProjectPage 前端兼容路径'),
('project/detail', '%project/detail%', '项目详情', 'ProjectDetailPage'),
('project/demandManage', '%project/%DemandManage%', '需求管理', 'DemandManagePage 后端路径'),
('demandManage', '%project/%DemandManage%', '需求管理', 'DemandManagePage 前端兼容路径'),
('workAppraisal/manager', '%workAppraisal/ManagerPage%', '经理评分', 'ManagerPage'),
('workAppraisal/normalWorker', '%workAppraisal/NormalWorkerPage%', '员工评分', 'NormalWorkerPage'),
('workAppraisal/managerUser', '%workAppraisal/ManagerUserPage%', '经理评分用户', 'ManagerUserPage'),
('workAppraisal/taskSet', '%workAppraisal/TaskSetPage%', '任务设置', 'TaskSetPage'),
('workAppraisal/detail', '%workAppraisal/AppraisalDetailPage%', '评分详情', 'AppraisalDetailPage'),
('workAppraisal/taskModule', '%workAppraisal/AppraisalDashboardPage%', '绩效看板', 'AppraisalDashboardPage'),
('workAppraisal/dashboard', '%workAppraisal/AppraisalDashboardPage%', '绩效看板(兼容)', 'AppraisalDashboardPage 别名路由'),
('workAppraisal/moduleDetail', '%workAppraisal/AppraisalModuleDetailPage%', '模块详情', 'AppraisalModuleDetailPage'),
('workAppraisal/myPerformance', '%projectBank/userScore%', '我的绩效(兼容)', 'UserScorePage 前端映射');

SELECT
  s.path,
  s.menu_name,
  s.remark
FROM tmp_page_menu_specs s
WHERE NOT EXISTS (
  SELECT 1
  FROM sys_menu m
  WHERE m.menu_type IN ('M', 'C')
    AND (
      m.path = s.path
      OR (s.component_like IS NOT NULL AND s.component_like <> '' AND m.component LIKE s.component_like)
    )
)
ORDER BY s.path;
