MusicSheetMapper.xml 36 KB

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