【每周总结】

        这一段时间也一直在写项目。因为上一次在写项目的时候我没有写关于评论的内容,所以这一次我就准备尝试写这一部分。由于项目开始的时候我先写了用户模块的内容,所以关于帖子的评论我最近才完成。我感觉这一部分理解了之后也不难,在查询的时候用list集合接收子评论的内容,然后在xml文件中把结果集封装好就可以了。

<resultMap id="postCommentPojo" type="com.xingchen.pojo.PostComment">
        <id property="postCommentId" column="post_comment_id"/>
        <result property="userId" column="user_id"/>
        <result property="userName" column="user_name"/>
        <result property="userHeadshotUrl" column="user_headshot_url"/>
        <result property="objectId" column="object_id"/>
        <result property="commentContent" column="comment_content"/>
        <result property="commentTime" column="comment_time"/>
        <collection property="childrenComment" ofType="com.xingchen.pojo.PostComment">
            <id property="postCommentId" column="children_id"/>
            <result property="userId" column="children_user_id"/>
            <result property="userName" column="children_user_name"/>
            <result property="userHeadshotUrl" column="children_user_headshot"/>
            <result property="objectId" column="children_object_id"/>
            <result property="objectName" column="children_user_name"/>
            <result property="commentContent" column="children_comment_content"/>
            <result property="commentTime" column="children_comment_time"/>
        </collection>
</resultMap>

<select id="viewComment" resultMap="postCommentPojo" parameterType="java.lang.Integer">
        select a.post_comment_id,
               a.user_id,
               b.user_name,
               b.user_headshot_url,
               a.object_id,
               a.comment_content,
               a.comment_time,
               c.post_comment_id as children_id,
               c.user_id as children_user_id,
               d.user_name as children_user_name,
               d.user_headshot_url as children_user_headshot,
               c.object_id as children_object_id,
               d.user_name as children_user_name,
               c.comment_content as children_comment_content,
               c.comment_time as children_comment_time
        from post_comment as a
        inner join user as b on a.user_id = b.user_id
        left join post_comment as c on a.post_comment_id = c.object_id
        inner join user as d on c.user_id = d.user_id
        where a.object_id = #{postId} and a.comment_state = '0' and c.comment_state = '1'
</select>

         这一段时间我的接口也写的差不多了,就剩下登录没有写好。在接下来的时间我准备把重心放在完善接口和回顾基础知识上面。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值