-- 为oroqen_culture_category表添加has_child字段
ALTER TABLE oroqen_culture_category ADD COLUMN has_child varchar(3) DEFAULT '0' COMMENT '是否有子节点(0-否,1-是)';

-- 更新现有数据，为有子节点的分类设置has_child为'1'
UPDATE oroqen_culture_category 
SET has_child = '1' 
WHERE id IN (
    SELECT parent_id FROM (
        SELECT DISTINCT parent_id 
        FROM oroqen_culture_category 
        WHERE parent_id IS NOT NULL AND parent_id != ''
    ) AS temp_table
);

-- 为oroqen_product_category表添加has_child字段（如果不存在）
ALTER TABLE oroqen_product_category ADD COLUMN has_child varchar(3) DEFAULT '0' COMMENT '是否有子节点(0-否,1-是)';

-- 更新现有数据，为有子节点的产品分类设置has_child为'1'
UPDATE oroqen_product_category 
SET has_child = '1' 
WHERE id IN (
    SELECT parent_id FROM (
        SELECT DISTINCT parent_id 
        FROM oroqen_product_category 
        WHERE parent_id IS NOT NULL AND parent_id != ''
    ) AS temp_table
);