-- ========================================
-- PMS模块完整菜单配置SQL
-- ========================================
-- 删除已存在的菜单
DELETE FROM sys_menu
WHERE menu_id IN (
        1925809154452340738,
        -- PMS主菜单
        1926240962230853634,
        -- 客户联系人
        1926240962230853635,
        -- 客户联系人查询
        1926240962230853636,
        -- 客户联系人新增
        1926240962230853637,
        -- 客户联系人修改
        1926240962230853638,
        -- 客户联系人删除
        1926240962230853639,
        -- 客户联系人导出
        1926240963610779650,
        -- 联系人标签
        1926240963610779651,
        -- 联系人标签查询
        1926240963610779652,
        -- 联系人标签新增
        1926240963610779653,
        -- 联系人标签修改
        1926240963610779654,
        -- 联系人标签删除
        1926240963610779655,
        -- 联系人标签导出
        1926240964416086017,
        -- 联系人标签关联
        1926240964416086018,
        -- 联系人标签关联查询
        1926240964416086019,
        -- 联系人标签关联新增
        1926240964416086020,
        -- 联系人标签关联修改
        1926240964416086021,
        -- 联系人标签关联删除
        1926240964416086022 -- 联系人标签关联导出
    );
-- 1. PMS主菜单
INSERT INTO sys_menu (
        menu_id,
        menu_name,
        parent_id,
        order_num,
        path,
        component,
        is_frame,
        is_cache,
        menu_type,
        visible,
        status,
        perms,
        icon,
        create_dept,
        create_by,
        create_time,
        remark
    )
VALUES (
        1925809154452340738,
        'PMS管理',
        '0',
        '5',
        'pms',
        null,
        1,
        0,
        'M',
        '0',
        '0',
        '',
        'ep:office-building',
        103,
        1,
        NOW(),
        'PMS管理目录'
    );
-- 2. 客户联系人菜单
INSERT INTO sys_menu (
        menu_id,
        menu_name,
        parent_id,
        order_num,
        path,
        component,
        is_frame,
        is_cache,
        menu_type,
        visible,
        status,
        perms,
        icon,
        create_dept,
        create_by,
        create_time,
        remark
    )
VALUES (
        1926240962230853634,
        '客户联系人',
        '1925809154452340738',
        '1',
        'contact',
        'pms/contact/index',
        1,
        0,
        'C',
        '0',
        '0',
        'pms:contacts:list',
        '#',
        103,
        1,
        NOW(),
        '客户联系人菜单'
    );
-- 客户联系人按钮权限
INSERT INTO sys_menu (
        menu_id,
        menu_name,
        parent_id,
        order_num,
        path,
        component,
        is_frame,
        is_cache,
        menu_type,
        visible,
        status,
        perms,
        icon,
        create_dept,
        create_by,
        create_time,
        remark
    )
VALUES (
        1926240962230853635,
        '客户联系人查询',
        1926240962230853634,
        '1',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contacts:query',
        '#',
        103,
        1,
        NOW(),
        ''
    ),
    (
        1926240962230853636,
        '客户联系人新增',
        1926240962230853634,
        '2',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contacts:add',
        '#',
        103,
        1,
        NOW(),
        ''
    ),
    (
        1926240962230853637,
        '客户联系人修改',
        1926240962230853634,
        '3',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contacts:edit',
        '#',
        103,
        1,
        NOW(),
        ''
    ),
    (
        1926240962230853638,
        '客户联系人删除',
        1926240962230853634,
        '4',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contacts:remove',
        '#',
        103,
        1,
        NOW(),
        ''
    ),
    (
        1926240962230853639,
        '客户联系人导出',
        1926240962230853634,
        '5',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contacts:export',
        '#',
        103,
        1,
        NOW(),
        ''
    );
-- 3. 联系人标签菜单
INSERT INTO sys_menu (
        menu_id,
        menu_name,
        parent_id,
        order_num,
        path,
        component,
        is_frame,
        is_cache,
        menu_type,
        visible,
        status,
        perms,
        icon,
        create_dept,
        create_by,
        create_time,
        remark
    )
VALUES (
        1926240963610779650,
        '联系人标签',
        '1925809154452340738',
        '2',
        'tag',
        'pms/tag/index',
        1,
        0,
        'C',
        '0',
        '0',
        'pms:contactTags:list',
        '#',
        103,
        1,
        NOW(),
        '联系人标签菜单'
    );
-- 联系人标签按钮权限
INSERT INTO sys_menu (
        menu_id,
        menu_name,
        parent_id,
        order_num,
        path,
        component,
        is_frame,
        is_cache,
        menu_type,
        visible,
        status,
        perms,
        icon,
        create_dept,
        create_by,
        create_time,
        remark
    )
VALUES (
        1926240963610779651,
        '联系人标签查询',
        1926240963610779650,
        '1',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contactTags:query',
        '#',
        103,
        1,
        NOW(),
        ''
    ),
    (
        1926240963610779652,
        '联系人标签新增',
        1926240963610779650,
        '2',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contactTags:add',
        '#',
        103,
        1,
        NOW(),
        ''
    ),
    (
        1926240963610779653,
        '联系人标签修改',
        1926240963610779650,
        '3',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contactTags:edit',
        '#',
        103,
        1,
        NOW(),
        ''
    ),
    (
        1926240963610779654,
        '联系人标签删除',
        1926240963610779650,
        '4',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contactTags:remove',
        '#',
        103,
        1,
        NOW(),
        ''
    ),
    (
        1926240963610779655,
        '联系人标签导出',
        1926240963610779650,
        '5',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contactTags:export',
        '#',
        103,
        1,
        NOW(),
        ''
    );
-- 4. 标签关联管理菜单
INSERT INTO sys_menu (
        menu_id,
        menu_name,
        parent_id,
        order_num,
        path,
        component,
        is_frame,
        is_cache,
        menu_type,
        visible,
        status,
        perms,
        icon,
        create_dept,
        create_by,
        create_time,
        remark
    )
VALUES (
        1926240964416086017,
        '标签关联管理',
        '1925809154452340738',
        '3',
        'tag-relation',
        'pms/tag-relation/index',
        1,
        0,
        'C',
        '0',
        '0',
        'pms:contactTagRelations:list',
        '#',
        103,
        1,
        NOW(),
        '联系人标签关联菜单'
    );
-- 标签关联管理按钮权限
INSERT INTO sys_menu (
        menu_id,
        menu_name,
        parent_id,
        order_num,
        path,
        component,
        is_frame,
        is_cache,
        menu_type,
        visible,
        status,
        perms,
        icon,
        create_dept,
        create_by,
        create_time,
        remark
    )
VALUES (
        1926240964416086018,
        '标签关联查询',
        1926240964416086017,
        '1',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contactTagRelations:query',
        '#',
        103,
        1,
        NOW(),
        ''
    ),
    (
        1926240964416086019,
        '标签关联新增',
        1926240964416086017,
        '2',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contactTagRelations:add',
        '#',
        103,
        1,
        NOW(),
        ''
    ),
    (
        1926240964416086020,
        '标签关联修改',
        1926240964416086017,
        '3',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contactTagRelations:edit',
        '#',
        103,
        1,
        NOW(),
        ''
    ),
    (
        1926240964416086021,
        '标签关联删除',
        1926240964416086017,
        '4',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contactTagRelations:remove',
        '#',
        103,
        1,
        NOW(),
        ''
    ),
    (
        1926240964416086022,
        '标签关联导出',
        1926240964416086017,
        '5',
        '#',
        '',
        1,
        0,
        'F',
        '0',
        '0',
        'pms:contactTagRelations:export',
        '#',
        103,
        1,
        NOW(),
        ''
    );
-- 为超级管理员角色分配所有PMS权限
INSERT INTO sys_role_menu (role_id, menu_id)
SELECT 1,
    menu_id
FROM sys_menu
WHERE menu_id IN (
        1925809154452340738,
        1926240962230853634,
        1926240962230853635,
        1926240962230853636,
        1926240962230853637,
        1926240962230853638,
        1926240962230853639,
        1926240963610779650,
        1926240963610779651,
        1926240963610779652,
        1926240963610779653,
        1926240963610779654,
        1926240963610779655,
        1926240964416086017,
        1926240964416086018,
        1926240964416086019,
        1926240964416086020,
        1926240964416086021,
        1926240964416086022
    )
    AND NOT EXISTS (
        SELECT 1
        FROM sys_role_menu
        WHERE role_id = 1
            AND sys_role_menu.menu_id = sys_menu.menu_id
    );
COMMIT;