提交 2a9287ce 编写于 作者: zhouweidong's avatar zhouweidong

补充忽略版本检查开关

上级 70d85d12
...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Component; ...@@ -21,6 +21,7 @@ import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.Map;
/** /**
* 数据库版本检查 * 数据库版本检查
...@@ -31,6 +32,7 @@ import java.lang.reflect.Field; ...@@ -31,6 +32,7 @@ import java.lang.reflect.Field;
public class VersionCheckAspect public class VersionCheckAspect
{ {
private final ExpressionParser parser = new SpelExpressionParser(); private final ExpressionParser parser = new SpelExpressionParser();
private final String IgnoreField="ignoreversioncheck";
@SneakyThrows @SneakyThrows
@Before("execution(* ${pub.getPKGCodeName()}.*.rest.*.update(..)) && @annotation(versionCheck)") @Before("execution(* ${pub.getPKGCodeName()}.*.rest.*.update(..)) && @annotation(versionCheck)")
...@@ -65,6 +67,11 @@ public class VersionCheckAspect ...@@ -65,6 +67,11 @@ public class VersionCheckAspect
private void versionCheck(VersionCheck versionCheck,Object resource,Object dto,Object id ){ private void versionCheck(VersionCheck versionCheck,Object resource,Object dto,Object id ){
EvaluationContext context = new StandardEvaluationContext(); EvaluationContext context = new StandardEvaluationContext();
context.setVariable("dto",dto); context.setVariable("dto",dto);
//忽略版本检查
Expression dtoParamsExp = parser.parseExpression("#dto.extensionparams");
Map dtoParam=dtoParamsExp.getValue(context, Map.class);
if(!ObjectUtils.isEmpty(dtoParam) && !ObjectUtils.isEmpty(dtoParam.get(IgnoreField)) && dtoParam.get(IgnoreField).equals(1))
return ;
Expression newExp = parser.parseExpression(String.format("#dto.%s",versionCheck.versionfield())); Expression newExp = parser.parseExpression(String.format("#dto.%s",versionCheck.versionfield()));
Object newVersion=newExp.getValue(context); Object newVersion=newExp.getValue(context);
if(ObjectUtils.isEmpty(newVersion)) if(ObjectUtils.isEmpty(newVersion))
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册