KwsRoleDao.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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.KwsRoleDao">
  4. <resultMap id="BaseResultMap" type="com.sckw.system.model.KwsRole">
  5. <id column="id" jdbcType="BIGINT" property="id" />
  6. <result column="name" jdbcType="VARCHAR" property="name" />
  7. <result column="dept_id" jdbcType="BIGINT" property="deptId" />
  8. <result column="remark" jdbcType="VARCHAR" property="remark" />
  9. <result column="status" jdbcType="INTEGER" property="status" />
  10. <result column="create_by" jdbcType="BIGINT" property="createBy" />
  11. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  12. <result column="update_by" jdbcType="BIGINT" property="updateBy" />
  13. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  14. <result column="del_flag" jdbcType="INTEGER" property="delFlag" />
  15. </resultMap>
  16. <sql id="Base_Column_List">
  17. id, name, dept_id, remark, status, create_by, create_time, update_by, update_time,
  18. del_flag
  19. </sql>
  20. <select id="selectByKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
  21. select
  22. <include refid="Base_Column_List" />
  23. from kws_role
  24. where id = #{id,jdbcType=BIGINT}
  25. </select>
  26. <insert id="insert" parameterType="com.sckw.system.model.KwsRole">
  27. insert into kws_role
  28. <trim prefix="(" suffix=")" suffixOverrides=",">
  29. <if test="id != null">
  30. id,
  31. </if>
  32. <if test="name != null">
  33. name,
  34. </if>
  35. <if test="deptId != null">
  36. dept_id,
  37. </if>
  38. <if test="remark != null">
  39. remark,
  40. </if>
  41. <if test="status != null">
  42. status,
  43. </if>
  44. <if test="createBy != null">
  45. create_by,
  46. </if>
  47. <if test="createTime != null">
  48. create_time,
  49. </if>
  50. <if test="updateBy != null">
  51. update_by,
  52. </if>
  53. <if test="updateTime != null">
  54. update_time,
  55. </if>
  56. <if test="delFlag != null">
  57. del_flag,
  58. </if>
  59. </trim>
  60. <trim prefix="values (" suffix=")" suffixOverrides=",">
  61. <if test="id != null">
  62. #{id,jdbcType=BIGINT},
  63. </if>
  64. <if test="name != null">
  65. #{name,jdbcType=VARCHAR},
  66. </if>
  67. <if test="deptId != null">
  68. #{deptId,jdbcType=BIGINT},
  69. </if>
  70. <if test="remark != null">
  71. #{remark,jdbcType=VARCHAR},
  72. </if>
  73. <if test="status != null">
  74. #{status,jdbcType=INTEGER},
  75. </if>
  76. <if test="createBy != null">
  77. #{createBy,jdbcType=BIGINT},
  78. </if>
  79. <if test="createTime != null">
  80. #{createTime,jdbcType=TIMESTAMP},
  81. </if>
  82. <if test="updateBy != null">
  83. #{updateBy,jdbcType=BIGINT},
  84. </if>
  85. <if test="updateTime != null">
  86. #{updateTime,jdbcType=TIMESTAMP},
  87. </if>
  88. <if test="delFlag != null">
  89. #{delFlag,jdbcType=INTEGER},
  90. </if>
  91. </trim>
  92. </insert>
  93. <update id="update" parameterType="com.sckw.system.model.KwsRole">
  94. update kws_role
  95. <set>
  96. <if test="name != null">
  97. name = #{name,jdbcType=VARCHAR},
  98. </if>
  99. <if test="deptId != null">
  100. dept_id = #{deptId,jdbcType=BIGINT},
  101. </if>
  102. <if test="remark != null">
  103. remark = #{remark,jdbcType=VARCHAR},
  104. </if>
  105. <if test="status != null">
  106. status = #{status,jdbcType=INTEGER},
  107. </if>
  108. <if test="createBy != null">
  109. create_by = #{createBy,jdbcType=BIGINT},
  110. </if>
  111. <if test="createTime != null">
  112. create_time = #{createTime,jdbcType=TIMESTAMP},
  113. </if>
  114. <if test="updateBy != null">
  115. update_by = #{updateBy,jdbcType=BIGINT},
  116. </if>
  117. <if test="updateTime != null">
  118. update_time = #{updateTime,jdbcType=TIMESTAMP},
  119. </if>
  120. <if test="delFlag != null">
  121. del_flag = #{delFlag,jdbcType=INTEGER},
  122. </if>
  123. </set>
  124. where id = #{id,jdbcType=BIGINT}
  125. </update>
  126. <select id="findPage" resultType="com.sckw.system.model.vo.res.RoleResVo" parameterType="java.util.Map" >
  127. select
  128. sr.id,
  129. sr.name,
  130. sr.dept_id,
  131. sr.remark,
  132. sr.status,
  133. su.name createBy,
  134. sr.create_time,
  135. sr.update_by,
  136. sr.update_time,
  137. sr.del_flag
  138. from kws_role sr
  139. left join kws_user su on sr.create_by = su.id
  140. left join kws_dept d on sr.dept_id = d.id
  141. where sr.del_flag = 0
  142. and su.del_flag = 0
  143. <if test="name != null and name != ''">
  144. and sr.name like concat('%', #{name, jdbcType=VARCHAR}, '%')
  145. </if>
  146. <if test="deptId != null and deptId != ''">
  147. and sr.deptId = #{deptId, jdbcType=VARCHAR}
  148. </if>
  149. <if test="entId != null and entId != ''">
  150. and d.ent_id = #{entId, jdbcType=VARCHAR}
  151. </if>
  152. <if test="startTime != null and startTime != ''">
  153. and sr.create_time >= #{startTime,jdbcType=DATE}
  154. </if>
  155. <if test="endTime != null and endTime != ''" >
  156. and sr.create_time &lt; date_add(#{endTime}, INTERVAL 1 DAY)
  157. </if>
  158. ORDER BY sr.create_time desc
  159. </select>
  160. <select id="queryRoleByUserId" resultType="com.sckw.system.model.KwsRole">
  161. select b.*
  162. from kws_user_role a
  163. left join kws_role b on a.role_id = b.id
  164. where a.del_flag = 0
  165. and b.del_flag = 0
  166. and a.user_id = #{userId}
  167. </select>
  168. <select id="selectBatchByKeys" resultType="com.sckw.system.model.KwsRole">
  169. select a.*
  170. from kws_role a
  171. where a.id in
  172. <foreach collection="list" item="item" open="(" close=")" separator=",">
  173. #{item}
  174. </foreach>
  175. and a.del_flag = 0
  176. </select>
  177. <select id="selectBatchByUnitIds" resultType="com.sckw.system.model.KwsRole">
  178. select a.*
  179. from kws_role a
  180. where a.dept_id in
  181. <foreach collection="list" item="item" open="(" close=")" separator=",">
  182. #{item}
  183. </foreach>
  184. and a.del_flag = 0
  185. </select>
  186. </mapper>