MusicSheetMapper.xml 19 KB

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