PhotoAlbumMapper.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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.PhotoAlbumDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.PhotoAlbum" id="PhotoAlbum">
  9. <result column="id_" property="id" />
  10. <result column="music_group_id_" property="musicGroupId" />
  11. <result column="name_" property="name" />
  12. <result column="client_show_" property="clientShow" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  13. <result column="type_" property="type" />
  14. <result column="cover_url_" property="coverUrl" />
  15. <result column="cover_thumbnail_url_" property="coverThumbnailUrl" />
  16. <result column="order_" property="order" />
  17. <result column="time_line_" property="timeLine" />
  18. <result column="create_time_" property="createTime" />
  19. <result column="update_time_" property="updateTime" />
  20. <result column="tenant_id_" property="tenantId"/>
  21. </resultMap>
  22. <!-- 根据主键查询一条记录 -->
  23. <select id="get" resultMap="PhotoAlbum" >
  24. SELECT * FROM photo_album_ WHERE id_ = #{id}
  25. </select>
  26. <!-- 全查询 -->
  27. <select id="findAll" resultMap="PhotoAlbum">
  28. SELECT * FROM photo_album_ where tenant_id_ = #{tenantId} ORDER BY id_
  29. </select>
  30. <!-- 向数据库增加一条记录 -->
  31. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.PhotoAlbum" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  32. INSERT INTO photo_album_ (music_group_id_,name_,client_show_,type_,cover_url_,cover_thumbnail_url_,create_time_,update_time_,order_,time_line_,tenant_id_)
  33. VALUES(#{musicGroupId},#{name},#{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  34. #{type},#{coverUrl},#{coverThumbnailUrl},NOW(),NOW(),#{order},#{timeLine},#{tenantId})
  35. </insert>
  36. <!-- 根据主键查询一条记录 -->
  37. <update id="update" parameterType="com.ym.mec.biz.dal.entity.PhotoAlbum">
  38. UPDATE photo_album_ <set>
  39. <if test="timeLine != null">
  40. time_line_ = #{timeLine},
  41. </if>
  42. <if test="coverUrl != null">
  43. cover_url_ = #{coverUrl},
  44. </if>
  45. <if test="order != null">
  46. order_ = #{order},
  47. </if>
  48. <if test="coverThumbnailUrl != null">
  49. cover_thumbnail_url_ = #{coverThumbnailUrl},
  50. </if>
  51. <if test="clientShow != null">
  52. client_show_ = #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  53. </if>
  54. <if test="musicGroupId != null">
  55. music_group_id_ = #{musicGroupId},
  56. </if>
  57. <if test="type != null">
  58. type_ = #{type},
  59. </if>
  60. <if test="name != null">
  61. name_ = #{name},
  62. </if>
  63. update_time_ = NOW()
  64. </set> WHERE id_ = #{id} and tenant_id_ = #{tenantId}
  65. </update>
  66. <update id="batchUpdate">
  67. <foreach collection="photoAlbumList" item="album" separator=";">
  68. UPDATE photo_album_ <set>
  69. <if test="album.timeLine != null">
  70. time_line_ = #{album.timeLine},
  71. </if>
  72. <if test="album.coverUrl != null">
  73. cover_url_ = #{album.coverUrl},
  74. </if>
  75. <if test="album.order != null">
  76. order_ = #{album.order},
  77. </if>
  78. <if test="album.coverThumbnailUrl != null">
  79. cover_thumbnail_url_ = #{album.coverThumbnailUrl},
  80. </if>
  81. <if test="album.clientShow != null">
  82. client_show_ = #{album.clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  83. </if>
  84. <if test="album.musicGroupId != null">
  85. music_group_id_ = #{album.musicGroupId},
  86. </if>
  87. <if test="album.type != null">
  88. type_ = #{album.type},
  89. </if>
  90. <if test="album.name != null">
  91. name_ = #{album.name},
  92. </if>
  93. update_time_ = NOW()
  94. </set> WHERE id_ = #{album.id} and tenant_id_ = #{album.tenantId}
  95. </foreach>
  96. </update>
  97. <!-- 根据主键删除一条记录 -->
  98. <delete id="delete" >
  99. DELETE FROM photo_album_ WHERE id_ = #{id}
  100. </delete>
  101. <delete id="deleteByIds">
  102. DELETE FROM photo_album_ WHERE FIND_IN_SET(id_,#{ids})
  103. </delete>
  104. <!-- 分页查询 -->
  105. <select id="queryPage" resultMap="PhotoAlbum" parameterType="map">
  106. SELECT * FROM photo_album_
  107. <include refid="queryPageSql"/>
  108. ORDER BY order_ ASC,id_ DESC
  109. <include refid="global.limit"/>
  110. </select>
  111. <sql id="queryPageSql">
  112. <where>
  113. tenant_id_ = #{tenantId}
  114. <if test="timeLine != null and timeLine != ''">
  115. AND DATE_FORMAT(time_line_,"%Y%m") = #{timeLine}
  116. </if>
  117. <if test="year != null and year != ''">
  118. AND DATE_FORMAT(time_line_,"%Y") = #{year}
  119. </if>
  120. <if test="type != null and type != ''">
  121. AND type_ = #{type}
  122. </if>
  123. <if test="musicGroupId != null and musicGroupId != ''">
  124. AND music_group_id_ = #{musicGroupId}
  125. </if>
  126. <if test="clientShow != null">
  127. AND client_show_ = #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  128. </if>
  129. </where>
  130. </sql>
  131. <!-- 查询当前表的总记录数 -->
  132. <select id="queryCount" resultType="int">
  133. SELECT COUNT(id_) FROM photo_album_
  134. <include refid="queryPageSql"/>
  135. </select>
  136. <select id="countTotalNumByAlbumIds" resultType="java.util.Map">
  137. SELECT photo_album_id_ 'key',COUNT(id_) 'value' FROM photo_
  138. WHERE photo_album_id_ IN
  139. <foreach collection="albumIds" separator="," item="albumId" close=")" open="(">
  140. #{albumId}
  141. </foreach>
  142. <if test="clientShow != null">
  143. AND client_show_ = #{clientShow,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  144. </if>
  145. GROUP BY photo_album_id_
  146. </select>
  147. <select id="findByTypeAndGroupId" resultMap="PhotoAlbum">
  148. SELECT * FROM photo_album_ WHERE music_group_id_ = #{musicGroupId} AND type_ = #{type} LIMIT 1
  149. </select>
  150. </mapper>