<?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.pcloud.book.applet.dao.impl.AppletNewsCommentDaoImpl" >
  <resultMap id="BaseResultMap" type="com.pcloud.book.applet.entity.AppletNewsComment" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="news_id" property="newsId" jdbcType="BIGINT" />
    <result column="comment" property="comment" jdbcType="VARCHAR" />
    <result column="wechat_user_id" property="wechatUserId" jdbcType="BIGINT" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  </resultMap>

  <sql id="Base_Column_List" >
    id, news_id, comment, wechat_user_id, create_time
  </sql>

  <insert id="insert" parameterType="com.pcloud.book.applet.entity.AppletNewsComment" useGeneratedKeys="true" keyProperty="id">
    insert into applet_news_comment (
        news_id, comment, wechat_user_id, create_time
      )
    values (
      #{newsId}, #{comment}, #{wechatUserId}, NOW()
      )
  </insert>

    <select id="listNewsCommentByNewsId" parameterType="map" resultType="com.pcloud.book.applet.dto.AppletNewsCommentDTO">
    SELECT
    id, news_id newsId, comment, wechat_user_id wechatUserId, create_time createTime
    FROM applet_news_comment
    where
    news_id = #{newsId}
    ORDER BY create_time desc
    </select>

</mapper>