MusicSheetMapper.xml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  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. ,s2.ai_default_frequency_ as aiDefaultFrequency
  202. FROM music_sheet t
  203. left join music_sheet_accompaniment msa on msa.music_sheet_id_ = t.id_
  204. left join sys_user su on t.create_by_ = su.id_
  205. left join subject s2 on t.music_subject_ = s2.id_
  206. where t.id_ = #{id}
  207. order by msa.sort_number_
  208. </select>
  209. <resultMap id="DetailResultMap" type="com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo">
  210. <id column="id" jdbcType="BIGINT" property="id"/>
  211. <result column="musicSheetName" jdbcType="VARCHAR" property="musicSheetName"/>
  212. <result column="userId" jdbcType="BIGINT" property="userId"/>
  213. <result column="composer" jdbcType="VARCHAR" property="composer"/>
  214. <result column="musicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  215. <result column="audioType" jdbcType="VARCHAR" property="audioType"/>
  216. <result column="musicTag" jdbcType="VARCHAR" property="musicTag"/>
  217. <result column="playSpeed" jdbcType="INTEGER" property="playSpeed"/>
  218. <result column="canEvaluate" jdbcType="TINYINT" property="canEvaluate"/>
  219. <result column="showFingering" jdbcType="TINYINT" property="showFingering"/>
  220. <result column="chargeType" jdbcType="TINYINT" property="chargeType"/>
  221. <result column="auditStatus" jdbcType="TINYINT" property="auditStatus"/>
  222. <result column="state" jdbcType="TINYINT" property="state"/>
  223. <result column="sortNumber" jdbcType="INTEGER" property="sortNumber"/>
  224. <result column="topFlag" jdbcType="TINYINT" property="topFlag"/>
  225. <result column="hotFlag" jdbcType="TINYINT" property="hotFlag"/>
  226. <result column="musicPrice" jdbcType="DECIMAL" property="musicPrice"/>
  227. <result column="audioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  228. <result column="musicTagNames" jdbcType="VARCHAR" property="musicTagNames"/>
  229. <result column="subjectNames" jdbcType="VARCHAR" property="subjectNames"/>
  230. <result column="xmlFileUrl" jdbcType="VARCHAR" property="xmlFileUrl"/>
  231. <result column="hasBeat" jdbcType="TINYINT" property="hasBeat"/>
  232. <result column="createTime" jdbcType="TIMESTAMP" property="createTime"/>
  233. <result column="createBy" jdbcType="BIGINT" property="createBy"/>
  234. <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime"/>
  235. <result column="updateBy" jdbcType="BIGINT" property="updateBy"/>
  236. <result column="delFlag" jdbcType="BOOLEAN" property="delFlag"/>
  237. <result column="url" jdbcType="BOOLEAN" property="url"/>
  238. <result column="metronomeUrl" jdbcType="BOOLEAN" property="metronomeUrl"/>
  239. <result column="midiUrl" jdbcType="BOOLEAN" property="midiUrl"/>
  240. <result column="mp3Type" jdbcType="VARCHAR" property="mp3Type"/>
  241. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  242. <result column="userName" jdbcType="VARCHAR" property="userName"/>
  243. <result column="auditVersion" jdbcType="VARCHAR" property="auditVersion"/>
  244. <result column="code" jdbcType="VARCHAR" property="code"/>
  245. <result column="reason" jdbcType="VARCHAR" property="reason"/>
  246. <result column="notation" jdbcType="VARCHAR" property="notation"/>
  247. <result column="aiDefaultFrequency" jdbcType="VARCHAR" property="aiDefaultFrequency"/>
  248. <collection property="background" ofType="com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment">
  249. <id column="accompanimentId" jdbcType="BIGINT" property="id"/>
  250. <result column="accompanimentMusicSheetId" jdbcType="BIGINT" property="musicSheetId"/>
  251. <result column="accompanimentMusicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  252. <result column="accompanimentAudioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  253. <result column="accompanimentSortNumber" jdbcType="TINYINT" property="sortNumber"/>
  254. <result column="accompanimentCreateTime" jdbcType="TIMESTAMP" property="createTime"/>
  255. <result column="accompanimentMetronomeUrl" jdbcType="VARCHAR" property="metronomeUrl"/>
  256. <result column="track" jdbcType="VARCHAR" property="track"/>
  257. </collection>
  258. </resultMap>
  259. <select id="selectStudentMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  260. select <include refid="Base_Column_List"/>
  261. ,su.username_ as addName
  262. ,su.avatar_ as addUserAvatar
  263. ,(select group_concat(mt.name_) from music_tag mt
  264. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  265. ,(select count(1) as num from music_favorite af
  266. left join sys_user su on af.user_id_ = su.id_
  267. where su.del_flag_ = 0 and af.music_sheet_id_ = t.id_) as favoriteCount
  268. ,(select group_concat(s.name_) from subject s
  269. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0) as subjectNames
  270. <if test="param.studentId != null">
  271. ,if(mf.id_ is not null,1,0) as favorite
  272. ,case when mspr.id_ is not null then 1
  273. when t.charge_type_ = 'FREE' then 1
  274. else 0 end as play
  275. </if>
  276. from music_sheet t
  277. left join sys_user su on t.create_by_ = su.id_
  278. left join (select count(1) as num,mf.music_sheet_id_
  279. from music_favorite mf group by mf.music_sheet_id_) t2 on t2.music_sheet_id_ = t.id_
  280. <if test="param.studentId != null">
  281. left join music_sheet_purchase_record mspr
  282. on mspr.music_sheet_id_ = t.id_
  283. and mspr.student_id_ = #{param.studentId}
  284. and order_status_ = 'PAID'
  285. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mf.user_id_ = #{param.studentId}
  286. </if>
  287. <where>
  288. su.del_flag_ = 0
  289. <include refid="QueryInfo"/>
  290. <if test="param.auditVersion != null ">
  291. and #{param.auditVersion} = t.audit_version_
  292. </if>
  293. </where>
  294. order by
  295. <if test="param.myself == null or param.myself == false ">
  296. t.top_flag_ desc, t.sort_number_ desc, t2.num desc,
  297. </if>
  298. t.id_ desc
  299. </select>
  300. <select id="selectMyMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  301. select <include refid="Base_Column_List"/>
  302. ,su.username_ as addName
  303. ,su.avatar_ as addUserAvatar
  304. ,(select group_concat(mt.name_) from music_tag mt
  305. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  306. ,(select group_concat(s.name_) from subject s
  307. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  308. ,if(mf.id_ is not null,1,0) as favorite
  309. from music_sheet t
  310. left join sys_user su on t.create_by_ = su.id_
  311. left join music_sheet_purchase_record mspr on mspr.music_sheet_id_ = t.id_
  312. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mspr.student_id_ = mf.user_id_
  313. <where>
  314. <include refid="QueryInfo"/>
  315. <if test="param.studentId != null">
  316. and mspr.student_id_ = #{param.studentId}
  317. and mspr.order_status_ = 'PAID'
  318. </if>
  319. <if test="param.userType != null">
  320. and mspr.client_type_ = #{param.userType}
  321. </if>
  322. </where>
  323. order by mspr.id_ desc
  324. </select>
  325. <select id="selectFavoriteMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  326. select <include refid="Base_Column_List"/>
  327. ,su.username_ as addName
  328. ,su.avatar_ as addUserAvatar
  329. ,(select group_concat(mt.name_) from music_tag mt
  330. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  331. ,(select group_concat(s.name_) from subject s
  332. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  333. ,if(mf.id_ is not null,1,0) as favorite
  334. from music_sheet t
  335. left join sys_user su on t.create_by_ = su.id_
  336. left join music_favorite mf on t.id_ = mf.music_sheet_id_
  337. <where>
  338. su.del_flag_ = 0
  339. <include refid="QueryInfo"/>
  340. <if test="param.studentId != null">
  341. and mf.user_id_ = #{param.studentId}
  342. </if>
  343. </where>
  344. order by mf.id_ desc
  345. </select>
  346. <select id="selectPracticeMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  347. select <include refid="Base_Column_List"/>
  348. ,su.username_ as addName
  349. ,su.avatar_ as addUserAvatar
  350. ,(select group_concat(mt.name_) from music_tag mt
  351. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  352. ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
  353. ,if(mf.id_ is not null,1,0) as favorite
  354. from music_sheet t
  355. left join sys_user su on t.create_by_ = su.id_
  356. left join music_sheet_practice_record mspr on mspr.music_sheet_id_ = t.id_
  357. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mspr.user_id_ = mf.user_id_
  358. <where>
  359. su.del_flag_ = 0
  360. <include refid="QueryInfo"/>
  361. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  362. and mspr.id_ in
  363. <foreach collection="practiceMusicIdList" item="item" open="(" close=")" separator=",">
  364. #{item}
  365. </foreach>
  366. </if>
  367. </where>
  368. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  369. order by field(mspr.id_,
  370. <foreach collection="practiceMusicIdList" item="item" separator=",">
  371. #{item}
  372. </foreach>
  373. </if>
  374. )
  375. </select>
  376. <select id="selectStudentOrderPage" resultType="com.yonge.cooleshow.biz.dal.vo.StudentMusicSheetOrderVo">
  377. select mspr.music_sheet_id_ as musicSheetId
  378. ,ms.music_sheet_name_ as musicSheetName
  379. ,ms.composer_ as composer
  380. ,ms.music_tag_ as musicTag
  381. ,(select group_concat(mt.name_) from music_tag mt
  382. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  383. ,mspr.purchase_price_ as purchasePrice
  384. ,mspr.order_no_ as orderNo
  385. ,mspr.purchase_time_ as purchaseTime
  386. from music_sheet_purchase_record mspr
  387. left join music_sheet ms on mspr.music_sheet_id_ = ms.id_
  388. <where>
  389. mspr.order_status_ = 'PAID'
  390. <if test="param.idAndName != null and param.idAndName != ''">
  391. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  392. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  393. </if>
  394. <if test="param.studentId != null">
  395. and mspr.student_id_ = #{param.studentId}
  396. </if>
  397. <if test="param.orderNo != null and param.orderNo != ''">
  398. and mspr.order_no_ = #{param.orderNo}
  399. </if>
  400. <if test="param.musicTagList != null and param.musicTagList.size() != 0">
  401. and
  402. <foreach collection="param.musicTagList" separator="or" item="item" open="(" close=")" >
  403. find_in_set(#{item},ms.music_tag_)
  404. </foreach>
  405. </if>
  406. <if test="param.startTime != null">
  407. and mspr.purchase_time_ &gt; #{param.startTime}
  408. </if>
  409. <if test="param.endTime != null">
  410. and mspr.purchase_time_ &lt; #{param.endTime}
  411. </if>
  412. <if test="param.delFlag != null">
  413. and ms.del_flag_ = #{param.delFlag}
  414. </if>
  415. </where>
  416. order by mspr.id_ desc
  417. </select>
  418. <select id="selectTeacherPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  419. select ms.id_ as musicSheetId
  420. ,ms.music_sheet_name_ as musicSheetName
  421. ,ms.composer_ as composer
  422. ,ms.music_tag_ as musicTag
  423. ,(select group_concat(mt.name_) from music_tag mt
  424. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  425. ,ms.play_speed_ as playSpeed
  426. ,ms.music_price_ as musicPrice
  427. ,ms.create_time_ as createTime
  428. ,ms.audit_status_ as auditStatus
  429. ,su.username_ as auditName
  430. from music_sheet ms
  431. left join music_sheet_auth_record msar on ms.id_ = msar.music_sheet_id_
  432. left join sys_user su on msar.verify_user_id_ = su.id_
  433. <where>
  434. <if test="param.idAndName != null and param.idAndName != ''">
  435. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  436. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
  437. or ms.composer_ like concat('%',#{param.idAndName},'%'))
  438. </if>
  439. <if test="param.teacherId != null">
  440. and ms.create_by_ = #{param.teacherId}
  441. </if>
  442. <if test="param.startTime != null">
  443. and ms.create_time_ &gt; #{param.startTime}
  444. </if>
  445. <if test="param.endTime != null">
  446. and ms.create_time_ &lt; #{param.endTime}
  447. </if>
  448. <if test="param.delFlag != null">
  449. and ms.del_flag_ = #{param.delFlag}
  450. </if>
  451. </where>
  452. order by ms.id_ desc
  453. </select>
  454. <select id="selectAuditPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  455. select
  456. ms.create_by_ as teacherId
  457. ,su.username_ as username
  458. ,su.real_name_ as realName
  459. ,su.phone_ as phone
  460. ,ms.id_ as musicSheetId
  461. ,ms.music_sheet_name_ as musicSheetName
  462. ,ms.composer_ as composer
  463. ,ms.music_tag_ as musicTag
  464. ,(select group_concat(mt.name_) from music_tag mt
  465. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  466. ,ms.play_speed_ as playSpeed
  467. ,ms.music_price_ as musicPrice
  468. ,ms.create_time_ as createTime
  469. ,if(msar.audit_state_ is null,ms.audit_status_,msar.audit_state_) as auditStatus
  470. ,su2.username_ as auditName
  471. from music_sheet ms
  472. left join sys_user su on su.id_ = ms.create_by_
  473. left join music_sheet_auth_record msar on ms.id_ = msar.music_sheet_id_
  474. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  475. <where>
  476. su.del_flag_ = 0 and
  477. ms.source_type_ = 'TEACHER' and
  478. msar.id_ is not null
  479. <if test="param.idAndName != null and param.idAndName != ''">
  480. and (su.id_ like concat('%',#{param.idAndName} ,'%')
  481. or su.username_ like concat('%',#{param.idAndName},'%')
  482. or su.phone_ like concat('%',#{param.idAndName},'%'))
  483. </if>
  484. <if test="param.auditName != null and param.auditName != ''">
  485. and su2.username_ like concat('%',#{param.auditName},'%')
  486. </if>
  487. <if test="param.authStatus != null">
  488. and msar.audit_state_ = #{param.authStatus}
  489. </if>
  490. <if test="param.startTime != null">
  491. and ms.create_time_ &gt; #{param.startTime}
  492. </if>
  493. <if test="param.endTime != null">
  494. and ms.create_time_ &lt; #{param.endTime}
  495. </if>
  496. <if test="param.delFlag != null">
  497. and ms.del_flag_ = #{param.delFlag}
  498. </if>
  499. <if test="param.chargeType != null">
  500. and ms.charge_type_ = #{param.chargeType}
  501. </if>
  502. </where>
  503. order by field(ms.audit_status_,'DOING') desc, ms.submit_audit_time_ desc
  504. </select>
  505. <select id="selectTeacherMusicSheetCount" resultType="java.lang.Integer">
  506. select count(1)
  507. from music_sheet
  508. where user_id_ = #{userId}
  509. and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0 and source_type_ = 'TEACHER'
  510. </select>
  511. <select id="selectMusicNum" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo">
  512. select
  513. sum(if(ms.source_type_ = 'PLATFORM',1,0)) as musicSheetPlatformCount,
  514. sum(if(ms.source_type_ = 'TEACHER',1,0)) as musicSheetTeacherCount,
  515. count(1) as musicSheetCount
  516. from music_sheet ms
  517. where ms.state_ = 1 and ms.del_flag_ = 0 and ms.audit_status_ = 'PASS' and ms.charge_type_ = 'CHARGE'
  518. </select>
  519. <select id="selectPayMusicSheet" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo$MusicSheetSmall">
  520. SELECT
  521. ms.id_ as musicSheetId,
  522. ms.music_sheet_name_ as musicSheetName,
  523. count(DISTINCT pr.student_id_) as num
  524. FROM
  525. music_sheet ms
  526. LEFT JOIN music_sheet_purchase_record pr ON ms.id_ = pr.music_sheet_id_
  527. WHERE
  528. ms.del_flag_=0
  529. AND ms.charge_type_='CHARGE'
  530. AND ms.state_=1
  531. AND pr.order_status_='PAID'
  532. GROUP BY ms.id_
  533. ORDER BY count(DISTINCT pr.student_id_) DESC,ms.id_ desc
  534. limit 5
  535. </select>
  536. <select id="selectTeacherCount" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherAuditMusicSheetVo">
  537. select
  538. sum(if(t.audit_status_ = 'DOING',1,0)) as doing,
  539. sum(if(t.audit_status_ = 'PASS'
  540. and t.state_ = 1,1,0)) as pass,
  541. sum(if(t.audit_status_ = 'UNPASS',1,0)) as upPass
  542. from
  543. music_sheet t
  544. where t.user_id_ = #{userId}
  545. </select>
  546. <select id="queryStudentTotal" resultType="com.yonge.cooleshow.biz.dal.vo.StudentTotalVo">
  547. select
  548. t.user_id_ as userId,
  549. a.musicAlbumNum,
  550. b.musicSheetNum
  551. from teacher t
  552. left join (
  553. select
  554. user_id_, count(1) as musicAlbumNum
  555. from album_favorite
  556. <where>
  557. <if test="null != userId">
  558. and user_id_ = #{userId}
  559. </if>
  560. </where>
  561. group by user_id_
  562. ) a on t.user_id_ = a.user_id_
  563. left join (
  564. select
  565. user_id_, count(1) as musicSheetNum
  566. from music_favorite
  567. <where>
  568. <if test="null != userId">
  569. and user_id_ = #{userId}
  570. </if>
  571. </where>
  572. group by user_id_
  573. ) b on t.user_id_ = b.user_id_
  574. </select>
  575. <select id="queryTeacherTotal" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherTotalVo">
  576. select
  577. t.user_id_ as userId,
  578. a.musicSheetNum as musicSheetNum
  579. from student t
  580. left join (
  581. select
  582. user_id_, count(1) as musicSheetNum
  583. from music_sheet
  584. where source_type_ = 'TEACHER' and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0
  585. <if test="null != userId">
  586. and user_id_ = #{userId}
  587. </if>
  588. group by user_id_
  589. ) a on t.user_id_ = a.user_id_
  590. </select>
  591. </mapper>