127 lines
4.2 KiB
XML
127 lines
4.2 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.ExtDataSetTableMapper">
|
|
|
|
<resultMap id="BaseResultMapDTO" type="io.dataease.dto.dataset.DataSetTableDTO"
|
|
extends="io.dataease.plugins.common.base.mapper.DatasetTableMapper.ResultMapWithBLOBs">
|
|
<result column="privileges" property="privileges"/>
|
|
</resultMap>
|
|
|
|
|
|
<resultMap id="roleItemMap" type="io.dataease.controller.sys.response.RoleUserItem">
|
|
<id property="id" column="id"/>
|
|
<result property="name" column="name"/>
|
|
</resultMap>
|
|
|
|
<select id="searchOne" resultMap="BaseResultMapDTO">
|
|
select
|
|
id, `name`, scene_id, data_source_id, `type`, `mode`,`info`, create_by, create_time,
|
|
get_auths(id,'dataset',#{userId}) as `privileges`, scene_id as pid
|
|
from dataset_table
|
|
<where>
|
|
<if test="id != null">
|
|
and id = #{id,jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="sceneId != null">
|
|
and scene_id = #{sceneId,jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="mode != null">
|
|
and mode = #{mode,jdbcType=INTEGER}
|
|
</if>
|
|
<if test="typeFilter != null">
|
|
and type in
|
|
<foreach collection="typeFilter" item="item" open="(" separator="," close=")">
|
|
#{item,jdbcType=INTEGER}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
<if test="sort != null">
|
|
order by ${sort}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="search" resultMap="BaseResultMapDTO">
|
|
select
|
|
id, `name`, scene_id, data_source_id, `type`, `mode`,`info`, create_by, create_time,
|
|
authInfo.privileges as `privileges`
|
|
from (select GET_V_AUTH_MODEL_ID_P_USE (#{userId}, 'dataset') cids) t,dataset_table
|
|
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 = 'dataset'
|
|
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 dataset_table.id = authInfo.auth_source
|
|
<where>
|
|
FIND_IN_SET(dataset_table.id,cids)
|
|
<if test="sceneId != null">
|
|
and scene_id = #{sceneId,jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="name != null">
|
|
and name like CONCAT('%', #{name},'%')
|
|
</if>
|
|
<if test="mode != null">
|
|
and mode = #{mode,jdbcType=INTEGER}
|
|
</if>
|
|
<if test="type != null">
|
|
and type = #{type,jdbcType=VARCHAR}
|
|
</if>
|
|
<if test="typeFilter != null">
|
|
and type in
|
|
<foreach collection="typeFilter" item="item" open="(" separator="," close=")">
|
|
#{item,jdbcType=INTEGER}
|
|
</foreach>
|
|
</if>
|
|
</where>
|
|
ORDER BY CONVERT(`name` using gbk)
|
|
</select>
|
|
|
|
|
|
<select id="searchDataSetTableWithPanelId" resultMap="BaseResultMapDTO">
|
|
select
|
|
id, `name`, scene_id, data_source_id, `type`, `mode`,`info`, create_by, create_time,
|
|
get_auths(id,'dataset',#{userId}) as `privileges`
|
|
from dataset_table
|
|
where id in (
|
|
SELECT
|
|
table_id
|
|
FROM
|
|
chart_view
|
|
WHERE
|
|
id IN (
|
|
SELECT
|
|
chart_view_id
|
|
FROM
|
|
panel_view
|
|
WHERE
|
|
panel_id = #{panelId}
|
|
)
|
|
)
|
|
</select>
|
|
|
|
</mapper>
|