-- Adjust parent_id to the local algorithm menu before execution. declare @parent_id bigint = 0; if not exists (select 1 from sys_menu where perms = 'algorithm:tidy:query') begin insert into sys_menu(menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) values (N'理货控制', @parent_id, 1, 'tidy', 'algorithm/tidy/index', null, 'TidyControl', 1, 0, 'C', '0', '0', 'algorithm:tidy:query', 'switch', 'admin', getdate(), '', null, N'自动/手动理货模式控制'); end; declare @menu_id bigint = (select top 1 menu_id from sys_menu where perms = 'algorithm:tidy:query'); if @menu_id is not null and not exists (select 1 from sys_menu where perms = 'algorithm:tidy:edit') begin insert into sys_menu(menu_name, parent_id, order_num, path, component, query, route_name, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark) values (N'理货模式修改', @menu_id, 1, '#', '', null, '', 1, 0, 'F', '0', '0', 'algorithm:tidy:edit', '#', 'admin', getdate(), '', null, ''); end;