TeacherMapper.xml 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056
  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="idcard_front_img_" property="idcardFrontImg"/>
  31. <result column="idcard_back_img_" property="idcardBackImg"/>
  32. <result column="idcard_hand_img_" property="idcardHandImg"/>
  33. <result column="update_time_" property="updateTime"/>
  34. <result column="create_time_" property="createTime"/>
  35. <result column="lecture_num_" property="lectureNum"/>
  36. <result column="username_" property="username"/>
  37. <result column="password_" property="password"/>
  38. <result column="real_name_" property="realName"/>
  39. <result column="salt_" property="salt"/>
  40. <result column="phone_" property="phone"/>
  41. <result column="avatar_" property="avatar"/>
  42. <result column="lock_flag_" property="lockFlag"/>
  43. <result column="del_flag_" property="delFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  44. <result column="wx_openid_" property="wxOpenid"/>
  45. <result column="qq_openid_" property="qqOpenid"/>
  46. <result column="user_type_" property="userType"/>
  47. <result column="gender_" property="gender"/>
  48. <result column="nation_" property="nation"/>
  49. <result column="birthdate_" property="birthdate"/>
  50. <result column="email_" property="email"/>
  51. <result column="im_token_" property="imToken"/>
  52. <result column="subject_name_" property="splitSubjectName"/>
  53. <result column="id_card_no_" property="idCardNo"/>
  54. </resultMap>
  55. <!-- 根据主键查询一条记录 -->
  56. <select id="get" resultMap="Teacher">
  57. 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_,
  58. 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_,
  59. t.create_time_,t.introduction_,t.demission_date_,t.is_support_course_schedule_rewards_rules_,t.is_support_extra_practice_lesson_,t.lecture_num_,t.idcard_front_img_,t.idcard_back_img_,t.idcard_hand_img_,
  60. su.real_name_,su.id_card_no_,su.password_,su.salt_,su.phone_,su.avatar_,
  61. su.lock_flag_,su.del_flag_,su.wx_openid_,su.qq_openid_,su.user_type_,
  62. su.gender_,su.nation_,su.birthdate_,su.email_,su.im_token_,su.username_,su.organ_id_
  63. FROM teacher t
  64. LEFT JOIN sys_user su ON t.id_ = su.id_
  65. WHERE t.id_ = #{id} AND su.del_flag_ = 0
  66. </select>
  67. <!-- 全查询 -->
  68. <select id="findAll" resultMap="Teacher">
  69. SELECT *
  70. FROM teacher
  71. ORDER BY id_
  72. </select>
  73. <!-- 向数据库增加一条记录 -->
  74. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Teacher" useGeneratedKeys="true" keyColumn="id"
  75. keyProperty="id">
  76. INSERT INTO teacher
  77. (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_,idcard_front_img_,idcard_back_img_,idcard_hand_img_)
  78. 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},#{idcardFrontImg},#{idcardBackImg},#{idcardHandImg})
  79. </insert>
  80. <insert id="addSysUser" parameterType="com.ym.mec.auth.api.entity.SysUser" useGeneratedKeys="true" keyColumn="id"
  81. keyProperty="id">
  82. INSERT INTO sys_user
  83. (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_)
  84. VALUES(#{imToken},#{id},#{username},#{salt},#{phone},#{avatar},#{organId},now(),now(),#{wxOpenid},#{qqOpenid},#{userType},
  85. #{gender},#{nation},#{birthdate},#{email},#{idCardNo},#{wechatId},#{realName},#{password})
  86. </insert>
  87. <!-- 根据主键查询一条记录 -->
  88. <update id="update" parameterType="com.ym.mec.biz.dal.entity.Teacher">
  89. UPDATE teacher
  90. <set>
  91. <if test="lectureNum != null">
  92. lecture_num_ = #{lectureNum},
  93. </if>
  94. <if test="graduateSchool != null">
  95. graduate_school_ = #{graduateSchool},
  96. </if>
  97. <if test="subjectId != null">
  98. subject_id_ = #{subjectId},
  99. </if>
  100. <if test="organId != null">
  101. organ_id_ = #{organId},
  102. </if>
  103. <if test="technicalTitles != null">
  104. technical_titles_ = #{technicalTitles},
  105. </if>
  106. <if test="entryDate != null">
  107. entry_date_ = #{entryDate},
  108. </if>
  109. <if test="demissionDate != null">
  110. demission_date_ = #{demissionDate},
  111. </if>
  112. <if test="jobType != null">
  113. job_type_ = #{jobType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  114. </if>
  115. <if test="flowOrganRange != null">
  116. flow_organ_range_ = #{flowOrganRange},
  117. </if>
  118. <if test="certificateType != null">
  119. certificate_type_ = #{certificateType},
  120. </if>
  121. <if test="jobNature != null">
  122. job_nature_ = #{jobNature,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  123. </if>
  124. <if test="isProbationPeriod != null">
  125. is_probation_period_ = #{isProbationPeriod,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  126. </if>
  127. <if test="updateTime != null">
  128. update_time_ = NOW(),
  129. </if>
  130. <if test="educationBackground != null">
  131. education_background_ = #{educationBackground},
  132. </if>
  133. <if test="certificateNum != null">
  134. certificate_num_ = #{certificateNum},
  135. </if>
  136. <if test="workUnit != null">
  137. work_unit_ = #{workUnit},
  138. </if>
  139. <if test="introduction != null">
  140. introduction_ = #{introduction},
  141. </if>
  142. <if test="isSupportCourseScheduleRewardsRules != null">
  143. is_support_course_schedule_rewards_rules_ = #{isSupportCourseScheduleRewardsRules},
  144. </if>
  145. <if test="isSupportExtraPracticeLesson != null">
  146. is_support_extra_practice_lesson_ = #{isSupportExtraPracticeLesson},
  147. </if>
  148. <if test="idcardFrontImg != null">
  149. idcard_front_img_ = #{idcardFrontImg},
  150. </if>
  151. <if test="idcardBackImg != null">
  152. idcard_back_img_ = #{idcardBackImg},
  153. </if>
  154. <if test="idcardHandImg != null">
  155. idcard_hand_img_ = #{idcardHandImg},
  156. </if>
  157. </set>
  158. WHERE id_ = #{id}
  159. </update>
  160. <!-- 根据主键删除一条记录 -->
  161. <update id="delete">
  162. DELETE FROM teacher WHERE id_ = #{id}
  163. </update>
  164. <update id="updateUser" parameterType="com.ym.mec.auth.api.entity.SysUser">
  165. UPDATE sys_user
  166. <set>
  167. <if test="delFlag != null">
  168. del_flag_ = #{delFlag, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  169. </if>
  170. <if test="wxOpenid != null">
  171. wx_openid_ = #{wxOpenid},
  172. </if>
  173. <if test="password != null">
  174. password_ = #{password},
  175. </if>
  176. <if test="avatar != null">
  177. avatar_ = #{avatar},
  178. </if>
  179. <if test="email != null">
  180. email_ = #{email},
  181. </if>
  182. <if test="gender != null">
  183. gender_ = #{gender},
  184. </if>
  185. <if test="salt != null">
  186. salt_ = #{salt},
  187. </if>
  188. <if test="username != null">
  189. username_ = #{username},
  190. </if>
  191. <if test="realName != null">
  192. real_name_ = #{realName},
  193. </if>
  194. <if test="userType != null">
  195. user_type_ = #{userType},
  196. </if>
  197. <if test="updateTime != null">
  198. update_time_ = NOW(),
  199. </if>
  200. <if test="lockFlag != null">
  201. lock_flag_ = #{lockFlag},
  202. </if>
  203. <if test="birthdate != null">
  204. birthdate_ = #{birthdate},
  205. </if>
  206. <if test="phone != null">
  207. phone_ = #{phone},
  208. </if>
  209. <if test="qqOpenid != null">
  210. qq_openid_ = #{qqOpenid},
  211. </if>
  212. <if test="nation != null">
  213. nation_ = #{nation},
  214. </if>
  215. <if test="organId != null">
  216. organ_id_ = #{organId},
  217. </if>
  218. <if test="imToken != null">
  219. im_token_ = #{imToken},
  220. </if>
  221. </set>
  222. WHERE id_ = #{id}
  223. </update>
  224. <!-- 分页查询 -->
  225. <select id="queryPage" resultMap="Teacher" parameterType="map">
  226. 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_,
  227. t.job_nature_,t.is_probation_period_,GROUP_CONCAT(s.name_) subject_name_,su.del_flag_
  228. FROM teacher t LEFT JOIN sys_user su ON t.id_ = su.id_
  229. LEFT JOIN `subject` s ON FIND_IN_SET(s.id_,t.subject_id_)
  230. WHERE su.del_flag_ = 0
  231. <include refid="queryPageMap"/>
  232. GROUP BY t.id_
  233. ORDER BY t.update_time_ DESC
  234. <include refid="global.limit"/>
  235. </select>
  236. <!-- 查询当前表的总记录数 -->
  237. <select id="queryCount" resultType="int">
  238. SELECT COUNT(DISTINCT t.id_)
  239. FROM teacher t LEFT JOIN sys_user su ON t.id_ = su.id_
  240. WHERE su.del_flag_ = 0
  241. <include refid="queryPageMap"/>
  242. </select>
  243. <sql id="queryPageMap">
  244. <if test="lockFlag != null">
  245. AND su.lock_flag_ = #{lockFlag}
  246. </if>
  247. <if test="teacherId != null">
  248. AND t.id_ IN
  249. <foreach collection="teacherId" separator="," open="(" close=")" item="item">
  250. #{item}
  251. </foreach>
  252. </if>
  253. <if test="search != null">
  254. AND (su.real_name_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%') OR t.id_ = #{search})
  255. </if>
  256. <if test="isSupportExtraPracticeLesson != null">
  257. AND is_support_extra_practice_lesson_ = #{isSupportExtraPracticeLesson}
  258. </if>
  259. </sql>
  260. <!-- 根据证件号查询老师 -->
  261. <select id="findByCertificateNum" resultMap="Teacher">
  262. SELECT * FROM teacher WHERE certificate_num_ = #{certificateNum} LIMIT 1
  263. </select>
  264. <select id="queryGroupStudents" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  265. SELECT su.username_,su.id_ user_id_,su.avatar_ head_url_,su.gender_,s.name_ subject_name_,sr.music_group_id_,su.user_type_
  266. FROM class_group_teacher_mapper cgtm
  267. LEFT JOIN class_group_student_mapper cgsm ON cgtm.class_group_id_ = cgsm.class_group_id_
  268. LEFT JOIN sys_user su ON cgsm.user_id_ = su.id_
  269. LEFT JOIN student_registration sr ON sr.user_id_ = cgsm.user_id_ AND cgsm.music_group_id_ = sr.music_group_id_
  270. LEFT JOIN `subject` s ON s.id_ = sr.actual_subject_id_
  271. LEFT JOIN music_group mg ON mg.id_ = cgsm.music_group_id_ AND cgsm.group_type_ = 'MUSIC'
  272. LEFT JOIN vip_group vg ON vg.id_ = cgsm.music_group_id_ AND cgsm.group_type_ = 'VIP'
  273. WHERE (cgtm.user_id_ = #{teacherId} OR mg.team_teacher_id_ = #{teacherId} OR mg.educational_teacher_id_ = #{teacherId}
  274. OR director_user_id_ = #{teacherId}) AND su.id_ IS NOT NULL AND (sr.music_group_status_ != 'QUIT' OR sr.id_ IS NULL)
  275. AND (mg.status_ = 'PROGRESS' OR vg.group_status_ IN (2,4) OR cgsm.group_type_ = 'PRACTICE')
  276. <if test="search != null">
  277. AND su.username_ LIKE CONCAT('%',#{search},'%')
  278. </if>
  279. GROUP BY su.id_,s.id_,sr.id_
  280. </select>
  281. <select id="queryNameByIds" resultType="java.util.Map" parameterType="list">
  282. select id_ `key`,IF(real_name_ IS NUll,'',real_name_) `value` FROM sys_user s WHERE FIND_IN_SET(id_,#{userIds})
  283. </select>
  284. <select id="queryPhoneByIds" resultType="java.util.Map" parameterType="list">
  285. select id_ `key`,phone_ `value` FROM sys_user s WHERE FIND_IN_SET(id_,#{userIds}) AND s.phone_ IS NOT NULL
  286. </select>
  287. <resultMap id="TeacherBasicDto" type="com.ym.mec.biz.dal.dto.TeacherBasicDto">
  288. <result property="id" column="id_"/>
  289. <result property="username" column="username_"/>
  290. <result property="realName" column="real_name_"/>
  291. <result property="organId" column="organ_id_"/>
  292. </resultMap>
  293. <resultMap id="ExtendTeacherBasicDto" type="com.ym.mec.biz.dal.dto.ExtendTeacherBasicDto" extends="TeacherBasicDto">
  294. <result property="isSupportExtraPracticeLesson" column="is_support_extra_practice_lesson_"/>
  295. <result property="avatar" column="avatar_"/>
  296. <result property="subjectNames" column="subject_names_"/>
  297. <result property="introduction" column="introduction_"/>
  298. </resultMap>
  299. <select id="findTeachers" resultMap="TeacherBasicDto">
  300. SELECT su.id_,su.username_,su.real_name_,t.organ_id_ FROM sys_user su
  301. LEFT JOIN teacher t ON su.id_=t.id_
  302. <where>
  303. <if test="userIds != null">
  304. su.id_ IN
  305. <foreach collection="userIds" separator="," open="(" close=")" item="item">
  306. #{item}
  307. </foreach>
  308. </if>
  309. </where>
  310. </select>
  311. <select id="findSimpleTeachers" resultType="com.ym.mec.biz.dal.dto.SimpleUserDto">
  312. SELECT su.id_ userId,su.real_name_ userName FROM sys_user su
  313. LEFT JOIN teacher t ON su.id_=t.id_
  314. <where>
  315. <if test="userIds != null">
  316. su.id_ IN
  317. <foreach collection="userIds" separator="," open="(" close=")" item="item">
  318. #{item}
  319. </foreach>
  320. </if>
  321. </where>
  322. </select>
  323. <select id="findTeaTeachersByOrganAndSubject" resultMap="TeacherBasicDto">
  324. SELECT
  325. su.id_,
  326. su.username_,
  327. su.real_name_,
  328. t.organ_id_
  329. FROM
  330. teacher t
  331. LEFT JOIN sys_user su ON t.id_ = su.id_
  332. WHERE
  333. FIND_IN_SET(#{subjectId},t.subject_id_)
  334. AND (t.organ_id_=#{organId} OR FIND_IN_SET(#{organId},t.flow_organ_range_))
  335. AND t.job_nature_='FULL_TIME'
  336. AND su.del_flag_=0 AND su.lock_flag_=0
  337. AND t.organ_id_!=36
  338. </select>
  339. <select id="findTeaTeachersByOrganAndSubject1" resultMap="ExtendTeacherBasicDto">
  340. SELECT
  341. su.id_,
  342. su.username_,
  343. su.real_name_,
  344. t.organ_id_,
  345. t.is_support_extra_practice_lesson_
  346. FROM
  347. teacher t
  348. LEFT JOIN sys_user su ON t.id_ = su.id_
  349. WHERE
  350. FIND_IN_SET(#{subjectId},t.subject_id_)
  351. AND (t.organ_id_=#{organId} OR FIND_IN_SET(#{organId},t.flow_organ_range_))
  352. AND t.job_nature_='FULL_TIME'
  353. AND su.del_flag_=0 AND su.lock_flag_=0
  354. AND t.organ_id_!=36
  355. </select>
  356. <select id="findTeaTeachersByOrganAndSubject2" resultMap="ExtendTeacherBasicDto">
  357. SELECT
  358. su.id_,
  359. su.username_,
  360. su.real_name_,
  361. su.avatar_,
  362. t.introduction_,
  363. t.organ_id_,
  364. t.is_support_extra_practice_lesson_,
  365. GROUP_CONCAT(s.name_) subject_names_
  366. FROM
  367. teacher t
  368. LEFT JOIN sys_user su ON t.id_ = su.id_
  369. LEFT JOIN subject s ON FIND_IN_SET(s.id_,t.subject_id_)
  370. WHERE
  371. FIND_IN_SET(#{subjectId},t.subject_id_)
  372. AND (t.organ_id_=#{organId} OR FIND_IN_SET(#{organId},t.flow_organ_range_))
  373. AND t.job_nature_='FULL_TIME'
  374. AND su.del_flag_=0 AND su.lock_flag_=0
  375. AND t.organ_id_!=36
  376. GROUP BY su.id_
  377. </select>
  378. <select id="findTeacherByOrganAndSubject" resultMap="TeacherBasicDto">
  379. SELECT
  380. su.id_,
  381. su.username_,
  382. su.real_name_,
  383. t.organ_id_
  384. FROM
  385. teacher t
  386. LEFT JOIN sys_user su ON t.id_ = su.id_
  387. WHERE
  388. FIND_IN_SET(#{subjectIds},t.subject_id_)
  389. AND INTE_ARRAY ( CONCAT( t.organ_id_, IF(t.flow_organ_range_ IS NULL,'',CONCAT(',', t.flow_organ_range_)) ), #{organIds} )
  390. </select>
  391. <select id="findByTeacherId" resultMap="TeacherBasicDto">
  392. SELECT
  393. su.id_,
  394. su.username_,
  395. su.real_name_,
  396. t.organ_id_
  397. FROM
  398. teacher t
  399. LEFT JOIN sys_user su ON t.id_ = su.id_
  400. WHERE
  401. t.id_=#{teacherId}
  402. </select>
  403. <select id="countCloses" resultType="java.lang.Integer">
  404. SELECT COUNT(cs.id_)
  405. FROM course_schedule cs
  406. LEFT JOIN course_schedule_teacher_salary csts ON cs.id_ = csts.course_schedule_id_
  407. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_ AND ta.teacher_id_ = csts.user_id_
  408. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  409. <include refid="queryCloses"/>
  410. </select>
  411. <resultMap id="TeacherCloseDto" type="com.ym.mec.biz.dal.dto.TeacherCloseDto">
  412. <result property="classDate" column="class_date_"/>
  413. <result property="classTime" column="start_class_time_"/>
  414. <result property="className" column="class_name_"/>
  415. <result property="courseScheduleType" column="class_type_"/>
  416. <result property="teacherRole" column="teacher_role_"/>
  417. <result property="currentClassTimes" column="current_class_times_"/>
  418. <result property="totalClassTimes" column="total_class_times_"/>
  419. <result property="signInStatus" column="sign_in_status_"/>
  420. <result property="signOutStatus" column="sign_out_status_"/>
  421. <result property="actualSalary" column="actual_salary_"/>
  422. <result property="expectSalary" column="expect_salary_"/>
  423. <result property="subsidy" column="subsidy_"/>
  424. <result property="settlementTime" column="settlement_time_"/>
  425. <result property="courseScheduleId" column="course_schedule_id_"/>
  426. </resultMap>
  427. <select id="queryCloses" resultMap="TeacherCloseDto">
  428. SELECT cs.id_ course_schedule_id_,cs.class_date_,cs.start_class_time_,cg.name_ class_name_,cs.type_ class_type_,
  429. csts.teacher_role_,ta.current_class_times_,cg.total_class_times_,
  430. IF(ta.sign_in_status_ IS NULL,3,ta.sign_in_status_) sign_in_status_,
  431. IF(ta.sign_out_status_ IS NULL,3,ta.sign_out_status_) sign_out_status_,
  432. csts.actual_salary_,csts.settlement_time_,csts.subsidy_,csts.expect_salary_
  433. FROM course_schedule cs
  434. LEFT JOIN course_schedule_teacher_salary csts ON cs.id_ = csts.course_schedule_id_
  435. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_ AND ta.teacher_id_ = csts.user_id_
  436. LEFT JOIN class_group cg ON cs.class_group_id_ = cg.id_
  437. <include refid="queryCloses"/>
  438. ORDER BY cs.class_date_,cs.start_class_time_ DESC
  439. <include refid="global.limit"/>
  440. </select>
  441. <select id="findTeacherNoPay" resultType="decimal">
  442. SELECT SUM(expect_salary_) FROM course_schedule_teacher_salary csts WHERE settlement_time_ IS NULL AND user_id_
  443. = #{teacherId}
  444. </select>
  445. <select id="findTeacherByMusicGroup" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  446. SELECT
  447. su.id_ user_id_,
  448. su.real_name_ username_
  449. FROM
  450. class_group_teacher_mapper cgtm
  451. LEFT JOIN class_group cg ON cg.id_=cgtm.class_group_id_
  452. LEFT JOIN sys_user su ON cgtm.user_id_=su.id_
  453. WHERE cg.music_group_id_=#{musicGroupId} AND cg.group_type_='MUSIC'
  454. GROUP BY su.id_
  455. </select>
  456. <resultMap id="MusicGroupTeachersDto" type="com.ym.mec.biz.dal.dto.MusicGroupTeachersDto">
  457. <result property="teacherName" column="real_name_"/>
  458. <result property="teacherPhone" column="phone_"/>
  459. <result property="jobNature" column="job_nature_"/>
  460. <result property="classGroupName" column="class_group_name_"/>
  461. <result property="classGroupId" column="class_group_id_"/>
  462. <result property="teacherId" column="teacher_id_"/>
  463. </resultMap>
  464. <select id="queryMusicGroupTeachers" resultMap="MusicGroupTeachersDto">
  465. SELECT su.real_name_,su.phone_,t.job_nature_,GROUP_CONCAT(cg.name_) class_group_name_,t.id_ teacher_id_
  466. FROM teacher t
  467. LEFT JOIN class_group_teacher_mapper cgtm ON t.id_ = cgtm.user_id_
  468. LEFT JOIN class_group cg ON cg.id_ = cgtm.class_group_id_
  469. LEFT JOIN sys_user su ON t.id_ = su.id_
  470. WHERE cg.del_flag_ != '1' AND cgtm.group_type_ = 'MUSIC'
  471. <include refid="queryMusicGroupTeachersSql"/>
  472. GROUP BY t.id_
  473. <include refid="global.limit"/>
  474. </select>
  475. <select id="countMusicGroupTeachers" resultType="java.lang.Integer">
  476. SELECT COUNT(DISTINCT t.id_)
  477. FROM teacher t
  478. LEFT JOIN class_group_teacher_mapper cgtm ON t.id_ = cgtm.user_id_
  479. LEFT JOIN class_group cg ON cg.id_ = cgtm.class_group_id_
  480. LEFT JOIN sys_user su ON t.id_ = su.id_
  481. WHERE cg.del_flag_ != '1' AND cgtm.group_type_ = 'MUSIC'
  482. <include refid="queryMusicGroupTeachersSql"/>
  483. </select>
  484. <sql id="queryMusicGroupTeachersSql">
  485. <if test="search != null and search != ''">
  486. AND (su.real_name_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%') OR
  487. su.id_=#{search})
  488. </if>
  489. <if test="musicGroupId != null and musicGroupId != ''">
  490. AND cgtm.music_group_id_ = #{musicGroupId}
  491. </if>
  492. <if test="classGroupId != null">
  493. AND cg.id_ = #{classGroupId}
  494. </if>
  495. </sql>
  496. <select id="findSignNum" resultType="java.util.Map">
  497. SELECT ta.teacher_id_ 'key',COUNT(ta.id_) 'value' FROM teacher_attendance ta
  498. WHERE FIND_IN_SET(ta.teacher_id_,#{teacherIdStr}) AND ta.music_group_id_ = #{musicGroupId}
  499. GROUP BY ta.teacher_id_
  500. </select>
  501. <sql id="queryTeacherAttendanceSql">
  502. <where>
  503. CONCAT(cs.class_date_,' ',cs.start_class_time_) &lt; NOW() AND cgtm.teacher_role_ = 'BISHOP'
  504. <if test="startTime != null and startTime != ''">
  505. AND cs.class_date_ &gt;= #{startTime}
  506. </if>
  507. <if test="endTime != null and endTime != ''">
  508. AND cs.class_date_ &lt;= #{endTime}
  509. </if>
  510. <if test="musicGroupId != null and musicGroupId != ''">
  511. AND ta.music_group_id_ = #{musicGroupId}
  512. </if>
  513. <if test="teacherName != null and teacherName != ''">
  514. AND su.real_name_ LIKE CONCAT('%',#{teacherName},'%')
  515. </if>
  516. </where>
  517. </sql>
  518. <resultMap id="MusicGroupTeacherAttendanceDto" type="com.ym.mec.biz.dal.dto.MusicGroupTeacherAttendanceDto">
  519. <result property="classDate" column="class_date_"/>
  520. <result property="startClassTime" column="start_class_time_"/>
  521. <result property="courseScheduleName" column="name_"/>
  522. <result property="realName" column="real_name_"/>
  523. <result property="signInStatus" column="sign_in_status_"/>
  524. <result property="signOutStatus" column="sign_out_status_"/>
  525. </resultMap>
  526. <select id="queryTeacherAttendance" resultMap="MusicGroupTeacherAttendanceDto">
  527. SELECT cs.class_date_,cs.start_class_time_,cs.name_,su.real_name_,
  528. IF(ta.sign_in_status_ IS NULL,3,ta.sign_in_status_) sign_in_status_,
  529. IF(ta.sign_out_status_ IS NULL,3,ta.sign_out_status_) sign_out_status_
  530. FROM course_schedule cs
  531. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_
  532. LEFT JOIN sys_user su ON su.id_ = ta.teacher_id_
  533. LEFT JOIN class_group_teacher_mapper cgtm ON cgtm.class_group_id_ = cs.class_group_id_ AND ta.teacher_id_ = cgtm.user_id_
  534. <include refid="queryTeacherAttendanceSql"/>
  535. ORDER BY cs.class_date_ DESC,cs.start_class_time_ DESC
  536. <include refid="global.limit"/>
  537. </select>
  538. <select id="countTeacherAttendance" resultType="java.lang.Integer">
  539. SELECT COUNT(cs.id_)
  540. FROM course_schedule cs
  541. LEFT JOIN teacher_attendance ta ON cs.id_ = ta.course_schedule_id_
  542. LEFT JOIN sys_user su ON su.id_ = ta.teacher_id_
  543. LEFT JOIN class_group_teacher_mapper cgtm ON cgtm.class_group_id_ = cs.class_group_id_ AND ta.teacher_id_ = cgtm.user_id_
  544. <include refid="queryTeacherAttendanceSql"/>
  545. </select>
  546. <select id="queryNameById" resultType="java.lang.String">
  547. select real_name_ FROM sys_user s WHERE id_ = #{userId} LIMIT 1
  548. </select>
  549. <resultMap id="musicGroupStudentApplyDto" type="com.ym.mec.biz.dal.dto.musicGroupStudentApplyDto">
  550. <result property="userId" column="user_id_"/>
  551. <result property="userName" column="username_"/>
  552. <result property="currentClass" column="current_class_"/>
  553. <result property="currentGrade" column="current_grade_"/>
  554. <result property="subjectName" column="subject_name_"/>
  555. <result property="subjectId" column="actual_subject_id_"/>
  556. <result property="paymentAmount" column="actual_amount_"/>
  557. <result property="payTime" column="pay_time_"/>
  558. <result property="paymentStatus" column="payment_status_"/>
  559. <result property="remark" column="remark_"/>
  560. </resultMap>
  561. <select id="queryMusicGroupStudentApply" resultMap="musicGroupStudentApplyDto">
  562. SELECT sr.user_id_,su.username_,sr.current_class_,sr.current_grade_,s.name_ subject_name_,sr.remark_,
  563. sr.payment_status_,sr.actual_subject_id_
  564. FROM student_registration sr
  565. LEFT JOIN sys_user su ON sr.user_id_ = su.id_
  566. LEFT JOIN `subject` s ON sr.actual_subject_id_ = s.id_
  567. <include refid="queryMusicGroupStudentApplySql"/>
  568. <include refid="global.limit"/>
  569. </select>
  570. <sql id="queryMusicGroupStudentApplySql">
  571. <where>
  572. sr.music_group_id_ = #{musicGroupId} AND sr.music_group_status_ != 'QUIT'
  573. <if test="subjectId != null">
  574. AND sr.actual_subject_id_ = #{subjectId}
  575. </if>
  576. <if test="paymentStatus != null">
  577. AND sr.payment_status_ = #{paymentStatus}
  578. </if>
  579. </where>
  580. </sql>
  581. <select id="countMusicGroupStudentApply" resultType="java.lang.Integer">
  582. SELECT COUNT(sr.user_id_)
  583. FROM student_registration sr
  584. LEFT JOIN sys_user su ON sr.user_id_ = su.id_
  585. LEFT JOIN `subject` s ON sr.actual_subject_id_ = s.id_
  586. <include refid="queryMusicGroupStudentApplySql"/>
  587. </select>
  588. <select id="queryMusicGroupStudents" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  589. SELECT su.real_name_ username_,su.id_ user_id_,su.avatar_ head_url_,
  590. su.gender_,GROUP_CONCAT(s.name_) subject_name_,su.user_type_
  591. FROM teacher t
  592. LEFT JOIN sys_user su ON t.id_ = su.id_
  593. LEFT JOIN `subject` s ON FIND_IN_SET(s.id_,t.subject_id_)
  594. WHERE FIND_IN_SET(t.id_,#{teacherIds})
  595. <if test="search != null">
  596. AND su.real_name_ LIKE CONCAT('%',#{search},'%')
  597. </if>
  598. GROUP BY t.id_
  599. </select>
  600. <select id="findOrganTeacherBySubject" resultMap="Teacher">
  601. SELECT su.* FROM teacher t
  602. LEFT JOIN sys_user su on t.id_ = su.id_ WHERE 1=1
  603. <if test="subjectId != null">
  604. AND FIND_IN_SET(#{subjectId},t.subject_id_)
  605. </if>
  606. </select>
  607. <sql id="queryCloses">
  608. <where>
  609. CONCAT(cs.class_date_,' ',cs.start_class_time_) &lt; NOW()
  610. <if test="teacherId != null">
  611. AND csts.user_id_ = #{teacherId}
  612. </if>
  613. <if test="courseStartDate != null and courseStartDate != ''">
  614. AND cs.class_date_ &gt;= #{courseStartDate}
  615. </if>
  616. <if test="courseEndDate != null and courseEndDate != ''">
  617. AND cs.class_date_ &lt;= #{courseEndDate}
  618. </if>
  619. <if test="courseScheduleType != null and courseScheduleType != ''">
  620. AND cs.type_ = #{courseScheduleType}
  621. </if>
  622. <if test="teacherRole != null and teacherRole != ''">
  623. AND csts.teacher_role_ = #{teacherRole}
  624. </if>
  625. <if test="signInStatus != null and signInStatus != 3">
  626. AND ta.sign_in_status_ = #{signInStatus}
  627. </if>
  628. <if test="signOutStatus != null and signOutStatus != 3">
  629. AND ta.sign_out_status_ = #{signOutStatus}
  630. </if>
  631. <if test="signOutStatus != null and signOutStatus == 3">
  632. AND ta.sign_out_status_ IS NULL
  633. </if>
  634. <if test="signInStatus != null and signInStatus == 3">
  635. AND ta.sign_in_status_ IS NULL
  636. </if>
  637. </where>
  638. </sql>
  639. <select id="queryOrganTeacherNum" resultType="map">
  640. select count(*) total,sum(case when job_nature_ = 'PART_TIME' then 1 else 0 end) part_time_num_,sum(case when
  641. job_nature_ = 'FULL_TIME' then 1 else 0 end) full_time_num_ from teacher
  642. where demission_date_ is null and organ_id_ not in (36,38)
  643. <if test="organId != null">
  644. and FIND_IN_SET(organ_id_,#{organId})
  645. </if>
  646. </select>
  647. <select id="findByFlowOrganRange" resultMap="Teacher">
  648. SELECT id_,CONCAT(IF(flow_organ_range_ IS NULL OR flow_organ_range_ = '',0,flow_organ_range_),",",
  649. IF(organ_id_ IS NULL OR organ_id_ = '',0,organ_id_)) flow_organ_range_ FROM teacher t
  650. <where>
  651. <if test="subjectId != null">
  652. AND FIND_IN_SET(#{subjectId},t.subject_id_)
  653. </if>
  654. <if test="jobNature != null">
  655. AND t.job_nature_ = #{jobNature}
  656. </if>
  657. <if test="isProbationPeriod != null">
  658. AND t.is_probation_period_ = #{isProbationPeriod}
  659. </if>
  660. <if test="isSupportExtraPracticeLesson != null">
  661. AND t.is_support_extra_practice_lesson_ = #{isSupportExtraPracticeLesson}
  662. </if>
  663. </where>
  664. </select>
  665. <select id="findByTeacherIds" resultMap="Teacher">
  666. SELECT * FROM teacher WHERE id_ IN
  667. <foreach collection="teacherIds" item="teacherId" open="(" close=")" separator=",">
  668. #{teacherId}
  669. </foreach>
  670. </select>
  671. <select id="findTeacherByOrganId" resultMap="TeacherBasicDto">
  672. SELECT su.id_,su.username_,su.real_name_ FROM teacher t
  673. LEFT JOIN sys_user su ON t.id_ = su.id_
  674. WHERE su.del_flag_ != 1
  675. <if test="organId != null">
  676. AND FIND_IN_SET(t.organ_id_,#{organId})
  677. </if>
  678. <if test="subjectIds != null">
  679. AND INTE_ARRAY(t.subject_id_,#{subjectIds})
  680. </if>
  681. <if test="jobNature != null">
  682. AND t.job_nature_ = #{jobNature}
  683. </if>
  684. </select>
  685. <select id="queryUsernameByIds" resultType="java.util.Map" parameterType="list">
  686. select id_ `key`,username_ `value` FROM sys_user s
  687. WHERE s.id_ IN
  688. <foreach collection="userIds" item="item" open="(" close=")" separator=",">
  689. #{item}
  690. </foreach>
  691. </select>
  692. <select id="searchTeachers" resultMap="TeacherBasicDto">
  693. SELECT su.id_,su.username_,su.real_name_ FROM teacher t
  694. LEFT JOIN sys_user su ON t.id_ = su.id_
  695. WHERE su.del_flag_ != 1
  696. <if test="organId != null">
  697. AND FIND_IN_SET(t.organ_id_,#{organId})
  698. </if>
  699. <if test="teacherName != null">
  700. AND su.real_name_ LIKE CONCAT('%',#{teacherName},'%')
  701. </if>
  702. </select>
  703. <select id="countTeacherName" resultType="java.lang.Integer">
  704. SELECT COUNT(su.id_) FROM teacher t
  705. LEFT JOIN sys_user su ON t.id_ = su.id_
  706. WHERE su.del_flag_ != 1
  707. <include refid="queryPageNameSql"/>
  708. </select>
  709. <sql id="queryPageNameSql">
  710. <if test="organId != null">
  711. AND FIND_IN_SET(t.organ_id_,#{organId})
  712. </if>
  713. <if test="subjectIds != null">
  714. AND INTE_ARRAY(t.subject_id_,#{subjectIds})
  715. </if>
  716. <if test="jobNature != null">
  717. AND t.job_nature_ = #{jobNature}
  718. </if>
  719. <if test="teacherId != null">
  720. AND t.id_ = #{teacherId}
  721. </if>
  722. <if test="search != null">
  723. AND (su.real_name_ LIKE CONCAT('%',#{search},'%') OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  724. </if>
  725. </sql>
  726. <select id="queryPageName" resultMap="Teacher">
  727. SELECT su.id_,su.real_name_,su.avatar_,GROUP_CONCAT(s.name_) subject_name_ FROM teacher t
  728. LEFT JOIN sys_user su ON t.id_ = su.id_
  729. LEFT JOIN subject s ON FIND_IN_SET(s.id_, t.subject_id_)
  730. WHERE su.del_flag_ != 1
  731. <include refid="queryPageNameSql"/>
  732. GROUP BY su.id_
  733. <include refid="global.limit"/>
  734. </select>
  735. <select id="getCourseScheduleHomework" resultMap="com.ym.mec.biz.dal.dao.CourseHomeworkDao.CourseHomework">
  736. SELECT * FROM course_homework WHERE course_schedule_id_ = #{courseScheduleId} LIMIT 1
  737. </select>
  738. <select id="lockTeachers" resultType="int">
  739. SELECT id_ FROM teacher WHERE id_ IN
  740. <foreach collection="userIds" item="userId" open="(" close=")" separator=",">
  741. #{userId}
  742. </foreach>
  743. FOR UPDATE
  744. </select>
  745. <resultMap type="com.ym.mec.auth.api.entity.SysUser" id="SysUser">
  746. <result column="id_" property="id"/>
  747. <result column="username_" property="username"/>
  748. <result column="real_name_" property="realName"/>
  749. <result column="password_" property="password"/>
  750. <result column="salt_" property="salt"/>
  751. <result column="phone_" property="phone"/>
  752. <result column="avatar_" property="avatar"/>
  753. <result column="organ_id_" property="organId"/>
  754. <result column="create_time_" property="createTime"/>
  755. <result column="update_time_" property="updateTime"/>
  756. <result column="lock_flag_" property="lockFlag"/>
  757. <result column="del_flag_" property="delFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  758. <result column="wx_openid_" property="wxOpenid"/>
  759. <result column="qq_openid_" property="qqOpenid"/>
  760. <result column="user_type_" property="userType"/>
  761. <result column="gender_" property="gender"/>
  762. <result column="nation_" property="nation"/>
  763. <result column="birthdate_" property="birthdate"/>
  764. <result column="email_" property="email"/>
  765. <result column="im_token_" property="imToken"/>
  766. <result column="id_card_no_" property="idCardNo"/>
  767. <result column="wechat_id_" property="wechatId"/>
  768. <result column="is_super_admin_" property="isSuperAdmin"/>
  769. <result column="current_grade_" property="currentGrade"/>
  770. <result column="current_class_" property="currentClass"/>
  771. </resultMap>
  772. <select id="getUser" resultMap="SysUser">
  773. SELECT su.*
  774. FROM sys_user su
  775. WHERE su.id_ = #{id} LIMIT 1
  776. </select>
  777. <select id="queryTeacherBaseInfo" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  778. SELECT
  779. CASE WHEN su.user_type_ LIKE '%TEACHER%' OR su.user_type_ LIKE '%SYSTEM%' THEN su.real_name_ ELSE su.username_ END username_,
  780. su.id_ user_id_,
  781. su.avatar_ head_url_,
  782. gender_,
  783. GROUP_CONCAT(s.name_) subject_name_
  784. FROM sys_user su
  785. LEFT JOIN teacher t ON su.id_ = t.id_
  786. LEFT JOIN `subject` s ON FIND_IN_SET(s.id_,t.subject_id_)
  787. WHERE su.id_ IN
  788. <foreach collection="teacherId" item="userId" open="(" close=")" separator=",">
  789. #{userId}
  790. </foreach>
  791. <if test="search != null and search != ''">
  792. AND su.real_name_ LIKE CONCAT('%',#{search},'%')
  793. </if>
  794. GROUP BY su.id_
  795. </select>
  796. <select id="queryTeacherImModel" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.ImUserModel">
  797. SELECT su.id_,su.avatar_,su.real_name_ username_
  798. FROM sys_user su
  799. WHERE su.id_ IN
  800. <foreach collection="teacherIds" item="userId" open="(" close=")" separator=",">
  801. #{userId}
  802. </foreach>
  803. </select>
  804. <select id="findMusicTeacherIds" resultType="java.lang.Integer">
  805. SELECT DISTINCT cgtm.user_id_ FROM class_group_student_mapper cgsm
  806. LEFT JOIN class_group_teacher_mapper cgtm ON cgsm.class_group_id_ = cgtm.class_group_id_
  807. LEFT JOIN music_group mg ON cgsm.music_group_id_ = mg.id_
  808. WHERE mg.status_ = 'PROGRESS' AND cgsm.user_id_ = #{studentId}
  809. </select>
  810. <select id="findVipTeacherIds" resultType="java.lang.Integer">
  811. SELECT DISTINCT cgtm.user_id_ FROM class_group_student_mapper cgsm
  812. LEFT JOIN class_group_teacher_mapper cgtm ON cgsm.class_group_id_ = cgtm.class_group_id_
  813. LEFT JOIN vip_group vg ON vg.id_ = cgsm.music_group_id_
  814. WHERE vg.group_status_ IN (2,3,4) AND cgsm.user_id_ = #{studentId}
  815. </select>
  816. <select id="findPracticeTeacherIds" resultType="java.lang.Integer">
  817. SELECT DISTINCT cgtm.user_id_ FROM class_group_student_mapper cgsm
  818. LEFT JOIN class_group_teacher_mapper cgtm ON cgsm.class_group_id_ = cgtm.class_group_id_
  819. LEFT JOIN practice_group pg ON pg.id_ = cgsm.music_group_id_
  820. WHERE cgsm.group_type_ = 'PRACTICE' AND cgsm.user_id_ = #{studentId}
  821. </select>
  822. <select id="findTeacherInfo" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  823. SELECT
  824. su.real_name_ username_,
  825. su.id_ user_id_,
  826. su.avatar_ head_url_,
  827. gender_,
  828. GROUP_CONCAT(s.name_) subject_name_
  829. FROM sys_user su
  830. LEFT JOIN teacher t ON su.id_ = t.id_
  831. LEFT JOIN `subject` s ON FIND_IN_SET(s.id_,t.subject_id_)
  832. WHERE su.id_ = #{id}
  833. </select>
  834. <select id="queryEducationIpa" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  835. SELECT su.real_name_ username_,su.id_ user_id_,su.avatar_ head_url_,su.gender_,GROUP_CONCAT(s.name_) subject_name_,su.user_type_
  836. FROM employee e
  837. LEFT JOIN teacher t ON INTE_ARRAY(e.organ_id_list_,t.flow_organ_range_) OR FIND_IN_SET(t.organ_id_,e.organ_id_list_)
  838. LEFT JOIN sys_user su ON t.id_ = su.id_
  839. LEFT JOIN `subject` s ON FIND_IN_SET(s.id_,t.subject_id_)
  840. WHERE e.user_id_ = #{userId}
  841. <if test="search != null and search != ''">
  842. AND su.real_name_ LIKE CONCAT('%',#{search},'%')
  843. </if>
  844. GROUP BY t.id_
  845. UNION ALL
  846. SELECT su.username_,su.id_ user_id_,su.avatar_ head_url_,su.gender_,NULL subject_name_,su.user_type_
  847. FROM employee e
  848. LEFT JOIN sys_user su ON FIND_IN_SET(su.organ_id_,e.organ_id_list_)
  849. LEFT JOIN student_registration sr ON su.id_ = sr.user_id_
  850. LEFT JOIN music_group mg ON mg.id_ = sr.music_group_id_
  851. WHERE e.user_id_ = #{userId} AND (sr.id_ IS NULL OR sr.music_group_status_ = 'QUIT' OR mg.status_ != 'PROGRESS')
  852. <if test="search != null and search != ''">
  853. AND su.username_ LIKE CONCAT('%',#{search},'%')
  854. </if>
  855. GROUP BY su.id_
  856. </select>
  857. <select id="findCloseCourseTeacherIds" resultType="java.lang.Integer">
  858. SELECT DISTINCT csts.user_id_ FROM course_schedule_student_payment cssp
  859. LEFT JOIN course_schedule cs ON cs.id_ = cssp.course_schedule_id_
  860. LEFT JOIN course_schedule_teacher_salary csts ON csts.course_schedule_id_ = cs.id_
  861. WHERE cssp.group_type_ IN ('VIP','PRACTICE') AND cs.status_ = 'OVER' AND cssp.user_id_ = #{studentId}
  862. </select>
  863. <select id="findCloseCourseStudentIds" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  864. SELECT su.username_,su.id_ user_id_,su.avatar_ head_url_,su.gender_,NULL subject_name_,su.user_type_
  865. FROM course_schedule_teacher_salary csts
  866. LEFT JOIN course_schedule cs ON csts.course_schedule_id_ = cs.id_
  867. LEFT JOIN course_schedule_student_payment cssp ON cs.id_ = cssp.course_schedule_id_
  868. LEFT JOIN sys_user su ON su.id_ = cssp.user_id_
  869. WHERE csts.group_type_ IN ('VIP','PRACTICE') AND cs.status_ = 'OVER' AND csts.user_id_ = #{teacherId} AND su.id_ IS NOT NULL
  870. <if test="search != null and search != ''">
  871. AND su.username_ LIKE CONCAT('%',#{search},'%')
  872. </if>
  873. GROUP BY su.id_
  874. </select>
  875. <select id="findVipEducationalStudentId" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  876. SELECT su.username_,su.id_ user_id_,su.avatar_ head_url_,su.gender_,NULL subject_name_,su.user_type_
  877. FROM vip_group vg
  878. LEFT JOIN course_schedule_student_payment cssp ON cssp.music_group_id_ = vg.id_
  879. LEFT JOIN sys_user su ON su.id_ = cssp.user_id_
  880. WHERE cssp.group_type_ = 'VIP' AND vg.educational_teacher_id_ = #{teacherId}
  881. GROUP BY su.id_
  882. </select>
  883. <select id="findCommEducationalStudentId" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  884. SELECT su.username_,su.id_ user_id_,su.avatar_ head_url_,su.gender_,NULL subject_name_,su.user_type_
  885. FROM courses_group vg
  886. LEFT JOIN course_schedule_student_payment cssp ON cssp.music_group_id_ = vg.id_
  887. LEFT JOIN sys_user su ON su.id_ = cssp.user_id_
  888. WHERE cssp.group_type_ = 'COMM' AND vg.educational_teacher_id_ = #{teacherId}
  889. GROUP BY su.id_
  890. </select>
  891. <select id="findPracticeEducationalStudentId" resultMap="com.ym.mec.biz.dal.dao.MusicGroupDao.BasicUserDto">
  892. SELECT su.username_,su.id_ user_id_,su.avatar_ head_url_,su.gender_,NULL subject_name_,su.user_type_
  893. FROM practice_group pg
  894. LEFT JOIN course_schedule_student_payment cssp ON cssp.music_group_id_ = pg.id_
  895. LEFT JOIN sys_user su ON su.id_ = cssp.user_id_
  896. WHERE cssp.group_type_ = 'PRACTICE' AND pg.educational_teacher_id_ = #{teacherId}
  897. GROUP BY su.id_
  898. </select>
  899. <select id="findPracticeEducationalTeacherId" resultType="java.lang.Integer">
  900. SELECT DISTINCT pg.educational_teacher_id_ FROM class_group_student_mapper cgsm
  901. LEFT JOIN class_group_teacher_mapper cgtm ON cgsm.class_group_id_ = cgtm.class_group_id_
  902. LEFT JOIN practice_group pg ON pg.id_ = cgsm.music_group_id_
  903. WHERE cgsm.group_type_ = 'PRACTICE' AND cgsm.user_id_ = #{userId}
  904. </select>
  905. <select id="findVipEducationalTeacherId" resultType="java.lang.Integer">
  906. SELECT DISTINCT vg.educational_teacher_id_ FROM class_group_student_mapper cgsm
  907. LEFT JOIN class_group_teacher_mapper cgtm ON cgsm.class_group_id_ = cgtm.class_group_id_
  908. LEFT JOIN vip_group vg ON vg.id_ = cgsm.music_group_id_
  909. WHERE cgsm.group_type_ = 'VIP' AND cgsm.user_id_ = #{userId}
  910. </select>
  911. <select id="findCommEducationalTeacherId" resultType="java.lang.Integer">
  912. SELECT DISTINCT vg.educational_teacher_id_ FROM class_group_student_mapper cgsm
  913. LEFT JOIN class_group_teacher_mapper cgtm ON cgsm.class_group_id_ = cgtm.class_group_id_
  914. LEFT JOIN courses_group vg ON vg.id_ = cgsm.music_group_id_
  915. WHERE cgsm.group_type_ = 'COMM' AND cgsm.user_id_ = #{userId}
  916. </select>
  917. <select id="queryCourseClassStudentIds" resultType="java.lang.Integer">
  918. SELECT cgsm.user_id_ FROM course_schedule_teacher_salary csts
  919. LEFT JOIN class_group_student_mapper cgsm ON csts.class_group_id_ = cgsm.class_group_id_
  920. WHERE csts.user_id_ = #{teacherId}
  921. GROUP BY cgsm.user_id_
  922. UNION ALL
  923. SELECT cgsm.user_id_ FROM class_group_teacher_mapper cgtm
  924. LEFT JOIN class_group_student_mapper cgsm ON cgtm.class_group_id_ = cgsm.class_group_id_
  925. WHERE cgtm.user_id_ = #{teacherId}
  926. GROUP BY cgsm.user_id_
  927. UNION ALL
  928. SELECT cssp.user_id_ FROM music_group mg
  929. LEFT JOIN course_schedule_student_payment cssp ON mg.id_ = cssp.music_group_id_
  930. WHERE (mg.educational_teacher_id_ = #{teacherId} OR mg.director_user_id_ = #{teacherId} OR mg.team_teacher_id_ = #{teacherId})
  931. AND cssp.group_type_ = 'MUSIC' AND mg.status_ = 'PROGRESS'
  932. UNION ALL
  933. SELECT cgsm.user_id_ FROM vip_group vg
  934. LEFT JOIN class_group_student_mapper cgsm ON vg.id_ = cgsm.music_group_id_
  935. WHERE vg.educational_teacher_id_ = #{teacherId} AND cgsm.group_type_ = 'VIP' AND vg.group_status_ IN (2,3,4)
  936. UNION ALL
  937. SELECT cssp.user_id_ FROM courses_group cg
  938. LEFT JOIN course_schedule_student_payment cssp ON cg.id_ = cssp.music_group_id_
  939. WHERE cg.educational_teacher_id_ = #{teacherId} AND cssp.group_type_ = 'COMM'
  940. UNION ALL
  941. SELECT cssp.user_id_ FROM practice_group pg
  942. LEFT JOIN course_schedule_student_payment cssp ON pg.id_ = cssp.music_group_id_
  943. WHERE pg.educational_teacher_id_ = #{teacherId} AND cssp.group_type_ = 'PRACTICE'
  944. </select>
  945. <select id="queryCourseClassTeacherIds" resultType="java.lang.Integer">
  946. SELECT csts.user_id_ FROM music_group mg
  947. LEFT JOIN course_schedule_teacher_salary csts ON mg.id_ = csts.music_group_id_
  948. WHERE csts.group_type_ = 'MUSIC' AND (mg.educational_teacher_id_ = #{teacherId} OR mg.director_user_id_ = #{teacherId} OR mg.team_teacher_id_ = #{teacherId})
  949. GROUP BY csts.user_id_
  950. UNION ALL
  951. SELECT csts.user_id_ FROM vip_group vg
  952. LEFT JOIN course_schedule_teacher_salary csts ON vg.id_ = csts.music_group_id_
  953. WHERE vg.educational_teacher_id_ = #{teacherId} AND csts.group_type_ = 'VIP' AND vg.group_status_ IN (2,3,4)
  954. GROUP BY csts.user_id_
  955. UNION ALL
  956. SELECT csts.user_id_ FROM courses_group cg
  957. LEFT JOIN course_schedule_teacher_salary csts ON cg.id_ = csts.music_group_id_
  958. WHERE cg.educational_teacher_id_ = #{teacherId} AND csts.group_type_ = 'COMM'
  959. GROUP BY csts.user_id_
  960. UNION ALL
  961. SELECT csts.user_id_ FROM practice_group pg
  962. LEFT JOIN course_schedule_teacher_salary csts ON pg.id_ = csts.music_group_id_
  963. WHERE pg.educational_teacher_id_ = #{teacherId} AND csts.group_type_ = 'PRACTICE'
  964. GROUP BY csts.user_id_
  965. UNION ALL
  966. SELECT cgtm.user_id_ FROM music_group mg
  967. LEFT JOIN class_group_teacher_mapper cgtm ON mg.id_ = cgtm.music_group_id_
  968. WHERE cgtm.group_type_ = 'MUSIC' AND mg.status_ = 'PROGRESS'
  969. AND (mg.educational_teacher_id_ = #{teacherId} OR mg.director_user_id_ = #{teacherId} OR mg.team_teacher_id_ = #{teacherId})
  970. GROUP BY cgtm.user_id_
  971. UNION ALL
  972. SELECT cgtm.user_id_ FROM vip_group vg
  973. LEFT JOIN class_group_teacher_mapper cgtm ON vg.id_ = cgtm.music_group_id_
  974. WHERE vg.educational_teacher_id_ = #{teacherId} AND cgtm.group_type_ = 'VIP' AND vg.group_status_ IN (2,3,4)
  975. GROUP BY cgtm.user_id_
  976. UNION ALL
  977. SELECT cgtm.user_id_ FROM courses_group cg
  978. LEFT JOIN class_group_teacher_mapper cgtm ON cg.id_ = cgtm.music_group_id_
  979. WHERE cg.educational_teacher_id_ = #{teacherId} AND cgtm.group_type_ = 'COMM'
  980. GROUP BY cgtm.user_id_
  981. UNION ALL
  982. SELECT cgtm.user_id_ FROM practice_group pg
  983. LEFT JOIN class_group_teacher_mapper cgtm ON pg.id_ = cgtm.music_group_id_
  984. WHERE pg.educational_teacher_id_ = #{teacherId} AND cgtm.group_type_ = 'PRACTICE'
  985. GROUP BY cgtm.user_id_
  986. UNION ALL
  987. SELECT vg.educational_teacher_id_ FROM class_group_teacher_mapper cgtm
  988. LEFT JOIN vip_group vg ON vg.id_ = cgtm.music_group_id_
  989. WHERE cgtm.user_id_ = #{teacherId} AND cgtm.group_type_ = 'VIP' AND vg.group_status_ IN (2,3,4)
  990. GROUP BY vg.educational_teacher_id_
  991. UNION ALL
  992. SELECT cg.educational_teacher_id_ FROM class_group_teacher_mapper cgtm
  993. LEFT JOIN courses_group cg ON cg.id_ = cgtm.music_group_id_
  994. WHERE cgtm.user_id_ = #{teacherId} AND cgtm.group_type_ = 'COMM'
  995. GROUP BY cg.educational_teacher_id_
  996. UNION ALL
  997. SELECT pg.educational_teacher_id_ FROM class_group_teacher_mapper cgtm
  998. LEFT JOIN practice_group pg ON pg.id_ = cgtm.music_group_id_
  999. WHERE cgtm.user_id_ = #{teacherId} AND cgtm.group_type_ = 'PRACTICE'
  1000. GROUP BY pg.educational_teacher_id_
  1001. UNION ALL
  1002. SELECT vg.educational_teacher_id_ FROM course_schedule_teacher_salary csts
  1003. LEFT JOIN vip_group vg ON vg.id_ = csts.music_group_id_
  1004. WHERE csts.user_id_ = #{teacherId} AND csts.group_type_ = 'VIP' AND vg.group_status_ IN (2,3,4)
  1005. GROUP BY vg.educational_teacher_id_
  1006. UNION ALL
  1007. SELECT cg.educational_teacher_id_ FROM course_schedule_teacher_salary csts
  1008. LEFT JOIN courses_group cg ON cg.id_ = csts.music_group_id_
  1009. WHERE csts.user_id_ = #{teacherId} AND csts.group_type_ = 'COMM'
  1010. GROUP BY cg.educational_teacher_id_
  1011. UNION ALL
  1012. SELECT pg.educational_teacher_id_ FROM course_schedule_teacher_salary csts
  1013. LEFT JOIN practice_group pg ON pg.id_ = csts.music_group_id_
  1014. WHERE csts.user_id_ = #{teacherId} AND csts.group_type_ = 'PRACTICE'
  1015. GROUP BY pg.educational_teacher_id_
  1016. </select>
  1017. <select id="queryMusicLeaderIds" resultType="java.lang.String">
  1018. SELECT DISTINCT CONCAT(mg.educational_teacher_id_,',',mg.director_user_id_,',',mg.team_teacher_id_) FROM course_schedule_teacher_salary csts
  1019. LEFT JOIN music_group mg ON mg.id_ = csts.music_group_id_
  1020. WHERE csts.user_id_ = #{teacherId} AND csts.group_type_ = 'MUSIC' AND mg.status_ = 'PROGRESS'
  1021. GROUP BY mg.id_
  1022. UNION ALL
  1023. SELECT DISTINCT CONCAT(mg.educational_teacher_id_,',',mg.director_user_id_,',',mg.team_teacher_id_) FROM class_group_teacher_mapper cgtm
  1024. LEFT JOIN music_group mg ON mg.id_ = cgtm.music_group_id_
  1025. WHERE cgtm.user_id_ = #{teacherId} AND cgtm.group_type_ = 'MUSIC' AND mg.status_ = 'PROGRESS'
  1026. GROUP BY mg.id_
  1027. </select>
  1028. </mapper>