Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
30c6f92b
提交
30c6f92b
编写于
12月 14, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
push
上级
503b9474
变更
7
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
97 行增加
和
32 行删除
+97
-32
DefaultGenerator.java
...re/src/main/java/cn/ibizlab/codegen/DefaultGenerator.java
+0
-2
EntityModel.java
...re/src/main/java/cn/ibizlab/codegen/lite/EntityModel.java
+2
-0
CliData.java
...-core/src/main/java/cn/ibizlab/codegen/model/CliData.java
+24
-8
CliOption.java
...ore/src/main/java/cn/ibizlab/codegen/model/CliOption.java
+34
-5
ModelStorage.java
.../src/main/java/cn/ibizlab/codegen/model/ModelStorage.java
+16
-12
TemplateDefinition.java
...ava/cn/ibizlab/codegen/templating/TemplateDefinition.java
+21
-5
I{{entities#SQL}}Service.java
...eName}}/{{modules}}/service/I{{entities#SQL}}Service.java
+0
-0
未找到文件。
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/DefaultGenerator.java
浏览文件 @
30c6f92b
...
...
@@ -41,8 +41,6 @@ public class DefaultGenerator implements Generator {
private
static
final
String
METADATA_DIR
=
".ibizlab-generator"
;
protected
CodegenConfig
config
;
private
String
basePath
;
private
String
contextPath
;
private
Map
<
String
,
String
>
generatorPropertyDefaults
=
new
HashMap
<>();
protected
TemplateProcessor
templateProcessor
=
null
;
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/lite/EntityModel.java
浏览文件 @
30c6f92b
...
...
@@ -7,6 +7,7 @@ import cn.ibizlab.codegen.utils.DataObject;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
...
...
@@ -17,6 +18,7 @@ import java.util.Map;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@JsonIgnoreProperties
(
value
=
"handler"
)
public
class
EntityModel
{
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/CliData.java
浏览文件 @
30c6f92b
...
...
@@ -3,6 +3,7 @@ package cn.ibizlab.codegen.model;
import
cn.ibizlab.codegen.CodegenConstants
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -13,6 +14,8 @@ import java.util.Map;
public
class
CliData
extends
DataObj
{
private
static
CliData
EMPTY
=
new
CliData
().
setOptions
(
new
ArrayList
<>());
public
CliData
set
(
String
key
,
Object
value
)
{
...
...
@@ -30,7 +33,7 @@ public class CliData extends DataObj
}
private
List
<
CliOption
>
options
;
private
List
<
CliOption
>
options
=
new
ArrayList
<>()
;
public
List
<
CliOption
>
getOptions
()
{
...
...
@@ -44,21 +47,34 @@ public class CliData extends DataObj
}
public
CliData
addOption
(
CliOption
option
)
{
if
(
this
.
options
==
null
)
this
.
options
=
new
ArrayList
<>();
this
.
options
.
add
(
option
);
if
(!
StringUtils
.
isEmpty
(
option
.
getCliSubType
()))
addSubTypeOption
(
option
);
return
this
;
}
List
<
CliOption
>
subTypes
=
null
;
public
CliData
addSubTypeOption
(
CliOption
option
)
{
CliData
subData
=
null
;
Object
sub
=
this
.
get
(
option
.
getCliSubType
());
if
(
sub
==
null
)
{
sub
Types
=
new
ArrayList
<>
();
this
.
set
(
option
.
getCliSubType
(),
sub
Types
);
sub
Data
=
new
CliData
();
this
.
set
(
option
.
getCliSubType
(),
sub
Data
);
}
else
sub
Types
=(
List
<
CliOption
>
)
sub
;
sub
Types
.
add
(
option
);
sub
Data
=(
CliData
)
sub
;
sub
Data
.
getOptions
()
.
add
(
option
);
return
this
;
}
public
CliData
getSubData
(
String
subType
)
{
if
(
this
.
containsKey
(
subType
))
return
(
CliData
)
this
.
get
(
subType
);
return
EMPTY
;
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/CliOption.java
浏览文件 @
30c6f92b
package
cn
.
ibizlab
.
codegen
.
model
;
import
cn.ibizlab.codegen.templating.TemplateFileType
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
cn.ibizlab.codegen.CodegenConstants
;
import
org.springframework.util.Assert
;
import
org.springframework.util.StringUtils
;
import
java.util.Map
;
...
...
@@ -10,15 +13,41 @@ import java.util.Map;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
CliOption
extends
DataObj
{
public
CliOption
setCliSubType
(
String
type
)
private
TemplateFileType
templateFileType
;
public
CliOption
setTemplateFileType
(
TemplateFileType
templateFileType
)
{
this
.
templateFileType
=
templateFileType
;
return
this
;
}
public
TemplateFileType
getTemplateFileType
()
{
return
this
.
templateFileType
;
}
private
String
cliSubType
;
public
CliOption
setCliSubType
(
String
cliSubType
)
{
this
.
set
(
"_cli-sub-type"
,
type
)
;
this
.
cliSubType
=
cliSubType
;
return
this
;
}
public
String
getCliSubType
()
{
return
this
.
getStringValue
(
"_cli-sub-type"
,
"default"
);
return
this
.
cliSubType
;
}
public
CliOption
baseData
(
Object
baseData
,
String
name
)
{
Assert
.
notNull
(
templateFileType
,
"模板类型为空"
);
this
.
set
(
templateFileType
.
name
(),
baseData
);
this
.
set
(
templateFileType
.
value
(),
name
);
if
(!
StringUtils
.
isEmpty
(
this
.
cliSubType
))
this
.
set
(
templateFileType
.
value
()+
"#"
+
this
.
cliSubType
,
name
);
return
this
;
}
public
CliOption
set
(
String
key
,
Object
value
)
...
...
@@ -37,7 +66,7 @@ public class CliOption extends DataObj
}
public
String
getProjectName
(){
return
this
.
getStringValue
(
"projectName"
,
this
.
getStringValue
(
"system_id"
,
this
.
getStringValue
(
"system"
,
this
.
getStringValue
(
"system_name"
))));
return
this
.
getStringValue
(
CodegenConstants
.
PROJECT_NAME
,
this
.
getStringValue
(
"system_id"
,
this
.
getStringValue
(
"system"
,
this
.
getStringValue
(
"system_name"
))));
}
public
CliOption
setProjectName
(
String
projectName
)
...
...
@@ -51,7 +80,7 @@ public class CliOption extends DataObj
}
public
String
getPackageName
(){
return
this
.
getStringValue
(
"packageName"
,
"cn.ibizlab"
);
return
this
.
getStringValue
(
CodegenConstants
.
PACKAGE_NAME
,
"cn.ibizlab"
);
}
public
CliOption
setPackageName
(
String
packageName
)
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/ModelStorage.java
浏览文件 @
30c6f92b
...
...
@@ -42,10 +42,12 @@ public class ModelStorage {
public
CliOption
newCliOption
()
public
CliOption
newCliOption
(
TemplateFileType
type
)
{
CliOption
opt
=
new
CliOption
();
opt
.
putAll
(
config
.
getAdditionalProperties
());
opt
.
setTemplateFileType
(
type
);
IPSSystem
ipsSystem
=
dynamicService
.
getPSSystem
();
if
(
StringUtils
.
isEmpty
(
config
.
getAdditionalProperties
().
get
(
CodegenConstants
.
PROJECT_NAME
)))
opt
.
setProjectName
(
ipsSystem
.
getCodeName
().
toLowerCase
()).
toString
();
...
...
@@ -53,6 +55,7 @@ public class ModelStorage {
opt
.
setProjectDesc
(
ipsSystem
.
getName
().
toLowerCase
()).
toString
();
if
(
StringUtils
.
isEmpty
(
config
.
getAdditionalProperties
().
get
(
CodegenConstants
.
PACKAGE_NAME
)))
opt
.
setPackageName
(
ipsSystem
.
getCodeName
().
toLowerCase
()).
toString
();
opt
.
set
(
"system"
,
ipsSystem
);
return
opt
;
}
...
...
@@ -89,7 +92,7 @@ public class ModelStorage {
if
(
dynamicService
.
getPSSystem
().
getAllPSSysServiceAPIs
()!=
null
)
{
dynamicService
.
getPSSystem
().
getAllPSSysServiceAPIs
().
forEach
(
item
->{
CliOption
opt
=
newCliOption
(
).
set
(
TemplateFileType
.
api
.
toString
(),
item
).
set
(
TemplateFileType
.
api
.
value
()
,
item
.
getCodeName
().
toLowerCase
());
CliOption
opt
=
newCliOption
(
TemplateFileType
.
api
).
baseData
(
item
,
item
.
getCodeName
().
toLowerCase
());
rt
.
addOption
(
opt
);
});
}
...
...
@@ -99,7 +102,7 @@ public class ModelStorage {
if
(
dynamicService
.
getPSSystem
().
getAllPSApps
()!=
null
)
{
dynamicService
.
getPSSystem
().
getAllPSApps
().
forEach
(
item
->{
CliOption
opt
=
newCliOption
(
).
set
(
TemplateFileType
.
app
.
toString
(),
item
).
set
(
TemplateFileType
.
app
.
value
()
,
item
.
getCodeName
().
toLowerCase
());
CliOption
opt
=
newCliOption
(
TemplateFileType
.
app
).
baseData
(
item
,
item
.
getCodeName
().
toLowerCase
());
rt
.
addOption
(
opt
);
});
}
...
...
@@ -110,7 +113,7 @@ public class ModelStorage {
if
(
api
.
getPSDEServiceAPIs
()!=
null
)
{
api
.
getPSDEServiceAPIs
().
forEach
(
item
->{
CliOption
opt
=
newCliOption
(
).
set
(
TemplateFileType
.
serviceApi
.
toString
(),
item
).
set
(
TemplateFileType
.
serviceApi
.
value
()
,
item
.
getCodeName
());
CliOption
opt
=
newCliOption
(
TemplateFileType
.
serviceApi
).
baseData
(
item
,
item
.
getCodeName
());
rt
.
addOption
(
opt
);
});
}
...
...
@@ -120,25 +123,26 @@ public class ModelStorage {
{
dynamicService
.
getPSSystem
().
getAllPSDataEntities
().
forEach
(
item
->{
PojoSchema
pojoSchema
=
this
.
getEntitySchema
(
item
.
getName
());
CliOption
opt
=
newCliOption
(
).
setModule
(
pojoSchema
.
getModule
()).
setCliSubType
(
pojoSchema
.
getStorageMod
e
())
.
set
(
TemplateFileType
.
entity
.
toString
(),
pojoSchema
).
set
(
TemplateFileType
.
entity
.
value
()
,
item
.
getCodeName
());
CliOption
opt
=
newCliOption
(
TemplateFileType
.
entity
).
setCliSubType
(
pojoSchema
.
getStorageMode
()).
setModule
(
pojoSchema
.
getModul
e
())
.
baseData
(
pojoSchema
,
item
.
getCodeName
());
rt
.
addOption
(
opt
);
});
}
else
if
(
type
.
equals
(
TemplateFileType
.
module
))
{
dynamicService
.
getPSSystem
().
getAllPSSystemModules
().
forEach
(
item
->{
CliOption
opt
=
newCliOption
()
.
set
(
TemplateFileType
.
module
.
toString
(),
item
).
set
(
TemplateFileType
.
module
.
value
()
,
item
.
getCodeName
());
CliOption
opt
=
newCliOption
(
TemplateFileType
.
module
)
.
baseData
(
item
,
item
.
getCodeName
());
rt
.
addOption
(
opt
);
});
}
else
if
(
type
.
equals
(
TemplateFileType
.
supportingFiles
))
{
CliOption
opt
=
newCliOption
();
opt
.
set
(
TemplateFileType
.
app
.
value
(),
getTemplateData
(
TemplateFileType
.
app
));
opt
.
set
(
TemplateFileType
.
api
.
value
(),
getTemplateData
(
TemplateFileType
.
api
));
opt
.
set
(
TemplateFileType
.
module
.
value
(),
getTemplateData
(
TemplateFileType
.
module
));
CliOption
opt
=
newCliOption
(
TemplateFileType
.
supportingFiles
)
.
set
(
TemplateFileType
.
app
.
value
(),
getTemplateData
(
TemplateFileType
.
app
))
.
set
(
TemplateFileType
.
api
.
value
(),
getTemplateData
(
TemplateFileType
.
api
))
.
set
(
TemplateFileType
.
module
.
value
(),
getTemplateData
(
TemplateFileType
.
module
));
rt
.
addOption
(
opt
);
}
templateData
.
put
(
type
,
rt
);
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/templating/TemplateDefinition.java
浏览文件 @
30c6f92b
...
...
@@ -13,6 +13,8 @@ import java.nio.file.Paths;
import
java.nio.file.Path
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
@Getter
@Setter
...
...
@@ -23,7 +25,7 @@ public class TemplateDefinition {
protected
TemplateFileType
templateType
;
private
String
subType
=
"default"
;
private
String
subType
;
protected
CliData
templateDatas
;
...
...
@@ -32,7 +34,11 @@ public class TemplateDefinition {
this
.
templateFile
=
templateFile
;
this
.
templateType
=
getType
(
Paths
.
get
(
this
.
templateFile
));
this
.
templateDatas
=
ModelStorage
.
getInstance
().
getTemplateData
(
this
.
templateType
);
CliData
data
=
ModelStorage
.
getInstance
().
getTemplateData
(
this
.
templateType
);
if
(
StringUtils
.
isEmpty
(
subType
))
this
.
templateDatas
=
data
;
else
this
.
templateDatas
=
data
.
getSubData
(
subType
);
}
...
...
@@ -46,10 +52,20 @@ public class TemplateDefinition {
String
fileName
=
path
.
getFileName
().
toString
();
for
(
TemplateFileType
type:
TemplateFileType
.
values
())
{
if
(
fileName
.
indexOf
(
"{{"
+
type
.
name
()+
"}}"
)>=
0
||
fileName
.
indexOf
(
"{{"
+
type
.
value
()+
"}}"
)>=
0
)
Pattern
p
=
Pattern
.
compile
(
"\\{\\{([^}]*)\\}\\}"
);
Matcher
m
=
p
.
matcher
(
fileName
);
while
(
m
.
find
())
{
String
[]
pairs
=
m
.
group
(
1
).
split
(
"#"
);
if
(
type
.
name
().
equalsIgnoreCase
(
pairs
[
0
])
||
type
.
value
().
equalsIgnoreCase
(
pairs
[
0
]))
{
if
(
pairs
.
length
>
1
&&(!
StringUtils
.
isEmpty
(
pairs
[
1
])))
this
.
setSubType
(
pairs
[
1
]);
return
type
;
}
}
}
return
getType
(
path
.
getParent
());
}
}
modules/ibizlab-generator-core/src/main/resources/templ/r7/{{projectName}}-core/src/main/java/{{packageName}}/{{modules}}/service/I{{entities}}Service.java
→
modules/ibizlab-generator-core/src/main/resources/templ/r7/{{projectName}}-core/src/main/java/{{packageName}}/{{modules}}/service/I{{entities
#SQL
}}Service.java
浏览文件 @
30c6f92b
文件已移动
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录