Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
4be084b0
提交
4be084b0
编写于
12月 17, 2021
作者:
sq3536
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
便捷操作
上级
4cca4e4d
变更
16
显示空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
266 行增加
和
29 行删除
+266
-29
CodegenConfig.java
...-core/src/main/java/cn/ibizlab/codegen/CodegenConfig.java
+1
-0
BaseModel.java
...ore/src/main/java/cn/ibizlab/codegen/model/BaseModel.java
+9
-5
CtrlModel.java
...ore/src/main/java/cn/ibizlab/codegen/model/CtrlModel.java
+3
-3
EntityModel.java
...e/src/main/java/cn/ibizlab/codegen/model/EntityModel.java
+2
-2
FieldModel.java
...re/src/main/java/cn/ibizlab/codegen/model/FieldModel.java
+0
-3
LabelExt.java
...core/src/main/java/cn/ibizlab/codegen/model/LabelExt.java
+141
-0
ModelStorage.java
.../src/main/java/cn/ibizlab/codegen/model/ModelStorage.java
+5
-5
PageModel.java
...ore/src/main/java/cn/ibizlab/codegen/model/PageModel.java
+7
-8
TransUtils.java
...re/src/main/java/cn/ibizlab/codegen/model/TransUtils.java
+1
-1
SpinalcaseLambda.java
...ibizlab/codegen/templating/mustache/SpinalcaseLambda.java
+45
-0
StringAdvUtils.java
...rc/main/java/cn/ibizlab/codegen/utils/StringAdvUtils.java
+17
-0
README.md
...generator-core/src/main/resources/templ/r7/.def/README.md
+2
-0
pub.txt
...b-generator-core/src/main/resources/templ/r7/.def/pub.txt
+1
-0
.ibizlab-generator-ignore
...ore/src/main/resources/templ/r7/.ibizlab-generator-ignore
+2
-1
{{appEntities}}-service.ts
...}}/src/service/{{appEntities}}/{{appEntities}}-service.ts
+29
-0
pom.xml
...bizlab-generator-core/src/main/resources/templ/r7/pom.xml
+1
-1
未找到文件。
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/CodegenConfig.java
浏览文件 @
4be084b0
...
...
@@ -113,6 +113,7 @@ public class CodegenConfig {
additionalProperties
.
put
(
"lowercase"
,
new
LowercaseLambda
().
generator
(
this
));
additionalProperties
.
put
(
"uppercase"
,
new
UppercaseLambda
());
additionalProperties
.
put
(
"snakecase"
,
new
SnakecaseLambda
());
additionalProperties
.
put
(
"spinalcase"
,
new
SpinalcaseLambda
());
additionalProperties
.
put
(
"titlecase"
,
new
TitlecaseLambda
());
additionalProperties
.
put
(
"camelcase"
,
new
CamelCaseLambda
(
true
).
generator
(
this
));
additionalProperties
.
put
(
"pascalcase"
,
new
CamelCaseLambda
(
false
).
generator
(
this
));
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/BaseModel.java
浏览文件 @
4be084b0
...
...
@@ -12,7 +12,7 @@ public class BaseModel {
public
String
getId
()
{
if
(
StringUtils
.
isEmpty
(
id
)&&(!
StringUtils
.
isEmpty
(
getCodeName
())))
id
=
this
.
getCodeName
();
id
=
this
.
getCodeName
()
.
toString
()
;
return
id
;
}
...
...
@@ -22,17 +22,20 @@ public class BaseModel {
return
(
T
)
this
;
}
public
String
getCodeName
()
{
return
codeName
;
public
LabelExt
getCodeName
()
{
return
new
LabelExt
(
codeName
)
;
}
public
<
T
>
T
setCodeName
(
String
codeName
)
{
this
.
codeName
=
codeName
;
return
(
T
)
this
;
}
public
String
getName
()
{
return
n
ame
;
public
LabelExt
getName
()
{
return
n
ew
LabelExt
(
name
)
;
}
public
<
T
>
T
setName
(
String
name
)
{
...
...
@@ -74,4 +77,5 @@ public class BaseModel {
return
(
T
)
this
;
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/CtrlModel.java
浏览文件 @
4be084b0
...
...
@@ -21,9 +21,9 @@ public class CtrlModel extends BaseModel{
this
.
setName
(
psControl
.
getName
());
if
(
psControl
.
getPSAppDataEntity
()!=
null
)
folder
=
psControl
.
getPSAppDataEntity
().
getCodeName
(
);
folder
=
new
LabelExt
(
psControl
.
getPSAppDataEntity
().
getCodeName
()
);
else
folder
=
"app"
;
folder
=
new
LabelExt
(
"app"
)
;
this
.
setId
(
String
.
format
(
"%1$s-%2$s-%3$s"
,
app
.
getCodeName
(),
folder
,
psControl
.
getCodeName
()));
}
...
...
@@ -32,7 +32,7 @@ public class CtrlModel extends BaseModel{
private
AppEntityModel
appEntity
;
private
String
folder
;
private
LabelExt
folder
;
public
IPSControl
getControl
()
{
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/EntityModel.java
浏览文件 @
4be084b0
...
...
@@ -102,7 +102,7 @@ public class EntityModel extends BaseModel {
{
references
.
forEach
(
ship
->{
if
(!
StringUtils
.
isEmpty
(
ship
.
getCodeName
()))
refMaps
.
put
(
ship
.
getCodeName
(),
ship
);
refMaps
.
put
(
ship
.
getCodeName
()
.
toString
()
,
ship
);
String
fkname
=
DataObject
.
getStringValue
(
ship
.
getName
(),
""
);
if
(!
StringUtils
.
isEmpty
(
fkname
))
refMaps
.
put
(
fkname
,
ship
);
...
...
@@ -134,7 +134,7 @@ public class EntityModel extends BaseModel {
fieldMap
=
new
LinkedHashMap
<>();
fields
.
forEach
(
field
->{
fieldMap
.
put
(
field
.
getFieldName
(),
field
);
fieldMap
.
put
(
field
.
getCodeName
(),
field
);
fieldMap
.
put
(
field
.
getCodeName
()
.
toString
()
,
field
);
});
}
return
fieldMap
;
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/FieldModel.java
浏览文件 @
4be084b0
...
...
@@ -29,9 +29,6 @@ public class FieldModel extends BaseModel {
this
.
setId
(
String
.
format
(
"%1$s-%2$s"
,
entity
.
getCodeName
(),
deField
.
getCodeName
()));
}
public
String
getCodeName
()
{
return
getDataEntityField
().
getCodeName
();
}
public
String
getFieldName
()
{
return
getDataEntityField
().
getName
();
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/LabelExt.java
0 → 100644
浏览文件 @
4be084b0
package
cn
.
ibizlab
.
codegen
.
model
;
import
cn.ibizlab.codegen.utils.StringAdvUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.stream.IntStream
;
public
class
LabelExt
implements
java
.
io
.
Serializable
,
Comparable
<
String
>,
CharSequence
{
private
String
label
=
""
;
public
LabelExt
(
String
label
)
{
if
(!
StringUtils
.
isEmpty
(
label
))
this
.
label
=
label
;
}
public
String
toLowerCase
()
{
return
label
.
toLowerCase
();
}
public
String
toUpperCase
()
{
return
label
.
toUpperCase
();
}
public
String
toPascalCase
()
{
return
StringAdvUtils
.
pascalcase
(
label
);
}
public
String
toCapFirst
()
{
return
StringAdvUtils
.
pascalcase
(
label
);
}
public
String
toCamelCase
()
{
return
StringAdvUtils
.
camelcase
(
label
);
}
public
String
toSpinalCase
()
{
return
StringAdvUtils
.
dashize
(
label
);
}
public
String
toSnakeCase
()
{
return
StringAdvUtils
.
snakecase
(
label
);
}
public
String
getLowerCase
()
{
return
toLowerCase
();
}
public
String
getUpperCase
()
{
return
toUpperCase
();
}
public
String
getPascalCase
()
{
return
toPascalCase
();
}
public
String
getCapFirst
()
{
return
toCapFirst
();
}
public
String
getCamelCase
()
{
return
toCamelCase
();
}
public
String
getSpinalCase
()
{
return
toSpinalCase
();
}
public
String
getSnakeCase
()
{
return
toSnakeCase
();
}
@Override
public
int
length
()
{
return
label
.
length
();
}
@Override
public
char
charAt
(
int
index
)
{
return
label
.
charAt
(
index
);
}
@Override
public
CharSequence
subSequence
(
int
start
,
int
end
)
{
return
label
.
subSequence
(
start
,
end
);
}
@Override
public
String
toString
()
{
return
label
;
}
@Override
public
IntStream
chars
()
{
return
label
.
chars
();
}
@Override
public
IntStream
codePoints
()
{
return
label
.
codePoints
();
}
@Override
public
int
compareTo
(
String
o
)
{
return
label
.
compareTo
(
o
);
}
public
int
compareToIgnoreCase
(
String
o
)
{
return
label
.
compareToIgnoreCase
(
o
);
}
public
boolean
startsWith
(
String
prefix
)
{
return
label
.
startsWith
(
prefix
);
}
public
boolean
endsWith
(
String
suffix
)
{
return
label
.
endsWith
(
suffix
);
}
public
int
indexOf
(
int
ch
)
{
return
label
.
indexOf
(
ch
,
0
);
}
public
String
substring
(
int
beginIndex
)
{
return
label
.
substring
(
beginIndex
);
}
public
String
substring
(
int
beginIndex
,
int
endIndex
)
{
return
label
.
substring
(
beginIndex
,
endIndex
);
}
public
String
replace
(
char
oldChar
,
char
newChar
)
{
return
label
.
replace
(
oldChar
,
newChar
);
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/ModelStorage.java
浏览文件 @
4be084b0
...
...
@@ -113,7 +113,7 @@ public class ModelStorage {
{
getSystemModel
().
getApis
().
forEach
(
api
->{
api
.
getApiEntities
().
forEach
(
item
->{
CliOption
opt
=
newCliOption
(
TemplateFileType
.
apiEntity
).
baseData
(
item
,
item
.
getCodeName
()).
set
(
"apis"
,
api
.
getCodeName
().
toLowerCase
());
CliOption
opt
=
newCliOption
(
TemplateFileType
.
apiEntity
).
baseData
(
item
,
item
.
getCodeName
()
.
toString
()
).
set
(
"apis"
,
api
.
getCodeName
().
toLowerCase
());
rt
.
addOption
(
opt
);
});
});
...
...
@@ -129,7 +129,7 @@ public class ModelStorage {
{
getSystemModel
().
getApps
().
forEach
(
app
->{
app
.
getAppEntities
().
forEach
(
item
->{
CliOption
opt
=
newCliOption
(
TemplateFileType
.
appEntity
).
baseData
(
item
,
item
.
getCodeName
().
to
Lower
Case
()).
set
(
"apps"
,
app
.
getCodeName
().
toLowerCase
());
CliOption
opt
=
newCliOption
(
TemplateFileType
.
appEntity
).
baseData
(
item
,
item
.
getCodeName
().
to
Spinal
Case
()).
set
(
"apps"
,
app
.
getCodeName
().
toLowerCase
());
rt
.
addOption
(
opt
);
});
});
...
...
@@ -138,7 +138,7 @@ public class ModelStorage {
{
getSystemModel
().
getEntities
().
forEach
(
item
->{
CliOption
opt
=
newCliOption
(
TemplateFileType
.
entity
).
setCliSubType
(
item
.
getStorageMode
()).
setModule
(
item
.
getModule
())
.
baseData
(
item
,
item
.
getCodeName
());
.
baseData
(
item
,
item
.
getCodeName
()
.
toString
()
);
rt
.
addOption
(
opt
);
});
}
...
...
@@ -154,7 +154,7 @@ public class ModelStorage {
{
getSystemModel
().
getApps
().
forEach
(
app
->{
app
.
getPages
().
forEach
(
item
->{
CliOption
opt
=
newCliOption
(
TemplateFileType
.
page
).
baseData
(
item
,
item
.
getCodeName
().
to
LowerCase
()).
set
(
"apps"
,
app
.
getCodeName
().
toLowerCase
()).
set
(
"appModules"
,
item
.
getAppModul
e
());
CliOption
opt
=
newCliOption
(
TemplateFileType
.
page
).
baseData
(
item
,
item
.
getCodeName
().
to
SpinalCase
()).
set
(
"apps"
,
app
.
getCodeName
().
toLowerCase
()).
set
(
"appModules"
,
item
.
getAppModule
().
toSpinalCas
e
());
rt
.
addOption
(
opt
);
});
});
...
...
@@ -163,7 +163,7 @@ public class ModelStorage {
{
getSystemModel
().
getApps
().
forEach
(
app
->{
app
.
getCtrls
().
forEach
(
item
->{
CliOption
opt
=
newCliOption
(
TemplateFileType
.
ctrl
).
baseData
(
item
,
item
.
getCodeName
().
to
LowerCase
()).
set
(
"apps"
,
app
.
getCodeName
().
toLowerCase
()).
set
(
"appEntities"
,
item
.
getFolder
().
toLower
Case
());
CliOption
opt
=
newCliOption
(
TemplateFileType
.
ctrl
).
baseData
(
item
,
item
.
getCodeName
().
to
SpinalCase
()).
set
(
"apps"
,
app
.
getCodeName
().
toLowerCase
()).
set
(
"appEntities"
,
item
.
getFolder
().
toSpinal
Case
());
rt
.
addOption
(
opt
);
});
});
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/PageModel.java
浏览文件 @
4be084b0
...
...
@@ -35,10 +35,10 @@ public class PageModel extends BaseModel{
if
(
ctrl
.
getControl
().
getPSAppDataEntity
()!=
null
)
{
AppEntityModel
ctrlAppEntity
=
app
.
getAppEntity
(
ctrl
.
getControl
().
getPSAppDataEntity
().
getCodeName
());
ctrl
.
setAppEntity
(
ctrlAppEntity
);
ctrlAppEntity
.
addCtrl
(
ctrl
.
getCodeName
(),
ctrl
);
ctrlAppEntity
.
addCtrl
(
ctrl
.
getCodeName
()
.
toString
()
,
ctrl
);
}
this
.
app
.
getCtrlsMap
().
put
(
ctrl
.
getId
(),
ctrl
);
this
.
ctrlsMap
.
put
(
ctrl
.
getCodeName
(),
ctrl
);
this
.
ctrlsMap
.
put
(
ctrl
.
getCodeName
()
.
toString
()
,
ctrl
);
}
});
}
...
...
@@ -54,14 +54,13 @@ public class PageModel extends BaseModel{
private
AppEntityModel
appEntity
;
public
String
getAppModule
()
public
LabelExt
getAppModule
()
{
if
(
getAppView
().
getPSAppDataEntity
()==
null
)
return
"default"
;
String
appModules
=
getAppView
().
getPSAppDataEntity
().
getCodeName
();
String
appModules
=
"default"
;
if
(
getAppView
().
getPSAppDataEntity
()!=
null
)
appModules
=
getAppView
().
getPSAppDataEntity
().
getCodeName
();
appModules
=
appModules
.
toLowerCase
();
return
appModules
;
return
new
LabelExt
(
appModules
);
}
private
Map
<
String
,
CtrlModel
>
ctrlsMap
=
new
LinkedHashMap
<>();
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/TransUtils.java
浏览文件 @
4be084b0
...
...
@@ -297,7 +297,7 @@ public class TransUtils {
}
else
if
(!
dataSet
.
getDatasetId
().
startsWith
(
entityModel
.
getEntityName
().
toLowerCase
()+
"-"
))
{
POSchema
.
Segment
segment
=
new
POSchema
.
Segment
().
setName
(
dataSet
.
getCodeName
()).
setVendorProvider
(
dataSourceType
).
setBody
(
dataSet
.
getDsCode
());
POSchema
.
Segment
segment
=
new
POSchema
.
Segment
().
setName
(
dataSet
.
getCodeName
()
.
toString
()
).
setVendorProvider
(
dataSourceType
).
setBody
(
dataSet
.
getDsCode
());
if
(!
StringUtils
.
isEmpty
(
dataSet
.
getDsModel
()))
segment
.
setFormat
(
dataSet
.
getDsModel
());
poSchema
.
addSegment
(
segment
);
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/templating/mustache/SpinalcaseLambda.java
0 → 100644
浏览文件 @
4be084b0
/*
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
cn
.
ibizlab
.
codegen
.
templating
.
mustache
;
import
cn.ibizlab.codegen.utils.StringAdvUtils
;
import
com.samskivert.mustache.Mustache
;
import
com.samskivert.mustache.Template
;
import
java.io.IOException
;
import
java.io.Writer
;
/**
* Converts text in a fragment to snake case.
*
* Register:
* <pre>
* additionalProperties.put("snakecase", new SnakecaseLambda());
* </pre>
*
* Use:
* <pre>
* {{#snakecase}}{{summary}}{{/snakecase}}
* </pre>
*/
public
class
SpinalcaseLambda
implements
Mustache
.
Lambda
{
@Override
public
void
execute
(
Template
.
Fragment
fragment
,
Writer
writer
)
throws
IOException
{
writer
.
write
(
StringAdvUtils
.
dashize
(
fragment
.
execute
()));
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/utils/StringAdvUtils.java
浏览文件 @
4be084b0
...
...
@@ -109,6 +109,23 @@ public class StringAdvUtils {
return
camelize
(
word
,
false
);
}
public
static
String
pascalcase
(
String
word
)
{
return
camelize
(
word
,
true
);
}
public
static
String
camelcase
(
String
word
)
{
return
camelize
(
word
,
false
);
}
public
static
String
spinalcase
(
String
word
)
{
return
dashize
(
word
);
}
public
static
String
snakecase
(
String
word
)
{
return
underscore
(
word
);
}
private
static
Pattern
camelizeSlashPattern
=
Pattern
.
compile
(
"\\/(.?)"
);
private
static
Pattern
camelizeUppercasePattern
=
Pattern
.
compile
(
"(\\.?)(\\w)([^\\.]*)$"
);
private
static
Pattern
camelizeUnderscorePattern
=
Pattern
.
compile
(
"(_)(.)"
);
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/.def/README.md
0 → 100644
浏览文件 @
4be084b0
预定义代码片段模板目录
其余模板文件引用时可以使用 {{>././.def/pub.txt}} 方式引用,支持相对路径
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/.def/pub.txt
0 → 100644
浏览文件 @
4be084b0
{{projectName}}
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/.ibizlab-generator-ignore
浏览文件 @
4be084b0
**.ibizlab-generator-ignore
**.DS_Store
**.def/**
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/app_{{apps}}/src/service/{{appEntities}}/{{appEntities}}-service.ts
浏览文件 @
4be084b0
{{
#
appEntity
.
ctrls
}}
这里是应用实体
ctrl
的代码名称
{{
codeName
}}
lowercase
{{
#
lowercase
}}{{
codeName
}}{{
/lowercase}
}
UPPERCASE
{{
#
uppercase
}}{{
codeName
}}{{
/uppercase}
}
PascalCase
{{
#
pascalcase
}}{{
codeName
}}{{
/pascalcase}
}
camelCase
{{
#
camelcase
}}{{
codeName
}}{{
/camelcase}
}
snake_case
{{
#
snakecase
}}{{
codeName
}}{{
/snakecase}
}
spinal
-
case
{{
#
spinalcase
}}{{
codeName
}}{{
/spinalcase}
}
另一种便捷写法,只支持
codeName
和
name
lowercase
{{
codeName
.
lowerCase
}}
UPPERCASE
{{
codeName
.
upperCase
}}
PascalCase
{{
codeName
.
pascalCase
}}
camelCase
{{
codeName
.
camelCase
}}
snake_case
{{
codeName
.
snakeCase
}}
spinal
-
case
{{
codeName
.
spinalCase
}}
{{
/appEntity.ctrls}}
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/pom.xml
浏览文件 @
4be084b0
...
...
@@ -9,7 +9,7 @@
<name>
{{projectDesc}}
</name>
<description></description>
<packaging>
pom
</packaging>
{{> {{{{projectName}}}}-util/pom.xml}}
<parent>
<groupId>
{{packageName}}
</groupId>
<artifactId>
{{projectName}}-dependencies
</artifactId>
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录