TenantAlbumMusicMapper.xml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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.music_sheet_name_ as musicSheetName,
  20. m.composer_ as composer,
  21. m.user_id_ as userId,
  22. m.music_subject_ as musicSubject,
  23. m.title_img_ as titleImg,
  24. m.exquisite_flag_ as exquisiteFlag,
  25. m.music_sheet_type_ as musicSheetType,
  26. t.tenant_album_id_ as tenantAlbumId
  27. FROM music_sheet m
  28. left join tenant_album_music t on t.music_sheet_id_ = m.id_
  29. <where>
  30. m.state_ = true and m.del_flag_ = 0 and t.del_flag_ = 0
  31. <if test="param.musicTagId != null ">
  32. and (find_in_set(#{param.musicTagId},m.music_subject_) or m.music_subject_ is null or m.music_subject_ = '')
  33. </if>
  34. <if test="param.subjectId != null" >
  35. and find_in_set(#{param.subjectId},m.music_subject_)
  36. </if>
  37. <if test="param.subjectType != null">
  38. and t.subject_type_ = #{param.subjectType}
  39. </if>
  40. <if test="param.level != null and param.level != ''">
  41. and t.level_ = #{param.level}
  42. </if>
  43. <if test="param.type != null and param.type != ''">
  44. and t.type_ = #{param.type}
  45. </if>
  46. <if test="param.albumId != null">
  47. and t.tenant_album_id_ = #{param.albumId}
  48. </if>
  49. <if test="param.keyword != null and param.keyword != ''">
  50. and m.music_sheet_name_ LIKE CONCAT('%',#{param.keyword},'%')
  51. </if>
  52. </where>
  53. order by t.sort_number_
  54. </select>
  55. <select id="selectMusicSheetIds" resultType="java.lang.Long">
  56. select
  57. t.music_sheet_id_
  58. FROM tenant_album_music t
  59. <where>
  60. t.del_flag_ = false
  61. <if test="level != null and level != ''">
  62. and t.level_ = #{level}
  63. </if>
  64. <if test="type != null and type != ''">
  65. and t.type_ = #{type}
  66. </if>
  67. <if test="subjectType != null and subjectType != ''">
  68. and t.subject_type_ = #{subjectType}
  69. </if>
  70. <if test="albumId != null and albumId != ''">
  71. and t.tenant_album_id_ = #{albumId}
  72. </if>
  73. </where>
  74. order by t.sort_number_ asc
  75. </select>
  76. <select id="selectMusicIdsByTenantIds" resultType="java.lang.Long">
  77. select
  78. distinct t.music_sheet_id_
  79. FROM tenant_album_music t
  80. left join tenant_album_ref t1 on t1.tenant_album_id_ = t.tenant_album_id_
  81. left join music_sheet t2 on t2.id_ = t.music_sheet_id_
  82. where t2.state_ = 1 and t2.del_flag_ = 0 and t2.audit_version_ = 0 and t1.tenant_id_ = #{tenantId} and t.del_flag_ = 0
  83. </select>
  84. <select id="getByAlbumAndEnable" resultType="com.yonge.cooleshow.biz.dal.entity.TenantAlbumMusic">
  85. select
  86. t.*
  87. from tenant_album_music t
  88. inner join music_sheet t1 on t.music_sheet_id_ = t1.id_
  89. where
  90. t.del_flag_ = 0 and t1.state_ = 1 and t1.del_flag_ = 0
  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. </mapper>