Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdata
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdata
提交
d43bc8ba
提交
d43bc8ba
编写于
8月 26, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
url 兼容map
上级
e0ab321f
变更
3
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
70 行增加
和
17 行删除
+70
-17
DOModel.java
...re/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
+20
-1
PojoSchema.java
.../src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
+42
-8
TransUtils.java
.../src/main/java/cn/ibizlab/core/data/model/TransUtils.java
+8
-8
未找到文件。
ibzdata-core/src/main/java/cn/ibizlab/core/data/domain/DOModel.java
浏览文件 @
d43bc8ba
...
...
@@ -11,6 +11,7 @@ import com.alibaba.fastjson.annotation.JSONField;
import
com.baomidou.mybatisplus.core.toolkit.IdWorker
;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
org.springframework.util.DigestUtils
;
import
org.springframework.util.ObjectUtils
;
import
cn.ibizlab.util.helper.DataObject
;
import
java.io.Serializable
;
...
...
@@ -192,7 +193,25 @@ public class DOModel implements Serializable {
if
(
PojoSchema
.
Type
.
integer
.
getCode
().
equals
(
keyProperty
.
getType
())||
PojoSchema
.
Type
.
number
.
getCode
().
equals
(
keyProperty
.
getType
()))
key
=
IdWorker
.
getId
();
else
key
=
IdWorker
.
get32UUID
();
{
Set
<
String
>
unionKeys
=
this
.
getSchema
().
getUnionKeys
();
if
(!
ObjectUtils
.
isEmpty
(
unionKeys
))
{
for
(
String
unionkey:
unionKeys
)
{
if
(
ObjectUtils
.
isEmpty
(
data
.
get
(
unionkey
.
toLowerCase
())))
return
null
;
if
(!
StringUtils
.
isEmpty
(
key
))
key
+=
"||"
;
else
key
+=
data
.
getStringValue
(
unionkey
.
toLowerCase
());
}
key
=
DigestUtils
.
md5DigestAsHex
(
key
.
toString
().
getBytes
());
}
else
key
=
IdWorker
.
get32UUID
();
}
data
.
set
(
keyPropertyName
,
key
);
}
else
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/PojoSchema.java
浏览文件 @
d43bc8ba
...
...
@@ -139,7 +139,6 @@ public class PojoSchema {
if
(
properties
!=
null
)
{
properties
.
values
().
forEach
(
prop
->{
PojoSchema
item
=
null
;
if
(
Type
.
object
.
getCode
().
equalsIgnoreCase
(
prop
.
getType
())&&(!
StringUtils
.
isEmpty
(
prop
.
getRef
())))
item
=
prop
;
...
...
@@ -149,9 +148,6 @@ public class PojoSchema {
item
=
prop
.
getItems
();
else
return
;
});
}
built
=
true
;
...
...
@@ -235,6 +231,11 @@ public class PojoSchema {
@JSONField
(
serialize
=
false
)
private
Map
<
String
,
PojoSchema
>
keyMap
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Set
<
String
>
unionKeys
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
synchronized
Map
<
String
,
PojoSchema
>
getKeyMap
()
...
...
@@ -243,24 +244,55 @@ public class PojoSchema {
{
if
(
keyMap
==
null
)
{
List
<
PojoSchema
>
keys
=
new
ArrayList
<>();
keyMap
=
new
LinkedHashMap
<>();
getProperties
().
values
().
forEach
(
sub
->{
if
(
sub
.
getOptions
().
isKeyField
()&&
sub
.
getOptions
().
isPhysicalField
())
key
Map
.
put
(
sub
.
getOptions
().
getFieldName
(),
sub
);
key
s
.
add
(
sub
);
});
if
(
key
Map
.
isEmpty
())
if
(
key
s
.
isEmpty
())
{
getProperties
().
values
().
forEach
(
sub
->{
if
(
sub
.
getOptions
().
isUnionKeyField
()&&
sub
.
getOptions
().
isPhysicalField
())
key
Map
.
put
(
sub
.
getOptions
().
getFieldName
(),
sub
);
key
s
.
add
(
sub
);
});
}
if
(
keys
.
size
()>
0
)
keys
.
sort
(
(
o1
,
o2
)
->
o1
.
getOptions
().
getUnionKey
().
compareTo
(
o2
.
getOptions
().
getUnionKey
())
);
keys
.
forEach
(
sub
->
keyMap
.
put
(
sub
.
getOptions
().
getFieldName
(),
sub
));
}
}
return
keyMap
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
synchronized
Set
<
String
>
getUnionKeys
()
{
if
(
Type
.
object
.
getCode
().
equals
(
this
.
type
))
{
if
(
unionKeys
==
null
)
{
List
<
PojoSchema
>
keys
=
new
ArrayList
<>();
Set
<
String
>
unions
=
new
LinkedHashSet
<>();
if
(
keys
.
isEmpty
())
{
getProperties
().
values
().
forEach
(
sub
->{
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
.
add
(
sub
.
getName
()));
unionKeys
=
unions
;
}
}
}
return
unionKeys
;
}
//// array
...
...
@@ -273,7 +305,9 @@ public class PojoSchema {
@JSONField
(
ordinal
=
23
)
private
Boolean
uniqueItems
;
public
void
setUniqueItems
(
Boolean
uniqueItems
)
{
this
.
uniqueItems
=
uniqueItems
;
}
/// String
...
...
ibzdata-core/src/main/java/cn/ibizlab/core/data/model/TransUtils.java
浏览文件 @
d43bc8ba
...
...
@@ -267,8 +267,6 @@ public class TransUtils {
if
(
pojoSchema
.
getKeyMap
()!=
null
&&
pojoSchema
.
getKeyMap
().
containsKey
(
column
.
getName
()))
{
String
primaryKeyName
=
"PK_"
+
poSchema
.
getName
().
toUpperCase
()+
"_"
+
column
.
getName
().
toUpperCase
();
if
(
primaryKeyName
.
length
()>
30
)
primaryKeyName
=
primaryKeyName
.
substring
(
0
,
30
);
column
.
getConstraints
(
true
).
setPrimaryKey
(
true
).
setPrimaryKeyName
(
primaryKeyName
);
}
if
(
sub
.
getOptions
().
isLogicValidField
())
...
...
@@ -285,8 +283,6 @@ public class TransUtils {
{
String
fkName
=
sub
.
getOptions
().
getRelationName
().
toUpperCase
();
if
((!
StringUtils
.
isEmpty
(
sub
.
getOptions
().
getRefTableName
()))&&(!
StringUtils
.
isEmpty
(
fkName
)))
{
if
(
fkName
.
length
()>
30
)
fkName
=
fkName
.
substring
(
0
,
30
);
column
.
getConstraints
(
true
).
setReferencedTableName
(
sub
.
getOptions
().
getRefTableName
()).
setReferencedColumnNames
(
sub
.
getOptions
().
getRefFieldName
()).
setForeignKeyName
(
fkName
);
poSchema
.
addForeignKeyConstraint
(
new
POSchema
.
ForeignKeyConstraint
().
setConstraintName
(
fkName
).
setBaseTableName
(
poSchema
.
getName
()).
setBaseColumnNames
(
column
.
getName
()).
setReferencedTableName
(
sub
.
getOptions
().
getRefTableName
()).
setReferencedColumnNames
(
sub
.
getOptions
().
getRefFieldName
()));
...
...
@@ -338,8 +334,6 @@ public class TransUtils {
if
(
keyMap
.
containsKey
(
column
.
getName
()))
{
String
primaryKeyName
=
"PK_"
+
poSchema
.
getName
().
toUpperCase
()+
"_"
+
column
.
getName
().
toUpperCase
();
if
(
primaryKeyName
.
length
()>
30
)
primaryKeyName
=
primaryKeyName
.
substring
(
0
,
30
);
column
.
getConstraints
(
true
).
setPrimaryKey
(
true
).
setPrimaryKeyName
(
primaryKeyName
);
}
if
(
fieldModel
.
isLogicValidField
())
...
...
@@ -359,8 +353,6 @@ public class TransUtils {
RelationshipModel
relationshipModel
=
relationshipModelMap
.
get
(
sub
.
getRelationName
());
String
fkName
=
sub
.
getRelationName
().
toUpperCase
();
if
(
relationshipModel
!=
null
&&(!
StringUtils
.
isEmpty
(
relationshipModel
.
getTableName
()))&&(!
StringUtils
.
isEmpty
(
fkName
)))
{
if
(
fkName
.
length
()>
30
)
fkName
=
fkName
.
substring
(
0
,
30
);
column
.
getConstraints
(
true
).
setReferencedTableName
(
relationshipModel
.
getTableName
())
.
setReferencedColumnNames
(
sub
.
getRefFieldName
()).
setForeignKeyName
(
fkName
);
...
...
@@ -369,6 +361,14 @@ public class TransUtils {
.
setReferencedTableName
(
relationshipModel
.
getTableName
()).
setReferencedColumnNames
(
sub
.
getRefFieldName
()));
}
}
else
if
((!
StringUtils
.
isEmpty
(
sub
.
getRelationName
())))
{
RelationshipModel
relationshipModel
=
relationshipModelMap
.
get
(
sub
.
getRelationName
());
String
fkName
=
sub
.
getRelationName
().
toUpperCase
();
if
(
relationshipModel
!=
null
&&(!
StringUtils
.
isEmpty
(
relationshipModel
.
getTableName
()))&&(!
StringUtils
.
isEmpty
(
fkName
)))
{
column
.
getConstraints
(
true
).
setReferencedTableName
(
relationshipModel
.
getTableName
())
.
setReferencedColumnNames
(
sub
.
getRefFieldName
());
}
}
if
(!
fieldModel
.
isPhysicalField
())
poSchema
.
addTransient
(
column
.
setComputed
(
true
));
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录