CommentMapper.xml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.chelvc.cloud.vehicle.server.dao.CommentMapper">
  4. <resultMap id="SIMPLE_COMMENT_RESULT_MAP" type="com.chelvc.cloud.vehicle.api.dto.CommentDTO">
  5. <id column="id" property="id" jdbcType="BIGINT"/>
  6. <result column="user_id" property="userId" jdbcType="BIGINT"/>
  7. <result column="score" property="score" jdbcType="DOUBLE"/>
  8. <result column="content" property="content" jdbcType="VARCHAR"/>
  9. <result column="attachments" property="attachments" jdbcType="VARCHAR"
  10. typeHandler="com.chelvc.framework.database.handler.FilesTypeHandler"/>
  11. <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
  12. </resultMap>
  13. <select id="listGoodsComments" resultMap="SIMPLE_COMMENT_RESULT_MAP">
  14. select id, user_id, score, content, attachments, create_time
  15. from `comment`
  16. <where>
  17. goods_id = #{goodsId}
  18. <if test="param.offset != null">
  19. and id > #{param.offset}
  20. </if>
  21. </where>
  22. order by create_time desc limit #{param.size}
  23. </select>
  24. <select id="getGoodsComments" resultMap="SIMPLE_COMMENT_RESULT_MAP">
  25. select id, user_id, score, content, attachments, create_time
  26. from `comment`
  27. <where>
  28. parent_id = #{parentId}
  29. <if test="goodsId != null">
  30. and goods_id = #{goodsId}
  31. </if>
  32. <if test="merchantId != null">
  33. and merchant_id = #{merchantId}
  34. </if>
  35. <if test="param.offset != null">
  36. and id > #{param.offset}
  37. </if>
  38. </where>
  39. order by create_time desc limit #{param.size}
  40. </select>
  41. </mapper>