Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
b9668ffb
提交
b9668ffb
编写于
8月 11, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
66c4d11a
变更
9
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
949 行增加
和
14 行删除
+949
-14
DOSchema.java
...e/src/main/java/cn/ibizlab/core/data/domain/DOSchema.java
+5
-2
DTOSchema.java
.../src/main/java/cn/ibizlab/core/data/domain/DTOSchema.java
+5
-2
DataObj.java
...ore/src/main/java/cn/ibizlab/core/data/model/DataObj.java
+204
-0
PojoModel.java
...e/src/main/java/cn/ibizlab/core/data/model/PojoModel.java
+156
-0
PojoOption.java
.../src/main/java/cn/ibizlab/core/data/model/PojoOption.java
+210
-0
PojoProperty.java
...rc/main/java/cn/ibizlab/core/data/model/PojoProperty.java
+106
-0
PojoSchema.java
.../src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
+235
-0
DOSchemaDTO.java
...der-api/src/main/java/cn/ibizlab/api/dto/DOSchemaDTO.java
+7
-4
DataObject.java
...util/src/main/java/cn/ibizlab/util/helper/DataObject.java
+21
-6
未找到文件。
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DOSchema.java
浏览文件 @
b9668ffb
...
...
@@ -8,6 +8,9 @@ import java.math.BigInteger;
import
java.util.HashMap
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
cn.ibizlab.core.data.model.PojoModel
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
...
...
@@ -94,7 +97,7 @@ public class DOSchema extends EntityBase implements Serializable {
@JSONField
(
name
=
"schema"
)
@JsonProperty
(
"schema"
)
@ApiModelProperty
(
"定义"
)
private
String
schema
;
private
PojoSchema
schema
;
/**
* 模型
...
...
@@ -102,7 +105,7 @@ public class DOSchema extends EntityBase implements Serializable {
@JSONField
(
name
=
"model"
)
@JsonProperty
(
"model"
)
@ApiModelProperty
(
"模型"
)
private
String
model
;
private
PojoModel
model
;
/**
* 存储
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DTOSchema.java
浏览文件 @
b9668ffb
...
...
@@ -8,6 +8,9 @@ import java.math.BigInteger;
import
java.util.HashMap
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
cn.ibizlab.core.data.model.PojoModel
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
...
...
@@ -94,7 +97,7 @@ public class DTOSchema extends EntityBase implements Serializable {
@JSONField
(
name
=
"schema"
)
@JsonProperty
(
"schema"
)
@ApiModelProperty
(
"定义"
)
private
String
schema
;
private
PojoSchema
schema
;
/**
* 模型
...
...
@@ -102,7 +105,7 @@ public class DTOSchema extends EntityBase implements Serializable {
@JSONField
(
name
=
"model"
)
@JsonProperty
(
"model"
)
@ApiModelProperty
(
"模型"
)
private
String
model
;
private
PojoModel
model
;
/**
* 映射
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/DataObj.java
0 → 100644
浏览文件 @
b9668ffb
package
cn
.
ibizlab
.
core
.
data
.
model
;
import
cn.ibizlab.util.domain.DTOBase
;
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
org.springframework.util.ObjectUtils
;
import
java.math.BigDecimal
;
import
java.sql.Timestamp
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
public
class
DataObj
<
K
,
V
>
extends
HashMap
<
K
,
V
>
{
public
<
T
>
T
set
(
String
key
,
V
value
)
{
this
.
put
((
K
)
key
,
value
);
return
(
T
)
this
;
}
@Override
public
V
get
(
Object
key
)
{
if
(
key
==
null
)
return
null
;
V
objValue
=
super
.
get
(
key
);
if
(
objValue
==
null
)
objValue
=
super
.
get
(
key
.
toString
().
toUpperCase
());
if
(
objValue
==
null
)
objValue
=
super
.
get
(
key
.
toString
().
toLowerCase
());
return
objValue
;
}
public
JSONObject
getJSONObjectValue
(
String
strParamName
)
{
return
getJSONObjectValue
(
strParamName
,
new
JSONObject
());
}
public
JSONObject
getJSONObjectValue
(
String
strParamName
,
JSONObject
jDefault
)
{
return
DataObject
.
getJSONObjectValue
(
this
.
get
(
strParamName
),
jDefault
);
}
public
<
T
>
List
<
T
>
getListValue
(
String
strParamName
,
Class
<
T
>
clazz
)
{
List
<
T
>
list
=
new
ArrayList
<>();
Object
val
=
this
.
get
(
strParamName
);
if
(
val
!=
null
&&
val
instanceof
List
)
{
list
=
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
val
),
clazz
);
}
return
list
;
}
public
List
<
String
>
getListValue
(
String
strParamName
)
{
return
DataObject
.
getListValue
(
strParamName
);
}
public
JSONArray
getJSONArrayValue
(
String
strParamName
)
{
return
getJSONArrayValue
(
strParamName
,
new
JSONArray
());
}
public
JSONArray
getJSONArrayValue
(
String
strParamName
,
JSONArray
jDefault
)
{
return
DataObject
.
getJSONArrayValue
(
this
.
get
(
strParamName
),
jDefault
);
}
public
Integer
getIntegerValue
(
String
objValue
)
{
return
getIntegerValue
(
objValue
,
Integer
.
MIN_VALUE
);
}
public
int
getIntegerValue
(
String
strParamName
,
int
nDefault
)
{
return
DataObject
.
getIntegerValue
(
this
.
get
(
strParamName
),
nDefault
);
}
public
Float
getFloatValue
(
String
objValue
)
{
return
this
.
getFloatValue
(
objValue
,-
9999
f
);
}
public
Float
getFloatValue
(
String
strParamName
,
float
fDefault
)
{
return
DataObject
.
getFloatValue
(
this
.
get
(
strParamName
),
fDefault
);
}
public
BigDecimal
getBigDecimalValue
(
String
objValue
)
{
return
this
.
getBigDecimalValue
(
objValue
,
BigDecimal
.
valueOf
(-
9999
));
}
public
BigDecimal
getBigDecimalValue
(
String
strParamName
,
BigDecimal
fDefault
)
{
return
DataObject
.
getBigDecimalValue
(
this
.
get
(
strParamName
),
fDefault
);
}
public
Long
getLongValue
(
String
strParamName
)
{
return
this
.
getLongValue
(
strParamName
,
Long
.
MIN_VALUE
);
}
public
Long
getLongValue
(
String
strParamName
,
long
nDefault
)
{
return
DataObject
.
getLongValue
(
this
.
get
(
strParamName
),
nDefault
);
}
public
String
getStringValue
(
String
objValue
)
{
return
getStringValue
(
objValue
,
""
);
}
public
String
getStringValue
(
String
strParamName
,
String
strDefault
)
{
return
DataObject
.
getStringValue
(
this
.
get
(
strParamName
),
strDefault
);
}
public
byte
[]
getBinaryValue
(
String
objValue
)
{
return
getBinaryValue
(
objValue
,
null
);
}
public
byte
[]
getBinaryValue
(
String
strParamName
,
byte
[]
def
)
{
return
DataObject
.
getBinaryValue
(
this
.
get
(
strParamName
),
def
);
}
public
Boolean
getBooleanValue
(
String
strParamName
)
{
return
getBooleanValue
(
strParamName
,
false
);
}
public
Boolean
getBooleanValue
(
String
strParamName
,
Boolean
bDefault
)
{
return
DataObject
.
getBooleanValue
(
this
.
get
(
strParamName
),
bDefault
);
}
public
Timestamp
getTimestampBegin
(
String
strParamName
)
{
return
getTimestampValue
(
strParamName
,
DataObject
.
getBeginDate
());
}
public
Timestamp
getTimestampEnd
(
String
strParamName
)
{
Object
objValue
=
this
.
get
(
strParamName
);
if
(
objValue
==
null
)
{
return
DataObject
.
getEndDate
();
}
try
{
Timestamp
t
=
DataObject
.
getTimestampValue
(
objValue
,
DataObject
.
getEndDate
());
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
String
time
=
df
.
format
(
t
);
Calendar
cl
=
Calendar
.
getInstance
(
TimeZone
.
getTimeZone
(
"GMT+8"
));
cl
.
setTime
(
Timestamp
.
valueOf
(
time
+
" 23:59:59"
));
return
new
Timestamp
(
cl
.
getTime
().
getTime
());
}
catch
(
Exception
ex
)
{
return
DataObject
.
getEndDate
();
}
}
public
Timestamp
getTimestampValue
(
String
strParamName
,
Timestamp
dtDefault
)
{
Object
objValue
=
this
.
get
(
strParamName
);
if
(
objValue
==
null
||
objValue
.
equals
(
""
))
{
return
dtDefault
;
}
try
{
return
DataObject
.
getTimestampValue
(
objValue
,
null
);
}
catch
(
Exception
ex
)
{
return
dtDefault
;
}
}
public
<
T
>
T
copyTo
(
T
targetEntity
,
boolean
bIncEmpty
){
if
(
targetEntity
instanceof
EntityBase
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
if
(
!
ObjectUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
value
)
&&
bIncEmpty
){
((
EntityBase
)
targetEntity
).
set
((
String
)
field
,
value
);
}
}
}
else
if
(
targetEntity
instanceof
DTOBase
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
if
(
!
ObjectUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
value
)
&&
bIncEmpty
){
((
DTOBase
)
targetEntity
).
set
(((
String
)
field
).
toLowerCase
(),
value
);
}
}
}
else
if
(
targetEntity
instanceof
DataObj
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
if
(
!
ObjectUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
value
)
&&
bIncEmpty
){
((
DataObj
)
targetEntity
).
set
((
String
)
field
,
value
);
}
}
}
else
if
(
targetEntity
instanceof
Map
){
for
(
K
field
:
this
.
keySet
()){
Object
value
=
this
.
get
(
field
);
if
(
!
ObjectUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
value
)
&&
bIncEmpty
){
((
Map
)
targetEntity
).
put
(
field
,
value
);
}
}
}
return
targetEntity
;
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoModel.java
0 → 100644
浏览文件 @
b9668ffb
package
cn
.
ibizlab
.
core
.
data
.
model
;
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
java.util.*
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
PojoModel
{
@JSONField
(
ordinal
=
1
)
private
String
id
;
@JSONField
(
ordinal
=
2
)
private
String
code
;
@JSONField
(
ordinal
=
3
)
private
String
name
;
@JSONField
(
ordinal
=
4
)
private
String
group
;
@JSONField
(
ordinal
=
5
)
private
List
<
PojoProperty
>
propertyList
;
@JSONField
(
ordinal
=
6
)
private
Map
<
String
,
Object
>
extensions
=
new
HashMap
<>();
public
PojoModel
setPropertyList
(
List
<
PojoProperty
>
propertyList
)
{
if
(
propertyList
!=
null
)
propertyList
.
forEach
(
property
->
property
.
setOwnerModel
(
this
));
this
.
propertyList
=
propertyList
;
return
this
;
}
public
PojoModel
addProperty
(
PojoProperty
property
)
{
if
(
propertyList
==
null
)
propertyList
=
new
ArrayList
<>();
property
.
setOwnerModel
(
this
);
this
.
propertyList
.
add
(
property
);
return
this
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Map
<
String
,
PojoProperty
>
properties
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Map
<
String
,
PojoProperty
>
getProperties
()
{
if
(
this
.
getPropertyList
()!=
null
&&
properties
==
null
)
{
properties
=
new
LinkedHashMap
<>();
getPropertyList
().
forEach
(
property
->{
properties
.
put
(
property
.
getCode
(),
property
);
});
}
return
properties
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Map
<
String
,
PojoProperty
>
getAllProperties
()
{
Map
<
String
,
PojoProperty
>
list
=
new
LinkedHashMap
<>();
if
(
getPropertyList
()!=
null
)
{
getPropertyList
().
forEach
(
item
->{
loop
(
item
,
list
);
});
}
return
list
;
}
private
void
loop
(
PojoProperty
property
,
Map
<
String
,
PojoProperty
>
list
)
{
list
.
put
(
property
.
getTag
(),
property
);
if
(
PropertyType
.
nested
.
equals
(
property
.
getPropertyType
())
||
PropertyType
.
object
.
equals
(
property
.
getPropertyType
()))
{
if
(
property
.
getModel
()!=
null
&&
property
.
getModel
().
getPropertyList
()!=
null
)
{
property
.
getModel
().
getPropertyList
().
forEach
(
item
->{
loop
(
item
,
list
);
});
}
}
}
public
PojoProperty
getProperty
(
String
code
)
{
if
(
code
.
indexOf
(
"."
)>
0
)
{
String
arr
[]=
code
.
split
(
"[.]"
);
if
(
arr
.
length
>
0
)
{
PojoProperty
property
=(
getProperties
()!=
null
)?
properties
.
get
(
arr
[
0
]):
null
;
if
(
property
==
null
)
return
null
;
if
(
property
.
getModel
()!=
null
)
return
property
.
getModel
().
getProperty
(
code
.
substring
(
code
.
indexOf
(
"."
)+
1
));
else
return
null
;
}
}
return
(
getProperties
()!=
null
)?
properties
.
get
(
code
):
null
;
}
public
static
enum
PropertyType
{
string
(
"string"
,
"字符"
),
integer
(
"integer"
,
"整型"
),
number
(
"number"
,
"数值"
),
date
(
"date"
,
"日期"
),
datetime
(
"datetime"
,
"时间"
),
object
(
"object"
,
"对象"
),
nested
(
"nested"
,
"嵌套"
),
recursion
(
"recursion"
,
"递归"
),
array
(
"array"
,
"数组"
);
public
final
String
code
;
public
final
String
name
;
private
PropertyType
(
String
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getName
()
{
return
name
;
}
@Override
public
String
toString
()
{
return
"PropertyType{"
+
"code='"
+
code
+
'\''
+
", name='"
+
name
+
'\''
+
'}'
;
}
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoOption.java
0 → 100644
浏览文件 @
b9668ffb
package
cn
.
ibizlab
.
core
.
data
.
model
;
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
org.springframework.util.StringUtils
;
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
PojoOption
extends
DataObj
{
public
PojoOption
set
(
String
key
,
Object
value
)
{
this
.
put
(
key
,
value
);
return
this
;
}
public
String
getName
()
{
return
this
.
getStringValue
(
"name"
);
}
public
PojoOption
setName
(
String
name
)
{
return
this
.
set
(
"name"
,
name
);
}
public
String
getCode
()
{
return
this
.
getStringValue
(
"code"
);
}
public
PojoOption
setCode
(
String
code
)
{
return
this
.
set
(
"code"
,
code
);
}
public
Boolean
isLogicValid
()
{
return
this
.
getBooleanValue
(
"logicValid"
);
}
public
PojoOption
setLogicValid
(
Boolean
logicValid
)
{
return
this
.
set
(
"logicValid"
,
logicValid
);
}
public
String
getLogicVal
()
{
return
this
.
getStringValue
(
"logicval"
,
"1"
);
}
public
PojoOption
setLogicVal
(
String
logicval
)
{
return
this
.
set
(
"logicval"
,
logicval
);
}
public
String
getLogicDelVal
()
{
return
this
.
getStringValue
(
"logicdelval"
,
"0"
);
}
public
PojoOption
setLogicDelVal
(
String
logicdelval
)
{
return
this
.
set
(
"logicdelval"
,
logicdelval
);
}
public
String
getRelationName
()
{
return
this
.
getStringValue
(
"relation_name"
);
}
public
PojoOption
setRelationName
(
String
relationName
)
{
return
this
.
set
(
"relation_name"
,
relationName
);
}
public
String
getRefEntityName
()
{
return
this
.
getStringValue
(
"ref_entity_name"
);
}
public
PojoOption
setRefEntityName
(
String
refEntityName
)
{
return
this
.
set
(
"ref_entity_name"
,
refEntityName
);
}
public
String
getRefFieldName
()
{
return
this
.
getStringValue
(
"ref_field_name"
);
}
public
PojoOption
setRefFieldName
(
String
refFieldName
)
{
return
this
.
set
(
"ref_field_name"
,
refFieldName
);
}
public
Boolean
isKeyField
()
{
return
this
.
getBooleanValue
(
"key_field"
);
}
public
PojoOption
setKeyField
(
Boolean
keyField
)
{
return
this
.
set
(
"key_field"
,
keyField
);
}
public
Boolean
isMajorField
()
{
return
this
.
getBooleanValue
(
"major_field"
);
}
public
PojoOption
setMajorField
(
Boolean
majorField
)
{
return
this
.
set
(
"major_field"
,
majorField
);
}
public
String
getUnionKey
()
{
return
this
.
getStringValue
(
"union_key"
);
}
public
PojoOption
setUnionKey
(
String
unionKey
)
{
return
this
.
set
(
"union_key"
,
unionKey
);
}
public
Boolean
isPhysicalField
()
{
return
this
.
getBooleanValue
(
"physical_field"
,
true
);
}
public
PojoOption
setPhysicalField
(
Boolean
physicalField
)
{
return
this
.
set
(
"physical_field"
,
physicalField
);
}
public
Boolean
isNullable
()
{
return
this
.
getBooleanValue
(
"nullable"
,
true
);
}
public
PojoOption
setNullable
(
Boolean
nullable
)
{
return
this
.
set
(
"nullable"
,
nullable
);
}
public
String
getFieldType
()
{
return
this
.
getStringValue
(
"field_type"
);
}
public
PojoOption
setFieldType
(
String
fieldType
)
{
return
this
.
set
(
"field_type"
,
fieldType
);
}
public
String
getPredefined
()
{
return
this
.
getStringValue
(
"predefined"
);
}
public
PojoOption
setPredefined
(
String
predefined
)
{
return
this
.
set
(
"predefined"
,
predefined
);
}
public
String
getDict
()
{
return
this
.
getStringValue
(
"dict"
);
}
public
PojoOption
setDict
(
String
dict
)
{
return
this
.
set
(
"dict"
,
dict
);
}
public
String
getDataType
()
{
return
this
.
getStringValue
(
"data_type"
);
}
public
PojoOption
setDataType
(
String
dataType
)
{
return
this
.
set
(
"data_type"
,
dataType
);
}
public
Integer
getDataLength
()
{
return
this
.
getIntegerValue
(
"data_length"
);
}
public
PojoOption
setDataLength
(
Integer
dataLength
)
{
return
this
.
set
(
"data_length"
,
dataLength
);
}
public
Integer
getDataPreci
()
{
return
this
.
getIntegerValue
(
"data_preci"
);
}
public
PojoOption
setDataPreci
(
Integer
dataPreci
)
{
return
this
.
set
(
"data_preci"
,
dataPreci
);
}
public
String
getExpression
()
{
return
this
.
getStringValue
(
"expression"
);
}
public
PojoOption
setExpression
(
String
expression
)
{
return
this
.
set
(
"expression"
,
expression
);
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isLogicValidField
()
{
return
"LOGICVALID"
.
equals
(
this
.
getPredefined
());
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isLastModifyField
()
{
return
"UPDATEDATE"
.
equals
(
this
.
getPredefined
());
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isCreateTimeField
()
{
return
"CREATEDATE"
.
equals
(
this
.
getPredefined
());
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isUnionKeyField
()
{
return
!
StringUtils
.
isEmpty
(
this
.
getUnionKey
());
}
}
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoProperty.java
0 → 100644
浏览文件 @
b9668ffb
package
cn
.
ibizlab
.
core
.
data
.
model
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSON
;
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.ObjectUtils
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
PojoProperty
{
@JSONField
(
ordinal
=
1
)
private
String
code
;
@JSONField
(
ordinal
=
2
)
private
String
name
;
@JSONField
(
ordinal
=
3
)
private
Boolean
required
;
@JSONField
(
ordinal
=
4
)
private
PojoModel
.
PropertyType
propertyType
;
@JSONField
(
ordinal
=
5
)
private
Boolean
uniqueKeys
;
@JSONField
(
ordinal
=
6
)
private
String
dict
;
@JSONField
(
ordinal
=
7
)
private
String
defaultValue
;
public
String
getDefaultValue
()
{
if
(
defaultValue
!=
null
&&
defaultValue
.
equalsIgnoreCase
(
"now"
))
return
DataObject
.
dayFormat
.
format
(
new
Date
());
return
DataObject
.
getStringValue
(
defaultValue
,
""
);
}
@JSONField
(
ordinal
=
8
)
private
PojoModel
model
;
public
PojoModel
getModel
()
{
if
(
propertyType
!=
null
&&
propertyType
.
equals
(
PojoModel
.
PropertyType
.
recursion
)
&&
ownerModel
!=
null
)
{
model
=
JSON
.
toJavaObject
(
JSON
.
parseObject
(
JSON
.
toJSONString
(
ownerModel
)),
PojoModel
.
class
);
if
(
model
!=
null
&&
model
.
getProperties
()!=
null
)
model
.
getPropertyList
().
forEach
(
prop
->
prop
.
setParentProperty
(
this
));
}
return
model
;
}
public
PojoProperty
setModel
(
PojoModel
model
)
{
if
(
model
!=
null
&&
model
.
getProperties
()!=
null
)
model
.
getPropertyList
().
forEach
(
prop
->
prop
.
setParentProperty
(
this
));
this
.
model
=
model
;
return
this
;
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
PojoModel
ownerModel
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
PojoProperty
parentProperty
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getTag
()
{
List
<
PojoProperty
>
list
=
new
ArrayList
<>();
PojoProperty
prop
=
this
.
getParentProperty
();
while
(
prop
!=
null
)
{
list
.
add
(
prop
);
prop
=
prop
.
getParentProperty
();
}
String
tag
=
""
;
for
(
int
i
=
list
.
size
()-
1
;
i
>=
0
;
i
--)
tag
=
tag
+
list
.
get
(
i
).
getCode
()+
"."
;
tag
+=
code
;
return
tag
;
}
}
\ No newline at end of file
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
0 → 100644
浏览文件 @
b9668ffb
package
cn
.
ibizlab
.
core
.
data
.
model
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
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.math.BigDecimal
;
import
java.util.*
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonInclude
(
JsonInclude
.
Include
.
NON_EMPTY
)
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
PojoSchema
{
@JSONField
(
ordinal
=
1
)
private
String
id
;
@JSONField
(
ordinal
=
2
)
private
String
type
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
String
code
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getCode
()
{
if
(
code
==
null
)
code
=
this
.
getOptions
()==
null
||
this
.
getOptions
().
getCode
()==
null
?
this
.
getName
():
this
.
getOptions
().
getCode
();
return
code
;
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
String
name
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getName
()
{
if
(
name
==
null
)
name
=
this
.
getOptions
()==
null
||
this
.
getOptions
().
getName
()==
null
?
""
:
this
.
getOptions
().
getName
();
return
name
;
}
public
PojoSchema
setName
(
String
name
)
{
if
(!
StringUtils
.
isEmpty
(
name
))
{
this
.
name
=
name
;
if
(
options
==
null
)
options
=
new
PojoOption
();
options
.
setName
(
name
);
}
return
this
;
}
@JSONField
(
ordinal
=
3
)
private
String
title
;
@JSONField
(
ordinal
=
4
)
private
String
description
;
@JSONField
(
ordinal
=
5
)
private
Integer
propertyOrder
;
@JSONField
(
ordinal
=
6
)
private
PojoOption
options
;
@JSONField
(
ordinal
=
7
)
private
String
ref
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
PojoSchema
copy
()
{
return
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
this
),
PojoSchema
.
class
);
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
boolean
built
=
false
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
PojoSchema
build
()
{
return
this
;
}
/// object
@JSONField
(
ordinal
=
11
)
private
Map
<
String
,
PojoSchema
>
properties
;
public
PojoSchema
setProperties
(
Map
<
String
,
PojoSchema
>
properties
)
{
if
(
properties
!=
null
)
{
properties
.
keySet
().
forEach
(
key
->{
properties
.
get
(
key
).
setName
(
key
).
setOwner
(
this
);
});
this
.
properties
=
properties
;
}
return
this
;
}
public
Map
<
String
,
PojoSchema
>
getProperties
()
{
if
(!
"object"
.
equals
(
this
.
type
))
{
properties
=
null
;
return
properties
;
}
if
(
properties
==
null
)
properties
=
new
LinkedHashMap
<>();
return
properties
;
}
public
PojoSchema
addProperties
(
String
name
,
PojoSchema
property
)
{
if
(
StringUtils
.
isEmpty
(
name
))
return
this
;
Map
<
String
,
PojoSchema
>
props
=
this
.
getProperties
();
if
(
props
!=
null
)
{
props
.
put
(
name
,
property
.
setName
(
name
).
setOwner
(
this
));
}
return
this
;
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
PojoSchema
owner
;
@JSONField
(
ordinal
=
12
)
private
Set
<
String
>
required
;
public
Set
<
String
>
getRequired
()
{
if
(!
"object"
.
equals
(
this
.
type
))
{
required
=
null
;
return
required
;
}
if
(
required
==
null
&&
properties
!=
null
)
{
required
=
new
LinkedHashSet
<>();
properties
.
values
().
forEach
(
prop
->{
if
(
prop
.
getOptions
()!=
null
&&(!
prop
.
getOptions
().
isNullable
()))
required
.
add
(
prop
.
getName
());
});
}
return
required
;
}
@JSONField
(
ordinal
=
13
)
private
Integer
minProperties
;
@JSONField
(
ordinal
=
14
)
private
Integer
maxProperties
;
//// array
@JSONField
(
ordinal
=
21
)
private
PojoSchema
items
;
@JSONField
(
ordinal
=
22
)
private
Integer
minItems
;
@JSONField
(
ordinal
=
23
)
private
Boolean
uniqueItems
;
/// String
@JSONField
(
ordinal
=
33
)
private
Integer
minLength
;
@JSONField
(
ordinal
=
34
)
private
Integer
maxLength
;
@JSONField
(
ordinal
=
35
)
private
String
pattern
;
@JSONField
(
ordinal
=
36
)
private
String
format
;
/// integer number
@JSONField
(
ordinal
=
41
)
private
BigDecimal
minimum
;
@JSONField
(
ordinal
=
42
)
private
BigDecimal
maximum
;
@JSONField
(
ordinal
=
43
)
private
Boolean
exclusiveMinimum
;
@JSONField
(
ordinal
=
44
)
private
Boolean
exclusiveMaximum
;
@JSONField
(
ordinal
=
45
)
private
Integer
multipleOf
;
public
static
void
main
(
String
[]
args
)
{
PojoSchema
schema
=
new
PojoSchema
().
setType
(
"object"
).
setRef
(
"#/definitions/entity"
);
PojoSchema
def
=
new
PojoSchema
();
def
.
setType
(
"object"
).
setTitle
(
"部门"
).
addProperties
(
"deptCode"
,
new
PojoSchema
().
setType
(
"string"
).
setTitle
(
"部门编码"
))
.
addProperties
(
"deptName"
,
new
PojoSchema
().
setType
(
"string"
).
setTitle
(
"部门名称"
)).
addProperties
(
"parent"
,
def
);
System
.
out
.
println
(
JSON
.
toJSONString
(
schema
));
}
}
ibzdata-provider/ibzdata-provider-api/src/main/java/cn/ibizlab/api/dto/DOSchemaDTO.java
浏览文件 @
b9668ffb
...
...
@@ -8,6 +8,9 @@ import java.util.Map;
import
java.util.HashMap
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
cn.ibizlab.core.data.model.PojoModel
;
import
cn.ibizlab.core.data.model.PojoSchema
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
...
...
@@ -100,7 +103,7 @@ public class DOSchemaDTO extends DTOBase implements Serializable {
@JsonProperty
(
"schema"
)
@Size
(
min
=
0
,
max
=
1048576
,
message
=
"内容长度必须小于等于[1048576]"
)
@ApiModelProperty
(
"定义"
)
private
String
schema
;
private
PojoSchema
schema
;
/**
* 属性 [MODEL]
...
...
@@ -110,7 +113,7 @@ public class DOSchemaDTO extends DTOBase implements Serializable {
@JsonProperty
(
"model"
)
@Size
(
min
=
0
,
max
=
1048576
,
message
=
"内容长度必须小于等于[1048576]"
)
@ApiModelProperty
(
"模型"
)
private
String
model
;
private
PojoModel
model
;
/**
* 属性 [POMODELS]
...
...
@@ -166,7 +169,7 @@ public class DOSchemaDTO extends DTOBase implements Serializable {
/**
* 设置 [SCHEMA]
*/
public
void
setSchema
(
String
schema
){
public
void
setSchema
(
PojoSchema
schema
){
this
.
schema
=
schema
;
this
.
modify
(
"schema"
,
schema
);
}
...
...
@@ -174,7 +177,7 @@ public class DOSchemaDTO extends DTOBase implements Serializable {
/**
* 设置 [MODEL]
*/
public
void
setModel
(
String
model
){
public
void
setModel
(
PojoModel
model
){
this
.
model
=
model
;
this
.
modify
(
"model"
,
model
);
}
...
...
ibzdata-util/src/main/java/cn/ibizlab/util/helper/DataObject.java
浏览文件 @
b9668ffb
...
...
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import
org.springframework.util.StringUtils
;
import
java.math.BigDecimal
;
import
java.math.BigInteger
;
import
java.sql.SQLException
;
import
java.sql.Timestamp
;
import
java.text.DateFormat
;
import
java.text.ParseException
;
...
...
@@ -35,6 +36,10 @@ public class DataObject {
}
return
rt
;
}
if
(
objValue
instanceof
BigDecimal
)
{
return
getBigDecimalValue
(
objValue
,
BigDecimal
.
ZERO
).
toString
();
}
return
objValue
.
toString
();
}
...
...
@@ -44,7 +49,7 @@ public class DataObject {
}
Object
resultValue
=
fieldValue
;
String
targetType
=
type
.
getSimpleName
();
if
(
targetType
.
equals
IgnoreCase
(
fieldValue
.
getClass
().
getSimpleName
())){
if
(
targetType
.
equals
(
fieldValue
.
getClass
().
getSimpleName
())){
return
resultValue
;
}
if
(
targetType
.
equals
(
"Boolean"
)){
...
...
@@ -158,7 +163,7 @@ public class DataObject {
if
(
objValue
instanceof
Boolean
)
{
return
(
Boolean
)
objValue
;
}
return
objValue
.
toString
().
equalsIgnoreCase
(
"true"
)||
objValue
.
toString
().
equals
(
"1"
)||
objValue
.
toString
().
equals
(
"y"
);
return
DataObject
.
getStringValue
(
objValue
,
""
).
equalsIgnoreCase
(
"true"
)||
objValue
.
toString
().
equals
(
"1"
)||
objValue
.
toString
().
equalsIgnoreCase
(
"y"
);
}
final
static
public
char
[]
getCharacterValue
(
Object
objValue
,
char
[]
cDefault
)
{
...
...
@@ -238,20 +243,20 @@ public class DataObject {
}
try
{
if
(
objValue
instanceof
BigDecimal
){
return
(
BigDecimal
)(
objValue
);
return
(
(
BigDecimal
)(
objValue
)).
stripTrailingZeros
(
);
}
if
(
objValue
instanceof
Double
){
return
BigDecimal
.
valueOf
((
Double
)
objValue
);
return
BigDecimal
.
valueOf
((
Double
)
objValue
)
.
stripTrailingZeros
()
;
}
if
(
objValue
instanceof
Long
){
return
BigDecimal
.
valueOf
((
Long
)
objValue
);
return
BigDecimal
.
valueOf
((
Long
)
objValue
)
.
stripTrailingZeros
()
;
}
String
strValue
=
objValue
.
toString
();
if
(
StringUtils
.
isEmpty
(
strValue
))
{
return
fDefault
;
}
strValue
=
strValue
.
replace
(
","
,
""
);
return
BigDecimal
.
valueOf
(
Double
.
parseDouble
(
strValue
));
return
BigDecimal
.
valueOf
(
Double
.
parseDouble
(
strValue
))
.
stripTrailingZeros
()
;
}
catch
(
Exception
ex
)
{
return
fDefault
;
}
...
...
@@ -379,6 +384,16 @@ public class DataObject {
return
new
java
.
sql
.
Timestamp
(
lValue
);
}
if
(
objValue
instanceof
oracle
.
sql
.
TIMESTAMP
)
{
try
{
oracle
.
sql
.
TIMESTAMP
tValue
=
(
oracle
.
sql
.
TIMESTAMP
)
objValue
;
return
tValue
.
timestampValue
();
}
catch
(
SQLException
e
)
{
return
tDefault
;
}
}
return
tDefault
;
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录