CourseCoursewareMapper.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. FROM course_courseware t
  35. left join music_sheet ms on t.music_sheet_id_ = ms.id_
  36. <where>
  37. t.del_flag_ = 0
  38. <if test="param.userId != null">
  39. and t.user_id_ = #{param.userId}
  40. </if>
  41. <if test="param.clientType != null">
  42. and t.client_type_ = #{param.clientType}
  43. </if>
  44. <if test="param.idAndName != null and param.idAndName != ''">
  45. and (ms.music_sheet_name_ like '%${param.idAndName}%' or ms.id_ like '%${param.idAndName}%')
  46. </if>
  47. <if test="param.musicTagIdList != null and param.musicTagIdList.size() != 0">
  48. and
  49. <foreach collection="param.musicTagIdList" open="(" close=")" separator="or" item="item">
  50. find_in_set(#{item},ms.music_tag_)
  51. </foreach>
  52. </if>
  53. <if test="param.subjectIdList != null and param.subjectIdList.size() != 0">
  54. and
  55. <foreach collection="param.subjectIdList" separator="or" item="item" open="(" close=")" >
  56. find_in_set(#{item},ms.music_subject_)
  57. </foreach>
  58. </if>
  59. <if test="param.status != null and param.status.code == 1">
  60. and (ms.payment_type_ like '%FREE%'
  61. 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')
  62. or EXISTS (select mspr.music_sheet_id_ from music_sheet_purchase_record mspr
  63. left join album_music_relate amr on amr.album_id_ = mspr.music_sheet_id_
  64. 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' )
  65. 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()))
  66. )
  67. </if>
  68. </where>
  69. </select>
  70. <select id="selectPayMusic" resultType="java.lang.Long">
  71. select cc.id_ from course_courseware cc
  72. where
  73. (EXISTS (select * from music_sheet_purchase_record mspr
  74. where mspr.music_sheet_id_ = cc.music_sheet_id_
  75. and mspr.student_id_ = cc.user_id_
  76. and mspr.order_status_ = 'PAID'
  77. and mspr.purchase_type_ = 'MUSIC'
  78. and mspr.client_type_ = 'TEACHER')
  79. or EXISTS (select mspr.music_sheet_id_ from music_sheet_purchase_record mspr
  80. left join album_music_relate amr on amr.album_id_ = mspr.music_sheet_id_
  81. where mspr.student_id_ = cc.user_id_
  82. and mspr.order_status_ = 'PAID'
  83. and mspr.purchase_type_ = 'ALBUM'
  84. and amr.music_sheet_id_ = cc.music_sheet_id_
  85. and mspr.client_type_ = 'TEACHER'))
  86. <if test="coursewareIdList != null and coursewareIdList.size() != 0">
  87. and cc.id_ in
  88. <foreach collection="coursewareIdList" separator="," item="item" open="(" close=")">
  89. #{item}
  90. </foreach>
  91. </if>
  92. </select>
  93. </mapper>