MusicSheetMapper.xml 28 KB

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