TempLiveTeacherCardMapper.xml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. <!--
  4. 这个文件是自动生成的。
  5. 不要修改此文件。所有改动将在下次重新自动生成时丢失。
  6. -->
  7. <mapper namespace="com.ym.mec.biz.dal.dao.TempLiveTeacherCardDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.TempLiveTeacherCard" id="TempLiveTeacherCard">
  9. <result column="id_" property="id"/>
  10. <result column="user_id_" property="userId"/>
  11. <result column="username_" property="username"/>
  12. <result column="avatar_" property="avatar"/>
  13. <result column="introduction_" property="introduction"/>
  14. <result column="music_content_" property="musicContent"/>
  15. <result column="subject_id_" property="subjectId"/>
  16. <result column="level_" property="level"/>
  17. <result column="im_group_id_" property="imGroupId"/>
  18. <result column="live_goods_id_" property="liveGoodsId"/>
  19. <result column="create_time_" property="createTime"/>
  20. <result column="update_time_" property="updateTime"/>
  21. <result column="recommend_level_flag_" property="recommendLevelFlag"/>
  22. <result column="join_flag_" property="joinFlag"/>
  23. <result column="subject_name_" property="subjectName"/>
  24. <result column="student_id_" property="studentId"/>
  25. </resultMap>
  26. <!-- 根据主键查询一条记录 -->
  27. <select id="get" resultMap="TempLiveTeacherCard">
  28. SELECT *
  29. FROM temp_live_teacher_card
  30. WHERE id_ = #{id}
  31. </select>
  32. <!-- 全查询 -->
  33. <select id="findAll" resultMap="TempLiveTeacherCard">
  34. SELECT *
  35. FROM temp_live_teacher_card
  36. ORDER BY id_
  37. </select>
  38. <!-- 向数据库增加一条记录 -->
  39. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.TempLiveTeacherCard" useGeneratedKeys="true"
  40. keyColumn="id" keyProperty="id">
  41. INSERT INTO temp_live_teacher_card
  42. (id_,user_id_,username_,avatar_,introduction_,music_content_,subject_id_,level_,im_group_id_,live_goods_id_,create_time_,update_time_)
  43. VALUES(#{id},#{username},#{userId},#{avatar},#{introduction},#{musicContent},#{subjectId},#{level},#{imGroupId},#{liveGoodsId},#{createTime},#{updateTime})
  44. </insert>
  45. <!-- 根据主键查询一条记录 -->
  46. <update id="update" parameterType="com.ym.mec.biz.dal.entity.TempLiveTeacherCard">
  47. UPDATE temp_live_teacher_card
  48. <set>
  49. <if test="subjectId != null">
  50. subject_id_ = #{subjectId},
  51. </if>
  52. <if test="userId != null">
  53. user_id_ = #{userId},
  54. </if>
  55. <if test="username != null">
  56. username_ = #{username},
  57. </if>
  58. <if test="avatar != null">
  59. avatar_ = #{avatar},
  60. </if>
  61. <if test="introduction != null">
  62. introduction_ = #{introduction},
  63. </if>
  64. <if test="id != null">
  65. id_ = #{id},
  66. </if>
  67. <if test="musicContent != null">
  68. music_content_ = #{musicContent},
  69. </if>
  70. <if test="imGroupId != null">
  71. im_group_id_ = #{imGroupId},
  72. </if>
  73. <if test="liveGoodsId != null">
  74. live_goods_id_ = #{liveGoodsId},
  75. </if>
  76. <if test="updateTime != null">
  77. update_time_ = #{updateTime},
  78. </if>
  79. <if test="level != null">
  80. level_ = #{level},
  81. </if>
  82. <if test="createTime != null">
  83. create_time_ = #{createTime},
  84. </if>
  85. </set>
  86. WHERE id_ = #{id}
  87. </update>
  88. <!-- 根据主键删除一条记录 -->
  89. <delete id="delete">
  90. DELETE
  91. FROM temp_live_teacher_card
  92. WHERE id_ = #{id}
  93. </delete>
  94. <!-- 分页查询 -->
  95. <select id="queryPage" resultMap="TempLiveTeacherCard" parameterType="map">
  96. SELECT * FROM temp_live_teacher_card ORDER BY id_
  97. <include refid="global.limit"/>
  98. </select>
  99. <!-- 查询当前表的总记录数 -->
  100. <select id="queryCount" resultType="int">
  101. SELECT COUNT(*)
  102. FROM temp_live_teacher_card
  103. </select>
  104. <select id="list" resultMap="TempLiveTeacherCard">
  105. select t.*,
  106. s.name_ as subject_name_,
  107. #{studentId} as student_id_,
  108. IF(a.live_goods_id_ is null,0,1) as recommend_level_flag_,
  109. (select count(1) from im_group_member m where m.im_group_id_ = t.im_group_id_ and m.user_id_ = #{studentId})>0 AS join_flag_
  110. from temp_live_teacher_card t
  111. left join `subject` s on t.subject_id_ = s.id_
  112. left join (
  113. select
  114. live_goods_id_,recommend_level_
  115. from temp_buy_free_live_theory_course
  116. where user_id_ = #{studentId} and recommend_level_ is not null
  117. group by live_goods_id_,recommend_level_
  118. ) a on t.live_goods_id_ = a.live_goods_id_ and t.level_ = a.recommend_level_
  119. where FIND_IN_SET(subject_id_,#{subjectId})
  120. order by field(t.level_,'one','two','three')
  121. </select>
  122. <select id="getBySubjectIdAndLevel" resultMap="TempLiveTeacherCard">
  123. SELECT *
  124. FROM temp_live_teacher_card
  125. WHERE subject_id_ = #{subjectId} and level_ = #{level}
  126. </select>
  127. <select id="querySubjectOption" resultType="com.ym.mec.biz.dal.entity.Subject">
  128. SELECT
  129. t.id_ as id,t.name_ as name
  130. FROM subject t
  131. where exists(
  132. select 1 from temp_live_teacher_card cs
  133. where t.id_ = cs.subject_id_
  134. and cs.username_ is not null
  135. and cs.music_content_ is not null
  136. )
  137. order by t.id_
  138. </select>
  139. <select id="getJoinStstus" resultType="java.lang.Integer">
  140. select case when
  141. (
  142. select count(1) from temp_buy_free_live_theory_course
  143. where user_id_ = #{userId} and live_goods_id_ = #{goodsId}
  144. ) = 0 then 0
  145. when (
  146. select count(1) from temp_live_teacher_card a
  147. left join im_group_member b on a.im_group_id_ = b.im_group_id_
  148. where a.live_goods_id_ = #{goodsId} and b.user_id_ = #{userId}
  149. ) = 0 then 1 else 2 end
  150. from dual
  151. </select>
  152. <select id="getJoinSubject" resultType="java.lang.String">
  153. select subject_id_ from temp_live_teacher_card a
  154. left join im_group_member b on a.im_group_id_ = b.im_group_id_
  155. where a.live_goods_id_ = #{goodsId} and b.user_id_ = #{userId}
  156. limit 1;
  157. </select>
  158. </mapper>