MenuServiceDaoImplMapper.xml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="menuServiceDaoImpl">
  6. <!-- 保存路由信息至 instance表中 add by wuxw 2018-07-03 -->
  7. <insert id="saveMenuGroupInfo" parameterType="Map">
  8. insert into m_menu_group(
  9. g_id,name,icon,label,seq,description
  10. ) values (
  11. #{gId},#{name},#{icon},#{label},#{seq},#{description}
  12. )
  13. </insert>
  14. <!-- 查询路由信息 add by wuxw 2018-07-03 -->
  15. <select id="getMenuGroupInfo" parameterType="Map" resultType="Map">
  16. select t.g_id,t.name,t.icon,t.label,t.seq,t.description,t.g_id gId
  17. from m_menu_group t
  18. where t.status_cd= '0'
  19. <if test="gId !=null and gId != ''">
  20. and t.g_id= #{gId}
  21. </if>
  22. <if test="name !=null and name != ''">
  23. and t.name like concat('%',#{name},'%')
  24. </if>
  25. <if test="icon !=null and icon != ''">
  26. and t.icon= #{icon}
  27. </if>
  28. <if test="label !=null and label != ''">
  29. and t.label= #{label}
  30. </if>
  31. <if test="seq !=null">
  32. and t.seq= #{seq}
  33. </if>
  34. <if test="description !=null and description != ''">
  35. and t.description= #{description}
  36. </if>
  37. order by t.create_time desc
  38. <if test="page != -1 and page != null ">
  39. limit #{page}, #{row}
  40. </if>
  41. </select>
  42. <!-- 修改路由信息 add by wuxw 2018-07-03 -->
  43. <update id="updateMenuGroupInfo" parameterType="Map">
  44. update m_menu_group t
  45. <set>
  46. <if test="statusCd !=null and statusCd != ''">
  47. t.status_cd = #{statusCd},
  48. </if>
  49. <if test="name !=null and name != ''">
  50. t.name= #{name},
  51. </if>
  52. <if test="icon !=null and icon != ''">
  53. t.icon= #{icon},
  54. </if>
  55. <if test="label !=null ">
  56. t.label= #{label},
  57. </if>
  58. <if test="seq !=null ">
  59. t.seq= #{seq},
  60. </if>
  61. <if test="description !=null and description != ''">
  62. t.description= #{description}
  63. </if>
  64. </set>
  65. where t.g_id= #{gId}
  66. </update>
  67. <!-- 查询路由数量 add by wuxw 2018-07-03 -->
  68. <select id="queryMenuGroupsCount" parameterType="Map" resultType="Map">
  69. select count(1) count
  70. from m_menu_group t
  71. where 1 =1
  72. <if test="gId !=null and gId != ''">
  73. and t.g_id= #{gId}
  74. </if>
  75. <if test="name !=null and name != ''">
  76. and t.name like concat('%',#{name},'%')
  77. </if>
  78. <if test="icon !=null and icon != ''">
  79. and t.icon= #{icon}
  80. </if>
  81. <if test="statusCd !=null and statusCd != ''">
  82. and t.status_cd= #{statusCd}
  83. </if>
  84. <if test="label !=null and label != ''">
  85. and t.label= #{label}
  86. </if>
  87. <if test="seq !=null">
  88. and t.seq= #{seq}
  89. </if>
  90. <if test="description !=null and description != ''">
  91. and t.description= #{description}
  92. </if>
  93. </select>
  94. <!-- 保存路由信息至 instance表中 add by wuxw 2018-07-03 -->
  95. <insert id="saveBasePrivilegeRelInfo" parameterType="Map">
  96. insert into p_privilege_rel(
  97. p_id,pg_id
  98. ) values (
  99. #{pId},#{pgId}
  100. )
  101. </insert>
  102. <!-- 保存路由信息至 instance表中 add by wuxw 2018-07-03 -->
  103. <insert id="saveBasePrivilegeInfo" parameterType="Map">
  104. insert into p_privilege(
  105. p_id,name,resource,domain,description,m_id
  106. ) values (
  107. #{pId},#{name},#{resource},#{domain},#{description},#{mId}
  108. )
  109. </insert>
  110. <!-- 查询路由信息 add by wuxw 2018-07-03 -->
  111. <select id="getBasePrivilegeInfo" parameterType="Map" resultType="Map">
  112. select t.p_id,t.name,t.domain,t.resource,t.description,t.p_id pId,t.create_time createTime
  113. from p_privilege t
  114. where t.status_cd= '0'
  115. <if test="pId !=null and pId != ''">
  116. and t.p_id= #{pId}
  117. </if>
  118. <if test="name !=null and name != ''">
  119. and t.name like concat('%',#{name},'%')
  120. </if>
  121. <if test="resource !=null and resource != ''">
  122. and t.resource = #{resource}
  123. </if>
  124. <if test="domain !=null and domain != ''">
  125. and t.domain= #{domain}
  126. </if>
  127. <if test="mId !=null and mId != ''">
  128. and t.m_id= #{mId}
  129. </if>
  130. order by t.create_time desc
  131. <if test="page != -1 and page != null ">
  132. limit #{page}, #{row}
  133. </if>
  134. </select>
  135. <!-- 修改路由信息 add by wuxw 2018-07-03 -->
  136. <update id="updateBasePrivilegeInfo" parameterType="Map">
  137. update p_privilege t
  138. <set>
  139. <if test="statusCd !=null and statusCd != ''">
  140. t.status_cd = #{statusCd},
  141. </if>
  142. <if test="name !=null and name != ''">
  143. t.name= #{name},
  144. </if>
  145. <if test="resource !=null and resource != ''">
  146. t.resource= #{resource},
  147. </if>
  148. <if test="domain !=null and domain != ''">
  149. t.domain= #{domain},
  150. </if>
  151. <if test="description !=null and description != ''">
  152. t.description= #{description}
  153. </if>
  154. </set>
  155. where t.p_id= #{pId}
  156. </update>
  157. <!-- 修改路由信息 add by wuxw 2018-07-03 -->
  158. <update id="updateBasePrivilegeRelInfo" parameterType="Map">
  159. update p_privilege_rel t
  160. <set>
  161. <if test="statusCd !=null and statusCd != ''">
  162. t.status_cd = #{statusCd},
  163. </if>
  164. <if test="pgId !=null and pgId != ''">
  165. t.pg_id= #{pgId},
  166. </if>
  167. </set>
  168. where t.p_id= #{pId}
  169. </update>
  170. <!-- 查询路由数量 add by wuxw 2018-07-03 -->
  171. <select id="queryBasePrivilegesCount" parameterType="Map" resultType="Map">
  172. select count(1) count
  173. from p_privilege t
  174. where 1 =1
  175. <if test="pId !=null and pId != ''">
  176. and t.p_id= #{pId}
  177. </if>
  178. <if test="name !=null and name != ''">
  179. and t.name like concat('%',#{name},'%')
  180. </if>
  181. <if test="resource !=null and resource != ''">
  182. and t.resource = #{resource}
  183. </if>
  184. <if test="domain !=null and domain != ''">
  185. and t.domain= #{domain}
  186. </if>
  187. <if test="mId !=null and mId != ''">
  188. and t.m_id= #{mId}
  189. </if>
  190. <if test="statusCd !=null and statusCd != ''">
  191. and t.status_cd= #{statusCd}
  192. </if>
  193. </select>
  194. <!-- 保存路由信息至 instance表中 add by wuxw 2018-07-03 -->
  195. <insert id="saveMenuInfo" parameterType="Map">
  196. insert into m_menu(
  197. m_id,name,g_id,url,seq,p_id,description,is_show
  198. ) values (
  199. #{mId},#{name},#{gId},#{url},#{seq},'-1',#{description},#{isShow}
  200. )
  201. </insert>
  202. <!-- 查询路由信息 add by wuxw 2018-07-03 -->
  203. <select id="getMenuInfo" parameterType="Map" resultType="Map">
  204. select DISTINCT t.m_id mId,t.name,t.g_id gId,t.url,t.seq,t.p_id pId,t.description,t.is_show isShow,
  205. if(t.is_show='Y','显示','不显示') isShowName,
  206. t.m_id pId,t.name pName
  207. from m_menu t,p_privilege p
  208. where t.status_cd= '0'
  209. and p.status_cd= '0'
  210. and t.m_id = p.m_id
  211. <if test="gId !=null and gId != ''">
  212. and t.g_id= #{gId}
  213. </if>
  214. <if test="name !=null and name != ''">
  215. and t.name like concat('%',#{name},'%')
  216. </if>
  217. <if test="mName !=null and mName != ''">
  218. and t.name like concat('%',#{mName},'%')
  219. </if>
  220. <if test="domain !=null and domain != ''">
  221. and p.domain= #{domain}
  222. </if>
  223. <if test="pName !=null and pName != ''">
  224. and p.name like concat('%',#{pName},'%')
  225. </if>
  226. <if test="mId !=null and mId != ''">
  227. and t.m_id= #{mId}
  228. </if>
  229. <if test="pId !=null and pId != ''">
  230. and p.p_id= #{pId}
  231. </if>
  232. <if test="isShow !=null and isShow != ''">
  233. and t.is_show= #{isShow}
  234. </if>
  235. <if test="url !=null and url != ''">
  236. and t.url like concat('%',#{url},'%')
  237. </if>
  238. <if test="seq !=null">
  239. and t.seq= #{seq}
  240. </if>
  241. <if test="description !=null and description != ''">
  242. and t.description= #{description}
  243. </if>
  244. <if test="uName != null and uName != ''">
  245. and exists(
  246. SELECT 1
  247. FROM p_privilege_user ppu,u_user u
  248. WHERE ppu.`p_id` = p.`p_id`
  249. AND ppu.`privilege_flag` = '0'
  250. and ppu.user_id = u.user_id
  251. AND u.`name` = #{uName}
  252. AND ppu.`status_cd` = '0'
  253. UNION
  254. SELECT 1
  255. FROM p_privilege_user ppu,
  256. p_privilege_group ppg,p_privilege_rel ppr,u_user u
  257. WHERE ppu.`p_id` = ppr.pg_id
  258. AND ppr.pg_id = ppg.pg_id
  259. AND ppr.p_id = p.`p_id`
  260. AND ppu.`privilege_flag` = '1'
  261. and ppu.user_id = u.user_id
  262. AND u.`name` = #{uName}
  263. AND ppu.`status_cd` = '0'
  264. AND ppg.status_cd = '0'
  265. AND ppr.status_cd = '0'
  266. )
  267. </if>
  268. order by t.seq asc
  269. <if test="page != -1 and page != null ">
  270. limit #{page}, #{row}
  271. </if>
  272. </select>
  273. <!-- 修改路由信息
  274. ,t.description,t.is_show isShow
  275. add by wuxw 2018-07-03 -->
  276. <update id="updateMenuInfo" parameterType="Map">
  277. update m_menu t
  278. <set>
  279. <if test="statusCd !=null and statusCd != ''">
  280. t.status_cd = #{statusCd},
  281. </if>
  282. <if test="name !=null and name != ''">
  283. t.name= #{name},
  284. </if>
  285. <if test="gId !=null and gId != ''">
  286. t.g_id= #{gId},
  287. </if>
  288. <if test="url !=null and url != ''">
  289. t.url= #{url},
  290. </if>
  291. <if test="seq !=null ">
  292. t.seq= #{seq},
  293. </if>
  294. <if test="isShow !=null and isShow != ''">
  295. t.is_show= #{isShow},
  296. </if>
  297. <if test="description !=null and description != ''">
  298. t.description= #{description}
  299. </if>
  300. </set>
  301. where t.m_id= #{mId}
  302. </update>
  303. <!-- 查询路由数量 add by wuxw 2018-07-03 -->
  304. <select id="queryMenusCount" parameterType="Map" resultType="Map">
  305. select count(DISTINCT(t.m_id)) count
  306. from m_menu t,p_privilege p
  307. where t.status_cd= '0'
  308. and p.status_cd= '0'
  309. and t.m_id = p.m_id
  310. <if test="gId !=null and gId != ''">
  311. and t.g_id= #{gId}
  312. </if>
  313. <if test="name !=null and name != ''">
  314. and t.name like concat('%',#{name},'%')
  315. </if>
  316. <if test="mName !=null and mName != ''">
  317. and t.name like concat('%',#{mName},'%')
  318. </if>
  319. <if test="pId !=null and pId != ''">
  320. and t.p_id= #{pId}
  321. </if>
  322. <if test="domain !=null and domain != ''">
  323. and p.domain= #{domain}
  324. </if>
  325. <if test="pName !=null and pName != ''">
  326. and p.name like concat('%',#{pName},'%')
  327. </if>
  328. <if test="mId !=null and mId != ''">
  329. and p.m_id= #{mId}
  330. </if>
  331. <if test="pId !=null and pId != ''">
  332. and t.p_id= #{pId}
  333. </if>
  334. <if test="isShow !=null and isShow != ''">
  335. and t.is_show= #{isShow}
  336. </if>
  337. <if test="url !=null and url != ''">
  338. and t.url like concat('%',#{url},'%')
  339. </if>
  340. <if test="seq !=null">
  341. and t.seq= #{seq}
  342. </if>
  343. <if test="description !=null and description != ''">
  344. and t.description= #{description}
  345. </if>
  346. <if test="uName != null and uName != ''">
  347. and exists(
  348. SELECT 1
  349. FROM p_privilege_user ppu,u_user u
  350. WHERE ppu.`p_id` = p.`p_id`
  351. AND ppu.`privilege_flag` = '0'
  352. and ppu.user_id = u.user_id
  353. AND u.`name` = #{uName}
  354. AND ppu.`status_cd` = '0'
  355. UNION
  356. SELECT 1
  357. FROM p_privilege_user ppu,
  358. p_privilege_group ppg,p_privilege_rel ppr,u_user u
  359. WHERE ppu.`p_id` = ppr.pg_id
  360. AND ppr.pg_id = ppg.pg_id
  361. AND ppr.p_id = p.`p_id`
  362. AND ppu.`privilege_flag` = '1'
  363. and ppu.user_id = u.user_id
  364. AND u.`name` = #{uName}
  365. AND ppu.`status_cd` = '0'
  366. AND ppg.status_cd = '0'
  367. AND ppr.status_cd = '0'
  368. )
  369. </if>
  370. </select>
  371. <select id="checkUserHasResource" parameterType="Map" resultType="Map">
  372. SELECT pp.*,'-1' AS pg_id,'' AS pg_name FROM p_privilege_user ppu,p_privilege pp
  373. WHERE ppu.`p_id` = pp.`p_id`
  374. <if test="resource != null and resource != ''">
  375. AND pp.`resource` = #{resource}
  376. </if>
  377. AND ppu.`privilege_flag` = '0'
  378. AND ppu.`user_id` = #{userId}
  379. AND ppu.`status_cd` = '0'
  380. AND pp.`status_cd` = '0'
  381. UNION
  382. SELECT pp.*,ppg.pg_id,ppg.name pg_name FROM p_privilege_user ppu,p_privilege_group ppg,p_privilege
  383. pp,p_privilege_rel ppr
  384. WHERE ppu.`p_id` = ppr.pg_id
  385. AND ppr.pg_id = ppg.pg_id
  386. AND ppr.p_id = pp.`p_id`
  387. <if test="resource != null and resource != ''">
  388. AND pp.`resource` = #{resource}
  389. </if>
  390. AND ppu.`privilege_flag` = '1'
  391. AND ppu.`user_id` = #{userId}
  392. AND ppu.`status_cd` = '0'
  393. AND pp.`status_cd` = '0'
  394. AND ppg.status_cd = '0'
  395. AND ppr.status_cd = '0'
  396. </select>
  397. </mapper>