SysPortalConfigMapper.xml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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.aidex.system.mapper.SysPortalConfigMapper">
  4. <sql id="sysPortalConfigColumns">
  5. a.name as "name",
  6. a.code as "code",
  7. a.application_range as "applicationRange",
  8. a.is_default as "isDefault",
  9. a.resource_id as "resourceId",
  10. a.system_defined_id as "systemDefinedId",
  11. a.content as "content",
  12. a.sort as "sort",
  13. a.status as "status",
  14. a.remark as "remark",
  15. a.id as "id",
  16. a.create_by as "createBy",
  17. a.create_dept as "createDept",
  18. a.create_time as "createTime",
  19. a.update_by as "updateBy",
  20. a.update_time as "updateTime",
  21. a.update_ip as "updateIp",
  22. a.version as "version",
  23. a.del_flag as "delFlag"
  24. </sql>
  25. <sql id="sysPortalConfigBaseColumns">
  26. a.name as "name",
  27. a.code as "code",
  28. a.application_range as "applicationRange",
  29. a.is_default as "isDefault",
  30. a.resource_id as "resourceId",
  31. a.system_defined_id as "systemDefinedId",
  32. a.sort as "sort",
  33. a.status as "status",
  34. a.content as "content",
  35. a.id as "id"
  36. </sql>
  37. <sql id="sysPortalConfigJoins">
  38. </sql>
  39. <select id="get" resultType="SysPortalConfig">
  40. SELECT
  41. <include refid="sysPortalConfigColumns"/>
  42. FROM sys_portal_config a
  43. <include refid="sysPortalConfigJoins"/>
  44. WHERE a.id = #{id}
  45. </select>
  46. <select id="findList" resultType="SysPortalConfig">
  47. SELECT
  48. <include refid="sysPortalConfigColumns"/>,
  49. case when a.application_range = 'U' THEN
  50. u.user_name
  51. when a.application_range = 'R' THEN
  52. r.role_name
  53. end resourceName
  54. FROM sys_portal_config a
  55. <include refid="sysPortalConfigJoins"/>
  56. left join sys_user u on a.resource_id = u.id
  57. left join sys_role r on a.resource_id = r.id
  58. <where>
  59. a.del_flag = #{DEL_FLAG_NORMAL}
  60. <if test="name != null and name != ''">
  61. and a.name like concat('%', #{name}, '%')
  62. </if>
  63. <if test="code != null and code != ''">
  64. and a.code like concat('%', #{code}, '%')
  65. </if>
  66. <if test="applicationRange != null and applicationRange != ''">
  67. AND a.application_range = #{applicationRange}
  68. </if>
  69. <if test="isDefault != null and isDefault != ''">
  70. AND a.is_default = #{isDefault}
  71. </if>
  72. </where>
  73. <choose>
  74. <when test="page !=null and page.orderByColumn != null and page.orderByColumn != ''">
  75. ORDER BY ${page.orderByColumn}
  76. </when>
  77. <otherwise>
  78. ORDER BY a.sort
  79. </otherwise>
  80. </choose>
  81. </select>
  82. <select id="findListWithUnique" resultType="SysPortalConfig">
  83. SELECT
  84. a.id
  85. FROM sys_portal_config a
  86. <include refid="sysPortalConfigJoins"/>
  87. <where>
  88. a.del_flag = #{DEL_FLAG_NORMAL}
  89. <if test="notEqualId != null and notEqualId != ''">
  90. AND id != #{notEqualId}
  91. </if>
  92. <if test="code != null and code != ''">
  93. and code = #{code}
  94. </if>
  95. </where>
  96. </select>
  97. <select id="findMaxSort" resultType="integer">
  98. SELECT
  99. max(a.sort)
  100. FROM sys_portal_config a
  101. WHERE a.del_flag = #{DEL_FLAG_NORMAL}
  102. </select>
  103. <insert id="insert">
  104. INSERT INTO sys_portal_config(
  105. name,
  106. code,
  107. application_range,
  108. is_default,
  109. resource_id,
  110. system_defined_id,
  111. content,
  112. sort,
  113. status,
  114. remark,
  115. id,
  116. create_by,
  117. create_dept,
  118. create_time,
  119. update_by,
  120. update_time,
  121. update_ip,
  122. version,
  123. del_flag
  124. ) VALUES (
  125. #{name},
  126. #{code},
  127. #{applicationRange},
  128. #{isDefault},
  129. #{resourceId},
  130. #{systemDefinedId},
  131. #{content},
  132. #{sort},
  133. #{status},
  134. #{remark},
  135. #{id},
  136. #{createBy},
  137. #{createDept},
  138. #{createTime},
  139. #{updateBy},
  140. #{updateTime},
  141. #{updateIp},
  142. #{version},
  143. #{delFlag}
  144. )
  145. </insert>
  146. <update id="update">
  147. UPDATE sys_portal_config SET
  148. name = #{name},
  149. code = #{code},
  150. application_range = #{applicationRange},
  151. is_default = #{isDefault},
  152. resource_id = #{resourceId},
  153. system_defined_id = #{systemDefinedId},
  154. content = #{content},
  155. sort = #{sort},
  156. status = #{status},
  157. remark = #{remark},
  158. update_by = #{updateBy},
  159. update_time = #{updateTime},
  160. update_ip = #{updateIp},
  161. version = version + 1
  162. WHERE id = #{id} and version = #{version}
  163. </update>
  164. <update id="delete">
  165. UPDATE sys_portal_config SET
  166. del_flag = #{DEL_FLAG_DELETE}
  167. WHERE id = #{id}
  168. </update>
  169. <delete id="deleteSysPortalConfigByIds">
  170. UPDATE sys_portal_config SET
  171. del_flag = '1'
  172. WHERE id in
  173. <foreach item="id" collection="array" open="(" separator="," close=")">
  174. #{id}
  175. </foreach>
  176. </delete>
  177. <select id="findUserConfigList" resultType="SysPortalConfig">
  178. SELECT
  179. <include refid="sysPortalConfigBaseColumns"/>
  180. FROM
  181. (
  182. SELECT
  183. *
  184. FROM
  185. sys_portal_config a
  186. WHERE
  187. a.del_flag = #{DEL_FLAG_NORMAL}
  188. AND a.application_range = 'U'
  189. AND a.resource_id = #{resourceId}
  190. UNION ALL
  191. SELECT
  192. *
  193. FROM
  194. sys_portal_config a
  195. WHERE
  196. a.del_flag = #{DEL_FLAG_NORMAL}
  197. AND a.application_range = 'S'
  198. AND NOT EXISTS (
  199. SELECT
  200. 1
  201. FROM
  202. sys_portal_config p
  203. WHERE
  204. p.del_flag = #{DEL_FLAG_NORMAL}
  205. AND p.application_range = 'U'
  206. AND p.resource_id = #{resourceId}
  207. AND p. CODE = a. CODE
  208. )
  209. UNION ALL
  210. SELECT
  211. *
  212. FROM
  213. sys_portal_config a
  214. WHERE
  215. a.del_flag = #{DEL_FLAG_NORMAL}
  216. AND a.application_range = 'R'
  217. AND NOT EXISTS (
  218. SELECT
  219. 1
  220. FROM
  221. sys_portal_config p
  222. WHERE
  223. p.del_flag = #{DEL_FLAG_NORMAL}
  224. AND p.application_range = 'U'
  225. AND p.resource_id = #{resourceId}
  226. AND p. CODE = a. CODE
  227. )
  228. AND EXISTS (
  229. SELECT
  230. 1
  231. FROM
  232. sys_user_role r
  233. WHERE
  234. r.role_id = a.resource_id
  235. and r.user_id = #{resourceId}
  236. )
  237. ) a
  238. ORDER BY
  239. a.create_time
  240. </select>
  241. <update id="updateNotDefaultByUser">
  242. UPDATE sys_portal_config SET
  243. is_default = 'N'
  244. WHERE application_range = 'U' and resource_id = #{resourceId};
  245. UPDATE sys_portal_config SET
  246. is_default = 'Y'
  247. WHERE id = #{id};
  248. </update>
  249. <select id="getPortalTemplateList" resultType="SysPortalConfig">
  250. SELECT
  251. <include refid="sysPortalConfigBaseColumns"/>
  252. FROM
  253. (
  254. SELECT
  255. *
  256. FROM
  257. sys_portal_config a
  258. WHERE
  259. a.del_flag = #{DEL_FLAG_NORMAL}
  260. AND a.application_range = 'S'
  261. union ALL
  262. SELECT
  263. *
  264. FROM
  265. sys_portal_config a
  266. WHERE
  267. a.del_flag = #{DEL_FLAG_NORMAL}
  268. AND a.application_range = 'R'
  269. AND EXISTS (
  270. SELECT
  271. 1
  272. FROM
  273. sys_user_role r
  274. WHERE
  275. r.role_id = a.resource_id
  276. AND r.user_id =#{resourceId}
  277. )
  278. ) a
  279. ORDER BY
  280. a.create_time
  281. </select>
  282. </mapper>