SysMusicScoreMapper.xml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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.SysMusicScoreDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.SysMusicScore" id="SysMusicScore">
  9. <result column="id_" property="id" />
  10. <result column="name_" property="name" />
  11. <result column="categories_name_" property="categoriesName" />
  12. <result column="music_score_categories_id_" property="musicScoreCategoriesId" />
  13. <result column="categories_id_" property="categoriesId" />
  14. <result column="type_" property="type" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  15. <result column="subject_ids_" property="subjectIds" />
  16. <result column="speed_" property="speed" />
  17. <result column="url_" property="url" />
  18. <result column="metronome_url_" property="metronomeUrl" />
  19. <result column="accompaniment_url_" property="accompanimentUrl" />
  20. <result column="accompaniment_metronome_url_" property="accompanimentMetronomeUrl" />
  21. <result column="create_user_id_" property="createUserId" />
  22. <result column="create_user_name_" property="createUserName" />
  23. <result column="is_open_metronome_" property="isOpenMetronome" />
  24. <result column="del_flag_" property="delFlag" />
  25. <result column="show_flag_" property="showFlag" />
  26. <result column="order_" property="order" />
  27. <result column="rank_ids_" property="rankIds" />
  28. <result column="render_from_" property="renderFrom" />
  29. <result column="enable_evaluation_" property="enableEvaluation" />
  30. <result column="subject_id_" property="subjectId" />
  31. <result column="client_type_" property="clientType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  32. <result column="update_time_" property="updateTime" />
  33. <result column="create_time_" property="createTime" />
  34. </resultMap>
  35. <!-- 根据主键查询一条记录 -->
  36. <select id="get" resultMap="SysMusicScore" >
  37. SELECT * FROM sys_music_score WHERE id_ = #{id}
  38. </select>
  39. <!-- 全查询 -->
  40. <select id="findAll" resultMap="SysMusicScore">
  41. SELECT * FROM sys_music_score ORDER BY id_
  42. </select>
  43. <!-- 向数据库增加一条记录 -->
  44. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.SysMusicScore" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  45. INSERT INTO sys_music_score (music_score_categories_id_,name_,type_,speed_,url_,metronome_url_,create_user_id_,order_,
  46. update_time_,create_time_,client_type_,rank_ids_,render_from_,enable_evaluation_,show_flag_)
  47. VALUES(#{musicScoreCategoriesId},#{name},#{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  48. #{speed},#{url},#{metronomeUrl},#{createUserId},#{order},NOW(),NOW(),#{clientType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  49. #{rankIds},#{renderFrom},#{enableEvaluation},#{showFlag})
  50. </insert>
  51. <!-- 根据主键查询一条记录 -->
  52. <update id="update" parameterType="com.ym.mec.biz.dal.entity.SysMusicScore">
  53. UPDATE sys_music_score <set>
  54. <if test="showFlag != null">
  55. show_flag_ = #{showFlag},
  56. </if>
  57. <if test="clientType != null">
  58. client_type_ = #{clientType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  59. </if>
  60. rank_ids_ = #{rankIds},
  61. <if test="renderFrom != null">
  62. render_from_ = #{renderFrom},
  63. </if>
  64. <if test="enableEvaluation != null">
  65. enable_evaluation_ = #{enableEvaluation},
  66. </if>
  67. <if test="order != null">
  68. order_ = #{order},
  69. </if>
  70. <if test="delFlag != null">
  71. del_flag_ = #{delFlag},
  72. </if>
  73. <if test="musicScoreCategoriesId != null">
  74. music_score_categories_id_ = #{musicScoreCategoriesId},
  75. </if>
  76. <if test="createUserId != null">
  77. create_user_id_ = #{createUserId},
  78. </if>
  79. metronome_url_ = #{metronomeUrl},
  80. url_ = #{url},
  81. <if test="subjectIds != null and subjectIds != ''">
  82. subject_ids_ = #{subjectIds},
  83. </if>
  84. <if test="type != null">
  85. type_ = #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  86. </if>
  87. <if test="name != null and name != ''">
  88. name_ = #{name},
  89. </if>
  90. <if test="speed != null">
  91. speed_ = #{speed},
  92. </if>
  93. update_time_ = NOW()
  94. </set>
  95. WHERE id_ = #{id}
  96. </update>
  97. <!-- 根据主键删除一条记录 -->
  98. <update id="delete" >
  99. UPDATE sys_music_score SET del_flag_ = 1 WHERE id_ = #{id}
  100. </update>
  101. <!-- 分页查询 -->
  102. <select id="queryPage" resultMap="SysMusicScore" parameterType="map">
  103. SELECT ses.*,su.real_name_ create_user_name_,smsc.name_ categories_name_,smsc.id_ categories_id_,
  104. smsa.mp3_url_ accompaniment_url_,smsa.metronome_mp3_url_ accompaniment_metronome_url_,smsa.is_open_metronome_,smsa.subject_id_
  105. FROM sys_music_score ses
  106. LEFT JOIN sys_music_score_accompaniment smsa ON smsa.exam_song_id_ = ses.id_
  107. LEFT JOIN sys_user su ON ses.create_user_id_ = su.id_
  108. LEFT JOIN sys_music_score_categories smsc ON smsc.id_ = ses.music_score_categories_id_
  109. <include refid="queryPageSql"/>
  110. GROUP BY ses.id_
  111. ORDER BY ses.music_score_categories_id_ DESC,ses.order_ ASC,ses.create_time_ DESC
  112. <include refid="global.limit"/>
  113. </select>
  114. <!-- 查询当前表的总记录数 -->
  115. <select id="queryCount" resultType="int">
  116. SELECT COUNT(DISTINCT ses.id_) FROM sys_music_score ses
  117. LEFT JOIN sys_music_score_categories smsc ON smsc.id_ = ses.music_score_categories_id_
  118. LEFT JOIN sys_music_score_accompaniment smsa ON smsa.exam_song_id_ = ses.id_
  119. <include refid="queryPageSql"/>
  120. </select>
  121. <select id="findByIds" resultMap="SysMusicScore">
  122. SELECT * FROM sys_music_score WHERE FIND_IN_SET(id_,#{musicScoreIds})
  123. </select>
  124. <select id="countBuyCategoriesIds" resultType="java.lang.Integer">
  125. SELECT COUNT(0) FROM sys_music_score WHERE FIND_IN_SET(music_score_categories_id_,#{categoriesIds}) AND del_flag_ = 0
  126. </select>
  127. <sql id="queryPageSql">
  128. <where>
  129. ses.del_flag_ = 0
  130. <if test="organId != null and organId != null">
  131. AND INTE_ARRAY(smsc.organ_id_,#{organId})
  132. </if>
  133. <if test="categoriesId != null">
  134. AND FIND_IN_SET(ses.music_score_categories_id_,#{categoriesId})
  135. </if>
  136. <if test="search != null and search != ''">
  137. AND (ses.id_ = #{search} OR ses.name_ LIKE CONCAT('%',#{search},'%'))
  138. </if>
  139. <if test="showFlag != null">
  140. AND ses.show_flag_ = #{showFlag}
  141. </if>
  142. <if test="subjectId != null">
  143. AND smsa.subject_id_ = #{subjectId}
  144. </if>
  145. <if test="clientType != null">
  146. AND ses.client_type_ = #{clientType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
  147. </if>
  148. <if test="type != null and type == 'COMMON'">
  149. AND ses.type_ = #{type}
  150. </if>
  151. <if test="type != null and type == 'ALL'">
  152. <if test="createUserId != null">
  153. AND (ses.type_ = 'COMMON' OR (ses.create_user_id_ = #{createUserId} AND ses.type_ = 'PERSON'))
  154. </if>
  155. </if>
  156. <if test="type != null and type == 'PERSON'">
  157. <if test="createUserId != null">
  158. AND ses.type_ = #{type} AND ses.create_user_id_ = #{createUserId}
  159. </if>
  160. <if test="createUserId == null">
  161. AND ses.type_ = #{type}
  162. </if>
  163. </if>
  164. <if test="rankType != null">
  165. <if test="rankType == 0">
  166. AND ses.rank_ids_ IS NULL
  167. </if>
  168. <if test="rankType == 1">
  169. AND ses.rank_ids_ IS NOT NULL AND ses.rank_ids_ != ''
  170. </if>
  171. </if>
  172. <if test="type == null or type == ''">
  173. <if test="createUserId != null">
  174. AND ses.create_user_id_ = #{createUserId}
  175. </if>
  176. </if>
  177. </where>
  178. </sql>
  179. </mapper>