CourseCoursewareMapper.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.dao.CourseCoursewareDao">
  4. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.CourseCourseware">
  5. <result column="id_" property="id" />
  6. <result column="user_id_" property="userId" />
  7. <result column="client_type_" property="clientType" />
  8. <result column="music_sheet_id_" property="musicSheetId" />
  9. <result column="create_time_" property="createTime" />
  10. <result column="update_time_" property="updateTime" />
  11. </resultMap>
  12. <!-- 表字段 -->
  13. <sql id="baseColumns">
  14. t.id_ as id
  15. , t.user_id_ as userId
  16. , t.client_type_ as clientType
  17. ,t.music_sheet_id_ as musicSheetId
  18. , t.create_time_ as createTime
  19. , t.update_time_ as updateTime
  20. </sql>
  21. <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.CourseCoursewareVo">
  22. SELECT
  23. <include refid="baseColumns"/>
  24. FROM course_courseware t
  25. where t.id_ = #{id}
  26. </select>
  27. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.CourseCoursewareVo">
  28. SELECT
  29. <include refid="baseColumns" />
  30. ,ms.music_sheet_name_ as musicSheetName
  31. ,ms.state_ as musicStatus
  32. ,ms.payment_type_ as paymentType
  33. ,ms.music_img_ as musicImg
  34. ,ms.title_img_ as titleImg
  35. FROM course_courseware t
  36. left join music_sheet ms on t.music_sheet_id_ = ms.id_
  37. <where>
  38. t.del_flag_ = 0
  39. <if test="param.userId != null">
  40. and t.user_id_ = #{param.userId}
  41. </if>
  42. <if test="param.clientType != null">
  43. and t.client_type_ = #{param.clientType}
  44. </if>
  45. <if test="param.idAndName != null and param.idAndName != ''">
  46. and (ms.music_sheet_name_ like '%${param.idAndName}%' or ms.id_ like '%${param.idAndName}%')
  47. </if>
  48. <if test="param.musicTagIdList != null and param.musicTagIdList.size() != 0">
  49. and
  50. <foreach collection="param.musicTagIdList" open="(" close=")" separator="or" item="item">
  51. find_in_set(#{item},ms.music_tag_)
  52. </foreach>
  53. </if>
  54. <if test="param.subjectIdList != null and param.subjectIdList.size() != 0">
  55. and
  56. <foreach collection="param.subjectIdList" separator="or" item="item" open="(" close=")" >
  57. find_in_set(#{item},ms.music_subject_)
  58. </foreach>
  59. </if>
  60. <if test="param.status != null and param.status.code == 1">
  61. and (ms.payment_type_ like '%FREE%'
  62. or EXISTS (select * from music_sheet_purchase_record mspr where mspr.music_sheet_id_ = ms.id_ and mspr.student_id_ = t.user_id_ and mspr.order_status_ = 'PAID' and mspr.purchase_type_ = 'MUSIC' and mspr.client_type_ = 'TEACHER')
  63. or EXISTS (select mspr.music_sheet_id_ from music_sheet_purchase_record mspr
  64. left join album_music_relate amr on amr.album_id_ = mspr.music_sheet_id_
  65. where mspr.student_id_ = t.user_id_ and mspr.order_status_ = 'PAID' and mspr.purchase_type_ = 'ALBUM' and amr.music_sheet_id_ = ms.id_ and mspr.client_type_ = 'TEACHER' )
  66. or (ms.payment_type_ like '%VIP%' and EXISTS(select 1 from teacher t1 where t1.user_id_ = t.user_id_ and t1.membership_end_time_ > now()))
  67. )
  68. </if>
  69. </where>
  70. </select>
  71. <select id="selectPayMusic" resultType="java.lang.Long">
  72. select cc.id_ from course_courseware cc
  73. where
  74. (EXISTS (select * from music_sheet_purchase_record mspr
  75. where mspr.music_sheet_id_ = cc.music_sheet_id_
  76. and mspr.student_id_ = cc.user_id_
  77. and mspr.order_status_ = 'PAID'
  78. and mspr.purchase_type_ = 'MUSIC'
  79. and mspr.client_type_ = 'TEACHER')
  80. or EXISTS (select mspr.music_sheet_id_ from music_sheet_purchase_record mspr
  81. left join album_music_relate amr on amr.album_id_ = mspr.music_sheet_id_
  82. where mspr.student_id_ = cc.user_id_
  83. and mspr.order_status_ = 'PAID'
  84. and mspr.purchase_type_ = 'ALBUM'
  85. and amr.music_sheet_id_ = cc.music_sheet_id_
  86. and mspr.client_type_ = 'TEACHER'))
  87. <if test="coursewareIdList != null and coursewareIdList.size() != 0">
  88. and cc.id_ in
  89. <foreach collection="coursewareIdList" separator="," item="item" open="(" close=")">
  90. #{item}
  91. </foreach>
  92. </if>
  93. </select>
  94. </mapper>