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