KwsUserDao.xml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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.sckw.system.dao.KwsUserDao">
  4. <resultMap id="BaseResultMap" type="com.sckw.system.model.KwsUser">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="system_type" jdbcType="INTEGER" property="systemType" />
  7. <result column="account" jdbcType="VARCHAR" property="account" />
  8. <result column="password" jdbcType="VARCHAR" property="password" />
  9. <result column="name" jdbcType="VARCHAR" property="name" />
  10. <result column="telephone" jdbcType="VARCHAR" property="telephone" />
  11. <result column="photo" jdbcType="VARCHAR" property="photo" />
  12. <result column="email" jdbcType="VARCHAR" property="email" />
  13. <result column="client_id" jdbcType="VARCHAR" property="clientId" />
  14. <result column="is_main" jdbcType="INTEGER" property="isMain" />
  15. <result column="remark" jdbcType="VARCHAR" property="remark" />
  16. <result column="status" jdbcType="INTEGER" property="status" />
  17. <result column="create_by" jdbcType="BIGINT" property="createBy" />
  18. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  19. <result column="update_by" jdbcType="BIGINT" property="updateBy" />
  20. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  21. <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
  22. </resultMap>
  23. <sql id="Base_Column_List">
  24. id, system_type, account, password, name, telephone, photo, email, client_id, is_main,
  25. remark, status, create_by, create_time, update_by, update_time, del_flag
  26. </sql>
  27. <select id="selectByKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  28. select
  29. <include refid="Base_Column_List" />
  30. from kws_user
  31. where id = #{id,jdbcType=BIGINT}
  32. </select>
  33. <insert id="insert" parameterType="com.sckw.system.model.KwsUser">
  34. insert into kws_user
  35. <trim prefix="(" suffix=")" suffixOverrides=",">
  36. <if test="id != null">
  37. id,
  38. </if>
  39. <if test="systemType != null">
  40. system_type,
  41. </if>
  42. <if test="account != null">
  43. account,
  44. </if>
  45. <if test="password != null">
  46. password,
  47. </if>
  48. <if test="name != null">
  49. name,
  50. </if>
  51. <if test="telephone != null">
  52. telephone,
  53. </if>
  54. <if test="photo != null">
  55. photo,
  56. </if>
  57. <if test="email != null">
  58. email,
  59. </if>
  60. <if test="clientId != null">
  61. client_id,
  62. </if>
  63. <if test="isMain != null">
  64. is_main,
  65. </if>
  66. <if test="remark != null">
  67. remark,
  68. </if>
  69. <if test="status != null">
  70. status,
  71. </if>
  72. <if test="createBy != null">
  73. create_by,
  74. </if>
  75. <if test="createTime != null">
  76. create_time,
  77. </if>
  78. <if test="updateBy != null">
  79. update_by,
  80. </if>
  81. <if test="updateTime != null">
  82. update_time,
  83. </if>
  84. <if test="delFlag != null">
  85. del_flag,
  86. </if>
  87. </trim>
  88. <trim prefix="values (" suffix=")" suffixOverrides=",">
  89. <if test="id != null">
  90. #{id,jdbcType=BIGINT},
  91. </if>
  92. <if test="systemType != null">
  93. #{systemType,jdbcType=INTEGER},
  94. </if>
  95. <if test="account != null">
  96. #{account,jdbcType=VARCHAR},
  97. </if>
  98. <if test="password != null">
  99. #{password,jdbcType=VARCHAR},
  100. </if>
  101. <if test="name != null">
  102. #{name,jdbcType=VARCHAR},
  103. </if>
  104. <if test="telephone != null">
  105. #{telephone,jdbcType=VARCHAR},
  106. </if>
  107. <if test="photo != null">
  108. #{photo,jdbcType=VARCHAR},
  109. </if>
  110. <if test="email != null">
  111. #{email,jdbcType=VARCHAR},
  112. </if>
  113. <if test="clientId != null">
  114. #{clientId,jdbcType=VARCHAR},
  115. </if>
  116. <if test="isMain != null">
  117. #{isMain,jdbcType=INTEGER},
  118. </if>
  119. <if test="remark != null">
  120. #{remark,jdbcType=VARCHAR},
  121. </if>
  122. <if test="status != null">
  123. #{status,jdbcType=INTEGER},
  124. </if>
  125. <if test="createBy != null">
  126. #{createBy,jdbcType=BIGINT},
  127. </if>
  128. <if test="createTime != null">
  129. #{createTime,jdbcType=TIMESTAMP},
  130. </if>
  131. <if test="updateBy != null">
  132. #{updateBy,jdbcType=BIGINT},
  133. </if>
  134. <if test="updateTime != null">
  135. #{updateTime,jdbcType=TIMESTAMP},
  136. </if>
  137. <if test="delFlag != null">
  138. #{delFlag,jdbcType=INTEGER},
  139. </if>
  140. </trim>
  141. </insert>
  142. <update id="update" parameterType="com.sckw.system.model.KwsUser">
  143. update kws_user
  144. <set>
  145. <if test="systemType != null">
  146. system_type = #{systemType,jdbcType=INTEGER},
  147. </if>
  148. <if test="account != null">
  149. account = #{account,jdbcType=VARCHAR},
  150. </if>
  151. <if test="password != null">
  152. password = #{password,jdbcType=VARCHAR},
  153. </if>
  154. <if test="name != null">
  155. name = #{name,jdbcType=VARCHAR},
  156. </if>
  157. <if test="telephone != null">
  158. telephone = #{telephone,jdbcType=VARCHAR},
  159. </if>
  160. <if test="photo != null">
  161. photo = #{photo,jdbcType=VARCHAR},
  162. </if>
  163. <if test="email != null">
  164. email = #{email,jdbcType=VARCHAR},
  165. </if>
  166. <if test="clientId != null">
  167. client_id = #{clientId,jdbcType=VARCHAR},
  168. </if>
  169. <if test="isMain != null">
  170. is_main = #{isMain,jdbcType=INTEGER},
  171. </if>
  172. <if test="remark != null">
  173. remark = #{remark,jdbcType=VARCHAR},
  174. </if>
  175. <if test="status != null">
  176. status = #{status,jdbcType=INTEGER},
  177. </if>
  178. <if test="createBy != null">
  179. create_by = #{createBy,jdbcType=BIGINT},
  180. </if>
  181. <if test="createTime != null">
  182. create_time = #{createTime,jdbcType=TIMESTAMP},
  183. </if>
  184. <if test="updateBy != null">
  185. update_by = #{updateBy,jdbcType=BIGINT},
  186. </if>
  187. <if test="updateTime != null">
  188. update_time = #{updateTime,jdbcType=TIMESTAMP},
  189. </if>
  190. <if test="delFlag != null">
  191. del_flag = #{delFlag,jdbcType=INTEGER},
  192. </if>
  193. </set>
  194. where id = #{id,jdbcType=BIGINT}
  195. </update>
  196. <select id="findPage" resultMap="BaseResultMap" parameterType="java.util.Map" >
  197. select
  198. <include refid="Base_Column_List" />
  199. from kws_user su
  200. where su.del_flag = 0
  201. <if test="systemType != null and systemType != ''">
  202. and su.system_type = #{system_type, jdbcType=VARCHAR}
  203. </if>
  204. <if test="account != null and account != ''">
  205. and su.account = #{account, jdbcType=VARCHAR}
  206. </if>
  207. <if test="name != null and name != ''">
  208. and su.name = #{name, jdbcType=VARCHAR}
  209. </if>
  210. <if test="telephone != null and telephone != ''">
  211. and su.telephone = #{telephone, jdbcType=VARCHAR}
  212. </if>
  213. <if test="email != null and email != ''">
  214. and su.email = #{email, jdbcType=VARCHAR}
  215. </if>
  216. <if test="deptId != null and deptId != ''">
  217. and su.id in (
  218. select
  219. sud.user_id
  220. from kws_user_dept sud
  221. left join kws_dept sd on sud.dept_id = sd.id
  222. where sd.del_flag = 0 and sud.del_flag = 0
  223. and sd.dept_id = #{deptId, jdbcType=VARCHAR}
  224. )
  225. </if>
  226. <if test="entId != null and entId != ''">
  227. and su.id in (
  228. select
  229. user_id
  230. from kws_user_dept
  231. where del_flag = 0 and ent_id = #{entId, jdbcType=VARCHAR}
  232. )
  233. </if>
  234. ORDER BY su.create_time desc
  235. </select>
  236. <select id="findList" resultType="com.sckw.system.model.KwsUser" parameterType="com.sckw.system.model.KwsUser" >
  237. select
  238. su.id, su.system_type systemType, su.account, su.password, su.name,
  239. su.telephone, su.photo, su.email, su.is_main isMain, su.remark, su.status
  240. from kws_user su
  241. where su.del_flag = 0
  242. <if test="systemType != null and systemType != ''">
  243. and su.system_type = #{systemType, jdbcType=INTEGER}
  244. </if>
  245. <if test="account != null and account != ''">
  246. and su.account = #{account, jdbcType=VARCHAR}
  247. </if>
  248. <if test="name != null and name != ''">
  249. and su.name = #{name, jdbcType=VARCHAR}
  250. </if>
  251. <if test="telephone != null and telephone != ''">
  252. and su.telephone = #{telephone, jdbcType=VARCHAR}
  253. </if>
  254. ORDER BY su.create_time desc
  255. </select>
  256. <select id="queryUserDeptByUserId" resultType="com.sckw.system.model.KwsUserDept">
  257. select a.* from kws_user_depot a where a.user_id = #{userId} and a.del_flag = 0
  258. </select>
  259. <select id="queryDeptByIds" resultType="com.sckw.system.model.KwsDept">
  260. select a.*
  261. from kws_dept a
  262. where a.id in
  263. <foreach collection="list" item="item" open="(" close=")" separator=",">
  264. #{item}
  265. </foreach>
  266. </select>
  267. </mapper>