LibManagerMapper.xml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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.ssj.service.mapper.LibManagerMapper">
  4. <select id="findOrgMyInfo" resultType="com.ssj.service.weixin.library.dto.SelfCorrectTeacherInfoDTO">
  5. select tb_lib_manager.name,
  6. tb_lib_manager.t_photo photo,
  7. tb_lib_manager.lib_id,
  8. tb_lib_join.league_name org_name,
  9. tb_lib_manager.telephone
  10. from tb_lib_manager,
  11. tb_lib_join
  12. where tb_lib_manager.lib_id = tb_lib_join.id
  13. and tb_lib_manager.state = 1
  14. and tb_lib_manager.user_id = #{teacherId}
  15. and tb_lib_manager.type = #{type}
  16. limit 1
  17. </select>
  18. <select id="findOrgMyInfoV1" resultType="com.ssj.service.weixin.library.dto.SelfCorrectTeacherInfoDTO">
  19. select tb_lib_manager.name,
  20. tb_lib_manager.t_photo photo,
  21. tb_lib_manager.lib_id,
  22. tb_lib_join.league_name org_name,
  23. tb_lib_manager.telephone
  24. from tb_lib_manager,
  25. tb_lib_join
  26. where tb_lib_manager.lib_id = tb_lib_join.id
  27. and tb_lib_manager.state = 1
  28. and tb_lib_manager.user_id = #{teacherId}
  29. and tb_lib_manager.type = #{type}
  30. </select>
  31. <select id="findSubjectMyInfo" resultType="com.ssj.service.weixin.library.dto.SubjectMyInfoDto">
  32. select tb_lib_manager.name,
  33. tb_lib_manager.t_photo photo,
  34. tb_lib_manager.course_name courseName,
  35. tb_lib_join.league_name leagueName,
  36. tb_lib_manager.telephone
  37. from tb_lib_manager,
  38. tb_lib_join
  39. where tb_lib_manager.lib_id = tb_lib_join.id
  40. and tb_lib_manager.state = 1
  41. and tb_lib_manager.user_id = #{teacherId}
  42. and tb_lib_manager.type = #{type}
  43. </select>
  44. <select id="findSchoolmasterInfo" resultType="com.ssj.service.conch.curator.dto.SchoolmasterInfoDTO">
  45. select schoolmaster.t_photo photo,
  46. schoolmaster.lib_id,
  47. tb_lib_join.league_name orgName,
  48. schoolmaster.telephone phone,
  49. schoolmaster.name schoolName,
  50. (select count(distinct tb_lib_vip.id)
  51. from tb_lib_vip
  52. where tb_lib_vip.lib_id = schoolmaster.lib_id and tb_lib_vip.stat = 1) studentNum,
  53. (select count(distinct tb_lib_manager.user_id)
  54. from tb_lib_manager
  55. where tb_lib_manager.lib_id = schoolmaster.lib_id
  56. and tb_lib_manager.type in (2, 10, 15)
  57. and tb_lib_manager.state = 1) teacherNum,
  58. tb_lib_join.lib_service,
  59. tb_lib_join.platform_service
  60. from tb_lib_manager schoolmaster,
  61. tb_lib_join
  62. where schoolmaster.lib_id = tb_lib_join.id
  63. and schoolmaster.user_id = #{schoolmasterUserId}
  64. and schoolmaster.type = 4
  65. and schoolmaster.state = 1
  66. </select>
  67. <select id="findExerciseTeacherList" resultType="com.ssj.service.kmt.exercisesys.dto.ExerciseTeacherDTO">
  68. select lm.*,
  69. sum(if((lm.teacherId = eb.handle_user_id and eb.had_handle = 0)
  70. or
  71. (lm.teacherId = eb.auditing_user_id and (eb.had_handle = 0 or eb.had_auditing = 0))
  72. or
  73. (lm.teacherId = eb.analysis_user_id and eb.analysis_handled = 0)
  74. or
  75. (lm.teacherId = eb.analysis_auditer_id and (eb.analysis_handled = 0 or eb.analysis_audited = 0)), 1, 0)
  76. ) unFinishCount,
  77. sum(if(eb.id is null, 0, 1)) totalCount
  78. from (select user_id teacherId, t_photo image, name, course_name subject, authority, is_banned, is_cancelled,
  79. is_formal
  80. from tb_lib_manager
  81. where state = 1
  82. and type = 17
  83. <if test="req.subject != null and req.subject != ''">
  84. and course_name regexp #{req.subject}
  85. </if>
  86. <choose>
  87. <when test="req.type != null and req.type != ''">
  88. and authority regexp #{req.type}
  89. </when>
  90. <otherwise>
  91. and authority regexp '[12348]'
  92. </otherwise>
  93. </choose>
  94. and #{req.maxCreateTime} > create_time) lm
  95. left join
  96. kmt_exercise_book eb
  97. on (lm.teacherId = eb.handle_user_id or
  98. lm.teacherId = eb.auditing_user_id or
  99. lm.teacherId = eb.analysis_user_id or
  100. lm.teacherId = eb.analysis_auditer_id)
  101. <where>
  102. <if test="req.teacherName != null and req.teacherName != ''">
  103. lm.name regexp #{req.teacherName}
  104. </if>
  105. </where>
  106. group by lm.teacherId, lm.is_banned, lm.is_cancelled
  107. order by lm.is_banned, lm.is_cancelled, unFinishCount desc
  108. </select>
  109. <!-- 查询kmt老师列表 -->
  110. <select id="findKmtTeacherList" resultType="com.ssj.service.kmt.exercisesys.dto.ExerciseTeacherDTO">
  111. select m.user_id teacher_id, m.t_photo image, m.name, m.is_banned, m.is_cancelled, m.is_formal, m.authority, etd.total_count, etd.un_finish_count,m.course_name subject,
  112. etd.question_total_count, etd.question_unfinish_count from tb_lib_manager m
  113. left join kmt_exercise_teacher_datalist etd on m.user_id=etd.teacher_id and etd.type=#{type}
  114. where m.state=1
  115. <if test="subject != null and subject != ''">
  116. and m.course_name regexp #{subject}
  117. </if>
  118. <choose>
  119. <when test="authority != null and authority != '' and authority != 0">
  120. and m.authority regexp #{authority}
  121. </when>
  122. <otherwise>
  123. and m.authority regexp '[56]'
  124. </otherwise>
  125. </choose>
  126. <if test="teacherName != null and teacherName != ''">
  127. and m.name regexp #{teacherName}
  128. </if>
  129. and m.type = 17
  130. order by m.is_banned, m.is_cancelled, etd.question_unfinish_count desc, etd.id
  131. </select>
  132. <select id="findExerciseTeacherDetails"
  133. resultType="com.ssj.service.kmt.exercisesys.dto.ExerciseTeacherDetailDTO">
  134. select book_id, exercise_book_id, book_name, grade, semester, course_name, version, book_type, book_status,
  135. unfinished_unit_count, total_unit_count, accuracy accuracyInt
  136. from kmt_exercise_book_count
  137. where user_id = #{req.teacherId}
  138. and #{req.maxCreateTime} > create_time
  139. <if test="req.bookName != null and req.bookName != ''">
  140. and book_name like concat('%',#{req.bookName},'%')
  141. </if>
  142. and book_status > 0
  143. order by book_status
  144. </select>
  145. <select id="findTeacherStatusDetail"
  146. resultType="com.ssj.service.kmt.exercisesys.dto.TeacherInfoStatusDetailDTO">
  147. select user_id teacherId,
  148. t_photo image,
  149. name,
  150. school,
  151. sex,
  152. create_time,
  153. major,
  154. telephone,
  155. authority,
  156. is_banned,
  157. is_cancelled,
  158. is_formal,
  159. course_name subject
  160. from tb_lib_manager
  161. where user_id = #{teacherId}
  162. and state = 1
  163. and type = 17
  164. order by create_time desc
  165. limit 1
  166. </select>
  167. <select id="findTbLibManagerByUserIdsAndType" resultType="com.ssj.bean.weixin.libmy.domain.TbLibManager">
  168. select * from tb_lib_manager where type in
  169. <foreach collection="types" open="(" item="type" separator="," close=")">
  170. #{type}
  171. </foreach>
  172. and user_id in
  173. <foreach collection="userIds" open="(" item="userId" separator="," close=")">
  174. #{userId}
  175. </foreach>
  176. </select>
  177. <select id="findExerciseTeacherByName" resultType="String">
  178. select user_id from tb_lib_manager
  179. where state=1
  180. and type=17
  181. and is_cancelled=0
  182. and name = #{name}
  183. union
  184. select user_id from tb_lib_manager_audit
  185. where type=17
  186. and status=3
  187. and name = #{name}
  188. limit 1
  189. </select>
  190. <select id="findManagerByNameAndType" resultType="com.ssj.bean.weixin.libmy.domain.TbLibManager">
  191. select * from tb_lib_manager where name regexp #{name} and type=#{type} and state=1
  192. </select>
  193. <select id="findRandManagerByTypeAndSubject" resultType="com.ssj.bean.weixin.libmy.domain.TbLibManager">
  194. select * from tb_lib_manager m where type=17 and authority regexp '6' and state=1
  195. <if test="subject != null and subject != ''">
  196. and course_name regexp #{subject}
  197. </if>
  198. order by rand() limit 1;
  199. </select>
  200. <select id="findCheckTeacherList"
  201. resultType="com.ssj.service.kmt.exercisesys.dto.FindCheckTeacherListDto">
  202. select user_id teacherId,
  203. name teacherName,
  204. is_banned,
  205. is_cancelled,
  206. is_formal,
  207. course_name subject
  208. from tb_lib_manager
  209. where type = 17
  210. and state = 1
  211. and authority regexp #{authorityType}
  212. and is_cancelled = 0
  213. and is_banned = 0
  214. <if test="subjects != null and subjects.size()>0" >
  215. <foreach collection="subjects" item="subject" index="index" open="" close=" " separator="">
  216. and course_name regexp #{subject}
  217. </foreach>
  218. </if>
  219. <if test="teacherName != null and teacherName != ''">
  220. and name regexp #{teacherName}
  221. </if>
  222. </select>
  223. <select id="findCheckTeacherDetailsList" resultType="java.util.Map">
  224. select t.id, t.book_id bookId, t.book_name bookName, t.grade grade, t.semester semester, t.course_name subject,
  225. t.version_name version, book_type bookType, t.answer_corrected_status bookStatus,t.check_time checkTime
  226. from kmt_exercise_book t
  227. where t.answer_correcter_id = #{teacherId}
  228. and t.create_time &lt;=#{maxCreateTime}
  229. order by t.answer_corrected_status,t.check_time desc
  230. </select>
  231. <select id="findCheckTeacherDetails" resultType="java.util.Map">
  232. select
  233. sum(case when t.answer_corrected_status=0 then 1 else 0 end) uncheckCount,
  234. sum(case when t.answer_corrected_status=1 then 1 else 0 end) checkCount
  235. from kmt_exercise_book t
  236. where t.answer_correcter_id = #{teacherId}
  237. and t.create_time &lt;=#{maxCreateTime}
  238. </select>
  239. <select id="findTbLibManagersByCreateTime" resultType="com.ssj.bean.weixin.libmy.domain.TbLibManager">
  240. SELECT *
  241. FROM
  242. tb_lib_manager
  243. WHERE
  244. state = 1
  245. AND type = 17
  246. and user_id is not null
  247. AND authority REGEXP '[12348]'
  248. <if test="req.subject != null and req.subject != ''">
  249. and course_name regexp #{req.subject}
  250. </if>
  251. <choose>
  252. <when test="req.type != null and req.type != ''">
  253. and authority regexp #{req.type}
  254. </when>
  255. <otherwise>
  256. and authority regexp '[12348]'
  257. </otherwise>
  258. </choose>
  259. <if test="req.teacherName != null and req.teacherName != ''">
  260. and name regexp #{req.teacherName}
  261. </if>
  262. GROUP BY
  263. user_id,
  264. is_banned,
  265. is_cancelled
  266. ORDER BY
  267. is_banned,
  268. is_cancelled
  269. </select>
  270. <select id="findKmtTeacherLists" resultType="java.util.Map">
  271. select sum(
  272. IF
  273. (
  274. ( eb.handle_user_id = #{userId} AND eb.had_handle = 0 )
  275. OR ( eb.auditing_user_id = #{userId} AND ( eb.had_handle = 0 OR eb.had_auditing = 0 ) )
  276. OR ( eb.analysis_user_id = #{userId} AND eb.analysis_handled = 0 )
  277. OR ( eb.analysis_auditer_id = #{userId} AND ( eb.analysis_handled = 0 OR eb.analysis_audited = 0 ) ),
  278. 1,
  279. 0
  280. )
  281. ) unFinishCount,
  282. sum(if(eb.id is null, 0, 1)) totalCount
  283. from kmt_exercise_book eb
  284. where eb.handle_user_id = #{userId}
  285. or eb.auditing_user_id = #{userId}
  286. or eb.analysis_user_id = #{userId}
  287. or eb.analysis_auditer_id = #{userId}
  288. </select>
  289. </mapper>