浏览代码

添加接口定义,添加venders地址配置

FanXiaoyu 6 年之前
父节点
当前提交
a56f7ff81f

+ 2 - 0
src/main/java/com/sagacloud/listener/VendersDpCamelContextInitialListener.java

@@ -1,6 +1,7 @@
 package com.sagacloud.listener;
 
 import com.sagacloud.route.InitEnvRoute;
+import com.sagacloud.route.Route;
 import org.apache.camel.CamelContext;
 import org.apache.camel.impl.DefaultCamelContext;
 
@@ -18,6 +19,7 @@ public class VendersDpCamelContextInitialListener implements ServletContextListe
         try {
             camelContext = new DefaultCamelContext();
             camelContext.addRoutes(new InitEnvRoute());
+            camelContext.addRoutes(new Route());
 
             camelContext.start();
         } catch (Exception e) {

+ 0 - 1
src/main/java/com/sagacloud/route/InitEnvRoute.java

@@ -10,7 +10,6 @@ import org.apache.camel.builder.RouteBuilder;
  */
 public class InitEnvRoute extends RouteBuilder {
 	public static String dataPlatform = PropUtil.getProperty("dataPlatform.baseUrl");
-	public static String projectId = PropUtil.getProperty("project.id");
     @Override
     public void configure() throws Exception {
 

+ 58 - 0
src/main/java/com/sagacloud/route/Route.java

@@ -0,0 +1,58 @@
+package com.sagacloud.route;
+
+import com.github.rjeschke.txtmark.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.commons.io.IOUtils;
+
+import javax.ws.rs.core.MediaType;
+import java.io.StringWriter;
+
+/**
+ * Created by Xiaoyu on 2018/7/10
+ */
+public class Route extends RouteBuilder {
+    @Override
+    public void configure() throws Exception {
+        rest().get("/doc")
+                .produces("text/html;charset=UTF-8")
+                .route()
+                .process(msg -> {
+                    String docContentStr = Processor.process(Route.class.getClassLoader().getResourceAsStream("documentation.md"));
+                    StringWriter writer = new StringWriter();
+                    IOUtils.copy(Route.class.getClassLoader().getResourceAsStream("template.html"), writer, "utf-8");
+                    String tmplateContentStr = writer.toString();
+                    msg.getOut().setBody(tmplateContentStr.replace("#replaceMePlease#", docContentStr));
+                });
+
+        rest("/manufacturer/property/query").post()
+                .consumes(MediaType.APPLICATION_JSON)
+                .produces(MediaType.APPLICATION_JSON)
+                .route()
+                .process();
+        rest("/supplier/property/query").post()
+                .consumes(MediaType.APPLICATION_JSON)
+                .produces(MediaType.APPLICATION_JSON)
+                .route()
+                .process();
+        rest("/insurance/project/query").post()
+                .consumes(MediaType.APPLICATION_JSON)
+                .produces(MediaType.APPLICATION_JSON)
+                .route()
+                .process();
+        rest("/insurance/contract/query").post()
+                .consumes(MediaType.APPLICATION_JSON)
+                .produces(MediaType.APPLICATION_JSON)
+                .route()
+                .process();
+        rest("/insurance/contract/property/query").post()
+                .consumes(MediaType.APPLICATION_JSON)
+                .produces(MediaType.APPLICATION_JSON)
+                .route()
+                .process();
+        rest("/maintainance/property/query").post()
+                .consumes(MediaType.APPLICATION_JSON)
+                .produces(MediaType.APPLICATION_JSON)
+                .route()
+                .process();
+    }
+}

+ 2 - 0
src/main/resources/prod/config.properties

@@ -1,2 +1,4 @@
 dataPlatform.baseUrl=http://localhost:8888/data-platform-3
+#vendersÄÚÍøµØÖ·
+venders.baseUrl=http://172.17.134.222:8888/venders
 

+ 1 - 0
src/main/resources/test/config.properties

@@ -1,2 +1,3 @@
 dataPlatform.baseUrl=http://192.168.20.225:8080/data-platform-3
+venders.baseUrl=http://192.168.20.225:8080/venders
 

+ 3 - 0
venders-dp.iml

@@ -3,6 +3,9 @@
   <component name="FacetManager">
     <facet type="web" name="Web">
       <configuration>
+        <descriptors>
+          <deploymentDescriptor name="web.xml" url="file://$MODULE_DIR$/src/main/webapp/WEB-INF/web.xml" />
+        </descriptors>
         <webroots>
           <root url="file://$MODULE_DIR$/src/main/webapp" relative="/" />
         </webroots>