MusicSheetMapper.xml 32 KB

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