MusicSheetMapper.xml 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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.mp3_type_ as mp3Type,
  53. t.create_time_ as createTime,
  54. t.create_by_ as createBy,
  55. t.update_time_ as updateTime,
  56. t.update_by_ as updateBy,
  57. t.del_flag_ as delFlag,
  58. t.source_type_ as sourceType,
  59. t.submit_audit_time_ as submitAuditTime,
  60. t.remark_ as remark
  61. </sql>
  62. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  63. select <include refid="Base_Column_List"/>
  64. ,su.username_ as addName
  65. ,su.avatar_ as addUserAvatar
  66. ,(select group_concat(mt.name_) from music_tag mt
  67. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  68. ,(select group_concat(s.name_) from subject s
  69. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  70. from music_sheet t
  71. left join sys_user su on t.create_by_ = su.id_
  72. <where>
  73. <include refid="QueryInfo"/>
  74. </where>
  75. order by t.id_ desc
  76. </select>
  77. <sql id="QueryInfo">
  78. <if test="param.idAndName != null and param.idAndName != ''">
  79. and (t.id_ like concat('%',#{param.idAndName},'%') or
  80. t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  81. </if>
  82. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  83. and
  84. <foreach collection="param.musicTagIdList" separator="and" item="item">
  85. find_in_set(#{item},t.music_tag_)
  86. </foreach>
  87. </if>
  88. <if test="param.subjectIds != null and param.subjectIds != ''">
  89. and
  90. <foreach collection="param.subjectIdList" separator="and" item="item">
  91. find_in_set(#{item},t.music_subject_)
  92. </foreach>
  93. </if>
  94. <if test="param.state != null">
  95. and t.state_ = #{param.state}
  96. </if>
  97. <if test="param.auditStatus != null">
  98. and t.audit_status_ = #{param.auditStatus}
  99. </if>
  100. <if test="param.createBy != null">
  101. and t.create_by_ = #{param.createBy}
  102. </if>
  103. <if test="param.delFlag != null">
  104. and t.del_flag_ = #{param.delFlag}
  105. </if>
  106. <if test="param.sourceType != null">
  107. and t.source_type_ = #{param.sourceType}
  108. </if>
  109. </sql>
  110. <select id="selectAlbumDetailPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  111. select distinct <include refid="Base_Column_List"/>
  112. ,(select group_concat(mt.name_) from music_tag mt
  113. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  114. ,(select group_concat(s.name_) from subject s
  115. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  116. from music_sheet t
  117. left join album_music_relate amr on t.id_ = amr.music_sheet_id_
  118. <where>
  119. <if test="param.idAndName != null and param.idAndName != ''">
  120. and (t.id_ like concat('%',#{param.idAndName},'%') or
  121. t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  122. </if>
  123. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  124. and
  125. <foreach collection="param.musicTagIdList" separator="and" item="item">
  126. find_in_set(#{item},t.music_tag_)
  127. </foreach>
  128. </if>
  129. <if test="param.subjectIds != null and param.subjectIds != ''">
  130. and
  131. <foreach collection="param.subjectIdList" separator="and" item="item">
  132. find_in_set(#{item},t.music_subject_)
  133. </foreach>
  134. </if>
  135. <if test="param.state != null">
  136. and t.state_ = #{param.state}
  137. </if>
  138. <if test="param.delFlag != null">
  139. and t.del_flag_ = #{param.delFlag}
  140. </if>
  141. <if test="param.id != null">
  142. <if test="param.type == 2">
  143. and amr.album_id_ = #{param.id}
  144. order by amr.create_time_
  145. </if>
  146. <if test="param.type == 1">
  147. and t.id_ not in(select amr2.music_sheet_id_ from album_music_relate amr2
  148. where amr2.album_id_ = #{param.id})
  149. </if>
  150. </if>
  151. </where>
  152. </select>
  153. <select id="detail" resultMap="DetailResultMap">
  154. SELECT
  155. <include refid="Base_Column_List"/>
  156. ,t.url_ as url
  157. ,t.midi_url_ as midiUrl
  158. ,t.metronome_url_ as metronomeUrl
  159. ,msa.id_ as accompanimentId
  160. ,msa.music_sheet_id_ as accompanimentMusicSheetId
  161. ,msa.music_subject_ as accompanimentMusicSubject
  162. ,msa.audio_file_url_ as accompanimentAudioFileUrl
  163. ,msa.sort_number_ as accompanimentSortNumber
  164. ,msa.create_time_ as accompanimentCreateTime
  165. ,msa.metronome_url_ as accompanimentMetronomeUrl
  166. ,msa.track_ as track
  167. ,su.username_ as userName
  168. ,(select group_concat(mt.name_) from music_tag mt
  169. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  170. ,(select group_concat(s.name_) from subject s
  171. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0) as subjectNames
  172. FROM music_sheet t
  173. left join music_sheet_accompaniment msa on msa.music_sheet_id_ = t.id_
  174. left join sys_user su on t.create_by_ = su.id_
  175. where t.id_ = #{id}
  176. order by msa.sort_number_
  177. </select>
  178. <resultMap id="DetailResultMap" type="com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo">
  179. <id column="id" jdbcType="BIGINT" property="id"/>
  180. <result column="musicSheetName" jdbcType="VARCHAR" property="musicSheetName"/>
  181. <result column="userId" jdbcType="BIGINT" property="userId"/>
  182. <result column="composer" jdbcType="VARCHAR" property="composer"/>
  183. <result column="musicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  184. <result column="audioType" jdbcType="VARCHAR" property="audioType"/>
  185. <result column="musicTag" jdbcType="VARCHAR" property="musicTag"/>
  186. <result column="playSpeed" jdbcType="INTEGER" property="playSpeed"/>
  187. <result column="canEvaluate" jdbcType="TINYINT" property="canEvaluate"/>
  188. <result column="showFingering" jdbcType="TINYINT" property="showFingering"/>
  189. <result column="chargeType" jdbcType="TINYINT" property="chargeType"/>
  190. <result column="auditStatus" jdbcType="TINYINT" property="auditStatus"/>
  191. <result column="sortNumber" jdbcType="INTEGER" property="sortNumber"/>
  192. <result column="topFlag" jdbcType="TINYINT" property="topFlag"/>
  193. <result column="hotFlag" jdbcType="TINYINT" property="hotFlag"/>
  194. <result column="musicPrice" jdbcType="DECIMAL" property="musicPrice"/>
  195. <result column="audioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  196. <result column="musicTagNames" jdbcType="VARCHAR" property="musicTagNames"/>
  197. <result column="subjectNames" jdbcType="VARCHAR" property="subjectNames"/>
  198. <result column="xmlFileUrl" jdbcType="VARCHAR" property="xmlFileUrl"/>
  199. <result column="hasBeat" jdbcType="TINYINT" property="hasBeat"/>
  200. <result column="createTime" jdbcType="TIMESTAMP" property="createTime"/>
  201. <result column="createBy" jdbcType="BIGINT" property="createBy"/>
  202. <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime"/>
  203. <result column="updateBy" jdbcType="BIGINT" property="updateBy"/>
  204. <result column="delFlag" jdbcType="BOOLEAN" property="delFlag"/>
  205. <result column="url" jdbcType="BOOLEAN" property="url"/>
  206. <result column="metronomeUrl" jdbcType="BOOLEAN" property="metronomeUrl"/>
  207. <result column="midiUrl" jdbcType="BOOLEAN" property="midiUrl"/>
  208. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  209. <result column="userName" jdbcType="VARCHAR" property="userName"/>
  210. <collection property="background" ofType="com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment">
  211. <id column="accompanimentId" jdbcType="BIGINT" property="id"/>
  212. <result column="accompanimentMusicSheetId" jdbcType="BIGINT" property="musicSheetId"/>
  213. <result column="accompanimentMusicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  214. <result column="accompanimentAudioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  215. <result column="accompanimentSortNumber" jdbcType="TINYINT" property="sortNumber"/>
  216. <result column="accompanimentCreateTime" jdbcType="TIMESTAMP" property="createTime"/>
  217. <result column="accompanimentMetronomeUrl" jdbcType="VARCHAR" property="metronomeUrl"/>
  218. <result column="track" jdbcType="VARCHAR" property="track"/>
  219. </collection>
  220. </resultMap>
  221. <select id="selectStudentMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  222. select <include refid="Base_Column_List"/>
  223. ,su.username_ as addName
  224. ,su.avatar_ as addUserAvatar
  225. ,(select group_concat(mt.name_) from music_tag mt
  226. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  227. ,(select group_concat(s.name_) from subject s
  228. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0) as subjectNames
  229. <if test="param.studentId != null">
  230. ,if(mf.id_ is not null,1,0) as favorite
  231. </if>
  232. from music_sheet t
  233. left join sys_user su on t.create_by_ = su.id_
  234. <if test="param.studentId != null">
  235. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mf.user_id_ = #{param.studentId}
  236. </if>
  237. <where>
  238. <include refid="QueryInfo"/>
  239. </where>
  240. order by t.id_ desc
  241. </select>
  242. <select id="selectMyMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  243. select <include refid="Base_Column_List"/>
  244. ,su.username_ as addName
  245. ,su.avatar_ as addUserAvatar
  246. ,(select group_concat(mt.name_) from music_tag mt
  247. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  248. ,(select group_concat(s.name_) from subject s
  249. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  250. from music_sheet t
  251. left join sys_user su on t.create_by_ = su.id_
  252. left join music_sheet_purchase_record mspr on mspr.music_sheet_id_ = t.id_
  253. <where>
  254. <include refid="QueryInfo"/>
  255. <if test="param.studentId != null">
  256. and mspr.student_id_ = #{param.studentId}
  257. and mspr.order_status_ = 1
  258. </if>
  259. </where>
  260. order by mspr.id_ desc
  261. </select>
  262. <select id="selectFavoriteMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  263. select <include refid="Base_Column_List"/>
  264. ,su.username_ as addName
  265. ,su.avatar_ as addUserAvatar
  266. ,(select group_concat(mt.name_) from music_tag mt
  267. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  268. ,(select group_concat(s.name_) from subject s
  269. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  270. ,if(mf.id_ is not null,1,0) as favorite
  271. from music_sheet t
  272. left join sys_user su on t.create_by_ = su.id_
  273. left join music_favorite mf on t.id_ = mf.music_sheet_id_
  274. <where>
  275. <include refid="QueryInfo"/>
  276. <if test="param.studentId != null">
  277. and mf.user_id_ = #{param.studentId}
  278. </if>
  279. </where>
  280. order by mf.id_ desc
  281. </select>
  282. <select id="selectPracticeMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  283. select <include refid="Base_Column_List"/>
  284. ,su.username_ as addName
  285. ,su.avatar_ as addUserAvatar
  286. ,(select group_concat(mt.name_) from music_tag mt
  287. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  288. ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
  289. from music_sheet t
  290. left join sys_user su on t.create_by_ = su.id_
  291. <where>
  292. <include refid="QueryInfo"/>
  293. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  294. and t.id_ in
  295. <foreach collection="practiceMusicIdList" item="item" open="(" close=")" separator=",">
  296. #{item}
  297. </foreach>
  298. </if>
  299. </where>
  300. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  301. order by field(t.id_,
  302. <foreach collection="practiceMusicIdList" item="item" separator=",">
  303. #{item}
  304. </foreach>
  305. </if>
  306. )
  307. </select>
  308. <select id="selectStudentOrderPage" resultType="com.yonge.cooleshow.biz.dal.vo.StudentMusicSheetOrderVo">
  309. select mspr.music_sheet_id_ as musicSheetId
  310. ,ms.music_sheet_name_ as musicSheetName
  311. ,ms.composer_ as composer
  312. ,ms.music_tag_ as musicTag
  313. ,(select group_concat(mt.name_) from music_tag mt
  314. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  315. ,mspr.purchase_price_ as purchasePrice
  316. ,mspr.order_no_ as orderNo
  317. ,mspr.purchase_time_ as purchaseTime
  318. from music_sheet_purchase_record mspr
  319. left join music_sheet ms on mspr.music_sheet_id_ = ms.id_
  320. <where>
  321. <if test="param.orderStatus != null">
  322. and mspr.order_status_ = #{param.orderStatus}
  323. </if>
  324. <if test="param.idAndName != null and param.idAndName != ''">
  325. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  326. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  327. </if>
  328. <if test="param.studentId != null">
  329. and mspr.student_id_ = #{param.studentId}
  330. </if>
  331. <if test="param.orderNo != null and param.orderNo != ''">
  332. and mspr.order_no_ = #{param.orderNo}
  333. </if>
  334. <if test="param.musicTagList != null and param.musicTagList.size() != 0">
  335. and
  336. <foreach collection="param.musicTagList" separator="and" item="item">
  337. find_in_set(#{item},ms.music_tag_)
  338. </foreach>
  339. </if>
  340. <if test="param.startTime != null">
  341. and mspr.purchase_time_ &gt; #{param.startTime}
  342. </if>
  343. <if test="param.endTime != null">
  344. and mspr.purchase_time_ &lt; #{param.endTime}
  345. </if>
  346. <if test="param.delFlag != null">
  347. and ms.del_flag_ = #{param.delFlag}
  348. </if>
  349. </where>
  350. order by mspr.id_ desc
  351. </select>
  352. <select id="selectTeacherPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  353. select ms.id_ as musicSheetId
  354. ,ms.music_sheet_name_ as musicSheetName
  355. ,ms.composer_ as composer
  356. ,ms.music_tag_ as musicTag
  357. ,(select group_concat(mt.name_) from music_tag mt
  358. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  359. ,ms.play_speed_ as playSpeed
  360. ,ms.music_price_ as musicPrice
  361. ,ms.create_time_ as createTime
  362. ,ms.audit_status_ as auditStatus
  363. ,su.username_ as auditName
  364. from music_sheet ms
  365. left join music_sheet_auth_record msar on ms.id_ = msar.music_sheet_id_
  366. left join sys_user su on msar.verify_user_id_ = su.id_
  367. <where>
  368. <if test="param.idAndName != null and param.idAndName != ''">
  369. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  370. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
  371. or ms.composer_ like concat('%',#{param.idAndName},'%'))
  372. </if>
  373. <if test="param.teacherId != null">
  374. and ms.create_by_ = #{param.teacherId}
  375. </if>
  376. <if test="param.startTime != null">
  377. and ms.create_time_ &gt; #{param.startTime}
  378. </if>
  379. <if test="param.endTime != null">
  380. and ms.create_time_ &lt; #{param.endTime}
  381. </if>
  382. <if test="param.delFlag != null">
  383. and ms.del_flag_ = #{param.delFlag}
  384. </if>
  385. </where>
  386. order by ms.id_ desc
  387. </select>
  388. <select id="selectAuditPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  389. select
  390. ms.create_by_ as teacherId
  391. ,su.username_ as username
  392. ,su.phone_ as phone
  393. ,ms.id_ as musicSheetId
  394. ,ms.music_sheet_name_ as musicSheetName
  395. ,ms.composer_ as composer
  396. ,ms.music_tag_ as musicTag
  397. ,(select group_concat(mt.name_) from music_tag mt
  398. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0) as musicTagNames
  399. ,ms.play_speed_ as playSpeed
  400. ,ms.music_price_ as musicPrice
  401. ,ms.create_time_ as createTime
  402. ,ms.audit_status_ as auditStatus
  403. ,su.username_ as auditName
  404. from music_sheet ms
  405. left join sys_user su on su.id_ = ms.create_by_
  406. left join music_sheet_auth_record msar on ms.id_ = msar.music_sheet_id_
  407. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  408. <where>
  409. ms.user_id_ &gt; 0
  410. <if test="param.idAndName != null and param.idAndName != ''">
  411. and (su.id_ like concat('%',#{param.idAndName} ,'%')
  412. or su.username_ like concat('%',#{param.idAndName},'%')
  413. or su.phone_ like concat('%',#{param.idAndName},'%'))
  414. </if>
  415. <if test="param.auditName != null and param.auditName != ''">
  416. and su2.username_ like concat('%',#{param.auditName},'%')
  417. </if>
  418. <if test="param.authStatus != null">
  419. and ms.audit_status_ = #{param.authStatus}
  420. </if>
  421. <if test="param.startTime != null">
  422. and ms.create_time_ &gt; #{param.startTime}
  423. </if>
  424. <if test="param.endTime != null">
  425. and ms.create_time_ &lt; #{param.endTime}
  426. </if>
  427. <if test="param.delFlag != null">
  428. and ms.del_flag_ = #{param.delFlag}
  429. </if>
  430. </where>
  431. order by ms.submit_audit_time_ desc
  432. </select>
  433. </mapper>