347 lines
12 KiB
XML
347 lines
12 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="io.dataease.ext.ExtPanelGroupMapper">
|
|
|
|
<resultMap id="BaseResultMapDTO" type="io.dataease.dto.panel.PanelGroupDTO"
|
|
extends="io.dataease.plugins.common.base.mapper.PanelGroupMapper.BaseResultMap">
|
|
<result column="label" jdbcType="VARCHAR" property="label"/>
|
|
<result column="privileges" jdbcType="VARCHAR" property="privileges"/>
|
|
<result column="default_panel_id" jdbcType="VARCHAR" property="defaultPanelId"/>
|
|
<result column="default_panel_name" jdbcType="VARCHAR" property="defaultPanelName"/>
|
|
<result column="source_panel_name" jdbcType="VARCHAR" property="sourcePanelName"/>
|
|
<result column="creator_name" jdbcType="VARCHAR" property="creatorName"/>
|
|
<result column="update_name" jdbcType="VARCHAR" property="updateName"/>
|
|
<result column="is_default" property="isDefault"/>
|
|
</resultMap>
|
|
|
|
<select id="findOneWithPrivileges" resultMap="BaseResultMapDTO">
|
|
select panel_group.*,
|
|
panel_group.name as label,
|
|
(select nick_name from sys_user where username = panel_group.create_by) as creator_name,
|
|
(select nick_name from sys_user where username = panel_group.update_by) as update_name,
|
|
get_auths(panel_group.id, 'panel', #{userId}) as `privileges`
|
|
from panel_group
|
|
where id = #{panelId}
|
|
</select>
|
|
|
|
<select id="panelGroupInit" resultMap="BaseResultMapDTO">
|
|
select id, name, panel_data
|
|
from panel_group
|
|
where node_type = 'panel'
|
|
and panel_type = 'self'
|
|
</select>
|
|
|
|
<select id="panelGroupListDefault" resultMap="BaseResultMapDTO">
|
|
SELECT
|
|
panel_group.id,
|
|
panel_group.`name`,
|
|
panel_group.pid,
|
|
panel_group.`level`,
|
|
panel_group.node_type,
|
|
panel_group.create_by,
|
|
panel_group.create_time,
|
|
panel_group.panel_type,
|
|
panel_group.`name` AS label,
|
|
panel_group.`source`,
|
|
panel_group.`panel_type`,
|
|
panel_group.`status`,
|
|
sourcePanelGroup.`mobile_layout`,
|
|
sourcePanelGroup.`name` as source_panel_name,
|
|
authInfo.privileges as `privileges`
|
|
from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'panel') cids) t,panel_group
|
|
LEFT JOIN panel_group sourcePanelGroup
|
|
on sourcePanelGroup.id=panel_group.source
|
|
left join (
|
|
SELECT
|
|
auth_source,
|
|
group_concat( DISTINCT sys_auth_detail.privilege_extend ) as `privileges`
|
|
FROM
|
|
(
|
|
`sys_auth`
|
|
LEFT JOIN `sys_auth_detail` ON ((
|
|
`sys_auth`.`id` = `sys_auth_detail`.`auth_id`
|
|
)))
|
|
WHERE
|
|
sys_auth_detail.privilege_value = 1
|
|
AND sys_auth.auth_source_type = 'panel'
|
|
AND (
|
|
(
|
|
sys_auth.auth_target_type = 'dept'
|
|
AND sys_auth.auth_target IN ( SELECT dept_id FROM sys_user WHERE user_id = #{userId} )
|
|
)
|
|
OR (
|
|
sys_auth.auth_target_type = 'user'
|
|
AND sys_auth.auth_target = #{userId}
|
|
)
|
|
OR (
|
|
sys_auth.auth_target_type = 'role'
|
|
AND sys_auth.auth_target IN ( SELECT role_id FROM sys_users_roles WHERE user_id = #{userId} )
|
|
)
|
|
)
|
|
GROUP BY
|
|
`sys_auth`.`auth_source`
|
|
) authInfo
|
|
on panel_group.id = authInfo.auth_source
|
|
<where>
|
|
FIND_IN_SET(panel_group.id,cids)
|
|
<if test="name != null">
|
|
and panel_group.name like CONCAT('%', #{name},'%')
|
|
</if>
|
|
<if test="nodeType != null">
|
|
and panel_group.node_type = #{nodeType}
|
|
</if>
|
|
<if test="panelType != null">
|
|
and panel_group.panel_type = #{panelType}
|
|
</if>
|
|
<if test="id != null">
|
|
and panel_group.id = #{id}
|
|
</if>
|
|
<if test="pid != null">
|
|
and panel_group.pid = #{pid}
|
|
</if>
|
|
<if test="level != null">
|
|
and panel_group.level = #{level}
|
|
</if>
|
|
</where>
|
|
ORDER BY panel_group.panel_sort desc, CONVERT(panel_group.name using gbk)
|
|
</select>
|
|
|
|
<select id="panelGroupList" resultMap="BaseResultMapDTO">
|
|
SELECT
|
|
panel_group.id,
|
|
panel_group.`name`,
|
|
panel_group.pid,
|
|
panel_group.`level`,
|
|
panel_group.node_type,
|
|
panel_group.create_by,
|
|
panel_group.create_time,
|
|
panel_group.panel_type,
|
|
panel_group.`name` AS label,
|
|
panel_group.`node_type`,
|
|
panel_group.`mobile_layout`,
|
|
panel_group.`status`,
|
|
(case when ISNULL(defaultPanelGroup.id) then false else true end) is_default,
|
|
defaultPanelGroup.id as default_panel_id,
|
|
defaultPanelGroup.`name` as default_panel_name,
|
|
authInfo.privileges as `privileges`
|
|
from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'panel') cids) t,panel_group
|
|
LEFT JOIN panel_group defaultPanelGroup
|
|
on defaultPanelGroup.source=panel_group.id and defaultPanelGroup.source is not null
|
|
left join (
|
|
SELECT
|
|
auth_source,
|
|
group_concat( DISTINCT sys_auth_detail.privilege_extend ) as `privileges`
|
|
FROM
|
|
(
|
|
`sys_auth`
|
|
LEFT JOIN `sys_auth_detail` ON ((
|
|
`sys_auth`.`id` = `sys_auth_detail`.`auth_id`
|
|
)))
|
|
WHERE
|
|
sys_auth_detail.privilege_value = 1
|
|
AND sys_auth.auth_source_type = 'panel'
|
|
AND (
|
|
(
|
|
sys_auth.auth_target_type = 'dept'
|
|
AND sys_auth.auth_target IN ( SELECT dept_id FROM sys_user WHERE user_id = #{userId} )
|
|
)
|
|
OR (
|
|
sys_auth.auth_target_type = 'user'
|
|
AND sys_auth.auth_target = #{userId}
|
|
)
|
|
OR (
|
|
sys_auth.auth_target_type = 'role'
|
|
AND sys_auth.auth_target IN ( SELECT role_id FROM sys_users_roles WHERE user_id = #{userId} )
|
|
)
|
|
)
|
|
GROUP BY
|
|
`sys_auth`.`auth_source`
|
|
) authInfo
|
|
on panel_group.id = authInfo.auth_source
|
|
<where>
|
|
FIND_IN_SET(panel_group.id,cids)
|
|
<if test="name != null">
|
|
and panel_group.name like CONCAT('%', #{name},'%')
|
|
</if>
|
|
<if test="nodeType != null">
|
|
and panel_group.node_type = #{nodeType}
|
|
</if>
|
|
<if test="panelType != null">
|
|
and panel_group.panel_type = #{panelType}
|
|
</if>
|
|
<if test="id != null">
|
|
and panel_group.id = #{id}
|
|
</if>
|
|
<if test="pid != null">
|
|
and panel_group.pid = #{pid}
|
|
</if>
|
|
<if test="level != null">
|
|
and panel_group.level = #{level}
|
|
</if>
|
|
</where>
|
|
ORDER BY panel_group.node_type desc, CONVERT(panel_group.name using gbk)
|
|
</select>
|
|
|
|
<delete id="deleteCircle">
|
|
delete
|
|
from panel_group
|
|
where FIND_IN_SET(panel_group.id, GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
|
|
or FIND_IN_SET(panel_group.source, GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
|
|
</delete>
|
|
|
|
<delete id="deleteCircleView">
|
|
delete
|
|
from chart_view
|
|
where FIND_IN_SET(chart_view.scene_id, GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
|
|
</delete>
|
|
|
|
<delete id="deleteCircleViewCache">
|
|
delete
|
|
from chart_view_cache
|
|
where FIND_IN_SET(chart_view_cache.scene_id, GET_PANEL_GROUP_WITH_CHILDREN(#{pid}))
|
|
</delete>
|
|
|
|
<insert id="copyPanelView">
|
|
INSERT INTO panel_view (id, panel_id, chart_view_id)
|
|
SELECT uuid(),
|
|
#{panelId},
|
|
chart_view_id
|
|
FROM panel_view
|
|
WHERE panel_id = #{panelId}
|
|
</insert>
|
|
|
|
<delete id="removeUselessViews">
|
|
DELETE
|
|
FROM
|
|
chart_view
|
|
WHERE
|
|
chart_view.chart_type = 'private'
|
|
AND chart_view.scene_id = #{panelId}
|
|
<if test="viewIds != null and viewIds.size>0">
|
|
AND id NOT IN
|
|
<foreach collection="viewIds" item="viewId" open="(" separator="," close=")">
|
|
#{viewId}
|
|
</foreach>
|
|
</if>
|
|
|
|
</delete>
|
|
|
|
<select id="queryPanelRelation" resultType="io.dataease.dto.RelationDTO" resultMap="io.dataease.ext.ExtDataSourceMapper.RelationResultMap">
|
|
select
|
|
ifnull(ds.id,'') `id`,
|
|
ds.name,
|
|
ds_auth.auths,
|
|
'link' `type`,
|
|
dt.id sub_id,
|
|
dt.name sub_name,
|
|
dt_auth.auths sub_auths,
|
|
if(dt.id is not null,'dataset',null) sub_type
|
|
from
|
|
panel_group pg
|
|
join
|
|
chart_view cv on cv.scene_id = pg.id
|
|
join
|
|
dataset_table dt on cv.table_id = dt.id
|
|
left join
|
|
(
|
|
select
|
|
t_dt.id,group_concat(distinct sad.privilege_type) auths
|
|
from
|
|
dataset_table t_dt
|
|
left join sys_auth sa on sa.auth_source = t_dt.id
|
|
left join sys_auth_detail sad on sa.id = sad.auth_id
|
|
where
|
|
sa.auth_source_type = 'dataset'
|
|
and
|
|
sad.privilege_value = 1
|
|
and
|
|
(
|
|
(
|
|
sa.auth_target_type = 'dept'
|
|
AND sa.auth_target in ( SELECT dept_id FROM sys_user WHERE user_id = #{userId,jdbcType=BIGINT} )
|
|
)
|
|
or
|
|
(
|
|
sa.auth_target_type = 'user'
|
|
AND sa.auth_target = #{userId,jdbcType=BIGINT}
|
|
)
|
|
or
|
|
(
|
|
sa.auth_target_type = 'role'
|
|
AND sa.auth_target in ( SELECT role_id FROM sys_users_roles WHERE user_id = #{userId,jdbcType=BIGINT} )
|
|
)
|
|
)
|
|
group by sa.auth_source
|
|
) dt_auth on dt.id = dt_auth.id
|
|
left join datasource ds on dt.data_source_id = ds.id
|
|
left join
|
|
(
|
|
select
|
|
t_pg.id,group_concat(distinct sad.privilege_type) auths
|
|
from
|
|
panel_group t_pg
|
|
left join sys_auth sa on sa.auth_source = t_pg.id
|
|
left join sys_auth_detail sad on sa.id = sad.auth_id
|
|
where
|
|
sa.auth_source_type = 'link'
|
|
and
|
|
sad.privilege_value = 1
|
|
and
|
|
(
|
|
(
|
|
sa.auth_target_type = 'dept'
|
|
AND sa.auth_target in ( SELECT dept_id FROM sys_user WHERE user_id = #{userId,jdbcType=BIGINT} )
|
|
)
|
|
OR
|
|
(
|
|
sa.auth_target_type = 'user'
|
|
AND sa.auth_target = #{userId,jdbcType=BIGINT}
|
|
)
|
|
OR
|
|
(
|
|
sa.auth_target_type = 'role'
|
|
AND sa.auth_target in ( SELECT role_id FROM sys_users_roles WHERE user_id = #{userId,jdbcType=BIGINT} )
|
|
)
|
|
)
|
|
group by sa.auth_source
|
|
) ds_auth on ds_auth.id = ds.id
|
|
where pg.id=#{panelId,jdbcType=VARCHAR}
|
|
group by id,sub_id
|
|
order by id
|
|
</select>
|
|
|
|
<select id="listPanelByUser" resultType="io.dataease.plugins.common.base.domain.PanelGroup"
|
|
resultMap="io.dataease.plugins.common.base.mapper.PanelGroupMapper.BaseResultMap">
|
|
select
|
|
pg.*
|
|
from
|
|
panel_group pg
|
|
join sys_auth sa on sa.auth_source = pg.id
|
|
join sys_auth_detail sad on sa.id = sad.auth_id
|
|
where
|
|
pg.node_type = 'panel'
|
|
and
|
|
sa.auth_source_type = 'panel'
|
|
and
|
|
sad.privilege_value = 1
|
|
and
|
|
(
|
|
(
|
|
sa.auth_target_type = 'dept'
|
|
AND sa.auth_target in ( SELECT dept_id FROM sys_user WHERE user_id = #{userId,jdbcType=BIGINT} )
|
|
)
|
|
OR
|
|
(
|
|
sa.auth_target_type = 'user'
|
|
AND sa.auth_target = #{userId,jdbcType=BIGINT}
|
|
)
|
|
OR
|
|
(
|
|
sa.auth_target_type = 'role'
|
|
AND sa.auth_target in ( SELECT role_id FROM sys_users_roles WHERE user_id = #{userId,jdbcType=BIGINT} )
|
|
)
|
|
)
|
|
group by pg.id
|
|
</select>
|
|
</mapper>
|