USE youlai_admin;

-- 会员管理菜单初始化
-- 说明：
-- 1. 本脚本负责会员后台管理菜单、按钮权限和系统管理员授权。
-- 2. 会员前台站点后续独立建设，此处仅覆盖管理后台会员运营入口。

-- 一级目录：会员中心
INSERT INTO `sys_menu`
(`id`, `parent_id`, `tree_path`, `name`, `type`, `route_name`, `route_path`, `component`, `perm`,
 `always_show`, `keep_alive`, `visible`, `sort`, `icon`, `redirect`, `create_time`, `update_time`, `params`)
VALUES
(1300, 0, '0', '会员中心', 'C', 'Member', '/member', 'Layout', NULL,
 1, NULL, 1, 11, 'user-filled', '/member/user', now(), now(), NULL)
ON DUPLICATE KEY UPDATE
`name` = VALUES(`name`),
`route_path` = VALUES(`route_path`),
`component` = VALUES(`component`),
`always_show` = VALUES(`always_show`),
`visible` = VALUES(`visible`),
`sort` = VALUES(`sort`),
`icon` = VALUES(`icon`),
`redirect` = VALUES(`redirect`),
`update_time` = now();

-- 会员管理
INSERT INTO `sys_menu`
(`id`, `parent_id`, `tree_path`, `name`, `type`, `route_name`, `route_path`, `component`, `perm`,
 `always_show`, `keep_alive`, `visible`, `sort`, `icon`, `redirect`, `create_time`, `update_time`, `params`)
VALUES
(1310, 1300, '0,1300', '会员管理', 'M', 'MemberUser', 'user', 'member/user/index', NULL,
 0, 1, 1, 1, 'avatar', NULL, now(), now(), NULL),
(13101, 1310, '0,1300,1310', '会员查询', 'B', NULL, '', NULL, 'member:user:list',
 NULL, NULL, 1, 1, '', NULL, now(), now(), NULL),
(13102, 1310, '0,1300,1310', '会员新增', 'B', NULL, '', NULL, 'member:user:create',
 NULL, NULL, 1, 2, '', NULL, now(), now(), NULL),
(13103, 1310, '0,1300,1310', '会员修改', 'B', NULL, '', NULL, 'member:user:update',
 NULL, NULL, 1, 3, '', NULL, now(), now(), NULL)
ON DUPLICATE KEY UPDATE
`name` = VALUES(`name`),
`route_name` = VALUES(`route_name`),
`route_path` = VALUES(`route_path`),
`component` = VALUES(`component`),
`perm` = VALUES(`perm`),
`keep_alive` = VALUES(`keep_alive`),
`visible` = VALUES(`visible`),
`sort` = VALUES(`sort`),
`icon` = VALUES(`icon`),
`update_time` = now();

-- 系统管理员授权
INSERT IGNORE INTO `sys_role_menu` (`role_id`, `menu_id`) VALUES
(2, 1300),
(2, 1310), (2, 13101), (2, 13102), (2, 13103);
