fix api interfaces compatible

This commit is contained in:
wuchao 2024-05-09 09:09:18 +08:00
parent 8d547d2566
commit f654e04801
2 changed files with 26 additions and 3 deletions

View File

@ -44,6 +44,8 @@ import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.extract.master.dto.WorkflowExecuteDto;
import org.apache.dolphinscheduler.plugin.task.api.enums.DataType;
import org.apache.dolphinscheduler.plugin.task.api.enums.Direct;
import org.apache.dolphinscheduler.plugin.task.api.model.Property;
import org.apache.commons.lang3.StringUtils;
@ -69,6 +71,9 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import com.google.gson.JsonElement;
import com.google.gson.JsonParser;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
@ -166,7 +171,16 @@ public class ExecutorController extends BaseController {
}
List<Property> startParamList = null;
if (startParams != null) {
startParamList = JSONUtils.toList(startParams, Property.class);
JsonElement jsonElement = JsonParser.parseString(startParams);
boolean isJson = jsonElement.isJsonObject();
if (isJson) {
Map<String, String> startParamMap = JSONUtils.toMap(startParams);
startParamList = startParamMap.entrySet().stream()
.map(entry -> new Property(entry.getKey(), Direct.IN, DataType.VARCHAR, entry.getValue()))
.collect(Collectors.toList());
} else {
startParamList = JSONUtils.toList(startParams, Property.class);
}
}
if (complementDependentMode == null) {
@ -265,7 +279,16 @@ public class ExecutorController extends BaseController {
List<Property> startParamList = null;
if (startParams != null) {
startParamList = JSONUtils.toList(startParams, Property.class);
JsonElement jsonElement = JsonParser.parseString(startParams);
boolean isJson = jsonElement.isJsonObject();
if (isJson) {
Map<String, String> startParamMap = JSONUtils.toMap(startParams);
startParamList = startParamMap.entrySet().stream()
.map(entry -> new Property(entry.getKey(), Direct.IN, DataType.VARCHAR, entry.getValue()))
.collect(Collectors.toList());
} else {
startParamList = JSONUtils.toList(startParams, Property.class);
}
}
if (complementDependentMode == null) {

View File

@ -154,11 +154,11 @@ public class CuringParamsServiceImpl implements CuringParamsService {
return new HashMap<>();
}
String startParamJson = cmdParam.get(CommandKeyConstants.CMD_PARAM_START_PARAMS);
Map<String, String> startParamMap = JSONUtils.toMap(startParamJson);
JsonElement jsonElement = JsonParser.parseString(startParamJson);
// check whether it is json
boolean isJson = jsonElement.isJsonObject();
if (isJson) {
Map<String, String> startParamMap = JSONUtils.toMap(startParamJson);
return startParamMap.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey,
entry -> new Property(entry.getKey(), Direct.IN, DataType.VARCHAR, entry.getValue())));
} else {