#namespace("Resource")
    -- 获取指定节点为根的子树
    #sql("getStructureTree")
        SELECT structure_id, parent_id FROM t_resource_structure WHERE structure_id = #para(parent_id)
        UNION  ALL
        SELECT structure_id, parent_id FROM t_resource_structure WHERE parent_id = #para(parent_id)
        UNION ALL
        SELECT b.structure_id, b.parent_id FROM t_resource_structure b
         JOIN (SELECT structure_id FROM t_resource_structure WHERE parent_id = #para(parent_id))
             AS a ON b.parent_id = a.structure_id
        UNION ALL
        SELECT b.structure_id, b.parent_id FROM t_resource_structure b
         JOIN (SELECT structure_id FROM t_resource_structure WHERE parent_id IN (SELECT structure_id FROM t_resource_base WHERE parent_id = #para(parent_id)))
        AS a ON b.parent_id = a.structure_id
    #end
    -- 资源查询列表
    #sql("getResourceBaseList")
        select * from t_resource_base as t1 where 1=1
            #if(stage_id)
               and t1.stage_id = #para(stage_id)
            #end
            #if(scheme_id)
               and t1.scheme_id = #para(scheme_id)
            #end
            #if(subject_id)
               and t1.subject_id = #para(subject_id)
            #end
            #if(keyword)
                and t1.resource_name like concat('%',#para(keyword),'%')
            #end
            #if(ids)
               and t1.structure_id in  #para(ids,'in')
            #end
    #end
#end