-- 车辆同步管理菜单 SQL
-- 菜单 ID自增，可以根据你的数据库实际情况调整

-- 父菜单（车辆管理）ID，假设为2020，需要根据实际情况调整
SET @parentMenuId = (SELECT menu_id FROM sys_menu WHERE menu_name = '车辆管理' AND menu_type = 'M' LIMIT 1);

-- 如果没有车辆管理父菜单，先创建
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
SELECT '车辆管理', 0, 4, 'vehicle', NULL, 1, 0, 'M', '0', '0', '', 'car', 'admin', sysdate(), '', NULL, '车辆管理目录'
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE menu_name = '车辆管理' AND menu_type = 'M');

-- 重新获取父菜单ID
SET @parentMenuId = (SELECT menu_id FROM sys_menu WHERE menu_name = '车辆管理' AND menu_type = 'M' LIMIT 1);

-- 车辆同步管理菜单
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
SELECT '车辆同步', @parentMenuId, 5, 'vehicleSync', 'system/vehicleSync/index', 1, 0, 'C', '0', '0', 'system:vehicleSync:list', 'upload', 'admin', sysdate(), '', NULL, '车辆同步菜单'
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'system:vehicleSync:list');

-- 获取车辆同步菜单ID
SET @vehicleSyncMenuId = (SELECT menu_id FROM sys_menu WHERE perms = 'system:vehicleSync:list' LIMIT 1);

-- 车辆同步按钮
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
SELECT '同步车辆', @vehicleSyncMenuId, 1, '#', '', 1, 0, 'F', '0', '0', 'system:vehicleSync:sync', '#', 'admin', sysdate(), '', NULL, ''
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'system:vehicleSync:sync');

-- 车辆同步查询按钮
INSERT INTO sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
SELECT '查询', @vehicleSyncMenuId, 2, '#', '', 1, 0, 'F', '0', '0', 'system:vehicleSync:query', '#', 'admin', sysdate(), '', NULL, ''
FROM DUAL
WHERE NOT EXISTS (SELECT 1 FROM sys_menu WHERE perms = 'system:vehicleSync:query');
