sysRoleModuleDao.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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="cn.ourwill.module.sys.dao.SysRoleModuleDao">
  4. <resultMap type="cn.ourwill.module.sys.entity.SysRoleModule" id="baseMap">
  5. <result column="id" property="id"/>
  6. <result column="role_id" property="roleId"/>
  7. <result column="module_id" property="moduleId"/>
  8. <result column="module_url" property="moduleUrl"/>
  9. <result column="module_pid" property="modulePid"/>
  10. <result column="module_id" property="moduleId"/>
  11. <result column="module_enname" property="moduleEnname"/>
  12. <result column="module_type" property="moduleType"/>
  13. <result column="status" property="status"/>
  14. <result column="c_id" property="cId"/>
  15. <result column="c_time" property="cTime"/>
  16. <result column="version" property="version"/>
  17. <result column="sort" property="sort"/>
  18. </resultMap>
  19. <sql id="columns">
  20. a.id ,
  21. a.role_id ,
  22. a.module_id ,
  23. a.c_id ,
  24. a.c_time ,
  25. a.version,
  26. m.sort,
  27. m.name as module_name,
  28. m.url as module_url,
  29. m.pid as module_pid,
  30. m.enname as module_enname,
  31. m.type as module_type,
  32. m.status as status,
  33. r.name as role_name
  34. </sql>
  35. <sql id="joinCols">
  36. left join sys_module m on a.module_id=m.id
  37. left join sys_role r on a.role_id=r.id
  38. </sql>
  39. <select id="get" resultMap="baseMap">
  40. SELECT
  41. <include refid="columns"/>
  42. FROM sys_role_module a
  43. <include refid="joinCols"/>
  44. WHERE a.id = #{id}
  45. </select>
  46. <select id="findList" resultMap="baseMap">
  47. SELECT
  48. <include refid="columns"/>
  49. FROM sys_role_module a
  50. <include refid="joinCols"/>
  51. <where>
  52. m.status=1
  53. /* and m.pid=0*/
  54. <if test="id !=null">
  55. and id = #{id}
  56. </if>
  57. <if test="roleId !=null">
  58. and role_id = #{roleId}
  59. </if>
  60. <if test="moduleId !=null">
  61. and module_id = #{moduleId}
  62. </if>
  63. <if test="cId !=null">
  64. and c_id = #{cId}
  65. </if>
  66. <if test="cTime !=null">
  67. and c_time = #{cTime}
  68. </if>
  69. <if test="version !=null">
  70. and version = #{version}
  71. </if>
  72. </where>
  73. <choose>
  74. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  75. ORDER BY ${page.orderBy}
  76. </when>
  77. <otherwise>
  78. </otherwise>
  79. </choose>
  80. </select>
  81. <select id="findAllList" resultMap="baseMap">
  82. SELECT
  83. <include refid="columns"/>
  84. FROM sys_role_module a
  85. <include refid="joinCols"/>
  86. <where>
  87. m.status=1
  88. <if test="id !=null">
  89. and id = #{id}
  90. </if>
  91. <if test="roleId !=null">
  92. and role_id = #{roleId}
  93. </if>
  94. <if test="moduleId !=null">
  95. and module_id = #{moduleId}
  96. </if>
  97. <if test="cId !=null">
  98. and c_id = #{cId}
  99. </if>
  100. <if test="version !=null">
  101. and version = #{version}
  102. </if>
  103. </where>
  104. <choose>
  105. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  106. ORDER BY ${page.orderBy}
  107. </when>
  108. <otherwise>
  109. </otherwise>
  110. </choose>
  111. </select>
  112. <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  113. parameterType="cn.ourwill.module.sys.entity.SysRoleModule">
  114. INSERT INTO sys_role_module
  115. <trim prefix="(" suffix=")" suffixOverrides=",">
  116. <if test=" id != null">
  117. id,
  118. </if>
  119. <if test=" roleId != null">
  120. role_id,
  121. </if>
  122. <if test=" moduleId != null">
  123. module_id,
  124. </if>
  125. <if test=" cId != null">
  126. c_id,
  127. </if>
  128. <if test=" cTime != null">
  129. c_time,
  130. </if>
  131. <if test=" version != null">
  132. version
  133. </if>
  134. </trim>
  135. <trim prefix="values (" suffix=")" suffixOverrides=",">
  136. <if test=" id != null">
  137. #{id}, </if>
  138. <if test=" roleId != null">
  139. #{roleId}, </if>
  140. <if test=" moduleId != null">
  141. #{moduleId}, </if>
  142. <if test=" cId != null">
  143. #{cId}, </if>
  144. <if test=" cTime != null">
  145. #{cTime}, </if>
  146. <if test=" version != null">
  147. #{version} </if>
  148. </trim>
  149. </insert>
  150. <update id="update" parameterType="cn.ourwill.module.sys.entity.SysRoleModule">
  151. UPDATE sys_role_module <set>
  152. <if test="id != null">
  153. id= #{id} ,
  154. </if>
  155. <if test="roleId != null">
  156. role_id= #{roleId} ,
  157. </if>
  158. <if test="moduleId != null">
  159. module_id= #{moduleId} ,
  160. </if>
  161. <if test="cId != null">
  162. c_id= #{cId} ,
  163. </if>
  164. <if test="cTime != null">
  165. c_time= #{cTime} ,
  166. </if>
  167. <if test="version != null">
  168. version= #{version}
  169. </if>
  170. </set>
  171. WHERE id = #{id}
  172. </update>
  173. <delete id="deleteById" parameterType="java.lang.Long">
  174. DELETE FROM sys_role_module WHERE id = #{id}
  175. </delete>
  176. <delete id="deleteByIds" parameterType="java.util.List">
  177. DELETE FROM sys_role_module WHERE id IN
  178. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  179. #{item}
  180. </foreach>
  181. </delete>
  182. <delete id="deleteByRoleId" parameterType="java.lang.Long">
  183. DELETE FROM sys_role_module WHERE role_id = #{roleId}
  184. </delete>
  185. <delete id="deleteByModuleId" parameterType="java.lang.Long">
  186. DELETE FROM sys_role_module WHERE module_id= #{id}
  187. </delete>
  188. </mapper>