MusicSheetMapper.xml 32 KB

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