TenantAlbumMusicMapper.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
  3. <mapper namespace="com.yonge.cooleshow.biz.dal.mapper.TenantAlbumMusicMapper">
  4. <!-- 表字段 -->
  5. <sql id="baseColumns">
  6. t.id_ AS id
  7. , t.tenant_id_ AS tenantId
  8. , t.subject_type_ AS subjectType
  9. , t.tenant_album_id_ AS tenantAlbumId
  10. , t.music_sheet_id_ AS musicSheetId
  11. , t.sort_number_ AS sortNumber
  12. , t.del_flag_ AS delFlag
  13. , t.update_time_ AS updateTime
  14. , t.create_time_ AS createTime
  15. </sql>
  16. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.wrapper.TenantAlbumMusicWrapper$StudentTenantAlbumMusic">
  17. SELECT
  18. m.id_ as id,
  19. m.cbs_music_sheet_id_ as cbsMusicSheetId,
  20. m.music_sheet_name_ as musicSheetName,
  21. m.composer_ as composer,
  22. m.user_id_ as userId,
  23. m.music_subject_ as musicSubject,
  24. m.title_img_ as titleImg,
  25. m.exquisite_flag_ as exquisiteFlag,
  26. m.music_sheet_type_ as musicSheetType,
  27. t.tenant_album_id_ as tenantAlbumId
  28. FROM music_sheet m
  29. left join tenant_album_music t on t.music_sheet_id_ = m.id_
  30. <where>
  31. find_in_set('TENANT',m.provider_type_) and
  32. m.tenant_state_ = true and m.tenant_del_flag_ = 0 and t.del_flag_ = 0 AND m.cbs_music_sheet_id_ IS NOT NULL
  33. <if test="param.subjectId != null" >
  34. and (find_in_set(#{param.subjectId},m.music_subject_) or m.music_subject_ is null or m.music_subject_ = '' OR m.is_all_subject_)
  35. </if>
  36. <if test="param.subjectType != null">
  37. and t.subject_type_ = #{param.subjectType}
  38. </if>
  39. <if test="param.albumId != null">
  40. and t.tenant_album_id_ = #{param.albumId}
  41. </if>
  42. <if test="param.categoryIds != null and param.categoryIds.size() != 0">
  43. and m.tenant_category_id_ in
  44. <foreach collection="param.categoryIds" item="item" index="index" open="(" close=")" separator=",">
  45. #{item}
  46. </foreach>
  47. </if>
  48. <if test="param.keyword != null and param.keyword != ''">
  49. and m.music_sheet_name_ LIKE CONCAT('%',#{param.keyword},'%')
  50. </if>
  51. </where>
  52. order by t.sort_number_
  53. </select>
  54. <select id="selectMusicSheetIds" resultType="java.lang.Long">
  55. select
  56. t.music_sheet_id_
  57. FROM tenant_album_music t
  58. <where>
  59. t.del_flag_ = false
  60. <if test="level != null and level != ''">
  61. and t.level_ = #{level}
  62. </if>
  63. <if test="type != null and type != ''">
  64. and t.type_ = #{type}
  65. </if>
  66. <if test="subjectType != null and subjectType != ''">
  67. and t.subject_type_ = #{subjectType}
  68. </if>
  69. <if test="albumId != null and albumId != ''">
  70. and t.tenant_album_id_ = #{albumId}
  71. </if>
  72. </where>
  73. order by t.sort_number_ asc
  74. </select>
  75. <select id="selectMusicIdsByTenantIds" resultType="java.lang.Long">
  76. select
  77. distinct t.music_sheet_id_
  78. FROM tenant_album_music t
  79. left join tenant_album_ref t1 on t1.tenant_album_id_ = t.tenant_album_id_
  80. left join music_sheet t2 on t2.id_ = t.music_sheet_id_ and find_in_set('TENANT',t2.provider_type_)
  81. where t2.tenant_state_ = 1 and t2.tenant_del_flag_ = 0 and t2.audit_version_ = 0 and t1.tenant_id_ = #{tenantId} and t.del_flag_ = 0
  82. </select>
  83. <select id="getByAlbumAndEnable" resultType="com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic">
  84. select
  85. t.*
  86. from tenant_album_music t
  87. left join music_sheet t1 on t.music_sheet_id_ = t1.id_ and find_in_set('TENANT',t1.provider_type_)
  88. where
  89. t.del_flag_ = 0 and ((t1.tenant_state_ = 1 and t1.tenant_del_flag_ = 0 and t.subject_type_ in ('ENSEMBLE', 'MUSIC', 'SUBJECT'))
  90. or t.subject_type_ not in ('ENSEMBLE', 'MUSIC', 'SUBJECT'))
  91. and t.tenant_album_id_ in
  92. <foreach collection="tenantAlbumIds" item="item" index="index" open="(" close=")" separator=",">
  93. #{item}
  94. </foreach>
  95. </select>
  96. <select id="getList" resultType="com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic">
  97. select
  98. t.*
  99. from tenant_album_music t
  100. left join music_sheet m on t.music_sheet_id_ = m.id_ and find_in_set('TENANT',m.provider_type_)
  101. where
  102. t.del_flag_ = 0 and m.tenant_del_flag_ =0 and m.tenant_state_ =1
  103. <if test="param.tenantAlbumId != null">
  104. and t.tenant_album_id_ = #{param.tenantAlbumId}
  105. </if>
  106. <if test="param.subjectType != null">
  107. and t.subject_type_ = #{param.subjectType}
  108. </if>
  109. <if test="albumIds != null and albumIds.size() != 0">
  110. and t.tenant_album_id_ in
  111. <foreach collection="albumIds" item="item" index="index" open="(" close=")" separator=",">
  112. #{item}
  113. </foreach>
  114. </if>
  115. <if test="param.subjectId != null">
  116. and ( find_in_set(#{param.subjectId},m.music_subject_) or m.music_subject_ is null or m.music_subject_ = ''
  117. or t.subject_type_ not in ('ENSEMBLE', 'MUSIC', 'SUBJECT') OR m.is_all_subject_)
  118. </if>
  119. </select>
  120. </mapper>