TeacherMapper.xml 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  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.TeacherDao">
  8. <resultMap type="com.ym.mec.biz.dal.entity.Teacher" id="Teacher">
  9. <result column="id_" property="id"/>
  10. <result column="organ_id_" property="organId"/>
  11. <result column="teacher_organ_id_" property="teacherOrganId"/>
  12. <result column="organ_name_" property="organName"/>
  13. <result column="job_type_" property="jobType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  14. <result column="job_nature_" property="jobNature" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  15. <result column="is_probation_period_" property="isProbationPeriod"
  16. typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  17. <result column="education_background_" property="educationBackground"/>
  18. <result column="graduate_school_" property="graduateSchool"/>
  19. <result column="technical_titles_" property="technicalTitles"/>
  20. <result column="work_unit_" property="workUnit"/>
  21. <result column="subject_id_" property="subjectId"/>
  22. <result column="entry_date_" property="entryDate"/>
  23. <result column="demission_date_" property="demissionDate"/>
  24. <result column="certificate_type_" property="certificateType"/>
  25. <result column="certificate_num_" property="certificateNum"/>
  26. <result column="flow_organ_range_" property="flowOrganRange"/>
  27. <result column="introduction_" property="introduction"/>
  28. <result column="is_support_extra_practice_lesson_" property="isSupportExtraPracticeLesson"/>
  29. <result column="is_support_course_schedule_rewards_rules_" property="isSupportCourseScheduleRewardsRules"/>
  30. <result column="update_time_" property="updateTime"/>
  31. <result column="create_time_" property="createTime"/>
  32. <result column="username_" property="username"/>
  33. <result column="password_" property="password"/>
  34. <result column="real_name_" property="realName"/>
  35. <result column="salt_" property="salt"/>
  36. <result column="phone_" property="phone"/>
  37. <result column="avatar_" property="avatar"/>
  38. <result column="lock_flag_" property="lockFlag"/>
  39. <result column="del_flag_" property="delFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  40. <result column="wx_openid_" property="wxOpenid"/>
  41. <result column="qq_openid_" property="qqOpenid"/>
  42. <result column="user_type_" property="userType"/>
  43. <result column="gender_" property="gender"/>
  44. <result column="nation_" property="nation"/>
  45. <result column="birthdate_" property="birthdate"/>
  46. <result column="email_" property="email"/>
  47. <result column="im_token_" property="imToken"/>
  48. <result column="subject_name_" property="splitSubjectName"/>
  49. </resultMap>
  50. <!-- 根据主键查询一条记录 -->
  51. <select id="get" resultMap="Teacher">
  52. SELECT t.id_,t.organ_id_ teacher_organ_id_,t.job_type_,t.job_nature_,t.is_probation_period_,t.education_background_,t.graduate_school_,t.graduate_school_,
  53. t.technical_titles_,t.work_unit_,t.subject_id_,t.entry_date_,t.certificate_type_,t.certificate_num_,t.flow_organ_range_,t.update_time_,
  54. t.create_time_,t.introduction_,t.demission_date_,t.is_support_course_schedule_rewards_rules_,t.is_support_extra_practice_lesson_,
  55. su.real_name_,su.password_,su.salt_,su.phone_,su.avatar_,
  56. su.lock_flag_,su.del_flag_,su.wx_openid_,su.qq_openid_,su.user_type_,
  57. su.gender_,su.nation_,su.birthdate_,su.email_,su.im_token_,su.username_,su.organ_id_
  58. FROM teacher t
  59. LEFT JOIN sys_user su ON t.id_ = su.id_
  60. WHERE t.id_ = #{id} AND su.del_flag_ = 0
  61. </select>
  62. <!-- 全查询 -->
  63. <select id="findAll" resultMap="Teacher">
  64. SELECT *
  65. FROM teacher
  66. ORDER BY id_
  67. </select>
  68. <!-- 向数据库增加一条记录 -->
  69. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Teacher" useGeneratedKeys="true" keyColumn="id"
  70. keyProperty="id">
  71. INSERT INTO teacher
  72. (id_,organ_id_,job_type_,job_nature_,is_probation_period_,education_background_,graduate_school_,technical_titles_,work_unit_,subject_id_,entry_date_,demission_date_,certificate_type_,certificate_num_,flow_organ_range_,introduction_,update_time_,create_time_,is_support_extra_practice_lesson_,is_support_course_schedule_rewards_rules_)
  73. VALUES(#{id},#{organId},#{jobType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{jobNature},#{isProbationPeriod,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{educationBackground},#{graduateSchool},#{technicalTitles},#{workUnit},#{subjectId},#{entryDate},#{demissionDate},#{certificateType},#{certificateNum},#{flowOrganRange},#{introduction},now(),now(),#{isSupportExtraPracticeLesson},#{isSupportCourseScheduleRewardsRules})
  74. </insert>
  75. <insert id="addSysUser" parameterType="com.ym.mec.auth.api.entity.SysUser" useGeneratedKeys="true" keyColumn="id"
  76. keyProperty="id">
  77. INSERT INTO sys_user
  78. (im_token_,id_,username_,salt_,phone_,avatar_,organ_id_,create_time_,update_time_,wx_openid_,qq_openid_,user_type_,gender_,nation_,birthdate_,email_,id_card_no_,wechat_id_,real_name_,password_)
  79. VALUES(#{imToken},#{id},#{username},#{salt},#{phone},#{avatar},#{organId},now(),now(),#{wxOpenid},#{qqOpenid},#{userType},
  80. #{gender},#{nation},#{birthdate},#{email},#{idCardNo},#{wechatId},#{realName},#{password})
  81. </insert>
  82. <!-- 根据主键查询一条记录 -->
  83. <update id="update" parameterType="com.ym.mec.biz.dal.entity.Teacher">
  84. UPDATE teacher
  85. <set>
  86. <if test="graduateSchool != null">
  87. graduate_school_ = #{graduateSchool},
  88. </if>
  89. <if test="subjectId != null">
  90. subject_id_ = #{subjectId},
  91. </if>
  92. <if test="organId != null">
  93. organ_id_ = #{organId},
  94. </if>
  95. <if test="technicalTitles != null">
  96. technical_titles_ = #{technicalTitles},
  97. </if>
  98. <if test="entryDate != null">
  99. entry_date_ = #{entryDate},
  100. </if>
  101. <if test="demissionDate != null">
  102. demission_date_ = #{demissionDate},
  103. </if>
  104. <if test="jobType != null">
  105. job_type_ = #{jobType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  106. </if>
  107. <if test="flowOrganRange != null">
  108. flow_organ_range_ = #{flowOrganRange},
  109. </if>
  110. <if test="certificateType != null">
  111. certificate_type_ = #{certificateType},
  112. </if>
  113. <if test="jobNature != null">
  114. job_nature_ = #{jobNature,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  115. </if>
  116. <if test="isProbationPeriod != null">
  117. is_probation_period_ = #{isProbationPeriod,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  118. </if>
  119. <if test="updateTime != null">
  120. update_time_ = NOW(),
  121. </if>
  122. <if test="educationBackground != null">
  123. education_background_ = #{educationBackground},
  124. </if>
  125. <if test="certificateNum != null">
  126. certificate_num_ = #{certificateNum},
  127. </if>
  128. <if test="workUnit != null">
  129. work_unit_ = #{workUnit},
  130. </if>
  131. <if test="introduction != null">
  132. introduction_ = #{introduction},
  133. </if>
  134. <if test="isSupportCourseScheduleRewardsRules != null">
  135. is_support_course_schedule_rewards_rules_ = #{isSupportCourseScheduleRewardsRules},
  136. </if>
  137. <if test="isSupportExtraPracticeLesson != null">
  138. is_support_extra_practice_lesson_ = #{isSupportExtraPracticeLesson},
  139. </if>
  140. </set>
  141. WHERE id_ = #{id}
  142. </update>
  143. <!-- 根据主键删除一条记录 -->
  144. <update id="delete">
  145. DELETE FROM teacher WHERE id_ = #{id}
  146. </update>
  147. <update id="updateUser" parameterType="com.ym.mec.auth.api.entity.SysUser">
  148. UPDATE sys_user
  149. <set>
  150. <if test="delFlag != null">
  151. del_flag_ = #{delFlag, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  152. </if>
  153. <if test="wxOpenid != null">
  154. wx_openid_ = #{wxOpenid},
  155. </if>
  156. <if test="password != null">
  157. password_ = #{password},
  158. </if>
  159. <if test="avatar != null">
  160. avatar_ = #{avatar},
  161. </if>
  162. <if test="email != null">
  163. email_ = #{email},
  164. </if>
  165. <if test="gender != null">
  166. gender_ = #{gender},
  167. </if>
  168. <if test="salt != null">
  169. salt_ = #{salt},
  170. </if>
  171. <if test="username != null">
  172. username_ = #{username},
  173. </if>
  174. <if test="realName != null">
  175. real_name_ = #{realName},
  176. </if>
  177. <if test="userType != null">
  178. user_type_ = #{userType},
  179. </if>
  180. <if test="updateTime != null">
  181. update_time_ = NOW(),
  182. </if>
  183. <if test="lockFlag != null">
  184. lock_flag_ = #{lockFlag},
  185. </if>
  186. <if test="birthdate != null">
  187. birthdate_ = #{birthdate},
  188. </if>
  189. <if test="phone != null">
  190. phone_ = #{phone},
  191. </if>
  192. <if test="qqOpenid != null">
  193. qq_openid_ = #{qqOpenid},
  194. </if>
  195. <if test="nation != null">
  196. nation_ = #{nation},
  197. </if>
  198. <if test="organId != null">
  199. organ_id_ = #{organId},
  200. </if>
  201. <if test="imToken != null">
  202. im_token_ = #{imToken},
  203. </if>
  204. </set>
  205. WHERE id_ = #{id}
  206. </update>
  207. <!-- 分页查询 -->
  208. <select id="queryPage" resultMap="Teacher" parameterType="map">
  209. SELECT t.id_,su.real_name_,su.lock_flag_,t.subject_id_,su.phone_,t.organ_id_ teacher_organ_id_,t.organ_id_,t.is_support_extra_practice_lesson_,
  210. t.job_nature_,t.is_probation_period_,GROUP_CONCAT(s.name_) subject_name_,su.del_flag_
  211. FROM teacher t LEFT JOIN sys_user su ON t.id_ = su.id_
  212. LEFT JOIN `subject` s ON FIND_IN_SET(s.id_,t.subject_id_)
  213. WHERE su.del_flag_ = 0
  214. <include refid="queryPageMap"/>
  215. GROUP BY t.id_
  216. ORDER BY t.update_time_ DESC
  217. <include refid="global.limit"/>
  218. </select>
  219. <!-- 查询当前表的总记录数 -->
  220. <select id="queryCount" resultType="int">
  221. SELECT COUNT(DISTINCT t.id_)
  222. FROM teacher t LEFT JOIN sys_user su ON t.id_ = su.id_
  223. WHERE su.del_flag_ = 0
  224. <include refid="queryPageMap"/>
  225. </select>
  226. <sql id="queryPageMap">
  227. <if test="lockFlag != null">
  228. AND su.lock_flag_ = #{lockFlag}
  229. </if>
  230. <if test="teacherId != null">
  231. AND t.id_ IN
  232. <foreach collection="teacherId" separator="," open="(" close=")" item="item">
  233. #{item}
  234. </foreach>
  235. </if>
  236. <if test="search != null">
  237. AND (su.real_name_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%') OR t.id_ = #{search})
  238. </if>
  239. <if test="isSupportExtraPracticeLesson != null">
  240. AND is_support_extra_practice_lesson_ = #{isSupportExtraPracticeLesson}
  241. </if>
  242. </sql>
  243. <!-- 根据证件号查询老师 -->
  244. <select id="findByCertificateNum" resultMap="Teacher">
  245. SELECT * FROM teacher WHERE certificate_num_ = #{certificateNum} LIMIT 1
  246. </select>
  247. <select id="queryGroupStudents" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  248. SELECT su.username_,su.id_ user_id_,su.avatar_ head_url_,su.gender_,s.name_ subject_name_,sr.music_group_id_,su.user_type_
  249. FROM class_group_teacher_mapper cgtm
  250. LEFT JOIN class_group_student_mapper cgsm ON cgtm.class_group_id_ = cgsm.class_group_id_
  251. LEFT JOIN sys_user su ON cgsm.user_id_ = su.id_
  252. LEFT JOIN student_registration sr ON sr.user_id_ = su.id_
  253. LEFT JOIN `subject` s ON s.id_ = sr.actual_subject_id_
  254. LEFT JOIN music_group mg ON mg.id_ = cgtm.music_group_id_
  255. WHERE (cgtm.user_id_ = #{teacherId} OR mg.team_teacher_id_ = #{teacherId} OR mg.educational_teacher_id_ = #{teacherId}
  256. OR director_user_id_ = #{teacherId}) AND su.id_ IS NOT NULL AND cgtm.music_group_id_ = sr.music_group_id_
  257. <if test="search != null">
  258. AND su.username_ LIKE CONCAT('%',#{search},'%')
  259. </if>
  260. GROUP BY su.id_,s.id_,sr.id_
  261. </select>
  262. <select id="queryNameByIds" resultType="java.util.Map" parameterType="list">
  263. select id_ `key`,IF(real_name_ IS NUll,'',real_name_) `value` FROM sys_user s WHERE FIND_IN_SET(id_,#{userIds})
  264. </select>
  265. <select id="queryPhoneByIds" resultType="java.util.Map" parameterType="list">
  266. select id_ `key`,phone_ `value` FROM sys_user s WHERE FIND_IN_SET(id_,#{userIds}) AND s.phone_ IS NOT NULL
  267. </select>
  268. <resultMap id="TeacherBasicDto" type="com.ym.mec.biz.dal.dto.TeacherBasicDto">
  269. <result property="id" column="id_"/>
  270. <result property="username" column="username_"/>
  271. <result property="realName" column="real_name_"/>
  272. <result property="organId" column="organ_id_"/>
  273. </resultMap>
  274. <resultMap id="ExtendTeacherBasicDto" type="com.ym.mec.biz.dal.dto.ExtendTeacherBasicDto" extends="TeacherBasicDto">
  275. <result property="isSupportExtraPracticeLesson" column="is_support_extra_practice_lesson_"/>
  276. </resultMap>
  277. <select id="findTeachers" resultMap="TeacherBasicDto">
  278. SELECT su.id_,su.username_,su.real_name_,t.organ_id_ FROM sys_user su
  279. LEFT JOIN teacher t ON su.id_=t.id_
  280. <where>
  281. <if test="userIds != null">
  282. su.id_ IN
  283. <foreach collection="userIds" separator="," open="(" close=")" item="item">
  284. #{item}
  285. </foreach>
  286. </if>
  287. </where>
  288. </select>
  289. <select id="findSimpleTeachers" resultType="com.ym.mec.biz.dal.dto.SimpleUserDto">
  290. SELECT su.id_ userId,su.real_name_ userName FROM sys_user su
  291. LEFT JOIN teacher t ON su.id_=t.id_
  292. <where>
  293. <if test="userIds != null">
  294. su.id_ IN
  295. <foreach collection="userIds" separator="," open="(" close=")" item="item">
  296. #{item}
  297. </foreach>
  298. </if>
  299. </where>
  300. </select>
  301. <select id="findTeaTeachersByOrganAndSubject" resultMap="TeacherBasicDto">
  302. SELECT
  303. su.id_,
  304. su.username_,
  305. su.real_name_,
  306. t.organ_id_
  307. FROM
  308. teacher t
  309. LEFT JOIN sys_user su ON t.id_ = su.id_
  310. WHERE
  311. FIND_IN_SET(#{subjectId},t.subject_id_)
  312. AND (t.organ_id_=#{organId} OR FIND_IN_SET(#{organId},t.flow_organ_range_))
  313. AND t.job_nature_='FULL_TIME'
  314. AND su.del_flag_=0 AND su.lock_flag_=0
  315. AND t.organ_id_!=36 AND t.organ_id_!=38
  316. </select>
  317. <select id="findTeaTeachersByOrganAndSubject1" resultMap="ExtendTeacherBasicDto">
  318. SELECT
  319. su.id_,
  320. su.username_,
  321. su.real_name_,
  322. t.organ_id_,
  323. t.is_support_extra_practice_lesson_
  324. FROM
  325. teacher t
  326. LEFT JOIN sys_user su ON t.id_ = su.id_
  327. WHERE
  328. FIND_IN_SET(#{subjectId},t.subject_id_)
  329. AND (t.organ_id_=#{organId} OR FIND_IN_SET(#{organId},t.flow_organ_range_))
  330. AND t.job_nature_='FULL_TIME'
  331. AND su.del_flag_=0 AND su.lock_flag_=0
  332. AND t.organ_id_!=36 AND t.organ_id_!=38
  333. </select>
  334. <select id="findTeacherByOrganAndSubject" resultMap="TeacherBasicDto">
  335. SELECT
  336. su.id_,
  337. su.username_,
  338. su.real_name_,
  339. t.organ_id_
  340. FROM
  341. teacher t
  342. LEFT JOIN sys_user su ON t.id_ = su.id_
  343. WHERE
  344. FIND_IN_SET(#{subjectIds},t.subject_id_)
  345. AND INTE_ARRAY ( CONCAT( t.organ_id_, IF(t.flow_organ_range_ IS NULL,'',CONCAT(',', t.flow_organ_range_)) ), #{organIds} )
  346. </select>
  347. <select id="findByTeacherId" resultMap="TeacherBasicDto">
  348. SELECT
  349. su.id_,
  350. su.username_,
  351. su.real_name_,
  352. t.organ_id_
  353. FROM
  354. teacher t
  355. LEFT JOIN sys_user su ON t.id_ = su.id_
  356. WHERE
  357. t.id_=#{teacherId}
  358. </select>
  359. <select id="countCloses" resultType="java.lang.Integer">
  360. SELECT COUNT(cs.id_)
  361. FROM course_schedule cs
  362. LEFT JOIN course_schedule_teacher_salary csts ON cs.id_ = csts.course_schedule_id_
  363. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_ AND ta.teacher_id_ = csts.user_id_
  364. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  365. <include refid="queryCloses"/>
  366. </select>
  367. <resultMap id="TeacherCloseDto" type="com.ym.mec.biz.dal.dto.TeacherCloseDto">
  368. <result property="classDate" column="class_date_"/>
  369. <result property="classTime" column="start_class_time_"/>
  370. <result property="className" column="class_name_"/>
  371. <result property="courseScheduleType" column="class_type_"/>
  372. <result property="teacherRole" column="teacher_role_"/>
  373. <result property="currentClassTimes" column="current_class_times_"/>
  374. <result property="totalClassTimes" column="total_class_times_"/>
  375. <result property="signInStatus" column="sign_in_status_"/>
  376. <result property="signOutStatus" column="sign_out_status_"/>
  377. <result property="actualSalary" column="actual_salary_"/>
  378. <result property="expectSalary" column="expect_salary_"/>
  379. <result property="subsidy" column="subsidy_"/>
  380. <result property="settlementTime" column="settlement_time_"/>
  381. <result property="courseScheduleId" column="course_schedule_id_"/>
  382. </resultMap>
  383. <select id="queryCloses" resultMap="TeacherCloseDto">
  384. SELECT cs.id_ course_schedule_id_,cs.class_date_,cs.start_class_time_,cg.name_ class_name_,cs.type_ class_type_,
  385. csts.teacher_role_,ta.current_class_times_,cg.total_class_times_,
  386. IF(ta.sign_in_status_ IS NULL,3,ta.sign_in_status_) sign_in_status_,
  387. IF(ta.sign_out_status_ IS NULL,3,ta.sign_out_status_) sign_out_status_,
  388. csts.actual_salary_,csts.settlement_time_,csts.subsidy_,csts.expect_salary_
  389. FROM course_schedule cs
  390. LEFT JOIN course_schedule_teacher_salary csts ON cs.id_ = csts.course_schedule_id_
  391. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_ AND ta.teacher_id_ = csts.user_id_
  392. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  393. <include refid="queryCloses"/>
  394. ORDER BY cs.class_date_,cs.start_class_time_ DESC
  395. <include refid="global.limit"/>
  396. </select>
  397. <select id="findTeacherNoPay" resultType="decimal">
  398. SELECT SUM(expect_salary_) FROM course_schedule_teacher_salary csts WHERE settlement_time_ IS NULL AND user_id_
  399. = #{teacherId}
  400. </select>
  401. <select id="findTeacherByMusicGroup" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  402. SELECT
  403. su.id_ user_id_,
  404. su.real_name_ username_
  405. FROM
  406. class_group_teacher_mapper cgtm
  407. LEFT JOIN class_group cg ON cg.id_=cgtm.class_group_id_
  408. LEFT JOIN sys_user su ON cgtm.user_id_=su.id_
  409. WHERE cg.music_group_id_=#{musicGroupId} AND cg.group_type_='MUSIC'
  410. GROUP BY su.id_
  411. </select>
  412. <resultMap id="MusicGroupTeachersDto" type="com.ym.mec.biz.dal.dto.MusicGroupTeachersDto">
  413. <result property="teacherName" column="real_name_"/>
  414. <result property="teacherPhone" column="phone_"/>
  415. <result property="jobNature" column="job_nature_"/>
  416. <result property="classGroupName" column="class_group_name_"/>
  417. <result property="classGroupId" column="class_group_id_"/>
  418. <result property="teacherId" column="teacher_id_"/>
  419. </resultMap>
  420. <select id="queryMusicGroupTeachers" resultMap="MusicGroupTeachersDto">
  421. SELECT su.real_name_,su.phone_,t.job_nature_,GROUP_CONCAT(cg.name_) class_group_name_,t.id_ teacher_id_
  422. FROM teacher t
  423. LEFT JOIN class_group_teacher_mapper cgtm ON t.id_ = cgtm.user_id_
  424. LEFT JOIN class_group cg ON cg.id_ = cgtm.class_group_id_
  425. LEFT JOIN sys_user su ON t.id_ = su.id_
  426. WHERE cg.del_flag_ != '1' AND cgtm.group_type_ = 'MUSIC'
  427. <include refid="queryMusicGroupTeachersSql"/>
  428. GROUP BY t.id_
  429. <include refid="global.limit"/>
  430. </select>
  431. <select id="countMusicGroupTeachers" resultType="java.lang.Integer">
  432. SELECT COUNT(DISTINCT t.id_)
  433. FROM teacher t
  434. LEFT JOIN class_group_teacher_mapper cgtm ON t.id_ = cgtm.user_id_
  435. LEFT JOIN class_group cg ON cg.id_ = cgtm.class_group_id_
  436. LEFT JOIN sys_user su ON t.id_ = su.id_
  437. WHERE cg.del_flag_ != '1' AND cgtm.group_type_ = 'MUSIC'
  438. <include refid="queryMusicGroupTeachersSql"/>
  439. </select>
  440. <sql id="queryMusicGroupTeachersSql">
  441. <if test="search != null and search != ''">
  442. AND (su.real_name_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%') OR
  443. su.id_=#{search})
  444. </if>
  445. <if test="musicGroupId != null and musicGroupId != ''">
  446. AND cgtm.music_group_id_ = #{musicGroupId}
  447. </if>
  448. <if test="classGroupId != null">
  449. AND cg.id_ = #{classGroupId}
  450. </if>
  451. </sql>
  452. <select id="findSignNum" resultType="java.util.Map">
  453. SELECT ta.teacher_id_ 'key',COUNT(ta.id_) 'value' FROM teacher_attendance ta
  454. WHERE FIND_IN_SET(ta.teacher_id_,#{teacherIdStr}) AND ta.music_group_id_ = #{musicGroupId}
  455. GROUP BY ta.teacher_id_
  456. </select>
  457. <sql id="queryTeacherAttendanceSql">
  458. <where>
  459. CONCAT(cs.class_date_,' ',cs.start_class_time_) &lt; NOW() AND cgtm.teacher_role_ = 'BISHOP'
  460. <if test="startTime != null and startTime != ''">
  461. AND cs.class_date_ &gt;= #{startTime}
  462. </if>
  463. <if test="endTime != null and endTime != ''">
  464. AND cs.class_date_ &lt;= #{endTime}
  465. </if>
  466. <if test="musicGroupId != null and musicGroupId != ''">
  467. AND ta.music_group_id_ = #{musicGroupId}
  468. </if>
  469. <if test="teacherName != null and teacherName != ''">
  470. AND su.real_name_ LIKE CONCAT('%',#{teacherName},'%')
  471. </if>
  472. </where>
  473. </sql>
  474. <resultMap id="MusicGroupTeacherAttendanceDto" type="com.ym.mec.biz.dal.dto.MusicGroupTeacherAttendanceDto">
  475. <result property="classDate" column="class_date_"/>
  476. <result property="startClassTime" column="start_class_time_"/>
  477. <result property="courseScheduleName" column="name_"/>
  478. <result property="realName" column="real_name_"/>
  479. <result property="signInStatus" column="sign_in_status_"/>
  480. <result property="signOutStatus" column="sign_out_status_"/>
  481. </resultMap>
  482. <select id="queryTeacherAttendance" resultMap="MusicGroupTeacherAttendanceDto">
  483. SELECT cs.class_date_,cs.start_class_time_,cs.name_,su.real_name_,
  484. IF(ta.sign_in_status_ IS NULL,3,ta.sign_in_status_) sign_in_status_,
  485. IF(ta.sign_out_status_ IS NULL,3,ta.sign_out_status_) sign_out_status_
  486. FROM course_schedule cs
  487. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_
  488. LEFT JOIN sys_user su ON su.id_ = ta.teacher_id_
  489. LEFT JOIN class_group_teacher_mapper cgtm ON cgtm.class_group_id_ = cs.class_group_id_ AND ta.teacher_id_ = cgtm.user_id_
  490. <include refid="queryTeacherAttendanceSql"/>
  491. ORDER BY cs.class_date_ DESC,cs.start_class_time_ DESC
  492. <include refid="global.limit"/>
  493. </select>
  494. <select id="countTeacherAttendance" resultType="java.lang.Integer">
  495. SELECT COUNT(cs.id_)
  496. FROM course_schedule cs
  497. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_
  498. LEFT JOIN sys_user su ON su.id_ = ta.teacher_id_
  499. LEFT JOIN class_group_teacher_mapper cgtm ON cgtm.class_group_id_ = cs.class_group_id_ AND ta.teacher_id_ = cgtm.user_id_
  500. <include refid="queryTeacherAttendanceSql"/>
  501. </select>
  502. <select id="queryNameById" resultType="java.lang.String">
  503. select real_name_ FROM sys_user s WHERE id_ = #{userId} LIMIT 1
  504. </select>
  505. <resultMap id="musicGroupStudentApplyDto" type="com.ym.mec.biz.dal.dto.musicGroupStudentApplyDto">
  506. <result property="userId" column="user_id_"/>
  507. <result property="userName" column="username_"/>
  508. <result property="currentClass" column="current_class_"/>
  509. <result property="currentGrade" column="current_grade_"/>
  510. <result property="subjectName" column="subject_name_"/>
  511. <result property="subjectId" column="actual_subject_id_"/>
  512. <result property="paymentAmount" column="actual_amount_"/>
  513. <result property="payTime" column="pay_time_"/>
  514. <result property="paymentStatus" column="payment_status_"/>
  515. <result property="remark" column="remark_"/>
  516. </resultMap>
  517. <select id="queryMusicGroupStudentApply" resultMap="musicGroupStudentApplyDto">
  518. SELECT sr.user_id_,su.username_,sr.current_class_,sr.current_grade_,s.name_ subject_name_,sr.remark_,
  519. sr.payment_status_,sr.actual_subject_id_
  520. FROM student_registration sr
  521. LEFT JOIN sys_user su ON sr.user_id_ = su.id_
  522. LEFT JOIN `subject` s ON sr.actual_subject_id_ = s.id_
  523. <include refid="queryMusicGroupStudentApplySql"/>
  524. <include refid="global.limit"/>
  525. </select>
  526. <sql id="queryMusicGroupStudentApplySql">
  527. <where>
  528. sr.music_group_id_ = #{musicGroupId} AND sr.music_group_status_ != 'QUIT'
  529. <if test="subjectId != null">
  530. AND sr.actual_subject_id_ = #{subjectId}
  531. </if>
  532. <if test="paymentStatus != null">
  533. AND sr.payment_status_ = #{paymentStatus}
  534. </if>
  535. </where>
  536. </sql>
  537. <select id="countMusicGroupStudentApply" resultType="java.lang.Integer">
  538. SELECT COUNT(sr.user_id_)
  539. FROM student_registration sr
  540. LEFT JOIN sys_user su ON sr.user_id_ = su.id_
  541. LEFT JOIN `subject` s ON sr.actual_subject_id_ = s.id_
  542. <include refid="queryMusicGroupStudentApplySql"/>
  543. </select>
  544. <select id="queryMusicGroupStudents" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  545. SELECT su.real_name_ username_,su.id_ user_id_,su.avatar_ head_url_,
  546. su.gender_,GROUP_CONCAT(s.name_) subject_name_,su.user_type_
  547. FROM teacher t
  548. LEFT JOIN sys_user su ON t.id_ = su.id_
  549. LEFT JOIN `subject` s ON FIND_IN_SET(s.id_,t.subject_id_)
  550. WHERE FIND_IN_SET(t.id_,#{teacherIds})
  551. <if test="search != null">
  552. AND su.real_name_ LIKE CONCAT('%',#{search},'%')
  553. </if>
  554. GROUP BY t.id_
  555. </select>
  556. <select id="findOrganTeacherBySubject" resultMap="Teacher">
  557. SELECT su.* FROM teacher t
  558. LEFT JOIN sys_user su on t.id_ = su.id_ WHERE 1=1
  559. <if test="subjectId != null">
  560. AND FIND_IN_SET(#{subjectId},t.subject_id_)
  561. </if>
  562. </select>
  563. <sql id="queryCloses">
  564. <where>
  565. CONCAT(cs.class_date_,' ',cs.start_class_time_) &lt; NOW()
  566. <if test="teacherId != null">
  567. AND csts.user_id_ = #{teacherId}
  568. </if>
  569. <if test="courseStartDate != null and courseStartDate != ''">
  570. AND cs.class_date_ &gt;= #{courseStartDate}
  571. </if>
  572. <if test="courseEndDate != null and courseEndDate != ''">
  573. AND cs.class_date_ &lt;= #{courseEndDate}
  574. </if>
  575. <if test="courseScheduleType != null and courseScheduleType != ''">
  576. AND cs.type_ = #{courseScheduleType}
  577. </if>
  578. <if test="teacherRole != null and teacherRole != ''">
  579. AND csts.teacher_role_ = #{teacherRole}
  580. </if>
  581. <if test="signInStatus != null and signInStatus != 3">
  582. AND ta.sign_in_status_ = #{signInStatus}
  583. </if>
  584. <if test="signOutStatus != null and signOutStatus != 3">
  585. AND ta.sign_out_status_ = #{signOutStatus}
  586. </if>
  587. <if test="signOutStatus != null and signOutStatus == 3">
  588. AND ta.sign_out_status_ IS NULL
  589. </if>
  590. <if test="signInStatus != null and signInStatus == 3">
  591. AND ta.sign_in_status_ IS NULL
  592. </if>
  593. </where>
  594. </sql>
  595. <select id="queryOrganTeacherNum" resultType="map">
  596. select count(*) total,sum(case when job_nature_ = 'PART_TIME' then 1 else 0 end) part_time_num_,sum(case when
  597. job_nature_ = 'FULL_TIME' then 1 else 0 end) full_time_num_ from teacher
  598. where demission_date_ is null
  599. <if test="organId != null">
  600. and FIND_IN_SET(organ_id_,#{organId})
  601. </if>
  602. </select>
  603. <select id="findByFlowOrganRange" resultMap="Teacher">
  604. SELECT id_,CONCAT(IF(flow_organ_range_ IS NULL OR flow_organ_range_ = '',0,flow_organ_range_),",",
  605. IF(organ_id_ IS NULL OR organ_id_ = '',0,organ_id_)) flow_organ_range_ FROM teacher t
  606. <where>
  607. <if test="subjectId != null">
  608. AND FIND_IN_SET(#{subjectId},t.subject_id_)
  609. </if>
  610. <if test="jobNature != null">
  611. AND t.job_nature_ = #{jobNature}
  612. </if>
  613. <if test="isProbationPeriod != null">
  614. AND t.is_probation_period_ = #{isProbationPeriod}
  615. </if>
  616. <if test="isSupportExtraPracticeLesson != null">
  617. AND t.is_support_extra_practice_lesson_ = #{isSupportExtraPracticeLesson}
  618. </if>
  619. </where>
  620. </select>
  621. <select id="findByTeacherIds" resultMap="Teacher">
  622. SELECT * FROM teacher WHERE id_ IN
  623. <foreach collection="teacherIds" item="teacherId" open="(" close=")" separator=",">
  624. #{teacherId}
  625. </foreach>
  626. </select>
  627. <select id="findTeacherByOrganId" resultMap="TeacherBasicDto">
  628. SELECT su.id_,su.username_,su.real_name_ FROM teacher t
  629. LEFT JOIN sys_user su ON t.id_ = su.id_
  630. WHERE su.del_flag_ != 1
  631. <if test="organId != null">
  632. AND FIND_IN_SET(t.organ_id_,#{organId})
  633. </if>
  634. <if test="subjectIds != null">
  635. AND INTE_ARRAY(t.subject_id_,#{subjectIds})
  636. </if>
  637. <if test="jobNature != null">
  638. AND t.job_nature_ = #{jobNature}
  639. </if>
  640. </select>
  641. <select id="queryUsernameByIds" resultType="java.util.Map" parameterType="list">
  642. select id_ `key`,username_ `value` FROM sys_user s
  643. WHERE s.id_ IN
  644. <foreach collection="userIds" item="item" open="(" close=")" separator=",">
  645. #{item}
  646. </foreach>
  647. </select>
  648. <select id="searchTeachers" resultMap="TeacherBasicDto">
  649. SELECT su.id_,su.username_,su.real_name_ FROM teacher t
  650. LEFT JOIN sys_user su ON t.id_ = su.id_
  651. WHERE su.del_flag_ != 1
  652. <if test="organId != null">
  653. AND FIND_IN_SET(t.organ_id_,#{organId})
  654. </if>
  655. <if test="teacherName != null">
  656. AND su.real_name_ LIKE CONCAT('%',#{teacherName},'%')
  657. </if>
  658. </select>
  659. <select id="countTeacherName" resultType="java.lang.Integer">
  660. SELECT COUNT(su.id_) FROM teacher t
  661. LEFT JOIN sys_user su ON t.id_ = su.id_
  662. WHERE su.del_flag_ != 1
  663. <include refid="queryPageNameSql"/>
  664. </select>
  665. <sql id="queryPageNameSql">
  666. <if test="organId != null">
  667. AND FIND_IN_SET(t.organ_id_,#{organId})
  668. </if>
  669. <if test="subjectIds != null">
  670. AND INTE_ARRAY(t.subject_id_,#{subjectIds})
  671. </if>
  672. <if test="jobNature != null">
  673. AND t.job_nature_ = #{jobNature}
  674. </if>
  675. <if test="teacherId != null">
  676. AND t.id_ = #{teacherId}
  677. </if>
  678. <if test="search != null">
  679. AND (su.real_name_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  680. </if>
  681. </sql>
  682. <select id="queryPageName" resultMap="Teacher">
  683. SELECT su.id_,su.real_name_,su.avatar_ FROM teacher t
  684. LEFT JOIN sys_user su ON t.id_ = su.id_
  685. WHERE su.del_flag_ != 1
  686. <include refid="queryPageNameSql"/>
  687. <include refid="global.limit"/>
  688. </select>
  689. <select id="getCourseScheduleHomework" resultMap="com.ym.mec.biz.dal.dao.CourseHomeworkDao.CourseHomework">
  690. SELECT * FROM course_homework WHERE course_schedule_id_ = #{courseScheduleId} LIMIT 1
  691. </select>
  692. <select id="lockTeachers" resultType="int">
  693. SELECT id_ FROM teacher WHERE id_ IN
  694. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  695. #{userId}
  696. </foreach>
  697. FOR UPDATE
  698. </select>
  699. <resultMap type="com.ym.mec.auth.api.entity.SysUser" id="SysUser">
  700. <result column="id_" property="id"/>
  701. <result column="username_" property="username"/>
  702. <result column="real_name_" property="realName"/>
  703. <result column="password_" property="password"/>
  704. <result column="salt_" property="salt"/>
  705. <result column="phone_" property="phone"/>
  706. <result column="avatar_" property="avatar"/>
  707. <result column="organ_id_" property="organId"/>
  708. <result column="create_time_" property="createTime"/>
  709. <result column="update_time_" property="updateTime"/>
  710. <result column="lock_flag_" property="lockFlag"/>
  711. <result column="del_flag_" property="delFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  712. <result column="wx_openid_" property="wxOpenid"/>
  713. <result column="qq_openid_" property="qqOpenid"/>
  714. <result column="user_type_" property="userType"/>
  715. <result column="gender_" property="gender"/>
  716. <result column="nation_" property="nation"/>
  717. <result column="birthdate_" property="birthdate"/>
  718. <result column="email_" property="email"/>
  719. <result column="im_token_" property="imToken"/>
  720. <result column="id_card_no_" property="idCardNo"/>
  721. <result column="wechat_id_" property="wechatId"/>
  722. <result column="is_super_admin_" property="isSuperAdmin"/>
  723. <result column="current_grade_" property="currentGrade"/>
  724. <result column="current_class_" property="currentClass"/>
  725. </resultMap>
  726. <select id="getUser" resultMap="SysUser">
  727. SELECT su.*
  728. FROM sys_user su
  729. WHERE su.id_ = #{id} LIMIT 1
  730. </select>
  731. </mapper>