SysPostInfoDao.xml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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.liang.dao.SysPostInfoDao">
  4. <resultMap type="com.liang.entity.SysPostInfo" id="SysPostInfoMap">
  5. <result property="postId" column="post_id" jdbcType="INTEGER"/>
  6. <result property="postCode" column="post_code" jdbcType="VARCHAR"/>
  7. <result property="postName" column="post_name" jdbcType="VARCHAR"/>
  8. <result property="postSort" column="post_sort" jdbcType="INTEGER"/>
  9. <result property="status" column="status" jdbcType="VARCHAR"/>
  10. <result property="createUser" column="create_user" jdbcType="INTEGER"/>
  11. <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  12. <result property="updateUser" column="update_user" jdbcType="INTEGER"/>
  13. <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
  14. <result property="descript" column="descript" jdbcType="VARCHAR"/>
  15. </resultMap>
  16. <!--查询单个-->
  17. <select id="queryById" resultMap="SysPostInfoMap">
  18. select
  19. post_id, post_code, post_name, post_sort, status, create_user, create_time, update_user, update_time, descript
  20. from sys_post_info
  21. where post_id = #{postId}
  22. </select>
  23. <!--查询指定行数据-->
  24. <select id="queryAllByLimit" resultMap="SysPostInfoMap">
  25. select
  26. post_id, post_code, post_name, post_sort, status, create_user, create_time, update_user, update_time, descript
  27. from sys_post_info
  28. <where>
  29. <if test="postId != null">
  30. and post_id = #{postId}
  31. </if>
  32. <if test="postCode != null and postCode != ''">
  33. and post_code = #{postCode}
  34. </if>
  35. <if test="postName != null and postName != ''">
  36. and post_name = #{postName}
  37. </if>
  38. <if test="postSort != null">
  39. and post_sort = #{postSort}
  40. </if>
  41. <if test="status != null and status != ''">
  42. and status = #{status}
  43. </if>
  44. <if test="createUser != null">
  45. and create_user = #{createUser}
  46. </if>
  47. <if test="createTime != null">
  48. and create_time = #{createTime}
  49. </if>
  50. <if test="updateUser != null">
  51. and update_user = #{updateUser}
  52. </if>
  53. <if test="updateTime != null">
  54. and update_time = #{updateTime}
  55. </if>
  56. <if test="descript != null and descript != ''">
  57. and descript = #{descript}
  58. </if>
  59. </where>
  60. limit #{pageable.offset}, #{pageable.pageSize}
  61. </select>
  62. <!--统计总行数-->
  63. <select id="count" resultType="java.lang.Long">
  64. select count(1)
  65. from sys_post_info
  66. <where>
  67. <if test="postId != null">
  68. and post_id = #{postId}
  69. </if>
  70. <if test="postCode != null and postCode != ''">
  71. and post_code = #{postCode}
  72. </if>
  73. <if test="postName != null and postName != ''">
  74. and post_name = #{postName}
  75. </if>
  76. <if test="postSort != null">
  77. and post_sort = #{postSort}
  78. </if>
  79. <if test="status != null and status != ''">
  80. and status = #{status}
  81. </if>
  82. <if test="createUser != null">
  83. and create_user = #{createUser}
  84. </if>
  85. <if test="createTime != null">
  86. and create_time = #{createTime}
  87. </if>
  88. <if test="updateUser != null">
  89. and update_user = #{updateUser}
  90. </if>
  91. <if test="updateTime != null">
  92. and update_time = #{updateTime}
  93. </if>
  94. <if test="descript != null and descript != ''">
  95. and descript = #{descript}
  96. </if>
  97. </where>
  98. </select>
  99. <!--新增所有列-->
  100. <insert id="insert" keyProperty="postId" useGeneratedKeys="true">
  101. if not exists (select * from sys_post_info where post_code = #{postCode} and post_name = #{postName})
  102. insert into sys_post_info(
  103. <if test="descript != null and descript != ''">
  104. descript,
  105. </if>
  106. post_code, post_name, post_sort, status, create_user, create_time)
  107. values (
  108. <if test="descript != null and descript != ''">
  109. #{descript},
  110. </if>
  111. #{postCode}, #{postName}, #{postSort}, #{status}, #{createUser}, GETDATE())
  112. </insert>
  113. <!--通过主键修改数据-->
  114. <update id="update">
  115. update sys_post_info
  116. set post_code = #{postCode},
  117. post_name = #{postName},
  118. post_sort = #{postSort},
  119. status = #{status},
  120. descript = #{descript},
  121. update_time = GETDATE()
  122. where post_id = #{postId}
  123. </update>
  124. <!--通过主键删除-->
  125. <delete id="deleteById">
  126. delete from sys_post_info where post_id = #{postId}
  127. </delete>
  128. <!--查询所有岗位-->
  129. <select id="getSysPostInfoList" resultMap="SysPostInfoMap" parameterType="map">
  130. select p.*, u.name as CJRXM
  131. from sys_post_info p
  132. left join sys_user_info u on u.user_id = p.create_user
  133. <where>
  134. <if test="postCode != null and postCode != ''">
  135. and post_code like '%'+#{postCode}+'%'
  136. </if>
  137. <if test="postName != null and postName != ''">
  138. and post_name like '%'+#{postName}+'%'
  139. </if>
  140. <if test="status != null and status != ''">
  141. and status = #{status}
  142. </if>
  143. </where>
  144. <choose>
  145. <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
  146. order by ${sortName} ${sortOrder}
  147. </when>
  148. <otherwise>
  149. order by post_sort asc
  150. </otherwise>
  151. </choose>
  152. </select>
  153. <!--查询岗位-->
  154. <select id="getSysPostInfo" resultMap="SysPostInfoMap" parameterType="map">
  155. select * from sys_post_info
  156. where status = 0
  157. <if test="postCode != null and postCode != ''">
  158. and post_code = #{postCode}
  159. </if>
  160. <if test="postName != null and postName != ''">
  161. and post_name = #{postName}
  162. </if>
  163. <if test="status != null and status != ''">
  164. and status = #{status}
  165. </if>
  166. </select>
  167. <!--查询岗位-->
  168. <select id="getSysPostInfo1" resultMap="SysPostInfoMap" parameterType="map">
  169. select * from sys_post_info
  170. where status = 0
  171. <if test="postId != null and postId != ''">
  172. and post_id = #{postId}
  173. </if>
  174. <if test="postCode != null and postCode != ''">
  175. and post_code = #{postCode}
  176. </if>
  177. <if test="postName != null and postName != ''">
  178. and post_name = #{postName}
  179. </if>
  180. <if test="status != null and status != ''">
  181. and status = #{status}
  182. </if>
  183. </select>
  184. <!--批量删除登陆日志-->
  185. <delete id="batchDelete" parameterType="java.util.ArrayList">
  186. delete from sys_post_info
  187. where post_id in
  188. <foreach item="item" index="index" collection="postIdList" open = "(" separator = "," close = ")">
  189. #{item}
  190. </foreach>
  191. </delete>
  192. </mapper>