Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
80a5cb0c
提交
80a5cb0c
编写于
1月 05, 2022
作者:
xignzi006
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Dto、Mapping发布
上级
a051b91e
变更
11
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
287 行增加
和
23 行删除
+287
-23
ApiDtoFieldModel.java
.../main/java/cn/ibizlab/codegen/model/ApiDtoFieldModel.java
+77
-0
ApiDtoModel.java
...e/src/main/java/cn/ibizlab/codegen/model/ApiDtoModel.java
+66
-0
ApiEntityModel.java
...rc/main/java/cn/ibizlab/codegen/model/ApiEntityModel.java
+25
-21
ModelStorage.java
.../src/main/java/cn/ibizlab/codegen/model/ModelStorage.java
+13
-0
TemplateFileType.java
.../java/cn/ibizlab/codegen/templating/TemplateFileType.java
+2
-0
{{apiDtos@DEFAULT}}.java.hbs
...{{packageName}}/{{apis}}/dto/{{apiDtos@DEFAULT}}.java.hbs
+74
-0
{{apiDtos@DEFILTER}}.java.hbs
...{packageName}}/{{apis}}/dto/{{apiDtos@DEFILTER}}.java.hbs
+3
-0
{{apiEntities}}DTO.java.hbs
.../{{packageName}}/{{apis}}/dto/{{apiEntities}}DTO.java.hbs
+3
-1
{{apiDtos@DEFAULT}}Mapping.java.hbs
...me}}/{{apis}}/mapping/{{apiDtos@DEFAULT}}Mapping.java.hbs
+18
-0
{{apiDtos@DEFILTER}}Mapping.java.hbs
...e}}/{{apis}}/mapping/{{apiDtos@DEFILTER}}Mapping.java.hbs
+3
-0
{{apiEntities}}Mapping.java.hbs
...geName}}/{{apis}}/mapping/{{apiEntities}}Mapping.java.hbs
+3
-1
未找到文件。
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/ApiDtoFieldModel.java
0 → 100644
浏览文件 @
80a5cb0c
package
cn
.
ibizlab
.
codegen
.
model
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
net.ibizsys.model.dataentity.IPSDataEntity
;
import
net.ibizsys.model.dataentity.defield.IPSDEField
;
import
net.ibizsys.model.dataentity.service.IPSDEMethodDTO
;
import
net.ibizsys.model.dataentity.service.IPSDEMethodDTOField
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
ApiDtoFieldModel
extends
BaseModel
{
private
ApiDtoModel
apiDto
;
private
String
type
=
""
;
public
ApiDtoFieldModel
(
ApiDtoModel
apiDto
,
IPSDEMethodDTOField
iPSDEMethodDTOField
)
{
this
.
opt
=
iPSDEMethodDTOField
;
this
.
apiDto
=
apiDto
;
this
.
type
=
iPSDEMethodDTOField
.
getType
();
this
.
setCodeName
(
iPSDEMethodDTOField
.
getName
());
this
.
setName
(
iPSDEMethodDTOField
.
getName
());
}
public
IPSDEMethodDTOField
getPSDEMethodDTOField
()
{
return
(
IPSDEMethodDTOField
)
opt
;
}
public
String
getJavaType
()
{
if
(
type
.
equals
(
"DTO"
))
{
return
getPSDEMethodDTOField
().
getRefPSDEMethodDTO
().
getName
();
}
else
if
(
type
.
equals
(
"DTOS"
))
{
return
String
.
format
(
"List<%s>"
,
getPSDEMethodDTOField
().
getRefPSDEMethodDTO
().
getName
());
}
else
if
(
type
.
equals
(
"SIMPLE"
))
{
return
PropType
.
findType
(
getPSDEMethodDTOField
().
getStdDataType
()).
java
;
}
else
if
(
type
.
equals
(
"SIMPLES"
))
{
return
String
.
format
(
"List<%s>"
,
PropType
.
findType
(
getPSDEMethodDTOField
().
getStdDataType
()).
java
);
}
return
"String"
;
}
public
String
getLogicName
()
{
if
(
StringUtils
.
isBlank
(
getPSDEMethodDTOField
().
getLogicName
()))
{
if
(
getPSDEMethodDTOField
().
getRefPSDataEntity
()
!=
null
)
return
getPSDEMethodDTOField
().
getRefPSDataEntity
().
getLogicName
();
}
return
getPSDEMethodDTOField
().
getLogicName
();
}
public
String
getJsonName
()
{
return
getPSDEMethodDTOField
().
getName
().
toLowerCase
();
}
public
boolean
isPredefinedType
(){
if
(
getPSDEMethodDTOField
().
getPSDEField
()!=
null
){
return
StringUtils
.
isNotEmpty
(
getPSDEMethodDTOField
().
getPSDEField
().
getPredefinedType
());
}
return
false
;
}
public
boolean
isKeyDEField
(){
if
(
getPSDEMethodDTOField
().
getPSDEField
()!=
null
){
return
getPSDEMethodDTOField
().
getPSDEField
().
isKeyDEField
();
}
return
false
;
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/ApiDtoModel.java
0 → 100644
浏览文件 @
80a5cb0c
package
cn
.
ibizlab
.
codegen
.
model
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
net.ibizsys.model.dataentity.IPSDataEntity
;
import
net.ibizsys.model.dataentity.service.IPSDEMethodDTO
;
import
net.ibizsys.model.dataentity.service.IPSDEMethodDTOField
;
import
net.ibizsys.model.dataentity.service.IPSDEServiceAPI
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
ApiDtoModel
extends
BaseModel
{
private
ApiModel
api
;
private
ApiEntityModel
apiEntity
;
String
type
=
""
;
public
ApiDtoModel
(
ApiEntityModel
apiEntityModel
,
IPSDEMethodDTO
iPSDEMethodDTO
)
{
this
.
opt
=
iPSDEMethodDTO
;
this
.
type
=
iPSDEMethodDTO
.
getType
();
this
.
apiEntity
=
apiEntityModel
;
this
.
api
=
apiEntityModel
.
getApi
();
this
.
setCodeName
(
iPSDEMethodDTO
.
getName
());
this
.
setName
(
iPSDEMethodDTO
.
getName
());
}
public
String
getLogicName
()
{
return
((
IPSDEServiceAPI
)
apiEntity
.
getOpt
()).
getLogicName
();
}
public
ApiEntityModel
getApiEntity
()
{
return
apiEntity
;
}
public
IPSDataEntity
getPSDataEntity
()
{
return
((
IPSDEMethodDTO
)
opt
).
getParentPSModelObject
(
IPSDataEntity
.
class
);
}
public
EntityModel
getEntity
()
{
return
api
.
getSystem
().
getEntity
(
getPSDataEntity
().
getCodeName
());
}
private
List
<
ApiDtoFieldModel
>
ApiDtoFields
;
public
List
<
ApiDtoFieldModel
>
getApiDtoFields
()
{
if
(
ApiDtoFields
==
null
)
{
ApiDtoFields
=
new
ArrayList
<>();
if
(((
IPSDEMethodDTO
)
opt
).
getPSDEMethodDTOFields
()
!=
null
)
{
for
(
IPSDEMethodDTOField
iPSDEMethodDTOField
:
((
IPSDEMethodDTO
)
opt
).
getPSDEMethodDTOFields
())
{
ApiDtoFieldModel
apiDtoFieldModel
=
new
ApiDtoFieldModel
(
this
,
iPSDEMethodDTOField
);
ApiDtoFields
.
add
(
apiDtoFieldModel
);
}
}
}
return
ApiDtoFields
;
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/ApiEntityModel.java
浏览文件 @
80a5cb0c
...
...
@@ -4,52 +4,56 @@ import lombok.Getter;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
net.ibizsys.model.dataentity.service.IPSDEMethodDTO
;
import
net.ibizsys.model.dataentity.service.IPSDEServiceAPI
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
ApiEntityModel
extends
BaseModel
{
public
class
ApiEntityModel
extends
BaseModel
{
public
ApiEntityModel
(
ApiModel
apiModel
,
IPSDEServiceAPI
apiDataEntity
)
{
this
.
opt
=
apiDataEntity
;
this
.
api
=
apiModel
;
public
ApiEntityModel
(
ApiModel
apiModel
,
IPSDEServiceAPI
apiDataEntity
)
{
this
.
opt
=
apiDataEntity
;
this
.
api
=
apiModel
;
this
.
setCodeName
(
apiDataEntity
.
getCodeName
());
this
.
setName
(
apiDataEntity
.
getName
());
this
.
setId
(
String
.
format
(
"%1$s-%2$s"
,
api
.
getCodeName
(),
apiDataEntity
.
getCodeName
()));
this
.
setId
(
String
.
format
(
"%1$s-%2$s"
,
api
.
getCodeName
(),
apiDataEntity
.
getCodeName
()));
if
(
apiDataEntity
.
getPSDataEntity
()
!=
null
&&
apiDataEntity
.
getPSDataEntity
().
getAllPSDEMethodDTOs
()
!=
null
)
{
for
(
IPSDEMethodDTO
iPSDEMethodDTO
:
apiDataEntity
.
getPSDataEntity
().
getAllPSDEMethodDTOs
())
{
apiDtosMap
.
put
(
iPSDEMethodDTO
.
getName
(),
new
ApiDtoModel
(
this
,
iPSDEMethodDTO
));
}
}
}
public
IPSDEServiceAPI
getApiDataEntity
()
{
return
(
IPSDEServiceAPI
)
opt
;
public
IPSDEServiceAPI
getApiDataEntity
()
{
return
(
IPSDEServiceAPI
)
opt
;
}
private
ApiModel
api
;
public
EntityModel
getEntity
()
{
public
EntityModel
getEntity
()
{
return
api
.
getSystem
().
getEntity
(
getApiDataEntity
().
getPSDataEntity
().
getCodeName
());
}
private
List
<
FieldModel
>
properties
;
public
List
<
FieldModel
>
getProperties
()
{
if
(
properties
==
null
)
{
properties
=
new
ArrayList
<>();
getEntity
().
getFields
().
forEach
(
field
->{
public
List
<
FieldModel
>
getProperties
()
{
if
(
properties
==
null
)
{
properties
=
new
ArrayList
<>();
getEntity
().
getFields
().
forEach
(
field
->
{
properties
.
add
(
field
);
});
}
return
properties
;
}
private
Map
<
String
,
ApiDtoModel
>
apiDtosMap
=
new
LinkedHashMap
<>();
public
Collection
<
ApiDtoModel
>
getDtos
()
{
return
apiDtosMap
.
values
();
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/ModelStorage.java
浏览文件 @
80a5cb0c
...
...
@@ -120,6 +120,19 @@ public class ModelStorage {
});
});
}
else
if
(
type
.
equals
(
TemplateFileType
.
apiDto
))
{
getSystemModel
().
getApis
().
forEach
(
api
->
{
api
.
getApiEntities
().
forEach
(
item
->
{
item
.
getDtos
().
forEach
(
dto
->
{
CliOption
opt
=
newCliOption
(
TemplateFileType
.
apiDto
)
.
setCliSubType
(
dto
.
getType
())
.
baseData
(
dto
,
dto
.
getCodeName
())
.
set
(
"apiDtos"
,
dto
.
getCodeName
()).
set
(
"apis"
,
dto
.
getApi
().
getCodeName
().
toLowerCase
());
rt
.
addOption
(
opt
);
});
});
});
}
else
if
(
type
.
equals
(
TemplateFileType
.
app
))
{
getSystemModel
().
getApps
().
forEach
(
item
->{
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/templating/TemplateFileType.java
浏览文件 @
80a5cb0c
...
...
@@ -6,6 +6,7 @@ public enum TemplateFileType {
page
(
Constants
.
PAGES
),
appEntity
(
Constants
.
APP_ENTITIES
),
apiEntity
(
Constants
.
API_ENTITIES
),
apiDto
(
Constants
.
API_DTOS
),
entity
(
Constants
.
ENTITIES
),
module
(
Constants
.
MODULES
),
api
(
Constants
.
APIS
),
...
...
@@ -45,6 +46,7 @@ public enum TemplateFileType {
public
static
final
String
APPS
=
"apps"
;
public
static
final
String
ENTITIES
=
"entities"
;
public
static
final
String
API_ENTITIES
=
"apiEntities"
;
public
static
final
String
API_DTOS
=
"apiDtos"
;
public
static
final
String
APP_ENTITIES
=
"appEntities"
;
public
static
final
String
MODULES
=
"modules"
;
public
static
final
String
PAGES
=
"pages"
;
...
...
modules/ibizlab-generator-core/src/main/resources/templ/r7/{{projectName}}-provider/{{projectName}}-provider-{{apis}}/src/main/java/{{packageName}}/{{apis}}/dto/{{apiDtos@DEFAULT}}.java.hbs
0 → 100644
浏览文件 @
80a5cb0c
{{#
unless
apiDto
.
apiEntity
.
subSysDE
}}
package
{{
packageName
}}
.
{{
apis
}}
.dto;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.math.BigInteger;
import java.util.Map;
import java.util.HashMap;
import java.io.Serializable;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.alibaba.fastjson.annotation.JSONField;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import cn.ibizlab.util.domain.DTOBase;
import cn.ibizlab.util.domain.DTOClient;
import lombok.*;
import lombok.experimental.Accessors;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* 服务DTO对象[
{{
apiDto
.
codeName
}}
]
*/
@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
@ApiModel("
{{
apiDto
.
logicName
}}
")
public class
{{
apiDto
.
codeName
}}
extends
{{#
eq
apiDto
.
apiEntity
.
entity
.
psSubSysServiceAPI
.
serviceType
"MIDDLEPLATFORM"
}}
DTOClient
{{else}}
DTOBase
{{/
eq
}}
implements Serializable {
private static final long serialVersionUID = 1L;
{{#
each
apiDto
.
apiDtoFields
}}
/**
*
{{
logicName
}}
*/
@JsonProperty("
{{
jsonName
}}
")
{{#
timeType
}}
@JsonFormat(pattern = "
{{
format
}}
", locale = "zh", timezone = "GMT+8")
{{/
timeType
}}
@JSONField(name = "
{{
jsonName
}}
"
{{#
timeType
}}
, format = "
{{
format
}}
"
{{/
timeType
}}
)
{{#
eq
javaType
"Long"
}}
@JsonSerialize(using = ToStringSerializer.class)
{{/
eq
}}
@ApiModelProperty("
{{
logicName
}}
")
private
{{
javaType
}}
{{
camelCase
codeName
}}
;
{{/
each
}}
{{#
each
apiDto
.
apiDtoFields
}}
{{#
unless
keyDEField
}}
{{#
unless
predefinedType
}}
/**
* 设置 [
{{
logicName
}}
]
*/
public
{{
apiDto
.
codeName
}}
set
{{
pascalCase
codeName
}}
(
{{
javaType
}}
{{
camelCase
codeName
}}
) {
this.
{{
camelCase
codeName
}}
=
{{
camelCase
codeName
}}
;
this.modify("
{{
lowerCase
name
}}
",
{{
camelCase
codeName
}}
);
return this;
}
{{/
unless
}}
{{/
unless
}}
{{/
each
}}
}
{{/
unless
}}
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/{{projectName}}-provider/{{projectName}}-provider-{{apis}}/src/main/java/{{packageName}}/{{apis}}/dto/{{apiDtos@DEFILTER}}.java.hbs
0 → 100644
浏览文件 @
80a5cb0c
{{#
eq
apiDto
.
name
""
}}
{{
apiDto
.
name
}}
{{/
eq
}}
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/{{projectName}}-provider/{{projectName}}-provider-{{apis}}/src/main/java/{{packageName}}/{{apis}}/dto/{{apiEntities}}DTO.java.hbs
浏览文件 @
80a5cb0c
{{#
eq
apiEntity
.
codeName
""
}}
{{#
unless
apiEntity
.
subSysDE
}}
package
{{
packageName
}}
.
{{
lowerCase
apiEntity
.
api
.
codeName
}}
.dto;
...
...
@@ -98,4 +99,5 @@ public class {{apiEntity.codeName}}DTO extends {{#eq apiEntity.entity.psSubSysSe
{{/
apiEntity
.
entity
.
nesteds
}}
}
{{/
unless
}}
\ No newline at end of file
{{/
unless
}}
{{/
eq
}}
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/{{projectName}}-provider/{{projectName}}-provider-{{apis}}/src/main/java/{{packageName}}/{{apis}}/mapping/{{apiDtos@DEFAULT}}Mapping.java.hbs
0 → 100644
浏览文件 @
80a5cb0c
{{#
unless
apiDto
.
apiEntity
.
subSysDE
}}
package
{{
packageName
}}
.
{{
apis
}}
.mapping;
{{#
with
apiDto
.
apiEntity
.
entity
as
|
entity
|
}}
import org.mapstruct.*;
import
{{
packageName
}}
.core.
{{
entity
.
module
}}
.domain.
{{
entity
.
codeName
}}
;
import
{{
packageName
}}
.
{{
apis
}}
.dto.
{{
apiDto
.
codeName
}}
;
import cn.ibizlab.util.domain.MappingBase;
@Mapper(componentModel = "spring", uses = {}, implementationName = "
{{
api
.
codeName
}}{{
apiDto
.
codeName
}}
Mapping",
nullValuePropertyMappingStrategy = NullValuePropertyMappingStrategy.IGNORE,
nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface
{{
apiDto
.
codeName
}}
Mapping extends MappingBase
<
{{
apiDto
.
codeName
}}
,
{{
entity
.
codeName
}}
>
{
}
{{/
with
}}
{{/
unless
}}
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/{{projectName}}-provider/{{projectName}}-provider-{{apis}}/src/main/java/{{packageName}}/{{apis}}/mapping/{{apiDtos@DEFILTER}}Mapping.java.hbs
0 → 100644
浏览文件 @
80a5cb0c
{{#
eq
apiDto
.
name
""
}}
{{
apiDto
.
name
}}
{{/
eq
}}
\ No newline at end of file
modules/ibizlab-generator-core/src/main/resources/templ/r7/{{projectName}}-provider/{{projectName}}-provider-{{apis}}/src/main/java/{{packageName}}/{{apis}}/mapping/{{apiEntities}}Mapping.java.hbs
浏览文件 @
80a5cb0c
{{#
eq
apiEntity
.
codeName
""
}}
{{#
unless
apiEntity
.
subSysDE
}}
package
{{
packageName
}}
.
{{
lowerCase
apiEntity
.
api
.
codeName
}}
.mapping;
...
...
@@ -15,4 +16,5 @@ public interface {{apiEntity.codeName}}Mapping extends MappingBase<{{apiEntity.c
}
{{/
with
}}
{{/
unless
}}
\ No newline at end of file
{{/
unless
}}
{{/
eq
}}
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录