Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
iBiz4j Spring R7
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
iBiz-R7后台标准模板
iBiz4j Spring R7
提交
2aa37ccd
提交
2aa37ccd
编写于
11月 24, 2020
作者:
zhouweidong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
属性值规则(规则组)
上级
7097d1bb
变更
3
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
150 行增加
和
1 行删除
+150
-1
%DE%%ITEM%RuleFlow.bpmn.ftl
...core/src/main/resources/rules/%DE%%ITEM%RuleFlow.bpmn.ftl
+1
-1
ValueRuleCheck.java.ftl
...ava/%SYS_PKGPATH%/util/annotation/ValueRuleCheck.java.ftl
+42
-0
ValueRuleValidator.java.ftl
...va/%SYS_PKGPATH%/util/service/ValueRuleValidator.java.ftl
+107
-0
未找到文件。
SLN/%PUBPRJ%-core/src/main/resources/rules/%DE%%ITEM%RuleFlow.bpmn.ftl
浏览文件 @
2aa37ccd
...
@@ -122,7 +122,7 @@ TARGET=PSDELOGIC
...
@@ -122,7 +122,7 @@ TARGET=PSDELOGIC
<#assign targetDBValueOP=LogicLinkCond.getPSDBValueOPId()><#comment>表达式</#comment>
<#assign targetDBValueOP=LogicLinkCond.getPSDBValueOPId()><#comment>表达式</#comment>
<#assign targetValue=LogicLinkCond.getValue()><#comment>值项</#comment>
<#assign targetValue=LogicLinkCond.getValue()><#comment>值项</#comment>
<#if targetDEField!=''>
<#if targetDEField!=''>
targetFieldName=srfcaseformat(targetDEField.codeName,'l_u2lC') ;
<#assign targetFieldName=srfcaseformat(targetDEField.codeName,'l_u2lC')>
</#if>
</#if>
<#assign condBody="RuleUtils.test($"+logicName+targetParam.getCodeName()?lower_case+".get(\""+targetFieldName+"\"),\""+targetDBValueOP+"\","+"\""+targetValue+"\")">
<#assign condBody="RuleUtils.test($"+logicName+targetParam.getCodeName()?lower_case+".get(\""+targetFieldName+"\"),\""+targetDBValueOP+"\","+"\""+targetValue+"\")">
<#assign fieldCond=fieldCond+condBody >
<#assign fieldCond=fieldCond+condBody >
...
...
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/annotation/ValueRuleCheck.java.ftl
0 → 100644
浏览文件 @
2aa37ccd
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
<#
if
sys
.
codeName
==
'Sample'
>
package
${
pub
.
getPKGCodeName
()}.
util
.
annotation
;
import
${
pub
.
getPKGCodeName
()}.
util
.
service
.
ValueRuleValidator
;
import
javax
.
validation
.
Constraint
;
import
javax
.
validation
.
Payload
;
import
java
.
lang
.
annotation
.
Documented
;
import
java
.
lang
.
annotation
.
Retention
;
import
java
.
lang
.
annotation
.
Target
;
import
static
java
.
lang
.
annotation
.
ElementType
.*;
import
static
java
.
lang
.
annotation
.
RetentionPolicy
.
RUNTIME
;
@
Target
({
FIELD
,
METHOD
,
PARAMETER
,
ANNOTATION_TYPE
,
TYPE_USE
})
@
Retention
(
RUNTIME
)
@
Constraint
(
validatedBy
=
{
ValueRuleValidator
.
class
})
@
Documented
public
@
interface
ValueRuleCheck
{
String
field
();
String
rule
();
String
message
()
default
"值规则检查异常!"
;
Class
<?>[]
groups
()
default
{};
Class
<?
extends
Payload
>[]
payload
()
default
{};
@
Target
({
FIELD
,
METHOD
,
PARAMETER
,
ANNOTATION_TYPE
})
@
Retention
(
RUNTIME
)
@
Documented
@
interface
List
{
ValueRuleCheck
[]
value
();
}
}
</#
if
>
\ No newline at end of file
SLN/%PUBPRJ%-util/src/main/java/%SYS_PKGPATH%/util/service/ValueRuleValidator.java.ftl
0 → 100644
浏览文件 @
2aa37ccd
<#
ibiztemplate
>
TARGET
=
PSSYSTEM
</#
ibiztemplate
>
<#
if
sys
.
codeName
==
'Sample'
>
package
${
pub
.
getPKGCodeName
()}.
util
.
service
;
import
${
pub
.
getPKGCodeName
()}.
util
.
annotation
.
ValueRuleCheck
;
import
${
pub
.
getPKGCodeName
()}.
util
.
domain
.
DTOBase
;
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
.
util
.
ObjectUtils
;
import
javax
.
validation
.
ConstraintValidator
;
import
javax
.
validation
.
ConstraintValidatorContext
;
import
java
.
util
.
HashMap
;
import
java
.
util
.
Map
;
public
class
ValueRuleValidator
implements
ConstraintValidator
<
ValueRuleCheck
,
DTOBase
>
{
private
static
Map
<
String
,
String
>
sysRule
=
new
HashMap
<>();
private
final
ExpressionParser
parser
=
new
SpelExpressionParser
();
private
String
field
;
private
String
rule
;
@
Override
public
void
initialize
(
ValueRuleCheck
constraintAnnotation
)
{
this
.
field
=
constraintAnnotation
.
field
();
this
.
rule
=
constraintAnnotation
.
rule
();
}
@
Override
public
boolean
isValid
(
DTOBase
dto
,
ConstraintValidatorContext
constraintContext
)
{
if
(
ObjectUtils
.
isEmpty
(
dto
)
||
ObjectUtils
.
isEmpty
(
rule
)
||
ObjectUtils
.
isEmpty
(
sysRule
.
get
(
rule
)))
{
return
true
;
}
EvaluationContext
searchContextCtx
=
new
StandardEvaluationContext
();
searchContextCtx
.
setVariable
(
"dto"
,
dto
);
Expression
searchContextExp
=
parser
.
parseExpression
(
sysRule
.
get
(
rule
));
return
searchContextExp
.
getValue
(
searchContextCtx
,
Boolean
.
class
);
}
static
{
<#
if
sys
.
getAllPSDataEntities
()??>
<#
list
sys
.
getAllPSDataEntities
()
as
de
>
<#
if
de
.
getAllPSDEFValueRules
()??>
<#
list
de
.
getAllPSDEFValueRules
()
as
deRule
>
<#
if
deRule
.
codeName
!='Default'>
<#
if
deRule
.
getPSDEFVRGroupCondition
()??>
<#
assign
group
=
deRule
.
getPSDEFVRGroupCondition
()>
<#
assign
ruleName
=
de
.
codeName
+
"_"
+
deRule
.
getPSDEField
().
codeName
+
"_"
+
deRule
.
codeName
>
<#
assign
ruleCond
=
getGroupCond
(
group
)>
sysRule
.
put
(
"${ruleName}"
,
"${ruleCond}"
);
</#
if
>
</#
if
>
</#
list
>
</#
if
>
</#
list
>
</#
if
>
}
}
</#
if
>
<#
comment
>
获取组条件表达式
</#
comment
>
<#
function
getGroupCond
group
>
<#
assign
strRuleCond
=
"("
>
<#
if
group
.
getPSDEFVRConditions
()??>
<#
assign
condOp
=
group
.
getCondOp
()?
replace
(
"AND"
,
"&&"
)?
replace
(
"OR"
,
"||"
)>
<#
list
group
.
getPSDEFVRConditions
()
as
childRule
>
<#
assign
childRuleType
=
childRule
.
getCondType
()>
<#
if
childRuleType
==
'GROUP'
>
<#
assign
strRuleCond
=
strRuleCond
+
getGroupCond
(
childRule
)>
<#
else
>
<#
assign
strRuleCond
=
strRuleCond
+
getFieldCond
(
childRule
)>
</#
if
>
<#
if
childRule_has_next
>
<#
assign
strRuleCond
=
strRuleCond
+
condOp
>//
拼接连接符
</#
if
>
</#
list
>
</#
if
>
<#
assign
strRuleCond
=
strRuleCond
+
")"
>
<#
return
strRuleCond
/>
</#
function
>
<#
comment
>
获取单项条件表达式
</#
comment
>
<#
function
getFieldCond
fieldRule
>
<#
assign
fieldCond
=
"("
>
<#
assign
condBody
=
""
>
<#
assign
targetFieldName
=
fieldRule
.
getDEFName
()><#
comment
>
目标属性名称
</#
comment
>
<#
assign
targetDEField
=((
de
.
getPSDEField
(
targetFieldName
,
true
))
!'')><#comment>目标属性</#comment>
<#
assign
targetDBValueOP
=
fieldRule
.
getCondOp
()><#
comment
>
表达式
</#
comment
>
<#
assign
targetValue
=
fieldRule
.
getParamValue
()><#
comment
>
值项
</#
comment
>
<#
if
targetDEField
!=''>
<#
assign
targetFieldName
=
srfcaseformat
(
targetDEField
.
codeName
,
'l_u2lC'
)>
</#
if
>
<#
assign
condBody
=
"T(${pub.getPKGCodeName()}.util.helper.RuleUtils).test(#dto.get(
\"
"
+
targetFieldName
+
"
\"
),
\"
"
+
targetDBValueOP
+
"
\"
,"
+
"
\"
"
+
targetValue
+
"
\"
)"
>
<#
assign
fieldCond
=
fieldCond
+
condBody
>
<#
assign
fieldCond
=
fieldCond
+
")"
>
<#
return
fieldCond
/>
</#
function
>
\ No newline at end of file
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录