MusicSheetMapper.xml 39 KB

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