提交 75e9537a authored 作者: junjie's avatar junjie

feat: 数据集 分组 场景

上级 2b909be5
......@@ -13,6 +13,8 @@ public class DatasetGroup implements Serializable {
private Integer level;
private String type;
private String createBy;
private Long createTime;
......
......@@ -374,6 +374,76 @@ public class DatasetGroupExample {
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
}
public Criteria andTypeIsNotNull() {
addCriterion("`type` is not null");
return (Criteria) this;
}
public Criteria andTypeEqualTo(String value) {
addCriterion("`type` =", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotEqualTo(String value) {
addCriterion("`type` <>", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThan(String value) {
addCriterion("`type` >", value, "type");
return (Criteria) this;
}
public Criteria andTypeGreaterThanOrEqualTo(String value) {
addCriterion("`type` >=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThan(String value) {
addCriterion("`type` <", value, "type");
return (Criteria) this;
}
public Criteria andTypeLessThanOrEqualTo(String value) {
addCriterion("`type` <=", value, "type");
return (Criteria) this;
}
public Criteria andTypeLike(String value) {
addCriterion("`type` like", value, "type");
return (Criteria) this;
}
public Criteria andTypeNotLike(String value) {
addCriterion("`type` not like", value, "type");
return (Criteria) this;
}
public Criteria andTypeIn(List<String> values) {
addCriterion("`type` in", values, "type");
return (Criteria) this;
}
public Criteria andTypeNotIn(List<String> values) {
addCriterion("`type` not in", values, "type");
return (Criteria) this;
}
public Criteria andTypeBetween(String value1, String value2) {
addCriterion("`type` between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andTypeNotBetween(String value1, String value2) {
addCriterion("`type` not between", value1, value2, "type");
return (Criteria) this;
}
public Criteria andCreateByIsNull() {
addCriterion("create_by is null");
return (Criteria) this;
......
package io.dataease.base.domain;
import java.io.Serializable;
import lombok.Data;
@Data
public class DatasetScene implements Serializable {
private String id;
private String name;
private String groupId;
private String createBy;
private Long createTime;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -6,6 +6,7 @@
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="pid" jdbcType="VARCHAR" property="pid" />
<result column="level" jdbcType="INTEGER" property="level" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
</resultMap>
......@@ -68,7 +69,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, `name`, pid, `level`, create_by, create_time
id, `name`, pid, `level`, `type`, create_by, create_time
</sql>
<select id="selectByExample" parameterType="io.dataease.base.domain.DatasetGroupExample" resultMap="BaseResultMap">
select
......@@ -102,11 +103,11 @@
</delete>
<insert id="insert" parameterType="io.dataease.base.domain.DatasetGroup">
insert into dataset_group (id, `name`, pid,
`level`, create_by, create_time
)
`level`, `type`, create_by,
create_time)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{pid,jdbcType=VARCHAR},
#{level,jdbcType=INTEGER}, #{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}
)
#{level,jdbcType=INTEGER}, #{type,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
#{createTime,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.DatasetGroup">
insert into dataset_group
......@@ -123,6 +124,9 @@
<if test="level != null">
`level`,
</if>
<if test="type != null">
`type`,
</if>
<if test="createBy != null">
create_by,
</if>
......@@ -143,6 +147,9 @@
<if test="level != null">
#{level,jdbcType=INTEGER},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
......@@ -172,6 +179,9 @@
<if test="record.level != null">
`level` = #{record.level,jdbcType=INTEGER},
</if>
<if test="record.type != null">
`type` = #{record.type,jdbcType=VARCHAR},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
......@@ -189,6 +199,7 @@
`name` = #{record.name,jdbcType=VARCHAR},
pid = #{record.pid,jdbcType=VARCHAR},
`level` = #{record.level,jdbcType=INTEGER},
`type` = #{record.type,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT}
<if test="_parameter != null">
......@@ -207,6 +218,9 @@
<if test="level != null">
`level` = #{level,jdbcType=INTEGER},
</if>
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
......@@ -221,6 +235,7 @@
set `name` = #{name,jdbcType=VARCHAR},
pid = #{pid,jdbcType=VARCHAR},
`level` = #{level,jdbcType=INTEGER},
`type` = #{type,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}
......
package io.dataease.base.mapper;
import io.dataease.base.domain.DatasetScene;
import io.dataease.base.domain.DatasetSceneExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface DatasetSceneMapper {
long countByExample(DatasetSceneExample example);
int deleteByExample(DatasetSceneExample example);
int deleteByPrimaryKey(String id);
int insert(DatasetScene record);
int insertSelective(DatasetScene record);
List<DatasetScene> selectByExample(DatasetSceneExample example);
DatasetScene selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") DatasetScene record, @Param("example") DatasetSceneExample example);
int updateByExample(@Param("record") DatasetScene record, @Param("example") DatasetSceneExample example);
int updateByPrimaryKeySelective(DatasetScene record);
int updateByPrimaryKey(DatasetScene record);
}
\ 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.DatasetSceneMapper">
<resultMap id="BaseResultMap" type="io.dataease.base.domain.DatasetScene">
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="group_id" jdbcType="VARCHAR" property="groupId" />
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
<result column="create_time" jdbcType="BIGINT" property="createTime" />
</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`, group_id, create_by, create_time
</sql>
<select id="selectByExample" parameterType="io.dataease.base.domain.DatasetSceneExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from dataset_scene
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from dataset_scene
where id = #{id,jdbcType=VARCHAR}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
delete from dataset_scene
where id = #{id,jdbcType=VARCHAR}
</delete>
<delete id="deleteByExample" parameterType="io.dataease.base.domain.DatasetSceneExample">
delete from dataset_scene
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="io.dataease.base.domain.DatasetScene">
insert into dataset_scene (id, `name`, group_id,
create_by, create_time)
values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{groupId,jdbcType=VARCHAR},
#{createBy,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" parameterType="io.dataease.base.domain.DatasetScene">
insert into dataset_scene
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="name != null">
`name`,
</if>
<if test="groupId != null">
group_id,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</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="groupId != null">
#{groupId,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
#{createTime,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="io.dataease.base.domain.DatasetSceneExample" resultType="java.lang.Long">
select count(*) from dataset_scene
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update dataset_scene
<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.groupId != null">
group_id = #{record.groupId,jdbcType=VARCHAR},
</if>
<if test="record.createBy != null">
create_by = #{record.createBy,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update dataset_scene
set id = #{record.id,jdbcType=VARCHAR},
`name` = #{record.name,jdbcType=VARCHAR},
group_id = #{record.groupId,jdbcType=VARCHAR},
create_by = #{record.createBy,jdbcType=VARCHAR},
create_time = #{record.createTime,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="io.dataease.base.domain.DatasetScene">
update dataset_scene
<set>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="groupId != null">
group_id = #{groupId,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=BIGINT},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="io.dataease.base.domain.DatasetScene">
update dataset_scene
set `name` = #{name,jdbcType=VARCHAR},
group_id = #{groupId,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_time = #{createTime,jdbcType=BIGINT}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
package io.dataease.controller.dataset;
import io.dataease.base.domain.DatasetGroup;
import io.dataease.controller.request.dataset.DataSetGroupRequest;
import io.dataease.dto.dataset.DataSetGroupDTO;
import io.dataease.service.dataset.DataSetGroupService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* @Author gin
......@@ -24,4 +23,14 @@ public class DataSetGroupController {
public DataSetGroupDTO save(@RequestBody DatasetGroup datasetGroup) {
return dataSetGroupService.save(datasetGroup);
}
@PostMapping("/tree")
public List<DataSetGroupDTO> tree(@RequestBody DataSetGroupRequest datasetGroup) {
return dataSetGroupService.tree(datasetGroup);
}
@PostMapping("/delete/{id}")
public void tree(@PathVariable String id) {
dataSetGroupService.delete(id);
}
}
package io.dataease.controller.request.dataset;
import io.dataease.base.domain.DatasetGroup;
import lombok.Data;
/**
* @Author gin
* @Date 2021/2/22 1:30 下午
*/
@Data
public class DataSetGroupRequest extends DatasetGroup {
private String sort;
}
......@@ -3,6 +3,8 @@ package io.dataease.dto.dataset;
import io.dataease.base.domain.DatasetGroup;
import lombok.Data;
import java.util.List;
/**
* @Author gin
* @Date 2021/2/20 8:17 下午
......@@ -10,4 +12,5 @@ import lombok.Data;
@Data
public class DataSetGroupDTO extends DatasetGroup {
private String label;
private List<DataSetGroupDTO> children;
}
......@@ -2,13 +2,19 @@ package io.dataease.service.dataset;
import com.alibaba.nacos.common.util.UuidUtils;
import io.dataease.base.domain.DatasetGroup;
import io.dataease.base.domain.DatasetGroupExample;
import io.dataease.base.mapper.DatasetGroupMapper;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.controller.request.dataset.DataSetGroupRequest;
import io.dataease.dto.dataset.DataSetGroupDTO;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author gin
......@@ -32,4 +38,77 @@ public class DataSetGroupService {
dataSetGroupDTO.setLabel(dataSetGroupDTO.getName());
return dataSetGroupDTO;
}
public void delete(String id) {
DataSetGroupRequest datasetGroup = new DataSetGroupRequest();
datasetGroup.setId(id);
List<DataSetGroupDTO> tree = tree(datasetGroup);
List<String> ids = new ArrayList<>();
getAllId(tree, ids);
DatasetGroupExample datasetGroupExample = new DatasetGroupExample();
datasetGroupExample.createCriteria().andIdIn(ids);
datasetGroupMapper.deleteByExample(datasetGroupExample);
}
public List<DataSetGroupDTO> tree(DataSetGroupRequest datasetGroup) {
DatasetGroupExample datasetGroupExample = new DatasetGroupExample();
DatasetGroupExample.Criteria criteria = datasetGroupExample.createCriteria();
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);
}
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;
}
public void getAll(List<DataSetGroupDTO> list, DataSetGroupRequest datasetGroup) {
for (DataSetGroupDTO obj : list) {
DatasetGroupExample datasetGroupExample = new DatasetGroupExample();
DatasetGroupExample.Criteria criteria = datasetGroupExample.createCriteria();
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);
}
}
}
public List<String> getAllId(List<DataSetGroupDTO> list, List<String> ids) {
for (DataSetGroupDTO dto : list) {
ids.add(dto.getId());
if (CollectionUtils.isNotEmpty(dto.getChildren())) {
getAllId(dto.getChildren(), ids);
}
}
return ids;
}
}
......@@ -340,19 +340,11 @@ CREATE TABLE IF NOT EXISTS `dataset_group` (
`name` varchar(64) NOT NULL COMMENT '名称',
`pid` varchar(50) COMMENT '父级ID',
`level` int(10) COMMENT '当前分组处于第几级',
`type` varchar(50) COMMENT 'group or scene',
`create_by` varchar(50) COMMENT '创建人ID',
`create_time` bigint(13) COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `dataset_scene` (
`id` varchar(50) NOT NULL COMMENT 'ID',
`name` varchar(64) NOT NULL COMMENT '名称',
`group_id` varchar(50) COMMENT 'DataSet Group ID',
`create_by` varchar(50) COMMENT '创建人ID',
`create_time` bigint(13) COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- dataset end
......@@ -34,8 +34,8 @@
.ms-aside-container {
height: calc(100vh - 40px);
padding: 20px;
min-width: 260px;
max-width: 460px;
min-width: 300px;
max-width: 500px;
}
.ms-main-container {
......
......@@ -1523,6 +1523,20 @@ export default {
datalist:'Data List',
add_group:'Add Group',
add_scene:'Add Scene',
group:'DataSet Group'
group:'Group',
scene:'Scene',
delete:'Delete',
move_to:'Move',
rename:'Rename',
tips:'Tips',
confirm_delete:'Confirm Delete',
delete_success:'Delete Success',
confirm:'Confirm',
cancel:'Cancel',
search:'Search',
back:'Back',
add_table:'Add Table',
process:'Process',
update:'Update'
}
};
......@@ -1526,6 +1526,20 @@ export default {
datalist:'数据列表',
add_group:'添加分组',
add_scene:'添加场景',
group:'分组'
group:'分组',
scene:'场景',
delete:'删除',
move_to:'移动到',
rename:'重命名',
tips:'提示',
confirm_delete:'确认删除',
delete_success:'删除成功',
confirm:'确认',
cancel:'取消',
search:'搜索',
back:'返回',
add_table:'添加表',
process:'进度',
update:'更新'
}
};
......@@ -1524,6 +1524,20 @@ export default {
datalist:'數據列表',
add_group:'添加分組',
add_scene:'添加場景',
group:'分組'
group:'分組',
scene:'場景',
delete:'刪除',
move_to:'移動到',
rename:'重命名',
tips:'提示',
confirm_delete:'確認刪除',
delete_success:'刪除成功',
confirm:'確認',
cancel:'取消',
search:'搜索',
back:'返回',
add_table:'添加表',
process:'進度',
update:'更新'
}
};
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论