<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.tangguo.mapper.BbsMomentCommentMapper">
    
    <select id="selectBbsMomentCommentList" resultType="com.tangguo.domain.BbsMomentComment">
        SELECT
            m.content AS moment_content,
            c.*
        FROM
            bbs_moment_comment c
        LEFT JOIN
            bbs_moment m ON m.id = c.moment_id
        <where>
            <if test="1==1">
                c.parent_id IS NULL
            </if>
            <if test="comment.momentContent != null and comment.momentContent != ''">
                AND m.content LIKE CONCAT('%', #{comment.momentContent}, '%')
            </if>
        </where>
        ORDER BY
            c.create_time DESC
    </select>
    
    
    <select id="selectBbsMomentComments" resultType="com.tangguo.domain.BbsMomentComment">
        SELECT
            r.*
        FROM
            bbs_moment_comment r
        LEFT JOIN
            bbs_moment_comment c ON c.id = r.parent_id
        WHERE
            FIND_IN_SET(#{commentId}, r.ancestor_path) AND r.id != #{commentId}
        ORDER BY
            r.create_time
    </select>

</mapper>
