Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz4j Spring R7
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7后台标准模板
iBiz4j Spring R7
提交
f848b13f
提交
f848b13f
编写于
11月 09, 2020
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
差异文件
合并分支 'dev' 到 'master'
Dev 查看合并请求
!34
上级
f4b459bf
317ccd47
变更
19
隐藏空白字符变更
内嵌
并排
正在显示
19 个修改的文件
包含
507 行增加
和
76 行删除
+507
-76
CHANGELOG.md
CHANGELOG.md
+8
-0
application-dev.yml.ftl
SLN/%PUBPRJ%-boot/src/main/resources/application-dev.yml.ftl
+56
-56
%DE%.java.ftl
...ava/%SYS_PKGPATH%/core/%MOD_PKGPATH%/domain/%DE%.java.ftl
+13
-0
I%DE%Service.java.ftl
...PKGPATH%/core/%MOD_PKGPATH%/service/I%DE%Service.java.ftl
+4
-4
%DE%ServiceImpl.java.ftl
.../core/%MOD_PKGPATH%/service/impl/%DE%ServiceImpl.java.ftl
+39
-2
%ITEM%JobHandler.java.ftl
...ava/%SYS_PKGPATH%/core/util/job/%ITEM%JobHandler.java.ftl
+24
-2
%SYS%.json.ftl
SLN/%PUBPRJ%-core/src/main/resources/sysmodel/%SYS%.json.ftl
+1
-1
RuntimeDict.json.ftl
...RJ%-core/src/main/resources/sysmodel/RuntimeDict.json.ftl
+45
-0
pom.xml.ftl
SLN/%PUBPRJ%-dependencies/pom.xml.ftl
+10
-6
DEField.java.ftl
.../main/java/%SYS_PKGPATH%/util/annotation/DEField.java.ftl
+10
-0
DupCheckAspect.java.ftl
...in/java/%SYS_PKGPATH%/util/aspect/DupCheckAspect.java.ftl
+162
-0
ESAspect.java.ftl
...src/main/java/%SYS_PKGPATH%/util/aspect/ESAspect.java.ftl
+2
-2
IBZDictFallback.java.ftl
...n/java/%SYS_PKGPATH%/util/client/IBZDictFallback.java.ftl
+26
-0
IBZDictFeignClient.java.ftl
...ava/%SYS_PKGPATH%/util/client/IBZDictFeignClient.java.ftl
+32
-0
EntityClient.java.ftl
...main/java/%SYS_PKGPATH%/util/domain/EntityClient.java.ftl
+1
-1
DupCheck.java.ftl
.../src/main/java/%SYS_PKGPATH%/util/enums/DupCheck.java.ftl
+26
-0
ExceptionTranslator.java.ftl
...va/%SYS_PKGPATH%/util/errors/ExceptionTranslator.java.ftl
+11
-2
PermissionSyncJob.java.ftl
...in/java/%SYS_PKGPATH%/util/job/PermissionSyncJob.java.ftl
+28
-0
AppController.java.ftl
.../main/java/%SYS_PKGPATH%/util/rest/AppController.java.ftl
+9
-0
未找到文件。
CHANGELOG.md
浏览文件 @
f848b13f
# **iBiz4j Spring R7 Template ChangeLog**
## [v2020.11.09]
-
支持属性重复值检查
-
支持引用组件包配置
-
支持定时任务中调用实体行为
-
修复serviceApi实体update脏检查处理
-
添加全局异常处理,数据库级异常补充errorKey
-
补充appData user扩展
-
系统预定义代码表推送RT
## [v2020.10.28]
-
修复虚拟联合主键模板错误
...
...
SLN/%PUBPRJ%-boot/src/main/resources/application-dev.yml.ftl
浏览文件 @
f848b13f
...
...
@@ -52,10 +52,10 @@ zuul:
<#assign serviceUrl=srfpluralize(appDataEntity.name?lower_case)>
<#if serviceId!="">
<#assign serviceId="$"+"{ibiz.ref.service."+serviceId?lower_case+":"+serviceId+"}">
${appEntity}:
path: /${serviceUrl}/**
serviceId: ${serviceId}
stripPrefix: false
${appEntity}:
path: /${serviceUrl}/**
serviceId: ${serviceId}
stripPrefix: false
</#if>
</#if>
</#list>
...
...
@@ -66,59 +66,59 @@ zuul:
stripPrefix: true
</#if>
<#if sys.getPSSystemSetting()?? && sys.getPSSystemSetting().getDataAccCtrlArch()?? && sys.getPSSystemSetting().getDataAccCtrlArch()==1>
loginv7:
path: /v7/login
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
changepwd:
path: /v7/changepwd
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
uaa:
path: /uaa/**
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
config:
path: /configs/**
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
loginv7:
path: /v7/login
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
changepwd:
path: /v7/changepwd
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
uaa:
path: /uaa/**
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
config:
path: /configs/**
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
<#if sys.getCodeName()!='ibzou' && sys.getCodeName()!='ibzrt'>
oucore:
path: /ibzorganizations/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
oudict:
path: /dictionarys/**/Ibzou**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
ou:
path: /ibzdepartments/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
uaadict:
path: /dictionarys/**/SysOperator
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
dict:
path: /dictionarys/**
serviceId: ${r'${ibiz.ref.service.dict:ibzdict-api}'}
stripPrefix: false
disk:
path: /net-disk/**
serviceId: ${r'${ibiz.ref.service.disk:ibzdisk-api}'}
stripPrefix: false
ou_sys_org:
path: /sysorganizations/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
ou_sys_dept:
path: /sysdepartments/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
lite-core:
path: /lite/**
serviceId: ${r'${ibiz.ref.service.lite:ibzlite-api}'}
stripPrefix: false
oucore:
path: /ibzorganizations/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
oudict:
path: /dictionarys/**/Ibzou**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
ou:
path: /ibzdepartments/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
uaadict:
path: /dictionarys/**/SysOperator
serviceId: ${r'${ibiz.ref.service.uaa:ibzuaa-api}'}
stripPrefix: false
dict:
path: /dictionarys/**
serviceId: ${r'${ibiz.ref.service.dict:ibzdict-api}'}
stripPrefix: false
disk:
path: /net-disk/**
serviceId: ${r'${ibiz.ref.service.disk:ibzdisk-api}'}
stripPrefix: false
ou_sys_org:
path: /sysorganizations/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
ou_sys_dept:
path: /sysdepartments/**
serviceId: ${r'${ibiz.ref.service.ou:ibzou-api}'}
stripPrefix: false
lite-core:
path: /lite/**
serviceId: ${r'${ibiz.ref.service.lite:ibzlite-api}'}
stripPrefix: false
</#if>
</#if>
<#comment>通过设置该参数,避免Zuul转发请求时丢失Authorization请求头信息</#comment>
...
...
SLN/%PUBPRJ%-core/src/main/java/%SYS_PKGPATH%/core/%MOD_PKGPATH%/domain/%DE%.java.ftl
浏览文件 @
f848b13f
...
...
@@ -23,6 +23,7 @@ import ${pub.getPKGCodeName()}.util.annotation.DEField;
import
${
pub
.
getPKGCodeName
()}.
util
.
enums
.
DEPredefinedFieldType
;
import
${
pub
.
getPKGCodeName
()}.
util
.
enums
.
DEFieldDefaultValueType
;
import
${
pub
.
getPKGCodeName
()}.
util
.
helper
.
DataObject
;
import
${
pub
.
getPKGCodeName
()}.
util
.
enums
.
DupCheck
;
import
java
.
io
.
Serializable
;
import
lombok
.*;
import
org
.
springframework
.
data
.
annotation
.
Transient
;
...
...
@@ -114,6 +115,18 @@ public class ${item.getCodeName()} extends EntityMP implements Serializable {
</#
if
>
</#
if
>
</#
if
>
<#
comment
>
重复值检查
</#
comment
>
<#
if
defield
.
getDupCheckMode
??
&&
defield
.
getDupCheckMode
()??
&&
defield
.
getDupCheckMode
()==
'ALL'
>
<#
if
defieldano
??
&&
defieldano
!='' >
<#
assign
defieldano
=
defieldano
+
" , "
>
</#
if
>
<#
if
defield
.
getDupCheckPSDEField
??
&&
defield
.
getDupCheckPSDEField
()??>
<#
assign
dupCheckField
=
srfcaseformat
(
defield
.
getDupCheckPSDEField
().
getCodeName
(),
'l_u2lC'
)
>
<#
assign
defieldano
=
defieldano
+
"dupCheck = DupCheck.ALL , dupCheckField=
\"
"
+
dupCheckField
+
"
\"
"
>
<#
else
>
<#
assign
defieldano
=
defieldano
+
"dupCheck = DupCheck.ALL"
>
</#
if
>
</#
if
>
/**
*
${
defield
.
getLogicName
()}
*/
...
...
SLN/%PUBPRJ%-core/src/main/java/%SYS_PKGPATH%/core/%MOD_PKGPATH%/service/I%DE%Service.java.ftl
浏览文件 @
f848b13f
...
...
@@ -38,7 +38,7 @@ import ${pub.getPKGCodeName()}.core.${de.getPSSystemModule().getCodeName()?lower
<#
comment
>
SQL
存储
-
Mybatis
</#
comment
>
<#
if
de
.
getStorageMode
()==
1
>
<#
assign
keyfield
=
item
.
getKeyPSDEField
()>
import
com
.
baomidou
.
mybatisplus
.
extension
.
service
.
IService
;
/**
...
...
@@ -63,13 +63,13 @@ public interface I${item.codeName}Service extends IService<${item.codeName}>{
boolean
execute
(
String
sql
,
Map
param
);
<#
if
hasDEPrefield
>
List
<${
de
.
codeName
}>
get
${
deCodeNameCamel
}
ByIds
(
List
<
String
>
ids
)
;
List
<${
de
.
codeName
}>
get
${
deCodeNameCamel
}
ByIds
(
List
<
${
srfr7javatype
(
keyfield
.
stdDataType
)}
>
ids
)
;
List
<${
de
.
codeName
}>
get
${
deCodeNameCamel
}
ByEntities
(
List
<${
de
.
codeName
}>
entities
)
;
</#
if
>
}
<#
comment
>
NoSQL
存储
-
MongoDB
</#
comment
>
<#
elseif
de
.
getStorageMode
()==
2
>
<#
assign
keyfield
=
item
.
getKeyPSDEField
()>
/**
*
实体
[${
item
.
codeName
}]
服务对象接口
*/
...
...
@@ -78,7 +78,7 @@ public interface I${item.codeName}Service{
<@
addIDESerivceBody
/>
<#
if
hasDEPrefield
>
List
<${
de
.
codeName
}>
get
${
deCodeNameCamel
}
ByIds
(
List
<
String
>
ids
)
;
List
<${
de
.
codeName
}>
get
${
deCodeNameCamel
}
ByIds
(
List
<
${
srfr7javatype
(
keyfield
.
stdDataType
)}
>
ids
)
;
List
<${
de
.
codeName
}>
get
${
deCodeNameCamel
}
ByEntities
(
List
<${
de
.
codeName
}>
entities
)
;
</#
if
>
}
...
...
SLN/%PUBPRJ%-core/src/main/java/%SYS_PKGPATH%/core/%MOD_PKGPATH%/service/impl/%DE%ServiceImpl.java.ftl
浏览文件 @
f848b13f
...
...
@@ -66,6 +66,7 @@ TARGET=PSDATAENTITY
<#
break
>
</#
list
>
</#
if
>
<#
assign
isDupCheck
=
isDupCheckEntity
(
de
)>
package
${
pub
.
getPKGCodeName
()}.
core
.${
item
.
getPSSystemModule
().
getCodeName
()?
lower_case
}.
service
.
impl
;
import
java
.
io
.
Serializable
;
...
...
@@ -881,7 +882,7 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#
if
hasDEPrefield
>
@
Override
public
List
<${
de
.
codeName
}>
get
${
deCodeNameCamel
}
ByIds
(
List
<
String
>
ids
)
{
public
List
<${
de
.
codeName
}>
get
${
deCodeNameCamel
}
ByIds
(
List
<
${
srfr7javatype
(
keyfield
.
stdDataType
)}
>
ids
)
{
return
this
.
listByIds
(
ids
);
}
...
...
@@ -962,6 +963,9 @@ public class ${item.getCodeName()}ServiceImpl extends ServiceImpl<${de.getCodeNa
<#
comment
>
发布
es
服务对象
</#
comment
>
<@
esAnno
/>
<#
comment
>
重复值检查
-
searchContext
</#
comment
>
<@
outputSearchContext
/>
}
<#
comment
>
NOSQL
存储
</#
comment
>
...
...
@@ -1422,7 +1426,7 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#
if
hasDEPrefield
>
@
Override
public
List
<${
de
.
codeName
}>
get
${
deCodeNameCamel
}
ByIds
(
List
<
String
>
ids
)
{
public
List
<${
de
.
codeName
}>
get
${
deCodeNameCamel
}
ByIds
(
List
<
${
srfr7javatype
(
keyfield
.
stdDataType
)}
>
ids
)
{
QueryBuilder
permissionCond
=
new
QueryBuilder
();
permissionCond
.
and
(
"${keyfield.codeName?lower_case}"
).
in
(
ids
);
Query
query
=
new
BasicQuery
(
permissionCond
.
get
().
toString
());
...
...
@@ -1455,6 +1459,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#
comment
>
发布
es
服务对象
</#
comment
>
<@
esAnno
/>
<#
comment
>
重复值检查
-
SearchContext
</#
comment
>
<@
outputSearchContext
/>
}
...
...
@@ -1965,6 +1972,9 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
<#
comment
>
实体数据导入
</#
comment
>
<@
deImportData
/>
<#
comment
>
重复值检查
-
SearchContext
</#
comment
>
<@
outputSearchContext
/>
}
<#
comment
>
无存储
</#
comment
>
...
...
@@ -2955,4 +2965,31 @@ public class ${item.getCodeName()}ServiceImpl implements I${de.getCodeName()}Ser
</#
macro
>
<#
comment
>
输出
SearchContext
,用于属性重复值检查
</#
comment
>
<#
macro
outputSearchContext
>
<#
if
isDupCheck
>
/**
*
获取
searchContext
*
@
return
*/
public
${
de
.
codeName
}
SearchContext
getSearchContext
(){
return
new
${
de
.
codeName
}
SearchContext
();
}
</#
if
>
</#
macro
>
<#
comment
>
判断属性是否配置了重复值检查
</#
comment
>
<#
function
isDupCheckEntity
dataEntity
>
<#
assign
dupCheck
=
false
>
<#
if
dataEntity
.
getAllPSDEFields
()??>
<#
list
dataEntity
.
getAllPSDEFields
()
as
defield
>
<#
if
defield
.
getDupCheckMode
??
&&
defield
.
getDupCheckMode
()??
&&
defield
.
getDupCheckMode
()==
'ALL'
>
<#
assign
dupCheck
=
true
>
<#
break
>
</#
if
>
</#
list
>
</#
if
>
<#
return
dupCheck
>
</#
function
>
</#
if
>
SLN/%PUBPRJ%-core/src/main/java/%SYS_PKGPATH%/core/util/job/%ITEM%JobHandler.java.ftl
浏览文件 @
f848b13f
...
...
@@ -7,13 +7,35 @@ import com.baomidou.jobs.api.JobsResponse;
import
com
.
baomidou
.
jobs
.
exception
.
JobsException
;
import
com
.
baomidou
.
jobs
.
handler
.
IJobsHandler
;
import
org
.
springframework
.
stereotype
.
Component
;
import
org
.
springframework
.
beans
.
factory
.
annotation
.
Autowired
;
import
org
.
springframework
.
context
.
annotation
.
Lazy
;
import
lombok
.
extern
.
slf4j
.
Slf4j
;
<#
assign
hasDEAction
=
false
>
<#
if
item
.
getPSDataEntity
??
&&
item
.
getPSDataEntity
()??
&&
item
.
getPSDEAction
??
&&
item
.
getPSDEAction
()??>
<#
assign
hasDEAction
=
true
>
<#
assign
de
=
item
.
getPSDataEntity
()>
<#
assign
deaction
=
item
.
getPSDEAction
()>
</#
if
>
@
Slf4j
@
Component
(
"${item.codeName}JobHandler"
)
public
class
${
item
.
codeName
}
JobHandler
implements
IJobsHandler
{
public
class
${
item
.
codeName
}
JobHandler
implements
IJobsHandler
{
<#
if
hasDEAction
>
@
Autowired
@
Lazy
protected
${
pub
.
getPKGCodeName
()}.
core
.${
de
.
getPSSystemModule
().
getCodeName
()?
lower_case
}.
service
.
I
${
de
.
getCodeName
()}
Service
${
srfcaseformat
(
de
.
getCodeName
(),
'l_u2lC'
)}
Service
;
</#
if
>
@
Override
public
JobsResponse
execute
(
String
tenantId
,
String
param
)
throws
JobsException
{
System
.
out
.
println
(
"执行 DemoJobHandler tenantId="
+
tenantId
+
",param="
+
param
);
<#
if
hasDEAction
>
${
pub
.
getPKGCodeName
()}.
core
.${
de
.
getPSSystemModule
().
getCodeName
()?
lower_case
}.
domain
.${
de
.
codeName
}
entity
=
new
${
pub
.
getPKGCodeName
()}.
core
.${
de
.
getPSSystemModule
().
getCodeName
()?
lower_case
}.
domain
.${
de
.
codeName
}();
entity
.
set
(
"tenantid"
,
tenantId
);
entity
.
set
(
"param"
,
param
);
${
srfcaseformat
(
de
.
getCodeName
(),
'l_u2lC'
)}
Service
.${
srfmethodname
(
deaction
.
getCodeName
())}(
entity
);
</#
if
>
log
.
info
(
"执行 DemoJobHandler tenantId="
+
tenantId
+
",param="
+
param
);
return
JobsResponse
.
ok
();
}
}
SLN/%PUBPRJ%-core/src/main/resources/sysmodel/%SYS%.json.ftl
浏览文件 @
f848b13f
...
...
@@ -45,7 +45,7 @@ TARGET=PSSYSTEM
<#if defield.getPrecision()?c!='0'>
"data_preci":${defield.getPrecision()?c},
</#if>
<#if defield.getDefaultPSDEFDTColumn()?? && defield.getDefaultPSDEFDTColumn().isFormula()==true>
<#if defield.getDefaultPSDEFDTColumn
?? && defield.getDefaultPSDEFDTColumn
()?? && defield.getDefaultPSDEFDTColumn().isFormula()==true>
"expression":"${defield.getDefaultPSDEFDTColumn().getFormulaFormat()}",
</#if>
<#if defield.getPredefinedType()?? && defield.getPredefinedType()!=''>
...
...
SLN/%PUBPRJ%-core/src/main/resources/sysmodel/RuntimeDict.json.ftl
0 → 100644
浏览文件 @
f848b13f
<#ibiztemplate>
TARGET=PSSYSTEM
</#ibiztemplate>
<#comment>系统是否包含预定义代码表</#comment>
<#assign hasPredefinedCodeList=false>
<#list sys.getAllPSCodeLists() as codelist>
<#if codelist.getPredefinedType()?? && codelist.getPredefinedType()=='RUNTIME'>
<#assign hasPredefinedCodeList=true>
<#break>
</#if>
</#list>
<#if hasPredefinedCodeList>
<#assign isFirstCodeList=true>
[ <#list sys.getAllPSCodeLists() as codelist>
<#if codelist.getPredefinedType()?? && codelist.getPredefinedType()=='RUNTIME'>
<#if isFirstCodeList==false>,</#if>
{
"name":"${codelist.name}",
"code":"${codelist.codeName}",
"group":"",
"memo":"",
"enable":"",
<#if codelist.getAllPSCodeItems()??>
"items":[<#list codelist.getAllPSCodeItems() as codeItem>
{
"catalog_id":"${codelist.codeName}",
"catalog_name":"${codelist.name}",
"value_key":"${codelist.codeName}-${codeItem.codeName}",
"value":"${codeItem.value}",
"label":"${codeItem.text}",
"disabled":"",
"showorder":""
<#if codeItem.getParentCodeItem?? && codeItem.getParentCodeItem()??>
,"parent":"${codeItem.getParentCodeItem().value}"
</#if>
}<#if codeItem_has_next>,</#if>
</#list>
]
</#if>
}
<#assign isFirstCodeList=false>
</#if>
</#list>
]
</#if>
\ No newline at end of file
SLN/%PUBPRJ%-dependencies/pom.xml.ftl
浏览文件 @
f848b13f
...
...
@@ -270,12 +270,6 @@ TARGET=PSSYSTEM
<version>${r'${jsonwebtoken-jjwt.version}'}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${r'${alibaba-druid.version}'}</version>
</dependency>
<dependency>
<groupId>org.zalando</groupId>
<artifactId>problem-spring-web</artifactId>
...
...
@@ -435,6 +429,16 @@ TARGET=PSSYSTEM
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
</#if>
<#comment>引用组件包</#comment>
<#if pub.getPSSysSFPubPkgs?? && pub.getPSSysSFPubPkgs()??>
<#list pub.getPSSysSFPubPkgs() as package>
<#if package.getPkgParam?? && package.getPkgParam()??>
${package.getPkgParam()}
</#if>
</#list>
</#if>
</dependencies>
</project>
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/annotation/DEField.java.ftl
浏览文件 @
f848b13f
...
...
@@ -5,6 +5,7 @@ package ${pub.getPKGCodeName()}.util.annotation;
import
${
pub
.
getPKGCodeName
()}.
util
.
enums
.
DEFieldDefaultValueType
;
import
${
pub
.
getPKGCodeName
()}.
util
.
enums
.
DEPredefinedFieldType
;
import
${
pub
.
getPKGCodeName
()}.
util
.
enums
.
DupCheck
;
import
java
.
lang
.
annotation
.
ElementType
;
import
java
.
lang
.
annotation
.
Retention
;
import
java
.
lang
.
annotation
.
RetentionPolicy
;
...
...
@@ -69,5 +70,14 @@ public @interface DEField
*
@
return
*/
String
format
()
default
""
;
/**
*
重复性检查
*
@
return
*/
DupCheck
dupCheck
()
default
DupCheck
.
NONE
;
/**
*
范围属性
*/
String
dupCheckField
()
default
""
;
}
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/aspect/DupCheckAspect.java.ftl
0 → 100644
浏览文件 @
f848b13f
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
<#
assign
hasDupCheckEntity
=
false
>
<#
list
sys
.
getAllPSDataEntities
()
as
dataEntity
>
<#
assign
isDupCheck
=
isDupCheckEntity
(
dataEntity
)>
<#
if
isDupCheck
>
<#
assign
hasDupCheckEntity
=
true
>
<#
break
>
</#
if
>
</#
list
>
<#
if
hasDupCheckEntity
>
package
${
pub
.
getPKGCodeName
()}.
util
.
aspect
;
import
lombok
.
extern
.
slf4j
.
Slf4j
;
import
${
pub
.
getPKGCodeName
()}.
util
.
annotation
.
DEField
;
import
${
pub
.
getPKGCodeName
()}.
util
.
enums
.
DupCheck
;
import
${
pub
.
getPKGCodeName
()}.
util
.
errors
.
BadRequestAlertException
;
import
${
pub
.
getPKGCodeName
()}.
util
.
filter
.
QueryFilter
;
import
${
pub
.
getPKGCodeName
()}.
util
.
filter
.
SearchContextBase
;
import
${
pub
.
getPKGCodeName
()}.
util
.
helper
.
DEFieldCacheMap
;
import
org
.
aspectj
.
lang
.
JoinPoint
;
import
org
.
aspectj
.
lang
.
annotation
.
AfterReturning
;
import
org
.
aspectj
.
lang
.
annotation
.
Aspect
;
import
org
.
springframework
.
data
.
domain
.
Page
;
import
org
.
springframework
.
expression
.
EvaluationContext
;
import
org
.
springframework
.
expression
.
Expression
;
import
org
.
springframework
.
expression
.
ExpressionParser
;
import
org
.
springframework
.
expression
.
spel
.
standard
.
SpelExpressionParser
;
import
org
.
springframework
.
expression
.
spel
.
support
.
StandardEvaluationContext
;
import
org
.
springframework
.
stereotype
.
Component
;
import
org
.
springframework
.
util
.
ObjectUtils
;
import
org
.
springframework
.
util
.
StringUtils
;
import
java
.
util
.
Map
;
/**
*
属性重复值检查切面
*/
@
Aspect
@
Component
@
Slf4j
public
class
DupCheckAspect
{
private
final
ExpressionParser
parser
=
new
SpelExpressionParser
();
<#
list
sys
.
getAllPSDataEntities
()
as
dataEntity
>
<#
assign
isDupCheck
=
isDupCheckEntity
(
dataEntity
)>
<#
assign
hasDefaultDS
=
checkDefaultDS
(
dataEntity
)>
<#
if
isDupCheck
&&
hasDefaultDS
>
/**
*
实体
[${
dataEntity
.
codeName
}]
*
*
@
param
point
*/
@
AfterReturning
(
value
=
"(execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.create*(..))||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.update*(..))||execution(* ${pub.getPKGCodeName()}.core.*.service.*${dataEntity.codeName}*.save*(..)) ) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.create*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.update*(..)) && !execution(* ${pub.getPKGCodeName()}.core.es.service.*.save*(..)) "
)
public
void
check
${
dataEntity
.
codeName
?
lower_case
?
cap_first
}(
JoinPoint
point
)
{
check
(
point
,
"search${dataEntity.getDefaultPSDEDataSet().codeName}"
);
}
</#
if
>
</#
list
>
/**
*
实体属性重复值检查
*
@
param
point
切点
*
@
param
defaultDS
实体默认数据集名称
*/
private
void
check
(
JoinPoint
point
,
String
defaultDS
)
{
Object
[]
args
=
point
.
getArgs
();
if
(
args
.
length
>
0
)
{
Object
entity
=
args
[
0
];
Object
service
=
point
.
getTarget
();
Map
<
String
,
DEField
>
deFields
=
DEFieldCacheMap
.
getDEFields
(
entity
.
getClass
());
for
(
Map
.
Entry
<
String
,
DEField
>
deField
:
deFields
.
entrySet
())
{
String
fieldName
=
deField
.
getKey
();
DEField
fieldAnnotation
=
deField
.
getValue
();
DupCheck
dupCheck
=
fieldAnnotation
.
dupCheck
();
String
dupCheckField
=
fieldAnnotation
.
dupCheckField
();
if
(
dupCheck
==
DupCheck
.
ALL
)
{
Object
newValue
=
getDEFieldValue
(
entity
,
fieldName
);
//
获取
searchContext
EvaluationContext
searchContextCtx
=
new
StandardEvaluationContext
();
searchContextCtx
.
setVariable
(
"service"
,
service
);
Expression
searchContextExp
=
parser
.
parseExpression
(
"#service.getSearchContext()"
);
SearchContextBase
searchContext
=
searchContextExp
.
getValue
(
searchContextCtx
,
SearchContextBase
.
class
);
//
设置检查属性值
QueryFilter
filter
=
new
QueryFilter
();
setValue
(
entity
,
filter
,
fieldName
,
newValue
);
//
设定重复值检查范围
if
(
!StringUtils.isEmpty(dupCheckField)){
Object
dupFieldValue
=
getDEFieldValue
(
entity
,
dupCheckField
);
setValue
(
entity
,
filter
,
dupCheckField
,
dupFieldValue
);
}
searchContext
.
setFilter
(
filter
);
//
使用当前值到数据库中进行查询,判断是否重复
EvaluationContext
oldValueMappingCtx
=
new
StandardEvaluationContext
();
oldValueMappingCtx
.
setVariable
(
"service"
,
service
);
oldValueMappingCtx
.
setVariable
(
"searchContext"
,
searchContext
);
Expression
oldValueMappingExp
=
parser
.
parseExpression
(
String
.
format
(
"#service.%s(#searchContext)"
,
defaultDS
));
Page
oldData
=
oldValueMappingExp
.
getValue
(
oldValueMappingCtx
,
Page
.
class
);
if
(
!ObjectUtils.isEmpty(oldData) && !ObjectUtils.isEmpty(oldData.getContent()) && oldData.getContent().size() > 1) {
throw
new
BadRequestAlertException
(
String
.
format
(
"数据保存失败,属性[%s]:值[%s]已存在!"
,
fieldName
,
newValue
),
"DupCheckAspect"
,
"DupCheck"
);
}
}
}
}
}
/**
*
获取实体属性值
*
@
param
entity
*
@
param
fieldName
*
@
return
*/
private
Object
getDEFieldValue
(
Object
entity
,
String
fieldName
){
EvaluationContext
exMappingCtx
=
new
StandardEvaluationContext
();
exMappingCtx
.
setVariable
(
"entity"
,
entity
);
Expression
esMappingExp
=
parser
.
parseExpression
(
String
.
format
(
"#entity.get(
\"
%s
\"
)"
,
fieldName
));
return
esMappingExp
.
getValue
(
exMappingCtx
);
}
/**
*
设置
filter
*
@
param
entity
*
@
param
filter
*
@
param
value
*/
private
void
setValue
(
Object
entity
,
QueryFilter
filter
,
String
fieldName
,
Object
value
){
if
(
ObjectUtils
.
isEmpty
(
value
))
filter
.
isnull
(
DEFieldCacheMap
.
getFieldColumnName
(
entity
.
getClass
(),
fieldName
));
else
filter
.
eq
(
DEFieldCacheMap
.
getFieldColumnName
(
entity
.
getClass
(),
fieldName
),
value
);
}
}
</#
if
>
<#
comment
>
判断属性是否配置了重复值检查
</#
comment
>
<#
function
isDupCheckEntity
dataEntity
>
<#
assign
dupCheck
=
false
>
<#
if
dataEntity
.
getAllPSDEFields
()??>
<#
list
dataEntity
.
getAllPSDEFields
()
as
defield
>
<#
if
defield
.
getDupCheckMode
??
&&
defield
.
getDupCheckMode
()??
&&
defield
.
getDupCheckMode
()==
'ALL'
>
<#
assign
dupCheck
=
true
>
<#
break
>
</#
if
>
</#
list
>
</#
if
>
<#
return
dupCheck
>
</#
function
>
<#
comment
>
判断实体中是否配置了默认数据集
</#
comment
>
<#
function
checkDefaultDS
dataEntity
>
<#
assign
defaultDS
=
false
>
<#
if
dataEntity
.
getDefaultPSDEDataSet
??
&&
dataEntity
.
getDefaultPSDEDataSet
()??
&&
dataEntity
.
getDefaultPSDEDataSet
().
getPSDEDataQueries
()??>
<#
list
dataEntity
.
getDefaultPSDEDataSet
().
getPSDEDataQueries
()
as
dq
>
<#
assign
defaultDS
=
true
>
<#
break
>
</#
list
>
</#
if
>
<#
return
defaultDS
>
</#
function
>
\ No newline at end of file
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/aspect/ESAspect.java.ftl
浏览文件 @
f848b13f
<#
ibiztemplate
>
TARGET
=
PS
DATAENTITY
TARGET
=
PS
SYSTEM
</#
ibiztemplate
>
<#
assign
hasESEntity
=
false
>
<#
list
sys
.
getAllPSDataEntities
()
as
dataEntity
>
...
...
@@ -9,7 +9,7 @@ TARGET=PSDATAENTITY
</#
if
>
</#
list
>
<#
if
hasESEntity
==
true
>
package
${
pub
.
getPKGCodeName
()}.
util
.
es
.
aspect
;
package
${
pub
.
getPKGCodeName
()}.
util
.
aspect
;
import
lombok
.
extern
.
slf4j
.
Slf4j
;
import
${
pub
.
getPKGCodeName
()}.
util
.
domain
.
EntityBase
;
...
...
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/client/IBZDictFallback.java.ftl
0 → 100644
浏览文件 @
f848b13f
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
<#
comment
>
系统是否包含预定义代码表
</#
comment
>
<#
assign
hasPredefinedCodeList
=
false
>
<#
list
sys
.
getAllPSCodeLists
()
as
codelist
>
<#
if
codelist
.
getPredefinedType
()??
&&
codelist
.
getPredefinedType
()==
'RUNTIME'
>
<#
assign
hasPredefinedCodeList
=
true
>
<#
break
>
</#
if
>
</#
list
>
<#
if
hasPredefinedCodeList
>
package
${
pub
.
getPKGCodeName
()}.
util
.
client
;
import
com
.
alibaba
.
fastjson
.
JSONArray
;
import
org
.
springframework
.
stereotype
.
Component
;
@
Component
public
class
IBZDictFallback
implements
IBZDictFeignClient
{
@
Override
public
Boolean
syncRuntimeDict
(
JSONArray
catalogs
)
{
return
null
;
}
}
</#
if
>
\ No newline at end of file
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/client/IBZDictFeignClient.java.ftl
0 → 100644
浏览文件 @
f848b13f
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
<#
comment
>
系统是否包含预定义代码表
</#
comment
>
<#
assign
hasPredefinedCodeList
=
false
>
<#
list
sys
.
getAllPSCodeLists
()
as
codelist
>
<#
if
codelist
.
getPredefinedType
()??
&&
codelist
.
getPredefinedType
()==
'RUNTIME'
>
<#
assign
hasPredefinedCodeList
=
true
>
<#
break
>
</#
if
>
</#
list
>
<#
if
hasPredefinedCodeList
>
package
${
pub
.
getPKGCodeName
()}.
util
.
client
;
import
com
.
alibaba
.
fastjson
.
JSONArray
;
import
com
.
alibaba
.
fastjson
.
JSONObject
;
import
org
.
springframework
.
cloud
.
openfeign
.
FeignClient
;
import
org
.
springframework
.
http
.
ResponseEntity
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
PathVariable
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RequestBody
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RequestMapping
;
import
org
.
springframework
.
web
.
bind
.
annotation
.
RequestMethod
;
import
java
.
util
.
List
;
import
java
.
util
.
Map
;
@
FeignClient
(
value
=
"${r'${ibiz.ref.service.dict:ibzdict-api}'}"
,
contextId
=
"dict"
,
fallback
=
IBZDictFallback
.
class
)
public
interface
IBZDictFeignClient
{
@
RequestMapping
(
method
=
RequestMethod
.
POST
,
value
=
"/dictionarys/catalogs/sync"
)
Boolean
syncRuntimeDict
(@
RequestBody
JSONArray
catalogs
);
}
</#
if
>
\ No newline at end of file
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/domain/EntityClient.java.ftl
浏览文件 @
f848b13f
...
...
@@ -9,9 +9,9 @@ public class EntityClient extends EntityBase {
@
Override
public
void
modify
(
String
field
,
Object
val
)
{
getExtensionparams
().
put
(
"dirtyflagenable"
,
true
);
if
(
val
==
null
){
this
.
getFocusNull
().
add
(
field
.
toLowerCase
());
getExtensionparams
().
put
(
"dirtyflagenable"
,
true
);
getExtensionparams
().
put
(
field
.
toLowerCase
()+
"dirtyflag"
,
true
);
}
else
{
...
...
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/enums/DupCheck.java.ftl
0 → 100644
浏览文件 @
f848b13f
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
package
${
pub
.
getPKGCodeName
()}.
util
.
enums
;
/**
*
属性重复值检查
*/
public
enum
DupCheck
{
/**
*
不检查
*/
NONE
,
/**
*
全部检查
*/
ALL
,
/**
*
非空检查
*/
NOTNULL
,
/**
*
指定范围检查
*/
RANGE
,
}
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/errors/ExceptionTranslator.java.ftl
浏览文件 @
f848b13f
...
...
@@ -4,7 +4,7 @@ TARGET=PSSYSTEM
package
${
pub
.
getPKGCodeName
()}.
util
.
errors
;
import
org
.
springframework
.
dao
.
ConcurrencyFailureException
;
import
org
.
springframework
.
dao
.
*
;
import
org
.
springframework
.
http
.
HttpHeaders
;
import
org
.
springframework
.
http
.
ResponseEntity
;
import
org
.
springframework
.
validation
.
BindingResult
;
...
...
@@ -93,9 +93,18 @@ public class ExceptionTranslator implements ProblemHandling {
return
create
(
ex
,
problem
,
request
);
}
@
ExceptionHandler
(
DataAccessException
.
class
)
public
ResponseEntity
<
Problem
>
handlerDataAccessFailure
(
DataAccessException
ex
,
NativeWebRequest
request
){
Problem
problem
=
Problem
.
builder
()
.
withStatus
(
Status
.
INTERNAL_SERVER_ERROR
)
.
with
(
"message"
,
ex
.
getMessage
())
.
build
();
return
create
(
ex
,
problem
,
request
,
createFailureAlert
(
ex
.
getClass
().
getSimpleName
(),
ex
.
getClass
().
getSimpleName
(),
ex
.
getMessage
()));
}
public
static
HttpHeaders
createFailureAlert
(
String
entityName
,
String
errorKey
,
String
defaultMessage
)
{
HttpHeaders
headers
=
new
HttpHeaders
();
headers
.
add
(
"X-ibz-error"
,
"error."
+
errorKey
);
headers
.
add
(
"X-ibz-error"
,
errorKey
);
headers
.
add
(
"X-ibz-params"
,
entityName
);
return
headers
;
}
...
...
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/job/PermissionSyncJob.java.ftl
浏览文件 @
f848b13f
...
...
@@ -20,6 +20,14 @@ TARGET=PSSYSTEM
<#
break
>
</#
list
>
</#
if
>
<#
comment
>
系统是否包含预定义代码表
</#
comment
>
<#
assign
hasPredefinedCodeList
=
false
>
<#
list
sys
.
getAllPSCodeLists
()
as
codelist
>
<#
if
codelist
.
getPredefinedType
()??
&&
codelist
.
getPredefinedType
()==
'RUNTIME'
>
<#
assign
hasPredefinedCodeList
=
true
>
<#
break
>
</#
if
>
</#
list
>
package
${
pub
.
getPKGCodeName
()}.
util
.
job
;
import
${
pub
.
getPKGCodeName
()}.
util
.
client
.
IBZUAAFeignClient
;
...
...
@@ -73,6 +81,12 @@ public class PermissionSyncJob implements ApplicationRunner {
@
Lazy
IBZLiteFeignClient
liteFeignClient
;
<#
if
hasPredefinedCodeList
>
@
Autowired
@
Lazy
${
pub
.
getPKGCodeName
()}.
util
.
client
.
IBZDictFeignClient
dictFeignClient
;
</#
if
>
@
Override
public
void
run
(
ApplicationArguments
args
)
{
try
{
...
...
@@ -142,5 +156,19 @@ public class PermissionSyncJob implements ApplicationRunner {
log
.
error
(
"推送消息模板失败"
);
}
</#
if
>
<#
if
hasPredefinedCodeList
>
try
{
InputStream
runtimeDict
=
this
.
getClass
().
getResourceAsStream
(
"/sysmodel/RuntimeDict.json"
);
//
获取当前系统所有实体资源能力
String
strRuntimeDict
=
IOUtils
.
toString
(
runtimeDict
,
"UTF-8"
);
if
(
dictFeignClient
.
syncRuntimeDict
(
JSONArray
.
parseArray
(
strRuntimeDict
))){
log
.
info
(
"推送系统预置代码表成功"
);
}
else
{
log
.
error
(
"推送系统预置代码表失败"
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"推送系统预置代码表失败"
);
}
</#
if
>
}
}
\ No newline at end of file
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/rest/AppController.java.ftl
浏览文件 @
f848b13f
...
...
@@ -62,6 +62,7 @@ public class AppController {
appData
.
put
(
"enablepermissionvalid"
,
false
);
else
appData
.
put
(
"enablepermissionvalid"
,
enablePermissionValid
);
fillAppData
(
appData
);
return
ResponseEntity
.
status
(
HttpStatus
.
OK
).
body
(
appData
);
}
...
...
@@ -90,4 +91,12 @@ public class AppController {
throw
new
BadRequestAlertException
(
"获取配置失败,参数缺失"
,
"IBZConfig"
,
configType
);
return
ResponseEntity
.
ok
(
ibzConfigService
.
getConfig
(
configType
,
targetType
,
userId
));
}
/**
*
应用参数扩展
*
@
param
appData
*/
protected
void
fillAppData
(
JSONObject
appData
){
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录