148 lines
5.6 KiB
XML
148 lines
5.6 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.ExtVAuthModelMapper">
|
|
<resultMap extends="io.dataease.plugins.common.base.mapper.VAuthModelMapper.ResultMapWithBLOBs" id="ExtResultMap"
|
|
type="io.dataease.dto.authModel.VAuthModelDTO">
|
|
<result column="privileges" jdbcType="VARCHAR" property="privileges"/>
|
|
<result column="inner_id" jdbcType="VARCHAR" property="innerId"/>
|
|
<result column="is_plugin" jdbcType="VARCHAR" property="isPlugin"/>
|
|
</resultMap>
|
|
|
|
<select id="queryAuthModel" resultMap="ExtResultMap">
|
|
SELECT
|
|
v_auth_model.id,
|
|
v_auth_model.name,
|
|
v_auth_model.label,
|
|
v_auth_model.pid,
|
|
v_auth_model.node_type,
|
|
v_auth_model.model_type,
|
|
v_auth_model.model_inner_type,
|
|
v_auth_model.auth_type,
|
|
v_auth_model.create_by,
|
|
v_auth_model.level,
|
|
v_auth_model.mode,
|
|
v_auth_model.data_source_id,
|
|
authInfo.PRIVILEGES AS `privileges`
|
|
FROM
|
|
( SELECT GET_V_AUTH_MODEL_ID_P_USE ( #{record.userId}, #{record.modelType} ) cids ) t,
|
|
v_auth_model
|
|
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 = #{record.modelType}
|
|
AND (
|
|
(
|
|
sys_auth.auth_target_type = 'dept'
|
|
AND sys_auth.auth_target IN ( SELECT dept_id FROM sys_user WHERE user_id = #{record.userId} )
|
|
)
|
|
OR (
|
|
sys_auth.auth_target_type = 'user'
|
|
AND sys_auth.auth_target = #{record.userId}
|
|
)
|
|
OR (
|
|
sys_auth.auth_target_type = 'role'
|
|
AND sys_auth.auth_target IN ( SELECT role_id FROM sys_users_roles WHERE user_id = #{record.userId} )
|
|
)
|
|
)
|
|
GROUP BY
|
|
`sys_auth`.`auth_source`
|
|
) authInfo ON v_auth_model.id = authInfo.auth_source
|
|
WHERE
|
|
FIND_IN_SET( v_auth_model.id, cids )
|
|
<if test="record.id != null">
|
|
and v_auth_model.id = #{record.id,jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="record.pid != null">
|
|
and v_auth_model.pid = #{record.pid,jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="record.nodeType != null">
|
|
and v_auth_model.node_type = #{record.nodeType,jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="record.modelType != null">
|
|
and v_auth_model.model_type = #{record.modelType,jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="record.modelInnerType != null">
|
|
and v_auth_model.model_inner_type = #{record.modelInnerType,jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="record.authType != null">
|
|
and v_auth_model.auth_type = #{record.authType,jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="record.createBy != null">
|
|
and v_auth_model.create_by = #{record.createBy,jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="record.level != null">
|
|
and v_auth_model.`level` = #{record.level,jdbcType=BIGINT}
|
|
</if>
|
|
<if test="record.mode != null">
|
|
<if test="record.mode == 0">
|
|
and v_auth_model.`mode` = 0
|
|
</if>
|
|
<if test='record.mode == 1 and record.modelType != null and record.modelType == "dataset"'>
|
|
and (v_auth_model.`mode` = 1 or (v_auth_model.`model_inner_type` = 'group' and v_auth_model.model_type =
|
|
'dataset'))
|
|
</if>
|
|
</if>
|
|
<if test="record.dataSourceId != null">
|
|
and v_auth_model.data_source_id = #{record.dataSourceId,jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="record.name != null">
|
|
and v_auth_model.`name` = #{record.name,jdbcType=LONGVARCHAR}
|
|
</if>
|
|
<if test="record.label != null">
|
|
and v_auth_model.`label` = #{record.label,jdbcType=LONGVARCHAR}
|
|
</if>
|
|
<if test="record.modelInnerTypeArray != null and record.modelInnerTypeArray.size() > 0">
|
|
and v_auth_model.model_inner_type in
|
|
<foreach collection="record.modelInnerTypeArray" item="item" separator="," open="(" close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
ORDER BY v_auth_model.node_type desc, CONVERT(v_auth_model.label using gbk) asc
|
|
</select>
|
|
|
|
<select id="queryAuthModelViews" resultMap="ExtResultMap">
|
|
SELECT
|
|
panel_view.id,
|
|
chart_view.id as 'inner_id',
|
|
chart_view.NAME,
|
|
chart_view.NAME AS 'label',
|
|
panel_view.panel_id AS pid,
|
|
chart_view.type as 'model_inner_type',
|
|
'leaf' AS node_type,
|
|
'view' AS model_type,
|
|
chart_view.is_plugin as 'is_plugin'
|
|
FROM
|
|
chart_view
|
|
LEFT JOIN panel_view ON panel_view.chart_view_id = chart_view.id
|
|
<where>
|
|
|
|
<if test="record.pids != null and record.pids.size() > 0">
|
|
and panel_view.panel_id in
|
|
<foreach collection="record.pids" item="item" separator="," open="(" close=")">
|
|
#{item}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
ORDER BY CONVERT(chart_view.name using gbk) asc
|
|
</select>
|
|
|
|
|
|
<select id="queryAuthViewsOriginal" resultMap="ExtResultMap">
|
|
SELECT
|
|
*
|
|
FROM
|
|
v_history_chart_view viewsOriginal
|
|
ORDER BY viewsOriginal.node_type desc, CONVERT(viewsOriginal.label using gbk) asc
|
|
</select>
|
|
|
|
</mapper>
|