Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
2cc4ed8f
提交
2cc4ed8f
编写于
8月 24, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
0ceb519d
变更
22
隐藏空白字符变更
内嵌
并排
正在显示
22 个修改的文件
包含
645 行增加
和
48 行删除
+645
-48
DOModel.java
...re/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
+1
-1
DSSetting.java
.../src/main/java/cn/ibizlab/core/data/domain/DSSetting.java
+164
-13
DataObj.java
...-core/src/main/java/cn/ibizlab/core/data/dto/DataObj.java
+1
-0
FilterData.java
...re/src/main/java/cn/ibizlab/core/data/dto/FilterData.java
+1
-0
DSSettingSearchContext.java
...a/cn/ibizlab/core/data/filter/DSSettingSearchContext.java
+0
-2
DstSystemModel.java
...c/main/java/cn/ibizlab/core/data/lite/DstSystemModel.java
+1
-1
DynamicModelService.java
...n/java/cn/ibizlab/core/data/lite/DynamicModelService.java
+13
-2
EntityModel.java
.../src/main/java/cn/ibizlab/core/data/lite/EntityModel.java
+1
-1
FieldModel.java
...e/src/main/java/cn/ibizlab/core/data/lite/FieldModel.java
+1
-1
LiteModelFallback.java
...ain/java/cn/ibizlab/core/data/lite/LiteModelFallback.java
+1
-1
LiteModelFeignClient.java
.../java/cn/ibizlab/core/data/lite/LiteModelFeignClient.java
+1
-1
MetaEntityModel.java
.../main/java/cn/ibizlab/core/data/lite/MetaEntityModel.java
+1
-1
MetaFieldModel.java
...c/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
+1
-1
Setting.java
...core/src/main/java/cn/ibizlab/core/data/lite/Setting.java
+2
-2
DSLinkConfig.java
...rc/main/java/cn/ibizlab/core/data/model/DSLinkConfig.java
+62
-0
PojoProperty.java
...rc/main/java/cn/ibizlab/core/data/model/PojoProperty.java
+1
-1
IDSSettingService.java
.../java/cn/ibizlab/core/data/service/IDSSettingService.java
+1
-1
ModelService.java
.../main/java/cn/ibizlab/core/data/service/ModelService.java
+50
-2
DOModelServiceImpl.java
...cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
+4
-4
DSSettingServiceImpl.java
.../ibizlab/core/data/service/impl/DSSettingServiceImpl.java
+150
-12
DataObject.java
...core/src/main/java/cn/ibizlab/util/helper/DataObject.java
+1
-1
Inflector.java
...-core/src/main/java/cn/ibizlab/util/helper/Inflector.java
+187
-0
未找到文件。
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
浏览文件 @
2cc4ed8f
...
...
@@ -11,7 +11,7 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
org.springframework.util.ObjectUtils
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
java.io.Serializable
;
import
lombok.*
;
import
io.swagger.annotations.ApiModel
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DSSetting.java
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
core
.
data
.
domain
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.math.BigInteger
;
import
java.util.HashMap
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
cn.ibizlab.core.data.dto.DataObj
;
import
cn.ibizlab.core.data.lite.MetaEntityModel
;
import
cn.ibizlab.core.data.lite.Setting
;
import
cn.ibizlab.core.data.model.DSLinkConfig
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.dynamic.datasource.DynamicRoutingDataSource
;
import
com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.DigestUtils
;
import
cn.ibizlab.util.domain.EntityBase
;
import
cn.ibizlab.util.annotation.DEField
;
import
cn.ibizlab.util.enums.DEPredefinedFieldType
;
import
cn.ibizlab.util.enums.DEFieldDefaultValueType
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.util.enums.DupCheck
;
import
java.io.Serializable
;
import
lombok.*
;
import
org.springframework.data.annotation.Transient
;
import
cn.ibizlab.util.annotation.Audit
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
org.springframework.util.StringUtils
;
/**
...
...
@@ -37,12 +38,11 @@ import io.swagger.annotations.ApiModelProperty;
@NoArgsConstructor
@AllArgsConstructor
@ApiModel
(
"数据源"
)
public
class
DSSetting
extends
EntityBase
implements
Serializable
{
public
class
DSSetting
implements
Serializable
{
/**
* 标识
*/
@DEField
(
defaultValue
=
"dsname"
,
defaultValueType
=
DEFieldDefaultValueType
.
PARAM
,
isKeyField
=
true
)
@JSONField
(
name
=
"ds_id"
)
@JsonProperty
(
"ds_id"
)
@ApiModelProperty
(
"标识"
)
...
...
@@ -74,6 +74,157 @@ public class DSSetting extends EntityBase implements Serializable {
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
Map
<
String
,
Object
>
extensionparams
;
public
Object
get
(
String
key
)
{
if
(
extensionparams
==
null
)
extensionparams
=
Setting
.
getMap
(
dsCfg
);
return
extensionparams
.
get
(
key
);
}
public
String
getStringValue
(
String
key
)
{
return
this
.
getStringValue
(
key
,
""
);
}
public
String
getStringValue
(
String
key
,
String
strDefault
)
{
return
DataObject
.
getStringValue
(
get
(
key
),
strDefault
);
}
public
DSSetting
set
(
String
key
,
Object
value
)
{
if
(
value
==
null
)
return
this
;
if
(
extensionparams
==
null
)
extensionparams
=
Setting
.
getMap
(
dsCfg
);
extensionparams
.
put
(
key
,
value
);
List
<
Setting
>
settingList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
Object
>
entry:
extensionparams
.
entrySet
())
{
if
(!
entry
.
getKey
().
equalsIgnoreCase
(
"param"
))
settingList
.
add
(
new
Setting
().
setProperty
(
entry
.
getKey
()).
setValue
(
DataObject
.
getStringValue
(
entry
.
getValue
(),
""
)));
}
setDsCfg
(
JSON
.
toJSONString
(
settingList
));
return
this
;
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
DataSourceProperty
dataSourceProperty
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
DataSourceProperty
getDataSourceProperty
()
{
if
(
dataSourceProperty
==
null
)
{
if
(!
isDatabase
())
return
null
;
dataSourceProperty
=
new
DataSourceProperty
().
setDriverClassName
(
this
.
getDSLinkConfig
().
getDriverClassName
()).
setUrl
(
this
.
getDSLinkConfig
().
getUrl
())
.
setUsername
(
this
.
getDSLinkConfig
().
getUsername
()).
setPassword
(
this
.
getDSLinkConfig
().
getPassword
())
.
setSchema
(
this
.
getDSLinkConfig
().
getSchema
());
dataSourceProperty
.
getDruid
().
setFilters
(
"stat,log4j2"
);
}
return
dataSourceProperty
;
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
boolean
isMongodb
()
{
return
this
.
getDSLinkConfig
().
isMongodb
();
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
boolean
isDatabase
()
{
return
this
.
getDSLinkConfig
().
isDatabase
();
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
boolean
isElasticSearch
()
{
return
this
.
getDSLinkConfig
().
isElasticSearch
();
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
boolean
isCassandra
()
{
return
this
.
getDSLinkConfig
().
isCassandra
();
}
public
Set
<
String
>
getUsings
()
{
return
this
.
getDSLinkConfig
().
getUsings
();
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
DSLinkConfig
dsLinkConfig
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
DSLinkConfig
getDSLinkConfig
()
{
if
(
dsLinkConfig
==
null
)
{
dsLinkConfig
=
new
DSLinkConfig
().
setName
(
this
.
getDsId
()).
setDescription
(
this
.
getDsName
()).
setDriverClassName
(
this
.
getStringValue
(
"driver-class-name"
))
.
setUrl
(
this
.
getStringValue
(
"url"
,
this
.
getStringValue
(
"uri"
)))
.
setUsername
(
this
.
getStringValue
(
"username"
)).
setPassword
(
this
.
getStringValue
(
"password"
))
.
setSchema
(
this
.
getStringValue
(
"defaultSchema"
,
this
.
getStringValue
(
"schema"
)));
String
strUsings
=
this
.
getStringValue
(
"usings"
);
if
(!
StringUtils
.
isEmpty
(
strUsings
))
{
Set
<
String
>
usings
=
new
LinkedHashSet
<>();
for
(
String
using:
strUsings
.
split
(
","
))
usings
.
add
(
using
);
dsLinkConfig
.
setUsings
(
usings
);
}
}
return
dsLinkConfig
;
}
public
DSSetting
setDSLinkConfig
(
DSLinkConfig
dsLinkConfig
)
{
if
(
dsLinkConfig
!=
null
)
{
this
.
dsLinkConfig
=
dsLinkConfig
;
List
<
Setting
>
settings
=
new
ArrayList
<>();
if
(!
StringUtils
.
isEmpty
(
dsLinkConfig
.
getName
()))
this
.
setDsId
(
dsLinkConfig
.
getName
());
if
(!
StringUtils
.
isEmpty
(
dsLinkConfig
.
getType
()))
this
.
setDsType
(
dsLinkConfig
.
getType
());
if
(!
StringUtils
.
isEmpty
(
dsLinkConfig
.
getDescription
()))
this
.
setDsName
(
dsLinkConfig
.
getDescription
());
if
(!
StringUtils
.
isEmpty
(
dsLinkConfig
.
getDriverClassName
()))
settings
.
add
(
new
Setting
().
setProperty
(
"driver-class-name"
).
setValue
(
dsLinkConfig
.
getDriverClassName
()));
if
(!
StringUtils
.
isEmpty
(
dsLinkConfig
.
getUrl
()))
settings
.
add
(
new
Setting
().
setProperty
(
"url"
).
setValue
(
dsLinkConfig
.
getUrl
()));
if
(!
StringUtils
.
isEmpty
(
dsLinkConfig
.
getUsername
()))
settings
.
add
(
new
Setting
().
setProperty
(
"username"
).
setValue
(
dsLinkConfig
.
getUsername
()));
if
(!
StringUtils
.
isEmpty
(
dsLinkConfig
.
getPassword
()))
settings
.
add
(
new
Setting
().
setProperty
(
"password"
).
setValue
(
dsLinkConfig
.
getPassword
()));
if
(!
StringUtils
.
isEmpty
(
dsLinkConfig
.
getSchema
()))
settings
.
add
(
new
Setting
().
setProperty
(
"schema"
).
setValue
(
dsLinkConfig
.
getSchema
()));
if
(!
ObjectUtils
.
isEmpty
(
dsLinkConfig
.
getUsings
()))
settings
.
add
(
new
Setting
().
setProperty
(
"usings"
).
setValue
(
String
.
join
(
","
,
dsLinkConfig
.
getUsings
())));
setDsCfg
(
JSON
.
toJSONString
(
settings
));
}
return
this
;
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/dto/DataObj.java
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
core
.
data
.
dto
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/dto/FilterData.java
浏览文件 @
2cc4ed8f
...
...
@@ -4,6 +4,7 @@ import cn.ibizlab.core.data.model.POSchema;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.core.data.filter.QueryFilter
;
import
cn.ibizlab.core.data.filter.QueryWrapperContext
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/filter/DSSettingSearchContext.java
浏览文件 @
2cc4ed8f
...
...
@@ -17,8 +17,6 @@ import org.springframework.util.ObjectUtils;
import
org.springframework.util.StringUtils
;
import
cn.ibizlab.util.filter.SearchContextBase
;
/**
* ServiceApi数据实体[DSSetting] 查询条件对象
*/
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DstSystemModel.java
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DynamicModelService.java
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.Inflector
;
import
com.alibaba.fastjson.JSON
;
import
net.ibizsys.model.IPSSystem
;
import
net.ibizsys.model.PSModelServiceImpl
;
...
...
@@ -158,8 +159,18 @@ public class DynamicModelService {
.
setSystemId
(
iPSSystem
.
getCodeName
()).
setSystemName
(
iPSSystem
.
getLogicName
()).
setShowOrder
(
i
);
i
++;
entities
.
put
(
metaEntityModel
.
getCodeName
(),
metaEntityModel
);
if
(!
metaEntityModel
.
getEntityName
().
equals
(
metaEntityModel
.
getCodeName
()))
entities
.
put
(
metaEntityModel
.
getEntityName
(),
metaEntityModel
);
if
(!
metaEntityModel
.
getCodeName
().
toLowerCase
().
equals
(
metaEntityModel
.
getCodeName
()))
entities
.
put
(
metaEntityModel
.
getCodeName
().
toLowerCase
(),
metaEntityModel
);
if
(!
entities
.
containsKey
(
metaEntityModel
.
getEntityName
()))
{
entities
.
put
(
metaEntityModel
.
getEntityName
(),
metaEntityModel
);
}
if
(!
entities
.
containsKey
(
metaEntityModel
.
getEntityName
().
toLowerCase
()))
{
entities
.
put
(
metaEntityModel
.
getEntityName
().
toLowerCase
(),
metaEntityModel
);
}
String
pluralize
=
Inflector
.
getInstance
().
pluralize
(
metaEntityModel
.
getCodeName
()).
toLowerCase
();
if
(!
entities
.
containsKey
(
pluralize
))
{
entities
.
put
(
pluralize
,
metaEntityModel
);
}
}
return
entities
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/EntityModel.java
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/FieldModel.java
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/LiteModelFallback.java
浏览文件 @
2cc4ed8f
...
...
@@ -19,7 +19,7 @@ public class LiteModelFallback implements LiteModelFeignClient {
}
@Override
public
List
<
EntityModel
>
getEntityModel
(
String
system
)
{
public
List
<
Meta
EntityModel
>
getEntityModel
(
String
system
)
{
return
null
;
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/LiteModelFeignClient.java
浏览文件 @
2cc4ed8f
...
...
@@ -24,7 +24,7 @@ public interface LiteModelFeignClient {
EntityModel
getProxyEntityModel
(
@PathVariable
(
"system"
)
String
system
,
@PathVariable
(
"entity"
)
String
entity
);
@GetMapping
(
"/lite/{system}/entities"
)
List
<
EntityModel
>
getEntityModel
(
@PathVariable
(
"system"
)
String
system
);
List
<
Meta
EntityModel
>
getEntityModel
(
@PathVariable
(
"system"
)
String
system
);
@GetMapping
(
"/lite/sysapps"
)
@Cacheable
(
value
=
"syspssystem"
,
key
=
"'row:sys-dst-sys-apps'"
)
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaEntityModel.java
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/Setting.java
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -33,7 +33,7 @@ public class Setting {
public
static
Map
getMap
(
String
configString
)
{
Map
map
=
new
HashMap
();
map
.
put
(
"
t
param"
,
configString
);
map
.
put
(
"param"
,
configString
);
if
(!(
StringUtils
.
isEmpty
(
configString
)))
{
try
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/DSLinkConfig.java
0 → 100644
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
core
.
data
.
model
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
org.springframework.util.StringUtils
;
import
java.util.HashMap
;
import
java.util.Set
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
DSLinkConfig
{
private
String
name
;
private
String
description
;
private
String
type
;
private
String
driverClassName
;
private
String
url
;
private
String
username
;
private
String
password
;
private
String
schema
;
private
Set
<
String
>
usings
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
boolean
isMongodb
()
{
return
"mongodb"
.
equalsIgnoreCase
(
this
.
getType
())||(
this
.
getUrl
()!=
null
&&
this
.
getUrl
().
startsWith
(
"mongodb"
));
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
boolean
isDatabase
()
{
return
(!
StringUtils
.
isEmpty
(
this
.
getDriverClassName
()))&&(!
StringUtils
.
isEmpty
(
this
.
getUrl
()));
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
boolean
isElasticSearch
()
{
return
"elasticsearch"
.
equalsIgnoreCase
(
this
.
getType
())||
"es"
.
equalsIgnoreCase
(
this
.
getType
());
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
boolean
isCassandra
()
{
return
"cassandra"
.
equalsIgnoreCase
(
this
.
getType
());
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoProperty.java
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
core
.
data
.
model
;
import
cn.ibizlab.
core.data.dto
.DataObject
;
import
cn.ibizlab.
util.helper
.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/IDSSettingService.java
浏览文件 @
2cc4ed8f
...
...
@@ -36,7 +36,7 @@ public interface IDSSettingService {
boolean
save
(
DSSetting
et
);
void
saveBatch
(
List
<
DSSetting
>
list
);
Page
<
DSSetting
>
searchDefault
(
DSSettingSearchContext
context
);
DSSetting
initDataSource
(
String
tag
);
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/ModelService.java
浏览文件 @
2cc4ed8f
...
...
@@ -4,6 +4,8 @@ import cn.ibizlab.core.data.domain.DOModel;
import
cn.ibizlab.core.data.lite.*
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
cn.ibizlab.core.data.model.TransUtils
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.Inflector
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -99,13 +101,59 @@ public class ModelService {
@Cacheable
(
value
=
"meta-entities"
,
key
=
"'system:keymap-'+#p0"
)
public
Map
<
String
,
String
>
getEntitiesBySystem
(
String
system
)
throws
Exception
{
public
Map
<
String
,
String
>
getEntitiyIdsBySystem
(
String
system
)
throws
Exception
{
DstSystemModel
dstSystemModel
=
proxy
.
getAllSystemModels
().
get
(
system
);
if
(
dstSystemModel
==
null
)
throw
new
BadRequestAlertException
(
"未找到对应的系统模型"
,
"DstSystem"
,
system
);
system
=
dstSystemModel
.
getPssystemid
();
Map
<
String
,
String
>
entities
=
new
HashMap
<>();
Map
<
String
,
MetaEntityModel
>
entityModels
=
dynamicService
.
getEntities
(
system
);
entityModels
.
entrySet
().
forEach
(
entity
->{
entities
.
put
(
entity
.
getKey
(),
entity
.
getValue
().
getEntityName
());
String
id
=
entity
.
getValue
().
getSystemId
().
concat
(
".domain."
).
concat
(
entity
.
getValue
().
getEntityName
());
entities
.
put
(
entity
.
getKey
(),
id
);
});
List
<
MetaEntityModel
>
liteEntities
=
liteService
.
getEntityModel
(
system
);
if
(!
ObjectUtils
.
isEmpty
(
liteEntities
))
{
liteEntities
.
forEach
(
metaEntityModel
->{
String
id
=
metaEntityModel
.
getSystemId
().
concat
(
".domain."
).
concat
(
metaEntityModel
.
getEntityName
());
if
(!
entities
.
containsKey
(
metaEntityModel
.
getCodeName
()))
entities
.
put
(
metaEntityModel
.
getCodeName
(),
id
);
if
(!
entities
.
containsKey
(
metaEntityModel
.
getCodeName
().
toLowerCase
()))
entities
.
put
(
metaEntityModel
.
getCodeName
().
toLowerCase
(),
id
);
if
(!
entities
.
containsKey
(
metaEntityModel
.
getEntityName
()))
{
entities
.
put
(
metaEntityModel
.
getEntityName
(),
id
);
}
if
(!
entities
.
containsKey
(
metaEntityModel
.
getEntityName
().
toLowerCase
()))
{
entities
.
put
(
metaEntityModel
.
getEntityName
().
toLowerCase
(),
id
);
}
String
pluralize
=
Inflector
.
getInstance
().
pluralize
(
metaEntityModel
.
getCodeName
()).
toLowerCase
();
if
(!
entities
.
containsKey
(
pluralize
))
{
entities
.
put
(
pluralize
,
id
);
}
});
}
File
dir
=
Paths
.
get
(
getModelPath
(),
system
,
"repo"
,
"domain"
).
toFile
();
if
(
dir
.
exists
())
{
for
(
File
file:
dir
.
listFiles
())
{
if
(!
file
.
getName
().
endsWith
(
".json"
))
continue
;
String
entityName
=
file
.
getName
().
replace
(
".json"
,
""
);
String
id
=
system
.
concat
(
".domain."
).
concat
(
entityName
);
if
(!
entities
.
containsKey
(
entityName
.
toLowerCase
()))
entities
.
put
(
entityName
.
toLowerCase
(),
id
);
}
}
return
null
;
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
浏览文件 @
2cc4ed8f
...
...
@@ -2,6 +2,7 @@ package cn.ibizlab.core.data.service.impl;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
...
...
@@ -10,11 +11,13 @@ import java.util.*;
import
cn.ibizlab.core.data.lite.EntityModel
;
import
cn.ibizlab.core.data.lite.LiteStorage
;
import
cn.ibizlab.core.data.model.DSLinkConfig
;
import
cn.ibizlab.core.data.model.POSchema
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
cn.ibizlab.core.data.model.TransUtils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
...
...
@@ -115,10 +118,7 @@ public class DOModelServiceImpl implements IDOModelService {
if
(
Files
.
exists
(
poPath
))
{
try
{
LinkedHashMap
map
=
JSON
.
parseObject
(
Files
.
readAllBytes
(
poPath
),
LinkedHashMap
.
class
);
map
.
keySet
().
forEach
(
dsType
->{
doModel
.
addPOSchema
(
dsType
.
toString
(),
JSON
.
parseObject
(
JSON
.
toJSONString
(
map
.
get
(
dsType
)),
POSchema
.
class
));
});
doModel
.
setPoSchemas
(
JSON
.
parseObject
(
new
String
(
Files
.
readAllBytes
(
poPath
),
StandardCharsets
.
UTF_8
),
new
TypeReference
<
LinkedHashMap
<
String
,
POSchema
>>(){}
));
}
catch
(
IOException
e
)
{
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DSSettingServiceImpl.java
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
core
.
data
.
service
.
impl
;
import
java.io.File
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Map
;
import
java.util.HashSet
;
import
java.util.HashMap
;
import
java.util.Collection
;
import
java.util.Objects
;
import
java.util.Optional
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.Paths
;
import
java.nio.file.StandardOpenOption
;
import
java.util.*
;
import
java.math.BigInteger
;
import
cn.ibizlab.core.data.lite.LiteStorage
;
import
cn.ibizlab.core.data.model.DSLinkConfig
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.TypeReference
;
import
com.baomidou.dynamic.datasource.DynamicRoutingDataSource
;
import
com.baomidou.dynamic.datasource.creator.DataSourceCreator
;
import
com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -29,8 +36,9 @@ import cn.ibizlab.core.data.domain.DSSetting;
import
cn.ibizlab.core.data.filter.DSSettingSearchContext
;
import
cn.ibizlab.core.data.service.IDSSettingService
;
import
cn.ibizlab.util.helper.CachedBeanCopier
;
import
cn.ibizlab.util.helper.DEFieldCacheMap
;
import
org.springframework.util.StringUtils
;
import
javax.sql.DataSource
;
/**
...
...
@@ -41,6 +49,50 @@ import cn.ibizlab.util.helper.DEFieldCacheMap;
public
class
DSSettingServiceImpl
implements
IDSSettingService
{
@Autowired
@Lazy
private
DSSettingServiceImpl
proxy
;
public
Map
<
String
,
DSLinkConfig
>
getAllConfigs
()
{
Path
path
=
Paths
.
get
(
LiteStorage
.
MODEL_PATH
,
"DATASOURCE.json"
);
try
{
Map
<
String
,
DSLinkConfig
>
all
=
new
HashMap
<>();
if
(!
Files
.
exists
(
path
))
{
Files
.
write
(
path
,
JSON
.
toJSONBytes
(
new
LinkedHashMap
<
String
,
DSLinkConfig
>()),
StandardOpenOption
.
CREATE
);
}
else
{
LinkedHashMap
<
String
,
DSLinkConfig
>
map
=
JSON
.
parseObject
(
new
String
(
Files
.
readAllBytes
(
path
),
StandardCharsets
.
UTF_8
),
new
TypeReference
<
LinkedHashMap
<
String
,
DSLinkConfig
>>(){});
map
.
entrySet
().
forEach
(
item
->{
String
id
=
item
.
getKey
();
DSLinkConfig
config
=
item
.
getValue
();
config
.
setName
(
id
);
if
(!
all
.
containsKey
(
id
))
all
.
put
(
id
,
config
);
if
(!
all
.
containsKey
(
id
.
toLowerCase
()))
all
.
put
(
id
.
toLowerCase
(),
config
);
if
(!
ObjectUtils
.
isEmpty
(
config
.
getUsings
()))
{
config
.
getUsings
().
forEach
(
using
->{
if
(!
all
.
containsKey
(
using
))
all
.
put
(
using
,
config
);
if
(!
all
.
containsKey
(
using
.
toLowerCase
()))
all
.
put
(
using
.
toLowerCase
(),
config
);
});
}
});
}
return
all
;
}
catch
(
Exception
e
)
{
throw
new
BadRequestAlertException
(
"读写文件失败"
,
"DSLinkConfig"
,
path
.
toString
());
}
}
@Override
public
boolean
create
(
DSSetting
et
)
{
//代码实现
...
...
@@ -53,6 +105,31 @@ public class DSSettingServiceImpl implements IDSSettingService {
@Override
public
boolean
update
(
DSSetting
et
)
{
//代码实现
synchronized
(
lock
)
{
DynamicRoutingDataSource
ds
=
(
DynamicRoutingDataSource
)
dataSource
;
if
(
check
.
containsKey
(
et
.
getDsId
()))
{
if
(
et
.
isDatabase
())
ds
.
removeDataSource
(
et
.
getDsId
());
check
.
remove
(
et
.
getDsId
());
}
if
(!
et
.
getDsId
().
equals
(
et
.
getDsId
().
toLowerCase
()))
{
check
.
remove
(
et
.
getDsId
().
toLowerCase
());
}
if
(!
ObjectUtils
.
isEmpty
(
et
.
getUsings
()))
{
et
.
getUsings
().
forEach
(
using
->{
check
.
remove
(
using
);
if
(!
using
.
equals
(
using
.
toLowerCase
()))
check
.
remove
(
using
.
toLowerCase
());
});
}
}
buildDS
(
et
);
return
true
;
}
...
...
@@ -70,7 +147,12 @@ public class DSSettingServiceImpl implements IDSSettingService {
@Override
public
DSSetting
get
(
String
key
)
{
DSSetting
et
=
new
DSSetting
();
et
.
setDsId
(
key
);
Map
<
String
,
DSLinkConfig
>
allConfigs
=
proxy
.
getAllConfigs
();
if
(
allConfigs
.
containsKey
(
key
))
et
.
setDSLinkConfig
(
allConfigs
.
get
(
key
));
else
throw
new
BadRequestAlertException
(
"未找到数据源配置信息"
,
"DSSetting"
,
key
);
return
et
;
}
...
...
@@ -95,7 +177,63 @@ public class DSSettingServiceImpl implements IDSSettingService {
}
private
HashMap
<
String
,
DSSetting
>
check
=
new
HashMap
<>();
private
Object
lock
=
new
Object
();
public
DSSetting
initDataSource
(
String
tag
)
{
if
(
check
.
containsKey
(
tag
))
return
check
.
get
(
tag
);
DSSetting
dstDataSource
=
null
;
synchronized
(
lock
)
{
if
(
check
.
containsKey
(
tag
))
return
check
.
get
(
tag
);
dstDataSource
=
this
.
get
(
tag
);
if
((!
tag
.
equalsIgnoreCase
(
dstDataSource
.
getDsId
()))&&
check
.
containsKey
(
dstDataSource
.
getDsId
()))
return
check
.
get
(
dstDataSource
.
getDsId
());
}
return
buildDS
(
dstDataSource
);
}
public
DSSetting
buildDS
(
DSSetting
dstDataSource
)
{
if
(
dstDataSource
!=
null
&&(!
StringUtils
.
isEmpty
(
dstDataSource
.
getDsCfg
())))
{
synchronized
(
lock
)
{
if
(
dstDataSource
.
isDatabase
())
{
DataSourceProperty
dataSourceProperty
=
dstDataSource
.
getDataSourceProperty
();
DynamicRoutingDataSource
ds
=
dataSource
;
DataSource
dataSource
=
druidDataSourceCreator
.
createDataSource
(
dataSourceProperty
);
ds
.
addDataSource
(
dstDataSource
.
getDsId
(),
dataSource
);
}
check
.
put
(
dstDataSource
.
getDsId
(),
dstDataSource
);
if
(!
dstDataSource
.
getDsId
().
equals
(
dstDataSource
.
getDsId
().
toLowerCase
()))
check
.
put
(
dstDataSource
.
getDsId
().
toLowerCase
(),
dstDataSource
);
if
(!
ObjectUtils
.
isEmpty
(
dstDataSource
.
getUsings
()))
{
dstDataSource
.
getUsings
().
forEach
(
using
->{
check
.
put
(
using
,
dstDataSource
);
if
(!
using
.
equals
(
using
.
toLowerCase
()))
check
.
put
(
using
.
toLowerCase
(),
dstDataSource
);
});
}
}
}
return
dstDataSource
;
}
@Autowired
@Lazy
private
DynamicRoutingDataSource
dataSource
;
@Autowired
@Lazy
private
DataSourceCreator
druidDataSourceCreator
;
/**
...
...
ibzdata-core/src/main/java/cn/ibizlab/
core/data/dto
/DataObject.java
→
ibzdata-core/src/main/java/cn/ibizlab/
util/helper
/DataObject.java
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
core
.
data
.
dto
;
package
cn
.
ibizlab
.
util
.
helper
;
import
com.alibaba.fastjson.JSONArray
;
...
...
ibzdata-core/src/main/java/cn/ibizlab/util/helper/Inflector.java
0 → 100644
浏览文件 @
2cc4ed8f
package
cn
.
ibizlab
.
util
.
helper
;
import
java.util.*
;
import
java.util.regex.*
;
/**
*
* 单复数转换类
* 2018年12月30日
*/
public
class
Inflector
{
private
static
final
Pattern
UNDERSCORE_PATTERN_1
=
Pattern
.
compile
(
"([A-Z]+)([A-Z][a-z])"
);
private
static
final
Pattern
UNDERSCORE_PATTERN_2
=
Pattern
.
compile
(
"([a-z\\d])([A-Z])"
);
private
static
List
<
RuleAndReplacement
>
plurals
=
new
ArrayList
<
RuleAndReplacement
>();
private
static
List
<
RuleAndReplacement
>
singulars
=
new
ArrayList
<
RuleAndReplacement
>();
private
static
List
<
String
>
uncountables
=
new
ArrayList
<
String
>();
private
static
Inflector
instance
;
private
Inflector
()
{
initialize
();
}
public
static
void
main
(
String
[]
args
)
{
// TODO Auto-generated method stub
// 单数转复数
System
.
out
.
println
(
Inflector
.
getInstance
().
pluralize
(
"water"
));
System
.
out
.
println
(
Inflector
.
getInstance
().
pluralize
(
"box"
));
System
.
out
.
println
(
Inflector
.
getInstance
().
pluralize
(
"tomato"
));
// 复数转单数
System
.
out
.
println
(
Inflector
.
getInstance
().
singularize
(
"apples"
));
}
private
void
initialize
()
{
plural
(
"$"
,
"s"
);
plural
(
"s$"
,
"s"
);
plural
(
"(ax|test)is$"
,
"$1es"
);
plural
(
"(octop|vir)us$"
,
"$1i"
);
plural
(
"(alias|status)$"
,
"$1es"
);
plural
(
"(bu)s$"
,
"$1es"
);
plural
(
"(buffal|tomat)o$"
,
"$1oes"
);
plural
(
"([ti])um$"
,
"$1a"
);
plural
(
"sis$"
,
"ses"
);
plural
(
"(?:([^f])fe|([lr])f)$"
,
"$1$2ves"
);
plural
(
"(hive)$"
,
"$1s"
);
plural
(
"([^aeiouy]|qu)y$"
,
"$1ies"
);
plural
(
"([^aeiouy]|qu)ies$"
,
"$1y"
);
plural
(
"(x|ch|ss|sh)$"
,
"$1es"
);
plural
(
"(matr|vert|ind)ix|ex$"
,
"$1ices"
);
plural
(
"([m|l])ouse$"
,
"$1ice"
);
plural
(
"(ox)$"
,
"$1es"
);
plural
(
"(quiz)$"
,
"$1zes"
);
singular
(
"s$"
,
""
);
singular
(
"(n)ews$"
,
"$1ews"
);
singular
(
"([ti])a$"
,
"$1um"
);
singular
(
"((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$"
,
"$1$2sis"
);
singular
(
"(^analy)ses$"
,
"$1sis"
);
singular
(
"([^f])ves$"
,
"$1fe"
);
singular
(
"(hive)s$"
,
"$1"
);
singular
(
"(tive)s$"
,
"$1"
);
singular
(
"([lr])ves$"
,
"$1f"
);
singular
(
"([^aeiouy]|qu)ies$"
,
"$1y"
);
singular
(
"(s)eries$"
,
"$1eries"
);
singular
(
"(m)ovies$"
,
"$1ovie"
);
singular
(
"(x|ch|ss|sh)es$"
,
"$1"
);
singular
(
"([m|l])ice$"
,
"$1ouse"
);
singular
(
"(bus)es$"
,
"$1"
);
singular
(
"(o)es$"
,
"$1"
);
singular
(
"(shoe)s$"
,
"$1"
);
singular
(
"(cris|ax|test)es$"
,
"$1is"
);
singular
(
"([octop|vir])i$"
,
"$1us"
);
singular
(
"(alias|status)es$"
,
"$1"
);
singular
(
"^(ox)es"
,
"$1"
);
singular
(
"(vert|ind)ices$"
,
"$1ex"
);
singular
(
"(matr)ices$"
,
"$1ix"
);
singular
(
"(quiz)zes$"
,
"$1"
);
irregular
(
"person"
,
"people"
);
irregular
(
"man"
,
"men"
);
irregular
(
"child"
,
"children"
);
irregular
(
"sex"
,
"sexes"
);
irregular
(
"move"
,
"moves"
);
uncountable
(
new
String
[]
{
"equipment"
,
"information"
,
"rice"
,
"money"
,
"species"
,
"series"
,
"fish"
,
"sheep"
});
}
public
static
Inflector
getInstance
()
{
if
(
instance
==
null
)
{
instance
=
new
Inflector
();
}
return
instance
;
}
public
String
underscore
(
String
camelCasedWord
)
{
String
underscoredWord
=
UNDERSCORE_PATTERN_1
.
matcher
(
camelCasedWord
).
replaceAll
(
"$1_$2"
);
underscoredWord
=
UNDERSCORE_PATTERN_2
.
matcher
(
underscoredWord
).
replaceAll
(
"$1_$2"
);
underscoredWord
=
underscoredWord
.
replace
(
'-'
,
'_'
).
toLowerCase
();
return
underscoredWord
;
}
public
String
pluralize
(
String
word
)
{
if
(
uncountables
.
contains
(
word
.
toLowerCase
()))
{
return
word
;
}
return
replaceWithFirstRule
(
word
,
plurals
);
}
public
String
singularize
(
String
word
)
{
if
(
uncountables
.
contains
(
word
.
toLowerCase
()))
{
return
word
;
}
return
replaceWithFirstRule
(
word
,
singulars
);
}
private
String
replaceWithFirstRule
(
String
word
,
List
<
RuleAndReplacement
>
ruleAndReplacements
)
{
for
(
RuleAndReplacement
rar
:
ruleAndReplacements
)
{
String
rule
=
rar
.
getRule
();
String
replacement
=
rar
.
getReplacement
();
// Return if we find a match.
Matcher
matcher
=
Pattern
.
compile
(
rule
,
Pattern
.
CASE_INSENSITIVE
).
matcher
(
word
);
if
(
matcher
.
find
())
{
return
matcher
.
replaceAll
(
replacement
);
}
}
return
word
;
}
public
String
tableize
(
String
className
)
{
return
pluralize
(
underscore
(
className
));
}
public
String
tableize
(
Class
<?>
klass
)
{
String
className
=
klass
.
getName
().
replace
(
klass
.
getPackage
().
getName
()
+
"."
,
""
);
return
tableize
(
className
);
}
public
static
void
plural
(
String
rule
,
String
replacement
)
{
plurals
.
add
(
0
,
new
RuleAndReplacement
(
rule
,
replacement
));
}
public
static
void
singular
(
String
rule
,
String
replacement
)
{
singulars
.
add
(
0
,
new
RuleAndReplacement
(
rule
,
replacement
));
}
public
static
void
irregular
(
String
singular
,
String
plural
)
{
plural
(
singular
,
plural
);
singular
(
plural
,
singular
);
}
public
static
void
uncountable
(
String
...
words
)
{
for
(
String
word
:
words
)
{
uncountables
.
add
(
word
);
}
}
}
class
RuleAndReplacement
{
private
String
rule
;
private
String
replacement
;
public
RuleAndReplacement
(
String
rule
,
String
replacement
)
{
this
.
rule
=
rule
;
this
.
replacement
=
replacement
;
}
public
String
getReplacement
()
{
return
replacement
;
}
public
void
setReplacement
(
String
replacement
)
{
this
.
replacement
=
replacement
;
}
public
String
getRule
()
{
return
rule
;
}
public
void
setRule
(
String
rule
)
{
this
.
rule
=
rule
;
}
}
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录