MusicSheetMapper.xml 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  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="exquisite_flag_" jdbcType="TINYINT" property="exquisiteFlag"/>
  22. <result column="music_price_" jdbcType="DECIMAL" property="musicPrice"/>
  23. <result column="audio_file_url_" jdbcType="VARCHAR" property="audioFileUrl"/>
  24. <result column="xml_file_url_" jdbcType="VARCHAR" property="xmlFileUrl"/>
  25. <result column="has_beat_" jdbcType="TINYINT" property="hasBeat"/>
  26. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  27. <result column="create_by_" jdbcType="BIGINT" property="createBy"/>
  28. <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
  29. <result column="update_by_" jdbcType="BIGINT" property="updateBy"/>
  30. <result column="remark_" jdbcType="VARCHAR" property="remark"/>
  31. <result column="notation_" jdbcType="VARCHAR" property="notation"/>
  32. <result column="accompaniment_type_" jdbcType="VARCHAR" property="accompanimentType"/>
  33. <result column="title_img_" jdbcType="VARCHAR" property="titleImg"/>
  34. <result column="music_img_" jdbcType="VARCHAR" property="musicImg"/>
  35. </resultMap>
  36. <sql id="Base_Column_List">
  37. t.id_ as id ,
  38. t.music_sheet_name_ as musicSheetName,
  39. t.user_id_ as userId,
  40. t.composer_ as composer,
  41. t.music_subject_ as musicSubject,
  42. t.audio_type_ as audioType,
  43. t.music_tag_ as musicTag,
  44. t.play_speed_ as playSpeed,
  45. t.can_evaluate_ as canEvaluate,
  46. t.show_fingering_ as showFingering,
  47. t.charge_type_ as chargeType,
  48. t.payment_type_ as paymentType,
  49. t.state_ as state,
  50. t.audit_status_ as auditStatus,
  51. t.sort_number_ as sortNumber,
  52. t.top_flag_ as topFlag,
  53. t.exquisite_flag_ as exquisiteFlag,
  54. t.hot_flag_ as hotFlag,
  55. t.music_price_ as musicPrice,
  56. t.audio_file_url_ as audioFileUrl,
  57. t.xml_file_url_ as xmlFileUrl,
  58. t.has_beat_ as hasBeat,
  59. t.mp3_type_ as mp3Type,
  60. t.ext_config_json_ as extConfigJson,
  61. t.create_time_ as createTime,
  62. t.create_by_ as createBy,
  63. t.update_time_ as updateTime,
  64. t.update_by_ as updateBy,
  65. t.del_flag_ as delFlag,
  66. t.audit_version_ as auditVersion,
  67. t.source_type_ as sourceType,
  68. t.submit_audit_time_ as submitAuditTime,
  69. t.accompaniment_type_ as accompanimentType,
  70. t.remark_ as remark,
  71. t.title_img_ as titleImg,
  72. t.reason_ as reason,
  73. t.music_img_ as musicImg,
  74. t.notation_ as notation
  75. </sql>
  76. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  77. select <include refid="Base_Column_List"/>
  78. ,su.username_ as addName
  79. ,su.avatar_ as addUserAvatar
  80. ,(select group_concat(mt.name_) from music_tag mt
  81. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  82. ,(select group_concat(s.name_) from subject s
  83. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  84. from music_sheet t
  85. left join sys_user su on t.create_by_ = su.id_
  86. <where>
  87. su.del_flag_ = 0
  88. <include refid="QueryInfo"/>
  89. <if test="param.auditVersion != null ">
  90. and #{param.auditVersion} = t.audit_version_
  91. </if>
  92. </where>
  93. order by
  94. <if test="param.myself == null or param.myself == false ">
  95. t.top_flag_ desc,t.sort_number_ desc,
  96. </if>
  97. t.id_ desc
  98. </select>
  99. <sql id="QueryInfo">
  100. <if test="param.idAndName != null and param.idAndName != ''">
  101. and (t.id_ like concat('%',#{param.idAndName},'%') or
  102. t.music_sheet_name_ like concat('%',#{param.idAndName},'%') or
  103. t.composer_ like concat ('%',#{param.idAndName},'%') or
  104. su.username_ like concat ('%',#{param.idAndName},'%') )
  105. </if>
  106. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  107. and
  108. <foreach collection="param.musicTagIdList" open="(" close=")" separator="or" item="item">
  109. find_in_set(#{item},t.music_tag_)
  110. </foreach>
  111. </if>
  112. <if test="param.subjectIds != null and param.subjectIds != ''">
  113. and
  114. <foreach collection="param.subjectIdList" separator="or" item="item" open="(" close=")" >
  115. find_in_set(#{item},t.music_subject_)
  116. </foreach>
  117. </if>
  118. <if test="param.state != null">
  119. and t.state_ = #{param.state}
  120. </if>
  121. <if test="param.auditStatus != null">
  122. and t.audit_status_ = #{param.auditStatus}
  123. </if>
  124. <if test="param.createBy != null">
  125. and t.create_by_ = #{param.createBy}
  126. </if>
  127. <if test="param.delFlag != null">
  128. and t.del_flag_ = #{param.delFlag}
  129. </if>
  130. <if test="param.sourceType != null">
  131. and t.source_type_ = #{param.sourceType}
  132. </if>
  133. <if test="param.chargeType != null">
  134. and (FIND_IN_SET(#{param.chargeType}, t.payment_type_))
  135. </if>
  136. <if test="param.topFlag != null">
  137. and t.top_flag_ = #{param.topFlag}
  138. </if>
  139. <if test="param.exquisiteFlag != null">
  140. and t.exquisite_flag_ = #{param.exquisiteFlag}
  141. </if>
  142. <if test="param.accompanimentType != null">
  143. and t.accompaniment_type_ = #{param.accompanimentType}
  144. </if>
  145. <if test="param.audioType != null">
  146. and t.audio_type_ = #{param.audioType}
  147. </if>
  148. </sql>
  149. <select id="selectAlbumDetailPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  150. select distinct <include refid="Base_Column_List"/>
  151. ,su.username_ as addName
  152. ,su.avatar_ as addUserAvatar
  153. ,(select group_concat(mt.name_) from music_tag mt
  154. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  155. ,(select group_concat(s.name_) from subject s
  156. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  157. ,(select count(1) from music_favorite f
  158. where f.music_sheet_id_ = t.id_) as favoriteCount
  159. ,amr.sort_number_ as albumSortNumber
  160. from music_sheet t
  161. left join album_music_relate amr on t.id_ = amr.music_sheet_id_
  162. left join sys_user su on t.create_by_ = su.id_
  163. <where>
  164. <if test="param.composer != null">
  165. AND t.composer_ LIKE '%${param.composer}%'
  166. </if>
  167. <if test="param.idAndName != null and param.idAndName != ''">
  168. and (t.id_ like concat('%',#{param.idAndName},'%') or
  169. t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  170. </if>
  171. <if test="param.chargeType != null">
  172. and t.charge_type_ = #{param.chargeType}
  173. </if>
  174. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  175. and
  176. <foreach collection="param.musicTagIdList" separator="or" item="item" open="(" close=")" >
  177. find_in_set(#{item},t.music_tag_)
  178. </foreach>
  179. </if>
  180. <if test="param.subjectIds != null and param.subjectIds != ''">
  181. and
  182. <foreach collection="param.subjectIdList" separator="or" item="item" open="(" close=")" >
  183. find_in_set(#{item},t.music_subject_)
  184. </foreach>
  185. </if>
  186. <if test="param.state != null">
  187. and t.state_ = #{param.state}
  188. </if>
  189. <if test="param.delFlag != null">
  190. and t.del_flag_ = #{param.delFlag}
  191. </if>
  192. <if test="param.sourceType != null">
  193. AND t.source_type_ = #{param.sourceType}
  194. </if>
  195. <if test="param.chargeType != null">
  196. AND (t.payment_type_ = 'FREE' OR FIND_IN_SET(#{param.chargeType}, t.payment_type_))
  197. </if>
  198. <if test="param.paymentTypes != null">
  199. AND t.payment_type_ IN (<foreach collection="param.paymentTypes" separator="," item="item">#{item}</foreach>)
  200. </if>
  201. <if test="param.id != null">
  202. <if test="param.type == 2">
  203. and amr.album_id_ = #{param.id}
  204. order by amr.sort_number_ desc, t.id_ desc
  205. </if>
  206. <if test="param.type == 1">
  207. and t.id_ not in(select amr2.music_sheet_id_ from album_music_relate amr2
  208. where amr2.album_id_ = #{param.id})
  209. order by t.id_ desc
  210. </if>
  211. </if>
  212. </where>
  213. </select>
  214. <select id="detail" resultMap="DetailResultMap">
  215. SELECT
  216. <include refid="Base_Column_List"/>
  217. ,t.url_ as url
  218. ,t.midi_url_ as midiUrl
  219. ,t.metronome_url_ as metronomeUrl
  220. ,msa.id_ as accompanimentId
  221. ,msa.music_sheet_id_ as accompanimentMusicSheetId
  222. ,msa.music_subject_ as accompanimentMusicSubject
  223. ,msa.audio_file_url_ as accompanimentAudioFileUrl
  224. ,msa.sort_number_ as accompanimentSortNumber
  225. ,msa.create_time_ as accompanimentCreateTime
  226. ,msa.metronome_url_ as accompanimentMetronomeUrl
  227. ,msa.track_ as track
  228. ,su.username_ as userName
  229. ,su.avatar_ as userAvatar
  230. ,(
  231. select group_concat(mt.name_) from music_tag mt
  232. where find_in_set(mt.id_,t.music_tag_)
  233. and mt.del_flag_ = 0 and mt.state_ = 1
  234. ) as musicTagNames
  235. ,s2.name_ as subjectNames
  236. ,s2.code_ as code
  237. ,su.real_name_ as realName
  238. ,s2.ai_default_frequency_ as aiDefaultFrequency
  239. FROM music_sheet t
  240. left join music_sheet_accompaniment msa on msa.music_sheet_id_ = t.id_
  241. left join sys_user su on t.create_by_ = su.id_
  242. left join subject s2 on t.music_subject_ = s2.id_
  243. where t.id_ = #{id}
  244. order by msa.sort_number_
  245. </select>
  246. <resultMap id="DetailResultMap" type="com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo">
  247. <id column="id" jdbcType="BIGINT" property="id"/>
  248. <result column="musicSheetName" jdbcType="VARCHAR" property="musicSheetName"/>
  249. <result column="userId" jdbcType="BIGINT" property="userId"/>
  250. <result column="composer" jdbcType="VARCHAR" property="composer"/>
  251. <result column="titleImg" jdbcType="VARCHAR" property="titleImg"/>
  252. <result column="musicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  253. <result column="audioType" jdbcType="VARCHAR" property="audioType"/>
  254. <result column="musicTag" jdbcType="VARCHAR" property="musicTag"/>
  255. <result column="playSpeed" jdbcType="INTEGER" property="playSpeed"/>
  256. <result column="canEvaluate" jdbcType="TINYINT" property="canEvaluate"/>
  257. <result column="showFingering" jdbcType="TINYINT" property="showFingering"/>
  258. <result column="chargeType" jdbcType="TINYINT" property="chargeType"/>
  259. <result column="auditStatus" property="auditStatus"/>
  260. <result column="state" jdbcType="TINYINT" property="state"/>
  261. <result column="sortNumber" jdbcType="INTEGER" property="sortNumber"/>
  262. <result column="topFlag" jdbcType="TINYINT" property="topFlag"/>
  263. <result column="hotFlag" jdbcType="TINYINT" property="hotFlag"/>
  264. <result column="musicPrice" jdbcType="DECIMAL" property="musicPrice"/>
  265. <result column="audioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  266. <result column="musicTagNames" jdbcType="VARCHAR" property="musicTagNames"/>
  267. <result column="subjectNames" jdbcType="VARCHAR" property="subjectNames"/>
  268. <result column="xmlFileUrl" jdbcType="VARCHAR" property="xmlFileUrl"/>
  269. <result column="hasBeat" jdbcType="TINYINT" property="hasBeat"/>
  270. <result column="createTime" jdbcType="TIMESTAMP" property="createTime"/>
  271. <result column="createBy" jdbcType="BIGINT" property="createBy"/>
  272. <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime"/>
  273. <result column="updateBy" jdbcType="BIGINT" property="updateBy"/>
  274. <result column="delFlag" jdbcType="BOOLEAN" property="delFlag"/>
  275. <result column="url" jdbcType="BOOLEAN" property="url"/>
  276. <result column="metronomeUrl" jdbcType="BOOLEAN" property="metronomeUrl"/>
  277. <result column="midiUrl" jdbcType="BOOLEAN" property="midiUrl"/>
  278. <result column="mp3Type" jdbcType="VARCHAR" property="mp3Type"/>
  279. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  280. <result column="userName" jdbcType="VARCHAR" property="userName"/>
  281. <result column="auditVersion" jdbcType="VARCHAR" property="auditVersion"/>
  282. <result column="code" jdbcType="VARCHAR" property="code"/>
  283. <result column="reason" jdbcType="VARCHAR" property="reason"/>
  284. <result column="accompanimentType" jdbcType="VARCHAR" property="accompanimentType"/>
  285. <result column="notation" jdbcType="VARCHAR" property="notation"/>
  286. <result column="musicImg" jdbcType="VARCHAR" property="musicImg"/>
  287. <result column="realName" jdbcType="VARCHAR" property="realName"/>
  288. <result column="auditTime" jdbcType="VARCHAR" property="auditTime"/>
  289. <result column="auditName" jdbcType="VARCHAR" property="auditName"/>
  290. <result column="auditReason" jdbcType="VARCHAR" property="auditReason"/>
  291. <result column="aiDefaultFrequency" jdbcType="VARCHAR" property="aiDefaultFrequency"/>
  292. <collection property="background" ofType="com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment">
  293. <id column="accompanimentId" jdbcType="BIGINT" property="id"/>
  294. <result column="accompanimentMusicSheetId" jdbcType="BIGINT" property="musicSheetId"/>
  295. <result column="accompanimentMusicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  296. <result column="accompanimentAudioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  297. <result column="accompanimentSortNumber" jdbcType="TINYINT" property="sortNumber"/>
  298. <result column="accompanimentCreateTime" jdbcType="TIMESTAMP" property="createTime"/>
  299. <result column="accompanimentMetronomeUrl" jdbcType="VARCHAR" property="metronomeUrl"/>
  300. <result column="track" jdbcType="VARCHAR" property="track"/>
  301. </collection>
  302. </resultMap>
  303. <select id="selectStudentMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  304. select <include refid="Base_Column_List"/>
  305. ,su.username_ as addName
  306. ,su.avatar_ as addUserAvatar
  307. ,(select group_concat(mt.name_) from music_tag mt
  308. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  309. ,(select count(1) as num from music_favorite af
  310. left join sys_user su on af.user_id_ = su.id_
  311. where su.del_flag_ = 0 and af.music_sheet_id_ = t.id_) as favoriteCount
  312. ,(select group_concat(s.name_) from subject s
  313. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0) as subjectNames
  314. <if test="param.studentId != null">
  315. ,if(mf.id_ is not null,1,0) as favorite
  316. <!-- ,case when mspr.id_ is not null then 1-->
  317. <!-- when t.charge_type_ = 'FREE' then 1-->
  318. <!-- else 0 end as play-->
  319. </if>
  320. from music_sheet t
  321. left join sys_user su on t.create_by_ = su.id_
  322. left join (select count(1) as num,mf.music_sheet_id_
  323. from music_favorite mf group by mf.music_sheet_id_) t2 on t2.music_sheet_id_ = t.id_
  324. <if test="param.studentId != null">
  325. <!-- left join music_sheet_purchase_record mspr-->
  326. <!-- on mspr.music_sheet_id_ = t.id_-->
  327. <!-- and mspr.student_id_ = #{param.studentId}-->
  328. <!-- and order_status_ = 'PAID'-->
  329. left join music_favorite mf on (t.id_ = mf.music_sheet_id_ and mf.user_id_ = #{param.studentId} <if test="clientType != null"> AND mf.client_type_ = #{clientType}</if> )
  330. </if>
  331. <where>
  332. su.del_flag_ = 0
  333. <include refid="QueryInfo"/>
  334. <if test="param.auditVersion != null ">
  335. and #{param.auditVersion} = t.audit_version_
  336. </if>
  337. </where>
  338. order by
  339. <if test="param.myself == null or param.myself == false ">
  340. t.top_flag_ desc, t.sort_number_ desc, t2.num desc,
  341. </if>
  342. t.id_ desc
  343. </select>
  344. <select id="selectMyMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  345. select <include refid="Base_Column_List"/>
  346. ,su.username_ as addName
  347. ,su.avatar_ as addUserAvatar
  348. ,(select group_concat(mt.name_) from music_tag mt
  349. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  350. ,(select group_concat(s.name_) from subject s
  351. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  352. ,if(mf.id_ is not null,1,0) as favorite
  353. from music_sheet t
  354. left join sys_user su on t.create_by_ = su.id_
  355. left join music_sheet_purchase_record mspr on mspr.music_sheet_id_ = t.id_
  356. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mspr.student_id_ = mf.user_id_
  357. <where>
  358. <include refid="QueryInfo"/>
  359. <if test="param.studentId != null">
  360. and mspr.student_id_ = #{param.studentId}
  361. and mspr.order_status_ = 'PAID'
  362. </if>
  363. <if test="param.userType != null">
  364. and mspr.client_type_ = #{param.userType}
  365. </if>
  366. </where>
  367. order by mspr.id_ desc
  368. </select>
  369. <select id="selectFavoriteMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  370. select <include refid="Base_Column_List"/>
  371. ,su.username_ as addName
  372. ,su.avatar_ as addUserAvatar
  373. ,(select group_concat(mt.name_) from music_tag mt
  374. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  375. ,(select group_concat(s.name_) from subject s
  376. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  377. ,if(mf.id_ is not null,1,0) as favorite
  378. from music_sheet t
  379. left join sys_user su on t.create_by_ = su.id_
  380. left join music_favorite mf on t.id_ = mf.music_sheet_id_
  381. <where>
  382. su.del_flag_ = 0
  383. <include refid="QueryInfo"/>
  384. <if test="clientType != null">
  385. AND mf.client_type_ = #{clientType}
  386. </if>
  387. <if test="param.studentId != null">
  388. and mf.user_id_ = #{param.studentId}
  389. </if>
  390. </where>
  391. order by mf.id_ desc
  392. </select>
  393. <select id="selectPracticeMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  394. select <include refid="Base_Column_List"/>
  395. ,su.username_ as addName
  396. ,su.avatar_ as addUserAvatar
  397. ,(select group_concat(mt.name_) from music_tag mt
  398. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  399. ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
  400. ,if(mf.id_ is not null,1,0) as favorite
  401. from sys_music_compare_record mspr
  402. left join music_sheet t on mspr.music_sheet_id_ = t.id_
  403. left join sys_user su on t.create_by_ = su.id_
  404. left join music_favorite mf on (t.id_ = mf.music_sheet_id_ and mspr.user_id_ = mf.user_id_ <if test="param.clientType != null"> AND mf.client_type_ = #{param.clientType}</if> )
  405. <where>
  406. su.del_flag_ = 0
  407. <include refid="QueryInfo"/>
  408. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  409. and mspr.id_ in
  410. <foreach collection="practiceMusicIdList" item="item" open="(" close=")" separator=",">
  411. #{item}
  412. </foreach>
  413. </if>
  414. </where>
  415. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  416. order by field(mspr.id_,
  417. <foreach collection="practiceMusicIdList" item="item" separator=",">
  418. #{item}
  419. </foreach>
  420. </if>
  421. )
  422. </select>
  423. <select id="selectStudentOrderPage" resultType="com.yonge.cooleshow.biz.dal.vo.StudentMusicSheetOrderVo">
  424. select mspr.music_sheet_id_ as musicSheetId
  425. ,ms.music_sheet_name_ as musicSheetName
  426. ,ms.composer_ as composer
  427. ,ms.title_img_ as titleImg
  428. ,ms.music_tag_ as musicTag
  429. ,(select group_concat(mt.name_) from music_tag mt
  430. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  431. ,mspr.purchase_price_ as purchasePrice
  432. ,mspr.order_no_ as orderNo
  433. ,mspr.purchase_time_ as purchaseTime
  434. from music_sheet_purchase_record mspr
  435. left join music_sheet ms on mspr.music_sheet_id_ = ms.id_
  436. <where>
  437. mspr.order_status_ = 'PAID'
  438. <if test="param.idAndName != null and param.idAndName != ''">
  439. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  440. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  441. </if>
  442. <if test="param.studentId != null">
  443. and mspr.student_id_ = #{param.studentId}
  444. </if>
  445. <if test="param.orderNo != null and param.orderNo != ''">
  446. and mspr.order_no_ = #{param.orderNo}
  447. </if>
  448. <if test="param.musicTagList != null and param.musicTagList.size() != 0">
  449. and
  450. <foreach collection="param.musicTagList" separator="or" item="item" open="(" close=")" >
  451. find_in_set(#{item},ms.music_tag_)
  452. </foreach>
  453. </if>
  454. <if test="param.startTime != null">
  455. and mspr.purchase_time_ &gt; #{param.startTime}
  456. </if>
  457. <if test="param.endTime != null">
  458. and mspr.purchase_time_ &lt; #{param.endTime}
  459. </if>
  460. <if test="param.delFlag != null">
  461. and ms.del_flag_ = #{param.delFlag}
  462. </if>
  463. </where>
  464. order by mspr.id_ desc
  465. </select>
  466. <select id="selectTeacherPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  467. select ms.id_ as musicSheetId
  468. ,ms.music_sheet_name_ as musicSheetName
  469. ,ms.composer_ as composer
  470. ,ms.title_img_ as titleImg
  471. ,ms.accompaniment_type_ as accompanimentType
  472. ,ms.music_tag_ as musicTag
  473. ,(select group_concat(mt.name_) from music_tag mt
  474. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  475. ,ms.play_speed_ as playSpeed
  476. ,ms.music_price_ as musicPrice
  477. ,ms.create_time_ as createTime
  478. ,ms.audit_status_ as auditStatus
  479. ,su.username_ as auditName
  480. from music_sheet ms
  481. left join music_sheet_auth_record msar on ms.id_ = msar.music_sheet_id_
  482. left join sys_user su on msar.verify_user_id_ = su.id_
  483. <where>
  484. <if test="param.idAndName != null and param.idAndName != ''">
  485. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  486. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
  487. or ms.composer_ like concat('%',#{param.idAndName},'%'))
  488. </if>
  489. <if test="param.teacherId != null">
  490. and ms.create_by_ = #{param.teacherId} and ms.source_type_ = 'TEACHER'
  491. </if>
  492. <if test="param.startTime != null">
  493. and ms.create_time_ &gt; #{param.startTime}
  494. </if>
  495. <if test="param.endTime != null">
  496. and ms.create_time_ &lt; #{param.endTime}
  497. </if>
  498. <if test="param.delFlag != null">
  499. and ms.del_flag_ = #{param.delFlag}
  500. </if>
  501. </where>
  502. order by ms.id_ desc
  503. </select>
  504. <select id="selectAuditPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  505. select
  506. msar.id_ as authMusicSheetId,
  507. ms.create_by_ as teacherId
  508. ,ms.exquisite_flag_ as exquisiteFlag
  509. ,ms.title_img_ as titleImg
  510. ,ms.accompaniment_type_ as accompanimentType
  511. ,su.username_ as username
  512. ,su.real_name_ as realName
  513. ,su.phone_ as phone
  514. ,ms.id_ as musicSheetId
  515. ,ms.music_sheet_name_ as musicSheetName
  516. ,ms.composer_ as composer
  517. ,ms.music_tag_ as musicTag
  518. ,(select group_concat(mt.name_) from music_tag mt
  519. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  520. ,ms.play_speed_ as playSpeed
  521. ,ms.music_price_ as musicPrice
  522. ,ms.update_time_ as createTime
  523. ,if(msar.audit_state_ is null,ms.audit_status_,msar.audit_state_) as auditStatus
  524. ,su2.username_ as auditName
  525. ,msar.first_auth_ as firstAuth
  526. from music_sheet_auth_record msar
  527. left join music_sheet ms on ms.id_ = msar.music_sheet_id_
  528. left join sys_user su on su.id_ = ms.create_by_
  529. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  530. <where>
  531. su.del_flag_ = 0 and
  532. ms.source_type_ = 'TEACHER'
  533. <if test="param.idAndName != null and param.idAndName != ''">
  534. and (su.id_ like concat('%',#{param.idAndName} ,'%')
  535. or su.username_ like concat('%',#{param.idAndName},'%')
  536. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
  537. or su.phone_ like concat('%',#{param.idAndName},'%'))
  538. </if>
  539. <if test="param.auditName != null and param.auditName != ''">
  540. and su2.username_ like concat('%',#{param.auditName},'%')
  541. </if>
  542. <if test="param.authStatus != null">
  543. and msar.audit_state_ = #{param.authStatus}
  544. </if>
  545. <if test="param.startTime != null">
  546. and ms.create_time_ &gt; #{param.startTime}
  547. </if>
  548. <if test="param.endTime != null">
  549. and ms.create_time_ &lt; #{param.endTime}
  550. </if>
  551. <if test="param.chargeType != null">
  552. and ms.charge_type_ = #{param.chargeType}
  553. </if>
  554. <if test="param.firstAuth != null">
  555. and msar.first_auth_ = #{param.firstAuth}
  556. </if>
  557. <if test="param.exquisiteFlag != null">
  558. and ms.exquisite_flag_ = #{param.exquisiteFlag}
  559. </if>
  560. </where>
  561. order by field(ms.audit_status_,'DOING') desc, ms.submit_audit_time_ desc
  562. </select>
  563. <select id="selectTeacherMusicSheetCount" resultType="java.lang.Integer">
  564. select count(1)
  565. from music_sheet
  566. where user_id_ = #{userId}
  567. and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0 and source_type_ = 'TEACHER'
  568. </select>
  569. <select id="selectMusicNum" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo">
  570. select
  571. sum(if(ms.source_type_ = 'PLATFORM',1,0)) as musicSheetPlatformCount,
  572. sum(if(ms.source_type_ = 'TEACHER',1,0)) as musicSheetTeacherCount,
  573. count(1) as musicSheetCount
  574. from music_sheet ms
  575. where ms.state_ = 1 and ms.del_flag_ = 0 and ms.audit_status_ = 'PASS' and find_in_set('CHARGE',ms.payment_type_)
  576. </select>
  577. <select id="selectPayMusicSheet" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo$MusicSheetSmall">
  578. SELECT
  579. ms.id_ as musicSheetId,
  580. ms.music_sheet_name_ as musicSheetName,
  581. count(DISTINCT pr.student_id_) as num
  582. FROM
  583. music_sheet ms
  584. LEFT JOIN music_sheet_purchase_record pr ON ms.id_ = pr.music_sheet_id_
  585. WHERE
  586. ms.del_flag_=0
  587. AND ms.charge_type_='CHARGE'
  588. AND ms.state_=1
  589. AND pr.order_status_='PAID'
  590. GROUP BY ms.id_
  591. ORDER BY count(DISTINCT pr.student_id_) DESC,ms.id_ desc
  592. limit 5
  593. </select>
  594. <select id="selectTeacherCount" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherAuditMusicSheetVo">
  595. select
  596. sum(if(t.audit_status_ = 'DOING',1,0)) as doing,
  597. sum(if(t.audit_status_ = 'PASS'
  598. and t.state_ = 1,1,0)) as pass,
  599. sum(if(t.audit_status_ = 'UNPASS',1,0)) as upPass
  600. from
  601. music_sheet t
  602. where t.user_id_ = #{userId}
  603. </select>
  604. <select id="queryStudentTotal" resultType="com.yonge.cooleshow.biz.dal.vo.StudentTotalVo">
  605. select
  606. t.user_id_ as userId,
  607. a.musicAlbumNum,
  608. b.musicSheetNum
  609. from student t
  610. left join (
  611. select
  612. user_id_, count(1) as musicAlbumNum
  613. from album_favorite
  614. <where>
  615. <if test="null != userId">
  616. and user_id_ = #{userId}
  617. </if>
  618. </where>
  619. group by user_id_
  620. ) a on t.user_id_ = a.user_id_
  621. left join (
  622. select
  623. user_id_, count(1) as musicSheetNum
  624. from music_favorite
  625. <where>
  626. <if test="null != userId">
  627. and user_id_ = #{userId}
  628. </if>
  629. </where>
  630. group by user_id_
  631. ) b on t.user_id_ = b.user_id_
  632. <where>
  633. <if test="null != userId">
  634. and t.user_id_ = #{userId}
  635. </if>
  636. </where>
  637. </select>
  638. <select id="queryTeacherTotal" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherTotalVo">
  639. select
  640. t.user_id_ as userId,
  641. a.musicSheetNum as musicSheetNum
  642. from teacher t
  643. left join (
  644. select
  645. user_id_, count(1) as musicSheetNum
  646. from music_sheet
  647. where source_type_ = 'TEACHER' and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0
  648. <if test="null != userId">
  649. and user_id_ = #{userId}
  650. </if>
  651. group by user_id_
  652. ) a on t.user_id_ = a.user_id_
  653. <where>
  654. <if test="null != userId">
  655. and t.user_id_ = #{userId}
  656. </if>
  657. </where>
  658. </select>
  659. <select id="auditDetailList" resultMap="DetailResultMap">
  660. SELECT
  661. <include refid="Base_Column_List"/>
  662. ,t.url_ as url
  663. ,t.midi_url_ as midiUrl
  664. ,t.metronome_url_ as metronomeUrl
  665. ,msa.id_ as accompanimentId
  666. ,msa.music_sheet_id_ as accompanimentMusicSheetId
  667. ,msa.music_subject_ as accompanimentMusicSubject
  668. ,msa.audio_file_url_ as accompanimentAudioFileUrl
  669. ,msa.sort_number_ as accompanimentSortNumber
  670. ,msa.create_time_ as accompanimentCreateTime
  671. ,msa.metronome_url_ as accompanimentMetronomeUrl
  672. ,msa.track_ as track
  673. ,su.username_ as userName
  674. ,su.avatar_ as userAvatar
  675. ,(
  676. select group_concat(mt.name_) from music_tag mt
  677. where find_in_set(mt.id_,t.music_tag_)
  678. and mt.del_flag_ = 0 and mt.state_ = 1
  679. ) as musicTagNames
  680. ,s2.name_ as subjectNames
  681. ,s2.code_ as code
  682. ,s2.ai_default_frequency_ as aiDefaultFrequency
  683. ,su.real_name_ as realName
  684. ,msar.update_time_ as auditTime
  685. ,su2.username_ as auditName
  686. ,msar.reason_ as auditReason
  687. from music_sheet_auth_record msar
  688. left join music_sheet t on t.id_ = msar.music_sheet_id_
  689. left join sys_user su on su.id_ = t.create_by_
  690. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  691. left join music_sheet_accompaniment msa on msa.music_sheet_id_ = t.id_
  692. left join subject s2 on t.music_subject_ = s2.id_
  693. <where>
  694. <if test="originalMusicSheetId != null">
  695. and #{originalMusicSheetId} = msar.original_music_sheet_id_
  696. </if>
  697. <if test="authMusicSheetId != null">
  698. and #{authMusicSheetId} &gt; msar.id_
  699. </if>
  700. </where>
  701. order by msar.id_ desc
  702. </select>
  703. <!--单曲专辑数量统计-->
  704. <select id="selectMusicAlbumStatInfo" resultType="com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper">
  705. SELECT t1.music_sheet_id_ AS id, COUNT(DISTINCT t1.id_) AS total
  706. FROM album_music_relate t1 JOIN music_sheet t2 ON (t1.music_sheet_id_ = t2.id_)
  707. <where>
  708. <if test="musicIds != null">
  709. AND t1.music_sheet_id_ IN (<foreach collection="musicIds" separator="," item="item">#{item}</foreach>)
  710. </if>
  711. </where>
  712. GROUP BY t1.music_sheet_id_
  713. </select>
  714. <!--单曲专辑数量统计-->
  715. </mapper>