Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
3c6d2fb9
提交
3c6d2fb9
authored
5月 27, 2022
作者:
wangjiahao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 使用Gson 替换fastjson
上级
3c594429
隐藏空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
237 行增加
和
216 行删除
+237
-216
XssAndSqlHttpServletRequestWrapper.java
...e/commons/wrapper/XssAndSqlHttpServletRequestWrapper.java
+1
-3
CommonConfig.java
backend/src/main/java/io/dataease/config/CommonConfig.java
+0
-2
ApiDefinition.java
...dataease/controller/request/datasource/ApiDefinition.java
+2
-2
ApiDefinitionRequest.java
...e/controller/request/datasource/ApiDefinitionRequest.java
+3
-3
DatasourceDTO.java
backend/src/main/java/io/dataease/dto/DatasourceDTO.java
+2
-2
ApiProvider.java
...ain/java/io/dataease/provider/datasource/ApiProvider.java
+73
-57
EsProvider.java
...main/java/io/dataease/provider/datasource/EsProvider.java
+5
-4
DataSetTableService.java
...java/io/dataease/service/dataset/DataSetTableService.java
+4
-4
ExtractDataService.java
.../java/io/dataease/service/dataset/ExtractDataService.java
+2
-5
PermissionService.java
...n/java/io/dataease/service/dataset/PermissionService.java
+4
-3
DatasourceService.java
...ava/io/dataease/service/datasource/DatasourceService.java
+71
-68
EngineService.java
...c/main/java/io/dataease/service/engine/EngineService.java
+37
-31
PanelGroupExtendDataService.java
...o/dataease/service/panel/PanelGroupExtendDataService.java
+3
-3
PanelGroupService.java
...ain/java/io/dataease/service/panel/PanelGroupService.java
+4
-4
PanelViewService.java
...main/java/io/dataease/service/panel/PanelViewService.java
+23
-23
StaticResourceService.java
...ataease/service/staticResource/StaticResourceService.java
+3
-2
没有找到文件。
backend/src/main/java/io/dataease/commons/wrapper/XssAndSqlHttpServletRequestWrapper.java
浏览文件 @
3c6d2fb9
...
...
@@ -13,7 +13,6 @@ import javax.servlet.ServletInputStream;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequestWrapper
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.Gson
;
import
io.dataease.commons.holder.ThreadLocalContextHolder
;
import
io.dataease.commons.utils.CommonBeanFactory
;
...
...
@@ -346,9 +345,8 @@ public class XssAndSqlHttpServletRequestWrapper extends HttpServletRequestWrappe
private
static
String
orders
(
String
json
)
{
if
(
StringUtils
.
isEmpty
(
json
))
return
null
;
try
{
Map
<
String
,
Object
>
map
=
JSONObject
.
parseObject
(
json
,
Map
.
class
);
Map
<
String
,
Object
>
map
=
new
Gson
().
fromJson
(
json
,
Map
.
class
);
Object
orders
=
map
.
get
(
"orders"
);
if
(
orders
!=
null
)
{
...
...
backend/src/main/java/io/dataease/config/CommonConfig.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
config
;
import
com.alibaba.fastjson.JSONObject
;
import
com.fit2cloud.autoconfigure.QuartzAutoConfiguration
;
import
io.dataease.plugins.common.base.domain.Datasource
;
import
io.dataease.commons.utils.CommonThreadPool
;
import
org.pentaho.di.core.KettleEnvironment
;
import
org.pentaho.di.repository.filerep.KettleFileRepository
;
...
...
backend/src/main/java/io/dataease/controller/request/datasource/ApiDefinition.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
controller
.
request
.
datasource
;
import
com.
alibaba.fastjson.JSON
Object
;
import
com.
google.gson.Json
Object
;
import
io.dataease.plugins.common.base.domain.DatasetTableField
;
import
lombok.Data
;
...
...
@@ -17,5 +17,5 @@ public class ApiDefinition {
private
String
request
;
private
String
dataPath
;
private
String
status
;
private
List
<
J
SON
Object
>
datas
=
new
ArrayList
<>();
private
List
<
J
son
Object
>
datas
=
new
ArrayList
<>();
}
backend/src/main/java/io/dataease/controller/request/datasource/ApiDefinitionRequest.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
controller
.
request
.
datasource
;
import
com.
alibaba.fastjson.JSON
Object
;
import
com.
google.gson.Json
Object
;
import
lombok.Data
;
import
java.util.ArrayList
;
import
java.util.List
;
@Data
public
class
ApiDefinitionRequest
{
private
List
<
J
SON
Object
>
headers
=
new
ArrayList
<>();
private
J
SONObject
body
=
new
JSON
Object
();
private
List
<
J
son
Object
>
headers
=
new
ArrayList
<>();
private
J
sonObject
body
=
new
Json
Object
();
private
AuthManager
authManager
=
new
AuthManager
();
...
...
backend/src/main/java/io/dataease/dto/DatasourceDTO.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
dto
;
import
com.
alibaba.fastjson.JSON
Array
;
import
com.
google.gson.Json
Array
;
import
io.dataease.plugins.common.base.domain.Datasource
;
import
io.dataease.plugins.common.constants.DatasourceCalculationMode
;
import
io.swagger.annotations.ApiModelProperty
;
...
...
@@ -16,7 +16,7 @@ public class DatasourceDTO extends Datasource {
@ApiModelProperty
(
"权限"
)
private
String
privileges
;
private
J
SON
Array
apiConfiguration
;
private
J
son
Array
apiConfiguration
;
private
String
typeDesc
;
private
DatasourceCalculationMode
calculationMode
;
}
backend/src/main/java/io/dataease/provider/datasource/ApiProvider.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
provider
.
datasource
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
com.google.gson.reflect.TypeToken
;
import
io.dataease.plugins.common.dto.datasource.TableDesc
;
import
io.dataease.plugins.common.dto.datasource.TableField
;
import
io.dataease.plugins.common.request.datasource.DatasourceRequest
;
...
...
@@ -23,7 +25,7 @@ import java.util.*;
import
java.util.stream.Collectors
;
@Service
(
"apiProvider"
)
public
class
ApiProvider
extends
Provider
{
public
class
ApiProvider
extends
Provider
{
@Override
...
...
@@ -36,7 +38,8 @@ public class ApiProvider extends Provider{
@Override
public
List
<
TableDesc
>
getTables
(
DatasourceRequest
datasourceRequest
)
throws
Exception
{
List
<
TableDesc
>
tableDescs
=
new
ArrayList
<>();
List
<
ApiDefinition
>
lists
=
JSONObject
.
parseArray
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
ApiDefinition
.
class
);
List
<
ApiDefinition
>
lists
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
new
TypeToken
<
List
<
ApiDefinition
>>()
{
}.
getType
());
for
(
ApiDefinition
apiDefinition
:
lists
)
{
TableDesc
tableDesc
=
new
TableDesc
();
tableDesc
.
setName
(
apiDefinition
.
getName
());
...
...
@@ -54,7 +57,7 @@ public class ApiProvider extends Provider{
public
Map
<
String
,
List
>
fetchResultAndField
(
DatasourceRequest
datasourceRequest
)
throws
Exception
{
Map
<
String
,
List
>
result
=
new
HashMap
<>();
List
<
String
[]>
dataList
=
new
ArrayList
<>();
List
<
TableField
>
fieldList
=
new
ArrayList
<>();
;
List
<
TableField
>
fieldList
=
new
ArrayList
<>();
ApiDefinition
apiDefinition
=
checkApiDefinition
(
datasourceRequest
);
String
response
=
execHttpRequest
(
apiDefinition
);
...
...
@@ -80,10 +83,11 @@ public class ApiProvider extends Provider{
}
public
List
<
TableField
>
getTableFileds
(
DatasourceRequest
datasourceRequest
)
throws
Exception
{
List
<
ApiDefinition
>
lists
=
JSONObject
.
parseArray
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
ApiDefinition
.
class
);
List
<
ApiDefinition
>
lists
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
new
TypeToken
<
List
<
ApiDefinition
>>()
{
}.
getType
());
List
<
TableField
>
tableFields
=
new
ArrayList
<>();
for
(
ApiDefinition
apiDefinition
:
lists
)
{
if
(
datasourceRequest
.
getTable
().
equalsIgnoreCase
(
apiDefinition
.
getName
()))
{
if
(
datasourceRequest
.
getTable
().
equalsIgnoreCase
(
apiDefinition
.
getName
()))
{
String
response
=
ApiProvider
.
execHttpRequest
(
apiDefinition
);
for
(
DatasetTableField
field
:
checkApiDefinition
(
apiDefinition
,
response
).
getFields
())
{
TableField
tableField
=
new
TableField
();
...
...
@@ -99,64 +103,66 @@ public class ApiProvider extends Provider{
}
public
String
checkStatus
(
DatasourceRequest
datasourceRequest
)
throws
Exception
{
List
<
ApiDefinition
>
apiDefinitionList
=
JSONObject
.
parseArray
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
ApiDefinition
.
class
);
JSONObject
apiItemStatuses
=
new
JSONObject
();
Gson
gson
=
new
Gson
();
List
<
ApiDefinition
>
apiDefinitionList
=
gson
.
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
new
TypeToken
<
List
<
ApiDefinition
>>()
{
}.
getType
());
JsonObject
apiItemStatuses
=
new
JsonObject
();
for
(
ApiDefinition
apiDefinition
:
apiDefinitionList
)
{
datasourceRequest
.
setTable
(
apiDefinition
.
getName
());
try
{
getData
(
datasourceRequest
);
apiItemStatuses
.
put
(
apiDefinition
.
getName
(),
"Success"
);
}
catch
(
Exception
ignore
)
{
apiItemStatuses
.
put
(
apiDefinition
.
getName
(),
"Error"
);
}
try
{
getData
(
datasourceRequest
);
apiItemStatuses
.
addProperty
(
apiDefinition
.
getName
(),
"Success"
);
}
catch
(
Exception
ignore
)
{
apiItemStatuses
.
addProperty
(
apiDefinition
.
getName
(),
"Error"
);
}
}
return
JSONObject
.
toJSONString
(
apiItemStatuses
);
return
gson
.
toJson
(
apiItemStatuses
);
}
static
public
String
execHttpRequest
(
ApiDefinition
apiDefinition
)
throws
Exception
{
static
public
String
execHttpRequest
(
ApiDefinition
apiDefinition
)
throws
Exception
{
String
response
=
""
;
HttpClientConfig
httpClientConfig
=
new
HttpClientConfig
();
ApiDefinitionRequest
apiDefinitionRequest
=
JSONObject
.
parseObject
(
apiDefinition
.
getRequest
(),
ApiDefinitionRequest
.
class
);
ApiDefinitionRequest
apiDefinitionRequest
=
new
Gson
().
fromJson
(
apiDefinition
.
getRequest
(),
ApiDefinitionRequest
.
class
);
//headers
for
(
J
SON
Object
header
:
apiDefinitionRequest
.
getHeaders
())
{
if
(
StringUtils
.
isNotEmpty
(
header
.
getString
(
"name"
))
&&
StringUtils
.
isNotEmpty
(
header
.
getString
(
"value"
)))
{
httpClientConfig
.
addHeader
(
header
.
get
String
(
"name"
),
header
.
getString
(
"value"
));
for
(
J
son
Object
header
:
apiDefinitionRequest
.
getHeaders
())
{
if
(
header
.
get
(
"name"
)
!=
null
&&
StringUtils
.
isNotEmpty
(
header
.
get
(
"name"
).
getAsString
())
&&
header
.
get
(
"value"
)
!=
null
&&
StringUtils
.
isNotEmpty
(
header
.
get
(
"value"
).
getAsString
()))
{
httpClientConfig
.
addHeader
(
header
.
get
(
"name"
).
getAsString
(),
header
.
get
(
"value"
).
getAsString
(
));
}
}
if
(
apiDefinitionRequest
.
getAuthManager
()
!=
null
if
(
apiDefinitionRequest
.
getAuthManager
()
!=
null
&&
StringUtils
.
isNotBlank
(
apiDefinitionRequest
.
getAuthManager
().
getUsername
())
&&
StringUtils
.
isNotBlank
(
apiDefinitionRequest
.
getAuthManager
().
getPassword
())
&&
apiDefinitionRequest
.
getAuthManager
().
getVerification
().
equals
(
"Basic Auth"
)){
&&
apiDefinitionRequest
.
getAuthManager
().
getVerification
().
equals
(
"Basic Auth"
))
{
String
authValue
=
"Basic "
+
Base64
.
getUrlEncoder
().
encodeToString
((
apiDefinitionRequest
.
getAuthManager
().
getUsername
()
+
":"
+
apiDefinitionRequest
.
getAuthManager
().
getPassword
()).
getBytes
());
httpClientConfig
.
addHeader
(
"Authorization"
,
authValue
);
}
switch
(
apiDefinition
.
getMethod
()){
switch
(
apiDefinition
.
getMethod
())
{
case
"GET"
:
response
=
HttpClientUtil
.
get
(
apiDefinition
.
getUrl
(),
httpClientConfig
);
break
;
case
"POST"
:
if
(
!
apiDefinitionRequest
.
getBody
().
containsKey
(
"type"
)
)
{
throw
new
Exception
(
"请求类型不能为空"
);
if
(
apiDefinitionRequest
.
getBody
().
get
(
"type"
)
==
null
)
{
throw
new
Exception
(
"请求类型不能为空"
);
}
String
type
=
apiDefinitionRequest
.
getBody
().
get
String
(
"type"
);
String
type
=
apiDefinitionRequest
.
getBody
().
get
(
"type"
).
getAsString
(
);
if
(
StringUtils
.
equalsAny
(
type
,
"JSON"
,
"XML"
,
"Raw"
))
{
String
raw
=
null
;
if
(
apiDefinitionRequest
.
getBody
().
containsKey
(
"raw"
)
)
{
raw
=
apiDefinitionRequest
.
getBody
().
get
String
(
"raw"
);
if
(
apiDefinitionRequest
.
getBody
().
get
(
"raw"
)
!=
null
)
{
raw
=
apiDefinitionRequest
.
getBody
().
get
(
"raw"
).
getAsString
(
);
response
=
HttpClientUtil
.
post
(
apiDefinition
.
getUrl
(),
raw
,
httpClientConfig
);
}
}
if
(
StringUtils
.
equalsAny
(
type
,
"Form_Data"
,
"WWW_FORM"
))
{
if
(
apiDefinitionRequest
.
getBody
().
containsKey
(
"kvs"
)
)
{
if
(
apiDefinitionRequest
.
getBody
().
get
(
"kvs"
)
!=
null
)
{
Map
<
String
,
String
>
body
=
new
HashMap
<>();
J
SONArray
kvsArr
=
apiDefinitionRequest
.
getBody
().
getJSON
Array
(
"kvs"
);
J
sonArray
kvsArr
=
apiDefinitionRequest
.
getBody
().
getAsJson
Array
(
"kvs"
);
for
(
int
i
=
0
;
i
<
kvsArr
.
size
();
i
++)
{
J
SONObject
kv
=
kvsArr
.
getJSONObject
(
i
);
if
(
kv
.
containsKey
(
"name"
)
)
{
body
.
put
(
kv
.
get
String
(
"name"
),
kv
.
getString
(
"value"
));
J
sonObject
kv
=
kvsArr
.
get
(
i
).
getAsJsonObject
(
);
if
(
kv
.
get
(
"name"
)
!=
null
)
{
body
.
put
(
kv
.
get
(
"name"
).
getAsString
(),
kv
.
get
(
"value"
).
getAsString
(
));
}
}
response
=
HttpClientUtil
.
post
(
apiDefinition
.
getUrl
(),
body
,
httpClientConfig
);
...
...
@@ -169,30 +175,30 @@ public class ApiProvider extends Provider{
return
response
;
}
static
public
ApiDefinition
checkApiDefinition
(
ApiDefinition
apiDefinition
,
String
response
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
response
))
{
static
public
ApiDefinition
checkApiDefinition
(
ApiDefinition
apiDefinition
,
String
response
)
throws
Exception
{
if
(
StringUtils
.
isEmpty
(
response
))
{
throw
new
Exception
(
"该请求返回数据为空"
);
}
List
<
LinkedHashMap
>
datas
=
new
ArrayList
<>();
try
{
Object
object
=
JsonPath
.
read
(
response
,
apiDefinition
.
getDataPath
());
if
(
object
instanceof
List
)
{
datas
=
(
List
<
LinkedHashMap
>)
object
;
}
else
{
datas
.
add
((
LinkedHashMap
)
object
);
Object
object
=
JsonPath
.
read
(
response
,
apiDefinition
.
getDataPath
());
if
(
object
instanceof
List
)
{
datas
=
(
List
<
LinkedHashMap
>)
object
;
}
else
{
datas
.
add
((
LinkedHashMap
)
object
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
Exception
(
"jsonPath 路径错误:"
+
e
.
getMessage
());
}
List
<
J
SON
Object
>
dataList
=
new
ArrayList
<>();
List
<
J
son
Object
>
dataList
=
new
ArrayList
<>();
List
<
DatasetTableField
>
fields
=
new
ArrayList
<>();
Set
<
String
>
fieldKeys
=
new
HashSet
<>();
//第一遍获取 field
for
(
LinkedHashMap
data
:
datas
)
{
Set
<
String
>
keys
=
data
.
keySet
();
for
(
String
key
:
keys
)
{
if
(!
fieldKeys
.
contains
(
key
))
{
if
(!
fieldKeys
.
contains
(
key
))
{
fieldKeys
.
add
(
key
);
DatasetTableField
tableField
=
new
DatasetTableField
();
tableField
.
setOriginName
(
key
);
...
...
@@ -207,9 +213,9 @@ public class ApiProvider extends Provider{
}
//第二遍获取 data
for
(
LinkedHashMap
data
:
datas
)
{
J
SONObject
jsonObject
=
new
JSON
Object
();
J
sonObject
jsonObject
=
new
Json
Object
();
for
(
String
key
:
fieldKeys
)
{
jsonObject
.
put
(
key
,
Optional
.
ofNullable
(
data
.
get
(
key
)).
orElse
(
""
).
toString
().
replaceAll
(
"\n"
,
" "
).
replaceAll
(
"\r"
,
" "
));
jsonObject
.
addProperty
(
key
,
Optional
.
ofNullable
(
data
.
get
(
key
)).
orElse
(
""
).
toString
().
replaceAll
(
"\n"
,
" "
).
replaceAll
(
"\r"
,
" "
));
}
dataList
.
add
(
jsonObject
);
}
...
...
@@ -218,15 +224,15 @@ public class ApiProvider extends Provider{
return
apiDefinition
;
}
private
List
<
String
[]>
fetchResult
(
String
result
,
ApiDefinition
apiDefinition
){
private
List
<
String
[]>
fetchResult
(
String
result
,
ApiDefinition
apiDefinition
)
{
List
<
String
[]>
dataList
=
new
LinkedList
<>();
List
<
LinkedHashMap
>
datas
=
new
ArrayList
<>();
Object
object
=
JsonPath
.
read
(
result
,
apiDefinition
.
getDataPath
());
if
(
object
instanceof
List
)
{
datas
=
(
List
<
LinkedHashMap
>)
object
;
}
else
{
datas
.
add
((
LinkedHashMap
)
object
);
Object
object
=
JsonPath
.
read
(
result
,
apiDefinition
.
getDataPath
());
if
(
object
instanceof
List
)
{
datas
=
(
List
<
LinkedHashMap
>)
object
;
}
else
{
datas
.
add
((
LinkedHashMap
)
object
);
}
for
(
LinkedHashMap
data
:
datas
)
{
String
[]
row
=
new
String
[
apiDefinition
.
getFields
().
size
()];
...
...
@@ -240,16 +246,26 @@ public class ApiProvider extends Provider{
return
dataList
;
}
private
ApiDefinition
checkApiDefinition
(
DatasourceRequest
datasourceRequest
)
throws
Exception
{
List
<
ApiDefinition
>
apiDefinitionList
=
JSONObject
.
parseArray
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
ApiDefinition
.
class
).
stream
().
filter
(
item
->
item
.
getName
().
equalsIgnoreCase
(
datasourceRequest
.
getTable
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
apiDefinitionList
)){
private
ApiDefinition
checkApiDefinition
(
DatasourceRequest
datasourceRequest
)
throws
Exception
{
List
<
ApiDefinition
>
apiDefinitionList
=
new
ArrayList
<>();
List
<
ApiDefinition
>
apiDefinitionListTemp
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
new
TypeToken
<
List
<
ApiDefinition
>>()
{
}.
getType
());
if
(
CollectionUtils
.
isEmpty
(
apiDefinitionListTemp
))
{
for
(
ApiDefinition
apiDefinition
:
apiDefinitionListTemp
)
{
if
(
apiDefinition
.
getName
().
equalsIgnoreCase
(
datasourceRequest
.
getTable
()))
{
apiDefinitionList
.
add
(
apiDefinition
);
}
}
}
if
(
CollectionUtils
.
isEmpty
(
apiDefinitionList
))
{
throw
new
Exception
(
"未找到API数据表"
);
}
if
(
apiDefinitionList
.
size
()
>
1
)
{
if
(
apiDefinitionList
.
size
()
>
1
)
{
throw
new
Exception
(
"存在重名的API数据表"
);
}
for
(
ApiDefinition
apiDefinition
:
apiDefinitionList
)
{
if
(
apiDefinition
.
getName
().
equalsIgnoreCase
(
datasourceRequest
.
getTable
())){
if
(
apiDefinition
.
getName
().
equalsIgnoreCase
(
datasourceRequest
.
getTable
()))
{
return
apiDefinition
;
}
}
...
...
backend/src/main/java/io/dataease/provider/datasource/EsProvider.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
provider
.
datasource
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonParser
;
import
io.dataease.commons.utils.HttpClientConfig
;
import
io.dataease.commons.utils.HttpClientUtil
;
import
io.dataease.controller.request.datasource.es.EsReponse
;
...
...
@@ -254,13 +254,14 @@ public class EsProvider extends Provider {
@Override
public
String
checkStatus
(
DatasourceRequest
datasourceRequest
)
throws
Exception
{
Gson
gson
=
new
Gson
();
EsConfiguration
esConfiguration
=
new
Gson
().
fromJson
(
datasourceRequest
.
getDatasource
().
getConfiguration
(),
EsConfiguration
.
class
);
String
response
=
exexGetQuery
(
datasourceRequest
);
if
(
J
SONObject
.
parseObject
(
response
).
getJSON
Object
(
"error"
)
!=
null
)
{
throw
new
Exception
(
J
SONObject
.
parseObject
(
response
).
getJSONObject
(
"error"
).
getString
(
"reason"
));
if
(
J
sonParser
.
parseString
(
response
).
getAsJsonObject
().
getAsJson
Object
(
"error"
)
!=
null
)
{
throw
new
Exception
(
J
sonParser
.
parseString
(
response
).
getAsJsonObject
().
getAsJsonObject
(
"error"
).
get
(
"reason"
).
getAsString
(
));
}
String
version
=
J
SONObject
.
parseObject
(
response
).
getJSONObject
(
"version"
).
getString
(
"number"
);
String
version
=
J
sonParser
.
parseString
(
response
).
getAsJsonObject
().
getAsJsonObject
(
"version"
).
get
(
"number"
).
getAsString
(
);
String
[]
versionList
=
version
.
split
(
"\\."
);
if
(
Integer
.
valueOf
(
versionList
[
0
])
<
7
&&
Integer
.
valueOf
(
versionList
[
1
])
<
3
)
{
throw
new
Exception
(
Translator
.
get
(
"i18n_es_limit"
));
...
...
backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
service
.
dataset
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
io.dataease.auth.annotation.DeCleaner
;
import
io.dataease.auth.api.dto.CurrentUserDto
;
import
io.dataease.dto.SysLogDTO
;
...
...
@@ -1341,8 +1341,8 @@ public class DataSetTableService {
String
keyword
=
datasourceTypes
.
getKeywordPrefix
()
+
"%s"
+
datasourceTypes
.
getKeywordSuffix
();
String
configuration
=
ds
.
getConfiguration
();
J
SONObject
jsonObject
=
JSON
.
parseObject
(
configuration
);
String
schema
=
jsonObject
.
get
String
(
"schema"
);
J
sonObject
jsonObject
=
JsonParser
.
parseString
(
configuration
).
getAsJsonObject
(
);
String
schema
=
jsonObject
.
get
(
"schema"
).
getAsString
(
);
String
joinPrefix
=
""
;
if
(
StringUtils
.
isNotEmpty
(
schema
)
&&
(
StringUtils
.
equalsIgnoreCase
(
ds
.
getType
(),
DatasourceTypes
.
db2
.
getType
())
||
StringUtils
.
equalsIgnoreCase
(
ds
.
getType
(),
DatasourceTypes
.
sqlServer
.
getType
())
||
...
...
backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
service
.
dataset
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
io.dataease.ext.ExtChartViewMapper
;
import
io.dataease.commons.constants.*
;
import
io.dataease.commons.model.AuthURD
;
import
io.dataease.commons.utils.*
;
import
io.dataease.controller.request.datasource.ApiDefinition
;
import
io.dataease.plugins.common.base.domain.*
;
import
io.dataease.plugins.common.base.mapper.DatasetTableMapper
;
import
io.dataease.plugins.common.base.mapper.DatasetTableTaskMapper
;
import
io.dataease.plugins.common.base.mapper.DatasourceMapper
;
import
io.dataease.plugins.common.constants.DatasourceTypes
;
import
io.dataease.plugins.common.constants.DeTypeConstants
;
import
io.dataease.plugins.common.dto.datasource.TableField
;
...
...
@@ -435,7 +432,7 @@ public class ExtractDataService {
}
private
void
extractApiData
(
DatasetTable
datasetTable
,
Datasource
datasource
,
List
<
DatasetTableField
>
datasetTableFields
,
String
extractType
)
throws
Exception
{
List
<
ApiDefinition
>
lists
=
JSONObject
.
parseArray
(
datasource
.
getConfiguration
(),
ApiDefinition
.
class
);
List
<
ApiDefinition
>
lists
=
new
Gson
().
fromJson
(
datasource
.
getConfiguration
(),
new
TypeToken
<
ArrayList
<
ApiDefinition
>>(){}.
getType
()
);
lists
=
lists
.
stream
().
filter
(
item
->
item
.
getName
().
equalsIgnoreCase
(
new
Gson
().
fromJson
(
datasetTable
.
getInfo
(),
DataTableInfoDTO
.
class
).
getTable
())).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
lists
))
{
throw
new
Exception
(
"未找到API数据表"
);
...
...
backend/src/main/java/io/dataease/service/dataset/PermissionService.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
service
.
dataset
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
io.dataease.auth.api.dto.CurrentRoleDto
;
import
io.dataease.auth.entity.SysUserEntity
;
import
io.dataease.auth.service.AuthUserService
;
...
...
@@ -46,7 +47,7 @@ public class PermissionService {
if
(
StringUtils
.
isEmpty
(
datasetRowPermissions
.
getFilter
()))
{
continue
;
}
List
<
ChartCustomFilterItemDTO
>
lists
=
JSONObject
.
parseArray
(
datasetRowPermissions
.
getFilter
(),
ChartCustomFilterItemDTO
.
class
);
List
<
ChartCustomFilterItemDTO
>
lists
=
new
Gson
().
fromJson
(
datasetRowPermissions
.
getFilter
(),
new
TypeToken
<
ArrayList
<
ChartCustomFilterItemDTO
>>(){}.
getType
()
);
lists
.
forEach
(
chartCustomFilterDTO
->
{
chartCustomFilterDTO
.
setFieldId
(
field
.
getId
());
if
(
datasetRowPermissions
.
getAuthTargetType
().
equalsIgnoreCase
(
"sysParams"
)){
...
...
@@ -77,7 +78,7 @@ public class PermissionService {
List
<
DatasetTableField
>
result
=
new
ArrayList
<>();
List
<
ColumnPermissionItem
>
allColumnPermissionItems
=
new
ArrayList
<>();
for
(
DataSetColumnPermissionsDTO
dataSetColumnPermissionsDTO
:
columnPermissions
(
datasetTableId
,
user
))
{
ColumnPermissions
columnPermissions
=
JSONObject
.
parseObject
(
dataSetColumnPermissionsDTO
.
getPermissions
(),
ColumnPermissions
.
class
);
ColumnPermissions
columnPermissions
=
new
Gson
().
fromJson
(
dataSetColumnPermissionsDTO
.
getPermissions
(),
ColumnPermissions
.
class
);
if
(!
columnPermissions
.
getEnable
()){
continue
;}
allColumnPermissionItems
.
addAll
(
columnPermissions
.
getColumns
().
stream
().
filter
(
columnPermissionItem
->
columnPermissionItem
.
getSelected
()).
collect
(
Collectors
.
toList
()));
}
...
...
backend/src/main/java/io/dataease/service/datasource/DatasourceService.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
service
.
datasource
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
com.google.gson.reflect.TypeToken
;
import
io.dataease.auth.annotation.DeCleaner
;
import
io.dataease.commons.constants.RedisConstants
;
import
io.dataease.ext.ExtDataSourceMapper
;
...
...
@@ -71,8 +73,8 @@ public class DatasourceService {
@Resource
private
Environment
env
;
public
Collection
<
DataSourceType
>
types
()
{
Collection
<
DataSourceType
>
types
=
new
ArrayList
<>();
public
Collection
<
DataSourceType
>
types
()
{
Collection
<
DataSourceType
>
types
=
new
ArrayList
<>();
types
.
addAll
(
SpringContextUtil
.
getApplicationContext
().
getBeansOfType
(
DataSourceType
.
class
).
values
());
SpringContextUtil
.
getApplicationContext
().
getBeansOfType
(
io
.
dataease
.
plugins
.
datasource
.
service
.
DatasourceService
.
class
).
values
().
forEach
(
datasourceService
->
{
types
.
add
(
datasourceService
.
getDataSourceType
());
...
...
@@ -81,11 +83,11 @@ public class DatasourceService {
}
@DeCleaner
(
DePermissionType
.
DATASOURCE
)
public
Datasource
addDatasource
(
Datasource
datasource
)
throws
Exception
{
if
(!
types
().
stream
().
map
(
DataSourceType:
:
getType
).
collect
(
Collectors
.
toList
()).
contains
(
datasource
.
getType
()))
{
public
Datasource
addDatasource
(
Datasource
datasource
)
throws
Exception
{
if
(!
types
().
stream
().
map
(
DataSourceType:
:
getType
).
collect
(
Collectors
.
toList
()).
contains
(
datasource
.
getType
()))
{
throw
new
Exception
(
"Datasource type not supported."
);
}
checkName
(
datasource
.
getName
(),
datasource
.
getType
(),
datasource
.
getId
());
checkName
(
datasource
.
getName
(),
datasource
.
getType
(),
datasource
.
getId
());
long
currentTimeMillis
=
System
.
currentTimeMillis
();
datasource
.
setId
(
UUID
.
randomUUID
().
toString
());
datasource
.
setUpdateTime
(
currentTimeMillis
);
...
...
@@ -101,7 +103,7 @@ public class DatasourceService {
public
void
handleConnectionPool
(
String
datasourceId
,
String
type
)
{
Datasource
datasource
=
datasourceMapper
.
selectByPrimaryKey
(
datasourceId
);
if
(
datasource
==
null
)
{
if
(
datasource
==
null
)
{
return
;
}
handleConnectionPool
(
datasource
,
type
);
...
...
@@ -126,44 +128,44 @@ public class DatasourceService {
List
<
DatasourceDTO
>
datasourceDTOS
=
extDataSourceMapper
.
queryUnion
(
request
);
datasourceDTOS
.
forEach
(
datasourceDTO
->
{
types
().
forEach
(
dataSourceType
->
{
if
(
dataSourceType
.
getType
().
equalsIgnoreCase
(
datasourceDTO
.
getType
()))
{
if
(
dataSourceType
.
getType
().
equalsIgnoreCase
(
datasourceDTO
.
getType
()))
{
datasourceDTO
.
setTypeDesc
(
dataSourceType
.
getName
());
datasourceDTO
.
setCalculationMode
(
dataSourceType
.
getCalculationMode
());
}
});
if
(!
datasourceDTO
.
getType
().
equalsIgnoreCase
(
DatasourceTypes
.
api
.
toString
()))
{
if
(!
datasourceDTO
.
getType
().
equalsIgnoreCase
(
DatasourceTypes
.
api
.
toString
()))
{
JdbcConfiguration
configuration
=
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
JdbcConfiguration
.
class
);
if
(
StringUtils
.
isNotEmpty
(
configuration
.
getCustomDriver
())
&&
!
configuration
.
getCustomDriver
().
equalsIgnoreCase
(
"default"
))
{
if
(
StringUtils
.
isNotEmpty
(
configuration
.
getCustomDriver
())
&&
!
configuration
.
getCustomDriver
().
equalsIgnoreCase
(
"default"
))
{
datasourceDTO
.
setCalculationMode
(
DatasourceCalculationMode
.
DIRECT
);
}
}
if
(
datasourceDTO
.
getType
().
equalsIgnoreCase
(
DatasourceTypes
.
mysql
.
toString
())){
datasourceDTO
.
setConfiguration
(
JSONObject
.
toJSONString
(
new
Gson
().
fromJson
(
datasourceDTO
.
getConfiguration
(),
MysqlConfiguration
.
class
))
);
datasourceDTO
.
setConfiguration
(
datasourceDTO
.
getConfiguration
()
);
}
if
(
datasourceDTO
.
getType
().
equalsIgnoreCase
(
DatasourceTypes
.
api
.
toString
()))
{
J
SONArray
apiDefinitionList
=
JSONObject
.
parseArray
(
datasourceDTO
.
getConfiguration
()
);
J
SONArray
apiDefinitionListWithStatus
=
new
JSON
Array
();
if
(
datasourceDTO
.
getType
().
equalsIgnoreCase
(
DatasourceTypes
.
api
.
toString
()))
{
J
sonArray
apiDefinitionList
=
JsonParser
.
parseString
(
datasourceDTO
.
getConfiguration
()).
getAsJsonArray
(
);
J
sonArray
apiDefinitionListWithStatus
=
new
Json
Array
();
int
success
=
0
;
if
(
StringUtils
.
isNotEmpty
(
datasourceDTO
.
getStatus
()))
{
J
SONObject
apiItemStatuses
=
JSONObject
.
parseObject
(
datasourceDTO
.
getStatus
()
);
if
(
StringUtils
.
isNotEmpty
(
datasourceDTO
.
getStatus
()))
{
J
sonObject
apiItemStatuses
=
JsonParser
.
parseString
(
datasourceDTO
.
getStatus
()).
getAsJsonObject
(
);
for
(
Object
apiDefinition
:
apiDefinitionList
)
{
String
status
=
apiItemStatuses
.
get
String
(
JSONObject
.
parseObject
(
apiDefinition
.
toString
()).
getString
(
"name"
)
);
J
SONObject
object
=
JSONObject
.
parseObject
(
apiDefinition
.
toString
()
);
object
.
put
(
"status"
,
status
);
String
status
=
apiItemStatuses
.
get
(
JsonParser
.
parseString
(
apiDefinition
.
toString
()).
getAsJsonObject
().
get
(
"name"
).
getAsString
()).
getAsString
(
);
J
sonObject
object
=
JsonParser
.
parseString
(
apiDefinition
.
toString
()).
getAsJsonObject
(
);
object
.
addProperty
(
"status"
,
status
);
apiDefinitionListWithStatus
.
add
(
object
);
if
(
StringUtils
.
isNotEmpty
(
status
)
&&
status
.
equalsIgnoreCase
(
"Success"
))
{
success
++;
if
(
StringUtils
.
isNotEmpty
(
status
)
&&
status
.
equalsIgnoreCase
(
"Success"
))
{
success
++;
}
}
}
datasourceDTO
.
setApiConfiguration
(
apiDefinitionListWithStatus
);
if
(
success
==
apiDefinitionList
.
size
())
{
if
(
success
==
apiDefinitionList
.
size
())
{
datasourceDTO
.
setStatus
(
"Success"
);
}
else
{
if
(
success
>
0
&&
success
<
apiDefinitionList
.
size
()
)
{
}
else
{
if
(
success
>
0
&&
success
<
apiDefinitionList
.
size
())
{
datasourceDTO
.
setStatus
(
"Warning"
);
}
else
{
}
else
{
datasourceDTO
.
setStatus
(
"Error"
);
}
}
...
...
@@ -191,8 +193,8 @@ public class DatasourceService {
DatasetTableExample
example
=
new
DatasetTableExample
();
example
.
createCriteria
().
andDataSourceIdEqualTo
(
datasourceId
);
List
<
DatasetTable
>
datasetTables
=
datasetTableMapper
.
selectByExample
(
example
);
if
(
CollectionUtils
.
isNotEmpty
(
datasetTables
))
{
return
ResultHolder
.
error
(
datasetTables
.
size
()
+
Translator
.
get
(
"i18n_datasource_not_allow_delete_msg"
));
if
(
CollectionUtils
.
isNotEmpty
(
datasetTables
))
{
return
ResultHolder
.
error
(
datasetTables
.
size
()
+
Translator
.
get
(
"i18n_datasource_not_allow_delete_msg"
));
}
Datasource
datasource
=
datasourceMapper
.
selectByPrimaryKey
(
datasourceId
);
datasourceMapper
.
deleteByPrimaryKey
(
datasourceId
);
...
...
@@ -200,11 +202,11 @@ public class DatasourceService {
return
ResultHolder
.
success
(
"success"
);
}
public
void
updateDatasource
(
UpdataDsRequest
updataDsRequest
)
throws
Exception
{
if
(!
types
().
stream
().
map
(
DataSourceType:
:
getType
).
collect
(
Collectors
.
toList
()).
contains
(
updataDsRequest
.
getType
()))
{
public
void
updateDatasource
(
UpdataDsRequest
updataDsRequest
)
throws
Exception
{
if
(!
types
().
stream
().
map
(
DataSourceType:
:
getType
).
collect
(
Collectors
.
toList
()).
contains
(
updataDsRequest
.
getType
()))
{
throw
new
Exception
(
"Datasource type not supported."
);
}
checkName
(
updataDsRequest
.
getName
(),
updataDsRequest
.
getType
(),
updataDsRequest
.
getId
());
checkName
(
updataDsRequest
.
getName
(),
updataDsRequest
.
getType
(),
updataDsRequest
.
getId
());
Datasource
datasource
=
new
Datasource
();
datasource
.
setName
(
updataDsRequest
.
getName
());
datasource
.
setDesc
(
updataDsRequest
.
getDesc
());
...
...
@@ -219,13 +221,13 @@ public class DatasourceService {
handleConnectionPool
(
updataDsRequest
.
getId
());
}
private
void
handleConnectionPool
(
String
datasourceId
){
private
void
handleConnectionPool
(
String
datasourceId
)
{
String
cacheType
=
env
.
getProperty
(
"spring.cache.type"
);
if
(
cacheType
!=
null
&&
cacheType
.
equalsIgnoreCase
(
"redis"
))
{
if
(
cacheType
!=
null
&&
cacheType
.
equalsIgnoreCase
(
"redis"
))
{
handleConnectionPool
(
datasourceId
,
"delete"
);
RedisTemplate
redisTemplate
=
SpringContextUtil
.
getBean
(
"redisTemplate"
,
RedisTemplate
.
class
);
redisTemplate
.
convertAndSend
(
RedisConstants
.
DS_REDIS_TOPIC
,
datasourceId
);
}
else
{
}
else
{
handleConnectionPool
(
datasourceId
,
"edit"
);
}
}
...
...
@@ -236,42 +238,43 @@ public class DatasourceService {
DatasourceRequest
datasourceRequest
=
new
DatasourceRequest
();
datasourceRequest
.
setDatasource
(
datasource
);
String
datasourceStatus
=
datasourceProvider
.
checkStatus
(
datasourceRequest
);
if
(
datasource
.
getType
().
equalsIgnoreCase
(
"api"
)){
if
(
datasource
.
getType
().
equalsIgnoreCase
(
"api"
))
{
Gson
gson
=
new
Gson
();
int
success
=
0
;
J
SONArray
apiDefinitionList
=
JSONObject
.
parseArray
(
datasource
.
getConfiguration
()
);
J
SONArray
apiDefinitionListWithStatus
=
new
JSON
Array
();
if
(
StringUtils
.
isNotEmpty
(
datasourceStatus
))
{
J
SONObject
apiItemStatuses
=
JSONObject
.
parseObject
(
datasourceStatus
);
J
sonArray
apiDefinitionList
=
JsonParser
.
parseString
(
datasource
.
getConfiguration
()).
getAsJsonArray
(
);
J
sonArray
apiDefinitionListWithStatus
=
new
Json
Array
();
if
(
StringUtils
.
isNotEmpty
(
datasourceStatus
))
{
J
sonObject
apiItemStatuses
=
JsonParser
.
parseString
(
datasourceStatus
).
getAsJsonObject
(
);
for
(
Object
apiDefinition
:
apiDefinitionList
)
{
String
status
=
apiItemStatuses
.
get
String
(
JSONObject
.
parseObject
(
apiDefinition
.
toString
()).
getString
(
"name"
)
);
J
SONObject
object
=
JSONObject
.
parseObject
(
apiDefinition
.
toString
()
);
object
.
put
(
"status"
,
status
);
String
status
=
apiItemStatuses
.
get
(
JsonParser
.
parseString
(
apiDefinition
.
toString
()).
getAsJsonObject
().
get
(
"name"
).
getAsString
()).
getAsString
(
);
J
sonObject
object
=
JsonParser
.
parseString
(
apiDefinition
.
toString
()).
getAsJsonObject
(
);
object
.
addProperty
(
"status"
,
status
);
apiDefinitionListWithStatus
.
add
(
object
);
if
(
StringUtils
.
isNotEmpty
(
status
)
&&
status
.
equalsIgnoreCase
(
"Success"
))
{
success
++;
if
(
StringUtils
.
isNotEmpty
(
status
)
&&
status
.
equalsIgnoreCase
(
"Success"
))
{
success
++;
}
}
}
datasource
.
setApiConfiguration
(
apiDefinitionListWithStatus
);
if
(
success
==
apiDefinitionList
.
size
())
{
if
(
success
==
apiDefinitionList
.
size
())
{
return
ResultHolder
.
success
(
datasource
);
}
if
(
success
>
0
&&
success
<
apiDefinitionList
.
size
()
)
{
if
(
success
>
0
&&
success
<
apiDefinitionList
.
size
())
{
return
ResultHolder
.
error
(
"Datasource has invalid tables"
,
datasource
);
}
return
ResultHolder
.
error
(
"Datasource is invalid."
,
datasource
);
}
return
ResultHolder
.
success
(
datasource
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
ResultHolder
.
error
(
"Datasource is invalid: "
+
e
.
getMessage
());
}
}
public
ResultHolder
validate
(
String
datasourceId
)
{
Datasource
datasource
=
datasourceMapper
.
selectByPrimaryKey
(
datasourceId
);
if
(
datasource
==
null
)
{
return
ResultHolder
.
error
(
"Can not find datasource: "
+
datasourceId
);
if
(
datasource
==
null
)
{
return
ResultHolder
.
error
(
"Can not find datasource: "
+
datasourceId
);
}
try
{
Provider
datasourceProvider
=
ProviderFactory
.
getProvider
(
datasource
.
getType
());
...
...
@@ -280,31 +283,31 @@ public class DatasourceService {
String
datasourceStatus
=
datasourceProvider
.
checkStatus
(
datasourceRequest
);
datasource
.
setStatus
(
datasourceStatus
);
if
(
datasource
.
getType
().
equalsIgnoreCase
(
"api"
))
{
List
<
ApiDefinition
>
apiDefinitionList
=
JSONObject
.
parseArray
(
datasource
.
getConfiguration
(),
ApiDefinition
.
class
);
J
SONObject
apiItemStatuses
=
JSONObject
.
parseObject
(
datasourceStatus
);
if
(
datasource
.
getType
().
equalsIgnoreCase
(
"api"
))
{
List
<
ApiDefinition
>
apiDefinitionList
=
new
Gson
().
fromJson
(
datasource
.
getConfiguration
(),
new
TypeToken
<
List
<
ApiDefinition
>>(){}.
getType
()
);
J
sonObject
apiItemStatuses
=
JsonParser
.
parseString
(
datasourceStatus
).
getAsJsonObject
(
);
int
success
=
0
;
for
(
ApiDefinition
apiDefinition
:
apiDefinitionList
)
{
String
status
=
apiItemStatuses
.
get
String
(
apiDefinition
.
getName
()
);
String
status
=
apiItemStatuses
.
get
(
apiDefinition
.
getName
()).
getAsString
(
);
apiDefinition
.
setStatus
(
status
);
if
(
status
.
equalsIgnoreCase
(
"Success"
))
{
success
++;
if
(
status
.
equalsIgnoreCase
(
"Success"
))
{
success
++;
}
}
if
(
success
==
apiDefinitionList
.
size
())
{
if
(
success
==
apiDefinitionList
.
size
())
{
return
ResultHolder
.
success
(
datasource
);
}
if
(
success
>
0
&&
success
<
apiDefinitionList
.
size
()
)
{
if
(
success
>
0
&&
success
<
apiDefinitionList
.
size
())
{
return
ResultHolder
.
error
(
"Datasource has invalid tables"
,
datasource
);
}
return
ResultHolder
.
error
(
"Datasource is invalid."
,
datasource
);
}
return
ResultHolder
.
success
(
"Success"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
datasource
.
setStatus
(
"Error"
);
return
ResultHolder
.
error
(
"Datasource is invalid: "
+
e
.
getMessage
());
}
finally
{
}
finally
{
datasourceMapper
.
updateByPrimaryKey
(
datasource
);
}
}
...
...
@@ -321,7 +324,7 @@ public class DatasourceService {
Provider
datasourceProvider
=
ProviderFactory
.
getProvider
(
ds
.
getType
());
DatasourceRequest
datasourceRequest
=
new
DatasourceRequest
();
datasourceRequest
.
setDatasource
(
ds
);
if
(!
ds
.
getType
().
equalsIgnoreCase
(
"api"
))
{
if
(!
ds
.
getType
().
equalsIgnoreCase
(
"api"
))
{
datasourceProvider
.
checkStatus
(
datasourceRequest
);
}
...
...
@@ -329,7 +332,7 @@ public class DatasourceService {
// 获取当前数据源下的db、api类型数据集
DatasetTableExample
datasetTableExample
=
new
DatasetTableExample
();
datasetTableExample
.
createCriteria
().
andTypeIn
(
Arrays
.
asList
(
"db"
,
"api"
)).
andDataSourceIdEqualTo
(
ds
.
getId
());
datasetTableExample
.
createCriteria
().
andTypeIn
(
Arrays
.
asList
(
"db"
,
"api"
)).
andDataSourceIdEqualTo
(
ds
.
getId
());
List
<
DatasetTable
>
datasetTables
=
datasetTableMapper
.
selectByExampleWithBLOBs
(
datasetTableExample
);
List
<
DBTableDTO
>
list
=
new
ArrayList
<>();
for
(
TableDesc
tableDesc
:
tables
)
{
...
...
@@ -364,7 +367,7 @@ public class DatasourceService {
return
datasourceMapper
.
selectByPrimaryKey
(
id
);
}
public
List
<
Datasource
>
selectByType
(
String
type
){
public
List
<
Datasource
>
selectByType
(
String
type
)
{
DatasourceExample
datasourceExample
=
new
DatasourceExample
();
datasourceExample
.
createCriteria
().
andTypeEqualTo
(
type
);
return
datasourceMapper
.
selectByExampleWithBLOBs
(
datasourceExample
);
...
...
@@ -373,7 +376,7 @@ public class DatasourceService {
public
void
initAllDataSourceConnectionPool
()
{
List
<
Datasource
>
datasources
=
datasourceMapper
.
selectByExampleWithBLOBs
(
new
DatasourceExample
());
datasources
.
forEach
(
datasource
->
{
commonThreadPool
.
addTask
(()
->
{
commonThreadPool
.
addTask
(()
->
{
try
{
handleConnectionPool
(
datasource
,
"add"
);
}
catch
(
Exception
e
)
{
...
...
@@ -396,7 +399,7 @@ public class DatasourceService {
}
}
public
void
updateDatasourceStatus
(){
public
void
updateDatasourceStatus
()
{
List
<
Datasource
>
datasources
=
datasourceMapper
.
selectByExampleWithBLOBs
(
new
DatasourceExample
());
datasources
.
forEach
(
datasource
->
checkAndUpdateDatasourceStatus
(
datasource
,
true
));
}
...
...
@@ -406,13 +409,13 @@ public class DatasourceService {
return
ApiProvider
.
checkApiDefinition
(
apiDefinition
,
response
);
}
public
List
<
Datasource
>
listByType
(
String
type
){
public
List
<
Datasource
>
listByType
(
String
type
)
{
DatasourceExample
example
=
new
DatasourceExample
();
example
.
createCriteria
().
andTypeEqualTo
(
type
);
return
datasourceMapper
.
selectByExampleWithBLOBs
(
example
);
}
private
void
checkAndUpdateDatasourceStatus
(
Datasource
datasource
){
private
void
checkAndUpdateDatasourceStatus
(
Datasource
datasource
)
{
try
{
Provider
datasourceProvider
=
ProviderFactory
.
getProvider
(
datasource
.
getType
());
DatasourceRequest
datasourceRequest
=
new
DatasourceRequest
();
...
...
@@ -424,7 +427,7 @@ public class DatasourceService {
}
}
private
void
checkAndUpdateDatasourceStatus
(
Datasource
datasource
,
Boolean
withMsg
){
private
void
checkAndUpdateDatasourceStatus
(
Datasource
datasource
,
Boolean
withMsg
)
{
try
{
Provider
datasourceProvider
=
ProviderFactory
.
getProvider
(
datasource
.
getType
());
DatasourceRequest
datasourceRequest
=
new
DatasourceRequest
();
...
...
@@ -454,7 +457,7 @@ public class DatasourceService {
param
.
put
(
"id"
,
id
);
param
.
put
(
"name"
,
datasource
.
getName
());
String
content
=
"数据源【"
+
datasource
.
getName
()
+
"】无效"
;
DeMsgutil
.
sendMsg
(
userId
,
typeId
,
content
,
gson
.
toJson
(
param
));
DeMsgutil
.
sendMsg
(
userId
,
typeId
,
content
,
gson
.
toJson
(
param
));
});
}
}
backend/src/main/java/io/dataease/service/engine/EngineService.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
service
.
engine
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.Gson
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
io.dataease.commons.utils.BeanUtils
;
import
io.dataease.commons.utils.HttpClientConfig
;
import
io.dataease.commons.utils.HttpClientUtil
;
...
...
@@ -34,15 +35,15 @@ import java.util.regex.Pattern;
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
class
EngineService
{
@Resource
private
Environment
env
;
private
Environment
env
;
@Resource
private
DeEngineMapper
deEngineMapper
;
@Resource
private
DatasourceService
datasource
;
static
private
List
<
String
>
simple_engine
=
Arrays
.
asList
(
"engine_mysql"
);
static
private
List
<
String
>
simple_engine
=
Arrays
.
asList
(
"engine_mysql"
);
static
private
List
<
String
>
cluster_engine
=
Arrays
.
asList
(
"engine_doris"
);
static
private
List
<
String
>
cluster_engine
=
Arrays
.
asList
(
"engine_doris"
);
public
Boolean
isLocalMode
()
{
return
env
.
getProperty
(
"engine_mode"
,
"local"
).
equalsIgnoreCase
(
"local"
);
...
...
@@ -96,24 +97,28 @@ public class EngineService {
String
response
;
try
{
response
=
HttpClientUtil
.
get
(
"http://"
+
dorisConfiguration
.
getHost
()
+
":"
+
dorisConfiguration
.
getHttpPort
()
+
"/api/backends"
,
httpClientConfig
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
return
ResultHolder
.
error
(
"Engine is invalid: "
+
e
.
getMessage
());
}
JSONArray
backends
=
Optional
.
ofNullable
(
JSONObject
.
parseObject
(
response
).
getJSONObject
(
"data"
)).
orElse
(
new
JSONObject
()).
getJSONArray
(
"backends"
);
if
(
CollectionUtils
.
isEmpty
(
backends
)){
JsonArray
backends
=
null
;
JsonObject
data
=
JsonParser
.
parseString
(
response
).
getAsJsonObject
().
getAsJsonObject
(
"data"
);
if
(
data
!=
null
)
{
backends
=
data
.
getAsJsonArray
(
"backends"
);
}
if
(
backends
==
null
||
backends
.
size
()
==
0
)
{
return
ResultHolder
.
error
(
"Engine is invalid: no backends found."
);
}
Integer
alives
=
0
;
for
(
int
i
=
0
;
i
<
backends
.
size
();
i
++)
{
J
SONObject
kv
=
backends
.
getJSONObject
(
i
);
if
(
kv
.
get
Boolean
(
"is_alive"
))
{
alives
++;
J
sonObject
kv
=
backends
.
get
(
i
).
getAsJsonObject
(
);
if
(
kv
.
get
(
"is_alive"
).
getAsBoolean
(
))
{
alives
++;
}
}
if
(
alives
<
dorisConfiguration
.
getReplicationNum
())
{
if
(
alives
<
dorisConfiguration
.
getReplicationNum
())
{
return
ResultHolder
.
error
(
"Engine params is invalid: 副本数量不能大于节点数量."
);
}
}
...
...
@@ -135,17 +140,17 @@ public class EngineService {
return
ResultHolder
.
success
(
engine
);
}
private
void
checkValid
(
DeEngine
engine
)
throws
Exception
{
if
(
isLocalMode
())
{
private
void
checkValid
(
DeEngine
engine
)
throws
Exception
{
if
(
isLocalMode
())
{
throw
new
Exception
(
"Setting engine is not supported."
);
}
if
(
isSimpleMode
())
{
if
(!
simple_engine
.
contains
(
engine
.
getType
()))
{
if
(
isSimpleMode
())
{
if
(!
simple_engine
.
contains
(
engine
.
getType
()))
{
throw
new
Exception
(
"Engine type not supported."
);
}
}
if
(
isClusterMode
())
{
if
(!
cluster_engine
.
contains
(
engine
.
getType
()))
{
if
(
isClusterMode
())
{
if
(!
cluster_engine
.
contains
(
engine
.
getType
()))
{
throw
new
Exception
(
"Engine type not supported."
);
}
}
...
...
@@ -160,21 +165,21 @@ public class EngineService {
Datasource
datasource
=
new
Datasource
();
if
(
isLocalMode
())
{
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"dataSourceType"
,
"jdbc"
);
jsonObject
.
put
(
"dataBase"
,
env
.
getProperty
(
"doris.db"
,
"doris"
));
jsonObject
.
put
(
"username"
,
env
.
getProperty
(
"doris.user"
,
"root"
));
jsonObject
.
put
(
"password"
,
env
.
getProperty
(
"doris.password"
,
"dataease"
));
jsonObject
.
put
(
"host"
,
env
.
getProperty
(
"doris.host"
,
"doris"
));
jsonObject
.
put
(
"port"
,
env
.
getProperty
(
"doris.port"
,
"9030"
));
jsonObject
.
put
(
"httpPort"
,
env
.
getProperty
(
"doris.httpPort"
,
"8030"
));
Map
jsonObjectMap
=
new
HashMap
();
jsonObject
Map
.
put
(
"dataSourceType"
,
"jdbc"
);
jsonObject
Map
.
put
(
"dataBase"
,
env
.
getProperty
(
"doris.db"
,
"doris"
));
jsonObject
Map
.
put
(
"username"
,
env
.
getProperty
(
"doris.user"
,
"root"
));
jsonObject
Map
.
put
(
"password"
,
env
.
getProperty
(
"doris.password"
,
"dataease"
));
jsonObject
Map
.
put
(
"host"
,
env
.
getProperty
(
"doris.host"
,
"doris"
));
jsonObject
Map
.
put
(
"port"
,
env
.
getProperty
(
"doris.port"
,
"9030"
));
jsonObject
Map
.
put
(
"httpPort"
,
env
.
getProperty
(
"doris.httpPort"
,
"8030"
));
DeEngine
engine
=
new
DeEngine
();
engine
.
setId
(
"doris"
);
engine
.
setName
(
"doris"
);
engine
.
setDesc
(
"doris"
);
engine
.
setType
(
"engine_doris"
);
engine
.
setConfiguration
(
jsonObject
.
toJSONString
(
));
engine
.
setConfiguration
(
new
Gson
().
toJson
(
jsonObjectMap
));
BeanUtils
.
copyBean
(
datasource
,
engine
);
}
if
(
isClusterMode
())
{
...
...
@@ -198,7 +203,7 @@ public class EngineService {
return
datasource
;
}
public
void
initSimpleEngine
(){
public
void
initSimpleEngine
()
{
if
(!
isSimpleMode
())
{
return
;
}
...
...
@@ -214,9 +219,10 @@ public class EngineService {
MysqlConfiguration
mysqlConfiguration
=
new
MysqlConfiguration
();
Pattern
WITH_SQL_FRAGMENT
=
Pattern
.
compile
(
"jdbc:mysql://(.*):(\\d+)/(.*)"
);
Matcher
matcher
=
WITH_SQL_FRAGMENT
.
matcher
(
env
.
getProperty
(
"spring.datasource.url"
));
if
(!
matcher
.
find
()){
return
;
};
if
(!
matcher
.
find
())
{
return
;
}
;
mysqlConfiguration
.
setHost
(
matcher
.
group
(
1
));
mysqlConfiguration
.
setPort
(
Integer
.
valueOf
(
matcher
.
group
(
2
)));
mysqlConfiguration
.
setDataBase
(
matcher
.
group
(
3
).
split
(
"\\?"
)[
0
]);
...
...
backend/src/main/java/io/dataease/service/panel/PanelGroupExtendDataService.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
service
.
panel
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.Gson
;
import
io.dataease.dto.chart.ChartViewDTO
;
import
io.dataease.exception.DataEaseException
;
import
io.dataease.plugins.common.base.domain.PanelGroupExtendData
;
...
...
@@ -25,11 +24,12 @@ public class PanelGroupExtendDataService {
private
PanelGroupExtendDataMapper
panelGroupExtendDataMapper
;
public
ChartViewDTO
getChartDataInfo
(
String
viewId
,
ChartViewDTO
view
){
Gson
gson
=
new
Gson
();
PanelGroupExtendDataExample
extendDataExample
=
new
PanelGroupExtendDataExample
();
extendDataExample
.
createCriteria
().
andViewIdEqualTo
(
viewId
);
List
<
PanelGroupExtendData
>
extendDataList
=
panelGroupExtendDataMapper
.
selectByExampleWithBLOBs
(
extendDataExample
);
if
(
CollectionUtils
.
isNotEmpty
(
extendDataList
)){
ChartViewDTO
chartViewTemplate
=
JSONObject
.
parseObject
(
extendDataList
.
get
(
0
).
getViewDetails
(),
ChartViewDTO
.
class
);
ChartViewDTO
chartViewTemplate
=
gson
.
fromJson
(
extendDataList
.
get
(
0
).
getViewDetails
(),
ChartViewDTO
.
class
);
view
.
setData
(
chartViewTemplate
.
getData
());
}
else
{
DataEaseException
.
throwException
(
"模板缓存数据中未获取指定视图数据:"
+
viewId
);
...
...
backend/src/main/java/io/dataease/service/panel/PanelGroupService.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
service
.
panel
;
import
com.
alibaba.fastjson.JSON
;
import
com.
google.gson.Gson
;
import
io.dataease.auth.annotation.DeCleaner
;
import
io.dataease.commons.constants.*
;
import
io.dataease.commons.utils.AuthUtils
;
...
...
@@ -384,6 +384,7 @@ public class PanelGroupService {
}
public
String
newPanel
(
PanelGroupRequest
request
)
{
Gson
gson
=
new
Gson
();
String
newPanelId
=
UUIDUtil
.
getUUIDAsString
();
String
newFrom
=
request
.
getNewFrom
();
String
templateStyle
=
null
;
...
...
@@ -405,13 +406,13 @@ public class PanelGroupService {
dynamicData
=
request
.
getDynamicData
();
staticResource
=
request
.
getStaticResource
();
}
Map
<
String
,
String
>
dynamicDataMap
=
JSON
.
parseObject
(
dynamicData
,
Map
.
class
);
Map
<
String
,
String
>
dynamicDataMap
=
gson
.
fromJson
(
dynamicData
,
Map
.
class
);
List
<
PanelViewInsertDTO
>
panelViews
=
new
ArrayList
<>();
List
<
PanelGroupExtendDataDTO
>
viewsData
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
String
>
entry
:
dynamicDataMap
.
entrySet
())
{
String
originViewId
=
entry
.
getKey
();
String
originViewData
=
entry
.
getValue
();
ChartViewDTO
chartView
=
JSON
.
parseObject
(
originViewData
,
ChartViewDTO
.
class
);
ChartViewDTO
chartView
=
gson
.
fromJson
(
originViewData
,
ChartViewDTO
.
class
);
String
position
=
chartView
.
getPosition
();
String
newViewId
=
UUIDUtil
.
getUUIDAsString
();
chartView
.
setId
(
newViewId
);
...
...
@@ -472,7 +473,6 @@ public class PanelGroupService {
extPanelViewLinkageMapper
.
copyViewLinkageField
(
copyId
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
"错误===》panel:"
+
panelGroupDTO
.
getId
()
+
";panelView:"
+
JSON
.
toJSONString
(
panelViewtemp
));
}
}
}
...
...
backend/src/main/java/io/dataease/service/panel/PanelViewService.java
浏览文件 @
3c6d2fb9
package
io
.
dataease
.
service
.
panel
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.gson.JsonArray
;
import
com.google.gson.JsonObject
;
import
com.google.gson.JsonParser
;
import
io.dataease.ext.ExtChartViewMapper
;
import
io.dataease.ext.ExtPanelGroupMapper
;
import
io.dataease.ext.ExtPanelViewMapper
;
...
...
@@ -95,28 +94,29 @@ public class PanelViewService {
String
panelData
=
panelGroup
.
getPanelData
();
if
(
StringUtils
.
isNotEmpty
(
panelData
))
{
mobileLayout
=
false
;
JSONArray
dataArray
=
JSON
.
parseArray
(
panelData
);
JsonArray
dataArray
=
JsonParser
.
parseString
(
panelData
).
getAsJsonArray
();
List
<
PanelViewInsertDTO
>
panelViewInsertDTOList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
dataArray
.
size
();
i
++)
{
J
SONObject
jsonObject
=
dataArray
.
getJSONObject
(
i
);
if
(
"view"
.
equals
(
jsonObject
.
getString
(
"type"
)))
{
panelViewInsertDTOList
.
add
(
new
PanelViewInsertDTO
(
jsonObject
.
get
JSONObject
(
"propValue"
).
getString
(
"viewId"
),
panelId
));
J
sonObject
jsonObject
=
dataArray
.
get
(
i
).
getAsJsonObject
(
);
if
(
jsonObject
.
get
(
"type"
)!=
null
&&
"view"
.
equals
(
jsonObject
.
get
(
"type"
).
getAsString
(
)))
{
panelViewInsertDTOList
.
add
(
new
PanelViewInsertDTO
(
jsonObject
.
get
(
"propValue"
).
getAsJsonObject
().
get
(
"viewId"
).
getAsString
(
),
panelId
));
}
// 选项卡内部视图
if
(
"de-tabs"
.
equals
(
jsonObject
.
getString
(
"type"
)))
{
J
SONObject
options
=
jsonObject
.
getJSON
Object
(
"options"
);
if
(
jsonObject
.
get
(
"type"
)!=
null
&&
"de-tabs"
.
equals
(
jsonObject
.
get
(
"type"
).
getAsString
(
)))
{
J
sonObject
options
=
jsonObject
.
getAsJson
Object
(
"options"
);
if
(
options
!=
null
)
{
J
SONArray
tabList
=
options
.
getJSON
Array
(
"tabList"
);
if
(
CollectionUtils
.
isNotEmpty
(
tabList
)
)
{
J
sonArray
tabList
=
options
.
getAsJson
Array
(
"tabList"
);
if
(
tabList
!=
null
&&
tabList
.
size
()
>
0
)
{
for
(
int
y
=
0
;
y
<
tabList
.
size
();
y
++)
{
if
(
tabList
.
getJSONObject
(
y
).
getString
(
"content"
).
indexOf
(
"viewId"
)>-
1
)
{
panelViewInsertDTOList
.
add
(
new
PanelViewInsertDTO
(
tabList
.
get
JSONObject
(
y
).
getJSONObject
(
"content"
).
getJSONObject
(
"propValue"
).
getString
(
"viewId"
),
panelId
,
"tab"
));
if
(
tabList
.
get
(
y
).
getAsJsonObject
().
get
(
"content"
).
toString
().
indexOf
(
"viewId"
)
>
-
1
)
{
panelViewInsertDTOList
.
add
(
new
PanelViewInsertDTO
(
tabList
.
get
(
y
).
getAsJsonObject
().
getAsJsonObject
(
"content"
).
getAsJsonObject
(
"propValue"
).
get
(
"viewId"
).
getAsString
(),
panelId
,
"tab"
));
}
}
}
}
}
if
(
jsonObject
.
get
Boolean
(
"mobileSelected"
)
!=
null
&&
jsonObject
.
getBoolean
(
"mobileSelected"
))
{
if
(
jsonObject
.
get
(
"mobileSelected"
)
!=
null
&&
jsonObject
.
get
(
"mobileSelected"
).
getAsBoolean
(
))
{
mobileLayout
=
true
;
}
}
...
...
@@ -124,11 +124,11 @@ public class PanelViewService {
if
(
CollectionUtils
.
isNotEmpty
(
panelViewInsertDTOList
))
{
extPanelViewMapper
.
savePanelView
(
panelViewInsertDTOList
);
//将视图从cache表中更新到正式表中
viewIds
=
panelViewInsertDTOList
.
stream
().
map
(
panelView
->
panelView
.
getChartViewId
()).
collect
(
Collectors
.
toList
());
viewIds
=
panelViewInsertDTOList
.
stream
().
map
(
panelView
->
panelView
.
getChartViewId
()).
collect
(
Collectors
.
toList
());
// extChartViewMapper.copyCacheToView(viewIds);
}
extChartViewMapper
.
deleteCacheWithPanel
(
viewIds
,
panelId
);
extChartViewMapper
.
deleteNoUseView
(
viewIds
,
panelId
);
extChartViewMapper
.
deleteCacheWithPanel
(
viewIds
,
panelId
);
extChartViewMapper
.
deleteNoUseView
(
viewIds
,
panelId
);
}
panelGroup
.
setMobileLayout
(
mobileLayout
);
return
viewIds
;
...
...
@@ -138,19 +138,19 @@ public class PanelViewService {
return
extPanelViewMapper
.
getPanelViewDetails
(
panelId
);
}
public
List
<
PanelView
>
findPanelViews
(
String
copyId
){
public
List
<
PanelView
>
findPanelViews
(
String
copyId
)
{
PanelViewExample
panelViewExample
=
new
PanelViewExample
();
panelViewExample
.
createCriteria
().
andCopyIdEqualTo
(
copyId
);
return
panelViewMapper
.
selectByExample
(
panelViewExample
);
}
public
PanelView
findByViewId
(
String
viewId
){
public
PanelView
findByViewId
(
String
viewId
)
{
PanelViewExample
panelViewExample
=
new
PanelViewExample
();
panelViewExample
.
createCriteria
().
andChartViewIdEqualTo
(
viewId
);
List
<
PanelView
>
result
=
panelViewMapper
.
selectByExample
(
panelViewExample
);
if
(
CollectionUtils
.
isNotEmpty
(
result
))
{
List
<
PanelView
>
result
=
panelViewMapper
.
selectByExample
(
panelViewExample
);
if
(
CollectionUtils
.
isNotEmpty
(
result
))
{
return
result
.
get
(
0
);
}
else
{
}
else
{
return
null
;
}
}
...
...
backend/src/main/java/io/dataease/service/staticResource/StaticResourceService.java
浏览文件 @
3c6d2fb9
...
...
@@ -2,7 +2,7 @@ package io.dataease.service.staticResource;
import
cn.hutool.core.codec.Base64Decoder
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.
alibaba.fastjson.JSON
;
import
com.
google.gson.Gson
;
import
io.dataease.commons.utils.FileUtils
;
import
io.dataease.commons.utils.LogUtil
;
import
io.dataease.commons.utils.StaticResourceUtils
;
...
...
@@ -51,8 +51,9 @@ public class StaticResourceService {
}
public
void
saveFilesToServe
(
String
staticResource
){
Gson
gson
=
new
Gson
();
if
(
StringUtils
.
isNotEmpty
(
staticResource
)){
Map
<
String
,
String
>
resource
=
JSON
.
parseObject
(
staticResource
,
Map
.
class
);
Map
<
String
,
String
>
resource
=
gson
.
fromJson
(
staticResource
,
Map
.
class
);
for
(
Map
.
Entry
<
String
,
String
>
entry:
resource
.
entrySet
()){
String
path
=
entry
.
getKey
();
Path
uploadPath
=
Paths
.
get
(
staticDir
.
toString
(),
path
.
substring
(
path
.
lastIndexOf
(
"/"
)+
1
,
path
.
length
()));
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论