KwsDeptDao.xml 8.0 KB

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