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 个修改的文件
包含
90 行增加
和
88 行删除
+90
-88
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
+0
-0
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
+0
-0
EngineService.java
...c/main/java/io/dataease/service/engine/EngineService.java
+35
-29
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
+22
-22
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
差异被折叠。
点击展开。
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
差异被折叠。
点击展开。
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
;
...
...
@@ -40,9 +41,9 @@ public class EngineService {
@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
())
{
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
))
{
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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论