MusicSheetMapper.xml 25 KB

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