Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
7c019597
提交
7c019597
编写于
8月 16, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
11dbd457
变更
29
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
29 个修改的文件
包含
1731 行增加
和
78 行删除
+1731
-78
application-boot.yml
ibzdata-boot/src/main/resources/application-boot.yml
+1
-1
application.yml
ibzdata-boot/src/main/resources/application.yml
+1
-1
DOModel.java
...re/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
+76
-6
DTOModel.java
...e/src/main/java/cn/ibizlab/core/data/domain/DTOModel.java
+22
-0
DataObj.java
...-core/src/main/java/cn/ibizlab/core/data/dto/DataObj.java
+1
-1
RequestData.java
...e/src/main/java/cn/ibizlab/core/data/dto/RequestData.java
+10
-0
EntityModel.java
.../src/main/java/cn/ibizlab/core/data/lite/EntityModel.java
+392
-0
FieldModel.java
...e/src/main/java/cn/ibizlab/core/data/lite/FieldModel.java
+105
-0
LiteModelFallback.java
...ain/java/cn/ibizlab/core/data/lite/LiteModelFallback.java
+22
-0
LiteModelFeignClient.java
.../java/cn/ibizlab/core/data/lite/LiteModelFeignClient.java
+23
-0
LiteStorage.java
.../src/main/java/cn/ibizlab/core/data/lite/LiteStorage.java
+31
-0
MetaEntityModel.java
.../main/java/cn/ibizlab/core/data/lite/MetaEntityModel.java
+122
-0
MetaFieldModel.java
...c/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
+266
-0
RelationshipModel.java
...ain/java/cn/ibizlab/core/data/lite/RelationshipModel.java
+34
-0
Setting.java
...core/src/main/java/cn/ibizlab/core/data/lite/Setting.java
+91
-0
DbDataMapper.java
...c/main/java/cn/ibizlab/core/data/mapper/DbDataMapper.java
+3
-3
POSchema.java
...re/src/main/java/cn/ibizlab/core/data/model/POSchema.java
+104
-21
PojoOption.java
.../src/main/java/cn/ibizlab/core/data/model/PojoOption.java
+45
-5
PojoSchema.java
.../src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
+61
-3
TransUtils.java
.../src/main/java/cn/ibizlab/core/data/model/TransUtils.java
+131
-1
IDataService.java
.../main/java/cn/ibizlab/core/data/service/IDataService.java
+6
-6
ModelService.java
.../main/java/cn/ibizlab/core/data/service/ModelService.java
+38
-0
BaseDataService.java
...va/cn/ibizlab/core/data/service/impl/BaseDataService.java
+8
-4
DOModelServiceImpl.java
...cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
+56
-3
DTOModelServiceImpl.java
...n/ibizlab/core/data/service/impl/DTOModelServiceImpl.java
+63
-3
DbDataServiceImpl.java
.../cn/ibizlab/core/data/service/impl/DbDataServiceImpl.java
+3
-2
DbDataMapper.xml
...re/src/main/resources/mapper/data/DbData/DbDataMapper.xml
+9
-9
DataResource.java
...r-api/src/main/java/cn/ibizlab/api/rest/DataResource.java
+5
-3
DataObject.java
...util/src/main/java/cn/ibizlab/util/helper/DataObject.java
+2
-6
未找到文件。
ibzdata-boot/src/main/resources/application-boot.yml
浏览文件 @
7c019597
...
...
@@ -2,7 +2,7 @@ spring:
datasource
:
username
:
root
password
:
root
url
:
jdbc:mysql://1
27.0.0.1
:3306/a_A_5d9d78509?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&allowMultiQueries=true&useTimezone=true&serverTimezone=GMT%2B8
url
:
jdbc:mysql://1
72.16.100.77
:3306/a_A_5d9d78509?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&useOldAliasMetadataBehavior=true&allowMultiQueries=true&useTimezone=true&serverTimezone=GMT%2B8
isSyncDBSchema
:
false
dynamic
:
druid
:
#以下是全局默认值,可以全局更改
...
...
ibzdata-boot/src/main/resources/application.yml
浏览文件 @
7c019597
spring
:
profiles
:
include
:
sys ,nacos, web-dev, api-dev, dev
include
:
sys ,nacos, web-dev, api-dev, dev
, boot
application
:
name
:
ibzdata
main
:
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
浏览文件 @
7c019597
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.model.POSchema
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
cn.ibizlab.core.data.model.TransUtils
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
...
...
@@ -28,6 +27,7 @@ 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
;
/**
...
...
@@ -106,6 +106,27 @@ public class DOModel extends EntityBase implements Serializable {
@ApiModelProperty
(
"模型"
)
private
String
model
;
public
void
setSchema
(
PojoSchema
schema
)
{
if
(
schema
!=
null
)
{
if
(
StringUtils
.
isEmpty
(
schema
.
getId
()))
schema
.
setId
(
schema
.
getSystem
()+
".domain."
+
schema
.
getName
());
this
.
setId
(
schema
.
getId
());
if
(!
StringUtils
.
isEmpty
(
schema
.
getName
()))
this
.
setName
(
schema
.
getName
());
if
(!
StringUtils
.
isEmpty
(
schema
.
getSystem
()))
this
.
setSystemId
(
schema
.
getSystem
());
if
(!
StringUtils
.
isEmpty
(
schema
.
getTitle
()))
this
.
setTitle
(
schema
.
getTitle
());
if
(!
StringUtils
.
isEmpty
(
schema
.
getDescription
()))
this
.
setDescription
(
schema
.
getDescription
());
if
(!
StringUtils
.
isEmpty
(
schema
.
getPackage
()))
this
.
setPackageName
(
schema
.
getPackage
());
}
this
.
schema
=
schema
;
}
/**
* 存储
*/
...
...
@@ -114,12 +135,23 @@ public class DOModel extends EntityBase implements Serializable {
@ApiModelProperty
(
"存储"
)
private
String
poModels
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getKeyPropertyName
()
{
if
(
this
.
getSchema
()!=
null
&&(!
ObjectUtils
.
isEmpty
(
this
.
schema
.
getKeyMap
().
values
())))
return
this
.
schema
.
getKeyMap
().
values
().
iterator
().
next
();
return
"id"
;
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getKeyFieldName
()
{
return
""
;
if
(
this
.
getSchema
()!=
null
&&(!
ObjectUtils
.
isEmpty
(
this
.
schema
.
getKeyMap
().
keySet
())))
return
this
.
schema
.
getKeyMap
().
keySet
().
iterator
().
next
();
return
"id"
;
}
...
...
@@ -128,9 +160,47 @@ public class DOModel extends EntityBase implements Serializable {
@JsonIgnore
public
String
getDefaultDataSource
()
{
return
""
;
return
getSchema
()!=
null
?
getSchema
().
getDefaultDataSoruce
():
""
;
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
Map
<
String
,
POSchema
>
poSchemas
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
POSchema
getDefaultPOSchema
()
{
return
getPOSchema
(
"default"
);
}
public
DOModel
addPOSchema
(
String
name
,
POSchema
poSchema
)
{
if
(
poSchemas
==
null
)
poSchemas
=
new
LinkedHashMap
<>();
poSchemas
.
put
(
name
,
poSchema
);
return
this
;
}
public
POSchema
getPOSchema
(
String
name
)
{
if
(
poSchemas
==
null
)
poSchemas
=
new
LinkedHashMap
<>();
if
(
poSchemas
.
containsKey
(
name
))
{
return
poSchemas
.
get
(
name
);
}
else
if
(
this
.
getSchema
()!=
null
&&(
"default"
.
equals
(
name
)||
this
.
getSchema
().
getDefaultTableName
().
equals
(
name
)))
{
POSchema
defaultPOSchema
=
TransUtils
.
PojoSchema2PO
(
this
.
getSchema
());
if
(
defaultPOSchema
!=
null
)
{
poSchemas
.
put
(
"default"
,
defaultPOSchema
);
poSchemas
.
put
(
this
.
getSchema
().
getDefaultTableName
(),
defaultPOSchema
);
return
defaultPOSchema
;
}
}
return
null
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DTOModel.java
浏览文件 @
7c019597
...
...
@@ -28,6 +28,7 @@ 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
;
/**
...
...
@@ -98,6 +99,27 @@ public class DTOModel extends EntityBase implements Serializable {
@ApiModelProperty
(
"定义"
)
private
PojoSchema
schema
;
public
void
setSchema
(
PojoSchema
schema
)
{
if
(
schema
!=
null
)
{
if
(
StringUtils
.
isEmpty
(
schema
.
getId
()))
schema
.
setId
(
schema
.
getSystem
()+
".dto."
+
schema
.
getName
());
this
.
setId
(
schema
.
getId
());
if
(!
StringUtils
.
isEmpty
(
schema
.
getName
()))
this
.
setName
(
schema
.
getName
());
if
(!
StringUtils
.
isEmpty
(
schema
.
getSystem
()))
this
.
setSystemId
(
schema
.
getSystem
());
if
(!
StringUtils
.
isEmpty
(
schema
.
getTitle
()))
this
.
setTitle
(
schema
.
getTitle
());
if
(!
StringUtils
.
isEmpty
(
schema
.
getDescription
()))
this
.
setDescription
(
schema
.
getDescription
());
if
(!
StringUtils
.
isEmpty
(
schema
.
getPackage
()))
this
.
setPackageName
(
schema
.
getPackage
());
}
this
.
schema
=
schema
;
}
/**
* 模型
*/
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/dto/DataObj.java
浏览文件 @
7c019597
...
...
@@ -65,7 +65,7 @@ public class DataObj<K,V> extends HashMap<K,V> {
public
Integer
getIntegerValue
(
String
objValue
)
{
return
getIntegerValue
(
objValue
,
Integer
.
MIN_VALUE
);
}
public
int
getIntegerValue
(
String
strParamName
,
int
nDefault
)
{
public
Integer
getIntegerValue
(
String
strParamName
,
Integer
nDefault
)
{
return
DataObject
.
getIntegerValue
(
this
.
get
(
strParamName
),
nDefault
);
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/dto/RequestData.java
浏览文件 @
7c019597
...
...
@@ -44,6 +44,16 @@ public class RequestData<T> extends BaseData
return
this
.
getStringValue
(
"system"
);
}
public
RequestData
setScope
(
String
scope
)
{
return
this
.
set
(
"scope"
,
scope
);
}
public
String
getScope
()
{
return
this
.
getStringValue
(
"scope"
,
"default"
);
}
public
RequestData
setEntity
(
String
entity
)
{
return
this
.
set
(
"entity"
,
entity
);
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/EntityModel.java
0 → 100644
浏览文件 @
7c019597
此差异已折叠。
点击以展开。
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/FieldModel.java
0 → 100644
浏览文件 @
7c019597
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
org.springframework.util.StringUtils
;
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
FieldModel
{
private
String
columnName
;
private
String
codeName
;
private
String
unionName
;
private
String
showName
;
private
String
comment
;
private
MetaFieldModel
field
;
private
RelationshipModel
reference
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getColumnExp
()
{
if
(
field
.
getPhysicalField
()!=
null
&&
1
==
field
.
getPhysicalField
())
{
return
columnName
+
" as \""
+
columnName
.
toUpperCase
()+
"\""
;
}
else
if
(!
StringUtils
.
isEmpty
(
field
.
getExpression
()))
{
return
field
.
getExpression
()+
" as \""
+
columnName
.
toUpperCase
()+
"\""
;
}
return
""
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isPhysicalField
()
{
return
this
.
getField
().
getPhysicalField
()!=
null
&&
1
==
this
.
getField
().
getPhysicalField
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isKeyField
()
{
return
this
.
getField
().
getKeyField
()!=
null
&&
1
==
this
.
getField
().
getKeyField
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isLogicValidField
()
{
return
"LOGICVALID"
.
equals
(
this
.
getField
().
getPredefined
());
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isLastModifyField
()
{
return
"UPDATEDATE"
.
equals
(
this
.
getField
().
getPredefined
());
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isCreateTimeField
()
{
return
"CREATEDATE"
.
equals
(
this
.
getField
().
getPredefined
());
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isUnionKeyField
()
{
return
!
StringUtils
.
isEmpty
(
this
.
getField
().
getUnionKey
());
}
public
String
getPropType
()
{
String
dataType
=
this
.
getField
().
getDataType
().
toUpperCase
();
if
(
dataType
.
indexOf
(
"TEXT"
)>=
0
||
dataType
.
indexOf
(
"CHAR"
)>=
0
||
dataType
.
indexOf
(
"LOB"
)>=
0
)
return
"string"
;
else
if
(
dataType
.
indexOf
(
"TIME"
)>=
0
)
return
"data-time"
;
else
if
(
dataType
.
indexOf
(
"DATE"
)>=
0
)
return
"date"
;
else
if
(
dataType
.
indexOf
(
"NUM"
)>=
0
||
dataType
.
indexOf
(
"FLOAT"
)>=
0
||
dataType
.
indexOf
(
"DOUBLE"
)>=
0
||
dataType
.
indexOf
(
"DECIMAL"
)>=
0
)
return
"number"
;
else
if
(
dataType
.
indexOf
(
"INT"
)==
0
)
return
"integer"
;
return
"string"
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/LiteModelFallback.java
0 → 100644
浏览文件 @
7c019597
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
import
java.util.Map
;
/**
* 实体[MetaModel] 服务对象接口
*/
@Component
public
class
LiteModelFallback
implements
LiteModelFeignClient
{
@Override
public
EntityModel
getProxyEntityModel
(
String
system
,
String
entity
)
{
return
null
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/LiteModelFeignClient.java
0 → 100644
浏览文件 @
7c019597
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.*
;
/**
* 实体[MetaModel] 服务对象接口
*/
@FeignClient
(
value
=
"${ibiz.ref.service.ibzlite-api:ibzlite-api}"
,
contextId
=
"LiteModel"
,
fallback
=
LiteModelFallback
.
class
)
public
interface
LiteModelFeignClient
{
String
defaultToken
=
"Bearer eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJpYnphZG1pbiIsImV4cCI6MTkzMzI0MTkzNywiaWF0IjoxNjE3ODgxOTM3fQ.dFmy-Sx0SlKQcDhbbAs9_bPkbAfy8eRLlGdtl-YZhfU82bCuS4n56ESK8fE0xQqqNJJM87X7U9CnWxRk9z9Xh_dqch-GW8qPj5s25cFsR96V2Ke-6XirCnS-fTRfY9ZIcqVT2gvFUE1MiSbEC-7SPgxcGrNZv0bLzmlW3drlSyQ"
;
@GetMapping
(
"/lite/{system}/entitys/{entity}"
)
@Cacheable
(
value
=
"entitymodel"
,
key
=
"'row:'+#p0+'.'+#p1"
)
EntityModel
getProxyEntityModel
(
@PathVariable
(
"system"
)
String
system
,
@PathVariable
(
"entity"
)
String
entity
);
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/LiteStorage.java
0 → 100644
浏览文件 @
7c019597
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
@Component
public
class
LiteStorage
{
private
static
LiteModelFeignClient
service
;
public
static
void
setLiteModelService
(
LiteModelFeignClient
service
)
{
if
(
LiteStorage
.
service
==
null
)
LiteStorage
.
service
=
service
;
}
public
static
LiteModelFeignClient
getLiteModelService
()
{
return
service
;
}
@Autowired
private
LiteModelFeignClient
client
;
@PostConstruct
public
void
init
(){
LiteStorage
.
setLiteModelService
(
client
);
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaEntityModel.java
0 → 100644
浏览文件 @
7c019597
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
java.sql.Timestamp
;
/**
* 实体[实体]
*/
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
MetaEntityModel
{
/**
* 标识
*/
@JSONField
(
name
=
"entity_id"
)
@JsonProperty
(
"entity_id"
)
private
String
entityId
;
/**
* 实体名
*/
@JSONField
(
name
=
"entity_name"
)
@JsonProperty
(
"entity_name"
)
private
String
entityName
;
/**
* 逻辑名称
*/
@JSONField
(
name
=
"logic_name"
)
@JsonProperty
(
"logic_name"
)
private
String
logicName
;
/**
* 代码名称
*/
@JSONField
(
name
=
"code_name"
)
@JsonProperty
(
"code_name"
)
private
String
codeName
;
/**
* 表名称
*/
@JSONField
(
name
=
"table_name"
)
@JsonProperty
(
"table_name"
)
private
String
tableName
;
/**
* 系统标识
*/
@JSONField
(
name
=
"system_id"
)
@JsonProperty
(
"system_id"
)
private
String
systemId
;
/**
* 系统
*/
@JSONField
(
name
=
"system_name"
)
@JsonProperty
(
"system_name"
)
private
String
systemName
;
/**
* 数据源标识
*/
@JSONField
(
name
=
"ds_id"
)
@JsonProperty
(
"ds_id"
)
private
String
dsId
;
/**
* 数据源
*/
@JSONField
(
name
=
"ds_name"
)
@JsonProperty
(
"ds_name"
)
private
String
dsName
;
/**
* 模块标识
*/
@JSONField
(
name
=
"module_id"
)
@JsonProperty
(
"module_id"
)
private
String
moduleId
;
/**
* 模块
*/
@JSONField
(
name
=
"module_name"
)
@JsonProperty
(
"module_name"
)
private
String
moduleName
;
/**
* 扩展参数
*/
@JSONField
(
name
=
"ext_params"
)
@JsonProperty
(
"ext_params"
)
private
String
extParams
;
/**
* 排序
*/
@JSONField
(
name
=
"show_order"
)
@JsonProperty
(
"show_order"
)
private
Integer
showOrder
;
/**
* 创建时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
locale
=
"zh"
,
timezone
=
"GMT+8"
)
@JSONField
(
name
=
"createdate"
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonProperty
(
"createdate"
)
private
Timestamp
createdate
;
/**
* 最后修改时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
locale
=
"zh"
,
timezone
=
"GMT+8"
)
@JSONField
(
name
=
"updatedate"
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonProperty
(
"updatedate"
)
private
Timestamp
updatedate
;
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/MetaFieldModel.java
0 → 100644
浏览文件 @
7c019597
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
java.sql.Timestamp
;
/**
* 实体[属性]
*/
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties
(
value
=
"handler"
)
@ApiModel
(
"属性"
)
public
class
MetaFieldModel
{
/**
* 属性标识
*/
@JSONField
(
name
=
"field_id"
)
@JsonProperty
(
"field_id"
)
@ApiModelProperty
(
"属性标识"
)
private
String
fieldId
;
/**
* 属性名称
*/
@JSONField
(
name
=
"field_name"
)
@JsonProperty
(
"field_name"
)
@ApiModelProperty
(
"属性名称"
)
private
String
fieldName
;
/**
* 代码名称
*/
@JSONField
(
name
=
"code_name"
)
@JsonProperty
(
"code_name"
)
@ApiModelProperty
(
"代码名称"
)
private
String
codeName
;
/**
* 实体标识
*/
@JSONField
(
name
=
"entity_id"
)
@JsonProperty
(
"entity_id"
)
@ApiModelProperty
(
"实体标识"
)
private
String
entityId
;
/**
* 实体名称
*/
@JSONField
(
name
=
"entity_name"
)
@JsonProperty
(
"entity_name"
)
@ApiModelProperty
(
"实体名称"
)
private
String
entityName
;
/**
* 实体代码名称
*/
@JSONField
(
name
=
"entity_code_name"
)
@JsonProperty
(
"entity_code_name"
)
@ApiModelProperty
(
"实体代码名称"
)
private
String
entityCodeName
;
/**
* 系统
*/
@JSONField
(
name
=
"system_id"
)
@JsonProperty
(
"system_id"
)
@ApiModelProperty
(
"系统"
)
private
String
systemId
;
/**
* 属性逻辑名
*/
@JSONField
(
name
=
"field_logic_name"
)
@JsonProperty
(
"field_logic_name"
)
@ApiModelProperty
(
"属性逻辑名"
)
private
String
fieldLogicName
;
/**
* 属性全路径名称
*/
@JSONField
(
name
=
"field_uni_name"
)
@JsonProperty
(
"field_uni_name"
)
@ApiModelProperty
(
"属性全路径名称"
)
private
String
fieldUniName
;
/**
* 显示名称
*/
@JSONField
(
name
=
"field_show_name"
)
@JsonProperty
(
"field_show_name"
)
@ApiModelProperty
(
"显示名称"
)
private
String
fieldShowName
;
/**
* 引用属性标识
*/
@JSONField
(
name
=
"ref_field_id"
)
@JsonProperty
(
"ref_field_id"
)
@ApiModelProperty
(
"引用属性标识"
)
private
String
refFieldId
;
/**
* 引用属性名称
*/
@JSONField
(
name
=
"ref_field_name"
)
@JsonProperty
(
"ref_field_name"
)
@ApiModelProperty
(
"引用属性名称"
)
private
String
refFieldName
;
/**
* 引用关系标识
*/
@JSONField
(
name
=
"relation_id"
)
@JsonProperty
(
"relation_id"
)
@ApiModelProperty
(
"引用关系标识"
)
private
String
relationId
;
/**
* 引用关系
*/
@JSONField
(
name
=
"relation_name"
)
@JsonProperty
(
"relation_name"
)
@ApiModelProperty
(
"引用关系"
)
private
String
relationName
;
/**
* 关系代码
*/
@JSONField
(
name
=
"relation_code_name"
)
@JsonProperty
(
"relation_code_name"
)
@ApiModelProperty
(
"关系代码"
)
private
String
relationCodeName
;
/**
* 引用实体
*/
@JSONField
(
name
=
"ref_entity_name"
)
@JsonProperty
(
"ref_entity_name"
)
@ApiModelProperty
(
"引用实体"
)
private
String
refEntityName
;
/**
* 主键
*/
@JSONField
(
name
=
"key_field"
)
@JsonProperty
(
"key_field"
)
@ApiModelProperty
(
"主键"
)
private
Integer
keyField
;
/**
* 主信息
*/
@JSONField
(
name
=
"major_field"
)
@JsonProperty
(
"major_field"
)
@ApiModelProperty
(
"主信息"
)
private
Integer
majorField
;
/**
* 联合主键
*/
@JSONField
(
name
=
"union_key"
)
@JsonProperty
(
"union_key"
)
@ApiModelProperty
(
"联合主键"
)
private
String
unionKey
;
/**
* 属性类型
*/
@JSONField
(
name
=
"field_type"
)
@JsonProperty
(
"field_type"
)
@ApiModelProperty
(
"属性类型"
)
private
String
fieldType
;
/**
* 预定义类型
*/
@JSONField
(
name
=
"predefined"
)
@JsonProperty
(
"predefined"
)
@ApiModelProperty
(
"预定义类型"
)
private
String
predefined
;
/**
* 数据字典
*/
@JSONField
(
name
=
"dict"
)
@JsonProperty
(
"dict"
)
@ApiModelProperty
(
"数据字典"
)
private
String
dict
;
/**
* 允许为空
*/
@JSONField
(
name
=
"nullable"
)
@JsonProperty
(
"nullable"
)
@ApiModelProperty
(
"允许为空"
)
private
Integer
nullable
;
/**
* 物理属性
*/
@JSONField
(
name
=
"physical_field"
)
@JsonProperty
(
"physical_field"
)
@ApiModelProperty
(
"物理属性"
)
private
Integer
physicalField
;
/**
* 数据类型
*/
@JSONField
(
name
=
"data_type"
)
@JsonProperty
(
"data_type"
)
@ApiModelProperty
(
"数据类型"
)
private
String
dataType
;
/**
* 长度
*/
@JSONField
(
name
=
"data_length"
)
@JsonProperty
(
"data_length"
)
@ApiModelProperty
(
"长度"
)
private
Integer
dataLength
;
/**
* 精度
*/
@JSONField
(
name
=
"data_preci"
)
@JsonProperty
(
"data_preci"
)
@ApiModelProperty
(
"精度"
)
private
Integer
dataPreci
;
/**
* 逻辑表达式
*/
@JSONField
(
name
=
"expression"
)
@JsonProperty
(
"expression"
)
@ApiModelProperty
(
"逻辑表达式"
)
private
String
expression
;
/**
* 扩展属性
*/
@JSONField
(
name
=
"extension_field"
)
@JsonProperty
(
"extension_field"
)
@ApiModelProperty
(
"扩展属性"
)
private
Integer
extensionField
;
/**
* 审计
*/
@JSONField
(
name
=
"is_enable_audit"
)
@JsonProperty
(
"is_enable_audit"
)
@ApiModelProperty
(
"审计"
)
private
Integer
isEnableAudit
;
/**
* 排序
*/
@JSONField
(
name
=
"show_order"
)
@JsonProperty
(
"show_order"
)
@ApiModelProperty
(
"排序"
)
private
Integer
showOrder
;
/**
* 创建时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
locale
=
"zh"
,
timezone
=
"GMT+8"
)
@JSONField
(
name
=
"createdate"
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonProperty
(
"createdate"
)
@ApiModelProperty
(
"创建时间"
)
private
Timestamp
createdate
;
/**
* 最后修改时间
*/
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
,
locale
=
"zh"
,
timezone
=
"GMT+8"
)
@JSONField
(
name
=
"updatedate"
,
format
=
"yyyy-MM-dd HH:mm:ss"
)
@JsonProperty
(
"updatedate"
)
@ApiModelProperty
(
"最后修改时间"
)
private
Timestamp
updatedate
;
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/RelationshipModel.java
0 → 100644
浏览文件 @
7c019597
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
java.util.Map
;
@Getter
@Setter
@NoArgsConstructor
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
RelationshipModel
{
private
String
codeName
;
private
String
entityName
;
private
String
entityCodeName
;
private
String
entityLogicName
;
private
String
systemId
;
private
String
dataSourceName
;
private
String
tableName
;
private
String
entityId
;
private
Map
relation
;
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/Setting.java
0 → 100644
浏览文件 @
7c019597
package
cn
.
ibizlab
.
core
.
data
.
lite
;
import
cn.ibizlab.util.domain.EntityBase
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
org.springframework.util.StringUtils
;
import
java.io.IOException
;
import
java.io.StringReader
;
import
java.util.*
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
Setting
{
private
String
property
;
private
String
value
;
public
static
String
getValue
(
String
configString
,
String
propertyName
)
{
return
DataObject
.
getStringValue
(
getMap
(
configString
).
get
(
propertyName
),
""
);
}
public
static
<
T
extends
EntityBase
>
T
getEntity
(
String
configString
,
T
entityBase
)
{
if
(
entityBase
!=
null
)
{
Map
map
=
getMap
(
configString
);
map
.
keySet
().
forEach
(
key
->{
entityBase
.
set
(
key
.
toString
(),
map
.
get
(
key
));
});
}
return
entityBase
;
}
public
static
Map
getMap
(
String
configString
)
{
Map
map
=
new
HashMap
();
map
.
put
(
"param"
,
configString
);
if
(!(
StringUtils
.
isEmpty
(
configString
)))
{
try
{
Object
obj
=
JSON
.
parse
(
configString
);
if
(
obj
==
null
)
return
map
;
else
if
(
obj
instanceof
JSONArray
)
{
List
<
Setting
>
settings
=
JSONArray
.
parseArray
(
configString
,
Setting
.
class
);
for
(
Setting
setting:
settings
)
map
.
put
(
setting
.
getProperty
(),
setting
.
getValue
());
}
else
if
(
obj
instanceof
JSONObject
)
{
JSONObject
jo
=
(
JSONObject
)
obj
;
jo
.
keySet
().
forEach
(
key
->{
map
.
put
(
key
,
jo
.
get
(
key
));
});
}
}
catch
(
Exception
ex
)
{
if
(
configString
.
indexOf
(
"="
)>
0
)
{
Properties
proper
=
new
Properties
();
try
{
proper
.
load
(
new
StringReader
(
configString
));
//把字符串转为reader
}
catch
(
IOException
e
)
{
}
Enumeration
enum1
=
proper
.
propertyNames
();
while
(
enum1
.
hasMoreElements
())
{
String
strKey
=
(
String
)
enum1
.
nextElement
();
String
strValue
=
proper
.
getProperty
(
strKey
);
map
.
put
(
strKey
,
strValue
);
}
}
}
}
return
map
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/mapper/DbDataMapper.java
浏览文件 @
7c019597
...
...
@@ -21,10 +21,10 @@ public interface DbDataMapper {
int
save
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
int
insert
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
int
insert
Data
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
int
update
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
int
update
Data
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
int
remove
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
int
remove
Data
(
@Param
(
"schema"
)
POSchema
schema
,
@Param
(
"data"
)
BaseData
data
);
}
\ No newline at end of file
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/POSchema.java
浏览文件 @
7c019597
...
...
@@ -29,10 +29,32 @@ public class POSchema {
private
String
defaultDataSource
;
private
String
logicVal
;
private
String
logicDelVal
;
private
List
<
Column
>
columns
;
public
POSchema
addColumn
(
Column
column
)
{
if
(
columns
==
null
)
columns
=
new
ArrayList
<>();
columns
.
add
(
column
);
if
(
columnMaps
!=
null
)
columnMaps
=
null
;
return
this
;
}
private
List
<
ForeignKeyConstraint
>
foreignKeyConstraints
;
public
POSchema
addForeignKeyConstraint
(
ForeignKeyConstraint
foreignKeyConstraint
)
{
if
(
foreignKeyConstraints
==
null
)
foreignKeyConstraints
=
new
ArrayList
<>();
foreignKeyConstraints
.
add
(
foreignKeyConstraint
);
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Map
<
String
,
Column
>
columnMaps
;
...
...
@@ -214,7 +236,7 @@ public class POSchema {
@JSONField
(
serialize
=
false
)
public
boolean
isPrimaryKey
()
{
return
this
.
getConstraints
()!=
null
&&
this
.
getConstraints
().
getPrimaryKey
();
return
this
.
getConstraints
()!=
null
&&
this
.
getConstraints
().
getPrimaryKey
()
!=
null
&&
this
.
getConstraints
().
getPrimaryKey
()==
true
;
}
@JsonIgnore
...
...
@@ -249,10 +271,33 @@ public class POSchema {
@JSONField
(
serialize
=
false
)
public
boolean
isText
()
{
return
this
.
getType
().
toUpperCase
().
indexOf
(
"TEXT"
)>=
0
||
this
.
getType
().
toUpperCase
().
indexOf
(
"CHAR"
)>=
0
;
return
this
.
getType
().
toUpperCase
().
indexOf
(
"TEXT"
)>=
0
||
this
.
getType
().
toUpperCase
().
indexOf
(
"CHAR"
)>=
0
||
this
.
getType
().
toUpperCase
().
indexOf
(
"LOB"
)>=
0
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isNumber
()
{
return
this
.
getType
().
toUpperCase
().
indexOf
(
"NUM"
)>=
0
||
this
.
getType
().
toUpperCase
().
indexOf
(
"FLOAT"
)>=
0
||
this
.
getType
().
toUpperCase
().
indexOf
(
"DOUBLE"
)>=
0
||
this
.
getType
().
toUpperCase
().
indexOf
(
"DECIMAL"
)>=
0
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isInt
()
{
return
this
.
getType
().
toUpperCase
().
indexOf
(
"INT"
)==
0
;
}
private
Constraints
constraints
;
public
Constraints
getConstraints
(
boolean
createWhenNotExist
)
{
if
(
createWhenNotExist
)
{
if
(
constraints
==
null
)
constraints
=
new
Constraints
();
}
return
constraints
;
}
}
@Getter
...
...
@@ -359,20 +404,47 @@ public class POSchema {
if
(
isLogicValid
())
{
String
defaultVal
=
this
.
getLogicValidColumn
().
getDefaultValue
();
if
(
StringUtils
.
isEmpty
(
defaultVal
))
defaultVal
=
"1"
;
sql
+=
" where t."
+
this
.
getLogicValidColumn
().
getName
()+
"="
;
if
(
this
.
getLogicValidColumn
().
isText
())
sql
+=(
"'"
+
defaultVal
+
"'"
);
else
sql
+=(
defaultVal
+
" "
);
sql
+=
" where t."
+
this
.
getLogicValidCond
();
}
defaultQueryScript
.
setBody
(
sql
);
}
return
defaultQueryScript
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
logicValidCond
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
logicValidDelCond
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
synchronized
String
getLogicValidCond
()
{
if
(
isLogicValid
()&&
logicValidCond
==
null
)
{
if
(
logicVal
==
null
)
logicVal
=
"1"
;
if
(
logicDelVal
==
null
)
logicDelVal
=
"0"
;
logicValidCond
=
this
.
getLogicValidColumn
().
getName
()+
"="
;
logicValidDelCond
=
this
.
getLogicValidColumn
().
getName
()+
"="
;
if
(
this
.
getLogicValidColumn
().
isText
())
{
logicValidCond
+=
(
"'"
+
logicVal
+
"'"
);
logicValidDelCond
+=
(
"'"
+
logicDelVal
+
"'"
);
}
else
{
logicValidCond
+=
(
logicVal
+
" "
);
logicValidDelCond
+=
(
logicDelVal
+
" "
);
}
}
else
logicValidCond
=
""
;
return
logicValidCond
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
String
baseColumns
;
...
...
@@ -401,18 +473,29 @@ public class POSchema {
return
baseColumns
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Script
getDefaultInsertScript
()
{
Script
defaultInsertScrip
=
new
Script
();
defaultInsertScrip
.
setName
(
"insert"
);
defaultInsertScrip
.
setVendorProvider
(
"mysql,oracle,postgresql"
);
String
sql
=
""
;
defaultInsertScrip
.
setBody
(
sql
);
return
defaultInsertScrip
;
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
boolean
built
=
false
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
synchronized
POSchema
build
()
{
if
(!
built
)
{
getColumnMaps
();
getBaseColumns
();
getLastModifyField
();
getCreateTimeColumn
();
getLogicValidColumn
();
getLogicValidCond
();
getTenantColumn
();
built
=
true
;
}
return
this
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoOption.java
浏览文件 @
7c019597
...
...
@@ -38,6 +38,22 @@ public class PojoOption extends DataObj
return
this
.
set
(
"name"
,
name
);
}
public
String
getSystem
(){
return
this
.
getStringValue
(
"system_id"
,
this
.
getStringValue
(
"system_name"
,
this
.
getStringValue
(
"system"
)));
}
public
String
getPackage
(){
return
this
.
getStringValue
(
"module_name"
,
this
.
getStringValue
(
"module"
,
this
.
getStringValue
(
"moduleid"
)));
}
public
String
getTableName
(){
return
this
.
getStringValue
(
"table_name"
,
getName
());
}
public
String
getDefaultDataSoruce
(){
return
this
.
getStringValue
(
"ds_name"
,
this
.
getSystem
()+
"-master"
);
}
public
Boolean
isLogicValid
()
{
return
this
.
getBooleanValue
(
"logicValid"
);
...
...
@@ -66,7 +82,7 @@ public class PojoOption extends DataObj
}
public
String
getFieldName
()
{
return
this
.
getStringValue
(
"field_name"
);
return
this
.
getStringValue
(
"field_name"
,
getName
()
);
}
public
PojoOption
setFieldName
(
String
code
)
{
...
...
@@ -82,6 +98,16 @@ public class PojoOption extends DataObj
return
this
.
set
(
"relation_name"
,
relationName
);
}
public
String
getRelationCodeName
()
{
return
this
.
getStringValue
(
"relation_code_name"
);
}
public
PojoOption
setRelationCodeName
(
String
relationCodeName
)
{
return
this
.
set
(
"relation_code_name"
,
relationCodeName
);
}
public
String
getRefEntityName
()
{
return
this
.
getStringValue
(
"ref_entity_name"
);
}
...
...
@@ -90,6 +116,14 @@ public class PojoOption extends DataObj
return
this
.
set
(
"ref_entity_name"
,
refEntityName
);
}
public
String
getRefTableName
()
{
return
this
.
getStringValue
(
"ref_table_name"
,
getRefEntityName
());
}
public
PojoOption
setRefTableName
(
String
refTableName
)
{
return
this
.
set
(
"ref_table_name"
,
refTableName
);
}
public
String
getRefFieldName
()
{
return
this
.
getStringValue
(
"ref_field_name"
);
}
...
...
@@ -123,7 +157,7 @@ public class PojoOption extends DataObj
}
public
Boolean
isPhysicalField
()
{
return
this
.
getBooleanValue
(
"physical_field"
,
t
rue
);
return
this
.
getBooleanValue
(
"physical_field"
,
t
his
.
getBooleanValue
(
"persisent"
,
true
)
);
}
public
PojoOption
setPhysicalField
(
Boolean
physicalField
)
{
...
...
@@ -131,7 +165,7 @@ public class PojoOption extends DataObj
}
public
Boolean
isNullable
()
{
return
this
.
getBooleanValue
(
"nullable"
,
true
);
return
this
.
getBooleanValue
(
"nullable"
,
!
this
.
getBooleanValue
(
"required"
,
true
)
);
}
public
PojoOption
setNullable
(
Boolean
nullable
)
{
...
...
@@ -161,7 +195,13 @@ public class PojoOption extends DataObj
public
PojoOption
setDict
(
String
dict
)
{
return
this
.
set
(
"dict"
,
dict
);
}
public
String
getDefaultValue
()
{
return
this
.
getStringValue
(
"defaultValue"
);
}
public
PojoOption
setDefaultValue
(
String
defaultValue
)
{
return
this
.
set
(
"defaultValue"
,
defaultValue
);
}
public
String
getDataType
()
{
return
this
.
getStringValue
(
"data_type"
);
}
...
...
@@ -171,7 +211,7 @@ public class PojoOption extends DataObj
}
public
Integer
getDataLength
()
{
return
this
.
getIntegerValue
(
"data_length"
);
return
this
.
getIntegerValue
(
"data_length"
,
this
.
getIntegerValue
(
"length"
,
null
)
);
}
public
PojoOption
setDataLength
(
Integer
dataLength
)
{
...
...
@@ -179,7 +219,7 @@ public class PojoOption extends DataObj
}
public
Integer
getDataPreci
()
{
return
this
.
getIntegerValue
(
"data_preci"
);
return
this
.
getIntegerValue
(
"data_preci"
,
this
.
getIntegerValue
(
"precision"
,
this
.
getIntegerValue
(
"preci"
,
null
))
);
}
public
PojoOption
setDataPreci
(
Integer
dataPreci
)
{
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
浏览文件 @
7c019597
...
...
@@ -57,6 +57,34 @@ public class PojoSchema {
return
this
;
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getSystem
()
{
return
this
.
getOptions
()==
null
?
""
:
this
.
getOptions
().
getSystem
();
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getDefaultDataSoruce
()
{
return
this
.
getOptions
()==
null
?
""
:
this
.
getOptions
().
getDefaultDataSoruce
();
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getDefaultTableName
()
{
return
this
.
getOptions
()==
null
?
""
:
this
.
getOptions
().
getTableName
();
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getPackage
()
{
return
this
.
getOptions
()==
null
?
""
:
this
.
getOptions
().
getSystem
();
}
@JSONField
(
ordinal
=
3
)
...
...
@@ -132,7 +160,7 @@ public class PojoSchema {
return
properties
;
}
public
PojoSchema
addPropert
ies
(
String
name
,
PojoSchema
property
)
public
PojoSchema
addPropert
y
(
String
name
,
PojoSchema
property
)
{
if
(
StringUtils
.
isEmpty
(
name
))
return
this
;
...
...
@@ -175,6 +203,36 @@ public class PojoSchema {
private
Integer
maxProperties
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Map
<
String
,
String
>
keyMap
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
synchronized
Map
<
String
,
String
>
getKeyMap
()
{
if
(
Type
.
object
.
getCode
().
equals
(
this
.
type
))
{
if
(
keyMap
==
null
)
{
keyMap
=
new
LinkedHashMap
<>();
getProperties
().
values
().
forEach
(
sub
->{
if
(
sub
.
getOptions
().
isKeyField
()&&
sub
.
getOptions
().
isPhysicalField
())
keyMap
.
put
(
sub
.
getOptions
().
getFieldName
(),
sub
.
getName
());
});
if
(
keyMap
.
isEmpty
())
{
getProperties
().
values
().
forEach
(
sub
->{
if
(
sub
.
getOptions
().
isUnionKeyField
()&&
sub
.
getOptions
().
isPhysicalField
())
keyMap
.
put
(
sub
.
getOptions
().
getFieldName
(),
sub
.
getName
());
});
}
}
}
return
keyMap
;
}
//// array
...
...
@@ -225,8 +283,8 @@ public class PojoSchema {
public
static
void
main
(
String
[]
args
)
{
PojoSchema
schema
=
new
PojoSchema
().
setType
(
"object"
).
setRef
(
"#/definitions/entity"
);
PojoSchema
def
=
new
PojoSchema
();
def
.
setType
(
"object"
).
setTitle
(
"部门"
).
addPropert
ies
(
"deptCode"
,
new
PojoSchema
().
setType
(
"string"
).
setTitle
(
"部门编码"
))
.
addPropert
ies
(
"deptName"
,
new
PojoSchema
().
setType
(
"string"
).
setTitle
(
"部门名称"
)).
addProperties
(
"parent"
,
def
);
def
.
setType
(
"object"
).
setTitle
(
"部门"
).
addPropert
y
(
"deptCode"
,
new
PojoSchema
().
setType
(
"string"
).
setTitle
(
"部门编码"
))
.
addPropert
y
(
"deptName"
,
new
PojoSchema
().
setType
(
"string"
).
setTitle
(
"部门名称"
)).
addProperty
(
"parent"
,
def
);
System
.
out
.
println
(
JSON
.
toJSONString
(
schema
));
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/TransUtils.java
浏览文件 @
7c019597
此差异已折叠。
点击以展开。
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/IDataService.java
浏览文件 @
7c019597
...
...
@@ -17,11 +17,11 @@ public interface IDataService
default
ResponseData
call
(
String
system
,
String
entity
,
String
method
,
RequestData
requestData
)
{
return
call
(
system
,
entity
,
method
,
""
,
requestData
);
return
call
(
system
,
""
,
entity
,
method
,
""
,
requestData
);
}
default
ResponseData
call
(
RequestData
requestData
)
{
return
call
(
getDOModel
(
requestData
.
getSystem
(),
requestData
.
getEntity
()),
requestData
.
getMethod
(),
requestData
.
getDataSource
(),
requestData
);
return
call
(
getDOModel
(
requestData
.
getSystem
(),
requestData
.
getEntity
()),
requestData
.
get
Scope
(),
requestData
.
get
Method
(),
requestData
.
getDataSource
(),
requestData
);
}
default
boolean
create
(
String
system
,
String
entity
,
BaseData
et
)
{
...
...
@@ -89,7 +89,7 @@ public interface IDataService
DOModel
getDOModel
(
String
system
,
String
entity
);
ResponseData
call
(
DOModel
model
,
String
method
,
String
datasource
,
RequestData
requestData
);
ResponseData
call
(
DOModel
model
,
String
scope
,
String
method
,
String
datasource
,
RequestData
requestData
);
boolean
create
(
DOModel
model
,
String
datasource
,
BaseData
et
);
void
createBatch
(
DOModel
model
,
String
datasource
,
List
<
BaseData
>
list
);
...
...
@@ -113,10 +113,10 @@ public interface IDataService
return
list
(
model
,
"default"
,
datasource
,
context
);
}
default
ResponseData
call
(
String
system
,
String
entity
,
String
method
,
String
datasource
,
RequestData
requestData
)
default
ResponseData
call
(
String
system
,
String
scope
,
String
entity
,
String
method
,
String
datasource
,
RequestData
requestData
)
{
requestData
.
setSystem
(
system
).
setEntity
(
entity
).
setMethod
(
method
).
setDataSource
(
datasource
);
return
call
(
getDOModel
(
system
,
entity
),
method
,
datasource
,
requestData
);
requestData
.
setSystem
(
system
).
set
Scope
(
scope
).
set
Entity
(
entity
).
setMethod
(
method
).
setDataSource
(
datasource
);
return
call
(
getDOModel
(
system
,
entity
),
scope
,
method
,
datasource
,
requestData
);
}
default
boolean
create
(
String
system
,
String
entity
,
String
datasource
,
BaseData
et
)
{
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/ModelService.java
0 → 100644
浏览文件 @
7c019597
package
cn
.
ibizlab
.
core
.
data
.
service
;
import
cn.ibizlab.core.data.domain.DOModel
;
import
cn.ibizlab.core.data.lite.EntityModel
;
import
cn.ibizlab.core.data.lite.LiteStorage
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
cn.ibizlab.core.data.model.TransUtils
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.nio.file.StandardOpenOption
;
import
java.util.List
;
@Service
@Slf4j
public
class
ModelService
{
@Value
(
"${ibiz.model.path:/app/file/model/}"
)
private
String
modelPath
;
@Autowired
private
IDOModelService
doModelService
;
public
DOModel
getDOModel
(
String
system
,
String
entity
)
{
return
doModelService
.
get
(
system
+
".domain."
+
entity
);
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/BaseDataService.java
浏览文件 @
7c019597
...
...
@@ -6,6 +6,7 @@ import cn.ibizlab.core.data.dto.DbDataQuery;
import
cn.ibizlab.core.data.dto.RequestData
;
import
cn.ibizlab.core.data.dto.ResponseData
;
import
cn.ibizlab.core.data.service.IDataService
;
import
cn.ibizlab.core.data.service.ModelService
;
import
cn.ibizlab.util.filter.SearchContextBase
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -30,7 +31,7 @@ public class BaseDataService implements IDataService {
@Override
public
DOModel
getDOModel
(
String
system
,
String
entity
)
{
return
null
;
return
modelService
.
getDOModel
(
system
,
entity
)
;
}
@Autowired
...
...
@@ -39,6 +40,9 @@ public class BaseDataService implements IDataService {
@Autowired
private
MongoDataServiceImpl
mongoProxyService
;
@Autowired
private
ModelService
modelService
;
public
IDataService
getProxyService
(
String
datasource
)
{
if
(
datasource
.
indexOf
(
"mongo"
)>
0
)
...
...
@@ -49,7 +53,7 @@ public class BaseDataService implements IDataService {
@Override
public
ResponseData
call
(
DOModel
model
,
String
method
,
String
datasource
,
RequestData
requestBody
)
public
ResponseData
call
(
DOModel
model
,
String
scope
,
String
method
,
String
datasource
,
RequestData
requestBody
)
{
if
(
"create"
.
equalsIgnoreCase
(
method
))
{
...
...
@@ -76,7 +80,7 @@ public class BaseDataService implements IDataService {
{
Serializable
key
=
requestBody
.
getKey
();
if
(
ObjectUtils
.
isEmpty
(
key
))
key
=
requestBody
.
getBaseData
().
getSerializableValue
(
model
.
getKey
Field
Name
());
key
=
requestBody
.
getBaseData
().
getSerializableValue
(
model
.
getKey
Property
Name
());
if
(
ObjectUtils
.
isEmpty
(
key
))
return
ResponseData
.
error
(
400
,
"key 没有输入"
);
if
(
remove
(
model
,
datasource
,
key
))
...
...
@@ -88,7 +92,7 @@ public class BaseDataService implements IDataService {
{
Serializable
key
=
requestBody
.
getKey
();
if
(
ObjectUtils
.
isEmpty
(
key
))
key
=
requestBody
.
getBaseData
().
getSerializableValue
(
model
.
getKey
Field
Name
());
key
=
requestBody
.
getBaseData
().
getSerializableValue
(
model
.
getKey
Property
Name
());
if
(
ObjectUtils
.
isEmpty
(
key
))
return
ResponseData
.
error
(
400
,
"key 没有输入"
);
BaseData
data
=
get
(
model
,
datasource
,
key
);
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DOModelServiceImpl.java
浏览文件 @
7c019597
package
cn
.
ibizlab
.
core
.
data
.
service
.
impl
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.nio.file.StandardOpenOption
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -12,6 +18,11 @@ import java.util.Objects;
import
java.util.Optional
;
import
java.math.BigInteger
;
import
cn.ibizlab.core.data.lite.EntityModel
;
import
cn.ibizlab.core.data.lite.LiteStorage
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
cn.ibizlab.core.data.model.TransUtils
;
import
com.alibaba.fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -40,6 +51,8 @@ import cn.ibizlab.util.helper.DEFieldCacheMap;
@Service
public
class
DOModelServiceImpl
implements
IDOModelService
{
@Value
(
"${ibiz.model.path:/app/file/model/}"
)
private
String
modelPath
;
@Override
public
boolean
create
(
DOModel
et
)
{
...
...
@@ -69,9 +82,49 @@ public class DOModelServiceImpl implements IDOModelService {
@Override
public
DOModel
get
(
String
key
)
{
DOModel
et
=
new
DOModel
();
et
.
setId
(
key
);
return
et
;
DOModel
doModel
=
new
DOModel
();
PojoSchema
schema
=
null
;
String
[]
args
=
key
.
split
(
"[.]"
);
String
system
=
args
[
0
];
String
entity
=
args
[
2
];
File
domainDir
=
new
File
(
modelPath
+
system
+
File
.
separator
+
"domain"
);
if
(!
domainDir
.
exists
())
domainDir
.
mkdirs
();
File
schemaJson
=
new
File
(
domainDir
,
entity
+
".json"
);
if
(!
schemaJson
.
exists
())
{
EntityModel
entityModel
=
LiteStorage
.
getLiteModelService
().
getProxyEntityModel
(
system
,
entity
);
if
(
entityModel
!=
null
)
{
schema
=
TransUtils
.
LiteEntityModelModel2Schema
(
entityModel
);
}
}
else
{
try
{
String
schemaJSON
=
new
String
(
Files
.
readAllBytes
(
Paths
.
get
(
domainDir
.
getAbsolutePath
(),
entity
+
".json"
)),
StandardCharsets
.
UTF_8
);
schema
=
JSON
.
parseObject
(
schemaJSON
,
PojoSchema
.
class
);
}
catch
(
IOException
e
)
{
}
}
if
(
schema
!=
null
)
{
doModel
.
setSchema
(
schema
);
try
{
Files
.
write
(
Paths
.
get
(
domainDir
.
getAbsolutePath
(),
entity
+
".json"
),
JSON
.
toJSONString
(
schema
).
getBytes
(
StandardCharsets
.
UTF_8
),
StandardOpenOption
.
CREATE
);
}
catch
(
IOException
e
)
{
}
}
else
{
throw
new
BadRequestAlertException
(
"未找到对应的模型"
,
"DOModel"
,
key
);
}
return
doModel
;
}
@Override
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DTOModelServiceImpl.java
浏览文件 @
7c019597
package
cn
.
ibizlab
.
core
.
data
.
service
.
impl
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.Serializable
;
import
java.nio.charset.StandardCharsets
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.nio.file.StandardOpenOption
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Set
;
...
...
@@ -12,6 +18,13 @@ import java.util.Objects;
import
java.util.Optional
;
import
java.math.BigInteger
;
import
cn.ibizlab.core.data.domain.DOModel
;
import
cn.ibizlab.core.data.lite.EntityModel
;
import
cn.ibizlab.core.data.lite.LiteStorage
;
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
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -40,6 +53,8 @@ import cn.ibizlab.util.helper.DEFieldCacheMap;
@Service
public
class
DTOModelServiceImpl
implements
IDTOModelService
{
@Value
(
"${ibiz.model.path:/app/file/model/}"
)
private
String
modelPath
;
@Override
public
boolean
create
(
DTOModel
et
)
{
...
...
@@ -69,9 +84,54 @@ public class DTOModelServiceImpl implements IDTOModelService {
@Override
public
DTOModel
get
(
String
key
)
{
DTOModel
et
=
new
DTOModel
();
et
.
setId
(
key
);
return
et
;
DTOModel
dtoModel
=
new
DTOModel
();
PojoSchema
schema
=
null
;
String
[]
args
=
key
.
split
(
"[.]"
);
String
system
=
args
[
0
];
String
dto
=
args
[
2
];
File
domainDir
=
new
File
(
modelPath
+
system
+
File
.
separator
+
"dto"
);
if
(!
domainDir
.
exists
())
domainDir
.
mkdirs
();
File
schemaJson
=
new
File
(
domainDir
,
dto
+
".json"
);
if
(!
schemaJson
.
exists
())
{
String
entity
=
dto
;
if
(
entity
.
endsWith
(
"DTO"
))
entity
=
entity
.
substring
(
0
,
entity
.
length
()-
3
);
EntityModel
entityModel
=
LiteStorage
.
getLiteModelService
().
getProxyEntityModel
(
system
,
entity
);
if
(
entityModel
!=
null
)
{
schema
=
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
TransUtils
.
LiteEntityModelModel2Schema
(
entityModel
)),
PojoSchema
.
class
);
schema
.
setName
(
dto
);
schema
.
setId
(
key
);
}
}
else
{
try
{
String
schemaJSON
=
new
String
(
Files
.
readAllBytes
(
Paths
.
get
(
domainDir
.
getAbsolutePath
(),
dto
+
".json"
)),
StandardCharsets
.
UTF_8
);
schema
=
JSON
.
parseObject
(
schemaJSON
,
PojoSchema
.
class
);
}
catch
(
IOException
e
)
{
}
}
if
(
schema
!=
null
)
{
dtoModel
.
setSchema
(
schema
);
try
{
Files
.
write
(
Paths
.
get
(
domainDir
.
getAbsolutePath
(),
dto
+
".json"
),
JSON
.
toJSONString
(
schema
).
getBytes
(
StandardCharsets
.
UTF_8
),
StandardOpenOption
.
CREATE
);
}
catch
(
IOException
e
)
{
}
}
else
{
throw
new
BadRequestAlertException
(
"未找到对应的模型"
,
"DOModel"
,
key
);
}
return
dtoModel
;
}
@Override
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/DbDataServiceImpl.java
浏览文件 @
7c019597
...
...
@@ -35,7 +35,7 @@ public class DbDataServiceImpl extends BaseDataService {
@Override
public
boolean
create
(
DOModel
model
,
String
datasource
,
BaseData
et
)
{
return
false
;
return
dbDataMapper
.
insertData
(
model
.
getDefaultPOSchema
().
build
(),
et
)==
1
;
}
@Override
...
...
@@ -47,7 +47,8 @@ public class DbDataServiceImpl extends BaseDataService {
@Override
public
boolean
update
(
DOModel
model
,
String
datasource
,
BaseData
et
)
{
return
false
;
dbDataMapper
.
updateData
(
model
.
getDefaultPOSchema
().
build
(),
et
);
return
true
;
}
@Override
...
...
ibzdata-core/src/main/resources/mapper/data/DbDataMapper.xml
→
ibzdata-core/src/main/resources/mapper/data/DbData
/DbData
Mapper.xml
浏览文件 @
7c019597
...
...
@@ -15,7 +15,7 @@
<if
test=
"ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere"
>
${ew.sqlSegment}
</if>
</select>
<insert
id=
"insert
"
parameterType=
"cn.ibizlab.core.data.dto.BaseData"
>
<insert
id=
"insert
Data"
parameterType=
"cn.ibizlab.core.data.dto.BaseData"
>
INSERT INTO ${schema.name}
(
<foreach
collection=
"schema.resultMap"
item=
"value"
index=
"key"
separator=
","
>
...
...
@@ -25,40 +25,40 @@
VALUES
(
<foreach
collection=
"schema.resultMap"
item=
"value"
index=
"key"
separator=
","
>
#
data[${value}]
#
{data[${value}]}
</foreach>
)
</insert>
<update
id=
"update
"
parameterType=
"cn.ibizlab.core.data.dto.BaseData"
>
<update
id=
"update
Data"
parameterType=
"cn.ibizlab.core.data.dto.BaseData"
>
update ${schema.name}
set
<foreach
collection=
"schema.resultMap"
item=
"value"
index=
"key"
separator=
","
>
<if
test=
"data
['_'+value+'dirtyflag']==true"
>
${key}= #data[${value}]
</if>
<if
test=
"data
.keys.contains(value)"
>
${key}= #{data[${value}]}
</if>
</foreach>
where
<foreach
collection=
"schema.keyMap"
item=
"value"
index=
"key"
separator=
"and"
>
${key}= #
data[${value}]
${key}= #
{data[${value}]}
</foreach>
</update>
<update
id=
"remove
"
parameterType=
"cn.ibizlab.core.data.dto.BaseData"
>
<update
id=
"remove
Data"
parameterType=
"cn.ibizlab.core.data.dto.BaseData"
>
<if
test=
"schema.logicValidColumn!=null"
>
update ${schema.name}
set
<foreach
collection=
"schema.resultMap"
item=
"value"
index=
"key"
separator=
","
>
${schema.logicValid
Column.name}= 0
${schema.logicValid
DelCond}
</foreach>
where
<foreach
collection=
"schema.keyMap"
item=
"value"
index=
"key"
separator=
"and"
>
${key}= #
data[${value}]
${key}= #
{data[${value}]}
</foreach>
</if>
<if
test=
"schema.logicValidColumn==null"
>
delete from ${schema.name} where
<foreach
collection=
"schema.keyMap"
item=
"value"
index=
"key"
separator=
"and"
>
${key}= #
data[${value}]
${key}= #
{data[${value}]}
</foreach>
</if>
...
...
ibzdata-provider/ibzdata-provider-api/src/main/java/cn/ibizlab/api/rest/DataResource.java
浏览文件 @
7c019597
...
...
@@ -29,12 +29,14 @@ public class DataResource
public
IDataService
dataService
;
@ApiOperation
(
value
=
"保存数据"
,
tags
=
{
"数据"
},
notes
=
"保存数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/{system}/{entity}/{method}"
)
public
ResponseEntity
<
BaseData
>
call
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@PathVariable
(
name
=
"method"
,
required
=
true
)
String
method
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
BaseData
baseData
)
{
ResponseData
<
BaseData
>
responseData
=
dataService
.
call
(
system
,
entity
,
method
,
datasource
,
new
RequestData
().
setBody
(
baseData
));
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
{
"/{system}/{entity}/{method}"
,
"/{system}/{scope}/{entity}/{method}"
}
)
public
ResponseEntity
<
BaseData
>
call
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"
scope"
,
required
=
false
)
String
scope
,
@PathVariable
(
name
=
"
entity"
,
required
=
true
)
String
entity
,
@PathVariable
(
name
=
"method"
,
required
=
true
)
String
method
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@RequestBody
BaseData
baseData
)
{
ResponseData
<
BaseData
>
responseData
=
dataService
.
call
(
system
,
scope
,
entity
,
method
,
datasource
,
new
RequestData
().
setBody
(
baseData
));
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
responseData
.
getBody
());
}
@ApiOperation
(
value
=
"新建数据"
,
tags
=
{
"数据"
},
notes
=
"新建数据"
)
@RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/{system}/{entity}"
)
public
ResponseEntity
<
BaseData
>
create
(
@PathVariable
(
name
=
"system"
,
required
=
true
)
String
system
,
@PathVariable
(
name
=
"entity"
,
required
=
true
)
String
entity
,
@RequestParam
(
name
=
"datasource"
,
required
=
false
)
String
datasource
,
@Validated
@RequestBody
BaseData
baseData
)
{
...
...
ibzdata-util/src/main/java/cn/ibizlab/util/helper/DataObject.java
浏览文件 @
7c019597
...
...
@@ -189,7 +189,7 @@ public class DataObject {
return
Double
.
parseDouble
(
strValue
);
}
final
static
public
int
getIntegerValue
(
Object
objValue
,
Integer
nDefault
)
{
final
static
public
Integer
getIntegerValue
(
Object
objValue
,
Integer
nDefault
)
{
if
(
objValue
==
null
)
{
return
nDefault
;
...
...
@@ -378,11 +378,7 @@ public class DataObject {
return
new
java
.
sql
.
Timestamp
(
lValue
);
}
if
(
objValue
instanceof
Integer
)
{
int
lValue
=
(
int
)
objValue
;
return
new
java
.
sql
.
Timestamp
(
lValue
);
}
if
(
objValue
instanceof
oracle
.
sql
.
TIMESTAMP
)
{
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录