判断列表是否有子项,如果有则返回ture

 <select id="lazyList"  resultMap="menuVOResultMap">
        SELECT
            menu.*,
            (
                SELECT
                    CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END
            FROM
                blade_menu
            WHERE
                parent_id = menu.id AND is_deleted = 0
        ) AS "has_children"
        FROM
            blade_menu menu
        WHERE menu.is_deleted = 0
        <if test="param1!=null">
            and menu.parent_id = #{param1}
        </if>
        <if test="param2.name!=null and param2.name!=''">
            and menu.name like concat(concat('%', #{param2.name}),'%')
        </if>
        <if test="param2.code!=null and param2.code!=''">
            and menu.code like concat(concat('%', #{param2.code}),'%')
        </if>
        <if test="param2.alias!=null and param2.alias!=''">
            and menu.alias like concat(concat('%', #{param2.alias}),'%')
        </if>
        ORDER BY menu.sort
    </select>

  

posted @ 2021-01-06 16:22  红尘沙漏  阅读(97)  评论(0编辑  收藏  举报