|
@ -1,8 +1,10 @@
|
|
|
package camel.gateway.processor;
|
|
|
package gateway.processor;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
|
|
|
/**
|
|
@ -23,15 +25,49 @@ public class AppApi {
|
|
|
private String msMethodName;
|
|
|
private String microServiceName;
|
|
|
|
|
|
private Collection<Param> parameters;
|
|
|
private Collection<ApiParam> parameters;
|
|
|
|
|
|
public AppApi(String apiInfo) throws IOException {
|
|
|
this.parse(apiInfo);
|
|
|
public AppApi() {
|
|
|
}
|
|
|
|
|
|
public static AppApi parse(String apiInfo) throws IOException {
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
return objectMapper.readValue(apiInfo, AppApi.class);
|
|
|
JsonNode jsonNode = objectMapper.readValue(apiInfo, JsonNode.class);
|
|
|
|
|
|
JsonNode detailModelList = jsonNode.get("detailModelList");
|
|
|
if (detailModelList != null && detailModelList.isArray() && detailModelList.size() != 0) {
|
|
|
JsonNode apiNode = detailModelList.get(0);
|
|
|
AppApi appApi = new AppApi();
|
|
|
appApi.setName(apiNode.path("name").asText());
|
|
|
appApi.setType(apiNode.path("type").asText());
|
|
|
appApi.setMethod(apiNode.path("method").asText());
|
|
|
appApi.setProtocol(apiNode.path("protocol").asText());
|
|
|
appApi.setVersion(apiNode.path("version").asText());
|
|
|
appApi.setMethodName(apiNode.path("methodName").asText());
|
|
|
appApi.setMicroServiceUri(apiNode.path("microServiceUri").asText());
|
|
|
appApi.setMsMethodName(apiNode.path("msMethodName").asText());
|
|
|
appApi.setMethodName(apiNode.path("methodName").asText());
|
|
|
appApi.setMicroServiceName(apiNode.path("microServiceName").asText());
|
|
|
|
|
|
JsonNode parametersNode = apiNode.get("parameters");
|
|
|
Collection<ApiParam> parameters = new ArrayList<>();
|
|
|
if (parametersNode != null && parametersNode.size() != 0) {
|
|
|
parametersNode.forEach(paramNode -> {
|
|
|
ApiParam apiParam = new ApiParam();
|
|
|
apiParam.setName(paramNode.path("name").asText());
|
|
|
apiParam.setType(paramNode.path("type").asText());
|
|
|
apiParam.setDataType(paramNode.path("dataType").asText());
|
|
|
apiParam.setDefaultValue(paramNode.path("defaultValue").asText());
|
|
|
parameters.add(apiParam);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
appApi.setParameters(parameters);
|
|
|
|
|
|
return appApi;
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
public String getName() {
|
|
@ -130,11 +166,11 @@ public class AppApi {
|
|
|
this.microServiceName = microServiceName;
|
|
|
}
|
|
|
|
|
|
public Collection<Param> getParameters() {
|
|
|
public Collection<ApiParam> getParameters() {
|
|
|
return parameters;
|
|
|
}
|
|
|
|
|
|
public void setParameters(Collection<Param> parameters) {
|
|
|
public void setParameters(Collection<ApiParam> parameters) {
|
|
|
this.parameters = parameters;
|
|
|
}
|
|
|
|