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
package
cn
.
ibizlab
.
codegen
.
model
;
import
cn.ibizlab.codegen.utils.Inflector
;
import
cn.ibizlab.codegen.utils.StringAdvUtils
;
import
com.alibaba.fastjson.JSONObject
;
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.IPSDEServiceAPIMethod
;
import
net.ibizsys.model.dataentity.service.IPSDEServiceAPIMethodInput
;
import
net.ibizsys.model.service.IPSSubSysServiceAPIDEMethod
;
import
net.ibizsys.model.service.IPSSubSysServiceAPIDTO
;
import
net.ibizsys.model.service.IPSSubSysServiceAPIMethodInput
;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Getter
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
ClientMethodModel
extends
BaseModel
{
private
static
String
[]
ignoreMethodNames
=
new
String
[]{
"GET"
,
"CREATE"
,
"UPDATE"
,
"REMOVE"
};
private
static
String
[]
booleanMethodNames
=
new
String
[]{
"CREATE"
,
"UPDATE"
,
"SAVE"
,
"CREATEBATCH"
,
"UPDATEBATCH"
,
"REMOVEBATCH"
,
"SAVEBATCH"
};
private
static
Map
<
String
,
String
>
lang
=
new
HashMap
<
String
,
String
>()
{{
put
(
"GET"
,
"获取"
);
put
(
"CREATE"
,
"创建"
);
put
(
"UPDATE"
,
"更新"
);
put
(
"SAVE"
,
"保存"
);
put
(
"REMOVE"
,
"删除"
);
put
(
"GETDRAFT"
,
"草稿"
);
put
(
"CHECKKEY"
,
"校验"
);
}};
private
ClientModel
client
;
private
ClientEntityModel
clientEntity
;
private
List
<
ClientEntityRSModel
>
parentClientEntities
;
public
String
getTags
()
{
return
clientEntity
.
getApiName
();
}
private
String
notes
;
private
String
clientName
;
public
String
getClientName
()
{
if
(
lang
.
containsKey
(
clientName
.
toUpperCase
()))
return
lang
.
get
(
clientName
.
toUpperCase
())
+
clientName
;
else
if
(
clientName
.
toUpperCase
().
startsWith
(
"FETCH"
))
return
"查询"
+
clientName
;
return
clientName
;
}
public
ClientMethodModel
(
ClientEntityModel
clientEntityModel
,
List
<
ClientEntityRSModel
>
parentClientEntities
,
IPSSubSysServiceAPIDEMethod
iPSSubSysServiceAPIDEMethod
)
{
this
.
opt
=
iPSSubSysServiceAPIDEMethod
;
this
.
clientEntity
=
clientEntityModel
;
this
.
client
=
clientEntityModel
.
getClient
();
this
.
parentClientEntities
=
parentClientEntities
;
this
.
setCodeName
(
iPSSubSysServiceAPIDEMethod
.
getCodeName
());
this
.
setName
(
iPSSubSysServiceAPIDEMethod
.
getName
());
this
.
clientName
=
ObjectUtils
.
isEmpty
(
iPSSubSysServiceAPIDEMethod
.
getLogicName
())
?
iPSSubSysServiceAPIDEMethod
.
getName
()
:
iPSSubSysServiceAPIDEMethod
.
getLogicName
();
this
.
notes
=
clientEntityModel
.
getCodeName
()
+
"-"
+
name
;
}
public
IPSSubSysServiceAPIDEMethod
getPSSubSysServiceAPIDEMethod
()
{
return
(
IPSSubSysServiceAPIDEMethod
)
opt
;
}
public
String
getMethodName
()
{
String
strName
=
super
.
getName
();
if
(!
CollectionUtils
.
isEmpty
(
parentClientEntities
))
{
strName
+=
"By"
;
for
(
ClientEntityRSModel
parent
:
parentClientEntities
)
{
strName
+=
StringAdvUtils
.
pascalcase
(
parent
.
getParentIdFieldCodeName
());
}
}
return
strName
;
}
private
String
requestPath
;
public
String
getRequestPath
()
{
if
(
requestPath
==
null
)
{
String
path
=
""
;
if
(!
CollectionUtils
.
isEmpty
(
parentClientEntities
))
{
for
(
ClientEntityRSModel
apiRs
:
parentClientEntities
)
{
String
strMajorEntityPlurlize
=
Inflector
.
getInstance
().
pluralize
(
StringAdvUtils
.
camelcase
(
apiRs
.
getMajorEntityCodeName
()).
toLowerCase
());
path
=
String
.
format
(
"/%s/{%s}"
,
strMajorEntityPlurlize
,
StringAdvUtils
.
camelcase
(
apiRs
.
getParentIdFieldCodeName
()))
+
path
;
}
}
//主键
String
strPlurlize
=
Inflector
.
getInstance
().
pluralize
(
StringAdvUtils
.
camelcase
(
clientEntity
.
getCodeName
()).
toLowerCase
());
if
(
getPSSubSysServiceAPIDEMethod
().
isNeedResourceKey
()
&&
(!
"save"
.
equalsIgnoreCase
(
name
)))
{
path
=
path
+
String
.
format
(
"/%s/{%s}"
,
strPlurlize
,
StringAdvUtils
.
camelcase
(
clientEntity
.
getEntity
().
getKeyField
().
getCodeName
()));
}
else
{
path
=
path
+
String
.
format
(
"/%s"
,
strPlurlize
);
}
//方法名
if
(!
ArrayUtils
.
contains
(
ignoreMethodNames
,
this
.
getName
().
toUpperCase
()))
{
path
=
path
+
String
.
format
(
"/%s"
,
this
.
getCodeName
().
toLowerCase
());
}
requestPath
=
path
;
}
return
requestPath
;
}
public
String
getRequestPath2
()
{
if
(!
ObjectUtils
.
isEmpty
(
this
.
getRequestPath
()))
return
requestPath
.
substring
(
1
);
return
""
;
}
private
List
pathVariables
;
public
List
getPathVariables
()
{
if
(
pathVariables
==
null
)
{
pathVariables
=
new
ArrayList
();
if
(!
CollectionUtils
.
isEmpty
(
parentClientEntities
))
{
for
(
ClientEntityRSModel
apiRs
:
parentClientEntities
)
{
String
strMajorEntityPlurlize
=
Inflector
.
getInstance
().
pluralize
(
StringAdvUtils
.
camelcase
(
apiRs
.
getMajorEntityCodeName
()).
toLowerCase
());
JSONObject
pathVariable
=
new
JSONObject
();
pathVariable
.
put
(
"name"
,
apiRs
.
getParentIdFieldCodeName
());
pathVariable
.
put
(
"type"
,
PropType
.
findType
(
apiRs
.
getParentIdFieldType
()));
pathVariables
.
add
(
0
,
pathVariable
);
}
}
if
(
getPSSubSysServiceAPIDEMethod
().
isNeedResourceKey
()
&&
(!
"save"
.
equalsIgnoreCase
(
name
)))
{
JSONObject
pathVariable
=
new
JSONObject
();
pathVariable
.
put
(
"name"
,
clientEntity
.
getEntity
().
getKeyField
().
getCodeName
());
pathVariable
.
put
(
"type"
,
clientEntity
.
getEntity
().
getKeyField
().
getType
());
pathVariables
.
add
(
pathVariable
);
}
}
return
pathVariables
;
}
public
String
getBody
()
{
if
(!
ObjectUtils
.
isEmpty
(
getInParam
()))
{
return
getInParam
()
+
" "
+
getInParamName
();
}
return
null
;
}
public
IPSSubSysServiceAPIDTO
getInputDTO
()
{
return
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodInput
().
getPSSubSysServiceAPIDTO
();
}
public
IPSSubSysServiceAPIDTO
getReturnDTO
()
{
if
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
()
==
null
||
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getPSSubSysServiceAPIDTO
()
==
null
)
return
getInputDTO
();
return
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getPSSubSysServiceAPIDTO
();
}
private
String
inParam
;
private
String
inParam2
;
public
String
getInParam
()
{
if
(
inParam
==
null
)
{
String
param
=
this
.
getClientEntity
().
getCodeName
();
IPSSubSysServiceAPIMethodInput
iPSSubSysServiceAPIMethodInput
=
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodInput
();
if
(
iPSSubSysServiceAPIMethodInput
!=
null
&&
iPSSubSysServiceAPIMethodInput
.
getPSSubSysServiceAPIDTO
()
!=
null
)
param
=
iPSSubSysServiceAPIMethodInput
.
getPSSubSysServiceAPIDTO
().
getName
().
replace
(
"FilterDTO"
,
"SearchContext"
);
if
(
"KEYFIELD"
.
equalsIgnoreCase
(
iPSSubSysServiceAPIMethodInput
.
getType
())
||
this
.
getName
().
equalsIgnoreCase
(
"Remove"
))
{
param
=
""
;
inParam2
=
clientEntity
.
getEntity
().
getKeyField
().
getType
().
java
;
inParamName
=
StringAdvUtils
.
camelcase
(
clientEntity
.
getEntity
().
getKeyField
().
getCodeName
());
inParamName2
=
StringAdvUtils
.
camelcase
(
clientEntity
.
getEntity
().
getKeyField
().
getCodeName
());
}
else
if
(
"KEYFIELDS"
.
equalsIgnoreCase
(
iPSSubSysServiceAPIMethodInput
.
getType
()))
{
param
=
"List<"
+
clientEntity
.
getEntity
().
getKeyField
().
getType
().
java
+
">"
;
inParam2
=
param
;
inParamName
=
"list"
;
inParamName2
=
"list"
;
}
else
if
(
"DTO"
.
equalsIgnoreCase
(
iPSSubSysServiceAPIMethodInput
.
getType
()))
{
inParam2
=
clientEntity
.
getEntity
().
getCodeName
();
inParamName
=
"dto"
;
inParamName2
=
"domain"
;
}
else
if
(
"DTOS"
.
equalsIgnoreCase
(
iPSSubSysServiceAPIMethodInput
.
getType
()))
{
param
=
"List<"
+
param
+
">"
;
inParam2
=
"List<"
+
clientEntity
.
getEntity
().
getCodeName
()
+
">"
;
inParamName
=
"dtos"
;
inParamName2
=
"domains"
;
}
inParam
=
param
;
inParam
=
inParam
.
replace
(
"DTO"
,
""
);
}
return
inParam
;
}
public
boolean
isNeedDto2Domain
()
{
if
(
"FETCH"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getMethodType
()))
return
false
;
IPSSubSysServiceAPIMethodInput
iPSSubSysServiceAPIMethodInput
=
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodInput
();
if
(
iPSSubSysServiceAPIMethodInput
==
null
)
return
false
;
return
"DTOS"
.
equalsIgnoreCase
(
iPSSubSysServiceAPIMethodInput
.
getType
())
||
"DTO"
.
equalsIgnoreCase
(
iPSSubSysServiceAPIMethodInput
.
getType
());
}
public
boolean
isListIn
()
{
IPSSubSysServiceAPIMethodInput
iPSSubSysServiceAPIMethodInput
=
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodInput
();
if
(
iPSSubSysServiceAPIMethodInput
==
null
)
return
false
;
return
"KEYFIELDS"
.
equalsIgnoreCase
(
iPSSubSysServiceAPIMethodInput
.
getType
())
||
"DTOS"
.
equalsIgnoreCase
(
iPSSubSysServiceAPIMethodInput
.
getType
());
}
private
String
inParamName
;
private
String
inParamName2
;
public
boolean
isListReturn
()
{
if
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
()
==
null
)
return
false
;
if
(
"DTOS"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getType
())
||
"OBJECTS"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getType
())
||
"SIMPLES"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getType
()))
return
true
;
return
false
;
}
public
String
typeReturn
()
{
if
(
isListReturn
())
{
if
(
"SIMPLES"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getType
()))
return
PropType
.
findType
(
this
.
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getStdDataType
()).
java
;
else
if
(
"DTOS"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getType
())
||
"OBJECTS"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getType
()))
return
this
.
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getName
();
}
return
""
;
}
public
boolean
isBooleanReturn
()
{
return
ArrayUtils
.
contains
(
booleanMethodNames
,
this
.
getName
().
toUpperCase
());
}
private
boolean
needDomain2Dto
=
true
;
private
String
outParam
;
private
String
outParam2
;
public
String
getOutParam
()
{
if
(
outParam
==
null
)
{
String
param
=
this
.
getClientEntity
().
getCodeName
();
if
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
()
!=
null
&&
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getPSSubSysServiceAPIDTO
()
!=
null
)
param
=
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getPSSubSysServiceAPIDTO
().
getName
();
if
(
"Remove"
.
equalsIgnoreCase
(
getName
()))
{
needDomain2Dto
=
false
;
param
=
"Boolean"
;
outParam2
=
"Boolean"
;
}
else
if
(
"VOID"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getType
()))
{
needDomain2Dto
=
isNeedDto2Domain
();
param
=
getInParam
();
outParam2
=
getInParam2
();
}
else
if
(
"SIMPLE"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getType
()))
{
needDomain2Dto
=
false
;
param
=
PropType
.
findType
(
this
.
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getStdDataType
()).
java
;
outParam2
=
param
;
}
else
if
(
"SIMPLES"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getType
()))
{
needDomain2Dto
=
false
;
param
=
"List<"
+
PropType
.
findType
(
this
.
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getStdDataType
()).
java
+
">"
;
outParam2
=
param
;
}
else
if
(
"DTO"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getType
()))
{
needDomain2Dto
=
false
;
outParam2
=
clientEntity
.
getEntity
().
getCodeName
();
}
else
if
(
"DTOS"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getType
())
||
"OBJECTS"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getPSSubSysServiceAPIMethodReturn
().
getType
()))
{
needDomain2Dto
=
false
;
param
=
"List<"
+
param
+
">"
;
outParam2
=
"List<"
+
clientEntity
.
getEntity
().
getCodeName
()
+
">"
;
}
if
(
"FETCH"
.
equalsIgnoreCase
(
getPSSubSysServiceAPIDEMethod
().
getMethodType
()))
{
needDomain2Dto
=
false
;
outParam
=
"Page<"
+
param
+
">"
;
}
else
outParam
=
param
;
//
outParam
=
outParam
.
replace
(
"DTO"
,
""
);
}
return
outParam
;
}
}
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
...
...
@@ -25,60 +25,56 @@ import java.util.stream.Collectors;
@Setter
@NoArgsConstructor
@Accessors
(
chain
=
true
)
public
class
EntityModel
extends
BaseModel
{
public
class
EntityModel
extends
BaseModel
{
private
SystemModel
system
;
public
String
getEntityName
()
{
return
getDataEntity
().
getName
();
}
public
String
getTableName
()
{
return
StringUtils
.
isEmpty
(
getDataEntity
().
getTableName
())
?
getDataEntity
().
getName
():
getDataEntity
().
getTableName
();
return
StringUtils
.
isEmpty
(
getDataEntity
().
getTableName
())
?
getDataEntity
().
getName
()
:
getDataEntity
().
getTableName
();
}
public
String
getLogicName
()
{
return
getDataEntity
().
getLogicName
();
}
public
String
getModule
()
{
if
(
getDataEntity
().
getPSSystemModule
()!=
null
)
if
(
getDataEntity
().
getPSSystemModule
()
!=
null
)
return
getDataEntity
().
getPSSystemModule
().
getCodeName
().
toLowerCase
();
return
"ungroup"
;
}
public
IPSDataEntity
getDataEntity
(){
return
(
IPSDataEntity
)
opt
;
public
IPSDataEntity
getDataEntity
()
{
return
(
IPSDataEntity
)
opt
;
}
private
List
<
DataSetModel
>
queries
;
public
EntityModel
addQueries
(
DataSetModel
dataSet
)
{
if
(
queries
==
null
)
queries
=
new
ArrayList
<>();
public
EntityModel
addQueries
(
DataSetModel
dataSet
)
{
if
(
queries
==
null
)
queries
=
new
ArrayList
<>();
queries
.
add
(
dataSet
);
return
this
;
}
private
Map
<
String
,
DataSetModel
>
dataQueries
;
public
EntityModel
addDataQueries
(
DataSetModel
dataSet
)
{
if
(
dataQueries
==
null
)
dataQueries
=
new
LinkedHashMap
<>();
dataQueries
.
put
(
dataSet
.
getDatasetId
(),
dataSet
);
if
(
"View"
.
equalsIgnoreCase
(
dataSet
.
codeName
)&&
viewDataQuery
==
null
)
viewDataQuery
=
dataSet
;
if
(
getDataEntity
().
getDefaultPSDEDataSet
().
getCodeName
().
equalsIgnoreCase
(
dataSet
.
codeName
)&&
defaultDataQuery
==
null
)
defaultDataQuery
=
dataSet
;
private
Map
<
String
,
DataSetModel
>
dataQueries
;
public
EntityModel
addDataQueries
(
DataSetModel
dataSet
)
{
if
(
dataQueries
==
null
)
dataQueries
=
new
LinkedHashMap
<>();
dataQueries
.
put
(
dataSet
.
getDatasetId
(),
dataSet
);
if
(
"View"
.
equalsIgnoreCase
(
dataSet
.
codeName
)
&&
viewDataQuery
==
null
)
viewDataQuery
=
dataSet
;
if
(
getDataEntity
().
getDefaultPSDEDataSet
().
getCodeName
().
equalsIgnoreCase
(
dataSet
.
codeName
)
&&
defaultDataQuery
==
null
)
defaultDataQuery
=
dataSet
;
return
this
;
}
...
...
@@ -88,57 +84,50 @@ public class EntityModel extends BaseModel {
private
List
<
DataSetModel
>
dataSets
;
public
EntityModel
addDataSet
(
DataSetModel
dataSet
)
{
if
(
dataSets
==
null
)
dataSets
=
new
ArrayList
<>();
public
EntityModel
addDataSet
(
DataSetModel
dataSet
)
{
if
(
dataSets
==
null
)
dataSets
=
new
ArrayList
<>();
dataSets
.
add
(
dataSet
);
return
this
;
}
private
List
<
FieldModel
>
fields
;
public
EntityModel
addField
(
FieldModel
fieldModel
)
{
if
(
fields
==
null
)
fields
=
new
ArrayList
<>();
public
EntityModel
addField
(
FieldModel
fieldModel
)
{
if
(
fields
==
null
)
fields
=
new
ArrayList
<>();
fields
.
add
(
fieldModel
);
return
this
;
}
private
List
<
RelationshipModel
>
references
;
public
EntityModel
addReference
(
RelationshipModel
relationshipModel
)
{
if
(
references
==
null
)
references
=
new
ArrayList
<>();
public
EntityModel
addReference
(
RelationshipModel
relationshipModel
)
{
if
(
references
==
null
)
references
=
new
ArrayList
<>();
references
.
add
(
relationshipModel
);
return
this
;
}
public
boolean
isHasReferences
()
{
public
boolean
isHasReferences
()
{
return
!
ObjectUtils
.
isEmpty
(
references
);
}
public
boolean
hasPhisicalLinkField
=
false
;
private
Map
<
String
,
RelationshipModel
>
refMaps
;
public
Map
<
String
,
RelationshipModel
>
getRefMaps
()
{
if
(
refMaps
==
null
)
refMaps
=
new
LinkedHashMap
<>();
if
(
references
!=
null
)
{
references
.
forEach
(
ship
->{
if
(!
StringUtils
.
isEmpty
(
ship
.
getCodeName
()))
refMaps
.
put
(
ship
.
getCodeName
().
toString
(),
ship
);
String
fkname
=
DataObject
.
getStringValue
(
ship
.
getName
(),
""
);
if
(!
StringUtils
.
isEmpty
(
fkname
))
public
boolean
hasPhisicalLinkField
=
false
;
private
Map
<
String
,
RelationshipModel
>
refMaps
;
public
Map
<
String
,
RelationshipModel
>
getRefMaps
()
{
if
(
refMaps
==
null
)
refMaps
=
new
LinkedHashMap
<>();
if
(
references
!=
null
)
{
references
.
forEach
(
ship
->
{
if
(!
StringUtils
.
isEmpty
(
ship
.
getCodeName
()))
refMaps
.
put
(
ship
.
getCodeName
().
toString
(),
ship
);
String
fkname
=
DataObject
.
getStringValue
(
ship
.
getName
(),
""
);
if
(!
StringUtils
.
isEmpty
(
fkname
))
refMaps
.
put
(
fkname
,
ship
);
});
}
...
...
@@ -147,76 +136,67 @@ public class EntityModel extends BaseModel {
private
List
<
RelationshipModel
>
nesteds
;
public
EntityModel
addNested
(
RelationshipModel
relationshipModel
)
{
if
(
nesteds
==
null
)
nesteds
=
new
ArrayList
<>();
public
EntityModel
addNested
(
RelationshipModel
relationshipModel
)
{
if
(
nesteds
==
null
)
nesteds
=
new
ArrayList
<>();
nesteds
.
add
(
relationshipModel
);
return
this
;
}
private
Map
<
String
,
EntityModel
>
relEntitiesMap
;
private
Map
<
String
,
EntityModel
>
relEntitiesMap
;
public
EntityModel
addRelEntity
(
String
codeName
,
EntityModel
entityModel
)
{
if
(
entityModel
==
null
||
StringUtils
.
isEmpty
(
codeName
)||
codeName
.
equalsIgnoreCase
(
this
.
codeName
))
public
EntityModel
addRelEntity
(
String
codeName
,
EntityModel
entityModel
)
{
if
(
entityModel
==
null
||
StringUtils
.
isEmpty
(
codeName
)
||
codeName
.
equalsIgnoreCase
(
this
.
codeName
))
return
this
;
if
(
relEntitiesMap
==
null
)
relEntitiesMap
=
new
LinkedHashMap
<>();
relEntitiesMap
.
put
(
codeName
,
entityModel
);
if
(
relEntitiesMap
==
null
)
relEntitiesMap
=
new
LinkedHashMap
<>();
relEntitiesMap
.
put
(
codeName
,
entityModel
);
return
this
;
}
public
Collection
<
EntityModel
>
getRelEntities
()
{
if
(
relEntitiesMap
==
null
)
{
if
(
this
.
references
!=
null
)
references
.
forEach
(
item
->
{
this
.
addRelEntity
(
item
.
getEntityCodeName
(),
item
.
getRelEntity
());
public
Collection
<
EntityModel
>
getRelEntities
()
{
if
(
relEntitiesMap
==
null
)
{
if
(
this
.
references
!=
null
)
references
.
forEach
(
item
->
{
this
.
addRelEntity
(
item
.
getEntityCodeName
(),
item
.
getRelEntity
());
});
if
(
this
.
nesteds
!=
null
)
nesteds
.
forEach
(
item
->
{
this
.
addRelEntity
(
item
.
getEntityCodeName
(),
item
.
getRelEntity
());
if
(
this
.
nesteds
!=
null
)
nesteds
.
forEach
(
item
->
{
this
.
addRelEntity
(
item
.
getEntityCodeName
(),
item
.
getRelEntity
());
});
if
(
this
.
indexRelation
!=
null
)
this
.
addRelEntity
(
this
.
indexRelation
.
getEntityCodeName
(),
this
.
indexRelation
.
getRelEntity
());
if
(
this
.
indexRelation
!=
null
)
this
.
addRelEntity
(
this
.
indexRelation
.
getEntityCodeName
(),
this
.
indexRelation
.
getRelEntity
());
}
if
(
relEntitiesMap
!=
null
)
if
(
relEntitiesMap
!=
null
)
return
relEntitiesMap
.
values
();
return
new
ArrayList
<>();
}
private
Map
<
String
,
FieldModel
>
fieldMap
=
null
;
public
Map
<
String
,
FieldModel
>
getFieldMap
()
{
if
(
fields
!=
null
&&
fieldMap
==
null
)
{
fieldMap
=
new
LinkedHashMap
<>();
fields
.
forEach
(
field
->{
fieldMap
.
put
(
field
.
getFieldName
(),
field
);
fieldMap
.
put
(
field
.
getCodeName
().
toString
(),
field
);
public
Map
<
String
,
FieldModel
>
getFieldMap
()
{
if
(
fields
!=
null
&&
fieldMap
==
null
)
{
fieldMap
=
new
LinkedHashMap
<>();
fields
.
forEach
(
field
->
{
fieldMap
.
put
(
field
.
getFieldName
(),
field
);
fieldMap
.
put
(
field
.
getCodeName
().
toString
(),
field
);
});
}
return
fieldMap
;
}
private
FieldModel
lastModifyField
;
public
FieldModel
getLastModifyField
()
{
if
(
fields
!=
null
&&
lastModifyField
==
null
)
for
(
FieldModel
fieldModel:
fields
)
if
(
fieldModel
.
isLastModifyField
())
{
lastModifyField
=
fieldModel
;
return
lastModifyField
;
}
if
(
fields
!=
null
&&
lastModifyField
==
null
)
for
(
FieldModel
fieldModel
:
fields
)
if
(
fieldModel
.
isLastModifyField
())
{
lastModifyField
=
fieldModel
;
return
lastModifyField
;
}
return
lastModifyField
;
}
...
...
@@ -226,226 +206,207 @@ public class EntityModel extends BaseModel {
public
FieldModel
getOrgField
()
{
if
(
fields
!=
null
&&
orgField
==
null
)
for
(
FieldModel
fieldModel:
fields
)
if
(
fieldModel
.
isOrgField
())
{
orgField
=
fieldModel
;
if
(
fields
!=
null
&&
orgField
==
null
)
for
(
FieldModel
fieldModel
:
fields
)
if
(
fieldModel
.
isOrgField
())
{
orgField
=
fieldModel
;
return
orgField
;
}
return
orgField
;
}
public
boolean
isLogicValid
()
{
public
boolean
isLogicValid
()
{
return
getDataEntity
().
isLogicValid
();
}
private
FieldModel
logicValidField
;
public
FieldModel
getLogicValidField
()
{
if
(
isLogicValid
()&&
logicValidField
==
null
)
{
if
(
fields
!=
null
)
{
for
(
FieldModel
fieldModel
:
fields
)
{
if
(
fieldModel
.
isLogicValidField
())
{
logicValidField
=
fieldModel
;
return
logicValidField
;
}
}
}
}
return
logicValidField
;
}
public
String
getValidLogicValue
()
{
String
validLogicValue
=
this
.
getDataEntity
().
getValidLogicValue
();
if
(
StringUtils
.
isEmpty
(
validLogicValue
))
validLogicValue
=
"1"
;
return
validLogicValue
;
}
public
String
getInvalidLogicValue
()
{
String
invalidLogicValue
=
this
.
getDataEntity
().
getInvalidLogicValue
();
if
(
StringUtils
.
isEmpty
(
invalidLogicValue
))
invalidLogicValue
=
"0"
;
return
invalidLogicValue
;
}
private
FieldModel
keyField
;
public
FieldModel
getLogicValidField
()
{
if
(
isLogicValid
()
&&
logicValidField
==
null
)
{
if
(
fields
!=
null
)
{
for
(
FieldModel
fieldModel
:
fields
)
{
if
(
fieldModel
.
isLogicValidField
())
{
logicValidField
=
fieldModel
;
return
logicValidField
;
}
}
}
}
return
logicValidField
;
}
public
String
getValidLogicValue
()
{
String
validLogicValue
=
this
.
getDataEntity
().
getValidLogicValue
();
if
(
StringUtils
.
isEmpty
(
validLogicValue
))
validLogicValue
=
"1"
;
return
validLogicValue
;
}
public
String
getInvalidLogicValue
()
{
String
invalidLogicValue
=
this
.
getDataEntity
().
getInvalidLogicValue
();
if
(
StringUtils
.
isEmpty
(
invalidLogicValue
))
invalidLogicValue
=
"0"
;
return
invalidLogicValue
;
}
private
FieldModel
keyField
;
public
FieldModel
getKeyField
()
{
if
(
fields
!=
null
&&
keyField
==
null
)
{
for
(
FieldModel
fieldModel:
fields
)
{
if
(
fieldModel
.
isKeyDEField
())
{
keyField
=
fieldModel
;
break
;
}
if
(
fields
!=
null
&&
keyField
==
null
)
{
for
(
FieldModel
fieldModel
:
fields
)
{
if
(
fieldModel
.
isKeyDEField
())
{
keyField
=
fieldModel
;
break
;
}
}
if
((!
keyField
.
isPhisicalDEField
())&&
getUnionKeyFields
().
size
()==
1
)
{
keyField
=
unionKeyFields
.
get
(
0
);
if
((!
keyField
.
isPhisicalDEField
())
&&
getUnionKeyFields
().
size
()
==
1
)
{
keyField
=
unionKeyFields
.
get
(
0
);
}
}
return
keyField
;
}
private
List
<
FieldModel
>
unionKeyFields
;
public
List
<
FieldModel
>
getUnionKeyFields
()
{
if
(
fields
!=
null
&&
unionKeyFields
==
null
)
{
unionKeyFields
=
new
ArrayList
<>();
if
(
getDataEntity
().
getUnionKeyValuePSDEFields
()!=
null
)
{
getDataEntity
().
getUnionKeyValuePSDEFields
().
forEach
(
def
->{
public
List
<
FieldModel
>
getUnionKeyFields
()
{
if
(
fields
!=
null
&&
unionKeyFields
==
null
)
{
unionKeyFields
=
new
ArrayList
<>();
if
(
getDataEntity
().
getUnionKeyValuePSDEFields
()
!=
null
)
{
getDataEntity
().
getUnionKeyValuePSDEFields
().
forEach
(
def
->
{
unionKeyFields
.
add
(
getFieldMap
().
get
(
def
.
getCodeName
()));
});
}
}
return
unionKeyFields
;
}
}
return
unionKeyFields
;
}
public
boolean
isUnionKeyMode
(){
return
!
ObjectUtils
.
isEmpty
(
getUnionKeyFields
());
public
boolean
isUnionKeyMode
()
{
return
!
ObjectUtils
.
isEmpty
(
getUnionKeyFields
());
}
public
List
<
FieldModel
>
getKeyFields
()
{
if
(
this
.
getKeyField
()!=
null
&&
this
.
getKeyField
().
isPhisicalDEField
())
{
if
(
this
.
getKeyField
()
!=
null
&&
this
.
getKeyField
().
isPhisicalDEField
())
{
List
<
FieldModel
>
keyFields
=
new
ArrayList
<>();
keyFields
.
add
(
getKeyField
());
return
keyFields
;
}
else
}
else
return
getUnionKeyFields
();
}
public
List
<
FieldModel
>
getQuickSearchFields
()
{
return
fields
.
stream
().
filter
(
s
->
s
.
getDataEntityField
().
isEnableQuickSearch
()).
collect
(
Collectors
.
toList
());
return
fields
.
stream
().
filter
(
s
->
s
.
getDataEntityField
().
isEnableQuickSearch
()).
collect
(
Collectors
.
toList
());
}
private
Map
<
String
,
ActionModel
>
actions
;
public
EntityModel
addAction
(
ActionModel
action
)
{
if
(
actions
==
null
)
actions
=
new
LinkedHashMap
<>();
actions
.
put
(
StringAdvUtils
.
camelcase
(
action
.
getCodeName
()),
action
);
public
EntityModel
addAction
(
ActionModel
action
)
{
if
(
actions
==
null
)
actions
=
new
LinkedHashMap
<>();
actions
.
put
(
StringAdvUtils
.
camelcase
(
action
.
getCodeName
()),
action
);
return
this
;
}
private
static
Set
<
String
>
ignoActions
=
new
HashSet
<
String
>(){{
add
(
"get"
);
add
(
"create"
);
add
(
"update"
);
add
(
"remove"
);
add
(
"save"
);
add
(
"getdraft"
);
add
(
"checkkey"
);
add
(
"createbatch"
);
add
(
"savebatch"
);
add
(
"updatebatch"
);
add
(
"removebatch"
);
private
static
Set
<
String
>
ignoActions
=
new
HashSet
<
String
>()
{{
add
(
"get"
);
add
(
"create"
);
add
(
"update"
);
add
(
"remove"
);
add
(
"save"
);
add
(
"getdraft"
);
add
(
"checkkey"
);
add
(
"createbatch"
);
add
(
"savebatch"
);
add
(
"updatebatch"
);
add
(
"removebatch"
);
}};
public
List
<
ActionModel
>
getExtActions
()
{
return
actions
.
values
().
stream
().
filter
(
s
->!
ignoActions
.
contains
(
s
.
getCodeName
().
toLowerCase
())).
collect
(
Collectors
.
toList
());
public
List
<
ActionModel
>
getExtActions
()
{
return
actions
.
values
().
stream
().
filter
(
s
->
!
ignoActions
.
contains
(
s
.
getCodeName
().
toLowerCase
())).
collect
(
Collectors
.
toList
());
}
public
String
getDsName
()
{
String
dsName
=
this
.
getDataEntity
().
getDSLink
();
if
(
StringUtils
.
isEmpty
(
dsName
)||
"DEFAULT"
.
equalsIgnoreCase
(
dsName
))
dsName
=
null
;
public
String
getDsName
()
{
String
dsName
=
this
.
getDataEntity
().
getDSLink
();
if
(
StringUtils
.
isEmpty
(
dsName
)
||
"DEFAULT"
.
equalsIgnoreCase
(
dsName
))
dsName
=
null
;
else
dsName
=
dsName
.
toLowerCase
();
dsName
=
dsName
.
toLowerCase
();
return
dsName
;
}
public
String
getTableName
(
String
dsType
)
{
return
this
.
getStringValue
(
"table-"
+
dsType
.
toLowerCase
(),
getTableName
());
public
String
getTableName
(
String
dsType
)
{
return
this
.
getStringValue
(
"table-"
+
dsType
.
toLowerCase
(),
getTableName
());
}
private
String
storage
=
"SQL"
;
private
String
storage
=
"SQL"
;
public
void
setStorage
(
Integer
type
)
{
switch
(
type
){
public
void
setStorage
(
Integer
type
)
{
switch
(
type
)
{
case
0
:
this
.
storage
=
"NONE"
;
this
.
storage
=
"NONE"
;
break
;
case
1
:
this
.
storage
=
"SQL"
;
this
.
storage
=
"SQL"
;
break
;
case
2
:
this
.
storage
=
"NoSQL"
;
this
.
storage
=
"NoSQL"
;
break
;
case
4
:
this
.
storage
=
"ServiceAPI"
;
this
.
storage
=
"ServiceAPI"
;
break
;
default
:
this
.
storage
=
"SQL"
;
this
.
storage
=
"SQL"
;
break
;
}
}
public
void
setStorage
(
String
type
)
{
this
.
storage
=
type
;
}
public
void
setStorage
(
String
type
)
{
this
.
storage
=
type
;
}
private
RelationshipModel
indexRelation
;
public
boolean
isIndexSubDE
()
{
if
(
this
.
getIndexRelation
()!=
null
)
public
boolean
isIndexSubDE
()
{
if
(
this
.
getIndexRelation
()
!=
null
)
return
true
;
return
false
;
}
public
boolean
isLogicInherit
()
{
if
(
this
.
getIndexRelation
()==
null
)
public
boolean
isLogicInherit
()
{
if
(
this
.
getIndexRelation
()
==
null
)
return
false
;
IPSDERBase
MinorPSDER
=
this
.
getIndexRelation
().
getDer
();
if
(
"DERINHERIT"
.
equals
(
MinorPSDER
.
getDERType
())
&&
MinorPSDER
instanceof
IPSDERInherit
)
{
return
((
IPSDERInherit
)
MinorPSDER
).
isLogicInherit
();
if
(
"DERINHERIT"
.
equals
(
MinorPSDER
.
getDERType
())
&&
MinorPSDER
instanceof
IPSDERInherit
)
{
return
((
IPSDERInherit
)
MinorPSDER
).
isLogicInherit
();
}
return
false
;
}
public
boolean
isHasPSDERsMapping
()
{
if
(
this
.
getReferences
()!=
null
)
{
for
(
RelationshipModel
rel:
this
.
getReferences
())
{
public
boolean
isHasPSDERsMapping
()
{
if
(
this
.
getReferences
()
!=
null
)
{
for
(
RelationshipModel
rel
:
this
.
getReferences
())
{
if
(
rel
.
getRelEntity
().
getStorage
().
equals
(
"NONE"
))
if
(
rel
.
getRelEntity
().
getStorage
().
equals
(
"NONE"
))
continue
;
if
(!(
rel
.
getDer
()
instanceof
PSDER1NImpl
))
if
(!(
rel
.
getDer
()
instanceof
PSDER1NImpl
))
continue
;
if
(((
PSDER1NImpl
)
rel
.
getDer
()).
getPSDER1NDEFieldMaps
()==
null
)
if
(((
PSDER1NImpl
)
rel
.
getDer
()).
getPSDER1NDEFieldMaps
()
==
null
)
continue
;
for
(
IPSDER1NDEFieldMap
derField
:
((
PSDER1NImpl
)
rel
.
getDer
()).
getPSDER1NDEFieldMaps
())
{
if
(
derField
.
getMapType
().
equals
(
"COUNT"
)
||
derField
.
getMapType
().
equals
(
"SUM"
)
for
(
IPSDER1NDEFieldMap
derField
:
((
PSDER1NImpl
)
rel
.
getDer
()).
getPSDER1NDEFieldMaps
())
{
if
(
derField
.
getMapType
().
equals
(
"COUNT"
)
||
derField
.
getMapType
().
equals
(
"SUM"
)
||
derField
.
getMapType
().
equals
(
"AVG"
)
||
derField
.
getMapType
().
equals
(
"MAX"
)
||
derField
.
getMapType
().
equals
(
"MIN"
))
return
true
;
}
...
...
@@ -454,37 +415,30 @@ public class EntityModel extends BaseModel {
return
false
;
}
public
boolean
isEnableES
()
{
public
boolean
isEnableES
()
{
return
"elasticsearch"
.
equalsIgnoreCase
(
this
.
getDataEntity
().
getUserTag
());
}
public
boolean
isHasDupCheck
()
{
if
(
this
.
getDefaultDataQuery
()==
null
)
public
boolean
isHasDupCheck
()
{
if
(
this
.
getDefaultDataQuery
()
==
null
)
return
false
;
if
(
getDataEntity
().
getStorageMode
()!=
1
&&
getDataEntity
().
getStorageMode
()!=
2
)
if
(
getDataEntity
().
getStorageMode
()
!=
1
&&
getDataEntity
().
getStorageMode
()
!=
2
)
return
false
;
for
(
IPSDEField
field:
getDataEntity
().
getAllPSDEFields
())
{
if
(
"ALL"
.
equalsIgnoreCase
(
field
.
getDupCheckMode
()))
for
(
IPSDEField
field
:
getDataEntity
().
getAllPSDEFields
())
{
if
(
"ALL"
.
equalsIgnoreCase
(
field
.
getDupCheckMode
()))
return
true
;
}
return
false
;
}
public
boolean
isNeedTypeHandler
()
{
if
(!
"NONE"
.
equalsIgnoreCase
(
getStorage
()))
public
boolean
isNeedTypeHandler
()
{
if
(!
"NONE"
.
equalsIgnoreCase
(
getStorage
()))
return
false
;
if
(
isHasReferences
())
{
for
(
RelationshipModel
ref:
getReferences
())
{
if
(
ref
.
getDer
()
instanceof
IPSDER1N
&&
ref
.
getRelEntity
().
getStorage
().
equalsIgnoreCase
(
"SQL"
))
{
IPSDEField
def
=((
IPSDER1N
)
ref
.
getDer
()).
getPSOne2ManyDataDEField
();
if
(
def
!=
null
&&
def
.
isPhisicalDEField
())
if
(
isHasReferences
())
{
for
(
RelationshipModel
ref
:
getReferences
())
{
if
(
ref
.
getDer
()
instanceof
IPSDER1N
&&
ref
.
getRelEntity
().
getStorage
().
equalsIgnoreCase
(
"SQL"
))
{
IPSDEField
def
=
((
IPSDER1N
)
ref
.
getDer
()).
getPSOne2ManyDataDEField
();
if
(
def
!=
null
&&
def
.
isPhisicalDEField
())
return
true
;
}
}
...
...
@@ -492,23 +446,20 @@ public class EntityModel extends BaseModel {
return
false
;
}
public
List
getMqPublishers
()
{
List
publishers
=
new
ArrayList
();
if
(
getDataEntity
().
getAllPSDEDataSyncs
()!=
null
)
{
getDataEntity
().
getAllPSDEDataSyncs
().
forEach
(
dataSync
->{
if
(
dataSync
.
getOutPSSysDataSyncAgent
()!=
null
&&
dataSync
.
getEventType
()!=
0
)
{
Map
map
=
new
HashMap
();
map
.
put
(
"dataSync"
,
dataSync
);
Set
<
String
>
monitors
=
new
LinkedHashSet
<>();
map
.
put
(
"monitors"
,
monitors
);
if
((
dataSync
.
getEventType
()&
1
)>
0
)
public
List
getMqPublishers
()
{
List
publishers
=
new
ArrayList
();
if
(
getDataEntity
().
getAllPSDEDataSyncs
()
!=
null
)
{
getDataEntity
().
getAllPSDEDataSyncs
().
forEach
(
dataSync
->
{
if
(
dataSync
.
getOutPSSysDataSyncAgent
()
!=
null
&&
dataSync
.
getEventType
()
!=
0
)
{
Map
map
=
new
HashMap
();
map
.
put
(
"dataSync"
,
dataSync
);
Set
<
String
>
monitors
=
new
LinkedHashSet
<>();
map
.
put
(
"monitors"
,
monitors
);
if
((
dataSync
.
getEventType
()
&
1
)
>
0
)
monitors
.
add
(
"create"
);
if
((
dataSync
.
getEventType
()&
2
)>
0
)
if
((
dataSync
.
getEventType
()
&
2
)
>
0
)
monitors
.
add
(
"update"
);
if
((
dataSync
.
getEventType
()&
4
)>
0
)
if
((
dataSync
.
getEventType
()
&
4
)
>
0
)
monitors
.
add
(
"remove"
);
publishers
.
add
(
map
);
}
...
...
@@ -518,172 +469,151 @@ public class EntityModel extends BaseModel {
}
private
List
<
OptionItem
>
dataScopes
;
public
List
<
OptionItem
>
getDataScopes
()
{
if
(
dataScopes
==
null
)
{
dataScopes
=
new
ArrayList
<>();
public
List
<
OptionItem
>
getDataScopes
()
{
if
(
dataScopes
==
null
)
{
dataScopes
=
new
ArrayList
<>();
dataScopes
.
add
(
new
OptionItem
().
setId
(
"all"
).
setName
(
"全部数据"
));
boolean
hasOrgId
=
false
,
hasDetpId
=
false
,
hasCreateBy
=
false
;
for
(
FieldModel
field:
getFields
())
{
if
(
"ORGID"
.
equalsIgnoreCase
(
field
.
getDataEntityField
().
getPredefinedType
()))
hasOrgId
=
true
;
else
if
(
"ORGSECTORID"
.
equalsIgnoreCase
(
field
.
getDataEntityField
().
getPredefinedType
()))
hasDetpId
=
true
;
else
if
(
"CREATEMAN"
.
equalsIgnoreCase
(
field
.
getDataEntityField
().
getPredefinedType
()))
hasCreateBy
=
true
;
boolean
hasOrgId
=
false
,
hasDetpId
=
false
,
hasCreateBy
=
false
;
for
(
FieldModel
field
:
getFields
())
{
if
(
"ORGID"
.
equalsIgnoreCase
(
field
.
getDataEntityField
().
getPredefinedType
()))
hasOrgId
=
true
;
else
if
(
"ORGSECTORID"
.
equalsIgnoreCase
(
field
.
getDataEntityField
().
getPredefinedType
()))
hasDetpId
=
true
;
else
if
(
"CREATEMAN"
.
equalsIgnoreCase
(
field
.
getDataEntityField
().
getPredefinedType
()))
hasCreateBy
=
true
;
}
if
(
hasOrgId
)
{
if
(
hasOrgId
)
{
dataScopes
.
add
(
new
OptionItem
().
setId
(
"curorg"
).
setName
(
"当前单位"
));
dataScopes
.
add
(
new
OptionItem
().
setId
(
"porg"
).
setName
(
"上级单位"
));
dataScopes
.
add
(
new
OptionItem
().
setId
(
"sorg"
).
setName
(
"下级单位"
));
}
if
(
hasDetpId
)
{
if
(
hasDetpId
)
{
dataScopes
.
add
(
new
OptionItem
().
setId
(
"curorgdept"
).
setName
(
"当前部门"
));
dataScopes
.
add
(
new
OptionItem
().
setId
(
"porgdept"
).
setName
(
"上级部门"
));
dataScopes
.
add
(
new
OptionItem
().
setId
(
"sorgdept"
).
setName
(
"下级部门"
));
}
if
(
hasCreateBy
)
if
(
hasCreateBy
)
dataScopes
.
add
(
new
OptionItem
().
setId
(
"createman"
).
setName
(
"创建人"
));
}
return
dataScopes
;
}
public
boolean
isHasScopes
()
{
return
getDataScopes
().
size
()
>
1
;
return
getDataScopes
().
size
()
>
1
;
}
private
Map
<
String
,
POSchema
>
poSchemas
;
public
POSchema
getDefaultPOSchema
()
{
public
POSchema
getDefaultPOSchema
()
{
return
getPOSchema
(
"default"
);
}
public
EntityModel
addPOSchema
(
String
name
,
POSchema
poSchema
)
{
if
(
poSchema
!=
null
)
{
if
(
poSchemas
==
null
)
poSchemas
=
new
LinkedHashMap
<>();
poSchemas
.
put
(
name
,
poSchema
.
build
());
public
EntityModel
addPOSchema
(
String
name
,
POSchema
poSchema
)
{
if
(
poSchema
!=
null
)
{
if
(
poSchemas
==
null
)
poSchemas
=
new
LinkedHashMap
<>();
poSchemas
.
put
(
name
,
poSchema
.
build
());
}
return
this
;
}
public
POSchema
getPOSchema
(
String
name
)
{
if
(
StringUtils
.
isEmpty
(
name
)&&(!
StringUtils
.
isEmpty
(
this
.
getDsName
())))
name
=
this
.
getDsName
();
if
(
StringUtils
.
isEmpty
(
name
))
name
=
"mysql"
;
if
(
poSchemas
==
null
)
poSchemas
=
new
LinkedHashMap
<>();
if
(
poSchemas
.
containsKey
(
name
))
{
public
POSchema
getPOSchema
(
String
name
)
{
if
(
StringUtils
.
isEmpty
(
name
)
&&
(!
StringUtils
.
isEmpty
(
this
.
getDsName
())))
name
=
this
.
getDsName
();
if
(
StringUtils
.
isEmpty
(
name
))
name
=
"mysql"
;
if
(
poSchemas
==
null
)
poSchemas
=
new
LinkedHashMap
<>();
if
(
poSchemas
.
containsKey
(
name
))
{
return
poSchemas
.
get
(
name
);
}
String
vendorProvider
=
POSchema
.
provider
.
get
(
name
.
toLowerCase
());
if
((!
StringUtils
.
isEmpty
(
vendorProvider
))&&(!
name
.
equalsIgnoreCase
(
vendorProvider
))&&
poSchemas
.
containsKey
(
vendorProvider
))
String
vendorProvider
=
POSchema
.
provider
.
get
(
name
.
toLowerCase
());
if
((!
StringUtils
.
isEmpty
(
vendorProvider
))
&&
(!
name
.
equalsIgnoreCase
(
vendorProvider
))
&&
poSchemas
.
containsKey
(
vendorProvider
))
return
poSchemas
.
get
(
vendorProvider
);
if
(
poSchemas
.
size
()>
0
)
if
(
poSchemas
.
size
()
>
0
)
return
poSchemas
.
values
().
iterator
().
next
();
return
null
;
}
public
String
getStringValue
(
String
key
,
String
defaultVal
)
{
return
extParams
.
getStringValue
(
key
,
defaultVal
);
public
String
getStringValue
(
String
key
,
String
defaultVal
)
{
return
extParams
.
getStringValue
(
key
,
defaultVal
);
}
private
boolean
hasResetField
=
false
;
private
boolean
hasResetField
=
false
;
private
ClientEntityModel
clientEntityModel
;
public
EntityModel
(
SystemModel
systemModel
,
IPSDataEntity
dataEntity
)
{
Assert
.
notNull
(
dataEntity
,
"未找到对应的实体模型:"
+
dataEntity
.
getId
());
this
.
opt
=
dataEntity
;
this
.
system
=
systemModel
;
public
EntityModel
(
SystemModel
systemModel
,
IPSDataEntity
dataEntity
)
{
Assert
.
notNull
(
dataEntity
,
"未找到对应的实体模型:"
+
dataEntity
.
getId
());
this
.
opt
=
dataEntity
;
this
.
system
=
systemModel
;
this
.
setCodeName
(
dataEntity
.
getCodeName
());
this
.
setName
(
dataEntity
.
getName
());
this
.
setStorage
(
dataEntity
.
getStorageMode
());
List
<
String
>
dsTypes
=
new
ArrayList
<>();
List
<
String
>
dsTypes
=
new
ArrayList
<>();
if
(
dataEntity
.
getAllPSDEDBConfigs
()!=
null
)
{
dataEntity
.
getAllPSDEDBConfigs
().
forEach
(
item
->{
String
dbType
=
item
.
getDBType
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
);
if
(
"mysql"
.
equals
(
dbType
))
if
(
dataEntity
.
getAllPSDEDBConfigs
()
!=
null
)
{
dataEntity
.
getAllPSDEDBConfigs
().
forEach
(
item
->
{
String
dbType
=
item
.
getDBType
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
);
if
(
"mysql"
.
equals
(
dbType
))
system
.
setEnableMysql
(
true
);
else
if
(
"oracle"
.
equals
(
dbType
))
else
if
(
"oracle"
.
equals
(
dbType
))
system
.
setEnableOracle
(
true
);
else
if
(
"postgresql"
.
equals
(
dbType
))
else
if
(
"postgresql"
.
equals
(
dbType
))
system
.
setEnablePostgreSQL
(
true
);
else
if
(
"dameng"
.
equals
(
dbType
)||
"dm"
.
equals
(
dbType
))
else
if
(
"dameng"
.
equals
(
dbType
)
||
"dm"
.
equals
(
dbType
))
system
.
setEnableDameng
(
true
);
dsTypes
.
add
(
dbType
);
if
(
this
.
getTableName
()!=
null
&&
(!
this
.
getTableName
().
equalsIgnoreCase
(
item
.
getTableName
())))
this
.
set
(
"table-"
+
item
.
getDBType
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
),
item
.
getTableName
());
if
(
this
.
getTableName
()
!=
null
&&
(!
this
.
getTableName
().
equalsIgnoreCase
(
item
.
getTableName
())))
this
.
set
(
"table-"
+
item
.
getDBType
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
),
item
.
getTableName
());
});
}
if
(
dataEntity
.
getMinorPSDERs
()!=
null
)
{
for
(
IPSDERBase
der
:
dataEntity
.
getMinorPSDERs
())
{
RelationshipModel
rel
=
new
RelationshipModel
(
this
,
der
);
if
(
dataEntity
.
getMinorPSDERs
()
!=
null
)
{
for
(
IPSDERBase
der
:
dataEntity
.
getMinorPSDERs
())
{
RelationshipModel
rel
=
new
RelationshipModel
(
this
,
der
);
rel
.
setRelationType
(
"reference"
).
setCodeName
(
der
.
getCodeName
()).
setEntityId
(
der
.
getMajorPSDataEntity
().
getId
())
.
setEntityCodeName
(
der
.
getMajorPSDataEntity
().
getCodeName
()).
setEntityName
(
der
.
getMajorPSDataEntity
().
getName
())
.
setEntityLogicName
(
der
.
getMajorPSDataEntity
().
getLogicName
()).
setTableName
(
der
.
getMajorPSDataEntity
().
getTableName
());
if
(
der
.
getMajorPSDataEntity
().
getPSSystemModule
()!=
null
)
if
(
der
.
getMajorPSDataEntity
().
getPSSystemModule
()
!=
null
)
rel
.
setModule
(
der
.
getMajorPSDataEntity
().
getPSSystemModule
().
getCodeName
().
toLowerCase
());
if
(
der
instanceof
IPSDER1N
)
{
IPSDER1N
der1n
=
(
IPSDER1N
)
der
;
String
refFieldName
=
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"name"
).
asText
();
String
refCodeName
=
refFieldName
;
if
(
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"codeName"
)
!=
null
)
refCodeName
=
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"codeName"
).
asText
();
if
(
der
instanceof
IPSDER1N
)
{
IPSDER1N
der1n
=(
IPSDER1N
)
der
;
String
refFieldName
=
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"name"
).
asText
();
String
refCodeName
=
refFieldName
;
if
(
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"codeName"
)!=
null
)
refCodeName
=
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"codeName"
).
asText
();
LookupModel
lookupModel
=
new
LookupModel
().
setRelationid
(
der
.
getId
())
LookupModel
lookupModel
=
new
LookupModel
().
setRelationid
(
der
.
getId
())
.
setFieldname
(
der1n
.
getPickupDEFName
()).
setCodeName
(
der1n
.
getPSPickupDEField
().
getCodeName
()).
setReffieldname
(
refFieldName
).
setRefCodeName
(
refCodeName
);
rel
.
addLookup
(
lookupModel
);
}
else
if
(
der
instanceof
IPSDERIndex
||
der
instanceof
IPSDERInherit
)
{
if
(
der
.
getMajorPSDataEntity
().
getKeyPSDEField
()!=
null
)
{
}
else
if
(
der
instanceof
IPSDERIndex
||
der
instanceof
IPSDERInherit
)
{
if
(
der
.
getMajorPSDataEntity
().
getKeyPSDEField
()
!=
null
)
{
LookupModel
lookupModel
=
new
LookupModel
().
setRelationid
(
der
.
getId
())
.
setFieldname
(
this
.
getDataEntity
().
getKeyPSDEField
().
getName
()).
setCodeName
(
this
.
getDataEntity
().
getKeyPSDEField
().
getCodeName
())
.
setReffieldname
(
der
.
getMajorPSDataEntity
().
getKeyPSDEField
().
getName
()).
setRefCodeName
(
der
.
getMajorPSDataEntity
().
getKeyPSDEField
().
getCodeName
());
rel
.
addLookup
(
lookupModel
);
}
if
(
der
.
getMajorPSDataEntity
().
getMajorPSDEField
()!=
null
)
{
if
(
der
.
getMajorPSDataEntity
().
getMajorPSDEField
()
!=
null
)
{
LookupModel
lookupModel
=
new
LookupModel
().
setRelationid
(
der
.
getId
())
.
setFieldname
(
this
.
getDataEntity
().
getMajorPSDEField
().
getName
()).
setCodeName
(
this
.
getDataEntity
().
getMajorPSDEField
().
getCodeName
())
.
setReffieldname
(
der
.
getMajorPSDataEntity
().
getMajorPSDEField
().
getName
()).
setRefCodeName
(
der
.
getMajorPSDataEntity
().
getMajorPSDEField
().
getCodeName
());
rel
.
addLookup
(
lookupModel
);
}
List
<
IPSDERIndexDEFieldMap
>
map
=
((
IPSDERIndex
)
der
).
getPSDERIndexDEFieldMaps
();
if
(!
ObjectUtils
.
isEmpty
(
map
))
{
map
.
forEach
(
item
->{
LookupModel
lookupModel
=
new
LookupModel
().
setRelationid
(
der
.
getId
())
if
(!
ObjectUtils
.
isEmpty
(
map
))
{
map
.
forEach
(
item
->
{
LookupModel
lookupModel
=
new
LookupModel
().
setRelationid
(
der
.
getId
())
.
setFieldname
(
item
.
getMinorPSDEField
().
getName
()).
setCodeName
(
item
.
getMinorPSDEField
().
getCodeName
())
.
setReffieldname
(
item
.
getMajorPSDEField
().
getName
()).
setRefCodeName
(
item
.
getMajorPSDEField
().
getCodeName
());
rel
.
addLookup
(
lookupModel
);
...
...
@@ -691,22 +621,18 @@ public class EntityModel extends BaseModel {
}
}
//聚合关系 暂时忽略
else
if
(
der
instanceof
IPSDERAggData
){
else
if
(
der
instanceof
IPSDERAggData
)
{
continue
;
}
if
(
"DERINHERIT"
.
equals
(
der
.
getDERType
()))
{
if
(
"DERINHERIT"
.
equals
(
der
.
getDERType
()))
{
rel
.
setRelationType
(
"inherit"
);
this
.
setIndexRelation
(
rel
);
}
else
if
(
"DERINDEX"
.
equals
(
der
.
getDERType
())
//&& der.getMajorPSDataEntity().getVirtualMode()!=3
&&
der
.
getMajorPSDataEntity
().
getIndexTypePSDEField
()!=
null
)
{
}
else
if
(
"DERINDEX"
.
equals
(
der
.
getDERType
())
//&& der.getMajorPSDataEntity().getVirtualMode()!=3
&&
der
.
getMajorPSDataEntity
().
getIndexTypePSDEField
()
!=
null
)
{
rel
.
setRelationType
(
"index"
);
this
.
setIndexRelation
(
rel
);
}
else
{
}
else
{
rel
.
setRelationType
(
"reference"
);
this
.
addReference
(
rel
);
}
...
...
@@ -714,52 +640,45 @@ public class EntityModel extends BaseModel {
}
if
(
dataEntity
.
getMajorPSDERs
()!=
null
)
{
for
(
IPSDERBase
der
:
dataEntity
.
getMajorPSDERs
())
{
if
(
der
instanceof
IPSDER1N
)
{
IPSDER1N
der1n
=(
IPSDER1N
)
der
;
String
codeName
=
der
.
getMinorCodeName
();
boolean
nestedRS
=
false
;
if
(
der1n
.
isNestedRS
())
nestedRS
=
true
;
else
if
(
der1n
.
getPSOne2ManyDataDEField
()!=
null
)
{
nestedRS
=
true
;
}
else
if
(
der1n
.
getMinorPSDataEntity
().
getPSSubSysServiceAPIDE
()!=
null
&&
der1n
.
getMinorPSDataEntity
().
getPSSubSysServiceAPIDE
().
isNested
())
{
nestedRS
=
true
;
if
(
dataEntity
.
getMajorPSDERs
()
!=
null
)
{
for
(
IPSDERBase
der
:
dataEntity
.
getMajorPSDERs
())
{
if
(
der
instanceof
IPSDER1N
)
{
IPSDER1N
der1n
=
(
IPSDER1N
)
der
;
String
codeName
=
der
.
getMinorCodeName
();
boolean
nestedRS
=
false
;
if
(
der1n
.
isNestedRS
())
nestedRS
=
true
;
else
if
(
der1n
.
getPSOne2ManyDataDEField
()
!=
null
)
{
nestedRS
=
true
;
}
else
if
(
der1n
.
getMinorPSDataEntity
().
getPSSubSysServiceAPIDE
()
!=
null
&&
der1n
.
getMinorPSDataEntity
().
getPSSubSysServiceAPIDE
().
isNested
())
{
nestedRS
=
true
;
}
if
(!
nestedRS
)
if
(!
nestedRS
)
continue
;
if
(
StringUtils
.
isEmpty
(
codeName
))
codeName
=
der
.
getMinorPSDataEntity
().
getCodeName
();
if
(
StringUtils
.
isEmpty
(
codeName
))
codeName
=
der
.
getMinorPSDataEntity
().
getCodeName
();
RelationshipModel
rel
=
new
RelationshipModel
(
this
,
der
);
RelationshipModel
rel
=
new
RelationshipModel
(
this
,
der
);
rel
.
setRelationType
(
"nested"
).
setCodeName
(
codeName
).
setEntityId
(
der
.
getMinorPSDataEntity
().
getId
())
.
setEntityCodeName
(
der
.
getMinorPSDataEntity
().
getCodeName
()).
setEntityName
(
der
.
getMinorPSDataEntity
().
getName
())
.
setEntityLogicName
(
der
.
getMinorPSDataEntity
().
getLogicName
()).
setTableName
(
der
.
getMinorPSDataEntity
().
getTableName
());
if
(
der
.
getMinorPSDataEntity
().
getPSSystemModule
()!=
null
)
if
(
der
.
getMinorPSDataEntity
().
getPSSystemModule
()
!=
null
)
rel
.
setModule
(
der
.
getMinorPSDataEntity
().
getPSSystemModule
().
getCodeName
().
toLowerCase
());
if
(
der1n
.
getPSOne2ManyDataDEField
()!=
null
&&
der1n
.
getPSOne2ManyDataDEField
().
isPhisicalDEField
()&&
der1n
.
getMinorPSDataEntity
().
getStorageMode
()==
0
)
{
if
(
der1n
.
getPSOne2ManyDataDEField
()
!=
null
&&
der1n
.
getPSOne2ManyDataDEField
().
isPhisicalDEField
()
&&
der1n
.
getMinorPSDataEntity
().
getStorageMode
()
==
0
)
{
rel
.
setColumnName
(
der1n
.
getPSOne2ManyDataDEField
().
getName
().
toLowerCase
());
rel
.
setCodeName
(
der1n
.
getPSOne2ManyDataDEField
().
getCodeName
());
}
rel
.
setFkFieldCodeName
(
der1n
.
getPSPickupDEField
().
getCodeName
());
String
refFieldName
=
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"name"
).
asText
();
String
refCodeName
=
refFieldName
;
if
(
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"codeName"
)!=
null
)
refCodeName
=
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"codeName"
).
asText
();
String
refFieldName
=
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"name"
).
asText
();
String
refCodeName
=
refFieldName
;
if
(
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"codeName"
)
!=
null
)
refCodeName
=
der1n
.
getPSPickupDEField
().
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"codeName"
).
asText
();
LookupModel
lookupModel
=
new
LookupModel
().
setRelationid
(
der
.
getId
())
LookupModel
lookupModel
=
new
LookupModel
().
setRelationid
(
der
.
getId
())
.
setFieldname
(
der1n
.
getPickupDEFName
()).
setCodeName
(
der1n
.
getPSPickupDEField
().
getCodeName
()).
setReffieldname
(
refFieldName
).
setRefCodeName
(
refCodeName
);
rel
.
addLookup
(
lookupModel
);
...
...
@@ -770,55 +689,49 @@ public class EntityModel extends BaseModel {
}
}
Map
<
String
,
FieldModel
>
fieldMaps
=
new
LinkedHashMap
<>();
for
(
IPSDEField
defield:
dataEntity
.
getAllPSDEFields
())
{
Map
<
String
,
FieldModel
>
fieldMaps
=
new
LinkedHashMap
<>();
for
(
IPSDEField
defield
:
dataEntity
.
getAllPSDEFields
())
{
if
(
defield
.
isPasteReset
())
this
.
hasResetField
=
true
;
if
(
defield
.
isPasteReset
())
this
.
hasResetField
=
true
;
FieldModel
fieldModel
=
new
FieldModel
(
this
,
defield
);
FieldModel
fieldModel
=
new
FieldModel
(
this
,
defield
);
if
(
defield
.
isMajorDEField
())
this
.
majorField
=
fieldModel
;
if
(
defield
.
isMajorDEField
())
this
.
majorField
=
fieldModel
;
try
{
fieldModel
.
setDict
(
defield
.
getPSCodeList
()!=
null
?
defield
.
getPSCodeList
().
getCodeName
():
null
);
}
catch
(
Exception
ex
){}
try
{
fieldModel
.
setDict
(
defield
.
getPSCodeList
()
!=
null
?
defield
.
getPSCodeList
().
getCodeName
()
:
null
);
}
catch
(
Exception
ex
)
{
}
if
(
defield
.
getAllPSDEFDTColumns
()!=
null
)
{
defield
.
getAllPSDEFDTColumns
().
forEach
(
col
->{
if
(!
fieldModel
.
getFieldName
().
equalsIgnoreCase
(
col
.
getColumnName
()))
fieldModel
.
set
(
"column-"
+
col
.
getDBType
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
),
col
.
getColumnName
());
if
(
StringUtils
.
isEmpty
(
fieldModel
)&&
defield
.
isFormulaDEField
()&&(!
StringUtils
.
isEmpty
(
col
.
getQueryCodeExp
())))
fieldModel
.
setExpression
(
col
.
getQueryCodeExp
().
replace
(
"`"
,
""
).
replace
(
"["
,
""
).
replace
(
"]"
,
""
));
if
(
defield
.
getAllPSDEFDTColumns
()
!=
null
)
{
defield
.
getAllPSDEFDTColumns
().
forEach
(
col
->
{
if
(!
fieldModel
.
getFieldName
().
equalsIgnoreCase
(
col
.
getColumnName
()))
fieldModel
.
set
(
"column-"
+
col
.
getDBType
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
),
col
.
getColumnName
());
if
(
StringUtils
.
isEmpty
(
fieldModel
)
&&
defield
.
isFormulaDEField
()
&&
(!
StringUtils
.
isEmpty
(
col
.
getQueryCodeExp
())))
fieldModel
.
setExpression
(
col
.
getQueryCodeExp
().
replace
(
"`"
,
""
).
replace
(
"["
,
""
).
replace
(
"]"
,
""
));
});
}
if
(
defield
.
isLinkDEField
()
&&
defield
instanceof
IPSLinkDEField
)
{
IPSLinkDEField
linkDEField
=
(
IPSLinkDEField
)
defield
;
String
relfieldname
=
linkDEField
.
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"name"
).
asText
();
String
relfieldcodename
=
linkDEField
.
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"codeName"
).
asText
();
if
(
defield
.
isLinkDEField
()
&&
defield
instanceof
IPSLinkDEField
)
{
IPSLinkDEField
linkDEField
=
(
IPSLinkDEField
)
defield
;
String
relfieldname
=
linkDEField
.
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"name"
).
asText
();
String
relfieldcodename
=
linkDEField
.
getObjectNode
().
get
(
"getRelatedPSDEField"
).
get
(
"codeName"
).
asText
();
linkDEField
.
getRelatedPSDEField
();
fieldModel
.
setRefFieldName
(
relfieldname
).
setRefFieldCodeName
(
relfieldcodename
);
if
(!
StringUtils
.
isEmpty
(
linkDEField
.
getPSDER
().
getCodeName
()))
{
RelationshipModel
relationshipModel
=
this
.
getRefMaps
().
get
(
linkDEField
.
getPSDER
().
getCodeName
());
if
(
relationshipModel
!=
null
&&(!
StringUtils
.
isEmpty
(
relationshipModel
.
getCodeName
())))
{
if
(!
StringUtils
.
isEmpty
(
linkDEField
.
getPSDER
().
getCodeName
()))
{
RelationshipModel
relationshipModel
=
this
.
getRefMaps
().
get
(
linkDEField
.
getPSDER
().
getCodeName
());
if
(
relationshipModel
!=
null
&&
(!
StringUtils
.
isEmpty
(
relationshipModel
.
getCodeName
())))
{
relationshipModel
.
addField
(
fieldModel
);
fieldModel
.
setReference
(
relationshipModel
);
if
(
"PICKUP"
.
equalsIgnoreCase
(
defield
.
getDataType
()))
{
if
(
"PICKUP"
.
equalsIgnoreCase
(
defield
.
getDataType
()))
{
relationshipModel
.
setFkField
(
fieldModel
);
relationshipModel
.
setFkFieldCodeName
(
fieldModel
.
getCodeName
().
toString
());
}
else
if
(
defield
.
isPhisicalDEField
()||(!
StringUtils
.
isEmpty
(
defield
.
getUnionKeyValue
())))
{
hasPhisicalLinkField
=
true
;
}
else
if
(
defield
.
isPhisicalDEField
()
||
(!
StringUtils
.
isEmpty
(
defield
.
getUnionKeyValue
())))
{
hasPhisicalLinkField
=
true
;
}
}
}
...
...
@@ -826,49 +739,43 @@ public class EntityModel extends BaseModel {
}
fieldMaps
.
put
(
fieldModel
.
getFieldName
(),
fieldModel
);
fieldMaps
.
put
(
fieldModel
.
getFieldName
(),
fieldModel
);
this
.
addField
(
fieldModel
);
}
if
(
dataEntity
.
getAllPSDEDataQueries
()!=
null
)
{
dataEntity
.
getAllPSDEDataQueries
().
forEach
(
dataQuery
->{
if
(
dataEntity
.
getAllPSDEDataQueries
()
!=
null
)
{
dataEntity
.
getAllPSDEDataQueries
().
forEach
(
dataQuery
->
{
try
{
if
(
dataQuery
.
getAllPSDEDataQueryCodes
()!=
null
)
{
dataQuery
.
getAllPSDEDataQueryCodes
().
forEach
(
dq
->{
if
(
StringUtils
.
isEmpty
(
dq
.
getQueryCode
()))
if
(
dataQuery
.
getAllPSDEDataQueryCodes
()
!=
null
)
{
dataQuery
.
getAllPSDEDataQueryCodes
().
forEach
(
dq
->
{
if
(
StringUtils
.
isEmpty
(
dq
.
getQueryCode
()))
return
;
String
select
=
TransUtils
.
contextParamConvert
(
dq
.
getQueryCode
());
String
where
=
null
;
if
(
dq
.
getPSDEDataQueryCodeConds
()!=
null
)
{
int
i
=
0
;
boolean
b
=
TransUtils
.
checkIgnoreNullvalueCond
(
dq
.
getPSDEDataQueryCodeConds
());
for
(
IPSDEDataQueryCodeCond
cond:
dq
.
getPSDEDataQueryCodeConds
())
{
if
(
i
==
0
)
where
=
" where "
;
else
if
(
i
>
0
)
where
=
where
.
concat
(
" and "
);
where
=
where
.
concat
(
b
?
TransUtils
.
checkNullContextParamConvert
(
cond
.
getCustomCond
()):
TransUtils
.
contextParamConvert
(
cond
.
getCustomCond
()));
String
select
=
TransUtils
.
contextParamConvert
(
dq
.
getQueryCode
());
String
where
=
null
;
if
(
dq
.
getPSDEDataQueryCodeConds
()
!=
null
)
{
int
i
=
0
;
boolean
b
=
TransUtils
.
checkIgnoreNullvalueCond
(
dq
.
getPSDEDataQueryCodeConds
());
for
(
IPSDEDataQueryCodeCond
cond
:
dq
.
getPSDEDataQueryCodeConds
())
{
if
(
i
==
0
)
where
=
" where "
;
else
if
(
i
>
0
)
where
=
where
.
concat
(
" and "
);
where
=
where
.
concat
(
b
?
TransUtils
.
checkNullContextParamConvert
(
cond
.
getCustomCond
())
:
TransUtils
.
contextParamConvert
(
cond
.
getCustomCond
()));
i
++;
}
}
DataSetModel
dsModel
=
new
DataSetModel
();
DataSetModel
dsModel
=
new
DataSetModel
();
dsModel
.
setEntity
(
this
);
dsModel
.
setName
(
dataQuery
.
getName
());
dsModel
.
setDatasetId
(
this
.
getEntityName
().
toLowerCase
()
+
"-dq-"
+
dataQuery
.
getCodeName
()+
"-"
+
dq
.
getDBType
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
))
.
setDsType
(
dq
.
getDBType
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
))
dsModel
.
setDatasetId
(
this
.
getEntityName
().
toLowerCase
()
+
"-dq-"
+
dataQuery
.
getCodeName
()
+
"-"
+
dq
.
getDBType
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
))
.
setDsType
(
dq
.
getDBType
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
))
.
setDatasetName
(
dataQuery
.
getLogicName
()).
setCodeName
(
dataQuery
.
getCodeName
())
.
setSelect
(
select
).
setWhere
(
where
)
.
setDsCode
(
select
.
concat
(
where
==
null
?
""
:
where
));
.
setDsCode
(
select
.
concat
(
where
==
null
?
""
:
where
));
this
.
addQueries
(
dsModel
);
this
.
addDataQueries
(
dsModel
);
...
...
@@ -881,65 +788,56 @@ public class EntityModel extends BaseModel {
});
}
if
(
dataEntity
.
getAllPSDEDataSets
()!=
null
)
{
dataEntity
.
getAllPSDEDataSets
().
forEach
(
dataSet
->{
if
(
dataEntity
.
getAllPSDEDataSets
()
!=
null
)
{
dataEntity
.
getAllPSDEDataSets
().
forEach
(
dataSet
->
{
String
select
=
"select t1.*"
;
String
select
=
"select t1.*"
;
String
from
=
" from ( %s ) t1 "
;
String
from
=
" from ( %s ) t1 "
;
String
where
=
null
;
String
where
=
null
;
String
groupBy
=
null
;
String
groupBy
=
null
;
String
orderBy
=
null
;
String
orderBy
=
null
;
if
(
dataSet
.
getGroupMode
()==
1
||
dataSet
.
getMajorSortPSDEField
()!=
null
)
{
if
(
dataSet
.
getGroupMode
()
==
1
||
dataSet
.
getMajorSortPSDEField
()
!=
null
)
{
if
(
dataSet
.
getGroupMode
()==
1
&&(!
ObjectUtils
.
isEmpty
(
dataSet
.
getPSDEDataSetGroupParams
())))
{
select
=
"select "
;
int
i
=
0
;
for
(
IPSDEDataSetGroupParam
obj:
dataSet
.
getPSDEDataSetGroupParams
())
{
if
(!(
obj
instanceof
PSDEDataSetGroupParamImpl
))
if
(
dataSet
.
getGroupMode
()
==
1
&&
(!
ObjectUtils
.
isEmpty
(
dataSet
.
getPSDEDataSetGroupParams
())))
{
select
=
"select "
;
int
i
=
0
;
for
(
IPSDEDataSetGroupParam
obj
:
dataSet
.
getPSDEDataSetGroupParams
())
{
if
(!(
obj
instanceof
PSDEDataSetGroupParamImpl
))
continue
;
PSDEDataSetGroupParamImpl
groupParam
=(
PSDEDataSetGroupParamImpl
)
obj
;
if
(
i
>
0
)
select
=
select
.
concat
(
","
);
if
(
groupParam
.
isEnableGroup
())
{
if
(!
StringUtils
.
isEmpty
(
groupParam
.
getGroupCode
()))
select
=
select
.
concat
(
groupParam
.
getGroupCode
());
PSDEDataSetGroupParamImpl
groupParam
=
(
PSDEDataSetGroupParamImpl
)
obj
;
if
(
i
>
0
)
select
=
select
.
concat
(
","
);
if
(
groupParam
.
isEnableGroup
())
{
if
(!
StringUtils
.
isEmpty
(
groupParam
.
getGroupCode
()))
select
=
select
.
concat
(
groupParam
.
getGroupCode
());
else
select
=
select
.
concat
(
groupParam
.
getName
());
}
else
select
=
select
.
concat
(
groupParam
.
getGroupCode
());
select
=
select
.
concat
(
" as "
).
concat
(
groupParam
.
getName
().
toLowerCase
());
select
=
select
.
concat
(
groupParam
.
getName
());
}
else
select
=
select
.
concat
(
groupParam
.
getGroupCode
());
select
=
select
.
concat
(
" as "
).
concat
(
groupParam
.
getName
().
toLowerCase
());
i
++;
}
}
if
(
dataSet
.
getGroupMode
()==
1
&&(!
ObjectUtils
.
isEmpty
(
dataSet
.
getPSDEDataSetGroupParams
())))
{
groupBy
=
" group by "
;
int
i
=
0
;
for
(
IPSDEDataSetGroupParam
obj:
dataSet
.
getPSDEDataSetGroupParams
())
{
if
(!(
obj
instanceof
PSDEDataSetGroupParamImpl
))
if
(
dataSet
.
getGroupMode
()
==
1
&&
(!
ObjectUtils
.
isEmpty
(
dataSet
.
getPSDEDataSetGroupParams
())))
{
groupBy
=
" group by "
;
int
i
=
0
;
for
(
IPSDEDataSetGroupParam
obj
:
dataSet
.
getPSDEDataSetGroupParams
())
{
if
(!(
obj
instanceof
PSDEDataSetGroupParamImpl
))
continue
;
PSDEDataSetGroupParamImpl
groupParam
=(
PSDEDataSetGroupParamImpl
)
obj
;
if
(
groupParam
.
isEnableGroup
())
{
if
(
i
>
0
)
groupBy
=
groupBy
.
concat
(
","
);
PSDEDataSetGroupParamImpl
groupParam
=
(
PSDEDataSetGroupParamImpl
)
obj
;
if
(
groupParam
.
isEnableGroup
())
{
if
(
i
>
0
)
groupBy
=
groupBy
.
concat
(
","
);
if
(!
StringUtils
.
isEmpty
(
groupParam
.
getGroupCode
()))
groupBy
=
groupBy
.
concat
(
groupParam
.
getGroupCode
());
if
(!
StringUtils
.
isEmpty
(
groupParam
.
getGroupCode
()))
groupBy
=
groupBy
.
concat
(
groupParam
.
getGroupCode
());
else
groupBy
=
groupBy
.
concat
(
groupParam
.
getName
());
groupBy
=
groupBy
.
concat
(
groupParam
.
getName
());
i
++;
}
}
...
...
@@ -951,34 +849,30 @@ public class EntityModel extends BaseModel {
try
{
if
(
dataSet
.
getPSDEDataQueries
()!=
null
)
{
DataSetModel
dsModel
=
new
DataSetModel
(
this
,
dataSet
);
if
(
dataSet
.
getPSDEDataQueries
()
!=
null
)
{
DataSetModel
dsModel
=
new
DataSetModel
(
this
,
dataSet
);
dsModel
.
setDatasetId
(
dataSet
.
getCodeName
())
.
setDatasetName
(
dataSet
.
getLogicName
()).
setCodeName
(
dataSet
.
getCodeName
()).
setSelect
(
select
).
setFrom
(
from
).
setGroupBy
(
groupBy
);
this
.
addDataSet
(
dsModel
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
dataSet
.
getPSDEDataQueries
().
forEach
(
dataQuery
->
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
dataSet
.
getPSDEDataQueries
().
forEach
(
dataQuery
->
{
try
{
if
(
dataQuery
.
getAllPSDEDataQueryCodes
()!=
null
)
{
if
(
dataQuery
.
getAllPSDEDataQueryCodes
()
!=
null
)
{
dsModel
.
addQueries
(
dataQuery
.
getCodeName
());
dataQuery
.
getAllPSDEDataQueryCodes
().
forEach
(
dq
->
{
String
code
=
""
;
if
(!
map
.
containsKey
(
dq
.
getDBType
()))
{
dataQuery
.
getAllPSDEDataQueryCodes
().
forEach
(
dq
->
{
String
code
=
""
;
if
(!
map
.
containsKey
(
dq
.
getDBType
()))
{
map
.
put
(
dq
.
getDBType
(),
""
);
code
=
""
;
}
else
{
code
=
""
;
}
else
{
code
=
map
.
get
(
dq
.
getDBType
());
code
=
code
+
"\r\n union all \r\n"
;
code
=
code
+
"\r\n union all \r\n"
;
}
code
=
code
+
TransUtils
.
getQueryCode
(
dq
);
code
=
code
+
TransUtils
.
getQueryCode
(
dq
);
;
//"<include refid=\""+this.getEntityName().toLowerCase()+"_dq_"+dataQuery.getCodeName()+"_"+dq.getDBType().toLowerCase()+"\"/>";
map
.
put
(
dq
.
getDBType
(),
"select t1.* from ("
+
code
+
") t1"
);
map
.
put
(
dq
.
getDBType
(),
"select t1.* from ("
+
code
+
") t1"
);
});
}
}
catch
(
Exception
exception
)
{
...
...
@@ -987,30 +881,27 @@ public class EntityModel extends BaseModel {
});
for
(
Map
.
Entry
<
String
,
String
>
entry:
map
.
entrySet
())
{
if
(
dataSet
.
getMajorSortPSDEField
()!=
null
)
{
IPSDEFDTColumn
column
=
dataSet
.
getMajorSortPSDEField
().
getPSDEFDTColumn
(
entry
.
getKey
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
),
false
);
for
(
Map
.
Entry
<
String
,
String
>
entry
:
map
.
entrySet
())
{
if
(
dataSet
.
getMajorSortPSDEField
()
!=
null
)
{
IPSDEFDTColumn
column
=
dataSet
.
getMajorSortPSDEField
().
getPSDEFDTColumn
(
entry
.
getKey
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
),
false
);
orderBy
=
" order by "
.
concat
(
column
==
null
?
dataSet
.
getMajorSortPSDEField
().
getName
():
column
.
getColumnName
());
if
(!
StringUtils
.
isEmpty
(
dataSet
.
getMajorSortDir
()))
orderBy
=
orderBy
.
concat
(
" "
).
concat
(
dataSet
.
getMajorSortDir
());
if
(
dataSet
.
getMinorSortPSDEField
()!=
null
)
{
IPSDEFDTColumn
subCol
=
dataSet
.
getMinorSortPSDEField
().
getPSDEFDTColumn
(
entry
.
getKey
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
),
false
);
orderBy
=
" order by "
.
concat
(
column
==
null
?
dataSet
.
getMajorSortPSDEField
().
getName
()
:
column
.
getColumnName
());
if
(!
StringUtils
.
isEmpty
(
dataSet
.
getMajorSortDir
()))
orderBy
=
orderBy
.
concat
(
" "
).
concat
(
dataSet
.
getMajorSortDir
());
if
(
dataSet
.
getMinorSortPSDEField
()
!=
null
)
{
IPSDEFDTColumn
subCol
=
dataSet
.
getMinorSortPSDEField
().
getPSDEFDTColumn
(
entry
.
getKey
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
),
false
);
orderBy
=
orderBy
.
concat
(
","
).
concat
(
subCol
==
null
?
dataSet
.
getMinorSortPSDEField
().
getName
():
subCol
.
getColumnName
());
if
(!
StringUtils
.
isEmpty
(
dataSet
.
getMinorSortDir
()))
orderBy
=
orderBy
.
concat
(
" "
).
concat
(
dataSet
.
getMinorSortDir
());
orderBy
=
orderBy
.
concat
(
","
).
concat
(
subCol
==
null
?
dataSet
.
getMinorSortPSDEField
().
getName
()
:
subCol
.
getColumnName
());
if
(!
StringUtils
.
isEmpty
(
dataSet
.
getMinorSortDir
()))
orderBy
=
orderBy
.
concat
(
" "
).
concat
(
dataSet
.
getMinorSortDir
());
}
}
String
sqlFormat
=
select
.
concat
(
from
).
concat
(
where
==
null
?
""
:
where
).
concat
(
groupBy
==
null
?
""
:
groupBy
).
concat
(
orderBy
==
null
?
""
:
orderBy
);
DataSetModel
dqModel
=
new
DataSetModel
(
this
,
dataSet
);
dqModel
.
setDatasetId
(
this
.
getEntityName
().
toLowerCase
()
+
"-ds-"
+
dataSet
.
getCodeName
()+
"-"
+
entry
.
getKey
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
))
.
setDsType
(
entry
.
getKey
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
))
String
sqlFormat
=
select
.
concat
(
from
).
concat
(
where
==
null
?
""
:
where
).
concat
(
groupBy
==
null
?
""
:
groupBy
).
concat
(
orderBy
==
null
?
""
:
orderBy
);
DataSetModel
dqModel
=
new
DataSetModel
(
this
,
dataSet
);
dqModel
.
setDatasetId
(
this
.
getEntityName
().
toLowerCase
()
+
"-ds-"
+
dataSet
.
getCodeName
()
+
"-"
+
entry
.
getKey
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
))
.
setDsType
(
entry
.
getKey
().
toLowerCase
().
replace
(
"mysql5"
,
"mysql"
))
.
setDatasetName
(
dataSet
.
getLogicName
()).
setCodeName
(
dataSet
.
getCodeName
())
.
setDsCode
(
entry
.
getValue
()).
setDsModel
(
sqlFormat
);
this
.
addQueries
(
dqModel
);
...
...
@@ -1019,14 +910,12 @@ public class EntityModel extends BaseModel {
}
}
}
catch
(
Exception
exception
)
{
}
});
...
...
@@ -1040,15 +929,23 @@ public class EntityModel extends BaseModel {
}
if
(
this
.
getDataEntity
().
getAllPSDEActions
()!=
null
)
{
this
.
getDataEntity
().
getAllPSDEActions
().
forEach
(
item
->{
String
tag
=
item
.
getCodeName
().
toLowerCase
();
addAction
(
new
ActionModel
(
this
,
item
));
if
(
this
.
getDataEntity
().
getAllPSDEActions
()
!=
null
)
{
this
.
getDataEntity
().
getAllPSDEActions
().
forEach
(
item
->
{
String
tag
=
item
.
getCodeName
().
toLowerCase
();
addAction
(
new
ActionModel
(
this
,
item
));
});
}
//外部接口实体
if
(
this
.
getDataEntity
().
getPSSubSysServiceAPI
()
!=
null
&&
this
.
getDataEntity
().
getPSSubSysServiceAPIDE
()
!=
null
)
{
if
(
this
.
getSystem
().
getClientMap
().
containsKey
(
this
.
getDataEntity
().
getPSSubSysServiceAPI
().
getCodeName
()))
{
ClientModel
clientModel
=
this
.
getSystem
().
getClientMap
().
get
(
this
.
getDataEntity
().
getPSSubSysServiceAPI
().
getCodeName
());
if
(
clientModel
.
getClientEntityMap
().
containsKey
(
this
.
getDataEntity
().
getPSSubSysServiceAPIDE
().
getCodeName
()))
{
clientEntityModel
=
clientModel
.
getClientEntityMap
().
get
(
this
.
getDataEntity
().
getPSSubSysServiceAPIDE
().
getCodeName
());
}
}
}
}
}
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
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录