SysModuleDao.xml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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.SysModuleDao">
  4. <resultMap type="cn.ourwill.module.sys.entity.SysModule" id="baseMap">
  5. <result column="id" property="id"/>
  6. <result column="pid" property="pid"/>
  7. <result column="name" property="text"/>
  8. <result column="url" property="url"/>
  9. <result column="type" property="type"/>
  10. <result column="desc" property="desc"/>
  11. <result column="sort" property="sort"/>
  12. <result column="version" property="version"/>
  13. <result column="status" property="status"/>
  14. </resultMap>
  15. <sql id="columns">
  16. id ,
  17. pid ,
  18. `name` ,
  19. url ,
  20. `type`,
  21. `desc` ,
  22. sort ,
  23. version,
  24. status
  25. </sql>
  26. <sql id="joinCols">
  27. </sql>
  28. <select id="get" resultMap="baseMap">
  29. SELECT
  30. <include refid="columns"/>
  31. FROM sys_module a
  32. <include refid="joinCols"/>
  33. WHERE a.id = #{id}
  34. </select>
  35. <select id="findList" resultMap="baseMap">
  36. SELECT
  37. <include refid="columns"/>
  38. FROM sys_module a
  39. <include refid="joinCols"/>
  40. <where>
  41. <if test="id !=null">
  42. and id = #{id}
  43. </if>
  44. <if test="pid !=null">
  45. and pid = #{pid}
  46. </if>
  47. <if test="text !=null">
  48. and `name` = #{text}
  49. </if>
  50. <if test="url !=null">
  51. and url = #{url}
  52. </if>
  53. <if test="desc !=null">
  54. and `desc` = #{desc}
  55. </if>
  56. <if test="sort !=null">
  57. and sort = #{sort}
  58. </if>
  59. <if test="version !=null">
  60. and version = #{version}
  61. </if>
  62. <if test="status !=null">
  63. and status = #{status}
  64. </if>
  65. </where>
  66. <choose>
  67. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  68. ORDER BY ${page.orderBy}
  69. </when>
  70. <otherwise>
  71. </otherwise>
  72. </choose>
  73. </select>
  74. <select id="findAllList" resultMap="baseMap">
  75. SELECT
  76. <include refid="columns"/>
  77. FROM sys_module a
  78. <include refid="joinCols"/>
  79. <where>
  80. and status="1"
  81. <if test="id !=null">
  82. and id = #{id}
  83. </if>
  84. <if test="pid !=null">
  85. and pid = #{pid}
  86. </if>
  87. <if test="text !=null">
  88. and `name` = #{text}
  89. </if>
  90. <if test="url !=null">
  91. and url = #{url}
  92. </if>
  93. <if test="version !=null">
  94. and version = #{version}
  95. </if>
  96. <if test="status !=null">
  97. and status = #{status}
  98. </if>
  99. </where>
  100. <choose>
  101. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  102. ORDER BY ${page.orderBy}
  103. </when>
  104. <otherwise>
  105. </otherwise>
  106. </choose>
  107. </select>
  108. <insert id="insert" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
  109. parameterType="cn.ourwill.module.sys.entity.SysModule">
  110. INSERT INTO sys_module
  111. <trim prefix="(" suffix=")" suffixOverrides=",">
  112. <if test=" id != null">
  113. id,
  114. </if>
  115. <if test=" pid != null">
  116. pid,
  117. </if>
  118. <if test=" text != null">
  119. `name`,
  120. </if>
  121. <if test=" url != null">
  122. url,
  123. </if>
  124. <if test=" desc != null">
  125. `desc`,
  126. </if>
  127. <if test=" sort != null">
  128. sort,
  129. </if>
  130. <if test=" type != null">
  131. `type`,
  132. </if>
  133. <if test=" version != null">
  134. version,
  135. </if>
  136. <if test=" status != null">
  137. status
  138. </if>
  139. </trim>
  140. <trim prefix="values (" suffix=")" suffixOverrides=",">
  141. <if test=" id != null">
  142. #{id}, </if>
  143. <if test=" pid != null">
  144. #{pid}, </if>
  145. <if test=" text != null">
  146. #{text}, </if>
  147. <if test=" url != null">
  148. #{url}, </if>
  149. <if test=" desc != null">
  150. #{desc}, </if>
  151. <if test=" sort != null">
  152. #{sort}, </if>
  153. <if test=" type != null">
  154. #{type}, </if>
  155. <if test=" version != null">
  156. #{version}, </if>
  157. <if test=" version != null">
  158. #{status} </if>
  159. </trim>
  160. </insert>
  161. <update id="update" parameterType="cn.ourwill.module.sys.entity.SysModule">
  162. UPDATE sys_module <set>
  163. <if test="id != null">
  164. id= #{id} ,
  165. </if>
  166. <if test="pid != null">
  167. pid= #{pid} ,
  168. </if>
  169. <if test="text != null">
  170. `name`= #{text} ,
  171. </if>
  172. <if test="url != null">
  173. url= #{url} ,
  174. </if>
  175. <if test="desc != null">
  176. `desc`= #{desc} ,
  177. </if>
  178. <if test="sort != null">
  179. sort= #{sort} ,
  180. </if>
  181. <if test="type != null">
  182. `type`= #{type} ,
  183. </if>
  184. <if test="version != null">
  185. version= #{version},
  186. </if>
  187. <if test="status != null">
  188. status= #{status}
  189. </if>
  190. </set>
  191. WHERE id = #{id}
  192. </update>
  193. <delete id="deleteById" parameterType="java.lang.Long">
  194. DELETE FROM sys_module WHERE id = #{id}
  195. </delete>
  196. <delete id="deleteByIds" parameterType="java.util.List">
  197. DELETE FROM sys_module WHERE id IN
  198. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  199. #{item},
  200. </foreach>
  201. </delete>
  202. <select id="getModuleByIds" parameterType="java.util.List" resultType="java.util.List">
  203. SELECT
  204. *
  205. FROM
  206. sys_module
  207. where id in
  208. <foreach collection="list" index="index" item="item" open="(" separator="," close=")">
  209. #{item},
  210. </foreach>
  211. </select>
  212. <select id="getModuleById" parameterType="java.lang.Long" resultType="cn.ourwill.module.sys.entity.SysModule">
  213. SELECT
  214. *
  215. FROM
  216. sys_module
  217. where id=#{VALUE }
  218. </select>
  219. <select id="getChildModule" resultMap="baseMap">
  220. SELECT
  221. *
  222. FROM
  223. sys_module
  224. where pid=#{VALUE }
  225. </select>
  226. </mapper>