MAXIMO查询菜单并根据权限过滤

本文介绍了一种复杂的SQL查询方法,用于获取不同层级的菜单项及其相关信息。通过联接多个表并使用子查询来筛选出特定用户可见的菜单项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

查询一级菜单
select t.position ID,
ELEMENTTYPE appType,
mod.description,
NULL PID
from maxmenu t, maxmodules mod
where t.keyvalue = mod.module
and t.menutype = 'MODULE'
and t.elementtype = 'MODULE'
and t.visible = 1
and t.moduleapp in
(select m.moduleapp
from maxmenu m
where m.menutype = 'MODULE'
and m.elementtype = 'APP'
and m.keyvalue in
(select distinct a.app
from applicationauth a
where a.groupname in
(select g.groupname
from groupuser g
where g.userid = 'ADMIN')
and a.optionname = 'READ')) ORDER BY position


查询二级菜单,一级菜单为300000
SELECT * FROM (
(select t.position ID,
ELEMENTTYPE appType,
t.headerdescription description,
'' apptable,
m.position PID
from maxmenu t,
(select t.position, mod.module
from maxmenu t, maxmodules mod
where t.keyvalue = mod.module
and t.menutype = 'MODULE'
and t.elementtype = 'MODULE'
and t.visible = 1
and t.moduleapp in
(select m.moduleapp
from maxmenu m
where m.menutype = 'MODULE'
and m.elementtype = 'APP'
and m.keyvalue in
(select distinct a.app
from applicationauth a
where a.groupname in
(select g.groupname
from groupuser g
where g.userid = 'ADMIN')
and a.optionname = 'READ'))) m,
(select POSITION,MODULEAPP,COUNT(1) CONUNTNUM from maxmenu m2,maxapps app where m2.keyvalue=app.app and m2.Elementtype='APP'
and M2.keyvalue in
(select m.keyvalue
from maxmenu m
where m.menutype = 'MODULE'
and m.keyvalue in
(select distinct a.app
from applicationauth a
where a.groupname in
(select g.groupname
from groupuser g
where g.userid = 'ADMIN')
and a.optionname = 'READ'))
GROUP BY POSITION,MODULEAPP HAVING COUNT(1)>0) CON
where t.menutype = 'MODULE'
and t.elementtype = 'HEADER'
and t.moduleapp = m.module
AND t.position=CON.POSITION
AND T.moduleapp=CON.moduleapp
and t.visible = 1
and m.position='300000'
and t.moduleapp in
(select m.moduleapp
from maxmenu m
where m.menutype = 'MODULE'
and m.keyvalue in
(select distinct a.app
from applicationauth a
where a.groupname in
(select g.groupname
from groupuser g
where g.userid = 'ADMIN')
and a.optionname = 'READ')))

union all
(select t.position ID,
ELEMENTTYPE appType,
t.headerdescription description,
p.maintbname apptable,
m.position PID
from maxmenu t,
maxapps p,
(select t.position, mod.module
from maxmenu t, maxmodules mod
where t.keyvalue = mod.module
and t.menutype = 'MODULE'
and t.elementtype = 'MODULE'
and t.visible = 1
and t.moduleapp in
(select m.moduleapp
from maxmenu m
where m.menutype = 'MODULE'
and m.elementtype = 'APP'
and m.keyvalue in
(select distinct a.app
from applicationauth a
where a.groupname in
(select g.groupname
from groupuser g
where g.userid = 'ADMIN')
and a.optionname = 'READ'))) m
where t.keyvalue = p.app
and t.menutype = 'MODULE'
and t.elementtype = 'APP'
and t.moduleapp = m.module
and t.subposition = 0
and t.visible = 1
and m.position='200000'
and t.moduleapp in
(select m.moduleapp
from maxmenu m
where m.menutype = 'MODULE'
and m.keyvalue in
(select distinct a.app
from applicationauth a
where a.groupname in
(select g.groupname
from groupuser g
where g.userid = 'ADMIN')
and a.optionname = 'READ'))))
ORDER BY ID


查询三级菜单,二级菜单为304000
select t.position ID,
ELEMENTTYPE appType,
p.description description,
p.maintbname apptable,
pa.position PID
from maxmenu t,
maxapps p,
(select t.position, M.module
from maxmenu t,
(select t.position, mod.module
from maxmenu t, maxmodules mod
where t.keyvalue = mod.module
and t.menutype = 'MODULE'
and t.elementtype = 'MODULE'
and t.visible = 1
and t.moduleapp in
(select m.moduleapp
from maxmenu m
where m.menutype = 'MODULE'
and m.elementtype = 'APP'
and m.keyvalue in
(select distinct a.app
from applicationauth a
where a.groupname in
(select g.groupname
from groupuser g
where g.userid = 'ADMIN')
and a.optionname = 'READ'))) m
where t.menutype = 'MODULE'
and t.elementtype = 'HEADER'
and t.moduleapp = m.module
and t.visible = 1
and t.moduleapp in
(select m.moduleapp
from maxmenu m
where m.menutype = 'MODULE'
and m.keyvalue in
(select distinct a.app
from applicationauth a
where a.groupname in
(select g.groupname
from groupuser g
where g.userid = 'ADMIN')
and a.optionname = 'READ'))) PA
where t.keyvalue = p.app
and t.menutype = 'MODULE'
and t.elementtype = 'APP'
and t.moduleapp = PA.module
AND T.position = PA.position
and t.visible = 1
and PA.position='304000'
and t.keyvalue in
(select m.keyvalue
from maxmenu m
where m.menutype = 'MODULE'
and m.keyvalue in
(select distinct a.app
from applicationauth a
where a.groupname in
(select g.groupname
from groupuser g
where g.userid = 'ADMIN')
and a.optionname = 'READ'))
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值