MusicSheetMapper.xml 28 KB

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