Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
e8233e50
提交
e8233e50
编写于
8月 31, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
默认值
上级
189eef7c
变更
6
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
128 行增加
和
48 行删除
+128
-48
DynamicModelService.java
...n/java/cn/ibizlab/core/data/lite/DynamicModelService.java
+17
-0
POSchema.java
...re/src/main/java/cn/ibizlab/core/data/model/POSchema.java
+7
-0
PojoOption.java
.../src/main/java/cn/ibizlab/core/data/model/PojoOption.java
+2
-2
PojoSchema.java
.../src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
+92
-38
TransUtils.java
.../src/main/java/cn/ibizlab/core/data/model/TransUtils.java
+7
-2
BaseDataService.java
...va/cn/ibizlab/core/data/service/impl/BaseDataService.java
+3
-6
未找到文件。
ibzdata-core/src/main/java/cn/ibizlab/core/data/lite/DynamicModelService.java
浏览文件 @
e8233e50
...
...
@@ -259,6 +259,23 @@ public class DynamicModelService {
modes
.
add
(
"query"
);
metaFieldModel
.
set
(
"search_modes"
,
String
.
join
(
","
,
modes
));
}
if
((!
StringUtils
.
isEmpty
(
defield
.
getDefaultValueType
()))||(!
StringUtils
.
isEmpty
(
defield
.
getDefaultValue
())))
{
String
defaultValue
=
""
;
if
(
StringUtils
.
isEmpty
(
defield
.
getDefaultValueType
())||
"NONE"
.
equalsIgnoreCase
(
defield
.
getDefaultValueType
()))
{
defaultValue
=
defield
.
getDefaultValue
();
}
else
if
(!
StringUtils
.
isEmpty
(
defield
.
getDefaultValue
()))
{
defaultValue
=
String
.
format
(
"${%1$s.%2$s}"
,
defield
.
getDefaultValueType
(),
defield
.
getDefaultValue
());
}
else
{
defaultValue
=
String
.
format
(
"${%1$s}"
,
defield
.
getDefaultValueType
());
}
metaFieldModel
.
set
(
"default_value"
,
defaultValue
);
}
fieldModel
.
setCodeName
(
metaFieldModel
.
getCodeName
()).
setColumnName
(
metaFieldModel
.
getFieldName
()).
setUnionName
(
metaFieldModel
.
getFieldUniName
()).
setShowName
(
metaFieldModel
.
getFieldShowName
())
.
setComment
(
metaFieldModel
.
getFieldLogicName
()).
setField
(
metaFieldModel
);
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/POSchema.java
浏览文件 @
e8233e50
...
...
@@ -402,6 +402,13 @@ public class POSchema {
@JSONField
(
ordinal
=
11
)
private
Set
<
String
>
searchModes
;
public
Column
setDefaultValue
(
String
defaultValue
)
{
if
((!
StringUtils
.
isEmpty
(
defaultValue
))&&(!
defaultValue
.
startsWith
(
"$"
)))
this
.
defaultValue
=
defaultValue
;
return
this
;
}
public
Column
putSearchModes
(
String
searchModes
)
{
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoOption.java
浏览文件 @
e8233e50
...
...
@@ -232,11 +232,11 @@ public class PojoOption extends DataObj
return
this
.
set
(
"dict"
,
dict
);
}
public
String
getDefaultValue
()
{
return
this
.
getStringValue
(
"default
V
alue"
);
return
this
.
getStringValue
(
"default
_v
alue"
);
}
public
PojoOption
setDefaultValue
(
String
defaultValue
)
{
return
this
.
set
(
"default
V
alue"
,
defaultValue
);
return
this
.
set
(
"default
_v
alue"
,
defaultValue
);
}
public
String
getDataType
()
{
return
this
.
getStringValue
(
"data_type"
);
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
浏览文件 @
e8233e50
...
...
@@ -5,6 +5,7 @@ import cn.ibizlab.core.data.dto.FilterData;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.DataObject
;
import
cn.ibizlab.util.helper.Inflector
;
import
cn.ibizlab.util.security.AuthenticationUser
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.annotation.JSONField
;
...
...
@@ -27,6 +28,7 @@ import java.math.BigDecimal;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
java.nio.file.StandardOpenOption
;
import
java.sql.Timestamp
;
import
java.util.*
;
@Getter
...
...
@@ -56,7 +58,7 @@ public class PojoSchema {
public
String
getName
()
{
if
(
name
==
null
)
name
=
this
.
getOptions
()
==
null
?
""
:
this
.
getOptions
()
.
getName
();
name
=
this
.
getOptions
().
getName
();
return
name
;
}
...
...
@@ -76,35 +78,35 @@ public class PojoSchema {
@JsonIgnore
public
String
getCodeName
()
{
return
this
.
getOptions
()
==
null
?
this
.
getName
():
this
.
getOptions
()
.
getStringValue
(
"code_name"
,
this
.
getName
());
return
this
.
getOptions
().
getStringValue
(
"code_name"
,
this
.
getName
());
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getSystem
()
{
return
this
.
getOptions
()
==
null
?
""
:
this
.
getOptions
()
.
getSystem
();
return
this
.
getOptions
().
getSystem
();
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getDefaultDataSoruce
()
{
return
this
.
getOptions
()
==
null
?
""
:
this
.
getOptions
()
.
getDefaultDataSoruce
();
return
this
.
getOptions
().
getDefaultDataSoruce
();
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getDefaultTableName
()
{
return
this
.
getOptions
()
==
null
?
""
:
this
.
getOptions
()
.
getTableName
();
return
this
.
getOptions
().
getTableName
();
}
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
String
getPackage
()
{
return
this
.
getOptions
()
==
null
?
""
:
this
.
getOptions
()
.
getSystem
();
return
this
.
getOptions
().
getSystem
();
}
...
...
@@ -121,6 +123,13 @@ public class PojoSchema {
@JSONField
(
ordinal
=
6
)
private
PojoOption
options
;
public
PojoOption
getOptions
()
{
if
(
options
==
null
)
options
=
new
PojoOption
();
return
options
;
}
public
PojoSchema
setOptions
(
PojoOption
options
)
{
if
(
options
==
null
)
...
...
@@ -221,7 +230,7 @@ public class PojoSchema {
{
references
=
new
ArrayList
<>();
getProperties
().
values
().
forEach
(
prop
->{
if
(
Type
.
object
.
getCode
().
equalsIgnoreCase
(
prop
.
getType
())&&
prop
.
getOptions
()!=
null
&&
(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
())))
{
if
(
Type
.
object
.
getCode
().
equalsIgnoreCase
(
prop
.
getType
())&&(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
())))
{
references
.
add
(
prop
);
}
});
...
...
@@ -242,7 +251,7 @@ public class PojoSchema {
referenceMap
=
new
LinkedHashMap
<>();
getProperties
().
keySet
().
forEach
(
key
->{
PojoSchema
prop
=
getProperties
().
get
(
key
);
if
(
Type
.
object
.
getCode
().
equalsIgnoreCase
(
prop
.
getType
())&&
prop
.
getOptions
()!=
null
&&
(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
())))
{
if
(
Type
.
object
.
getCode
().
equalsIgnoreCase
(
prop
.
getType
())&&(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
())))
{
referenceMap
.
put
(
key
,
prop
);
if
(!
key
.
equals
(
key
.
toLowerCase
()))
referenceMap
.
put
(
key
.
toLowerCase
(),
prop
);
...
...
@@ -280,14 +289,14 @@ public class PojoSchema {
public
Map
<
String
,
PojoSchema
>
getRefProperties
()
{
Map
<
String
,
PojoSchema
>
refProperties
=
new
LinkedHashMap
<>();
if
(
this
.
getOwner
()!=
null
&&
Type
.
object
.
getCode
().
equalsIgnoreCase
(
this
.
getType
())&&
this
.
getOptions
()!=
null
&&
(!
StringUtils
.
isEmpty
(
this
.
getOptions
().
getRelationName
())))
if
(
this
.
getOwner
()!=
null
&&
Type
.
object
.
getCode
().
equalsIgnoreCase
(
this
.
getType
())&&(!
StringUtils
.
isEmpty
(
this
.
getOptions
().
getRelationName
())))
{
this
.
getOwner
().
getProperties
().
entrySet
().
forEach
(
entry
->
{
String
key
=
entry
.
getKey
();
if
(
key
.
equals
(
this
.
getName
()))
return
;
PojoSchema
prop
=
entry
.
getValue
();
if
(
prop
.
getOptions
()!=
null
&&
(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
()))&&
prop
.
getOptions
().
getRelationName
().
equals
(
this
.
getOptions
().
getRelationName
()))
if
((!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
()))&&
prop
.
getOptions
().
getRelationName
().
equals
(
this
.
getOptions
().
getRelationName
()))
{
refProperties
.
put
(
key
,
prop
);
}
...
...
@@ -307,7 +316,7 @@ public class PojoSchema {
if
(
key
.
equals
(
refSchema
.
getName
()))
return
;
PojoSchema
prop
=
entry
.
getValue
();
if
(
prop
.
getOptions
()!=
null
&&
(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
()))&&
prop
.
getOptions
().
getRelationName
().
equals
(
refSchema
.
getOptions
().
getRelationName
()))
if
((!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getRelationName
()))&&
prop
.
getOptions
().
getRelationName
().
equals
(
refSchema
.
getOptions
().
getRelationName
()))
{
refProperties
.
put
(
key
,
prop
);
}
...
...
@@ -335,7 +344,7 @@ public class PojoSchema {
{
required
=
new
LinkedHashSet
<>();
properties
.
values
().
forEach
(
prop
->{
if
(
prop
.
getOptions
()!=
null
&&(!
prop
.
getOptions
().
isNullable
()
))
if
(
!
prop
.
getOptions
().
isNullable
(
))
required
.
add
(
prop
.
getName
());
});
}
...
...
@@ -379,6 +388,8 @@ public class PojoSchema {
List
<
PojoSchema
>
keys
=
new
ArrayList
<>();
keyMap
=
new
LinkedHashMap
<>();
getProperties
().
values
().
forEach
(
sub
->{
if
(
Type
.
array
.
getCode
().
equals
(
sub
.
getType
())||
Type
.
object
.
getCode
().
equals
(
sub
.
getType
()))
return
;
if
(
sub
.
getOptions
().
isKeyField
())
keyProperty
=
sub
;
if
(
sub
.
getOptions
().
isKeyField
()&&
sub
.
getOptions
().
isPhysicalField
())
...
...
@@ -387,6 +398,8 @@ public class PojoSchema {
if
(
keys
.
isEmpty
())
{
getProperties
().
values
().
forEach
(
sub
->{
if
(
Type
.
array
.
getCode
().
equals
(
sub
.
getType
())||
Type
.
object
.
getCode
().
equals
(
sub
.
getType
()))
return
;
if
(
sub
.
getOptions
().
isUnionKeyField
()&&
sub
.
getOptions
().
isPhysicalField
())
keys
.
add
(
sub
);
});
...
...
@@ -410,13 +423,12 @@ public class PojoSchema {
List
<
PojoSchema
>
keys
=
new
ArrayList
<>();
Map
<
String
,
PojoSchema
>
unions
=
new
LinkedHashMap
<>();
if
(
keys
.
isEmpty
())
{
getProperties
().
values
().
forEach
(
sub
->{
if
(
sub
.
getOptions
().
isUnionKeyField
()&&
sub
.
getOptions
().
isPhysicalField
())
keys
.
add
(
sub
);
});
}
getProperties
().
values
().
forEach
(
sub
->{
if
(
Type
.
array
.
getCode
().
equals
(
sub
.
getType
())||
Type
.
object
.
getCode
().
equals
(
sub
.
getType
()))
return
;
if
(
sub
.
getOptions
().
isUnionKeyField
()&&
sub
.
getOptions
().
isPhysicalField
())
keys
.
add
(
sub
);
});
if
(
keys
.
size
()>
0
)
{
keys
.
sort
((
o1
,
o2
)
->
o1
.
getOptions
().
getUnionKey
().
compareTo
(
o2
.
getOptions
().
getUnionKey
()));
keys
.
forEach
(
sub
->
unions
.
put
(
sub
.
getOptions
().
getFieldName
(),
sub
));
...
...
@@ -657,19 +669,16 @@ public class PojoSchema {
for
(
Map
.
Entry
<
String
,
PojoSchema
>
entrySet:
refProperties
.
entrySet
())
{
PojoSchema
prop
=
entrySet
.
getValue
();
if
(
prop
.
getOptions
()!=
null
)
{
if
(
"PICKUP"
.
equalsIgnoreCase
(
prop
.
getOptions
().
getFieldType
()))
{
if
(!
ObjectUtils
.
isEmpty
(
parent
.
getKey
()))
data
.
set
(
entrySet
.
getKey
().
toLowerCase
(),
parent
.
getKey
());
if
(
parent
.
keySet
().
size
()==
1
)
break
;
}
String
refFieldCodeName
=
prop
.
getOptions
().
getRefFieldCodeName
();
if
((!
StringUtils
.
isEmpty
(
refFieldCodeName
))&&
parent
.
get
(
refFieldCodeName
.
toLowerCase
())!=
null
)
data
.
set
(
entrySet
.
getKey
().
toLowerCase
(),
parent
.
get
(
refFieldCodeName
.
toLowerCase
()));
if
(
"PICKUP"
.
equalsIgnoreCase
(
prop
.
getOptions
().
getFieldType
()))
{
if
(!
ObjectUtils
.
isEmpty
(
parent
.
getKey
()))
data
.
set
(
entrySet
.
getKey
().
toLowerCase
(),
parent
.
getKey
());
if
(
parent
.
keySet
().
size
()==
1
)
break
;
}
String
refFieldCodeName
=
prop
.
getOptions
().
getRefFieldCodeName
();
if
((!
StringUtils
.
isEmpty
(
refFieldCodeName
))&&
parent
.
get
(
refFieldCodeName
.
toLowerCase
())!=
null
)
data
.
set
(
entrySet
.
getKey
().
toLowerCase
(),
parent
.
get
(
refFieldCodeName
.
toLowerCase
()));
}
if
(
refProperties
.
size
()>
1
)
...
...
@@ -686,6 +695,54 @@ public class PojoSchema {
return
data
;
}
public
BaseData
fillDefaultValue
(
BaseData
data
,
boolean
newFlag
)
{
AuthenticationUser
curUser
=
AuthenticationUser
.
getAuthenticationUser
();
if
(
StringUtils
.
isEmpty
(
curUser
.
getUserid
()))
{
curUser
.
setUserid
(
data
.
getStringValue
(
"SRF_PERSONID"
));
curUser
.
setPersonname
(
data
.
getStringValue
(
"SRF_PERSONNAME"
));
}
getProperties
().
values
().
forEach
(
sub
->
{
if
(
Type
.
array
.
getCode
().
equals
(
sub
.
getType
())
||
Type
.
object
.
getCode
().
equals
(
sub
.
getType
())
||
!
sub
.
getOptions
().
isPhysicalField
()
||
(!
StringUtils
.
isEmpty
(
sub
.
getOptions
().
getDefaultValue
())))
return
;
if
(
newFlag
&&(!
ObjectUtils
.
isEmpty
(
data
.
get
(
sub
.
getName
().
toLowerCase
()))))
return
;
String
predefined
=
this
.
getOptions
().
getPredefined
();
if
(!
newFlag
)
{
if
(
predefined
.
equals
(
"UPDATEDATE"
))
data
.
set
(
sub
.
getName
().
toLowerCase
(),
new
Timestamp
(
System
.
currentTimeMillis
()));
else
if
(
predefined
.
equals
(
"UPDATEMAN"
))
data
.
set
(
sub
.
getName
().
toLowerCase
(),
curUser
.
getUserid
());
else
if
(
predefined
.
equals
(
"UPDATEMANNAME"
))
data
.
set
(
sub
.
getName
().
toLowerCase
(),
curUser
.
getPersonname
());
return
;
}
String
DV
=
sub
.
getOptions
().
getDefaultValue
();
String
defaultValueType
=
""
;
String
defaultValue
=
""
;
if
(
DV
.
startsWith
(
"$"
))
{
DV
=
DV
.
replace
(
"${"
,
""
).
replace
(
"}"
,
""
);
String
dvs
[]
=
DV
.
split
(
"[.]"
);
if
(
dvs
.
length
>=
1
)
defaultValueType
=
dvs
[
0
];
if
(
dvs
.
length
>=
2
)
defaultValue
=
dvs
[
1
];
}
else
defaultValue
=
DV
;
});
return
data
;
}
public
FilterData
fillParentFilter
(
FilterData
data
)
{
if
(
ObjectUtils
.
isEmpty
(
data
.
getParentDatas
()))
...
...
@@ -698,13 +755,10 @@ public class PojoSchema {
for
(
Map
.
Entry
<
String
,
PojoSchema
>
keyset:
this
.
getRefProperties
(
refSchema
).
entrySet
())
{
PojoSchema
prop
=
keyset
.
getValue
();
if
(
prop
.
getOptions
()!=
null
)
{
if
(
"PICKUP"
.
equalsIgnoreCase
(
prop
.
getOptions
().
getFieldType
()))
{
if
(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getFieldName
()))
data
.
set
(
"n_"
+
prop
.
getOptions
().
getFieldName
()+
"_eq"
,
parent
.
getKey
());
break
;
}
if
(
"PICKUP"
.
equalsIgnoreCase
(
prop
.
getOptions
().
getFieldType
()))
{
if
(!
StringUtils
.
isEmpty
(
prop
.
getOptions
().
getFieldName
()))
data
.
set
(
"n_"
+
prop
.
getOptions
().
getFieldName
()+
"_eq"
,
parent
.
getKey
());
break
;
}
}
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/TransUtils.java
浏览文件 @
e8233e50
...
...
@@ -4,6 +4,7 @@ import cn.ibizlab.core.data.domain.POModel;
import
cn.ibizlab.core.data.lite.*
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.LinkedHashMap
;
...
...
@@ -102,7 +103,7 @@ public class TransUtils {
}
else
{
property
.
setPropertyType
(
PojoModel
.
PropertyType
.
valueOf
(
sub
.
getType
()));
if
(
sub
.
getOptions
()!=
null
&&(!
StringUtils
.
isEmpty
(
sub
.
getOptions
().
getDict
()
)))
if
(
!
StringUtils
.
isEmpty
(
sub
.
getOptions
().
getDict
(
)))
property
.
setDict
(
sub
.
getOptions
().
getDict
());
}
...
...
@@ -140,9 +141,13 @@ public class TransUtils {
.
setOptions
(
new
PojoOption
().
setAll
(
JSONObject
.
parseObject
(
JSON
.
toJSONString
(
fieldModel
.
getField
()))));
Object
searchModes
=
fieldModel
.
getField
().
get
(
"search_modes"
);
if
(
searchModes
!=
null
)
if
(
!
ObjectUtils
.
isEmpty
(
searchModes
)
)
sub
.
getOptions
().
setSearchModes
(
searchModes
.
toString
());
Object
defaultValue
=
fieldModel
.
getField
().
get
(
"default_value"
);
if
(!
ObjectUtils
.
isEmpty
(
defaultValue
))
sub
.
getOptions
().
setDefaultValue
(
defaultValue
.
toString
());
sub
.
getOptions
().
remove
(
"ext_params"
);
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/service/impl/BaseDataService.java
浏览文件 @
e8233e50
...
...
@@ -240,12 +240,9 @@ public class BaseDataService implements IDataService {
{
refProperties
.
entrySet
().
forEach
(
propEntry
->{
PojoSchema
prop
=
propEntry
.
getValue
();
if
(
prop
.
getOptions
()!=
null
)
{
String
refFieldCodeName
=
prop
.
getOptions
().
getRefFieldCodeName
();
if
((!
StringUtils
.
isEmpty
(
refFieldCodeName
))&&
parentData
.
get
(
refFieldCodeName
.
toLowerCase
())!=
null
)
et
.
set
(
propEntry
.
getKey
().
toLowerCase
(),
parentData
.
get
(
refFieldCodeName
.
toLowerCase
()));
}
String
refFieldCodeName
=
prop
.
getOptions
().
getRefFieldCodeName
();
if
((!
StringUtils
.
isEmpty
(
refFieldCodeName
))&&
parentData
.
get
(
refFieldCodeName
.
toLowerCase
())!=
null
)
et
.
set
(
propEntry
.
getKey
().
toLowerCase
(),
parentData
.
get
(
refFieldCodeName
.
toLowerCase
()));
});
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录