UserBindingTeacherMapper.xml 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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.UserBindingTeacherDao">
  4. <select id="selectStudent" resultType="com.yonge.cooleshow.biz.dal.vo.CourseStudentVo">
  5. SELECT
  6. su.id_ AS userId,
  7. su.username_ AS userName,
  8. su.real_name_ AS realName,
  9. su.avatar_ AS avatar,
  10. su.phone_ AS phone,
  11. (SELECT group_concat(name_) FROM `subject` WHERE find_in_set(id_,s.subject_id_)) AS subjectName,
  12. DATEDIFF(NOW(),b.last_end_class_) AS lastEndClass
  13. FROM user_binding_teacher b
  14. LEFT JOIN sys_user su ON b.student_id_=su.id_
  15. LEFT JOIN student s ON b.student_id_=s.user_id_
  16. <where>
  17. su.del_flag_ = 0
  18. <if test="param.subjectId != null">
  19. AND find_in_set(#{param.subjectId},s.subject_id_)
  20. </if>
  21. <if test="param.teacherId !=null">
  22. AND b.teacher_id_ = #{param.teacherId}
  23. </if>
  24. <if test="param.userName !=null and param.userName !=''">
  25. AND su.username_ LIKE CONCAT('%', #{param.userName}, '%')
  26. </if>
  27. <if test="param.studentList !=null and param.studentList.size>0">
  28. AND su.id_ IN
  29. <foreach collection="param.studentList" item="item" open="(" separator="," close=")">
  30. #{item.userId}
  31. </foreach>
  32. </if>
  33. </where>
  34. </select>
  35. <!-- 表字段 -->
  36. <sql id="teacherColumns">
  37. t.user_id_ as "userId"
  38. , t.education_background_ as "educationBackground"
  39. , t.graduate_school_ as "graduateSchool"
  40. , t.technical_titles_ as "technicalTitles"
  41. , t.work_unit_ as "workUnit"
  42. , t.subject_id_ as "subjectId"
  43. , t.introduction_ as "introduction"
  44. , t.subject_ as "subject"
  45. , t.grad_certificate_ as "gradCertificate"
  46. , t.degree_certificate_ as "degreeCertificate"
  47. , t.teacher_certificate_ as "teacherCertificate"
  48. , t.entry_flag_ as "entryFlag"
  49. , t.entry_auth_date_ as "entryAuthDate"
  50. , t.musician_flag_ as "musicianFlag"
  51. , t.musician_date_ as "musicianDate"
  52. , t.live_flag_ as "liveFlag"
  53. , t.live_date_ as "liveDate"
  54. , t.memo_ as "memo"
  55. , t.create_time_ as "createTime"
  56. , t.update_time_ as "updateTime"
  57. </sql>
  58. <select id="getBindTeacherByPhone" resultType="com.yonge.cooleshow.biz.dal.vo.TeacherVo">
  59. SELECT
  60. <include refid="teacherColumns"/>,
  61. u.avatar_ as avatar,
  62. u.username_ as username,
  63. u.gender_ as `gender`,
  64. u.birthdate_ as birthdate,
  65. u.phone_ as phone,
  66. (case when isnull(u.id_card_no_) then 0 else 1 end) as isReal,
  67. u.real_name_ as realName,
  68. u.id_card_no_ as idCardNo,
  69. u.lock_flag_ as lockFlag,
  70. (
  71. SELECT GROUP_CONCAT(name_ ORDER by locate(id_,t.subject_id_)) FROM subject WHERE FIND_IN_SET(id_,t.subject_id_)
  72. ) as subjectName
  73. FROM (
  74. select a.* from user_binding_teacher a
  75. left join sys_user b on a.student_id_ = b.id_
  76. where b.phone_ = #{phone}
  77. ) a
  78. left join teacher t on a.teacher_id_ = t.user_id_
  79. left join sys_user u on t.user_id_ = u.id_
  80. where u.del_flag_ = 0
  81. </select>
  82. <select id="queryUnbindList" resultType="com.yonge.cooleshow.biz.dal.entity.UserBindingTeacher">
  83. select
  84. t.*
  85. from user_binding_teacher t
  86. left join (
  87. SELECT
  88. a.teacher_id_,b.user_id_
  89. FROM course_schedule a
  90. left join course_schedule_student_payment b on a.id_ = b.course_id_
  91. WHERE a.end_time_ >= DATE_SUB(NOW(),INTERVAL #{days} DAY)
  92. AND a.type_ = 'PIANO_ROOM_CLASS'
  93. GROUP BY a.teacher_id_,b.user_id_
  94. ) v on t.teacher_id_ = v.teacher_id_ and t.student_id_ = v.user_id_
  95. where v.user_id_ is null and t.created_time_ &lt;= DATE_SUB(NOW(),INTERVAL #{days} DAY)
  96. </select>
  97. <select id="selectBindingUserPage"
  98. resultType="com.yonge.cooleshow.biz.dal.vo.userBindingTeacher.UserBindingTeacherWrapper">
  99. select
  100. su.id_ as userId,
  101. su.username_ as username,
  102. su.gender_ as gender,
  103. su.birthdate_ as birthdate,
  104. su.phone_ as phone,
  105. ubt.created_time_ as bindingTime
  106. from user_binding_teacher ubt
  107. left join sys_user su on su.id_ = ubt.student_id_
  108. <where>
  109. <if test="query.teacherId != null">
  110. and #{query.teacherId} = ubt.teacher_id_
  111. </if>
  112. <if test="query.search != null and query.search != ''">
  113. and ( su.id_ like ('%${query.search}%')
  114. or su.username_ like ('%${query.search}%')
  115. or su.phone_ like ('%${query.search}%')
  116. )
  117. </if>
  118. <if test="query.startTime != null">
  119. and ubt.created_time_ &gt;= #{query.startTime}
  120. </if>
  121. <if test="query.endTime != null">
  122. and ubt.created_time_ &lt;= #{query.endTime}
  123. </if>
  124. </where>
  125. order by ubt.id_ desc
  126. </select>
  127. </mapper>