Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
201cc6f4
提交
201cc6f4
authored
2月 25, 2021
作者:
junjie
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(数据集): 字段类型抽象转换
上级
b642ba1c
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
192 行增加
和
21 行删除
+192
-21
DatasetTableField.java
.../main/java/io/dataease/base/domain/DatasetTableField.java
+3
-0
DatasetTableFieldExample.java
...ava/io/dataease/base/domain/DatasetTableFieldExample.java
+60
-0
DatasetTableFieldMapper.xml
.../java/io/dataease/base/mapper/DatasetTableFieldMapper.xml
+22
-5
DataSetGroupService.java
...java/io/dataease/service/dataset/DataSetGroupService.java
+19
-0
DataSetTableService.java
...java/io/dataease/service/dataset/DataSetTableService.java
+46
-0
V9__dataset_tables.sql
...nd/src/main/resources/db/migration/V9__dataset_tables.sql
+4
-2
ViewTable.vue
frontend/src/business/components/dataset/data/ViewTable.vue
+17
-2
en-US.js
frontend/src/i18n/en-US.js
+4
-1
zh-CN.js
frontend/src/i18n/zh-CN.js
+13
-10
zh-TW.js
frontend/src/i18n/zh-TW.js
+4
-1
没有找到文件。
backend/src/main/java/io/dataease/base/domain/DatasetTableField.java
浏览文件 @
201cc6f4
...
...
@@ -21,5 +21,7 @@ public class DatasetTableField implements Serializable {
private
Long
lastSyncTime
;
private
Integer
deType
;
private
static
final
long
serialVersionUID
=
1L
;
}
\ No newline at end of file
backend/src/main/java/io/dataease/base/domain/DatasetTableFieldExample.java
浏览文件 @
201cc6f4
...
...
@@ -633,6 +633,66 @@ public class DatasetTableFieldExample {
addCriterion
(
"last_sync_time not between"
,
value1
,
value2
,
"lastSyncTime"
);
return
(
Criteria
)
this
;
}
public
Criteria
andDeTypeIsNull
()
{
addCriterion
(
"de_type is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andDeTypeIsNotNull
()
{
addCriterion
(
"de_type is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andDeTypeEqualTo
(
Integer
value
)
{
addCriterion
(
"de_type ="
,
value
,
"deType"
);
return
(
Criteria
)
this
;
}
public
Criteria
andDeTypeNotEqualTo
(
Integer
value
)
{
addCriterion
(
"de_type <>"
,
value
,
"deType"
);
return
(
Criteria
)
this
;
}
public
Criteria
andDeTypeGreaterThan
(
Integer
value
)
{
addCriterion
(
"de_type >"
,
value
,
"deType"
);
return
(
Criteria
)
this
;
}
public
Criteria
andDeTypeGreaterThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"de_type >="
,
value
,
"deType"
);
return
(
Criteria
)
this
;
}
public
Criteria
andDeTypeLessThan
(
Integer
value
)
{
addCriterion
(
"de_type <"
,
value
,
"deType"
);
return
(
Criteria
)
this
;
}
public
Criteria
andDeTypeLessThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"de_type <="
,
value
,
"deType"
);
return
(
Criteria
)
this
;
}
public
Criteria
andDeTypeIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"de_type in"
,
values
,
"deType"
);
return
(
Criteria
)
this
;
}
public
Criteria
andDeTypeNotIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"de_type not in"
,
values
,
"deType"
);
return
(
Criteria
)
this
;
}
public
Criteria
andDeTypeBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"de_type between"
,
value1
,
value2
,
"deType"
);
return
(
Criteria
)
this
;
}
public
Criteria
andDeTypeNotBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"de_type not between"
,
value1
,
value2
,
"deType"
);
return
(
Criteria
)
this
;
}
}
public
static
class
Criteria
extends
GeneratedCriteria
{
...
...
backend/src/main/java/io/dataease/base/mapper/DatasetTableFieldMapper.xml
浏览文件 @
201cc6f4
...
...
@@ -10,6 +10,7 @@
<result
column=
"checked"
jdbcType=
"BIT"
property=
"checked"
/>
<result
column=
"column_index"
jdbcType=
"INTEGER"
property=
"columnIndex"
/>
<result
column=
"last_sync_time"
jdbcType=
"BIGINT"
property=
"lastSyncTime"
/>
<result
column=
"de_type"
jdbcType=
"INTEGER"
property=
"deType"
/>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<where>
...
...
@@ -70,7 +71,8 @@
</where>
</sql>
<sql
id=
"Base_Column_List"
>
id, table_id, origin_name, `name`, `type`, `checked`, column_index, last_sync_time
id, table_id, origin_name, `name`, `type`, `checked`, column_index, last_sync_time,
de_type
</sql>
<select
id=
"selectByExample"
parameterType=
"io.dataease.base.domain.DatasetTableFieldExample"
resultMap=
"BaseResultMap"
>
select
...
...
@@ -105,10 +107,10 @@
<insert
id=
"insert"
parameterType=
"io.dataease.base.domain.DatasetTableField"
>
insert into dataset_table_field (id, table_id, origin_name,
`name`, `type`, `checked`, column_index,
last_sync_time)
last_sync_time
, de_type
)
values (#{id,jdbcType=VARCHAR}, #{tableId,jdbcType=VARCHAR}, #{originName,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{checked,jdbcType=BIT}, #{columnIndex,jdbcType=INTEGER},
#{lastSyncTime,jdbcType=BIGINT})
#{lastSyncTime,jdbcType=BIGINT}
, #{deType,jdbcType=INTEGER}
)
</insert>
<insert
id=
"insertSelective"
parameterType=
"io.dataease.base.domain.DatasetTableField"
>
insert into dataset_table_field
...
...
@@ -137,6 +139,9 @@
<if
test=
"lastSyncTime != null"
>
last_sync_time,
</if>
<if
test=
"deType != null"
>
de_type,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
...
...
@@ -163,6 +168,9 @@
<if
test=
"lastSyncTime != null"
>
#{lastSyncTime,jdbcType=BIGINT},
</if>
<if
test=
"deType != null"
>
#{deType,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select
id=
"countByExample"
parameterType=
"io.dataease.base.domain.DatasetTableFieldExample"
resultType=
"java.lang.Long"
>
...
...
@@ -198,6 +206,9 @@
<if
test=
"record.lastSyncTime != null"
>
last_sync_time = #{record.lastSyncTime,jdbcType=BIGINT},
</if>
<if
test=
"record.deType != null"
>
de_type = #{record.deType,jdbcType=INTEGER},
</if>
</set>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
...
...
@@ -212,7 +223,8 @@
`type` = #{record.type,jdbcType=VARCHAR},
`checked` = #{record.checked,jdbcType=BIT},
column_index = #{record.columnIndex,jdbcType=INTEGER},
last_sync_time = #{record.lastSyncTime,jdbcType=BIGINT}
last_sync_time = #{record.lastSyncTime,jdbcType=BIGINT},
de_type = #{record.deType,jdbcType=INTEGER}
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
...
...
@@ -241,6 +253,9 @@
<if
test=
"lastSyncTime != null"
>
last_sync_time = #{lastSyncTime,jdbcType=BIGINT},
</if>
<if
test=
"deType != null"
>
de_type = #{deType,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
...
...
@@ -252,7 +267,8 @@
`type` = #{type,jdbcType=VARCHAR},
`checked` = #{checked,jdbcType=BIT},
column_index = #{columnIndex,jdbcType=INTEGER},
last_sync_time = #{lastSyncTime,jdbcType=BIGINT}
last_sync_time = #{lastSyncTime,jdbcType=BIGINT},
de_type = #{deType,jdbcType=INTEGER}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
backend/src/main/java/io/dataease/service/dataset/DataSetGroupService.java
浏览文件 @
201cc6f4
...
...
@@ -2,9 +2,11 @@ package io.dataease.service.dataset;
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.commons.utils.BeanUtils
;
import
io.dataease.controller.request.dataset.DataSetGroupRequest
;
import
io.dataease.controller.request.dataset.DataSetTableRequest
;
import
io.dataease.dto.dataset.DataSetGroupDTO
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -24,6 +26,8 @@ import java.util.stream.Collectors;
public
class
DataSetGroupService
{
@Resource
private
DatasetGroupMapper
datasetGroupMapper
;
@Resource
private
DataSetTableService
dataSetTableService
;
public
DataSetGroupDTO
save
(
DatasetGroup
datasetGroup
)
{
if
(
StringUtils
.
isEmpty
(
datasetGroup
.
getId
()))
{
...
...
@@ -48,6 +52,21 @@ public class DataSetGroupService {
DatasetGroupExample
datasetGroupExample
=
new
DatasetGroupExample
();
datasetGroupExample
.
createCriteria
().
andIdIn
(
ids
);
datasetGroupMapper
.
deleteByExample
(
datasetGroupExample
);
// 获取type为scene的id,删除场景下的表和字段
deleteTableAndField
(
tree
.
stream
().
filter
(
ele
->
{
return
StringUtils
.
equalsIgnoreCase
(
ele
.
getType
(),
"scene"
);
}).
map
(
DatasetGroup:
:
getId
).
collect
(
Collectors
.
toList
()));
}
public
void
deleteTableAndField
(
List
<
String
>
sceneIds
)
{
for
(
String
sceneId
:
sceneIds
)
{
DataSetTableRequest
dataSetTableRequest
=
new
DataSetTableRequest
();
dataSetTableRequest
.
setSceneId
(
sceneId
);
List
<
DatasetTable
>
list
=
dataSetTableService
.
list
(
dataSetTableRequest
);
for
(
DatasetTable
table
:
list
)
{
dataSetTableService
.
delete
(
table
.
getId
());
}
}
}
public
List
<
DataSetGroupDTO
>
tree
(
DataSetGroupRequest
datasetGroup
)
{
...
...
backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java
浏览文件 @
201cc6f4
...
...
@@ -19,6 +19,7 @@ import io.dataease.dto.dataset.DataTableInfoDTO;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.text.MessageFormat
;
import
java.util.*
;
...
...
@@ -161,6 +162,7 @@ public class DataSetTableService {
}
public
void
saveTableField
(
DatasetTable
datasetTable
)
throws
Exception
{
Datasource
ds
=
datasourceMapper
.
selectByPrimaryKey
(
datasetTable
.
getDataSourceId
());
DataSetTableRequest
dataSetTableRequest
=
new
DataSetTableRequest
();
BeanUtils
.
copyBean
(
dataSetTableRequest
,
datasetTable
);
List
<
TableFiled
>
fields
=
getFields
(
dataSetTableRequest
);
...
...
@@ -173,6 +175,7 @@ public class DataSetTableService {
datasetTableField
.
setOriginName
(
filed
.
getFieldName
());
datasetTableField
.
setName
(
filed
.
getRemarks
());
datasetTableField
.
setType
(
filed
.
getFieldType
());
datasetTableField
.
setDeType
(
transFieldType
(
ds
.
getType
(),
filed
.
getFieldType
()));
datasetTableField
.
setChecked
(
true
);
datasetTableField
.
setColumnIndex
(
i
);
datasetTableField
.
setLastSyncTime
(
syncTime
);
...
...
@@ -192,4 +195,47 @@ public class DataSetTableService {
return
MessageFormat
.
format
(
"SELECT {0} FROM {1}"
,
StringUtils
.
join
(
fields
,
","
),
table
);
}
}
public
Integer
transFieldType
(
String
type
,
String
field
)
{
DatasourceTypes
datasourceType
=
DatasourceTypes
.
valueOf
(
type
);
switch
(
datasourceType
)
{
case
mysql:
return
transMysqlField
(
field
);
case
sqlServer:
default
:
return
0
;
}
}
public
Integer
transMysqlField
(
String
field
)
{
switch
(
field
)
{
case
"CHAR"
:
case
"VARCHAR"
:
case
"TEXT"
:
case
"TINYTEXT"
:
case
"MEDIUMTEXT"
:
case
"LONGTEXT"
:
case
"ENUM"
:
return
0
;
// 文本
case
"DATE"
:
case
"TIME"
:
case
"YEAR"
:
case
"DATETIME"
:
case
"TIMESTAMP"
:
return
1
;
// 时间
case
"INT"
:
case
"BIT"
:
case
"TINYINT"
:
case
"SMALLINT"
:
case
"MEDIUMINT"
:
case
"INTEGER"
:
case
"BIGINT"
:
case
"FLOAT"
:
case
"DOUBLE"
:
case
"DECIMAL"
:
return
2
;
// 数值
default
:
return
0
;
}
}
}
backend/src/main/resources/db/migration/V9__dataset_tables.sql
浏览文件 @
201cc6f4
...
...
@@ -18,12 +18,14 @@ CREATE TABLE IF NOT EXISTS `dataset_table_field`
`table_id`
varchar
(
50
)
NOT
NULL
COMMENT
'表ID'
,
`origin_name`
varchar
(
255
)
NOT
NULL
COMMENT
'原始名'
,
`name`
varchar
(
255
)
NOT
NULL
COMMENT
'字段名'
,
`type`
varchar
(
50
)
NOT
NULL
COMMENT
'字段类型'
,
`type`
varchar
(
50
)
NOT
NULL
COMMENT
'原始字段类型'
,
`de_type`
int
(
10
)
NOT
NULL
COMMENT
'dataease字段类型:0-文本,1-时间,2-数值...'
,
`checked`
tinyint
(
1
)
NOT
NULL
DEFAULT
true
COMMENT
'是否选中'
,
`column_index`
int
(
10
)
NOT
NULL
COMMENT
'列位置'
,
`last_sync_time`
bigint
(
13
)
COMMENT
'同步时间'
,
PRIMARY
KEY
(
`id`
),
KEY
`IDX_TABLE_ID`
(
`table_id`
)
KEY
`IDX_TABLE_ID`
(
`table_id`
),
KEY
`IDX_DE_TYPE`
(
`de_type`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
;
frontend/src/business/components/dataset/data/ViewTable.vue
浏览文件 @
201cc6f4
...
...
@@ -10,7 +10,7 @@
<el-button
size=
"mini"
@
click=
"edit"
>
{{
$t
(
'dataset.edit'
)
}}
</el-button>
<el-button
size=
"mini"
type=
"primary"
>
<el-button
size=
"mini"
type=
"primary"
@
click=
"createView"
>
{{
$t
(
'dataset.create_view'
)
}}
</el-button>
</el-row>
...
...
@@ -38,6 +38,11 @@
<el-dialog
:title=
"table.name"
:visible
.
sync=
"editField"
:fullscreen=
"true"
:show-close=
"false"
>
<el-table
:data=
"tableFields"
size=
"mini"
max-height=
"600px"
>
<el-table-column
property=
"type"
:label=
"$t('dataset.field_type')"
width=
"100"
>
<template
slot-scope=
"scope"
>
<span
v-if=
"scope.row.deType === 0"
>
{{
$t
(
'dataset.text'
)
}}
</span>
<span
v-if=
"scope.row.deType === 1"
>
{{
$t
(
'dataset.time'
)
}}
</span>
<span
v-if=
"scope.row.deType === 2"
>
{{
$t
(
'dataset.value'
)
}}
</span>
</
template
>
</el-table-column>
<el-table-column
property=
"name"
:label=
"$t('dataset.field_name')"
width=
"180"
>
<
template
slot-scope=
"scope"
>
...
...
@@ -60,18 +65,24 @@
<el-button
type=
"primary"
@
click=
"saveEdit"
size=
"mini"
>
{{$t('dataset.confirm')}}
</el-button>
</div>
</el-dialog>
<el-dialog
title=
"view"
:visible
.
sync=
"createViewDialog"
:fullscreen=
"true"
>
<chart-edit/>
</el-dialog>
</el-row>
</el-col>
</template>
<
script
>
import
TabDataPreview
from
"./TabDataPreview"
;
import
ChartEdit
from
"../../chart/View/ChartEdit"
;
export
default
{
name
:
"ViewTable"
,
components
:
{
TabDataPreview
},
components
:
{
ChartEdit
,
TabDataPreview
},
data
()
{
return
{
createViewDialog
:
false
,
editField
:
false
,
table
:
{
name
:
''
...
...
@@ -131,6 +142,10 @@ export default {
this
.
initTableFields
();
},
createView
()
{
this
.
createViewDialog
=
true
;
},
saveEdit
()
{
console
.
log
(
this
.
tableFields
);
this
.
$post
(
'/dataset/field/batchEdit'
,
this
.
tableFields
,
response
=>
{
...
...
frontend/src/i18n/en-US.js
浏览文件 @
201cc6f4
...
...
@@ -1565,6 +1565,9 @@ export default {
field_origin_name
:
'Origin Name'
,
field_check
:
'Checked'
,
update_info
:
'Update Info'
,
join_view
:
'Relation View'
join_view
:
'Relation View'
,
text
:
'Text'
,
time
:
'Time'
,
value
:
'Value'
}
};
frontend/src/i18n/zh-CN.js
浏览文件 @
201cc6f4
export
default
{
commons
:
{
upload
:
'上传'
,
upload
:
'上传'
,
cover
:
'覆盖'
,
not_cover
:
'不覆盖'
,
import_mode
:
'导入模式'
,
...
...
@@ -220,8 +220,8 @@ export default {
loginImage
:
'登陆页面右侧图片'
,
loginTitle
:
'登陆页面提示信息'
,
pageTitle
:
'页面 Title'
,
favicon
:
"Favicon(浏览器Tab页上的小图标)"
,
advice_size
:
"建议图片大小"
,
favicon
:
"Favicon(浏览器Tab页上的小图标)"
,
advice_size
:
"建议图片大小"
,
},
system_config
:
{
base_config
:
'基本配置'
,
...
...
@@ -229,12 +229,12 @@ export default {
url
:
'当前站点URL'
,
url_tip
:
'例如:http://localhost:8081'
,
logo
:
"系统LOGO(显示在系统主页左上角的LOGO)"
,
advice_size
:
"建议图片大小"
,
title
:
"Title(浏览器Tab页上的显示的文字)"
,
favicon
:
"Favicon(浏览器Tab页上的小图标)"
,
system_name
:
"系统名称(显示在系统主页左上角的系统名称)"
,
advice_size
:
"建议图片大小"
,
title
:
"Title(浏览器Tab页上的显示的文字)"
,
favicon
:
"Favicon(浏览器Tab页上的小图标)"
,
system_name
:
"系统名称(显示在系统主页左上角的系统名称)"
,
login_image
:
"登录页图片(登录页中显示的图片)"
,
login_name
:
"登录页显示的系统名称"
login_name
:
"登录页显示的系统名称"
}
},
workspace
:
{
...
...
@@ -1570,7 +1570,7 @@ export default {
table
:
'表'
,
edit
:
'编辑'
,
create_view
:
'创建试图'
,
data_preview
:
'数据预览'
data_preview
:
'数据预览'
},
dataset
:
{
datalist
:
'数据列表'
,
...
...
@@ -1607,7 +1607,10 @@ export default {
field_origin_name
:
'原始名'
,
field_check
:
'选中'
,
update_info
:
'更新信息'
,
join_view
:
'关联视图'
join_view
:
'关联视图'
,
text
:
'文本'
,
time
:
'时间'
,
value
:
'数值'
},
datasource
:
{
create
:
'新建数据连接'
,
...
...
frontend/src/i18n/zh-TW.js
浏览文件 @
201cc6f4
...
...
@@ -1566,6 +1566,9 @@ export default {
field_origin_name
:
'原始名'
,
field_check
:
'選中'
,
update_info
:
'更新信息'
,
join_view
:
'關聯視圖'
join_view
:
'關聯視圖'
,
text
:
'文本'
,
time
:
'時間'
,
value
:
'數值'
}
};
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论