SysDepartmentMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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.ssm.mapper.system.SysDepartmentMapper">
  4. <resultMap id="BaseResultMap" type="com.ssm.model.system.SysDepartment">
  5. <id column="DepID" property="depid" jdbcType="INTEGER" />
  6. <result column="DepCode" property="depcode" jdbcType="VARCHAR" />
  7. <result column="CreatedUserID" property="createduserid"
  8. jdbcType="INTEGER" />
  9. <result column="CreatedDatetime" property="createddatetime"
  10. jdbcType="TIMESTAMP" />
  11. <result column="LastUpdateUserID" property="lastupdateuserid"
  12. jdbcType="INTEGER" />
  13. <result column="LastUpdateDatetime" property="lastupdatedatetime"
  14. jdbcType="TIMESTAMP" />
  15. <result column="DepName" property="depname" jdbcType="VARCHAR" />
  16. <result column="LanguageType" property="languagetype" jdbcType="INTEGER" />
  17. <result column="ParentID" property="parentid" jdbcType="INTEGER" />
  18. <result column="IsDeleted" property="isdeleted" jdbcType="BIT" />
  19. <result column="Level" property="level" jdbcType="INTEGER" />
  20. <result column="DepartmentID" property="departmentid" jdbcType="INTEGER" />
  21. <result column="DeptRoleCode" property="deptrolecode" jdbcType="CLOB" />
  22. <collection property="positions" ofType="com.ssm.model.system.SysPosition">
  23. <id property="positionid" column="positionid" />
  24. <result property="positionname" column="positionname" />
  25. </collection>
  26. </resultMap>
  27. <resultMap id="ResultMapWithBLOBs" type="com.ssm.model.system.SysDepartment"
  28. extends="BaseResultMap">
  29. <result column="DeptRoleCode" property="deptrolecode" jdbcType="CLOB" />
  30. </resultMap>
  31. <sql id="Example_Where_Clause">
  32. <where>
  33. <foreach collection="oredCriteria" item="criteria" separator="or">
  34. <if test="criteria.valid">
  35. <trim prefix="(" suffix=")" prefixOverrides="and">
  36. <foreach collection="criteria.criteria" item="criterion">
  37. <choose>
  38. <when test="criterion.noValue">
  39. and ${criterion.condition}
  40. </when>
  41. <when test="criterion.singleValue">
  42. and ${criterion.condition} #{criterion.value}
  43. </when>
  44. <when test="criterion.betweenValue">
  45. and ${criterion.condition} #{criterion.value} and
  46. #{criterion.secondValue}
  47. </when>
  48. <when test="criterion.listValue">
  49. and ${criterion.condition}
  50. <foreach collection="criterion.value" item="listItem"
  51. open="(" close=")" separator=",">
  52. #{listItem}
  53. </foreach>
  54. </when>
  55. </choose>
  56. </foreach>
  57. </trim>
  58. </if>
  59. </foreach>
  60. </where>
  61. </sql>
  62. <sql id="Update_By_Example_Where_Clause">
  63. <where>
  64. <foreach collection="example.oredCriteria" item="criteria"
  65. separator="or">
  66. <if test="criteria.valid">
  67. <trim prefix="(" suffix=")" prefixOverrides="and">
  68. <foreach collection="criteria.criteria" item="criterion">
  69. <choose>
  70. <when test="criterion.noValue">
  71. and ${criterion.condition}
  72. </when>
  73. <when test="criterion.singleValue">
  74. and ${criterion.condition} #{criterion.value}
  75. </when>
  76. <when test="criterion.betweenValue">
  77. and ${criterion.condition} #{criterion.value} and
  78. #{criterion.secondValue}
  79. </when>
  80. <when test="criterion.listValue">
  81. and ${criterion.condition}
  82. <foreach collection="criterion.value" item="listItem"
  83. open="(" close=")" separator=",">
  84. #{listItem}
  85. </foreach>
  86. </when>
  87. </choose>
  88. </foreach>
  89. </trim>
  90. </if>
  91. </foreach>
  92. </where>
  93. </sql>
  94. <sql id="Base_Column_List">
  95. DepID, DepCode, CreatedUserID, CreatedDatetime, LastUpdateUserID,
  96. LastUpdateDatetime,
  97. DepName, LanguageType, ParentID, IsDeleted,Level,DepartmentID
  98. </sql>
  99. <sql id="Blob_Column_List">
  100. DeptRoleCode
  101. </sql>
  102. <!-- 级联菜单 -->
  103. <select id="selectAll" resultMap="BaseResultMap" parameterType="com.ssm.model.system.SysDepartment">
  104. select sd.depid , sd.depname, sp.positionid, sp.positionname
  105. from
  106. SysDepartment sd
  107. , SysPosition sp
  108. where 1=1 and sd.depid = sp.depid and sd.isDeleted=0 and sp.isDeleted=0
  109. order by sd.depid asc
  110. </select>
  111. <select id="selectByExampleWithBLOBs" resultMap="ResultMapWithBLOBs"
  112. parameterType="com.ssm.model.system.SysDepartmentExample">
  113. select
  114. <if test="distinct">
  115. distinct
  116. </if>
  117. <include refid="Base_Column_List" />
  118. ,
  119. <include refid="Blob_Column_List" />
  120. from SysDepartment
  121. <if test="_parameter != null">
  122. <include refid="Example_Where_Clause" />
  123. </if>
  124. <if test="orderByClause != null">
  125. order by ${orderByClause}
  126. </if>
  127. </select>
  128. <select id="selectByExample" resultMap="BaseResultMap"
  129. parameterType="com.ssm.model.system.SysDepartmentExample">
  130. select
  131. <if test="distinct">
  132. distinct
  133. </if>
  134. <include refid="Base_Column_List" />
  135. from SysDepartment
  136. <if test="_parameter != null">
  137. <include refid="Example_Where_Clause" />
  138. </if>
  139. <if test="orderByClause != null">
  140. order by ${orderByClause}
  141. </if>
  142. </select>
  143. <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs"
  144. parameterType="java.lang.Integer">
  145. select
  146. <include refid="Base_Column_List" />
  147. ,
  148. <include refid="Blob_Column_List" />
  149. from SysDepartment
  150. where DepID = #{depid,jdbcType=INTEGER}
  151. </select>
  152. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  153. delete from SysDepartment
  154. where DepID = #{depid,jdbcType=INTEGER}
  155. </delete>
  156. <delete id="deleteByExample" parameterType="com.ssm.model.system.SysDepartmentExample">
  157. delete from SysDepartment
  158. <if test="_parameter != null">
  159. <include refid="Example_Where_Clause" />
  160. </if>
  161. </delete>
  162. <insert id="insert" parameterType="com.ssm.model.system.SysDepartment">
  163. insert into SysDepartment (DepID, DepCode, CreatedUserID,
  164. CreatedDatetime, LastUpdateUserID, LastUpdateDatetime,
  165. DepName, LanguageType, ParentID,
  166. IsDeleted, DeptRoleCode)
  167. values (#{depid,jdbcType=INTEGER}, #{depcode,jdbcType=VARCHAR},
  168. #{createduserid,jdbcType=INTEGER},
  169. #{createddatetime,jdbcType=TIMESTAMP},
  170. #{lastupdateuserid,jdbcType=INTEGER},
  171. #{lastupdatedatetime,jdbcType=TIMESTAMP},
  172. #{depname,jdbcType=VARCHAR}, #{languagetype,jdbcType=INTEGER}, #{parentid,jdbcType=INTEGER},
  173. #{isdeleted,jdbcType=BIT}, #{deptrolecode,jdbcType=CLOB})
  174. </insert>
  175. <insert id="insertSelective" parameterType="com.ssm.model.system.SysDepartment">
  176. insert into SysDepartment
  177. <trim prefix="(" suffix=")" suffixOverrides=",">
  178. <if test="depid != null">
  179. DepID,
  180. </if>
  181. <if test="depcode != null">
  182. DepCode,
  183. </if>
  184. <if test="createduserid != null">
  185. CreatedUserID,
  186. </if>
  187. <if test="createddatetime != null">
  188. CreatedDatetime,
  189. </if>
  190. <if test="lastupdateuserid != null">
  191. LastUpdateUserID,
  192. </if>
  193. <if test="lastupdatedatetime != null">
  194. LastUpdateDatetime,
  195. </if>
  196. <if test="depname != null">
  197. DepName,
  198. </if>
  199. <if test="languagetype != null">
  200. LanguageType,
  201. </if>
  202. <if test="parentid != null">
  203. ParentID,
  204. </if>
  205. <if test="isdeleted != null">
  206. IsDeleted,
  207. </if>
  208. <if test="deptrolecode != null">
  209. DeptRoleCode,
  210. </if>
  211. <if test="level != null">
  212. level,
  213. </if>
  214. <if test="departmentid != null">
  215. departmentid,
  216. </if>
  217. </trim>
  218. <trim prefix="values (" suffix=")" suffixOverrides=",">
  219. <if test="depid != null">
  220. #{depid,jdbcType=INTEGER},
  221. </if>
  222. <if test="depcode != null">
  223. #{depcode,jdbcType=VARCHAR},
  224. </if>
  225. <if test="createduserid != null">
  226. #{createduserid,jdbcType=INTEGER},
  227. </if>
  228. <if test="createddatetime != null">
  229. #{createddatetime,jdbcType=TIMESTAMP},
  230. </if>
  231. <if test="lastupdateuserid != null">
  232. #{lastupdateuserid,jdbcType=INTEGER},
  233. </if>
  234. <if test="lastupdatedatetime != null">
  235. #{lastupdatedatetime,jdbcType=TIMESTAMP},
  236. </if>
  237. <if test="depname != null">
  238. #{depname,jdbcType=VARCHAR},
  239. </if>
  240. <if test="languagetype != null">
  241. #{languagetype,jdbcType=INTEGER},
  242. </if>
  243. <if test="parentid != null">
  244. #{parentid,jdbcType=INTEGER},
  245. </if>
  246. <if test="isdeleted != null">
  247. #{isdeleted,jdbcType=BIT},
  248. </if>
  249. <if test="deptrolecode != null">
  250. #{deptrolecode,jdbcType=CLOB},
  251. </if>
  252. <if test="level != null">
  253. #{level,jdbcType=INTEGER},
  254. </if>
  255. <if test="departmentid != null">
  256. #{departmentid,jdbcType=INTEGER},
  257. </if>
  258. </trim>
  259. </insert>
  260. <select id="countByExample" parameterType="com.ssm.model.system.SysDepartmentExample"
  261. resultType="java.lang.Integer">
  262. select count(*) from SysDepartment
  263. <if test="_parameter != null">
  264. <include refid="Example_Where_Clause" />
  265. </if>
  266. </select>
  267. <update id="updateByExampleSelective" parameterType="map">
  268. update SysDepartment
  269. <set>
  270. <if test="record.depid != null">
  271. DepID = #{record.depid,jdbcType=INTEGER},
  272. </if>
  273. <if test="record.depcode != null">
  274. DepCode = #{record.depcode,jdbcType=VARCHAR},
  275. </if>
  276. <if test="record.createduserid != null">
  277. CreatedUserID = #{record.createduserid,jdbcType=INTEGER},
  278. </if>
  279. <if test="record.createddatetime != null">
  280. CreatedDatetime = #{record.createddatetime,jdbcType=TIMESTAMP},
  281. </if>
  282. <if test="record.lastupdateuserid != null">
  283. LastUpdateUserID = #{record.lastupdateuserid,jdbcType=INTEGER},
  284. </if>
  285. <if test="record.lastupdatedatetime != null">
  286. LastUpdateDatetime = #{record.lastupdatedatetime,jdbcType=TIMESTAMP},
  287. </if>
  288. <if test="record.depname != null">
  289. DepName = #{record.depname,jdbcType=VARCHAR},
  290. </if>
  291. <if test="record.languagetype != null">
  292. LanguageType = #{record.languagetype,jdbcType=INTEGER},
  293. </if>
  294. <if test="record.parentid != null">
  295. ParentID = #{record.parentid,jdbcType=INTEGER},
  296. </if>
  297. <if test="record.isdeleted != null">
  298. IsDeleted = #{record.isdeleted,jdbcType=BIT},
  299. </if>
  300. <if test="record.deptrolecode != null">
  301. DeptRoleCode = #{record.deptrolecode,jdbcType=CLOB},
  302. </if>
  303. </set>
  304. <if test="_parameter != null">
  305. <include refid="Update_By_Example_Where_Clause" />
  306. </if>
  307. </update>
  308. <update id="updateByExampleWithBLOBs" parameterType="map">
  309. update SysDepartment
  310. set DepID = #{record.depid,jdbcType=INTEGER},
  311. DepCode = #{record.depcode,jdbcType=VARCHAR},
  312. CreatedUserID = #{record.createduserid,jdbcType=INTEGER},
  313. CreatedDatetime = #{record.createddatetime,jdbcType=TIMESTAMP},
  314. LastUpdateUserID = #{record.lastupdateuserid,jdbcType=INTEGER},
  315. LastUpdateDatetime = #{record.lastupdatedatetime,jdbcType=TIMESTAMP},
  316. DepName = #{record.depname,jdbcType=VARCHAR},
  317. LanguageType = #{record.languagetype,jdbcType=INTEGER},
  318. ParentID = #{record.parentid,jdbcType=INTEGER},
  319. IsDeleted = #{record.isdeleted,jdbcType=BIT},
  320. DeptRoleCode = #{record.deptrolecode,jdbcType=CLOB}
  321. <if test="_parameter != null">
  322. <include refid="Update_By_Example_Where_Clause" />
  323. </if>
  324. </update>
  325. <update id="updateByExample" parameterType="map">
  326. update SysDepartment
  327. set DepID = #{record.depid,jdbcType=INTEGER},
  328. DepCode = #{record.depcode,jdbcType=VARCHAR},
  329. CreatedUserID = #{record.createduserid,jdbcType=INTEGER},
  330. CreatedDatetime = #{record.createddatetime,jdbcType=TIMESTAMP},
  331. LastUpdateUserID = #{record.lastupdateuserid,jdbcType=INTEGER},
  332. LastUpdateDatetime = #{record.lastupdatedatetime,jdbcType=TIMESTAMP},
  333. DepName = #{record.depname,jdbcType=VARCHAR},
  334. LanguageType = #{record.languagetype,jdbcType=INTEGER},
  335. ParentID = #{record.parentid,jdbcType=INTEGER},
  336. IsDeleted = #{record.isdeleted,jdbcType=BIT}
  337. <if test="_parameter != null">
  338. <include refid="Update_By_Example_Where_Clause" />
  339. </if>
  340. </update>
  341. <update id="updateByPrimaryKeySelective" parameterType="com.ssm.model.system.SysDepartment">
  342. update SysDepartment
  343. <set>
  344. <if test="depcode != null">
  345. DepCode = #{depcode,jdbcType=VARCHAR},
  346. </if>
  347. <if test="createduserid != null">
  348. CreatedUserID = #{createduserid,jdbcType=INTEGER},
  349. </if>
  350. <if test="createddatetime != null">
  351. CreatedDatetime = #{createddatetime,jdbcType=TIMESTAMP},
  352. </if>
  353. <if test="lastupdateuserid != null">
  354. LastUpdateUserID = #{lastupdateuserid,jdbcType=INTEGER},
  355. </if>
  356. <if test="lastupdatedatetime != null">
  357. LastUpdateDatetime = #{lastupdatedatetime,jdbcType=TIMESTAMP},
  358. </if>
  359. <if test="depname != null">
  360. DepName = #{depname,jdbcType=VARCHAR},
  361. </if>
  362. <if test="languagetype != null">
  363. LanguageType = #{languagetype,jdbcType=INTEGER},
  364. </if>
  365. <if test="parentid != null">
  366. ParentID = #{parentid,jdbcType=INTEGER},
  367. </if>
  368. <if test="isdeleted != null">
  369. IsDeleted = #{isdeleted,jdbcType=BIT},
  370. </if>
  371. <if test="deptrolecode != null">
  372. DeptRoleCode = #{deptrolecode,jdbcType=CLOB},
  373. </if>
  374. <if test="level != null">
  375. level = #{level,jdbcType=INTEGER},
  376. </if>
  377. <if test="departmentid != null">
  378. departmentid = #{departmentid,jdbcType=INTEGER},
  379. </if>
  380. </set>
  381. where DepID = #{depid,jdbcType=INTEGER}
  382. </update>
  383. <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.ssm.model.system.SysDepartment">
  384. update SysDepartment
  385. set DepCode = #{depcode,jdbcType=VARCHAR},
  386. CreatedUserID = #{createduserid,jdbcType=INTEGER},
  387. CreatedDatetime = #{createddatetime,jdbcType=TIMESTAMP},
  388. LastUpdateUserID = #{lastupdateuserid,jdbcType=INTEGER},
  389. LastUpdateDatetime = #{lastupdatedatetime,jdbcType=TIMESTAMP},
  390. DepName = #{depname,jdbcType=VARCHAR},
  391. LanguageType = #{languagetype,jdbcType=INTEGER},
  392. ParentID = #{parentid,jdbcType=INTEGER},
  393. IsDeleted = #{isdeleted,jdbcType=BIT},
  394. DeptRoleCode = #{deptrolecode,jdbcType=CLOB}
  395. where DepID = #{depid,jdbcType=INTEGER}
  396. </update>
  397. <update id="updateByPrimaryKey" parameterType="com.ssm.model.system.SysDepartment">
  398. update SysDepartment
  399. set DepCode = #{depcode,jdbcType=VARCHAR},
  400. CreatedUserID = #{createduserid,jdbcType=INTEGER},
  401. CreatedDatetime = #{createddatetime,jdbcType=TIMESTAMP},
  402. LastUpdateUserID = #{lastupdateuserid,jdbcType=INTEGER},
  403. LastUpdateDatetime = #{lastupdatedatetime,jdbcType=TIMESTAMP},
  404. DepName = #{depname,jdbcType=VARCHAR},
  405. LanguageType = #{languagetype,jdbcType=INTEGER},
  406. ParentID = #{parentid,jdbcType=INTEGER},
  407. IsDeleted = #{isdeleted,jdbcType=BIT}
  408. where DepID = #{depid,jdbcType=INTEGER}
  409. </update>
  410. <select id="sysDepartmentList" resultMap="BaseResultMap">
  411. select
  412. <include refid="Base_Column_List" />
  413. from SysDepartment where IsDeleted=0
  414. </select>
  415. <!-- 根据父id查询 -->
  416. <select id="sysDepartmentParentid" resultMap="BaseResultMap" parameterType="java.lang.Integer">
  417. select
  418. <include refid="Base_Column_List" />
  419. from SysDepartment
  420. where departmentid = #{parentid,jdbcType=INTEGER}
  421. </select>
  422. <select id="selectParentid" resultType="java.lang.Integer" parameterType="java.lang.Integer">
  423. select
  424. count(1)
  425. from SysDepartment
  426. where parentid = #{parentid}
  427. </select>
  428. <select id="selectMaxParentid" resultType="java.lang.Integer" parameterType="java.lang.Integer">
  429. select
  430. max(DepartmentID)
  431. from SysDepartment
  432. where parentid = #{parentid}
  433. </select>
  434. <!-- 分页查询 部门-->
  435. <select id="sysDepartmentQuery" resultMap="BaseResultMap">
  436. select * from SysDepartment WHERE IsDeleted=0
  437. <if test="departmentid != null and departmentid != '' and departmentid !=-1">
  438. AND DepartmentID LIKE CONCAT('%',#{departmentid},'%')
  439. </if>
  440. ORDER BY cast(DepartmentID as char(30))
  441. </select>
  442. <!-- <resultMap id="BaseResultMap5" type="com.ssm.model.system.SysDepartment" extends="BaseResultMap">
  443. <collection property="positions" ofType="com.ssm.model.system.SysPosition">
  444. <id property="positionid" column="positionid" />
  445. <result property="positionname" column="positionname" />
  446. <result property="positioncode" column="PositionCode" />
  447. </collection>
  448. </resultMap>
  449. <select id="sysDepartmentQuery" resultMap="BaseResultMap5">
  450. SELECT
  451. p.PositionName as positionname, 职位名称
  452. p.PositionCode as PositionCode,职位编码
  453. d.DepName as DepName,部门名称
  454. d.DepCode,部门编码
  455. p.IsDeleted,
  456. p.PositionID as positionid,
  457. d.DeptRoleCode,
  458. d.DepID as DepID
  459. FROM
  460. SysPosition p
  461. INNER JOIN SysDepartment d ON p.DepID=d.DepID
  462. ORDER BY d.DeptRoleCode
  463. </select> -->
  464. </mapper>