EmployeeMapper.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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.web.dal.dao.EmployeeDao">
  8. <resultMap type="com.ym.mec.web.dal.entity.Employee" id="Employee">
  9. <result column="user_id_" property="userId" />
  10. <result column="organ_id_" property="organId" />
  11. <result column="job_nature_" property="jobNature" />
  12. <result column="is_probation_period_" property="isProbationPeriod" />
  13. <result column="education_background_" property="educationBackground" />
  14. <result column="graduate_school_" property="graduateSchool" />
  15. <result column="technical_titles_" property="technicalTitles" />
  16. <result column="entry_date_" property="entryDate" />
  17. <result column="certificate_type_" property="certificateType" />
  18. <result column="certificate_num_" property="certificateNum" />
  19. <result column="update_time_" property="updateTime" />
  20. <result column="create_time_" property="createTime" />
  21. <result column="introduction_" property="introduction" />
  22. <result column="demission_date_" property="demissionDate" />
  23. </resultMap>
  24. <!-- 根据主键查询一条记录 -->
  25. <select id="get" resultMap="Employee" >
  26. SELECT * FROM employee WHERE user_id_ = #{userId}
  27. </select>
  28. <!-- 全查询 -->
  29. <select id="findAll" resultMap="Employee">
  30. SELECT * FROM employee ORDER BY user_id_
  31. </select>
  32. <!-- 向数据库增加一条记录 -->
  33. <insert id="insert" parameterType="com.ym.mec.web.dal.entity.Employee" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  34. <!--
  35. <selectKey resultClass="int" keyProperty="id" >
  36. SELECT SEQ_WSDEFINITION_ID.nextval AS ID FROM DUAL
  37. </selectKey>
  38. -->
  39. INSERT INTO employee (user_id_,organ_id_,job_nature_,is_probation_period_,education_background_,graduate_school_,technical_titles_,entry_date_,certificate_type_,certificate_num_,update_time_,create_time_,introduction_,demission_date_) VALUES(#{userId},#{organId},#{jobNature},#{isProbationPeriod},#{educationBackground},#{graduateSchool},#{technicalTitles},#{entryDate},#{certificateType},#{certificateNum},#{updateTime},#{createTime},#{introduction},#{demissionDate})
  40. </insert>
  41. <!-- 根据主键查询一条记录 -->
  42. <update id="update" parameterType="com.ym.mec.web.dal.entity.Employee">
  43. UPDATE employee <set>
  44. <if test="isProbationPeriod != null">
  45. is_probation_period_ = #{isProbationPeriod},
  46. </if>
  47. <if test="graduateSchool != null">
  48. graduate_school_ = #{graduateSchool},
  49. </if>
  50. <if test="organId != null">
  51. organ_id_ = #{organId},
  52. </if>
  53. <if test="introduction != null">
  54. introduction_ = #{introduction},
  55. </if>
  56. <if test="technicalTitles != null">
  57. technical_titles_ = #{technicalTitles},
  58. </if>
  59. <if test="entryDate != null">
  60. entry_date_ = #{entryDate},
  61. </if>
  62. <if test="jobNature != null">
  63. job_nature_ = #{jobNature},
  64. </if>
  65. <if test="createTime != null">
  66. create_time_ = #{createTime},
  67. </if>
  68. <if test="userId != null">
  69. user_id_ = #{userId},
  70. </if>
  71. <if test="certificateType != null">
  72. certificate_type_ = #{certificateType},
  73. </if>
  74. <if test="updateTime != null">
  75. update_time_ = #{updateTime},
  76. </if>
  77. <if test="educationBackground != null">
  78. education_background_ = #{educationBackground},
  79. </if>
  80. <if test="certificateNum != null">
  81. certificate_num_ = #{certificateNum},
  82. </if>
  83. <if test="demissionDate != null">
  84. demission_date_ = #{demissionDate},
  85. </if>
  86. </set> WHERE user_id_ = #{userId}
  87. </update>
  88. <update id="updatePassword">
  89. UPDATE sys_user SET password_ = #{password} WHERE id_ = #{userID}
  90. </update>
  91. <update id="updateUserLockStatus">
  92. UPDATE sys_user SET lock_flag_ = IF(lock_flag_=0,9,0) WHERE id_=#{userID}
  93. </update>
  94. <!-- 根据主键删除一条记录 -->
  95. <delete id="delete" >
  96. DELETE FROM employee WHERE user_id_ = #{userId}
  97. </delete>
  98. <!-- 分页查询 -->
  99. <select id="queryPage" resultMap="Employee" parameterType="map">
  100. SELECT * FROM employee ORDER BY user_id_ <include refid="global.limit"/>
  101. </select>
  102. <!-- 查询当前表的总记录数 -->
  103. <select id="queryCount" resultType="int">
  104. SELECT COUNT(*) FROM employee
  105. </select>
  106. <resultMap type="com.ym.mec.web.dal.dto.EmployeeDto" id="EmployeeDto">
  107. <result property="id" column="id_" />
  108. <result property="username" column="username_" />
  109. <result property="gender" column="gender_" typeHandler="com.ym.mec.common.dal.CustomEnumTypeHandler"/>
  110. <result property="phone" column="phone_" />
  111. <result property="lockFlag" column="role_name_" />
  112. <result property="roleName" column="lock_flag_" />
  113. <result property="jobNature" column="job_nature_" />
  114. <result property="entryDate" column="entry_date_" />
  115. <result property="demissionDate" column="demission_date_" />
  116. </resultMap>
  117. <sql id="queryCondition">
  118. <where>
  119. <if test="organId != null">
  120. and su.organ_id_ = #{organId}
  121. </if>
  122. <if test="roleId != null">
  123. and sr.id_ = #{roleId}
  124. </if>
  125. <if test="userNameOrPhone != null">
  126. and (su.username_ like LIKE CONCAT('%',#{userNameOrPhone},'%')
  127. or su.phone_ like LIKE CONCAT('%',#{userNameOrPhone},'%') or )
  128. </if>
  129. </where>
  130. </sql>
  131. <select id="queryEmployByOrganId" resultMap="EmployeeDto">
  132. SELECT
  133. su.id_,
  134. su.username_,
  135. su.gender_,
  136. su.phone_,
  137. sr.role_name_,
  138. su.lock_flag_,
  139. e.job_nature_,
  140. e.entry_date_,
  141. e.demission_date_
  142. FROM
  143. sys_user su
  144. LEFT JOIN employee e ON su.id_=e.user_id_
  145. LEFT JOIN sys_user_role sur ON su.id_=sur.user_id_
  146. LEFT JOIN sys_role sr ON sur.role_id_=sr.id_
  147. <include refid="queryCondition"/>
  148. </select>
  149. <select id="queryEmployByOrganIdCount" resultType="java.lang.Integer">
  150. SELECT
  151. count(*)
  152. FROM
  153. sys_user su
  154. LEFT JOIN employee e ON su.id_=e.user_id_
  155. LEFT JOIN sys_user_role sur ON su.id_=sur.user_id_
  156. LEFT JOIN sys_role sr ON sur.role_id_=sr.id_
  157. </select>
  158. </mapper>