Pārlūkot izejas kodu

同步项目名称

FanXiaoyu 6 gadi atpakaļ
vecāks
revīzija
809fbe682a

+ 27 - 3
src/main/java/com/sagacloud/route/InitEnvRoute.java

@@ -1,5 +1,7 @@
 package com.sagacloud.route;
 
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.sagacloud.cache.ProPasCache;
 import com.sagacloud.utils.PropUtil;
 import org.apache.camel.builder.RouteBuilder;
@@ -12,8 +14,9 @@ import java.util.List;
  * Created by wo on 5/24/17.
  */
 public class InitEnvRoute extends RouteBuilder {
-	public static String dataPlatform = PropUtil.getProperty("dataPlatform.baseUrl");
-	public static String venders = PropUtil.getProperty("venders.baseUrl");
+    public static String dataPlatform = PropUtil.getProperty("dataPlatform.baseUrl");
+    public static String venders = PropUtil.getProperty("venders.baseUrl");
+
     @Override
     public void configure() throws Exception {
 
@@ -25,7 +28,7 @@ public class InitEnvRoute extends RouteBuilder {
                 .process(exchange -> {
                     ProPasCache.syncProject(exchange.getIn().getBody(String.class));
                 })
-                .to(venders+"/auxiliary/vender/query")
+                .to(venders + "/auxiliary/vender/query")
                 .process(exchange -> {
                     ProPasCache.syncVender(exchange.getIn().getBody(String.class));
                 });
@@ -34,6 +37,27 @@ public class InitEnvRoute extends RouteBuilder {
                 .get()
                 .to("direct:syn");
 
+        rest("/project/sync_name").post()
+                .consumes(MediaType.APPLICATION_JSON)
+                .produces(MediaType.APPLICATION_JSON)
+                .route()
+                .to("direct:synProjectName");
+
+        from("direct:synProjectName")
+                .process(exchange -> {
+                    JSONArray criterias = new JSONArray();
+                    for (String pjId : ProPasCache.nameMap.keySet()) {
+                        JSONObject obj = new JSONObject();
+                        obj.put("projectId",pjId);
+                        obj.put("projectLocalName",ProPasCache.nameMap.get(pjId));
+                        criterias.add(obj);
+                    }
+                    JSONObject inserJson = new JSONObject();
+                    inserJson.put("criterias",criterias);
+                    exchange.getIn().setBody(inserJson.toString());
+                })
+                .to(InitEnvRoute.venders+"/auxiliary/project/create?bridgeEndpoint=true");
+
     }
 
 }

+ 5 - 1
src/main/resources/documentation.md

@@ -217,4 +217,8 @@ post体:
 
     http://<host>:<port>/venders-dp/project/sync_all
 
-post方法, 不需要传Post数据:
+post方法, 不需要传Post数据:
+
+##更新项目名称接口
+    http://<host>:<port>/venders-dp/project/sync_name
+post:无

+ 5 - 5
venders-dp.iml

@@ -27,6 +27,7 @@
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="Maven: com.alibaba:fastjson:1.2.47" level="project" />
     <orderEntry type="library" name="Maven: org.glassfish.jersey.containers:jersey-container-servlet-core:2.25.1" level="project" />
     <orderEntry type="library" name="Maven: org.glassfish.hk2.external:javax.inject:2.5.0-b32" level="project" />
     <orderEntry type="library" name="Maven: org.glassfish.jersey.core:jersey-common:2.25.1" level="project" />
@@ -44,12 +45,12 @@
     <orderEntry type="library" name="Maven: javax.validation:validation-api:1.1.0.Final" level="project" />
     <orderEntry type="library" name="Maven: javax.ws.rs:javax.ws.rs-api:2.0.1" level="project" />
     <orderEntry type="library" name="Maven: com.doctusoft:json-schema-java7:1.4.1" level="project" />
+    <orderEntry type="library" name="Maven: org.json:json:20160810" level="project" />
     <orderEntry type="library" name="Maven: com.google.guava:guava:19.0" level="project" />
     <orderEntry type="library" name="Maven: org.threeten:threetenbp:1.3.3" level="project" />
     <orderEntry type="library" name="Maven: commons-validator:commons-validator:1.5.1" level="project" />
     <orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.9.2" level="project" />
     <orderEntry type="library" name="Maven: commons-digester:commons-digester:1.8.1" level="project" />
-    <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
     <orderEntry type="library" name="Maven: commons-collections:commons-collections:3.2.2" level="project" />
     <orderEntry type="library" name="Maven: org.apache.camel:camel-core:2.19.0" level="project" />
     <orderEntry type="library" name="Maven: com.sun.xml.bind:jaxb-core:2.2.11" level="project" />
@@ -62,12 +63,11 @@
     <orderEntry type="library" name="Maven: org.apache.camel:camel-servlet:2.19.0" level="project" />
     <orderEntry type="library" name="Maven: com.github.rjeschke:txtmark:0.13" level="project" />
     <orderEntry type="library" name="Maven: commons-io:commons-io:2.4" level="project" />
-    <orderEntry type="library" name="Maven: org.json:json:20180130" level="project" />
     <orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.5" level="project" />
     <orderEntry type="library" name="Maven: org.slf4j:slf4j-log4j12:1.7.5" level="project" />
     <orderEntry type="library" name="Maven: log4j:log4j:1.2.17" level="project" />
-    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.5" level="project" />
-    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
-    <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.5" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.1" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.3" level="project" />
+    <orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
   </component>
 </module>