select gr.role
from group_roles gr
inner join groups_users gu on gr.group_uuid=gu.group_uuid
where
gr.entity_uuid is null and
gu.user_uuid=#{userUuid, jdbcType=VARCHAR}
union
select gr.role
from group_roles gr
where
gr.group_uuid is null and
gr.entity_uuid is null
union
select ur.role
from user_roles ur
where
ur.user_uuid=#{userUuid, jdbcType=VARCHAR}
and ur.entity_uuid is null
select gr.role
from group_roles gr
where
gr.entity_uuid is null and
gr.group_uuid is null
select count(1) from
(
select gu.user_uuid
from groups_users gu
inner join group_roles gr on gr.group_uuid = gu.group_uuid
where
gr.role = #{permission, jdbcType=VARCHAR} and
gr.entity_uuid is null and
gr.group_uuid is not null and
gr.group_uuid != #{excludedGroupUuid, jdbcType=VARCHAR}
union
select ur.user_uuid
from user_roles ur
where
ur.entity_uuid is null and
ur.role = #{permission, jdbcType=VARCHAR}
) remaining
select count(1) from
(
select gu.user_uuid
from groups_users gu
inner join group_roles gr on gr.group_uuid = gu.group_uuid
where
gr.role = #{permission, jdbcType=VARCHAR} and
gr.entity_uuid is null and
gr.group_uuid is not null and
gu.user_uuid != #{excludedUserUuid, jdbcType=VARCHAR}
union
select ur.user_uuid
from user_roles ur
where
ur.entity_uuid is null and
ur.role = #{permission, jdbcType=VARCHAR} and
ur.user_uuid != #{excludedUserUuid, jdbcType=VARCHAR}
) remaining
select gu.user_uuid
from groups_users gu
inner join group_roles gr on gr.group_uuid = gu.group_uuid
where
gr.role = #{permission, jdbcType=VARCHAR} and
gr.entity_uuid is null and
gr.group_uuid is not null
union
select ur.user_uuid
from user_roles ur
where
ur.entity_uuid is null and
ur.role = #{permission, jdbcType=VARCHAR}
select count(1) from
(
select gu.user_uuid
from groups_users gu
inner join group_roles gr on gr.group_uuid = gu.group_uuid
where
gr.role = #{permission, jdbcType=VARCHAR} and
gr.entity_uuid is null and
gr.group_uuid is not null and
(gu.group_uuid != #{groupUuid, jdbcType=VARCHAR} or gu.user_uuid != #{userUuid, jdbcType=VARCHAR})
union
select ur.user_uuid
from user_roles ur
where
ur.entity_uuid is null and
ur.role = #{permission, jdbcType=VARCHAR}
) remaining
select count(1) from
(
select gu.user_uuid
from groups_users gu
inner join group_roles gr on gr.group_uuid = gu.group_uuid
where
gr.role = #{permission, jdbcType=VARCHAR} and
gr.entity_uuid is null and
gr.group_uuid is not null
union
select ur.user_uuid
from user_roles ur
where
ur.entity_uuid is null and
ur.role = #{permission, jdbcType=VARCHAR} and
ur.user_uuid != #{userUuid, jdbcType=VARCHAR}
) remaining
select
gr.entity_uuid
from
group_roles gr
where
gr.role=#{role, jdbcType=VARCHAR}
and (
gr.group_uuid is null
or exists (
select
1
from
groups_users gu
where
gu.user_uuid = #{userUuid, jdbcType=VARCHAR}
and gr.group_uuid = gu.group_uuid
)
)
and gr.entity_uuid in
#{element, jdbcType=VARCHAR}
union
select
entity.uuid
from
user_roles ur
inner join ( ) entity on
entity.uuid = ur.entity_uuid
where
ur.role=#{role, jdbcType=VARCHAR}
and ur.user_uuid=#{userUuid, jdbcType=INTEGER}
and entity.uuid in
#{element, jdbcType=VARCHAR}
union
select
entity.uuid
from
( ) entity
where entity.uuid in
#{element ,jdbcType=VARCHAR}
and entity.isPrivate = ${_false}
and #{role, jdbcType=VARCHAR} in ('user','codeviewer')
select
gr.entity_uuid
from
group_roles gr
where
gr.role=#{role, jdbcType=VARCHAR}
and gr.group_uuid is null
and gr.entity_uuid in
#{element, jdbcType=VARCHAR}
union
select
gu.user_uuid
from
groups_users gu
inner join group_roles gr on
gr.group_uuid=gu.group_uuid
where
gr.entity_uuid=#{entityUuid, jdbcType=VARCHAR}
and gr.role=#{role, jdbcType=VARCHAR}
and gu.user_uuid in
#{uuid, jdbcType=VARCHAR}
union
select
ur.user_uuid
from
user_roles ur
where
ur.entity_uuid=#{entityUuid, jdbcType=VARCHAR}
and ur.role=#{role, jdbcType=VARCHAR}
and ur.user_uuid IN
#{uuid, jdbcType=VARCHAR}
union
select
u.uuid
from
users u
where
u.uuid in
#{uuid, jdbcType=VARCHAR}
and exists (
select
1
from
( ) entity
where
entity.uuid =#{entityUuid, jdbcType=VARCHAR}
and entity.isPrivate = ${_false}
and #{role, jdbcType=VARCHAR} in ('user','codeviewer')
)
select ur.role
from user_roles ur
inner join ( ) entity on entity.uuid = ur.entity_uuid
where
entity.uuid = #{entityUuid, jdbcType=VARCHAR} and
ur.user_uuid = #{userUuid, jdbcType=VARCHAR}
union
select gr.role
from group_roles gr
inner join groups_users gu on gr.group_uuid = gu.group_uuid
inner join ( ) entity on entity.uuid = gr.entity_uuid
where
entity.uuid = #{entityUuid, jdbcType=VARCHAR} and
gu.user_uuid = #{userUuid, jdbcType=VARCHAR}
union
select
gu.user_uuid,
gr.role
from group_roles gr
inner join groups_users gu on gr.group_uuid = gu.group_uuid
inner join external_groups eg on gr.group_uuid = eg.group_uuid
where
gr.entity_uuid = #{entityUuid, jdbcType=VARCHAR}
and eg.external_identity_provider = #{managedInstanceProvider, jdbcType=VARCHAR}
select
gu.user_uuid,
gr.role
from group_roles gr
inner join groups_users gu on gr.group_uuid = gu.group_uuid
where
gr.entity_uuid = #{entityUuid, jdbcType=VARCHAR}
and
select
gr.role
from
group_roles gr
inner join ( ) entity on
entity.uuid = gr.entity_uuid
where
entity.uuid = #{entityUuid, jdbcType=VARCHAR}
and gr.group_uuid is null
select
u.login as "login",
${_true} as "global",
u.email as "email"
from
users u
inner join user_roles ur on
ur.user_uuid = u.uuid
and ur.role=#{permission, jdbcType=VARCHAR}
and ur.entity_uuid is null
where
u.email is not null
union
select
u.login as "login",
${_true} as "global",
u.email as "email"
from users u
inner join groups_users gu on
u.uuid=gu.user_uuid
inner join group_roles gr on
gr.group_uuid = gu.group_uuid
and gr.role = #{permission, jdbcType=VARCHAR}
and gr.entity_uuid is null
where
u.email is not null
select u.login
from users u
where
u.login in #{login, jdbcType=VARCHAR}
and (
exists (
select 1
from user_roles ur
inner join ( ) entity on entity.uuid = ur.entity_uuid
where
entity.kee = #{entityKey, jdbcType=VARCHAR}
and ur.role = #{permission, jdbcType=VARCHAR}
and ur.user_uuid = u.uuid
) or exists (
select 1
from ( ) entity
inner join group_roles gr on gr.entity_uuid = entity.uuid
inner join groups_users gu on gu.group_uuid = gr.group_uuid
where
entity.kee = #{entityKey, jdbcType=VARCHAR}
and gu.user_uuid = u.uuid
and gr.role = #{permission, jdbcType=VARCHAR}
)
or exists (
select 1
from ( ) entity
where
entity.kee = #{entityKey, jdbcType=VARCHAR}
and entity.isPrivate = ${_false}
)
)