USE cattletrade;

-- 直接修复脚本：强制更新被截断的字段值
-- 使用最直接的方式，确保更新成功

-- ============================================
-- 步骤1：先查看当前值（用于确认）
-- ============================================
-- SELECT id, name, page_url, authority FROM sys_menu WHERE id IN (88, 93) AND is_delete = 0;

-- ============================================
-- 步骤2：修复进仓管理菜单（id=88）
-- ============================================
-- 当前错误值：warehouse/warehouselr
-- 目标正确值：warehouse/warehouseIn

UPDATE sys_menu 
SET 
    page_url = 'warehouse/warehouseIn',
    update_time = NOW()
WHERE id = 88;

-- 验证更新是否成功
SELECT 
    id, 
    name, 
    page_url, 
    CHAR_LENGTH(page_url) as page_url_len,
    'warehouse/warehouseIn' as expected,
    CHAR_LENGTH('warehouse/warehouseIn') as expected_len
FROM sys_menu 
WHERE id = 88;

-- ============================================
-- 步骤3：修复出仓管理菜单（id=93）
-- ============================================
-- 当前错误值：page_url = warehouse/warehouseO, authority = warehouseout:li
-- 目标正确值：page_url = warehouse/warehouseOut, authority = warehouseout:list

UPDATE sys_menu 
SET 
    page_url = 'warehouse/warehouseOut',
    authority = 'warehouseout:list',
    update_time = NOW()
WHERE id = 93;

-- 验证更新是否成功
SELECT 
    id, 
    name, 
    page_url, 
    CHAR_LENGTH(page_url) as page_url_len,
    authority,
    CHAR_LENGTH(authority) as authority_len,
    'warehouse/warehouseOut' as expected_page_url,
    CHAR_LENGTH('warehouse/warehouseOut') as expected_page_url_len,
    'warehouseout:list' as expected_authority,
    CHAR_LENGTH('warehouseout:list') as expected_authority_len
FROM sys_menu 
WHERE id = 93;

-- ============================================
-- 步骤4：最终验证（执行后运行此查询）
-- ============================================
SELECT 
    id, 
    parent_id, 
    type, 
    name, 
    route_url, 
    page_url, 
    CHAR_LENGTH(page_url) as page_url_len,
    authority,
    CHAR_LENGTH(authority) as authority_len
FROM sys_menu 
WHERE id IN (88, 93)
  AND is_delete = 0;

-- 预期结果：
-- id=88: page_url='warehouse/warehouseIn', page_url_len=20
-- id=93: page_url='warehouse/warehouseOut', page_url_len=21, authority='warehouseout:list', authority_len=16

