Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
576834e2
提交
576834e2
编写于
8月 14, 2022
作者:
ibiz4j
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
提交
上级
200f1b52
变更
7
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
220 行增加
和
31 行删除
+220
-31
AppModel.java
...core/src/main/java/cn/ibizlab/codegen/model/AppModel.java
+4
-2
Catalog.java
...-core/src/main/java/cn/ibizlab/codegen/model/Catalog.java
+32
-0
Option.java
...r-core/src/main/java/cn/ibizlab/codegen/model/Option.java
+16
-0
VoFieldModel.java
.../src/main/java/cn/ibizlab/codegen/model/VoFieldModel.java
+112
-8
pom.xml.hbs
.../src/main/resources/templ/{{projectName}}-api/pom.xml.hbs
+30
-2
{{dicts}}Dict.java.hbs
.../{{packageName}}/api/{{apps}}/dict/{{dicts}}Dict.java.hbs
+16
-12
{{pascalCase ctrls@FORM}}Dto.java.hbs
...lCase appEntities}}/{{pascalCase ctrls@FORM}}Dto.java.hbs
+10
-7
未找到文件。
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/AppModel.java
浏览文件 @
576834e2
...
...
@@ -163,7 +163,7 @@ public class AppModel extends BaseModel{
Map
<
String
,
Catalog
>
catalogs
=
new
LinkedHashMap
<>();
if
(!
ObjectUtils
.
isEmpty
(
rootPath
))
{
java
.
nio
.
file
.
Path
path
=
Paths
.
get
(
rootPath
,
getApplication
().
getDynaModelFilePath
().
replace
(
"/PSSYSAPP.json"
,
"/ALLCODELIST.json"
)
);
java
.
nio
.
file
.
Path
path
=
Paths
.
get
(
rootPath
,
"PSSYSAPPS"
,
"/ALLCODELIST.json"
);
if
(
Files
.
exists
(
path
))
{
try
{
...
...
@@ -201,7 +201,9 @@ public class AppModel extends BaseModel{
catalog
.
setCodeItem
(
codeList
.
getPSCodeItems
());
}
}
dictMaps
.
put
(
catalog
.
getCodeName
(),
catalog
);
if
(!
ObjectUtils
.
isEmpty
(
catalog
.
getOptions
()))
catalog
.
setOpt
(
codeList
);
dictMaps
.
put
(
catalog
.
getCodeName
(),
catalog
);
});
}
}
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/Catalog.java
浏览文件 @
576834e2
...
...
@@ -11,6 +11,8 @@ import lombok.Getter;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
net.ibizsys.model.app.IPSApplication
;
import
net.ibizsys.model.app.codelist.IPSAppCodeList
;
import
net.ibizsys.model.codelist.IPSCodeItem
;
import
org.springframework.util.ObjectUtils
;
...
...
@@ -31,6 +33,13 @@ public class Catalog extends BaseModel
private
List
<
Option
>
options
=
new
ArrayList
<>();
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
IPSAppCodeList
getCodeList
()
{
return
(
IPSAppCodeList
)
opt
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getValueType
()
...
...
@@ -38,6 +47,29 @@ public class Catalog extends BaseModel
return
ObjectUtils
.
isEmpty
(
options
)?
"String"
:
options
.
get
(
0
).
getValueType
();
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
private
Map
<
String
,
Option
>
sets
;
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
Map
<
String
,
Option
>
getSets
()
{
if
(
sets
==
null
)
{
sets
=
new
LinkedHashMap
<>();
this
.
getOptions
().
forEach
(
opt
->
loop
(
opt
));
}
return
sets
;
}
private
void
loop
(
Option
opt
)
{
sets
.
put
(
opt
.
getValue
().
toString
(),
opt
);
if
(!
ObjectUtils
.
isEmpty
(
opt
.
getChildren
()))
opt
.
getChildren
().
forEach
(
sub
->{
loop
(
sub
);
});
}
public
Option
findCodeItem
(
Object
value
)
{
return
findCodeItem
(
value
,
this
.
options
);
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/Option.java
浏览文件 @
576834e2
...
...
@@ -51,6 +51,22 @@ public class Option
return
"Integer"
;
}
@JsonIgnore
@JSONField
(
serialize
=
false
)
public
String
getName
()
{
String
name
=
"V_"
+
getValue
().
toString
().
replace
(
"("
,
""
).
replace
(
")"
,
""
)
.
replace
(
"("
,
""
).
replace
(
")"
,
""
)
.
replace
(
":"
,
""
).
replace
(
":"
,
""
)
.
replace
(
"、"
,
""
).
replace
(
"."
,
""
)
.
replace
(
"。"
,
""
).
replace
(
";"
,
""
)
.
replace
(
";"
,
""
).
replace
(
"-"
,
""
)
.
replace
(
","
,
""
).
replace
(
"\\"
,
""
)
.
replace
(
"/"
,
""
).
replace
(
","
,
""
);
return
name
;
}
public
Option
addChildren
(
Option
item
)
{
if
(
children
==
null
)
children
=
new
ArrayList
<
Option
>();
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/VoFieldModel.java
浏览文件 @
576834e2
package
cn
.
ibizlab
.
codegen
.
model
;
import
cn.ibizlab.codegen.utils.StringAdvUtils
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
net.ibizsys.model.app.dataentity.IPSAppDEField
;
import
net.ibizsys.model.control.IPSEditor
;
import
net.ibizsys.model.control.editor.IPSCheckBoxList
;
import
net.ibizsys.model.control.editor.IPSCodeListEditor
;
import
net.ibizsys.model.control.editor.IPSMDropDownList
;
import
net.ibizsys.model.control.form.IPSDEFDCatGroupLogic
;
import
net.ibizsys.model.control.form.IPSDEForm
;
import
net.ibizsys.model.control.form.IPSDEFormItem
;
import
net.ibizsys.model.dataentity.service.IPSDEMethodDTOField
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
@Getter
...
...
@@ -57,21 +63,60 @@ public class VoFieldModel extends BaseModel {
return
type
;
}
private
String
logicName
;
public
String
getLogicName
()
{
String
logicName
=
this
.
getPSDEFormItem
().
getCaption
();
if
(
logicName
==
null
)
{
logicName
=
this
.
getPSDEFormItem
().
getCaption
();
if
(
StringUtils
.
isEmpty
(
logicName
)&&
this
.
getPSEditor
()!=
null
)
{
logicName
=
this
.
getPSEditor
().
getLogicName
();
}
if
(
StringUtils
.
isEmpty
(
logicName
)&&
this
.
getAppDEField
()!=
null
)
{
logicName
=
this
.
getAppDEField
().
getLogicName
();
}
if
(
StringUtils
.
isEmpty
(
logicName
)&&
this
.
getPSEditor
()!=
null
)
{
logicName
=
this
.
getPSEditor
().
getLogicName
();
}
if
(
StringUtils
.
isEmpty
(
logicName
)&&
this
.
getAppDEField
()!=
null
)
{
logicName
=
this
.
getAppDEField
().
getLogicName
();
}
return
logicName
;
}
public
String
javaType
()
private
String
javaType
;
public
String
getJavaType
()
{
return
getType
().
getJava
();
if
(
javaType
==
null
)
{
javaType
=
getType
().
getJava
();
if
(
this
.
getDict
()!=
null
)
{
javaType
=
StringAdvUtils
.
pascalcase
(
this
.
getDictCodeName
())+
"Dict"
;
if
(!
singleSelect
)
javaType
=
javaType
+
"[]"
;
}
}
return
javaType
;
}
private
String
dictCodeName
;
private
boolean
singleSelect
=
true
;
private
Catalog
dict
;
public
Catalog
getDict
()
{
if
(
dictCodeName
==
null
)
{
dictCodeName
=
""
;
if
(
getPSEditor
()!=
null
&&
getPSEditor
()
instanceof
IPSCodeListEditor
)
{
IPSCodeListEditor
codeListEditor
=(
IPSCodeListEditor
)
getPSDEFormItem
().
getPSEditor
();
if
(
codeListEditor
.
getPSAppCodeList
()!=
null
)
{
dictCodeName
=
codeListEditor
.
getPSAppCodeList
().
getCodeName
();
dict
=
this
.
getVoModel
().
getApp
().
getDictMaps
().
get
(
dictCodeName
);
if
(
"treempick"
.
equalsIgnoreCase
(
codeListEditor
.
getEditorType
())||
codeListEditor
instanceof
IPSMDropDownList
||
codeListEditor
instanceof
IPSCheckBoxList
)
singleSelect
=
false
;
}
}
}
return
dict
;
}
private
String
format
;
...
...
@@ -106,8 +151,67 @@ public class VoFieldModel extends BaseModel {
return
getCodeName
().
toLowerCase
();
}
public
boolean
isRequired
()
{
if
(!
getPSDEFormItem
().
isAllowEmpty
())
{
if
(!
ObjectUtils
.
isEmpty
(
getPSDEFormItem
().
getPSDEFDGroupLogics
()))
{
for
(
IPSDEFDCatGroupLogic
logic:
getPSDEFormItem
().
getPSDEFDGroupLogics
())
if
(
"ITEMBLANK"
.
equalsIgnoreCase
(
logic
.
getLogicCat
()))
return
false
;
}
return
true
;
}
return
false
;
}
public
String
getDefaultValue
()
{
String
dv
=
""
;
if
(!
ObjectUtils
.
isEmpty
(
this
.
getPSDEFormItem
().
getCreateDV
()))
{
if
(
ObjectUtils
.
isEmpty
(
this
.
getPSDEFormItem
().
getCreateDVT
()))
dv
=
this
.
getPSDEFormItem
().
getCreateDV
();
}
if
(
ObjectUtils
.
isEmpty
(
dv
))
{
if
(!
ObjectUtils
.
isEmpty
(
this
.
getPSDEFormItem
().
getUpdateDV
()))
{
if
(
ObjectUtils
.
isEmpty
(
this
.
getPSDEFormItem
().
getUpdateDVT
()))
dv
=
this
.
getPSDEFormItem
().
getUpdateDV
();
}
}
if
(!
ObjectUtils
.
isEmpty
(
dv
))
{
if
(
this
.
getDict
()
!=
null
)
{
dv
=
StringAdvUtils
.
pascalcase
(
dictCodeName
)
+
"Dict.V_"
+
dv
.
replace
(
"("
,
""
).
replace
(
")"
,
""
)
.
replace
(
"("
,
""
).
replace
(
")"
,
""
)
.
replace
(
":"
,
""
).
replace
(
":"
,
""
)
.
replace
(
"、"
,
""
).
replace
(
"."
,
""
)
.
replace
(
"。"
,
""
).
replace
(
";"
,
""
)
.
replace
(
";"
,
""
).
replace
(
"-"
,
""
)
.
replace
(
","
,
""
).
replace
(
"\\"
,
""
)
.
replace
(
"/"
,
""
).
replace
(
","
,
""
);
if
(!
this
.
isSingleSelect
())
return
""
;
}
else
if
(
getType
().
isString
())
dv
=
"\""
+
dv
+
"\""
;
}
return
dv
;
}
private
String
example
;
public
String
getExample
()
{
if
(
example
==
null
)
{
example
=
""
;
}
if
(
this
.
getDict
()
!=
null
&&
!
ObjectUtils
.
isEmpty
(
this
.
getDict
().
getOptions
()))
{
example
=
this
.
getDict
().
getOptions
().
get
(
0
).
getValue
().
toString
();
if
(!
this
.
isSingleSelect
()&&
this
.
getDict
().
getOptions
().
size
()>
1
)
{
example
+=
this
.
getDict
().
getCodeList
().
getValueSeparator
()==
null
?
";"
:
this
.
getDict
().
getCodeList
().
getValueSeparator
();
example
+=
this
.
getDict
().
getOptions
().
get
(
0
).
getValue
().
toString
();
}
}
return
example
;
}
}
modules/ibizlab-template/ibizlab-template-apivo/src/main/resources/templ/{{projectName}}-api/pom.xml.hbs
浏览文件 @
576834e2
...
...
@@ -12,7 +12,35 @@
<artifactId>
{{
projectName
}}
-api
</artifactId>
<name>
{{
projectDesc
}}
Api
</name>
<description>
{{
projectDesc
}}
Api
</description>
<dependencies>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-annotations
</artifactId>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
</dependency>
<dependency>
<groupId>
org.projectlombok
</groupId>
<artifactId>
lombok
</artifactId>
<version>
1.18.12
</version>
</dependency>
<dependency>
<groupId>
io.swagger
</groupId>
<artifactId>
swagger-annotations
</artifactId>
<version>
1.6.2
</version>
<scope>
compile
</scope>
</dependency>
<dependency>
<groupId>
jakarta.validation
</groupId>
<artifactId>
jakarta.validation-api
</artifactId>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
...
...
@@ -32,7 +60,7 @@
../
</output>
<inputSpec>
../../XFOnline_1_3/model
</inputSpec>
<templateDirs>
${basedir}/src/main/resources/templ
...
...
modules/ibizlab-template/ibizlab-template-apivo/src/main/resources/templ/{{projectName}}-api/src/main/java/{{packageName}}/api/{{apps}}/dict/{{dicts}}.java.hbs
→
modules/ibizlab-template/ibizlab-template-apivo/src/main/resources/templ/{{projectName}}-api/src/main/java/{{packageName}}/api/{{apps}}/dict/{{dicts}}
Dict
.java.hbs
浏览文件 @
576834e2
package
{{
packageName
}}
.api.
{{
apps
}}
.dict.
{{
pascalCase
dict
.
codeName
}}
;
{{#
eq
apps
"link"
}}
package
{{
packageName
}}
.api.
{{
apps
}}
.dict;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
/**
*
{{
dict
.
name
}}
*
字典:
{{
dict
.
name
}}
*/
public class
{{
pascalCase
dict
.
codeName
}}
{
@ApiModel(value = "
{{
dict
.
codeName
}}
", description = "字典:
{{
dict
.
name
}}
")
public enum
{{
pascalCase
dict
.
codeName
}}
Dict {
{{#
each
dict
.
option
s
}}
{{#
each
dict
.
set
s
}}
{{#
eq
dict
.
valueType
"String"
}}
V_
{{
value
}}
_N_
{{
label
}}
("
{{
value
}}
","
{{
label
}}
",
{{#if
parent
}}
"
{{
parent
}}
"
{{else}}
null
{{/if}}
)
{{#if
@last
}}
;
{{else}}
,
{{/if}}
{{
name
}}
("
{{
value
}}
","
{{
label
}}
",
{{#if
parent
}}
"
{{
parent
}}
"
{{else}}
null
{{/if}}
)
{{#if
@last
}}
;
{{else}}
,
{{/if}}
{{/
eq
}}
{{#
eq
dict
.
valueType
"Integer"
}}
V_
{{
value
}}
_N_
{{
label
}}
(
{{
value
}}
,"
{{
label
}}
",
{{#if
parent
}}{{
parent
}}{{else}}
null
{{/if}}
)
{{#if
@last
}}
;
{{else}}
,
{{/if}}
{{
name
}}
(
{{
value
}}
,"
{{
label
}}
",
{{#if
parent
}}{{
parent
}}{{else}}
null
{{/if}}
)
{{#if
@last
}}
;
{{else}}
,
{{/if}}
{{/
eq
}}
{{/
each
}}
...
...
@@ -36,7 +39,7 @@ public class {{pascalCase dict.codeName}} {
return parent;
}
{{
pascalCase
dict
.
codeName
}}
(
{{
dict
.
valueType
}}
value, String label,
{{
dict
.
valueType
}}
parent) {
{{
pascalCase
dict
.
codeName
}}
Dict
(
{{
dict
.
valueType
}}
value, String label,
{{
dict
.
valueType
}}
parent) {
this.value = value;
this.label = label;
this.parent = parent;
...
...
@@ -44,16 +47,17 @@ public class {{pascalCase dict.codeName}} {
@JsonCreator
@JSONCreator
public static
{{
pascalCase
dict
.
codeName
}}
valueOf(Object tag) {
public static
{{
pascalCase
dict
.
codeName
}}
Dict
valueOf(Object tag) {
if(tag==null)
return null;
for (
{{
pascalCase
dict
.
codeName
}}
item : values())
for (
{{
pascalCase
dict
.
codeName
}}
Dict
item : values())
if (item.getValue().equals(tag)
{{#
eq
dict
.
valueType
"Integer"
}}
||item.getValue().toString().equals(tag)
{{/
eq
}}
)
return item;
Sjjcy
ret =null;
for (
{{
pascalCase
dict
.
codeName
}}
item : values())
{{
pascalCase
dict
.
codeName
}}
Dict
ret =null;
for (
{{
pascalCase
dict
.
codeName
}}
Dict
item : values())
if (item.getLabel().equals(tag))
ret = item;
return ret;
}
}
\ No newline at end of file
}
{{/
eq
}}
\ No newline at end of file
modules/ibizlab-template/ibizlab-template-apivo/src/main/resources/templ/{{projectName}}-api/src/main/java/{{packageName}}/api/{{apps}}/dto/{{pascalCase appEntities}}/{{pascalCase ctrls@FORM}}Dto.java.hbs
浏览文件 @
576834e2
package
{{
packageName
}}
.api.
{{
apps
}}
.dto.
{{
pascalCase
appEntity
.
codeName
}}
;
{{#
eq
apps
"link"
}}
package
{{
packageName
}}
.api.
{{
apps
}}
.dto.
{{
pascalCase
appEntities
}}
;
import java.sql.Timestamp;
import java.util.ArrayList;
...
...
@@ -21,15 +22,16 @@ import lombok.*;
import lombok.experimental.Accessors;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import
{{
packageName
}}
.api.
{{
apps
}}
.dict.*;
/**
*
{{
ctrl
.
appEntity
.
entity
.
logicName
}}
DTO对象[
{{
ctrl
.
codeName
}}
]
{{
replace
ctrl
.
logicName
"
编辑
"
""
}}
*
{{
ctrl
.
appEntity
.
entity
.
logicName
}}
DTO对象[
{{
ctrl
.
codeName
}}
]
{{
replace
ctrl
.
logicName
"
表单
"
""
}}
*/
@Getter
@Setter
@NoArgsConstructor
@ApiModel(
"
{{
ctrl
.
appEntity
.
entity
.
logicName
}}
DTO对象[
{{
ctrl
.
codeName
}}
]
")
public class
{{
ctrl
.
codeName
}}
Dto implements Serializable {
@ApiModel(
value = "
{{
appEntities
}}
-
{{
ctrl
.
codeName
}}
", description = "
{{
ctrl
.
appEntity
.
entity
.
logicName
}}
DTO对象[
{{
ctrl
.
codeName
}}
]
{{
replace
ctrl
.
logicName
"表单"
""
}}
")
public class
{{
pascalCase
ctrl
.
codeName
}}
Dto implements Serializable {
private static final long serialVersionUID = 1L;
...
...
@@ -45,8 +47,9 @@ public class {{ctrl.codeName}}Dto implements Serializable {
{{#
eq
javaType
"Long"
}}
@JsonSerialize(using = ToStringSerializer.class)
{{/
eq
}}
@ApiModelProperty(
"
{{
logicName
}}
"
)
private
{{
javaType
}}
{{
camelCase
codeName
}}
;
@ApiModelProperty(
value = "
{{
logicName
}}
"
{{#if
timeType
}}
, notes = "格式:
{{
format
}}
"
{{/if}}{{#if
dict
}}
, notes = "字典:
{{
dict
.
name
}}
", dataType = "
{{
lowerCase
type
.
java
}}
", reference = "
{{
dictCodeName
}}
"
{{/if}}{{#if
required
}}
, required = true
{{/if}}{{#if
hidden
}}
, hidden = true
{{/if}}{{#if
example
}}
, example = "
{{
example
}}
"
{{/if}}
)
private
{{
javaType
}}
{{
camelCase
codeName
}}
{{#if
defaultValue
}}
=
{{
defaultValue
}}{{/if}}
;
{{/
each
}}
}
\ No newline at end of file
}
{{/
eq
}}
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录