权限区分需要用视图来关联查询权限表,如果符合就查询出来。
权限表:
sql:
-- 查询出用户的权限
with user_auth as (
select * from s_user_function where user_id=%uid%
and function_id='200002'
and authority_type = 1
and system_id = 2
),
-- 查询出在权限下的用户的features
-- 如果scope等于1就只加载当前tentantid下的createby的features
-- 如果scope等于2就加载tenantid的features
user_features as (
select dt.* from pm_spatial_design_pipeline as dt
inner join user_auth
on
case when user_auth.scope = 2 then
dt.tenantid=user_auth.tenant_id
else
dt.tenantid=user_auth.tenant_id and dt.createuid=user_auth.user_id||''
end
),
-- 对feature根据长度进行排序
rank_user_features as (
select * ,row_number() over(partition by projectid order by ST_Length(shape) desc) as rn from user_features
)
select pipelineid,
shape,
tenantid,
linename,
devicemodel,
pointlength,
depth,
projectid,
sectionid,
jobid,
createtime,
color,
createuid,
deviceid from
rank_user_features as r
where 1=1 and
case
when %all%=1 then
0=0
else
rn <= %maplevel%
end
这样只需在url传参的时候把用户ip传递上来就可以:
viewparams参数表示视图参数
如同: