1
0

CommentPictureDao.xml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.kmall.admin.dao.CommentPictureDao">
  4. <resultMap type="com.kmall.admin.entity.CommentPictureEntity" id="commentPictureMap">
  5. <result property="id" column="id"/>
  6. <result property="commentId" column="comment_id"/>
  7. <result property="picUrl" column="pic_url"/>
  8. <result property="sortOrder" column="sort_order"/>
  9. </resultMap>
  10. <select id="queryObject" resultType="com.kmall.admin.entity.CommentPictureEntity">
  11. select
  12. `id`,
  13. `comment_id`,
  14. `pic_url`,
  15. `sort_order`
  16. from mall_comment_picture
  17. where id = #{id}
  18. </select>
  19. <select id="queryList" resultType="com.kmall.admin.entity.CommentPictureEntity">
  20. select
  21. `id`,
  22. `comment_id`,
  23. `pic_url`,
  24. `sort_order`
  25. from mall_comment_picture
  26. WHERE 1=1
  27. <if test="commentId != null and commentId.trim() != ''">
  28. AND comment_id = #{commentId}
  29. </if>
  30. <choose>
  31. <when test="sidx != null and sidx.trim() != ''">
  32. order by ${sidx} ${order}
  33. </when>
  34. <otherwise>
  35. order by id desc
  36. </otherwise>
  37. </choose>
  38. <if test="offset != null and limit != null">
  39. limit #{offset}, #{limit}
  40. </if>
  41. </select>
  42. <select id="queryTotal" resultType="int">
  43. select count(*) from mall_comment_picture
  44. WHERE 1=1
  45. <if test="commentId != null and commentId.trim() != ''">
  46. AND comment_id = #{commentId}
  47. </if>
  48. </select>
  49. <insert id="save" parameterType="com.kmall.admin.entity.CommentPictureEntity" useGeneratedKeys="true" keyProperty="id">
  50. insert into mall_comment_picture(
  51. `comment_id`,
  52. `pic_url`,
  53. `sort_order`)
  54. values(
  55. #{commentId},
  56. #{picUrl},
  57. #{sortOrder})
  58. </insert>
  59. <update id="update" parameterType="com.kmall.admin.entity.CommentPictureEntity">
  60. update mall_comment_picture
  61. <set>
  62. <if test="commentId != null">`comment_id` = #{commentId},</if>
  63. <if test="picUrl != null">`pic_url` = #{picUrl},</if>
  64. <if test="sortOrder != null">`sort_order` = #{sortOrder}</if>
  65. </set>
  66. where id = #{id}
  67. </update>
  68. <delete id="delete">
  69. delete from mall_comment_picture where id = #{value}
  70. </delete>
  71. <delete id="deleteBatch">
  72. delete from mall_comment_picture where id in
  73. <foreach item="id" collection="array" open="(" separator="," close=")">
  74. #{id}
  75. </foreach>
  76. </delete>
  77. <delete id="deleteByCommentId">
  78. delete from mall_comment_picture where comment_id = #{commentId}
  79. </delete>
  80. </mapper>