TeacherMapper.xml 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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="organ_name_" property="organName"/>
  12. <result column="job_type_" property="jobType"/>
  13. <result column="job_nature_" property="jobNature"/>
  14. <result column="is_probation_period_" property="isProbationPeriod" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  15. <result column="education_background_" property="educationBackground"/>
  16. <result column="graduate_school_" property="graduateSchool"/>
  17. <result column="technical_titles_" property="technicalTitles"/>
  18. <result column="work_unit_" property="workUnit"/>
  19. <result column="subject_id_" property="subjectId"/>
  20. <result column="entry_date_" property="entryDate"/>
  21. <result column="demission_date_" property="demissionDate"/>
  22. <result column="certificate_type_" property="certificateType"/>
  23. <result column="certificate_num_" property="certificateNum"/>
  24. <result column="flow_organ_range_" property="flowOrganRange"/>
  25. <result column="introduction_" property="introduction"/>
  26. <result column="update_time_" property="updateTime"/>
  27. <result column="create_time_" property="createTime"/>
  28. <result column="username_" property="username"/>
  29. <result column="password_" property="password"/>
  30. <result column="salt_" property="salt"/>
  31. <result column="phone_" property="phone"/>
  32. <result column="avatar_" property="avatar"/>
  33. <result column="lock_flag_" property="lockFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  34. <result column="del_flag_" property="delFlag" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  35. <result column="wx_openid_" property="wxOpenid"/>
  36. <result column="qq_openid_" property="qqOpenid"/>
  37. <result column="user_type_" property="userType" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  38. <result column="gender_" property="gender" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  39. <result column="nation_" property="nation"/>
  40. <result column="birthdate_" property="birthdate"/>
  41. <result column="email_" property="email"/>
  42. <result column="im_token_" property="imToken"/>
  43. </resultMap>
  44. <!-- 根据主键查询一条记录 -->
  45. <select id="get" resultMap="Teacher">
  46. SELECT t.*,su.username_,su.password_,su.salt_,su.phone_,su.avatar_,
  47. su.lock_flag_,su.del_flag_,su.wx_openid_,su.qq_openid_,su.user_type_,
  48. su.gender_,su.nation_,su.birthdate_,su.email_,su.im_token_,t.subject_id_,t.organ_id_,o.name_ organ_name_
  49. FROM teacher t
  50. LEFT JOIN sys_user su ON t.id_ = su.id_
  51. LEFT JOIN organization o ON t.organ_id_ = o.id_
  52. WHERE t.id_ = #{userId} AND o.del_flag_ = 0
  53. </select>
  54. <!-- 全查询 -->
  55. <select id="findAll" resultMap="Teacher">
  56. SELECT * FROM teacher ORDER BY user_id_
  57. </select>
  58. <!-- 向数据库增加一条记录 -->
  59. <insert id="insert" parameterType="com.ym.mec.biz.dal.entity.Teacher" useGeneratedKeys="true" keyColumn="id"
  60. keyProperty="id">
  61. INSERT INTO teacher
  62. (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_)
  63. VALUES(#{id},#{organId},#{jobType},#{jobNature},#{isProbationPeriod,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{educationBackground},#{graduateSchool},#{technicalTitles},#{workUnit},#{subjectId},#{entryDate},#{demissionDate},#{certificateType},#{certificateNum},#{flowOrganRange},#{introduction},now(),now())
  64. </insert>
  65. <!-- 根据主键查询一条记录 -->
  66. <update id="update" parameterType="com.ym.mec.biz.dal.entity.Teacher">
  67. UPDATE teacher
  68. <set>
  69. <if test="graduateSchool != null">
  70. graduate_school_ = #{graduateSchool},
  71. </if>
  72. <if test="subjectId != null">
  73. subject_id_ = #{subjectId},
  74. </if>
  75. <if test="organId != null">
  76. organ_id_ = #{organId},
  77. </if>
  78. <if test="technicalTitles != null">
  79. technical_titles_ = #{technicalTitles},
  80. </if>
  81. <if test="entryDate != null">
  82. entry_date_ = #{entryDate},
  83. </if>
  84. <if test="demissionDate != null">
  85. demission_date_ = #{demissionDate},
  86. </if>
  87. <if test="jobType != null">
  88. job_type_ = #{jobType},
  89. </if>
  90. <if test="flowOrganRange != null">
  91. flow_organ_range_ = #{flowOrganRange},
  92. </if>
  93. <if test="certificateType != null">
  94. certificate_type_ = #{certificateType},
  95. </if>
  96. <if test="jobNature != null">
  97. job_nature_ = #{jobNature},
  98. </if>
  99. <if test="isProbationPeriod != null">
  100. is_probation_period_ = #{isProbationPeriod,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  101. </if>
  102. <if test="updateTime != null">
  103. update_time_ = #{updateTime},
  104. </if>
  105. <if test="educationBackground != null">
  106. education_background_ = #{educationBackground},
  107. </if>
  108. <if test="certificateNum != null">
  109. certificate_num_ = #{certificateNum},
  110. </if>
  111. <if test="workUnit != null">
  112. work_unit_ = #{workUnit},
  113. </if>
  114. <if test="introduction != null">
  115. introduction_ = #{introduction},
  116. </if>
  117. </set>
  118. WHERE user_id_ = #{userId}
  119. </update>
  120. <!-- 根据主键删除一条记录 -->
  121. <update id="delete">
  122. DELETE FROM teacher WHERE user_id_ = #{userId}
  123. </update>
  124. <update id="updateUser" parameterType="com.ym.mec.auth.api.entity.SysUser">
  125. UPDATE sys_user
  126. <set>
  127. <if test="delFlag != null">
  128. del_flag_ = #{delFlag, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  129. </if>
  130. <if test="wxOpenid != null">
  131. wx_openid_ = #{wxOpenid},
  132. </if>
  133. <if test="avatar != null">
  134. avatar_ = #{avatar},
  135. </if>
  136. <if test="email != null">
  137. email_ = #{email},
  138. </if>
  139. <if test="gender != null">
  140. gender_ = #{gender, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  141. </if>
  142. <if test="salt != null">
  143. salt_ = #{salt},
  144. </if>
  145. <if test="username != null">
  146. username_ = #{username},
  147. </if>
  148. <if test="userType != null">
  149. user_type_ = #{userType, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  150. </if>
  151. <if test="updateTime != null">
  152. update_time_ = #{updateTime},
  153. </if>
  154. <if test="lockFlag != null">
  155. lock_flag_ = #{lockFlag, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
  156. </if>
  157. <if test="birthdate != null">
  158. birthdate_ = #{birthdate},
  159. </if>
  160. <if test="phone != null">
  161. phone_ = #{phone},
  162. </if>
  163. <if test="qqOpenid != null">
  164. qq_openid_ = #{qqOpenid},
  165. </if>
  166. <if test="nation != null">
  167. nation_ = #{nation},
  168. </if>
  169. <if test="organId != null">
  170. organ_id_ = #{organId},
  171. </if>
  172. <if test="imToken != null">
  173. im_token_ = #{imToken},
  174. </if>
  175. </set>
  176. WHERE id_ = #{id}
  177. </update>
  178. <!-- 分页查询 -->
  179. <select id="queryPage" resultMap="Teacher" parameterType="map">
  180. SELECT t.*,su.username_,su.password_,su.salt_,su.phone_,su.avatar_,
  181. su.lock_flag_,su.del_flag_,su.wx_openid_,su.qq_openid_,su.user_type_,
  182. su.gender_,su.nation_,su.birthdate_,su.email_,su.im_token_,t.subject_id_,t.organ_id_,o.name_ organ_name_
  183. FROM teacher t
  184. LEFT JOIN sys_user su ON t.id_ = su.id_
  185. LEFT JOIN organization o ON t.organ_id_ = o.id_
  186. <include refid="queryPageMap"/>
  187. <include refid="global.limit"/>
  188. </select>
  189. <sql id="queryPageMap">
  190. <where>
  191. <if test="lockFlag != null">
  192. AND su.lock_flag_ = #{lockFlag}
  193. </if>
  194. <if test="subjectId != null">
  195. AND t.subject_id_ LIKE CONCAT('%',#{subjectId},'%')
  196. </if>
  197. <if test="organId != null">
  198. AND o.organ_id_ = #{organId}
  199. </if>
  200. <if test="jobNature != null">
  201. AND t.job_nature_ = #{jobNature}
  202. </if>
  203. <if test="isProbationPeriod != null">
  204. AND t.is_probation_period_ = #{isProbationPeriod}
  205. </if>
  206. </where>
  207. </sql>
  208. <!-- 查询当前表的总记录数 -->
  209. <select id="queryCount" resultType="int">
  210. SELECT COUNT(t.id_) FROM teacher t
  211. LEFT JOIN sys_user su ON t.id_ = su.id_
  212. LEFT JOIN `subject` s ON t.subject_id_ = s.id_
  213. LEFT JOIN organization o ON t.organ_id_ = o.id_
  214. <include refid="queryPageMap"/>
  215. </select>
  216. <!-- 根据证件号查询老师 -->
  217. <select id="findByCertificateNum" resultMap="Teacher">
  218. SELECT * FROM teacher WHERE certificate_num_ = #{certificateNum}
  219. </select>
  220. </mapper>