<?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.FtbCourseGainedMapper">


    <!--    获取用户有无对该心得点赞-->
    <select id="getGainedListOfChapterEnd" resultType="jnpf.model.cultivate.po.gained.FtbCourseGainedEntity">
        select g.*,c.commentNum from (select  F_CourseId courseId,F_ChapterId chapterId,F_Content content,F_Status `status`,F_ReadType readType,F_OrganizeId organizeId,F_PositionId positionId,F_CreatorUserId creatorUserId,F_Id id,F_CreatorTime creatorTime
                                      from  ftb_cultivate_course_gained where F_ChapterId = #{chapterId} and F_EnabledMark = 1) g left join (select F_GainedId,count(1) commentNum from ftb_training_course_gained_comment GROUP BY F_GainedId ) c on g.id = c.F_GainedId ORDER BY c.commentNum desc,g.creatorTime desc limit 2
    </select>
</mapper>