Procházet zdrojové kódy

Merge branch 'dev/icss' into debug

gaodm před 6 roky
rodič
revize
c3eae30cb9

+ 8 - 0
config-server/src/main/resources/shared/icssman-service-dev.yml

@@ -98,3 +98,11 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+fastdfs:
+  connect_timeout_in_seconds: 60
+  network_timeout_in_seconds: 60
+  charset: UTF-8
+  http_tracker_http_port: 8080
+  http_anti_steal_token: no
+  tracker_servers: 192.168.2.236:22122
+

+ 9 - 0
config-server/src/main/resources/shared/icssman-service-local.yml

@@ -98,3 +98,12 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+fastdfs:
+  connect_timeout_in_seconds: 60
+  network_timeout_in_seconds: 60
+  charset: UTF-8
+  http_tracker_http_port: 8080
+  http_anti_steal_token: no
+  tracker_servers: 192.168.2.236:22122
+
+

+ 8 - 0
config-server/src/main/resources/shared/icssman-service-pro.yml

@@ -98,3 +98,11 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+fastdfs:
+  connect_timeout_in_seconds: 60
+  network_timeout_in_seconds: 60
+  charset: UTF-8
+  http_tracker_http_port: 8080
+  http_anti_steal_token: no
+  tracker_servers: 192.168.2.236:22122
+

+ 7 - 0
config-server/src/main/resources/shared/icssman-service-test.yml

@@ -98,3 +98,10 @@ mybatis-plus:
     map-underscore-to-camel-case: true
     cache-enabled: false
 
+fastdfs:
+  connect_timeout_in_seconds: 60
+  network_timeout_in_seconds: 60
+  charset: UTF-8
+  http_tracker_http_port: 8080
+  http_anti_steal_token: no
+  tracker_servers: 192.168.2.241:22122

+ 0 - 10
icssman-service/src/main/java/com/diagbot/client/fastdfs/FastDFSClient.java

@@ -9,7 +9,6 @@ import org.csource.fastdfs.StorageServer;
 import org.csource.fastdfs.TrackerClient;
 import org.csource.fastdfs.TrackerServer;
 import org.slf4j.LoggerFactory;
-import org.springframework.core.io.ClassPathResource;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
@@ -23,15 +22,6 @@ import java.io.InputStream;
 public class FastDFSClient {
     private static org.slf4j.Logger logger = LoggerFactory.getLogger(FastDFSClient.class);
 
-    static {
-        try {
-            String filePath = new ClassPathResource("fdfs_client.conf").getFile().getPath();
-            ClientGlobal.init(filePath);
-        } catch (Exception e) {
-            logger.error("FastDFS Client Init Fail!", e);
-        }
-    }
-
     public static String[] upload(FastDFSFile file) {
         logger.info("File Name: " + file.getName() + "File Length:" + file.getContent().length);
 

+ 49 - 0
icssman-service/src/main/java/com/diagbot/config/FastDFSConfigurer.java

@@ -0,0 +1,49 @@
+package com.diagbot.config;
+
+import lombok.extern.slf4j.Slf4j;
+import org.csource.fastdfs.ClientGlobal;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Properties;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2019/3/1 14:15
+ */
+@Configuration
+@Slf4j
+public class FastDFSConfigurer {
+    @Value("${fastdfs.connect_timeout_in_seconds}")
+    private String connectTimeout;
+    @Value("${fastdfs.network_timeout_in_seconds}")
+    private String networkTimeout;
+    @Value("${fastdfs.charset}")
+    private String charset;
+    @Value("${fastdfs.http_tracker_http_port}")
+    private String httpTrackerHttpPort;
+    @Value("${fastdfs.http_anti_steal_token}")
+    private String httpAntiStealToken;
+    @Value("${fastdfs.tracker_servers}")
+    private String trackerServers;
+
+    @Bean
+    public Integer fastDFSInit(){
+        try {
+            Properties props = new Properties();
+            props.put(ClientGlobal.PROP_KEY_CONNECT_TIMEOUT_IN_SECONDS, connectTimeout);
+            props.put(ClientGlobal.PROP_KEY_NETWORK_TIMEOUT_IN_SECONDS, networkTimeout);
+            props.put(ClientGlobal.PROP_KEY_CHARSET, charset);
+            props.put(ClientGlobal.PROP_KEY_HTTP_TRACKER_HTTP_PORT, httpTrackerHttpPort);
+            props.put(ClientGlobal.PROP_KEY_HTTP_ANTI_STEAL_TOKEN, httpAntiStealToken);
+            props.put(ClientGlobal.PROP_KEY_TRACKER_SERVERS, trackerServers);
+            ClientGlobal.initByProperties(props);
+
+        } catch (Exception e) {
+            log.error("FastDFS Client Init Fail!", e);
+        }
+        return 1;
+    }
+}

+ 0 - 7
icssman-service/src/main/resources/fdfs_client.conf

@@ -1,7 +0,0 @@
-connect_timeout = 60
-network_timeout = 60
-charset = UTF-8
-http.tracker_http_port = 8080
-http.anti_steal_token = no
-
-tracker_server = 192.168.2.236:22122