MusicSheetMapper.xml 68 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446
  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="favorite_count_" jdbcType="INTEGER" property="favoriteCount"/>
  15. <result column="virtual_number_" property="virtualNumber" />
  16. <result column="first_pass_audit_time_" jdbcType="TIMESTAMP" property="firstPassAuditTime"/>
  17. <result column="can_evaluate_" jdbcType="TINYINT" property="canEvaluate"/>
  18. <result column="show_fingering_" jdbcType="TINYINT" property="showFingering"/>
  19. <result column="charge_type_" jdbcType="TINYINT" property="chargeType"/>
  20. <result column="audit_status_" jdbcType="TINYINT" property="auditStatus"/>
  21. <result column="sort_number_" jdbcType="INTEGER" property="sortNumber"/>
  22. <result column="top_flag_" jdbcType="TINYINT" property="topFlag"/>
  23. <result column="hot_flag_" jdbcType="TINYINT" property="hotFlag"/>
  24. <result column="exquisite_flag_" jdbcType="TINYINT" property="exquisiteFlag"/>
  25. <result column="music_price_" jdbcType="DECIMAL" property="musicPrice"/>
  26. <result column="audio_file_url_" jdbcType="VARCHAR" property="audioFileUrl"/>
  27. <result column="xml_file_url_" jdbcType="VARCHAR" property="xmlFileUrl"/>
  28. <result column="has_beat_" jdbcType="TINYINT" property="hasBeat"/>
  29. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime"/>
  30. <result column="create_by_" jdbcType="BIGINT" property="createBy"/>
  31. <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime"/>
  32. <result column="update_by_" jdbcType="BIGINT" property="updateBy"/>
  33. <result column="remark_" jdbcType="VARCHAR" property="remark"/>
  34. <result column="notation_" jdbcType="VARCHAR" property="notation"/>
  35. <result column="accompaniment_type_" jdbcType="VARCHAR" property="accompanimentType"/>
  36. <result column="title_img_" jdbcType="VARCHAR" property="titleImg"/>
  37. <result column="music_img_" jdbcType="VARCHAR" property="musicImg"/>
  38. <result column="first_tone_" jdbcType="VARCHAR" property="firstTone"/>
  39. <result column="fixed_tone_" jdbcType="VARCHAR" property="fixedTone"/>
  40. <result column="music_sheet_type_" jdbcType="VARCHAR" property="musicSheetType"/>
  41. <result column="provider_type_" jdbcType="VARCHAR" property="providerType"/>
  42. <result column="cbs_music_sheet_id_" property="cbsMusicSheetId"/>
  43. <result column="score_type_" property="scoreType"/>
  44. <result column="tenant_sort_number_" property="tenantSortNumber"/>
  45. <result column="tenant_state_" property="tenantState"/>
  46. <result column="tenant_notation_" property="tenantNotation"/>
  47. <result column="tenant_category_id_" property="tenantCategoryId"/>
  48. <result column="tenant_score_type_" property="tenantScoreType"/>
  49. <result column="tenant_del_flag_" property="tenantCategoryId"/>
  50. </resultMap>
  51. <sql id="Base_Column_List">
  52. t.id_ as id ,
  53. t.music_sheet_name_ as musicSheetName,
  54. t.user_id_ as userId,
  55. t.composer_ as composer,
  56. t.music_subject_ as musicSubject,
  57. t.audio_type_ as audioType,
  58. t.music_tag_ as musicTag,
  59. t.play_speed_ as playSpeed,
  60. t.favorite_count_ as favoriteCount,
  61. t.virtual_number_ as virtualNumber,
  62. t.first_pass_audit_time_ as firstPassAuditTime,
  63. t.can_evaluate_ as canEvaluate,
  64. t.show_fingering_ as showFingering,
  65. t.charge_type_ as chargeType,
  66. t.payment_type_ as paymentType,
  67. t.provider_type_ as providerType,
  68. t.state_ as state,
  69. t.client_state_ as clientState,
  70. t.platform_state_ as platformState,
  71. t.sort_number_ as sortNumber,
  72. t.top_flag_ as topFlag,
  73. t.exquisite_flag_ as exquisiteFlag,
  74. t.hot_flag_ as hotFlag,
  75. t.music_price_ as musicPrice,
  76. t.audio_file_url_ as audioFileUrl,
  77. t.xml_file_url_ as xmlFileUrl,
  78. t.has_beat_ as hasBeat,
  79. t.mp3_type_ as mp3Type,
  80. t.ext_config_json_ as extConfigJson,
  81. t.create_time_ as createTime,
  82. t.create_by_ as createBy,
  83. t.update_time_ as updateTime,
  84. t.update_by_ as updateBy,
  85. t.del_flag_ as delFlag,
  86. t.audit_version_ as auditVersion,
  87. t.source_type_ as sourceType,
  88. t.accompaniment_type_ as accompanimentType,
  89. t.remark_ as remark,
  90. t.first_tone_ as firstTone,
  91. t.fixed_tone_ as fixedTone,
  92. t.title_img_ as titleImg,
  93. t.reason_ as reason,
  94. t.music_img_ as musicImg,
  95. t.notation_ as notation,
  96. t.music_json_ as musicJSON,
  97. t.music_svg_ as musicSvg,
  98. t.music_jian_svg_ as musicJianSvg,
  99. t.music_first_svg_ as musicFirstSvg,
  100. t.music_sheet_type_ as musicSheetType,
  101. t.audit_status_ as auditStatus,
  102. t.submit_audit_time_ as submitAuditTime,
  103. t.cbs_music_sheet_id_ as cbsMusicSheetId,
  104. t.score_type_ as scoreType,
  105. t.tenant_sort_number_ as tenantSortNumber,
  106. t.tenant_state_ as tenantState,
  107. t.tenant_notation_ as tenantNotation,
  108. t.tenant_category_id_ as tenantCategoryId,
  109. t.tenant_score_type_ as tenantScoreType,
  110. t.tenant_del_flag_ as tenantDelFlag
  111. </sql>
  112. <insert id="batchInsert">
  113. insert into music_sheet
  114. (cbs_music_sheet_id_,music_tag_,payment_type_,charge_type_,top_flag_,exquisite_flag_,sort_number_,state_,audit_status_
  115. ,music_sheet_name_,music_subject_,music_svg_,composer_,accompaniment_type_,play_speed_,
  116. music_price_,notation_,music_sheet_type_,source_type_,provider_type_,audio_type_,show_fingering_,
  117. can_evaluate_,create_by_,user_id_,score_type_,is_all_subject_,first_pass_audit_time_
  118. )
  119. values
  120. <foreach collection="vos" item="item" separator=",">
  121. (#{item.musicSheetId},
  122. #{item.musicTagIds},#{item.paymentType},#{item.paymentType},
  123. #{item.topFlag},#{item.exquisiteFlag},#{item.sortNo},0
  124. ,'PASS'
  125. ,#{item.musicSheetUpdate.name},
  126. #{item.musicSheetUpdate.subjectIds},
  127. #{item.musicSheetUpdate.musicSvg},
  128. #{item.musicSheetUpdate.composer},
  129. #{item.musicSheetUpdate.audioType},
  130. #{item.musicSheetUpdate.playSpeed},
  131. #{item.musicSheetUpdate.musicPrice},
  132. #{item.isConvertibleScore},
  133. #{item.musicSheetUpdate.musicSheetType},
  134. CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  135. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER'
  136. ELSE 'TENANT' END,
  137. CASE WHEN #{item.availableType} = 'PLATFORM' THEN 'PLATFORM' ELSE 'TENANT' END,
  138. #{item.musicSheetUpdate.playMode},
  139. #{item.musicSheetUpdate.showFingering},
  140. #{item.musicSheetUpdate.canEvaluate},
  141. #{item.musicSheetUpdate.userId},#{item.musicSheetUpdate.userId},
  142. #{item.scoreType},#{item.musicSheetUpdate.isAllSubject},now()
  143. )
  144. </foreach>
  145. </insert>
  146. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  147. select <include refid="Base_Column_List"/>
  148. from music_sheet t
  149. left join sys_user su on t.create_by_ = su.id_
  150. <if test="param.sortByAlbumIdDesc != null">
  151. left join tenant_album_music tam on tam.music_sheet_id_ = t.id_ and tam.tenant_album_id_ = #{param.sortByAlbumIdDesc} and tam.del_flag_=0
  152. </if>
  153. <if test="param.auditStatus != null">
  154. left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
  155. </if>
  156. <where>
  157. 1=1
  158. <if test="param.clientState != null">
  159. and t.client_state_ = #{param.clientState}
  160. </if>
  161. <if test="param.platformState != null">
  162. and t.platform_state_ = #{param.platformState}
  163. </if>
  164. <if test="param.excludeMusicIds != null and param.excludeMusicIds.size() != 0">
  165. and t.id_ not in
  166. <foreach collection="param.excludeMusicIds" separator="," item="item" open="(" close=")">
  167. #{item}
  168. </foreach>
  169. </if>
  170. <if test="param.mustMatchSubjectIds != null and param.mustMatchSubjectIds.size() != 0">
  171. and
  172. <foreach collection="param.mustMatchSubjectIds" separator="and" item="item" open="(" close=")">
  173. find_in_set(#{item},t.music_subject_)
  174. </foreach>
  175. </if>
  176. <include refid="QueryInfo"/>
  177. <if test="param.auditStatus == null">
  178. AND t.cbs_music_sheet_id_ IS NOT NULL
  179. </if>
  180. <if test="param.tenantCategoryIds != null and param.tenantCategoryIds.size() != 0">
  181. and t.tenant_category_id_ in
  182. <foreach collection="param.tenantCategoryIds" separator="," item="item" open="(" close=")">
  183. #{item}
  184. </foreach>
  185. </if>
  186. <if test="param.auditVersion != null ">
  187. and #{param.auditVersion} = t.audit_version_
  188. </if>
  189. <if test="param.notation">
  190. AND t.notation_ = #{param.notation}
  191. </if>
  192. </where>
  193. <if test="param.auditStatus != null">
  194. group by msar.music_sheet_id_
  195. </if>
  196. order by
  197. <if test="param.sortByAlbumIdDesc != null">
  198. if(isnull(tam.id_),0,1),
  199. </if>
  200. <if test="param.myself == null or param.myself == false ">
  201. t.top_flag_ desc,t.sort_number_ desc,
  202. </if>
  203. t.cbs_music_sheet_id_ desc
  204. </select>
  205. <sql id="QueryInfo">
  206. <if test="param.musicSheetType != null">
  207. and t.music_sheet_type_ = #{param.musicSheetType}
  208. </if>
  209. <if test="param.idAndName != null and param.idAndName != ''">
  210. <if test="param.auditStatus != null">
  211. AND ((su.id_ like concat('%',#{param.idAndName} ,'%')
  212. or su.username_ like concat('%',#{param.idAndName},'%')
  213. or su.phone_ like concat('%',#{param.idAndName},'%')) OR
  214. (t.music_sheet_name_ like concat('%',#{param.idAndName},'%') AND msar.last_audit_state_ = 'PASS') OR
  215. (JSON_UNQUOTE(JSON_EXTRACT(music_sheet_json_, '$.name')) LIKE CONCAT('%',#{param.idAndName},'%') AND msar.last_audit_state_ != 'PASS'))
  216. </if>
  217. <if test="param.auditStatus == null">
  218. AND (su.id_ like concat('%',#{param.idAndName} ,'%')
  219. or su.username_ like concat('%',#{param.idAndName},'%')
  220. or su.phone_ like concat('%',#{param.idAndName},'%') OR
  221. t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  222. </if>
  223. </if>
  224. <if test="param.search != null and param.search != ''">
  225. and (t.cbs_music_sheet_id_ like concat('%',#{param.search},'%') or
  226. t.music_sheet_name_ like concat('%',#{param.search},'%') or
  227. t.composer_ like concat ('%',#{param.search},'%'))
  228. </if>
  229. <if test="param.providerType != null">
  230. and find_in_set(#{param.providerType},t.provider_type_)
  231. </if>
  232. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  233. and
  234. <foreach collection="param.musicTagIdList" open="(" close=")" separator="or" item="item">
  235. find_in_set(#{item},t.music_tag_)
  236. </foreach>
  237. </if>
  238. <if test="param.subjectIdList != null and param.subjectIdList.size() != 0">
  239. and(
  240. <foreach collection="param.subjectIdList" separator="or" item="item" open="(" close=")">
  241. find_in_set(#{item},t.music_subject_)
  242. </foreach>
  243. or t.music_subject_ is null or t.music_subject_ = '' OR t.is_all_subject_
  244. )
  245. </if>
  246. <if test="param.subjectIds != null and param.subjectIds != ''">
  247. and(find_in_set(#{param.subjectIds},t.music_subject_) or t.music_subject_ is null or t.music_subject_ = '' OR t.is_all_subject_)
  248. </if>
  249. <if test="param.musicSheetIdlist != null and param.musicSheetIdlist.size() != 0">
  250. and t.id_ in
  251. <foreach collection="param.musicSheetIdlist" separator="," item="item" open="(" close=")">
  252. #{item}
  253. </foreach>
  254. </if>
  255. <if test="param.state != null">
  256. <if test="param.providerType != null">
  257. <if test="param.providerType.code == 'TENANT'">
  258. and t.tenant_state_ = #{param.state}
  259. </if>
  260. <if test="param.providerType.code == 'PLATFORM'">
  261. and t.state_ = #{param.state}
  262. </if>
  263. </if>
  264. <if test="param.providerType == null">
  265. and t.state_ = #{param.state}
  266. </if>
  267. </if>
  268. <if test="param.auditStatus != null">
  269. and msar.last_audit_state_ = #{param.auditStatus}
  270. </if>
  271. <if test="param.scoreType != null">
  272. and t.score_type_ = #{param.scoreType}
  273. </if>
  274. <if test="param.createBy != null">
  275. and t.create_by_ = #{param.createBy}
  276. </if>
  277. <if test="param.delFlag != null">
  278. <if test="param.providerType != null">
  279. <if test="param.providerType.code == 'TENANT'">
  280. and t.tenant_del_flag_ = #{param.delFlag}
  281. </if>
  282. <if test="param.providerType.code == 'PLATFORM'">
  283. and t.del_flag_ = #{param.delFlag}
  284. </if>
  285. </if>
  286. <if test="param.providerType == null">
  287. and t.del_flag_ = #{param.delFlag}
  288. </if>
  289. </if>
  290. <if test="param.sourceType != null">
  291. and t.source_type_ = #{param.sourceType}
  292. </if>
  293. <if test="param.chargeType != null">
  294. and (FIND_IN_SET(#{param.chargeType}, t.payment_type_))
  295. </if>
  296. <if test="param.topFlag != null">
  297. and t.top_flag_ = #{param.topFlag}
  298. </if>
  299. <if test="param.exquisiteFlag != null">
  300. and t.exquisite_flag_ = #{param.exquisiteFlag}
  301. </if>
  302. <if test="param.accompanimentType != null">
  303. and t.accompaniment_type_ = #{param.accompanimentType}
  304. </if>
  305. <if test="param.audioType != null">
  306. and t.audio_type_ = #{param.audioType}
  307. </if>
  308. </sql>
  309. <select id="selectAlbumDetailPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  310. select distinct <include refid="Base_Column_List"/>
  311. ,su.username_ as addName
  312. ,su.avatar_ as addUserAvatar
  313. ,(select group_concat(mt.name_) from music_tag mt
  314. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  315. ,(select group_concat(s.name_) from subject s
  316. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  317. ,amr.sort_number_ as albumSortNumber
  318. from music_sheet t
  319. left join album_music_relate amr on t.id_ = amr.music_sheet_id_
  320. left join sys_user su on t.create_by_ = su.id_
  321. <where>
  322. t.cbs_music_sheet_id_ IS NOT NULL and find_in_set('PLATFORM',t.provider_type_)
  323. <if test="param.composer != null">
  324. AND t.composer_ LIKE '%${param.composer}%'
  325. </if>
  326. <if test="param.providerType != null">
  327. and find_in_set(#{param.providerType},t.provider_type_)
  328. </if>
  329. <if test="param.idAndName != null and param.idAndName != ''">
  330. and (t.id_ like concat('%',#{param.idAndName},'%') or
  331. t.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  332. </if>
  333. <if test="param.search != null and param.search != ''">
  334. and (t.cbs_music_sheet_id_ like concat('%',#{param.search},'%') or
  335. t.music_sheet_name_ like concat('%',#{param.search},'%'))
  336. </if>
  337. <if test="param.chargeType != null">
  338. and t.charge_type_ = #{param.chargeType}
  339. </if>
  340. <if test="param.excludeMusicIds != null and param.excludeMusicIds.size() != 0">
  341. and t.id_ not in
  342. <foreach collection="param.excludeMusicIds" separator="," item="item" open="(" close=")">
  343. #{item}
  344. </foreach>
  345. </if>
  346. <if test="param.musicTagIds != null and param.musicTagIds != ''">
  347. and
  348. <foreach collection="param.musicTagIdList" separator="or" item="item" open="(" close=")" >
  349. find_in_set(#{item},t.music_tag_)
  350. </foreach>
  351. </if>
  352. <if test="param.subjectIdList != null and param.subjectIdList.size() != 0">
  353. and
  354. <foreach collection="param.subjectIdList" separator="or" item="item" open="(" close=")" >
  355. find_in_set(#{item},t.music_subject_)
  356. </foreach>
  357. </if>
  358. <if test="param.musicSheetType != null">
  359. and t.music_sheet_type_ = #{param.musicSheetType}
  360. </if>
  361. <if test="param.state != null">
  362. and t.state_ = #{param.state}
  363. </if>
  364. <if test="param.delFlag != null">
  365. and t.del_flag_ = #{param.delFlag}
  366. </if>
  367. <if test="param.sourceType != null">
  368. AND t.source_type_ = #{param.sourceType}
  369. </if>
  370. <if test="param.chargeType != null">
  371. AND (t.payment_type_ = 'FREE' OR FIND_IN_SET(#{param.chargeType}, t.payment_type_))
  372. </if>
  373. <if test="param.paymentTypes != null">
  374. AND t.payment_type_ IN (<foreach collection="param.paymentTypes" separator="," item="item">#{item}</foreach>)
  375. </if>
  376. <if test="param.id != null">
  377. <if test="param.type == 2">
  378. and amr.album_id_ = #{param.id}
  379. order by amr.sort_number_ desc, t.id_ desc
  380. </if>
  381. <if test="param.type == 1">
  382. and t.id_ not in(select amr2.music_sheet_id_ from album_music_relate amr2
  383. where amr2.album_id_ = #{param.id})
  384. order by t.id_ desc
  385. </if>
  386. </if>
  387. </where>
  388. </select>
  389. <select id="detail" resultMap="DetailResultMap">
  390. SELECT
  391. <include refid="Base_Column_List"/>
  392. ,t.url_ as url
  393. ,t.midi_url_ as midiUrl
  394. ,t.metronome_url_ as metronomeUrl
  395. ,msa.id_ as accompanimentId
  396. ,msa.music_sheet_id_ as accompanimentMusicSheetId
  397. ,msa.audio_file_url_ as accompanimentAudioFileUrl
  398. ,msa.sort_number_ as accompanimentSortNumber
  399. ,msa.create_time_ as accompanimentCreateTime
  400. ,msa.track_ as track
  401. ,msa.musical_instrument_id_ as musicalInstrumentId
  402. ,su.username_ as userName
  403. ,su.avatar_ as userAvatar
  404. ,(
  405. select group_concat(mt.name_) from music_tag mt
  406. where find_in_set(mt.id_,t.music_tag_)
  407. and mt.del_flag_ = 0 and mt.state_ = 1
  408. ) as musicTagNames
  409. ,s2.name_ as subjectNames
  410. ,s2.code_ as code
  411. ,su.real_name_ as realName
  412. ,s2.ai_default_frequency_ as aiDefaultFrequency
  413. FROM music_sheet t
  414. left join music_sheet_accompaniment msa on msa.music_sheet_id_ = t.id_
  415. left join sys_user su on t.create_by_ = su.id_
  416. left join subject s2 on t.music_subject_ = s2.id_
  417. where t.id_ = #{id} AND t.cbs_music_sheet_id_ IS NOT NULL
  418. order by msa.sort_number_
  419. </select>
  420. <resultMap id="DetailResultMap" type="com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo">
  421. <id column="id" jdbcType="BIGINT" property="id"/>
  422. <result column="musicSheetName" jdbcType="VARCHAR" property="musicSheetName"/>
  423. <result column="userId" jdbcType="BIGINT" property="userId"/>
  424. <result column="cbsMusicSheetId" jdbcType="BIGINT" property="cbsMusicSheetId"/>
  425. <result column="composer" jdbcType="VARCHAR" property="composer"/>
  426. <result column="titleImg" jdbcType="VARCHAR" property="titleImg"/>
  427. <result column="musicSubject" jdbcType="VARCHAR" property="musicSubject"/>
  428. <result column="audioType" jdbcType="VARCHAR" property="audioType"/>
  429. <result column="providerType" jdbcType="VARCHAR" property="providerType"/>
  430. <result column="musicTag" jdbcType="VARCHAR" property="musicTag"/>
  431. <result column="playSpeed" jdbcType="INTEGER" property="playSpeed"/>
  432. <result column="canEvaluate" jdbcType="TINYINT" property="canEvaluate"/>
  433. <result column="showFingering" jdbcType="TINYINT" property="showFingering"/>
  434. <result column="chargeType" jdbcType="TINYINT" property="chargeType"/>
  435. <result column="auditStatus" property="auditStatus"/>
  436. <result column="state" jdbcType="TINYINT" property="state"/>
  437. <result column="sortNumber" jdbcType="INTEGER" property="sortNumber"/>
  438. <result column="topFlag" jdbcType="TINYINT" property="topFlag"/>
  439. <result column="hotFlag" jdbcType="TINYINT" property="hotFlag"/>
  440. <result column="musicPrice" jdbcType="DECIMAL" property="musicPrice"/>
  441. <result column="audioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  442. <result column="musicTagNames" jdbcType="VARCHAR" property="musicTagNames"/>
  443. <result column="subjectNames" jdbcType="VARCHAR" property="subjectNames"/>
  444. <result column="xmlFileUrl" jdbcType="VARCHAR" property="xmlFileUrl"/>
  445. <result column="hasBeat" jdbcType="TINYINT" property="hasBeat"/>
  446. <result column="createTime" jdbcType="TIMESTAMP" property="createTime"/>
  447. <result column="createBy" jdbcType="BIGINT" property="createBy"/>
  448. <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime"/>
  449. <result column="updateBy" jdbcType="BIGINT" property="updateBy"/>
  450. <result column="delFlag" jdbcType="BOOLEAN" property="delFlag"/>
  451. <result column="url" jdbcType="BOOLEAN" property="url"/>
  452. <result column="metronomeUrl" jdbcType="BOOLEAN" property="metronomeUrl"/>
  453. <result column="midiUrl" jdbcType="BOOLEAN" property="midiUrl"/>
  454. <result column="mp3Type" jdbcType="VARCHAR" property="mp3Type"/>
  455. <result column="remark" jdbcType="VARCHAR" property="remark"/>
  456. <result column="userName" jdbcType="VARCHAR" property="userName"/>
  457. <result column="auditVersion" jdbcType="VARCHAR" property="auditVersion"/>
  458. <result column="code" jdbcType="VARCHAR" property="code"/>
  459. <result column="reason" jdbcType="VARCHAR" property="reason"/>
  460. <result column="accompanimentType" jdbcType="VARCHAR" property="accompanimentType"/>
  461. <result column="notation" jdbcType="VARCHAR" property="notation"/>
  462. <result column="musicImg" jdbcType="VARCHAR" property="musicImg"/>
  463. <result column="favoriteCount" jdbcType="VARCHAR" property="favoriteCount"/>
  464. <result column="firstPassAuditTime" jdbcType="VARCHAR" property="firstPassAuditTime"/>
  465. <result column="realName" jdbcType="VARCHAR" property="realName"/>
  466. <result column="auditTime" jdbcType="VARCHAR" property="auditTime"/>
  467. <result column="auditName" jdbcType="VARCHAR" property="auditName"/>
  468. <result column="auditReason" jdbcType="VARCHAR" property="auditReason"/>
  469. <result column="aiDefaultFrequency" jdbcType="VARCHAR" property="aiDefaultFrequency"/>
  470. <result column="musicJSON" jdbcType="VARCHAR" property="musicJSON"/>
  471. <result column="musicSvg" jdbcType="VARCHAR" property="musicSvg"/>
  472. <result column="musicJianSvg" jdbcType="VARCHAR" property="musicJianSvg"/>
  473. <result column="musicFirstSvg" jdbcType="VARCHAR" property="musicFirstSvg"/>
  474. <result column="musicSheetType" jdbcType="VARCHAR" property="musicSheetType"/>
  475. <result column="musicSheetJson" jdbcType="VARCHAR" property="musicSheetJson"/>
  476. <result column="tenantSortNumber" jdbcType="VARCHAR" property="tenantSortNumber"/>
  477. <result column="tenantState" jdbcType="VARCHAR" property="tenantState"/>
  478. <result column="tenantNotation" jdbcType="VARCHAR" property="tenantNotation"/>
  479. <result column="tenantCategoryId" jdbcType="VARCHAR" property="tenantCategoryId"/>
  480. <result column="tenantScoreType" jdbcType="VARCHAR" property="tenantScoreType"/>
  481. <result column="tenantDelFlag" jdbcType="VARCHAR" property="tenantDelFlag"/>
  482. <result column="scoreType" jdbcType="VARCHAR" property="scoreType"/>
  483. <collection property="background" ofType="com.yonge.cooleshow.biz.dal.entity.MusicSheetAccompaniment">
  484. <id column="accompanimentId" jdbcType="BIGINT" property="id"/>
  485. <result column="accompanimentMusicSheetId" jdbcType="BIGINT" property="musicSheetId"/>
  486. <result column="accompanimentMusicSubject" jdbcType="VARCHAR" property="musicSubjectId"/>
  487. <result column="accompanimentAudioFileUrl" jdbcType="VARCHAR" property="audioFileUrl"/>
  488. <result column="accompanimentSortNumber" jdbcType="TINYINT" property="sortNumber"/>
  489. <result column="accompanimentCreateTime" jdbcType="TIMESTAMP" property="createTime"/>
  490. <result column="accompanimentMetronomeUrl" jdbcType="VARCHAR" property="metronomeUrl"/>
  491. <result column="track" jdbcType="VARCHAR" property="track"/>
  492. <result column="musicalInstrumentId" jdbcType="VARCHAR" property="musicalInstrumentId"/>
  493. </collection>
  494. </resultMap>
  495. <select id="selectStudentMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  496. select <include refid="Base_Column_List"/>
  497. ,su.username_ as addName
  498. ,su.avatar_ as addUserAvatar
  499. from music_sheet t
  500. left join sys_user su on t.create_by_ = su.id_
  501. <if test="param.auditStatus != null">
  502. left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
  503. </if>
  504. <where>
  505. 1=1
  506. <include refid="QueryInfo"/>
  507. <if test="param.auditVersion != null ">
  508. and #{param.auditVersion} = t.audit_version_
  509. </if>
  510. </where>
  511. <if test="param.auditStatus != null">
  512. group by msar.music_sheet_id_
  513. </if>
  514. order by
  515. <choose>
  516. <when test="param.musicSortType != null and param.musicSortType.code == 'TOP'">
  517. t.top_flag_ desc, t.sort_number_ desc,
  518. </when>
  519. <when test="param.musicSortType != null and param.musicSortType.code == 'HOT'">
  520. t.favorite_count_ desc,
  521. </when>
  522. <when test="param.musicSortType != null and param.musicSortType.code == 'NEW'">
  523. t.first_pass_audit_time_ desc,
  524. </when>
  525. <otherwise>
  526. <if test="param.myself == null or param.myself == false ">
  527. t.top_flag_ desc, t.sort_number_ desc, t.favorite_count_ desc,
  528. </if>
  529. </otherwise>
  530. </choose>
  531. t.id_ desc
  532. </select>
  533. <select id="selectMyMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  534. select distinct <include refid="Base_Column_List"/>
  535. ,su.username_ as addName
  536. ,su.avatar_ as addUserAvatar
  537. ,(select group_concat(mt.name_) from music_tag mt
  538. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  539. ,(select group_concat(s.name_) from subject s
  540. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  541. ,if(mf.id_ is not null,1,0) as favorite
  542. from music_sheet t
  543. left join sys_user su on t.create_by_ = su.id_
  544. left join music_sheet_purchase_record mspr on mspr.music_sheet_id_ = t.id_
  545. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mspr.student_id_ = mf.user_id_
  546. <if test="param.auditStatus != null">
  547. left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
  548. </if>
  549. <where>
  550. 1=1
  551. <include refid="QueryInfo"/>
  552. <if test="param.studentId != null">
  553. and mspr.student_id_ = #{param.studentId}
  554. and mspr.order_status_ = 'PAID'
  555. </if>
  556. <if test="param.userType != null">
  557. and mspr.client_type_ = #{param.userType}
  558. </if>
  559. <if test="param.purchaseType != null">
  560. AND mspr.purchase_type_ = #{param.purchaseType}
  561. </if>
  562. <if test="param.courseGift != null">
  563. AND mspr.course_music_album_id_ <choose><when test="param.courseGift == 0"> = </when><otherwise> > </otherwise> </choose> 0
  564. </if>
  565. </where>
  566. <if test="param.auditStatus != null">
  567. group by msar.music_sheet_id_
  568. </if>
  569. order by mspr.id_ desc
  570. </select>
  571. <select id="selectFavoriteMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  572. select <include refid="Base_Column_List"/>
  573. ,su.username_ as addName
  574. ,su.avatar_ as addUserAvatar
  575. ,(select group_concat(mt.name_) from music_tag mt
  576. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  577. ,(select group_concat(s.name_) from subject s
  578. where find_in_set(s.id_,t.music_subject_) and s.del_flag_ = 0 ) as subjectNames
  579. ,if(mf.id_ is not null,1,0) as favorite
  580. from music_sheet t
  581. left join sys_user su on t.create_by_ = su.id_
  582. left join music_favorite mf on t.id_ = mf.music_sheet_id_
  583. <if test="param.auditStatus != null">
  584. left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
  585. </if>
  586. <where>
  587. mf.client_type_ = #{clientType}
  588. <if test="clientType.code == 'STUDENT'">
  589. and t.del_flag_=0 and t.state_ =1 and find_in_set('PLATFORM',t.provider_type_)
  590. </if>
  591. <if test="clientType.code == 'TEACHER'">
  592. and ((t.del_flag_=0 and t.state_ =1 and find_in_set('PLATFORM',t.provider_type_))
  593. <if test="param.tenantId !=null">
  594. or (t.tenant_del_flag_=0 and t.tenant_state_ =1 and find_in_set('TENANT',t.provider_type_)
  595. and t.id_ in (select s.music_sheet_id_ from tenant_album_music s
  596. left join tenant_album s1 on s.tenant_album_id_ = s1.id_ where s.tenant_id_ = #{param.tenantId}
  597. and s.del_flag_ = 0 and s.subject_type_ in ('ENSEMBLE','MUSIC','SUBJECT') and s1.del_flag_= 0 and s1.status_ = 1
  598. )
  599. )
  600. </if>
  601. )
  602. </if>
  603. <if test="param.studentId != null">
  604. and mf.user_id_ = #{param.studentId}
  605. </if>
  606. </where>
  607. <if test="param.auditStatus != null">
  608. group by msar.music_sheet_id_
  609. </if>
  610. order by mf.id_ desc
  611. </select>
  612. <select id="selectPracticeMusicPage" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  613. select <include refid="Base_Column_List"/>
  614. ,su.username_ as addName
  615. ,su.avatar_ as addUserAvatar
  616. ,(select group_concat(mt.name_) from music_tag mt
  617. where find_in_set(mt.id_,t.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  618. ,(select group_concat(s.name_) from subject s where find_in_set(s.id_,t.music_subject_) ) as subjectNames
  619. ,if(mf.id_ is not null,1,0) as favorite
  620. from sys_music_compare_record mspr
  621. left join music_sheet t on mspr.music_sheet_id_ = t.id_
  622. <if test="param.auditStatus != null">
  623. left join music_sheet_auth_record msar ON msar.music_sheet_id_ = t.id_
  624. </if>
  625. left join sys_user su on t.create_by_ = su.id_
  626. left join music_favorite mf on (t.id_ = mf.music_sheet_id_ and mspr.user_id_ = mf.user_id_ <if test="param.clientType != null"> AND mf.client_type_ = #{param.clientType}</if> )
  627. <where>
  628. 1=1
  629. <include refid="QueryInfo"/>
  630. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  631. and mspr.id_ in
  632. <foreach collection="practiceMusicIdList" item="item" open="(" close=")" separator=",">
  633. #{item}
  634. </foreach>
  635. </if>
  636. </where>
  637. <if test="param.auditStatus != null">
  638. group by msar.music_sheet_id_
  639. </if>
  640. <if test="practiceMusicIdList != null and practiceMusicIdList.size() != 0">
  641. order by field(mspr.id_,
  642. <foreach collection="practiceMusicIdList" item="item" separator=",">
  643. #{item}
  644. </foreach>
  645. </if>
  646. )
  647. </select>
  648. <select id="selectStudentOrderPage" resultType="com.yonge.cooleshow.biz.dal.vo.StudentMusicSheetOrderVo">
  649. select distinct mspr.music_sheet_id_ as musicSheetId
  650. ,ms.music_sheet_name_ as musicSheetName
  651. ,ms.composer_ as composer
  652. ,ms.title_img_ as titleImg
  653. ,ms.music_tag_ as musicTag
  654. ,(select group_concat(mt.name_) from music_tag mt
  655. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  656. ,mspr.purchase_price_ as purchasePrice
  657. ,mspr.order_no_ as orderNo
  658. ,mspr.purchase_time_ as purchaseTime
  659. from music_sheet_purchase_record mspr
  660. left join music_sheet ms on mspr.music_sheet_id_ = ms.id_
  661. <where>
  662. mspr.order_status_ = 'PAID' and mspr.purchase_type_ = 'MUSIC'
  663. <if test="param.idAndName != null and param.idAndName != ''">
  664. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  665. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%'))
  666. </if>
  667. <if test="param.studentId != null">
  668. and mspr.student_id_ = #{param.studentId}
  669. </if>
  670. <if test="param.orderNo != null and param.orderNo != ''">
  671. and mspr.order_no_ = #{param.orderNo}
  672. </if>
  673. <if test="param.musicTagList != null and param.musicTagList.size() != 0">
  674. and
  675. <foreach collection="param.musicTagList" separator="or" item="item" open="(" close=")" >
  676. find_in_set(#{item},ms.music_tag_)
  677. </foreach>
  678. </if>
  679. <if test="param.startTime != null">
  680. and mspr.purchase_time_ &gt; #{param.startTime}
  681. </if>
  682. <if test="param.endTime != null">
  683. and mspr.purchase_time_ &lt; #{param.endTime}
  684. </if>
  685. </where>
  686. order by mspr.id_ desc
  687. </select>
  688. <select id="selectTeacherPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  689. select ms.id_ as musicSheetId
  690. ,ms.music_sheet_name_ as musicSheetName
  691. ,ms.composer_ as composer
  692. ,ms.title_img_ as titleImg
  693. ,ms.accompaniment_type_ as accompanimentType
  694. ,ms.music_tag_ as musicTag
  695. ,(select group_concat(mt.name_) from music_tag mt
  696. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  697. ,ms.play_speed_ as playSpeed
  698. ,ms.music_price_ as musicPrice
  699. ,ms.create_time_ as createTime
  700. ,ms.audit_status_ as auditStatus
  701. ,su.username_ as auditName
  702. from music_sheet ms
  703. left join music_sheet_auth_record msar on ms.id_ = msar.music_sheet_id_
  704. left join sys_user su on msar.verify_user_id_ = su.id_
  705. <where>
  706. <if test="param.idAndName != null and param.idAndName != ''">
  707. and (ms.id_ like concat('%',#{param.idAndName} ,'%')
  708. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
  709. or ms.composer_ like concat('%',#{param.idAndName},'%'))
  710. </if>
  711. <if test="param.teacherId != null">
  712. and ms.create_by_ = #{param.teacherId} and ms.source_type_ = 'TEACHER'
  713. </if>
  714. <if test="param.startTime != null">
  715. and ms.create_time_ &gt; #{param.startTime}
  716. </if>
  717. <if test="param.endTime != null">
  718. and ms.create_time_ &lt; #{param.endTime}
  719. </if>
  720. <if test="param.delFlag != null">
  721. and ms.del_flag_ = #{param.delFlag}
  722. </if>
  723. </where>
  724. order by ms.id_ desc
  725. </select>
  726. <select id="selectAuditPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherMusicSheetVo">
  727. select
  728. msar.id_ as authMusicSheetId,
  729. ms.create_by_ as teacherId
  730. ,ms.exquisite_flag_ as exquisiteFlag
  731. ,ms.title_img_ as titleImg
  732. ,ms.accompaniment_type_ as accompanimentType
  733. ,su.username_ as username
  734. ,su.real_name_ as realName
  735. ,su.phone_ as phone
  736. ,ms.id_ as musicSheetId
  737. ,ms.music_sheet_name_ as musicSheetName
  738. ,ms.composer_ as composer
  739. ,ms.music_tag_ as musicTag
  740. ,(select group_concat(mt.name_) from music_tag mt
  741. where find_in_set(mt.id_,ms.music_tag_) and mt.del_flag_ = 0 and mt.state_ = 1) as musicTagNames
  742. ,ms.play_speed_ as playSpeed
  743. ,ms.music_price_ as musicPrice
  744. ,ms.update_time_ as createTime
  745. ,if(msar.audit_state_ is null,ms.audit_status_,msar.audit_state_) as auditStatus
  746. ,su2.username_ as auditName
  747. ,msar.first_auth_ as firstAuth
  748. from music_sheet_auth_record msar
  749. left join music_sheet ms on ms.id_ = msar.music_sheet_id_
  750. left join sys_user su on su.id_ = ms.create_by_
  751. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  752. <where>ms.source_type_ = 'TEACHER'
  753. <if test="param.idAndName != null and param.idAndName != ''">
  754. and (su.id_ like concat('%',#{param.idAndName} ,'%')
  755. or su.username_ like concat('%',#{param.idAndName},'%')
  756. or ms.music_sheet_name_ like concat('%',#{param.idAndName},'%')
  757. or su.phone_ like concat('%',#{param.idAndName},'%'))
  758. </if>
  759. <if test="param.auditName != null and param.auditName != ''">
  760. and su2.username_ like concat('%',#{param.auditName},'%')
  761. </if>
  762. <if test="param.authStatus != null">
  763. and msar.audit_state_ = #{param.authStatus} and msar.audit_state_ = msar.last_audit_state_
  764. </if>
  765. <if test="param.startTime != null">
  766. and ms.create_time_ &gt; #{param.startTime}
  767. </if>
  768. <if test="param.endTime != null">
  769. and ms.create_time_ &lt; #{param.endTime}
  770. </if>
  771. <if test="param.chargeType != null">
  772. and ms.charge_type_ = #{param.chargeType}
  773. </if>
  774. <if test="param.firstAuth != null">
  775. and msar.first_auth_ = #{param.firstAuth}
  776. </if>
  777. <if test="param.exquisiteFlag != null">
  778. and ms.exquisite_flag_ = #{param.exquisiteFlag}
  779. </if>
  780. </where>
  781. order by field(ms.audit_status_,'DOING') desc, ms.submit_audit_time_ desc
  782. </select>
  783. <select id="selectTeacherMusicSheetCount" resultType="java.lang.Integer">
  784. select count(1)
  785. from music_sheet
  786. where user_id_ = #{userId}
  787. and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0 and source_type_ = 'TEACHER'
  788. </select>
  789. <select id="selectMusicNum" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo">
  790. select
  791. sum(if(ms.source_type_ = 'PLATFORM',1,0)) as musicSheetPlatformCount,
  792. sum(if(ms.source_type_ = 'TEACHER',1,0)) as musicSheetTeacherCount,
  793. count(1) as musicSheetCount
  794. from music_sheet ms
  795. where ms.state_ = 1 and ms.del_flag_ = 0 and ms.audit_status_ = 'PASS' and find_in_set('CHARGE',ms.payment_type_) and find_in_set('PLATFORM',ms.provider_type_)
  796. </select>
  797. <select id="selectPayMusicSheet" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo$MusicSheetSmall">
  798. SELECT
  799. ms.id_ as musicSheetId,
  800. ms.music_sheet_name_ as musicSheetName,
  801. count(DISTINCT pr.student_id_) as num
  802. FROM
  803. music_sheet ms
  804. LEFT JOIN music_sheet_purchase_record pr ON ms.id_ = pr.music_sheet_id_
  805. WHERE
  806. ms.del_flag_=0
  807. AND ms.charge_type_='CHARGE'
  808. AND ms.state_=1
  809. AND pr.order_status_='PAID'
  810. GROUP BY ms.id_
  811. ORDER BY count(DISTINCT pr.student_id_) DESC,ms.id_ desc
  812. limit 5
  813. </select>
  814. <select id="selectTeacherCount" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherAuditMusicSheetVo">
  815. select
  816. sum(if(t.audit_status_ = 'DOING',1,0)) as doing,
  817. sum(if(t.audit_status_ = 'PASS'
  818. and t.state_ = 1,1,0)) as pass,
  819. sum(if(t.audit_status_ = 'UNPASS',1,0)) as upPass
  820. from
  821. music_sheet t
  822. where t.user_id_ = #{userId}
  823. </select>
  824. <select id="queryStudentTotal" resultType="com.yonge.cooleshow.biz.dal.vo.StudentTotalVo">
  825. select
  826. t.user_id_ as userId,
  827. a.musicAlbumNum,
  828. b.musicSheetNum
  829. from student t
  830. left join (
  831. select
  832. user_id_, count(1) as musicAlbumNum
  833. from album_favorite
  834. <where>
  835. <if test="null != userId">
  836. and user_id_ = #{userId}
  837. </if>
  838. </where>
  839. group by user_id_
  840. ) a on t.user_id_ = a.user_id_
  841. left join (
  842. select
  843. user_id_, count(1) as musicSheetNum
  844. from music_favorite
  845. <where>
  846. <if test="null != userId">
  847. and user_id_ = #{userId}
  848. </if>
  849. </where>
  850. group by user_id_
  851. ) b on t.user_id_ = b.user_id_
  852. <where>
  853. <if test="null != userId">
  854. and t.user_id_ = #{userId}
  855. </if>
  856. </where>
  857. </select>
  858. <select id="queryTeacherTotal" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherTotalVo">
  859. select
  860. t.user_id_ as userId,
  861. a.musicSheetNum as musicSheetNum
  862. from teacher t
  863. left join (
  864. select
  865. user_id_, count(1) as musicSheetNum
  866. from music_sheet
  867. where source_type_ = 'TEACHER' and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0
  868. <if test="null != userId">
  869. and user_id_ = #{userId}
  870. </if>
  871. group by user_id_
  872. ) a on t.user_id_ = a.user_id_
  873. <where>
  874. <if test="null != userId">
  875. and t.user_id_ = #{userId}
  876. </if>
  877. </where>
  878. </select>
  879. <select id="auditDetail" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetDetailVo">
  880. SELECT
  881. su.username_ as userName
  882. ,su.avatar_ as userAvatar
  883. ,su.real_name_ as realName
  884. ,msar.update_time_ as auditTime
  885. ,msar.create_time_ as submitAuditTime
  886. ,msar.audit_state_ as auditStatus
  887. ,su2.username_ as auditName
  888. ,msar.reason_ as auditReason
  889. ,msar.music_sheet_json_ as musicSheetJson
  890. ,msar.batch_no_ as batchNo
  891. ,msar.id_ as id
  892. from music_sheet_auth_record msar
  893. left join music_sheet t on t.id_ = msar.music_sheet_id_
  894. left join sys_user su on su.id_ = t.create_by_
  895. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  896. WHERE msar.id_ = #{recordId}
  897. </select>
  898. <select id="auditDetailList" resultType="com.yonge.cooleshow.biz.dal.wrapper.MusicSheetWrapper$MusicSheetDetailVo">
  899. SELECT
  900. su.username_ as userName
  901. ,su.avatar_ as userAvatar
  902. ,su.real_name_ as realName
  903. ,msar.update_time_ as auditTime
  904. ,msar.create_time_ as submitAuditTime
  905. ,msar.audit_state_ as auditStatus
  906. ,su2.username_ as auditName
  907. ,msar.reason_ as auditReason
  908. ,msar.music_sheet_json_ as musicSheetJson
  909. ,msar.batch_no_ as batchNo
  910. ,msar.id_ as id
  911. from music_sheet_auth_record msar
  912. left join music_sheet t on t.id_ = msar.music_sheet_id_
  913. left join sys_user su on su.id_ = t.create_by_
  914. left join sys_user su2 on msar.verify_user_id_ = su2.id_
  915. <where>
  916. <if test="batchNo != null and batchNo != ''">
  917. and #{batchNo} = msar.batch_no_
  918. </if>
  919. </where>
  920. order by msar.id_ desc
  921. </select>
  922. <!--单曲专辑数量统计-->
  923. <select id="selectMusicAlbumStatInfo" resultType="com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper">
  924. SELECT t1.music_sheet_id_ AS id, COUNT(DISTINCT t1.id_) AS total
  925. FROM album_music_relate t1 JOIN music_sheet t2 ON (t1.music_sheet_id_ = t2.id_)
  926. <where>
  927. <if test="musicIds != null">
  928. AND t1.music_sheet_id_ IN (<foreach collection="musicIds" separator="," item="item">#{item}</foreach>)
  929. </if>
  930. </where>
  931. GROUP BY t1.music_sheet_id_
  932. </select>
  933. <update id="updateFavoriteCount">
  934. update music_sheet set favorite_count_ =
  935. <choose>
  936. <when test="state.code == 0">
  937. favorite_count_ - 1
  938. </when>
  939. <when test="state.code == 1">
  940. favorite_count_ + 1
  941. </when>
  942. <otherwise>
  943. favorite_count_
  944. </otherwise>
  945. </choose>
  946. where id_ = #{musicSheetId}
  947. </update>
  948. <update id="updateBatchByCbsId">
  949. <foreach collection="vos" item="item" index="index" separator=";">
  950. update music_sheet ms set
  951. ms.music_tag_ = #{item.musicTagIds},ms.payment_type_ = #{item.paymentType},
  952. ms.charge_type_ = #{item.paymentType},
  953. ms.music_price_ = #{item.musicPrice},ms.top_flag_ = #{item.topFlag},
  954. ms.exquisite_flag_ = #{item.exquisiteFlag},ms.sort_number_ = #{item.sortNo},ms.del_flag_ = 0,
  955. ms.audit_status_ = 'PASS',
  956. ms.score_type_ = #{item.scoreType},
  957. ms.state_ = #{item.status},
  958. ms.notation_ = #{item.isConvertibleScore},
  959. ms.provider_type_ = CASE WHEN #{item.availableType} = 'PLATFORM' THEN 'PLATFORM' ELSE 'TENANT' END
  960. <if test="item.musicSheetUpdate != null">
  961. ,ms.music_sheet_name_ = #{item.musicSheetUpdate.name},
  962. ms.music_subject_ = #{item.musicSheetUpdate.subjectIds},
  963. ms.music_svg_ = #{item.musicSheetUpdate.musicSvg},
  964. ms.composer_ = #{item.musicSheetUpdate.composer},
  965. ms.accompaniment_type_ = #{item.musicSheetUpdate.audioType},
  966. ms.play_speed_ = #{item.musicSheetUpdate.playSpeed},
  967. ms.notation_ = #{item.musicSheetUpdate.notation},
  968. ms.music_sheet_type_ = #{item.musicSheetUpdate.musicSheetType},
  969. ms.create_by_ = #{item.musicSheetUpdate.userId},
  970. ms.audio_type_ = #{item.musicSheetUpdate.playMode},
  971. ms.show_fingering_ = #{item.musicSheetUpdate.showFingering},
  972. ms.can_evaluate_ = #{item.musicSheetUpdate.canEvaluate},
  973. ms.is_all_subject_ = #{item.musicSheetUpdate.isAllSubject},
  974. ms.source_type_ = CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  975. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER' ELSE 'TENANT' END,
  976. ms.first_pass_audit_time_ = IF(#{item.musicSheetUpdate.sourceType} = 'PERSON' and ms.first_pass_audit_time_ is null, now(), ms.first_pass_audit_time_)
  977. </if>
  978. where ms.cbs_music_sheet_id_ = #{item.musicSheetId}
  979. </foreach>
  980. </update>
  981. <update id="batchEnable">
  982. update music_sheet
  983. <set>
  984. <if test="tenantFlag == 1">
  985. tenant_state_ = #{status},
  986. </if>
  987. <if test="tenantFlag == 0">
  988. client_state_ = #{status}
  989. </if>
  990. </set>
  991. where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
  992. </update>
  993. <update id="batchDel">
  994. update music_sheet
  995. <set>
  996. <if test="tenantFlag == 1">
  997. tenant_del_flag_ = 1,
  998. </if>
  999. <if test="tenantFlag == 0">
  1000. del_flag_ = 1
  1001. </if>
  1002. </set>
  1003. where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
  1004. </update>
  1005. <update id="updateMusicSheet">
  1006. update music_sheet
  1007. set music_sheet_name_ = #{param.name},music_subject_ = #{param.subjectIds},music_svg_ = #{param.musicSvg},
  1008. composer_ = #{param.composer},title_img_ = #{param.musicCover},music_img_ = #{param.musicCover},accompaniment_type_ = #{param.audioType},
  1009. play_speed_ = #{param.playSpeed},is_all_subject_ = #{param.isAllSubject},platform_state_ = #{param.platformStatus},
  1010. music_sheet_type_ = #{param.musicSheetType},source_type_ = CASE WHEN #{param.sourceType} = 'PLATFORM' THEN 'PLATFORM' ELSE 'TEACHER' END,
  1011. create_by_ = #{param.userId},tenant_category_id_ = #{param.musicCategoryId}
  1012. where cbs_music_sheet_id_ = #{param.id}
  1013. </update>
  1014. <select id="countByUser" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetUploadCountVo">
  1015. select user_id_ userId, count(id_) count
  1016. from music_sheet
  1017. where del_flag_ = false and state_ =1 and source_type_ = 'TEACHER' and user_id_ in
  1018. <foreach collection="userIds" open="(" close=")" separator="," item="item">
  1019. #{item}
  1020. </foreach>
  1021. group by user_id_
  1022. </select>
  1023. <select id="searchMusic" resultType="java.lang.Long">
  1024. select t.id_ from music_sheet t
  1025. <if test="param.tenantAlbumIds != null and param.tenantAlbumIds.size() != 0">
  1026. left join tenant_album_music tam on t.id_ = tam.music_sheet_id_
  1027. </if>
  1028. <where>
  1029. <if test="param.subjectId != null">
  1030. and ( t.music_subject_ = #{param.subjectId} or t.music_subject_ is null or t.music_subject_ = '' OR t.is_all_subject_)
  1031. </if>
  1032. <if test="param.name != null and param.name != ''">
  1033. and t.music_sheet_name_ like concat('%',#{param.name},'%')
  1034. </if>
  1035. <if test="param.tenantAlbumIds != null and param.tenantAlbumIds.size() != 0">
  1036. and tam.tenant_album_id_ in
  1037. <foreach collection="param.tenantAlbumIds" item="item" open="(" close=")" separator=",">
  1038. #{item}
  1039. </foreach>
  1040. and tam.del_flag_=0
  1041. and tam.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT')
  1042. </if>
  1043. <if test="param.providerType != null">
  1044. and find_in_set(#{param.providerType},t.provider_type_)
  1045. <if test="param.providerType != null">
  1046. <if test="param.providerType.code == 'TENANT'">
  1047. and t.tenant_state_ = true and t.tenant_del_flag_ = 0
  1048. </if>
  1049. <if test="param.providerType.code == 'PLATFORM'">
  1050. and t.state_=1 and t.audit_version_ = 0 and t.del_flag_ = 0 and t.audit_status_ = 'PASS'
  1051. </if>
  1052. </if>
  1053. </if>
  1054. </where>
  1055. order by t.top_flag_ desc, t.sort_number_ desc, t.favorite_count_ desc
  1056. </select>
  1057. <select id="searchAlbum" resultType="java.lang.Long">
  1058. select id_ from music_album t
  1059. <where>
  1060. t.album_status_=1 and del_flag_=0 and audit_version_ = 0
  1061. <if test="param.subjectId != null">
  1062. and ( t.subject_id_ = #{param.subjectId} or t.subject_id_ is null or t.subject_id_ = '')
  1063. </if>
  1064. <if test="param.name != null and param.name != ''">
  1065. and t.album_name_ like concat('%',#{param.name},'%')
  1066. </if>
  1067. </where>
  1068. order by t.sort_number_ desc
  1069. </select>
  1070. <select id="personOwnerList"
  1071. resultType="com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetExtendWrapper$MusicSheetExtend">
  1072. select su.id_ userId,su.username_ username
  1073. ,'TEACHER' clientType,su.phone_ phone from teacher t
  1074. left join sys_user su ON su.id_ = t.user_id_
  1075. where su.user_type_ LIKE '%TEACHER%' AND su.del_flag_ = 0 AND su.lock_flag_ = 0 AND t.lock_flag_ = 0
  1076. <if test="param.name != null and param.name != ''">
  1077. AND (su.phone_ LIKE CONCAT('%',#{param.name},'%') OR su.username_ LIKE CONCAT('%',#{param.name},'%'))
  1078. </if>
  1079. <if test="param.userIdList != null and param.userIdList.size > 0">
  1080. AND su.id_ IN
  1081. <foreach collection="param.userIdList" item="item" open="(" close=")" separator=",">
  1082. #{item}
  1083. </foreach>
  1084. </if>
  1085. </select>
  1086. <select id="orgOwnerList"
  1087. resultType="com.dayaedu.cbs.openfeign.wrapper.music.CbsMusicSheetExtendWrapper$MusicSheetExtend">
  1088. select id_ organizationRoleId,name_ organizationRole,'ORG' clientType,phone_ phone from tenant_info where enable_flag_ = 1
  1089. <if test="param.name != null and param.name != ''">
  1090. AND (phone_ LIKE CONCAT('%',#{param.name},'%') OR name_ LIKE CONCAT('%',#{param.name},'%'))
  1091. </if>
  1092. <if test="param.userIdList != null and param.userIdList.size > 0">
  1093. AND id_ IN
  1094. <foreach collection="param.userIdList" item="item" open="(" close=")" separator=",">
  1095. #{item}
  1096. </foreach>
  1097. </if>
  1098. </select>
  1099. <select id="get" resultType="com.yonge.cooleshow.biz.dal.entity.MusicSheet">
  1100. select <include refid="Base_Column_List"/>
  1101. from music_sheet t
  1102. where t.id_ = #{id}
  1103. </select>
  1104. <select id="selectSyncPage" resultType="com.yonge.cooleshow.biz.dal.entity.MusicSheet">
  1105. select *
  1106. from music_sheet
  1107. where del_flag_ = 0 and audit_status_ = 'PASS' and cbs_music_sheet_id_ is null
  1108. </select>
  1109. <select id="queryTenantRelatedList" resultType="com.yonge.cooleshow.biz.dal.vo.MusicSheetVo">
  1110. select
  1111. <include refid="Base_Column_List"/>
  1112. from music_sheet t
  1113. left join tenant_album_music t1 on t1.music_sheet_id_ = t.id_
  1114. <where>
  1115. t.tenant_del_flag_ = 0 and t.tenant_state_ =1 and t.cbs_music_sheet_id_ is not null
  1116. and t1.del_flag_=0 and t1.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT')
  1117. <if test="queryInfo.albumId != null">
  1118. and t1.tenant_album_id_ = #{queryInfo.albumId}
  1119. </if>
  1120. <if test="queryInfo.albumId == null">
  1121. and 1=2
  1122. </if>
  1123. <if test="queryInfo.musicSheetId != null">
  1124. and t.id_ != #{queryInfo.musicSheetId}
  1125. </if>
  1126. <if test="queryInfo.subjectId != null">
  1127. and find_in_set(#{queryInfo.subjectId},t.music_subject_)
  1128. </if>
  1129. <if test="queryInfo.musicSheetType != null">
  1130. and t.music_sheet_type_ = #{queryInfo.musicSheetType}
  1131. </if>
  1132. </where>
  1133. </select>
  1134. <select id="countTeacherEnable" resultType="int">
  1135. select count(1)
  1136. from music_sheet
  1137. where state_ = 1 and del_flag_ = 0 and source_type_ = 'TEACHER' and create_by_ = #{userId}
  1138. </select>
  1139. <update id="updateTenantByCbsId">
  1140. update music_sheet ms set
  1141. ms.tenant_sort_number_ = #{item.sortNo},ms.tenant_del_flag_ = 0,
  1142. ms.tenant_score_type_ = #{item.scoreType},
  1143. ms.audit_status_ = 'PASS',
  1144. ms.tenant_state_ = #{item.status},
  1145. ms.tenant_notation_ = #{item.isConvertibleScore},
  1146. ms.provider_type_ = CASE WHEN ms.provider_type_ is null or ms.provider_type_ = '' THEN 'TENANT'
  1147. when find_in_set('TENANT',ms.provider_type_) then ms.provider_type_
  1148. else concat(ms.provider_type_,',','TENANT') end
  1149. <if test="item.musicSheetUpdate != null">
  1150. ,ms.music_sheet_name_ = #{item.musicSheetUpdate.name},
  1151. ms.music_subject_ = #{item.musicSheetUpdate.subjectIds},
  1152. ms.music_svg_ = #{item.musicSheetUpdate.musicSvg},
  1153. ms.composer_ = #{item.musicSheetUpdate.composer},
  1154. ms.accompaniment_type_ = #{item.musicSheetUpdate.audioType},
  1155. ms.play_speed_ = #{item.musicSheetUpdate.playSpeed},
  1156. ms.music_sheet_type_ = #{item.musicSheetUpdate.musicSheetType},
  1157. ms.create_by_ = #{item.musicSheetUpdate.userId},
  1158. ms.audio_type_ = #{item.musicSheetUpdate.playMode},
  1159. ms.tenant_category_id_ = #{item.musicSheetUpdate.musicCategoryId},
  1160. ms.show_fingering_ = #{item.musicSheetUpdate.showFingering},
  1161. ms.can_evaluate_ = #{item.musicSheetUpdate.canEvaluate},
  1162. ms.upload_time_ = #{item.musicSheetUpdate.createTime},
  1163. ms.source_type_ = CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  1164. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER' ELSE 'TENANT' END
  1165. </if>
  1166. where ms.cbs_music_sheet_id_ = #{item.musicSheetId}
  1167. </update>
  1168. <update id="updatePlatformByCbsId">
  1169. update music_sheet ms set
  1170. ms.music_tag_ = #{item.musicTagIds},ms.payment_type_ = #{item.paymentType},
  1171. ms.first_pass_audit_time_ = IF((#{item.musicSheetUpdate.sourceType} = 'PERSON' and ms.first_pass_audit_time_ is null) or !find_in_set('PLATFORM',ms.provider_type_),
  1172. now(), ms.first_pass_audit_time_),
  1173. ms.charge_type_ = #{item.paymentType},
  1174. ms.music_price_ = #{item.musicPrice},ms.top_flag_ = #{item.topFlag},
  1175. ms.exquisite_flag_ = #{item.exquisiteFlag},ms.sort_number_ = #{item.sortNo},ms.del_flag_ = 0,
  1176. ms.audit_status_ = 'PASS',
  1177. ms.score_type_ = #{item.scoreType},
  1178. ms.state_ = #{item.status},
  1179. ms.client_state_ = #{item.clientStatus},
  1180. ms.notation_ = #{item.isConvertibleScore},
  1181. ms.provider_type_ = CASE WHEN ms.provider_type_ is null or ms.provider_type_ = '' THEN 'PLATFORM'
  1182. when find_in_set('PLATFORM',ms.provider_type_) then ms.provider_type_
  1183. else concat(ms.provider_type_,',','PLATFORM') end
  1184. <if test="item.musicSheetUpdate != null">
  1185. ,ms.music_sheet_name_ = #{item.musicSheetUpdate.name}
  1186. ,ms.platform_state_ = #{item.musicSheetUpdate.platformStatus},
  1187. ms.music_subject_ = #{item.musicSheetUpdate.subjectIds},
  1188. ms.music_svg_ = #{item.musicSheetUpdate.musicSvg},
  1189. ms.composer_ = #{item.musicSheetUpdate.composer},
  1190. ms.accompaniment_type_ = #{item.musicSheetUpdate.audioType},
  1191. ms.play_speed_ = #{item.musicSheetUpdate.playSpeed},
  1192. ms.notation_ = #{item.musicSheetUpdate.notation},
  1193. ms.music_sheet_type_ = #{item.musicSheetUpdate.musicSheetType},
  1194. ms.create_by_ = #{item.musicSheetUpdate.userId},
  1195. ms.audio_type_ = #{item.musicSheetUpdate.playMode},
  1196. ms.show_fingering_ = #{item.musicSheetUpdate.showFingering},
  1197. ms.can_evaluate_ = #{item.musicSheetUpdate.canEvaluate},
  1198. ms.source_type_ = CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  1199. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER' ELSE 'TENANT' END
  1200. </if>
  1201. where ms.cbs_music_sheet_id_ = #{item.musicSheetId}
  1202. </update>
  1203. <insert id="tenantInsert">
  1204. insert into music_sheet
  1205. (cbs_music_sheet_id_,tenant_sort_number_,tenant_score_type_,tenant_state_,tenant_notation_,tenant_category_id_,tenant_del_flag_
  1206. ,music_sheet_name_,music_subject_,music_svg_,composer_,accompaniment_type_,play_speed_,
  1207. music_sheet_type_,provider_type_,audio_type_,show_fingering_,
  1208. can_evaluate_,create_by_,user_id_,audit_status_,upload_time_,source_type_
  1209. )
  1210. values
  1211. (#{item.musicSheetId},
  1212. #{item.sortNo},#{item.scoreType},#{item.status},#{item.isConvertibleScore}
  1213. ,#{item.musicSheetUpdate.musicCategoryId}
  1214. ,#{item.delFlag}
  1215. ,#{item.musicSheetUpdate.name},
  1216. #{item.musicSheetUpdate.subjectIds},
  1217. #{item.musicSheetUpdate.musicSvg},
  1218. #{item.musicSheetUpdate.composer},
  1219. #{item.musicSheetUpdate.audioType},
  1220. #{item.musicSheetUpdate.playSpeed},
  1221. #{item.musicSheetUpdate.musicSheetType},
  1222. 'TENANT',
  1223. #{item.musicSheetUpdate.playMode},
  1224. #{item.musicSheetUpdate.showFingering},
  1225. #{item.musicSheetUpdate.canEvaluate},
  1226. #{item.musicSheetUpdate.userId},
  1227. #{item.musicSheetUpdate.userId},
  1228. 'PASS',
  1229. #{item.musicSheetUpdate.createTime},
  1230. CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  1231. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER'
  1232. ELSE 'TENANT' END
  1233. )
  1234. </insert>
  1235. <insert id="platformInsert">
  1236. insert into music_sheet
  1237. (cbs_music_sheet_id_,music_tag_,payment_type_,charge_type_,top_flag_,exquisite_flag_,sort_number_,state_,audit_status_
  1238. ,music_sheet_name_,music_subject_,music_svg_,composer_,accompaniment_type_,play_speed_,
  1239. music_price_,notation_,music_sheet_type_,source_type_,provider_type_,audio_type_,show_fingering_,
  1240. can_evaluate_,create_by_,user_id_,score_type_,platform_state_,client_state_,first_pass_audit_time_
  1241. )
  1242. values
  1243. (#{item.musicSheetId},
  1244. #{item.musicTagIds},#{item.paymentType},#{item.paymentType},
  1245. #{item.topFlag},#{item.exquisiteFlag},#{item.sortNo},0
  1246. ,'PASS'
  1247. ,#{item.musicSheetUpdate.name},
  1248. #{item.musicSheetUpdate.subjectIds},
  1249. #{item.musicSheetUpdate.musicSvg},
  1250. #{item.musicSheetUpdate.composer},
  1251. #{item.musicSheetUpdate.audioType},
  1252. #{item.musicSheetUpdate.playSpeed},
  1253. #{item.musicSheetUpdate.musicPrice},
  1254. #{item.isConvertibleScore},
  1255. #{item.musicSheetUpdate.musicSheetType},
  1256. CASE WHEN #{item.musicSheetUpdate.sourceType} = 'PLATFORM' THEN 'PLATFORM'
  1257. WHEN #{item.musicSheetUpdate.sourceType} = 'PERSON' THEN 'TEACHER'
  1258. ELSE 'TENANT' END,
  1259. 'PLATFORM',
  1260. #{item.musicSheetUpdate.playMode},
  1261. #{item.musicSheetUpdate.showFingering},
  1262. #{item.musicSheetUpdate.canEvaluate},
  1263. #{item.musicSheetUpdate.userId},#{item.musicSheetUpdate.userId},
  1264. #{item.scoreType},
  1265. #{item.musicSheetUpdate.platformStatus},
  1266. #{item.clientStatus},
  1267. now()
  1268. )
  1269. </insert>
  1270. <update id="updateState">
  1271. update music_sheet
  1272. set state_ = client_state_ and platform_state_
  1273. where FIND_IN_SET(cbs_music_sheet_id_,#{ids})
  1274. </update>
  1275. <update id="delPractice">
  1276. update sys_music_compare_record
  1277. set hidden_flag_ = 1
  1278. where user_id_ = #{userId} and music_sheet_id_ = #{musicSheetId} and client_id_ = #{clientEnum}
  1279. </update>
  1280. <select id="cloudPage" resultType="com.yonge.cooleshow.biz.dal.wrapper.MusicSheetWrapper$MusicSheetCloud">
  1281. select t.id_, t.music_sheet_name_,t.title_img_,t.composer_,t.cbs_music_sheet_id_ ,t.payment_type_,t.music_price_ as musicPrice
  1282. from music_sheet t
  1283. <if test="param.recentFlag != null and param.recentFlag == 1">
  1284. left join sys_music_compare_record msar on t.id_ = msar.music_sheet_id_
  1285. </if>
  1286. <if test="param.albumId != null">
  1287. left join tenant_album_music tam on t.id_ = tam.music_sheet_id_ and tam.del_flag_ = 0
  1288. </if>
  1289. <if test="param.favoriteFlag != null and param.favoriteFlag == 1">
  1290. left join music_favorite mf on t.id_ = mf.music_sheet_id_ and mf.user_id_ = #{param.userId} and mf.client_type_ = #{param.clientType}
  1291. </if>
  1292. <where>
  1293. t.cbs_music_sheet_id_ is not null
  1294. <if test="param.name != null and param.name != ''">
  1295. and t.music_sheet_name_ like concat('%',#{param.name},'%')
  1296. </if>
  1297. <if test="param.favoriteFlag != null and param.favoriteFlag == 1">
  1298. and mf.id_ is not null
  1299. </if>
  1300. <if test="param.status != null">
  1301. <if test="param.providerType != null">
  1302. <if test="param.providerType.code == 'TENANT'">
  1303. and t.tenant_state_ = #{param.status}
  1304. </if>
  1305. <if test="param.providerType.code == 'PLATFORM'">
  1306. and t.state_ = #{param.status}
  1307. </if>
  1308. </if>
  1309. <if test="param.providerType == null">
  1310. and t.state_ = #{param.status}
  1311. </if>
  1312. </if>
  1313. <if test="param.delFlag != null">
  1314. <if test="param.providerType != null">
  1315. <if test="param.providerType.code == 'TENANT'">
  1316. and t.tenant_del_flag_ = #{param.delFlag}
  1317. </if>
  1318. <if test="param.providerType.code == 'PLATFORM'">
  1319. and t.del_flag_ = #{param.delFlag}
  1320. </if>
  1321. </if>
  1322. <if test="param.providerType == null">
  1323. and t.del_flag_ = #{param.delFlag}
  1324. </if>
  1325. </if>
  1326. <if test="param.versionFlag != null">
  1327. and t.audit_version_ = #{param.versionFlag}
  1328. </if>
  1329. <if test="param.recentFlag != null and param.recentFlag == 1">
  1330. <if test="param.userId != null">
  1331. and msar.user_id_ = #{param.userId}
  1332. </if>
  1333. <if test="param.clientType != null and param.clientType != ''">
  1334. and msar.client_id_ = #{param.clientType}
  1335. </if>
  1336. </if>
  1337. <if test="param.excludeMusicId != null">
  1338. and t.id_ != #{param.excludeMusicId}
  1339. </if>
  1340. <if test="param.ids != null and param.ids.size() != 0">
  1341. and t.id_ in
  1342. <foreach collection="param.ids" item="item" open="(" close=")" separator=",">
  1343. #{item}
  1344. </foreach>
  1345. </if>
  1346. <if test="param.providerType != null and param.providerType.code == 'TENANT'">
  1347. <if test="param.albumId != null">
  1348. and tam.tenant_album_id_ = #{param.albumId}
  1349. and tam.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT')
  1350. </if>
  1351. <if test="param.albumId == null">
  1352. and 1=2
  1353. </if>
  1354. </if>
  1355. <if test="param.providerType != null">
  1356. and find_in_set(#{param.providerType},t.provider_type_)
  1357. </if>
  1358. <if test="param.musicSheetType != null">
  1359. and t.music_sheet_type_ = #{param.musicSheetType}
  1360. </if>
  1361. <if test="param.subjectId != null">
  1362. and (find_in_set(#{param.subjectId},t.music_subject_)or t.music_subject_ is null or t.music_subject_ = '' OR t.is_all_subject_)
  1363. </if>
  1364. </where>
  1365. GROUP BY t.id_
  1366. <if test="param.recentFlag !=null and param.recentFlag == true">
  1367. order by
  1368. max(msar.create_time_) desc
  1369. </if>
  1370. <if test="param.favoriteFlag != null and param.favoriteFlag == 1">
  1371. order by mf.id_ desc
  1372. </if>
  1373. <if test="param.recentFlag == null">
  1374. order by tam.level_,tam.type_,tam.sort_number_
  1375. </if>
  1376. </select>
  1377. <!--单曲专辑数量统计-->
  1378. </mapper>