Menu.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  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.oqpo.api.mapper.system.MenuMapper">
  4. <select id="selectUserAuthMenuList" resultType="com.oqpo.api.entity.oper.MenuEntity">
  5. with recursive tree_menu_list /* selectUserAuthMenuList */
  6. as
  7. (
  8. select 1 level
  9. , menu_no
  10. , top_menu_no
  11. , menu_nm
  12. , view_num
  13. , open_cd
  14. , conn_url
  15. , cast(menu_no as char(100) character set utf8) id_path
  16. , use_yn
  17. , fn_code_nm('USE_YN', use_yn) as use_yn_nm
  18. , menu_id
  19. from np_sys_menu
  20. where top_menu_no = 10
  21. union all
  22. select c.level + 1
  23. , b.menu_no
  24. , b.top_menu_no
  25. , b.menu_nm
  26. , b.view_num
  27. , b.open_cd
  28. , b.conn_url
  29. , concat(c.id_path, '->', case when b.view_num <![CDATA[ < ]]> 10 then concat('0',b.view_num) else b.view_num end ,'->', b.menu_no) as id_path
  30. , b.use_yn
  31. , fn_code_nm('USE_YN', b.use_yn) as use_yn_nm
  32. , b.menu_id
  33. from np_sys_menu b, tree_menu_list c
  34. where c.menu_no = b.top_menu_no
  35. and b.sys_type_cd = 'W'
  36. )
  37. select tlist.menu_no, tlist.top_menu_no, fn_get_menu_nm(tlist.top_menu_no) as top_menu_nm, tlist.menu_nm, tlist.view_num, tlist.level , tlist.use_yn, tlist.use_yn_nm
  38. , tlist.open_cd, case when tlist.open_cd != 'C' then (select count(*) from np_sys_menu where top_menu_no = tlist.menu_no ) else 0 end as b_menu_cnt
  39. , tlist.conn_url, tlist.menu_id
  40. from tree_menu_list tlist
  41. <if test="systemAdminYn neq 'Y'.toString() ">
  42. join ( select 100 as top_menu_no, top_menu_no as menu_no, 'Y' as wr_yn
  43. from np_user_auth uauth
  44. join np_auth_info ainfo on uauth.auth_no = ainfo.auth_no and ainfo.use_yn = 'Y'
  45. where uauth.user_id = #{userId}
  46. union all
  47. select ainfo.top_menu_no, adtl.menu_no, adtl.wr_yn
  48. from np_user_auth uauth
  49. join np_auth_info ainfo on uauth.auth_no = ainfo.auth_no and ainfo.use_yn = 'Y'
  50. join np_auth_dtl adtl on uauth.auth_no = adtl.auth_no and adtl.use_yn = 'Y'
  51. where uauth.user_id = #{userId} ) umenu
  52. on tlist.top_menu_no = umenu.top_menu_no and tlist.menu_no = umenu.menu_no
  53. </if>
  54. where tlist.use_yn = 'Y'
  55. and tlist.open_cd in ('T','C')
  56. order by id_path
  57. </select>
  58. <select id="selectAuthMenuList" resultType="com.oqpo.api.entity.oper.MenuEntity">
  59. select x.* from ( /** selectAuthMenuList */
  60. select distinct
  61. <choose>
  62. <when test="systemAdminYn eq 'Y'.toString()">
  63. menu.menu_no
  64. , menu.menu_nm
  65. , '' as 'auth.authNo'
  66. , #{userId} as 'userAuth.userId'
  67. </when>
  68. <when test="superAdminYn eq 'Y'.toString()">
  69. menu.menu_no
  70. , menu.menu_nm
  71. , '' as 'auth.authNo'
  72. , #{userId} as 'userAuth.userId'
  73. </when>
  74. <otherwise>
  75. menu.menu_no
  76. , menu.menu_nm
  77. , auth.auth_no as 'auth.authNo'
  78. , userAuth.user_id as 'userAuth.userId'
  79. </otherwise>
  80. </choose>
  81. , menu.menu_id
  82. , menu.conn_url
  83. , #{systemAdminYn} as 'member.systemAdminYn'
  84. , #{superAdminYn} as 'member.superAdminYn'
  85. , 1 as level
  86. , view_num
  87. from np_sys_menu menu
  88. <if test="systemAdminYn neq 'Y'.toString() and superAdminYn neq 'Y'.toString()">
  89. inner join np_auth_info auth
  90. on menu.menu_no = auth.top_menu_no
  91. and auth.use_yn = 'Y'
  92. inner join np_user_auth userAuth
  93. on auth.auth_no = userAuth.auth_no
  94. and userAuth.user_id = #{userId}
  95. </if>
  96. where menu.open_cd in ('S', 'T', 'C')
  97. and menu.use_yn = 'Y'
  98. and menu.sys_type_cd = 'W'
  99. <if test="systemAdminYn eq 'Y'.toString() or superAdminYn eq 'Y'.toString()">
  100. and menu.top_menu_no = 100
  101. <if test="superAdminYn eq 'Y'.toString()">
  102. and menu.menu_no != 2
  103. </if>
  104. </if>
  105. order by menu.view_num
  106. ) x
  107. order by x.view_num
  108. </select>
  109. <select id="selectAuthSubMenuList" resultType="com.oqpo.api.entity.oper.MenuEntity">
  110. select distinct /** selectAuthSubMenuList */
  111. menu.menu_no
  112. , menu.menu_nm
  113. , menu.menu_id
  114. , menu.conn_url
  115. , menu.icon_yn
  116. <if test="memberEntity.systemAdminYn neq 'Y'.toString() and memberEntity.superAdminYn neq 'Y'.toString()">
  117. , authDtl.wr_yn as 'authDtl.writeYn'
  118. </if>
  119. <if test="memberEntity.systemAdminYn eq 'Y'.toString() or memberEntity.superAdminYn eq 'Y'.toString()">
  120. , 'Y' as 'authDtl.writeYn'
  121. </if>
  122. , 2 as level
  123. from np_sys_menu menu
  124. <if test="memberEntity.systemAdminYn neq 'Y'.toString() and memberEntity.superAdminYn neq 'Y'.toString()">
  125. inner join np_auth_dtl authDtl
  126. on menu.menu_no = authDtl.menu_no
  127. and authDtl.auth_no = #{menuEntity.authDtl.authNo}
  128. and authDtl.use_yn = 'Y'
  129. inner join np_user_auth auth
  130. on authDtl.auth_no = auth.auth_no
  131. and auth.user_id = #{menuEntity.userAuth.userId}
  132. </if>
  133. where menu.open_cd in ('S', 'T', 'C')
  134. and menu.use_yn = 'Y'
  135. and menu.top_menu_no = #{menuEntity.menuNo}
  136. and menu.sys_type_cd = 'W'
  137. order by menu.view_num
  138. </select>
  139. <select id="selectAllMenuList" resultType="com.oqpo.api.entity.oper.MenuEntity">
  140. with recursive tree_menu_list /* selectAllMenuList */
  141. as
  142. (
  143. select 1 level
  144. , menu_no
  145. , top_menu_no
  146. , menu_nm
  147. , view_num
  148. , open_cd
  149. , cast(menu_no as char(100) character set utf8) id_path
  150. , use_yn
  151. , fn_code_nm('USE_YN', use_yn) as use_yn_nm
  152. from np_sys_menu
  153. where top_menu_no = 0
  154. union all
  155. select c.level + 1
  156. , b.menu_no
  157. , b.top_menu_no
  158. , b.menu_nm
  159. , b.view_num
  160. , b.open_cd
  161. , concat(c.id_path, '->', case when b.view_num <![CDATA[ < ]]> 10 then concat('0',b.view_num) else b.view_num end ,'->', b.menu_no) as id_path
  162. , b.use_yn
  163. , fn_code_nm('USE_YN', b.use_yn) as use_yn_nm
  164. from np_sys_menu b, tree_menu_list c
  165. where c.menu_no = b.top_menu_no
  166. )
  167. select tlist.menu_no, tlist.top_menu_no, fn_get_menu_nm(tlist.top_menu_no) as top_menu_nm, tlist.menu_nm, tlist.view_num, tlist.level , tlist.use_yn, tlist.use_yn_nm
  168. , tlist.open_cd, case when tlist.open_cd != 'C' then (select count(*) from np_sys_menu where top_menu_no = tlist.menu_no ) else 0 end as b_menu_cnt
  169. from tree_menu_list tlist
  170. order by id_path
  171. </select>
  172. <select id="selectMenuInfo" resultType="com.oqpo.api.entity.oper.MenuEntity">
  173. select /* selectMenuInfo */
  174. menu_no, menu_id, top_menu_no, menu_nm, use_yn, view_num, conn_url, icon_yn, role_desc, open_cd
  175. ,fn_get_menu_nm(top_menu_no) as top_menu_nm
  176. from np_sys_menu
  177. where menu_no = #{menuNo}
  178. </select>
  179. <insert id="insertMenu" >
  180. insert into np_sys_menu /** insertMenu */
  181. ( menu_id, top_menu_no, menu_nm, use_yn, view_num, conn_url, icon_yn, role_desc, open_cd , add_dt, add_id, chg_dt, chg_id)
  182. values
  183. ( #{entity.menuId}, #{entity.topMenuNo}, #{entity.menuNm}, #{entity.useYn}, #{entity.viewNum}, #{entity.connUrl}, #{entity.iconYn}, #{entity.roleDesc}, #{entity.openCd}, now(), #{userId}, now(), #{userId})
  184. </insert>
  185. <update id="updateMenu" >
  186. update np_sys_menu
  187. set chg_dt = now()
  188. , chg_id = #{userId}
  189. , menu_nm = #{entity.menuNm}
  190. , use_yn = #{entity.useYn}
  191. , view_num = #{entity.viewNum}
  192. , conn_url = #{entity.connUrl}
  193. , icon_yn = #{entity.iconYn}
  194. , role_desc = #{entity.roleDesc}
  195. , open_cd = #{entity.openCd}
  196. where menu_no = #{entity.menuNo}
  197. </update>
  198. <delete id="deleteMenu" >
  199. delete from np_sys_menu
  200. where menu_no = #{menuNo}
  201. </delete>
  202. <select id="selectMenuIdDupYn" resultType="String">
  203. select case when count(*) <![CDATA[ > ]]> 0 then 'Y' else 'N' end as cnt /* selectMenuIdDupYn */
  204. from np_sys_menu
  205. where menu_id = #{menuId}
  206. </select>
  207. <select id="selectTopMenuList" resultType="com.oqpo.api.entity.oper.MenuEntity">
  208. select /* selectTopMenuList */
  209. menu_no, menu_id, top_menu_no, menu_nm, use_yn, view_num, conn_url, icon_yn, role_desc, open_cd
  210. ,fn_get_menu_nm(top_menu_no) as top_menu_nm
  211. from np_sys_menu
  212. where top_menu_no = 100
  213. and use_yn = 'Y'
  214. and open_cd in ('T','C')
  215. order by view_num asc
  216. </select>
  217. <select id="selectBottomMenuList" resultType="com.oqpo.api.entity.oper.MenuEntity">
  218. with recursive tree_menu_list /* selectBottomMenuList */
  219. as
  220. (
  221. select 1 level
  222. , menu_no
  223. , top_menu_no
  224. , menu_nm
  225. , cast(menu_no as char(100) character set utf8) id_path
  226. from np_sys_menu
  227. where top_menu_no = #{topMenuNo}
  228. and open_cd <![CDATA[ <> ]]> 'P'
  229. union all
  230. select c.level + 1
  231. , b.menu_no
  232. , b.top_menu_no
  233. , b.menu_nm
  234. , concat(c.id_path, '->', case when b.view_num <![CDATA[ < ]]> 10 then concat('0',b.view_num) else b.view_num end ,'->', b.menu_no) as id_path
  235. from np_sys_menu b, tree_menu_list c
  236. where c.menu_no = b.top_menu_no
  237. and b.open_cd <![CDATA[ <> ]]> 'P'
  238. )
  239. select tlist.menu_no, tlist.top_menu_no, fn_get_menu_nm(tlist.top_menu_no) as top_menu_nm, tlist.menu_nm
  240. <if test="authNo != null and authNo != ''">
  241. , case when dtl.menu_no is null then 'N' else 'Y' end as 'authDtl.readYn'
  242. , nvl(dtl.wr_yn,'N') as 'authDtl.writeYn'
  243. </if>
  244. <if test="authNo == null or authNo == ''">
  245. , 'N' as 'authDtl.readYn', 'N' as 'authDtl.writeYn'
  246. </if>
  247. from tree_menu_list tlist
  248. <if test="authNo != null and authNo != ''">
  249. left outer join np_auth_dtl dtl on tlist.menu_no = dtl.menu_no and dtl.auth_no = nvl(#{authNo},'N')
  250. </if>
  251. order by id_path
  252. </select>
  253. <select id="selectPopMenuList" resultType="com.oqpo.api.entity.oper.MenuEntity">
  254. with recursive tree_menu_list
  255. as
  256. (
  257. select 1 level
  258. , menu_no
  259. , top_menu_no
  260. , menu_nm
  261. , menu_nm as id_path_nm
  262. , open_cd
  263. from np_sys_menu
  264. where top_menu_no = 10
  265. and sys_type_cd = 'W'
  266. and open_cd <![CDATA[ <> ]]> 'p'
  267. union all
  268. select c.level + 1
  269. , b.menu_no
  270. , b.top_menu_no
  271. , b.menu_nm
  272. , concat(c.id_path_nm, '>', b.menu_nm ) as id_path_nm
  273. , b.open_cd
  274. from np_sys_menu b, tree_menu_list c
  275. where c.menu_no = b.top_menu_no
  276. and b.open_cd <![CDATA[ <> ]]> 'p'
  277. )
  278. select menu_no, menu_nm, id_path_nm
  279. from tree_menu_list
  280. where open_cd = 'C'
  281. <if test="sTopMenuNo != null and sTopMenuNo != ''">
  282. and top_menu_no = #{sTopMenuNo}
  283. </if>
  284. <if test="sMenuNm != null and sMenuNm != ''">
  285. and menu_nm like concat('%',#{sMenuNm},'%')
  286. </if>
  287. <choose>
  288. <when test="gridRequest.sidx != null and gridRequest.sidx != ''">
  289. <if test="gridRequest.sidx == 'VIEW_NUM'.toString()">
  290. <if test="gridRequest.sord == 'asc'.toString()">
  291. order by menu_nm asc
  292. </if>
  293. <if test="gridRequest.sord == 'desc'.toString()">
  294. order by menu_nm desc
  295. </if>
  296. </if>
  297. </when>
  298. <otherwise>
  299. order by menu_nm asc
  300. </otherwise>
  301. </choose>
  302. <if test="gridRequest.pagingYn == true">
  303. limit #{gridRequest.gridFirst}, #{gridRequest.gridSize}
  304. </if>
  305. </select>
  306. <select id="selectPopMenuCnt" resultType="Integer">
  307. with recursive tree_menu_list
  308. as
  309. (
  310. select 1 level
  311. , menu_no
  312. , top_menu_no
  313. , menu_nm
  314. , menu_nm as id_path_nm
  315. , open_cd
  316. from np_sys_menu
  317. where top_menu_no = 10
  318. and open_cd <![CDATA[ <> ]]> 'p'
  319. union all
  320. select c.level + 1
  321. , b.menu_no
  322. , b.top_menu_no
  323. , b.menu_nm
  324. , concat(c.id_path_nm, '>', b.menu_nm ) as id_path_nm
  325. , b.open_cd
  326. from np_sys_menu b, tree_menu_list c
  327. where c.menu_no = b.top_menu_no
  328. and b.open_cd <![CDATA[ <> ]]> 'p'
  329. )
  330. select count(*) as cnt
  331. from tree_menu_list
  332. where open_cd = 'C'
  333. <if test="sTopMenuNo != null and sTopMenuNo != ''">
  334. and top_menu_no = #{sTopMenuNo}
  335. </if>
  336. <if test="sMenuNm != null and sMenuNm != ''">
  337. and menu_nm like concat('%',#{sMenuNm},'%')
  338. </if>
  339. </select>
  340. <select id="selectMobleMenuList" resultType="com.oqpo.api.entity.oper.MenuEntity">
  341. select 2 level
  342. , menu_no
  343. , menu_id
  344. , top_menu_no
  345. , menu_nm
  346. , menu_nm as id_path_nm
  347. , open_cd
  348. , view_num
  349. from np_sys_menu
  350. where top_menu_no = 1002
  351. and sys_type_cd = 'M'
  352. order by view_num
  353. </select>
  354. <select id="selectUserMobileAuthMenuList" resultType="com.oqpo.api.entity.oper.MenuEntity">
  355. with recursive tree_menu_list /* selectUserMobileAuthMenuList */
  356. as
  357. (
  358. select 1 level
  359. , menu_no
  360. , top_menu_no
  361. , menu_nm
  362. , view_num
  363. , open_cd
  364. , conn_url
  365. , cast(menu_no as char(100) character set utf8) id_path
  366. , use_yn
  367. , fn_code_nm('USE_YN', use_yn) as use_yn_nm
  368. , menu_id
  369. from np_sys_menu
  370. where top_menu_no = 10
  371. union all
  372. select c.level + 1
  373. , b.menu_no
  374. , b.top_menu_no
  375. , b.menu_nm
  376. , b.view_num
  377. , b.open_cd
  378. , b.conn_url
  379. , concat(c.id_path, '->', case when b.view_num <![CDATA[ < ]]> 10 then concat('0',b.view_num) else b.view_num end ,'->', b.menu_no) as id_path
  380. , b.use_yn
  381. , fn_code_nm('USE_YN', b.use_yn) as use_yn_nm
  382. , b.menu_id
  383. from np_sys_menu b, tree_menu_list c
  384. where c.menu_no = b.top_menu_no
  385. and b.sys_type_cd = 'M'
  386. )
  387. select tlist.menu_no, tlist.top_menu_no, fn_get_menu_nm(tlist.top_menu_no) as top_menu_nm, tlist.menu_nm, tlist.view_num, tlist.level , tlist.use_yn, tlist.use_yn_nm
  388. , tlist.open_cd, case when tlist.open_cd != 'C' then (select count(*) from np_sys_menu where top_menu_no = tlist.menu_no ) else 0 end as b_menu_cnt
  389. , tlist.conn_url, tlist.menu_id
  390. from tree_menu_list tlist
  391. <if test="systemAdminYn neq 'Y'.toString() ">
  392. join ( select 100 as top_menu_no, top_menu_no as menu_no, 'Y' as wr_yn
  393. from np_user_auth uauth
  394. join np_auth_info ainfo on uauth.auth_no = ainfo.auth_no and ainfo.use_yn = 'Y'
  395. where uauth.user_id = #{userId}
  396. union all
  397. select ainfo.top_menu_no, adtl.menu_no, adtl.wr_yn
  398. from np_user_auth uauth
  399. join np_auth_info ainfo on uauth.auth_no = ainfo.auth_no and ainfo.use_yn = 'Y'
  400. join np_auth_dtl adtl on uauth.auth_no = adtl.auth_no and adtl.use_yn = 'Y'
  401. where uauth.user_id = #{userId} ) umenu
  402. on tlist.top_menu_no = umenu.top_menu_no and tlist.menu_no = umenu.menu_no
  403. </if>
  404. where tlist.use_yn = 'Y'
  405. and tlist.open_cd in ('T','C')
  406. order by id_path
  407. </select>
  408. </mapper>