TeacherMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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.TeacherDao">
  4. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.Teacher">
  5. <result column="user_id_" property="userId" />
  6. <result column="education_background_" property="educationBackground" />
  7. <result column="graduate_school_" property="graduateSchool" />
  8. <result column="technical_titles_" property="technicalTitles" />
  9. <result column="work_unit_" property="workUnit" />
  10. <result column="subject_id_" property="subjectId" />
  11. <result column="introduction_" property="introduction" />
  12. <result column="subject_" property="subject" />
  13. <result column="grad_certificate_" property="gradCertificate" />
  14. <result column="degree_certificate_" property="degreeCertificate" />
  15. <result column="teacher_certificate_" property="teacherCertificate" />
  16. <result column="entry_flag_" property="entryFlag" />
  17. <result column="entry_auth_date_" property="entryAuthDate" />
  18. <result column="musician_flag_" property="musicianFlag" />
  19. <result column="musician_date_" property="musicianDate" />
  20. <result column="member_rank_setting_id_" property="memberRankSettingId"/>
  21. <result column="membership_start_time_" property="membershipStartTime"/>
  22. <result column="membership_end_time_" property="membershipEndTime"/>
  23. <result column="live_flag_" property="liveFlag" />
  24. <result column="live_date_" property="liveDate" />
  25. <result column="music_date_" property="musicDate" />
  26. <result column="video_date_" property="videoDate" />
  27. <result column="style_date_" property="styleDate" />
  28. <result column="degree_date_" property="degreeDate" />
  29. <result column="teacher_date_" property="teacherDate" />
  30. <result column="degree_flag_" property="degreeFlag" />
  31. <result column="teacher_flag_" property="teacherFlag" />
  32. <result column="browse_" property="browse" />
  33. <result column="memo_" property="memo" />
  34. <result column="lock_flag_" property="lockFlag" />
  35. <result column="create_time_" property="createTime" />
  36. <result column="update_time_" property="updateTime" />
  37. </resultMap>
  38. <!-- 表字段 -->
  39. <sql id="baseColumns">
  40. t.user_id_ as "userId"
  41. , t.education_background_ as "educationBackground"
  42. , t.graduate_school_ as "graduateSchool"
  43. , t.technical_titles_ as "technicalTitles"
  44. , t.work_unit_ as "workUnit"
  45. , t.subject_id_ as "subjectId"
  46. , t.introduction_ as "introduction"
  47. , t.subject_ as "subject"
  48. , t.grad_certificate_ as "gradCertificate"
  49. , t.degree_certificate_ as "degreeCertificate"
  50. , t.teacher_certificate_ as "teacherCertificate"
  51. , t.entry_flag_ as "entryFlag"
  52. , t.entry_auth_date_ as "entryAuthDate"
  53. , t.musician_flag_ as "musicianFlag"
  54. , t.musician_date_ as "musicianDate"
  55. , t.live_flag_ as "liveFlag"
  56. , t.music_date_ as "musicDate"
  57. , t.video_date_ as "videoDate"
  58. , t.style_date_ as "styleDate"
  59. , t.degree_date_ as "degreeDate"
  60. , t.teacher_date_ as "teacherDate"
  61. , t.degree_flag_ as "degreeFlag"
  62. , t.teacher_flag_ as "teacherFlag"
  63. , t.member_rank_setting_id_ as "memberRankSettingId"
  64. , t.membership_start_time_ as "membershipStartTime"
  65. , t.membership_end_time_ as "membershipEndTime"
  66. , t.browse_ as "browse"
  67. , t.memo_ as "memo"
  68. , t.tag_ as "tag"
  69. , t.create_time_ as "createTime"
  70. , t.update_time_ as "updateTime"
  71. </sql>
  72. <!-- 分页查询 -->
  73. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherVo" >
  74. SELECT
  75. <include refid="baseColumns"/>,
  76. if(u.lock_flag_ = 0 and t.lock_flag_ = 0,0,1) as lockFlag,
  77. u.username_ as username,
  78. u.phone_ as phone,
  79. u.real_name_ as realName,
  80. (case when t.membership_end_time_ &gt;= now() then 1 else 0 end) isVip,
  81. <!-- t.tag_ tag,-->
  82. u.del_flag_ as delFlag,
  83. (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
  84. (case when isnull(b.user_id_) then 0 else 1 end) as isBank
  85. FROM teacher t
  86. left join sys_user u on t.user_id_ = u.id_
  87. left join (
  88. select distinct user_id_ from user_bank_card where del_flag_ = 0
  89. ) b on t.user_id_ = b.user_id_
  90. <where>
  91. <if test="null != param.search and '' != param.search">
  92. AND (
  93. t.user_id_ LIKE CONCAT('%', #{param.search}, '%') or
  94. u.username_ LIKE CONCAT('%', #{param.search}, '%') or
  95. u.real_name_ LIKE CONCAT('%', #{param.search}, '%') or
  96. u.phone_ LIKE CONCAT('%', #{param.search}, '%')
  97. )
  98. </if>
  99. <if test="null != param.teacherType and '' != param.teacherType">
  100. and (
  101. 1=0
  102. <if test='param.teacherType.contains("TOURIST")'>
  103. or (t.entry_flag_ = 0 and t.musician_flag_ = 0)
  104. </if>
  105. <if test='param.teacherType.contains("ENTRY")'>
  106. or t.entry_flag_ = 1
  107. </if>
  108. <if test='param.teacherType.contains("MUSICIAN")'>
  109. or t.musician_flag_ = 1
  110. </if>
  111. )
  112. </if>
  113. <if test="param.isVip != null">
  114. <if test="param.isVip == 0">
  115. and (t.membership_end_time_ is null or t.membership_end_time_ &lt; now())
  116. </if>
  117. <if test="param.isVip == 1">
  118. and t.membership_end_time_ &gt;= now()
  119. </if>
  120. </if>
  121. <if test="param.tag != null">
  122. and find_in_set(#{param.tag},t.tag_)
  123. </if>
  124. <if test="null != param.lockFlag">
  125. and t.lock_flag_ = #{param.lockFlag}
  126. </if>
  127. <if test="null != param.delFlag">
  128. and u.del_flag_ = #{param.delFlag}
  129. </if>
  130. </where>
  131. </select>
  132. <resultMap id="BasicUserInfo" type="com.yonge.cooleshow.biz.dal.dto.BasicUserInfo">
  133. <result property="userId" column="user_id_"/>
  134. <result property="username" column="username_"/>
  135. <result property="realName" column="real_name_"/>
  136. <result property="avatar" column="avatar_"/>
  137. </resultMap>
  138. <select id="getBasicUserInfo" resultMap="BasicUserInfo">
  139. SELECT id_ user_id_,username_,real_name_,avatar_ FROM sys_user
  140. WHERE del_flag_ = 0 and id_ = #{userId} LIMIT 1
  141. </select>
  142. <select id="findBasicUserInfo" resultMap="BasicUserInfo">
  143. SELECT id_ user_id_,username_,real_name_,avatar_ FROM sys_user
  144. WHERE del_flag_ = 0 and id_ IN
  145. <foreach collection="studentIds" open="(" close=")" separator="," item="userId">
  146. #{userId}
  147. </foreach>
  148. </select>
  149. <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherVo">
  150. SELECT
  151. <include refid="baseColumns"/>,
  152. if(u.lock_flag_ = 0 and t.lock_flag_ = 0,0,1) as lockFlag,
  153. u.avatar_ as avatar,
  154. u.username_ as username,
  155. u.gender_ as `gender`,
  156. u.birthdate_ as birthdate,
  157. u.phone_ as phone,
  158. (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
  159. (!isnull(membership_end_time_) and membership_end_time_ > now()) as isVip,
  160. u.real_name_ as realName,
  161. u.id_card_no_ as idCardNo,
  162. (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
  163. (
  164. SELECT GROUP_CONCAT(name_ ORDER by locate(id_,t.subject_id_)) FROM subject WHERE FIND_IN_SET(id_,t.subject_id_)
  165. ) as subjectName,
  166. u.user_type_ as userType
  167. FROM teacher t
  168. left join sys_user u on t.user_id_ = u.id_
  169. left join (
  170. select distinct user_id_ from user_bank_card where del_flag_ = 0 and user_id_ = #{userId}
  171. ) b on t.user_id_ = b.user_id_
  172. where u.del_flag_ = 0 and t.user_id_ = #{userId}
  173. </select>
  174. <select id="querySubject" resultMap="com.yonge.cooleshow.biz.dal.dao.SubjectDao.Subject">
  175. SELECT s.* FROM `subject` s
  176. LEFT JOIN teacher t ON FIND_IN_SET(s.id_,t.subject_id_)
  177. WHERE t.user_id_ = #{userId}
  178. </select>
  179. <update id="setSubject">
  180. update teacher set subject_id_ = #{subjectIds},update_time_ = now() where user_id_ = #{id}
  181. </update>
  182. <update id="addHomeBrowse">
  183. update teacher set browse_ = browse_ + 1 where user_id_ = #{userId}
  184. </update>
  185. <select id="querySubjectItem" resultType="com.yonge.cooleshow.biz.dal.entity.Subject">
  186. select t.* from subject t
  187. join (
  188. select a.subject_id_ from (
  189. <trim prefixOverrides="union all">
  190. <if test="type == null or type =='MUSIC'">union all
  191. (select music_subject_ as subject_id_ from music_sheet where user_id_ = #{userId} GROUP BY
  192. music_subject_)
  193. </if>
  194. <if test="type == null or type =='VIDEO'">
  195. union all
  196. (select lesson_subject_ as subject_id_ from video_lesson_group where teacher_id_ = #{userId} GROUP BY lesson_subject_)
  197. </if>
  198. <if test="type == null or type =='PINAO_ROOM'">
  199. union all
  200. (select subject_id_ as subject_id_ from course_group where type_ = 'PIANO_ROOM_CLASS' and teacher_id_ = #{userId} GROUP BY subject_id_)
  201. </if>
  202. <if test="type == null or type =='PRACTICE'">
  203. union all
  204. (select subject_id_ as subject_id_ from course_group where type_ = 'PRACTICE' and teacher_id_ = #{userId} GROUP BY subject_id_)
  205. </if>
  206. <if test="type == null or type =='LIVE'">
  207. union all
  208. (select subject_id_ as subject_id_ from course_group where type_ = 'LIVE' and teacher_id_ = #{userId} GROUP BY subject_id_)
  209. </if>
  210. </trim>
  211. ) a group by a.subject_id_
  212. ) a on t.id_ = a.subject_id_
  213. where t.parent_subject_id_ != 0
  214. and not exists(
  215. select 1 from teacher s where s.user_id_ = #{userId} and find_in_set(t.id_,s.subject_id_)
  216. )
  217. </select>
  218. <select id="queryMyFans" resultType="com.yonge.cooleshow.biz.dal.vo.MyFens">
  219. SELECT
  220. s.student_id_ AS userId,
  221. u.avatar_ AS avatar,
  222. u.username_ AS userName,
  223. u.real_name_ AS realName,
  224. u.gender_ AS gender,
  225. (SELECT group_concat(name_) FROM `subject` WHERE find_in_set(id_,sr.subject_id_)) AS subjectName,
  226. if(sr.membership_start_time_ &lt;= now() and sr.membership_end_time_ &gt;= now(),1,0) AS isVip
  227. FROM student_star s
  228. LEFT JOIN sys_user u ON s.student_id_ = u.id_
  229. LEFT JOIN student sr ON s.student_id_ = sr.user_id_
  230. WHERE u.del_flag_ = 0 and s.teacher_id_ =#{teacherId}
  231. </select>
  232. </mapper>