Skip to content

Commit

Permalink
增加了@BizAction的函数需要为参数增加@name注解
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Oct 30, 2024
1 parent a9d6a83 commit e383f38
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
38 changes: 22 additions & 16 deletions nop-biz/src/main/java/io/nop/biz/crud/AutoExprRunner.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
package io.nop.biz.crud;

import io.nop.api.core.exceptions.NopException;
import io.nop.biz.BizConstants;
import io.nop.commons.lang.Undefined;
import io.nop.core.lang.eval.IEvalScope;
Expand Down Expand Up @@ -38,26 +39,31 @@ public static void runAutoExpr(String action,
if (ignoreFields != null && ignoreFields.contains(propMeta.getName()))
continue;

ObjConditionExpr autoExpr = propMeta.getAutoExpr();
if (autoExpr == null) {
// 只有save的时候才考虑设置缺省值。
if (propMeta.getDefaultValue() != null && BizConstants.METHOD_SAVE.equals(action)) {
BeanTool.setProperty(entity, name, propMeta.getDefaultValue());
try {
ObjConditionExpr autoExpr = propMeta.getAutoExpr();
if (autoExpr == null) {
// 只有save的时候才考虑设置缺省值。
if (propMeta.getDefaultValue() != null && BizConstants.METHOD_SAVE.equals(action)) {
BeanTool.setProperty(entity, name, propMeta.getDefaultValue());
}
continue;
}
continue;
}

if (autoExpr.getWhen() != null && !autoExpr.getWhen().contains(action))
continue;
if (autoExpr.getWhen() != null && !autoExpr.getWhen().contains(action))
continue;

Object value = null;
if (autoExpr.getSource() != null) {
scope.setLocalValue(null, OrmConstants.VAR_PROP_META, propMeta);
value = autoExpr.getSource().invoke(scope);
}
Object value = null;
if (autoExpr.getSource() != null) {
scope.setLocalValue(null, OrmConstants.VAR_PROP_META, propMeta);
value = autoExpr.getSource().invoke(scope);
}

if (value != Undefined.undefined)
BeanTool.setProperty(entity, name, value);
if (value != Undefined.undefined)
BeanTool.setProperty(entity, name, value);
} catch (NopException e) {
e.addXplStack("runAutoExprForProp:" + propMeta.getName());
throw e;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import io.nop.api.core.annotations.biz.BizAction;
import io.nop.api.core.annotations.biz.BizModel;
import io.nop.api.core.annotations.core.Name;
import io.nop.biz.crud.CrudBizModel;
import io.nop.core.context.IServiceContext;
import io.nop.dyn.dao.entity.NopDynFunctionMeta;
Expand All @@ -27,7 +28,7 @@ public NopDynFunctionMetaBizModel() {

@BizAction
@Override
protected void afterEntityChange(NopDynFunctionMeta entity, IServiceContext context, String action) {
protected void afterEntityChange(@Name("entity") NopDynFunctionMeta entity, IServiceContext context, @Name("action") String action) {
super.afterEntityChange(entity, context, action);

codeGen.generateBizModel(entity.getEntityMeta());
Expand Down

0 comments on commit e383f38

Please sign in to comment.