MusicSheetMapper.xml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.yonge.cooleshow.biz.dal.dao.MusicSheetDao">
  5. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.MusicSheet">
  6. <id column="id_" jdbcType="BIGINT" property="id"/>
  7. <result column="music_sheet_name_" jdbcType="VARCHAR" property="musicSheetName"/>
  8. <result column="user_id_" jdbcType="BIGINT" property="userId"/>
  9. <result column="composer_" jdbcType="VARCHAR" property="composer"/>
  10. <result column="music_subject_" jdbcType="VARCHAR" property="musicSubject"/>
  11. <result column="audio_type_" jdbcType="VARCHAR" property="audioType"/>
  12. <result column="music_tag_" jdbcType="VARCHAR" property="musicTag"/>
  13. <result column="play_speed_" jdbcType="INTEGER" property="playSpeed"/>
  14. <result column="can_evaluate_" jdbcType="TINYINT" property="canEvaluate"/>
  15. <result column="show_fingering_" jdbcType="TINYINT" property="showFingering"/>
  16. <result column="charge_type_" jdbcType="TINYINT" property="chargeType"/>
  17. <result column="audit_status_" jdbcType="TINYINT" property="auditStatus"/>
  18. <result column="sort_number_" jdbcType="INTEGER" property="sortNumber"/>
  19. <result column="top_flag_" jdbcType="TINYINT" property="topFlag"/>
  20. <result column="hot_flag_" jdbcType="TINYINT" property="hotFlag"/>
  21. <result column="music_price_" jdbcType="DECIMAL" property="musicPrice"/>
  22. <result column="audio_file_url_" jdbcType="VARCHAR" property="audioFileUrl"/>
  23. <result column="xml_file_url_" jdbcType="VARCHAR" property="xmlFileUrl"/>
  24. <result column="has_beat_" jdbcType="TINYINT" property="hasBeat"/>
  25. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  26. <result column="create_by_" jdbcType="BIGINT" property="createBy"/>
  27. <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
  28. <result column="update_by_" jdbcType="BIGINT" property="updateBy"/>
  29. <result column="remark_" jdbcType="VARCHAR" property="remark"/>
  30. </resultMap>
  31. <sql id="Base_Column_List">
  32. t.id_ as id ,
  33. t.music_sheet_name_ as musicSheetName,
  34. t.user_id_ as userId,
  35. t.composer_ as composer,
  36. t.music_subject_ as musicSubject,
  37. t.audio_type_ as audioType,
  38. t.music_tag_ as musicTag,
  39. t.play_speed_ as playSpeed,
  40. t.can_evaluate_ as canEvaluate,
  41. t.show_fingering_ as showFingering,
  42. t.charge_type_ as chargeType,
  43. t.state_ as state,
  44. t.audit_status_ as auditStatus,
  45. t.sort_number_ as sortNumber,
  46. t.top_flag_ as topFlag,
  47. t.hot_flag_ as hotFlag,
  48. t.music_price_ as musicPrice,
  49. t.audio_file_url_ as audioFileUrl,
  50. t.xml_file_url_ as xmlFileUrl,
  51. t.has_beat_ as hasBeat,
  52. t.create_time_ as createTime,
  53. t.create_by_ as createBy,
  54. t.update_time_ as updateTime,
  55. t.update_by_ as updateBy,
  56. t.remark_ as remark
  57. </sql>
  58. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  59. select <include refid="Base_Column_List"/>
  60. ,su.username_ as addName
  61. ,su.avatar_ as addUserAvatar
  62. ,(select group_concat(mt.name_) from music_tag mt
  63. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  64. ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
  65. from music_sheet t
  66. left join sys_user su on t.create_by_ = su.id_
  67. <where>
  68. <include refid="QueryInfo"/>
  69. </where>
  70. </select>
  71. <sql id="QueryInfo">
  72. <if test="param.idAndName != null and param.idAndName != ''">
  73. and (t.id_ like concat('%',#{param.idAndName},'%') or
  74. t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  75. </if>
  76. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  77. and
  78. <foreach collection="param.musicTagIdList" separator="and" item="item">
  79. find_in_set(#{item},t.music_tag_)
  80. </foreach>
  81. </if>
  82. <if test="param.subjectIds != null and param.subjectIds != ''">
  83. and
  84. <foreach collection="param.subjectIdList" separator="and" item="item">
  85. find_in_set(#{item},t.music_subject_)
  86. </foreach>
  87. </if>
  88. <if test="param.state != null">
  89. and t.state_ = #{param.state}
  90. </if>
  91. <if test="param.auditStatus != null">
  92. and t.audit_status_ = #{param.auditStatus}
  93. </if>
  94. <if test="param.createBy != null">
  95. and t.create_by_ = #{param.createBy}
  96. </if>
  97. </sql>
  98. <select id="selectAlbumDetailPage" resultType="com.yonge.cooleshow.biz.dal.entity.MusicSheet">
  99. select <include refid="Base_Column_List"/>
  100. from music_sheet t
  101. left join album_music_relate amr on t.id_ = amr.music_sheet_id_
  102. <where>
  103. <if test="param.idAndName != null and param.idAndName != ''">
  104. and (t.id_ like concat('%',#{param.idAndName},'%') or
  105. t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  106. </if>
  107. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  108. and
  109. <foreach collection="param.musicTagIdList" separator="and" item="item">
  110. find_in_set(#{item},t.music_tag_)
  111. </foreach>
  112. </if>
  113. <if test="param.subjectIds != null and param.subjectIds != ''">
  114. and
  115. <foreach collection="param.subjectIdList" separator="and" item="item">
  116. find_in_set(#{item},t.music_subject_)
  117. </foreach>
  118. </if>
  119. <if test="param.state != null">
  120. and t.state_ = #{param.state}
  121. </if>
  122. <if test="param.id != null">
  123. <if test="param.type == 2">
  124. and amr.album_id_ = #{param.id}
  125. order by amr.create_time_
  126. </if>
  127. <if test="param.type == 1">
  128. and (amr.album_id_ &lt;&gt; #{param.id} or amr.album_id_ is null)
  129. </if>
  130. </if>
  131. </where>
  132. </select>
  133. <select id="detail" resultMap="DetailResultMap">
  134. SELECT
  135. <include refid="Base_Column_List"/>
  136. ,msa.id_ as accompanimentId
  137. ,msa.music_sheet_id_ as accompanimentMusicSheetId
  138. ,msa.music_subject_ as accompanimentMusicSubject
  139. ,msa.audio_file_url_ as accompanimentAudioFileUrl
  140. ,msa.sort_number_ as accompanimentSortNumber
  141. ,msa.create_time_ as accompanimentCreateTime
  142. FROM music_sheet t
  143. left join music_sheet_accompaniment msa on msa.music_sheet_id_ = t.id_
  144. where t.id_ = #{id}
  145. order by msa.sort_number_
  146. </select>
  147. <resultMap id="DetailResultMap" type="com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo">
  148. <id column="id" jdbcType="BIGINT" property="id"/>
  149. <result column="musicSheetName" jdbcType="VARCHAR" property="musicSheetName"/>
  150. <result column="userId" jdbcType="BIGINT" property="userId"/>
  151. <result column="composer" jdbcType="VARCHAR" property="composer"/>
  152. <result column="musicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  153. <result column="audioType" jdbcType="VARCHAR" property="audioType"/>
  154. <result column="musicTag" jdbcType="VARCHAR" property="musicTag"/>
  155. <result column="playSpeed" jdbcType="INTEGER" property="playSpeed"/>
  156. <result column="canEvaluate" jdbcType="TINYINT" property="canEvaluate"/>
  157. <result column="showFingering" jdbcType="TINYINT" property="showFingering"/>
  158. <result column="chargeType" jdbcType="TINYINT" property="chargeType"/>
  159. <result column="auditStatus" jdbcType="TINYINT" property="auditStatus"/>
  160. <result column="sortNumber" jdbcType="INTEGER" property="sortNumber"/>
  161. <result column="topFlag" jdbcType="TINYINT" property="topFlag"/>
  162. <result column="hotFlag" jdbcType="TINYINT" property="hotFlag"/>
  163. <result column="musicPrice" jdbcType="DECIMAL" property="musicPrice"/>
  164. <result column="audioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  165. <result column="xmlFileUrl" jdbcType="VARCHAR" property="xmlFileUrl"/>
  166. <result column="hasBeat" jdbcType="TINYINT" property="hasBeat"/>
  167. <result column="createTime" jdbcType="TIMESTAMP" property="createTime"/>
  168. <result column="createBy" jdbcType="BIGINT" property="createBy"/>
  169. <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime"/>
  170. <result column="updateBy" jdbcType="BIGINT" property="updateBy"/>
  171. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  172. <collection property="background" ofType="com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment">
  173. <id column="accompanimentId" jdbcType="BIGINT" property="id"/>
  174. <result column="accompanimentMusicSheetId" jdbcType="BIGINT" property="musicSheetId"/>
  175. <result column="accompanimentMusicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  176. <result column="accompanimentAudioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  177. <result column="accompanimentSortNumber" jdbcType="TINYINT" property="sortNumber"/>
  178. <result column="accompanimentCreateTime" jdbcType="TIMESTAMP" property="createTime"/>
  179. </collection>
  180. </resultMap>
  181. <select id="selectStudentMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  182. select <include refid="Base_Column_List"/>
  183. ,su.username_ as addName
  184. ,su.avatar_ as addUserAvatar
  185. ,(select group_concat(mt.name_) from music_tag mt
  186. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  187. ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
  188. <if test="param.studentId != null">
  189. ,if(mf.id_ is not null,1,0) as favorite
  190. </if>
  191. from music_sheet t
  192. left join sys_user su on t.create_by_ = su.id_
  193. <if test="param.studentId != null">
  194. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mf.user_id_ = #{param.studentId}
  195. </if>
  196. <where>
  197. <include refid="QueryInfo"/>
  198. </where>
  199. </select>
  200. <select id="selectMyMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  201. select <include refid="Base_Column_List"/>
  202. ,su.username_ as addName
  203. ,su.avatar_ as addUserAvatar
  204. ,(select group_concat(mt.name_) from music_tag mt
  205. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  206. ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
  207. from music_sheet t
  208. left join sys_user su on t.create_by_ = su.id_
  209. left join music_sheet_purchase_record mspr on mspr.music_sheet_id_ = t.id_
  210. <where>
  211. <include refid="QueryInfo"/>
  212. <if test="param.studentId != null">
  213. and mspr.student_id_ = #{param.studentId}
  214. and mspr.order_status_ = 1
  215. </if>
  216. </where>
  217. </select>
  218. <select id="selectFavoriteMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  219. select <include refid="Base_Column_List"/>
  220. ,su.username_ as addName
  221. ,su.avatar_ as addUserAvatar
  222. ,(select group_concat(mt.name_) from music_tag mt
  223. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  224. ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
  225. ,if(mf.id_ is not null,1,0) as favorite
  226. from music_sheet t
  227. left join sys_user su on t.create_by_ = su.id_
  228. left join music_favorite mf on t.id_ = mf.music_sheet_id_
  229. <where>
  230. <include refid="QueryInfo"/>
  231. <if test="param.studentId != null">
  232. and mf.user_id_ = #{param.studentId}
  233. </if>
  234. </where>
  235. </select>
  236. <select id="selectPracticeMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  237. select <include refid="Base_Column_List"/>
  238. ,su.username_ as addName
  239. ,su.avatar_ as addUserAvatar
  240. ,(select group_concat(mt.name_) from music_tag mt
  241. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  242. ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
  243. from music_sheet t
  244. left join sys_user su on t.create_by_ = su.id_
  245. <where>
  246. <include refid="QueryInfo"/>
  247. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  248. and t.id_ in
  249. <foreach collection="practiceMusicIdList" item="item" open="(" close=")" separator=",">
  250. #{item}
  251. </foreach>
  252. </if>
  253. </where>
  254. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  255. order by field(t.id_,
  256. <foreach collection="practiceMusicIdList" item="item" separator=",">
  257. #{item}
  258. </foreach>
  259. </if>
  260. )
  261. </select>
  262. </mapper>