MusicSheetMapper.xml 29 KB

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