Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
224da2a8
提交
224da2a8
编写于
12月 15, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
拉平model属性
上级
c6c2fbb9
变更
15
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
360 行增加
和
222 行删除
+360
-222
BaseModel.java
...ore/src/main/java/cn/ibizlab/codegen/model/BaseModel.java
+38
-0
DataSetModel.java
.../src/main/java/cn/ibizlab/codegen/model/DataSetModel.java
+7
-24
DynamicModelStorage.java
...in/java/cn/ibizlab/codegen/model/DynamicModelStorage.java
+6
-9
EntityModel.java
...e/src/main/java/cn/ibizlab/codegen/model/EntityModel.java
+17
-53
FieldModel.java
...re/src/main/java/cn/ibizlab/codegen/model/FieldModel.java
+11
-104
LookupModel.java
...e/src/main/java/cn/ibizlab/codegen/model/LookupModel.java
+0
-17
POSchema.java
...core/src/main/java/cn/ibizlab/codegen/model/POSchema.java
+7
-8
PropType.java
...core/src/main/java/cn/ibizlab/codegen/model/PropType.java
+80
-0
RelationshipModel.java
...main/java/cn/ibizlab/codegen/model/RelationshipModel.java
+6
-3
SystemModel.java
...e/src/main/java/cn/ibizlab/codegen/model/SystemModel.java
+6
-0
TransUtils.java
...re/src/main/java/cn/ibizlab/codegen/model/TransUtils.java
+2
-2
MustacheCollector.java
...java/cn/ibizlab/codegen/templating/MustacheCollector.java
+177
-0
MustacheEngineAdapter.java
.../cn/ibizlab/codegen/templating/MustacheEngineAdapter.java
+1
-1
pom.xml
...bizlab-generator-core/src/main/resources/templ/r7/pom.xml
+1
-0
{{entities}}.java
...java/{{packageName}}/{{modules}}/domain/{{entities}}.java
+1
-1
未找到文件。
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/BaseModel.java
0 → 100644
浏览文件 @
224da2a8
package
cn
.
ibizlab
.
codegen
.
model
;
public
class
BaseModel
{
protected
Object
opt
;
public
<
T
>
T
setOpt
(
Object
opt
)
{
this
.
opt
=
opt
;
return
(
T
)
this
;
}
protected
DataObj
extParams
=
new
DataObj
();
public
<
T
>
T
set
(
String
key
,
Object
val
)
{
extParams
.
set
(
key
,
val
);
return
(
T
)
this
;
}
public
Object
get
(
String
key
)
{
return
extParams
.
get
(
key
);
}
public
Object
getOpt
()
{
return
opt
;
}
public
DataObj
getExtParams
()
{
return
extParams
;
}
public
<
T
>
T
setExtParams
(
DataObj
extParams
)
{
this
.
extParams
=
extParams
;
return
(
T
)
this
;
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/DataSetModel.java
浏览文件 @
224da2a8
...
...
@@ -9,6 +9,7 @@ import lombok.Getter;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
net.ibizsys.model.dataentity.ds.IPSDEDataSet
;
/**
* 实体[数据集]
...
...
@@ -17,60 +18,42 @@ import lombok.experimental.Accessors;
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonIgnoreProperties
(
value
=
"handler"
)
@ApiModel
(
"数据集"
)
public
class
DataSetModel
{
public
class
DataSetModel
extends
BaseModel
{
/**
* 标识
*/
@JSONField
(
name
=
"dataset_id"
)
@JsonProperty
(
"dataset_id"
)
@ApiModelProperty
(
"标识"
)
private
String
datasetId
;
/**
* 名称
*/
@JSONField
(
name
=
"dataset_name"
)
@JsonProperty
(
"dataset_name"
)
@ApiModelProperty
(
"名称"
)
private
String
datasetName
;
/**
* 实体标识
*/
@JSONField
(
name
=
"entity_id"
)
@JsonProperty
(
"entity_id"
)
@ApiModelProperty
(
"实体标识"
)
private
String
entityId
;
/**
* 实体
*/
@JSONField
(
name
=
"entity_name"
)
@JsonProperty
(
"entity_name"
)
@ApiModelProperty
(
"实体"
)
private
String
entityName
;
/**
* 代码名称
*/
@JSONField
(
name
=
"code_name"
)
@JsonProperty
(
"code_name"
)
@ApiModelProperty
(
"代码名称"
)
private
String
codeName
;
/**
* 代码
*/
@JSONField
(
name
=
"ds_code"
)
@JsonProperty
(
"ds_code"
)
@ApiModelProperty
(
"代码"
)
private
String
dsCode
;
/**
* 模型
*/
@JSONField
(
name
=
"ds_model"
)
@JsonProperty
(
"ds_model"
)
@ApiModelProperty
(
"模型"
)
private
String
dsModel
;
public
IPSDEDataSet
getDataSets
()
{
return
(
IPSDEDataSet
)
opt
;
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/DynamicModelStorage.java
浏览文件 @
224da2a8
...
...
@@ -89,9 +89,8 @@ public class DynamicModelStorage {
IPSSystem
iPSSystem
=
getPSSystem
();
IPSDataEntity
dataEntity
=
iPSSystem
.
getPSDataEntity
(
entity
,
true
);
Assert
.
notNull
(
dataEntity
,
"未找到对应的实体模型:"
+
entity
);
EntityModel
entityModel
=
new
EntityModel
();
EntityModel
entityModel
=
new
EntityModel
()
.
setOpt
(
dataEntity
)
;
entityModel
.
setStorageMode
(
dataEntity
.
getStorageMode
());
entityModel
.
setEntity
(
dataEntity
);
List
<
String
>
dsTypes
=
new
ArrayList
<>();
if
(
dataEntity
.
getAllPSDEDBConfigs
()!=
null
)
...
...
@@ -111,8 +110,7 @@ public class DynamicModelStorage {
{
for
(
IPSDERBase
der
:
dataEntity
.
getMinorPSDERs
())
{
RelationshipModel
rel
=
new
RelationshipModel
();
rel
.
setRelation
(
der
);
RelationshipModel
rel
=
new
RelationshipModel
().
setOpt
(
der
);
rel
.
setName
(
der
.
getName
()).
setRelationType
(
der
.
getDERType
()).
setCodeName
(
der
.
getCodeName
()).
setEntityId
(
der
.
getMajorPSDataEntity
().
getId
())
.
setEntityCodeName
(
der
.
getMajorPSDataEntity
().
getCodeName
()).
setEntityName
(
der
.
getMajorPSDataEntity
().
getName
())
.
setEntityLogicName
(
der
.
getMajorPSDataEntity
().
getLogicName
()).
setTableName
(
der
.
getMajorPSDataEntity
().
getTableName
());
...
...
@@ -141,8 +139,7 @@ public class DynamicModelStorage {
{
if
(
StringUtils
.
isEmpty
(
der
.
getMinorCodeName
()))
continue
;
RelationshipModel
rel
=
new
RelationshipModel
();
rel
.
setRelation
(
der
);
RelationshipModel
rel
=
new
RelationshipModel
().
setOpt
(
der
);
rel
.
setName
(
der
.
getName
()).
setRelationType
(
der
.
getDERType
()).
setCodeName
(
der
.
getMinorCodeName
()).
setEntityId
(
der
.
getMinorPSDataEntity
().
getId
())
.
setEntityCodeName
(
der
.
getMinorPSDataEntity
().
getCodeName
()).
setEntityName
(
der
.
getMinorPSDataEntity
().
getName
())
.
setEntityLogicName
(
der
.
getMinorPSDataEntity
().
getLogicName
()).
setTableName
(
der
.
getMinorPSDataEntity
().
getTableName
());
...
...
@@ -169,8 +166,7 @@ public class DynamicModelStorage {
String
dict
=
null
;
try
{
dict
=
defield
.
getPSCodeList
()!=
null
?
defield
.
getPSCodeList
().
getCodeName
():
null
;
}
catch
(
Exception
ex
){}
FieldModel
fieldModel
=
new
FieldModel
();
fieldModel
.
setField
(
defield
);
FieldModel
fieldModel
=
new
FieldModel
().
setOpt
(
defield
);
if
(
defield
.
getAllPSDEFDTColumns
()!=
null
)
{
...
...
@@ -347,7 +343,8 @@ public class DynamicModelStorage {
}
}
}
DataSetModel
dsModel
=
new
DataSetModel
().
setDatasetId
(
entityModel
.
getEntityName
().
toLowerCase
()+
"-ds-"
+
dataSet
.
getCodeName
()+
"-"
+
entry
.
getKey
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
))
DataSetModel
dsModel
=
new
DataSetModel
().
setOpt
(
dataSet
);
dsModel
.
setDatasetId
(
entityModel
.
getEntityName
().
toLowerCase
()+
"-ds-"
+
dataSet
.
getCodeName
()+
"-"
+
entry
.
getKey
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
))
.
setDatasetName
(
dataSet
.
getLogicName
()).
setCodeName
(
dataSet
.
getCodeName
())
.
setEntityId
(
entityModel
.
getEntityId
()).
setEntityName
(
entityModel
.
getEntityName
()).
setDsCode
(
entry
.
getValue
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
)).
setDsModel
(
sql
);
entityModel
.
addDataSet
(
dsModel
);
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/EntityModel.java
浏览文件 @
224da2a8
...
...
@@ -19,7 +19,7 @@ import java.util.Map;
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
EntityModel
{
public
class
EntityModel
extends
BaseModel
{
...
...
@@ -53,11 +53,14 @@ public class EntityModel {
public
String
getModule
()
{
if
(
getEntity
().
getPSSystemModule
()!=
null
)
return
getEntity
().
getPSSystemModule
().
getCodeName
();
return
"
U
ngroup"
;
return
getEntity
().
getPSSystemModule
().
getCodeName
()
.
toLowerCase
()
;
return
"
u
ngroup"
;
}
private
IPSDataEntity
entity
;
public
IPSDataEntity
getEntity
(){
return
(
IPSDataEntity
)
opt
;
}
private
List
<
DataSetModel
>
dataSets
;
...
...
@@ -103,7 +106,7 @@ public class EntityModel {
references
.
forEach
(
ship
->{
if
(!
StringUtils
.
isEmpty
(
ship
.
getCodeName
()))
refMaps
.
put
(
ship
.
getCodeName
(),
ship
);
if
(!
StringUtils
.
isEmpty
(
ship
.
get
Relation
()))
{
if
(!
StringUtils
.
isEmpty
(
ship
.
get
Name
()))
{
String
fkname
=
DataObject
.
getStringValue
(
ship
.
getRelation
().
getName
(),
""
);
if
(!
StringUtils
.
isEmpty
(
fkname
))
refMaps
.
put
(
fkname
,
ship
);
...
...
@@ -135,7 +138,7 @@ public class EntityModel {
{
fieldMap
=
new
LinkedHashMap
<>();
fields
.
forEach
(
field
->{
fieldMap
.
put
(
field
.
get
Column
Name
(),
field
);
fieldMap
.
put
(
field
.
get
Field
Name
(),
field
);
fieldMap
.
put
(
field
.
getCodeName
(),
field
);
});
}
...
...
@@ -158,26 +161,11 @@ public class EntityModel {
return
lastModifyField
;
}
private
boolean
isLogicValid
=
true
;
public
boolean
isLogicValid
()
{
if
(
isLogicValid
&&
logicValidField
==
null
)
{
if
(
fields
!=
null
)
{
for
(
FieldModel
fieldModel
:
fields
)
{
if
(
fieldModel
.
isLogicValidField
())
{
logicValidField
=
fieldModel
;
return
isLogicValid
;
}
}
}
isLogicValid
=
false
;
}
return
isLogicValid
;
return
getEntity
().
isLogicValid
();
}
...
...
@@ -185,7 +173,7 @@ public class EntityModel {
public
FieldModel
getLogicValidField
()
{
if
(
isLogicValid
&&
logicValidField
==
null
)
{
if
(
isLogicValid
()
&&
logicValidField
==
null
)
{
if
(
fields
!=
null
)
{
for
(
FieldModel
fieldModel
:
fields
)
{
if
(
fieldModel
.
isLogicValidField
())
{
...
...
@@ -194,33 +182,24 @@ public class EntityModel {
}
}
}
isLogicValid
=
false
;
}
return
logicValidField
;
}
private
String
validLogicValue
;
public
String
getValidLogicValue
()
{
if
(
StringUtils
.
isEmpty
(
validLogicValue
))
validLogicValue
=
this
.
getEntity
().
getValidLogicValue
();
String
validLogicValue
=
this
.
getEntity
().
getValidLogicValue
();
if
(
StringUtils
.
isEmpty
(
validLogicValue
))
validLogicValue
=
"1"
;
return
validLogicValue
;
}
private
String
invalidLogicValue
;
public
String
getInvalidLogicValue
()
{
if
(
StringUtils
.
isEmpty
(
invalidLogicValue
))
invalidLogicValue
=
this
.
getEntity
().
getInvalidLogicValue
();
String
invalidLogicValue
=
this
.
getEntity
().
getInvalidLogicValue
();
if
(
StringUtils
.
isEmpty
(
invalidLogicValue
))
invalidLogicValue
=
"0"
;
return
invalidLogicValue
;
...
...
@@ -233,7 +212,7 @@ public class EntityModel {
public
FieldModel
getKeyField
()
{
if
(
fields
!=
null
&&
keyField
==
null
)
for
(
FieldModel
fieldModel:
fields
)
if
(
fieldModel
.
isKeyField
())
{
if
(
fieldModel
.
isKey
DE
Field
())
{
keyField
=
fieldModel
;
return
keyField
;
}
...
...
@@ -258,7 +237,7 @@ public class EntityModel {
public
List
<
FieldModel
>
getKeyFields
()
{
if
(
this
.
getKeyField
()!=
null
&&
this
.
getKeyField
().
isPh
ysical
Field
())
{
if
(
this
.
getKeyField
()!=
null
&&
this
.
getKeyField
().
isPh
isicalDE
Field
())
{
List
<
FieldModel
>
keyFields
=
new
ArrayList
<>();
keyFields
.
add
(
getKeyField
());
return
keyFields
;
...
...
@@ -329,12 +308,8 @@ public class EntityModel {
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
Map
<
String
,
POSchema
>
poSchemas
;
@JSONField
(
serialize
=
false
)
@JsonIgnore
public
POSchema
getDefaultPOSchema
()
{
return
getPOSchema
(
"default"
);
...
...
@@ -374,18 +349,7 @@ public class EntityModel {
return
null
;
}
private
DataObj
extParams
=
new
DataObj
();
public
EntityModel
set
(
String
key
,
Object
val
)
{
extParams
.
set
(
key
,
val
);
return
this
;
}
public
Object
get
(
String
key
)
{
return
key
;
}
public
String
getStringValue
(
String
key
,
String
defaultVal
)
{
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/FieldModel.java
浏览文件 @
224da2a8
...
...
@@ -18,35 +18,32 @@ import java.util.Set;
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
FieldModel
{
public
class
FieldModel
extends
BaseModel
{
public
String
getCodeName
()
{
return
getField
().
getCodeName
();
}
public
String
getFieldName
()
{
return
getField
().
getName
();
}
public
String
getColumnName
(){
return
getField
().
getName
();
}
public
String
getLogicName
()
{
return
getField
().
getLogicName
();
}
public
Data
Type
getType
()
public
Prop
Type
getType
()
{
return
DataType
.
findTypeNam
e
(
this
.
getField
().
getStdDataType
());
return
PropType
.
findTyp
e
(
this
.
getField
().
getStdDataType
());
}
private
String
expression
;
private
IPSDEField
field
;
public
IPSDEField
getField
()
{
return
(
IPSDEField
)
opt
;
}
private
RelationshipModel
reference
;
...
...
@@ -54,45 +51,31 @@ public class FieldModel {
private
String
refFieldCodeName
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isPhysicalField
()
public
boolean
isPhisicalDEField
()
{
return
this
.
getField
().
isPhisicalDEField
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isKeyField
()
public
boolean
isKeyDEField
()
{
return
this
.
getField
().
isKeyDEField
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isLogicValidField
()
{
return
"LOGICVALID"
.
equals
(
this
.
getField
().
getPredefinedType
());
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isLastModifyField
()
{
return
"UPDATEDATE"
.
equals
(
this
.
getField
().
getPredefinedType
());
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isCreateTimeField
()
{
return
"CREATEDATE"
.
equals
(
this
.
getField
().
getPredefinedType
());
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isUnionKeyField
()
{
return
!
StringUtils
.
isEmpty
(
this
.
getField
().
getUnionKeyValue
());
...
...
@@ -133,13 +116,6 @@ public class FieldModel {
}
private
DataObj
extParams
=
new
DataObj
();
public
FieldModel
set
(
String
key
,
Object
val
)
{
extParams
.
set
(
key
,
val
);
return
this
;
}
public
String
getStringValue
(
String
key
,
String
defaultVal
)
{
...
...
@@ -148,78 +124,9 @@ public class FieldModel {
public
String
getColumnName
(
String
dsType
)
{
return
this
.
getStringValue
(
"column-"
+
dsType
.
toLowerCase
(),
get
Column
Name
());
return
this
.
getStringValue
(
"column-"
+
dsType
.
toLowerCase
(),
get
Field
Name
());
}
public
static
enum
DataType
{
UNKNOWN
(
0
,
"UNKNOWN"
,
"string"
,
"String"
),
BIGINT
(
1
,
"BIGINT"
,
"number"
,
"Long"
),
BINARY
(
2
,
"BINARY"
,
"string"
,
"String"
),
BIT
(
3
,
"BIT"
,
"boolean"
,
"Boolean"
),
CHAR
(
4
,
"CHAR"
,
"string"
,
"String"
),
DATETIME
(
5
,
"DATETIME"
,
"string"
,
"Timestamp"
),
DECIMAL
(
6
,
"DECIMAL"
,
"number"
,
"BigDecimal"
),
FLOAT
(
7
,
"FLOAT"
,
"number"
,
"BigDecimal"
),
IMAGE
(
8
,
"IMAGE"
,
"string"
,
"String"
),
INT
(
9
,
"INT"
,
"number"
,
"Integer"
),
MONEY
(
10
,
"MONEY"
,
"number"
,
"BigDecimal"
),
NCHAR
(
11
,
"NCHAR"
,
"string"
,
"String"
),
NTEXT
(
12
,
"NTEXT"
,
"string"
,
"String"
),
NVARCHAR
(
13
,
"NVARCHAR"
,
"string"
,
"String"
),
NUMERIC
(
14
,
"NUMERIC"
,
"number"
,
"BigDecimal"
),
REAL
(
15
,
"REAL"
,
"number"
,
"Float"
),
SMALLDATETIME
(
16
,
"SMALLDATETIME"
,
"string"
,
"Timestamp"
),
SMALLINT
(
17
,
"SMALLINT"
,
"number"
,
"Integer"
),
SMALLMONEY
(
18
,
"SMALLMONEY"
,
"number"
,
"BigDecimal"
),
SQL_VARIANT
(
19
,
"SQL_VARIANT"
,
"string"
,
"String"
),
SYSNAME
(
20
,
"SYSNAME"
,
"string"
,
"String"
),
TEXT
(
21
,
"TEXT"
,
"string"
,
"String"
),
TIMESTAMP
(
22
,
"TIMESTAMP"
,
"string"
,
"Timestamp"
),
TINYINT
(
23
,
"TINYINT"
,
"number"
,
"Integer"
),
VARBINARY
(
24
,
"VARBINARY"
,
"string"
,
"String"
),
VARCHAR
(
25
,
"VARCHAR"
,
"string"
,
"String"
),
UNIQUEIDENTIFIER
(
26
,
"UNIQUEIDENTIFIER"
,
"string"
,
"String"
),
DATE
(
27
,
"DATE"
,
"string"
,
"Timestamp"
),
TIME
(
28
,
"TIME"
,
"string"
,
"Timestamp"
);
public
final
int
code
;
public
final
String
name
;
public
final
String
prop
;
public
final
String
java
;
private
DataType
(
int
code
,
String
name
,
String
prop
,
String
java
)
{
this
.
code
=
code
;
this
.
name
=
name
;
this
.
prop
=
prop
;
this
.
java
=
java
;
}
public
int
getCode
()
{
return
code
;
}
public
String
getName
()
{
return
name
;
}
public
String
getProp
()
{
return
prop
;
}
public
String
getJava
()
{
return
java
;
}
public
static
DataType
findTypeName
(
Integer
type
)
{
for
(
DataType
userTypeEnum
:
DataType
.
values
())
{
if
(
userTypeEnum
.
getCode
()==
type
)
{
return
userTypeEnum
;
}
}
return
VARCHAR
;
}
}
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/LookupModel.java
浏览文件 @
224da2a8
...
...
@@ -19,39 +19,22 @@ import java.io.Serializable;
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@ApiModel
(
"lookup"
)
public
class
LookupModel
implements
Serializable
{
/**
* 标识
*/
@JSONField
(
name
=
"id"
)
@JsonProperty
(
"id"
)
@ApiModelProperty
(
"标识"
)
private
String
id
;
/**
* 关系标识
*/
@JSONField
(
name
=
"relationId"
)
@JsonProperty
(
"relationId"
)
@ApiModelProperty
(
"关系标识"
)
private
String
relationid
;
/**
* 属性名称
*/
@JSONField
(
name
=
"fieldName"
)
@JsonProperty
(
"fieldName"
)
@ApiModelProperty
(
"属性名称"
)
private
String
fieldname
;
/**
* 引用属性名称
*/
@JSONField
(
name
=
"refFieldName"
)
@JsonProperty
(
"refFieldName"
)
@ApiModelProperty
(
"引用属性名称"
)
private
String
reffieldname
;
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/POSchema.java
浏览文件 @
224da2a8
...
...
@@ -10,6 +10,7 @@ import lombok.Getter;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
net.ibizsys.model.dataentity.IPSDataEntity
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
...
...
@@ -57,7 +58,7 @@ public class POSchema {
@JSONField
(
serialize
=
false
)
@JsonIgnore
private
Object
node
;
private
IPSDataEntity
node
;
@JSONField
(
ordinal
=
7
)
private
List
<
Column
>
columns
;
...
...
@@ -502,22 +503,20 @@ public class POSchema {
@JSONField
(
serialize
=
false
)
public
boolean
isText
()
{
String
type
=
this
.
getType
().
toUpperCase
();
return
type
.
indexOf
(
"TEXT"
)>=
0
||
type
.
indexOf
(
"CHAR"
)>=
0
||
type
.
indexOf
(
"LOB"
)>=
0
;
return
"String"
.
equalsIgnoreCase
(
PropType
.
findByDBType
(
type
).
java
);
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isNumber
()
{
String
type
=
this
.
getType
().
toUpperCase
();
return
type
.
indexOf
(
"NUM"
)>=
0
||
type
.
indexOf
(
"FLOAT"
)>=
0
||
type
.
indexOf
(
"DOUBLE"
)>=
0
||
type
.
indexOf
(
"DECIMAL"
)>=
0
;
return
"BigDecimal"
.
equalsIgnoreCase
(
PropType
.
findByDBType
(
type
).
java
);
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
boolean
isInt
()
{
String
type
=
this
.
getType
().
toUpperCase
(
);
return
type
.
indexOf
(
"INT"
)==
0
;
PropType
propType
=
PropType
.
findByDBType
(
type
);
return
"Long"
.
equalsIgnoreCase
(
propType
.
java
)||
"Integer"
.
equalsIgnoreCase
(
propType
.
java
)
;
}
@JsonIgnore
...
...
@@ -525,7 +524,7 @@ public class POSchema {
public
boolean
isDateTime
()
{
String
type
=
this
.
getType
().
toUpperCase
();
return
type
.
indexOf
(
"DATE"
)>=
0
||
type
.
indexOf
(
"TIME"
)>=
0
;
return
"Timestamp"
.
equalsIgnoreCase
(
PropType
.
findByDBType
(
type
).
java
)
;
}
@JSONField
(
ordinal
=
12
)
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/PropType.java
0 → 100644
浏览文件 @
224da2a8
package
cn
.
ibizlab
.
codegen
.
model
;
public
enum
PropType
{
UNKNOWN
(
0
,
"UNKNOWN"
,
"string"
,
"String"
),
BIGINT
(
1
,
"BIGINT"
,
"number"
,
"Long"
),
BINARY
(
2
,
"BINARY"
,
"string"
,
"String"
),
BIT
(
3
,
"BIT"
,
"boolean"
,
"Boolean"
),
CHAR
(
4
,
"CHAR"
,
"string"
,
"String"
),
DATETIME
(
5
,
"DATETIME"
,
"string"
,
"Timestamp"
),
DECIMAL
(
6
,
"DECIMAL"
,
"number"
,
"BigDecimal"
),
FLOAT
(
7
,
"FLOAT"
,
"number"
,
"BigDecimal"
),
IMAGE
(
8
,
"IMAGE"
,
"string"
,
"String"
),
INT
(
9
,
"INT"
,
"number"
,
"Integer"
),
MONEY
(
10
,
"MONEY"
,
"number"
,
"BigDecimal"
),
NCHAR
(
11
,
"NCHAR"
,
"string"
,
"String"
),
NTEXT
(
12
,
"NTEXT"
,
"string"
,
"String"
),
NVARCHAR
(
13
,
"NVARCHAR"
,
"string"
,
"String"
),
NUMERIC
(
14
,
"NUMERIC"
,
"number"
,
"BigDecimal"
),
REAL
(
15
,
"REAL"
,
"number"
,
"Float"
),
SMALLDATETIME
(
16
,
"SMALLDATETIME"
,
"string"
,
"Timestamp"
),
SMALLINT
(
17
,
"SMALLINT"
,
"number"
,
"Integer"
),
SMALLMONEY
(
18
,
"SMALLMONEY"
,
"number"
,
"BigDecimal"
),
SQL_VARIANT
(
19
,
"SQL_VARIANT"
,
"string"
,
"String"
),
SYSNAME
(
20
,
"SYSNAME"
,
"string"
,
"String"
),
TEXT
(
21
,
"TEXT"
,
"string"
,
"String"
),
TIMESTAMP
(
22
,
"TIMESTAMP"
,
"string"
,
"Timestamp"
),
TINYINT
(
23
,
"TINYINT"
,
"number"
,
"Integer"
),
VARBINARY
(
24
,
"VARBINARY"
,
"string"
,
"String"
),
VARCHAR
(
25
,
"VARCHAR"
,
"string"
,
"String"
),
UNIQUEIDENTIFIER
(
26
,
"UNIQUEIDENTIFIER"
,
"string"
,
"String"
),
DATE
(
27
,
"DATE"
,
"string"
,
"Timestamp"
),
TIME
(
28
,
"TIME"
,
"string"
,
"Timestamp"
);
public
final
int
code
;
public
final
String
name
;
public
final
String
json
;
public
final
String
java
;
private
PropType
(
int
code
,
String
name
,
String
json
,
String
java
)
{
this
.
code
=
code
;
this
.
name
=
name
;
this
.
json
=
json
;
this
.
java
=
java
;
}
public
int
getCode
()
{
return
code
;
}
public
String
getName
()
{
return
name
;
}
public
String
getJson
()
{
return
json
;
}
public
String
getJava
()
{
return
java
;
}
public
static
PropType
findType
(
Integer
type
)
{
for
(
PropType
userTypeEnum
:
values
())
{
if
(
userTypeEnum
.
getCode
()==
type
)
{
return
userTypeEnum
;
}
}
return
PropType
.
VARCHAR
;
}
public
static
PropType
findByDBType
(
String
type
)
{
for
(
PropType
userTypeEnum
:
values
())
{
if
(
userTypeEnum
.
getName
()==
type
)
{
return
userTypeEnum
;
}
}
return
VARCHAR
;
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/RelationshipModel.java
浏览文件 @
224da2a8
...
...
@@ -14,8 +14,7 @@ import java.util.List;
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
RelationshipModel
{
public
class
RelationshipModel
extends
BaseModel
{
private
String
name
;
...
...
@@ -33,7 +32,11 @@ public class RelationshipModel {
private
String
relationType
;
private
IPSDERBase
relation
;
public
IPSDERBase
getRelation
()
{
return
(
IPSDERBase
)
opt
;
}
private
List
<
FieldModel
>
fields
;
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/SystemModel.java
0 → 100644
浏览文件 @
224da2a8
package
cn
.
ibizlab
.
codegen
.
model
;
public
class
SystemModel
{
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/TransUtils.java
浏览文件 @
224da2a8
...
...
@@ -124,7 +124,7 @@ public class TransUtils {
Map
<
String
,
FieldModel
>
keyMap
=
new
LinkedHashMap
<>();
Map
<
String
,
RelationshipModel
>
relationshipModelMap
=
new
LinkedHashMap
<>();
if
(
entityModel
.
getKeyFields
()!=
null
)
entityModel
.
getKeyFields
().
forEach
(
model
->
keyMap
.
put
(
model
.
get
Column
Name
(),
model
));
if
(
entityModel
.
getKeyFields
()!=
null
)
entityModel
.
getKeyFields
().
forEach
(
model
->
keyMap
.
put
(
model
.
get
Field
Name
(),
model
));
int
order
=
1
;
for
(
FieldModel
fieldModel
:
entityModel
.
getFields
())
{
...
...
@@ -188,7 +188,7 @@ public class TransUtils {
}
}
if
(!
fieldModel
.
isPh
ysical
Field
())
if
(!
fieldModel
.
isPh
isicalDE
Field
())
poSchema
.
addTransient
(
column
.
setComputed
(
true
));
else
poSchema
.
addColumn
(
column
);
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/templating/MustacheCollector.java
0 → 100644
浏览文件 @
224da2a8
//
// JMustache - A Java implementation of the Mustache templating language
// http://github.com/samskivert/jmustache/blob/master/LICENSE
package
cn
.
ibizlab
.
codegen
.
templating
;
import
cn.ibizlab.codegen.model.BaseModel
;
import
com.samskivert.mustache.BasicCollector
;
import
com.samskivert.mustache.Mustache
;
import
java.lang.reflect.Array
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.util.AbstractList
;
import
java.util.Iterator
;
import
java.util.LinkedHashSet
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* The default collector used by JMustache.
*/
public
class
MustacheCollector
extends
BasicCollector
{
@Override
public
Mustache
.
VariableFetcher
createFetcher
(
Object
ctx
,
String
name
)
{
Mustache
.
VariableFetcher
fetcher
=
super
.
createFetcher
(
ctx
,
name
);
if
(
fetcher
!=
null
)
return
fetcher
;
// first check for a getter which provides the value
Class
<?>
cclass
=
ctx
.
getClass
();
final
Method
m
=
getMethod
(
cclass
,
name
);
if
(
m
!=
null
)
{
return
new
Mustache
.
VariableFetcher
()
{
public
Object
get
(
Object
ctx
,
String
name
)
throws
Exception
{
return
m
.
invoke
(
ctx
);
}
};
}
// next check for a getter which provides the value
final
Field
f
=
getField
(
cclass
,
name
);
if
(
f
!=
null
)
{
return
new
Mustache
.
VariableFetcher
()
{
public
Object
get
(
Object
ctx
,
String
name
)
throws
Exception
{
return
f
.
get
(
ctx
);
}
};
}
// finally check for a default interface method which provides the value (this is left to
// last because it's much more expensive and hopefully something already matched above)
final
Method
im
=
getIfaceMethod
(
cclass
,
name
);
if
(
im
!=
null
)
{
return
new
Mustache
.
VariableFetcher
()
{
public
Object
get
(
Object
ctx
,
String
name
)
throws
Exception
{
return
im
.
invoke
(
ctx
);
}
};
}
if
(
ctx
instanceof
BaseModel
)
{
if
(((
BaseModel
)
ctx
).
getOpt
()!=
null
)
{
Class
<?>
cclass2
=
((
BaseModel
)
ctx
).
getOpt
().
getClass
();
final
Method
opt
=
getMethod
(
cclass2
,
name
);
if
(
opt
!=
null
)
{
return
new
Mustache
.
VariableFetcher
()
{
public
Object
get
(
Object
ctx
,
String
name
)
throws
Exception
{
return
opt
.
invoke
(((
BaseModel
)
ctx
).
getOpt
());
}
};
}
}
Object
val
=((
BaseModel
)
ctx
).
get
(
name
);
if
(
val
!=
null
)
{
return
new
Mustache
.
VariableFetcher
()
{
public
Object
get
(
Object
ctx
,
String
name
)
throws
Exception
{
return
val
;
}
};
}
}
return
null
;
}
@Override
public
<
K
,
V
>
Map
<
K
,
V
>
createFetcherCache
()
{
return
new
ConcurrentHashMap
<
K
,
V
>();
}
protected
Method
getMethod
(
Class
<?>
clazz
,
String
name
)
{
// first check up the superclass chain
for
(
Class
<?>
cc
=
clazz
;
cc
!=
null
&&
cc
!=
Object
.
class
;
cc
=
cc
.
getSuperclass
())
{
Method
m
=
getMethodOn
(
cc
,
name
);
if
(
m
!=
null
)
return
m
;
}
return
null
;
}
protected
Method
getIfaceMethod
(
Class
<?>
clazz
,
String
name
)
{
// enumerate the transitive closure of all interfaces implemented by clazz
Set
<
Class
<?>>
ifaces
=
new
LinkedHashSet
<
Class
<?>>();
for
(
Class
<?>
cc
=
clazz
;
cc
!=
null
&&
cc
!=
Object
.
class
;
cc
=
cc
.
getSuperclass
())
{
addIfaces
(
ifaces
,
cc
,
false
);
}
// now search those in the order that we found them
for
(
Class
<?>
iface
:
ifaces
)
{
Method
m
=
getMethodOn
(
iface
,
name
);
if
(
m
!=
null
)
return
m
;
}
return
null
;
}
private
void
addIfaces
(
Set
<
Class
<?>>
ifaces
,
Class
<?>
clazz
,
boolean
isIface
)
{
if
(
isIface
)
ifaces
.
add
(
clazz
);
for
(
Class
<?>
iface
:
clazz
.
getInterfaces
())
addIfaces
(
ifaces
,
iface
,
true
);
}
protected
Method
getMethodOn
(
Class
<?>
clazz
,
String
name
)
{
Method
m
;
try
{
m
=
clazz
.
getDeclaredMethod
(
name
);
if
(!
m
.
getReturnType
().
equals
(
void
.
class
))
return
makeAccessible
(
m
);
}
catch
(
Exception
e
)
{
// fall through
}
String
upperName
=
Character
.
toUpperCase
(
name
.
charAt
(
0
))
+
name
.
substring
(
1
);
try
{
m
=
clazz
.
getDeclaredMethod
(
"get"
+
upperName
);
if
(!
m
.
getReturnType
().
equals
(
void
.
class
))
return
makeAccessible
(
m
);
}
catch
(
Exception
e
)
{
// fall through
}
try
{
m
=
clazz
.
getDeclaredMethod
(
"is"
+
upperName
);
if
(
m
.
getReturnType
().
equals
(
boolean
.
class
)
||
m
.
getReturnType
().
equals
(
Boolean
.
class
))
return
makeAccessible
(
m
);
}
catch
(
Exception
e
)
{
// fall through
}
return
null
;
}
private
Method
makeAccessible
(
Method
m
)
{
if
(!
m
.
isAccessible
())
m
.
setAccessible
(
true
);
return
m
;
}
protected
Field
getField
(
Class
<?>
clazz
,
String
name
)
{
Field
f
;
try
{
f
=
clazz
.
getDeclaredField
(
name
);
if
(!
f
.
isAccessible
())
{
f
.
setAccessible
(
true
);
}
return
f
;
}
catch
(
Exception
e
)
{
// fall through
}
Class
<?>
sclass
=
clazz
.
getSuperclass
();
if
(
sclass
!=
Object
.
class
&&
sclass
!=
null
)
{
return
getField
(
clazz
.
getSuperclass
(),
name
);
}
return
null
;
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/templating/MustacheEngineAdapter.java
浏览文件 @
224da2a8
...
...
@@ -41,7 +41,7 @@ public class MustacheEngineAdapter implements TemplatingEngineAdapter {
return
"mustache"
;
}
Mustache
.
Compiler
compiler
=
Mustache
.
compiler
();
Mustache
.
Compiler
compiler
=
Mustache
.
compiler
()
.
withCollector
(
new
MustacheCollector
())
;
/**
* Compiles a template into a string
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/pom.xml
浏览文件 @
224da2a8
...
...
@@ -10,6 +10,7 @@
<description></description>
<packaging>
pom
</packaging>
{{>../{{projectName}}-util/pom.xml}}
<parent>
<groupId>
{{packageName}}
</groupId>
<artifactId>
{{projectName}}-dependencies
</artifactId>
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/{{projectName}}-core/src/main/java/{{packageName}}/{{modules}}/domain/{{entities}}.java
浏览文件 @
224da2a8
package
{{
packageName
}}.{{
module
}}.
domain
;
//{{entity.dsTypes}} {{entity.ds_types}} {{entity.dataAccCtrlArch}}
public
class
{{
entity
.
codeName
}}
{
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录