From 73bf229464908e5c754a0185abd1fc92b59984dd Mon Sep 17 00:00:00 2001 From: junjie Date: Tue, 23 Feb 2021 18:23:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=95=B0=E6=8D=AE=E9=9B=86):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0DB=EF=BC=8CDB=20curd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/dataease/base/domain/DatasetTable.java | 23 + .../base/domain/DatasetTableExample.java | 680 ++++++++++++++++++ .../base/mapper/DatasetTableMapper.java | 30 + .../base/mapper/DatasetTableMapper.xml | 243 +++++++ .../dataset/DataSetTableController.java | 45 ++ .../request/dataset/DataSetTableRequest.java | 18 + .../dataease/dto/dataset/DataSetTableDTO.java | 17 + .../service/dataset/DataSetTableService.java | 57 ++ .../db/migration/V9__dataset_tables.sql | 11 + .../components/dataset/data/AddDB.vue | 20 +- .../dataset/data/TabDataPreview.vue | 64 ++ .../components/dataset/data/ViewTable.vue | 94 +++ .../components/dataset/group/Group.vue | 140 +++- .../src/business/components/dataset/router.js | 6 + frontend/src/business/store.js | 6 +- frontend/src/i18n/en-US.js | 6 +- frontend/src/i18n/zh-CN.js | 10 +- frontend/src/i18n/zh-TW.js | 6 +- 18 files changed, 1448 insertions(+), 28 deletions(-) create mode 100644 backend/src/main/java/io/dataease/base/domain/DatasetTable.java create mode 100644 backend/src/main/java/io/dataease/base/domain/DatasetTableExample.java create mode 100644 backend/src/main/java/io/dataease/base/mapper/DatasetTableMapper.java create mode 100644 backend/src/main/java/io/dataease/base/mapper/DatasetTableMapper.xml create mode 100644 backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java create mode 100644 backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java create mode 100644 backend/src/main/java/io/dataease/dto/dataset/DataSetTableDTO.java create mode 100644 backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java create mode 100644 backend/src/main/resources/db/migration/V9__dataset_tables.sql create mode 100644 frontend/src/business/components/dataset/data/TabDataPreview.vue create mode 100644 frontend/src/business/components/dataset/data/ViewTable.vue diff --git a/backend/src/main/java/io/dataease/base/domain/DatasetTable.java b/backend/src/main/java/io/dataease/base/domain/DatasetTable.java new file mode 100644 index 0000000000..1d9a38ef03 --- /dev/null +++ b/backend/src/main/java/io/dataease/base/domain/DatasetTable.java @@ -0,0 +1,23 @@ +package io.dataease.base.domain; + +import java.io.Serializable; +import lombok.Data; + +@Data +public class DatasetTable implements Serializable { + private String id; + + private String name; + + private String sceneId; + + private String dataSourceId; + + private String type; + + private String createBy; + + private Long createTime; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/domain/DatasetTableExample.java b/backend/src/main/java/io/dataease/base/domain/DatasetTableExample.java new file mode 100644 index 0000000000..2aa5150e3b --- /dev/null +++ b/backend/src/main/java/io/dataease/base/domain/DatasetTableExample.java @@ -0,0 +1,680 @@ +package io.dataease.base.domain; + +import java.util.ArrayList; +import java.util.List; + +public class DatasetTableExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public DatasetTableExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andIdIsNull() { + addCriterion("id is null"); + return (Criteria) this; + } + + public Criteria andIdIsNotNull() { + addCriterion("id is not null"); + return (Criteria) this; + } + + public Criteria andIdEqualTo(String value) { + addCriterion("id =", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotEqualTo(String value) { + addCriterion("id <>", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThan(String value) { + addCriterion("id >", value, "id"); + return (Criteria) this; + } + + public Criteria andIdGreaterThanOrEqualTo(String value) { + addCriterion("id >=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThan(String value) { + addCriterion("id <", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLessThanOrEqualTo(String value) { + addCriterion("id <=", value, "id"); + return (Criteria) this; + } + + public Criteria andIdLike(String value) { + addCriterion("id like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdNotLike(String value) { + addCriterion("id not like", value, "id"); + return (Criteria) this; + } + + public Criteria andIdIn(List values) { + addCriterion("id in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdNotIn(List values) { + addCriterion("id not in", values, "id"); + return (Criteria) this; + } + + public Criteria andIdBetween(String value1, String value2) { + addCriterion("id between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andIdNotBetween(String value1, String value2) { + addCriterion("id not between", value1, value2, "id"); + return (Criteria) this; + } + + public Criteria andNameIsNull() { + addCriterion("`name` is null"); + return (Criteria) this; + } + + public Criteria andNameIsNotNull() { + addCriterion("`name` is not null"); + return (Criteria) this; + } + + public Criteria andNameEqualTo(String value) { + addCriterion("`name` =", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotEqualTo(String value) { + addCriterion("`name` <>", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThan(String value) { + addCriterion("`name` >", value, "name"); + return (Criteria) this; + } + + public Criteria andNameGreaterThanOrEqualTo(String value) { + addCriterion("`name` >=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThan(String value) { + addCriterion("`name` <", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLessThanOrEqualTo(String value) { + addCriterion("`name` <=", value, "name"); + return (Criteria) this; + } + + public Criteria andNameLike(String value) { + addCriterion("`name` like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameNotLike(String value) { + addCriterion("`name` not like", value, "name"); + return (Criteria) this; + } + + public Criteria andNameIn(List values) { + addCriterion("`name` in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameNotIn(List values) { + addCriterion("`name` not in", values, "name"); + return (Criteria) this; + } + + public Criteria andNameBetween(String value1, String value2) { + addCriterion("`name` between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andNameNotBetween(String value1, String value2) { + addCriterion("`name` not between", value1, value2, "name"); + return (Criteria) this; + } + + public Criteria andSceneIdIsNull() { + addCriterion("scene_id is null"); + return (Criteria) this; + } + + public Criteria andSceneIdIsNotNull() { + addCriterion("scene_id is not null"); + return (Criteria) this; + } + + public Criteria andSceneIdEqualTo(String value) { + addCriterion("scene_id =", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdNotEqualTo(String value) { + addCriterion("scene_id <>", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdGreaterThan(String value) { + addCriterion("scene_id >", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdGreaterThanOrEqualTo(String value) { + addCriterion("scene_id >=", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdLessThan(String value) { + addCriterion("scene_id <", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdLessThanOrEqualTo(String value) { + addCriterion("scene_id <=", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdLike(String value) { + addCriterion("scene_id like", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdNotLike(String value) { + addCriterion("scene_id not like", value, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdIn(List values) { + addCriterion("scene_id in", values, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdNotIn(List values) { + addCriterion("scene_id not in", values, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdBetween(String value1, String value2) { + addCriterion("scene_id between", value1, value2, "sceneId"); + return (Criteria) this; + } + + public Criteria andSceneIdNotBetween(String value1, String value2) { + addCriterion("scene_id not between", value1, value2, "sceneId"); + return (Criteria) this; + } + + public Criteria andDataSourceIdIsNull() { + addCriterion("data_source_id is null"); + return (Criteria) this; + } + + public Criteria andDataSourceIdIsNotNull() { + addCriterion("data_source_id is not null"); + return (Criteria) this; + } + + public Criteria andDataSourceIdEqualTo(String value) { + addCriterion("data_source_id =", value, "dataSourceId"); + return (Criteria) this; + } + + public Criteria andDataSourceIdNotEqualTo(String value) { + addCriterion("data_source_id <>", value, "dataSourceId"); + return (Criteria) this; + } + + public Criteria andDataSourceIdGreaterThan(String value) { + addCriterion("data_source_id >", value, "dataSourceId"); + return (Criteria) this; + } + + public Criteria andDataSourceIdGreaterThanOrEqualTo(String value) { + addCriterion("data_source_id >=", value, "dataSourceId"); + return (Criteria) this; + } + + public Criteria andDataSourceIdLessThan(String value) { + addCriterion("data_source_id <", value, "dataSourceId"); + return (Criteria) this; + } + + public Criteria andDataSourceIdLessThanOrEqualTo(String value) { + addCriterion("data_source_id <=", value, "dataSourceId"); + return (Criteria) this; + } + + public Criteria andDataSourceIdLike(String value) { + addCriterion("data_source_id like", value, "dataSourceId"); + return (Criteria) this; + } + + public Criteria andDataSourceIdNotLike(String value) { + addCriterion("data_source_id not like", value, "dataSourceId"); + return (Criteria) this; + } + + public Criteria andDataSourceIdIn(List values) { + addCriterion("data_source_id in", values, "dataSourceId"); + return (Criteria) this; + } + + public Criteria andDataSourceIdNotIn(List values) { + addCriterion("data_source_id not in", values, "dataSourceId"); + return (Criteria) this; + } + + public Criteria andDataSourceIdBetween(String value1, String value2) { + addCriterion("data_source_id between", value1, value2, "dataSourceId"); + return (Criteria) this; + } + + public Criteria andDataSourceIdNotBetween(String value1, String value2) { + addCriterion("data_source_id not between", value1, value2, "dataSourceId"); + 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 values) { + addCriterion("`type` in", values, "type"); + return (Criteria) this; + } + + public Criteria andTypeNotIn(List 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; + } + + public Criteria andCreateByIsNotNull() { + addCriterion("create_by is not null"); + return (Criteria) this; + } + + public Criteria andCreateByEqualTo(String value) { + addCriterion("create_by =", value, "createBy"); + return (Criteria) this; + } + + public Criteria andCreateByNotEqualTo(String value) { + addCriterion("create_by <>", value, "createBy"); + return (Criteria) this; + } + + public Criteria andCreateByGreaterThan(String value) { + addCriterion("create_by >", value, "createBy"); + return (Criteria) this; + } + + public Criteria andCreateByGreaterThanOrEqualTo(String value) { + addCriterion("create_by >=", value, "createBy"); + return (Criteria) this; + } + + public Criteria andCreateByLessThan(String value) { + addCriterion("create_by <", value, "createBy"); + return (Criteria) this; + } + + public Criteria andCreateByLessThanOrEqualTo(String value) { + addCriterion("create_by <=", value, "createBy"); + return (Criteria) this; + } + + public Criteria andCreateByLike(String value) { + addCriterion("create_by like", value, "createBy"); + return (Criteria) this; + } + + public Criteria andCreateByNotLike(String value) { + addCriterion("create_by not like", value, "createBy"); + return (Criteria) this; + } + + public Criteria andCreateByIn(List values) { + addCriterion("create_by in", values, "createBy"); + return (Criteria) this; + } + + public Criteria andCreateByNotIn(List values) { + addCriterion("create_by not in", values, "createBy"); + return (Criteria) this; + } + + public Criteria andCreateByBetween(String value1, String value2) { + addCriterion("create_by between", value1, value2, "createBy"); + return (Criteria) this; + } + + public Criteria andCreateByNotBetween(String value1, String value2) { + addCriterion("create_by not between", value1, value2, "createBy"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNull() { + addCriterion("create_time is null"); + return (Criteria) this; + } + + public Criteria andCreateTimeIsNotNull() { + addCriterion("create_time is not null"); + return (Criteria) this; + } + + public Criteria andCreateTimeEqualTo(Long value) { + addCriterion("create_time =", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotEqualTo(Long value) { + addCriterion("create_time <>", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThan(Long value) { + addCriterion("create_time >", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeGreaterThanOrEqualTo(Long value) { + addCriterion("create_time >=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThan(Long value) { + addCriterion("create_time <", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeLessThanOrEqualTo(Long value) { + addCriterion("create_time <=", value, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeIn(List values) { + addCriterion("create_time in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotIn(List values) { + addCriterion("create_time not in", values, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeBetween(Long value1, Long value2) { + addCriterion("create_time between", value1, value2, "createTime"); + return (Criteria) this; + } + + public Criteria andCreateTimeNotBetween(Long value1, Long value2) { + addCriterion("create_time not between", value1, value2, "createTime"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/mapper/DatasetTableMapper.java b/backend/src/main/java/io/dataease/base/mapper/DatasetTableMapper.java new file mode 100644 index 0000000000..e99df7a37d --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/DatasetTableMapper.java @@ -0,0 +1,30 @@ +package io.dataease.base.mapper; + +import io.dataease.base.domain.DatasetTable; +import io.dataease.base.domain.DatasetTableExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface DatasetTableMapper { + long countByExample(DatasetTableExample example); + + int deleteByExample(DatasetTableExample example); + + int deleteByPrimaryKey(String id); + + int insert(DatasetTable record); + + int insertSelective(DatasetTable record); + + List selectByExample(DatasetTableExample example); + + DatasetTable selectByPrimaryKey(String id); + + int updateByExampleSelective(@Param("record") DatasetTable record, @Param("example") DatasetTableExample example); + + int updateByExample(@Param("record") DatasetTable record, @Param("example") DatasetTableExample example); + + int updateByPrimaryKeySelective(DatasetTable record); + + int updateByPrimaryKey(DatasetTable record); +} \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/base/mapper/DatasetTableMapper.xml b/backend/src/main/java/io/dataease/base/mapper/DatasetTableMapper.xml new file mode 100644 index 0000000000..1a6c56e7af --- /dev/null +++ b/backend/src/main/java/io/dataease/base/mapper/DatasetTableMapper.xml @@ -0,0 +1,243 @@ + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + id, `name`, scene_id, data_source_id, `type`, create_by, create_time + + + + + delete from dataset_table + where id = #{id,jdbcType=VARCHAR} + + + delete from dataset_table + + + + + + insert into dataset_table (id, `name`, scene_id, + data_source_id, `type`, create_by, + create_time) + values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{sceneId,jdbcType=VARCHAR}, + #{dataSourceId,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR}, + #{createTime,jdbcType=BIGINT}) + + + insert into dataset_table + + + id, + + + `name`, + + + scene_id, + + + data_source_id, + + + `type`, + + + create_by, + + + create_time, + + + + + #{id,jdbcType=VARCHAR}, + + + #{name,jdbcType=VARCHAR}, + + + #{sceneId,jdbcType=VARCHAR}, + + + #{dataSourceId,jdbcType=VARCHAR}, + + + #{type,jdbcType=VARCHAR}, + + + #{createBy,jdbcType=VARCHAR}, + + + #{createTime,jdbcType=BIGINT}, + + + + + + update dataset_table + + + id = #{record.id,jdbcType=VARCHAR}, + + + `name` = #{record.name,jdbcType=VARCHAR}, + + + scene_id = #{record.sceneId,jdbcType=VARCHAR}, + + + data_source_id = #{record.dataSourceId,jdbcType=VARCHAR}, + + + `type` = #{record.type,jdbcType=VARCHAR}, + + + create_by = #{record.createBy,jdbcType=VARCHAR}, + + + create_time = #{record.createTime,jdbcType=BIGINT}, + + + + + + + + update dataset_table + set id = #{record.id,jdbcType=VARCHAR}, + `name` = #{record.name,jdbcType=VARCHAR}, + scene_id = #{record.sceneId,jdbcType=VARCHAR}, + data_source_id = #{record.dataSourceId,jdbcType=VARCHAR}, + `type` = #{record.type,jdbcType=VARCHAR}, + create_by = #{record.createBy,jdbcType=VARCHAR}, + create_time = #{record.createTime,jdbcType=BIGINT} + + + + + + update dataset_table + + + `name` = #{name,jdbcType=VARCHAR}, + + + scene_id = #{sceneId,jdbcType=VARCHAR}, + + + data_source_id = #{dataSourceId,jdbcType=VARCHAR}, + + + `type` = #{type,jdbcType=VARCHAR}, + + + create_by = #{createBy,jdbcType=VARCHAR}, + + + create_time = #{createTime,jdbcType=BIGINT}, + + + where id = #{id,jdbcType=VARCHAR} + + + update dataset_table + set `name` = #{name,jdbcType=VARCHAR}, + scene_id = #{sceneId,jdbcType=VARCHAR}, + data_source_id = #{dataSourceId,jdbcType=VARCHAR}, + `type` = #{type,jdbcType=VARCHAR}, + create_by = #{createBy,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT} + where id = #{id,jdbcType=VARCHAR} + + \ No newline at end of file diff --git a/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java new file mode 100644 index 0000000000..bf401cbc8d --- /dev/null +++ b/backend/src/main/java/io/dataease/controller/dataset/DataSetTableController.java @@ -0,0 +1,45 @@ +package io.dataease.controller.dataset; + +import io.dataease.base.domain.DatasetTable; +import io.dataease.controller.request.dataset.DataSetTableRequest; +import io.dataease.service.dataset.DataSetTableService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @Author gin + * @Date 2021/2/20 8:29 下午 + */ +@RestController +@RequestMapping("dataset/table") +public class DataSetTableController { + @Resource + private DataSetTableService dataSetTableService; + + @PostMapping("batchAdd") + public void batchAdd(@RequestBody List datasetTable) { + dataSetTableService.batchInsert(datasetTable); + } + + @PostMapping("update") + public DatasetTable save(@RequestBody DatasetTable datasetTable) { + return dataSetTableService.save(datasetTable); + } + + @PostMapping("delete/{id}") + public void delete(@PathVariable String id) { + dataSetTableService.delete(id); + } + + @PostMapping("list") + public List list(@RequestBody DataSetTableRequest dataSetTableRequest) { + return dataSetTableService.list(dataSetTableRequest); + } + + @PostMapping("get/{id}") + public DatasetTable get(@PathVariable String id) { + return dataSetTableService.get(id); + } +} diff --git a/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java b/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java new file mode 100644 index 0000000000..aed452a87a --- /dev/null +++ b/backend/src/main/java/io/dataease/controller/request/dataset/DataSetTableRequest.java @@ -0,0 +1,18 @@ +package io.dataease.controller.request.dataset; + +import io.dataease.base.domain.DatasetTable; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * @Author gin + * @Date 2021/2/23 3:06 下午 + */ +@Setter +@Getter +public class DataSetTableRequest extends DatasetTable { + private String sort; + private List tableNames; +} diff --git a/backend/src/main/java/io/dataease/dto/dataset/DataSetTableDTO.java b/backend/src/main/java/io/dataease/dto/dataset/DataSetTableDTO.java new file mode 100644 index 0000000000..87b996749f --- /dev/null +++ b/backend/src/main/java/io/dataease/dto/dataset/DataSetTableDTO.java @@ -0,0 +1,17 @@ +package io.dataease.dto.dataset; + +import io.dataease.base.domain.DatasetTable; +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +/** + * @Author gin + * @Date 2021/2/23 2:55 下午 + */ +@Setter +@Getter +public class DataSetTableDTO extends DatasetTable { + private List children; +} diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java new file mode 100644 index 0000000000..1fc10c9cc6 --- /dev/null +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -0,0 +1,57 @@ +package io.dataease.service.dataset; + +import com.alibaba.nacos.common.util.UuidUtils; +import io.dataease.base.domain.DatasetTable; +import io.dataease.base.domain.DatasetTableExample; +import io.dataease.base.mapper.DatasetTableMapper; +import io.dataease.commons.utils.BeanUtils; +import io.dataease.controller.request.dataset.DataSetTableRequest; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @Author gin + * @Date 2021/2/23 2:54 下午 + */ +@Service +public class DataSetTableService { + @Resource + private DatasetTableMapper datasetTableMapper; + + public void batchInsert(List datasetTable) { + for (DatasetTable table : datasetTable) { + save(table); + } + } + + public DatasetTable save(DatasetTable datasetTable) { + if (StringUtils.isEmpty(datasetTable.getId())) { + datasetTable.setId(UuidUtils.generateUuid()); + datasetTable.setCreateTime(System.currentTimeMillis()); + datasetTableMapper.insert(datasetTable); + } else { + datasetTableMapper.updateByPrimaryKey(datasetTable); + } + return datasetTable; + } + + public void delete(String id) { + datasetTableMapper.deleteByPrimaryKey(id); + } + + public List list(DataSetTableRequest dataSetTableRequest) { + DatasetTableExample datasetTableExample = new DatasetTableExample(); + datasetTableExample.createCriteria().andSceneIdEqualTo(dataSetTableRequest.getSceneId()); + if (StringUtils.isNotEmpty(dataSetTableRequest.getSort())) { + datasetTableExample.setOrderByClause(dataSetTableRequest.getSort()); + } + return datasetTableMapper.selectByExample(datasetTableExample); + } + + public DatasetTable get(String id) { + return datasetTableMapper.selectByPrimaryKey(id); + } +} diff --git a/backend/src/main/resources/db/migration/V9__dataset_tables.sql b/backend/src/main/resources/db/migration/V9__dataset_tables.sql new file mode 100644 index 0000000000..b5983e1b8d --- /dev/null +++ b/backend/src/main/resources/db/migration/V9__dataset_tables.sql @@ -0,0 +1,11 @@ +CREATE TABLE IF NOT EXISTS `dataset_table` ( + `id` varchar(50) NOT NULL COMMENT 'ID', + `name` varchar(64) NOT NULL COMMENT '表名称', + `scene_id` varchar(50) NOT NULL COMMENT '场景ID', + `data_source_id` varchar(50) NOT NULL COMMENT '数据源ID', + `type` varchar(50) COMMENT 'db,sql,excel,custom', + `create_by` varchar(50) COMMENT '创建人ID', + `create_time` bigint(13) COMMENT '创建时间', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + diff --git a/frontend/src/business/components/dataset/data/AddDB.vue b/frontend/src/business/components/dataset/data/AddDB.vue index cfeae2c7b4..a5e76bdcfc 100644 --- a/frontend/src/business/components/dataset/data/AddDB.vue +++ b/frontend/src/business/components/dataset/data/AddDB.vue @@ -81,9 +81,23 @@ export default { }, save() { - console.log(this.checkTableList); - console.log(this.scene); - this.$store.commit('setSceneData',new Date().getTime()); + // console.log(this.checkTableList); + // console.log(this.scene); + let sceneId = this.scene.id; + let dataSourceId = this.dataSource; + let tables = []; + this.checkTableList.forEach(function (name) { + tables.push({ + name: name, + sceneId: sceneId, + dataSourceId: dataSourceId, + type: 'db' + }) + }); + this.$post('/dataset/table/batchAdd', tables, response => { + this.$store.commit('setSceneData', new Date().getTime()); + this.cancel(); + }); }, cancel() { diff --git a/frontend/src/business/components/dataset/data/TabDataPreview.vue b/frontend/src/business/components/dataset/data/TabDataPreview.vue new file mode 100644 index 0000000000..480d362da0 --- /dev/null +++ b/frontend/src/business/components/dataset/data/TabDataPreview.vue @@ -0,0 +1,64 @@ + + + + + diff --git a/frontend/src/business/components/dataset/data/ViewTable.vue b/frontend/src/business/components/dataset/data/ViewTable.vue new file mode 100644 index 0000000000..051831bd82 --- /dev/null +++ b/frontend/src/business/components/dataset/data/ViewTable.vue @@ -0,0 +1,94 @@ + + + + + diff --git a/frontend/src/business/components/dataset/group/Group.vue b/frontend/src/business/components/dataset/group/Group.vue index c762db4e6c..f3c959b744 100644 --- a/frontend/src/business/components/dataset/group/Group.vue +++ b/frontend/src/business/components/dataset/group/Group.vue @@ -164,20 +164,15 @@ {{sceneData}} - - - - + + ({{data.type}}) {{ data.name }} @@ -192,13 +187,13 @@ - + {{$t('dataset.rename')}} - + {{$t('dataset.delete')}} @@ -207,6 +202,19 @@ + + + + + + + + + + @@ -220,7 +228,9 @@ export default { dialogTitle: '', search: '', editGroup: false, - data: null, + editTable: false, + data: [], + tableData: [], currGroup: null, expandedArray: [], groupForm: { @@ -231,25 +241,37 @@ export default { children: [], sort: 'type desc,name asc' }, + tableForm: { + name: '', + sort: 'type asc,create_time desc,name asc' + }, groupFormRules: { name: [ {required: true, message: this.$t('commons.input_content'), trigger: 'blur'}, ], + }, + tableFormRules: { + name: [ + {required: true, message: this.$t('commons.input_content'), trigger: 'blur'}, + ], } } }, computed: { sceneData: function () { console.log(this.$store.state.dataset.sceneData + ' do post'); + this.tableTree(); return this.$store.state.dataset.sceneData; } }, mounted() { this.tree(this.groupForm); + this.tableTree(); this.$router.push('/dataset'); }, activated() { this.tree(this.groupForm); + this.tableTree(); this.$router.push('/dataset'); }, watch: { @@ -275,11 +297,11 @@ export default { }, clickMore(param) { - // console.log(param); + console.log(param); switch (param.type) { case 'rename': this.add(param.data.type); - this.groupForm = param.data; + this.groupForm = JSON.parse(JSON.stringify(param.data)); break; case 'move': @@ -287,6 +309,13 @@ export default { case 'delete': this.delete(param.data); break; + case 'renameTable': + this.editTable = true; + this.tableForm = JSON.parse(JSON.stringify(param.data)); + break; + case 'deleteTable': + this.deleteTable(param.data); + break; } }, @@ -335,6 +364,32 @@ export default { }); }, + saveTable(table) { + console.log(table); + this.$refs['tableForm'].validate((valid) => { + if (valid) { + this.$post("/dataset/table/update", table, response => { + this.closeTable(); + this.$message({ + message: this.$t('commons.save_success'), + type: 'success', + showClose: true, + }); + this.tableTree(); + this.$router.push('/dataset/home'); + this.$store.commit('setTable', null); + }) + } else { + this.$message({ + message: this.$t('commons.input_content'), + type: 'error', + showClose: true, + }); + return false; + } + }); + }, + delete(data) { this.$confirm(this.$t('dataset.confirm_delete'), this.$t('dataset.tips'), { confirmButtonText: this.$t('dataset.confirm'), @@ -353,6 +408,26 @@ export default { }); }, + deleteTable(data) { + this.$confirm(this.$t('dataset.confirm_delete'), this.$t('dataset.tips'), { + confirmButtonText: this.$t('dataset.confirm'), + cancelButtonText: this.$t('dataset.cancel'), + type: 'warning' + }).then(() => { + this.$post("/dataset/table/delete/" + data.id, null, response => { + this.$message({ + type: 'success', + message: this.$t('dataset.delete_success'), + showClose: true, + }); + this.tableTree(); + this.$router.push('/dataset/home'); + this.$store.commit('setTable', null); + }); + }).catch(() => { + }); + }, + close() { this.editGroup = false; this.groupForm = { @@ -365,12 +440,31 @@ export default { } }, + closeTable() { + this.editTable = false; + this.tableForm = { + name: '', + } + }, + tree(group) { this.$post("/dataset/group/tree", group, response => { this.data = response.data; }) }, + tableTree() { + this.tableData = []; + if (this.currGroup) { + this.$post('/dataset/table/list', { + sort: 'type asc,create_time desc,name asc', + sceneId: this.currGroup.id + }, response => { + this.tableData = response.data; + }); + } + }, + nodeClick(data, node) { // console.log(data); // console.log(node); @@ -418,10 +512,6 @@ export default { } }, - sceneClick() { - - }, - addDB() { this.$router.push({ name: 'add_db', @@ -429,8 +519,20 @@ export default { scene: this.currGroup } }) - } - } + }, + + sceneClick(data, node) { + // console.log(data); + this.$store.commit('setTable', data.id); + this.$router.push({ + name: 'table', + params: { + table: data + } + }); + }, + + }, } diff --git a/frontend/src/business/components/dataset/router.js b/frontend/src/business/components/dataset/router.js index 96da9392e9..1556fcc4f6 100644 --- a/frontend/src/business/components/dataset/router.js +++ b/frontend/src/business/components/dataset/router.js @@ -1,6 +1,7 @@ const DataSet = () => import('@/business/components/dataset/DataSet'); const DataSetHome = () => import('@/business/components/dataset/data/DataHome'); const DataSetAddDB = () => import('@/business/components/dataset/data/AddDB'); +const DataSetTable = () => import('@/business/components/dataset/data/ViewTable'); // const PerformanceTestHome = () => import('@/business/components/performance/home/PerformanceTestHome') // const EditPerformanceTest = () => import('@/business/components/performance/test/EditPerformanceTest') // const PerformanceTestList = () => import('@/business/components/performance/test/PerformanceTestList') @@ -26,6 +27,11 @@ export default { name: 'add_db', component: DataSetAddDB, }, + { + path: 'table', + name: 'table', + component: DataSetTable, + }, // { // path: 'test/create', // name: "createPerTest", diff --git a/frontend/src/business/store.js b/frontend/src/business/store.js index c451521b63..1a5ea8c025 100644 --- a/frontend/src/business/store.js +++ b/frontend/src/business/store.js @@ -5,11 +5,15 @@ Vue.use(Vuex); const Dataset = { state: { - sceneData: "" + sceneData: "", + table: "" }, mutations: { setSceneData(state, sceneData) { state.sceneData = sceneData; + }, + setTable(state, table) { + state.table = table; } } } diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 61130f1c11..7e1a792b49 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -1545,6 +1545,10 @@ export default { custom_data: 'Custom Data', pls_slc_tbl_left:'Please select table from left', add_db_table:'Add Table', - pls_slc_data_source:'Select Data Source' + pls_slc_data_source:'Select Data Source', + table:'Table', + edit: 'Edit', + create_view: 'Create View', + data_preview:'Data Preview' } }; diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 20215ef730..2e2bfd0ced 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -1552,9 +1552,13 @@ export default { sql_data: 'SQL数据集', excel_data: 'Excel数据集', custom_data: '自助数据集', - pls_slc_tbl_left:'请从左侧选择表', - add_db_table:'添加数据库表', - pls_slc_data_source:'请选择数据库连接' + pls_slc_tbl_left: '请从左侧选择表', + add_db_table: '添加数据库表', + pls_slc_data_source: '请选择数据库连接', + table: '表', + edit: '编辑', + create_view: '创建试图', + data_preview:'数据预览' }, datasource: { create: '新建数据连接', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 7d52fdb170..e87f989da9 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -1546,6 +1546,10 @@ export default { custom_data: '自助數據集', pls_slc_tbl_left:'請從左側選擇表', add_db_table:'添加數據庫表', - pls_slc_data_source:'請選擇數據庫連接' + pls_slc_data_source:'請選擇數據庫連接', + table:'表', + edit: '編輯', + create_view: '創建試圖', + data_preview:'數據預覽' } };