INSERT INTO sd_nodes (id,project_id, parent_id, node_order, node_type, node_name, custom3, create_time) VALUES (#{item.id},#{item.projectId}, #{item.parentId}, #{item.nodeOrder}, #{item.nodeType}, #{item.nodeName}, #{item.custom3}, #{item.createTime}) UPDATE sd_nodes a LEFT JOIN sd_nodes b ON b.project_id = a.project_id AND a.custom3 = CONCAT( b.custom3,b.node_name, '/' ) SET a.parent_id = b.id WHERE b.id IS NOT NULL WITH RECURSIVE node_tree AS ( SELECT id FROM sd_nodes WHERE id = #{nodeId} UNION ALL SELECT n.id FROM sd_nodes n INNER JOIN node_tree t ON n.parent_id = t.id ) DELETE FROM sd_nodes WHERE id IN (SELECT id FROM node_tree)