CommentDao

<?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="cn.jnu.core.dao.CommentDao" >

    <!-- 根据商品id查询出其所有评论 -->
    <select id="findCommentListByGoodsId" parameterType="Integer" resultType="Comment" >
        select comment_id, goods_id, a.user_id, username publisher, content, create_time time
        from m_user a, m_comment b
        where a.user_id = b.user_id and goods_id = #{goods_id}
    </select>
    
    <!-- 根据cid查询某一条评论 -->
    <select id="findCommentById" parameterType="Integer" resultType="Comment" >
        select comment_id, goods_id, a.user_id, username publisher, content, create_time time
        from m_user a, m_comment b
        where a.user_id = b.user_id and b.comment_id = #{comment_id}
    </select>
    
    <!-- 给gid对应的商品添加评论 -->
    <insert id="addComment" parameterType="Comment" >
        insert into m_comment
        values (
            #{comment_id, jdbcType=NUMERIC}, 
            #{goods_id, jdbcType=NUMERIC}, 
            #{user_id, jdbcType=NUMERIC}, 
            #{time, jdbcType=TIMESTAMP}, 
            #{content, jdbcType=VARCHAR}
        )
    </insert>
    
    <!-- 根据评论id删除评论 -->
    <delete id="removeComment" parameterType="Integer" >
        delete from m_comment
        where comment_id = #{comment_id}
    </delete>
</mapper>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 不能控制自己欲望的人永远无法获得自由。如果你想让生活听你的指挥,就要先控制行为的需求。如果不能对自己的欲望加以评估...
    温软的稻草阅读 3,434评论 0 3
  • 2019-01-09 天气 阴 我跟孩子我俩制定一个秘密计划,每天早起20分钟,背背英语单词,再复习复习...
    a9ea37b05bb5阅读 1,508评论 0 0
  • 疣体腐蚀剂
    单车快递阅读 1,040评论 0 1