Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibizlab-generator
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibizlab-generator
提交
810f0bea
提交
810f0bea
编写于
10月 26, 2022
作者:
chenxiang@lab.ibiz5.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
接口实体模板
上级
3b784b35
变更
13
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
1167 行增加
和
811 行删除
+1167
-811
ClientDtoModel.java
...rc/main/java/cn/ibizlab/codegen/model/ClientDtoModel.java
+22
-0
ClientEntityModel.java
...main/java/cn/ibizlab/codegen/model/ClientEntityModel.java
+121
-0
ClientEntityRSModel.java
...in/java/cn/ibizlab/codegen/model/ClientEntityRSModel.java
+53
-0
ClientMethodModel.java
...main/java/cn/ibizlab/codegen/model/ClientMethodModel.java
+301
-0
ClientModel.java
...e/src/main/java/cn/ibizlab/codegen/model/ClientModel.java
+93
-0
EntityModel.java
...e/src/main/java/cn/ibizlab/codegen/model/EntityModel.java
+452
-555
ModelStorage.java
.../src/main/java/cn/ibizlab/codegen/model/ModelStorage.java
+16
-0
SubEntityApiModel.java
...main/java/cn/ibizlab/codegen/model/SubEntityApiModel.java
+0
-25
SystemModel.java
...e/src/main/java/cn/ibizlab/codegen/model/SystemModel.java
+16
-30
TemplateFileType.java
.../java/cn/ibizlab/codegen/templating/TemplateFileType.java
+4
-4
{{clientEntities}}FeignClient.java.hbs
...{{modules}}/client/{{clientEntities}}FeignClient.java.hbs
+65
-0
{{entities@ServiceAPI}}FeignClient.java.hbs
...ules}}/client/{{entities@ServiceAPI}}FeignClient.java.hbs
+0
-136
{{entities@ServiceAPI}}ServiceBase.java.hbs
.../service/impl/{{entities@ServiceAPI}}ServiceBase.java.hbs
+24
-61
未找到文件。
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/ClientDtoModel.java
0 → 100644
浏览文件 @
810f0bea
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
net.ibizsys.model.service.IPSSubSysServiceAPIDTO
;
import
java.util.ArrayList
;
import
java.util.List
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
ClientDtoModel
extends
BaseModel
{
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/ClientEntityModel.java
0 → 100644
浏览文件 @
810f0bea
package
cn
.
ibizlab
.
codegen
.
model
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
net.ibizsys.model.dataentity.service.IPSDEServiceAPIMethod
;
import
net.ibizsys.model.dataentity.service.IPSDEServiceAPIRS
;
import
net.ibizsys.model.service.IPSSubSysServiceAPIDE
;
import
net.ibizsys.model.service.IPSSubSysServiceAPIDEMethod
;
import
net.ibizsys.model.service.IPSSubSysServiceAPIDERS
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
ClientEntityModel
extends
BaseModel
{
private
ClientModel
client
;
public
ClientEntityModel
(
ClientModel
clientModel
,
IPSSubSysServiceAPIDE
iPSSubSysServiceAPIDE
)
{
this
.
opt
=
iPSSubSysServiceAPIDE
;
this
.
client
=
clientModel
;
this
.
setCodeName
(
iPSSubSysServiceAPIDE
.
getCodeName
());
this
.
setName
(
iPSSubSysServiceAPIDE
.
getName
());
this
.
setId
(
String
.
format
(
"%1$s-%2$s"
,
client
.
getCodeName
(),
iPSSubSysServiceAPIDE
.
getCodeName
()));
}
public
IPSSubSysServiceAPIDE
getPSSubSysServiceAPIDE
()
{
return
(
IPSSubSysServiceAPIDE
)
opt
;
}
public
EntityModel
getEntity
()
{
return
this
.
getClient
().
getSystem
().
getEntity
(
getCodeName
());
}
private
String
apiName
;
public
String
getApiName
()
{
if
(
apiName
==
null
)
this
.
apiName
=
ObjectUtils
.
isEmpty
(
getPSSubSysServiceAPIDE
().
getLogicName
())
?
getEntity
().
getLogicName
()
:
getPSSubSysServiceAPIDE
().
getLogicName
();
return
apiName
;
}
public
boolean
isMajor
()
{
return
getPSSubSysServiceAPIDE
().
isMajor
();
}
public
List
<
ClientMethodModel
>
getMethods
()
{
List
<
ClientMethodModel
>
methods
=
new
ArrayList
<>();
//主接口方法
if
(
getPSSubSysServiceAPIDE
().
isMajor
()
&&
getPSSubSysServiceAPIDE
().
getPSSubSysServiceAPIDEMethods
()
!=
null
)
{
for
(
IPSSubSysServiceAPIDEMethod
iPSSubSysServiceAPIDEMethod
:
getPSSubSysServiceAPIDE
().
getPSSubSysServiceAPIDEMethods
())
{
methods
.
add
(
new
ClientMethodModel
(
this
,
null
,
iPSSubSysServiceAPIDEMethod
));
}
}
//接口关系方法
// if (this.getClient().getPSSubSysServiceAPI().getAllPSSubSysServiceAPIDERSs() != null) {
// for (IPSSubSysServiceAPIDERS iPSSubSysServiceAPIDERS : this.getClient().getPSSubSysServiceAPI().getAllPSSubSysServiceAPIDERSs()) {
// if(!iPSSubSysServiceAPIDERS.getMinorPSSubSysServiceAPIDE().getId().equalsIgnoreCase(this.getPSSubSysServiceAPIDE().getId()))
// continue;
// if (iPSSubSysServiceAPIDERS.getPSDEServiceAPIMethods() != null) {
// ApiEntityRSModel apiEntityRSModel = api.getApiEntityRS(iPSDEServiceAPIRS.getName());
// //计算父路径
// List<List<ApiEntityRSModel>> parentApiEntityList = new ArrayList<>();
// fillDEAPIRSPath(parentApiEntityList, apiEntityRSModel, null);
// for (List<ApiEntityRSModel> parentApiEntities : parentApiEntityList) {
// for (IPSDEServiceAPIMethod iPSDEServiceAPIMethod : iPSDEServiceAPIRS.getPSDEServiceAPIMethods()) {
// if(iPSDEServiceAPIMethod.getPSDEDataSet()!=null && iPSDEServiceAPIMethod.getPSDEDataSet().getPSDEDataQueries()==null)
// continue ;
// methods.add(new ApiMethodModel(this, parentApiEntities, iPSDEServiceAPIMethod));
// }
// }
// }
// }
// }
return
methods
;
}
/**
* 递归计算接口关系path
* 注意自身关系
*
* @param parentClientEntityList
* @param clientEntityRSModel
* @param parentClientEntities
*/
private
void
fillDEAPIRSPath
(
List
<
List
<
ClientEntityRSModel
>>
parentClientEntityList
,
ClientEntityRSModel
clientEntityRSModel
,
List
<
ClientEntityRSModel
>
parentClientEntities
)
{
if
(
parentClientEntities
==
null
)
{
parentClientEntities
=
new
ArrayList
<>();
}
//防止递归
if
(
parentClientEntities
.
stream
().
anyMatch
(
rs
->
rs
.
getName
().
equals
(
clientEntityRSModel
.
getName
())))
{
return
;
}
parentClientEntities
.
add
(
clientEntityRSModel
);
if
(
clientEntityRSModel
.
isMajorEntityMajor
())
{
List
<
ClientEntityRSModel
>
temp
=
new
ArrayList
<>();
temp
.
addAll
(
parentClientEntities
);
parentClientEntityList
.
add
(
temp
);
}
//递归
// List<ApiEntityRSModel> parents = api.getApiEntityParentRSes(apiEntityRSModel.getMajorEntityCodeName());
List
<
ClientEntityRSModel
>
parents
=
new
ArrayList
<>();
if
(!
CollectionUtils
.
isEmpty
(
parents
))
{
for
(
ClientEntityRSModel
parentRs
:
parents
)
{
List
<
ClientEntityRSModel
>
tempParentApiEntities
=
new
ArrayList
<>();
tempParentApiEntities
.
addAll
(
parentClientEntities
);
fillDEAPIRSPath
(
parentClientEntityList
,
parentRs
,
tempParentApiEntities
);
}
}
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/ClientEntityRSModel.java
0 → 100644
浏览文件 @
810f0bea
package
cn
.
ibizlab
.
codegen
.
model
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
net.ibizsys.model.service.IPSSubSysServiceAPIDERS
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
ClientEntityRSModel
extends
BaseModel
{
public
ClientEntityRSModel
(
ClientModel
clientModel
,
IPSSubSysServiceAPIDERS
iPSSubSysServiceAPIDERS
)
{
this
.
opt
=
iPSSubSysServiceAPIDERS
;
this
.
clientModel
=
clientModel
;
this
.
setCodeName
(
iPSSubSysServiceAPIDERS
.
getCodeName
());
this
.
setName
(
iPSSubSysServiceAPIDERS
.
getName
());
}
private
ClientModel
clientModel
;
public
String
getParentIdFieldCodeName
()
{
// if (getPSDEServiceAPIRS().getParentIdPSDEField() != null)
// return getPSDEServiceAPIRS().getParentIdPSDEField().getCodeName();
return
""
;
}
public
int
getParentIdFieldType
()
{
// if (getPSDEServiceAPIRS().getParentIdPSDEField() != null)
// return getPSDEServiceAPIRS().getParentIdPSDEField().getStdDataType();
return
PropType
.
VARCHAR
.
code
;
}
public
String
getMajorEntityCodeName
()
{
return
getPSDEServiceAPIRS
().
getMajorPSSubSysServiceAPIDE
().
getCodeName
();
}
public
boolean
isMajorEntityMajor
()
{
return
getPSDEServiceAPIRS
().
getMajorPSSubSysServiceAPIDE
().
isMajor
();
}
public
String
getMinorEntityCodeName
()
{
return
getPSDEServiceAPIRS
().
getMinorPSSubSysServiceAPIDE
().
getCodeName
();
}
private
IPSSubSysServiceAPIDERS
getPSDEServiceAPIRS
()
{
return
(
IPSSubSysServiceAPIDERS
)
opt
;
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/ClientMethodModel.java
0 → 100644
浏览文件 @
810f0bea
此差异已折叠。
点击以展开。
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/
SubServiceApi
Model.java
→
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/
Client
Model.java
浏览文件 @
810f0bea
...
...
@@ -13,24 +13,59 @@ import java.util.*;
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
SubServiceApi
Model
extends
BaseModel
{
public
class
Client
Model
extends
BaseModel
{
private
SystemModel
system
;
private
Map
<
String
,
SubEntityApiModel
>
subEntityApi
=
new
LinkedHashMap
<>();
private
Map
<
String
,
ClientEntityModel
>
clientEntityMap
=
new
LinkedHashMap
<>();
public
SubServiceApiModel
(
IPSSubSysServiceAPI
iPSSubSysServiceAPI
)
{
private
Map
<
String
,
ClientEntityRSModel
>
clientEntityRSMap
=
new
LinkedHashMap
<>();
public
Collection
<
ClientEntityRSModel
>
getClientEntityRSes
()
{
return
clientEntityRSMap
.
values
();
}
public
ClientEntityRSModel
getClientEntityRS
(
String
name
)
{
return
clientEntityRSMap
.
get
(
name
);
}
private
Map
<
String
,
List
<
ClientEntityRSModel
>>
clientEntityParentRSMap
=
new
LinkedHashMap
<>();
public
List
<
ClientEntityRSModel
>
getApiEntityParentRSes
(
String
name
)
{
return
clientEntityParentRSMap
.
get
(
name
);
}
public
String
service
;
public
ClientModel
(
IPSSubSysServiceAPI
iPSSubSysServiceAPI
)
{
this
.
opt
=
iPSSubSysServiceAPI
;
this
.
setCodeName
(
iPSSubSysServiceAPI
.
getCodeName
());
this
.
setName
(
iPSSubSysServiceAPI
.
getName
());
if
(
getPSSubSysServiceAPI
().
getAllPSSubSysServiceAPIDEs
()
!=
null
)
{
getPSSubSysServiceAPI
().
getAllPSSubSysServiceAPIDEs
().
forEach
(
item
->
{
clientEntityMap
.
put
(
item
.
getCodeName
(),
new
ClientEntityModel
(
this
,
item
));
});
}
service
=
getPSSubSysServiceAPI
().
getServiceCodeName
().
replace
(
"_"
,
"-"
);
if
(
getPSSubSysServiceAPI
().
getAllPSSubSysServiceAPIDERSs
()
!=
null
)
{
getPSSubSysServiceAPI
().
getAllPSSubSysServiceAPIDERSs
().
forEach
(
item
->
{
ClientEntityRSModel
clientEntityRSModel
=
new
ClientEntityRSModel
(
this
,
item
);
clientEntityRSMap
.
put
(
item
.
getName
(),
clientEntityRSModel
);
if
(!
clientEntityParentRSMap
.
containsKey
(
clientEntityRSModel
.
getMinorEntityCodeName
()))
{
clientEntityParentRSMap
.
put
(
clientEntityRSModel
.
getMinorEntityCodeName
(),
new
ArrayList
<>());
}
clientEntityParentRSMap
.
get
(
clientEntityRSModel
.
getMinorEntityCodeName
()).
add
(
clientEntityRSModel
);
});
}
}
public
Collection
<
SubEntityApiModel
>
getSubEntityApi
s
()
{
return
subEntityApi
.
values
();
public
Collection
<
ClientEntityModel
>
getClientEntitie
s
()
{
return
clientEntityMap
.
values
();
}
public
SubEntityApiModel
getSubEntityApi
(
String
codeName
)
{
return
subEntityApi
.
get
(
codeName
);
public
ClientEntityModel
getClientEntity
(
String
codeName
)
{
return
clientEntityMap
.
get
(
codeName
);
}
public
IPSSubSysServiceAPI
getPSSubSysServiceAPI
()
{
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/EntityModel.java
浏览文件 @
810f0bea
此差异已折叠。
点击以展开。
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/ModelStorage.java
浏览文件 @
810f0bea
...
...
@@ -124,6 +124,22 @@ public class ModelStorage {
});
});
});
}
else
if
(
type
.
equals
(
TemplateFileType
.
clientService
))
{
getSystemModel
().
getClient
().
forEach
(
clientService
->
{
CliOption
opt
=
newCliOption
(
TemplateFileType
.
clientService
)
.
baseData
(
clientService
,
clientService
.
getCodeName
());
rt
.
addOption
(
opt
);
});
}
else
if
(
type
.
equals
(
TemplateFileType
.
clientEntity
))
{
getSystemModel
().
getClient
().
forEach
(
client
->
{
client
.
getClientEntities
().
forEach
(
clientEntity
->
{
CliOption
opt
=
newCliOption
(
TemplateFileType
.
clientEntity
)
.
baseData
(
clientEntity
,
clientEntity
.
getCodeName
())
.
set
(
"modules"
,
clientEntity
.
getEntity
().
getModule
().
toLowerCase
())
.
set
(
"clients"
,
clientEntity
.
getClient
().
getCodeName
().
toLowerCase
());
rt
.
addOption
(
opt
);
});
});
}
else
if
(
type
.
equals
(
TemplateFileType
.
app
))
{
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/SubEntityApiModel.java
已删除
100644 → 0
浏览文件 @
3b784b35
package
cn
.
ibizlab
.
codegen
.
model
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
import
lombok.Setter
;
import
lombok.experimental.Accessors
;
import
net.ibizsys.model.service.IPSSubSysServiceAPI
;
import
net.ibizsys.model.service.IPSSubSysServiceAPIDE
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
SubEntityApiModel
extends
BaseModel
{
private
SubServiceApiModel
subServiceApi
;
public
SubEntityApiModel
(
SubServiceApiModel
subServiceApiModel
,
IPSSubSysServiceAPIDE
iPSSubSysServiceAPIDE
)
{
subServiceApi
=
subServiceApiModel
;
this
.
opt
=
iPSSubSysServiceAPIDE
;
this
.
setCodeName
(
iPSSubSysServiceAPIDE
.
getCodeName
());
this
.
setName
(
iPSSubSysServiceAPIDE
.
getName
());
}
}
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/model/SystemModel.java
浏览文件 @
810f0bea
package
cn
.
ibizlab
.
codegen
.
model
;
import
cn.ibizlab.codegen.templating.TemplateFileType
;
import
cn.ibizlab.codegen.utils.StringAdvUtils
;
import
lombok.Getter
;
import
lombok.NoArgsConstructor
;
...
...
@@ -8,24 +7,11 @@ import lombok.Setter;
import
lombok.experimental.Accessors
;
import
net.ibizsys.model.IPSSystem
;
import
net.ibizsys.model.codelist.IPSCodeList
;
import
net.ibizsys.model.database.IPSDEFDTColumn
;
import
net.ibizsys.model.dataentity.IPSDataEntity
;
import
net.ibizsys.model.dataentity.defield.IPSDEField
;
import
net.ibizsys.model.dataentity.defield.IPSLinkDEField
;
import
net.ibizsys.model.dataentity.der.IPSDER1N
;
import
net.ibizsys.model.dataentity.der.IPSDERBase
;
import
net.ibizsys.model.dataentity.ds.IPSDEDataQueryCode
;
import
net.ibizsys.model.dataentity.ds.IPSDEDataQueryCodeCond
;
import
net.ibizsys.model.dataentity.ds.IPSDEDataSetGroupParam
;
import
net.ibizsys.model.dataentity.ds.PSDEDataSetGroupParamImpl
;
import
net.ibizsys.model.pub.IPSSysSFPub
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ObjectUtils
;
import
org.springframework.util.StringUtils
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
@Getter
@Setter
...
...
@@ -66,7 +52,7 @@ public class SystemModel extends BaseModel {
else
this
.
setDeploySysId
(
system
.
getDeploySysId
());
getEntitiesMap
();
get
SubServiceApi
Map
();
get
Client
Map
();
}
public
IPSSystem
getSystem
()
{
...
...
@@ -258,38 +244,38 @@ public class SystemModel extends BaseModel {
return
getApisMap
().
values
();
}
private
Map
<
String
,
SubServiceApiModel
>
subServiceApi
Map
;
private
Map
<
String
,
ClientModel
>
client
Map
;
private
Map
<
String
,
List
<
SubServiceApiModel
>>
subServiceApiModule
s
;
private
Map
<
String
,
List
<
ClientModel
>>
moduleClient
s
;
public
synchronized
Map
<
String
,
SubServiceApiModel
>
getSubServiceApi
Map
()
{
if
(
subServiceApi
Map
==
null
)
{
subServiceApi
Map
=
new
LinkedHashMap
<>();
public
synchronized
Map
<
String
,
ClientModel
>
getClient
Map
()
{
if
(
client
Map
==
null
)
{
client
Map
=
new
LinkedHashMap
<>();
if
(
getSystem
().
getAllPSSubSysServiceAPIs
()!=
null
)
{
getSystem
().
getAllPSSubSysServiceAPIs
().
forEach
(
subSysServiceAPI
->
{
SubServiceApiModel
subapi
=
new
SubServiceApi
Model
(
subSysServiceAPI
).
setSystem
(
this
);
subServiceApi
Map
.
put
(
subSysServiceAPI
.
getCodeName
(),
subapi
);
ClientModel
subapi
=
new
Client
Model
(
subSysServiceAPI
).
setSystem
(
this
);
client
Map
.
put
(
subSysServiceAPI
.
getCodeName
(),
subapi
);
String
module
=
subapi
.
getModule
();
if
(!
StringUtils
.
isEmpty
(
module
))
{
if
(
subServiceApiModules
==
null
)
subServiceApiModules
=
new
LinkedHashMap
<>();
if
(!
subServiceApiModule
s
.
containsKey
(
module
))
subServiceApiModule
s
.
put
(
module
,
new
ArrayList
<>());
subServiceApiModule
s
.
get
(
module
).
add
(
subapi
);
if
(
moduleClients
==
null
)
moduleClients
=
new
LinkedHashMap
<>();
if
(!
moduleClient
s
.
containsKey
(
module
))
moduleClient
s
.
put
(
module
,
new
ArrayList
<>());
moduleClient
s
.
get
(
module
).
add
(
subapi
);
}
});
}
}
return
subServiceApi
Map
;
return
client
Map
;
}
public
Collection
<
SubServiceApiModel
>
getSubServiceApi
()
{
return
get
SubServiceApi
Map
().
values
();
public
Collection
<
ClientModel
>
getClient
()
{
return
get
Client
Map
().
values
();
}
...
...
modules/ibizlab-generator-core/src/main/java/cn/ibizlab/codegen/templating/TemplateFileType.java
浏览文件 @
810f0bea
...
...
@@ -11,8 +11,8 @@ public enum TemplateFileType {
module
(
Constants
.
MODULES
),
workflow
(
Constants
.
WORKFLOWS
),
sysUtil
(
Constants
.
SYSUTILS
),
subService
(
Constants
.
SUB_SERVICEAPI
S
),
subEntity
(
Constants
.
SUB
_ENTITIES
),
clientService
(
Constants
.
CLIENT
S
),
clientEntity
(
Constants
.
CLIENT
_ENTITIES
),
api
(
Constants
.
APIS
),
app
(
Constants
.
APPS
),
dict
(
Constants
.
DICTS
),
...
...
@@ -56,8 +56,8 @@ public enum TemplateFileType {
public
static
final
String
ENTITIES
=
"entities"
;
public
static
final
String
WORKFLOWS
=
"workflows"
;
public
static
final
String
SYSUTILS
=
"syUtils"
;
public
static
final
String
SUB_SERVICEAPIS
=
"subServiceApi
s"
;
public
static
final
String
SUB_ENTITIES
=
"sub
Entities"
;
public
static
final
String
CLIENTS
=
"client
s"
;
public
static
final
String
CLIENT_ENTITIES
=
"client
Entities"
;
public
static
final
String
API_ENTITIES
=
"apiEntities"
;
public
static
final
String
API_DTOS
=
"apiDtos"
;
public
static
final
String
APP_ENTITIES
=
"appEntities"
;
...
...
modules/ibizlab-template/ibizlab-template-ibizedge/src/main/resources/templ/{{projectName}}-core/src/main/java/{{packageName}}/core/{{modules}}/client/{{clientEntities}}FeignClient.java.hbs
0 → 100644
浏览文件 @
810f0bea
package
{{
packageName
}}
.core.
{{
clientEntity
.
entity
.
module
}}
.client;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.Map;
import java.util.HashSet;
import java.util.HashMap;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.math.BigInteger;
import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.util.security.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.Assert;
import org.springframework.beans.factory.annotation.Value;
import cn.ibizlab.util.errors.BadRequestAlertException;
{{#
system
.
enableGlobalTransaction
}}
import io.seata.spring.annotation.GlobalTransactional;
{{/
system
.
enableGlobalTransaction
}}
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Lazy;
import
{{
packageName
}}
.core.
{{
clientEntity
.
entity
.
module
}}
.domain.
{{
clientEntity
.
entity
.
codeName
}}
;
import
{{
packageName
}}
.core.
{{
clientEntity
.
entity
.
module
}}
.filter.
{{
clientEntity
.
entity
.
codeName
}}
SearchContext;
import
{{
packageName
}}
.core.
{{
clientEntity
.
entity
.
module
}}
.service.
{{
clientEntity
.
entity
.
codeName
}}
Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@FeignClient(value = "${ibiz.ref.service.
{{
lowerCase
clientEntity
.
client
.
codeName
}}
:
{{
lowerCase
clientEntity
.
client
.
service
}}
}", contextId = "
{{
lowerCase
clientEntity
.
codeName
}}
")
public interface
{{
clientEntity
.
codeName
}}
FeignClient {
{{#
each
clientEntity
.
methods
}}
{{#
neq
name
"Select"
}}
@RequestMapping(method = RequestMethod.
{{
requestMethod
}}
, value = "
{{
requestPath2
}}
")
{{#
neq
codeName
"CheckKey"
}}{{
outParam
}}{{/
neq
}}{{#
eq
codeName
"CheckKey"
}}
Integer
{{/
eq
}}
{{
camelCase
codeName
}}{{#
each
pathVariables
}}{{#if
@first
}}
By
{{else}}
And
{{/if}}{{
pascalCase
name
}}{{/
each
}}
(
{{#
each
pathVariables
}}{{#
unless
@first
}}
,
{{/
unless
}}
@PathVariable("
{{
camelCase
name
}}
")
{{
type
.
java
}}
{{
camelCase
name
}}{{/
each
}}{{#if
body
}}{{#if
pathVariables
}}
,
{{/if}}{{#
neq
requestMethod
'GET'
}}
@Validated @RequestBody
{{/
neq
}}{{
body
}}{{/if}}
) ;
{{/
neq
}}
{{/
each
}}
@RequestMapping(method = RequestMethod.POST, value = "
{{
pluralize
clientEntity
.
codeName
}}
/batch")
Boolean createBatch(@RequestBody List
<
{{
clientEntity
.
entity
.
codeName
}}
>
domains);
@RequestMapping(method = RequestMethod.PUT, value = "
{{
pluralize
clientEntity
.
codeName
}}
/batch")
boolean updateBatch(@RequestBody List
<
{{
clientEntity
.
entity
.
codeName
}}
>
domains);
@RequestMapping(method = RequestMethod.POST, value = "
{{
pluralize
clientEntity
.
codeName
}}
/savebatch")
boolean saveBatch(@RequestBody List
<
{{
clientEntity
.
entity
.
codeName
}}
>
domains);
@RequestMapping(method = RequestMethod.POST, value = "
{{
pluralize
clientEntity
.
codeName
}}
/import")
Map importData(@RequestParam(value = "config") String config ,@RequestBody List
<
{{
clientEntity
.
entity
.
codeName
}}
>
domains);
@RequestMapping(method = RequestMethod.DELETE, value = {"
{{
pluralize
clientEntity
.
codeName
}}
","/
{{
pluralize
clientEntity
.
codeName
}}
/batch"})
boolean removeBatch(@RequestBody List
<
{{
clientEntity
.
entity
.
keyField
.
type
.
java
}}
>
ids);
}
\ No newline at end of file
modules/ibizlab-template/ibizlab-template-ibizedge/src/main/resources/templ/{{projectName}}-core/src/main/java/{{packageName}}/core/{{modules}}/client/{{entities@ServiceAPI}}FeignClient.java.hbs
已删除
100644 → 0
浏览文件 @
3b784b35
package
{{
packageName
}}
.core.
{{
entity
.
module
}}
.client;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.Map;
import java.util.HashSet;
import java.util.HashMap;
import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.math.BigInteger;
import lombok.extern.slf4j.Slf4j;
import cn.ibizlab.util.security.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.util.Assert;
import org.springframework.beans.factory.annotation.Value;
import cn.ibizlab.util.errors.BadRequestAlertException;
{{#
system
.
enableGlobalTransaction
}}
import io.seata.spring.annotation.GlobalTransactional;
{{/
system
.
enableGlobalTransaction
}}
import org.springframework.transaction.annotation.Transactional;
import org.springframework.context.annotation.Lazy;
import
{{
packageName
}}
.core.
{{
entity
.
module
}}
.domain.
{{
entity
.
codeName
}}
;
import
{{
packageName
}}
.core.
{{
entity
.
module
}}
.filter.
{{
entity
.
codeName
}}
SearchContext;
import
{{
packageName
}}
.core.
{{
entity
.
module
}}
.service.
{{
entity
.
codeName
}}
Service;
import cn.ibizlab.util.helper.CachedBeanCopier;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
public interface
{{
entity
.
codeName
}}
FeignClient {
default
{{
entity
.
codeName
}}
get(
{{
entity
.
codeName
}}
et){
return get(et.get
{{
pascalCase
entity
.
keyField
.
codeName
}}
());
}
@RequestMapping(method = RequestMethod.GET, value = "/
{{
pluralize
entity
.
codeName
}}
/{key}")
{{
entity
.
codeName
}}
get(
{{
entity
.
keyField
.
type
.
java
}}
key);
default List
<
{{
entity
.
codeName
}}
>
getByIds(Collection
<
{{
entity
.
keyField
.
type
.
java
}}
>
ids) {
List
<
{{
entity
.
codeName
}}
>
entities =new ArrayList();
ids.forEach(key -> {
{{
entity
.
codeName
}}
et = new
{{
entity
.
codeName
}}
();
et.set
{{
pascalCase
entity
.
keyField
.
codeName
}}
(key);
entities.add(et);
});
return getByEntities(entities);
}
List
<
{{
entity
.
codeName
}}
>
getByEntities(List
<
{{
entity
.
codeName
}}
>
entities);
{{
entity
.
codeName
}}
getDraft(
{{
entity
.
codeName
}}
et);
Integer checkKey(
{{
entity
.
codeName
}}
et);
boolean create(
{{
entity
.
codeName
}}
et);
{{#
entity
.
enableEntityCache
}}
@CacheEvict(value = "
{{
lowerCase
entity
.
codeName
}}
", allEntries = true)
{{/
entity
.
enableEntityCache
}}
boolean createBatch(List
<
{{
entity
.
codeName
}}
>
list);
boolean update(
{{
entity
.
codeName
}}
et);
{{#
entity
.
enableEntityCache
}}
@CacheEvict(value = "
{{
lowerCase
entity
.
codeName
}}
", allEntries = true)
{{/
entity
.
enableEntityCache
}}
boolean updateBatch(List
<
{{
entity
.
codeName
}}
>
list);
boolean save(
{{
entity
.
codeName
}}
et);
{{#
entity
.
enableEntityCache
}}
@CacheEvict(value = "
{{
lowerCase
entity
.
codeName
}}
", allEntries = true)
{{/
entity
.
enableEntityCache
}}
boolean saveBatch(List
<
{{
entity
.
codeName
}}
>
list);
default boolean remove(
{{
entity
.
keyField
.
type
.
java
}}
key) {
{{
entity
.
codeName
}}
et = new
{{
entity
.
codeName
}}
();
et.set
{{
pascalCase
entity
.
keyField
.
codeName
}}
(key);
return remove(et);
}
default boolean remove(List
<
{{
entity
.
keyField
.
type
.
java
}}
>
key) {
return removeBatch(key);
}
boolean remove(
{{
entity
.
codeName
}}
et);
{{#
entity
.
enableEntityCache
}}
@CacheEvict(value = "
{{
lowerCase
entity
.
codeName
}}
", allEntries = true)
{{/
entity
.
enableEntityCache
}}
boolean removeBatch(Collection
<
{{
entity
.
keyField
.
type
.
java
}}
>
ids);
{{#
each
entity
.
extActions
}}
default
{{
outParam
}}
{{
camelCase
codeName
}}
(
{{
inParam
}}
{{
inParamName
}}
) {
{{#if
voidReturn
}}
return
{{
inParamName
}}
;
{{else}}
return null;
{{/if}}
}
{{/
each
}}
{{#
entity
.
dataSets
}}
Page
<
{{
entity
.
codeName
}}
>
search
{{
pascalCase
codeName
}}
(
{{
entity
.
codeName
}}
SearchContext context);
List
<
{{
entity
.
codeName
}}
>
list
{{
pascalCase
codeName
}}
(
{{
entity
.
codeName
}}
SearchContext context);
{{/
entity
.
dataSets
}}
{{#
entity
.
references
}}
List
<
{{
entity
.
codeName
}}
>
selectBy
{{
pascalCase
fkField
.
codeName
}}
(
{{
fkField
.
type
.
java
}}
{{
camelCase
fkField
.
codeName
}}
);
{{#
entity
.
enableEntityCache
}}
@CacheEvict(value = "
{{
lowerCase
entity
.
codeName
}}
", allEntries = true)
{{/
entity
.
enableEntityCache
}}
boolean removeBy
{{
pascalCase
fkField
.
codeName
}}
(
{{
fkField
.
type
.
java
}}
{{
camelCase
fkField
.
codeName
}}
);
{{#
entity
.
enableEntityCache
}}
@CacheEvict(value = "
{{
lowerCase
entity
.
codeName
}}
", allEntries = true)
{{/
entity
.
enableEntityCache
}}
boolean resetBy
{{
pascalCase
fkField
.
codeName
}}
(
{{
fkField
.
type
.
java
}}
{{
camelCase
fkField
.
codeName
}}
);
{{#
entity
.
enableEntityCache
}}
@CacheEvict(value = "
{{
lowerCase
entity
.
codeName
}}
", allEntries = true)
{{/
entity
.
enableEntityCache
}}
boolean saveBy
{{
pascalCase
fkField
.
codeName
}}
(
{{
fkField
.
type
.
java
}}
{{
camelCase
fkField
.
codeName
}}
,List
<
{{
entity
.
codeName
}}
>
list);
{{/
entity
.
references
}}
}
\ No newline at end of file
modules/ibizlab-template/ibizlab-template-ibizedge/src/main/resources/templ/{{projectName}}-core/src/main/java/{{packageName}}/core/{{modules}}/service/impl/{{entities@ServiceAPI}}ServiceBase.java.hbs
浏览文件 @
810f0bea
...
...
@@ -11,8 +11,13 @@ import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.math.BigInteger;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.stream.Collectors
;
import lombok.extern.slf4j.Slf4j;
{{#if
entity
.
clientEntityModel
}}
import
{{
packageName
}}
.core.
{{
entity
.
module
}}
.client.
{{
entity
.
clientEntityModel
.
codeName
}}
FeignClient;
{{/if}}
import org.springframework.beans.BeanUtils;
import cn.ibizlab.util.security.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
...
...
@@ -49,115 +54,73 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
@Service("
{{
entity
.
codeName
}}
Service")
public class
{{
entity
.
codeName
}}
ServiceBase implements
{{
entity
.
codeName
}}
Service {
{{#
entity
.
relEntities
}}
{{#
neq
storage
"NONE"
}}
{{#if
entity
.
clientEntityModel
}}
@Autowired
@Lazy
protected
{{
packageName
}}
.core.
{{
module
}}
.service.
{{
codeName
}}
Service
{{
camelCase
codeName
}}
Service;
{{/
neq
}}
{{/
entity
.
relEntities
}}
{{#if
entity
.
indexSubDE
}}
@Autowired
@Lazy
protected
{{
packageName
}}
.core.
{{
entity
.
module
}}
.mapping.
{{
entity
.
codeName
}}
InheritMapping
{{
camelCase
entity
.
codeName
}}
InheritMapping;
{{
entity
.
clientEntityModel
.
codeName
}}
FeignClient
{{
camelCase
entity
.
clientEntityModel
.
codeName
}}
FeignClient;
{{/if}}
protected int batchSize = 500;
public
{{
entity
.
codeName
}}
get(
{{
entity
.
codeName
}}
et) {
return et;
return
{{
camelCase
entity
.
clientEntityModel
.
codeName
}}
FeignClient.getBy
{{
pascalCase
entity
.
keyField
.
codeName
}}
(et.get
{{
pascalCase
entity
.
keyField
.
codeName
}}
());
}
public List
<
{{
entity
.
codeName
}}
>
getByEntities(List
<
{{
entity
.
codeName
}}
>
entities) {
return null;
}
{{#
entity
.
hasReferences
}}
public void fillParentData(
{{
entity
.
codeName
}}
et) {
}
{{/
entity
.
hasReferences
}}
public
{{
entity
.
codeName
}}
getDraft(
{{
entity
.
codeName
}}
et) {
{{#
entity
.
hasReferences
}}
fillParentData(et);
{{/
entity
.
hasReferences
}}
return et;
return
{{
camelCase
entity
.
clientEntityModel
.
codeName
}}
FeignClient.getDraft(et);
}
public Integer checkKey(
{{
entity
.
codeName
}}
et) {
return
null
;
return
{{
camelCase
entity
.
clientEntityModel
.
codeName
}}
FeignClient.checkKey(et)
;
}
@Override
{{#
eq
entity
.
actions
.
create
.
transactionMode
"GLOBAL"
}}
@GlobalTransactional
{{/
eq
}}{{#
eq
entity
.
actions
.
create
.
transactionMode
"DEFAULT"
}}
@Transactional
{{/
eq
}}
public boolean create(
{{
entity
.
codeName
}}
et) {
{{
entity
.
codeName
}}
rt =
{{
camelCase
entity
.
clientEntityModel
.
codeName
}}
FeignClient.create(et);
BeanUtils.copyProperties(rt, et);
return true;
}
{{#
eq
entity
.
actions
.
create
.
transactionMode
"GLOBAL"
}}
@GlobalTransactional
{{/
eq
}}{{#
eq
entity
.
actions
.
create
.
transactionMode
"DEFAULT"
}}
@Transactional
{{/
eq
}}
public boolean createBatch(List
<
{{
entity
.
codeName
}}
>
list) {
return
true
;
return
{{
camelCase
entity
.
clientEntityModel
.
codeName
}}
FeignClient.createBatch(list)
;
}
{{#
eq
entity
.
actions
.
update
.
transactionMode
"GLOBAL"
}}
@GlobalTransactional
{{/
eq
}}{{#
eq
entity
.
actions
.
update
.
transactionMode
"DEFAULT"
}}
@Transactional
{{/
eq
}}
public boolean update(
{{
entity
.
codeName
}}
et) {
{{#
entity
.
hasReferences
}}
fillParentData(et);
{{/
entity
.
hasReferences
}}
{{
entity
.
codeName
}}
rt =
{{
camelCase
entity
.
clientEntityModel
.
codeName
}}
FeignClient.updateBy
{{
pascalCase
entity
.
keyField
.
codeName
}}
(et.get
{{
pascalCase
entity
.
keyField
.
codeName
}}
(), et);
BeanUtils.copyProperties(rt, et);
return true;
}
{{#
eq
entity
.
actions
.
update
.
transactionMode
"GLOBAL"
}}
@GlobalTransactional
{{/
eq
}}{{#
eq
entity
.
actions
.
update
.
transactionMode
"DEFAULT"
}}
@Transactional
{{/
eq
}}
public boolean updateBatch(List
<
{{
entity
.
codeName
}}
>
list) {
return
true
;
return
{{
camelCase
entity
.
clientEntityModel
.
codeName
}}
FeignClient.updateBatch(list)
;
}
{{#
eq
entity
.
actions
.
save
.
transactionMode
"GLOBAL"
}}
@GlobalTransactional
{{/
eq
}}{{#
eq
entity
.
actions
.
save
.
transactionMode
"DEFAULT"
}}
@Transactional
{{/
eq
}}
public boolean save(
{{
entity
.
codeName
}}
et) {
if(checkKey(et)==0)
return getSelf().update(et);
else
return getSelf().create(et);
{{
entity
.
codeName
}}
rt =
{{
camelCase
entity
.
clientEntityModel
.
codeName
}}
FeignClient.save(et);
BeanUtils.copyProperties(rt, et);
return true;
}
{{#
eq
entity
.
actions
.
save
.
transactionMode
"GLOBAL"
}}
@GlobalTransactional
{{/
eq
}}{{#
eq
entity
.
actions
.
save
.
transactionMode
"DEFAULT"
}}
@Transactional
{{/
eq
}}
public boolean saveBatch(List
<
{{
entity
.
codeName
}}
>
list) {
List
<
{{
entity
.
codeName
}}
>
rt=this.getByEntities(list);
Set
<Serializable>
keys=new HashSet
<>
();
rt.forEach(et->{
Serializable key = et.get
{{
pascalCase
entity
.
keyField
.
codeName
}}
();
if(!ObjectUtils.isEmpty(key))
keys.add(key);
});
List
<
{{
entity
.
codeName
}}
>
_create=new ArrayList
<>
();
List
<
{{
entity
.
codeName
}}
>
_update=new ArrayList
<>
();
list.forEach(et-> {
Serializable key = et.get
{{
pascalCase
entity
.
keyField
.
codeName
}}
();
if(keys.contains(key))
_update.add(et);
else
_create.add(et);
});
List rtList=new ArrayList
<>
();
if(_update.size()>0
&&
(!getSelf().updateBatch(_update)))
return false;
if(_create.size()>0
&&
(!getSelf().createBatch(_create)))
return false;
return true;
return
{{
camelCase
entity
.
clientEntityModel
.
codeName
}}
FeignClient.saveBatch(list);
}
{{#
eq
entity
.
actions
.
remove
.
transactionMode
"GLOBAL"
}}
@GlobalTransactional
{{/
eq
}}{{#
eq
entity
.
actions
.
remove
.
transactionMode
"DEFAULT"
}}
@Transactional
{{/
eq
}}
public boolean remove(
{{
entity
.
codeName
}}
et) {
return false ;
return
{{
camelCase
entity
.
clientEntityModel
.
codeName
}}
FeignClient.removeBy
{{
pascalCase
entity
.
keyField
.
codeName
}}
(et.get
{{
pascalCase
entity
.
keyField
.
codeName
}}
());
}
{{#
eq
entity
.
actions
.
remove
.
transactionMode
"GLOBAL"
}}
@GlobalTransactional
{{/
eq
}}{{#
eq
entity
.
actions
.
remove
.
transactionMode
"DEFAULT"
}}
@Transactional
{{/
eq
}}
public boolean removeByEntities(List
<
{{
entity
.
codeName
}}
>
entities) {
return false;
return
{{
camelCase
entity
.
clientEntityModel
.
codeName
}}
FeignClient.removeBatch(entities.stream().map(e->e.get
{{
pascalCase
entity
.
keyField
.
codeName
}}
()).collect(Collectors.toList()));
}
{{#
entity
.
extActions
}}
...
...
@@ -173,7 +136,7 @@ public class {{entity.codeName}}ServiceBase implements {{entity.codeName}}Servic
{{/
entity
.
extActions
}}
{{#
entity
.
dataSets
}}
public Page
<
{{
entity
.
codeName
}}
>
search
{{
pascalCase
codeName
}}
(
{{
entity
.
codeName
}}
SearchContext context) {
return
null
;
return
{{
camelCase
entity
.
clientEntityModel
.
codeName
}}
FeignClient.fetch
{{
pascalCase
codeName
}}
(context)
;
}
public List
<
{{
entity
.
codeName
}}
>
list
{{
pascalCase
codeName
}}
(
{{
entity
.
codeName
}}
SearchContext context) {
return null;
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录