MenuServiceDaoImplMapper.xml 15 KB

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