TeacherMapper.xml 6.2 KB

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