Fix the issue that flow control component will end the process #297
This commit is contained in:
@@ -46,6 +46,7 @@ import we.exception.ExecuteScriptException;
|
||||
import we.exception.RedirectException;
|
||||
import we.exception.StopAndResponseException;
|
||||
import we.fizz.component.ComponentHelper;
|
||||
import we.fizz.component.ComponentResult;
|
||||
import we.fizz.component.IComponent;
|
||||
import we.fizz.component.StepContextPosition;
|
||||
import we.fizz.exception.FizzRuntimeException;
|
||||
@@ -178,7 +179,13 @@ public class Pipeline {
|
||||
ctx.addStepCircleResult(pos.getStepName());
|
||||
return Mono.just(r);
|
||||
});
|
||||
}).flatMap(sr -> Mono.just((StepResponse)sr));
|
||||
}).flatMap(sr -> {
|
||||
if (sr instanceof ComponentResult) {
|
||||
return Mono.just(stepResponse);
|
||||
} else {
|
||||
return Mono.just((StepResponse) sr);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
step.beforeRun(stepContext, null);
|
||||
return createStep(step);
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.alibaba.fastjson.JSON;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
import we.fizz.component.ComponentHelper;
|
||||
import we.fizz.component.ComponentResult;
|
||||
import we.fizz.component.ComponentTypeEnum;
|
||||
import we.fizz.component.IComponent;
|
||||
import we.fizz.component.StepContextPosition;
|
||||
@@ -146,6 +147,15 @@ public class Step {
|
||||
});
|
||||
}
|
||||
return Mono.just(new HashMap());
|
||||
}).flatMap(r -> {
|
||||
if (r instanceof ComponentResult) {
|
||||
Map<String, Object> inputResult = new HashMap<String, Object>();
|
||||
inputResult.put("data", new HashMap<String, Object>());
|
||||
inputResult.put("request", input);
|
||||
return Mono.just(inputResult);
|
||||
} else {
|
||||
return Mono.just(r);
|
||||
}
|
||||
});
|
||||
monos.add(result);
|
||||
} else {
|
||||
|
||||
@@ -102,7 +102,7 @@ public class ComponentHelper {
|
||||
stepContext.addConditionResult(stepCtxPos.getStepName(), stepCtxPos.getRequestName(), c.getDesc(),
|
||||
rs);
|
||||
if (!rs) {
|
||||
return Mono.empty();
|
||||
return Mono.just(new ComponentResult());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -113,7 +113,7 @@ public class ComponentHelper {
|
||||
return f.apply(stepContext, stepCtxPos);
|
||||
}
|
||||
}
|
||||
return Mono.empty();
|
||||
return Mono.just(new ComponentResult());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package we.fizz.component;
|
||||
|
||||
public class ComponentResult {
|
||||
|
||||
public ComponentResult() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import we.fizz.StepContext;
|
||||
import we.fizz.component.ComponentHelper;
|
||||
import we.fizz.component.ComponentResult;
|
||||
import we.fizz.component.ComponentTypeEnum;
|
||||
import we.fizz.component.IComponent;
|
||||
import we.fizz.component.StepContextPosition;
|
||||
@@ -307,10 +308,10 @@ public class Circle implements IComponent {
|
||||
}
|
||||
}
|
||||
}
|
||||
return Mono.empty();
|
||||
return Mono.just(new ComponentResult());
|
||||
});
|
||||
} else {
|
||||
return Mono.empty();
|
||||
return Mono.just(new ComponentResult());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.noear.snack.ONode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
@@ -36,6 +38,7 @@ import we.fizz.component.RefDataTypeEnum;
|
||||
import we.fizz.component.ValueTypeEnum;
|
||||
import we.fizz.exception.FizzRuntimeException;
|
||||
import we.fizz.input.PathMapping;
|
||||
import we.fizz.input.extension.request.RequestInput;
|
||||
|
||||
/**
|
||||
* Condition component
|
||||
@@ -45,6 +48,8 @@ import we.fizz.input.PathMapping;
|
||||
*/
|
||||
@Data
|
||||
public class Condition implements IComponent {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Condition.class);
|
||||
|
||||
private static final String type = ComponentTypeEnum.CONDITION.getCode();
|
||||
|
||||
@@ -213,6 +218,7 @@ public class Condition implements IComponent {
|
||||
}
|
||||
} catch (FizzRuntimeException e) {
|
||||
String message = type + ": " + e.getMessage() + ", data=" + JSON.toJSONString(this);
|
||||
LOGGER.error(message, e);
|
||||
throw new FizzRuntimeException(message, e.getCause());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user