TeacherMapper.xml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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="live_flag_" property="liveFlag" />
  21. <result column="live_date_" property="liveDate" />
  22. <result column="browse_" property="browse" />
  23. <result column="memo_" property="memo" />
  24. <result column="create_time_" property="createTime" />
  25. <result column="update_time_" property="updateTime" />
  26. </resultMap>
  27. <!-- 表字段 -->
  28. <sql id="baseColumns">
  29. t.user_id_ as "userId"
  30. , t.education_background_ as "educationBackground"
  31. , t.graduate_school_ as "graduateSchool"
  32. , t.technical_titles_ as "technicalTitles"
  33. , t.work_unit_ as "workUnit"
  34. , t.subject_id_ as "subjectId"
  35. , t.introduction_ as "introduction"
  36. , t.subject_ as "subject"
  37. , t.grad_certificate_ as "gradCertificate"
  38. , t.degree_certificate_ as "degreeCertificate"
  39. , t.teacher_certificate_ as "teacherCertificate"
  40. , t.entry_flag_ as "entryFlag"
  41. , t.entry_auth_date_ as "entryAuthDate"
  42. , t.musician_flag_ as "musicianFlag"
  43. , t.musician_date_ as "musicianDate"
  44. , t.live_flag_ as "liveFlag"
  45. , t.live_date_ as "liveDate"
  46. , t.browse_ as "browse"
  47. , t.memo_ as "memo"
  48. , t.tag_ as "tag"
  49. , t.create_time_ as "createTime"
  50. , t.update_time_ as "updateTime"
  51. </sql>
  52. <!-- 分页查询 -->
  53. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherVo" >
  54. SELECT
  55. <include refid="baseColumns"/>,
  56. u.username_ as username,
  57. u.phone_ as phone,
  58. u.lock_flag_ as lockFlag,
  59. (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
  60. (case when isnull(b.user_id_) then 0 else 1 end) as isBank
  61. FROM teacher t
  62. left join sys_user u on t.user_id_ = u.id_
  63. left join (
  64. select distinct user_id_ from user_bank_card where del_flag_ = 0
  65. ) b on t.user_id_ = b.user_id_
  66. <where>
  67. u.del_flag_ = 0
  68. <if test="null != param.search and '' != param.search">
  69. AND (
  70. t.user_id_ LIKE CONCAT('%', #{param.search}, '%') or
  71. u.username_ LIKE CONCAT('%', #{param.search}, '%') or
  72. u.phone_ LIKE CONCAT('%', #{param.search}, '%')
  73. )
  74. </if>
  75. <if test="null != param.teacherType and '' != param.teacherType">
  76. and (
  77. 1=0
  78. <if test='param.teacherType.contains("TOURIST")'>
  79. or (t.entry_flag_ = 0 and t.musician_flag_ = 0)
  80. </if>
  81. <if test='param.teacherType.contains("ENTRY")'>
  82. or t.entry_flag_ = 1
  83. </if>
  84. <if test='param.teacherType.contains("MUSICIAN")'>
  85. or t.musician_flag_ = 1
  86. </if>
  87. )
  88. </if>
  89. </where>
  90. </select>
  91. <resultMap id="BasicUserInfo" type="com.yonge.cooleshow.biz.dal.dto.BasicUserInfo">
  92. <result property="userId" column="user_id_"/>
  93. <result property="username" column="username_"/>
  94. <result property="realName" column="real_name_"/>
  95. <result property="avatar" column="avatar_"/>
  96. </resultMap>
  97. <select id="getBasicUserInfo" resultMap="BasicUserInfo">
  98. SELECT id_ user_id_,username_,real_name_,avatar_ FROM sys_user
  99. WHERE del_flag_ = 0 and id_ = #{userId} LIMIT 1
  100. </select>
  101. <select id="findBasicUserInfo" resultMap="BasicUserInfo">
  102. SELECT id_ user_id_,username_,real_name_,avatar_ FROM sys_user
  103. WHERE del_flag_ = 0 and id_ IN
  104. <foreach collection="studentIds" open="(" close=")" separator="," item="userId">
  105. #{userId}
  106. </foreach>
  107. </select>
  108. <select id="detail" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherVo">
  109. SELECT
  110. <include refid="baseColumns"/>,
  111. u.avatar_ as avatar,
  112. u.username_ as username,
  113. u.gender_ as `gender`,
  114. u.birthdate_ as birthdate,
  115. u.phone_ as phone,
  116. (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
  117. u.real_name_ as realName,
  118. u.id_card_no_ as idCardNo,
  119. u.lock_flag_ as lockFlag,
  120. (case when isnull(b.user_id_) then 0 else 1 end) as isBank,
  121. (
  122. SELECT GROUP_CONCAT(name_) FROM subject WHERE FIND_IN_SET(id_,t.subject_id_)
  123. ) as subjectName,
  124. u.user_type_ as userType
  125. FROM teacher t
  126. left join sys_user u on t.user_id_ = u.id_
  127. left join (
  128. select distinct user_id_ from user_bank_card where del_flag_ = 0 and user_id_ = #{userId}
  129. ) b on t.user_id_ = b.user_id_
  130. where u.del_flag_ = 0 and t.user_id_ = #{userId}
  131. </select>
  132. <select id="querySubject" resultMap="com.yonge.cooleshow.biz.dal.dao.SubjectDao.Subject">
  133. SELECT s.* FROM `subject` s
  134. LEFT JOIN teacher t ON FIND_IN_SET(s.id_,t.subject_id_)
  135. WHERE t.user_id_ = #{userId}
  136. </select>
  137. <update id="setSubject">
  138. update teacher set subject_id_ = #{subjectIds},update_time_ = now() where user_id_ = #{id}
  139. </update>
  140. <update id="addHomeBrowse">
  141. update teacher set browse_ = browse_ + 1 where user_id_ = #{userId}
  142. </update>
  143. <select id="querySubjectItem" resultType="com.yonge.cooleshow.biz.dal.entity.Subject">
  144. select * from subject t
  145. where t.parent_subject_id_ != 0
  146. and exists(
  147. select 1 from teacher s where s.user_id_ = #{userId} and find_in_set(t.id_,s.subject_id_)
  148. union all
  149. select 1 from music_sheet a where a.user_id_ = #{userId} and find_in_set(t.id_,a.music_subject_)
  150. union all
  151. select 1 from course_group b where b.teacher_id_ = #{userId} and find_in_set(t.id_,b.subject_id_)
  152. union all
  153. select 1 from video_lesson_group c where c.teacher_id_ = #{userId} and find_in_set(t.id_,c.lesson_subject_)
  154. )
  155. </select>
  156. <select id="queryMyFans" resultType="com.yonge.cooleshow.biz.dal.vo.MyFens">
  157. SELECT
  158. s.student_id_ AS userId,
  159. u.avatar_ AS avatar,
  160. u.username_ AS userName,
  161. u.real_name_ AS realName,
  162. u.gender_ AS gender,
  163. (SELECT group_concat(name_) FROM `subject` WHERE find_in_set(id_,sr.subject_id_)) AS subjectName
  164. FROM student_star s
  165. LEFT JOIN sys_user u ON s.student_id_ = u.id_
  166. LEFT JOIN student sr ON s.student_id_ = sr.user_id_
  167. WHERE u.del_flag_ = 0 and s.teacher_id_ =#{teacherId}
  168. </select>
  169. </mapper>