提交 79e93655 authored 作者: wangjiahao's avatar wangjiahao

feat: 数据权限配置

上级 175f5510
......@@ -23,4 +23,6 @@ public class SysUserEntity implements Serializable {
private String email;
private String phone;
private Boolean isAdmin;
}
package io.dataease.base.domain;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
@Data
public class SysAuth implements Serializable {
private String id;
private String authSource;
private String authSourceType;
private String authTarget;
private String authTargetType;
private Long authTime;
private String authDetails;
private String authUser;
private Date updateTime;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package io.dataease.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class SysAuthDetail implements Serializable {
private String id;
private String authId;
private String privilegeName;
private Integer privilegeType;
private Integer privilegeValue;
private String privilegeExtend;
private String remark;
private String createUser;
private Long createTime;
private Long updateTime;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package io.dataease.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class VAuthModel implements Serializable {
private String id;
private String name;
private String label;
private String pid;
private String nodeType;
private String modelType;
private String modelInnerType;
private String authType;
private String createBy;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package io.dataease.base.mapper;
import io.dataease.base.domain.SysAuthDetail;
import io.dataease.base.domain.SysAuthDetailExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface SysAuthDetailMapper {
long countByExample(SysAuthDetailExample example);
int deleteByExample(SysAuthDetailExample example);
int deleteByPrimaryKey(String id);
int insert(SysAuthDetail record);
int insertSelective(SysAuthDetail record);
List<SysAuthDetail> selectByExample(SysAuthDetailExample example);
SysAuthDetail selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") SysAuthDetail record, @Param("example") SysAuthDetailExample example);
int updateByExample(@Param("record") SysAuthDetail record, @Param("example") SysAuthDetailExample example);
int updateByPrimaryKeySelective(SysAuthDetail record);
int updateByPrimaryKey(SysAuthDetail record);
}
\ No newline at end of file
package io.dataease.base.mapper;
import io.dataease.base.domain.SysAuth;
import io.dataease.base.domain.SysAuthExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface SysAuthMapper {
long countByExample(SysAuthExample example);
int deleteByExample(SysAuthExample example);
int deleteByPrimaryKey(String id);
int insert(SysAuth record);
int insertSelective(SysAuth record);
List<SysAuth> selectByExample(SysAuthExample example);
SysAuth selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") SysAuth record, @Param("example") SysAuthExample example);
int updateByExample(@Param("record") SysAuth record, @Param("example") SysAuthExample example);
int updateByPrimaryKeySelective(SysAuth record);
int updateByPrimaryKey(SysAuth record);
}
\ No newline at end of file
package io.dataease.base.mapper;
import io.dataease.base.domain.VAuthModel;
import io.dataease.base.domain.VAuthModelExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface VAuthModelMapper {
long countByExample(VAuthModelExample example);
int deleteByExample(VAuthModelExample example);
int insert(VAuthModel record);
int insertSelective(VAuthModel record);
List<VAuthModel> selectByExample(VAuthModelExample example);
int updateByExampleSelective(@Param("record") VAuthModel record, @Param("example") VAuthModelExample example);
int updateByExample(@Param("record") VAuthModel record, @Param("example") VAuthModelExample example);
}
\ No newline at end of file
<?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.base.mapper.VAuthModelMapper">
<resultMap id="BaseResultMap" type="io.dataease.base.domain.VAuthModel">
<result column="id" jdbcType="VARCHAR" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="label" jdbcType="VARCHAR" property="label" />
<result column="pid" jdbcType="VARCHAR" property="pid" />
<result column="node_type" jdbcType="VARCHAR" property="nodeType" />
<result column="model_type" jdbcType="VARCHAR" property="modelType" />
<result column="model_inner_type" jdbcType="VARCHAR" property="modelInnerType" />
<result column="auth_type" jdbcType="VARCHAR" property="authType" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, `label`, pid, node_type, model_type, model_inner_type, auth_type, create_by
</sql>
<select id="selectByExample" parameterType="io.dataease.base.domain.VAuthModelExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from v_auth_model
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<delete id="deleteByExample" parameterType="io.dataease.base.domain.VAuthModelExample">
delete from v_auth_model
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.dataease.base.domain.VAuthModel">
insert into v_auth_model (id, `name`, `label`,
pid, node_type, model_type,
model_inner_type, auth_type, create_by
)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{label,jdbcType=VARCHAR},
#{pid,jdbcType=VARCHAR}, #{nodeType,jdbcType=VARCHAR}, #{modelType,jdbcType=VARCHAR},
#{modelInnerType,jdbcType=VARCHAR}, #{authType,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.VAuthModel">
insert into v_auth_model
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
`name`,
</if>
<if test="label != null">
`label`,
</if>
<if test="pid != null">
pid,
</if>
<if test="nodeType != null">
node_type,
</if>
<if test="modelType != null">
model_type,
</if>
<if test="modelInnerType != null">
model_inner_type,
</if>
<if test="authType != null">
auth_type,
</if>
<if test="createBy != null">
create_by,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="label != null">
#{label,jdbcType=VARCHAR},
</if>
<if test="pid != null">
#{pid,jdbcType=VARCHAR},
</if>
<if test="nodeType != null">
#{nodeType,jdbcType=VARCHAR},
</if>
<if test="modelType != null">
#{modelType,jdbcType=VARCHAR},
</if>
<if test="modelInnerType != null">
#{modelInnerType,jdbcType=VARCHAR},
</if>
<if test="authType != null">
#{authType,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.dataease.base.domain.VAuthModelExample" resultType="java.lang.Long">
select count(*) from v_auth_model
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update v_auth_model
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
`name` = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.label != null">
`label` = #{record.label,jdbcType=VARCHAR},
</if>
<if test="record.pid != null">
pid = #{record.pid,jdbcType=VARCHAR},
</if>
<if test="record.nodeType != null">
node_type = #{record.nodeType,jdbcType=VARCHAR},
</if>
<if test="record.modelType != null">
model_type = #{record.modelType,jdbcType=VARCHAR},
</if>
<if test="record.modelInnerType != null">
model_inner_type = #{record.modelInnerType,jdbcType=VARCHAR},
</if>
<if test="record.authType != null">
auth_type = #{record.authType,jdbcType=VARCHAR},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update v_auth_model
set id = #{record.id,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
`label` = #{record.label,jdbcType=VARCHAR},
pid = #{record.pid,jdbcType=VARCHAR},
node_type = #{record.nodeType,jdbcType=VARCHAR},
model_type = #{record.modelType,jdbcType=VARCHAR},
model_inner_type = #{record.modelInnerType,jdbcType=VARCHAR},
auth_type = #{record.authType,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
</mapper>
\ No newline at end of file
......@@ -11,6 +11,7 @@
<result column="email" jdbcType="VARCHAR" property="email" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="enabled" property="enabled" />
<result column="is_admin" jdbcType="BIT" property="isAdmin" />
</resultMap>
<resultMap id="roleMap" type="io.dataease.auth.api.dto.CurrentRoleDto" >
......@@ -20,11 +21,11 @@
<select id="findUser" resultMap="baseMap">
select user_id, username,nick_name, dept_id, password, enabled,email, phone from sys_user where user_id = #{userId}
select user_id, username,nick_name, dept_id, password, enabled,email, phone,is_admin from sys_user where user_id = #{userId}
</select>
<select id="findUserByName" resultMap="baseMap">
select user_id, username,nick_name, dept_id, password, enabled,email, phone from sys_user where username = #{username}
select user_id, username,nick_name, dept_id, password, enabled,email, phone,is_admin from sys_user where username = #{username}
</select>
<select id="roleCodes" resultType="String">
......
package io.dataease.base.mapper.ext;
import io.dataease.controller.request.BaseTreeRequest;
import io.dataease.controller.request.chart.ChartGroupRequest;
import io.dataease.dto.chart.ChartGroupDTO;
import java.util.List;
public interface ExtChartGroupMapper {
List<ChartGroupDTO> search(ChartGroupRequest ChartGroup);
}
<?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.base.mapper.ext.ExtChartGroupMapper">
<resultMap id="BaseResultMapDTO" type="io.dataease.dto.chart.ChartGroupDTO"
extends="io.dataease.base.mapper.ChartGroupMapper.BaseResultMap">
<result column="label" property="label"/>
<result column="privileges" property="privileges"/>
</resultMap>
<select id="search" resultMap="BaseResultMapDTO">
select
id, `name`, pid, `level`, `type`, create_by, create_time,`name` as label,
get_auths(id,'chart',#{userId}) as `privileges`
from chart_group
<where>
FIND_IN_SET(chart_group.id,GET_V_AUTH_MODEL_ID_P_USE(#{userId},'chart'))
<if test="id != null">
and chart_group.id = #{id,jdbcType=VARCHAR}
</if>
<if test="name != null and name != ''">
and chart_group.`name` = CONCAT('%', #{name},'%')
</if>
<if test="pid != null">
and chart_group.pid = #{pid,jdbcType=VARCHAR}
</if>
<if test="level != null">
and chart_group.`level` = #{level,jdbcType=INTEGER}
</if>
<if test="type != null and type != ''">
and chart_group.`type` = #{type,jdbcType=VARCHAR}
</if>
<if test="createBy != null">
and chart_group.create_by = #{createBy,jdbcType=VARCHAR}
</if>
<if test="createTime != null">
and chart_group.create_time = #{createTime,jdbcType=BIGINT}
</if>
</where>
<if test="sort != null">
order by ${sort}
</if>
</select>
</mapper>
package io.dataease.base.mapper.ext;
import io.dataease.controller.request.chart.ChartViewRequest;
import io.dataease.dto.chart.ChartViewDTO;
import java.util.List;
public interface ExtChartViewMapper {
List<ChartViewDTO> search(ChartViewRequest request);
}
<?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.base.mapper.ext.ExtChartViewMapper">
<resultMap id="BaseResultMapDTO" type="io.dataease.dto.chart.ChartViewDTO"
extends="io.dataease.base.mapper.ChartViewMapper.ResultMapWithBLOBs">
<result column="label" property="label"/>
<result column="privileges" property="privileges"/>
</resultMap>
<select id="search" resultMap="BaseResultMapDTO">
select
id, `name`, scene_id, table_id, `type`, title, create_by, create_time, update_time,
style_priority,x_axis, y_axis, custom_attr, custom_style, custom_filter, snapshot,
get_auths(id,'chart',#{userId}) as `privileges`
from chart_view
<where>
FIND_IN_SET(chart_view.id,GET_V_AUTH_MODEL_ID_P_USE(#{userId},'chart'))
<if test="sceneId != null">
and scene_id = #{sceneId,jdbcType=VARCHAR}
</if>
</where>
<if test="sort != null">
order by ${sort}
</if>
</select>
</mapper>
package io.dataease.base.mapper.ext;
import io.dataease.controller.request.dataset.DataSetGroupRequest;
import io.dataease.dto.dataset.DataSetGroupDTO;
import java.util.List;
public interface ExtDataSetGroupMapper {
List<DataSetGroupDTO> search(DataSetGroupRequest ChartGroup);
}
<?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.base.mapper.ext.ExtDataSetGroupMapper">
<resultMap id="BaseResultMapDTO" type="io.dataease.dto.dataset.DataSetGroupDTO"
extends="io.dataease.base.mapper.DatasetGroupMapper.BaseResultMap">
<result column="label" property="label"/>
<result column="privileges" property="privileges"/>
</resultMap>
<select id="search" resultMap="BaseResultMapDTO">
select
id, `name`, pid, `level`, `type`, create_by, create_time,`name` as label,
get_auths(id,'dataset',#{userId}) as `privileges`
from dataset_group
<where>
FIND_IN_SET(dataset_group.id,GET_V_AUTH_MODEL_ID_P_USE(#{userId},'dataset'))
<if test="id != null">
and dataset_group.id = #{id,jdbcType=VARCHAR}
</if>
<if test="name != null and name != ''">
and dataset_group.`name` = CONCAT('%', #{name},'%')
</if>
<if test="pid != null">
and dataset_group.pid = #{pid,jdbcType=VARCHAR}
</if>
<if test="level != null">
and dataset_group.`level` = #{level,jdbcType=INTEGER}
</if>
<if test="type != null and type != ''">
and dataset_group.`type` = #{type,jdbcType=VARCHAR}
</if>
<if test="createBy != null">
and dataset_group.create_by = #{createBy,jdbcType=VARCHAR}
</if>
<if test="createTime != null">
and dataset_group.create_time = #{createTime,jdbcType=BIGINT}
</if>
</where>
<if test="sort != null">
order by ${sort}
</if>
</select>
</mapper>
package io.dataease.base.mapper.ext;
import io.dataease.controller.request.dataset.DataSetTableRequest;
import io.dataease.dto.dataset.DataSetTableDTO;
import java.util.List;
public interface ExtDataSetTableMapper {
List<DataSetTableDTO> search(DataSetTableRequest request);
}
<?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.base.mapper.ext.ExtDataSetTableMapper">
<resultMap id="BaseResultMapDTO" type="io.dataease.dto.dataset.DataSetTableDTO"
extends="io.dataease.base.mapper.DatasetTableMapper.ResultMapWithBLOBs">
<result column="privileges" property="privileges"/>
</resultMap>
<select id="search" resultMap="BaseResultMapDTO">
select
id, `name`, scene_id, data_source_id, `type`, `mode`, create_by, create_time,
get_auths(id,'dataset',#{userId}) as `privileges`
from dataset_table
<where>
FIND_IN_SET(dataset_table.id,GET_V_AUTH_MODEL_ID_P_USE(#{userId},'dataset'))
<if test="sceneId != null">
and scene_id = #{sceneId,jdbcType=VARCHAR}
</if>
</where>
<if test="sort != null">
order by ${sort}
</if>
</select>
</mapper>
package io.dataease.base.mapper.ext;
import io.dataease.base.domain.Datasource;
import io.dataease.base.mapper.ext.query.GridExample;
import io.dataease.controller.request.DatasourceUnionRequest;
import io.dataease.dto.DatasourceDTO;
import java.util.List;
public interface ExtDataSourceMapper {
List<Datasource> query(GridExample example);
List<DatasourceDTO> query(GridExample example);
List<DatasourceDTO> queryUnion(DatasourceUnionRequest request);
}
......@@ -2,17 +2,19 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="io.dataease.base.mapper.ext.ExtDataSourceMapper">
<select id="query" parameterType="io.dataease.base.mapper.ext.query.GridExample" resultMap="io.dataease.base.mapper.DatasourceMapper.BaseResultMap">
select id , name , `desc` ,`type` , configuration ,create_time ,update_time from datasource
<resultMap id="BaseResultMapDTO" type="io.dataease.dto.DatasourceDTO"
extends="io.dataease.base.mapper.DatasourceMapper.ResultMapWithBLOBs">
<result column="privileges" property="privileges"/>
</resultMap>
<select id="query" parameterType="io.dataease.base.mapper.ext.query.GridExample" resultMap="BaseResultMapDTO">
select id , name , `desc` ,`type` , configuration ,create_time ,update_time,
get_auths(id,'link',#{extendCondition}) as `privileges`
from datasource
<if test="_parameter != null">
<include refid="io.dataease.base.mapper.ext.query.GridSql.gridCondition" />
</if>
and FIND_IN_SET(datasource.id,GET_V_AUTH_MODEL_ID_P_USE(#{extendCondition},'link'))
<if test="orderByClause != null">
order by ${orderByClause}
</if>
......@@ -21,5 +23,37 @@
</if>
</select>
<select id="queryUnion" resultMap="BaseResultMapDTO">
select id , name , `desc` ,`type` , configuration ,create_time ,update_time
from datasource
<where>
FIND_IN_SET(datasource.id,GET_V_AUTH_MODEL_ID_P_USE(#{userId},'link'))
<if test="id != null">
id = #{id,jdbcType=VARCHAR}
</if>
<if test="name != null">
`name` = concat('%',#{name,jdbcType=VARCHAR},'%')
</if>
<if test="desc != null">
`desc` = #{desc,jdbcType=VARCHAR}
</if>
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR}
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT}
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=BIGINT}
</if>
<if test="configuration != null">
configuration = #{configuration,jdbcType=LONGVARCHAR}
</if>
</where>
<if test="sort == null">
order by ${sort}
</if>
</select>
</mapper>
package io.dataease.base.mapper.ext;
import io.dataease.base.mapper.ext.query.GridExample;
import io.dataease.controller.request.BaseTreeRequest;
import io.dataease.controller.sys.request.SimpleTreeNode;
import io.dataease.dto.SysDeptDTO;
import org.apache.ibatis.annotations.*;
import java.util.List;
......@@ -26,4 +28,7 @@ public interface ExtDeptMapper {
List<SimpleTreeNode> allNodes();
List<SimpleTreeNode> nodesByExample(GridExample example);
List<SysDeptDTO> searchTree(BaseTreeRequest request);
}
......@@ -5,6 +5,7 @@
<resultMap id="BaseResultMapDTO" type="io.dataease.dto.panel.PanelGroupDTO"
extends="io.dataease.base.mapper.PanelGroupMapper.BaseResultMap">
<result column="label" jdbcType="VARCHAR" property="label"/>
<result column="privileges" jdbcType="VARCHAR" property="privileges"/>
</resultMap>
<select id="panelGroup" resultMap="BaseResultMapDTO">
......@@ -12,8 +13,50 @@
</select>
<select id="panelGroupList" resultMap="BaseResultMapDTO">
select id, `name`, pid, `level`, node_type, create_by, create_time, panel_type,`name` as label from panel_group
SELECT
id,
`name`,
pid,
`level`,
node_type,
create_by,
create_time,
panel_type,
`name` AS label,
authInfo.`privileges`
from panel_group
left join
(SELECT
`sys_auth`.`auth_source` AS `auth_source`,
`sys_auth`.`auth_source_type` AS `auth_source_type`,
group_concat( 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_target_type = 'dept'
AND sys_auth.auth_target = ( 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 = ( SELECT role_id FROM sys_users_roles WHERE user_id = #{userId} )
)
)
GROUP BY
`sys_auth`.`auth_source`,
`sys_auth`.`auth_source_type`) authInfo
on panel_group.id = authInfo.auth_source and authInfo.auth_source_type='panel'
<where>
FIND_IN_SET(panel_group.id,GET_V_AUTH_MODEL_ID_P_USE(#{userId},'panel'))
<if test="name != null">
and panel_group.name like CONCAT('%', #{name},'%')
</if>
......
package io.dataease.base.mapper.ext;
import io.dataease.base.domain.SysAuthDetail;
import io.dataease.controller.request.SysAuthDetailRequest;
import io.dataease.controller.request.SysAuthRequest;
import io.dataease.dto.SysAuthDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ExtSysAuthDetailMapper {
List<SysAuthDetail> searchAuthTypeModel(@Param("authTypeModel") String authTypeModel);
void copyAuthModel(@Param("authTypeModel") String authTypeModel,@Param("authId") String authId,@Param("createUser") String createUser);
void authDetailsChange(@Param("privilegeValue")Integer privilegeValue,@Param("privilegeType")Integer privilegeType,@Param("authIds")List<String> authIds);
}
<?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.base.mapper.ext.ExtSysAuthDetailMapper">
<select id="searchAuthTypeModel" resultMap="io.dataease.base.mapper.SysAuthDetailMapper.BaseResultMap">
select
sys_auth_detail.privilege_name ,
sys_auth_detail.privilege_type ,
sys_auth_detail.privilege_value
from sys_auth_detail where sys_auth_detail.auth_id =#{authTypeModel} order by sys_auth_detail.privilege_type desc
</select>
<insert id="copyAuthModel">
INSERT INTO sys_auth_detail (
id,
auth_id,
privilege_name,
privilege_type,
privilege_value,
privilege_extend,
remark,
create_user,
create_time
) SELECT
uuid() AS id,
#{authId} AS auth_id,
sys_auth_detail.privilege_name,
sys_auth_detail.privilege_type,
sys_auth_detail.privilege_value,
sys_auth_detail.privilege_extend,
sys_auth_detail.remark,
#{createUser} AS create_user,
unix_timestamp(now())* 1000 AS create_time
FROM
sys_auth_detail where auth_id =#{authTypeModel}
</insert>
<update id="authDetailsChange">
UPDATE sys_auth_detail
SET privilege_value = #{privilegeValue}
<where>
auth_id in
<foreach collection='authIds' item='authId' open='(' separator=',' close=')'>#{authId}</foreach>
<if test="privilegeValue == 1">
and privilege_type &lt;= #{privilegeType}
</if>
<if test="privilegeValue == 0">
and privilege_type &gt;= #{privilegeType}
</if>
</where>
</update>
</mapper>
package io.dataease.base.mapper.ext;
import io.dataease.controller.request.SysAuthRequest;
import io.dataease.dto.SysAuthDTO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface ExtSysAuthMapper {
List<SysAuthDTO> searchAuth(SysAuthRequest request);
Boolean authExist(@Param("authSource") String authSource, @Param("authTarget") String authTarget);
String findAuthId(@Param("authSource") String authSource,
@Param("authSourceType") String authSourceType,
@Param("authTarget") String authTarget,
@Param("authTargetType") String authTargetType);
}
<?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.base.mapper.ext.ExtSysAuthMapper">
<resultMap id="BaseResultMapDTO" type="io.dataease.dto.SysAuthDTO"
extends="io.dataease.base.mapper.SysAuthMapper.BaseResultMap">
<collection property="sysAuthDetails" ofType="io.dataease.base.domain.SysAuthDetail" javaType="list">
<result column="auth_id" property="authId"/>
<result column="privilege_name" property="privilegeName"/>
<result column="privilege_type" property="privilegeType"/>
<result column="privilege_value" property="privilegeValue"/>
<result column="privilege_extend" property="privilegeExtend"/>
</collection>
</resultMap>
<select id="searchAuth" resultMap="BaseResultMapDTO">
select
sys_auth.id,
sys_auth.auth_source,
sys_auth.auth_source_type,
sys_auth.auth_target,
sys_auth.auth_target_type,
sys_auth.auth_time,
sys_auth.auth_details,
sys_auth.auth_user,
sys_auth.update_time,
sys_auth_detail.auth_id,
sys_auth_detail.auth_id ,
sys_auth_detail.privilege_name ,
sys_auth_detail.privilege_type ,
sys_auth_detail.privilege_value ,
sys_auth_detail.privilege_extend
from sys_auth left join sys_auth_detail on sys_auth.id = sys_auth_detail.auth_id
<where>
sys_auth_detail.auth_id is not null
<if test="authSources != null and authSources.size > 0">
and sys_auth.auth_source in
<foreach collection="authSources" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="authTargets != null and authTargets.size > 0">
and sys_auth.auth_target in
<foreach collection="authTargets" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="authSource != null">
and sys_auth.auth_source=#{authSource}
</if>
<if test="authSourceType != null">
and sys_auth.auth_source_type=#{authSourceType}
</if>
<if test="authTarget != null">
and sys_auth.auth_target=#{authTarget}
</if>
<if test="authTargetType != null">
and sys_auth.auth_target_type=#{authTargetType}
</if>
</where>
order by sys_auth_detail.privilege_type desc
</select>
<select id="authExist" resultType="Boolean">
select if(count(1)=0,0,1) from sys_auth where auth_source=#{authSource} and auth_target=#{authTarget}
</select>
<select id="findAuthId" resultType="String">
select id from sys_auth where auth_source=#{authSource} and auth_source_type=#{authSourceType} and auth_target=#{authTarget} and auth_target_type=#{authTargetType} limit 1
</select>
</mapper>
package io.dataease.base.mapper.ext;
import io.dataease.controller.request.BaseTreeRequest;
import io.dataease.dto.VAuthModelDTO;
import java.util.List;
public interface ExtVAuthModelMapper {
List<VAuthModelDTO> searchTree(BaseTreeRequest request);
}
<?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.base.mapper.ext.ExtVAuthModelMapper">
<resultMap id="BaseResultMapDTO" type="io.dataease.dto.VAuthModelDTO"
extends="io.dataease.base.mapper.VAuthModelMapper.BaseResultMap">
<result column="children_count" property="childrenCount"/>
<result column="leaf" property="leaf"/>
</resultMap>
<select id="searchTree" resultMap="BaseResultMapDTO">
SELECT
auth.*,
authCount.children_count AS children_count,
IF
(( authCount.children_count > 0 ), 0, 1 ) AS leaf
FROM
( SELECT * FROM v_auth_model
<where>
model_type = #{modelType}
<if test="createBy != null">
and ( v_auth_model.type ='spine' OR ( v_auth_model.create_by = #{createBy} AND v_auth_model.type = 'leaf'))
</if>
<if test="pid !=null">
and v_auth_model.pid = #{pid}
</if>
<if test="withExtend == null and id != null">
and v_auth_model.id = #{id}
</if>
<if test="withExtend == 'parent' and id != null">
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT(#{id},#{modelType}))
</if>
<if test="withExtend == 'children' and id != null">
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_CHILDREN(#{id},#{modelType}))
</if>
<if test="name != null and name !='' and withExtend == 'parent'">
and FIND_IN_SET(v_auth_model.id,GET_V_AUTH_MODEL_WITH_PARENT ( (select GROUP_CONCAT(id) from v_auth_model where model_type = #{modelType} and `name` like CONCAT('%', #{name},'%')) ,#{modelType}))
</if>
<if test="name != null and name =='' and withExtend == 'parent'">
and v_auth_model.pid = '0'
</if>
</where>
) auth
LEFT JOIN (
SELECT
count( 1 ) AS `children_count`,
`authTemp`.`pid` AS `pid`
FROM
( SELECT * FROM v_auth_model
<where>
model_type = #{modelType}
<if test="createBy != null">
and ( v_auth_model.type ='spine' OR ( v_auth_model.create_by = #{createBy} AND v_auth_model.type = 'leaf'))
</if>
</where>
) authTemp
GROUP BY
authTemp.pid
) authCount ON
auth.id = authCount.pid
<where>
<if test="createBy != null">
(chartcount.children_count>0 or chart.create_by = #{createBy})
</if>
</where>
</select>
</mapper>
......@@ -13,10 +13,20 @@ public class GridExample {
protected List<Criteria> oredCriteria;
protected String extendCondition;
public GridExample() {
oredCriteria = new ArrayList<Criteria>();
}
public String getExtendCondition() {
return extendCondition;
}
public void setExtendCondition(String extendCondition) {
this.extendCondition = extendCondition;
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
......
package io.dataease.commons.constants;
/**
* Author: wangjiahao
* Date: 2021-03-22
* Description:
*/
public class SystemConstants {
public final static String WITH_EXTEND_NOW = "now";
public final static String WITH_EXTEND_PARENT = "parent";
public final static String WITH_EXTEND_CHILDREN = "children";
public final static int PRIVILEGE_VALUE_ON= 1;
public final static int PRIVILEGE_VALUE_OFF = 0;
}
......@@ -28,7 +28,7 @@ public class ChartViewController {
}
@PostMapping("/list")
public List<ChartViewWithBLOBs> list(@RequestBody ChartViewRequest chartViewRequest) {
public List<ChartViewDTO> list(@RequestBody ChartViewRequest chartViewRequest) {
return chartViewService.list(chartViewRequest);
}
......
......@@ -5,6 +5,7 @@ import io.dataease.base.domain.DatasetTableField;
import io.dataease.base.domain.DatasetTableIncrementalConfig;
import io.dataease.controller.request.dataset.DataSetTableRequest;
import io.dataease.datasource.dto.TableFiled;
import io.dataease.dto.dataset.DataSetTableDTO;
import io.dataease.service.dataset.DataSetTableService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
......@@ -39,7 +40,7 @@ public class DataSetTableController {
}
@PostMapping("list")
public List<DatasetTable> list(@RequestBody DataSetTableRequest dataSetTableRequest) {
public List<DataSetTableDTO> list(@RequestBody DataSetTableRequest dataSetTableRequest) {
return dataSetTableService.list(dataSetTableRequest);
}
......
......@@ -52,9 +52,5 @@ public class PanelGroupController {
return panelGroupService.findOne(id);
}
@PostMapping("/saveGroupWithDesign")
public void saveGroupWithDesign(@RequestBody PanelGroupRequest request) {
panelGroupService.saveGroupWithDesign(request);
}
}
package io.dataease.controller.request;
import io.dataease.commons.constants.SystemConstants;
import lombok.Data;
/**
* Author: wangjiahao
* Date: 2021-05-11
* Description:
*/
@Data
public class BaseTreeRequest {
private String id;
private String name;
//授权资源类型 eg:chart role
private String modelType;
//pid 为0 时 查询的是顶级节点 SQL需要相应的处理
private String pid;
//now 返回当前条件查询的数据 parent 返回当前数据查询的数据同时递归父节点数据; children 返回当前数据查询的数据同时递归子节点数据
private String withExtend= SystemConstants.WITH_EXTEND_NOW;
private String createBy;
public BaseTreeRequest() {
}
public BaseTreeRequest(String id,String modelType, String withExtend) {
this.id = id;
this.modelType = modelType;
this.withExtend = withExtend;
}
}
package io.dataease.controller.request;
import io.dataease.base.domain.Datasource;
import lombok.Data;
/**
* Author: wangjiahao
* Date: 2021-05-18
* Description:
*/
@Data
public class DatasourceUnionRequest extends Datasource {
private String userId;
private String sort;
}
package io.dataease.controller.request;
import io.dataease.base.domain.SysAuthDetail;
/**
* Author: wangjiahao
* Date: 2021-05-13
* Description:
*/
public class SysAuthDetailRequest extends SysAuthDetail {
}
package io.dataease.controller.request;
import io.dataease.base.domain.SysAuth;
import io.dataease.base.domain.SysAuthDetail;
import lombok.Data;
import java.util.List;
/**
* Author: wangjiahao
* Date: 2021-05-11
* Description:
*/
@Data
public class SysAuthRequest extends SysAuth {
private List<String> authSources;
private List<String> authTargets;
private SysAuthDetail authDetail;
}
......@@ -8,4 +8,5 @@ import lombok.Data;
@Data
public class ChartGroupRequest extends ChartGroup {
private String sort;
private String userId;
}
......@@ -12,4 +12,6 @@ import lombok.Setter;
@Getter
public class ChartViewRequest extends ChartViewWithBLOBs {
private String sort;
private String userId;
}
......@@ -10,4 +10,6 @@ import lombok.Data;
@Data
public class DataSetGroupRequest extends DatasetGroup {
private String sort;
private String userId;
}
......@@ -16,4 +16,6 @@ public class DataSetTableRequest extends DatasetTable {
private String sort;
private List<String> tableNames;
private String row = "1000";
private String userId;
}
......@@ -13,10 +13,13 @@ import lombok.Data;
public class PanelGroupRequest extends PanelGroupDTO {
private String sort;
private String userId;
public PanelGroupRequest() {
}
public PanelGroupRequest(String pid) {
public PanelGroupRequest(String pid,String userId) {
super.setPid(pid);
this.userId= userId;
}
}
package io.dataease.controller.sys;
import io.dataease.base.domain.SysAuth;
import io.dataease.base.domain.SysAuthDetail;
import io.dataease.base.domain.SysDept;
import io.dataease.controller.ResultHolder;
import io.dataease.controller.request.BaseTreeRequest;
import io.dataease.controller.request.SysAuthDetailRequest;
import io.dataease.controller.request.SysAuthRequest;
import io.dataease.dto.BaseAuthDetail;
import io.dataease.dto.VAuthModelDTO;
import io.dataease.service.sys.SysAuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
/**
* Author: wangjiahao
* Date: 2021-05-11
* Description:
*/
@RestController
@RequiredArgsConstructor
@Api(tags = "系统:权限管理")
@RequestMapping("/api/sys_auth")
public class SysAuthController {
@Resource
private SysAuthService sysAuthService;
@ApiOperation("查询视图")
@PostMapping("/authModels")
public List<VAuthModelDTO> authModels(@RequestBody BaseTreeRequest request){
return sysAuthService.searchAuthModelTree(request);
}
@ApiOperation("查询授权")
@PostMapping("/authDetails")
public Map<String,List<SysAuthDetail>> authDetails(@RequestBody SysAuthRequest request){
return sysAuthService.searchAuthDetails(request);
}
@ApiOperation("查询授权模板")
@GetMapping("/authDetailsModel/{authType}")
public List<SysAuthDetail>authDetailsModel(@PathVariable String authType){
return sysAuthService.searchAuthDetailsModel(authType);
}
@ApiOperation("修改权限")
@PostMapping("/authChange")
public void authChange(@RequestBody SysAuthRequest request){
sysAuthService.authChange(request);
}
}
......@@ -25,7 +25,6 @@ import java.util.stream.Collectors;
@RequestMapping("/api/dept")
public class SysDeptController extends ResultHolder {
@Autowired
private DeptService deptService;
......@@ -35,6 +34,7 @@ public class SysDeptController extends ResultHolder {
List<DeptNodeResponse> nodeResponses = nodes.stream().map(node -> {
DeptNodeResponse deptNodeResponse = BeanUtils.copyBean(new DeptNodeResponse(), node);
deptNodeResponse.setHasChildren(node.getSubCount() > 0);
deptNodeResponse.setLeaf(node.getSubCount() == 0);
deptNodeResponse.setTop(node.getPid() == deptService.DEPT_ROOT_PID);
return deptNodeResponse;
}).collect(Collectors.toList());
......@@ -48,6 +48,7 @@ public class SysDeptController extends ResultHolder {
List<DeptNodeResponse> nodeResponses = nodes.stream().map(node -> {
DeptNodeResponse deptNodeResponse = BeanUtils.copyBean(new DeptNodeResponse(), node);
deptNodeResponse.setHasChildren(node.getSubCount() > 0);
deptNodeResponse.setLeaf(node.getSubCount() == 0);
deptNodeResponse.setTop(node.getPid() == deptService.DEPT_ROOT_PID);
return deptNodeResponse;
}).collect(Collectors.toList());
......
......@@ -3,10 +3,14 @@ package io.dataease.controller.sys.response;
import io.dataease.base.domain.SysDept;
import lombok.Data;
import java.util.List;
@Data
public class DeptNodeResponse extends SysDept {
private boolean hasChildren;
private boolean leaf;
private boolean top;
}
......@@ -3,11 +3,15 @@ package io.dataease.datasource.controller;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import io.dataease.base.domain.Datasource;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.PageUtils;
import io.dataease.commons.utils.Pager;
import io.dataease.controller.request.DatasourceUnionRequest;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.datasource.dto.DBTableDTO;
import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.datasource.service.DatasourceService;
import io.dataease.dto.DatasourceDTO;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
......@@ -31,12 +35,14 @@ public class DatasourceController {
}
@GetMapping("/list")
public List<Datasource> getDatasourceList() throws Exception {
return datasourceService.getDatasourceList(new Datasource());
public List<DatasourceDTO> getDatasourceList() throws Exception {
DatasourceUnionRequest request = new DatasourceUnionRequest();
request.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
return datasourceService.getDatasourceList(request);
}
@PostMapping("/list/{goPage}/{pageSize}")
public Pager<List<Datasource>> getDatasourceList(@RequestBody BaseGridRequest request, @PathVariable int goPage, @PathVariable int pageSize) throws Exception {
public Pager<List<DatasourceDTO>> getDatasourceList(@RequestBody BaseGridRequest request, @PathVariable int goPage, @PathVariable int pageSize) throws Exception {
Page<Object> page = PageHelper.startPage(goPage, pageSize, true);
// return PageUtils.setPageInfo(page, datasourceService.getDatasourceList(request));
return PageUtils.setPageInfo(page, datasourceService.gridQuery(request));
......
......@@ -5,22 +5,29 @@ import io.dataease.base.domain.*;
import io.dataease.base.mapper.*;
import io.dataease.base.mapper.ext.ExtDataSourceMapper;
import io.dataease.base.mapper.ext.query.GridExample;
import io.dataease.commons.constants.TestCaseConstants;
import io.dataease.commons.exception.DEException;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.CommonThreadPool;
import io.dataease.controller.request.DatasourceUnionRequest;
import io.dataease.controller.sys.base.BaseGridRequest;
import io.dataease.controller.sys.base.ConditionEntity;
import io.dataease.datasource.dto.DBTableDTO;
import io.dataease.datasource.provider.DatasourceProvider;
import io.dataease.datasource.provider.ProviderFactory;
import io.dataease.datasource.request.DatasourceRequest;
import io.dataease.dto.DatasourceDTO;
import io.dataease.dto.dataset.DataTableInfoDTO;
import io.dataease.service.dataset.DataSetGroupService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
......@@ -53,21 +60,22 @@ public class DatasourceService {
return datasource;
}
public List<Datasource> getDatasourceList(Datasource request) throws Exception {
DatasourceExample example = new DatasourceExample();
DatasourceExample.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(request.getName())) {
criteria.andNameLike(StringUtils.wrapIfMissing(request.getName(), "%"));
}
if (StringUtils.isNotBlank(request.getType())) {
criteria.andTypeEqualTo(request.getType());
}
example.setOrderByClause("update_time desc");
return datasourceMapper.selectByExampleWithBLOBs(example);
public List<DatasourceDTO> getDatasourceList(DatasourceUnionRequest request) throws Exception {
request.setSort("update_time desc");
return extDataSourceMapper.queryUnion(request);
}
public List<Datasource> gridQuery(BaseGridRequest request) {
public List<DatasourceDTO> gridQuery(BaseGridRequest request) {
//如果没有查询条件增加一个默认的条件
if(CollectionUtils.isEmpty(request.getConditions())){
ConditionEntity conditionEntity = new ConditionEntity();
conditionEntity.setField("1");
conditionEntity.setOperator("eq");
conditionEntity.setValue("1");
request.setConditions(Arrays.asList(conditionEntity));
}
GridExample gridExample = request.convertExample();
gridExample.setExtendCondition(String.valueOf(AuthUtils.getUser().getUserId()));
return extDataSourceMapper.query(gridExample);
}
......
package io.dataease.dto;
import lombok.Data;
/**
* Author: wangjiahao
* Date: 2021-05-12
* Description:
*/
@Data
public class BaseAuthDetail {
private Integer privilegeType;//类型
private Integer privilegeValue;//值 1 不可用 2 可用
}
package io.dataease.dto;
import io.dataease.base.domain.Datasource;
import lombok.Data;
/**
* Author: wangjiahao
* Date: 2021-05-18
* Description:
*/
@Data
public class DatasourceDTO extends Datasource {
private String privileges;
}
package io.dataease.dto;
import io.dataease.base.domain.SysAuth;
import io.dataease.base.domain.SysAuthDetail;
import lombok.Data;
import java.util.List;
/**
* Author: wangjiahao
* Date: 2021-05-12
* Description:
*/
@Data
public class SysAuthDTO extends SysAuth {
private List<SysAuthDetail> sysAuthDetails;
// private List<BaseAuthDetail> baseAuthDetails;
//
// private String authDetails;
//
// @Override
// public void setAuthDetails(String authDetails) {
// this.authDetails = authDetails;
// if(StringUtils.isNotEmpty(authDetails)){
// try{
// baseAuthDetails = JSON.parseArray(authDetails,BaseAuthDetail.class);
// }catch (Exception e){
// e.printStackTrace();
// //ignored
// }
// }
// }
//
// public List<BaseAuthDetail> getBaseAuthDetails() {
// return baseAuthDetails;
// }
//
// public void setBaseAuthDetails(List<BaseAuthDetail> baseAuthDetails) {
// this.baseAuthDetails = baseAuthDetails;
// }
//
// @Override
// public String getAuthDetails() {
// return authDetails;
// }
}
package io.dataease.dto;
import io.dataease.base.domain.SysDept;
/**
* Author: wangjiahao
* Date: 2021-05-14
* Description:
*/
public class SysDeptDTO extends SysDept {
}
package io.dataease.dto;
import io.dataease.base.domain.VAuthModel;
import lombok.Data;
import java.util.List;
/**
* Author: wangjiahao
* Date: 2021-05-11
* Description:
*/
@Data
public class VAuthModelDTO extends VAuthModel {
private List<VAuthModelDTO> children;
private Boolean leaf;
private Integer childrenCount;
private Boolean hasChildren;
}
......@@ -9,5 +9,8 @@ import java.util.List;
@Data
public class ChartGroupDTO extends DatasetGroup {
private String label;
private List<ChartGroupDTO> children;
private String privileges;
}
......@@ -14,4 +14,6 @@ import java.util.Map;
@Getter
public class ChartViewDTO extends ChartViewWithBLOBs {
private Map<String, Object> data;
private String privileges;
}
......@@ -13,4 +13,6 @@ import java.util.List;
public class DataSetGroupDTO extends DatasetGroup {
private String label;
private List<DataSetGroupDTO> children;
private String privileges;
}
......@@ -14,4 +14,5 @@ import java.util.List;
@Getter
public class DataSetTableDTO extends DatasetTable {
private List<DataSetTableDTO> children;
private String privileges;
}
......@@ -20,9 +20,8 @@ public class PanelGroupDTO extends PanelGroupWithBLOBs {
private List<PanelGroupDTO> children;
//仪表盘组件样式设计
private List<PanelDesignDTO> panelDesigns = new ArrayList<>();
private Boolean leaf;
private List<ChartViewDTO> viewsUsable = new ArrayList<>();
private String privileges;
}
......@@ -2,6 +2,7 @@ package io.dataease.service.chart;
import io.dataease.base.domain.*;
import io.dataease.base.mapper.ChartGroupMapper;
import io.dataease.base.mapper.ext.ExtChartGroupMapper;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.controller.request.chart.ChartGroupRequest;
......@@ -25,6 +26,9 @@ public class ChartGroupService {
@Resource
private ChartViewService chartViewService;
@Resource
private ExtChartGroupMapper extChartGroupMapper;
public ChartGroupDTO save(ChartGroup chartGroup) {
checkName(chartGroup);
if (StringUtils.isEmpty(chartGroup.getId())) {
......@@ -64,56 +68,28 @@ public class ChartGroupService {
return chartGroupMapper.selectByPrimaryKey(id);
}
public List<ChartGroupDTO> tree(ChartGroupRequest ChartGroup) {
ChartGroupExample ChartGroupExample = new ChartGroupExample();
ChartGroupExample.Criteria criteria = ChartGroupExample.createCriteria();
criteria.andCreateByEqualTo(AuthUtils.getUser().getUsername());
if (StringUtils.isNotEmpty(ChartGroup.getName())) {
criteria.andNameLike("%" + ChartGroup.getName() + "%");
}
if (StringUtils.isNotEmpty(ChartGroup.getType())) {
criteria.andTypeEqualTo(ChartGroup.getType());
public List<ChartGroupDTO> tree(ChartGroupRequest chartGroup) {
chartGroup.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
if(chartGroup.getLevel() == null){
chartGroup.setLevel(0);
}
if (StringUtils.isNotEmpty(ChartGroup.getId())) {
criteria.andIdEqualTo(ChartGroup.getId());
} else {
criteria.andLevelEqualTo(0);
}
ChartGroupExample.setOrderByClause(ChartGroup.getSort());
List<ChartGroup> ChartGroups = chartGroupMapper.selectByExample(ChartGroupExample);
List<ChartGroupDTO> DTOs = ChartGroups.stream().map(ele -> {
ChartGroupDTO dto = new ChartGroupDTO();
BeanUtils.copyBean(dto, ele);
dto.setLabel(ele.getName());
return dto;
}).collect(Collectors.toList());
getAll(DTOs, ChartGroup);
return DTOs;
List<ChartGroupDTO> treeInfo = extChartGroupMapper.search(chartGroup);
getAll(treeInfo, chartGroup);
return treeInfo;
}
public void getAll(List<ChartGroupDTO> list, ChartGroupRequest ChartGroup) {
public void getAll(List<ChartGroupDTO> list, ChartGroupRequest chartGroup) {
for (ChartGroupDTO obj : list) {
ChartGroupExample ChartGroupExample = new ChartGroupExample();
ChartGroupExample.Criteria criteria = ChartGroupExample.createCriteria();
criteria.andCreateByEqualTo(AuthUtils.getUser().getUsername());
if (StringUtils.isNotEmpty(ChartGroup.getName())) {
criteria.andNameLike("%" + ChartGroup.getName() + "%");
}
if (StringUtils.isNotEmpty(ChartGroup.getType())) {
criteria.andTypeEqualTo(ChartGroup.getType());
}
criteria.andPidEqualTo(obj.getId());
ChartGroupExample.setOrderByClause(ChartGroup.getSort());
List<ChartGroup> ChartGroups = chartGroupMapper.selectByExample(ChartGroupExample);
List<ChartGroupDTO> DTOs = ChartGroups.stream().map(ele -> {
ChartGroupDTO dto = new ChartGroupDTO();
BeanUtils.copyBean(dto, ele);
dto.setLabel(ele.getName());
return dto;
}).collect(Collectors.toList());
obj.setChildren(DTOs);
if (CollectionUtils.isNotEmpty(DTOs)) {
getAll(DTOs, ChartGroup);
ChartGroupRequest newChartGroup = new ChartGroupRequest();
newChartGroup.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
newChartGroup.setName(chartGroup.getName());
newChartGroup.setType(chartGroup.getType());
newChartGroup.setPid(obj.getId());
newChartGroup.setSort(chartGroup.getSort());
List<ChartGroupDTO> treeInfo = extChartGroupMapper.search(newChartGroup);
obj.setChildren(treeInfo);
if (CollectionUtils.isNotEmpty(treeInfo)) {
getAll(treeInfo, chartGroup);
}
}
}
......
......@@ -5,6 +5,7 @@ import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import io.dataease.base.domain.*;
import io.dataease.base.mapper.ChartViewMapper;
import io.dataease.base.mapper.ext.ExtChartViewMapper;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.commons.utils.CommonBeanFactory;
......@@ -42,6 +43,8 @@ public class ChartViewService {
@Resource
private ChartViewMapper chartViewMapper;
@Resource
private ExtChartViewMapper extChartViewMapper;
@Resource
private DataSetTableService dataSetTableService;
@Resource
private DatasourceService datasourceService;
......@@ -65,17 +68,9 @@ public class ChartViewService {
return chartView;
}
public List<ChartViewWithBLOBs> list(ChartViewRequest chartViewRequest) {
ChartViewExample chartViewExample = new ChartViewExample();
ChartViewExample.Criteria criteria = chartViewExample.createCriteria();
criteria.andCreateByEqualTo(AuthUtils.getUser().getUsername());
if (StringUtils.isNotEmpty(chartViewRequest.getSceneId())) {
criteria.andSceneIdEqualTo(chartViewRequest.getSceneId());
}
if (StringUtils.isNotEmpty(chartViewRequest.getSort())) {
chartViewExample.setOrderByClause(chartViewRequest.getSort());
}
return chartViewMapper.selectByExampleWithBLOBs(chartViewExample);
public List<ChartViewDTO> list(ChartViewRequest chartViewRequest) {
chartViewRequest.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
return extChartViewMapper.search(chartViewRequest);
}
public ChartViewWithBLOBs get(String id) {
......
......@@ -4,11 +4,13 @@ import io.dataease.base.domain.DatasetGroup;
import io.dataease.base.domain.DatasetGroupExample;
import io.dataease.base.domain.DatasetTable;
import io.dataease.base.mapper.DatasetGroupMapper;
import io.dataease.base.mapper.ext.ExtDataSetGroupMapper;
import io.dataease.commons.utils.AuthUtils;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.controller.request.dataset.DataSetGroupRequest;
import io.dataease.controller.request.dataset.DataSetTableRequest;
import io.dataease.dto.dataset.DataSetGroupDTO;
import io.dataease.dto.dataset.DataSetTableDTO;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
......@@ -30,6 +32,8 @@ public class DataSetGroupService {
private DatasetGroupMapper datasetGroupMapper;
@Resource
private DataSetTableService dataSetTableService;
@Resource
private ExtDataSetGroupMapper extDataSetGroupMapper;
public DataSetGroupDTO save(DatasetGroup datasetGroup) {
checkName(datasetGroup);
......@@ -68,63 +72,35 @@ public class DataSetGroupService {
for (String sceneId : sceneIds) {
DataSetTableRequest dataSetTableRequest = new DataSetTableRequest();
dataSetTableRequest.setSceneId(sceneId);
List<DatasetTable> list = dataSetTableService.list(dataSetTableRequest);
for (DatasetTable table : list) {
List<DataSetTableDTO> list = dataSetTableService.list(dataSetTableRequest);
for (DataSetTableDTO table : list) {
dataSetTableService.delete(table.getId());
}
}
}
public List<DataSetGroupDTO> tree(DataSetGroupRequest datasetGroup) {
DatasetGroupExample datasetGroupExample = new DatasetGroupExample();
DatasetGroupExample.Criteria criteria = datasetGroupExample.createCriteria();
criteria.andCreateByEqualTo(AuthUtils.getUser().getUsername());
if (StringUtils.isNotEmpty(datasetGroup.getName())) {
criteria.andNameLike("%" + datasetGroup.getName() + "%");
}
if (StringUtils.isNotEmpty(datasetGroup.getType())) {
criteria.andTypeEqualTo(datasetGroup.getType());
}
if (StringUtils.isNotEmpty(datasetGroup.getId())) {
criteria.andIdEqualTo(datasetGroup.getId());
} else {
criteria.andLevelEqualTo(0);
datasetGroup.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
if(datasetGroup.getLevel() == null){
datasetGroup.setLevel(0);
}
datasetGroupExample.setOrderByClause(datasetGroup.getSort());
List<DatasetGroup> datasetGroups = datasetGroupMapper.selectByExample(datasetGroupExample);
List<DataSetGroupDTO> DTOs = datasetGroups.stream().map(ele -> {
DataSetGroupDTO dto = new DataSetGroupDTO();
BeanUtils.copyBean(dto, ele);
dto.setLabel(ele.getName());
return dto;
}).collect(Collectors.toList());
getAll(DTOs, datasetGroup);
return DTOs;
List<DataSetGroupDTO> treeInfo = extDataSetGroupMapper.search(datasetGroup);
getAll(treeInfo, datasetGroup);
return treeInfo;
}
public void getAll(List<DataSetGroupDTO> list, DataSetGroupRequest datasetGroup) {
for (DataSetGroupDTO obj : list) {
DatasetGroupExample datasetGroupExample = new DatasetGroupExample();
DatasetGroupExample.Criteria criteria = datasetGroupExample.createCriteria();
criteria.andCreateByEqualTo(AuthUtils.getUser().getUsername());
if (StringUtils.isNotEmpty(datasetGroup.getName())) {
criteria.andNameLike("%" + datasetGroup.getName() + "%");
}
if (StringUtils.isNotEmpty(datasetGroup.getType())) {
criteria.andTypeEqualTo(datasetGroup.getType());
}
criteria.andPidEqualTo(obj.getId());
datasetGroupExample.setOrderByClause(datasetGroup.getSort());
List<DatasetGroup> datasetGroups = datasetGroupMapper.selectByExample(datasetGroupExample);
List<DataSetGroupDTO> DTOs = datasetGroups.stream().map(ele -> {
DataSetGroupDTO dto = new DataSetGroupDTO();
BeanUtils.copyBean(dto, ele);
dto.setLabel(ele.getName());
return dto;
}).collect(Collectors.toList());
obj.setChildren(DTOs);
if (CollectionUtils.isNotEmpty(DTOs)) {
getAll(DTOs, datasetGroup);
DataSetGroupRequest newDataSetGroup = new DataSetGroupRequest();
newDataSetGroup.setUserId(String.valueOf(AuthUtils.getUser().getUserId()));
newDataSetGroup.setName(datasetGroup.getName());
newDataSetGroup.setType(datasetGroup.getType());
newDataSetGroup.setPid(obj.getId());
newDataSetGroup.setSort(datasetGroup.getSort());
List<DataSetGroupDTO> treeInfo = extDataSetGroupMapper.search(newDataSetGroup);
obj.setChildren(treeInfo);
if (CollectionUtils.isNotEmpty(treeInfo)) {
getAll(treeInfo, datasetGroup);
}
}
}
......
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论