TeacherMapper.xml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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.keao.edu.user.dao.TeacherDao">
  8. <resultMap type="com.keao.edu.user.entity.Teacher" id="Teacher">
  9. <result column="user_id_" property="userId" />
  10. <result column="title_" property="title" />
  11. <result column="subject_id_list_" property="subjectIdList" />
  12. <result column="salary_settlement_type_" property="salarySettlementType" typeHandler="com.keao.edu.common.dal.CustomEnumTypeHandler"/>
  13. <result column="salary_" property="salary" />
  14. <result column="del_flag_" property="delFlag"/>
  15. <result column="total_invigilation_num_" property="totalInvigilationNum"/>
  16. <result column="total_invigilation_student_num_" property="totalInvigilationStudentNum"/>
  17. <result column="total_settlement_fee_" property="totalSettlementCost"/>
  18. <result column="create_time_" property="createTime" />
  19. <result column="update_time_" property="updateTime" />
  20. <result column="tenant_id_" property="tenantId" />
  21. <result column="organ_id_" property="organId" />
  22. <result column="city_" property="city" />
  23. <result column="certificate_no_" property="certificateNo" />
  24. <result column="subsidy_" property="subsidy" />
  25. <association property="sysUser" columnPrefix="sys_user_" resultMap="com.keao.edu.user.dao.SysUserDao.SysUser"/>
  26. </resultMap>
  27. <resultMap id="TeacherDto" type="com.keao.edu.user.dto.TeacherDto" extends="Teacher">
  28. <result property="subjectNames" column="subject_names_"/>
  29. </resultMap>
  30. <select id="get" resultMap="Teacher">
  31. SELECT t.*,
  32. su.id_ sys_user_id_,
  33. su.username_ sys_user_username_,
  34. su.phone_ sys_user_phone_,
  35. su.avatar_ sys_user_avatar_,
  36. su.real_name_ sys_user_real_name_,
  37. su.user_type_ sys_user_user_type_
  38. FROM teacher t
  39. LEFT JOIN sys_user su ON t.user_id_ = su.id_
  40. WHERE t.user_id_ = #{id}
  41. </select>
  42. <update id="update" parameterType="com.keao.edu.user.entity.Teacher">
  43. UPDATE teacher
  44. <set>
  45. <if test="subsidy != null">
  46. subsidy_ = #{subsidy},
  47. </if>
  48. <if test="title != null">
  49. title_ = #{title},
  50. </if>
  51. <if test="subjectIdList != null">
  52. subject_id_list_ = #{subjectIdList},
  53. </if>
  54. <if test="salarySettlementType != null">
  55. salary_settlement_type_ = #{salarySettlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},
  56. </if>
  57. <if test="delFlag != null">
  58. del_flag_ = #{delFlag},
  59. </if>
  60. <if test="salary != null">
  61. salary_ = #{salary},
  62. </if>
  63. <if test="tenantId != null">
  64. tenant_id_ = #{tenantId},
  65. </if>
  66. <if test="organId != null">
  67. organ_id_ = #{organId},
  68. </if>
  69. <if test="totalInvigilationNum != null">
  70. total_invigilation_num_ = #{totalInvigilationNum},
  71. </if>
  72. <if test="totalInvigilationStudentNum != null">
  73. total_invigilation_student_num_ = #{totalInvigilationStudentNum},
  74. </if>
  75. <if test="totalSettlementCost != null">
  76. total_settlement_fee_ = #{totalSettlementCost},
  77. </if>
  78. <if test="city != null">
  79. city_ = #{city},
  80. </if>
  81. <if test="certificateNo != null">
  82. certificate_no_ = #{certificateNo},
  83. </if>
  84. update_time_ = NOW()
  85. </set>
  86. WHERE user_id_ = #{userId}
  87. </update>
  88. <update id="batchUpdate" parameterType="com.keao.edu.user.entity.Teacher">
  89. <foreach collection="teachers" item="teacher" separator=";">
  90. UPDATE teacher
  91. <set>
  92. <if test="teacher.totalInvigilationNum != null">
  93. total_invigilation_num_ = #{teacher.totalInvigilationNum},
  94. </if>
  95. <if test="teacher.totalInvigilationStudentNum != null">
  96. total_invigilation_student_num_ = #{teacher.totalInvigilationStudentNum},
  97. </if>
  98. <if test="teacher.totalSettlementCost != null">
  99. total_settlement_fee_ = #{teacher.totalSettlementCost},
  100. </if>
  101. update_time_ = NOW()
  102. </set>
  103. WHERE user_id_ = #{teacher.userId}
  104. </foreach>
  105. </update>
  106. <!-- 全查询 -->
  107. <select id="findAll" resultMap="Teacher">
  108. SELECT * FROM teacher WHERE tenant_id_ = #{tenantId}
  109. </select>
  110. <!-- 向数据库增加一条记录 -->
  111. <insert id="insert" parameterType="com.keao.edu.user.entity.Teacher" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  112. INSERT INTO teacher (user_id_,title_,subject_id_list_,salary_settlement_type_,salary_,create_time_,update_time_,tenant_id_,organ_id_,city_,certificate_no_,subsidy_)
  113. VALUES(#{userId},#{title},#{subjectIdList},#{salarySettlementType,typeHandler=com.keao.edu.common.dal.CustomEnumTypeHandler},#{salary},NOW(),NOW(),#{tenantId},#{organId},#{city},#{certificateNo},#{subsidy})
  114. </insert>
  115. <update id="delete">
  116. UPDATE teacher SET del_flag_ = 1,update_time_ = NOW() WHERE user_id_ = #{id}
  117. </update>
  118. <sql id="teacherQueryPage">
  119. <where>
  120. t.del_flag_ = 0
  121. <if test="search != null and search != ''">
  122. AND (t.user_id_ = #{search}
  123. OR su.real_name_ LIKE CONCAT('%',#{search},'%')
  124. OR su.phone_ LIKE CONCAT('%',#{search},'%'))
  125. </if>
  126. <if test="tenantId != null and tenantId != 0">
  127. AND t.tenant_id_ = #{tenantId}
  128. </if>
  129. <if test="organId != null and organId != 0">
  130. AND t.organ_id_ = #{organId}
  131. </if>
  132. <if test="settlementType != null and settlementType != ''">
  133. AND t.salary_settlement_type_ = #{settlementType}
  134. </if>
  135. </where>
  136. </sql>
  137. <!-- 分页查询 -->
  138. <select id="queryPage" resultMap="Teacher" parameterType="map">
  139. SELECT t.*,
  140. su.id_ sys_user_id_,
  141. su.username_ sys_user_username_,
  142. su.phone_ sys_user_phone_,
  143. su.avatar_ sys_user_avatar_,
  144. su.real_name_ sys_user_real_name_
  145. FROM teacher t
  146. LEFT JOIN sys_user su ON t.user_id_ = su.id_
  147. <include refid="teacherQueryPage"/>
  148. order by t.create_time_ desc
  149. <include refid="global.limit"/>
  150. </select>
  151. <!-- 查询当前表的总记录数 -->
  152. <select id="queryCount" resultType="int">
  153. SELECT COUNT(DISTINCT t.user_id_) FROM teacher t
  154. LEFT JOIN sys_user su ON t.user_id_ = su.id_
  155. <include refid="teacherQueryPage"/>
  156. </select>
  157. <select id="getWithTeachers" resultMap="Teacher">
  158. SELECT * FROM teacher WHERE user_id_ IN
  159. <foreach collection="teacherIds" item="teacherId" separator="," open="(" close=")">
  160. #{teacherId}
  161. </foreach>
  162. </select>
  163. <select id="queryTeacherSubjectNames" resultType="java.util.Map">
  164. SELECT t.user_id_ 'key',GROUP_CONCAT(s.name_) 'value' FROM teacher t
  165. LEFT JOIN `subject` s ON FIND_IN_SET(s.id_,t.subject_id_list_)
  166. WHERE t.user_id_ IN
  167. <foreach collection="teacherIds" separator="," open="(" close=")" item="item">
  168. #{item}
  169. </foreach>
  170. GROUP BY t.user_id_
  171. </select>
  172. </mapper>