MenuMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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="com.huaxu.dao.MenuMapper">
  6. <resultMap type="MenuEntity" id="MenuResult">
  7. <result property="id" column="id"/>
  8. <result property="appId" column="app_id"/>
  9. <result property="thirdMenuId" column="third_menu_id"/>
  10. <result property="parentMenuId" column="parent_menu_id"/>
  11. <result property="name" column="name"/>
  12. <result property="englishName" column="ENGLISH_NAME"/>
  13. <result property="menuImage" column="menu_image"/>
  14. <result property="menuDynamicImage" column="MENU_DYNAMIC_IMAGE"/>
  15. <result property="permissionFlag" column="permission_flag"/>
  16. <result property="linkPath" column="link_path"/>
  17. <result property="seq" column="seq"/>
  18. <result property="showState" column="show_state"/>
  19. <result property="remark" column="remark"/>
  20. <result property="isTenant" column="is_tenant"/>
  21. <result property="isAdmin" column="is_admin"/>
  22. <result property="dateCreate" column="date_create"/>
  23. <result property="createBy" column="create_by"/>
  24. <result property="dateUpdate" column="date_update"/>
  25. <result property="updateBy" column="update_by"/>
  26. <result property="status" column="status"/>
  27. </resultMap>
  28. <!-- 实体栏位 -->
  29. <sql id="menuColumns">
  30. a.id as "id" ,
  31. a.app_id as "appId" ,
  32. a.third_menu_id as "thirdMenuId" ,
  33. a.parent_menu_id as "parentMenuId" ,
  34. a.name as "name" ,
  35. a.ENGLISH_NAME as "englishName",
  36. a.MENU_DYNAMIC_IMAGE as "menuDynamicImage",
  37. a.menu_image as "menuImage" ,
  38. a.permission_flag as "permissionFlag" ,
  39. a.link_path as "linkPath" ,
  40. a.seq as "seq" ,
  41. a.show_state as "showState" ,
  42. a.remark as "remark" ,
  43. a.is_tenant as "isTenant" ,
  44. a.is_admin as "isAdmin" ,
  45. a.date_create as "dateCreate" ,
  46. a.create_by as "createBy" ,
  47. a.date_update as "dateUpdate" ,
  48. a.update_by as "updateBy" ,
  49. a.status as "status"
  50. </sql>
  51. <!-- 根据主键获取实体 -->
  52. <select id="findMenuById" resultType="com.huaxu.entity.MenuEntity">
  53. SELECT
  54. <include refid="menuColumns"/>
  55. FROM uims_menu a
  56. WHERE a.id = #{id} and a.status=1
  57. </select>
  58. <!-- 根据主键获取实体 -->
  59. <select id="findMenuByParentIds" resultType="com.huaxu.entity.MenuEntity">
  60. SELECT
  61. <include refid="menuColumns"/>
  62. FROM uims_menu a
  63. WHERE a.PARENT_MENU_ID in
  64. <foreach collection = "Ids" item = "dramaId" open = "(" close = ")" separator = "," >
  65. #{dramaId}
  66. </foreach>
  67. and a.status=1
  68. </select>
  69. <!-- 根据主键获取租户菜单 -->
  70. <select id="findTenantMenuByParentIds" resultType="com.huaxu.entity.MenuEntity">
  71. select a.id
  72. from uims_tenant_menu a
  73. inner JOIN uims_menu b on a.menu_id=b.id
  74. inner join uims_menu c on b.id =c.PARENT_MENU_ID and c.status=1
  75. inner join uims_tenant_menu d on d.menu_id=c.id and d.status=1
  76. <if test="tenantId != null and tenantId != ''">
  77. and d.TENANT_ID=#{tenantId}
  78. </if>
  79. WHERE a.id in
  80. <foreach collection = "Ids" item = "dramaId" open = "(" close = ")" separator = "," >
  81. #{dramaId}
  82. </foreach>
  83. </select>
  84. <!-- 根据获取实体List -->
  85. <select id="findList" resultType="com.huaxu.entity.MenuEntity">
  86. SELECT
  87. <include refid="menuColumns"/>
  88. FROM uims_menu a
  89. <where>
  90. a.status=1
  91. <if test="name != null and name != ''">
  92. and a.name LIKE concat('%',#{name},'%')
  93. </if>
  94. <if test="parentMenuId != null and parentMenuId != ''">
  95. and a.PARENT_MENU_ID = #{parentMenuId}
  96. </if>
  97. </where>
  98. order by a.seq
  99. </select>
  100. <!-- 根据获取实体List -->
  101. <select id="findTenantList" resultType="com.huaxu.entity.MenuEntity">
  102. select
  103. b.id as "id" ,
  104. b.app_id as "appId" ,
  105. b.third_menu_id as "thirdMenuId" ,
  106. b.parent_menu_id as "parentMenuId" ,
  107. a.id as "tenantMenuId",
  108. a.MENU_NAME as "name" ,
  109. a.ENGLISH_NAME as "englishName",
  110. a.MENU_DYNAMIC_IMAGE as "menuDynamicImage",
  111. a.menu_image as "menuImage" ,
  112. b.permission_flag as "permissionFlag" ,
  113. a.link_path as "linkPath" ,
  114. a.MENU_SEQ as "seq" ,
  115. b.show_state as "showState" ,
  116. a.remark as "remark" ,
  117. b.is_tenant as "isTenant" ,
  118. b.is_admin as "isAdmin" ,
  119. a.date_create as "dateCreate" ,
  120. a.create_by as "createBy" ,
  121. a.date_update as "dateUpdate" ,
  122. a.update_by as "updateBy" ,
  123. a.status as "status"
  124. from uims_tenant_menu a
  125. inner join uims_menu b on a.MENU_ID=b.id and b.STATUS=1
  126. <where>
  127. a.status=1 and b.is_tenant=1
  128. <if test="name != null and name != ''">
  129. and a.MENU_NAME LIKE concat('%',#{name},'%')
  130. </if>
  131. <if test="tenantId != null and tenantId != ''">
  132. and a.tenant_id = #{tenantId}
  133. </if>
  134. </where>
  135. order by a.MENU_SEQ
  136. </select>
  137. <!-- 根据获取实体List -->
  138. <select id="findUserMenuById" resultType="com.huaxu.entity.MenuEntity">
  139. select
  140. a.id as "id" ,
  141. b.app_id as "appId" ,
  142. b.third_menu_id as "thirdMenuId" ,
  143. b.parent_menu_id as "parentMenuId" ,
  144. a.id as "tenantMenuId",
  145. a.MENU_NAME as "name" ,
  146. a.menu_image as "menuImage" ,
  147. a.ENGLISH_NAME as "englishName",
  148. a.MENU_DYNAMIC_IMAGE as "menuDynamicImage",
  149. b.permission_flag as "permissionFlag" ,
  150. a.link_path as "linkPath" ,
  151. a.MENU_SEQ as "seq" ,
  152. b.show_state as "showState" ,
  153. a.remark as "remark" ,
  154. b.is_tenant as "isTenant" ,
  155. b.is_admin as "isAdmin" ,
  156. a.date_create as "dateCreate" ,
  157. a.create_by as "createBy" ,
  158. a.date_update as "dateUpdate" ,
  159. a.update_by as "updateBy" ,
  160. a.status as "status"
  161. from uims_tenant_menu a
  162. inner join uims_menu b on a.MENU_ID=b.id and b.STATUS=1
  163. <where>
  164. a.status=1 and b.id = #{id}
  165. <if test="tenantId != null and tenantId != ''">
  166. and a.tenant_id = #{tenantId}
  167. </if>
  168. </where>
  169. </select>
  170. <!-- 根据获取实体List -->
  171. <select id="findUserList" resultType="com.huaxu.entity.MenuEntity">
  172. select
  173. b.id as "id" ,
  174. b.app_id as "appId" ,
  175. b.third_menu_id as "thirdMenuId" ,
  176. b.parent_menu_id as "parentMenuId" ,
  177. a.id as "tenantMenuId",
  178. a.MENU_NAME as "name" ,
  179. a.ENGLISH_NAME as "englishName",
  180. a.MENU_DYNAMIC_IMAGE as "menuDynamicImage",
  181. a.menu_image as "menuImage" ,
  182. b.permission_flag as "permissionFlag" ,
  183. a.link_path as "linkPath" ,
  184. a.MENU_SEQ as "seq" ,
  185. b.show_state as "showState" ,
  186. a.remark as "remark" ,
  187. b.is_tenant as "isTenant" ,
  188. b.is_admin as "isAdmin" ,
  189. a.date_create as "dateCreate" ,
  190. a.create_by as "createBy" ,
  191. a.date_update as "dateUpdate" ,
  192. a.update_by as "updateBy" ,
  193. a.status as "status"
  194. from uims_user_role userrole
  195. inner join uims_role_menu rolemenu on rolemenu.ROLE_ID=userrole.ROLE_ID and rolemenu.status=1
  196. inner join uims_menu b on rolemenu.MENU_ID=b.id and b.STATUS=1
  197. inner join uims_tenant_menu a on a.MENU_ID= b.id and a.status=1
  198. <if test="tenantId != null and tenantId != ''">
  199. and a.tenant_id = #{tenantId}
  200. </if>
  201. <where>
  202. a.status=1 and userrole.status=1 and b.is_tenant=1 and userrole.user_id=#{userId}
  203. <if test="name != null and name != ''">
  204. and a.MENU_NAME LIKE concat('%',#{name},'%')
  205. </if>
  206. </where>
  207. order by a.MENU_SEQ
  208. </select>
  209. <!-- 超级管理员查询 一级菜单List -->
  210. <select id="findAllFirstMenu" resultType="com.huaxu.entity.MenuEntity">
  211. SELECT
  212. a.id as "id" ,
  213. a.app_id as "appId" ,
  214. a.third_menu_id as "thirdMenuId" ,
  215. a.parent_menu_id as "parentMenuId" ,
  216. a.name as "name" ,
  217. a.ENGLISH_NAME as "englishName",
  218. a.MENU_DYNAMIC_IMAGE as "menuDynamicImage",
  219. a.menu_image as "menuImage" ,
  220. a.permission_flag as "permissionFlag" ,
  221. a.link_path as "linkPath" ,
  222. a.seq as "seq" ,
  223. case when a.is_admin=1 then 1 else 0 end as "isOwner",
  224. a.show_state as "showState" ,
  225. a.remark as "remark" ,
  226. a.is_tenant as "isTenant" ,
  227. a.is_admin as "isAdmin" ,
  228. a.date_create as "dateCreate" ,
  229. a.create_by as "createBy" ,
  230. a.date_update as "dateUpdate" ,
  231. a.update_by as "updateBy" ,
  232. a.status as "status"
  233. FROM uims_menu a
  234. <where>
  235. a.status=1 and a.PARENT_MENU_ID=0 and a.SHOW_STATE=1 and a.is_admin=1 and a.app_id != 1004
  236. </where>
  237. order by a.IS_ADMIN desc,a.seq
  238. </select>
  239. <!-- 租户管理员查询租户菜单 -->
  240. <select id="findTenantByMenuId" resultType="com.huaxu.entity.MenuEntity">
  241. select b.id
  242. from uims_tenant_menu b
  243. <where>
  244. b.status=1 and b.MENU_ID= #{id}
  245. <if test="tenantId != null and tenantId != ''">
  246. and b.tenant_id = #{tenantId}
  247. </if>
  248. </where>
  249. limit 1
  250. </select>
  251. <!-- 租户管理员查询租户菜单 -->
  252. <select id="findTenantFirstMenu" resultType="com.huaxu.entity.MenuEntity">
  253. select
  254. a.id as "id" ,
  255. a.parent_menu_id as "parentMenuId" ,
  256. b.MENU_NAME as "name" ,
  257. b.MENU_IMAGE as "menuImage" ,
  258. b.ENGLISH_NAME as "englishName",
  259. b.MENU_DYNAMIC_IMAGE as "menuDynamicImage",
  260. a.permission_flag as "permissionFlag" ,
  261. b.LINK_PATH as "linkPath" ,
  262. b.MENU_SEQ as "seq" ,
  263. a.show_state as "showState" ,
  264. b.remark as "remark" ,
  265. b.date_create as "dateCreate" ,
  266. b.create_by as "createBy" ,
  267. b.date_update as "dateUpdate" ,
  268. b.update_by as "updateBy" ,
  269. b.status as "status"
  270. from uims_tenant_menu b
  271. inner join uims_menu a on a.id= b.MENU_ID and a.status=1
  272. <where>
  273. b.status=1 and a.PARENT_MENU_ID=0 and a.show_state=1 and a.is_tenant=1 and a.app_id != 1004
  274. <if test="tenantId != null and tenantId != ''">
  275. and b.tenant_id = #{tenantId}
  276. </if>
  277. </where>
  278. order by b.MENU_SEQ
  279. </select>
  280. <!-- 普通用户查询租户菜单 -->
  281. <select id="findUserFirstMenu" resultType="com.huaxu.entity.MenuEntity">
  282. SELECT
  283. a.id as "id" ,
  284. a.parent_menu_id as "parentMenuId" ,
  285. b.MENU_NAME as "name" ,
  286. b.MENU_IMAGE as "menuImage" ,
  287. b.ENGLISH_NAME as "englishName",
  288. b.MENU_DYNAMIC_IMAGE as "menuDynamicImage",
  289. a.permission_flag as "permissionFlag" ,
  290. b.LINK_PATH as "linkPath" ,
  291. b.MENU_SEQ as "seq" ,
  292. a.show_state as "showState" ,
  293. b.remark as "remark" ,
  294. b.date_create as "dateCreate" ,
  295. b.create_by as "createBy" ,
  296. b.date_update as "dateUpdate" ,
  297. b.update_by as "updateBy" ,
  298. b.status as "status"
  299. from uims_user_role userrole
  300. inner join uims_role_menu rolemenu on rolemenu.ROLE_ID=userrole.ROLE_ID and rolemenu.status=1
  301. inner join uims_menu a on a.id=rolemenu.MENU_ID and a.STATUS=1 and a.app_id != 1004
  302. inner join uims_tenant_menu b on a.id= b.MENU_ID and b.status=1
  303. <if test="tenantId != null and tenantId != ''">
  304. and b.tenant_id = #{tenantId}
  305. </if>
  306. <where>
  307. userrole.status=1 and a.PARENT_MENU_ID=0 and a.SHOW_STATE=1 and a.is_tenant=1
  308. <if test="userId != null and userId != ''">
  309. and userrole.user_id = #{userId}
  310. </if>
  311. </where>
  312. order by b.MENU_SEQ
  313. </select>
  314. <!-- 超级管理员获取左侧菜单 -->
  315. <select id="findSystemUserMenu" resultType="com.huaxu.entity.MenuEntity">
  316. SELECT
  317. <include refid="menuColumns"/>
  318. FROM uims_menu a
  319. <where>
  320. a.status=1 and a.SHOW_STATE=1 and a.is_admin=1
  321. <if test="appId != null and appId != ''">
  322. and a.app_id = #{appId}
  323. </if>
  324. </where>
  325. order by a.seq
  326. </select>
  327. <!-- 租户管理员获取左侧菜单 -->
  328. <select id="findTenantUserMenu" resultType="com.huaxu.entity.MenuEntity">
  329. select
  330. a.id as "id" ,
  331. a.parent_menu_id as "parentMenuId" ,
  332. b.MENU_NAME as "name" ,
  333. b.MENU_IMAGE as "menuImage" ,
  334. b.ENGLISH_NAME as "englishName",
  335. b.MENU_DYNAMIC_IMAGE as "menuDynamicImage",
  336. a.permission_flag as "permissionFlag" ,
  337. b.LINK_PATH as "linkPath" ,
  338. b.MENU_SEQ as "seq" ,
  339. a.show_state as "showState" ,
  340. b.remark as "remark" ,
  341. b.date_create as "dateCreate" ,
  342. b.create_by as "createBy" ,
  343. b.date_update as "dateUpdate" ,
  344. b.update_by as "updateBy" ,
  345. b.status as "status"
  346. from uims_tenant_menu b
  347. inner join uims_menu a on a.id= b.MENU_ID and a.status=1
  348. <where>
  349. b.status=1 and a.SHOW_STATE=1 and a.is_tenant=1
  350. <if test="appId != null and appId != ''">
  351. and a.app_id = #{appId}
  352. </if>
  353. <if test="tenantId != null and tenantId != ''">
  354. and b.tenant_id = #{tenantId}
  355. </if>
  356. </where>
  357. order by b.MENU_SEQ
  358. </select>
  359. <!-- 普通用户获取实体List -->
  360. <select id="findUserMenu" resultType="com.huaxu.entity.MenuEntity">
  361. SELECT
  362. a.id as "id" ,
  363. a.parent_menu_id as "parentMenuId" ,
  364. b.MENU_NAME as "name" ,
  365. b.MENU_IMAGE as "menuImage" ,
  366. b.ENGLISH_NAME as "englishName",
  367. b.MENU_DYNAMIC_IMAGE as "menuDynamicImage",
  368. a.permission_flag as "permissionFlag" ,
  369. b.LINK_PATH as "linkPath" ,
  370. b.MENU_SEQ as "seq" ,
  371. a.show_state as "showState" ,
  372. b.remark as "remark" ,
  373. b.date_create as "dateCreate" ,
  374. b.create_by as "createBy" ,
  375. b.date_update as "dateUpdate" ,
  376. b.update_by as "updateBy" ,
  377. b.status as "status"
  378. from uims_user_role userrole
  379. inner join uims_role_menu rolemenu on rolemenu.ROLE_ID=userrole.ROLE_ID and rolemenu.status=1
  380. inner join uims_menu a on a.id=rolemenu.MENU_ID and a.STATUS=1
  381. inner join uims_tenant_menu b on a.id= b.MENU_ID and b.status=1
  382. <if test="tenantId != null and tenantId != ''">
  383. and b.tenant_id = #{tenantId}
  384. </if>
  385. <where>
  386. userrole.status=1 and a.SHOW_STATE=1 and a.is_tenant=1
  387. <if test="userId != null and userId != ''">
  388. and userrole.user_id = #{userId}
  389. </if>
  390. <if test="appId != null and appId != ''">
  391. and a.app_id = #{appId}
  392. </if>
  393. </where>
  394. order by b.MENU_SEQ
  395. </select>
  396. <!-- 超级管理员获取租户菜单 -->
  397. <select id="findSystemTenantMenu" resultType="com.huaxu.entity.MenuEntity">
  398. SELECT
  399. <include refid="menuColumns"/>
  400. FROM uims_menu a
  401. <where>
  402. a.status=1 and is_tenant =1
  403. </where>
  404. order by a.seq
  405. </select>
  406. <!-- 根据获取实体 page -->
  407. <select id="findPage" resultType="com.huaxu.entity.MenuEntity">
  408. SELECT
  409. <include refid="menuColumns"/>
  410. FROM uims_menu a
  411. <where>
  412. a.status=1
  413. <if test="menu.name != null and menu.name != ''">
  414. and a.name LIKE concat('%',#{menu.name},'%')
  415. </if>
  416. </where>
  417. </select>
  418. <update id="updateState">
  419. update uims_tenant_menu set status=0 where id=#{Id}
  420. </update>
  421. </mapper>