<?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="jnpf.cultivate.mapper.FtbCourseGainedCommentMapper">

    <!-- 通用结果映射 -->
    <resultMap id="baseResultMap" type="jnpf.model.cultivate.po.gained.FtbCourseGainedCommentEntity">
        <id column="F_Id" property="id"/>
        <result column="F_CourseId" property="courseId"/>
        <result column="F_ChapterId" property="chapterId"/>
        <result column="F_GainedId" property="gainedId"/>
        <result column="F_Content" property="content"/>
        <result column="F_ParentId" property="parentId"/>
        <result column="F_OrganizeId" property="organizeId"/>
        <result column="F_PositionId" property="positionId"/>
        <result column="F_Account" property="account"/>
        <result column="F_RealName" property="realName"/>
        <result column="F_CreatorTime" property="creatorTime"/>
        <result column="F_CreatorUserId" property="creatorUserId"/>
    </resultMap>



    <!-- app 端评论分页列表查询 -->
    <select id="appCommentPage" resultType="jnpf.model.cultivate.v2.gained.vo.V2AppCourseGainedCommentVO">
        SELECT
            c.F_Id id,
            c.F_CourseId courseId,
            c.F_ChapterId chapterId,
            c.F_GainedId gainedId,
            c.F_Content content,
            c.F_ParentId parentId,
            c.F_OrganizeId organizeId,
            c.F_PositionId positionId,
            c.F_Account account,
            c.F_RealName realName,
            c.F_CreatorTime creatorTime,
            c.F_CreatorUserId creatorUserId
        FROM ftb_cultivate_course_gained_comment c
        WHERE c.F_GainedId = #{req.gainedId}  and (c.F_ParentId ="" or c.F_ParentId IS NULL)
        ORDER BY c.F_CreatorTime desc
    </select>

    <select id="appSimpleComment" resultType="jnpf.model.cultivate.v2.gained.vo.V2SimpleCourseGainedCommentVO">
        SELECT c.F_Id       id,
               c.F_ParentId parentId
        FROM ftb_cultivate_course_gained_comment c
        WHERE c.F_GainedId = #{gainedId}
    </select>

    <select id="queryAllByIds" resultType="jnpf.model.cultivate.po.gained.FtbCourseGainedCommentEntity">
        SELECT
            c.F_Id id,
            c.F_CourseId courseId,
            c.F_ChapterId chapterId,
            c.F_GainedId gainedId,
            c.F_Content content,
            c.F_ParentId parentId,
            c.F_OrganizeId organizeId,
            c.F_PositionId positionId,
            c.F_Account account,
            c.F_RealName realName,
            c.F_CreatorTime creatorTime,
            c.F_CreatorUserId creatorUserId
        FROM ftb_cultivate_course_gained_comment c
        WHERE c.F_Id IN
        <foreach item="item" collection="childIds" separator="," open="(" close=")" index="">
            #{item}
        </foreach>
        ORDER BY c.F_CreatorTime asc
    </select>

    <select id="queryNextAllComment" resultType="jnpf.model.cultivate.po.gained.FtbCourseGainedCommentEntity">

        SELECT
        c.F_Id id,
        c.F_CourseId courseId,
        c.F_ChapterId chapterId,
        c.F_GainedId gainedId,
        c.F_Content content,
        c.F_ParentId parentId,
        c.F_OrganizeId organizeId,
        c.F_PositionId positionId,
        c.F_Account account,
        c.F_RealName realName,
        c.F_CreatorTime creatorTime,
        c.F_CreatorUserId creatorUserId
        FROM ftb_cultivate_course_gained_comment c
        WHERE c.F_Path LIKE CONCAT(#{firstCommentId}, '%')
        ORDER BY c.F_CreatorTime asc
    </select>
</mapper>
