EmployeeMapper.xml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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. <mapper namespace="com.usoftchina.saas.document.mapper.EmployeeMapper">
  4. <resultMap id="BaseResultMap" type="com.usoftchina.saas.document.entities.Employee">
  5. <id column="em_id" jdbcType="INTEGER" property="id" />
  6. <result column="em_code" jdbcType="VARCHAR" property="em_code" />
  7. <result column="em_name" jdbcType="VARCHAR" property="em_name" />
  8. <result column="em_password" jdbcType="VARCHAR" property="em_password" />
  9. <result column="em_class" jdbcType="VARCHAR" property="em_class" />
  10. <result column="em_mobile" jdbcType="VARCHAR" property="em_mobile" />
  11. <result column="em_email" jdbcType="VARCHAR" property="em_email" />
  12. <result column="companyId" jdbcType="INTEGER" property="companyId" />
  13. <result column="updaterId" jdbcType="INTEGER" property="updaterId" />
  14. <result column="updateTime" jdbcType="TIMESTAMP" property="updateTime" />
  15. <result column="em_text1" jdbcType="VARCHAR" property="em_text1" />
  16. <result column="em_text2" jdbcType="VARCHAR" property="em_text2" />
  17. <result column="em_text3" jdbcType="VARCHAR" property="em_text3" />
  18. <result column="em_text4" jdbcType="VARCHAR" property="em_text4" />
  19. <result column="em_text5" jdbcType="VARCHAR" property="em_text5" />
  20. </resultMap>
  21. <sql id="Base_Column_List">
  22. em_id, em_code, em_name, em_password, em_class, em_mobile, em_email, companyId, updaterId,
  23. updateTime, em_text1, em_text2, em_text3, em_text4, em_text5
  24. </sql>
  25. <select id="selectByPrimaryKey" parameterType="long" resultMap="BaseResultMap">
  26. select
  27. <include refid="Base_Column_List" />
  28. from employee
  29. where em_id = #{em_id,jdbcType=INTEGER}
  30. </select>
  31. <select id="selectByMobile" parameterType="string" resultMap="BaseResultMap">
  32. select
  33. <include refid="Base_Column_List" />
  34. from employee
  35. where em_mobile = #{mobile,jdbcType=INTEGER}
  36. </select>
  37. <delete id="deleteByPrimaryKey" parameterType="long">
  38. delete from employee
  39. where em_id = #{em_id,jdbcType=INTEGER}
  40. </delete>
  41. <insert id="insertSelective" parameterType="com.usoftchina.saas.document.entities.Employee">
  42. <selectKey resultType="java.lang.Long" keyProperty="id">
  43. SELECT LAST_INSERT_ID() AS ID
  44. </selectKey>
  45. insert into employee
  46. <trim prefix="(" suffix=")" suffixOverrides=",">
  47. <if test="em_code != null">
  48. em_code,
  49. </if>
  50. <if test="em_name != null">
  51. em_name,
  52. </if>
  53. <if test="em_password != null">
  54. em_password,
  55. </if>
  56. <if test="em_class != null">
  57. em_class,
  58. </if>
  59. <if test="em_mobile != null">
  60. em_mobile,
  61. </if>
  62. <if test="em_email != null">
  63. em_email,
  64. </if>
  65. <if test="companyId != null">
  66. companyId,
  67. </if>
  68. <if test="updaterId != null">
  69. updaterId,
  70. </if>
  71. <if test="updateTime != null">
  72. updateTime,
  73. </if>
  74. <if test="em_text1 != null">
  75. em_text1,
  76. </if>
  77. <if test="em_text2 != null">
  78. em_text2,
  79. </if>
  80. <if test="em_text3 != null">
  81. em_text3,
  82. </if>
  83. <if test="em_text4 != null">
  84. em_text4,
  85. </if>
  86. <if test="em_text5 != null">
  87. em_text5,
  88. </if>
  89. <if test="creatorId != null" >
  90. creatorId,
  91. </if>
  92. <if test="createTime != null" >
  93. createTime,
  94. </if>
  95. <if test="creatorName != null" >
  96. creatorName,
  97. </if>
  98. </trim>
  99. <trim prefix="values (" suffix=")" suffixOverrides=",">
  100. <if test="em_code != null">
  101. #{em_code,jdbcType=VARCHAR},
  102. </if>
  103. <if test="em_name != null">
  104. #{em_name,jdbcType=VARCHAR},
  105. </if>
  106. <if test="em_password != null">
  107. #{em_password,jdbcType=VARCHAR},
  108. </if>
  109. <if test="em_class != null">
  110. #{em_class,jdbcType=VARCHAR},
  111. </if>
  112. <if test="em_mobile != null">
  113. #{em_mobile,jdbcType=VARCHAR},
  114. </if>
  115. <if test="em_email != null">
  116. #{em_email,jdbcType=VARCHAR},
  117. </if>
  118. <if test="companyId != null">
  119. #{companyId,jdbcType=INTEGER},
  120. </if>
  121. <if test="updaterId != null">
  122. #{updaterId,jdbcType=INTEGER},
  123. </if>
  124. <if test="updateTime != null">
  125. #{updateTime,jdbcType=TIMESTAMP},
  126. </if>
  127. <if test="em_text1 != null">
  128. #{em_text1,jdbcType=VARCHAR},
  129. </if>
  130. <if test="em_text2 != null">
  131. #{em_text2,jdbcType=VARCHAR},
  132. </if>
  133. <if test="em_text3 != null">
  134. #{em_text3,jdbcType=VARCHAR},
  135. </if>
  136. <if test="em_text4 != null">
  137. #{em_text4,jdbcType=VARCHAR},
  138. </if>
  139. <if test="em_text5 != null">
  140. #{em_text5,jdbcType=VARCHAR},
  141. </if>
  142. <if test="creatorId != null" >
  143. #{creatorId,jdbcType=INTEGER},
  144. </if>
  145. <if test="createTime != null" >
  146. #{createTime,jdbcType=TIMESTAMP},
  147. </if>
  148. <if test="creatorName != null" >
  149. #{creatorName,jdbcType=VARCHAR},
  150. </if>
  151. </trim>
  152. </insert>
  153. <update id="updateByPrimaryKeySelective" parameterType="com.usoftchina.saas.document.entities.Employee">
  154. update employee
  155. <set>
  156. <if test="em_code != null">
  157. em_code = #{em_code,jdbcType=VARCHAR},
  158. </if>
  159. <if test="em_name != null">
  160. em_name = #{em_name,jdbcType=VARCHAR},
  161. </if>
  162. <if test="em_password != null">
  163. em_password = #{em_password,jdbcType=VARCHAR},
  164. </if>
  165. <if test="em_class != null">
  166. em_class = #{em_class,jdbcType=VARCHAR},
  167. </if>
  168. <if test="em_mobile != null">
  169. em_mobile = #{em_mobile,jdbcType=VARCHAR},
  170. </if>
  171. <if test="em_email != null">
  172. em_email = #{em_email,jdbcType=VARCHAR},
  173. </if>
  174. <if test="companyId != null">
  175. companyId = #{companyId,jdbcType=INTEGER},
  176. </if>
  177. <if test="updaterId != null">
  178. updaterId = #{updaterId,jdbcType=INTEGER},
  179. </if>
  180. <if test="updateTime != null">
  181. updateTime = #{updateTime,jdbcType=TIMESTAMP},
  182. </if>
  183. <if test="em_text1 != null">
  184. em_text1 = #{em_text1,jdbcType=VARCHAR},
  185. </if>
  186. <if test="em_text2 != null">
  187. em_text2 = #{em_text2,jdbcType=VARCHAR},
  188. </if>
  189. <if test="em_text3 != null">
  190. em_text3 = #{em_text3,jdbcType=VARCHAR},
  191. </if>
  192. <if test="em_text4 != null">
  193. em_text4 = #{em_text4,jdbcType=VARCHAR},
  194. </if>
  195. <if test="em_text5 != null">
  196. em_text5 = #{em_text5,jdbcType=VARCHAR},
  197. </if>
  198. </set>
  199. where em_id = #{id,jdbcType=INTEGER}
  200. </update>
  201. <!--查询所有物料信息-->
  202. <select id="selectEmployeeListByCondition" resultMap="BaseResultMap" parameterType="com.usoftchina.saas.commons.dto.DocReqDTO">
  203. SELECT * FROM Employee
  204. <where>
  205. <if test="con != null">
  206. ${con}
  207. </if>
  208. <if test="companyId != null">
  209. and companyid = #{companyId}
  210. </if>
  211. </where>
  212. ORDER BY em_ID DESC
  213. </select>
  214. <select id="validateCodeWhenInsert" resultType="int">
  215. select count(*) from Employee where em_code = #{code} and companyId =#{companyId}
  216. </select>
  217. <select id="validateCodeWhenUpdate" resultType="int" >
  218. select count(*) from Employee where em_code = #{code} and em_id != #{id} and companyId =#{companyId}
  219. </select>
  220. <select id="validatePhoneWhenInsert" resultType="int">
  221. select count(*) from Employee where em_mobile = #{phone} and companyId =#{companyId}
  222. </select>
  223. <select id="validatePhoneWhenUpdate" resultType="int" >
  224. select count(*) from Employee where em_mobile = #{phone} and em_id != #{id} and companyId =#{companyId}
  225. </select>
  226. <select id="validateNameAndCodeWhenInsert" resultType="int">
  227. select count(*) from Employee where (em_code = #{code} or em_name = #{name}) and companyId =#{companyId}
  228. </select>
  229. <select id="validateNameAndCodeWhenUpdate" resultType="int">
  230. select count(*) from Employee where (em_code = #{code} or em_name = #{name}) and em_id !=#{id} and companyId =#{companyId}
  231. </select>
  232. </mapper>