MusicSheetMapper.xml 32 KB

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