-- =============================================================================
-- sys_menu 订阅模块菜单插入脚本（字段与 api/model/sys_menu.js 一致）
-- path：不含斜杠（与首页 path=home 等约定一致）；component 仍为 subscription/xxx 供前端映射
-- 执行前请备份。若已存在同名「订阅管理」父菜单，请先删除子菜单再删父级，或改下面名称。
-- 若数据库表另有 created_at / updated_at 等列，请在 INSERT 中补全或给默认值。
-- =============================================================================

-- -----------------------------------------------------------------------------
-- 方案一（推荐）：一级目录「订阅管理」+ 子菜单，parent_id 指向父记录 id
-- -----------------------------------------------------------------------------

INSERT INTO sys_menu
  (name, parent_id, icon, path, type, model_id, form_id, component, api_path, is_show_menu, is_show, sort)
VALUES
  (
    '订阅管理',
    0,
    'ios-apps',
    'subscription',
    '菜单',
    0,
    0,
    '',
    '',
    1,
    1,
    900
  );

SET @sub_parent_id = LAST_INSERT_ID();

INSERT INTO sys_menu
  (name, parent_id, icon, path, type, model_id, form_id, component, api_path, is_show_menu, is_show, sort)
VALUES
  ('运营看板', @sub_parent_id, 'ios-speedometer', 'subscription_dashboard', '页面', 0, 0, 'subscription/dashboard', '', 1, 1, 10),
  ('业务用户', @sub_parent_id, 'ios-people', 'subscription_user', '页面', 0, 0, 'subscription/user', '', 1, 1, 20),
  ('套餐管理', @sub_parent_id, 'ios-pricetags', 'subscription_plan', '页面', 0, 0, 'subscription/plan', '', 1, 1, 30),
  ('订阅列表', @sub_parent_id, 'ios-list', 'subscription_subscription', '页面', 0, 0, 'subscription/subscription', '', 1, 1, 40),
  ('API Token', @sub_parent_id, 'ios-key', 'subscription_token', '页面', 0, 0, 'subscription/token', '', 1, 1, 50),
  ('支付确认', @sub_parent_id, 'ios-cash', 'subscription_payment', '页面', 0, 0, 'subscription/payment', '', 1, 1, 60),
  ('月用量', @sub_parent_id, 'ios-analytics', 'subscription_usage', '页面', 0, 0, 'subscription/usage', '', 1, 1, 70),
  ('审计日志', @sub_parent_id, 'ios-paper', 'subscription_audit', '页面', 0, 0, 'subscription/audit', '', 1, 1, 80);

-- -----------------------------------------------------------------------------
-- 方案二（可选）：全部挂在根节点 parent_id=0，无父级目录（与 component-map 仍一致）
-- 若已执行方案一，请勿再执行下面语句，避免重复菜单。
-- -----------------------------------------------------------------------------
/*
INSERT INTO sys_menu
  (name, parent_id, icon, path, type, model_id, form_id, component, api_path, is_show_menu, is_show, sort)
VALUES
  ('运营看板', 0, 'ios-speedometer', 'subscription_dashboard', '页面', 0, 0, 'subscription/dashboard', '', 1, 1, 910),
  ('业务用户', 0, 'ios-people', 'subscription_user', '页面', 0, 0, 'subscription/user', '', 1, 1, 920),
  ('套餐管理', 0, 'ios-pricetags', 'subscription_plan', '页面', 0, 0, 'subscription/plan', '', 1, 1, 930),
  ('订阅列表', 0, 'ios-list', 'subscription_subscription', '页面', 0, 0, 'subscription/subscription', '', 1, 1, 940),
  ('API Token', 0, 'ios-key', 'subscription_token', '页面', 0, 0, 'subscription/token', '', 1, 1, 950),
  ('支付确认', 0, 'ios-cash', 'subscription_payment', '页面', 0, 0, 'subscription/payment', '', 1, 1, 960),
  ('月用量', 0, 'ios-analytics', 'subscription_usage', '页面', 0, 0, 'subscription/usage', '', 1, 1, 970),
  ('审计日志', 0, 'ios-paper', 'subscription_audit', '页面', 0, 0, 'subscription/audit', '', 1, 1, 980);
*/
