MusicSheetMapper.xml 32 KB

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