PhotoMapper.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.PhotoDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.Photo" id="Photo">
  9. <result column="id_" property="id" />
  10. <result column="photo_album_id_" property="photoAlbumId" />
  11. <result column="name_" property="name" />
  12. <result column="client_show_" property="clientShow" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  13. <result column="url_" property="url" />
  14. <result column="thumbnail_url_" property="thumbnailUrl" />
  15. <result column="order_" property="order" />
  16. <result column="create_time_" property="createTime" />
  17. <result column="update_time_" property="updateTime" />
  18. <result column="tenant_id_" property="tenantId"/>
  19. </resultMap>
  20. <!-- 根据主键查询一条记录 -->
  21. <select id="get" resultMap="Photo" >
  22. SELECT * FROM photo_ WHERE id_ = #{id}
  23. </select>
  24. <!-- 全查询 -->
  25. <select id="findAll" resultMap="Photo">
  26. SELECT * FROM photo_ where tenant_id_ = #{tenantId} ORDER BY id_
  27. </select>
  28. <!-- 向数据库增加一条记录 -->
  29. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Photo" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  30. INSERT INTO photo_ (photo_album_id_,name_,client_show_,url_,thumbnail_url_,create_time_,update_time_,order_,tenant_id_)
  31. VALUES(#{photoAlbumId},#{name},#{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{url},#{thumbnailUrl},NOW(),NOW(),#{order},#{tenantId})
  32. </insert>
  33. <insert id="batchInsert">
  34. INSERT INTO photo_ (photo_album_id_,name_,client_show_,url_,thumbnail_url_,create_time_,update_time_,order_,tenant_id_)
  35. VALUES
  36. <foreach collection="photoList" item="photo" separator=",">
  37. (#{photo.photoAlbumId},#{photo.name},#{photo.clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  38. #{photo.url},#{photo.thumbnailUrl},NOW(),NOW(),#{photo.order},#{photo.tenantId})
  39. </foreach>
  40. </insert>
  41. <!-- 根据主键查询一条记录 -->
  42. <update id="update" parameterType="com.ym.mec.biz.dal.entity.Photo">
  43. UPDATE photo_ <set>
  44. <if test="order != null">
  45. order_ = #{order},
  46. </if>
  47. <if test="photoAlbumId != null">
  48. photo_album_id_ = #{photoAlbumId},
  49. </if>
  50. <if test="url != null">
  51. url_ = #{url},
  52. </if>
  53. <if test="clientShow != null">
  54. client_show_ = #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  55. </if>
  56. <if test="thumbnailUrl != null">
  57. thumbnail_url_ = #{thumbnailUrl},
  58. </if>
  59. <if test="name != null">
  60. name_ = #{name},
  61. </if>
  62. update_time_ = NOW()
  63. </set> WHERE id_ = #{id} and tenant_id_ = #{tenantId}
  64. </update>
  65. <update id="batchUpdate">
  66. <foreach collection="photoList" item="item" separator=";">
  67. UPDATE photo_ <set>
  68. <if test="item.order != null">
  69. order_ = #{item.order},
  70. </if>
  71. <if test="item.photoAlbumId != null">
  72. photo_album_id_ = #{item.photoAlbumId},
  73. </if>
  74. <if test="item.url != null">
  75. url_ = #{item.url},
  76. </if>
  77. <if test="item.clientShow != null">
  78. client_show_ = #{item.clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  79. </if>
  80. <if test="item.thumbnailUrl != null">
  81. thumbnail_url_ = #{item.thumbnailUrl},
  82. </if>
  83. <if test="item.name != null">
  84. name_ = #{item.name},
  85. </if>
  86. update_time_ = NOW()
  87. </set> WHERE id_ = #{item.id} and tenant_id_ = #{item.tenantId}
  88. </foreach>
  89. </update>
  90. <!-- 根据主键删除一条记录 -->
  91. <delete id="delete" >
  92. DELETE FROM photo_ WHERE id_ = #{id}
  93. </delete>
  94. <delete id="deleteByAlbumIds">
  95. DELETE FROM photo_ WHERE FIND_IN_SET(photo_album_id_,#{albumIds})
  96. </delete>
  97. <delete id="deleteByIds">
  98. DELETE FROM photo_ WHERE FIND_IN_SET(id_,#{ids})
  99. </delete>
  100. <!-- 分页查询 -->
  101. <select id="queryPage" resultMap="Photo" parameterType="map">
  102. SELECT * FROM photo_
  103. <include refid="queryPageSql"/>
  104. ORDER BY order_ ASC,id_ DESC
  105. <include refid="global.limit"/>
  106. </select>
  107. <sql id="queryPageSql">
  108. <where>
  109. tenant_id_ = #{tenantId}
  110. <if test="photoAlbumId != null">
  111. AND photo_album_id_ = #{photoAlbumId}
  112. </if>
  113. <if test="clientShow != null">
  114. AND client_show_ = #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  115. </if>
  116. </where>
  117. </sql>
  118. <!-- 查询当前表的总记录数 -->
  119. <select id="queryCount" resultType="int">
  120. SELECT COUNT(id_) FROM photo_
  121. <include refid="queryPageSql"/>
  122. </select>
  123. </mapper>