-- 检查导航数据的SQL查询
-- 请将 {tenantId} 替换为实际的租户ID

-- 1. 检查网站基本信息
SELECT 
    website_id,
    tenant_id,
    tenant_name,
    website_name,
    running,
    version,
    expiration_time,
    create_time
FROM cms_website 
WHERE tenant_id = {tenantId};

-- 2. 检查顶部导航数据
SELECT 
    navigation_id,
    title,
    parent_id,
    model,
    path,
    icon,
    color,
    hide,
    top,
    bottom,
    position,
    sort_number,
    target,
    tenant_id,
    deleted
FROM cms_navigation 
WHERE tenant_id = {tenantId} 
  AND deleted = 0 
  AND hide = 0 
  AND (top = 0 OR position = 1)
ORDER BY sort_number ASC, position ASC, navigation_id ASC;

-- 3. 检查底部导航数据  
SELECT 
    navigation_id,
    title,
    parent_id,
    model,
    path,
    icon,
    color,
    hide,
    top,
    bottom,
    position,
    sort_number,
    target,
    tenant_id,
    deleted
FROM cms_navigation 
WHERE tenant_id = {tenantId} 
  AND deleted = 0 
  AND hide = 0 
  AND (bottom = 0 OR position = 2)
ORDER BY sort_number ASC, position ASC, navigation_id ASC;

-- 4. 检查所有导航数据（包括隐藏的）
SELECT 
    navigation_id,
    title,
    parent_id,
    model,
    path,
    icon,
    color,
    hide,
    top,
    bottom,
    position,
    sort_number,
    target,
    tenant_id,
    deleted,
    status
FROM cms_navigation 
WHERE tenant_id = {tenantId}
ORDER BY deleted ASC, hide ASC, sort_number ASC;

-- 5. 统计导航数据
SELECT 
    '总导航数' as type,
    COUNT(*) as count
FROM cms_navigation 
WHERE tenant_id = {tenantId}
UNION ALL
SELECT 
    '有效导航数' as type,
    COUNT(*) as count
FROM cms_navigation 
WHERE tenant_id = {tenantId} AND deleted = 0
UNION ALL
SELECT 
    '顶部导航数' as type,
    COUNT(*) as count
FROM cms_navigation 
WHERE tenant_id = {tenantId} AND deleted = 0 AND hide = 0 AND (top = 0 OR position = 1)
UNION ALL
SELECT 
    '底部导航数' as type,
    COUNT(*) as count
FROM cms_navigation 
WHERE tenant_id = {tenantId} AND deleted = 0 AND hide = 0 AND (bottom = 0 OR position = 2);
